forked from testaco/DCP6
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fifo16x16s.v
51 lines (51 loc) · 1.44 KB
/
fifo16x16s.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// 16-bit wide SRL16-based FIFO
//
// (C) Copyright 2004 John B. Stephensen
//
// This Verilog source file and all its derivatives are licensed only for
// personal non-profit educational use in the Amateur Radio Service and
// the license is not transferrable. The information is provided as-is for
// experimental purposes and the author does not warranty its freedom
// from defects or its suitability for any specific application.
//
// This module is a 15-entry FIFO. The FIFO is empty when reset (counter = 15),
// fills when IV is true and empties when OE is true. This FIFO uses asynchronous
// logic and is somewhat slower than otherwise possible, but uses the least resources.
//
// 20 slices are used and the maximum clock speed is 229 MHz.
//
module fifo16x16s(pdi,iv,oe,pdo,ov,empty,full,clk,rst);
input [15:0] pdi;
input iv;
input oe;
output [15:0] pdo;
output ov;
output empty;
output full;
input clk;
input rst;
// internal signals
reg [3:0] addr; // FIFO output address
wire we; // write enable
// read and write enable logic
assign we = iv & ~full;
assign ov = oe & ~empty;
// address counter
always @ (posedge clk)
begin
if (rst) addr <= 4'b1111;
else if (we^ov) addr <= addr + {~we,~we,~we,1'b1};
end
// full and empty flag logic
assign empty = (addr == 15);
assign full = (addr == 14);
// storage elements
srl16x16e sr (
.y(pdo),
.d(pdi),
.a(addr),
.ce(we),
.clk(clk)
);
endmodule