Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: dmu_dsn_ucb_in32.v | |
4 | // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
5 | // 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
6 | // | |
7 | // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
8 | // | |
9 | // This program is free software; you can redistribute it and/or modify | |
10 | // it under the terms of the GNU General Public License as published by | |
11 | // the Free Software Foundation; version 2 of the License. | |
12 | // | |
13 | // This program is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | // | |
18 | // You should have received a copy of the GNU General Public License | |
19 | // along with this program; if not, write to the Free Software | |
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | // | |
22 | // For the avoidance of doubt, and except that if any non-GPL license | |
23 | // choice is available it will apply instead, Sun elects to use only | |
24 | // the General Public License version 2 (GPLv2) at this time for any | |
25 | // software where a choice of GPL license versions is made | |
26 | // available with the language indicating that GPLv2 or any later version | |
27 | // may be used, or where a choice of which version of the GPL is applied is | |
28 | // otherwise unspecified. | |
29 | // | |
30 | // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
31 | // CA 95054 USA or visit www.sun.com if you need additional information or | |
32 | // have any questions. | |
33 | // | |
34 | // ========== Copyright Header End ============================================ | |
35 | module dmu_dsn_ucb_in32 ( | |
36 | // Global // | |
37 | reset, | |
38 | enl2clk, | |
39 | // UCB bus // | |
40 | vld, | |
41 | data, | |
42 | stall, | |
43 | // local unit // | |
44 | indata_buf_vld, | |
45 | indata_buf, | |
46 | stall_a1 ); | |
47 | ||
48 | // Global interface | |
49 | input reset; | |
50 | input enl2clk; | |
51 | ||
52 | ||
53 | // UCB bus interface | |
54 | input vld; | |
55 | input [31:0] data; | |
56 | output stall; | |
57 | ||
58 | ||
59 | // Local interface | |
60 | output indata_buf_vld; | |
61 | output [127:0] indata_buf; | |
62 | input stall_a1; | |
63 | ||
64 | // Internal signals | |
65 | reg vld_d1; | |
66 | reg stall; | |
67 | reg stall_d1; | |
68 | reg [31:0] data_d1; | |
69 | wire skid_buf0_en; | |
70 | reg vld_buf0; | |
71 | reg [31:0] data_buf0; | |
72 | reg skid_buf1_en; | |
73 | reg vld_buf1; | |
74 | reg [31:0] data_buf1; | |
75 | wire skid_buf0_sel; | |
76 | reg skid_buf1_sel; | |
77 | wire vld_mux; | |
78 | wire [31:0] data_mux; | |
79 | wire [3:0] indata_vec_next; | |
80 | reg [3:0] indata_vec; | |
81 | wire [127:0] indata_buf_next; | |
82 | reg indata_vec0_d1; | |
83 | wire stall_a1_inv; | |
84 | reg [127:0] indata_buf; | |
85 | ||
86 | ||
87 | //////////////////////////////////////////////////////////////////////// | |
88 | // Code starts here | |
89 | //////////////////////////////////////////////////////////////////////// | |
90 | /************************************************************ | |
91 | * UCB bus interface flops | |
92 | * This is to make signals going between NCU and UCB flop-to-flop | |
93 | * to improve timing. | |
94 | ************************************************************/ | |
95 | /* | |
96 | dffre #(1) vld_d1_ff (.d(vld), | |
97 | .reset(reset), | |
98 | .en(~stall_d1), | |
99 | .clk(enl2clk), | |
100 | .q(vld_d1) ); | |
101 | ||
102 | dffe #(32) data_d1_ff (.d(data[31:0]), | |
103 | .en(~stall_d1), | |
104 | .clk(enl2clk), | |
105 | .q(data_d1[31:0]) ); | |
106 | ||
107 | dffr #(1) stall_ff (.d(stall_a1), | |
108 | .clk(enl2clk), | |
109 | .reset(reset), | |
110 | .q(stall) ); | |
111 | ||
112 | dffr #(1) stall_d1_ff (.d(stall), | |
113 | .clk(enl2clk), | |
114 | .reset(reset), | |
115 | .q(stall_d1) ); | |
116 | */ | |
117 | always @(posedge enl2clk ) begin | |
118 | if (reset) begin | |
119 | vld_d1 <= 1'b0; | |
120 | stall <= 1'b0; | |
121 | stall_d1<= 1'b0; | |
122 | end | |
123 | else begin | |
124 | if (~stall_d1) vld_d1 <= vld; | |
125 | stall <= stall_a1; | |
126 | stall_d1 <= stall; | |
127 | end | |
128 | end | |
129 | ||
130 | always @(posedge enl2clk ) | |
131 | if (reset) begin | |
132 | data_d1[31:0] <= 32'b0; | |
133 | end | |
134 | else begin | |
135 | if (~stall_d1) data_d1[31:0] <= data[31:0]; | |
136 | end | |
137 | ||
138 | /************************************************************ | |
139 | * Skid buffer | |
140 | * We need a two deep skid buffer to handle stalling. | |
141 | ************************************************************/ | |
142 | // Assertion: stall has to be deasserted for more than 1 cycle | |
143 | // ie time between two separate stalls has to be | |
144 | // at least two cycles. Otherwise, contents from | |
145 | // skid buffer will be lost. | |
146 | ||
147 | // Buffer 0 | |
148 | assign skid_buf0_en = stall_a1 & ~stall; | |
149 | /* | |
150 | dffre #(1) vld_buf0_ff (.d(vld_d1), | |
151 | .reset(reset), | |
152 | .en(skid_buf0_en), | |
153 | .clk(enl2clk), | |
154 | .q(vld_buf0) ); | |
155 | ||
156 | dffe #(32) data_buf0_ff (.d(data_d1[31:0]), | |
157 | .en(skid_buf0_en), | |
158 | .clk(enl2clk), | |
159 | .q(data_buf0[31:0]) ); | |
160 | ||
161 | // Buffer 1 | |
162 | dffr #(1) skid_buf1_en_ff (.d(skid_buf0_en), | |
163 | .clk(enl2clk), | |
164 | .reset(reset), | |
165 | .q(skid_buf1_en) ); | |
166 | ||
167 | dffre #(1) vld_buf1_ff (.d(vld_d1), | |
168 | .reset(reset), | |
169 | .en(skid_buf1_en), | |
170 | .clk(enl2clk), | |
171 | .q(vld_buf1) ); | |
172 | ||
173 | dffe #(32) data_buf1_ff (.d(data_d1[31:0]), | |
174 | .en(skid_buf1_en), | |
175 | .clk(enl2clk), | |
176 | .q(data_buf1[31:0]) ); | |
177 | */ | |
178 | ||
179 | always @(posedge enl2clk ) begin | |
180 | if (reset) begin | |
181 | vld_buf0 <= 1'b0; | |
182 | skid_buf1_en <= 1'b0; | |
183 | vld_buf1 <= 1'b0; | |
184 | end | |
185 | else begin | |
186 | if (skid_buf0_en) vld_buf0 <= vld_d1; | |
187 | skid_buf1_en <= skid_buf0_en; | |
188 | if (skid_buf1_en) vld_buf1 <= vld_d1; | |
189 | end | |
190 | end | |
191 | ||
192 | always @(posedge enl2clk ) | |
193 | if (reset) begin | |
194 | data_buf0[31:0]<= 32'b0; | |
195 | data_buf1[31:0]<= 32'b0; | |
196 | end | |
197 | else begin | |
198 | if (skid_buf0_en) data_buf0[31:0]<= data_d1[31:0]; | |
199 | if (skid_buf1_en) data_buf1[31:0]<= data_d1[31:0]; | |
200 | end | |
201 | ||
202 | /************************************************************ | |
203 | * Mux between skid buffer and interface flop | |
204 | ************************************************************/ | |
205 | // Assertion: stall has to be deasserted for more than 1 cycle | |
206 | // ie time between two separate stalls has to be | |
207 | // at least two cycles. Otherwise, contents from | |
208 | // skid buffer will be lost. | |
209 | ||
210 | assign skid_buf0_sel = ~stall_a1 & stall; | |
211 | /* | |
212 | dffr #(1) skid_buf1_sel_ff (.d(skid_buf0_sel), | |
213 | .clk(enl2clk), | |
214 | .reset(reset), | |
215 | .q(skid_buf1_sel) ); | |
216 | */ | |
217 | always @(posedge enl2clk ) begin | |
218 | if (reset) begin | |
219 | skid_buf1_sel <= 1'b0; | |
220 | end | |
221 | else begin | |
222 | skid_buf1_sel <= skid_buf0_sel; | |
223 | end | |
224 | end | |
225 | ||
226 | assign vld_mux = skid_buf0_sel ? vld_buf0 : | |
227 | skid_buf1_sel ? vld_buf1 : vld_d1; | |
228 | ||
229 | assign data_mux[31:0] = skid_buf0_sel ? data_buf0[31:0] : | |
230 | skid_buf1_sel ? data_buf1[31:0] : data_d1[31:0]; | |
231 | ||
232 | ||
233 | /************************************************************ | |
234 | * Assemble inbound data | |
235 | ************************************************************/ | |
236 | // valid vector | |
237 | assign indata_vec_next[3:0] = {vld_mux,indata_vec[3:1]}; | |
238 | assign stall_a1_inv = ~stall_a1 ; | |
239 | /* | |
240 | dffre #(4) indata_vec_ff (.d(indata_vec_next[3:0]), | |
241 | .en(stall_a1_inv), | |
242 | .reset(reset), | |
243 | .clk(enl2clk), | |
244 | .q(indata_vec[3:0]) ); | |
245 | */ | |
246 | // data buffer | |
247 | assign indata_buf_next[127:0] = {data_mux[31:0],indata_buf[127:32]}; | |
248 | /* | |
249 | dffe #(128) indata_buf_ff (.d(indata_buf_next[127:0]), | |
250 | .en(stall_a1_inv), | |
251 | .clk(enl2clk), | |
252 | .q(indata_buf[127:0]) ); | |
253 | */ | |
254 | // detect a new packet | |
255 | /* | |
256 | dffre #(1) indata_vec0_d1_ff (.d(indata_vec[0]), | |
257 | .reset(reset), | |
258 | .en(stall_a1_inv), | |
259 | .clk(enl2clk), | |
260 | .q(indata_vec0_d1) ); | |
261 | */ | |
262 | always @(posedge enl2clk ) | |
263 | if (reset) begin | |
264 | indata_vec[3:0] <= 4'b0; | |
265 | indata_vec0_d1 <= 1'b0; | |
266 | end | |
267 | else begin | |
268 | if (stall_a1_inv) indata_vec[3:0] <= indata_vec_next[3:0]; | |
269 | if (stall_a1_inv) indata_vec0_d1 <= indata_vec[0]; | |
270 | end | |
271 | ||
272 | always @(posedge enl2clk ) | |
273 | if (reset) begin | |
274 | indata_buf[127:0]<= 128'b0; | |
275 | end | |
276 | else begin | |
277 | if (stall_a1_inv) indata_buf[127:0]<= indata_buf_next[127:0]; | |
278 | end | |
279 | ||
280 | ||
281 | assign indata_buf_vld = indata_vec[0] & ~indata_vec0_d1; | |
282 | ||
283 | ||
284 | endmodule // dmu_dsn_ucb_in32 |