// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: mac_pio_intf.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 : mac_pio_intf.v
* Description : It contains mac pio interface mux and demux logic.
* Copyright (c) 2020, Sun Microsystems, Inc.
* Sun Proprietary and Confidential
* Modification : 4/1/2004 -by John Lo
* 1. Changed address bus width from
* 16 bits to 19 bits for pio_clients_addr.
* 2. Support both 32 bit and 64 bit addressing.
* 3. Changed PIO read/write data bus from
* The MSB 32 bits are "0".
*************************************************************************/
// global broadcast signals
// individual internal inputs
pcs_int0, // pcs link down interrupt, secondary interrupt
pcs_int1, // pcs link down interrupt, secondary interrupt
pcs_int2, // pcs link down interrupt, secondary interrupt
pcs_int3, // pcs link down interrupt, secondary interrupt
mac_pio_intr0,// port 0 interrupt
mac_pio_intr1,// port 1 interrupt
mac_pio_intr2,// port 2 interrupt
mac_pio_intr3,// port 3 interrupt
// global broadcast signals
input [19:0] pio_clients_addr;
input [31:0] pio_clients_wdata;
output [63:0] mac_pio_rdata;
// individual internal inputs
input [31:0] rdata_xmac0;
input [31:0] rdata_xpcs0;
input [31:0] rdata_xmac1;
input [31:0] rdata_xpcs1;
input [31:0] rdata_bmac2;
input [31:0] rdata_bmac3;
input xmac_fc_interrupt0;
input pcs_int0; // pcs link down interrupt, secondary interrupt
input xmac_fc_interrupt1;
input pcs_int1; // pcs link down interrupt, secondary interrupt
input bm_control_interrupt2;
input pcs_int2; // pcs link down interrupt, secondary interrupt
input bm_control_interrupt3;
input pcs_int3; // pcs link down interrupt, secondary interrupt
input [31:0] xmac_debug0;
input [31:0] xpcs_debug0;
input [2:0] mac_debug_sel0;
input [31:0] xmac_debug1;
input [31:0] xpcs_debug1;
input [31:0] esrctl_debug;
output [31:0] mac_debug_port;
output mac_pio_intr0;// port 0 interrupt
output mac_pio_intr1;// port 1 interrupt
output mac_pio_intr2;// port 2 interrupt
output mac_pio_intr3;// port 3 interrupt
// xmac address range: [8:0] x2 -> reserve 1 bit -> 10
// big_mac address range: [8:0] x2 ->
// xpcs address range: [6:0] x2 ->
// pcs address range: [6:0] x4 ->
// ---------------------------------
wire [19:0] pio_clients_addr;
wire [31:0] pio_clients_wdata;
wire [63:0] mac_pio_rdata;
// individual internal wire
wire [2:0] mac_debug_sel0;
// register the input signals:
// vlint flag_dangling_net_within_module off
// vlint flag_net_has_no_load off
wire [19:0] pio_clients_addr_64bit;
// vlint flag_net_has_no_load on
// vlint flag_dangling_net_within_module on
SYNC_CELL reset_SYNC_CELL(.D(niu_reset_l),.CP(clk),.Q(reset_l));
RegDff #(1) pio_sel_RegDff(
pls_gen pio_sel_pls_gen(.clk(clk),.in(pio_sel),.out(pio_sel_pls));
RegDff #(1) pio_sel_pls_d1_RegDff(.din(pio_sel_pls),.clk(clk),.qout(pio_sel_pls_d1));
RegDff #(1) pio_sel_pls_d2_RegDff(.din(pio_sel_pls_d1),.clk(clk),.qout(pio_sel_pls_d2));
RegDff #(20) pio_clients_addr_64bit_RegDff(
.din(pio_clients_addr[19:0]),
.qout(pio_clients_addr_64bit[19:0]));
assign pio_addr[16:0] = pio_clients_addr_64bit[16:0];
RegDff #(1) pio_rd_RegDff(
RegDff #(32) pio_wdata_RegDff(
.din(pio_clients_wdata[31:0]),
wire sel_xmac0 = pio_sel & (~pio_addr[2]) & (pio_addr[16:13] == `XMAC0_ADDR_OFFSET);
wire sel_xpcs0 = pio_sel & (~pio_addr[2]) & (pio_addr[16:13] == `XPCS0_ADDR_OFFSET);
wire sel_pcs0 = pio_sel & (~pio_addr[2]) & (pio_addr[16:13] == `PCS0_ADDR_OFFSET);
wire sel_xmac1 = pio_sel & (~pio_addr[2]) & (pio_addr[16:13] == `XMAC1_ADDR_OFFSET);
wire sel_xpcs1 = pio_sel & (~pio_addr[2]) & (pio_addr[16:13] == `XPCS1_ADDR_OFFSET);
wire sel_pcs1 = pio_sel & (~pio_addr[2]) & (pio_addr[16:13] == `PCS1_ADDR_OFFSET);
wire sel_bmac2 = pio_sel & (~pio_addr[2]) & (pio_addr[16:13] == `BMAC2_ADDR_OFFSET);
wire sel_pcs2 = pio_sel & (~pio_addr[2]) & (pio_addr[16:13] == `PCS2_ADDR_OFFSET);
wire sel_bmac3 = pio_sel & (~pio_addr[2]) & (pio_addr[16:13] == `BMAC3_ADDR_OFFSET);
wire sel_pcs3 = pio_sel & (~pio_addr[2]) & (pio_addr[16:13] == `PCS3_ADDR_OFFSET);
wire sel_esr = pio_sel & (~pio_addr[2]) & (pio_addr[16:13] == `ESR_ADDR_OFFSET);
wire sel_mif = pio_sel & (~pio_addr[2]) & (pio_addr[16:13] == `MIF_ADDR_OFFSET);
wire mac_pio_interrupt0= txmac_interrupt0 |
wire mac_pio_interrupt1= txmac_interrupt1 |
wire mac_pio_interrupt2= bm_tx_interrupt2 |
wire mac_pio_interrupt3= bm_tx_interrupt3 |
FD1 mac_pio_intr0_FD1(.CP(clk),.D(mac_pio_interrupt0),
FD1 mac_pio_intr1_FD1(.CP(clk),.D(mac_pio_interrupt1),
FD1 mac_pio_intr2_FD1(.CP(clk),.D(mac_pio_interrupt2),
FD1 mac_pio_intr3_FD1(.CP(clk),.D(mac_pio_interrupt3),
always @ (/*AUTOSENSE*/ack_bmac2 or ack_bmac3 or ack_esr or ack_mif
or ack_pcs0 or ack_pcs1 or ack_pcs2 or ack_pcs3 or ack_xmac0
or ack_xmac1 or ack_xpcs0 or ack_xpcs1 or pio_addr
or pio_err_bmac2 or pio_err_bmac3 or pio_err_esr
or pio_err_mif or pio_err_pcs0 or pio_err_pcs1
or pio_err_pcs2 or pio_err_pcs3 or pio_err_xmac0
or pio_err_xmac1 or pio_err_xpcs0 or pio_err_xpcs1
or pio_sel or pio_sel_pls_d2 or rdata_bmac2 or rdata_bmac3
or rdata_esr or rdata_mif or rdata_pcs0 or rdata_pcs1
or rdata_pcs2 or rdata_pcs3 or rdata_xmac0 or rdata_xmac1
or rdata_xpcs0 or rdata_xpcs1 or sel_bmac2 or sel_bmac3
or sel_esr or sel_mif or sel_pcs0 or sel_pcs1 or sel_pcs2
or sel_pcs3 or sel_xmac0 or sel_xmac1 or sel_xpcs0
if ((pio_sel) & (~pio_addr[2]))
case ({sel_xmac0,sel_xpcs0,sel_pcs0,
sel_xmac1,sel_xpcs1,sel_pcs1,
12'b1000_0000_0000: begin
12'b0100_0000_0000: begin
12'b0010_0000_0000: begin
12'b0001_0000_0000: begin
12'b0000_1000_0000: begin
12'b0000_0100_0000: begin
12'b0000_0010_0000: begin
12'b0000_0001_0000: begin
12'b0000_0000_1000: begin
12'b0000_0000_0100: begin
12'b0000_0000_0010: begin
12'b0000_0000_0001: begin
pio_ack = pio_sel_pls_d2;
pio_rdata = 32'hdead_beef;
pio_err = pio_sel_pls_d2;
endcase // case({sel_xmac0,sel_xpcs0,sel_pcs0,...
// accessing reserved upper 32 bit field.
// write operation is silent drop without pio_err
// read operation rdata is always zeros.
else if (pio_sel & pio_addr[2])
pio_ack = pio_sel_pls_d2;
pio_rdata = 32'hdead_beef;
RegDff #(64) mac_pio_rdata_RegDff(.din({32'b0,pio_rdata[31:0]}),
.qout(mac_pio_rdata[63:0]));
FD1 mac_pio_err_FD1(.CP(clk),.D(pio_err),
FD1 mac_pio_ack_FD1(.CP(clk),.D(pio_ack),
reg [31:0] mac_debug_port;
always @ (/*AUTOSENSE*/esrctl_debug or mac_debug_sel0 or xmac_debug0
or xmac_debug1 or xpcs_debug0 or xpcs_debug1)
case (mac_debug_sel0) // synopsys parallel_case full_case infer_mux
3'h0: mac_debug_port = xmac_debug0;
3'h1: mac_debug_port = xpcs_debug0;
3'h2: mac_debug_port = xmac_debug1;
3'h3: mac_debug_port = xpcs_debug1;
3'h4: mac_debug_port = esrctl_debug;
default: mac_debug_port = xmac_debug0;
endcase // casex(mac_debug_sel)
endmodule // mac_pio_intf