forked from DinaMMF/Graduation-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
top_tb.v
200 lines (188 loc) · 4.93 KB
/
top_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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 01:03:52 02/18/2021
// Design Name: top
// Module Name: F:/College Stuff/Year 4/Graduation Project/System/Binary adder/decimal_adder/decimal_adder/top_tb.v
// Project Name: decimal_adder
// Target Device:
// Tool versions:
// Description:
//
// Verilog Test Fixture created by ISE for module: top
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
////////////////////////////////////////////////////////////////////////////////
module top_tb;
// Inputs
reg clk_tb;
reg reset_n_tb;
reg [31:0] sw_address_tb;
reg sw_read_en_tb;
reg sw_write_en_tb;
reg [31:0] sw_datain_tb;
// Outputs
wire [31:0] sw_dataout_tb;
wire fpu_fused_m_a_tb;
wire fpu_simd_tb;
wire [2:0] fpu_simd_no_op_tb;
// Instantiate the Unit Under Test (UUT)
top uut (
.clk(clk_tb),
.reset_n(reset_n_tb),
.sw_address(sw_address_tb),
.sw_read_en(sw_read_en_tb),
.sw_write_en(sw_write_en_tb),
.sw_datain(sw_datain_tb),
.sw_dataout(sw_dataout_tb),
.fpu_fused_m_a(fpu_fused_m_a_tb),
.fpu_simd(fpu_simd_tb),
.fpu_simd_no_op(fpu_simd_no_op_tb)
);
always
begin
#(10/2.0) clk_tb = 1'b0;
#(10 - 10/2.0) clk_tb = 1'b1;
end
initial begin
// Initialize Inputs
clk_tb = 0;
reset_n_tb = 0;
sw_address_tb = 0;
sw_read_en_tb = 0;
sw_write_en_tb = 0;
sw_datain_tb = 0;
// Wait 100 ns for global reset to finish
#100;
reset_n_tb = 1'b1;
sw_write_en_tb = 1'b1;
repeat (1)
begin
@ ( posedge clk_tb );
end
sw_address_tb = 32'h0000_0010;
sw_datain_tb = 32'b00100110010001001101001011100111;
repeat (1)
begin
@ ( posedge clk_tb );
end
sw_address_tb = 32'h0000_0050;
sw_datain_tb = 32'b1010_0110_0001_0000_0101_1111_0101_0100;
repeat (1)
begin
@ ( posedge clk_tb );
end
sw_address_tb = 32'h0000_0000;
sw_datain_tb = 32'b0000_0000_0000_0000_0000_0000_0100_0110;
repeat (1)
begin
@ ( posedge clk_tb );
end
sw_write_en_tb = 1'b0;
sw_read_en_tb = 1'b0;
repeat (2)
begin
@ ( posedge clk_tb );
end
sw_read_en_tb = 1'b1;
sw_address_tb = 32'h0000_0130; // read output (takes 4 clk cycles )
repeat (1)
begin
@ ( posedge clk_tb );
end
/* sw_read_en_tb = 1'b0;
sw_write_en_tb = 1'b1;
sw_address_tb = 32'h0000_0000;
sw_datain_tb = 32'h0000_0047; */
sw_address_tb = 32'h0000_0110; // read status reg
repeat (1)
begin
@ ( posedge clk_tb );
end
sw_write_en_tb = 1'b1;
sw_read_en_tb = 1'b0;
sw_address_tb = 32'h0000_0000;
sw_datain_tb = 32'b0000_0000_0000_0000_0000_0000_0100_0111; //reset
repeat (4)
begin
@ ( posedge clk_tb );
end
sw_write_en_tb = 1'b0;
repeat (2)
begin
@ ( posedge clk_tb );
end
sw_write_en_tb = 1'b0; // read command reg to check that reset is zero after 4 clk cycles
sw_read_en_tb = 1'b1;
sw_address_tb = 32'h0000_0000;
repeat (3)
begin
@ ( posedge clk_tb );
end
reset_n_tb = 0;
repeat (1)
begin
@ ( posedge clk_tb );
end
reset_n_tb = 1;
repeat (1)
begin
@ ( posedge clk_tb );
end
sw_write_en_tb = 1'b1;
sw_read_en_tb = 1'b0;
sw_address_tb = 32'h0000_0010;
sw_datain_tb = 32'b00100110010001001101001011100111;
sw_address_tb = 32'h0000_0050;
sw_datain_tb = 32'b1010_0110_0001_0000_0101_1111_0101_0101;
repeat (1)
begin
@ ( posedge clk_tb );
end
sw_address_tb = 32'h0000_0000;
sw_datain_tb = 32'b0000_0000_0000_0000_0000_0000_0100_0100; // fpu_enable = 0
repeat (1)
begin
@ ( posedge clk_tb );
end
sw_write_en_tb = 1'b0;
sw_read_en_tb = 1'b0;
repeat (2)
begin
@ ( posedge clk_tb );
end
sw_read_en_tb = 1'b1;
sw_address_tb = 32'h0000_0130; // read output (takes 4 clk cycles )
repeat (1)
begin
@ ( posedge clk_tb );
end
sw_write_en_tb = 1'b1;
sw_read_en_tb = 1'b0;
sw_address_tb = 32'h0000_0000;
sw_datain_tb = 32'b0000_0000_0000_0000_0000_0000_0100_1110; // interrupt_enable = 1
repeat (1)
begin
@ ( posedge clk_tb );
end
sw_write_en_tb = 1'b0;
sw_read_en_tb = 1'b1;
sw_address_tb = 32'h0000_0110; // read status_reg
repeat (6)
begin
@ ( posedge clk_tb );
end
sw_read_en_tb = 1'b0;
sw_write_en_tb = 1'b1;
sw_address_tb = 32'h0000_0110; // read output (takes 4 clk cycles )
sw_datain_tb = sw_dataout_tb & 32'b1111_11111_11111_1111_1111_1111_1111_1110;
// Add stimulus here
end
endmodule