dprgf011h.v
12.9 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
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
*************************************************************************/
// $Id: dprgf011h.v,v 1.1.1.1 2002/05/17 06:07:48 blythe Exp $
// Scalar Unit 2Read/1Write Register File
module dprgf011h(
INST_RAL, INST_RALB,
INST_RAH, INST_RAHB,
INST_RBL, INST_RBLB,
INST_RBH, INST_RBHB,
INST_WL, INST_WLB,
INST_WH, INST_WHB,
d,
a, b
);
input [15:0] INST_RAL, INST_RALB ;
input [15:0] INST_RAH, INST_RAHB ;
input [15:0] INST_RBL, INST_RBLB ;
input [15:0] INST_RBH, INST_RBHB ;
input [15:0] INST_WL, INST_WLB ;
input [15:0] INST_WH, INST_WHB ;
input [31:0] d;
output [31:0] a, b;
/***********************************************************
* Local signals,mem and variables
**********************************************************/
reg [31:0] mem[0:31];
reg [31:0] a, b;
reg raError, rbError, wError;
reg [4:0] ra_addr, rb_addr, w_addr;
reg Wen,WenSoft,WenHard;
reg ErrorEn;
reg Noise;
initial
begin
ErrorEn = 0;
raError = 0;
rbError = 0;
wError = 0;
Wen = 0;
WenSoft = 0;
WenHard = 0;
Noise = 0;
end
initial
begin
#100 ErrorEn = 1;
end
/************************************************************
* Address Encoding and Error detection.
************************************************************/
always @(INST_RAL or INST_RAH or INST_RALB or INST_RAHB)
begin
raError = 0;
case ({INST_RAHB,INST_RALB,INST_RAH,INST_RAL})
64'hffff_fffe_0000_0001: ra_addr = 5'd0;
64'hffff_fffd_0000_0002: ra_addr = 5'd1;
64'hffff_fffb_0000_0004: ra_addr = 5'd2;
64'hffff_fff7_0000_0008: ra_addr = 5'd3;
64'hffff_ffef_0000_0010: ra_addr = 5'd4;
64'hffff_ffdf_0000_0020: ra_addr = 5'd5;
64'hffff_ffbf_0000_0040: ra_addr = 5'd6;
64'hffff_ff7f_0000_0080: ra_addr = 5'd7;
64'hffff_feff_0000_0100: ra_addr = 5'd8;
64'hffff_fdff_0000_0200: ra_addr = 5'd9;
64'hffff_fbff_0000_0400: ra_addr = 5'd10;
64'hffff_f7ff_0000_0800: ra_addr = 5'd11;
64'hffff_efff_0000_1000: ra_addr = 5'd12;
64'hffff_dfff_0000_2000: ra_addr = 5'd13;
64'hffff_bfff_0000_4000: ra_addr = 5'd14;
64'hffff_7fff_0000_8000: ra_addr = 5'd15;
64'hfffe_ffff_0001_0000: ra_addr = 5'd16;
64'hfffd_ffff_0002_0000: ra_addr = 5'd17;
64'hfffb_ffff_0004_0000: ra_addr = 5'd18;
64'hfff7_ffff_0008_0000: ra_addr = 5'd19;
64'hffef_ffff_0010_0000: ra_addr = 5'd20;
64'hffdf_ffff_0020_0000: ra_addr = 5'd21;
64'hffbf_ffff_0040_0000: ra_addr = 5'd22;
64'hff7f_ffff_0080_0000: ra_addr = 5'd23;
64'hfeff_ffff_0100_0000: ra_addr = 5'd24;
64'hfdff_ffff_0200_0000: ra_addr = 5'd25;
64'hfbff_ffff_0400_0000: ra_addr = 5'd26;
64'hf7ff_ffff_0800_0000: ra_addr = 5'd27;
64'hefff_ffff_1000_0000: ra_addr = 5'd28;
64'hdfff_ffff_2000_0000: ra_addr = 5'd29;
64'hbfff_ffff_4000_0000: ra_addr = 5'd30;
64'h7fff_ffff_8000_0000: ra_addr = 5'd31;
default : begin ra_addr = 5'd0; raError = ErrorEn; end
endcase
end
always @(INST_RBL or INST_RBH or INST_RBLB or INST_RBHB)
begin
rbError = 0;
case ({INST_RBHB,INST_RBLB,INST_RBH,INST_RBL})
64'hffff_fffe_0000_0001: rb_addr = 5'd0;
64'hffff_fffd_0000_0002: rb_addr = 5'd1;
64'hffff_fffb_0000_0004: rb_addr = 5'd2;
64'hffff_fff7_0000_0008: rb_addr = 5'd3;
64'hffff_ffef_0000_0010: rb_addr = 5'd4;
64'hffff_ffdf_0000_0020: rb_addr = 5'd5;
64'hffff_ffbf_0000_0040: rb_addr = 5'd6;
64'hffff_ff7f_0000_0080: rb_addr = 5'd7;
64'hffff_feff_0000_0100: rb_addr = 5'd8;
64'hffff_fdff_0000_0200: rb_addr = 5'd9;
64'hffff_fbff_0000_0400: rb_addr = 5'd10;
64'hffff_f7ff_0000_0800: rb_addr = 5'd11;
64'hffff_efff_0000_1000: rb_addr = 5'd12;
64'hffff_dfff_0000_2000: rb_addr = 5'd13;
64'hffff_bfff_0000_4000: rb_addr = 5'd14;
64'hffff_7fff_0000_8000: rb_addr = 5'd15;
64'hfffe_ffff_0001_0000: rb_addr = 5'd16;
64'hfffd_ffff_0002_0000: rb_addr = 5'd17;
64'hfffb_ffff_0004_0000: rb_addr = 5'd18;
64'hfff7_ffff_0008_0000: rb_addr = 5'd19;
64'hffef_ffff_0010_0000: rb_addr = 5'd20;
64'hffdf_ffff_0020_0000: rb_addr = 5'd21;
64'hffbf_ffff_0040_0000: rb_addr = 5'd22;
64'hff7f_ffff_0080_0000: rb_addr = 5'd23;
64'hfeff_ffff_0100_0000: rb_addr = 5'd24;
64'hfdff_ffff_0200_0000: rb_addr = 5'd25;
64'hfbff_ffff_0400_0000: rb_addr = 5'd26;
64'hf7ff_ffff_0800_0000: rb_addr = 5'd27;
64'hefff_ffff_1000_0000: rb_addr = 5'd28;
64'hdfff_ffff_2000_0000: rb_addr = 5'd29;
64'hbfff_ffff_4000_0000: rb_addr = 5'd30;
64'h7fff_ffff_8000_0000: rb_addr = 5'd31;
default : begin rb_addr = 5'd0; rbError = ErrorEn; end
endcase
end
always @(INST_WL or INST_WH or INST_WLB or INST_WHB)
begin
wError = 0;
case ({INST_WHB,INST_WLB,INST_WH,INST_WL})
64'hffff_ffff_0000_0000: begin
w_addr = 5'd0;
WenSoft = 0;
WenHard = 0;
end
64'hffff_fffe_0000_0000: begin w_addr = 5'd0; WenSoft = 1; end
64'hffff_fffd_0000_0000: begin w_addr = 5'd1; WenSoft = 1; end
64'hffff_fffb_0000_0000: begin w_addr = 5'd2; WenSoft = 1; end
64'hffff_fff7_0000_0000: begin w_addr = 5'd3; WenSoft = 1; end
64'hffff_ffef_0000_0000: begin w_addr = 5'd4; WenSoft = 1; end
64'hffff_ffdf_0000_0000: begin w_addr = 5'd5; WenSoft = 1; end
64'hffff_ffbf_0000_0000: begin w_addr = 5'd6; WenSoft = 1; end
64'hffff_ff7f_0000_0000: begin w_addr = 5'd7; WenSoft = 1; end
64'hffff_feff_0000_0000: begin w_addr = 5'd8; WenSoft = 1; end
64'hffff_fdff_0000_0000: begin w_addr = 5'd9; WenSoft = 1; end
64'hffff_fbff_0000_0000: begin w_addr = 5'd10; WenSoft = 1; end
64'hffff_f7ff_0000_0000: begin w_addr = 5'd11; WenSoft = 1; end
64'hffff_efff_0000_0000: begin w_addr = 5'd12; WenSoft = 1; end
64'hffff_dfff_0000_0000: begin w_addr = 5'd13; WenSoft = 1; end
64'hffff_bfff_0000_0000: begin w_addr = 5'd14; WenSoft = 1; end
64'hffff_7fff_0000_0000: begin w_addr = 5'd15; WenSoft = 1; end
64'hfffe_ffff_0000_0000: begin w_addr = 5'd16; WenSoft = 1; end
64'hfffd_ffff_0000_0000: begin w_addr = 5'd17; WenSoft = 1; end
64'hfffb_ffff_0000_0000: begin w_addr = 5'd18; WenSoft = 1; end
64'hfff7_ffff_0000_0000: begin w_addr = 5'd19; WenSoft = 1; end
64'hffef_ffff_0000_0000: begin w_addr = 5'd20; WenSoft = 1; end
64'hffdf_ffff_0000_0000: begin w_addr = 5'd21; WenSoft = 1; end
64'hffbf_ffff_0000_0000: begin w_addr = 5'd22; WenSoft = 1; end
64'hff7f_ffff_0000_0000: begin w_addr = 5'd23; WenSoft = 1; end
64'hfeff_ffff_0000_0000: begin w_addr = 5'd24; WenSoft = 1; end
64'hfdff_ffff_0000_0000: begin w_addr = 5'd25; WenSoft = 1; end
64'hfbff_ffff_0000_0000: begin w_addr = 5'd26; WenSoft = 1; end
64'hf7ff_ffff_0000_0000: begin w_addr = 5'd27; WenSoft = 1; end
64'hefff_ffff_0000_0000: begin w_addr = 5'd28; WenSoft = 1; end
64'hdfff_ffff_0000_0000: begin w_addr = 5'd29; WenSoft = 1; end
64'hbfff_ffff_0000_0000: begin w_addr = 5'd30; WenSoft = 1; end
64'h7fff_ffff_0000_0000: begin w_addr = 5'd31; WenSoft = 1; end
64'hffff_ffff_0000_0001: begin w_addr = 5'd0; WenSoft = 1; end
64'hffff_ffff_0000_0002: begin w_addr = 5'd1; WenSoft = 1; end
64'hffff_ffff_0000_0004: begin w_addr = 5'd2; WenSoft = 1; end
64'hffff_ffff_0000_0008: begin w_addr = 5'd3; WenSoft = 1; end
64'hffff_ffff_0000_0010: begin w_addr = 5'd4; WenSoft = 1; end
64'hffff_ffff_0000_0020: begin w_addr = 5'd5; WenSoft = 1; end
64'hffff_ffff_0000_0040: begin w_addr = 5'd6; WenSoft = 1; end
64'hffff_ffff_0000_0080: begin w_addr = 5'd7; WenSoft = 1; end
64'hffff_ffff_0000_0100: begin w_addr = 5'd8; WenSoft = 1; end
64'hffff_ffff_0000_0200: begin w_addr = 5'd9; WenSoft = 1; end
64'hffff_ffff_0000_0400: begin w_addr = 5'd10; WenSoft = 1; end
64'hffff_ffff_0000_0800: begin w_addr = 5'd11; WenSoft = 1; end
64'hffff_ffff_0000_1000: begin w_addr = 5'd12; WenSoft = 1; end
64'hffff_ffff_0000_2000: begin w_addr = 5'd13; WenSoft = 1; end
64'hffff_ffff_0000_4000: begin w_addr = 5'd14; WenSoft = 1; end
64'hffff_ffff_0000_8000: begin w_addr = 5'd15; WenSoft = 1; end
64'hffff_ffff_0001_0000: begin w_addr = 5'd16; WenSoft = 1; end
64'hffff_ffff_0002_0000: begin w_addr = 5'd17; WenSoft = 1; end
64'hffff_ffff_0004_0000: begin w_addr = 5'd18; WenSoft = 1; end
64'hffff_ffff_0008_0000: begin w_addr = 5'd19; WenSoft = 1; end
64'hffff_ffff_0010_0000: begin w_addr = 5'd20; WenSoft = 1; end
64'hffff_ffff_0020_0000: begin w_addr = 5'd21; WenSoft = 1; end
64'hffff_ffff_0040_0000: begin w_addr = 5'd22; WenSoft = 1; end
64'hffff_ffff_0080_0000: begin w_addr = 5'd23; WenSoft = 1; end
64'hffff_ffff_0100_0000: begin w_addr = 5'd24; WenSoft = 1; end
64'hffff_ffff_0200_0000: begin w_addr = 5'd25; WenSoft = 1; end
64'hffff_ffff_0400_0000: begin w_addr = 5'd26; WenSoft = 1; end
64'hffff_ffff_0800_0000: begin w_addr = 5'd27; WenSoft = 1; end
64'hffff_ffff_1000_0000: begin w_addr = 5'd28; WenSoft = 1; end
64'hffff_ffff_2000_0000: begin w_addr = 5'd29; WenSoft = 1; end
64'hffff_ffff_4000_0000: begin w_addr = 5'd30; WenSoft = 1; end
64'hffff_ffff_8000_0000: begin w_addr = 5'd31; WenSoft = 1; end
64'hffff_fffe_0000_0001: begin w_addr = 5'd0; WenHard = 1; end
64'hffff_fffd_0000_0002: begin w_addr = 5'd1; WenHard = 1; end
64'hffff_fffb_0000_0004: begin w_addr = 5'd2; WenHard = 1; end
64'hffff_fff7_0000_0008: begin w_addr = 5'd3; WenHard = 1; end
64'hffff_ffef_0000_0010: begin w_addr = 5'd4; WenHard = 1; end
64'hffff_ffdf_0000_0020: begin w_addr = 5'd5; WenHard = 1; end
64'hffff_ffbf_0000_0040: begin w_addr = 5'd6; WenHard = 1; end
64'hffff_ff7f_0000_0080: begin w_addr = 5'd7; WenHard = 1; end
64'hffff_feff_0000_0100: begin w_addr = 5'd8; WenHard = 1; end
64'hffff_fdff_0000_0200: begin w_addr = 5'd9; WenHard = 1; end
64'hffff_fbff_0000_0400: begin w_addr = 5'd10; WenHard = 1; end
64'hffff_f7ff_0000_0800: begin w_addr = 5'd11; WenHard = 1; end
64'hffff_efff_0000_1000: begin w_addr = 5'd12; WenHard = 1; end
64'hffff_dfff_0000_2000: begin w_addr = 5'd13; WenHard = 1; end
64'hffff_bfff_0000_4000: begin w_addr = 5'd14; WenHard = 1; end
64'hffff_7fff_0000_8000: begin w_addr = 5'd15; WenHard = 1; end
64'hfffe_ffff_0001_0000: begin w_addr = 5'd16; WenHard = 1; end
64'hfffd_ffff_0002_0000: begin w_addr = 5'd17; WenHard = 1; end
64'hfffb_ffff_0004_0000: begin w_addr = 5'd18; WenHard = 1; end
64'hfff7_ffff_0008_0000: begin w_addr = 5'd19; WenHard = 1; end
64'hffef_ffff_0010_0000: begin w_addr = 5'd20; WenHard = 1; end
64'hffdf_ffff_0020_0000: begin w_addr = 5'd21; WenHard = 1; end
64'hffbf_ffff_0040_0000: begin w_addr = 5'd22; WenHard = 1; end
64'hff7f_ffff_0080_0000: begin w_addr = 5'd23; WenHard = 1; end
64'hfeff_ffff_0100_0000: begin w_addr = 5'd24; WenHard = 1; end
64'hfdff_ffff_0200_0000: begin w_addr = 5'd25; WenHard = 1; end
64'hfbff_ffff_0400_0000: begin w_addr = 5'd26; WenHard = 1; end
64'hf7ff_ffff_0800_0000: begin w_addr = 5'd27; WenHard = 1; end
64'hefff_ffff_1000_0000: begin w_addr = 5'd28; WenHard = 1; end
64'hdfff_ffff_2000_0000: begin w_addr = 5'd29; WenHard = 1; end
64'hbfff_ffff_4000_0000: begin w_addr = 5'd30; WenHard = 1; end
64'h7fff_ffff_8000_0000: begin w_addr = 5'd31; WenHard = 1; end
default : begin
w_addr = 5'd0;
WenSoft = 0;
WenHard = 0;
wError = ErrorEn;
end
endcase
Wen = WenSoft | WenHard;
end
/**************************************************************
* Write Port
**************************************************************/
always @(w_addr or d or Wen or WenHard or wError)
if (wError)
$display($time," ERROR: Write Address Error for 2R/1W regfile");
else
if (Wen && !WenHard)
mem[w_addr] = 32'hx;
else
if (Wen && WenHard)
mem[w_addr] = d;
/**************************************************************
* Read Port:A
**************************************************************/
always @(ra_addr or raError or w_addr or Wen or d or Noise)
if (raError)
a[31:0] = 32'hx;
else
a[31:0] = mem[ra_addr];
/**************************************************************
* Read Port:B
**************************************************************/
always @(rb_addr or rbError or w_addr or Wen or d or Noise)
if (rbError)
b[31:0] = 32'hx;
else
b[31:0] = mem[rb_addr];
endmodule