//==================================================== // internal signals and registers //==================================================== reg [8:0] multi_rate_rom_start_addr ; // the interleaver mapping rom start addr (depending on the code rate) reg [8:0] multi_rate_rom_end_addr ; // the interleaver mapping rom end addr (depending on the code rate) reg [8:0] multi_rate_rom_length ; // the length of interleaver mapping rom (depending on the code rate)
always @(posedge clk_Modulation) begin if (reset == 1'b1) begin multi_rate_rom_start_addr <= 'd0; multi_rate_rom_end_addr <= 'd0; multi_rate_rom_length <= 'd0; end elseif(tx_Modulation == 'd3)begin multi_rate_rom_start_addr <= 'd0; multi_rate_rom_end_addr <= 'd287; multi_rate_rom_length <= 'd288; end end
//----------------cnt_data_in------------------ always @(posedge clk_Modulation) begin if (reset == 1'b1) begin cnt_data_in <= 'd0; end elseif(tx_interleaver_in_valid)begin cnt_data_in <= cnt_data_in + 1'b1; end elsebegin cnt_data_in <= 'd0; end end
always @(posedge clk_Modulation) begin tx_interleaver_in_valid_dly <= tx_interleaver_in_valid; end
//----------------data_len------------------ always @(posedge clk_Modulation) begin if (reset == 1'b1) begin data_len <= 'd0; end elseif(tx_interleaver_in_valid_neg_pls)begin data_len <= cnt_data_in; end end
//----------------rd_rom_fifo_en------------------ always @(posedge clk_Modulation) begin if (reset == 1'b1) begin rd_rom_fifo_en <= 1'b0; end elseif(rd_rom_fifo_en == 1'b1 && cnt_fifo_rd == data_len-1)begin rd_rom_fifo_en <= 1'b0; end elseif(tx_interleaver_in_valid_neg_pls == 1'b1)begin rd_rom_fifo_en <= 1'b1; end end
//----------------cnt_fifo_rd------------------ always @(posedge clk_Modulation) begin if (reset == 1'b1) begin cnt_fifo_rd <= 'd0; end elseif (rd_rom_fifo_en == 1'b1 && cnt_fifo_rd == data_len-1) begin cnt_fifo_rd <= 'd0; end elseif(rd_rom_fifo_en) begin cnt_fifo_rd <= cnt_fifo_rd + 1'b1; end end
//----------------rom_addr------------------ always @(posedge clk_Modulation) begin if (reset == 1'b1) begin rom_addr <= 'd0; end elseif(tx_interleaver_in_valid_neg_pls)begin rom_addr <= multi_rate_rom_start_addr; end elseif ((rom_addr == multi_rate_rom_end_addr) && (rd_rom_fifo_en == 1'b1)) begin rom_addr <= multi_rate_rom_start_addr; end elseif(rd_rom_fifo_en == 1'b1)begin rom_addr <= rom_addr + 1'b1; end end
//----------------wr_ram_addr_base------------------ always @(posedge clk_Modulation) begin if (reset == 1'b1) begin wr_ram_addr_base <= 'd0; end elseif(rd_rom_fifo_en == 1'b1)begin if(rom_addr == multi_rate_rom_length-1)begin wr_ram_addr_base <= wr_ram_addr_base + multi_rate_rom_length; end end elsebegin wr_ram_addr_base <= 'd0; end end
assign wr_ram_addr = wr_ram_addr_base + rom_dout;
always @(posedge clk_Modulation) begin wr_ram_en <= rd_rom_fifo_en; wr_ram_en_dly <= wr_ram_en; end assign wr_ram_en_neg_pls = (~wr_ram_en) & wr_ram_en_dly;