// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: ccu.v
// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// For the avoidance of doubt, and except that if any non-GPL license
// choice is available it will apply instead, Sun elects to use only
// the General Public License version 2 (GPLv2) at this time for any
// software where a choice of GPL license versions is made
// available with the language indicating that GPLv2 or any later version
// may be used, or where a choice of which version of the GPL is applied is
// otherwise unspecified.
// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
// CA 95054 USA or visit www.sun.com if you need additional information or
// ========== Copyright Header End ============================================
tcu_ccu_clk_stretch, // TBD
// ------------------------------------
// INPUT-OUTPUT DECLARATIONS
// ------------------------------------
input [3:0] ncu_ccu_data;
output [3:0] ccu_ncu_data;
output [1:0] rng_vcoctrl_sel;
output [1:0] rng_anlg_sel;
output ccu_cmp_io_sync_en;
output ccu_io_cmp_sync_en;
output [1:0] ccu_mio_pll_char_out;
output ccu_mio_serdes_dtm;
output ccu_dbg1_serdes_dtm;
input mio_ccu_vreg_selbg_l;
input mio_ccu_pll_clamp_fltr;
input [5:0] mio_ccu_pll_div2;
input [6:0] mio_ccu_pll_div4;
input mio_ccu_pll_trst_l;
input mio_ccu_pll_char_in;
input gl_ccu_io_clk_stop;
input [1:0] tcu_ccu_mux_sel;
input tcu_ccu_ext_cmp_clk;
input tcu_ccu_ext_dr_clk ;
input tcu_ccu_clk_stretch; // TBD
output ccu_sys_cmp_sync_en;
output ccu_cmp_sys_sync_en;
output ccu_rst_sync_stable;
// ------------------------------------
// EXTERNAL WIRE/REG DECLARATIONS
// ------------------------------------
wire [1:0] rng_vcoctrl_sel;
wire [1:0] ccu_mio_pll_char_out;
wire ccu_dbg1_serdes_dtm;
wire mio_ccu_vreg_selbg_l;
wire mio_ccu_pll_clamp_fltr;
wire [5:0] mio_ccu_pll_div2;
wire [6:0] mio_ccu_pll_div4;
wire mio_ccu_pll_char_in;
wire [1:0] tcu_ccu_mux_sel;
wire tcu_ccu_ext_cmp_clk;
wire tcu_ccu_ext_dr_clk ;
wire tcu_ccu_clk_stretch; // TBD
wire ccu_sys_cmp_sync_en;
wire ccu_cmp_sys_sync_en;
wire ccu_rst_sync_stable;
// ***********************************************
// ***********************************************
// ------------------------------------
// INTERNAL WIRE/REG DECLARATIONS
// ------------------------------------
wire [5:0] ucb_thr_id_in;
wire [1:0] ucb_buf_id_in;
wire [5:0] ucb_thr_id_out;
wire [1:0] ucb_buf_id_out;
wire [63:0] ucb_data_out;
wire aligned_rst_n_gated;
wire dft_rst_a_l_ungated;
wire [4:0] io_cmp_shift_amt;
// dtm1 dtm2 mio_dtm dbg1_dtm ccu_serdes_dtm
// phase info for io/cmp sync pulses (starting w/0)
// ================================================
// mode ratio cmp-io io-cmp
// tcu_ccu_mux_sel == 00 functional mode
// tcu_ccu_mux_sel == 01 clk stretch
// tcu_ccu_mux_sel == 10 external clk mode
// tcu_ccu_mux_sel == 11 debug event macro test
// ccu interferes w/mux_sel when dtm==1
// when dtm==1, in dr domain mux_sel is forced to 11.
// when mux_sel == 11 in macro test mode, external clocks are
// allowed to propagate, and pll mux_sel forced to 10
// (pll_testmode | atpg_mode) block off ext clks otherwise
// on the pll, pll_dtm and pll_bypass now
// needs to be OR'ed w/tcu_ccu_mux_sel[1]
.rst_ccu_ (rst_ccu_), // sys_clk domain reset input
.aligned (gclk_aligned), // (aligned),
.pll_arst_l (pll_arst_l), // async pll reset input
.pll_div4_msb (pll_div4_msb),
.io2x_phase_180 (io2x_phase_180),
.io_phase_0 (io_phase_0),
.io_phase_180(io_phase_180),
.ccu_sys_cmp_sync_en (ccu_sys_cmp_sync_en),
.ccu_rst_sync_stable (ccu_rst_sync_stable),
.ccu_cmp_sys_sync_en (ccu_cmp_sys_sync_en),
.serdes_dtm1 (serdes_dtm1),
.serdes_dtm2 (serdes_dtm2),
// .ccu_vco_aligned (ccu_vco_aligned),
.pll_div3_lat (pll_div3_lat),
.pll_div4_lat (pll_div4_lat),
.csr_rst_n (csr_ucb_rst_n), // cmp domain reset for csr/ucb blocks
.ccu_dbg1_serdes_dtm (ccu_dbg1_serdes_dtm),
.ccu_mio_serdes_dtm (ccu_mio_serdes_dtm),
.ccu_io2x_sync_en (ccu_io2x_sync_en),
.ccu_pre_dr_sync_en (ccu_pre_dr_sync_en), // new input
.ccu_dr_sync_en (ccu_dr_sync_en), // changed to output
.tcu_atpg_mode(tcu_atpg_mode),
.scan_out (core_scan_out),
.rng_arst_l (rng_arst_l),
.ccu_serdes_dtm_lat (ccu_serdes_dtm),
.rng_ch_sel (rng_ch_sel),
.ccu_cmp_io_sync_en (ccu_cmp_io_sync_en),
.ccu_io_cmp_sync_en (ccu_io_cmp_sync_en),
.aligned_rst_n (aligned_rst_n),
.dr_shift_amt (dr_shift_amt)
///////////////////////////////////////////////////////////
// ** CMP PLL CLK DOMAIN **
///////////////////////////////////////////////////////////
ccu_hm_top ccu_hm_wrapper (
.cmp_pll_clk_l (cmp_pll_clk_l),
.dr_shift_amt (dr_shift_amt),
.rst_n (rst_ccu_), // arst_msff non-scan flops
.rst_out_n (dft_rst_a_l_ungated), // frac. divider reset out
.pulse_out (ccu_vco_aligned)
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// ***********************************************
// generate sync pulse for cmp<->dr
// ***********************************************
ccu_cmp_dr_sync cmp_dr_sync (
.align_shift (align_shift),
.ccu_serdes_dtm (ccu_serdes_dtm),
.pulse (ccu_pre_dr_sync_en),
.rst_n (aligned_rst_n) // syncrst_msff scan flops
// ***********************************************
// generate io phase signal from vco clk
// ***********************************************
ccu_divider gen_io_phase (
.rst_n (aligned_rst_n_gated), // arst_msff scan flops
.phase_180 (io_phase_180)
// ***********************************************
// generate io2x phase signal from vco clk
// ***********************************************
ccu_divider gen_io2x_phase (
.rst_n (aligned_rst_n_gated), // arst_msff scan flops
.phase_180 (io2x_phase_180)
// ***********************************************
// generate sync pulses for cmp<->io
// ***********************************************
assign dtm8_1 = (ccu_serdes_dtm && (ratio == 5'h07));
assign dtm11_1 = (ccu_serdes_dtm && (ratio == 5'h0A));
assign dtm15_1 = (ccu_serdes_dtm && (ratio == 5'h0E));
assign io_cmp_shift_amt = dtm8_1 ? 5'd07 :
ccu_pulse_shift io_cmp_sp_shift (
.rst_n (aligned_rst_n_gated), // arst_msff scan flops
.shift (io_cmp_shift_amt), // now depends on func/dtm
.pulse_in (io_phase_180),
// ***********************************************
// pll signal gating/muxing
// ***********************************************
assign jtag_mt_mode = &tcu_ccu_mux_sel; // both high
assign ext_dr_clk = (mio_pll_testmode | tcu_atpg_mode | jtag_mt_mode) & tcu_ccu_ext_dr_clk;
assign ext_cmp_clk = (mio_pll_testmode | tcu_atpg_mode | jtag_mt_mode) & tcu_ccu_ext_cmp_clk;
assign div2 = mio_pll_testmode ? mio_ccu_pll_div2 : pll_div2;
assign div4 = mio_pll_testmode ? mio_ccu_pll_div4 : pll_div4_lat;
assign pll_arst_l = (tcu_atpg_mode | jtag_mt_mode) ? 1'b0 :
mio_pll_testmode ? mio_ccu_pll_trst_l :
assign clamp_fltr = mio_pll_testmode ? mio_ccu_pll_clamp_fltr : pll_clamp_fltr;
assign char_in = (mio_pll_testmode & mio_ccu_pll_char_in) | pll_char_in;
assign dft_rst_a_l = ~(tcu_atpg_mode | jtag_mt_mode) & dft_rst_a_l_ungated;
// assign pll_bypass = tcu_atpg_mode; // ccu_serdes_dtm ? ccu_serdes_dtm : tcu_ccu_mux_sel[1] ;
// assign pll_dtm = tcu_atpg_mode | ccu_serdes_dtm;
assign pll_bypass = tcu_atpg_mode | tcu_ccu_mux_sel[1] ;
assign pll_dtm = tcu_atpg_mode | ccu_serdes_dtm | tcu_ccu_mux_sel[1];
// atpg_mode has highest priority just in case any of the
// other controls are state based
assign dr_sel_a = tcu_atpg_mode ? tcu_ccu_mux_sel :
assign pll_sel_a = tcu_atpg_mode ? tcu_ccu_mux_sel :
// ***********************************************
// ***********************************************
n2_core_pll_cust ccu_pll (
.pll_testmode ( mio_pll_testmode ),
.dft_rst_a_l ( dft_rst_a_l ),
.dr_ext_clk ( ext_dr_clk ), // bypass clk (tcu)
.dr_sdel ( st_delay_dr ), // stretch amnt (csr)
.dr_sel_a ( dr_sel_a ), // mux sel (tcu) or set by dtm or macro test
.dr_stretch_a ( st_phase_hi ), // stretch hi/lo ph (csr)
.pll_arst_l ( pll_arst_l ), // (rst)
.pll_bypass ( pll_bypass ),
.pll_char_in ( char_in ), // (csr | mio)
.pll_clamp_fltr ( clamp_fltr ), // (csr | mio)
.pll_div1 ( pll_div1 ), // (csr)
.pll_div2 ( div2 ), // (csr | mio)
.pll_div3 ( pll_div3_lat ), // (csr)
.pll_div4 ( div4 ), // (csr | mio)
.ccu_serdes_dtm ( pll_dtm ), // ccu_serdes_dtm
.pll_ext_clk ( ext_cmp_clk ), // bypass clk (tcu)
.pll_sys_clk ({pll_sys_clk_n,pll_sys_clk_p}), // 0->p, 1->n
.pll_sdel ( st_delay_cmp ), // stretch amnt (csr)
.pll_sel_a ( pll_sel_a ), // mux sel (tcu) or set by macro test
.pll_stretch_a ( st_phase_hi ), // stretch hi/lo ph (csr)
.sel_l2clk_fbk ( 1'b0 ), // permanently deselect fdbk
.vdd_hv15 ( pll_vdd), // (bump)
.vreg_selbg_l ( mio_ccu_vreg_selbg_l ), // (mio)
.ccu_rst_ref_buf2 ( ref_clk ),
.ccu_rst_sys_clk ( ccu_rst_sys_clk ),
.dr_clk_out ( dr_pll_clk ),
.dr_clk_out_l ( dr_pll_clk_l ),
.pll_char_out ( ccu_mio_pll_char_out ), // to mio - not modeled
.pll_clk_out ( cmp_pll_clk ),
.pll_clk_out_l ( cmp_pll_clk_l )
// ***********************************************
// ***********************************************
clkgen_ccu_cmp clkgen_cmp (
.scan_out(cmp_hdr_scan_out),
.wmr_protect(wmr_protect),
.rst_wmr_protect(rst_wmr_protect),
.ccu_cmp_slow_sync_en(1'b0),
.ccu_slow_cmp_sync_en(1'b0),
.tcu_atpg_mode(tcu_atpg_mode),
// ***********************************************
// ***********************************************
clkgen_ccu_io clkgen_io (
.ccu_serdes_dtm(ccu_serdes_dtm),
.scan_out (io_hdr_scan_out),
.ccu_cmp_slow_sync_en(1'b0),
.ccu_slow_cmp_sync_en(1'b0),
.tcu_div_bypass(tcu_atpg_mode),
.ccu_div_ph(gl_ccu_io_out),
.tcu_atpg_mode(tcu_atpg_mode),
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// ***********************************************
// io domain reset generation
// ***********************************************
ccu_io_rstgen io_rstgen_blk (
.csr_ucb_rst_n( csr_ucb_rst_n ),
.tcu_atpg_mode( tcu_atpg_mode ),
// ***********************************************
// csr block instantiation
// ***********************************************
.wr_req_vld (ucb_wr_req_vld),
.req_accepted(ucb_req_acpted),
.rd_req_vld(ucb_rd_req_vld),
.thr_id_in (ucb_thr_id_in),
.buf_id_in (ucb_buf_id_in),
.rack_busy(ucb_ack_busy),
.thr_id_out(ucb_thr_id_out),
.buf_id_out(ucb_buf_id_out),
.rd_ack_vld(ucb_rd_ack_vld),
.rd_nack_vld(ucb_rd_nack_vld),
.rst_n (csr_rst_n), // arst_msff scan flops
.wmr_protect (wmr_protect),
.st_phase_hi ( st_phase_hi ),
.st_delay_dr ( st_delay_dr ),
.st_delay_cmp ( st_delay_cmp ),
.serdes_dtm1 (serdes_dtm1),
.serdes_dtm2 (serdes_dtm2),
.change ( ccu_rst_change ),
.align_shift ( align_shift ),
.pll_char_in ( pll_char_in ),
.pll_clamp_fltr ( pll_clamp_fltr ),
.rng_bypass (rng_bypass),
.rng_vcoctrl_sel (rng_vcoctrl_sel),
.rng_anlg_sel (rng_anlg_sel)
// ***********************************************
// scan gating and muxing
// ***********************************************
assign aclk_gated = tcu_atpg_mode & aclk;
assign bclk_gated = tcu_atpg_mode & bclk;
assign scan_en_gated = tcu_atpg_mode & tcu_scan_en;
assign aligned_rst_n_gated = tcu_atpg_mode | aligned_rst_n;
assign scan_out = tcu_atpg_mode?core_scan_out:scan_in;
// ***********************************************
// ucb flow ctl instantiation
// ***********************************************
// the following requires sunv to plain verilog conversion
.scan_out (ucb_scan_out),
.ccu_ncu_stall (ccu_ncu_stall),
.ccu_ncu_vld (ccu_ncu_vld),
.ccu_ncu_data (ccu_ncu_data),
.rd_req_vld (ucb_rd_req_vld),
.wr_req_vld (ucb_wr_req_vld),
.thr_id_in (ucb_thr_id_in),
.buf_id_in (ucb_buf_id_in),
.ack_busy (ucb_ack_busy),
.rst_n (ucb_rst_n), // syncrst_msff scan flops
.scan_in (io_hdr_scan_out),
.tcu_scan_en (scan_en_gated),
.ncu_ccu_vld (ncu_ccu_vld),
.ncu_ccu_data (ncu_ccu_data),
.ncu_ccu_stall (ncu_ccu_stall),
.req_acpted (ucb_req_acpted),
.rd_ack_vld (ucb_rd_ack_vld),
.rd_nack_vld (ucb_rd_nack_vld),
.thr_id_out (ucb_thr_id_out),
.buf_id_out (ucb_buf_id_out),
// ***********************************************************
// ***********************************************************
cl_a1_l1hdr_8x header_l2clk (