-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlab6regfile.jsim
171 lines (156 loc) · 3.09 KB
/
lab6regfile.jsim
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
* test vectors for debugging Beta register file circuitry
* allow verification, but not a real checkin
.checkoff "" "Lab #6: regfile" 0
Xregfile clk werf ra2sel rega[4:0] regb[4:0] regc[4:0] wdata[31:0] radata[31:0] rbdata[31:0] regfile
Vclk clk 0 pulse(3.3,0,49.9ns,.1ns,.1ns,49.9ns,100ns)
Wra2sel ra2sel nrz(0,3.3,100n,0n,.1n,.1n)
// see if R31 reads as 0
+ 0 1
// fill up the regfile and read it back
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0
// make sure ra2sel works okay
+ 1 0 1
Wrega rega[4:0] nrz(0,3.3,100n,0n,.1n,.1n)
// see if R31 reads as 0
+ 31 31
// fill up the regfile and read it back
+ 0 0 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 0
// make sure ra2sel works okay
+ 5 12 23
Wregb regb[4:0] nrz(0,3.3,100n,0n,.1n,.1n)
// see if R31 reads as 0
+ 31 0
// fill up the regfile and read it back
+ 0 0 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 0
// make sure ra2sel works okay
+ 7 9 11
Wregc regc[4:0] nrz(0,3.3,100n,0n,.1n,.1n)
// see if R31 reads as 0
+ 0 31
// fill up the regfile and read it back
+ 0 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
+ 0 0
// make sure ra2sel works okay
+ 8 10 12
Wwerf werf nrz(0,3.3,100n,0n,.1n,.1n)
// see if R31 reads as 0
+ 0 0
// fill up the regfile and read it back
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 0 0
// make sure ra2sel works okay
+ 0 0 0
Wwdata wdata[31:0] nrz(0,3.3,100n,0n,.1n,.1n)
// see if R31 reads as 0
+ 0 0
// fill up the regfile and read it back
+ 0 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
+31 31
// make sure ra2sel works okay
+ 0 0 0
.verify radata[31:0] tvpairs()
// see if R31 reads as 0
+ 99n 0x0
+ 199n 0x0
// fill up the regfile and read it back
// +299n ??? -- not written yet!
+ 399n 0
+ 499n 1
+ 599n 2
+ 699n 3
+ 799n 4
+ 899n 5
+ 999n 6
+ 1099n 7
+ 1199n 8
+ 1299n 9
+ 1399n 10
+ 1499n 11
+ 1599n 12
+ 1699n 13
+ 1799n 14
+ 1899n 15
+ 1999n 16
+ 2099n 17
+ 2199n 18
+ 2299n 19
+ 2399n 20
+ 2499n 21
+ 2599n 22
+ 2699n 23
+ 2799n 24
+ 2899n 25
+ 2999n 26
+ 3099n 27
+ 3199n 28
+ 3299n 29
+ 3399n 30
+ 3499n 0
+ 3599n 0
+ 3699n 5
+ 3799n 12
+ 3899n 23
.verify rbdata[31:0] tvpairs()
// see if R31 reads as 0
+ 99n 0x0
+ 199n 0x0
// fill up the regfile and read it back
// +299n ??? -- not written yet!
+ 399n 0
+ 499n 1
+ 599n 2
+ 699n 3
+ 799n 4
+ 899n 5
+ 999n 6
+ 1099n 7
+ 1199n 8
+ 1299n 9
+ 1399n 10
+ 1499n 11
+ 1599n 12
+ 1699n 13
+ 1799n 14
+ 1899n 15
+ 1999n 16
+ 2099n 17
+ 2199n 18
+ 2299n 19
+ 2399n 20
+ 2499n 21
+ 2599n 22
+ 2699n 23
+ 2799n 24
+ 2899n 25
+ 2999n 26
+ 3099n 27
+ 3199n 28
+ 3299n 29
+ 3399n 30
+ 3499n 0
+ 3599n 0
+ 3699n 8
+ 3799n 9
+ 3899n 12
* Run the simulation
.tran 3900ns
* Some useful plots... you can plot additional signals by specifying
* the appropriate .plot commands in your main netlist file.
.plot clk
.plot werf
.plot ra2sel
.plot rega[4:0]
.plot regb[4:0]
.plot regc[4:0]
.plot wdata[31:0]
.plot radata[31:0]
.plot rbdata[31:0]