Skip to content
Snippets Groups Projects
Commit e8f7c756 authored by Yaman Umuroglu's avatar Yaman Umuroglu
Browse files

[FIFO] add hw maxcount tracking to rtl FIFOs with opt attribute

parent 6ce1f50d
No related branches found
No related tags found
No related merge requests found
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
`define Q_srl `define Q_srl
module Q_srl (clock, reset, i_d, i_v, i_r, o_d, o_v, o_r, count); module Q_srl (clock, reset, i_d, i_v, i_r, o_d, o_v, o_r, count, maxcount);
parameter depth = 16; // - greatest #items in queue (2 <= depth <= 256) parameter depth = 16; // - greatest #items in queue (2 <= depth <= 256)
parameter width = 16; // - width of data (i_d, o_d) parameter width = 16; // - width of data (i_d, o_d)
...@@ -90,7 +90,9 @@ module Q_srl (clock, reset, i_d, i_v, i_r, o_d, o_v, o_r, count); ...@@ -90,7 +90,9 @@ module Q_srl (clock, reset, i_d, i_v, i_r, o_d, o_v, o_r, count);
wire o_b; // - output stream back-pressure wire o_b; // - output stream back-pressure
output [addrwidth:0] count; // - output number of elems in queue output [addrwidth:0] count; // - output number of elems in queue
output [addrwidth:0] maxcount; // - maximum observed count since reset
reg [addrwidth:0] maxcount_reg; // - maximum count seen until now
reg [addrwidth-1:0] addr, addr_, a_; // - SRL16 address reg [addrwidth-1:0] addr, addr_, a_; // - SRL16 address
// for data output // for data output
reg shift_en_; // - SRL16 shift enable reg shift_en_; // - SRL16 shift enable
...@@ -124,6 +126,7 @@ module Q_srl (clock, reset, i_d, i_v, i_r, o_d, o_v, o_r, count); ...@@ -124,6 +126,7 @@ module Q_srl (clock, reset, i_d, i_v, i_r, o_d, o_v, o_r, count);
assign o_d = srlo; // - output data from queue assign o_d = srlo; // - output data from queue
assign o_v = o_v_reg; // - output valid if non-empty assign o_v = o_v_reg; // - output valid if non-empty
assign i_b = i_b_reg; // - input bp if full assign i_b = i_b_reg; // - input bp if full
assign maxcount = maxcount_reg;
assign i_r = !i_b; assign i_r = !i_b;
assign o_b = !o_r; assign o_b = !o_r;
...@@ -140,6 +143,7 @@ module Q_srl (clock, reset, i_d, i_v, i_r, o_d, o_v, o_r, count); ...@@ -140,6 +143,7 @@ module Q_srl (clock, reset, i_d, i_v, i_r, o_d, o_v, o_r, count);
addr_full <= 0; addr_full <= 0;
o_v_reg <= 0; o_v_reg <= 0;
i_b_reg <= 1; i_b_reg <= 1;
maxcount_reg <= '0;
end end
else begin else begin
state <= state_; state <= state_;
...@@ -147,6 +151,7 @@ module Q_srl (clock, reset, i_d, i_v, i_r, o_d, o_v, o_r, count); ...@@ -147,6 +151,7 @@ module Q_srl (clock, reset, i_d, i_v, i_r, o_d, o_v, o_r, count);
addr_full <= addr_full_; addr_full <= addr_full_;
o_v_reg <= o_v_reg_; o_v_reg <= o_v_reg_;
i_b_reg <= i_b_reg_; i_b_reg <= i_b_reg_;
maxcount_reg <= (count > maxcount_reg ? count : maxcount_reg);
end end
end // always @ (posedge clock) end // always @ (posedge clock)
......
...@@ -68,6 +68,8 @@ class StreamingFIFO(HLSCustomOp): ...@@ -68,6 +68,8 @@ class StreamingFIFO(HLSCustomOp):
"auto", "auto",
{"auto", "block", "distributed", "ultra"}, {"auto", "block", "distributed", "ultra"},
), ),
# whether depth monitoring is enabled (impl_style=rtl only)
"depth_monitor": ("i", False, 0),
} }
my_attrs.update(super().get_nodeattr_types()) my_attrs.update(super().get_nodeattr_types())
...@@ -97,6 +99,14 @@ class StreamingFIFO(HLSCustomOp): ...@@ -97,6 +99,14 @@ class StreamingFIFO(HLSCustomOp):
def verify_node(self): def verify_node(self):
pass pass
def get_verilog_top_module_intf_names(self):
ret = super().get_verilog_top_module_intf_names()
is_rtl = self.get_nodeattr("impl_style") == "rtl"
is_depth_monitor = self.get_nodeattr("depth_monitor") == 1
if is_rtl and is_depth_monitor:
ret["ap_none"] = ["maxcount"]
return ret
def get_verilog_top_module_name(self): def get_verilog_top_module_name(self):
"Return the Verilog top module name for this node." "Return the Verilog top module name for this node."
......
...@@ -319,6 +319,7 @@ module $TOPNAME$( ...@@ -319,6 +319,7 @@ module $TOPNAME$(
ap_clk, ap_clk,
ap_rst_n, ap_rst_n,
count, count,
maxcount,
in0_$HLS_SNAME$_TDATA, in0_$HLS_SNAME$_TDATA,
in0_$HLS_SNAME$_TVALID, in0_$HLS_SNAME$_TVALID,
in0_$HLS_SNAME$_TREADY, in0_$HLS_SNAME$_TREADY,
...@@ -330,6 +331,7 @@ out_$HLS_SNAME$_TREADY ...@@ -330,6 +331,7 @@ out_$HLS_SNAME$_TREADY
input ap_clk; input ap_clk;
input ap_rst_n; input ap_rst_n;
output $COUNT_RANGE$ count; output $COUNT_RANGE$ count;
output $COUNT_RANGE$ maxcount;
input $IN_RANGE$ in0_$HLS_SNAME$_TDATA; input $IN_RANGE$ in0_$HLS_SNAME$_TDATA;
input in0_$HLS_SNAME$_TVALID; input in0_$HLS_SNAME$_TVALID;
output in0_$HLS_SNAME$_TREADY; output in0_$HLS_SNAME$_TREADY;
...@@ -346,6 +348,7 @@ $LAYER_NAME$ ...@@ -346,6 +348,7 @@ $LAYER_NAME$
.clock(ap_clk), .clock(ap_clk),
.reset(!ap_rst_n), .reset(!ap_rst_n),
.count(count), .count(count),
.maxcount(maxcount),
.i_d(in0_$HLS_SNAME$_TDATA), .i_d(in0_$HLS_SNAME$_TDATA),
.i_v(in0_$HLS_SNAME$_TVALID), .i_v(in0_$HLS_SNAME$_TVALID),
.i_r(in0_$HLS_SNAME$_TREADY), .i_r(in0_$HLS_SNAME$_TREADY),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment