Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / mcu / rtl / mcu_ucbbuf_ctl.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: mcu_ucbbuf_ctl.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`define DRIF_MCU_STATE_00 5'd0
36`define DRIF_MCU_STATE_01 5'd1
37`define DRIF_MCU_STATE_02 5'd2
38`define DRIF_MCU_STATE_03 5'd3
39`define DRIF_MCU_STATE_04 5'd4
40`define DRIF_MCU_STATE_05 5'd5
41`define DRIF_MCU_STATE_06 5'd6
42`define DRIF_MCU_STATE_07 5'd7
43`define DRIF_MCU_STATE_08 5'd8
44`define DRIF_MCU_STATE_09 5'd9
45`define DRIF_MCU_STATE_10 5'd10
46`define DRIF_MCU_STATE_11 5'd11
47`define DRIF_MCU_STATE_12 5'd12
48`define DRIF_MCU_STATE_13 5'd13
49`define DRIF_MCU_STATE_14 5'd14
50`define DRIF_MCU_STATE_15 5'd15
51`define DRIF_MCU_STATE_16 5'd16
52`define DRIF_MCU_STATE_17 5'd17
53`define DRIF_MCU_STATE_18 5'd18
54`define DRIF_MCU_STATE_19 5'd19
55`define DRIF_MCU_STATE_20 5'd20
56`define DRIF_MCU_STATE_21 5'd21
57`define DRIF_MCU_STATE_22 5'd22
58`define DRIF_MCU_STATE_23 5'd23
59`define DRIF_MCU_STATE_24 5'd24
60`define DRIF_MCU_STATE_25 5'd25
61`define DRIF_MCU_STATE_26 5'd26
62
63`define DRIF_MCU_STATE_MAX 4
64`define DRIF_MCU_STATE_WIDTH 5
65
66//
67// UCB Packet Type
68// ===============
69//
70`define UCB_READ_NACK 4'b0000 // ack/nack types
71`define UCB_READ_ACK 4'b0001
72`define UCB_WRITE_ACK 4'b0010
73`define UCB_IFILL_ACK 4'b0011
74`define UCB_IFILL_NACK 4'b0111
75
76`define UCB_READ_REQ 4'b0100 // req types
77`define UCB_WRITE_REQ 4'b0101
78`define UCB_IFILL_REQ 4'b0110
79
80`define UCB_INT 4'b1000 // plain interrupt
81`define UCB_INT_VEC 4'b1100 // interrupt with vector
82`define UCB_RESET_VEC 4'b1101 // reset with vector
83`define UCB_IDLE_VEC 4'b1110 // idle with vector
84`define UCB_RESUME_VEC 4'b1111 // resume with vector
85
86
87//
88// UCB Data Packet Format
89// ======================
90//
91`define UCB_NOPAY_PKT_WIDTH 64 // packet without payload
92`define UCB_64PAY_PKT_WIDTH 128 // packet with 64 bit payload
93`define UCB_128PAY_PKT_WIDTH 192 // packet with 128 bit payload
94
95`define UCB_DATA_EXT_HI 191 // (64) extended data
96`define UCB_DATA_EXT_LO 128
97`define UCB_DATA_HI 127 // (64) data
98`define UCB_DATA_LO 64
99`define UCB_RSV_HI 63 // (9) reserved bits
100`define UCB_RSV_LO 55
101`define UCB_ADDR_HI 54 // (40) bit address
102`define UCB_ADDR_LO 15
103`define UCB_SIZE_HI 14 // (3) request size
104`define UCB_SIZE_LO 12
105`define UCB_BUF_HI 11 // (2) buffer ID
106`define UCB_BUF_LO 10
107`define UCB_THR_HI 9 // (6) cpu/thread ID
108`define UCB_THR_LO 4
109`define UCB_PKT_HI 3 // (4) packet type
110`define UCB_PKT_LO 0
111
112`define UCB_DATA_EXT_WIDTH 64
113`define UCB_DATA_WIDTH 64
114`define UCB_RSV_WIDTH 9
115`define UCB_ADDR_WIDTH 40
116`define UCB_SIZE_WIDTH 3
117`define UCB_BUF_WIDTH 2
118`define UCB_THR_WIDTH 6
119`define UCB_PKT_WIDTH 4
120
121// Size encoding for the UCB_SIZE_HI/LO field
122// 000 - byte
123// 001 - half-word
124// 010 - word
125// 011 - double-word
126`define UCB_SIZE_1B 3'b000
127`define UCB_SIZE_2B 3'b001
128`define UCB_SIZE_4B 3'b010
129`define UCB_SIZE_8B 3'b011
130`define UCB_SIZE_16B 3'b100
131
132
133//
134// UCB Interrupt Packet Format
135// ===========================
136//
137`define UCB_INT_PKT_WIDTH 64
138
139`define UCB_INT_RSV_HI 63 // (7) reserved bits
140`define UCB_INT_RSV_LO 57
141`define UCB_INT_VEC_HI 56 // (6) interrupt vector
142`define UCB_INT_VEC_LO 51
143`define UCB_INT_STAT_HI 50 // (32) interrupt status
144`define UCB_INT_STAT_LO 19
145`define UCB_INT_DEV_HI 18 // (9) device ID
146`define UCB_INT_DEV_LO 10
147//`define UCB_THR_HI 9 // (6) cpu/thread ID shared with
148//`define UCB_THR_LO 4 data packet format
149//`define UCB_PKT_HI 3 // (4) packet type shared with
150//`define UCB_PKT_LO 0 // data packet format
151
152`define UCB_INT_RSV_WIDTH 7
153`define UCB_INT_VEC_WIDTH 6
154`define UCB_INT_STAT_WIDTH 32
155`define UCB_INT_DEV_WIDTH 9
156
157
158`define MCU_CAS_BIT2_SEL_PA10 4'h1
159`define MCU_CAS_BIT2_SEL_PA32 4'h2
160`define MCU_CAS_BIT2_SEL_PA33 4'h4
161`define MCU_CAS_BIT2_SEL_PA34 4'h8
162
163`define MCU_CAS_BIT3_SEL_PA11 4'h1
164`define MCU_CAS_BIT3_SEL_PA33 4'h2
165`define MCU_CAS_BIT3_SEL_PA34 4'h4
166`define MCU_CAS_BIT3_SEL_PA35 4'h8
167
168`define MCU_CAS_BIT4_SEL_PA12 3'h1
169`define MCU_CAS_BIT4_SEL_PA35 3'h2
170`define MCU_CAS_BIT4_SEL_PA36 3'h4
171
172`define MCU_DIMMHI_SEL_ZERO 6'h01
173`define MCU_DIMMHI_SEL_PA32 6'h02
174`define MCU_DIMMHI_SEL_PA33 6'h04
175`define MCU_DIMMHI_SEL_PA34 6'h08
176`define MCU_DIMMHI_SEL_PA35 6'h10
177`define MCU_DIMMHI_SEL_PA36 6'h20
178
179`define MCU_DIMMLO_SEL_ZERO 4'h1
180`define MCU_DIMMLO_SEL_PA10 4'h2
181`define MCU_DIMMLO_SEL_PA11 4'h4
182`define MCU_DIMMLO_SEL_PA12 4'h8
183
184`define MCU_RANK_SEL_ZERO 7'h01
185`define MCU_RANK_SEL_PA32 7'h02
186`define MCU_RANK_SEL_PA33 7'h04
187`define MCU_RANK_SEL_PA34 7'h08
188`define MCU_RANK_SEL_PA35 7'h10
189`define MCU_RANK_SEL_PA10 7'h20
190`define MCU_RANK_SEL_PA11 7'h40
191
192`define MCU_ADDR_ERR_SEL_39_32 6'h01
193`define MCU_ADDR_ERR_SEL_39_33 6'h02
194`define MCU_ADDR_ERR_SEL_39_34 6'h04
195`define MCU_ADDR_ERR_SEL_39_35 6'h08
196`define MCU_ADDR_ERR_SEL_39_36 6'h10
197`define MCU_ADDR_ERR_SEL_39_37 6'h20
198
199`define DRIF_ERR_IDLE 0
200`define DRIF_ERR_IDLE_ST 5'h1
201`define DRIF_ERR_READ0 1
202`define DRIF_ERR_READ0_ST 5'h2
203`define DRIF_ERR_WRITE 2
204`define DRIF_ERR_WRITE_ST 5'h4
205`define DRIF_ERR_READ1 3
206`define DRIF_ERR_READ1_ST 5'h8
207`define DRIF_ERR_CRC_FR 4
208`define DRIF_ERR_CRC_FR_ST 5'h10
209
210`define MCU_WDQ_RF_DATA_WIDTH 72
211`define MCU_WDQ_RF_ADDR_WIDTH 5
212`define MCU_WDQ_RF_DEPTH 32
213
214// FBDIMM header defines
215`define FBD_TS0_HDR 12'hbfe
216`define FBD_TS1_HDR 12'hffe
217`define FBD_TS2_HDR 12'h7fe
218`define FBD_TS3_HDR 12'h3fe
219
220// MCU FBDIMM Channel commands
221`define FBD_DRAM_CMD_NOP 3'h0
222`define FBD_DRAM_CMD_OTHER 3'h1
223`define FBD_DRAM_CMD_RD 3'h2
224`define FBD_DRAM_CMD_WR 3'h3
225`define FBD_DRAM_CMD_ACT 3'h4
226`define FBD_DRAM_CMD_WDATA 3'h5
227
228`define FBD_DRAM_CMD_OTHER_REF 3'h5
229`define FBD_DRAM_CMD_OTHER_SRE 3'h4
230`define FBD_DRAM_CMD_OTHER_PDE 3'h2
231`define FBD_DRAM_CMD_OTHER_SRPDX 3'h3
232
233`define FBD_CHNL_CMD_NOP 2'h0
234`define FBD_CHNL_CMD_SYNC 2'h1
235`define FBD_CHNL_CMD_SCRST 2'h2
236
237`define FBDIC_ERR_IDLE_ST 7'h01
238`define FBDIC_ERR_IDLE 0
239
240`define FBDIC_ERR_STS_ST 7'h02
241`define FBDIC_ERR_STS 1
242
243`define FBDIC_ERR_SCRST_ST 7'h04
244`define FBDIC_ERR_SCRST 2
245
246`define FBDIC_ERR_SCRST_STS_ST 7'h08
247`define FBDIC_ERR_SCRST_STS 3
248
249`define FBDIC_ERR_STS2_ST 7'h10
250`define FBDIC_ERR_STS2 4
251
252`define FBDIC_ERR_FASTRST_ST 7'h20
253`define FBDIC_ERR_FASTRST 5
254
255`define FBDIC_ERR_FASTRST_STS_ST 7'h40
256`define FBDIC_ERR_FASTRST_STS 6
257
258
259// IBIST DEFINITION
260
261`define L_2_0 12'h555
262`define L_2_1 12'h555
263`define L_4_0 12'h333
264`define L_4_1 12'h333
265`define L_6_0 12'h1c7
266`define L_6_1 12'h1c7
267`define L_8_0 12'h0f0
268`define L_8_1 12'hf0f
269`define L_24_0 12'h000
270`define L_24_1 12'hfff
271
272`define idle 4'h0
273
274`define error_0 4'h1
275`define error_1 4'h2
276
277`define start1_0 4'h3
278`define start1_1 4'h4
279`define start2_0 4'h5
280`define start2_1 4'h6
281
282`define pat1_0 4'h7
283`define pat1_1 4'h8
284
285`define clkpat_0 4'h9
286`define clkpat_1 4'ha
287
288`define const_0 4'hb
289`define const_1 4'hc
290
291`define stop1_0 4'h1
292`define stop1_1 4'h2
293
294`define stop2_0 4'hd
295`define stop2_1 4'he
296`define error 4'hf
297
298`define IBTX_STATE_IDLE 0
299`define IBTX_STATE_PATT 1
300`define IBTX_STATE_MODN 2
301`define IBTX_STATE_CONST 3
302
303`define IBRX_STATE_IDLE 0
304`define IBRX_STATE_PATT 1
305`define IBRX_STATE_MODN 2
306`define IBRX_STATE_CONST 3
307
308
309
310////////////////////////////////////////////////////////////////////////
311// Local header file includes / local defines
312////////////////////////////////////////////////////////////////////////
313`define UCB_BUF_DEPTH 2
314//`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
315`define UCB_BUF_WIDTH 117
316
317module mcu_ucbbuf_ctl (
318 iob_ucb_vld,
319 iob_ucb_data,
320 ucb_iob_stall,
321 rd_req_vld,
322 wr_req_vld,
323 thr_id_in,
324 buf_id_in,
325 size_in,
326 addr_in,
327 data_in,
328 req_acpted,
329 rd_ack_vld,
330 rd_nack_vld,
331 thr_id_out,
332 buf_id_out,
333 data128,
334 data_out,
335 ack_busy,
336 int_vld,
337 int_typ,
338 int_thr_id,
339 dev_id,
340 int_stat,
341 int_vec,
342 int_busy,
343 ucb_iob_vld,
344 ucb_iob_data,
345 iob_ucb_stall,
346 l1clk,
347 scan_in,
348 scan_out,
349 tcu_aclk,
350 tcu_bclk,
351 tcu_scan_en);
352wire siclk;
353wire soclk;
354wire se;
355wire ucbin_scanin;
356wire ucbin_scanout;
357wire [0:0] inv_buf_head_next;
358wire [0:0] inv_buf_head;
359wire buf_head_ff_scanin;
360wire buf_head_ff_scanout;
361wire [0:0] inv_buf_tail_next;
362wire [0:0] inv_buf_tail;
363wire buf_tail_ff_scanin;
364wire buf_tail_ff_scanout;
365wire buf_full_en;
366wire buf_full_ff_scanin;
367wire buf_full_ff_scanout;
368wire buf_empty_en;
369wire inv_buf_empty_next;
370wire inv_buf_empty;
371wire buf_empty_ff_scanin;
372wire buf_empty_ff_scanout;
373wire buf0_ff_scanin;
374wire buf0_ff_scanout;
375wire buf1_ff_scanin;
376wire buf1_ff_scanout;
377wire ack_buf_vld_ff_scanin;
378wire ack_buf_vld_ff_scanout;
379wire ack_buf_is_nack_ff_scanin;
380wire ack_buf_is_nack_ff_scanout;
381wire ack_buf_is_data128_ff_scanin;
382wire ack_buf_is_data128_ff_scanout;
383wire ack_buf_ff_scanin;
384wire ack_buf_ff_scanout;
385wire int_buf_vld_ff_scanin;
386wire int_buf_vld_ff_scanout;
387wire int_buf_ff_scanin;
388wire int_buf_ff_scanout;
389wire int_last_rd_en;
390wire int_last_rd_ff_scanin;
391wire int_last_rd_ff_scanout;
392wire ucbout_scanin;
393wire ucbout_scanout;
394
395
396// parameter IOB_UCB_WIDTH = 4; // data bus width from IOB to UCB
397// parameter UCB_IOB_WIDTH = 4; // data bus width from UCB to IOB
398// parameter REG_WIDTH = 64; // please do not change this parameter
399
400
401// Request from NCU
402input iob_ucb_vld;
403input [3:0] iob_ucb_data;
404output ucb_iob_stall;
405
406// Request to local unit
407output rd_req_vld;
408output wr_req_vld;
409output [`UCB_THR_HI-`UCB_THR_LO:0] thr_id_in;
410output [`UCB_BUF_HI-`UCB_BUF_LO:0] buf_id_in;
411output [`UCB_SIZE_HI-`UCB_SIZE_LO:0] size_in; // only pertinent to PCI
412output [`UCB_ADDR_HI-`UCB_ADDR_LO:0] addr_in;
413output [`UCB_DATA_HI-`UCB_DATA_LO:0] data_in;
414input req_acpted;
415
416// Ack/Nack from local unit
417input rd_ack_vld;
418input rd_nack_vld;
419input [`UCB_THR_HI-`UCB_THR_LO:0] thr_id_out;
420input [`UCB_BUF_HI-`UCB_BUF_LO:0] buf_id_out;
421input data128; // set to 1 if data returned is 128 bit
422input [63:0] data_out;
423output ack_busy;
424
425// Interrupt from local unit
426input int_vld;
427input [`UCB_PKT_HI-`UCB_PKT_LO:0] int_typ; // interrupt type
428input [`UCB_THR_HI-`UCB_THR_LO:0] int_thr_id; // interrupt thread ID
429input [`UCB_INT_DEV_HI-`UCB_INT_DEV_LO:0] dev_id; // interrupt device ID
430input [`UCB_INT_STAT_HI-`UCB_INT_STAT_LO:0] int_stat; // interrupt status
431input [`UCB_INT_VEC_HI-`UCB_INT_VEC_LO:0] int_vec; // interrupt vector
432output int_busy;
433
434// Output to IO Bridge
435output ucb_iob_vld;
436output [3:0] ucb_iob_data;
437input iob_ucb_stall;
438
439// Globals
440input l1clk;
441input scan_in;
442output scan_out;
443input tcu_aclk;
444input tcu_bclk;
445input tcu_scan_en;
446
447// Local signals
448wire indata_buf_vld;
449wire [127:0] indata_buf;
450wire ucb_iob_stall_a1;
451
452wire read_pending;
453wire write_pending;
454wire illegal_write_size;
455
456wire rd_buf;
457wire [1:0] buf_head_next;
458wire [1:0] buf_head;
459wire wr_buf;
460wire [1:0] buf_tail_next;
461wire [1:0] buf_tail;
462wire buf_full_next;
463wire buf_full;
464wire buf_empty_next;
465wire buf_empty;
466wire [116:0] req_in;
467wire buf0_en;
468wire [116:0] buf0;
469wire buf1_en;
470wire [116:0] buf1;
471wire [116:0] req_out;
472wire rd_req_vld_nq;
473wire wr_req_vld_nq;
474
475wire ack_buf_rd;
476wire ack_buf_wr;
477wire ack_buf_vld;
478wire ack_buf_vld_next;
479wire ack_buf_is_nack;
480wire ack_buf_is_data128;
481wire [3:0] ack_typ_out;
482wire [75:0] ack_buf_in;
483wire [75:0] ack_buf;
484wire [31:0] ack_buf_vec;
485
486wire int_buf_rd;
487wire int_buf_wr;
488wire int_buf_vld;
489wire int_buf_vld_next;
490wire [56:0] int_buf_in;
491wire [56:0] int_buf;
492wire [31:0] int_buf_vec;
493
494wire int_last_rd;
495wire outdata_buf_busy;
496wire outdata_buf_wr;
497wire [127:0] outdata_buf_in;
498wire [31:0] outdata_vec_in;
499
500
501////////////////////////////////////////////////////////////////////////
502// Code starts here
503////////////////////////////////////////////////////////////////////////
504
505// Scan reassigns
506assign siclk = tcu_aclk;
507assign soclk = tcu_bclk;
508assign se = tcu_scan_en;
509
510/************************************************************
511 * Inbound Data
512 ************************************************************/
513// Register size is hardcoded to 64 bits here because all
514// units using the UCB module will only write to 64 bit registers.
515mcu_ucbin_ctl ucbin (
516 .scan_in(ucbin_scanin),
517 .scan_out(ucbin_scanout),
518 .l1clk(l1clk),
519 .vld(iob_ucb_vld),
520 .data(iob_ucb_data),
521 .stall(ucb_iob_stall),
522 .indata_buf_vld(indata_buf_vld),
523 .indata_buf(indata_buf),
524 .stall_a1(ucb_iob_stall_a1),
525 .tcu_aclk(tcu_aclk),
526 .tcu_bclk(tcu_bclk),
527 .tcu_scan_en(tcu_scan_en));
528
529
530/************************************************************
531 * Decode inbound packet type
532 ************************************************************/
533assign read_pending = (indata_buf[`UCB_PKT_HI:`UCB_PKT_LO] == `UCB_READ_REQ) & indata_buf_vld;
534
535assign write_pending = (indata_buf[`UCB_PKT_HI:`UCB_PKT_LO] ==
536 `UCB_WRITE_REQ) &
537 indata_buf_vld;
538
539// 3'b011 is the encoding for double word. All writes have to be
540// 64 bits except writes going to PCI. PCI will instantiate a
541// customized version of UCB.
542assign illegal_write_size = (indata_buf[`UCB_SIZE_HI:`UCB_SIZE_LO] !=
543 3'b011);
544
545assign ucb_iob_stall_a1 = (read_pending | write_pending) & buf_full;
546
547
548/************************************************************
549 * Inbound buffer
550 ************************************************************/
551// Head pointer
552assign rd_buf = req_acpted;
553assign buf_head_next = rd_buf ? {buf_head[0],
554 buf_head[1]} :
555 buf_head;
556
557assign inv_buf_head_next[0] = ~buf_head_next[0];
558assign buf_head[0] = ~inv_buf_head[0];
559
560mcu_ucbbuf_ctl_msff_ctl_macro__width_2 buf_head_ff (
561 .scan_in(buf_head_ff_scanin),
562 .scan_out(buf_head_ff_scanout),
563 .din({buf_head_next[1],inv_buf_head_next[0]}),
564 .l1clk(l1clk),
565 .dout({buf_head[1],inv_buf_head[0]}),
566 .siclk(siclk),
567 .soclk(soclk));
568
569// Tail pointer
570assign wr_buf = (read_pending |
571 (write_pending & ~illegal_write_size)) &
572 ~buf_full;
573assign buf_tail_next = wr_buf ? {buf_tail[0],
574 buf_tail[1]} :
575 buf_tail;
576
577assign inv_buf_tail_next[0] = ~buf_tail_next[0];
578assign buf_tail[0] = ~inv_buf_tail[0];
579
580mcu_ucbbuf_ctl_msff_ctl_macro__width_2 buf_tail_ff (
581 .scan_in(buf_tail_ff_scanin),
582 .scan_out(buf_tail_ff_scanout),
583 .din({buf_tail_next[1],inv_buf_tail_next[0]}),
584 .l1clk(l1clk),
585 .dout({buf_tail[1],inv_buf_tail[0]}),
586 .siclk(siclk),
587 .soclk(soclk));
588
589// Buffer full
590assign buf_full_next = (buf_head_next == buf_tail_next) & wr_buf;
591assign buf_full_en = rd_buf|wr_buf;
592mcu_ucbbuf_ctl_msff_ctl_macro__en_1__width_1 buf_full_ff (.din(buf_full_next),
593 .scan_in(buf_full_ff_scanin),
594 .scan_out(buf_full_ff_scanout),
595 .en(buf_full_en),
596 .l1clk(l1clk),
597 .dout(buf_full),
598 .siclk(siclk),
599 .soclk(soclk));
600
601// Buffer empty
602assign buf_empty_next = ((buf_head_next == buf_tail_next) & rd_buf);
603
604assign buf_empty_en = rd_buf | wr_buf;
605
606assign inv_buf_empty_next = ~buf_empty_next;
607assign buf_empty = ~inv_buf_empty;
608
609mcu_ucbbuf_ctl_msff_ctl_macro__en_1__width_1 buf_empty_ff (
610 .scan_in(buf_empty_ff_scanin),
611 .scan_out(buf_empty_ff_scanout),
612 .din(inv_buf_empty_next),
613 .en(buf_empty_en),
614 .l1clk(l1clk),
615 .dout(inv_buf_empty),
616 .siclk(siclk),
617 .soclk(soclk));
618
619
620assign req_in = {indata_buf[`UCB_DATA_HI:`UCB_DATA_LO],
621 indata_buf[`UCB_ADDR_HI:`UCB_ADDR_LO],
622 indata_buf[`UCB_SIZE_HI:`UCB_SIZE_LO],
623 indata_buf[`UCB_BUF_HI:`UCB_BUF_LO],
624 indata_buf[`UCB_THR_HI:`UCB_THR_LO],
625 write_pending & ~illegal_write_size,
626 read_pending};
627
628// Buffer 0
629assign buf0_en = buf_tail[0] & wr_buf;
630mcu_ucbbuf_ctl_msff_ctl_macro__en_1__width_117 buf0_ff (
631 .scan_in(buf0_ff_scanin),
632 .scan_out(buf0_ff_scanout),
633 .din(req_in),
634 .en(buf0_en),
635 .l1clk(l1clk),
636 .dout(buf0),
637 .siclk(siclk),
638 .soclk(soclk));
639// Buffer 1
640assign buf1_en = buf_tail[1] & wr_buf;
641mcu_ucbbuf_ctl_msff_ctl_macro__en_1__width_117 buf1_ff (
642 .scan_in(buf1_ff_scanin),
643 .scan_out(buf1_ff_scanout),
644 .din(req_in),
645 .en(buf1_en),
646 .l1clk(l1clk),
647 .dout(buf1),
648 .siclk(siclk),
649 .soclk(soclk));
650
651assign req_out = buf_head[0] ? buf0 :
652 buf_head[1] ? buf1 : {`UCB_BUF_WIDTH{1'b0}};
653
654
655/************************************************************
656 * Inbound interface to local unit
657 ************************************************************/
658assign {data_in,
659 addr_in,
660 size_in,
661 buf_id_in,
662 thr_id_in,
663 wr_req_vld_nq,
664 rd_req_vld_nq} = req_out;
665
666assign rd_req_vld = rd_req_vld_nq & ~buf_empty;
667assign wr_req_vld = wr_req_vld_nq & ~buf_empty;
668
669
670/************************************************************
671 * Outbound Ack/Nack
672 ************************************************************/
673assign ack_buf_wr = rd_ack_vld | rd_nack_vld;
674
675assign ack_buf_vld_next = ack_buf_wr ? 1'b1 :
676 ack_buf_rd ? 1'b0 :
677 ack_buf_vld;
678
679mcu_ucbbuf_ctl_msff_ctl_macro__width_1 ack_buf_vld_ff (
680 .scan_in(ack_buf_vld_ff_scanin),
681 .scan_out(ack_buf_vld_ff_scanout),
682 .din(ack_buf_vld_next),
683 .l1clk(l1clk),
684 .dout(ack_buf_vld),
685 .siclk(siclk),
686 .soclk(soclk));
687
688mcu_ucbbuf_ctl_msff_ctl_macro__en_1 ack_buf_is_nack_ff (
689 .scan_in(ack_buf_is_nack_ff_scanin),
690 .scan_out(ack_buf_is_nack_ff_scanout),
691 .din(rd_nack_vld),
692 .en(ack_buf_wr),
693 .l1clk(l1clk),
694 .dout(ack_buf_is_nack),
695 .siclk(siclk),
696 .soclk(soclk));
697
698mcu_ucbbuf_ctl_msff_ctl_macro__en_1 ack_buf_is_data128_ff (
699 .scan_in(ack_buf_is_data128_ff_scanin),
700 .scan_out(ack_buf_is_data128_ff_scanout),
701 .din(data128),
702 .en(ack_buf_wr),
703 .l1clk(l1clk),
704 .dout(ack_buf_is_data128),
705 .siclk(siclk),
706 .soclk(soclk));
707
708assign ack_typ_out = rd_ack_vld ? `UCB_READ_ACK:
709 `UCB_READ_NACK;
710
711assign ack_buf_in = {data_out,
712 buf_id_out,
713 thr_id_out,
714 ack_typ_out};
715
716// msff_ctl_macro ack_buf_ff (width=REG_WIDTH+`UCB_BUF_HI-`UCB_PKT_LO+1,en=1) (.din(ack_buf_in),
717// 64+11-10+1
718mcu_ucbbuf_ctl_msff_ctl_macro__en_1__width_76 ack_buf_ff (
719 .scan_in(ack_buf_ff_scanin),
720 .scan_out(ack_buf_ff_scanout),
721 .din(ack_buf_in),
722 .en(ack_buf_wr),
723 .l1clk(l1clk),
724 .dout(ack_buf),
725 .siclk(siclk),
726 .soclk(soclk));
727
728assign ack_buf_vec = ack_buf_is_nack ? {{16{1'b0}},
729 {16{1'b1}}} :
730 ack_buf_is_data128 ? {32{1'b1}} :
731 {32{1'b1}};
732
733assign ack_busy = ack_buf_vld;
734
735
736/************************************************************
737 * Outbound Interrupt
738 ************************************************************/
739// Assertion: int_buf_wr shoudn't be asserted if int_buf_busy
740assign int_buf_wr = int_vld;
741
742assign int_buf_vld_next = int_buf_wr ? 1'b1 :
743 int_buf_rd ? 1'b0 : int_buf_vld;
744
745mcu_ucbbuf_ctl_msff_ctl_macro__width_1 int_buf_vld_ff (
746 .scan_in(int_buf_vld_ff_scanin),
747 .scan_out(int_buf_vld_ff_scanout),
748 .din(int_buf_vld_next),
749 .l1clk(l1clk),
750 .dout(int_buf_vld),
751 .siclk(siclk),
752 .soclk(soclk));
753
754assign int_buf_in = {int_vec, int_stat, dev_id, int_thr_id, int_typ};
755
756 // msff_ctl_macro int_buf_ff (width=`UCB_INT_VEC_HI-`UCB_PKT_LO+1,en=1) (.din(int_buf_in),
757mcu_ucbbuf_ctl_msff_ctl_macro__en_1__width_57 int_buf_ff (
758 .scan_in(int_buf_ff_scanin),
759 .scan_out(int_buf_ff_scanout),
760 .din(int_buf_in),
761 .en(int_buf_wr),
762 .l1clk(l1clk),
763 .dout(int_buf),
764 .siclk(siclk),
765 .soclk(soclk));
766
767assign int_buf_vec = {{16{1'b0}}, {16{1'b1}}};
768
769assign int_busy = int_buf_vld;
770
771
772/************************************************************
773 * Outbound ack/interrupt Arbitration
774 ************************************************************/
775assign int_last_rd_en = ack_buf_rd|int_buf_rd;
776mcu_ucbbuf_ctl_msff_ctl_macro__en_1__width_1 int_last_rd_ff (
777 .scan_in(int_last_rd_ff_scanin),
778 .scan_out(int_last_rd_ff_scanout),
779 .din(int_buf_rd),
780 .en(int_last_rd_en),
781 .l1clk(l1clk),
782 .dout(int_last_rd),
783 .siclk(siclk),
784 .soclk(soclk));
785
786assign ack_buf_rd = ~outdata_buf_busy & ack_buf_vld &
787 (~int_buf_vld | int_last_rd);
788
789assign int_buf_rd = ~outdata_buf_busy & int_buf_vld &
790 (~ack_buf_vld | ~int_last_rd);
791
792assign outdata_buf_wr = ack_buf_rd | int_buf_rd;
793
794assign outdata_buf_in = ack_buf_rd ? {ack_buf[75:12],
795 {9{1'b0}},
796 {40{1'b0}},
797 {3{1'b0}},
798 ack_buf[`UCB_BUF_HI:`UCB_BUF_LO],
799 ack_buf[`UCB_THR_HI:`UCB_THR_LO],
800 ack_buf[`UCB_PKT_HI:`UCB_PKT_LO]}:
801 {{64{1'b0}},
802 {7{1'b0}},
803 int_buf[`UCB_INT_VEC_HI:`UCB_INT_VEC_LO],
804 int_buf[`UCB_INT_STAT_HI:`UCB_INT_STAT_LO],
805 int_buf[`UCB_INT_DEV_HI:`UCB_INT_DEV_LO],
806 int_buf[`UCB_THR_HI:`UCB_THR_LO],
807 int_buf[`UCB_PKT_HI:`UCB_PKT_LO]};
808
809assign outdata_vec_in = ack_buf_rd ? ack_buf_vec :
810 int_buf_vec;
811
812mcu_ucbout_ctl ucbout (
813 .scan_in(ucbout_scanin),
814 .scan_out(ucbout_scanout),
815 .l1clk(l1clk),
816 .outdata_buf_wr(outdata_buf_wr),
817 .outdata_buf_in(outdata_buf_in),
818 .outdata_vec_in(outdata_vec_in),
819 .outdata_buf_busy(outdata_buf_busy),
820 .vld(ucb_iob_vld),
821 .data(ucb_iob_data),
822 .stall(iob_ucb_stall),
823 .tcu_aclk(tcu_aclk),
824 .tcu_bclk(tcu_bclk),
825 .tcu_scan_en(tcu_scan_en));
826
827
828// fixscan start:
829assign ucbin_scanin = scan_in ;
830assign buf_head_ff_scanin = ucbin_scanout ;
831assign buf_tail_ff_scanin = buf_head_ff_scanout ;
832assign buf_full_ff_scanin = buf_tail_ff_scanout ;
833assign buf_empty_ff_scanin = buf_full_ff_scanout ;
834assign buf0_ff_scanin = buf_empty_ff_scanout ;
835assign buf1_ff_scanin = buf0_ff_scanout ;
836assign ack_buf_vld_ff_scanin = buf1_ff_scanout ;
837assign ack_buf_is_nack_ff_scanin = ack_buf_vld_ff_scanout ;
838assign ack_buf_is_data128_ff_scanin = ack_buf_is_nack_ff_scanout;
839assign ack_buf_ff_scanin = ack_buf_is_data128_ff_scanout;
840assign int_buf_vld_ff_scanin = ack_buf_ff_scanout ;
841assign int_buf_ff_scanin = int_buf_vld_ff_scanout ;
842assign int_last_rd_ff_scanin = int_buf_ff_scanout ;
843assign ucbout_scanin = int_last_rd_ff_scanout ;
844assign scan_out = ucbout_scanout ;
845// fixscan end:
846endmodule
847
848
849
850
851
852// any PARAMS parms go into naming of macro
853
854module mcu_ucbbuf_ctl_msff_ctl_macro__en_1__width_1 (
855 din,
856 en,
857 l1clk,
858 scan_in,
859 siclk,
860 soclk,
861 dout,
862 scan_out);
863wire [0:0] fdin;
864
865 input [0:0] din;
866 input en;
867 input l1clk;
868 input scan_in;
869
870
871 input siclk;
872 input soclk;
873
874 output [0:0] dout;
875 output scan_out;
876assign fdin[0:0] = (din[0:0] & {1{en}}) | (dout[0:0] & ~{1{en}});
877
878
879
880
881
882
883dff #(1) d0_0 (
884.l1clk(l1clk),
885.siclk(siclk),
886.soclk(soclk),
887.d(fdin[0:0]),
888.si(scan_in),
889.so(scan_out),
890.q(dout[0:0])
891);
892
893
894
895
896
897
898
899
900
901
902
903
904endmodule
905
906
907
908
909
910
911
912
913
914
915
916
917
918// any PARAMS parms go into naming of macro
919
920module mcu_ucbbuf_ctl_msff_ctl_macro__en_1__width_4 (
921 din,
922 en,
923 l1clk,
924 scan_in,
925 siclk,
926 soclk,
927 dout,
928 scan_out);
929wire [3:0] fdin;
930wire [2:0] so;
931
932 input [3:0] din;
933 input en;
934 input l1clk;
935 input scan_in;
936
937
938 input siclk;
939 input soclk;
940
941 output [3:0] dout;
942 output scan_out;
943assign fdin[3:0] = (din[3:0] & {4{en}}) | (dout[3:0] & ~{4{en}});
944
945
946
947
948
949
950dff #(4) d0_0 (
951.l1clk(l1clk),
952.siclk(siclk),
953.soclk(soclk),
954.d(fdin[3:0]),
955.si({scan_in,so[2:0]}),
956.so({so[2:0],scan_out}),
957.q(dout[3:0])
958);
959
960
961
962
963
964
965
966
967
968
969
970
971endmodule
972
973
974
975
976
977
978
979
980
981
982
983
984
985// any PARAMS parms go into naming of macro
986
987module mcu_ucbbuf_ctl_msff_ctl_macro__width_1 (
988 din,
989 l1clk,
990 scan_in,
991 siclk,
992 soclk,
993 dout,
994 scan_out);
995wire [0:0] fdin;
996
997 input [0:0] din;
998 input l1clk;
999 input scan_in;
1000
1001
1002 input siclk;
1003 input soclk;
1004
1005 output [0:0] dout;
1006 output scan_out;
1007assign fdin[0:0] = din[0:0];
1008
1009
1010
1011
1012
1013
1014dff #(1) d0_0 (
1015.l1clk(l1clk),
1016.siclk(siclk),
1017.soclk(soclk),
1018.d(fdin[0:0]),
1019.si(scan_in),
1020.so(scan_out),
1021.q(dout[0:0])
1022);
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035endmodule
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049// any PARAMS parms go into naming of macro
1050
1051module mcu_ucbbuf_ctl_msff_ctl_macro__en_1 (
1052 din,
1053 en,
1054 l1clk,
1055 scan_in,
1056 siclk,
1057 soclk,
1058 dout,
1059 scan_out);
1060wire [0:0] fdin;
1061
1062 input [0:0] din;
1063 input en;
1064 input l1clk;
1065 input scan_in;
1066
1067
1068 input siclk;
1069 input soclk;
1070
1071 output [0:0] dout;
1072 output scan_out;
1073assign fdin[0:0] = (din[0:0] & {1{en}}) | (dout[0:0] & ~{1{en}});
1074
1075
1076
1077
1078
1079
1080dff #(1) d0_0 (
1081.l1clk(l1clk),
1082.siclk(siclk),
1083.soclk(soclk),
1084.d(fdin[0:0]),
1085.si(scan_in),
1086.so(scan_out),
1087.q(dout[0:0])
1088);
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101endmodule
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115// any PARAMS parms go into naming of macro
1116
1117module mcu_ucbbuf_ctl_msff_ctl_macro__en_1__width_32 (
1118 din,
1119 en,
1120 l1clk,
1121 scan_in,
1122 siclk,
1123 soclk,
1124 dout,
1125 scan_out);
1126wire [31:0] fdin;
1127wire [30:0] so;
1128
1129 input [31:0] din;
1130 input en;
1131 input l1clk;
1132 input scan_in;
1133
1134
1135 input siclk;
1136 input soclk;
1137
1138 output [31:0] dout;
1139 output scan_out;
1140assign fdin[31:0] = (din[31:0] & {32{en}}) | (dout[31:0] & ~{32{en}});
1141
1142
1143
1144
1145
1146
1147dff #(32) d0_0 (
1148.l1clk(l1clk),
1149.siclk(siclk),
1150.soclk(soclk),
1151.d(fdin[31:0]),
1152.si({scan_in,so[30:0]}),
1153.so({so[30:0],scan_out}),
1154.q(dout[31:0])
1155);
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168endmodule
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182// any PARAMS parms go into naming of macro
1183
1184module mcu_ucbbuf_ctl_msff_ctl_macro__en_1__width_128 (
1185 din,
1186 en,
1187 l1clk,
1188 scan_in,
1189 siclk,
1190 soclk,
1191 dout,
1192 scan_out);
1193wire [127:0] fdin;
1194wire [126:0] so;
1195
1196 input [127:0] din;
1197 input en;
1198 input l1clk;
1199 input scan_in;
1200
1201
1202 input siclk;
1203 input soclk;
1204
1205 output [127:0] dout;
1206 output scan_out;
1207assign fdin[127:0] = (din[127:0] & {128{en}}) | (dout[127:0] & ~{128{en}});
1208
1209
1210
1211
1212
1213
1214dff #(128) d0_0 (
1215.l1clk(l1clk),
1216.siclk(siclk),
1217.soclk(soclk),
1218.d(fdin[127:0]),
1219.si({scan_in,so[126:0]}),
1220.so({so[126:0],scan_out}),
1221.q(dout[127:0])
1222);
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235endmodule
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249// any PARAMS parms go into naming of macro
1250
1251module mcu_ucbbuf_ctl_msff_ctl_macro__width_2 (
1252 din,
1253 l1clk,
1254 scan_in,
1255 siclk,
1256 soclk,
1257 dout,
1258 scan_out);
1259wire [1:0] fdin;
1260wire [0:0] so;
1261
1262 input [1:0] din;
1263 input l1clk;
1264 input scan_in;
1265
1266
1267 input siclk;
1268 input soclk;
1269
1270 output [1:0] dout;
1271 output scan_out;
1272assign fdin[1:0] = din[1:0];
1273
1274
1275
1276
1277
1278
1279dff #(2) d0_0 (
1280.l1clk(l1clk),
1281.siclk(siclk),
1282.soclk(soclk),
1283.d(fdin[1:0]),
1284.si({scan_in,so[0:0]}),
1285.so({so[0:0],scan_out}),
1286.q(dout[1:0])
1287);
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300endmodule
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314// any PARAMS parms go into naming of macro
1315
1316module mcu_ucbbuf_ctl_msff_ctl_macro__en_1__width_117 (
1317 din,
1318 en,
1319 l1clk,
1320 scan_in,
1321 siclk,
1322 soclk,
1323 dout,
1324 scan_out);
1325wire [116:0] fdin;
1326wire [115:0] so;
1327
1328 input [116:0] din;
1329 input en;
1330 input l1clk;
1331 input scan_in;
1332
1333
1334 input siclk;
1335 input soclk;
1336
1337 output [116:0] dout;
1338 output scan_out;
1339assign fdin[116:0] = (din[116:0] & {117{en}}) | (dout[116:0] & ~{117{en}});
1340
1341
1342
1343
1344
1345
1346dff #(117) d0_0 (
1347.l1clk(l1clk),
1348.siclk(siclk),
1349.soclk(soclk),
1350.d(fdin[116:0]),
1351.si({scan_in,so[115:0]}),
1352.so({so[115:0],scan_out}),
1353.q(dout[116:0])
1354);
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367endmodule
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381// any PARAMS parms go into naming of macro
1382
1383module mcu_ucbbuf_ctl_msff_ctl_macro__en_1__width_76 (
1384 din,
1385 en,
1386 l1clk,
1387 scan_in,
1388 siclk,
1389 soclk,
1390 dout,
1391 scan_out);
1392wire [75:0] fdin;
1393wire [74:0] so;
1394
1395 input [75:0] din;
1396 input en;
1397 input l1clk;
1398 input scan_in;
1399
1400
1401 input siclk;
1402 input soclk;
1403
1404 output [75:0] dout;
1405 output scan_out;
1406assign fdin[75:0] = (din[75:0] & {76{en}}) | (dout[75:0] & ~{76{en}});
1407
1408
1409
1410
1411
1412
1413dff #(76) d0_0 (
1414.l1clk(l1clk),
1415.siclk(siclk),
1416.soclk(soclk),
1417.d(fdin[75:0]),
1418.si({scan_in,so[74:0]}),
1419.so({so[74:0],scan_out}),
1420.q(dout[75:0])
1421);
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434endmodule
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448// any PARAMS parms go into naming of macro
1449
1450module mcu_ucbbuf_ctl_msff_ctl_macro__en_1__width_57 (
1451 din,
1452 en,
1453 l1clk,
1454 scan_in,
1455 siclk,
1456 soclk,
1457 dout,
1458 scan_out);
1459wire [56:0] fdin;
1460wire [55:0] so;
1461
1462 input [56:0] din;
1463 input en;
1464 input l1clk;
1465 input scan_in;
1466
1467
1468 input siclk;
1469 input soclk;
1470
1471 output [56:0] dout;
1472 output scan_out;
1473assign fdin[56:0] = (din[56:0] & {57{en}}) | (dout[56:0] & ~{57{en}});
1474
1475
1476
1477
1478
1479
1480dff #(57) d0_0 (
1481.l1clk(l1clk),
1482.siclk(siclk),
1483.soclk(soclk),
1484.d(fdin[56:0]),
1485.si({scan_in,so[55:0]}),
1486.so({so[55:0],scan_out}),
1487.q(dout[56:0])
1488);
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501endmodule
1502
1503
1504
1505
1506
1507
1508// any PARAMS parms go into naming of macro
1509
1510module mcu_ucbbuf_ctl_msff_ctl_macro__width_32 (
1511 din,
1512 l1clk,
1513 scan_in,
1514 siclk,
1515 soclk,
1516 dout,
1517 scan_out);
1518wire [31:0] fdin;
1519wire [30:0] so;
1520
1521 input [31:0] din;
1522 input l1clk;
1523 input scan_in;
1524
1525
1526 input siclk;
1527 input soclk;
1528
1529 output [31:0] dout;
1530 output scan_out;
1531assign fdin[31:0] = din[31:0];
1532
1533
1534
1535
1536
1537
1538dff #(32) d0_0 (
1539.l1clk(l1clk),
1540.siclk(siclk),
1541.soclk(soclk),
1542.d(fdin[31:0]),
1543.si({scan_in,so[30:0]}),
1544.so({so[30:0],scan_out}),
1545.q(dout[31:0])
1546);
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559endmodule
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573// any PARAMS parms go into naming of macro
1574
1575module mcu_ucbbuf_ctl_msff_ctl_macro__width_128 (
1576 din,
1577 l1clk,
1578 scan_in,
1579 siclk,
1580 soclk,
1581 dout,
1582 scan_out);
1583wire [127:0] fdin;
1584wire [126:0] so;
1585
1586 input [127:0] din;
1587 input l1clk;
1588 input scan_in;
1589
1590
1591 input siclk;
1592 input soclk;
1593
1594 output [127:0] dout;
1595 output scan_out;
1596assign fdin[127:0] = din[127:0];
1597
1598
1599
1600
1601
1602
1603dff #(128) d0_0 (
1604.l1clk(l1clk),
1605.siclk(siclk),
1606.soclk(soclk),
1607.d(fdin[127:0]),
1608.si({scan_in,so[126:0]}),
1609.so({so[126:0],scan_out}),
1610.q(dout[127:0])
1611);
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624endmodule
1625
1626
1627
1628
1629
1630
1631
1632