-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlifo_test.v
95 lines (86 loc) · 1.39 KB
/
lifo_test.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
`include "lifo.v"
module LIFO_Test;
logic clk, rst, full, psh, pll;
logic [7:0] in, out;
LIFO#(.WIDTH(8), .DEPTH(4)) lifo
(
.clkin(clk),
.rst(rst),
.psh(psh),
.pll(pll),
.in(in),
.out(out),
.full(full)
);
initial begin
$display("FIFO Memory");
$monitor($time," CLK=%x, RST=%x, FULL=%x, PSH=%x, PLL=%x, IN=%x, OUT=%x",
clk, rst, full, psh, pll, in, out);
// Reset memory
$display("Reset");
rst = 1; clk = 0; psh = 0; pll = 0; in = 0;
#5
rst = 0;
#5
// Push memory
$display("Push test");
assert (!full);
psh = 1;
clk = 1; in = 8'hA1;
#5
clk = 0; in = 8'hB2;
#5
clk = 1;
#5
clk = 0; in = 8'hC3;
#5
clk = 1;
#5
clk = 0; in = 8'hD4;
assert (!full);
#5
clk = 1;
#5
clk = 0; in = 'z; psh = 0;
#5
assert (full);
// Pull
$display("Pull test");
pll = 1;
clk = 1;
#5
assert(out == 8'hD4);
clk = 0;
#5
assert(!full);
clk = 1;
assert(!full);
assert(out == 8'hC3);
#5
clk = 0;
#5
clk = 1;
assert(!full);
assert(out == 8'hB2);
#5
clk = 0;
#5
clk = 1;
assert(!full);
assert(out == 8'hA1);
#5
clk = 0;
#5
clk = 1;
assert(!full);
assert(out == 8'h00);
#5
clk = 0;
#5
clk = 1;
assert(!full);
assert(out == 8'h00);
#5
clk = 0;
end
endmodule