// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: ccu_mon.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 ============================================
//#############################################################
//### WHAT: monitor ccu and print out clock info
//#############################################################
integer sys_clk_per_int, dtm_mode;
reg [5:0] div1, div2, div3;
real div1_eff, div2_eff, div3_eff, div4_eff; // effective values (warning: in real number)
real sys_clk_per, cmp_clk_per, dr_clk_per, io_clk_per, io2x_clk_per; // expected values
real cmp2sys_ratio, dr2sys_ratio, cmp2dr_ratio, cmp2io_ratio, cmp2io2x_ratio; // clk ratio
always @(negedge `CCU.rst_ccu_pll_)
$display("%t: ccu_mon[ccu_mon]: clk info: rst asserts rst_ccu_pll_ to reset/relock PLL", $time);
always @(posedge `CCU.rst_ccu_pll_) begin // at CCU input: get sys clk period
@(posedge `CCU.pll_sys_clk_p);
@(posedge `CCU.pll_sys_clk_p);
sys_clk_per_int = $time - sys_clk_per_int;
sys_clk_per = sys_clk_per_int; // warning: convert to real number
always @(posedge `CCU.rst_ccu_pll_) begin // at CCU's csr_blk: record div values when CCU should latch them in
$display("%t: ccu_mon[ccu_mon]: clk info: rst deasserts rst_ccu_pll_", $time);
div1 = `CCU.csr_blk.pll_div1;
div2 = `CCU.csr_blk.pll_div2;
div3 = `CCU.csr_blk.pll_div3;
div4 = `CCU.csr_blk.pll_div4;
div1_eff = div1 + 1.0; // effective value. Warning: convert to real number
div2_eff = div2 + 1.0; // effective value. Warning: convert to real number
div3_eff = div3 + 1.0; // effective value. Warning: convert to real number
div4_eff = div4[6:1]; // integral/whole part. Warning: convert to real number
div4_eff = div4_eff + 0.5; // fractional part. Warning: convert to real number
always @(posedge `CCU.ccu_rst_sync_stable) begin // clock info: compute and print out expected values when clocks and sync are stable
$display("%t: ccu_mon[ccu_mon]: clk info: ccu asserts ccu_rst_sync_stable", $time);
dtm_mode = ((`CCU.csr_blk.serdes_dtm1 === 1'b1)
|| (`CCU.csr_blk.serdes_dtm2 === 1'b1))? 1 : 0; // serdes dtm signals should be stable here
cmp_clk_per = (sys_clk_per * div1_eff) / div2_eff;
if (dtm_mode) begin // DTM mode
dr_clk_per = sys_clk_per * div1_eff;
io_clk_per = sys_clk_per * div1_eff;
io2x_clk_per = sys_clk_per * div1_eff;
cmp2sys_ratio = div2_eff / div1_eff;
cmp2io2x_ratio = div2_eff;
else begin // functional mode
io_clk_per = cmp_clk_per * 4.0;
io2x_clk_per = cmp_clk_per * 2.0;
dr_clk_per = (sys_clk_per * div1_eff * div4_eff) / (div2_eff * div3_eff);
cmp2sys_ratio = div2_eff / div1_eff;
dr2sys_ratio = (div2_eff * div3_eff) / (div1_eff * div4_eff);
cmp2dr_ratio = div4_eff / div3_eff;
$display("%t: ccu_mon[ccu_mon]: clk info: div1_eff=%.0f, div2_eff=%.0f, div3_eff=%.0f, div4_eff=%.1f, serdes_dtm=%0d", $time, div1_eff, div2_eff, div3_eff, div4_eff, dtm_mode);
$display("%t: ccu_mon[ccu_mon]: clk info: sys_clk_per=%.2f", $time, sys_clk_per);
$display("%t: ccu_mon[ccu_mon]: clk info: expected: cmp_clk_per=%.2f, dr_clk_per=%.2f, io_clk_per=%.2f, io2x_clk_per=%.2f", $time, cmp_clk_per, dr_clk_per, io_clk_per, io2x_clk_per);
$display("%t: ccu_mon[ccu_mon]: clk info: expected: cmp2sys_ratio=%.2f, dr2sys_ratio=%.2f, cmp2dr_ratio=%.2f, cmp2io_ratio=%.2f, cmp2io2x_ratio=%.2f", $time, cmp2sys_ratio, dr2sys_ratio, cmp2dr_ratio, cmp2io_ratio, cmp2io2x_ratio);
`endif // end of `ifndef ASIC_GATES
`endif // end of `ifndef GATESIM
//#############################################################
//### WHAT: monitor JTAG tck clock (this is legacy code)
//#############################################################
assign tckCLK = `TOP.tck;
always @(posCycle or negCycle)
period=posCycle+negCycle;
posCycle = posTime - negTime;
if (negCycle != posCycle)
$dispmon("tb_top", `DEBUG, "Period change for tck: %0dps (neg:%0dps -> pos:%0dps)", posCycle*2, negCycle, posCycle);
negCycle = negTime - posTime;
if (negCycle != posCycle)
$dispmon("tb_top", `DEBUG, "Period change for tck: %0dps (pos:%0dps -> neg:%0dps)", negCycle*2, posCycle, negCycle);
//// This Verilog task is called from the Vera testbench side at end of simulation
$dispmon("tb_top", `INFO, "TCK : %0d ps (%0d MHz)", period, 1.0E6/period);
//###################################################
//### WHAT: instantiate MCU's DR clkgen module for TCU SAT
//### to produce an ALWAYS running DR clock
//###################################################
.gclk(`CPU.mcu0.dr_gclk), // connect to MCU's DR gclk
.cluster_div_en(1'b0), // must tie low
.cluster_arst_l(1'b1), // tie high
//---the rest of the inputs: tie low/high---
.ccu_cmp_slow_sync_en(1'b0),
.ccu_slow_cmp_sync_en(1'b0),
.ccu_div_ph(1'b0), // not matter if cluster_div_en is 0
.ccu_serdes_dtm(1'b0), // not used inside clkgen module
.clk_ext(1'b0), // not used inside clkgen module
//---outputs: not connect---
//###################################################
//### WHAT: instantiate RDP's IO2X clkgen module for TCU SAT
//### to produce ALWAYS running IO2X clock
//###################################################
// added this for removing NIU in T2
// 2 signals were getting called from rdp (which is in NIU).
// so, i replaced them with their equivalent behavior (since i removed rdp when i removed NIU)
// list of signals that are stubbed for NIU
integer status; time niu_stub_time;
status = $value$plusargs("NIU_STUB_TIME=%d", niu_stub_time);
$display("At time %0t, stubbing initiated for NCU/SIU - NIU signals from %m (OpenSparc T2)\n",$time);
//$dispmon("ccu_mon",1,"At time %0d, stubbing initiated for NCU/SIU - NIU signals (OpenSparc T2)\n",$time);
force `CPU.ncu_niu_ctag_cei =0;
force `CPU.ncu_niu_ctag_uei =0;
force `CPU.ncu_niu_d_pei =0;
force `CPU.ncu_niu_data[31:0] =32'b0;
force `CPU.ncu_niu_stall =0;
force `CPU.ncu_niu_vld =0;
force `CPU.ncu_sii_niua_pei =0;
force `CPU.ncu_sii_niuctag_cei =0;
force `CPU.ncu_sii_niuctag_uei =0;
force `CPU.ncu_sii_niud_pei =0;
force `CPU.niu_dbg1_stall_ack =0;
force `CPU.niu_efu_4k_data =0;
force `CPU.niu_efu_4k_xfer_en =0;
force `CPU.niu_efu_cfifo0_data =0;
force `CPU.niu_efu_cfifo0_xfer_en =0;
force `CPU.niu_efu_cfifo1_data =0;
force `CPU.niu_efu_cfifo1_xfer_en =0;
force `CPU.niu_efu_fdo =0;
force `CPU.niu_efu_ipp0_data =0;
force `CPU.niu_efu_ipp0_xfer_en =0;
force `CPU.niu_efu_ipp1_data =0;
force `CPU.niu_efu_ipp1_xfer_en =0;
force `CPU.niu_efu_mac0_ro_data =0;
force `CPU.niu_efu_mac0_ro_xfer_en =0;
force `CPU.niu_efu_mac0_sf_data =0;
force `CPU.niu_efu_mac0_sf_xfer_en =0;
force `CPU.niu_efu_mac1_ro_data =0;
force `CPU.niu_efu_mac1_ro_xfer_en =0;
force `CPU.niu_efu_mac1_sf_data =0;
force `CPU.niu_efu_mac1_sf_xfer_en =0;
force `CPU.niu_efu_ram0_data =0;
force `CPU.niu_efu_ram0_xfer_en =0;
force `CPU.niu_efu_ram1_data =0;
force `CPU.niu_efu_ram1_xfer_en =0;
force `CPU.niu_efu_ram_data =0;
force `CPU.niu_efu_ram_xfer_en =0;
force `CPU.niu_mio_debug_clock[1:0] =2'b0;
force `CPU.niu_mio_debug_data[31:0] =32'b0;
force `CPU.niu_ncu_ctag_ce =0;
force `CPU.niu_ncu_ctag_ue =0;
force `CPU.niu_ncu_d_pe =0;
force `CPU.niu_ncu_data[31:0] =32'b0;
force `CPU.niu_ncu_stall =0;
force `CPU.niu_ncu_vld =0;
force `CPU.niu_sii_data[127:0] =128'b0;
force `CPU.niu_sii_datareq =0;
force `CPU.niu_sii_hdr_vld =0;
force `CPU.niu_sii_parity[7:0] =8'b0;
force `CPU.niu_sii_reqbypass =0;
force `CPU.niu_sio_dq =0;
force `CPU.niu_txc_interrupts =0;
// very important to have the following free running clock with the associated delays
// exactly as is used below......... also, note we are in ps now instead of fs
#107250 forever #750 x=~x; // clock half-period is 750 ps, not 750 fs
// added this module and the 2 associated 'rdp' derivative signals
clkgen_rdp_io2x clkgen_io2x(
.gclk(`CPU.cmp_gclk_c0_rdp),
clkgen_rdp_io2x clkgen_io2x(
.gclk(`CPU.niu.cmp_gclk_c0_rdp), // connect to RDP's gclk
.ccu_div_ph(`CPU.niu.gl_io2x_out_c1b), // connect to RDP's io2x_out
.gclk(`CPU.rdp.cmp_gclk_c0_rdp), // connect to RDP's gclk
.ccu_div_ph(`CPU.rdp.gl_rdp_io2x_out), // connect to RDP's io2x_out
.cluster_div_en(1'b1), // must tie high
.cluster_arst_l(1'b1), // tie high
//---the rest of the inputs: tie low/high---
.ccu_cmp_slow_sync_en(1'b0),
.ccu_slow_cmp_sync_en(1'b0),
.ccu_serdes_dtm(1'b0), // not used inside clkgen module
.clk_ext(1'b0), // not used inside clkgen module
`endif // end of `ifndef ASIC_GATES
`endif // end of `ifndef GATESIM
// added these modules, they are necessary for compilation
// **************************
// **************************
output l2clk; // assume we do not need aclk, bclk outputs
output aclk; // buffered version of aclk
output bclk; // buffered version of bclk
output scan_out; // unused as of today - feb 10, 05
output pce_ov; // pce override to l1 header
output wmr_protect; // warm reset protect
output wmr_; // warm reset (active low)
output por_; // power-on-reset
output cmp_slow_sync_en; // cmp->slow clk sync pulse
output slow_cmp_sync_en; // slow->cmp clk sync pulse
// output io2x_sync_en; // cmp<->io2x clk sync pulse
// output dr_sync_en; // cmp<->dr clk sync pulse
// ctrl in (for pipelining)
input ccu_cmp_slow_sync_en;
input ccu_slow_cmp_sync_en;
// input ccu_io2x_sync_en;
// ctrl in (for clock gen)
input tcu_div_bypass; // bypasses clk divider to mux in ext clk
input ccu_div_ph; // phase signal from ccu (div/4 or div/2)
input cluster_div_en; // if enabled, l2clk is divided down
input gclk; // global clk - this is either cmp or dr
input clk_ext; // external clk muxed in for ioclk bypass
input scan_en; // unused as of today - feb 10, 05
input scan_in; // unused as of today - feb 10, 05
// **************************
// **************************
wire ccu_cmp_slow_sync_en;
wire ccu_slow_cmp_sync_en;
// wire ccu_io2x_sync_en;
// **************************
// **************************
// needs a few edits to cluster header def - mahmud.hassan
// modified custom cell name for avoiding
// collision with sparc core and other clusters - mhassan
n2_clk_clstr_hdr_cust xcluster_header (
.cluster_arst_l (cluster_arst_l),
.ccu_div_ph (ccu_div_ph),
.cluster_div_en (cluster_div_en),
.tcu_div_bypass (tcu_div_bypass),
// .ccu_serdes_dtm (ccu_serdes_dtm),
.ccu_cmp_slow_sync_en (ccu_cmp_slow_sync_en),
.ccu_slow_cmp_sync_en (ccu_slow_cmp_sync_en),
// .ccu_io2x_sync_en (ccu_io2x_sync_en ),
// .ccu_dr_sync_en (ccu_dr_sync_en ),
.tcu_pce_ov (tcu_pce_ov),
.tcu_clk_stop (tcu_clk_stop),
.rst_wmr_protect (rst_wmr_protect),
.cmp_slow_sync_en (cmp_slow_sync_en),
.slow_cmp_sync_en (slow_cmp_sync_en),
// .io2x_sync_en (io2x_sync_en ),
// .dr_sync_en (dr_sync_en ),
.wmr_protect (wmr_protect),
.array_wr_inhibit (array_wr_inhibit),
.tcu_atpg_mode (tcu_atpg_mode),
.tcu_wr_inhibit (tcu_wr_inhibit),
// cclk -> l2clk from right
FC_NO_NIU_T2_n2_clk_rdp_io2x_cust xright (
// cclk -> l2clk from left
FC_NO_NIU_T2_n2_clk_rdp_io2x_cust xleft (
module FC_NO_NIU_T2_n2_clk_rdp_io2x_cust(cclk, l2clk);
assign #(1) l2clk = cclk;