ewrf32b18w.v
7.22 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
/**************************************************************************
* *
* 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: ewrf32b18w.v,v 1.4 2002/12/10 21:46:58 rws Exp $
/////////////////////////////////////////////////////////////////////////
//
// Project Reality
//
// module: ewrf32b18w
// description: two 9-word by 32-bit register files.
// One for attributes and the other for da/de.
// Both has a read port and a write port.
// The one for da/de has a bypass feather.
//
// designer: Mike M. Cai 6/28/94
//
/////////////////////////////////////////////////////////////////////////
module ewrf32b18w ( wa_data, wa_addr, wen_a, wde_data, wde_addr, wen_de,
ra_addr, rb_addr, // ra_addr is for attribute
ra_data, rb_data, // rb_addr is for da/de
ew_stall_attr, start_gclk, clk);
input ew_stall_attr, start_gclk, clk;
input wen_a, wen_de;
input [3:0] wa_addr;
input [3:0] wde_addr;
input [31:0] wa_data, wde_data;
input [3:0] ra_addr, rb_addr;
output [31:0] ra_data, rb_data;
reg [8:0] ra_line, rb_line;
reg [8:0] wa_line;
reg [8:0] wde_line;
wire [8:0] wa_line_wengclk, wde_line_wengclk;
wire [31:0] ra_data_m, rb_data_m;
// wire [31:0] wa_data_delay;
reg [31:0] rb_data_mm;
reg [31:0] ra_data, rb_data;
// decode address this
// read port a
always @(ra_addr)
case (ra_addr)
4'b0000: ra_line = 9'b000000001;
4'b0001: ra_line = 9'b000000010;
4'b0010: ra_line = 9'b000000100;
4'b0011: ra_line = 9'b000001000;
4'b0100: ra_line = 9'b000010000;
4'b0101: ra_line = 9'b000100000;
4'b0110: ra_line = 9'b001000000;
4'b0111: ra_line = 9'b010000000;
4'b1000: ra_line = 9'b100000000;
default: ra_line = 9'b100000000;
endcase
// read port b
always @(rb_addr)
case (rb_addr)
4'b0000: rb_line = 9'b000000001;
4'b0001: rb_line = 9'b000000010;
4'b0010: rb_line = 9'b000000100;
4'b0011: rb_line = 9'b000001000;
4'b0100: rb_line = 9'b000010000;
4'b0101: rb_line = 9'b000100000;
4'b0110: rb_line = 9'b001000000;
4'b0111: rb_line = 9'b010000000;
4'b1000: rb_line = 9'b100000000;
default: rb_line = 9'b100000000;
endcase
// write port for attributes
always @(wa_addr)
case (wa_addr)
4'b0000: wa_line = 9'h001;
4'b0001: wa_line = 9'h002;
4'b0010: wa_line = 9'h004;
4'b0011: wa_line = 9'h008;
4'b0100: wa_line = 9'h010;
4'b0101: wa_line = 9'h020;
4'b0110: wa_line = 9'h040;
4'b0111: wa_line = 9'h080;
4'b1000: wa_line = 9'h100;
default: wa_line = 9'h100;
endcase
assign wa_line_wengclk = wa_line & {9{wen_a}};
// write port for da/de
always @(wde_addr)
casez (wde_addr)
4'b0000: wde_line = 9'h001;
4'b0001: wde_line = 9'h002;
4'b0010: wde_line = 9'h004;
4'b0011: wde_line = 9'h008;
4'b0100: wde_line = 9'h010;
4'b0101: wde_line = 9'h020;
4'b0110: wde_line = 9'h040;
4'b0111: wde_line = 9'h080;
4'b1000: wde_line = 9'h100;
default: wde_line = 9'h100;
endcase
assign wde_line_wengclk = wde_line & {9{wen_de}};
// ewrfdelay delaywdata(.out_data(wa_data_delay), .in_data(wa_data));
reg [31:0] ra_data0;
reg [31:0] ra_data1;
reg [31:0] ra_data2;
reg [31:0] ra_data3;
reg [31:0] ra_data4;
reg [31:0] ra_data5;
reg [31:0] ra_data6;
reg [31:0] ra_data7;
reg [31:0] ra_data8;
reg [31:0] rb_data0;
reg [31:0] rb_data1;
reg [31:0] rb_data2;
reg [31:0] rb_data3;
reg [31:0] rb_data4;
reg [31:0] rb_data5;
reg [31:0] rb_data6;
reg [31:0] rb_data7;
reg [31:0] rb_data8;
wire [31:0] nxt_ra_data0 = wa_line_wengclk[0] ? wa_data : ra_data0;
wire [31:0] nxt_ra_data1 = wa_line_wengclk[1] ? wa_data : ra_data1;
wire [31:0] nxt_ra_data2 = wa_line_wengclk[2] ? wa_data : ra_data2;
wire [31:0] nxt_ra_data3 = wa_line_wengclk[3] ? wa_data : ra_data3;
wire [31:0] nxt_ra_data4 = wa_line_wengclk[4] ? wa_data : ra_data4;
wire [31:0] nxt_ra_data5 = wa_line_wengclk[5] ? wa_data : ra_data5;
wire [31:0] nxt_ra_data6 = wa_line_wengclk[6] ? wa_data : ra_data6;
wire [31:0] nxt_ra_data7 = wa_line_wengclk[7] ? wa_data : ra_data7;
wire [31:0] nxt_ra_data8 = wa_line_wengclk[8] ? wa_data : ra_data8;
wire [31:0] nxt_rb_data0 = wde_line_wengclk[0] ? wde_data : rb_data0;
wire [31:0] nxt_rb_data1 = wde_line_wengclk[1] ? wde_data : rb_data1;
wire [31:0] nxt_rb_data2 = wde_line_wengclk[2] ? wde_data : rb_data2;
wire [31:0] nxt_rb_data3 = wde_line_wengclk[3] ? wde_data : rb_data3;
wire [31:0] nxt_rb_data4 = wde_line_wengclk[4] ? wde_data : rb_data4;
wire [31:0] nxt_rb_data5 = wde_line_wengclk[5] ? wde_data : rb_data5;
wire [31:0] nxt_rb_data6 = wde_line_wengclk[6] ? wde_data : rb_data6;
wire [31:0] nxt_rb_data7 = wde_line_wengclk[7] ? wde_data : rb_data7;
wire [31:0] nxt_rb_data8 = wde_line_wengclk[8] ? wde_data : rb_data8;
always @(negedge clk) begin
if (start_gclk) begin
ra_data0 <= nxt_ra_data0;
ra_data1 <= nxt_ra_data1;
ra_data2 <= nxt_ra_data2;
ra_data3 <= nxt_ra_data3;
ra_data4 <= nxt_ra_data4;
ra_data5 <= nxt_ra_data5;
ra_data6 <= nxt_ra_data6;
ra_data7 <= nxt_ra_data7;
ra_data8 <= nxt_ra_data8;
ra_data8 <= nxt_ra_data8;
rb_data0 <= nxt_rb_data0;
rb_data1 <= nxt_rb_data1;
rb_data2 <= nxt_rb_data2;
rb_data3 <= nxt_rb_data3;
rb_data4 <= nxt_rb_data4;
rb_data5 <= nxt_rb_data5;
rb_data6 <= nxt_rb_data6;
rb_data7 <= nxt_rb_data7;
rb_data8 <= nxt_rb_data8;
end
end
assign ra_data_m = {32{ra_line[0]}} & ra_data0
| {32{ra_line[1]}} & ra_data1
| {32{ra_line[2]}} & ra_data2
| {32{ra_line[3]}} & ra_data3
| {32{ra_line[4]}} & ra_data4
| {32{ra_line[5]}} & ra_data5
| {32{ra_line[6]}} & ra_data6
| {32{ra_line[7]}} & ra_data7
| {32{ra_line[8]}} & ra_data8;
assign rb_data_m = {32{rb_line[0]}} & rb_data0
| {32{rb_line[1]}} & rb_data1
| {32{rb_line[2]}} & rb_data2
| {32{rb_line[3]}} & rb_data3
| {32{rb_line[4]}} & rb_data4
| {32{rb_line[5]}} & rb_data5
| {32{rb_line[6]}} & rb_data6
| {32{rb_line[7]}} & rb_data7
| {32{rb_line[8]}} & rb_data8;
always @(posedge clk)
if (start_gclk) begin
if ((rb_addr == wde_addr) && wen_de)
rb_data_mm = wde_data;
else
rb_data_mm = rb_data_m;
ra_data <= ew_stall_attr ? ra_data : ra_data_m;
rb_data <= ew_stall_attr ? rb_data : rb_data_mm;
end
endmodule // ewrf32b18w