// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: dmu_clu_ctm_cmdgen.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 dmu_clu_ctm_cmdgen
// uns req fifo credit port
// >>>>>>>>>>>>>>>>>>>>>>>>> Parameter Declarations <<<<<<<<<<<<<<<<<<<<<<<<<
// --------------------------------------------------------
// --------------------------------------------------------
// --------------------------------------------------------
// Ingress Command Record (ICR) Type Encoding
// --------------------------------------------------------
parameter DMA_MRD_32BIT = 7'b00_00000,
DMA_MRD_64BIT = 7'b01_00000,
DMA_MRDLK_32BIT = 7'b00_00001,
DMA_MRDLK_64BIT = 7'b01_00001,
DMA_MWR_32BIT = 7'b10_00000,
DMA_MWR_64BIT = 7'b11_00000,
MSI_EQ_WR_32BIT = 7'b10_11000,
MSI_EQ_WR_64BIT = 7'b11_11000,
MSG_EQ_WR_32BIT = 7'b10_10000,
MSG_EQ_WR_64BIT = 7'b11_10000,
// --------------------------------------------------------
// CTM-to-CRM Unsupported Request Command Encoding
// --------------------------------------------------------
parameter DMA_MRD_ERR = 3'b001,
// --------------------------------------------------------
// DMC-to-JBC Command Encoding
// --------------------------------------------------------
parameter DMA_WRF = 4'b0000,
// --------------------------------------------------------
// ICR Completion Status Encoding
// --------------------------------------------------------
parameter UR_CPLSTS = 3'b001,
// --------------------------------------------------------
// UNSUPPORTED FIFO CREDIT PARAMETERS
// --------------------------------------------------------
parameter UNS_CRDTCNT = 3'h6;
parameter UNS_CRDTCNT_WDTH = 3;
// >>>>>>>>>>>>>>>>>>>>>>>>> Port Declarations <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// --------------------------------------------------------
// --------------------------------------------------------
// --------------------------------------------------------
// --------------------------------------------------------
// Cmd Port -> DMC Req/Resp
output [(`FIRE_D2J_CMD_WDTH - 1):0] d2j_cmd;
output [(`FIRE_D2J_ADDR_WDTH - 1):0] d2j_addr;
output [(`FIRE_D2J_CTAG_WDTH - 1):0] d2j_ctag;
// --------------------------------------------------------
// --------------------------------------------------------
// Unsupported Request Record (URR) Port
output [(`FIRE_DLC_CLU_URR_WDTH - 1):0] ctm2crm_rcd;
// --------------------------------------------------------
// --------------------------------------------------------
input [(`FIRE_DLC_ICR_TYP_WDTH - 1):0] icr_typ;
input [(`FIRE_DLC_ICR_CLSTS_WDTH - 1):0] icr_clsts;
input [(`FIRE_DLC_ICR_ADDR_WDTH - 1):0] icr_addr;
input [(`FIRE_DLC_ICR_STAT_WDTH - 1):0] icr_cmdsts;
input [(`FIRE_DLC_ICR_SBDTAG_WDTH - 1):0] icr_sbdtag;
// --------------------------------------------------------
// --------------------------------------------------------
input [(`FIRE_DLC_TCR_ADDR_WDTH - 1):0] tcr_addr;
input [(`FIRE_DLC_TCR_MTAG_WDTH - 1):0] tcr_mtag;
// --------------------------------------------------------
// Tag Manager - Next Available Tag
// --------------------------------------------------------
input [(TAG_WDTH - 1):0] nxt_tag;
// --------------------------------------------------------
// Buffer Manager - Next Available DOU DMA Address
// --------------------------------------------------------
// --------------------------------------------------------
// Command Process Select
// --------------------------------------------------------
// --------------------------------------------------------
// UNS Req Fifo-Credit Interface
// --------------------------------------------------------
output uns_req_crdt_avail;
// --------------------------------------------------------
// ICR Decoded Type Control Signals
// --------------------------------------------------------
// >>>>>>>>>>>>>>>>>>>>>>>>> Data Type Declarations <<<<<<<<<<<<<<<<<<<<<<<<<
// ~~~~~~~~~~~~~~~~~~~~~~~~~ REGISTERS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ********** Flops **********
// Cmd Port -> DMC Req/Resp
reg [(`FIRE_D2J_CMD_WDTH - 1):0] d2j_cmd;
reg [(`FIRE_D2J_ADDR_WDTH - 1):0] d2j_addr;
reg [(`FIRE_D2J_CTAG_WDTH - 1):0] d2j_ctag;
// Unsupported Request Record (URR) Port
reg [(`FIRE_DLC_CLU_URR_WDTH - 1):0] ctm2crm_rcd;
// unsupported request fifo credit count
reg [(UNS_CRDTCNT_WDTH - 1):0] q_count_uns;
// ********** Non-Flops ******
reg [(`FIRE_D2J_CMD_WDTH - 1):0] icr_jbc_cmd;
reg [(`FIRE_DLC_CLU_URR_TYP_WDTH - 1):0] uns_cmd;
reg [(`FIRE_D2J_CMD_WDTH - 1):0] jbc_cmd;
reg [(`FIRE_D2J_ADDR_WDTH - 1):0] jbc_addr;
reg [(`FIRE_D2J_CTAG_WDTH - 1):0] jbc_ctag;
// next unsupported request fifo credit count
reg [(UNS_CRDTCNT_WDTH - 1):0] nxt_q_count_uns;
// ~~~~~~~~~~~~~~~~~~~~~~~~~ NETS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// unsupported request fifo credit increment
// >>>>>>>>>>>>>>>>>>>>>>>>> 0-in Checkers <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-active (~`CPU.dmu.dmc.clu.ctm.icr_fifo_empty &
((icr_typ == DMA_MRD_32BIT) |
(icr_typ == DMA_MRD_64BIT) |
(icr_typ == DMA_MWR_32BIT) |
(icr_typ == DMA_MWR_64BIT) |
-active (~`CPU.dmu.dmc.clu.ctm.icr_fifo_empty &
(((icr_typ == DMA_MRD_32BIT) & ~icr_cmdsts[0]) |
((icr_typ == DMA_MRD_64BIT) & ~icr_cmdsts[0]) |
((icr_typ == DMA_MWR_32BIT) & ~icr_cmdsts[0]) |
((icr_typ == DMA_MWR_64BIT) & ~icr_cmdsts[0]) |
((icr_typ == MSI_EQ_WR_32BIT) & ~icr_cmdsts[0]) |
((icr_typ == MSI_EQ_WR_64BIT) & ~icr_cmdsts[0]) |
((icr_typ == MSG_EQ_WR_32BIT) & ~icr_cmdsts[0]) |
((icr_typ == MSG_EQ_WR_64BIT) & ~icr_cmdsts[0]) |
-active (~`CPU.dmu.dmc.clu.ctm.icr_fifo_empty &
-active (~`CPU.dmu.dmc.clu.ctm.icr_fifo_empty &
((icr_typ == DMA_MRD_32BIT) |
(icr_typ == DMA_MRD_64BIT) |
(icr_typ == DMA_MWR_32BIT) |
(icr_typ == DMA_MWR_64BIT) |
(icr_typ == MSI_EQ_WR_32BIT) |
(icr_typ == MSI_EQ_WR_64BIT) |
(icr_typ == MSG_EQ_WR_32BIT) |
(icr_typ == MSG_EQ_WR_64BIT)))
-active (~`CPU.dmu.dmc.clu.ctm.icr_fifo_empty &
-active (~`CPU.dmu.dmc.clu.ctm.icr_fifo_empty &
((icr_typ == DMA_MRD_32BIT) |
(icr_typ == DMA_MRD_64BIT) |
(icr_typ == DMA_MRDLK_32BIT) |
(icr_typ == DMA_MRDLK_64BIT) |
-active (~`CPU.dmu.dmc.clu.ctm.icr_fifo_empty &
-active (~`CPU.dmu.dmc.clu.ctm.icr_fifo_empty &
// 0in max -var q_count_uns -val 6
// >>>>>>>>>>>>>>>>>>>>>>>>> RTL Model <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// --------------------------------------------------------
// ICR Command Process (Ingress Command Record)
// --------------------------------------------------------
// ----- type decode---------------------------------------------------------
always @(icr_typ or icr_clsts or icr_cmdsts)
icr_jbc_cmd = {`FIRE_D2J_CMD_WDTH{1'b0}};
uns_cmd = {`FIRE_DLC_CLU_URR_TYP_WDTH{1'b0}};
// =======================================================
// icr_cmdsts [0] : 1'b0 = no err, 1'b1 = err
// icr_clsts [0] : 1'b0 = full, 1'b1 = partial
// icr_cmdsts [0] : 1'b0 = no err, 1'b1 = err
// icr_clsts [0] : 1'b0 = pio64, 1'b1 = pio16
// =======================================================
/* 0in < case -parallel -full
-active ~`CPU.dmu.dmc.clu.ctm.icr_fifo_empty
-message "Illegal ICR type received by CLU"
mwr_vld = ~icr_cmdsts[0];
eqwr_vld = ~icr_cmdsts[0];
eqwr_err = icr_cmdsts[0];
-active ~`CPU.dmu.dmc.clu.ctm.icr_fifo_empty
-message "Illegal PIO_CPL error encoding received by CLU"
UR_CPLSTS : icr_jbc_cmd = PIO_RDERR_BUS;
TO_CPLSTS : icr_jbc_cmd = PIO_RDERR_TO;
// --------------------------------------------------------
// JBC Command/Address Construction
// --------------------------------------------------------
// ----- cmd_typ assignment (ICR/TCR) ---------------------------------------
always @(icr_jbc_cmd or cmd_req_sel)
if (cmd_req_sel) // 1'b0 = icr, 1'b1 = tcr
// ----- addr assignment (ICR/TCR) ------------------------------------------
always @(icr_addr or tcr_addr or cmd_req_sel)
if (cmd_req_sel) // 1'b0 = icr, 1'b1 = tcr
jbc_addr = {icr_addr[(`FIRE_DLC_ICR_ADDR_WDTH -1):7],icr_addr[5:0]};
// ----- ctag assignment (ICR/TCR) ------------------------------------------
always @(dma_dptr or tcr_mtag or cmd_req_sel or
nxt_tag or icr_sbdtag or icr_clsts or icr_addr or
pio16_vld or pio64_vld or pio_err)
jbc_ctag[15] = cmd_req_sel;
// jbc_ctag[14:11] = nxt_tag;
// jbc_ctag[10] = dma_dptr[4];
// if (~cmd_req_sel & (pio16_vld | pio64_vld | pio_err))
// jbc_ctag[9:6] = icr_sbdtag[3:0];
// jbc_ctag[9:6] = dma_dptr[3:0];
jbc_ctag[14:12] = nxt_tag[3:1];
if (~cmd_req_sel & (pio16_vld | pio64_vld | pio_err))
jbc_ctag[11:8] = icr_sbdtag[3:0];
jbc_ctag[11:8] = {nxt_tag[0],dma_dptr[4:2]};
if (~cmd_req_sel & (pio16_vld | pio64_vld | pio_err))
jbc_ctag[7:6] = {1'b0,icr_addr[6]};
jbc_ctag[7:6] = dma_dptr[1:0];
jbc_ctag[5:0] = tcr_mtag;
if (pio16_vld | pio64_vld | pio_err)
jbc_ctag[5:0] = icr_addr[5:0];
jbc_ctag[5:0] = {icr_sbdtag, icr_clsts};
// --------------------------------------------------------
// CTM-CRM Unsupported Request Fifo-Credit Manager
// --------------------------------------------------------
// generate q_count_uns load signal
assign q_count_uns_ld = crm2ctm_rcd_deq ^ proc_uns;
// credit availability flag
assign uns_req_crdt_avail = |q_count_uns;
always @(proc_uns or q_count_uns)
nxt_q_count_uns = q_count_uns - 1'b1;
nxt_q_count_uns = q_count_uns + 1'b1;
q_count_uns <= UNS_CRDTCNT;
q_count_uns <= nxt_q_count_uns;
// --------------------------------------------------------
// Sequential Logic : DMC-JBC Interface
// --------------------------------------------------------
d2j_cmd <= `FIRE_D2J_CMD_WDTH'b0;
d2j_addr <= `FIRE_D2J_ADDR_WDTH'b0;
d2j_ctag <= `FIRE_D2J_CTAG_WDTH'b0;
// --------------------------------------------------------
// Sequential Logic : CTM-CRM Interface
// --------------------------------------------------------
ctm2crm_rcd[`FIRE_DLC_CLU_URR_TYP] <= `FIRE_DLC_CLU_URR_TYP_WDTH'b0;
ctm2crm_rcd[`FIRE_DLC_CLU_URR_SBDTAG] <= `FIRE_DLC_ICR_SBDTAG_WDTH'b0;
ctm2crm_rcd[`FIRE_DLC_CLU_URR_TYP] <= uns_cmd;
ctm2crm_rcd[`FIRE_DLC_CLU_URR_SBDTAG] <= icr_sbdtag;
endmodule // dmu_clu_ctm_cmdgen