1 | // ========== Copyright Header Begin ========================================== |
---|
2 | // |
---|
3 | // OpenSPARC T1 Processor File: bw_r_rf16x128d.v |
---|
4 | // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. |
---|
5 | // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. |
---|
6 | // |
---|
7 | // The above named program is free software; you can redistribute it and/or |
---|
8 | // modify it under the terms of the GNU General Public |
---|
9 | // License version 2 as published by the Free Software Foundation. |
---|
10 | // |
---|
11 | // The above named program is distributed in the hope that it will be |
---|
12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
14 | // General Public License for more details. |
---|
15 | // |
---|
16 | // You should have received a copy of the GNU General Public |
---|
17 | // License along with this work; if not, write to the Free Software |
---|
18 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
19 | // |
---|
20 | // ========== Copyright Header End ============================================ |
---|
21 | //////////////////////////////////////////////////////////////////////// |
---|
22 | // 16 X 128 R1 W1 RF macro with decoded wordlines. |
---|
23 | // REad/Write ports can be accessed in PH1 only. |
---|
24 | //////////////////////////////////////////////////////////////////////// |
---|
25 | |
---|
26 | module bw_r_rf16x128d(/*AUTOARG*/ |
---|
27 | // Outputs |
---|
28 | dout, so, |
---|
29 | // Inputs |
---|
30 | din, rd_wl, wr_wl, read_en, wr_en, rst_tri_en, rclk, se, si, |
---|
31 | reset_l, sehold |
---|
32 | ); |
---|
33 | |
---|
34 | input [127:0] din; // data input |
---|
35 | input [15:0] rd_wl; // read addr |
---|
36 | input [15:0] wr_wl; // write addr |
---|
37 | input read_en; |
---|
38 | input wr_en; // used in conjunction with |
---|
39 | // word_wen and byte_wen |
---|
40 | input rst_tri_en ; // gates off writes during SCAN. |
---|
41 | input rclk; |
---|
42 | input se, si ; |
---|
43 | input reset_l; |
---|
44 | input sehold; // hold scan in data. |
---|
45 | |
---|
46 | output [127:0] dout; |
---|
47 | output so; |
---|
48 | |
---|
49 | |
---|
50 | |
---|
51 | |
---|
52 | reg [127:0] dout; |
---|
53 | |
---|
54 | // memory array |
---|
55 | reg [127:0] inq_ary [15:0]; |
---|
56 | |
---|
57 | // internal variable |
---|
58 | integer i; |
---|
59 | reg [127:0] temp, data_in; |
---|
60 | reg [3:0] rdptr_d1, wrptr_d1; |
---|
61 | wire [160:0] scan_out; |
---|
62 | |
---|
63 | reg [127:0] wrdata_d1 ; |
---|
64 | reg ren_d1; |
---|
65 | reg wr_en_d1; |
---|
66 | reg [15:0] rd_wl_d1, wr_wl_d1; |
---|
67 | reg rst_tri_en_d1; |
---|
68 | |
---|
69 | always @(posedge rclk ) begin |
---|
70 | |
---|
71 | wrdata_d1 <= ( sehold)? wrdata_d1 : din; |
---|
72 | wr_en_d1 <= ( sehold)? wr_en_d1 : wr_en ; |
---|
73 | wr_wl_d1 <= (sehold) ? wr_wl_d1 : wr_wl ; |
---|
74 | ren_d1 <= (sehold)? ren_d1 : read_en; |
---|
75 | rd_wl_d1 <= (sehold) ? rd_wl_d1 : rd_wl ; |
---|
76 | |
---|
77 | rst_tri_en_d1 <= rst_tri_en ; // not a real flop ( only used as a trigger ). Works only for accesses made in PH1 |
---|
78 | end |
---|
79 | |
---|
80 | ////////////////////////////////////////////////////////////////////// |
---|
81 | // Read Operation |
---|
82 | ////////////////////////////////////////////////////////////////////// |
---|
83 | |
---|
84 | always @(/*AUTOSENSE*/ /*memory or*/ rd_wl_d1 or ren_d1 or reset_l |
---|
85 | or rst_tri_en_d1 or wr_en_d1 or wr_wl_d1) |
---|
86 | begin |
---|
87 | if (reset_l) |
---|
88 | |
---|
89 | begin |
---|
90 | // ---- \/ added the rst_tri_en qual on 11/11 \/------ |
---|
91 | if (ren_d1) |
---|
92 | begin |
---|
93 | |
---|
94 | |
---|
95 | case(rd_wl_d1 & {16{~rst_tri_en}}) |
---|
96 | 16'b0000_0000_0000_0000: ; // do nothing. |
---|
97 | 16'b0000_0000_0000_0001: rdptr_d1 = 4'b0000; |
---|
98 | 16'b0000_0000_0000_0010: rdptr_d1 = 4'b0001; |
---|
99 | 16'b0000_0000_0000_0100: rdptr_d1 = 4'b0010; |
---|
100 | 16'b0000_0000_0000_1000: rdptr_d1 = 4'b0011; |
---|
101 | 16'b0000_0000_0001_0000: rdptr_d1 = 4'b0100; |
---|
102 | 16'b0000_0000_0010_0000: rdptr_d1 = 4'b0101; |
---|
103 | 16'b0000_0000_0100_0000: rdptr_d1 = 4'b0110; |
---|
104 | 16'b0000_0000_1000_0000: rdptr_d1 = 4'b0111; |
---|
105 | 16'b0000_0001_0000_0000: rdptr_d1 = 4'b1000; |
---|
106 | 16'b0000_0010_0000_0000: rdptr_d1 = 4'b1001; |
---|
107 | 16'b0000_0100_0000_0000: rdptr_d1 = 4'b1010; |
---|
108 | 16'b0000_1000_0000_0000: rdptr_d1 = 4'b1011; |
---|
109 | 16'b0001_0000_0000_0000: rdptr_d1 = 4'b1100; |
---|
110 | 16'b0010_0000_0000_0000: rdptr_d1 = 4'b1101; |
---|
111 | 16'b0100_0000_0000_0000: rdptr_d1 = 4'b1110; |
---|
112 | 16'b1000_0000_0000_0000: rdptr_d1 = 4'b1111; |
---|
113 | default: rdptr_d1 = 4'bx ; |
---|
114 | endcase |
---|
115 | |
---|
116 | `ifdef INNO_MUXEX |
---|
117 | `else |
---|
118 | |
---|
119 | // Checking for Xs on the rd pointer input when read is enabled |
---|
120 | if(rdptr_d1 == 4'bx) begin |
---|
121 | `ifdef MODELSIM |
---|
122 | $display("rf_error"," read pointer error %h ", rdptr_d1[3:0]); |
---|
123 | `else |
---|
124 | $error("rf_error"," read pointer error %h ", rdptr_d1[3:0]); |
---|
125 | `endif |
---|
126 | end |
---|
127 | `endif |
---|
128 | |
---|
129 | if(rst_tri_en_d1) begin // special case |
---|
130 | dout[127:0] = 128'hFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF ; |
---|
131 | end |
---|
132 | |
---|
133 | // RW -conflict case and the case where all wlines are zero |
---|
134 | |
---|
135 | else if ((( wr_en_d1 & ~rst_tri_en ) && (rd_wl_d1 == wr_wl_d1))|| |
---|
136 | ((rd_wl_d1 & {16{~rst_tri_en}}) == 16'b0 )) begin |
---|
137 | dout[127:0] = 128'bx ; |
---|
138 | end |
---|
139 | |
---|
140 | else dout = inq_ary[rdptr_d1]; |
---|
141 | |
---|
142 | end // of if rd_en |
---|
143 | |
---|
144 | end // if reset_l |
---|
145 | else dout = 128'b0 ; |
---|
146 | end // always @ (... |
---|
147 | |
---|
148 | |
---|
149 | ////////////////////////////////////////////////////////////////////// |
---|
150 | // Write Operation |
---|
151 | ////////////////////////////////////////////////////////////////////// |
---|
152 | always @ (/*AUTOSENSE*/reset_l or rst_tri_en_d1 or wr_en_d1 |
---|
153 | or wr_wl_d1 or wrdata_d1) |
---|
154 | begin |
---|
155 | if ( reset_l) begin |
---|
156 | |
---|
157 | `ifdef INNO_MUXEX |
---|
158 | if(wr_en_d1==1'bx) begin |
---|
159 | // do nothing |
---|
160 | end |
---|
161 | `else |
---|
162 | |
---|
163 | if(wr_en_d1==1'bx) begin |
---|
164 | `ifdef MODELSIM |
---|
165 | $display("rf_error"," write enable error %b ", wr_en_d1); |
---|
166 | `else |
---|
167 | $error("rf_error"," write enable error %b ", wr_en_d1); |
---|
168 | `endif |
---|
169 | end |
---|
170 | `endif |
---|
171 | |
---|
172 | else if(wr_en_d1 & ~rst_tri_en ) begin |
---|
173 | |
---|
174 | case(wr_wl_d1) |
---|
175 | 16'b0000_0000_0000_0000: ; // do nothing. |
---|
176 | 16'b0000_0000_0000_0001: wrptr_d1 = 4'b0000; |
---|
177 | 16'b0000_0000_0000_0010: wrptr_d1 = 4'b0001; |
---|
178 | 16'b0000_0000_0000_0100: wrptr_d1 = 4'b0010; |
---|
179 | 16'b0000_0000_0000_1000: wrptr_d1 = 4'b0011; |
---|
180 | 16'b0000_0000_0001_0000: wrptr_d1 = 4'b0100; |
---|
181 | 16'b0000_0000_0010_0000: wrptr_d1 = 4'b0101; |
---|
182 | 16'b0000_0000_0100_0000: wrptr_d1 = 4'b0110; |
---|
183 | 16'b0000_0000_1000_0000: wrptr_d1 = 4'b0111; |
---|
184 | 16'b0000_0001_0000_0000: wrptr_d1 = 4'b1000; |
---|
185 | 16'b0000_0010_0000_0000: wrptr_d1 = 4'b1001; |
---|
186 | 16'b0000_0100_0000_0000: wrptr_d1 = 4'b1010; |
---|
187 | 16'b0000_1000_0000_0000: wrptr_d1 = 4'b1011; |
---|
188 | 16'b0001_0000_0000_0000: wrptr_d1 = 4'b1100; |
---|
189 | 16'b0010_0000_0000_0000: wrptr_d1 = 4'b1101; |
---|
190 | 16'b0100_0000_0000_0000: wrptr_d1 = 4'b1110; |
---|
191 | 16'b1000_0000_0000_0000: wrptr_d1 = 4'b1111; |
---|
192 | default: wrptr_d1= 4'bx ; |
---|
193 | endcase |
---|
194 | |
---|
195 | `ifdef INNO_MUXEX |
---|
196 | if(wr_wl_d1!=16'b0) |
---|
197 | inq_ary[wrptr_d1] = wrdata_d1 ; |
---|
198 | `else |
---|
199 | |
---|
200 | if(wrptr_d1 == 4'bx) begin |
---|
201 | `ifdef MODELSIM |
---|
202 | $display("rf_error"," write pointer error %h ", wrptr_d1[3:0]); |
---|
203 | `else |
---|
204 | $error("rf_error"," write pointer error %h ", wrptr_d1[3:0]); |
---|
205 | `endif |
---|
206 | end |
---|
207 | else begin |
---|
208 | if(wr_wl_d1!=16'b0) |
---|
209 | inq_ary[wrptr_d1] = wrdata_d1 ; |
---|
210 | end |
---|
211 | `endif |
---|
212 | end |
---|
213 | |
---|
214 | else begin |
---|
215 | // do nothing |
---|
216 | end |
---|
217 | |
---|
218 | end // of if reset_l |
---|
219 | |
---|
220 | end // always @ (... |
---|
221 | |
---|
222 | |
---|
223 | endmodule // rf_16x128d |
---|
224 | |
---|
225 | |
---|
226 | |
---|