// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: niu_scam_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 ============================================
/**********************************************************
***********************************************************
File name : niu_scam_ctl.v
Module(s) name : niu_scam_ctl
Parent modules : niu_scam.v
Author's name : George Chu
************************************************************
***********************************************************/
input cam_compare_d; // initiate compare operation
/**********************************************************/
/*--------------------------------------------------------*/
wire [2:0] pio_cam_cyc_1 = 3'h2; // geo, real 3-1=2
wire [2:0] pio_cam_cyc_2 = 3'h1; // geo, real 3-2=1
wire n_cmp_enc = (cyc_cnt==pio_cam_cyc_2[2:0]) && (c_scam_st==`NIU_SCAM_CMP);
/*--------------------------------------------------------*/
/**********************************************************/
always @(cam_compare_d or
n_scam_st = `NIU_SCAM_IDL;
case (c_scam_st) //synopsys parallel_case
n_scam_st = `NIU_SCAM_CMP;
n_scam_st = `NIU_SCAM_IDL;
if (cyc_cnt>=pio_cam_cyc_1) begin
n_scam_st = `NIU_SCAM_IDL;
n_scam_st = `NIU_SCAM_CMP;
n_scam_st = `NIU_SCAM_IDL;
niu_scam_cnt_i_r_3 cam_cnt_i_r_3_0(.incr(inc_cyc_cnt), .rs(clr_cam), .ck(cam_clk), .qo(cyc_cnt[2:0]));
/**********************************************************/
always @(pio_wt_d or pio_rd_d or
n_pio_rw_st = `NIU_SCAM_PIO_IDL;
case (c_pio_rw_st) //synopsys parallel_case
if (pio_wt_d || pio_rd_d) begin
n_catch_pio_rd = pio_rd_d;
n_pio_rw_st = `NIU_SCAM_PIO_OUT;
n_pio_rw_st = `NIU_SCAM_PIO_IDL;
n_pio_rw_st = `NIU_SCAM_PIO_IDL;
n_pio_rw_st = `NIU_SCAM_PIO_IDL;
assign wt_data = pio_wt_d && !pio_sel_d && (c_pio_rw_st==`NIU_SCAM_PIO_IDL) && !cmp_busy;
assign wt_mask = pio_wt_d && pio_sel_d && (c_pio_rw_st==`NIU_SCAM_PIO_IDL) && !cmp_busy;
assign rd_data = pio_rd_d && !pio_sel_d && (c_pio_rw_st==`NIU_SCAM_PIO_IDL);
assign rd_mask = pio_rd_d && pio_sel_d && (c_pio_rw_st==`NIU_SCAM_PIO_IDL);
/**********************************************************/
always @(posedge cam_clk)
/*geo*/ cmp_enc <= #1 (1'h0);
catch_pio_rd <= #1 (1'h0);
c_pio_rw_st <= #1 (`NIU_SCAM_PIO_IDL);
/*geo*/ cmp_enc <= #1 (n_cmp_enc);
cmp_busy <= #1 (n_cmp_busy);
cam_valid <= #1 (n_cam_valid);
clr_cam <= #1 (n_clr_scam);
c_scam_st <= #1 (n_scam_st);
catch_pio_rd <= #1 (n_catch_pio_rd);
pio_rd_vld <= #1 (catch_pio_rd);
c_pio_rw_st <= #1 (n_pio_rw_st);