Commit baa32a59 authored by Andrey Filippov's avatar Andrey Filippov

replaced non-memory 2-d arrays with 1-d ones, added _ram suffix to all memories

parent 3946f6c4
......@@ -141,12 +141,12 @@ module cmprs_afi_mux#(
// reg [2:0] cur_chn; // 'b0xx - none, 'b1** - ** - channel number (should match fifo_ren*)
reg [1:0] cur_chn; // 'b0xx - none, 'b1** - ** - channel number (should match fifo_ren*)
reg [7:0] left_to_eof[0:3]; // number of chunks left to end of frame
reg [31:0] left_to_eof; // number of chunks left to end of frame
reg [3:0] fifo_flush_d; // fifo_flush* delayed by 1 clk (to detect rising edge
reg [3:0] eof_stb; // single-cycle pulse after fifo_flush is asserted
// reg [1:0] w64_cnt; // count 64-bit words in a chunk
reg [8:0] counts_corr0[0:3]; // registers to hold corrected (decremented currently processed ones if any) fifo count values, MSB - needs flush
reg [8:0] counts_corr1[0:1]; // first arbitration level winning values
reg [35:0] counts_corr0; // registers to hold corrected (decremented currently processed ones if any) fifo count values, MSB - needs flush
reg [17:0] counts_corr1; // first arbitration level winning values
reg [8:0] counts_corr2; // second arbitration level winning values
reg [1:0] winner1; // 2 first level arbitration winners
......@@ -201,10 +201,10 @@ module cmprs_afi_mux#(
// use last_chunk_w to apply a special id to waddr and wdata and watch for it during readout
// compose ID of channel number, frame bumber LSBs and last/not last chunk
assign last_chunk_w[3:0] = {(left_to_eof[3]==1)?1'b1:1'b0,
(left_to_eof[2]==1)?1'b1:1'b0,
(left_to_eof[1]==1)?1'b1:1'b0,
(left_to_eof[0]==1)?1'b1:1'b0};
assign last_chunk_w[3:0] = {(left_to_eof[3 * 8 +: 8]==1),
(left_to_eof[2 * 8 +: 8]==1),
(left_to_eof[1 * 8 +: 8]==1),
(left_to_eof[0 * 8 +: 8]==1)};
assign pre_busy_w = !busy[0] && ready_to_start && need_to_bother && !ptr_resetting;
assign done_burst_w = busy[0] && !(|wleft[3:1]); // when wleft[3:0] == 0, busy is 0
......@@ -262,60 +262,60 @@ module cmprs_afi_mux#(
// TODO: change &w64_cnt[1:0] so left_to_eof[*] will be updated earlier and valid at pre_busy_w
// Done, updating at the first (not last) word of 4
if (eof_stb[0]) left_to_eof[0] <= fifo_count0 - (fifo_ren0 & (&wleft[1:0]));
else if (fifo_ren0 & (&wleft[1:0])) left_to_eof[0] <= left_to_eof[0] - 1;
if (eof_stb[0]) left_to_eof[0 * 8 +: 8] <= fifo_count0 - (fifo_ren0 & (&wleft[1:0]));
else if (fifo_ren0 & (&wleft[1:0])) left_to_eof[0 * 8 +: 8] <= left_to_eof[0 * 8 +: 8] - 1;
if (eof_stb[1]) left_to_eof[1] <= fifo_count1 - (fifo_ren1 & (&wleft[1:0]));
else if (fifo_ren1 & (&wleft[1:0])) left_to_eof[1] <= left_to_eof[1] - 1;
if (eof_stb[1]) left_to_eof[1 * 8 +: 8] <= fifo_count1 - (fifo_ren1 & (&wleft[1:0]));
else if (fifo_ren1 & (&wleft[1:0])) left_to_eof[1 * 8 +: 8] <= left_to_eof[1 * 8 +: 8] - 1;
if (eof_stb[2]) left_to_eof[2] <= fifo_count2 - (fifo_ren2 & (&wleft[1:0]));
else if (fifo_ren2 & (&wleft[1:0])) left_to_eof[2] <= left_to_eof[2] - 1;
if (eof_stb[2]) left_to_eof[2 * 8 +: 8] <= fifo_count2 - (fifo_ren2 & (&wleft[1:0]));
else if (fifo_ren2 & (&wleft[1:0])) left_to_eof[2 * 8 +: 8] <= left_to_eof[2 * 8 +: 8] - 1;
if (eof_stb[3]) left_to_eof[3] <= fifo_count3 - (fifo_ren3 & (&wleft[1:0]));
else if (fifo_ren3 & (&wleft[1:0])) left_to_eof[3] <= left_to_eof[3] - 1;
if (eof_stb[3]) left_to_eof[3 * 8 +: 8] <= fifo_count3 - (fifo_ren3 & (&wleft[1:0]));
else if (fifo_ren3 & (&wleft[1:0])) left_to_eof[3 * 8 +: 8] <= left_to_eof[3 * 8 +: 8] - 1;
// Calculate corrected values decrementing currently served channel (if any) values by 1 (latency 1 clk)
if ((fifo_count0 == 0) || !en_chn[0]) counts_corr0[0] <= 0;
else if (fifo_ren[0]) counts_corr0[0] <= (fifo_count0_m1 == 0)? 0 : {fifo_flush0,fifo_count0_m1};
else counts_corr0[0] <= {fifo_flush0,fifo_count0};
if ((fifo_count0 == 0) || !en_chn[0]) counts_corr0[0 * 9 +: 9] <= 0;
else if (fifo_ren[0]) counts_corr0[0 * 9 +: 9] <= (fifo_count0_m1 == 0)? 0 : {fifo_flush0,fifo_count0_m1};
else counts_corr0[0 * 9 +: 9] <= {fifo_flush0,fifo_count0};
if ((fifo_count1 == 0) || !en_chn[1]) counts_corr0[1] <= 0;
else if (fifo_ren[1]) counts_corr0[1] <= (fifo_count1_m1 == 0)? 0 : {fifo_flush1,fifo_count1_m1};
else counts_corr0[1] <= {fifo_flush1,fifo_count1};
if ((fifo_count1 == 0) || !en_chn[1]) counts_corr0[1 * 9 +: 9] <= 0;
else if (fifo_ren[1]) counts_corr0[1 * 9 +: 9] <= (fifo_count1_m1 == 0)? 0 : {fifo_flush1,fifo_count1_m1};
else counts_corr0[1 * 9 +: 9] <= {fifo_flush1,fifo_count1};
if ((fifo_count2 == 0) || !en_chn[2]) counts_corr0[2] <= 0;
else if (fifo_ren[2]) counts_corr0[2] <= (fifo_count2_m1 == 0)? 0 : {fifo_flush2,fifo_count2_m1};
else counts_corr0[2] <= {fifo_flush2,fifo_count2};
if ((fifo_count2 == 0) || !en_chn[2]) counts_corr0[2 * 9 +: 9] <= 0;
else if (fifo_ren[2]) counts_corr0[2 * 9 +: 9] <= (fifo_count2_m1 == 0)? 0 : {fifo_flush2,fifo_count2_m1};
else counts_corr0[2 * 9 +: 9] <= {fifo_flush2,fifo_count2};
if ((fifo_count3 == 0) || !en_chn[3]) counts_corr0[3] <= 0;
else if (fifo_ren[3]) counts_corr0[3] <= (fifo_count3_m1 == 0)? 0 : {fifo_flush3,fifo_count3_m1};
else counts_corr0[3] <= {fifo_flush3,fifo_count3};
if ((fifo_count3 == 0) || !en_chn[3]) counts_corr0[3 * 9 +: 9] <= 0;
else if (fifo_ren[3]) counts_corr0[3 * 9 +: 9] <= (fifo_count3_m1 == 0)? 0 : {fifo_flush3,fifo_count3_m1};
else counts_corr0[3 * 9 +: 9] <= {fifo_flush3,fifo_count3};
// 2-level arbitration
// first arbitration level (latency 2 clk)
if (counts_corr0[1] > counts_corr0[0]) begin
counts_corr1[0] <= counts_corr0[1];
if (counts_corr0[1 * 9 +: 9] > counts_corr0[0 * 9 +: 9]) begin
counts_corr1[0 * 9 +: 9] <= counts_corr0[1 * 9 +: 9];
winner1[0] <= 1;
end else begin
counts_corr1[0] <= counts_corr0[0];
counts_corr1[0 * 9 +: 9] <= counts_corr0[0 * 9 +: 9];
winner1[0] <= 0;
end
if (counts_corr0[3] > counts_corr0[2]) begin
counts_corr1[1] <= counts_corr0[3];
if (counts_corr0[3 * 9 +: 9] > counts_corr0[2 * 9 +: 9]) begin
counts_corr1[1 * 9 +: 9] <= counts_corr0[3 * 9 +: 9];
winner1[1] <= 1;
end else begin
counts_corr1[1] <= counts_corr0[2];
counts_corr1[1 * 9 +: 9] <= counts_corr0[2 * 9 +: 9];
winner1[1] <= 0;
end
// second arbitration level (latency 3 clk)
if (counts_corr1[1] > counts_corr1[0]) begin
counts_corr2 <= counts_corr1[1];
if (counts_corr1[1 * 9 +: 9] > counts_corr1[0 * 9 +: 9]) begin
counts_corr2 <= counts_corr1[1 * 9 +: 9];
winner2 <= {1'b1,winner1[1]};
end else begin
counts_corr2 <= counts_corr1[0];
counts_corr2 <= counts_corr1[0 * 9 +: 9];
winner2 <= {1'b0,winner1[0]};
end
//ready_to_start need_to_bother
......@@ -325,7 +325,7 @@ module cmprs_afi_mux#(
else if (done_burst_w) busy <= 0; // {busy[2:0],1'b0};
if (!en) wleft <= 0;
else if (pre_busy_w) wleft <= {(|counts_corr2[7:2])? 2'b11 : left_to_eof[winner2][1:0], 2'b11};
else if (pre_busy_w) wleft <= {(|counts_corr2[7:2])? 2'b11 : left_to_eof[winner2 * 8 +: 8][1:0], 2'b11};
else if (wleft != 0) wleft <= wleft - 1;
......@@ -354,7 +354,7 @@ module cmprs_afi_mux#(
if (pre_busy_w) chunk_inc <= (|counts_corr2[7:2])?
3'h4 :
({1'b0,left_to_eof[winner2][1:0]} + 3'h1);
({1'b0,left_to_eof[winner2 * 8 +: 8][1:0]} + 3'h1);
end
......@@ -395,8 +395,7 @@ module cmprs_afi_mux#(
.we (cmd_we) // output
);
wire [26:0] chunk_ptr_rd01[0:1];
wire [53:0] chunk_ptr_rd01; // [0:1];
cmprs_afi_mux_ptr cmprs_afi_mux_ptr_i (
.hclk (hclk), // input
......@@ -414,9 +413,9 @@ module cmprs_afi_mux#(
.ptr_resetting (ptr_resetting), // output
.chunk_addr (chunk_addr), // output[26:0] reg
.chunk_ptr_ra (chunk_ptr_ra[2:0]), // input[2:0]
.chunk_ptr_rd (chunk_ptr_rd01[0]) // output[26:0]
.chunk_ptr_rd (chunk_ptr_rd01[0 * 27 +: 27]) // output[26:0]
);
assign chunk_ptr_rd=chunk_ptr_ra[3]?chunk_ptr_rd01[1]:chunk_ptr_rd01[0];
assign chunk_ptr_rd=chunk_ptr_ra[3]?chunk_ptr_rd01[1 * 27 +: 27]:chunk_ptr_rd01[0 * 27 +: 27];
cmprs_afi_mux_ptr_wresp cmprs_afi_mux_ptr_wresp_i (
.hclk (hclk), // input
.length_di (sa_len_d[26:0]), // input[26:0]
......@@ -425,7 +424,7 @@ module cmprs_afi_mux#(
.en (en), // input
.reset_pointers (reset_pointers), // input[3:0]
.chunk_ptr_ra (chunk_ptr_ra[2:0]), // input[2:0]
.chunk_ptr_rd (chunk_ptr_rd01[1]), // output[26:0]
.chunk_ptr_rd (chunk_ptr_rd01[1* 27 +: 27]), // output[26:0]
.eof_written ({eof_written3,eof_written2,eof_written1,eof_written0}), // output[3:0] reg
.afi_bvalid (afi_bvalid), // input
.afi_bready (afi_bready), // output
......
......@@ -49,22 +49,21 @@ module cmprs_afi_mux_status #(
reg [15:0] mode_data_mclk; // some bits unused
wire mode_we_hclk;
reg [7:0] mode_hclk;
// wire [1:0] sel[0:3]={mode_hclk[7:6],mode_hclk[5:4],mode_hclk[3:2],mode_hclk[1:0]};
reg [1:0] index;
reg [CMPRS_AFIMUX_CYCBITS-1:0] cntr;
reg [CMPRS_AFIMUX_WIDTH-1:0] chunk_ptr_hclk; // pointer data
reg [1:0] chunk_chn_hclk; // pointer channel
reg [1:0] index;
reg [CMPRS_AFIMUX_CYCBITS-1:0] cntr;
reg [CMPRS_AFIMUX_WIDTH-1:0] chunk_ptr_hclk; // pointer data
reg [1:0] chunk_chn_hclk; // pointer channel
reg [CMPRS_AFIMUX_WIDTH-1:0] status_data[0:3];
reg [4 * CMPRS_AFIMUX_WIDTH-1:0] status_data;
wire stb_w;
reg stb_r;
wire stb_mclk;
wire [7:0] ad[0:3];
wire [3:0] rq;
wire [3:0] start;
wire [31:0] ad;
wire [3:0] rq;
wire [3:0] start;
assign stb_w = en && (cntr==0);
always @ (posedge mclk) begin
......@@ -78,7 +77,7 @@ module cmprs_afi_mux_status #(
if (mode_data_mclk[10]) mode_hclk[5:4] <= mode_data_mclk[ 9: 8];
if (mode_data_mclk[14]) mode_hclk[7:6] <= mode_data_mclk[13:12];
if (stb_mclk) status_data[chunk_chn_hclk] <= chunk_ptr_hclk;
if (stb_mclk) status_data[chunk_chn_hclk * CMPRS_AFIMUX_WIDTH +: CMPRS_AFIMUX_WIDTH] <= chunk_ptr_hclk;
end
if (!en) {index,cntr} <= 0;
......@@ -104,80 +103,80 @@ module cmprs_afi_mux_status #(
pulse_cross_clock mode_we_hclk_i (.rst(rst), .src_clk(mclk), .dst_clk(hclk), .in_pulse(mode_we), .out_pulse(mode_we_hclk),.busy());
pulse_cross_clock stb_mclk_i (.rst(rst), .src_clk(hclk), .dst_clk(mclk), .in_pulse(stb_r), .out_pulse(stb_mclk), .busy());
status_router4 status_router4_i (
.rst (rst), // input
.clk (mclk), // input
.db_in0 (ad[0]), // input[7:0]
.rq_in0 (rq[0]), // input
.start_in0 (start[0]), // output
.rst (rst), // input
.clk (mclk), // input
.db_in0 (ad[0 * 8 +: 8]), // input[7:0]
.rq_in0 (rq[0]), // input
.start_in0 (start[0]), // output
.db_in1 (ad[1]), // input[7:0]
.rq_in1 (rq[1]), // input
.start_in1 (start[1]), // output
.db_in2 (ad[2]), // input[7:0]
.rq_in2 (rq[2]), // input
.start_in2 (start[2]), // output
.db_in3 (ad[3]), // input[7:0]
.rq_in3 (rq[3]), // input
.start_in3 (start[3]), // output
.db_out (status_ad), // output[7:0]
.rq_out (status_rq), // output
.start_out (status_start) // input
.db_in1 (ad[1 * 8 +: 8]), // input[7:0]
.rq_in1 (rq[1]), // input
.start_in1 (start[1]), // output
.db_in2 (ad[2 * 8 +: 8]), // input[7:0]
.rq_in2 (rq[2]), // input
.start_in2 (start[2]), // output
.db_in3 (ad[3 * 8 +: 8]), // input[7:0]
.rq_in3 (rq[3]), // input
.start_in3 (start[3]), // output
.db_out (status_ad), // output[7:0]
.rq_out (status_rq), // output
.start_out (status_start) // input
);
status_generate #(
.STATUS_REG_ADDR (CMPRS_AFIMUX_STATUS_REG_ADDR+0),
.PAYLOAD_BITS (CMPRS_AFIMUX_WIDTH)
) status_generate0_i (
.rst (rst), // input
.clk (mclk), // input
.we (status_we && (cmd_a==0)), // input
.wd (cmd_data[7:0]), // input[7:0]
.status (status_data[0]), // input[25:0]
.ad (ad[0]), // output[7:0]
.rq (rq[0]), // output
.start (start[0]) // input
.rst (rst), // input
.clk (mclk), // input
.we (status_we && (cmd_a==0)), // input
.wd (cmd_data[7:0]), // input[7:0]
.status (status_data[0 * CMPRS_AFIMUX_WIDTH +: CMPRS_AFIMUX_WIDTH]), // input[25:0]
.ad (ad[0 * 8 +: 8]), // output[7:0]
.rq (rq[0]), // output
.start (start[0]) // input
);
status_generate #(
.STATUS_REG_ADDR (CMPRS_AFIMUX_STATUS_REG_ADDR+0),
.PAYLOAD_BITS (CMPRS_AFIMUX_WIDTH)
) status_generate1_i (
.rst (rst), // input
.clk (mclk), // input
.we (status_we && (cmd_a==1)), // input
.wd (cmd_data[7:0]), // input[7:0]
.status (status_data[1]), // input[25:0]
.ad (ad[1]), // output[7:0]
.rq (rq[1]), // output
.start (start[1]) // input
.rst (rst), // input
.clk (mclk), // input
.we (status_we && (cmd_a==1)), // input
.wd (cmd_data[7:0]), // input[7:0]
.status (status_data[1 * CMPRS_AFIMUX_WIDTH +: CMPRS_AFIMUX_WIDTH]), // input[25:0]
.ad (ad[1 * 8 +: 8]), // output[7:0]
.rq (rq[1]), // output
.start (start[1]) // input
);
status_generate #(
.STATUS_REG_ADDR (CMPRS_AFIMUX_STATUS_REG_ADDR+0),
.PAYLOAD_BITS (CMPRS_AFIMUX_WIDTH)
) status_generate2_i (
.rst (rst), // input
.clk (mclk), // input
.we (status_we && (cmd_a==2)), // input
.wd (cmd_data[7:0]), // input[7:0]
.status (status_data[2]), // input[25:0]
.ad (ad[2]), // output[7:0]
.rq (rq[2]), // output
.start (start[2]) // input
.rst (rst), // input
.clk (mclk), // input
.we (status_we && (cmd_a==2)), // input
.wd (cmd_data[7:0]), // input[7:0]
.status (status_data[2 * CMPRS_AFIMUX_WIDTH +: CMPRS_AFIMUX_WIDTH]), // input[25:0]
.ad (ad[2 * 8 +: 8]), // output[7:0]
.rq (rq[2]), // output
.start (start[2]) // input
);
status_generate #(
.STATUS_REG_ADDR (CMPRS_AFIMUX_STATUS_REG_ADDR+0),
.PAYLOAD_BITS (CMPRS_AFIMUX_WIDTH)
) status_generate3_i (
.rst (rst), // input
.clk (mclk), // input
.we (status_we && (cmd_a==3)), // input
.wd (cmd_data[7:0]), // input[7:0]
.status (status_data[3]), // input[25:0]
.ad (ad[3]), // output[7:0]
.rq (rq[3]), // output
.start (start[3]) // input
.rst (rst), // input
.clk (mclk), // input
.we (status_we && (cmd_a==3)), // input
.wd (cmd_data[7:0]), // input[7:0]
.status (status_data[3 * CMPRS_AFIMUX_WIDTH +: CMPRS_AFIMUX_WIDTH]), // input[25:0]
.ad (ad[3 * 8 +: 8]), // output[7:0]
.rq (rq[3]), // output
.start (start[3]) // input
);
endmodule
......
......@@ -103,7 +103,7 @@ module histogram_saxi#(
);
localparam ATTRIB_WIDTH = NUM_FRAME_BITS + 4 +2;
reg [HIST_SAXI_MODE_WIDTH-1:0] mode;
wire en = mode[HIST_SAXI_EN] & mode[HIST_SAXI_NRESET];
reg [3:0] awcache_mode;
......@@ -123,7 +123,7 @@ module histogram_saxi#(
reg [1:0] mux_sel;
wire start_w;
reg started;
reg [NUM_FRAME_BITS + 4 +2 -1:0] attrib [0:3]; // to hold frame number, sensor number and burst (color) for the histograms in the buffer
reg [ATTRIB_WIDTH -1:0] attrib; // to hold frame number, sensor number and burst (color) for the histograms in the buffer
wire page_sent_mclk; // page sent over saxi - pulse in mclk domain
reg [1:0] page_wr; // page number being written
reg [7:0] page_wa; // 32-bit word address in page being written
......@@ -292,7 +292,7 @@ module histogram_saxi#(
wr_attr <= en && !dav_r && dav;
if (wr_attr) attrib[page_wr] <= {enc_rq[1:0], sub_chn_r, frame_r, burst[1:0]};
if (wr_attr) attrib[page_wr * ATTRIB_WIDTH +: ATTRIB_WIDTH] <= {enc_rq[1:0], sub_chn_r, frame_r, burst[1:0]};
if (!dav_r) page_wa <= 0;
else page_wa <= page_wa + 1;
......@@ -322,7 +322,7 @@ module histogram_saxi#(
if (!en_aclk) block_start_r <= 0;
else block_start_r <= {block_run[2:0], block_start_w};
if (block_start_r[0]) attrib_r <= attrib[page_rd];
if (block_start_r[0]) attrib_r <= attrib[page_rd * ATTRIB_WIDTH +: ATTRIB_WIDTH];
if (block_start_r[1]) hist_start_page_r <= hist_start_page[attrib_chn];
if (block_start_r[2]) hist_start_addr[31:12] <= hist_start_page_r + attrib_frame;
......
......@@ -103,6 +103,7 @@ module mult_saxi_wr #(
// localparam BURSTS_CAP0= (MULT_SAXI_HALF_BRAM ? 'h400 : 'h800 ) / MULT_SAXI_BURST0 / 4;
localparam BRAM_A_WDTH = MULT_SAXI_HALF_BRAM?9:10;
localparam CHN_A_WDTH = BRAM_A_WDTH - 2;
wire [3:0] en_chn_mclk;
wire [3:0] run_chn_mclk;
......@@ -112,16 +113,16 @@ module mult_saxi_wr #(
wire en_aclk= |en_chn_aclk; // at least one channel enabled
wire [3:0] rq_wr;
wire [3:0] grant_wr;
wire [BRAM_A_WDTH-3:0] wa_chn[0:3];
wire [4 * CHN_A_WDTH - 1:0] wa_chn;
wire [3:0] adv_wr_done; // outputs grant_wr for short bursts, or several clocks before end of wr
wire [3:0] rq_out_chn;
wire [BRAM_A_WDTH-3:0] ra_chn[0:3];
wire [4 * CHN_A_WDTH - 1:0] ra_chn;
wire [3:0] pre_re;
reg en_we_arb; // @mclk should be reset by we_grant
wire we_grant; // @mclk
wire [1:0] we_cur_chn; // @mclk
wire [31:0] data_in[0:3];
wire [127:0] data_in;
wire [3:0] pre_valid;
reg [3:0] valid;
reg [BRAM_A_WDTH-1:0] buf_wa; // multiplexed buffer write adderss
......@@ -152,10 +153,7 @@ module mult_saxi_wr #(
assign {en_chn3, en_chn2, en_chn1, en_chn0} = en_chn_mclk;
assign {read_burst3, read_burst2, read_burst1, read_burst0} = grant_wr; // single clock pulse
assign data_in[0] = data_in_chn0;
assign data_in[1] = data_in_chn1;
assign data_in[2] = data_in_chn2;
assign data_in[3] = data_in_chn3;
assign data_in = {data_in_chn3, data_in_chn2, data_in_chn1, data_in_chn0};
assign pre_valid = {pre_valid_chn3, pre_valid_chn2, pre_valid_chn1, pre_valid_chn0};
assign en_chn_mclk = mode_reg[3:0];
......@@ -182,12 +180,12 @@ module mult_saxi_wr #(
.valid (valid[0]), // input
.rq_wr (rq_wr[0]), // output
.grant_wr (grant_wr[0]), // input
.wa (wa_chn[0]), // output[7:0]
.wa (wa_chn[0 * CHN_A_WDTH +: CHN_A_WDTH]), // output[7:0]
.adv_wr_done (adv_wr_done[0]), // output
.rq_out (rq_out_chn[0]), // output reg
.grant_out (grant_rd[0]), // input
.fifo_half_full(fifo_half_full), // input
.ra (ra_chn[0]), // output[7:0]
.ra (ra_chn[0* CHN_A_WDTH +: CHN_A_WDTH]), // output[7:0]
.pre_re (pre_re[0]), // output
.first_re (first_re[0]), // output reg // 1 clock later than pre_re
.last_re (last_re[0]), // output reg // 1 clock later than pre_re
......@@ -207,12 +205,12 @@ module mult_saxi_wr #(
.valid (valid[1]), // input
.rq_wr (rq_wr[1]), // output
.grant_wr (grant_wr[1]), // input
.wa (wa_chn[1]), // output[7:0]
.wa (wa_chn[1 * CHN_A_WDTH +: CHN_A_WDTH]), // output[7:0]
.adv_wr_done (adv_wr_done[1]), // output
.rq_out (rq_out_chn[1]), // output reg
.grant_out (grant_rd[1]), // input
.fifo_half_full(fifo_half_full), // input
.ra (ra_chn[1]), // output[7:0]
.ra (ra_chn[1* CHN_A_WDTH +: CHN_A_WDTH]), // output[7:0]
.pre_re (pre_re[1]), // output
.first_re (first_re[1]), // output reg // 1 clock later than pre_re
.last_re (last_re[1]), // output reg // 1 clock later than pre_re
......@@ -232,12 +230,12 @@ module mult_saxi_wr #(
.valid (valid[2]), // input
.rq_wr (rq_wr[2]), // output
.grant_wr (grant_wr[2]), // input
.wa (wa_chn[2]), // output[7:0]
.wa (wa_chn[2 * CHN_A_WDTH +: CHN_A_WDTH]), // output[7:0]
.adv_wr_done (adv_wr_done[2]), // output
.rq_out (rq_out_chn[2]), // output reg
.grant_out (grant_rd[2]), // input
.fifo_half_full(fifo_half_full), // input
.ra (ra_chn[2]), // output[7:0]
.ra (ra_chn[2* CHN_A_WDTH +: CHN_A_WDTH]), // output[7:0]
.pre_re (pre_re[2]), // output
.first_re (first_re[2]), // output reg // 1 clock later than pre_re
.last_re (last_re[2]), // output reg // 1 clock later than pre_re
......@@ -257,12 +255,12 @@ module mult_saxi_wr #(
.valid (valid[3]), // input
.rq_wr (rq_wr[3]), // output
.grant_wr (grant_wr[3]), // input
.wa (wa_chn[3]), // output[7:0]
.wa (wa_chn[3 * CHN_A_WDTH +: CHN_A_WDTH]), // output[7:0]
.adv_wr_done (adv_wr_done[3]), // output
.rq_out (rq_out_chn[3]), // output reg
.grant_out (grant_rd[3]), // input
.fifo_half_full(fifo_half_full), // input
.ra (ra_chn[3]), // output[7:0]
.ra (ra_chn[3* CHN_A_WDTH +: CHN_A_WDTH]), // output[7:0]
.pre_re (pre_re[3]), // output
.first_re (first_re[3]), // output reg // 1 clock later than pre_re
.last_re (last_re[3]), // output reg // 1 clock later than pre_re
......@@ -299,8 +297,8 @@ module mult_saxi_wr #(
if (pre_pre_buf_we && !pre_buf_we) chn_wr <= we_cur_chn; // to re-start arbitration early
// multiplex address and data
buf_wa <= {chn_wr, wa_chn[chn_wr]};
buf_wd <= data_in[chn_wr];
buf_wa <= {chn_wr, wa_chn[chn_wr * CHN_A_WDTH +: CHN_A_WDTH]};
buf_wd <= data_in[chn_wr* 32 +: 32];
// early re-enable arbitration (en_we_arb)
if (!en_mclk || adv_wr_done[chn_wr]) en_we_arb <= 1;
else if (we_grant) en_we_arb <= 0;
......@@ -318,7 +316,7 @@ module mult_saxi_wr #(
always @ (posedge aclk) begin
en_chn_aclk <=en_chn_mclk;
chn_rd <= re_cur_chn; // delay by 1 clock (to increase overlap)
buf_ra <= {chn_rd, ra_chn[chn_rd]};
buf_ra <= {chn_rd, ra_chn[chn_rd* CHN_A_WDTH +: CHN_A_WDTH]};
buf_re <= {buf_re[1:0], pre_re[chn_rd]};
pre_first_rd_valid <= first_re[chn_rd];
is_last_rd <= {is_last_rd[0], last_re[chn_rd]};
......
......@@ -77,8 +77,8 @@ module encoderDCAC393(
reg [2:0] block_mem_ra;
reg [2:0] block_mem_wa;
reg [2:0] block_mem_wa_save;
reg [6:0] block_mem[0:7];
wire [6:0] block_mem_o=block_mem[block_mem_ra[2:0]];
reg [6:0] block_mem_ram[0:7];
wire [6:0] block_mem_o=block_mem_ram[block_mem_ra[2:0]];
assign comp_numbero[2:0]= block_mem_o[2:0];
assign comp_firsto= block_mem_o[3];
......@@ -86,7 +86,7 @@ module encoderDCAC393(
assign comp_lastinmbo= block_mem_o[5];
assign lasto= block_mem_o[6];
always @ (posedge clk) begin
if (stb) block_mem[block_mem_wa[2:0]] <= {lasti, comp_lastinmbi, comp_colori,comp_firsti,comp_numberi[2:0]};
if (stb) block_mem_ram[block_mem_wa[2:0]] <= {lasti, comp_lastinmbi, comp_colori,comp_firsti,comp_numberi[2:0]};
if (!en) block_mem_wa[2:0] <= 3'h0;
else if (stb) block_mem_wa[2:0] <= block_mem_wa[2:0] +1;
......
......@@ -112,8 +112,8 @@ module quantizer393(
reg [ 2:0] block_mem_ra;
reg [ 2:0] block_mem_wa;
reg [ 2:0] block_mem_wa_save;
reg [15:0] block_mem[0:7];
wire [15:0] block_mem_o=block_mem[block_mem_ra[2:0]];
reg [15:0] block_mem_ram[0:7];
wire [15:0] block_mem_o=block_mem_ram[block_mem_ra[2:0]];
assign dc[8:0] = block_mem_o[8:0];
assign ctype = block_mem_o[9];
......@@ -125,7 +125,7 @@ module quantizer393(
assign dcc_stb = start[2];
always @ (posedge clk) begin
if (stb) block_mem[block_mem_wa[2:0]] <= {coring_num[2:0],tsi[2:0], ctypei, dci[8:0]};
if (stb) block_mem_ram[block_mem_wa[2:0]] <= {coring_num[2:0],tsi[2:0], ctypei, dci[8:0]};
if (!en) block_mem_wa[2:0] <= 3'h0;
else if (stb) block_mem_wa[2:0] <= block_mem_wa[2:0] +1;
......
......@@ -71,7 +71,7 @@ module imu_exttime393(
wire [1:0] chn_enc_w;
reg [15:0] ts_ram [0:3]; // inner timestamp x16 memory that receives timestamp from one of the 4 input channel fifos
wire [7:0] dout_chn[0:3];
wire [31:0] dout_chn;
wire [7:0] copy_data; // data from the selected input fifos
reg [7:0] copy_data_r; // low byte of the timestamp data being copied from one of the input fifos to the ts_ram
......@@ -83,7 +83,7 @@ module imu_exttime393(
chn_pri_w[3] | chn_pri_w[1]};
assign pre_copy_w = (|in_full) && !copy_selected[0] && !ts_full;
assign copy_data = dout_chn[sel_chn]; // 4:1 mux
assign copy_data = dout_chn[sel_chn * 8 +: 8]; // 4:1 mux
// acquire external timestamps @ mclk
......@@ -136,7 +136,7 @@ module imu_exttime393(
.advance (ts_stb[0]), // enough time
.rclk (mclk), // input
.rstb (pre_copy_started && (sel_chn == 2'h0)),// input
.dout (dout_chn[0]) // output[7:0] reg valid with copy_selected[1]
.dout (dout_chn[0 * 8 +: 8]) // output[7:0] reg valid with copy_selected[1]
);
timestamp_fifo timestamp_fifo_chn1_i (
......@@ -148,7 +148,7 @@ module imu_exttime393(
.advance (ts_stb[1]), // enough time
.rclk (mclk), // input
.rstb (pre_copy_started && (sel_chn == 2'h1)),// input
.dout (dout_chn[1]) // output[7:0] reg valid with copy_selected[1]
.dout (dout_chn[1 * 8 +: 8]) // output[7:0] reg valid with copy_selected[1]
);
timestamp_fifo timestamp_fifo_chn2_i (
......@@ -160,7 +160,7 @@ module imu_exttime393(
.advance (ts_stb[2]), // enough time
.rclk (mclk), // input
.rstb (pre_copy_started && (sel_chn == 2'h2)),// input
.dout (dout_chn[2]) // output[7:0] reg valid with copy_selected[1]
.dout (dout_chn[2 * 8 +: 8]) // output[7:0] reg valid with copy_selected[1]
);
timestamp_fifo timestamp_fifo_chn3_i (
......@@ -172,7 +172,7 @@ module imu_exttime393(
.advance (ts_stb[3]), // enough time
.rclk (mclk), // input
.rstb (pre_copy_started && (sel_chn == 2'h3)),// input
.dout (dout_chn[3]) // output[7:0] reg valid with copy_selected[1]
.dout (dout_chn[3 * 8 +: 8]) // output[7:0] reg valid with copy_selected[1]
);
......
......@@ -298,18 +298,18 @@ module sensors393 #(
reg [7:0] cmd_ad;
reg cmd_stb;
wire [7:0] status_ad_chn[0:3];
wire [31:0] status_ad_chn;
wire [3:0] status_rq_chn;
wire [3:0] status_start_chn;
wire [15:0] px_data[0:3];
wire [63:0] px_data;
wire [3:0] px_valid;
wire [3:0] last_in_line;
wire [3:0] hist_request;
wire [3:0] hist_grant;
wire [1:0] hist_chn[0:3];
wire [7:0] hist_chn;
wire [3:0] hist_dvalid;
wire [31:0] hist_data[0:3];
wire [127:0] hist_data;
wire [255:0] buf_dout_all;
// wire [3:0] sns_pg; // bidir!
......@@ -443,13 +443,13 @@ module sensors393 #(
.mclk (mclk), // input
.cmd_ad_in (cmd_ad), // input[7:0]
.cmd_stb_in (cmd_stb), // input
.status_ad (status_ad_chn[i]), // output[7:0]
.status_ad (status_ad_chn[i * 8 +: 8]), // output[7:0]
.status_rq (status_rq_chn[i]), // output
.status_start (status_start_chn[i]), // input
.trigger_mode (trigger_mode), // input
.trig_in (trig_in[i]), // input
.dout (px_data[i]), // output[15:0]
.dout (px_data[16 * i +: 16]), // output[15:0]
.dout_valid (px_valid[i]), // output
.last_in_line (last_in_line[i]), // output
.sof_out (sof_out_pclk[i]), // output
......@@ -458,24 +458,22 @@ module sensors393 #(
.sof_late_mclk(sof_late_mclk[i]), // output
.hist_request (hist_request[i]), // output
.hist_grant (hist_grant[i]), // input
.hist_chn (hist_chn[i]), // output[1:0]
.hist_chn (hist_chn[2 * i +: 2]), // output[1:0]
.hist_dvalid (hist_dvalid[i]), // output
.hist_data (hist_data[i]) // output[31:0]
.hist_data (hist_data[i * 32 +: 32])// output[31:0]
);
sensor_membuf #(
.WADDR_WIDTH(9)
) sensor_membuf_i (
.pclk (pclk), // input
.px_data (px_data[i]), // input[15:0]
.px_valid (px_valid[i]), // input
.last_in_line (last_in_line[i]), // input
.mclk (mclk), // input
.rpage_set (rpage_set[i]), // input
.rpage_next (rpage_next[i]), // input
.buf_rd (buf_rd[i]), // input
//buf_dout_all
// .buf_dout ((i & 2) ? ((i & 1) ? buf_dout3 : buf_dout2): ((i & 1) ? buf_dout1: buf_dout0)) // output[63:0]
.pclk (pclk), // input
.px_data (px_data[16 * i +: 16]), // input[15:0]
.px_valid (px_valid[i]), // input
.last_in_line (last_in_line[i]), // input
.mclk (mclk), // input
.rpage_set (rpage_set[i]), // input
.rpage_next (rpage_next[i]), // input
.buf_rd (buf_rd[i]), // input
.buf_dout (buf_dout_all[64*i +: 64]) // output[63:0]
);
end
......@@ -493,76 +491,76 @@ module sensors393 #(
.HIST_SAXI_MODE_ADDR_MASK (HIST_SAXI_MODE_ADDR_MASK),
.NUM_FRAME_BITS (NUM_FRAME_BITS)
) histogram_saxi_i (
.rst (rst), // input
.mclk (mclk), // input
.aclk (aclk), // input
.frame0 (frame_num0), // input[3:0]
.hist_request0 (hist_request[0]), // input
.hist_grant0 (hist_grant[0]), // output
.hist_chn0 (hist_chn[0]), // input[1:0]
.hist_dvalid0 (hist_dvalid[0]), // input
.hist_data0 (hist_data[0]), // input[31:0]
.frame1 (frame_num1), // input[3:0]
.hist_request1 (hist_request[1]), // input
.hist_grant1 (hist_grant[1]), // output
.hist_chn1 (hist_chn[1]), // input[1:0]
.hist_dvalid1 (hist_dvalid[1]), // input
.hist_data1 (hist_data[1]), // input[31:0]
.frame2 (frame_num2), // input[3:0]
.hist_request2 (hist_request[2]), // input
.hist_grant2 (hist_grant[2]), // output
.hist_chn2 (hist_chn[2]), // input[1:0] SuppressThisWarning VEditor : VDT bug - wrong dimension
.hist_dvalid2 (hist_dvalid[2]), // input
.hist_data2 (hist_data[2]), // input[31:0]
.frame3 (frame_num3), // input[3:0]
.hist_request3 (hist_request[3]), // input
.hist_grant3 (hist_grant[3]), // output
.hist_chn3 (hist_chn[3]), // input[1:0] SuppressThisWarning VEditor : VDT bug - wrong dimension
.hist_dvalid3 (hist_dvalid[3]), // input
.hist_data3 (hist_data[3]), // input[31:0]
.cmd_ad (cmd_ad), // input[7:0]
.cmd_stb (cmd_stb), // input
.saxi_awaddr (saxi_awaddr), // output[31:0]
.saxi_awvalid (saxi_awvalid), // output
.saxi_awready (saxi_awready), // input
.saxi_awid (saxi_awid), // output[5:0]
.saxi_awlock (saxi_awlock), // output[1:0]
.saxi_awcache (saxi_awcache), // output[3:0]
.saxi_awprot (saxi_awprot), // output[2:0]
.saxi_awlen (saxi_awlen), // output[3:0]
.saxi_awsize (saxi_awsize), // output[1:0]
.saxi_awburst (saxi_awburst), // output[1:0]
.saxi_awqos (saxi_awqos), // output[3:0]
.saxi_wdata (saxi_wdata), // output[31:0]
.saxi_wvalid (saxi_wvalid), // output
.saxi_wready (saxi_wready), // input
.saxi_wid (saxi_wid), // output[5:0]
.saxi_wlast (saxi_wlast), // output
.saxi_wstrb (saxi_wstrb), // output[3:0]
.saxi_bvalid (saxi_bvalid), // input
.saxi_bready (saxi_bready), // output
.saxi_bid (saxi_bid), // input[5:0]
.saxi_bresp (saxi_bresp) // input[1:0]
.rst (rst), // input
.mclk (mclk), // input
.aclk (aclk), // input
.frame0 (frame_num0), // input[3:0]
.hist_request0 (hist_request[0]), // input
.hist_grant0 (hist_grant[0]), // output
.hist_chn0 (hist_chn[0 * 2 +: 2]), // input[1:0]
.hist_dvalid0 (hist_dvalid[0]), // input
.hist_data0 (hist_data[0 * 32 +: 32]),// input[31:0]
.frame1 (frame_num1), // input[3:0]
.hist_request1 (hist_request[1]), // input
.hist_grant1 (hist_grant[1]), // output
.hist_chn1 (hist_chn[1 * 2 +: 2]), // input[1:0]
.hist_dvalid1 (hist_dvalid[1]), // input
.hist_data1 (hist_data[1 * 32 +: 32]),// input[31:0]
.frame2 (frame_num2), // input[3:0]
.hist_request2 (hist_request[2]), // input
.hist_grant2 (hist_grant[2]), // output
.hist_chn2 (hist_chn[2 * 2 +: 2]), // input[1:0]
.hist_dvalid2 (hist_dvalid[2]), // input
.hist_data2 (hist_data[2 * 32 +: 32]),// input[31:0]
.frame3 (frame_num3), // input[3:0]
.hist_request3 (hist_request[3]), // input
.hist_grant3 (hist_grant[3]), // output
.hist_chn3 (hist_chn[3 * 2 +: 2]), // input[1:0]
.hist_dvalid3 (hist_dvalid[3]), // input
.hist_data3 (hist_data[3 * 32 +: 32]),// input[31:0]
.cmd_ad (cmd_ad), // input[7:0]
.cmd_stb (cmd_stb), // input
.saxi_awaddr (saxi_awaddr), // output[31:0]
.saxi_awvalid (saxi_awvalid), // output
.saxi_awready (saxi_awready), // input
.saxi_awid (saxi_awid), // output[5:0]
.saxi_awlock (saxi_awlock), // output[1:0]
.saxi_awcache (saxi_awcache), // output[3:0]
.saxi_awprot (saxi_awprot), // output[2:0]
.saxi_awlen (saxi_awlen), // output[3:0]
.saxi_awsize (saxi_awsize), // output[1:0]
.saxi_awburst (saxi_awburst), // output[1:0]
.saxi_awqos (saxi_awqos), // output[3:0]
.saxi_wdata (saxi_wdata), // output[31:0]
.saxi_wvalid (saxi_wvalid), // output
.saxi_wready (saxi_wready), // input
.saxi_wid (saxi_wid), // output[5:0]
.saxi_wlast (saxi_wlast), // output
.saxi_wstrb (saxi_wstrb), // output[3:0]
.saxi_bvalid (saxi_bvalid), // input
.saxi_bready (saxi_bready), // output
.saxi_bid (saxi_bid), // input[5:0]
.saxi_bresp (saxi_bresp) // input[1:0]
);
status_router4 status_router4_i (
.rst (rst), // input
.clk (mclk), // input
.db_in0 (status_ad_chn[0]), // input[7:0]
.rq_in0 (status_rq_chn[0]), // input
.start_in0 (status_start_chn[0]), // output
.db_in1 (status_ad_chn[1]), // input[7:0]
.rq_in1 (status_rq_chn[1]), // input
.start_in1 (status_start_chn[1]), // output
.db_in2 (status_ad_chn[2]), // input[7:0]
.rq_in2 (status_rq_chn[2]), // input
.start_in2 (status_start_chn[2]), // output
.db_in3 (status_ad_chn[3]), // input[7:0]
.rq_in3 (status_rq_chn[3]), // input
.start_in3 (status_start_chn[3]), // output
.db_out (status_ad), // output[7:0]
.rq_out (status_rq), // output
.start_out (status_start) // input
.rst (rst), // input
.clk (mclk), // input
.db_in0 (status_ad_chn[0 +: 8]), // input[7:0]
.rq_in0 (status_rq_chn[0]), // input
.start_in0 (status_start_chn[0]), // output
.db_in1 (status_ad_chn[8 +: 8]), // input[7:0]
.rq_in1 (status_rq_chn[1]), // input
.start_in1 (status_start_chn[1]), // output
.db_in2 (status_ad_chn[16 +: 8]), // input[7:0]
.rq_in2 (status_rq_chn[2]), // input
.start_in2 (status_start_chn[2]), // output
.db_in3 (status_ad_chn[24 +: 8]), // input[7:0]
.rq_in3 (status_rq_chn[3]), // input
.start_in3 (status_start_chn[3]), // output
.db_out (status_ad), // output[7:0]
.rq_out (status_rq), // output
.start_out (status_start) // input
);
idelay_ctrl# (
......
......@@ -108,26 +108,19 @@ module timing393 #(
wire [3:0] frame_sync;
wire [3:0] trig;
wire [3:0] ts_local_snap; // ts_snap_mclk make a timestamp pulse single @(posedge pclk)
wire [3:0] ts_local_stb; // 1 clk before ts_snd_data is valid
wire [7:0] ts_local_data [0:3]; // byte-wide serialized timestamp message
// wire ts_pio_snap; // ts_snap_mclk make a timestamp pulse single @(posedge pclk)
// wire ts_pio_stb; // 1 clk before ts_snd_data is valid
// wire [7:0] ts_pio_data; // byte-wide serialized timestamp message
wire [3:0] ts_local_snap; // ts_snap_mclk make a timestamp pulse single @(posedge pclk)
wire [3:0] ts_local_stb; // 1 clk before ts_snd_data is valid
wire [31:0] ts_local_data; // byte-wide serialized timestamp message
wire [3:0] ts_stb; // 1 clk before ts_snd_data is valid
wire [7:0] ts_data [0:3]; // byte-wide serialized timestamp message
wire [31:0] ts_data; // byte-wide serialized timestamp message (channels concatenated)
wire [31:0] live_sec; // current time seconds, updated @ mclk
wire [19:0] live_usec; // current time microseconds, updated @ mclk
assign {ts_stb_chn3, ts_stb_chn2, ts_stb_chn1, ts_stb_chn0} = ts_stb;
assign ts_data_chn0 = ts_data[0];
assign ts_data_chn1 = ts_data[1];
assign ts_data_chn2 = ts_data[2];
assign ts_data_chn3 = ts_data[3];
assign {ts_data_chn3, ts_data_chn2, ts_data_chn1, ts_data_chn0} = ts_data;
assign {trig_chn3, trig_chn2, trig_chn1, trig_chn0} = trig;
assign frame_sync = {frsync_chn3, frsync_chn2, frsync_chn1, frsync_chn0};
......@@ -143,72 +136,72 @@ module timing393 #(
.RTC_SET_CORR (RTC_SET_CORR),
.RTC_SET_STATUS (RTC_SET_STATUS)
) rtc393_i (
.rst (rst), // input
.mclk (mclk), // input
.refclk (refclk), // input
.cmd_ad (cmd_ad), // input[7:0]
.cmd_stb (cmd_stb), // input
.status_ad (status_ad), // output[7:0]
.status_rq (status_rq), // output
.rst (rst), // input
.mclk (mclk), // input
.refclk (refclk), // input
.cmd_ad (cmd_ad), // input[7:0]
.cmd_stb (cmd_stb), // input
.status_ad (status_ad), // output[7:0]
.status_rq (status_rq), // output
.status_start (status_start), // input
.live_sec (live_sec), // output[31:0]
.live_usec (live_usec) // output[19:0]
.live_sec (live_sec), // output[31:0]
.live_usec (live_usec) // output[19:0]
);
timestamp_snapshot timestamp_snapshot_logger_i (
.rst (rst), // input
.tclk (mclk), // input
.sec (live_sec), // input[31:0]
.usec (live_usec), // input[19:0]
.sclk (lclk), // input
.snap (ts_logger_snap), // input
.pre_stb (ts_logger_stb), // output
.ts_data (ts_logger_data) // output[7:0] reg
.rst (rst), // input
.tclk (mclk), // input
.sec (live_sec), // input[31:0]
.usec (live_usec), // input[19:0]
.sclk (lclk), // input
.snap (ts_logger_snap), // input
.pre_stb (ts_logger_stb), // output
.ts_data (ts_logger_data) // output[7:0] reg
);
timestamp_snapshot timestamp_snapshot_chn0_i (
.rst (rst), // input
.tclk (mclk), // input
.sec (live_sec), // input[31:0]
.usec (live_usec), // input[19:0]
.sclk (mclk), // input
.snap (ts_local_snap[0]), // input
.pre_stb (ts_local_stb[0]), // output
.ts_data (ts_local_data[0]) // output[7:0] reg
.rst (rst), // input
.tclk (mclk), // input
.sec (live_sec), // input[31:0]
.usec (live_usec), // input[19:0]
.sclk (mclk), // input
.snap (ts_local_snap[0]), // input
.pre_stb (ts_local_stb[0]), // output
.ts_data (ts_local_data[0 * 8 +: 8]) // output[7:0] reg
);
timestamp_snapshot timestamp_snapshot_chn1_i (
.rst (rst), // input
.tclk (mclk), // input
.sec (live_sec), // input[31:0]
.usec (live_usec), // input[19:0]
.sclk (mclk), // input
.snap (ts_local_snap[1]), // input
.pre_stb (ts_local_stb[1]), // output
.ts_data (ts_local_data[1]) // output[7:0] reg
.rst (rst), // input
.tclk (mclk), // input
.sec (live_sec), // input[31:0]
.usec (live_usec), // input[19:0]
.sclk (mclk), // input
.snap (ts_local_snap[1]), // input
.pre_stb (ts_local_stb[1]), // output
.ts_data (ts_local_data[1 * 8 +: 8]) // output[7:0] reg
);
timestamp_snapshot timestamp_snapshot_chn2_i (
.rst (rst), // input
.tclk (mclk), // input
.sec (live_sec), // input[31:0]
.usec (live_usec), // input[19:0]
.sclk (mclk), // input
.snap (ts_local_snap[2]), // input
.pre_stb (ts_local_stb[2]), // output
.ts_data (ts_local_data[2]) // output[7:0] reg
.rst (rst), // input
.tclk (mclk), // input
.sec (live_sec), // input[31:0]
.usec (live_usec), // input[19:0]
.sclk (mclk), // input
.snap (ts_local_snap[2]), // input
.pre_stb (ts_local_stb[2]), // output
.ts_data (ts_local_data[2 * 8 +: 8]) // output[7:0] reg
);
timestamp_snapshot timestamp_snapshot_chn3_i (
.rst (rst), // input
.tclk (mclk), // input
.sec (live_sec), // input[31:0]
.usec (live_usec), // input[19:0]
.sclk (mclk), // input
.snap (ts_local_snap[3]), // input
.pre_stb (ts_local_stb[3]), // output
.ts_data (ts_local_data[3]) // output[7:0] reg
.rst (rst), // input
.tclk (mclk), // input
.sec (live_sec), // input[31:0]
.usec (live_usec), // input[19:0]
.sclk (mclk), // input
.snap (ts_local_snap[3]), // input
.pre_stb (ts_local_stb[3]), // output
.ts_data (ts_local_data[3 * 8 +: 8]) // output[7:0] reg
);
camsync393 #(
......@@ -230,43 +223,43 @@ module timing393 #(
.CAMSYNC_PRE_MAGIC (CAMSYNC_PRE_MAGIC),
.CAMSYNC_POST_MAGIC (CAMSYNC_POST_MAGIC)
) camsync393_i (
.rst (rst), // input
.mclk (mclk), // input
.cmd_ad (cmd_ad), // input[7:0]
.cmd_stb (cmd_stb), // input
.pclk (pclk), // input
.gpio_in (gpio_in), // input[9:0]
.gpio_out (gpio_out), // output[9:0]
.gpio_out_en (gpio_out_en), // output[9:0] reg
.triggered_mode (triggered_mode), // output
.frsync_chn0 (frame_sync[0]), // input
.trig_chn0 (trig[0]), // output
.frsync_chn1 (frame_sync[1]), // input
.trig_chn1 (trig[1]), // output
.frsync_chn2 (frame_sync[2]), // input
.trig_chn2 (trig[2]), // output
.frsync_chn3 (frame_sync[3]), // input
.trig_chn3 (trig[3]), // output
.ts_snap_mclk_chn0 (ts_local_snap[0]), // output
.ts_snd_stb_chn0 (ts_local_stb[0]), // input
.ts_snd_data_chn0 (ts_local_data[0]), // input[7:0]
.ts_snap_mclk_chn1 (ts_local_snap[1]), // output
.ts_snd_stb_chn1 (ts_local_stb[1]), // input
.ts_snd_data_chn1 (ts_local_data[1]), // input[7:0]
.ts_snap_mclk_chn2 (ts_local_snap[2]), // output
.ts_snd_stb_chn2 (ts_local_stb[2]), // input
.ts_snd_data_chn2 (ts_local_data[2]), // input[7:0]
.ts_snap_mclk_chn3 (ts_local_snap[3]), // output
.ts_snd_stb_chn3 (ts_local_stb[3]), // input
.ts_snd_data_chn3 (ts_local_data[3]), // input[7:0]
.ts_rcv_stb_chn0 (ts_stb[0]), // output
.ts_rcv_data_chn0 (ts_data[0]), // output[7:0]
.ts_rcv_stb_chn1 (ts_stb[1]), // output
.ts_rcv_data_chn1 (ts_data[1]), // output[7:0]
.ts_rcv_stb_chn2 (ts_stb[2]), // output
.ts_rcv_data_chn2 (ts_data[2]), // output[7:0]
.ts_rcv_stb_chn3 (ts_stb[3]), // output
.ts_rcv_data_chn3 (ts_data[3]) // output[7:0]
.rst (rst), // input
.mclk (mclk), // input
.cmd_ad (cmd_ad), // input[7:0]
.cmd_stb (cmd_stb), // input
.pclk (pclk), // input
.gpio_in (gpio_in), // input[9:0]
.gpio_out (gpio_out), // output[9:0]
.gpio_out_en (gpio_out_en), // output[9:0] reg
.triggered_mode (triggered_mode), // output
.frsync_chn0 (frame_sync[0]), // input
.trig_chn0 (trig[0]), // output
.frsync_chn1 (frame_sync[1]), // input
.trig_chn1 (trig[1]), // output
.frsync_chn2 (frame_sync[2]), // input
.trig_chn2 (trig[2]), // output
.frsync_chn3 (frame_sync[3]), // input
.trig_chn3 (trig[3]), // output
.ts_snap_mclk_chn0 (ts_local_snap[0]), // output
.ts_snd_stb_chn0 (ts_local_stb[0]), // input
.ts_snd_data_chn0 (ts_local_data[0 * 8 +: 8]), // input[7:0]
.ts_snap_mclk_chn1 (ts_local_snap[1]), // output
.ts_snd_stb_chn1 (ts_local_stb[1]), // input
.ts_snd_data_chn1 (ts_local_data[1 * 8 +: 8]), // input[7:0]
.ts_snap_mclk_chn2 (ts_local_snap[2]), // output
.ts_snd_stb_chn2 (ts_local_stb[2]), // input
.ts_snd_data_chn2 (ts_local_data[2 * 8 +: 8]), // input[7:0]
.ts_snap_mclk_chn3 (ts_local_snap[3]), // output
.ts_snd_stb_chn3 (ts_local_stb[3]), // input
.ts_snd_data_chn3 (ts_local_data[3 * 8 +: 8]), // input[7:0]
.ts_rcv_stb_chn0 (ts_stb[0]), // output
.ts_rcv_data_chn0 (ts_data[0 * 8 +: 8]), // output[7:0]
.ts_rcv_stb_chn1 (ts_stb[1]), // output
.ts_rcv_data_chn1 (ts_data[1 * 8 +: 8]), // output[7:0]
.ts_rcv_stb_chn2 (ts_stb[2]), // output
.ts_rcv_data_chn2 (ts_data[2 * 8 +: 8]), // output[7:0]
.ts_rcv_stb_chn3 (ts_stb[3]), // output
.ts_rcv_data_chn3 (ts_data[3 * 8 +: 8]) // output[7:0]
);
endmodule
......
......@@ -92,9 +92,9 @@ module cmd_frame_sequencer#(
reg we_fifo_wp; // enable writing to fifo write pointer memory
reg next_frame_rq; // request to switch to the new frame page, clear pointer for the one just left
wire pre_wpage_inc;
reg [PNTR_WIDH-1:0] fifo_wr_pointers [0:7];
wire [PNTR_WIDH-1:0] fifo_wr_pointers_outw=fifo_wr_pointers[wpage_w];
wire [PNTR_WIDH-1:0] fifo_wr_pointers_outr=fifo_wr_pointers[page_r];
reg [PNTR_WIDH-1:0] fifo_wr_pointers_ram [0:7];
wire [PNTR_WIDH-1:0] fifo_wr_pointers_outw=fifo_wr_pointers_ram[wpage_w];
wire [PNTR_WIDH-1:0] fifo_wr_pointers_outr=fifo_wr_pointers_ram[page_r];
reg [PNTR_WIDH-1:0] fifo_wr_pointers_outw_r;
reg [PNTR_WIDH-1:0] fifo_wr_pointers_outr_r;
......@@ -205,7 +205,7 @@ module cmd_frame_sequencer#(
if (cmd_we_any_r[1]) fifo_wr_pointers_outw_r <= fifo_wr_pointers_outw; // register pointer RAM output (write port)
// write to pointer RAM (to the same address as just read from if read)
if (we_fifo_wp) fifo_wr_pointers[wpage_w] <= wpage_inc[1] ? {PNTR_WIDH{1'b0}}:(fifo_wr_pointers_outw_r + 1);
if (we_fifo_wp) fifo_wr_pointers_ram[wpage_w] <= wpage_inc[1] ? {PNTR_WIDH{1'b0}}:(fifo_wr_pointers_outw_r + 1);
if (cmd_we_any_r[1]) seq_cmd_wa <= {wpage_w, fifo_wr_pointers_outw};
......
......@@ -52,21 +52,23 @@ module cmd_seq_mux#(
output reg [31:0] wdata_out, // write data, valid with waddr_out and wr_en_out
input ackn_out // command sequencer address/data accepted
);
wire [3:0] wr_en = {wr_en3 & ~ackn3, wr_en2 & ~ackn2, wr_en1 & ~ackn1, wr_en0 & ~ackn0};
wire [3:0] pri_one_rr[0:3]; // round robin priority
wire [3:0] pri_one;
reg [1:0] chn_r; // last served channel
wire rq_any;
wire [1:0] pri_enc_w;
reg full_r;
wire ackn_w; //pre-acknowledge of one of the channels
reg [3:0] ackn_r;
wire [3:0] wr_en = {wr_en3 & ~ackn3, wr_en2 & ~ackn2, wr_en1 & ~ackn1, wr_en0 & ~ackn0};
wire [15:0] pri_one_rr; // round robin priority
wire [3:0] pri_one;
reg [1:0] chn_r; // last served channel
wire rq_any;
wire [1:0] pri_enc_w;
reg full_r;
wire ackn_w; //pre-acknowledge of one of the channels
reg [3:0] ackn_r;
assign pri_one_rr[0]={wr_en[3] & ~(|wr_en[2:1]), wr_en[2] & ~wr_en[1], wr_en[1], wr_en[0] & ~(|wr_en[3:1])};
assign pri_one_rr[1]={wr_en[3] & ~ wr_en[2], wr_en[2], wr_en[1] & ~(|wr_en[3:2]) & wr_en[0], wr_en[0] & ~(|wr_en[3:2])};
assign pri_one_rr[2]={wr_en[3], wr_en[2]&~(|wr_en[1:0])&wr_en[3], wr_en[1] & ~ wr_en[3] & wr_en[0], wr_en[0] & ~ wr_en[3] };
assign pri_one_rr[3]={wr_en[3] & ~(|wr_en[2:0]), wr_en[2]&~(|wr_en[1:0]), wr_en[1] & wr_en[0], wr_en[0] };
assign pri_one = pri_one_rr[chn_r];
assign pri_one_rr = {wr_en[3] & ~(|wr_en[2:0]), wr_en[2]&~(|wr_en[1:0]), wr_en[1] & wr_en[0], wr_en[0],
wr_en[3], wr_en[2]&~(|wr_en[1:0])&wr_en[3], wr_en[1] & ~ wr_en[3] & wr_en[0], wr_en[0] & ~ wr_en[3],
wr_en[3] & ~ wr_en[2], wr_en[2], wr_en[1] & ~(|wr_en[3:2]) & wr_en[0], wr_en[0] & ~(|wr_en[3:2]),
wr_en[3] & ~(|wr_en[2:1]), wr_en[2] & ~wr_en[1], wr_en[1], wr_en[0] & ~(|wr_en[3:1])};
assign pri_one = pri_one_rr[chn_r * 4 +: 4];
assign rq_any= |wr_en;
assign pri_enc_w ={pri_one[3] | pri_one[2],
pri_one[3] | pri_one[1]};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment