Commit 500cf616 authored by Andrey Filippov's avatar Andrey Filippov

fixed axi simulation modules, added IRQ support

parent ea63654a
...@@ -62,52 +62,52 @@ ...@@ -62,52 +62,52 @@
<link> <link>
<name>vivado_logs/VivadoBitstream.log</name> <name>vivado_logs/VivadoBitstream.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoBitstream-20160313162251081.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoBitstream-20160316003619053.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoOpt.log</name> <name>vivado_logs/VivadoOpt.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoOpt-20160313162251081.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoOpt-20160316003619053.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoOptPhys.log</name> <name>vivado_logs/VivadoOptPhys.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoOptPhys-20160313162251081.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoOptPhys-20160316003619053.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoOptPower.log</name> <name>vivado_logs/VivadoOptPower.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoOptPower-20160313162251081.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoOptPower-20160316003619053.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoPlace.log</name> <name>vivado_logs/VivadoPlace.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoPlace-20160313162251081.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoPlace-20160316003619053.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoRoute.log</name> <name>vivado_logs/VivadoRoute.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoRoute-20160313162251081.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoRoute-20160316003619053.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoSynthesis.log</name> <name>vivado_logs/VivadoSynthesis.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoSynthesis-20160313161825094.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoSynthesis-20160316003135844.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoTimimgSummaryReportImplemented.log</name> <name>vivado_logs/VivadoTimimgSummaryReportImplemented.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoTimimgSummaryReportImplemented-20160313162251081.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoTimimgSummaryReportImplemented-20160316003619053.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoTimimgSummaryReportSynthesis.log</name> <name>vivado_logs/VivadoTimimgSummaryReportSynthesis.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoTimimgSummaryReportSynthesis-20160313161825094.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoTimimgSummaryReportSynthesis-20160316003135844.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoTimingReportSynthesis.log</name> <name>vivado_logs/VivadoTimingReportSynthesis.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoTimingReportSynthesis-20160313161825094.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoTimingReportSynthesis-20160316003135844.log</location>
</link> </link>
<link> <link>
<name>vivado_state/x393-opt-phys.dcp</name> <name>vivado_state/x393-opt-phys.dcp</name>
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
<link> <link>
<name>vivado_state/x393-synth.dcp</name> <name>vivado_state/x393-synth.dcp</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_state/x393-synth-20160313161825094.dcp</location> <location>/home/andrey/git/x393/vivado_state/x393-synth-20160316003135844.dcp</location>
</link> </link>
</linkedResources> </linkedResources>
</projectDescription> </projectDescription>
...@@ -67,7 +67,6 @@ module cmprs_afi_mux_ptr_wresp( ...@@ -67,7 +67,6 @@ module cmprs_afi_mux_ptr_wresp(
reg [26:0] len_ram[0:3]; // start chunk/num cunks in a buffer (write port @mclk) reg [26:0] len_ram[0:3]; // start chunk/num cunks in a buffer (write port @mclk)
reg [26:0] chunk_ptr_inc; // incremented by 1..4 chunk pointer reg [26:0] chunk_ptr_inc; // incremented by 1..4 chunk pointer
reg [27:0] chunk_ptr_rovr; // incremented chunk pointer, decremented by length (MSB - sign) reg [27:0] chunk_ptr_rovr; // incremented chunk pointer, decremented by length (MSB - sign)
/// reg [ 3:0] busy; // one-hot busy stages (usually end with [3]
reg [ 4:0] busy; // one-hot busy stages (usually end with [4] reg [ 4:0] busy; // one-hot busy stages (usually end with [4]
reg [ 4:0] id_r; // registered ID data - MSB is unused reg [ 4:0] id_r; // registered ID data - MSB is unused
...@@ -88,14 +87,9 @@ module cmprs_afi_mux_ptr_wresp( ...@@ -88,14 +87,9 @@ module cmprs_afi_mux_ptr_wresp(
assign ptr_wa = {eof,chn}; // valid @busy[2] assign ptr_wa = {eof,chn}; // valid @busy[2]
assign afi_bready = afi_bready_r; assign afi_bready = afi_bready_r;
/// assign pre_we= resetting[0] || // a pair of cycles to reset chunk pointer and frame chunk pointer
/// busy[2] || // always update chunk pointer
/// (busy[3] && last_burst_in_frame); // optionally update frame chunk pointer (same value)
assign pre_we= resetting[0] || // a pair of cycles to reset chunk pointer and frame chunk pointer assign pre_we= resetting[0] || // a pair of cycles to reset chunk pointer and frame chunk pointer
busy[3] || // always update chunk pointer busy[3] || // always update chunk pointer
(busy[4] && last_burst_in_frame); // optionally update frame chunk pointer (same value) (busy[4] && last_burst_in_frame); // optionally update frame chunk pointer (same value)
/// assign pre_busy= afi_bvalid_r && en && !(|busy[1:0]) && !pre_we;
/// assign start_resetting_w = !afi_bvalid_r && en && !(|busy[1:0]) && !pre_we && (|reset_rq);
assign pre_busy= afi_bvalid_r && en && !(|busy[2:0]) && !pre_we; assign pre_busy= afi_bvalid_r && en && !(|busy[2:0]) && !pre_we;
assign start_resetting_w = !afi_bvalid_r && en && !(|busy[2:0]) && !pre_we && (|reset_rq); assign start_resetting_w = !afi_bvalid_r && en && !(|busy[2:0]) && !pre_we && (|reset_rq);
...@@ -108,11 +102,10 @@ module cmprs_afi_mux_ptr_wresp( ...@@ -108,11 +102,10 @@ module cmprs_afi_mux_ptr_wresp(
afi_bvalid_r <= afi_bvalid; afi_bvalid_r <= afi_bvalid;
afi_bready_r <= !en || pre_busy; // (!busy[0] && !pre_busy && !resetting[0] && !start_resetting_w); afi_bready_r <= !en || pre_busy; // (!busy[0] && !pre_busy && !resetting[0] && !start_resetting_w);
// busy <= {busy[2:0], pre_busy}; // adjust bits
busy <= {busy[3:0], pre_busy}; // adjust bits busy <= {busy[3:0], pre_busy}; // adjust bits
// id_r <= afi_bid[4:0]; // id_r[5] is never used - revoved // if (afi_bready && afi_bvalid) id_r <= afi_bid[4:0]; // id_r[5] is never used - revoved
if (afi_bready && afi_bvalid) id_r <= afi_bid[4:0]; // id_r[5] is never used - revoved if (afi_bvalid && pre_busy) id_r <= afi_bid[4:0]; // id_r[5] is never used - revoved
if (start_resetting_w) reset_rq_pri <= {reset_rq[3] & ~(|reset_rq[2:0]), if (start_resetting_w) reset_rq_pri <= {reset_rq[3] & ~(|reset_rq[2:0]),
reset_rq[2] & ~(|reset_rq[1:0]), reset_rq[2] & ~(|reset_rq[1:0]),
...@@ -126,10 +119,8 @@ module cmprs_afi_mux_ptr_wresp( ...@@ -126,10 +119,8 @@ module cmprs_afi_mux_ptr_wresp(
else resetting <= {resetting[0], start_resetting_w | (resetting[0] & ~resetting[1])}; else resetting <= {resetting[0], start_resetting_w | (resetting[0] & ~resetting[1])};
if (resetting == 2'b01) chn <= reset_rq_enc; if (resetting == 2'b01) chn <= reset_rq_enc;
/// else if (busy[0]) chn <= id_r[0 +: 2];
else if (busy[1]) chn <= id_r[0 +: 2]; else if (busy[1]) chn <= id_r[0 +: 2];
/// if (busy[0]) begin // first busy cycle
if (busy[1]) begin // first busy cycle if (busy[1]) begin // first busy cycle
last_burst_in_frame <= id_r[2]; last_burst_in_frame <= id_r[2];
chunk_inc <= {1'b0,id_r[3 +:2]} + 1; chunk_inc <= {1'b0,id_r[3 +:2]} + 1;
...@@ -140,9 +131,6 @@ module cmprs_afi_mux_ptr_wresp( ...@@ -140,9 +131,6 @@ module cmprs_afi_mux_ptr_wresp(
if ((resetting == 2'b01) || busy[0]) eof <= 0; if ((resetting == 2'b01) || busy[0]) eof <= 0;
else if (ptr_we) eof <= 1; // always second write cycle else if (ptr_we) eof <= 1; // always second write cycle
// @@@ delay by 1 clk
/// if (busy[1]) chunk_ptr_inc <= ptr_ram[ptr_wa] + chunk_inc; // second clock of busy
/// if (busy[2]) chunk_ptr_rovr <={1'b0,chunk_ptr_inc} - {1'b0,len_ram[chn]}; // third clock of busy
if (busy[2]) chunk_ptr_inc <= ptr_ram[ptr_wa] + chunk_inc; // second clock of busy if (busy[2]) chunk_ptr_inc <= ptr_ram[ptr_wa] + chunk_inc; // second clock of busy
if (busy[3]) chunk_ptr_rovr <={1'b0,chunk_ptr_inc} - {1'b0,len_ram[chn]}; // third clock of busy if (busy[3]) chunk_ptr_rovr <={1'b0,chunk_ptr_inc} - {1'b0,len_ram[chn]}; // third clock of busy
......
...@@ -34,25 +34,42 @@ ...@@ -34,25 +34,42 @@
`timescale 1ns/1ps `timescale 1ns/1ps
module cmprs_status( module cmprs_status(
input mrst,
input mclk, // system clock input mclk, // system clock
input eof_written, input eof_written,
input stuffer_running, input stuffer_running,
input reading_frame, input reading_frame,
output [2:0] status input set_interrupts,
input [1:0] data_in,
output [4:0] status,
output irq
); );
reg stuffer_running_r; reg stuffer_running_r;
reg flushing_fifo; reg flushing_fifo;
reg is_r; // interrupt status (not masked)
reg im_r; // interrupt mask
assign status = {flushing_fifo, stuffer_running_r, reading_frame};
assign status = {flushing_fifo,
stuffer_running_r,
reading_frame,
im_r, is_r};
assign irq = is_r && im_r;
always @(posedge mclk) begin always @(posedge mclk) begin
if (mrst) im_r <= 0;
else if (set_interrupts && data_in[1]) im_r <= data_in[0];
if (mrst) is_r <= 0;
else if (eof_written) is_r <= 1;
else if (set_interrupts && (data_in == 1)) is_r <= 0;
stuffer_running_r <= stuffer_running; stuffer_running_r <= stuffer_running;
if (stuffer_running_r && !stuffer_running) flushing_fifo <= 1; if (stuffer_running_r && !stuffer_running) flushing_fifo <= 1;
else if (eof_written) flushing_fifo <= 0; else if (eof_written) flushing_fifo <= 0;
end end
endmodule endmodule
...@@ -54,6 +54,7 @@ module compressor393 # ( ...@@ -54,6 +54,7 @@ module compressor393 # (
parameter CMPRS_FORMAT= 2, parameter CMPRS_FORMAT= 2,
parameter CMPRS_COLOR_SATURATION= 3, parameter CMPRS_COLOR_SATURATION= 3,
parameter CMPRS_CORING_MODE= 4, parameter CMPRS_CORING_MODE= 4,
parameter CMPRS_INTERRUPTS= 5,
parameter CMPRS_TABLES= 6, // 6..7 parameter CMPRS_TABLES= 6, // 6..7
parameter TABLE_QUANTIZATION_INDEX = 0, parameter TABLE_QUANTIZATION_INDEX = 0,
parameter TABLE_CORING_INDEX = 1, parameter TABLE_CORING_INDEX = 1,
...@@ -147,6 +148,7 @@ module compressor393 # ( ...@@ -147,6 +148,7 @@ module compressor393 # (
output [7:0] status_ad, // status address/data - up to 5 bytes: A - {seq,status[1:0]} - status[2:9] - status[10:17] - status[18:25] output [7:0] status_ad, // status address/data - up to 5 bytes: A - {seq,status[1:0]} - status[2:9] - status[10:17] - status[18:25]
output status_rq, // input request to send status downstream output status_rq, // input request to send status downstream
input status_start, // Acknowledge of the first status packet byte (address) input status_start, // Acknowledge of the first status packet byte (address)
output [3:0] cmprs_irq, // Compressor done interruupt
// Buffer interfaces, combined for 4 channels // Buffer interfaces, combined for 4 channels
input [3:0] xfer_reset_page_rd, // from mcntrl_tiled_rw ( input [3:0] xfer_reset_page_rd, // from mcntrl_tiled_rw (
...@@ -280,7 +282,6 @@ module compressor393 # ( ...@@ -280,7 +282,6 @@ module compressor393 # (
wire [3:0] flush_hclk; // before last data was written wire [3:0] flush_hclk; // before last data was written
wire [31:0] fifo_count; wire [31:0] fifo_count;
/* Instance template for module status_router8 */
status_router8 status_router8_i ( status_router8 status_router8_i (
.rst (1'b0), //rst), // input .rst (1'b0), //rst), // input
.clk (mclk), // input .clk (mclk), // input
...@@ -339,6 +340,7 @@ module compressor393 # ( ...@@ -339,6 +340,7 @@ module compressor393 # (
.CMPRS_FORMAT (CMPRS_FORMAT), .CMPRS_FORMAT (CMPRS_FORMAT),
.CMPRS_COLOR_SATURATION (CMPRS_COLOR_SATURATION), .CMPRS_COLOR_SATURATION (CMPRS_COLOR_SATURATION),
.CMPRS_CORING_MODE (CMPRS_CORING_MODE), .CMPRS_CORING_MODE (CMPRS_CORING_MODE),
.CMPRS_INTERRUPTS (CMPRS_INTERRUPTS),
.CMPRS_TABLES (CMPRS_TABLES), .CMPRS_TABLES (CMPRS_TABLES),
.TABLE_QUANTIZATION_INDEX (TABLE_QUANTIZATION_INDEX), .TABLE_QUANTIZATION_INDEX (TABLE_QUANTIZATION_INDEX),
.TABLE_CORING_INDEX (TABLE_CORING_INDEX), .TABLE_CORING_INDEX (TABLE_CORING_INDEX),
...@@ -414,6 +416,7 @@ module compressor393 # ( ...@@ -414,6 +416,7 @@ module compressor393 # (
.status_ad (status_ad_mux[8 * i +: 8]), // output[7:0] .status_ad (status_ad_mux[8 * i +: 8]), // output[7:0]
.status_rq (status_rq_mux[i]), // output .status_rq (status_rq_mux[i]), // output
.status_start (status_start_mux[i]), // input .status_start (status_start_mux[i]), // input
.irq (cmprs_irq[i]), // output
.xfer_reset_page_rd (xfer_reset_page_rd[i]), // input .xfer_reset_page_rd (xfer_reset_page_rd[i]), // input
.buf_wpage_nxt (buf_wpage_nxt[i]), // input .buf_wpage_nxt (buf_wpage_nxt[i]), // input
.buf_we (buf_we[i]), // input .buf_we (buf_we[i]), // input
......
...@@ -47,6 +47,7 @@ module jp_channel#( ...@@ -47,6 +47,7 @@ module jp_channel#(
parameter CMPRS_FORMAT= 2, parameter CMPRS_FORMAT= 2,
parameter CMPRS_COLOR_SATURATION= 3, parameter CMPRS_COLOR_SATURATION= 3,
parameter CMPRS_CORING_MODE= 4, parameter CMPRS_CORING_MODE= 4,
parameter CMPRS_INTERRUPTS= 5,
parameter CMPRS_TABLES= 6, // 6(data)..7(address) parameter CMPRS_TABLES= 6, // 6(data)..7(address)
parameter TABLE_QUANTIZATION_INDEX = 0, parameter TABLE_QUANTIZATION_INDEX = 0,
parameter TABLE_CORING_INDEX = 1, parameter TABLE_CORING_INDEX = 1,
...@@ -116,7 +117,6 @@ module jp_channel#( ...@@ -116,7 +117,6 @@ module jp_channel#(
`endif `endif
)( )(
// input rst, // global reset
input xclk, // global clock input, compressor single clock rate input xclk, // global clock input, compressor single clock rate
`ifdef USE_XCLK2X `ifdef USE_XCLK2X
input xclk2x, // global clock input, compressor double clock rate, nominally rising edge aligned input xclk2x, // global clock input, compressor double clock rate, nominally rising edge aligned
...@@ -132,6 +132,7 @@ module jp_channel#( ...@@ -132,6 +132,7 @@ module jp_channel#(
output [7:0] status_ad, // status address/data - up to 5 bytes: A - {seq,status[1:0]} - status[2:9] - status[10:17] - status[18:25] output [7:0] status_ad, // status address/data - up to 5 bytes: A - {seq,status[1:0]} - status[2:9] - status[10:17] - status[18:25]
output status_rq, // input request to send status downstream output status_rq, // input request to send status downstream
input status_start, // Acknowledge of the first status packet byte (address) input status_start, // Acknowledge of the first status packet byte (address)
output irq, // processor interrupt
// Buffer interface (buffer to be a part of the memory controller - it is connected there by a 64-bit data, here - by an 9-bit one // Buffer interface (buffer to be a part of the memory controller - it is connected there by a 64-bit data, here - by an 9-bit one
input xfer_reset_page_rd, // from mcntrl_tiled_rw ( input xfer_reset_page_rd, // from mcntrl_tiled_rw (
...@@ -140,10 +141,6 @@ module jp_channel#( ...@@ -140,10 +141,6 @@ module jp_channel#(
input buf_we, // @!mclk write buffer from memory, increment write input buf_we, // @!mclk write buffer from memory, increment write
input [63:0] buf_din, // data out input [63:0] buf_din, // data out
// output [11:0] buf_ra,
// output buf_ren,
// output buf_regen,
// input [ 7:0] buf_di,
input page_ready_chn, // single mclk (posedge) input page_ready_chn, // single mclk (posedge)
output next_page_chn, // single mclk (posedge): Done with the page in the buffer, memory controller may read more data output next_page_chn, // single mclk (posedge): Done with the page in the buffer, memory controller may read more data
...@@ -186,8 +183,8 @@ module jp_channel#( ...@@ -186,8 +183,8 @@ module jp_channel#(
input fifo_rst, // reset FIFO (set read address to write, reset count) input fifo_rst, // reset FIFO (set read address to write, reset count)
input fifo_ren, input fifo_ren,
output [63:0] fifo_rdata, output [63:0] fifo_rdata,
output fifo_eof, // single rclk pulse signalling EOF output fifo_eof, // single rclk pulse signaling EOF
input eof_written, // confirm frame written ofer AFI to the system memory (single rclk pulse) input eof_written, // confirm frame written over AFI to the system memory (single rclk pulse)
output fifo_flush, // EOF, need to output all what is in FIFO (Stays active until enough data chunks are read) output fifo_flush, // EOF, need to output all what is in FIFO (Stays active until enough data chunks are read)
output flush_hclk, // output before writing last chunk - use it to suspend AFI to have output flush_hclk, // output before writing last chunk - use it to suspend AFI to have
// last burst marked as the last one (otherwise last may be empty if frame had %4==0 chunks) // last burst marked as the last one (otherwise last may be empty if frame had %4==0 chunks)
...@@ -313,16 +310,9 @@ module jp_channel#( ...@@ -313,16 +310,9 @@ module jp_channel#(
wire enc_dv; wire enc_dv;
//TODO: use next signals for status //TODO: use next signals for status
// wire eof_written_mclk;
// wire stuffer_done_mclk;
wire stuffer_running_mclk; wire stuffer_running_mclk;
wire reading_frame; wire reading_frame;
/// wire last_block; //huffman393
/// wire test_lbw;
`ifdef USE_XCLK2X `ifdef USE_XCLK2X
wire [15:0] huff_do; // output[15:0] reg wire [15:0] huff_do; // output[15:0] reg
wire [3:0] huff_dl; // output[3:0] reg wire [3:0] huff_dl; // output[3:0] reg
...@@ -342,6 +332,7 @@ module jp_channel#( ...@@ -342,6 +332,7 @@ module jp_channel#(
wire set_format_w; wire set_format_w;
wire set_color_saturation_w; wire set_color_saturation_w;
wire set_coring_w; wire set_coring_w;
wire set_interrupts_w;
wire set_tables_w; wire set_tables_w;
wire stuffer_running; // @negedge xclk2x from registering timestamp until done wire stuffer_running; // @negedge xclk2x from registering timestamp until done
...@@ -353,6 +344,7 @@ module jp_channel#( ...@@ -353,6 +344,7 @@ module jp_channel#(
wire [ 2:0] coring_num; wire [ 2:0] coring_num;
reg dcc_en; reg dcc_en;
wire [15:0] dccdata; // was not used in late nc353 wire [15:0] dccdata; // was not used in late nc353
wire dccvld; // was not used in late nc353 wire dccvld; // was not used in late nc353
...@@ -361,8 +353,10 @@ module jp_channel#( ...@@ -361,8 +353,10 @@ module jp_channel#(
assign set_format_w = cmd_we && (cmd_a== CMPRS_FORMAT); assign set_format_w = cmd_we && (cmd_a== CMPRS_FORMAT);
assign set_color_saturation_w = cmd_we && (cmd_a== CMPRS_COLOR_SATURATION); assign set_color_saturation_w = cmd_we && (cmd_a== CMPRS_COLOR_SATURATION);
assign set_coring_w = cmd_we && (cmd_a== CMPRS_CORING_MODE); assign set_coring_w = cmd_we && (cmd_a== CMPRS_CORING_MODE);
assign set_interrupts_w = cmd_we && (cmd_a== CMPRS_INTERRUPTS);
assign set_tables_w = cmd_we && ((cmd_a & 6)== CMPRS_TABLES); assign set_tables_w = cmd_we && ((cmd_a & 6)== CMPRS_TABLES);
`ifdef USE_XCLK2X `ifdef USE_XCLK2X
// re-sync to posedge xclk2x // re-sync to posedge xclk2x
reg xrst2xn; reg xrst2xn;
...@@ -586,18 +580,23 @@ module jp_channel#( ...@@ -586,18 +580,23 @@ module jp_channel#(
.data (cmd_data), // output[31:0] .data (cmd_data), // output[31:0]
.we (cmd_we) // output .we (cmd_we) // output
); );
wire [2:0] status_data;
wire [4:0] status_data;
cmprs_status cmprs_status_i ( cmprs_status cmprs_status_i (
.mrst (mrst), // input
.mclk (mclk), // input .mclk (mclk), // input
.eof_written (eof_written_mclk), // input .eof_written (eof_written_mclk), // input
.stuffer_running (stuffer_running_mclk), // input .stuffer_running (stuffer_running_mclk), // input
.reading_frame (reading_frame), // input .reading_frame (reading_frame), // input
.status (status_data) // output[2:0] .set_interrupts (set_interrupts_w), // input
.data_in (cmd_data[1:0]), // input[1:0]
.status (status_data), // output[2:0]
.irq (irq) // output
); );
status_generate #( status_generate #(
.STATUS_REG_ADDR (CMPRS_STATUS_REG_ADDR), .STATUS_REG_ADDR (CMPRS_STATUS_REG_ADDR),
.PAYLOAD_BITS (3), .PAYLOAD_BITS (7),
.EXTRA_WORDS (1), .EXTRA_WORDS (1),
.EXTRA_REG_ADDR (CMPRS_HIFREQ_REG_ADDR) .EXTRA_REG_ADDR (CMPRS_HIFREQ_REG_ADDR)
...@@ -607,7 +606,7 @@ module jp_channel#( ...@@ -607,7 +606,7 @@ module jp_channel#(
.srst (mrst), // input .srst (mrst), // input
.we (set_status_w), // input .we (set_status_w), // input
.wd (cmd_data[7:0]), // input[7:0] .wd (cmd_data[7:0]), // input[7:0]
.status ({hifreq,status_data}), // input[2:0] .status ({hifreq,status_data,2'b0}), // input[2:0]
.ad (status_ad), // output[7:0] .ad (status_ad), // output[7:0]
.rq (status_rq), // output .rq (status_rq), // output
.start (status_start) // input .start (status_start) // input
......
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
* contains all the components and scripts required to completely simulate it * contains all the components and scripts required to completely simulate it
* with at least one of the Free Software programs. * with at least one of the Free Software programs.
*******************************************************************************/ *******************************************************************************/
parameter FPGA_VERSION = 32'h03930071; // Fixing AXI HP multiplexer xclk -0.083 -1.968 44 / 15163 (77.17%) parameter FPGA_VERSION = 32'h03930073; // Adding interrupts support
// parameter FPGA_VERSION = 32'h03930072; // Adding hact monitor bit 77.9%, failed timing
// parameter FPGA_VERSION = 32'h03930071; // Fixing AXI HP multiplexer xclk -0.083 -1.968 44 / 15163 (77.17%)
// parameter FPGA_VERSION = 32'h03930070; // Fixing HiSPi xclk -0.049 -0.291 17, utilization 15139 (77.04%) // parameter FPGA_VERSION = 32'h03930070; // Fixing HiSPi xclk -0.049 -0.291 17, utilization 15139 (77.04%)
// parameter FPGA_VERSION = 32'h0393006f; // Fixing JP4 mode - xcl -0.002 -0.004 2, utilization 15144 (77.07 %) // parameter FPGA_VERSION = 32'h0393006f; // Fixing JP4 mode - xcl -0.002 -0.004 2, utilization 15144 (77.07 %)
// parameter FPGA_VERSION = 32'h0393006f; // Fixing JP4 mode - xclk -0.209/-2.744/23, utilization 15127 (76.98%) // parameter FPGA_VERSION = 32'h0393006f; // Fixing JP4 mode - xclk -0.209/-2.744/23, utilization 15127 (76.98%)
......
...@@ -633,6 +633,7 @@ ...@@ -633,6 +633,7 @@
parameter CMPRS_FORMAT= 2, parameter CMPRS_FORMAT= 2,
parameter CMPRS_COLOR_SATURATION= 3, parameter CMPRS_COLOR_SATURATION= 3,
parameter CMPRS_CORING_MODE= 4, parameter CMPRS_CORING_MODE= 4,
parameter CMPRS_INTERRUPTS= 5,
parameter CMPRS_TABLES= 6, // 6..7 parameter CMPRS_TABLES= 6, // 6..7
parameter TABLE_QUANTIZATION_INDEX = 0, parameter TABLE_QUANTIZATION_INDEX = 0,
parameter TABLE_CORING_INDEX = 1, parameter TABLE_CORING_INDEX = 1,
...@@ -762,6 +763,7 @@ ...@@ -762,6 +763,7 @@
parameter CMDFRAMESEQ_CTRL = 31, parameter CMDFRAMESEQ_CTRL = 31,
parameter CMDFRAMESEQ_RST_BIT = 14, parameter CMDFRAMESEQ_RST_BIT = 14,
parameter CMDFRAMESEQ_RUN_BIT = 13, parameter CMDFRAMESEQ_RUN_BIT = 13,
parameter CMDFRAMESEQ_IRQ_BIT = 0,
parameter CMDSEQMUX_ADDR = 'h702, // only status control parameter CMDSEQMUX_ADDR = 'h702, // only status control
parameter CMDSEQMUX_MASK = 'h7ff, parameter CMDSEQMUX_MASK = 'h7ff,
......
This diff is collapsed.
...@@ -965,12 +965,89 @@ class X393Jpeg(object): ...@@ -965,12 +965,89 @@ class X393Jpeg(object):
ff d9 ff d9
""" """
""" """
cd /usr/local/verilog/; test_mcntrl.py @hargs
measure_all "*DI"
setup_all_sensors True None 0xf
#write_sensor_i2c 0 1 0 0x30700101
compressor_control all None None None None None 2
program_gamma all 0 0.57 0.04
write_sensor_i2c 0 1 0 0x030600b4
write_sensor_i2c 0 1 0 0x31c68400
write_sensor_i2c 0 1 0 0x306e9280
#write_sensor_i2c 0 1 0 0x30700002
write_sensor_i2c 0 1 0 0x301a001c
print_sensor_i2c 0 0x31c6 0xff 0x10 0
compressor_control 0 2
jpeg_write "img.jpeg" 0
jpeg_acquire_write
write_sensor_i2c 0 1 0 0x30700000
-------
setup_all_sensors True None 0xf
write_sensor_i2c 0 1 0 0x30700101
compressor_control all None None None None None 2
program_gamma all 0 0.57 0.04
write_sensor_i2c 0 1 0 0x030600b4
print_sensor_i2c 0 0x306 0xff 0x10 0
print_sensor_i2c 0 0x303a 0xff 0x10 0
print_sensor_i2c 0 0x301a 0xff 0x10 0
print_sensor_i2c 0 0x31c6 0xff 0x10 0
write_sensor_i2c 0 1 0 0x31c68400
print_sensor_i2c 0 0x31c6 0xff 0x10 0
print_sensor_i2c 0 0x306e 0xff 0x10 0
write_sensor_i2c 0 1 0 0x306e9280
write_sensor_i2c 0 1 0 0x30700002
write_sensor_i2c 0 1 0 0x301a001c
print_sensor_i2c 0 0x31c6 0xff 0x10 0
compressor_control 0 2
x393 +0.001s--> jpeg_write "img.jpeg" 0
http://192.168.0.7/imgsrv.py?y_quality=85&gamma=0.5&verbose=0&cmode=jpeg&bayer=2&expos=3000&flip_x=1&flip_y=1
JP46: demuxing... JP46: demuxing...
Corrupt JPEG data: bad Huffman code Corrupt JPEG data: bad Huffman code
Corrupt JPEG data: bad Huffman code Corrupt JPEG data: bad Huffman code
Corrupt JPEG data: bad Huffman code Corrupt JPEG data: bad Huffman code
def jpeg_acquire_write(self,
file_path = "img.jpeg",
channel = 0,
cmode = None, # vrlg.CMPRS_CBIT_CMODE_JPEG18, # read it from the saved
bayer = None,
y_quality = None,
c_quality = None,
portrait = None,
gamma = None, # 0.57,
black = None, # 0.04,
colorsat_blue = None, # 2.0, colorsat_blue, #0x180 # 0x90 for 1x
colorsat_red = None, # 2.0, colorsat_red, #0x16c, # 0xb6 for x1
server_root = "/www/pages/",
verbose = 1):
def print_sensor_i2c (self,
num_sensor,
reg_addr,
indx = 1,
sa7 = 0x48,
verbose = 1):
Read sequence of bytes available and print the result as a single hex number
@param num_sensor - sensor port number (0..3), or "all" - same to all sensors
@param reg_addr - register to read address 1/2 bytes (defined by previously set format)
@param indx - i2c command index in 1 256-entry table (defines here i2c delay, number of address bytes and number of data bytes)
@param sa7 - 7-bit i2c slave address
@param verbose - verbose level
print_sensor_i2c 0 0x306 0xff 0x10 0
#should be no MSB first (0x31c68400) #should be no MSB first (0x31c68400)
cd /usr/local/verilog/; test_mcntrl.py @hargs cd /usr/local/verilog/; test_mcntrl.py @hargs
......
...@@ -129,6 +129,7 @@ class X393Sensor(object): ...@@ -129,6 +129,7 @@ class X393Sensor(object):
status= self.get_status_sensor_io(num_sensor) status= self.get_status_sensor_io(num_sensor)
print ("print_status_sensor_io(%d):"%(num_sensor)) print ("print_status_sensor_io(%d):"%(num_sensor))
#last_in_line_1cyc_mclk, dout_valid_1cyc_mclk #last_in_line_1cyc_mclk, dout_valid_1cyc_mclk
"""
print (" last_in_line_1cyc_mclk = %d"%((status>>23) & 1)) print (" last_in_line_1cyc_mclk = %d"%((status>>23) & 1))
print (" dout_valid_1cyc_mclk = %d"%((status>>22) & 1)) print (" dout_valid_1cyc_mclk = %d"%((status>>22) & 1))
print (" alive_hist0_gr = %d"%((status>>21) & 1)) print (" alive_hist0_gr = %d"%((status>>21) & 1))
...@@ -140,10 +141,13 @@ class X393Sensor(object): ...@@ -140,10 +141,13 @@ class X393Sensor(object):
print (" vact_alive = %d"%((status>>15) & 1)) print (" vact_alive = %d"%((status>>15) & 1))
print (" hact_ext_alive = %d"%((status>>14) & 1)) print (" hact_ext_alive = %d"%((status>>14) & 1))
print (" hact_alive = %d"%((status>>13) & 1)) print (" hact_alive = %d"%((status>>13) & 1))
"""
print (" hact_run = %d"%((status>>13) & 1))
print (" locked_pxd_mmcm = %d"%((status>>12) & 1)) print (" locked_pxd_mmcm = %d"%((status>>12) & 1))
print (" clkin_pxd_stopped_mmcm = %d"%((status>>11) & 1)) print (" clkin_pxd_stopped_mmcm = %d"%((status>>11) & 1))
print (" clkfb_pxd_stopped_mmcm = %d"%((status>>10) & 1)) print (" clkfb_pxd_stopped_mmcm = %d"%((status>>10) & 1))
print (" ps_rdy = %d"%((status>> 9) & 1)) print (" xfpgadone = %d"%((status>> 9) & 1))
print (" ps_rdy = %d"%((status>> 8) & 1))
print (" ps_out = %d"%((status>> 0) & 0xff)) print (" ps_out = %d"%((status>> 0) & 0xff))
print (" xfpgatdo = %d"%((status>>25) & 1)) print (" xfpgatdo = %d"%((status>>25) & 1))
print (" senspgmin = %d"%((status>>24) & 1)) print (" senspgmin = %d"%((status>>24) & 1))
...@@ -788,6 +792,43 @@ class X393Sensor(object): ...@@ -788,6 +792,43 @@ class X393Sensor(object):
self.set_sensor_io_ctl (num_sensor = num_sensor, self.set_sensor_io_ctl (num_sensor = num_sensor,
set_delays = True) set_delays = True)
def set_sensor_io_dly_hispi (self,
num_sensor,
mmcm_phase = None,
lane0_dly = None,
lane1_dly = None,
lane2_dly = None,
lane3_dly = None):
"""
Set sensor port input delays and mmcm phase
@param num_sensor - sensor port number (0..3) or all, 'A'
@param mmcm_phase - MMCM clock phase
@param lane0_dly - delay in the lane0 (3 LSB are not used) // All 4 lane delays should be set simultaneously
@param lane1_dly - delay in the lane1 (3 LSB are not used)
@param lane2_dly - delay in the lane2 (3 LSB are not used)
@param lane3_dly - delay in the lane3 (3 LSB are not used))
"""
try:
if (num_sensor == all) or (num_sensor[0].upper() == "A"): #all is a built-in function
for num_sensor in range(4):
self.set_sensor_io_dly_hispi (num_sensor = num_sensor,
mmcm_phase = mmcm_phase,
lane0_dly = lane0_dly,
lane1_dly = lane1_dly,
lane2_dly = lane2_dly,
lane3_dly = lane3_dly)
return
except:
pass
reg_addr = (vrlg.SENSOR_GROUP_ADDR + num_sensor * vrlg.SENSOR_BASE_INC) + vrlg.SENSIO_RADDR + vrlg.SENSIO_DELAYS
try: # if any delay is None - do not set
dlys=(lane0_dly & 0xff) | ((lane1_dly & 0xff) << 8) | ((lane2_dly & 0xff) << 16) | ((lane3_dly & 0xff) << 24)
self.x393_axi_tasks.write_control_register(reg_addr + 2, dlys)
except:
pass
if not mmcm_phase is None:
self.x393_axi_tasks.write_control_register(reg_addr + 3, mmcm_phase & 0xff)
def set_sensor_hispi_lanes(self, def set_sensor_hispi_lanes(self,
num_sensor, num_sensor,
lane0 = 0, lane0 = 0,
......
...@@ -204,6 +204,9 @@ module sens_10398 #( ...@@ -204,6 +204,9 @@ module sens_10398 #(
reg [ PXD_CLK_DIV_BITS-1:0] pxd_clk_cntr; reg [ PXD_CLK_DIV_BITS-1:0] pxd_clk_cntr;
reg [1:0] prst_with_sens_mrst = 2'h3; // prst extended to include sensor reset and rst_mmcm reg [1:0] prst_with_sens_mrst = 2'h3; // prst extended to include sensor reset and rst_mmcm
wire async_prst_with_sens_mrst = ~imrst | rst_mmcm; // mclk domain wire async_prst_with_sens_mrst = ~imrst | rst_mmcm; // mclk domain
reg hact_r;
wire hact_mclk;
reg hact_alive;
assign status = { locked_pxd_mmcm, assign status = { locked_pxd_mmcm,
clkin_pxd_stopped_mmcm, clkfb_pxd_stopped_mmcm, xfpgadone, clkin_pxd_stopped_mmcm, clkfb_pxd_stopped_mmcm, xfpgadone,
...@@ -278,6 +281,10 @@ module sens_10398 #( ...@@ -278,6 +281,10 @@ module sens_10398 #(
if (mrst) gp_r[1] <= 0; if (mrst) gp_r[1] <= 0;
else if (set_ctrl_r && data_r[SENS_CTRL_GP1 + 1]) gp_r[1] <= data_r[SENS_CTRL_GP1]; else if (set_ctrl_r && data_r[SENS_CTRL_GP1 + 1]) gp_r[1] <= data_r[SENS_CTRL_GP1];
if (mrst || set_iclk_phase || set_idelays) hact_alive <= 0;
else if (hact_mclk) hact_alive <= 1;
end end
// generate (slow) clock for the sensor - it will be multiplied by the sensor VCO // generate (slow) clock for the sensor - it will be multiplied by the sensor VCO
...@@ -294,6 +301,8 @@ module sens_10398 #( ...@@ -294,6 +301,8 @@ module sens_10398 #(
if (async_prst_with_sens_mrst) prst_with_sens_mrst <= 2'h3; if (async_prst_with_sens_mrst) prst_with_sens_mrst <= 2'h3;
else if (prst) prst_with_sens_mrst <= 2'h3; else if (prst) prst_with_sens_mrst <= 2'h3;
else prst_with_sens_mrst <= prst_with_sens_mrst >> 1; else prst_with_sens_mrst <= prst_with_sens_mrst >> 1;
hact_r <= hact;
end end
cmd_deser #( cmd_deser #(
...@@ -315,7 +324,7 @@ module sens_10398 #( ...@@ -315,7 +324,7 @@ module sens_10398 #(
status_generate #( status_generate #(
.STATUS_REG_ADDR(SENSIO_STATUS_REG), .STATUS_REG_ADDR(SENSIO_STATUS_REG),
.PAYLOAD_BITS(15) // +3) // +STATUS_ALIVE_WIDTH) // STATUS_PAYLOAD_BITS) .PAYLOAD_BITS(15+1) // +3) // +STATUS_ALIVE_WIDTH) // STATUS_PAYLOAD_BITS)
) status_generate_sens_io_i ( ) status_generate_sens_io_i (
.rst (1'b0), // rst), // input .rst (1'b0), // rst), // input
.clk (mclk), // input .clk (mclk), // input
...@@ -323,7 +332,7 @@ module sens_10398 #( ...@@ -323,7 +332,7 @@ module sens_10398 #(
.we (set_status_r), // input .we (set_status_r), // input
.wd (data_r[7:0]), // input[7:0] .wd (data_r[7:0]), // input[7:0]
// .status ({status_alive,status}), // input[25:0] // .status ({status_alive,status}), // input[25:0]
.status (status), // input[25:0] .status ({hact_alive,status}), // input[15:0]
.ad (status_ad), // output[7:0] .ad (status_ad), // output[7:0]
.rq (status_rq), // output .rq (status_rq), // output
.start (status_start) // input .start (status_start) // input
...@@ -535,5 +544,16 @@ module sens_10398 #( ...@@ -535,5 +544,16 @@ module sens_10398 #(
.I(sns_shutter_done) // input .I(sns_shutter_done) // input
); );
// just to verify hact is active
pulse_cross_clock hact_mclk_i (
.rst (1'b0), // input
.src_clk (pclk), // input
.dst_clk (mclk), // input
.in_pulse (hact && !hact_r), // input
.out_pulse (hact_mclk), // output
.busy() // output
);
endmodule endmodule
...@@ -284,7 +284,8 @@ fifo_same_clock_fill #( .DATA_WIDTH(50),.DATA_DEPTH(2)) // read - 4, write - 3 ...@@ -284,7 +284,8 @@ fifo_same_clock_fill #( .DATA_WIDTH(50),.DATA_DEPTH(2)) // read - 4, write - 3
.over (), //waddr_over), // output reg .over (), //waddr_over), // output reg
.wcount (), //waddr_wcount), // output[3:0] reg .wcount (), //waddr_wcount), // output[3:0] reg
.rcount (), //waddr_rcount), // output[3:0] reg .rcount (), //waddr_rcount), // output[3:0] reg
.num_in_fifo(racount) // output[3:0] .wnum_in_fifo (racount), // output[3:0]
.rnum_in_fifo () // output[3:0]
); );
fifo_same_clock_fill #( .DATA_WIDTH(73),.DATA_DEPTH(7)) // read - 4, write - 32? fifo_same_clock_fill #( .DATA_WIDTH(73),.DATA_DEPTH(7)) // read - 4, write - 32?
...@@ -302,7 +303,8 @@ fifo_same_clock_fill #( .DATA_WIDTH(73),.DATA_DEPTH(7)) // read - 4, write - 3 ...@@ -302,7 +303,8 @@ fifo_same_clock_fill #( .DATA_WIDTH(73),.DATA_DEPTH(7)) // read - 4, write - 3
.over (), //waddr_over), .over (), //waddr_over),
.wcount (), //waddr_wcount), .wcount (), //waddr_wcount),
.rcount (), //waddr_rcount), .rcount (), //waddr_rcount),
.num_in_fifo(rcount) .wnum_in_fifo (),
.rnum_in_fifo (rcount)
); );
......
...@@ -104,6 +104,8 @@ Solved it! ...@@ -104,6 +104,8 @@ Solved it!
To make it work, I set the (AR/AW)CACHE=0x11 and (AR/AW)PROT=0x00. In the CDMA datasheet, these were the recommended values, which I confirmed with ChipScope, when attached to CDMA's master port. To make it work, I set the (AR/AW)CACHE=0x11 and (AR/AW)PROT=0x00. In the CDMA datasheet, these were the recommended values, which I confirmed with ChipScope, when attached to CDMA's master port.
The default values set by VHLS were 0x00 and 0x10 respectively, which is also the case in the last post. The default values set by VHLS were 0x00 and 0x10 respectively, which is also the case in the last post.
Alex Alex
UPDATE: Xilinx docs say that (AR/AW)CACHE is ignored
*/ */
reg [3:0] WrDataThreshold = 'hf; reg [3:0] WrDataThreshold = 'hf;
...@@ -315,24 +317,26 @@ fifo_same_clock_fill #( .DATA_WIDTH(50),.DATA_DEPTH(5)) // read - 4, write - 3 ...@@ -315,24 +317,26 @@ fifo_same_clock_fill #( .DATA_WIDTH(50),.DATA_DEPTH(5)) // read - 4, write - 3
.over (), //waddr_over), // output reg .over (), //waddr_over), // output reg
.wcount (), //waddr_wcount), // output[3:0] reg .wcount (), //waddr_wcount), // output[3:0] reg
.rcount (), //waddr_rcount), // output[3:0] reg .rcount (), //waddr_rcount), // output[3:0] reg
.num_in_fifo(wacount) // output[3:0] .wnum_in_fifo (wacount), // output[3:0]
.rnum_in_fifo () // output[3:0]
); );
fifo_same_clock_fill #( .DATA_WIDTH(79),.DATA_DEPTH(7)) fifo_same_clock_fill #( .DATA_WIDTH(79),.DATA_DEPTH(7))
wdata_i ( wdata_i (
.rst(rst), .rst (rst),
.clk(aclk), .clk (aclk),
.sync_rst (1'b0), .sync_rst (1'b0),
.we(wvalid && wready), .we (wvalid && wready),
.re(fifo_wd_rd), //start_write_burst_w), // wrong .re (fifo_wd_rd), //start_write_burst_w), // wrong
.data_in({wlast, wid[5:0], wstrb[7:0], wdata[63:0]}), .data_in ({wlast, wid[5:0], wstrb[7:0], wdata[63:0]}),
.data_out({wlast_out,wid_out[5:0], wstrb_out[7:0], wdata_out[63:0]}), .data_out ({wlast_out,wid_out[5:0], wstrb_out[7:0], wdata_out[63:0]}),
.nempty(w_nempty), .nempty (w_nempty),
.half_full(), //w_half_full), .half_full (), //w_half_full),
.under (), //wdata_under), // output reg .under (), //wdata_under), // output reg
.over (), //wdata_over), // output reg .over (), //wdata_over), // output reg
.wcount (), //wdata_wcount), // output[3:0] reg .wcount (), //wdata_wcount), // output[3:0] reg
.rcount (), //wdata_rcount), // output[3:0] reg .rcount (), //wdata_rcount), // output[3:0] reg
.num_in_fifo(wcount) // output[3:0] .wnum_in_fifo (wcount), // output[3:0]
.rnum_in_fifo () // output[3:0]
); );
// **** Write response channel **** // **** Write response channel ****
wire [ 1:0] bresp_value=2'b0; wire [ 1:0] bresp_value=2'b0;
...@@ -346,31 +350,32 @@ fifo_same_clock_fill #( .DATA_WIDTH(79),.DATA_DEPTH(7)) ...@@ -346,31 +350,32 @@ fifo_same_clock_fill #( .DATA_WIDTH(79),.DATA_DEPTH(7))
dly_16 #( dly_16 #(
.WIDTH(1) .WIDTH(1)
) bresp_dly_16_i ( ) bresp_dly_16_i (
.clk(aclk), // input .clk (aclk), // input
.rst(rst), // input .rst (rst), // input
.dly(sim_bresp_latency[3:0]), // input[3:0] .dly (sim_bresp_latency[3:0]), // input[3:0]
.din(last_confirmed_write), //fifo_wd_rd), // input[0:0] .din (last_confirmed_write), //fifo_wd_rd), // input[0:0]
.dout(fifo_wd_rd_dly) // output[0:0] .dout (fifo_wd_rd_dly) // output[0:0]
); );
// first FIFO for bresp - latency outside of the module // first FIFO for bresp - latency outside of the module
// wresp per burst, not per item ! // wresp per burst, not per item !
fifo_same_clock_fill #( .DATA_WIDTH(8),.DATA_DEPTH(5)) fifo_same_clock_fill #( .DATA_WIDTH(8),.DATA_DEPTH(5))
wresp_ext_i ( wresp_ext_i (
.rst(rst), .rst (rst),
.clk(aclk), .clk (aclk),
.sync_rst (1'b0), .sync_rst (1'b0),
.we(last_confirmed_write), // fifo_wd_rd), .we (last_confirmed_write), // fifo_wd_rd),
.re(fifo_wd_rd_dly), // not allowing RE next cycle after bvalid .re (fifo_wd_rd_dly), // not allowing RE next cycle after bvalid
.data_in({wid_out[5:0],bresp_value[1:0]}), .data_in ({wid_out[5:0],bresp_value[1:0]}),
.data_out({bid_in[5:0],bresp_in[1:0]}), .data_out ({bid_in[5:0],bresp_in[1:0]}),
.nempty(), .nempty (),
.half_full(), //), .half_full (), //),
.under (), //wresp_under), // output reg .under (), //wresp_under), // output reg
.over (), //wresp_over), // output reg .over (), //wresp_over), // output reg
.wcount (), //wresp_wcount), // output[3:0] reg .wcount (), //wresp_wcount), // output[3:0] reg
.rcount (), //wresp_rcount), // output[3:0] reg .rcount (), //wresp_rcount), // output[3:0] reg
.num_in_fifo() // wresp_num_in_fifo) // output[3:0] .wnum_in_fifo (), // wresp_num_in_fifo) // output[3:0]
.rnum_in_fifo () // wresp_num_in_fifo) // output[3:0]
); );
assign wresp_re=bready && bvalid; // && !was_wresp_re; assign wresp_re=bready && bvalid; // && !was_wresp_re;
...@@ -382,20 +387,21 @@ fifo_same_clock_fill #( .DATA_WIDTH(8),.DATA_DEPTH(5)) ...@@ -382,20 +387,21 @@ fifo_same_clock_fill #( .DATA_WIDTH(8),.DATA_DEPTH(5))
// second wresp FIFO (does it exist in the actual module)? // second wresp FIFO (does it exist in the actual module)?
fifo_same_clock_fill #( .DATA_WIDTH(8),.DATA_DEPTH(5)) fifo_same_clock_fill #( .DATA_WIDTH(8),.DATA_DEPTH(5))
wresp_i ( wresp_i (
.rst(rst), .rst (rst),
.clk(aclk), .clk (aclk),
.sync_rst (1'b0), .sync_rst (1'b0),
.we(fifo_wd_rd_dly), .we (fifo_wd_rd_dly),
.re(wresp_re), // not allowing RE next cycle after bvalid .re (wresp_re), // not allowing RE next cycle after bvalid
.data_in({bid_in[5:0],bresp_in[1:0]}), .data_in ({bid_in[5:0],bresp_in[1:0]}),
.data_out({bid[5:0],bresp[1:0]}), .data_out ({bid[5:0],bresp[1:0]}),
.nempty(), //bvalid), .nempty (), //bvalid),
.half_full(), //), .half_full (), //),
.under (), //wresp_under), // output reg .under (), //wresp_under), // output reg
.over (), //wresp_over), // output reg .over (), //wresp_over), // output reg
.wcount (), //wresp_wcount), // output[3:0] reg .wcount (), //wresp_wcount), // output[3:0] reg
.rcount (), //wresp_rcount), // output[3:0] reg .rcount (), //wresp_rcount), // output[3:0] reg
.num_in_fifo(wresp_num_in_fifo) // wresp_num_in_fifo) // output[3:0] .wnum_in_fifo (), // wresp_num_in_fifo) // output[3:0]
.rnum_in_fifo (wresp_num_in_fifo) // wresp_num_in_fifo) // output[3:0]
); );
endmodule endmodule
......
...@@ -264,29 +264,31 @@ fifo_same_clock_fill #( .DATA_WIDTH(50),.DATA_DEPTH(AW_FIFO_DEPTH)) // read - ...@@ -264,29 +264,31 @@ fifo_same_clock_fill #( .DATA_WIDTH(50),.DATA_DEPTH(AW_FIFO_DEPTH)) // read -
.data_in ({awid[5:0], awburst[1:0], awsize[1:0], awlen[3:0], awaddr[31:0], awqos[3:0]}), .data_in ({awid[5:0], awburst[1:0], awsize[1:0], awlen[3:0], awaddr[31:0], awqos[3:0]}),
.data_out ({awid_out[5:0], awburst_out[1:0],awsize_out[1:0],awlen_out[3:0],awaddr_out[31:0], sim_wr_qos[3:0]}), .data_out ({awid_out[5:0], awburst_out[1:0],awsize_out[1:0],awlen_out[3:0],awaddr_out[31:0], sim_wr_qos[3:0]}),
.nempty (aw_nempty), .nempty (aw_nempty),
.half_full (), //aw_half_full), .half_full (), // aw_half_full),
.under (), //waddr_under), // output reg .under (), // waddr_under), // output reg
.over (), //waddr_over), // output reg .over (), // waddr_over), // output reg
.wcount (), //waddr_wcount), // output[3:0] reg .wcount (), // waddr_wcount), // output[3:0] reg
.rcount (), //waddr_rcount), // output[3:0] reg .rcount (), // waddr_rcount), // output[3:0] reg
.num_in_fifo(wacount) // output[3:0] .wnum_in_fifo (wacount), // output[3:0]
.rnum_in_fifo () // output[3:0]
); );
fifo_same_clock_fill #( .DATA_WIDTH(43),.DATA_DEPTH(W_FIFO_DEPTH)) fifo_same_clock_fill #( .DATA_WIDTH(43), .DATA_DEPTH(W_FIFO_DEPTH))
wdata_i ( wdata_i (
.rst(rst), .rst (rst),
.clk(aclk), .clk (aclk),
.sync_rst (1'b0), .sync_rst (1'b0),
.we(wvalid && wready), .we (wvalid && wready),
.re(fifo_wd_rd), //start_write_burst_w), // wrong .re (fifo_wd_rd), //start_write_burst_w), // wrong
.data_in({wlast, wid[5:0], wstrb[3:0], wdata[31:0]}), .data_in ({wlast, wid[5:0], wstrb[3:0], wdata[31:0]}),
.data_out({wlast_out,wid_out[5:0], wstrb_out[3:0], wdata_out[31:0]}), .data_out ({wlast_out,wid_out[5:0], wstrb_out[3:0], wdata_out[31:0]}),
.nempty(w_nempty), .nempty (w_nempty),
.half_full(), //w_half_full), .half_full (), //w_half_full),
.under (), //wdata_under), // output reg .under (), //wdata_under), // output reg
.over (), //wdata_over), // output reg .over (), //wdata_over), // output reg
.wcount (), //wdata_wcount), // output[3:0] reg .wcount (), //wdata_wcount), // output[3:0] reg
.rcount (), //wdata_rcount), // output[3:0] reg .rcount (), //wdata_rcount), // output[3:0] reg
.num_in_fifo(wcount) // output[3:0] .wnum_in_fifo (wcount), // output[3:0]
.rnum_in_fifo () // output[3:0]
); );
// **** Write response channel **** // **** Write response channel ****
wire [ 1:0] bresp_value=2'b0; wire [ 1:0] bresp_value=2'b0;
...@@ -311,20 +313,21 @@ fifo_same_clock_fill #( .DATA_WIDTH(43),.DATA_DEPTH(W_FIFO_DEPTH)) ...@@ -311,20 +313,21 @@ fifo_same_clock_fill #( .DATA_WIDTH(43),.DATA_DEPTH(W_FIFO_DEPTH))
// wresp per burst, not per item ! // wresp per burst, not per item !
fifo_same_clock_fill #( .DATA_WIDTH(8),.DATA_DEPTH(5)) fifo_same_clock_fill #( .DATA_WIDTH(8),.DATA_DEPTH(5))
wresp_ext_i ( wresp_ext_i (
.rst(rst), .rst (rst),
.clk(aclk), .clk (aclk),
.sync_rst (1'b0), .sync_rst (1'b0),
.we(last_confirmed_write), // fifo_wd_rd), .we (last_confirmed_write), // fifo_wd_rd),
.re(fifo_wd_rd_dly), // not allowing RE next cycle after bvalid .re (fifo_wd_rd_dly), // not allowing RE next cycle after bvalid
.data_in({wid_out[5:0],bresp_value[1:0]}), .data_in ({wid_out[5:0],bresp_value[1:0]}),
.data_out({bid_in[5:0],bresp_in[1:0]}), .data_out ({bid_in[5:0],bresp_in[1:0]}),
.nempty(), .nempty (),
.half_full(), //), .half_full (), //),
.under (), //wresp_under), // output reg .under (), //wresp_under), // output reg
.over (), //wresp_over), // output reg .over (), //wresp_over), // output reg
.wcount (), //wresp_wcount), // output[3:0] reg .wcount (), //wresp_wcount), // output[3:0] reg
.rcount (), //wresp_rcount), // output[3:0] reg .rcount (), //wresp_rcount), // output[3:0] reg
.num_in_fifo() // wresp_num_in_fifo) // output[3:0] .wnum_in_fifo (), // wresp_num_in_fifo) // output[3:0]
.rnum_in_fifo () // wresp_num_in_fifo) // output[3:0]
); );
assign wresp_re=bready && bvalid; // && !was_wresp_re; assign wresp_re=bready && bvalid; // && !was_wresp_re;
...@@ -336,20 +339,21 @@ fifo_same_clock_fill #( .DATA_WIDTH(8),.DATA_DEPTH(5)) ...@@ -336,20 +339,21 @@ fifo_same_clock_fill #( .DATA_WIDTH(8),.DATA_DEPTH(5))
// second wresp FIFO (does it exist in the actual module)? // second wresp FIFO (does it exist in the actual module)?
fifo_same_clock_fill #( .DATA_WIDTH(8),.DATA_DEPTH(5)) fifo_same_clock_fill #( .DATA_WIDTH(8),.DATA_DEPTH(5))
wresp_i ( wresp_i (
.rst(rst), .rst (rst),
.clk(aclk), .clk (aclk),
.sync_rst (1'b0), .sync_rst (1'b0),
.we(fifo_wd_rd_dly), .we (fifo_wd_rd_dly),
.re(wresp_re), // not allowing RE next cycle after bvalid .re (wresp_re), // not allowing RE next cycle after bvalid
.data_in({bid_in[5:0],bresp_in[1:0]}), .data_in ({bid_in[5:0],bresp_in[1:0]}),
.data_out({bid[5:0],bresp[1:0]}), .data_out ({bid[5:0],bresp[1:0]}),
.nempty(), //bvalid), .nempty (), //bvalid),
.half_full(), //), .half_full (), //),
.under (), //wresp_under), // output reg .under (), //wresp_under), // output reg
.over (), //wresp_over), // output reg .over (), //wresp_over), // output reg
.wcount (), //wresp_wcount), // output[3:0] reg .wcount (), //wresp_wcount), // output[3:0] reg
.rcount (), //wresp_rcount), // output[3:0] reg .rcount (), //wresp_rcount), // output[3:0] reg
.num_in_fifo(wresp_num_in_fifo) // wresp_num_in_fifo) // output[3:0] .wnum_in_fifo (), // wresp_num_in_fifo) // output[3:0]
.rnum_in_fifo (wresp_num_in_fifo) // wresp_num_in_fifo) // output[3:0]
); );
endmodule endmodule
......
...@@ -54,6 +54,8 @@ ...@@ -54,6 +54,8 @@
// [14] - reset all FIFO (takes 32 clock pulses), also - stops seq until run command // [14] - reset all FIFO (takes 32 clock pulses), also - stops seq until run command
// [13:12] - 3 - run seq, 2 - stop seq , 1,0 - no change to run state // [13:12] - 3 - run seq, 2 - stop seq , 1,0 - no change to run state
// New - [1:0] - 0: NOP, 1: clear IRQ, 2 - Clear IE, 3: set IE
module cmd_frame_sequencer#( module cmd_frame_sequencer#(
parameter CMDFRAMESEQ_ADDR= 'h780, parameter CMDFRAMESEQ_ADDR= 'h780,
parameter CMDFRAMESEQ_MASK= 'h7e0, parameter CMDFRAMESEQ_MASK= 'h7e0,
...@@ -63,21 +65,25 @@ module cmd_frame_sequencer#( ...@@ -63,21 +65,25 @@ module cmd_frame_sequencer#(
parameter CMDFRAMESEQ_REL = 16, parameter CMDFRAMESEQ_REL = 16,
parameter CMDFRAMESEQ_CTRL = 31, parameter CMDFRAMESEQ_CTRL = 31,
parameter CMDFRAMESEQ_RST_BIT = 14, parameter CMDFRAMESEQ_RST_BIT = 14,
parameter CMDFRAMESEQ_RUN_BIT = 13 parameter CMDFRAMESEQ_RUN_BIT = 13,
parameter CMDFRAMESEQ_IRQ_BIT = 0 // [1:0] used
)( )(
input mrst, input mrst,
input mclk, // for command/status input mclk, // for command/status
// programming interface // programming interface
input [7:0] cmd_ad, // byte-serial command address/data (up to 6 bytes: AL-AH-D0-D1-D2-D3 input [7:0] cmd_ad, // byte-serial command address/data (up to 6 bytes: AL-AH-D0-D1-D2-D3
input cmd_stb, // strobe (with first byte) for the command a/d input cmd_stb, // strobe (with first byte) for the command a/d
// frame syn and frame number // frame sync and frame number
input frame_sync, // @posedge mclk input frame_sync, // @posedge mclk
output [ 3:0] frame_no, // @posedge mclk output [ 3:0] frame_no, // @posedge mclk
// command mux interface // command mux interface
output [AXI_WR_ADDR_BITS-1:0] waddr, // write address, valid with wr_en_out output [AXI_WR_ADDR_BITS-1:0] waddr, // write address, valid with wr_en_out
output valid, // output data valid output valid, // output data valid
output [31:0] wdata, // write data, valid with waddr_out and wr_en_out output [31:0] wdata, // write data, valid with waddr_out and wr_en_out
input ackn // command sequencer address/data accepted input ackn, // command sequencer address/data accepted
// Interrupt mask, status, request
output is, // interrupt status (not masked)
output im // interrupt mask
); );
localparam PNTR_WIDH = (CMDFRAMESEQ_DEPTH > 32) ?((CMDFRAMESEQ_DEPTH > 64) ? 7 : 6) : 5; localparam PNTR_WIDH = (CMDFRAMESEQ_DEPTH > 32) ?((CMDFRAMESEQ_DEPTH > 64) ? 7 : 6) : 5;
wire [4:0] cmd_a; // 3 cycles before data wire [4:0] cmd_a; // 3 cycles before data
...@@ -133,6 +139,16 @@ module cmd_frame_sequencer#( ...@@ -133,6 +139,16 @@ module cmd_frame_sequencer#(
reg valid_r; reg valid_r;
wire [63:0] cmdseq_do; // output data from the sequence wire [63:0] cmdseq_do; // output data from the sequence
wire [1:0] irq_bits = cmd_data[CMDFRAMESEQ_IRQ_BIT +: 2];
reg is_r; // interrupt status (not masked)
reg im_r; // interrtupt mask
wire irq_ctrl;
assign is = is_r; // interrupt status (not masked)
assign im = im_r; // interrtupt mask
assign irq_ctrl = cmd_we_ctl_r[2] && (|irq_bits);
assign waddr = cmdseq_do[32 +:AXI_WR_ADDR_BITS]; assign waddr = cmdseq_do[32 +:AXI_WR_ADDR_BITS];
assign wdata = cmdseq_do[31:0]; assign wdata = cmdseq_do[31:0];
assign seq_cmd_ra = {page_r,rpointer}; assign seq_cmd_ra = {page_r,rpointer};
...@@ -152,6 +168,18 @@ module cmd_frame_sequencer#( ...@@ -152,6 +168,18 @@ module cmd_frame_sequencer#(
assign commands_pending = rpointer != fifo_wr_pointers_outr_r; // only look at the current page different pages will trigger page increment first assign commands_pending = rpointer != fifo_wr_pointers_outr_r; // only look at the current page different pages will trigger page increment first
assign pre_cmd_seq_w = commands_pending & ~(|page_r_inc) & seq_enrun; assign pre_cmd_seq_w = commands_pending & ~(|page_r_inc) & seq_enrun;
assign valid = valid_r; assign valid = valid_r;
// parameter CMDFRAMESEQ_IRQ_BIT = 0,
// parameter CMDFRAMESEQ_IRQ_BITS = 2
always @ (posedge mclk) begin
if (mrst) is_r <= 0;
else if (frame_sync) is_r <= 1;
else if (irq_ctrl && (irq_bits == 2'b01)) is_r <= 0;
if (mrst) im_r <= 0;
else if (irq_ctrl && irq_bits[1]) im_r <= irq_bits[0];
end
always @ (posedge mclk) begin always @ (posedge mclk) begin
if (mrst) por <= 0; if (mrst) por <= 0;
else por <= {por[1:0], 1'b1}; else por <= {por[1:0], 1'b1};
......
...@@ -55,24 +55,32 @@ module cmd_seq_mux#( ...@@ -55,24 +55,32 @@ module cmd_seq_mux#(
input wr_en0, // write enable input wr_en0, // write enable
input [31:0] wdata0, // write data, valid with waddr_out and wr_en_out input [31:0] wdata0, // write data, valid with waddr_out and wr_en_out
output ackn0, // command sequencer address/data accepted output ackn0, // command sequencer address/data accepted
input is0, // interrupt status (not masked)
input im0, // interrupt mask
// Sensor channel 1 // Sensor channel 1
input [ 3:0] frame_num1, // @posedge mclk input [ 3:0] frame_num1, // @posedge mclk
input [AXI_WR_ADDR_BITS-1:0] waddr1, // write address, valid with wr_en_out input [AXI_WR_ADDR_BITS-1:0] waddr1, // write address, valid with wr_en_out
input wr_en1, // write enable input wr_en1, // write enable
input [31:0] wdata1, // write data, valid with waddr_out and wr_en_out input [31:0] wdata1, // write data, valid with waddr_out and wr_en_out
output ackn1, // command sequencer address/data accepted output ackn1, // command sequencer address/data accepted
input is1, // interrupt status (not masked)
input im1, // interrupt mask
// Sensor channel 2 // Sensor channel 2
input [ 3:0] frame_num2, // @posedge mclk input [ 3:0] frame_num2, // @posedge mclk
input [AXI_WR_ADDR_BITS-1:0] waddr2, // write address, valid with wr_en_out input [AXI_WR_ADDR_BITS-1:0] waddr2, // write address, valid with wr_en_out
input wr_en2, // write enable input wr_en2, // write enable
input [31:0] wdata2, // write data, valid with waddr_out and wr_en_out input [31:0] wdata2, // write data, valid with waddr_out and wr_en_out
output ackn2, // command sequencer address/data accepted output ackn2, // command sequencer address/data accepted
input is2, // interrupt status (not masked)
input im2, // interrupt mask
// Sensor channel 3 // Sensor channel 3
input [ 3:0] frame_num3, // @posedge mclk input [ 3:0] frame_num3, // @posedge mclk
input [AXI_WR_ADDR_BITS-1:0] waddr3, // write address, valid with wr_en_out input [AXI_WR_ADDR_BITS-1:0] waddr3, // write address, valid with wr_en_out
input wr_en3, // write enable input wr_en3, // write enable
input [31:0] wdata3, // write data, valid with waddr_out and wr_en_out input [31:0] wdata3, // write data, valid with waddr_out and wr_en_out
output ackn3, // command sequencer address/data accepted output ackn3, // command sequencer address/data accepted
input is3, // interrupt status (not masked)
input im3, // interrupt mask
// mux output // mux output
output reg [AXI_WR_ADDR_BITS-1:0] waddr_out, // write address, valid with wr_en_out output reg [AXI_WR_ADDR_BITS-1:0] waddr_out, // write address, valid with wr_en_out
output wr_en_out, // write enable output wr_en_out, // write enable
...@@ -89,6 +97,9 @@ module cmd_seq_mux#( ...@@ -89,6 +97,9 @@ module cmd_seq_mux#(
wire ackn_w; //pre-acknowledge of one of the channels wire ackn_w; //pre-acknowledge of one of the channels
reg [3:0] ackn_r; reg [3:0] ackn_r;
wire [3:0] is = {is[3], is[2], is[1], is[0]};
wire [3:0] im = {im[3], im[2], im[1], im[0]};
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], 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[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], wr_en[2], wr_en[1] & ~(|wr_en[3:2]) & wr_en[0], wr_en[0] & ~(|wr_en[3:2]),
...@@ -164,7 +175,7 @@ module cmd_seq_mux#( ...@@ -164,7 +175,7 @@ module cmd_seq_mux#(
status_generate #( status_generate #(
.STATUS_REG_ADDR (CMDSEQMUX_STATUS), .STATUS_REG_ADDR (CMDSEQMUX_STATUS),
.PAYLOAD_BITS (18), .PAYLOAD_BITS (26),
.REGISTER_STATUS (1) .REGISTER_STATUS (1)
) status_generate_cmd_seq_mux_i ( ) status_generate_cmd_seq_mux_i (
.rst (1'b0), //rst), // input .rst (1'b0), //rst), // input
...@@ -172,7 +183,7 @@ module cmd_seq_mux#( ...@@ -172,7 +183,7 @@ module cmd_seq_mux#(
.srst (mrst), // input .srst (mrst), // input
.we (cmd_status), // input .we (cmd_status), // input
.wd (cmd_data[7:0]), // input[7:0] .wd (cmd_data[7:0]), // input[7:0]
.status ({frame_num3, frame_num2, frame_num1, frame_num0, 2'b0}), // input[18:0] // 2 LSBs - may add "real" status .status ({im, is, frame_num3, frame_num2, frame_num1, frame_num0, 2'b0}), // input[18:0] // 2 LSBs - may add "real" status
.ad (status_ad), // output[7:0] .ad (status_ad), // output[7:0]
.rq (status_rq), // output .rq (status_rq), // output
.start (status_start) // input .start (status_start) // input
......
...@@ -53,7 +53,8 @@ module fifo_same_clock_fill ...@@ -53,7 +53,8 @@ module fifo_same_clock_fill
output reg over, // overwritten output reg over, // overwritten
output reg [DATA_DEPTH-1:0] wcount, output reg [DATA_DEPTH-1:0] wcount,
output reg [DATA_DEPTH-1:0] rcount, output reg [DATA_DEPTH-1:0] rcount,
output [DATA_DEPTH: 0] num_in_fifo output [DATA_DEPTH: 0] wnum_in_fifo, // number of items in FIFO on write side
output [DATA_DEPTH: 0] rnum_in_fifo // number of items in FIFO on read side
); );
localparam integer DATA_2DEPTH=(1<<DATA_DEPTH)-1; localparam integer DATA_2DEPTH=(1<<DATA_DEPTH)-1;
//ISExst: FF/Latch ddrc_test01.axibram_write_i.waddr_i.fill[4] has a constant value of 0 in block <ddrc_test01>. This FF/Latch will be trimmed during the optimization process. //ISExst: FF/Latch ddrc_test01.axibram_write_i.waddr_i.fill[4] has a constant value of 0 in block <ddrc_test01>. This FF/Latch will be trimmed during the optimization process.
...@@ -61,38 +62,45 @@ module fifo_same_clock_fill ...@@ -61,38 +62,45 @@ module fifo_same_clock_fill
//ISExst: FF/Latch ddrc_test01.axibram_write_i.wdata_i.fill[4] has a constant value of 0 in block <ddrc_test01>. This FF/Latch will be trimmed during the optimization process. //ISExst: FF/Latch ddrc_test01.axibram_write_i.wdata_i.fill[4] has a constant value of 0 in block <ddrc_test01>. This FF/Latch will be trimmed during the optimization process.
// Do not understand - why? // Do not understand - why?
reg [DATA_DEPTH: 0] fill=0; // RAM fill reg [DATA_DEPTH: 0] fill=0; // RAM fill
reg [DATA_DEPTH: 0] fifo_fill=0; // FIFO (RAM+reg) fill reg [DATA_DEPTH: 0] wfifo_fill=0; // FIFO (RAM+reg) fill - total number in FIFO
reg [DATA_DEPTH: 0] rfifo_fill=0; // number in FIFO, ready to be read out
reg [DATA_WIDTH-1:0] inreg; reg [DATA_WIDTH-1:0] inreg;
reg [DATA_WIDTH-1:0] outreg; reg [DATA_WIDTH-1:0] outreg;
reg [DATA_DEPTH-1:0] ra; reg [DATA_DEPTH-1:0] ra;
reg [DATA_DEPTH-1:0] wa; reg [DATA_DEPTH-1:0] wa;
wire [DATA_DEPTH:0] next_fill; wire [DATA_DEPTH:0] next_fill;
reg wem; reg [1:0] wem;
wire rem; wire rem;
reg out_full=0; //output register full reg out_full=0; //output register full
reg [DATA_WIDTH-1:0] ram [0:DATA_2DEPTH]; reg [DATA_WIDTH-1:0] ram [0:DATA_2DEPTH];
reg ram_nempty; reg ram_nempty;
assign next_fill = fill[DATA_DEPTH:0]+((wem && ~rem)?1:((~wem && rem && ram_nempty)?-1:0)); assign next_fill = fill[DATA_DEPTH:0]+((wem[0] && ~rem)?1:((~wem[0] && rem && ram_nempty)?-1:0));
assign rem= ram_nempty && (re || !out_full); assign rem= ram_nempty && (re || !out_full);
assign data_out=outreg; assign data_out=outreg;
assign nempty=out_full; assign nempty=out_full;
// assign num_in_fifo=fill[DATA_DEPTH:0]; // assign num_in_fifo=fill[DATA_DEPTH:0];
assign num_in_fifo=fifo_fill[DATA_DEPTH:0]; assign wnum_in_fifo=wfifo_fill[DATA_DEPTH:0];
assign rnum_in_fifo=rfifo_fill[DATA_DEPTH:0];
always @ (posedge clk or posedge rst) begin always @ (posedge clk or posedge rst) begin
if (rst) fill <= 0; if (rst) fill <= 0;
else if (sync_rst) fill <= 0; else if (sync_rst) fill <= 0;
else fill <= next_fill; else fill <= next_fill;
if (rst) fifo_fill <= 0; if (rst) wfifo_fill <= 0;
else if (sync_rst) fifo_fill <= 0; else if (sync_rst) wfifo_fill <= 0;
else if ( we && !re) fifo_fill <= fifo_fill+1; else if ( we && !re) wfifo_fill <= wfifo_fill+1;
else if (!we && re) fifo_fill <= fifo_fill-1; else if (!we && re) wfifo_fill <= wfifo_fill-1;
if (rst) rfifo_fill <= 0; // pessimistic, all writes are delayed by 2
else if (sync_rst) rfifo_fill <= 0;
else if ( wem[1] && !re) rfifo_fill <= rfifo_fill+1;
else if (!wem[1] && re) rfifo_fill <= rfifo_fill-1;
if (rst) wem <= 0; if (rst) wem <= 0;
else if (sync_rst) wem <= 0; else if (sync_rst) wem <= 0;
else wem <= we; else wem <= {wem[0], we};
if (rst) ram_nempty <= 0; if (rst) ram_nempty <= 0;
else if (sync_rst) ram_nempty <= 0; else if (sync_rst) ram_nempty <= 0;
...@@ -100,7 +108,7 @@ module fifo_same_clock_fill ...@@ -100,7 +108,7 @@ module fifo_same_clock_fill
if (rst) wa <= 0; if (rst) wa <= 0;
else if (sync_rst) wa <= 0; else if (sync_rst) wa <= 0;
else if (wem) wa <= wa+1; else if (wem[0]) wa <= wa+1;
if (rst) ra <= 0; if (rst) ra <= 0;
else if (sync_rst) ra <= 0; else if (sync_rst) ra <= 0;
...@@ -123,12 +131,13 @@ module fifo_same_clock_fill ...@@ -123,12 +131,13 @@ module fifo_same_clock_fill
// no reset elements // no reset elements
always @ (posedge clk) begin always @ (posedge clk) begin
half_full <=(fill & (1<<(DATA_DEPTH-1)))!=0; half_full <=(fill & (1<<(DATA_DEPTH-1)))!=0;
if (wem) ram[wa] <= inreg;
if (wem[0]) ram[wa] <= inreg;
if (we) inreg <= data_in; if (we) inreg <= data_in;
if (rem) outreg <= ram[ra]; if (rem) outreg <= ram[ra];
// under <= ~we & re & ~nempty; // underrun error
// over <= we & ~re & (fill == (1<< (DATA_DEPTH-1))); // overrun error
under <= re & ~nempty; // underrun error under <= re & ~nempty; // underrun error
over <= wem & ~rem & fill[DATA_DEPTH] & ~fill[DATA_DEPTH-1]; // overrun error over <= wem[0] & ~rem & fill[DATA_DEPTH] & ~fill[DATA_DEPTH-1]; // overrun error
end end
endmodule endmodule
...@@ -299,7 +299,9 @@ module x393 #( ...@@ -299,7 +299,9 @@ module x393 #(
wire [3:0] frseq_valid; wire [3:0] frseq_valid;
wire [127:0] frseq_wdata; wire [127:0] frseq_wdata;
wire [3:0] frseq_ackn; wire [3:0] frseq_ackn;
wire [3:0] frseq_is;
wire [3:0] frseq_im;
wire [3:0] frseq_irq = frseq_is & frseq_im; // frame interrupts
// parallel address/data - where higher bandwidth (single-cycle) is needed // parallel address/data - where higher bandwidth (single-cycle) is needed
wire [AXI_WR_ADDR_BITS-1:0] par_waddr; wire [AXI_WR_ADDR_BITS-1:0] par_waddr;
...@@ -521,6 +523,9 @@ module x393 #( ...@@ -521,6 +523,9 @@ module x393 #(
// Compressor signals for interrupts generation // Compressor signals for interrupts generation
wire [3:0] eof_written_mclk; // output // SuppressThisWarning VEditor - (yet) unused wire [3:0] eof_written_mclk; // output // SuppressThisWarning VEditor - (yet) unused
wire [3:0] stuffer_done_mclk; // output// SuppressThisWarning VEditor - (yet) unused wire [3:0] stuffer_done_mclk; // output// SuppressThisWarning VEditor - (yet) unused
wire [3:0] cmprs_irq; // compressor done, data confirmed written to memory)
// Compressor frame synchronization // Compressor frame synchronization
// GPIO internal signals (for camera GPIOs, not Zynq PS GPIO) // GPIO internal signals (for camera GPIOs, not Zynq PS GPIO)
...@@ -813,7 +818,8 @@ assign axi_grst = axi_rst_pre; ...@@ -813,7 +818,8 @@ assign axi_grst = axi_rst_pre;
.CMDFRAMESEQ_REL (CMDFRAMESEQ_REL), .CMDFRAMESEQ_REL (CMDFRAMESEQ_REL),
.CMDFRAMESEQ_CTRL (CMDFRAMESEQ_CTRL), .CMDFRAMESEQ_CTRL (CMDFRAMESEQ_CTRL),
.CMDFRAMESEQ_RST_BIT (CMDFRAMESEQ_RST_BIT), .CMDFRAMESEQ_RST_BIT (CMDFRAMESEQ_RST_BIT),
.CMDFRAMESEQ_RUN_BIT (CMDFRAMESEQ_RUN_BIT) .CMDFRAMESEQ_RUN_BIT (CMDFRAMESEQ_RUN_BIT),
.CMDFRAMESEQ_IRQ_BIT (CMDFRAMESEQ_IRQ_BIT)
) cmd_frame_sequencer_i ( ) cmd_frame_sequencer_i (
.mrst (mrst), // input .mrst (mrst), // input
.mclk (mclk), // input .mclk (mclk), // input
...@@ -824,7 +830,10 @@ assign axi_grst = axi_rst_pre; ...@@ -824,7 +830,10 @@ assign axi_grst = axi_rst_pre;
.waddr (frseq_waddr[i * AXI_WR_ADDR_BITS +: AXI_WR_ADDR_BITS]), // output[13:0] .waddr (frseq_waddr[i * AXI_WR_ADDR_BITS +: AXI_WR_ADDR_BITS]), // output[13:0]
.valid (frseq_valid[i]), // output .valid (frseq_valid[i]), // output
.wdata (frseq_wdata[i * 32 +: 32]), // output[31:0] .wdata (frseq_wdata[i * 32 +: 32]), // output[31:0]
.ackn (frseq_ackn[i]) // input .ackn (frseq_ackn[i]), // input
.is (frseq_is[i]), // output
.im (frseq_im[i]) // output
); );
end end
endgenerate endgenerate
...@@ -848,24 +857,33 @@ assign axi_grst = axi_rst_pre; ...@@ -848,24 +857,33 @@ assign axi_grst = axi_rst_pre;
.wr_en0 (frseq_valid[0]), // input .wr_en0 (frseq_valid[0]), // input
.wdata0 (frseq_wdata[0 * 32 +: 32]), // input[31:0] .wdata0 (frseq_wdata[0 * 32 +: 32]), // input[31:0]
.ackn0 (frseq_ackn[0]), // output .ackn0 (frseq_ackn[0]), // output
.is0 (frseq_is[0]), // input
.im0 (frseq_im[0]), // input
.frame_num1 (frame_num[1 * NUM_FRAME_BITS +: 4]), // input[3:0] Use 4 bits even if NUM_FRAME_BITS > 4 .frame_num1 (frame_num[1 * NUM_FRAME_BITS +: 4]), // input[3:0] Use 4 bits even if NUM_FRAME_BITS > 4
.waddr1 (frseq_waddr[1 * AXI_WR_ADDR_BITS +: AXI_WR_ADDR_BITS]), // input[13:0] .waddr1 (frseq_waddr[1 * AXI_WR_ADDR_BITS +: AXI_WR_ADDR_BITS]), // input[13:0]
.wr_en1 (frseq_valid[1]), // input .wr_en1 (frseq_valid[1]), // input
.wdata1 (frseq_wdata[1 * 32 +: 32]), // input[31:0] .wdata1 (frseq_wdata[1 * 32 +: 32]), // input[31:0]
.ackn1 (frseq_ackn[1]), // output .ackn1 (frseq_ackn[1]), // output
.is1 (frseq_is[1]), // input
.im1 (frseq_im[1]), // input
.frame_num2 (frame_num[2 * NUM_FRAME_BITS +: 4]), // input[3:0] Use 4 bits even if NUM_FRAME_BITS > 4 .frame_num2 (frame_num[2 * NUM_FRAME_BITS +: 4]), // input[3:0] Use 4 bits even if NUM_FRAME_BITS > 4
.waddr2 (frseq_waddr[2 * AXI_WR_ADDR_BITS +: AXI_WR_ADDR_BITS]), // input[13:0] .waddr2 (frseq_waddr[2 * AXI_WR_ADDR_BITS +: AXI_WR_ADDR_BITS]), // input[13:0]
.wr_en2 (frseq_valid[2]), // input .wr_en2 (frseq_valid[2]), // input
.wdata2 (frseq_wdata[2 * 32 +: 32]), // input[31:0] .wdata2 (frseq_wdata[2 * 32 +: 32]), // input[31:0]
.ackn2 (frseq_ackn[2]), // output .ackn2 (frseq_ackn[2]), // output
.is2 (frseq_is[2]), // input
.im2 (frseq_im[2]), // input
.frame_num3 (frame_num[3 * NUM_FRAME_BITS +: 4]), // input[3:0] Use 4 bits even if NUM_FRAME_BITS > 4 .frame_num3 (frame_num[3 * NUM_FRAME_BITS +: 4]), // input[3:0] Use 4 bits even if NUM_FRAME_BITS > 4
.waddr3 (frseq_waddr[3 * AXI_WR_ADDR_BITS +: AXI_WR_ADDR_BITS]), // input[13:0] .waddr3 (frseq_waddr[3 * AXI_WR_ADDR_BITS +: AXI_WR_ADDR_BITS]), // input[13:0]
.wr_en3 (frseq_valid[3]), // input .wr_en3 (frseq_valid[3]), // input
.wdata3 (frseq_wdata[3 * 32 +: 32]), // input[31:0] .wdata3 (frseq_wdata[3 * 32 +: 32]), // input[31:0]
.ackn3 (frseq_ackn[3]), // output .ackn3 (frseq_ackn[3]), // output
.is3 (frseq_is[3]), // input
.im3 (frseq_im[3]), // input
.waddr_out (cseq_waddr), // output[13:0] reg .waddr_out (cseq_waddr), // output[13:0] reg
.wr_en_out (cseq_wr_en), // output .wr_en_out (cseq_wr_en), // output
.wdata_out (cseq_wdata), // output[31:0] reg .wdata_out (cseq_wdata), // output[31:0] reg
...@@ -1905,6 +1923,7 @@ assign axi_grst = axi_rst_pre; ...@@ -1905,6 +1923,7 @@ assign axi_grst = axi_rst_pre;
.status_ad (status_compressor_ad), // output[7:0] .status_ad (status_compressor_ad), // output[7:0]
.status_rq (status_compressor_rq), // output .status_rq (status_compressor_rq), // output
.status_start (status_compressor_start), // input .status_start (status_compressor_start), // input
.cmprs_irq (cmprs_irq[3:0]), // output[3:0]
.xfer_reset_page_rd (cmprs_xfer_reset_page_rd), // input[3:0] .xfer_reset_page_rd (cmprs_xfer_reset_page_rd), // input[3:0]
.buf_wpage_nxt (cmprs_buf_wpage_nxt), // input[3:0] .buf_wpage_nxt (cmprs_buf_wpage_nxt), // input[3:0]
...@@ -2662,7 +2681,12 @@ assign axi_grst = axi_rst_pre; ...@@ -2662,7 +2681,12 @@ assign axi_grst = axi_rst_pre;
.DMA3DATYPE(), // DMAC 3 DMA Ackbowledge TYpe (completed single AXI, completed burst AXI, flush request), output .DMA3DATYPE(), // DMAC 3 DMA Ackbowledge TYpe (completed single AXI, completed burst AXI, flush request), output
.DMA3RSTN(), // DMAC 3 RESET output (reserved, do not use), output .DMA3RSTN(), // DMAC 3 RESET output (reserved, do not use), output
// Interrupt signals // Interrupt signals
.IRQF2P(), // Interrupts, OL to PS [19:0], input .IRQF2P({4'b0,
cmprs_irq[3:0], // [15:12] Compressor done interrupts
frseq_irq[3:0], // [11: 8] Frame sync interrupts
7'b0,
1'b0 // Put SATA here
}), // Interrupts, OL to PS [19:0], input
.IRQP2F(), // Interrupts, OL to PS [28:0], output .IRQP2F(), // Interrupts, OL to PS [28:0], output
// Event Signals // Event Signals
.EVENTEVENTI(), // EVENT Wake up one or both CPU from WFE state, input .EVENTEVENTI(), // EVENT Wake up one or both CPU from WFE state, input
......
...@@ -1852,14 +1852,14 @@ simul_axi_master_rdaddr ...@@ -1852,14 +1852,14 @@ simul_axi_master_rdaddr
.arid_in(ARID_IN[11:0]), .arid_in(ARID_IN[11:0]),
.araddr_in(ARADDR_IN[31:0]), .araddr_in(ARADDR_IN[31:0]),
.arlen_in(ARLEN_IN[3:0]), .arlen_in(ARLEN_IN[3:0]),
.arsize_in(ARSIZE_IN[2:0]), .arsize_in(ARSIZE_IN[1:0]),
.arburst_in(ARBURST_IN[1:0]), .arburst_in(ARBURST_IN[1:0]),
.arcache_in(4'b0), .arcache_in(4'b0),
.arprot_in(3'b0), // .arprot_in(2'b0), .arprot_in(3'b0), // .arprot_in(2'b0),
.arid(arid[11:0]), .arid(arid[11:0]),
.araddr(araddr[31:0]), .araddr(araddr[31:0]),
.arlen(arlen[3:0]), .arlen(arlen[3:0]),
.arsize(arsize[2:0]), .arsize(arsize[1:0]),
.arburst(arburst[1:0]), .arburst(arburst[1:0]),
.arcache(arcache[3:0]), .arcache(arcache[3:0]),
.arprot(arprot[2:0]), .arprot(arprot[2:0]),
......
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