`timescale 1 ns / 1 ps module cnv_res_collect# ( parameter CLK_PERIOD = 10 , parameter CHIPSET_QTY = 4 , parameter CH_OF_CHIPSET = 16 ) ( input clk , input rst_n , input trans_round , //TODO: use for 'axi_str_rxd_tlast' input [16-1:0] record_ch_qty , input [32*CHIPSET_QTY-1:0] cnv_res_tdata_array , input [ CHIPSET_QTY-1:0] cnv_res_tlast_array , output reg [ CHIPSET_QTY-1:0] cnv_res_tready_array , input [ CHIPSET_QTY-1:0] cnv_res_tvalid_array , output reg [31:0] m_axis_eeg_tdata , output reg m_axis_eeg_tlast , input m_axis_eeg_tready , output reg m_axis_eeg_tvalid ); //***************************************************************************** // localparam definition //***************************************************************************** localparam IDLE = 4'd0 ; localparam SCAN_ST = 4'd1 ; localparam CHANNEL_QTY = CH_OF_CHIPSET*CHIPSET_QTY ; //2^6: 0~63 //***************************************************************************** // Internal register and wire declarations //***************************************************************************** reg [ 4-1:0] cstate ; reg [ 4-1:0] nstate ; wire [32-1:0] cnv_res_tdata[0:CHIPSET_QTY-1] ; wire cnv_res_tlast[0:CHIPSET_QTY-1] ; wire cnv_res_tready[0:CHIPSET_QTY-1] ; wire cnv_res_tvalid[0:CHIPSET_QTY-1] ; reg [32-1:0] cnv_res_tdata_r[0:CHIPSET_QTY-1] ; reg cnv_res_tvalid_r[0:CHIPSET_QTY-1] ; reg cnv_res_tlast_r[0:CHIPSET_QTY-1] ; reg [ 8-1:0] scan_cnt ; reg [ 8-1:0] recv_cnt ; genvar i; //***************************************************************************** always@( posedge clk or negedge rst_n ) begin if( !rst_n ) cstate <= IDLE; else cstate <= nstate; end always@( * ) begin case ( cstate ) IDLE: if ( cnv_res_tvalid_array ) nstate <= SCAN_ST; else nstate <= IDLE; SCAN_ST: if ( scan_cnt == CHIPSET_QTY-1 ) nstate <= IDLE; else nstate <= SCAN_ST; default: nstate <= IDLE; endcase end always @ ( posedge clk or negedge rst_n ) begin if ( !rst_n ) cnv_res_tready_array <= 0; else if ( cstate == IDLE && nstate == IDLE ) cnv_res_tready_array <= {CHIPSET_QTY{1'b1}}; else cnv_res_tready_array <= 0; end generate for(i=0;i