OpenCores
URL https://opencores.org/ocsvn/sparc64soc/sparc64soc/trunk

Subversion Repositories sparc64soc

[/] [sparc64soc/] [trunk/] [T1-common/] [common/] [ucb_flow_jbi.v] - Blame information for rev 7

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dmitryr
// ========== Copyright Header Begin ==========================================
2
// 
3
// OpenSPARC T1 Processor File: ucb_flow_jbi.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
/*
23
//  Module Name:        ucb_flow_jbi
24
//      Description:    Unit Control Block
25
//                      - supports 1B/2B/4B/8B/16B read with flow control
26
//                      - supports 1B/2B/4B/8B write with flow control
27
//                      - does NOT support ifill request
28
//                      - supports interrupt return to IO Bridge
29
//                      - provides 1+2 deep buffer for incoming requests
30
//                        from the IO Bridge
31
//                      - provides single buffer for returns going back
32
//                        to the IO Bridge
33
//
34
//                      This module is customized for the JBI.
35
//
36
//                      Data bus width to and from the IO Bridge is
37
//                      configured through parameters UCB_IOB_WIDTH and
38
//                      IOB_UCB_WIDTH.  Supported widths are:
39
//
40
//                      IOB_UCB_WIDTH  UCB_IOB_WIDTH
41
//                      ----------------------------
42
//                      32             8
43
//                      16             8
44
//                       8             8
45
//                       4             4
46
 */
47
////////////////////////////////////////////////////////////////////////
48
// Global header file includes
49
////////////////////////////////////////////////////////////////////////
50
`include        "sys.h" // system level definition file which 
51
                        // contains the time scale definition
52
 
53
`include        "iop.h"
54
 
55
////////////////////////////////////////////////////////////////////////
56
// Local header file includes / local defines
57
////////////////////////////////////////////////////////////////////////
58
`define         UCB_BUF_DEPTH   2
59
`define         UCB_BUF_WIDTH   64+(`UCB_ADDR_HI-`UCB_ADDR_LO+1)+(`UCB_SIZE_HI-`UCB_SIZE_LO+1)+(`UCB_BUF_HI-`UCB_BUF_LO+1)+(`UCB_THR_HI-`UCB_THR_LO+1)+1+1
60
 
61
module ucb_flow_jbi (/*AUTOARG*/
62
   // Outputs
63
   ucb_iob_stall, rd_req_vld, wr_req_vld, thr_id_in, buf_id_in,
64
   size_in, addr_in, data_in, ack_busy, int_busy, ucb_iob_vld,
65
   ucb_iob_data,
66
   // Inputs
67
   clk, rst_l, iob_ucb_vld, iob_ucb_data, req_acpted, rd_ack_vld,
68
   rd_nack_vld, thr_id_out, buf_id_out, data128, data_out, int_vld,
69
   int_typ, int_thr_id, dev_id, int_stat, int_vec, iob_ucb_stall
70
   );
71
   // synopsys template
72
 
73
   parameter IOB_UCB_WIDTH = 32;  // data bus width from IOB to UCB
74
   parameter UCB_IOB_WIDTH = 8;   // data bus width from UCB to IOB
75
   parameter REG_WIDTH     = 128;  // please do not change this parameter
76
 
77
 
78
   // Globals
79
   input                                clk;
80
   input                                rst_l;
81
 
82
   // Request from IO Bridge
83
   input                                iob_ucb_vld;
84
   input [IOB_UCB_WIDTH-1:0]             iob_ucb_data;
85
   output                               ucb_iob_stall;
86
 
87
   // Request to local unit
88
   output                               rd_req_vld;
89
   output                               wr_req_vld;
90
   output [`UCB_THR_HI-`UCB_THR_LO:0]   thr_id_in;
91
   output [`UCB_BUF_HI-`UCB_BUF_LO:0]   buf_id_in;
92
   output [`UCB_SIZE_HI-`UCB_SIZE_LO:0] size_in;   // only pertinent to JBI and SPI
93
   output [`UCB_ADDR_HI-`UCB_ADDR_LO:0] addr_in;
94
   output [`UCB_DATA_HI-`UCB_DATA_LO:0] data_in;
95
   input                                req_acpted;
96
 
97
   // Ack/Nack from local unit
98
   input                                rd_ack_vld;
99
   input                                rd_nack_vld;
100
   input [`UCB_THR_HI-`UCB_THR_LO:0]     thr_id_out;
101
   input [`UCB_BUF_HI-`UCB_BUF_LO:0]     buf_id_out;
102
   input                                data128;   // set to 1 if data returned is 128 bit
103
   input [REG_WIDTH-1:0]                 data_out;
104
   output                               ack_busy;
105
 
106
   // Interrupt from local unit
107
   input                                int_vld;
108
   input [`UCB_PKT_HI-`UCB_PKT_LO:0]     int_typ;          // interrupt type
109
   input [`UCB_THR_HI-`UCB_THR_LO:0]     int_thr_id;       // interrupt thread ID
110
   input [`UCB_INT_DEV_HI-`UCB_INT_DEV_LO:0] dev_id;      // interrupt device ID
111
   input [`UCB_INT_STAT_HI-`UCB_INT_STAT_LO:0] int_stat;  // interrupt status
112
   input [`UCB_INT_VEC_HI-`UCB_INT_VEC_LO:0]   int_vec;   // interrupt vector
113
   output                               int_busy;
114
 
115
   // Output to IO Bridge
116
   output                               ucb_iob_vld;
117
   output [UCB_IOB_WIDTH-1:0]            ucb_iob_data;
118
   input                                iob_ucb_stall;
119
 
120
   // Local signals
121
   wire                                 indata_buf_vld;
122
   wire [127:0]                         indata_buf;
123
   wire                                 ucb_iob_stall_a1;
124
 
125
   wire                                 read_pending;
126
   wire                                 write_pending;
127
 
128
   wire                                 rd_buf;
129
   wire [`UCB_BUF_DEPTH-1:0]             buf_head_next;
130
   wire [`UCB_BUF_DEPTH-1:0]             buf_head;
131
   wire                                 wr_buf;
132
   wire [`UCB_BUF_DEPTH-1:0]             buf_tail_next;
133
   wire [`UCB_BUF_DEPTH-1:0]             buf_tail;
134
   wire                                 buf_full_next;
135
   wire                                 buf_full;
136
   wire                                 buf_empty_next;
137
   wire                                 buf_empty;
138
   wire [`UCB_BUF_WIDTH-1:0]             req_in;
139
   wire                                 buf0_en;
140
   wire [`UCB_BUF_WIDTH-1:0]             buf0;
141
   wire                                 buf1_en;
142
   wire [`UCB_BUF_WIDTH-1:0]             buf1;
143
   wire [`UCB_BUF_WIDTH-1:0]             req_out;
144
   wire                                 rd_req_vld_nq;
145
   wire                                 wr_req_vld_nq;
146
 
147
   wire                                 ack_buf_rd;
148
   wire                                 ack_buf_wr;
149
   wire                                 ack_buf_vld;
150
   wire                                 ack_buf_vld_next;
151
   wire                                 ack_buf_is_nack;
152
   wire                                 ack_buf_is_data128;
153
   wire [`UCB_PKT_HI-`UCB_PKT_LO:0]     ack_typ_out;
154
   wire [REG_WIDTH+`UCB_BUF_HI-`UCB_PKT_LO:0] ack_buf_in;
155
   wire [REG_WIDTH+`UCB_BUF_HI-`UCB_PKT_LO:0] ack_buf;
156
   wire [(REG_WIDTH+64)/UCB_IOB_WIDTH-1:0] ack_buf_vec;
157
 
158
   wire                                 int_buf_rd;
159
   wire                                 int_buf_wr;
160
   wire                                 int_buf_vld;
161
   wire                                 int_buf_vld_next;
162
   wire [`UCB_INT_VEC_HI-`UCB_PKT_LO:0] int_buf_in;
163
   wire [`UCB_INT_VEC_HI-`UCB_PKT_LO:0] int_buf;
164
   wire [(REG_WIDTH+64)/UCB_IOB_WIDTH-1:0] int_buf_vec;
165
 
166
   wire                                 int_last_rd;
167
   wire                                 outdata_buf_busy;
168
   wire                                 outdata_buf_wr;
169
   wire [REG_WIDTH+63:0]                outdata_buf_in;
170
   wire [(REG_WIDTH+64)/UCB_IOB_WIDTH-1:0] outdata_vec_in;
171
 
172
 
173
////////////////////////////////////////////////////////////////////////
174
// Code starts here
175
////////////////////////////////////////////////////////////////////////
176
   /************************************************************
177
    * Inbound Data
178
    ************************************************************/
179
   // Register size is hardcoded to 64 bits here
180
   ucb_bus_in #(IOB_UCB_WIDTH,64) ucb_bus_in (.rst_l(rst_l),
181
                                              .clk(clk),
182
                                              .vld(iob_ucb_vld),
183
                                              .data(iob_ucb_data),
184
                                              .stall(ucb_iob_stall),
185
                                              .indata_buf_vld(indata_buf_vld),
186
                                              .indata_buf(indata_buf),
187
                                              .stall_a1(ucb_iob_stall_a1));
188
 
189
 
190
   /************************************************************
191
    * Decode inbound packet type
192
    ************************************************************/
193
   assign        read_pending = (indata_buf[`UCB_PKT_HI:`UCB_PKT_LO] ==
194
                                 `UCB_READ_REQ) &
195
                                indata_buf_vld;
196
 
197
   assign        write_pending = (indata_buf[`UCB_PKT_HI:`UCB_PKT_LO] ==
198
                                  `UCB_WRITE_REQ) &
199
                                  indata_buf_vld;
200
 
201
   assign        ucb_iob_stall_a1 = (read_pending | write_pending) & buf_full;
202
 
203
 
204
   /************************************************************
205
    * Inbound buffer
206
    ************************************************************/
207
   // Head pointer
208
   assign        rd_buf = req_acpted;
209
   assign        buf_head_next = ~rst_l ? `UCB_BUF_DEPTH'b01 :
210
                                 rd_buf ? {buf_head[`UCB_BUF_DEPTH-2:0],
211
                                           buf_head[`UCB_BUF_DEPTH-1]} :
212
                                          buf_head;
213
   dff_ns #(`UCB_BUF_DEPTH) buf_head_ff (.din(buf_head_next),
214
                                         .clk(clk),
215
                                         .q(buf_head));
216
 
217
   // Tail pointer
218
   assign        wr_buf = (read_pending |
219
                           write_pending) &
220
                          ~buf_full;
221
   assign        buf_tail_next = ~rst_l ? `UCB_BUF_DEPTH'b01 :
222
                                 wr_buf ? {buf_tail[`UCB_BUF_DEPTH-2:0],
223
                                           buf_tail[`UCB_BUF_DEPTH-1]} :
224
                                          buf_tail;
225
   dff_ns #(`UCB_BUF_DEPTH) buf_tail_ff (.din(buf_tail_next),
226
                                         .clk(clk),
227
                                         .q(buf_tail));
228
 
229
   // Buffer full
230
   assign        buf_full_next = (buf_head_next == buf_tail_next) &
231
                                 wr_buf;
232
   dffrle_ns #(1) buf_full_ff (.din(buf_full_next),
233
                               .rst_l(rst_l),
234
                               .en(rd_buf|wr_buf),
235
                               .clk(clk),
236
                               .q(buf_full));
237
 
238
   // Buffer empty
239
   assign        buf_empty_next = ((buf_head_next == buf_tail_next) &
240
                                   rd_buf) | ~rst_l;
241
   dffe_ns #(1) buf_empty_ff (.din(buf_empty_next),
242
                              .en(rd_buf|wr_buf|~rst_l),
243
                              .clk(clk),
244
                              .q(buf_empty));
245
 
246
 
247
   assign        req_in = {indata_buf[`UCB_DATA_HI:`UCB_DATA_LO],
248
                           indata_buf[`UCB_ADDR_HI:`UCB_ADDR_LO],
249
                           indata_buf[`UCB_SIZE_HI:`UCB_SIZE_LO],
250
                           indata_buf[`UCB_BUF_HI:`UCB_BUF_LO],
251
                           indata_buf[`UCB_THR_HI:`UCB_THR_LO],
252
                           write_pending,
253
                           read_pending};
254
 
255
   // Buffer 0
256
   assign        buf0_en = buf_tail[0] & wr_buf;
257
   dffe_ns #(`UCB_BUF_WIDTH) buf0_ff (.din(req_in),
258
                                      .en(buf0_en),
259
                                      .clk(clk),
260
                                      .q(buf0));
261
   // Buffer 1
262
   assign        buf1_en = buf_tail[1] & wr_buf;
263
   dffe_ns #(`UCB_BUF_WIDTH) buf1_ff (.din(req_in),
264
                                      .en(buf1_en),
265
                                      .clk(clk),
266
                                      .q(buf1));
267
 
268
   assign        req_out = buf_head[0] ? buf0 :
269
                           buf_head[1] ? buf1 :
270
                                         {`UCB_BUF_WIDTH{1'b0}};
271
 
272
 
273
   /************************************************************
274
    * Inbound interface to local unit
275
    ************************************************************/
276
   assign        {data_in,
277
                  addr_in,
278
                  size_in,
279
                  buf_id_in,
280
                  thr_id_in,
281
                  wr_req_vld_nq,
282
                  rd_req_vld_nq} = req_out;
283
 
284
   assign        rd_req_vld = rd_req_vld_nq & ~buf_empty;
285
   assign        wr_req_vld = wr_req_vld_nq & ~buf_empty;
286
 
287
 
288
   /************************************************************
289
    * Outbound Ack/Nack
290
    ************************************************************/
291
   assign        ack_buf_wr = rd_ack_vld | rd_nack_vld;
292
 
293
   assign        ack_buf_vld_next = ack_buf_wr ? 1'b1 :
294
                                    ack_buf_rd ? 1'b0 :
295
                                                 ack_buf_vld;
296
 
297
   dffrl_ns #(1) ack_buf_vld_ff (.din(ack_buf_vld_next),
298
                                 .clk(clk),
299
                                 .rst_l(rst_l),
300
                                 .q(ack_buf_vld));
301
 
302
   dffe_ns #(1) ack_buf_is_nack_ff (.din(rd_nack_vld),
303
                                    .en(ack_buf_wr),
304
                                    .clk(clk),
305
                                    .q(ack_buf_is_nack));
306
 
307
   dffe_ns #(1) ack_buf_is_data128_ff (.din(data128),
308
                                       .en(ack_buf_wr),
309
                                       .clk(clk),
310
                                       .q(ack_buf_is_data128));
311
 
312
   assign        ack_typ_out = rd_ack_vld ? `UCB_READ_ACK:
313
                                            `UCB_READ_NACK;
314
 
315
 
316
   assign        ack_buf_in = {data_out,
317
                               buf_id_out,
318
                               thr_id_out,
319
                               ack_typ_out};
320
 
321
   dffe_ns #(REG_WIDTH+`UCB_BUF_HI-`UCB_PKT_LO+1) ack_buf_ff (.din(ack_buf_in),
322
                                                              .en(ack_buf_wr),
323
                                                              .clk(clk),
324
                                                              .q(ack_buf));
325
 
326
   assign        ack_buf_vec = ack_buf_is_nack    ? {{REG_WIDTH/UCB_IOB_WIDTH{1'b0}},
327
                                                     {64/UCB_IOB_WIDTH{1'b1}}} :
328
                               ack_buf_is_data128 ? {(REG_WIDTH+64)/UCB_IOB_WIDTH{1'b1}} :
329
                                                    {(64+64)/UCB_IOB_WIDTH{1'b1}};
330
 
331
   assign        ack_busy = ack_buf_vld;
332
 
333
 
334
   /************************************************************
335
    * Outbound Interrupt
336
    ************************************************************/
337
   // Assertion: int_buf_wr shoudn't be asserted if int_buf_busy
338
   assign        int_buf_wr = int_vld;
339
 
340
   assign        int_buf_vld_next = int_buf_wr ? 1'b1 :
341
                                    int_buf_rd ? 1'b0 :
342
                                                 int_buf_vld;
343
 
344
   dffrl_ns #(1) int_buf_vld_ff (.din(int_buf_vld_next),
345
                                 .clk(clk),
346
                                 .rst_l(rst_l),
347
                                 .q(int_buf_vld));
348
 
349
   assign        int_buf_in = {int_vec,
350
                               int_stat,
351
                               dev_id,
352
                               int_thr_id,
353
                               int_typ};
354
 
355
   dffe_ns #(`UCB_INT_VEC_HI-`UCB_PKT_LO+1) int_buf_ff (.din(int_buf_in),
356
                                                        .en(int_buf_wr),
357
                                                        .clk(clk),
358
                                                        .q(int_buf));
359
 
360
   assign        int_buf_vec = {{REG_WIDTH/UCB_IOB_WIDTH{1'b0}},
361
                                {64/UCB_IOB_WIDTH{1'b1}}};
362
 
363
   assign        int_busy = int_buf_vld;
364
 
365
 
366
   /************************************************************
367
    * Outbound ack/interrupt Arbitration
368
    ************************************************************/
369
   dffrle_ns #(1) int_last_rd_ff (.din(int_buf_rd),
370
                                  .en(ack_buf_rd|int_buf_rd),
371
                                  .rst_l(rst_l),
372
                                  .clk(clk),
373
                                  .q(int_last_rd));
374
 
375
   assign        ack_buf_rd = ~outdata_buf_busy & ack_buf_vld &
376
                              (~int_buf_vld | int_last_rd);
377
 
378
   assign        int_buf_rd = ~outdata_buf_busy & int_buf_vld &
379
                              (~ack_buf_vld | ~int_last_rd);
380
 
381
   assign        outdata_buf_wr = ack_buf_rd | int_buf_rd;
382
 
383
   assign        outdata_buf_in = ack_buf_rd ? {ack_buf[REG_WIDTH+`UCB_BUF_HI:`UCB_BUF_HI+1],
384
                                                {(`UCB_RSV_HI-`UCB_RSV_LO+1){1'b0}},
385
                                                {(`UCB_ADDR_HI-`UCB_ADDR_LO+1){1'b0}},
386
                                                {(`UCB_SIZE_HI-`UCB_SIZE_LO+1){1'b0}},
387
                                                ack_buf[`UCB_BUF_HI:`UCB_BUF_LO],
388
                                                ack_buf[`UCB_THR_HI:`UCB_THR_LO],
389
                                                ack_buf[`UCB_PKT_HI:`UCB_PKT_LO]}:
390
                                               {{REG_WIDTH{1'b0}},
391
                                                {(`UCB_INT_RSV_HI-`UCB_INT_RSV_LO+1){1'b0}},
392
                                                int_buf[`UCB_INT_VEC_HI:`UCB_INT_VEC_LO],
393
                                                int_buf[`UCB_INT_STAT_HI:`UCB_INT_STAT_LO],
394
                                                int_buf[`UCB_INT_DEV_HI:`UCB_INT_DEV_LO],
395
                                                int_buf[`UCB_THR_HI:`UCB_THR_LO],
396
                                                int_buf[`UCB_PKT_HI:`UCB_PKT_LO]};
397
 
398
   assign        outdata_vec_in = ack_buf_rd ? ack_buf_vec :
399
                                               int_buf_vec;
400
 
401
   ucb_bus_out #(UCB_IOB_WIDTH, REG_WIDTH) ucb_bus_out (.rst_l(rst_l),
402
                                                        .clk(clk),
403
                                                        .outdata_buf_wr(outdata_buf_wr),
404
                                                        .outdata_buf_in(outdata_buf_in),
405
                                                        .outdata_vec_in(outdata_vec_in),
406
                                                        .outdata_buf_busy(outdata_buf_busy),
407
                                                        .vld(ucb_iob_vld),
408
                                                        .data(ucb_iob_data),
409
                                                        .stall(iob_ucb_stall));
410
 
411
 
412
`undef          UCB_BUF_WIDTH
413
 
414
endmodule // ucb_flow_jbi
415
 
416
 
417
// Local Variables:
418
// verilog-library-directories:(".")
419
// End:
420
 
421
 
422
 
423
 
424
 
425
 
426
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.