//----------------tx_modulate_in_valid_dly------------------ always @(posedge clk_Modulation) begin tx_modulate_in_valid_dly <= tx_modulate_in_valid; end assign tx_modulate_in_valid_neg_pls = tx_modulate_in_valid_dly & (~tx_modulate_in_valid);
//----------------constellation_ponit------------------ always @(posedge clk_Modulation) begin if(reset == 1'b1)begin constellation_point <= 'd0; end elseif(tx_modulate_in_valid_neg_pls)begin constellation_point <= 'd0; end elseif(tx_modulate_in_valid)begin constellation_point <= {constellation_point[4:0], tx_modulate_in_bit}; end end
//----------------cnt_data_in------------------ always @(posedge clk_Modulation) begin if (reset == 11'b1) begin cnt_data_in <= 'd0; end elseif(tx_modulate_in_valid == 1'b1 && cnt_data_in == 'd5)begin cnt_data_in <= 'd0; end elseif(tx_modulate_in_valid == 1'b1)begin cnt_data_in <= cnt_data_in + 1'b1; end end
//---------------constellation_point_vld------------------- always @(posedge clk_Modulation) begin if(reset == 1'b1)begin constellation_point_vld <= 1'b0; end elseif(tx_modulate_in_valid == 1'b1 && cnt_data_in == 'd5)begin constellation_point_vld <= 1'b1; end elsebegin constellation_point_vld <= 1'b0; end end
//----------------cnt_constellation_point------------------ always @(posedge clk_Modulation) begin if(reset == 1'b1)begin cnt_constellation_point <= 'd0; end elseif(tx_modulate_in_valid_neg_pls)begin cnt_constellation_point <= 'd0; end elseif(tx_modulate_in_valid == 1'b1 && cnt_data_in == 'd5)begin cnt_constellation_point <= cnt_constellation_point + 1'b1; end end
//----------------num_of_constellation_point------------------ always @(posedge clk_Modulation) begin if (reset == 1'b1) begin num_of_constellation_point <= 'd0; num_of_constellation_point_vld <= 1'b0; end elseif (tx_modulate_in_valid_neg_pls) begin num_of_constellation_point <= cnt_constellation_point; num_of_constellation_point_vld <= 1'b1; end elsebegin num_of_constellation_point_vld <= 1'b0; end end
always @(posedge clk_Modulation) begin if (reset == 1'b1) begin n_ofdm_syms <= 'd0; end elseif(divider_result_vld)begin n_ofdm_syms <=divider_result[23:8]; end end
//----------------state------------------ always @(posedge clk_Modulation) begin if(reset == 1'b1)begin state <= IDLE; end elsebegin case(state) IDLE : begin if(tx_modulate_in_valid_neg_pls)begin state <= MODULATE; end end
MODULATE : begin if (cnt_mapping == 'd51) begin state <= ARBIT; end end
ARBIT : begin if(empty == 1'b1)begin state <= IDLE; end elseif(tx_freq_to_timed_cycle_flag == 1'b1 && empty==1'b0)begin state <= MODULATE; end end
default : state <= IDLE; endcase end end
//----------------cnt_mapping------------------ always @(posedge clk_Modulation) begin if (reset == 1'b1) begin cnt_mapping <= 'd0; end elseif (state == MODULATE && cnt_mapping == 'd51) begin cnt_mapping <= 'd0; end elseif (state == MODULATE) begin cnt_mapping <= cnt_mapping + 1'b1; end elsebegin cnt_mapping <= 'd0; end end
always @(posedge clk_Modulation) begin if (reset == 1'b1) begin rom_addr <= 'd0; end elseif (tx_modulate_in_valid_neg_pls) begin rom_addr <= 1; end elseif (state == MODULATE && cnt_mapping == 'd51 && rom_addr == 126) begin rom_addr <= 'd0; end elseif (state == MODULATE && cnt_mapping == 'd51 ) begin rom_addr <= rom_addr + 1'b1; end end
//----------------rd_fifo_en------------------ always @(*) begin if (state == MODULATE) begin if (cnt_mapping == 'd5 || cnt_mapping == 'd19 || cnt_mapping == 'd32 || cnt_mapping == 'd46) begin rd_fifo_en = 1'b0; end elsebegin rd_fifo_en = 1'b1; end end elsebegin rd_fifo_en = 1'b0; end end
//------------------tx_modulate_re_out---------------- always @(posedge clk_Modulation) begin if (reset == 1'b1) begin tx_modulate_re_out <= 'd0; end elseif(state == MODULATE)begin // insert pilot according to the pilot index,when rom dout is 1, the inserted pilot is 1 1 1 -1 // when rom dout is 0 the inserted pilot is -1 -1 -1 1 if(cnt_mapping == 'd5 || cnt_mapping == 'd19 || cnt_mapping =='d32)begin if (rom_dout == 1'b1) begin tx_modulate_re_out <= QAM64_IQ_ONE; end elsebegin tx_modulate_re_out <= QAM64_IQ_MINUS_ONE; end end elseif (cnt_mapping == 'd46) begin if (rom_dout == 1'b1) begin tx_modulate_re_out <= QAM64_IQ_MINUS_ONE; end elsebegin tx_modulate_re_out <= QAM64_IQ_ONE; end end elsebegin case(rd_fifo_dout[5:3]) 3'b000: tx_modulate_re_out <= QAM64_IQ_B000; 3'b001: tx_modulate_re_out <= QAM64_IQ_B001; 3'b010: tx_modulate_re_out <= QAM64_IQ_B010; 3'b011: tx_modulate_re_out <= QAM64_IQ_B011; 3'b100: tx_modulate_re_out <= QAM64_IQ_B100; 3'b101: tx_modulate_re_out <= QAM64_IQ_B101; 3'b110: tx_modulate_re_out <= QAM64_IQ_B110; 3'b111: tx_modulate_re_out <= QAM64_IQ_B111; default : tx_modulate_re_out <= 'd0; endcase end end elsebegin tx_modulate_re_out <= 'd0; end end
//------------------tx_modulate_im_out---------------- always @(posedge clk_Modulation) begin if (reset == 1'b1) begin tx_modulate_im_out <= 'd0; end elseif(state == MODULATE)begin // insert pilot according to the pilot index,when rom dout is 1, the inserted pilot is 1 1 1 -1 // when rom dout is 0 the inserted pilot is -1 -1 -1 1 if(cnt_mapping == 'd5 || cnt_mapping == 'd19 || cnt_mapping =='d32 || cnt_mapping == 'd46)begin tx_modulate_im_out <= 'd0; end elsebegin case(rd_fifo_dout[2:0]) 3'b000: tx_modulate_im_out <= QAM64_IQ_B000; 3'b001: tx_modulate_im_out <= QAM64_IQ_B001; 3'b010: tx_modulate_im_out <= QAM64_IQ_B010; 3'b011: tx_modulate_im_out <= QAM64_IQ_B011; 3'b100: tx_modulate_im_out <= QAM64_IQ_B100; 3'b101: tx_modulate_im_out <= QAM64_IQ_B101; 3'b110: tx_modulate_im_out <= QAM64_IQ_B110; 3'b111: tx_modulate_im_out <= QAM64_IQ_B111; default : tx_modulate_im_out <= 'd0; endcase end end elsebegin tx_modulate_im_out <= 'd0; end end
always @(posedge clk_Modulation) begin if (reset == 1'b1) begin tx_modulate_out_valid <= 1'b0; end elseif (state == MODULATE) begin tx_modulate_out_valid <= 1'b1; end elsebegin tx_modulate_out_valid <= 1'b0; end end