// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: ncu_i2cbuf4_ni_ctl.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 ============================================
module ncu_i2cbuf4_ni_ctl (
wire stall_d1_ff_scanout;
wire vld_buf0_ff_scanout;
wire data_buf0_ff_scanin;
wire data_buf0_ff_scanout;
wire skid_buf1_en_ff_scanin;
wire skid_buf1_en_ff_scanout;
wire vld_buf1_ff_scanout;
wire data_buf1_ff_scanin;
wire data_buf1_ff_scanout;
wire skid_buf1_sel_ff_scanin;
wire skid_buf1_sel_ff_scanout;
wire [31:0] indata_vec_next;
wire indata_vec_ff_scanin;
wire indata_vec_ff_scanout;
wire [127:0] indata_buf_next;
wire indata_buf_ff_scanin;
wire indata_buf_ff_scanout;
wire indata_vec0_d1_ff_scanin;
wire indata_vec0_d1_ff_scanout;
wire req_ack_dbl_buf_full;
wire buf1_older_ff_scanin;
wire buf1_older_ff_scanout;
wire buf0_vld_ff_scanout;
wire buf1_vld_ff_scanout;
wire buf0_obj_ff_scanout;
wire buf1_obj_ff_scanout;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
input [3:0] ucb_iob_data;
// i2c slow control/datapath interface
output [127:0] req_ack_obj;
input rd_req_ack_dbl_buf;
/************************************************************
* Assemble inbound packet
************************************************************/
// ucb_bus_in #(UCB_BUS_WIDTH) ucb_bus_in
// .data(ucb_iob_data[UCB_BUS_WIDTH-1:0]),
// .stall(iob_ucb_stall),
// .indata_buf_vld(indata_buf_vld),
// .indata_buf(indata_buf[127:0]),
// .stall_a1(iob_ucb_stall_a1)
//=============================================================
//=============================================================
//=============================================================
/************************************************************
* UCB bus interface flops
* This is to make signals going between IOB and UCB flop-to-flop
************************************************************/
assign stall_d1_n = ~stall_d1;
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_1 vld_d1_ff
.scan_in(vld_d1_ff_scanin),
.scan_out(vld_d1_ff_scanout),
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_4 data_d1_ff
.scan_in(data_d1_ff_scanin),
.scan_out(data_d1_ff_scanout),
.din (ucb_iob_data[3:0]),
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__width_1 stall_ff
.scan_in(stall_ff_scanin),
.scan_out(stall_ff_scanout),
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__width_1 stall_d1_ff
.scan_in(stall_d1_ff_scanin),
.scan_out(stall_d1_ff_scanout),
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__width_1 rdy0_ff
.scan_in(rdy0_ff_scanin),
.scan_out(rdy0_ff_scanout),
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__width_1 rdy1_ff
.scan_in(rdy1_ff_scanin),
.scan_out(rdy1_ff_scanout),
/************************************************************
* We need a two deep skid buffer to handle stalling.
************************************************************/
// Assertion: stall has to be deasserted for more than 1 cycle
// ie time between two separate stalls has to be
// at least two cycles. Otherwise, contents from
// skid buffer will be lost.
assign skid_buf0_en = iob_ucb_stall_a1 & ~iob_ucb_stall;
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_1 vld_buf0_ff
.scan_in(vld_buf0_ff_scanin),
.scan_out(vld_buf0_ff_scanout),
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_4 data_buf0_ff
.scan_in(data_buf0_ff_scanin),
.scan_out(data_buf0_ff_scanout),
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__width_1 skid_buf1_en_ff
.scan_in(skid_buf1_en_ff_scanin),
.scan_out(skid_buf1_en_ff_scanout),
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_1 vld_buf1_ff
.scan_in(vld_buf1_ff_scanin),
.scan_out(vld_buf1_ff_scanout),
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_4 data_buf1_ff
.scan_in(data_buf1_ff_scanin),
.scan_out(data_buf1_ff_scanout),
/************************************************************
* Mux between skid buffer and interface flop
************************************************************/
// Assertion: stall has to be deasserted for more than 1 cycle
// ie time between two separate stalls has to be
// at least two cycles. Otherwise, contents from
// skid buffer will be lost.
assign skid_buf0_sel = ~iob_ucb_stall_a1 & iob_ucb_stall;
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__width_1 skid_buf1_sel_ff
.scan_in(skid_buf1_sel_ff_scanin),
.scan_out(skid_buf1_sel_ff_scanout),
assign vld_mux = skid_buf0_sel ? vld_buf0 :
skid_buf1_sel ? vld_buf1 : vld_d1;
assign data_mux[3:0] = skid_buf0_sel ? data_buf0[3:0] :
skid_buf1_sel ? data_buf1[3:0] : data_d1[3:0];
/************************************************************
************************************************************/
assign indata_vec_next[31:0] = {vld_mux, indata_vec[31:1]};
assign iob_ucb_stall_a1_= ~iob_ucb_stall_a1;
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_32 indata_vec_ff
.scan_in(indata_vec_ff_scanin),
.scan_out(indata_vec_ff_scanout),
.dout (indata_vec[31:0]),
.din (indata_vec_next[31:0]),
assign indata_buf_next[127:0] = {data_mux[3:0], indata_buf[127:4]};
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_128 indata_buf_ff
.scan_in(indata_buf_ff_scanin),
.scan_out(indata_buf_ff_scanout),
.dout (indata_buf[127:0]),
.din (indata_buf_next[127:0]),
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_1 indata_vec0_d1_ff
.scan_in(indata_vec0_d1_ff_scanin),
.scan_out(indata_vec0_d1_ff_scanout),
assign indata_buf_vld = indata_vec[0] & ~indata_vec0_d1;
//=============================================================
//=============================================================
//=============================================================
/************************************************************
* Decode inbound packet type
************************************************************/
assign req_ack_pending = indata_buf_vld;
assign iob_ucb_stall_a1 = (req_ack_pending & req_ack_dbl_buf_full);
/************************************************************
* Double buffer to store non-interrupt packets
************************************************************/
assign wr_req_ack_dbl_buf = req_ack_pending & ~req_ack_dbl_buf_full;
// dbl_buf #(128) req_ack_dbl_buf (
// .wr(wr_req_ack_dbl_buf),
// .din(indata_buf[127:0]),
// .rd(rd_req_ack_dbl_buf),
// .dout(req_ack_obj[127:0]),
// .full(req_ack_dbl_buf_full));
//=============================================================
//=============================================================
//=============================================================
// if both entries are empty, write to entry pointed to by the older pointer
assign wr_buf0 = wr_req_ack_dbl_buf & (buf1_vld | (~buf0_vld & ~buf1_older));
assign wr_buf1 = wr_req_ack_dbl_buf & (buf0_vld | (~buf1_vld & buf1_older));
// read from the older entry
assign rd_buf0 = rd_req_ack_dbl_buf & ~buf1_older;
assign rd_buf1 = rd_req_ack_dbl_buf & buf1_older;
// flip older pointer when an entry is read
assign rd_buf = rd_req_ack_dbl_buf & (buf0_vld | buf1_vld);
assign buf1_older_n = ~buf1_older ;
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_1 buf1_older_ff
.scan_in(buf1_older_ff_scanin),
.scan_out(buf1_older_ff_scanout),
// set valid bit for writes and reset for reads
assign en_vld0 = wr_buf0 | rd_buf0;
assign en_vld1 = wr_buf1 | rd_buf1;
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_1 buf0_vld_ff
.scan_in(buf0_vld_ff_scanin),
.scan_out(buf0_vld_ff_scanout),
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_1 buf1_vld_ff
.scan_in(buf1_vld_ff_scanin),
.scan_out(buf1_vld_ff_scanout),
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_128 buf0_obj_ff
.scan_in(buf0_obj_ff_scanin),
.scan_out(buf0_obj_ff_scanout),
.din (indata_buf[127:0]),
ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_128 buf1_obj_ff
.scan_in(buf1_obj_ff_scanin),
.scan_out(buf1_obj_ff_scanout),
.din (indata_buf[127:0]),
// mux out the older entry
assign req_ack_obj[127:0] = (buf1_older) ? buf1_obj[127:0] : buf0_obj[127:0] ;
assign req_ack_vld = buf0_vld | buf1_vld;
assign req_ack_dbl_buf_full = buf0_vld & buf1_vld;
//=============================================================
//=============================================================
//=============================================================
/**** adding clock header ****/
ncu_i2cbuf4_ni_ctl_l1clkhdr_ctl_macro clkgen (
/*** building tcu port ***/
assign pce_ov = tcu_pce_ov;
assign stop = tcu_clk_stop;
assign vld_d1_ff_scanin = scan_in ;
assign data_d1_ff_scanin = vld_d1_ff_scanout ;
assign stall_ff_scanin = data_d1_ff_scanout ;
assign stall_d1_ff_scanin = stall_ff_scanout ;
assign rdy0_ff_scanin = stall_d1_ff_scanout ;
assign rdy1_ff_scanin = rdy0_ff_scanout ;
assign vld_buf0_ff_scanin = rdy1_ff_scanout ;
assign data_buf0_ff_scanin = vld_buf0_ff_scanout ;
assign skid_buf1_en_ff_scanin = data_buf0_ff_scanout ;
assign vld_buf1_ff_scanin = skid_buf1_en_ff_scanout ;
assign data_buf1_ff_scanin = vld_buf1_ff_scanout ;
assign skid_buf1_sel_ff_scanin = data_buf1_ff_scanout ;
assign indata_vec_ff_scanin = skid_buf1_sel_ff_scanout ;
assign indata_buf_ff_scanin = indata_vec_ff_scanout ;
assign indata_vec0_d1_ff_scanin = indata_buf_ff_scanout ;
assign buf1_older_ff_scanin = indata_vec0_d1_ff_scanout;
assign buf0_vld_ff_scanin = buf1_older_ff_scanout ;
assign buf1_vld_ff_scanin = buf0_vld_ff_scanout ;
assign buf0_obj_ff_scanin = buf1_vld_ff_scanout ;
assign buf1_obj_ff_scanin = buf0_obj_ff_scanout ;
assign scan_out = buf1_obj_ff_scanout ;
// any PARAMS parms go into naming of macro
module ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_1 (
assign fdin[0:0] = (din[0:0] & {1{en}}) | (dout[0:0] & ~{1{en}});
// any PARAMS parms go into naming of macro
module ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_4 (
assign fdin[3:0] = (din[3:0] & {4{en}}) | (dout[3:0] & ~{4{en}});
// any PARAMS parms go into naming of macro
module ncu_i2cbuf4_ni_ctl_msff_ctl_macro__width_1 (
assign fdin[0:0] = din[0:0];
// any PARAMS parms go into naming of macro
module ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_32 (
assign fdin[31:0] = (din[31:0] & {32{en}}) | (dout[31:0] & ~{32{en}});
.so({so[30:0],scan_out}),
// any PARAMS parms go into naming of macro
module ncu_i2cbuf4_ni_ctl_msff_ctl_macro__en_1__width_128 (
assign fdin[127:0] = (din[127:0] & {128{en}}) | (dout[127:0] & ~{128{en}});
.si({scan_in,so[126:0]}),
.so({so[126:0],scan_out}),
// any PARAMS parms go into naming of macro
module ncu_i2cbuf4_ni_ctl_l1clkhdr_ctl_macro (