// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: ipg_checker.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 ============================================
/*******************************************************************
* File Name : ipg_checker.v
* Description : For checking variable ipg.
* Copyright (c) 2020, Sun Microsystems, Inc.
* Sun Proprietary and Confidential
******************************************************************/
reg [`BYTE] ipg_net_credit;
reg [`BYTE] stored_ipg_count;
SYNC_CELL SYNC_X2_TX_RESET(.D(tx_reset),.CP(x2_tx_clk),.Q(x2_tx_reset));
assign #1 dly1_tx_clk = tx_clk;
assign #1 dly2_tx_clk = dly1_tx_clk;
assign x2_tx_clk = dly1_tx_clk ^ dly2_tx_clk;
always @ (posedge x2_tx_clk)
itxc[0] & (itxd[`BYTE0] == `T) | // lane0
itxc[1] & (itxd[`BYTE1] == `T) | // lane1
itxc[2] & (itxd[`BYTE2] == `T) | // lane2
itxc[3] & (itxd[`BYTE3] == `T) ; // lane3
assign S_det = itxc[0] & (itxd[`BYTE0] == `S); // lane0
RSFF ipg_count_en_RSFF(.reset(x2_tx_reset),
assign ipg_count_en = (ipg_count_en_temp | T_det) & (~S_det);
PlsGen2 store_ipg_time_PlsGen2(
.lead(),.trail(store_ipg_time));
wire [`BYTE] itxc_bit0 = {7'b0,itxc[0]};
wire [`BYTE] itxc_bit1 = {7'b0,itxc[1]};
wire [`BYTE] itxc_bit2 = {7'b0,itxc[2]};
wire [`BYTE] itxc_bit3 = {7'b0,itxc[3]};
wire [`BYTE] itxc_count = itxc_bit0 + itxc_bit1 + itxc_bit2 + itxc_bit3;
always @ (posedge x2_tx_clk)
check_ipg_time <= store_ipg_time;
always @ (posedge x2_tx_clk)
if (x2_tx_reset | store_ipg_time)
ipg_count <= itxc_count + ipg_count;
always @ (posedge x2_tx_clk)
stored_ipg_count <= ipg_count;
stored_ipg_count <= stored_ipg_count;
always @ (posedge x2_tx_clk)
ipg_net_credit <= `CREDIT_BIAS;
if (ipg_count >= `CREDIT_BIAS)
ipg_net_credit <= ipg_net_credit + (ipg_count - `CREDIT_BIAS);
ipg_net_credit <= ipg_net_credit - (`CREDIT_BIAS - ipg_count);
else ipg_net_credit <= ipg_net_credit;
xREG #(1) stored_add_crc_xREG(.din(add_crc),
xREG #(1) stored_B_eop_xREG(.din(B_eop),
always @ (negedge check_ipg_time) // LAN mode only
if (warning_msg_en & (~x2_tx_reset) & var_min_ipg_en & (~stretch_mode) &
((stored_ipg_count < 9) | (stored_ipg_count > 15)))
$display(" \n(* ERROR: at sim time = %d, from ipg_checker module, the ipg_checker has detected incorrect ipg value, stored_ipg_count = %d *)", $time, stored_ipg_count);
always @ (negedge check_ipg_time)
if (warning_msg_en & ~x2_tx_reset)
if (stretch_mode) // WAN mode
$display("\n (* WARNING: from ipg_checker module, stored_ipg_count = %d, stored_add_crc = %h, stored_B_eop = %h, at sim time = %d, *)", stored_ipg_count,stored_add_crc, stored_B_eop, $time);
$display("\n (* WARNING: from ipg_checker module, stored_ipg_count = %d, ipg_net_credit = %d, stored_add_crc = %h, stored_B_eop = %h, at sim time = %d, *)", stored_ipg_count, ipg_net_credit, stored_add_crc, stored_B_eop, $time);