-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserial_bcd_alu_tb.v
114 lines (102 loc) · 1.67 KB
/
serial_bcd_alu_tb.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
module serial_bcd_alu_tb;
reg rst_n, clk;
reg en, in;
reg [19:0] rreg;
wire result;
serial_bcd_alu DUT (
.rst_n( rst_n ),
.clk( clk ),
.en( en ),
.in( in ),
.result( result )
);
always #5 clk = ~clk;
initial
begin
$monitor( $time, ": %0h%0h%0h%0h%0h",
rreg[19:16], rreg[15:12], rreg[11:8],
rreg[7:4], rreg[3:0]
);
clk = 0;
rst_n = 0;
en = 0;
in = 0;
#20 rst_n = 1;
#50 en = 1;
in = 0;
#10 in = 1;
#10 in = 0;
#10 in = 0;
#10 in = 1;
#10 in = 1;
#10 in = 1;
#10 in = 0;
#10 in = 1;
#10 in = 0;
#10 in = 0;
#10 in = 0;
#10 in = 0;
#10 in = 1;
#10 in = 0;
#10 in = 0;
#10 in = 0;
#10 in = 0;
#10 in = 0;
#10 in = 1;
#10 in = 1;
#10 in = 1;
#10 in = 1;
#10 in = 0;
#10 in = 0;
#10 in = 1;
#10 in = 1;
#10 in = 0;
#10 in = 0;
#10 in = 0;
#10 in = 1;
#10 in = 0;
#10 in = 0;
#10 en = 0;
#500 en = 1;
in = 1;
#10 in = 1;
#10 in = 0;
#10 in = 0;
#10 in = 0;
#10 in = 1;
#10 in = 1;
#10 in = 0;
#10 in = 0;
#10 in = 1;
#10 in = 0;
#10 in = 0;
#10 in = 0;
#10 in = 0;
#10 in = 1;
#10 in = 0;
#10 in = 1;
#10 in = 1;
#10 in = 1;
#10 in = 0;
#10 in = 0;
#10 in = 0;
#10 in = 1;
#10 in = 0;
#10 in = 1;
#10 in = 0;
#10 in = 0;
#10 in = 0;
#10 in = 1;
#10 in = 1;
#10 in = 0;
#10 in = 0;
#10 in = 1;
#10 en = 0;
#500 $stop;
end
always @( posedge clk )
if( !rst_n )
rreg <= 0;
else
rreg <= { result, rreg[19:1] };
endmodule