// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: dmu_cmu_tcm.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 ============================================
//************************************************
//************************************************
// Egress Packet Record Field Widths
// parameter CL2CM_WDTH = `FIRE_DLC_EPR_REC_WDTH; //80
parameter EPRMSB = `FIRE_DLC_EPR_MSB; // CL2CM_WDTH -1
parameter PRTYP_WDTH = `FIRE_DLC_EPR_TYP_WDTH, // 6
PRLEN_WDTH = `FIRE_DLC_EPR_LEN_WDTH, //10
PRDWBE_WDTH = `FIRE_DLC_EPR_DWBE_WDTH, // 8
PRADDR_WDTH = `FIRE_DLC_EPR_ADDR_WDTH, //34
PRSBDTAG_WDTH = `FIRE_DLC_EPR_SBDTAG_WDTH, // 5
PRDPTR_WDTH = `FIRE_DLC_EPR_DPTR_WDTH, // 6
PRPKSEQNUM_WDTH = `FIRE_DLC_EPR_PKSEQNUM_WDTH, // 5
PRCNTXTNUM_WDTH = `FIRE_DLC_EPR_CNTXTNUM_WDTH; // 5
parameter PRTYPMSB = PRTYP_WDTH -1,
PRLENMSB = PRLEN_WDTH -1,
PRDWBEMSB = PRDWBE_WDTH -1,
PRADDRMSB = PRADDR_WDTH -1,
PRSBDTAGMSB = PRSBDTAG_WDTH -1,
PRDPTRMSB = PRDPTR_WDTH -1,
PRPKSEQNUMMSB = PRPKSEQNUM_WDTH -1,
PRCNTXTNUMMSB = PRCNTXTNUM_WDTH -1;
// Egress Retire Record Field Widths
// parameter CM2RM_WDTH = `FIRE_DLC_ERR_REC_WDTH; //70
parameter RRMSB = `FIRE_DLC_ERR_MSB; // CM2RM_WDTH -1
parameter RRTYP_WDTH = `FIRE_DLC_ERR_TYP_WDTH, // 7
RRLEN_WDTH = `FIRE_DLC_ERR_LEN_WDTH, //10
RRFDWBE_WDTH = `FIRE_DLC_ERR_FDWBE_WDTH, // 4
RRLDWBE_WDTH = `FIRE_DLC_ERR_LDWBE_WDTH, // 4
RRADDR_WDTH = `FIRE_DLC_ERR_ADDR_WDTH, //34
RRSBDTAG_WDTH = `FIRE_DLC_ERR_SBDTAG_WDTH, // 5
RRDPTR_WDTH = `FIRE_DLC_ERR_DPTR_WDTH; // 6
parameter RRTYPMSB = RRTYP_WDTH -1,
RRLENMSB = RRLEN_WDTH -1,
RRDWBEMSB = RRFDWBE_WDTH + RRLDWBE_WDTH -1,
RRADDRMSB = RRADDR_WDTH -1,
RRSBDTAGMSB = RRSBDTAG_WDTH -1,
RRDPTRMSB = RRDPTR_WDTH -1;
// parameter CTXARRAY_WDTH = 43, // Context CTX entry width
parameter CTXARRAY_WDTH = 44, // Context CTX entry width
CTXARRAYMSB = CTXARRAY_WDTH -1,
CTXADDRMSB = CTXADDRLSB + CTXADDR_WDTH -1;
parameter ORDERBITLSB = 0, //0
ORDERBITMSB = ORDERBITLSB + ORDERBIT_WDTH -1, //31
ERRLSB = ORDERBITLSB + ORDERBIT_WDTH,
PSEQLSB = ERRLSB + ERR_WDTH,
PSEQMSB = PSEQLSB + PSEQ_WDTH -1, //37
PKTOTLSB = PSEQLSB + PSEQ_WDTH,
PKTOTMSB = PKTOTLSB + PKTOT_WDTH -1; //42
parameter PSEQARRAY_WDTH = 5, // Context PKSEQ entry width
PSEQARRAYMSB = PSEQARRAY_WDTH -1,
PSEQADDRMSB = PSEQADDRLSB + PSEQADDR_WDTH -1;
parameter PTRCLSTLSB = 0, //0
PTRCLSTMSB = PTRCLSTLSB + PTRCLST_WDTH -1, //3
CBITLSB = PTRCLSTLSB + PTRCLST_WDTH,
CBITMSB = CBITLSB + CBIT_WDTH -1; //4
parameter CLSTARRAY_WDTH = 54, // Context CLST entry width
CLSTARRAYMSB = CLSTARRAY_WDTH -1,
CLSTADDRMSB = CLSTADDRLSB + CLSTADDR_WDTH -1;
CPKSEQMSB = CPKSEQLSB + CPKSEQ_WDTH -1,
CDPTRLSB = CPKSEQLSB + CPKSEQ_WDTH,
CDPTRMSB = CDPTRLSB + CDPTR_WDTH -1,
CSBDTAGLSB = CDPTRLSB + CDPTR_WDTH,
CSBDTAGMSB = CSBDTAGLSB + CSBDTAG_WDTH -1,
CADDRLSB = CSBDTAGLSB + CSBDTAG_WDTH,
CADDRMSB = CADDRLSB + CADDR_WDTH -1,
CDWBELSB = CADDRLSB + CADDR_WDTH,
CDWBEMSB = CDWBELSB + CDWBE_WDTH -1,
CLSTPKTLSB = CDWBELSB + CDWBE_WDTH,
CLSTPKTMSB = CLSTPKTLSB + CLSTPKT_WDTH -1,
CLENLSB = CLSTPKTLSB + CLSTPKT_WDTH,
CLENMSB = CLENLSB + CLEN_WDTH -1,
CTYPLSB = CLENLSB + CLEN_WDTH,
CTYPMSB = CTYPLSB + CTYP_WDTH -1;
parameter RETADDRARRAY_WDTH = 17,
RETADDRMSB = RETADDRARRAY_WDTH -1;
//************************************************
//************************************************
input clk; // The input clock
input rst_l; // synopsys sync_set_reset "rst_l"
input [EPRMSB : 0] cl2cm_rcd;
output [RRMSB : 0] cm2rm_rcd;
output [CTXADDRMSB :0] tcm2ctx_ctx_addr;
input [CTXARRAYMSB : 0] ctx2tcm_cur_ctx;
output [CTXARRAYMSB : 0] tcm2ctx_ctx;
output [PSEQADDRMSB :0] tcm2ctx_pkseq_addr;
input [PSEQARRAYMSB : 0] ctx2tcm_cur_pkseq;
output [PSEQARRAYMSB : 0] tcm2ctx_pkseq;
input [CLSTADDRMSB :0] ctx2tcm_nxlst_addr;
output [CLSTADDRMSB :0] tcm2ctx_ctxlst_addr;
output [CLSTARRAYMSB : 0] tcm2ctx_lst;
input [CLSTARRAYMSB : 0] ctx2tcm_cur_lst;
output [RETADDRMSB :0] tcm2ctx_ret_addr;
input [`FIRE_DLC_CMU_TCM_DS_BITS] dbg2tcm_dbg_sel_a;
input [`FIRE_DLC_CMU_TCM_DS_BITS] dbg2tcm_dbg_sel_b;
output [`FIRE_DBG_DATA_BITS] tcm2dbg_dbg_a;
output [`FIRE_DBG_DATA_BITS] tcm2dbg_dbg_b;
//************************************************
//************************************************
// Packet Record queue signals
// for use with debuig ports
// Packet Record field assignments to TCM signals
wire [PRTYPMSB :0] pkttyp;
wire [PRLENMSB :0] pktlen;
wire [PRDWBEMSB :0] pktdwbe;
wire [PRADDRMSB :0] pktaddr;
wire [PRSBDTAGMSB :0] pkttr_tag;
wire [PRDPTRMSB :0] pktdptr;
wire [PRPKSEQNUMMSB :0] pktseq_num;
wire [PRCNTXTNUMMSB :0] pktcntxt_num;
reg [CTXADDRMSB :0] tcm2ctx_ctx_addr_hld;
wire [CTXARRAYMSB : 0] ctx2tcm_cur_ctx;
reg [CTXARRAYMSB : 0] tcm_cur_ctx;
reg [CTXARRAYMSB : 0] tcm2ctx_ctx;
reg [PSEQADDRMSB :0] tcm2ctx_pkseq_addr;
wire [PSEQARRAYMSB : 0] ctx2tcm_cur_pkseq;
reg [PSEQARRAYMSB : 0] tcm2ctx_pkseq;
wire [CLSTADDRMSB :0] ctx2tcm_nxlst_addr;
reg [CLSTADDRMSB :0] tcm2ctx_ctxlst_addr;
reg [CLSTARRAYMSB : 0] tcm2ctx_lst;
wire [CLSTARRAYMSB : 0] ctx2tcm_cur_lst;
wire [CPKSEQMSB :0] scan_pkseq_num;
reg [RETADDRMSB :0] tcm2ctx_ret_addr;
wire [ORDERBITMSB :0] ctx_order_bits;
wire [ORDERBITMSB :0] new_order_bits;
// Retire Record field assignments
reg [RRDWBEMSB :0] rrdwbe;
reg [RRADDRMSB :0] rraddr;
reg [RRSBDTAGMSB :0] rrsbdtag;
reg [RRDPTRMSB :0] rrdptr;
reg [RRTYPMSB :0] next_rrtyp;
reg [RRLENMSB :0] next_rrlen;
reg [RRDWBEMSB :0] next_rrdwbe;
reg [RRADDRMSB :0] next_rraddr;
reg [RRSBDTAGMSB :0] next_rrsbdtag;
reg [RRDPTRMSB :0] next_rrdptr;
reg [PRPKSEQNUMMSB :0] next_pktseq_num;
reg [PRCNTXTNUMMSB :0] next_pktcntxt_num;
reg [RRTYPMSB :0] pipe_rrtyp;
reg [RRLENMSB :0] pipe_rrlen;
reg [RRDWBEMSB :0] pipe_rrdwbe;
reg [RRADDRMSB :0] pipe_rraddr;
reg [RRSBDTAGMSB :0] pipe_rrsbdtag;
reg [RRDPTRMSB :0] pipe_rrdptr;
reg [PRPKSEQNUMMSB :0] pipe_pktseq_num;
reg [PRCNTXTNUMMSB :0] pipe_pktcntxt_num;
reg [CTXADDRMSB :0] ctx_relrcd;
reg [PSEQADDRMSB :0] pkseq_relrcd;
reg [CLSTADDRMSB :0] clst_relrcd;
reg [ORDERBITMSB :0] upd_order_bits;
reg [ORDERBITMSB :0] scan_order_bits;
reg [`FIRE_DLC_CMU_TCM_DS_BITS] dbg_sel [0:1];
reg [`FIRE_DBG_DATA_BITS] dbg_bus [0:1];
reg [`FIRE_DBG_DATA_BITS] nxt_dbg_bus [0:1];
// *************** Local Declarations *************************************
parameter DEQIDLE = 2'b00, // Idle
DEQ = 2'b01; // dequeue next packets
parameter CTXIDLE = 3'b000, // Context Scanner is IDLE
CTXSEQ = 3'b001, // look up packet sequence
CTXCHK = 3'b010, // check packet against context
CTXDIS = 3'b011, // dispatch (store,send)
CTXNXT = 3'b100; // look up next packet sequence
parameter LSTIDLE = 2'b00, // Packet Sequence Put Idle
LSTGNT = 2'b01, // Packet Sequence Put has CLIST address
LSTUPD = 2'b10; // write PSEQ at CLIST entry address,
parameter BLDIDLE = 3'b000, // Build Context Idle
BLDCNTX = 3'b010, // Context ops in progress
BLDBPAS = 3'b011; // NO context ops needed
parameter CLASCP = 3'b001,
//************************************************
//************************************************
//0in state_transition -var deq_state -val DEQIDLE -next DEQIDLE DEQ
//0in state_transition -var deq_state -val DEQ -next DEQIDLE
//0in state_transition -var ctx_state -val CTXIDLE -next CTXIDLE CTXSEQ
//0in state_transition -var ctx_state -val CTXSEQ -next CTXCHK CTXIDLE
//0in state_transition -var ctx_state -val CTXCHK -next CTXIDLE CTXDIS
//0in state_transition -var ctx_state -val CTXDIS -next CTXNXT CTXIDLE CTXDIS CTXSEQ
//0in state_transition -var ctx_state -val CTXNXT -next CTXSEQ
//0in state_transition -var lst_state -val LSTIDLE -next LSTIDLE LSTGNT
//0in state_transition -var lst_state -val LSTGNT -next LSTGNT LSTUPD
//0in state_transition -var lst_state -val LSTUPD -next LSTIDLE
// build_crcd (pipeline staging and command record build)
//0in state_transition -var bld_state -val BLDIDLE -next BLDIDLE BLDBPAS BLDCNTX
//0in state_transition -var bld_state -val BLDCNTX -next BLDCNTX BLDIDLE
//0in state_transition -var bld_state -val BLDBPAS -next BLDBPAS BLDIDLE
// ********** Parse Packet Record Procedures (parse_rcd)*********/
// Transaction Type Decode - Context Function Encoding(typ_dcd)
always @(pkttyp or pkt_clsts)
case(pkttyp) // synopsys parallel_case
7'b0000100, // PIO Cfg Rd 0
7'b0000101, // PIO Cfg RD 1
7'b1000100, // PIO Cfg Wr 0
7'b1000101 : next_clastyp = CLASPIO; // PIO Cfg Wr 1
7'b1111010 : next_clastyp = CLASMDO; // Mondo Rpy
case (pkt_clsts) // synopsys parallel_case
3'b001 : next_clastyp = CLASUSP; // DMA CPLk,Unsup Cpl
default : next_clastyp = CLASCP;
endcase // case(pkt_clsts)
7'b1001010 : next_clastyp = CLASCPD; // DMA CP D
default : next_clastyp = 3'b111; // to satisfy vlint
always @( rst_l or ctx_order_bits or pipe_pktseq_num or pipe_clastyp
case({pipe_clastyp,ctx_ck}) // synopsys parallel_case
if(pipe_pktseq_num == 0) begin
if ((ctx_order_bits[pipe_pktseq_num] == 1'b1)
&& (ctx_order_bits[pipe_pktseq_num - 1'b1] == 1'b0)) begin
end // else: !if(pipe_pktseq_num == 0)
end // else: !if(rst_l == 1'b0)
always @(pipe_pktseq_num)
upd_order_bits = {32{1'b1}};
upd_order_bits[pipe_pktseq_num] = 1'b0;
scan_order_bits = {32{1'b1}};
scan_order_bits[scan_pkseq_num] = 1'b0;
// Parse Packet Record to issue Retire Records or Context ops
// pipelined next retire record staging
always @(next_clastyp or pkttyp or pktlen or pktdwbe or pktaddr or
pkttr_tag or pktdptr or pktseq_num or pktcntxt_num)
case(next_clastyp) // synopsys full_case parallel_case
CLASPIO: begin // All PIO's
next_rrtyp = pkttyp[PRTYPMSB :0];
next_rrlen = pktlen[PRLENMSB :0];
next_rrdwbe = pktdwbe[PRDWBEMSB :0];
next_rraddr = pktaddr[PRADDRMSB :0];
next_rrsbdtag = pkttr_tag[PRSBDTAGMSB :0];
next_rrdptr = pktdptr[PRDPTRMSB :0];
CLASMDO : begin // Mondo Rpy
next_rrtyp = pkttyp[PRTYPMSB :0];
next_rrlen = pktlen[PRLENMSB :0];
next_rrdwbe = pktdwbe[PRDWBEMSB :0];
next_rraddr = pktaddr[PRADDRMSB :0];
next_rrsbdtag = pkttr_tag[PRSBDTAGMSB :0];
next_rrdptr = pktdptr[PRDPTRMSB :0];
CLASCPD : begin // DMA CP D
next_rrtyp = pkttyp[PRTYPMSB :0];
next_rrlen = pktlen[PRLENMSB :0];
next_rrdwbe = pktdwbe[PRDWBEMSB :0];
next_rraddr = pktaddr[PRADDRMSB :0];
next_rrsbdtag = pkttr_tag[PRSBDTAGMSB :0];
next_rrdptr = pktdptr[PRDPTRMSB :0];
next_pktseq_num = pktseq_num[PRPKSEQNUMMSB :0];
next_pktcntxt_num = pktcntxt_num[PRCNTXTNUMMSB :0];
CLASUSP : begin // Unsup CP
next_rrtyp = pkttyp[PRTYPMSB :0];
next_rrlen = pktlen[PRLENMSB :0];
next_rrdwbe = {pktdwbe[PRDWBEMSB :5],1'b1,pktdwbe[3 :0]};
next_rraddr = pktaddr[PRADDRMSB :0];
next_rrsbdtag = pkttr_tag[PRSBDTAGMSB :0];
next_rrdptr = pktdptr[PRDPTRMSB :0];
next_pktseq_num = pktseq_num[PRPKSEQNUMMSB :0];
next_pktcntxt_num = pktcntxt_num[PRCNTXTNUMMSB :0];
endcase // case(next_clastyp)
end // always @ (next_clastyp or pkttyp or pktlen or pktdwbe or pktaddr or...
// Class Type pipeline stage
scan_mode <= look_up ? 1'b1 : (~stop_scan & scan_mode);
pipe_rrtyp <= {RRTYP_WDTH{1'b0}};
pipe_rrlen <= {RRLEN_WDTH{1'b0}};
pipe_rrdwbe <= {RRFDWBE_WDTH + RRLDWBE_WDTH{1'b0}};
pipe_rraddr <= {RRADDR_WDTH{1'b0}};
pipe_rrsbdtag <= {RRSBDTAG_WDTH{1'b0}};
pipe_rrdptr <= {RRDPTR_WDTH{1'b0}};
pipe_pktseq_num <= {PRPKSEQNUM_WDTH{1'b0}};
pipe_pktcntxt_num <= {PRCNTXTNUM_WDTH{1'b0}};
pipe_clastyp <= {3{1'b0}};
pipe_rrtyp <= ld_pipe ? next_rrtyp : pipe_rrtyp;
pipe_rrlen <= ld_pipe ? next_rrlen : pipe_rrlen;
pipe_rrdwbe <= ld_pipe ? next_rrdwbe : pipe_rrdwbe;
pipe_rraddr <= ld_pipe ? next_rraddr : pipe_rraddr;
pipe_rrsbdtag <= ld_pipe ? next_rrsbdtag : pipe_rrsbdtag;
pipe_rrdptr <= ld_pipe ? next_rrdptr : pipe_rrdptr;
pipe_pktseq_num <= ld_pipe ? next_pktseq_num : pipe_pktseq_num;
pipe_pktcntxt_num <= ld_pipe ? next_pktcntxt_num : pipe_pktcntxt_num;
pipe_clastyp <= ld_pipe ? next_clastyp : pipe_clastyp;
end // always @ (posedge clk)
always @(deq_state or pkmpty or pipe_full or rm2cm_rcd_full)
case(deq_state) // synopsys parallel_case
case(pkmpty) // synopsys full_case parallel_case
1'b1: deq_next = DEQIDLE;
case(pipe_full | rm2cm_rcd_full) // synopsys full_case parallel_case
1'b1 : deq_next = DEQIDLE;
endcase // case(pipe_full | rm2cm_rcd_full)
default : deq_next = DEQIDLE;
endcase // case(deq_state)
end // always @ (deq_state or pkmpty or pipe_full)
// DEQ state machine outputs
always @(deq_state or pipe_full or pkmpty or next_clastyp or
case(deq_state) // synopsys parallel_case
case(pkmpty) // synopsys full_case parallel_case
case(pipe_full | rm2cm_rcd_full) // synopsys full_case parallel_case
case(next_clastyp) // synopsys parallel_case
CLASMDO : next_pkvld = 1'b0;
CLASCPD : next_pkvld = 1'b1;
default : next_pkvld = 1'b0;
endcase // case(next_clastyp)
endcase // case(pipe_full | rm2cm_rcd_full)
endcase // case(deq_state)
end // always @ (deq_state or pipe_full or next_clastyp)
deq_state <= DEQIDLE; // Synchronous Reset
// Context look-up (ctx_upd fsm)
always @(ctx_state or pkvld or store_pkt or frwd_pkt or last_in_pkt
or last_scan_pkt or cpl or do_pkseq or scan_mode or
case(ctx_state) // synopsys parallel_case
case(pkvld) // synopsys full_case parallel_case
1'b0: ctx_next = CTXIDLE;
case(scan_mode) // synopsys full_case parallel_case
if(last_scan_pkt) ctx_next = CTXIDLE;
1'b0 : ctx_next = CTXCHK;
endcase // case(scan_mode)
case(rm2cm_rcd_full) // synopsys full_case parallel_case
1'b1 : ctx_next = CTXCHK;
1'b0 : ctx_next = CTXDIS;
endcase // case(rm2cm_rcd_full)
case(scan_mode) // synopsys full_case parallel_case
case({store_pkt,frwd_pkt}) // synopsys parallel_case
if(last_in_pkt) ctx_next = CTXIDLE;
2'b10 : begin // wait for lst gnt?
if (do_pkseq) ctx_next = CTXIDLE;
default : ctx_next = CTXIDLE;
endcase // case({store_pkt,frwd_pkt})
case(cpl) // synopsys full_case parallel_case
case (pkvld) // synopsys full_case parallel_case
1'b0: ctx_next = CTXIDLE;
endcase // case(scan_mode)
CTXNXT : ctx_next = CTXSEQ;
default : ctx_next = CTXIDLE; // to satisfy vlint
endcase // case(ctx_state)
end // always @ (ctx_state or pkvld or store_pkt or frwd_pkt or last_in_pkt...
// Context look-up (ctx_upd fsm)
always @(ctx_state or pkvld or store_pkt or frwd_pkt or last_in_pkt
or last_scan_pkt or cpl or do_pkseq or scan_mode)
case(ctx_state) // synopsys parallel_case
case(pkvld) // synopsys full_case parallel_case
next_ctx_addr = 1'b0; //next_ctx_addr = 1'b1;
case(scan_mode) // synopsys full_case parallel_case
case(last_scan_pkt) // synopsys full_case parallel_case
next_ctx_ck = 1'b0; // next_ctx_ck = 1'b1;
endcase // case(last_scan_pkt)
endcase // case(scan_mode)
case(scan_mode) // synopsys full_case parallel_case
1'b1 : next_ctx_ck = 1'b0;
1'b0 : next_ctx_ck = 1'b1;
endcase // case(scan_mode)
case(scan_mode) // synopsys full_case parallel_case
case({store_pkt,frwd_pkt}) // synopsys parallel_case
case(last_in_pkt) // synopsys full_case parallel_case
endcase // case(last_in_pkt)
2'b10 : begin // wait for lst gnt?
case(cpl) // synopsys full_case parallel_case
case(do_pkseq) // synopsys full_case parallel_case
endcase // case(do_pkseq)
case(do_pkseq) // synopsys full_case parallel_case
endcase // case(do_pkseq)
endcase // case({store_pkt,frwd_pkt})
case(cpl) // synopsys full_case parallel_case
do_ctx = 1'b0; // do_ctx = 1'b1;
xfr_strt = 1'b0; // xfr_strt = 1'b1;
case (pkvld) // synopsys full_case parallel_case
1'b1: next_ctx_addr = 1'b1;
1'b0: next_ctx_addr = 1'b0;
endcase // case(scan_mode)
next_ctx_ck = 1'b0; // do not check incoming pkseq, get frm clist
default : begin // to satisfy vlint
endcase // case(ctx_state)
end // always @ (ctx_state or next_pkvld or store_pkt or frwd_pkt or last_pkt...
ctx_state <= CTXIDLE; // Synchronous Reset
// CLIST Egress Packet Put FSM (lst_upd)
always @(lst_state or ctx2tcm_lst_gnt or next_clist_put)
case(lst_state) // synopsys parallel_case
case(next_clist_put) // synopsys full_case parallel_case
endcase // case(next_clist_put)
case(ctx2tcm_lst_gnt) // synopsys full_case parallel_case
endcase // case(ctx2tcm_lst_gnt)
default : begin // to satisfy vlint
endcase // case(lst_state)
end // always @ (lst_state or ctx2tcm_lst_gnt or next_clist_put)
lst_state <= LSTIDLE; // Synchronous Reset
// *************** Build Context Procedures (build_cntx)*********/
// Packet Record Dequeue Process
// packet record dequeue state machine (dq_fsm)
// Parse Schedule Record to issue Packet Records
// lengths are represented in DW's
// Context Build Process (build_cntx)
// Transfer State machine
always @(bld_state or pipe_mpty or rm2cm_rcd_full or pipe_clastyp
or xfr_strt or last_in_pkt or last_scan_pkt or stop_scan
case(bld_state) // synopsys full_case parallel_case
case(pipe_mpty) // synopsys full_case parallel_case
1'b1 : bld_next = BLDIDLE;
case(pipe_clastyp) // synopsys parallel_case
CLASMDO : bld_next = BLDBPAS;
CLASCPD : bld_next = BLDCNTX;
default : bld_next = BLDIDLE;
endcase // case(next_clastyp)
endcase // case(pipe_mpty)
case(rm2cm_rcd_full) // synopsys full_case parallel_case
case({scan_mode,xfr_strt}) // synopsys full_case parallel_case
case(stop_scan) // synopsys full_case parallel_case
1'b1 : bld_next = BLDIDLE;
1'b0 : bld_next = BLDCNTX;
endcase // case({stop_scan,pipe_mpty})
case({pipe_clastyp, last_in_pkt}) // synopsys parallel_case
{CLASCPD,1'b0} : bld_next = BLDCNTX;
{CLASCPD,1'b1} : bld_next = BLDIDLE;
default : bld_next = BLDIDLE;
endcase // case({pipe_clastyp, last_in_pkt})
case(stop_scan) // synopsys full_case parallel_case
1'b1 : bld_next = BLDIDLE;
1'b0 : bld_next = BLDCNTX;
endcase // case(stop_scan)
case(last_scan_pkt) // synopsys full_case parallel_case
1'b1 : bld_next = BLDIDLE;
case(stop_scan) // synopsys full_case parallel_case
1'b1 : bld_next = BLDIDLE;
1'b0 : bld_next = BLDCNTX;
endcase // case(stop_scan)
endcase // case(last_scan_pkt)
endcase // case({scan_mode,xfr_strt})
1'b1 : bld_next = BLDCNTX;
endcase // case(rm2cm_rcd_full)
case(rm2cm_rcd_full) // synopsys full_case parallel_case
1'b0 : bld_next = BLDIDLE;
1'b1 : bld_next = BLDBPAS;
endcase // case(rm2cm_rcd_full)
default : bld_next = BLDIDLE;
endcase // case(bld_state)
end // always @ (bld_state or pkmpty or rm2cm_rcd_full or next_clastyp...
// BLD state machine outputs
always @(bld_state or rm2cm_rcd_full or pipe_clastyp or xfr_strt
or last_in_pkt or last_scan_pkt or stop_scan or scan_mode)
// next_deq_pipe signal to dequeue next packet record in pipeline
// next_gen_pkt signal to start retire record build
// next_rcd_enq enqueues packet to pipeline
case(bld_state) // synopsys full_case parallel_case
case(rm2cm_rcd_full) // synopsys full_case parallel_case
case({scan_mode,xfr_strt}) // synopsys full_case parallel_case
case(stop_scan) // synopsys full_case parallel_case
1'b1 : next_deq_pipe = 1'b1;
1'b0 : next_deq_pipe = 1'b0;
endcase // case(stop_scan)
case({pipe_clastyp, last_in_pkt}) // synopsys parallel_case
endcase // case({pipe_clastyp, last_in_pkt})
case(last_scan_pkt) // synopsys full_case parallel_case
case(stop_scan) // synopsys full_case parallel_case
endcase // case(stop_scan)
endcase // case(last_scan_pkt)
endcase // case({scan_mode,xfr_strt})
endcase // case(rm2cm_rcd_full)
case(rm2cm_rcd_full) // synopsys full_case parallel_case
endcase // case(rm2cm_rcd_full)
endcase // case(bld_state)
end // always @ (bld_state or pkmpty or rm2cm_rcd_full or next_clastyp...
bld_state <= BLDIDLE; // Synchronous Reset
//************************************************
//************************************************
dmu_cmu_tcm_pkrcd_q tcm_queue (
.cntxt_num(pktcntxt_num),
.overflow(), // .overflow(overflow),
.underflow() // .underflow(underflow)
// ********************** signal registers *************************/
case(bld_state) // synopsys parallel_case
BLDIDLE : begin // BLDIDLE
ctx_relrcd <= ld_pipe ? pipe_pktcntxt_num : ctx_relrcd;
pkseq_relrcd <= tcm2ctx_ctx[PSEQMSB : PSEQLSB];
BLDCNTX : begin // BLDCNTX
case({next_gen_pkt, scan_mode}) // synopsys parallel_case
ctx_relrcd <= pipe_pktcntxt_num;
pkseq_relrcd <= tcm_cur_ctx[PSEQMSB : PSEQLSB] + pipe_pktseq_num;
clst_relrcd <= tcm2ctx_ctxlst_addr;
ctx_sel <= ctx2tcm_cur_lst[CLSTPKTMSB];
ctx_relrcd <= ctx_relrcd;
pkseq_relrcd <= tcm2ctx_pkseq_addr; // tcm_cur_ctx[PSEQMSB : PSEQLSB] + scan_pkseq_num;
clst_relrcd <= tcm2ctx_ctxlst_addr;
ctx_relrcd <= ctx_relrcd;
pkseq_relrcd <= pkseq_relrcd;
clst_relrcd <= clst_relrcd;
endcase // case({next_gen_pkt, scan_mode})
BLDBPAS : begin // BLDBPAS
ctx_relrcd <= ctx_relrcd;
pkseq_relrcd <= pkseq_relrcd;
clst_relrcd <= clst_relrcd;
ctx_relrcd <= ctx_relrcd;
pkseq_relrcd <= pkseq_relrcd;
clst_relrcd <= clst_relrcd;
endcase // case(bld_state)
end // always @ (posedge clk)
tcm2ctx_ctx_addr_hld <= 0;
tcm2ctx_ctxlst_addr <= 0;
tcm2ctx_ctxlst_addr <= 0;
hld_pkvld <= next_pkvld ? 1'b1 : (~clear_pkvld & hld_pkvld);
pipe_full <= ld_pipe ? 1'b1 : (~next_deq_pipe & pipe_full);
cm2rm_rcd_enq <= next_rcd_enq;
tcm2ctx_ctx_addr_hld <= (next_ctx_addr
&& ((pipe_clastyp == CLASCP) || (pipe_clastyp == CLASCPD))
&& hld_pkvld) ? pipe_pktcntxt_num
tcm2ctx_ctx_rw <= do_ctx;
? {tcm_cur_ctx[CTXARRAYMSB : ERRLSB],(scan_order_bits & ctx_order_bits)}
: {tcm_cur_ctx[CTXARRAYMSB : ERRLSB],new_order_bits})
case(do_next_pkt) // synopsys parallel_case
case ({scan_mode,store_pkt}) // synopsys parallel_case
2'b10 : tcm2ctx_pkseq_addr <= tcm2ctx_pkseq_addr + 1'b1;
2'b01 : tcm2ctx_pkseq_addr <= ctx2tcm_cur_ctx[PSEQMSB : PSEQLSB] + pipe_pktseq_num;
2'b00 : tcm2ctx_pkseq_addr <= ctx2tcm_cur_ctx[PSEQMSB : PSEQLSB] + pipe_pktseq_num;
endcase // case({scan_mode,store_pkt})
1'b0 : tcm2ctx_pkseq_addr <= tcm2ctx_pkseq_addr;
endcase // case(do_next_lst)
tcm2ctx_pkseq <= do_pkseq ? {1'b1, tcm2ctx_ctxlst_addr}
tcm2ctx_pkseq_rw <= do_pkseq;
tcm2ctx_ctxlst_addr <= do_next_lst
? ctx2tcm_cur_pkseq[PTRCLSTMSB : PTRCLSTLSB]
: (ctx2tcm_lst_gnt ? ctx2tcm_nxlst_addr
tcm2ctx_lst <= do_lst ? {pipe_rrtyp,
{4'h0,pipe_rrdwbe[(PRDWBEMSB -4) :0]},
pipe_pktseq_num} : tcm2ctx_lst;
tcm2ctx_clst_rw <= do_lst;
tcm2ctx_lst_req <= next_lst_req;
do_next_lst <= do_next_pkt;
tcm_cur_ctx <= next_ctx_addr ? ctx2tcm_cur_ctx : tcm_cur_ctx;
last_in_pkt <= ((tcm_cur_ctx[PKTOTMSB :PKTOTLSB] - {1'b0,pipe_pktseq_num}) == 6'h01)
last_scan_pkt <= (scan_mode == 1'b1)
? (do_ctx ? ((tcm_cur_ctx[PKTOTMSB :PKTOTLSB] - {1'b0,scan_pkseq_num}) == 6'h01)
tcm2ctx_ret_req <= cm2rm_rcd_enq;
tcm2ctx_ret_addr <= cm2rm_rcd_enq ? ({ctx_sel,ctx_relrcd,
cpl <= ctx2tcm_cur_pkseq[CBITMSB : CBITLSB];
end // else: !if(rst_l == 1'b0)
end // always @ (posedge clk)
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
always @ (dbg2tcm_dbg_sel_a or dbg2tcm_dbg_sel_b)
dbg_sel[0] = dbg2tcm_dbg_sel_a;
dbg_sel[1] = dbg2tcm_dbg_sel_b;
always @ (dbg_sel[0] or dbg_sel[1] or next_clastyp or next_pktseq_num or
frwd_pkt or store_pkt or ctx_ck or scan_mode or stop_scan or
pipe_clastyp or pkmpty or pipe_full or next_pkvld or ld_pipe or
next_deq_pkr or deq_state or pipe_pktseq_num or do_pkseq or
last_in_pkt or ctx_state or pkvld or next_ctx_ck or tcm_is_idle or
next_clist_put or do_next_pkt or look_up or do_ctx or xfr_strt or
next_deq_pipe or next_gen_pkt or next_rcd_enq or rm2cm_rcd_full or
bld_state or next_lst_req or do_lst or lst_state
for (i = 0; i < 2; i = i + 1) begin
case (dbg_sel[i]) // synopsys infer_mux
3'b000: nxt_dbg_bus[i] = {next_clastyp,next_pktseq_num};
3'b001: nxt_dbg_bus[i] = {frwd_pkt,store_pkt,ctx_ck,scan_mode,stop_scan,pipe_clastyp};
3'b010: nxt_dbg_bus[i] = {tcm_is_idle,pkmpty,pipe_full,next_pkvld,ld_pipe,next_deq_pkr,deq_state};
3'b011: nxt_dbg_bus[i] = {pipe_clastyp,pipe_pktseq_num};
3'b100: nxt_dbg_bus[i] = {store_pkt,do_pkseq,last_in_pkt,scan_mode,pkvld,ctx_state};
3'b101: nxt_dbg_bus[i] = {pkvld,next_ctx_ck,next_clist_put,do_next_pkt,look_up,do_ctx,stop_scan,xfr_strt};
3'b110: nxt_dbg_bus[i] = {1'b0,next_deq_pipe,next_gen_pkt,next_rcd_enq,rm2cm_rcd_full,bld_state};
3'b111: nxt_dbg_bus[i] = {2'b00,next_lst_req,do_pkseq,do_lst,next_clist_put,lst_state};
endcase // case(dbg_sel[i])
end // for (i = 0; i < 2; i = i + 1)
end // always @ (dbg_sel[0] or dbg_sel[1] or...
// ********************** Output Procedures ************************/
always @ (posedge clk) begin
for (k = 0; k < 2; k = k + 1) begin
for (k = 0; k < 2; k = k + 1) begin
dbg_bus[k] <= nxt_dbg_bus[k];
end // always @ (posedge clk)
// Pipeline stages for next retire record packet sequence
// Registered outputs for Retire Record outputs
rrtyp <= {RRTYP_WDTH{1'b0}};
rrlen <= {RRLEN_WDTH{1'b0}};
rrdwbe <= {RRFDWBE_WDTH + RRLDWBE_WDTH{1'b0}};
rraddr <= {RRADDR_WDTH{1'b0}};
rrsbdtag <= {RRSBDTAG_WDTH{1'b0}};
rrdptr <= {RRDPTR_WDTH{1'b0}};
case(bld_state) // synopsys parallel_case
BLDIDLE : begin // BLDIDLE
BLDCNTX : begin // BLDCNTX
case({next_gen_pkt, scan_mode}) // synopsys parallel_case
rrdwbe <= ({pipe_rrdwbe[PRDWBEMSB : PRDWBEMSB -2],last_pkt
,pipe_rrdwbe[(PRDWBEMSB -4) :0]});
rrsbdtag <= pipe_rrsbdtag;
rrtyp <= ctx2tcm_cur_lst[CTYPMSB :CTYPLSB];
rrlen <= ctx2tcm_cur_lst[CLENMSB :CLENLSB];
rrdwbe <= ({{ctx2tcm_cur_lst[CDWBEMSB : CDWBEMSB -3] | {3'b0, ctx2tcm_cur_lst[CLSTPKTMSB]}},
ctx2tcm_cur_lst[(CDWBEMSB -4) : CDWBELSB]});
rraddr <= {22'h000000,ctx2tcm_cur_lst[CADDRMSB :CADDRLSB]};
rrsbdtag <= ctx2tcm_cur_lst[CSBDTAGMSB :CSBDTAGLSB];
rrdptr <= ctx2tcm_cur_lst[CDPTRMSB :CDPTRLSB];
endcase // case({next_gen_pkt, scan_mode})
BLDBPAS : begin // BLDBPAS
rrtyp <= next_rcd_enq ? pipe_rrtyp : rrtyp;
rrlen <= next_rcd_enq ? pipe_rrlen : rrlen;
rrdwbe <= next_rcd_enq ? pipe_rrdwbe : rrdwbe;
rraddr <= next_rcd_enq ? pipe_rraddr : rraddr;
rrsbdtag <= next_rcd_enq ? pipe_rrsbdtag : rrsbdtag;
rrdptr <= next_rcd_enq ? pipe_rrdptr : rrdptr;
endcase // case(bld_state)
end // always @ (posedge clk)
tcm_is_idle <= ((pkmpty == 1'b1) && (deq_state == DEQIDLE) &&
(ctx_state == CTXIDLE) && (lst_state == LSTIDLE) &&
(pipe_mpty == 1'b1) && (bld_state == BLDIDLE))
end // always @ (posedge clk)
// ***********************Assignments *****************************/
assign pkt_clsts = pktdwbe[2:0];
assign pipe_mpty = ~pipe_full;
assign pkvld = next_pkvld | hld_pkvld;
assign last_pkt = last_in_pkt | last_scan_pkt;
assign new_order_bits = (((pipe_clastyp == CLASCPD) || (pipe_clastyp == CLASCP))
? (upd_order_bits & ctx_order_bits)
assign ctx_order_bits = ctx2tcm_cur_ctx[ORDERBITMSB :ORDERBITLSB];
assign scan_pkseq_num = ctx2tcm_cur_lst[CPKSEQMSB :0];
assign cm2rm_rcd [RRMSB :0] = { // Egress Retire Record
rrsbdtag[RRSBDTAGMSB :0],
assign tcm2ctx_ctx_addr = (next_ctx_addr
&& ((pipe_clastyp == CLASCP) || (pipe_clastyp == CLASCPD))
&& hld_pkvld) ? pipe_pktcntxt_num
assign tcm2dbg_dbg_a = dbg_bus[0];
assign tcm2dbg_dbg_b = dbg_bus[1];