Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / niu / rtl / niu_pio_ucb_in32.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: niu_pio_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////////////////////////////////////////////////////////////////////////////////
36//
37//
38// Copyright (C) 2003 by Sun Microsystems, Inc.
39//
40// All rights reserved. No part of this design may be reproduced,
41// stored in a retrieval system, or transmitted, in any form or by
42// any means, electronic, mechanical, photocopying, recording, or
43// otherwise, without prior written permission of Sun Microsystems,
44// Inc.
45//
46// Sun Proprietary/Confidential
47//
48//
49// Primary Contact: Jimmy.Lau@sun.com x48745
50// Description: This interface is modified based on Niagra ucb_bus_in.
51// Instaniated by UCB modules and NCU to receive
52// packets on the UCB bus. This module supports 32 bit
53// data bus in.
54//
55// Revision: 1. March 08, 2004 - John Lo
56// Changed modules name from
57// ucb_bus_in32_niu.v to niu_pio_ucb_in32
58//
59// Changed enl2clk to clk.
60//
61//
62////////////////////////////////////////////////////////////////////////////////
63
64
65module niu_pio_ucb_in32 (
66 // Global //
67 reset,
68 clk,
69 // UCB bus //
70 vld,
71 data,
72 stall,
73 // local unit //
74 indata_buf_vld,
75 indata_buf,
76 stall_a1 );
77
78// Global interface
79input reset;
80input clk;
81
82
83// UCB bus interface
84input vld;
85input [31:0] data;
86output stall;
87
88
89// Local interface
90output indata_buf_vld;
91output [127:0] indata_buf;
92input stall_a1;
93
94// Internal signals
95wire vld_d1;
96wire stall_d1;
97wire [31:0] data_d1;
98wire skid_buf0_en;
99wire vld_buf0;
100wire [31:0] data_buf0;
101wire skid_buf1_en;
102wire vld_buf1;
103wire [31:0] data_buf1;
104wire skid_buf0_sel;
105wire skid_buf1_sel;
106wire vld_mux;
107wire [31:0] data_mux;
108wire [3:0] indata_vec_next;
109wire [3:0] indata_vec;
110wire [127:0] indata_buf_next;
111wire indata_vec0_d1;
112wire stall_a1_inv;
113
114
115////////////////////////////////////////////////////////////////////////
116// Code starts here
117////////////////////////////////////////////////////////////////////////
118/************************************************************
119 * UCB bus interface flops
120 * This is to make signals going between NCU and UCB flop-to-flop
121 * to improve timing.
122 ************************************************************/
123dffre #(1) vld_d1_ff (.d(vld),
124 .reset(reset),
125 .en(~stall_d1),
126 .clk(clk),
127 .q(vld_d1) );
128
129dffe #(32) data_d1_ff (.d(data[31:0]),
130 .en(~stall_d1),
131 .clk(clk),
132 .q(data_d1[31:0]) );
133
134dffr #(1) stall_ff (.d(stall_a1),
135 .clk(clk),
136 .reset(reset),
137 .q(stall) );
138
139dffr #(1) stall_d1_ff (.d(stall),
140 .clk(clk),
141 .reset(reset),
142 .q(stall_d1) );
143
144
145/************************************************************
146 * Skid buffer
147 * We need a two deep skid buffer to handle stalling.
148 ************************************************************/
149// Assertion: stall has to be deasserted for more than 1 cycle
150// ie time between two separate stalls has to be
151// at least two cycles. Otherwise, contents from
152// skid buffer will be lost.
153
154// Buffer 0
155assign skid_buf0_en = stall_a1 & ~stall;
156
157dffre #(1) vld_buf0_ff (.d(vld_d1),
158 .reset(reset),
159 .en(skid_buf0_en),
160 .clk(clk),
161 .q(vld_buf0) );
162
163dffe #(32) data_buf0_ff (.d(data_d1[31:0]),
164 .en(skid_buf0_en),
165 .clk(clk),
166 .q(data_buf0[31:0]) );
167
168// Buffer 1
169dffr #(1) skid_buf1_en_ff (.d(skid_buf0_en),
170 .clk(clk),
171 .reset(reset),
172 .q(skid_buf1_en) );
173
174dffre #(1) vld_buf1_ff (.d(vld_d1),
175 .reset(reset),
176 .en(skid_buf1_en),
177 .clk(clk),
178 .q(vld_buf1) );
179
180dffe #(32) data_buf1_ff (.d(data_d1[31:0]),
181 .en(skid_buf1_en),
182 .clk(clk),
183 .q(data_buf1[31:0]) );
184
185/************************************************************
186 * Mux between skid buffer and interface flop
187 ************************************************************/
188// Assertion: stall has to be deasserted for more than 1 cycle
189// ie time between two separate stalls has to be
190// at least two cycles. Otherwise, contents from
191// skid buffer will be lost.
192
193assign skid_buf0_sel = ~stall_a1 & stall;
194
195dffr #(1) skid_buf1_sel_ff (.d(skid_buf0_sel),
196 .clk(clk),
197 .reset(reset),
198 .q(skid_buf1_sel) );
199
200assign vld_mux = skid_buf0_sel ? vld_buf0 :
201 skid_buf1_sel ? vld_buf1 : vld_d1;
202
203assign data_mux[31:0] = skid_buf0_sel ? data_buf0[31:0] :
204 skid_buf1_sel ? data_buf1[31:0] : data_d1[31:0];
205
206
207/************************************************************
208 * Assemble inbound data
209 ************************************************************/
210// valid vector
211assign indata_vec_next[3:0] = {vld_mux,indata_vec[3:1]};
212assign stall_a1_inv = ~stall_a1 ;
213dffre #(4) indata_vec_ff (.d(indata_vec_next[3:0]),
214 .en(stall_a1_inv),
215 .reset(reset),
216 .clk(clk),
217 .q(indata_vec[3:0]) );
218
219// data buffer
220assign indata_buf_next[127:0] = {data_mux[31:0],indata_buf[127:32]};
221dffe #(128) indata_buf_ff (.d(indata_buf_next[127:0]),
222 .en(stall_a1_inv),
223 .clk(clk),
224 .q(indata_buf[127:0]) );
225
226// detect a new packet
227dffre #(1) indata_vec0_d1_ff (.d(indata_vec[0]),
228 .reset(reset),
229 .en(stall_a1_inv),
230 .clk(clk),
231 .q(indata_vec0_d1) );
232
233assign indata_buf_vld = indata_vec[0] & ~indata_vec0_d1;
234
235
236endmodule // niu_pio_ucb_in32
237