-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmyFIFO.v
More file actions
62 lines (52 loc) · 1.17 KB
/
myFIFO.v
File metadata and controls
62 lines (52 loc) · 1.17 KB
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
52
53
54
55
56
57
58
59
60
61
62
// Implementing the behavioral model of FIFO..
// not gate level for now...
// Let's make a FIFO 4 flit deep
// Each flit is of width 4 bits...
module myFIFO (
data_in, // input data to the FIFO
clk, // for moving data
rst, // to zero in all the values in the FIFO
data_out // output data to the FIFO
);
// Input ports
input [3:0] data_in; // this is a wire...
input clk; // clock; this is a wire
input rst; // reset; this is a wire
// Output ports
output [3:0] data_out; // this is a reg.
// Port data type
wire [3:0] data_in;
wire clk;
wire rst;
reg [3:0] data_out;
// Now intermediate regs.. to make
// FIFO 4 flit deep..
reg [3:0] first;
reg [3:0] second;
reg [3:0] third;
// Now the logic of the FIFO...
// considering asynchronous reset...
// // give inital values to each of the
// // buffer..
// initial begin
// first = 4'b0000;
// second = 4'b0000;
// third = 4'b0000;
// data_out = 4'b0000;
// end
always @(posedge clk or posedge rst) begin
if (rst) begin
// reset
first <= 4'b0000;
second <= 4'b0000;
third <= 4'b0000;
data_out <= 4'b0000;
end
else begin
first <= data_in;
second <= first;
third <= second;
data_out <= third;
end
end
endmodule