summaryrefslogtreecommitdiffstats
path: root/usrp2/gpmc/fifo_watcher.v
diff options
context:
space:
mode:
Diffstat (limited to 'usrp2/gpmc/fifo_watcher.v')
-rw-r--r--usrp2/gpmc/fifo_watcher.v26
1 files changed, 26 insertions, 0 deletions
diff --git a/usrp2/gpmc/fifo_watcher.v b/usrp2/gpmc/fifo_watcher.v
new file mode 100644
index 000000000..8b8f1abfb
--- /dev/null
+++ b/usrp2/gpmc/fifo_watcher.v
@@ -0,0 +1,26 @@
+
+
+module fifo_watcher
+ (input clk, input reset, input clear,
+ input src_rdy, input dst_rdy, input sof, input eof,
+ output have_packet, output [15:0] length, input next);
+
+ wire write = src_rdy & dst_rdy & eof;
+
+ fifo_short #(.WIDTH(16)) frame_lengths
+ (.clk(clk), .reset(reset), .clear(clear),
+ .datain(counter), .src_rdy_i(write), .dst_rdy_o(),
+ .dataout(length), .src_rdy_o(have_packet), .dst_rdy_i(next) );
+
+ reg [15:0] counter;
+ always @(posedge clk)
+ if(reset | clear)
+ counter <= 1; // Start at 1
+ else if(src_rdy & dst_rdy)
+ if(eof)
+ counter <= 1;
+ else
+ counter <= counter + 1;
+
+
+endmodule // fifo_watcher