基于网络编码的多信源组播通信系统,包括源代码,原理图等(四)
--------- Regs/ wires -----------
wire [SRC_WIDTH-1:0] src_num_plus1;
reg [SRC_WIDTH-1:0] src_num,src_num_sel,src_num_sel_next; //source sequence number for packets that is being decoded
reg [SRC_WIDTH-1:0] src_num_next;
wire [GEN_WIDTH-1:0] gen_num_plus1;
reg [GEN_WIDTH-1:0] gen_num,gen_num_sel,gen_num_sel_next; //generation sequence number for packets that is being decoded
reg [GEN_WIDTH-1:0] gen_num_next;
reg [CAM_NUMS-1:0] cam_lookup_reslt; // result of looking up packets in cam,stands for which cam finds the packet
reg [CAM_NUMS-1:0] cam_lookup_reslt_next;
reg[CAM_NUMS-1:0] cam_lookup_reslt_pre,cam_lookup_reslt_save;
reg[CAM_NUMS-1:0] cam_lookup_reslt_pre_next,cam_lookup_reslt_save_next;
reg [CAM_ADDR_WIDTH-1:0] other_dram_addr;
reg [CAM_ADDR_WIDTH-1:0] other_dram_addr_next;
reg [DRAM_NUMS_WIDTH-1:0] other_port_num_rd; //the other result from looking up cams
reg has_factor2; //has the other looking up result
reg has_factor2_next;
reg has_factor2_next;
reg [DRAM_NUMS_WIDTH-1:0] other_port_num_rd_next;
reg [NUM_STATES-1:0] state;
reg [NUM_STATES-1:0] state_next;
reg [4:0] couter;
wire [4:0] couter_next;
reg couter_start;
reg[CAM_ADDR_WIDTH-1:0] atch_addr_temp_2,match_addr_temp_2_next;
reg[CAM_ADDR_WIDTH-1:0] match_addr_temp_1,match_addr_temp_1_next;
reg[CAM_ADDR_WIDTH-1:0] match_addr_temp_0,match_addr_temp_0_next;
reg [SRC_GEN_SEQ_WIDTH-1:0] cmp_data;
// ------------ main code and logic -------------
assign src_num_plus1 = (src_num == 2) ? 0 : src_num + 1;
assign gen_num_plus1 = (gen_num == 2**GEN_WIDTH-1) ? 0 : gen_num + 1;
assign rd_dcod_src_gen_1 = {src_num_sel,gen_num_sel};
assign couter_next = (couter_start == 1) ? couter+1 : couter;
assign cmp_data_0 = cmp_data;
assign cmp_data_1 = cmp_data;
assign cmp_data_2 = cmp_data;
/* This state machine completes decode control task. If enough packets have
* been saved in cams and DRAMS, it starts to decode to packets. If
* a packet can not be decoded becouse of losing, it will decode the next
* packet automatically */
always @(*) begin
state_next = state;
gen_num_next = gen_num;
src_num_next = src_num;
src_num_sel_next = src_num_sel;
gen_num_sel_next = gen_num_sel;
cam_lookup_reslt_next = cam_lookup_reslt;
rd_dcod_reg_req_1 = 1'b0;
addr_vld = 1'b0;
pkt_vld = 1'b0;
pkt_not_find = 1'b0;
other_dram_addr_next = other_dram_addr;
other_port_num_rd_next =other_port_num_rd;
has_factor2_next = has_factor2;
pkt_dcoding = 12'hfff;
block_num_rd = 2'b0;
cam_lookup_reslt_pre_next = cam_lookup_reslt_pre;
cam_lookup_reslt_save_next = cam_lookup_reslt_save;
port_num_rd = 2'b11;
couter_start = 1'b0;
match_addr_temp_2_next = match_addr_temp_2;
match_addr_temp_1_next = match_addr_temp_1;
match_addr_temp_0_next = match_addr_temp_0;
cmp_data_mask_0 = 24'h0;
cmp_data_mask_1 = 24'h0;
cmp_data_mask_2 = 24'h0;
has_other_factor = 0;
cmp_data = 24'hffffff;
case(state)
/* --- waiting for the cam has been writen enough packet */
IDLE: begin
if(cam_vld) begin
couter_start = 1;
end
if(couter == 5'b11111)
state_next = GET_SRC_GEN_NUM;
end
/* Goes round-robin around the sources and generations,
* gets the source sequence number and generation sequebce
* number of a packet need to be decoded */
GET_SRC_GEN_NUM: begin
state_next = LOOK_UP_CAM;
rd_dcod_reg_req_1 = 1; // read the decoded reg grp
src_num_sel_next = src_num;
gen_num_sel_next = gen_num;
src_num_next = src_num_plus1;
if(src_num == 4'b0010)
gen_num_next = gen_num_plus1;
end
/* --- look up pkt in three cams to get block number of DRAM*/
LOOK_UP_CAM:
if(req_ack_vld_1) begin
if(alredy_decod_1 == 1) //
源代码原理 相关文章:
- 基于网络编码的多信源组播通信系统,包括源代码,原理图等(二)(12-06)
- 基于网络编码的多信源组播通信系统,包括源代码,原理图等(一)(12-06)
- 电源设计小贴士 1:为您的电源选择正确的工作频率(12-25)
- 用于电压或电流调节的新调节器架构(07-19)
- 超低静态电流电源管理IC延长便携应用工作时间(04-14)
- 电源设计小贴士 2:驾驭噪声电源(01-01)