Line 16... |
Line 16... |
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
// License along with this work; if not, write to the Free Software
|
// License along with this work; if not, write to the Free Software
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
//
|
//
|
// ========== Copyright Header End ============================================
|
// ========== Copyright Header End ============================================
|
|
`ifdef SIMPLY_RISC_TWEAKS
|
|
`define SIMPLY_RISC_SCANIN .si(0)
|
|
`else
|
|
`define SIMPLY_RISC_SCANIN .si()
|
|
`endif
|
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
/*
|
/*
|
// Module Name: sparc_ifu_swlthrfsm
|
// Module Name: sparc_ifu_swlthrfsm
|
// Description:
|
// Description:
|
// The switch logithrfsm contains the thread state machine.
|
// The switch logithrfsm contains the thread state machine.
|
*/
|
*/
|
|
|
/*
|
`include "ifu.h"
|
/* ========== Copyright Header Begin ==========================================
|
|
*
|
|
* OpenSPARC T1 Processor File: ifu.h
|
|
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
|
|
*
|
|
* The above named program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public
|
|
* License version 2 as published by the Free Software Foundation.
|
|
*
|
|
* The above named 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 work; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*
|
|
* ========== Copyright Header End ============================================
|
|
*/
|
|
////////////////////////////////////////////////////////////////////////
|
|
/*
|
|
//
|
|
// Module Name: ifu.h
|
|
// Description:
|
|
// All ifu defines
|
|
*/
|
|
|
|
//--------------------------------------------
|
|
// Icache Values in IFU::ICD/ICV/ICT/FDP/IFQDP
|
|
//--------------------------------------------
|
|
// Set Values
|
|
|
|
// IC_IDX_HI = log(icache_size/4ways) - 1
|
|
|
|
|
|
// !!IMPORTANT!! a change to IC_LINE_SZ will mean a change to the code as
|
|
// well. Unfortunately this has not been properly parametrized.
|
|
// Changing the IC_LINE_SZ param alone is *not* enough.
|
|
|
|
|
|
// !!IMPORTANT!! a change to IC_TAG_HI will mean a change to the code as
|
|
// well. Changing the IC_TAG_HI param alone is *not* enough to
|
|
// change the PA range.
|
|
// highest bit of PA
|
|
|
|
|
|
|
|
// Derived Values
|
|
// 4095
|
|
|
|
|
|
// number of entries - 1 = 511
|
|
|
|
|
|
// 12
|
|
|
|
|
|
// 28
|
|
|
|
|
|
// 7
|
|
|
|
|
|
// tags for all 4 ways + parity
|
|
// 116
|
|
|
|
|
|
// 115
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
// For thread scheduler in IFU::DTU::SWL
|
|
//----------------------------------------------------------------------
|
|
// thread states: (thr_state[4:0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// thread configuration register bit fields
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
// For MIL fsm in IFU::IFQ
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------
|
|
// Interrupt Block
|
|
//---------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------
|
|
// IFQ
|
|
//-------------------------------------
|
|
// valid bit plus ifill
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//`ifdef SPARC_L2_64B
|
|
|
|
|
|
//`else
|
|
//`define BANK_ID_HI 8
|
|
//`define BANK_ID_LO 7
|
|
//`endif
|
|
|
|
//`define CPX_INV_PA_HI 116
|
|
//`define CPX_INV_PA_LO 112
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
// IFU Traps
|
|
//----------------------------------------
|
|
// precise
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// disrupting
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module sparc_ifu_thrfsm(/*AUTOARG*/
|
module sparc_ifu_thrfsm(/*AUTOARG*/
|
// Outputs
|
// Outputs
|
so, thr_state,
|
so, thr_state,
|
// Inputs
|
// Inputs
|
Line 252... |
Line 78... |
or rst_thread or schedule or spec_ld or stall
|
or rst_thread or schedule or spec_ld or stall
|
or start_thread or sw_cond or switch_out or thaw_thread
|
or start_thread or sw_cond or switch_out or thaw_thread
|
or thr_state)
|
or thr_state)
|
begin
|
begin
|
case (thr_state[4:0])
|
case (thr_state[4:0])
|
5'b00000: // 5'b00000
|
`THRFSM_IDLE: // 5'b00000
|
begin
|
begin
|
if (rst_thread | thaw_thread)
|
if (rst_thread | thaw_thread)
|
next_state = 5'b00001;
|
next_state = `THRFSM_WAIT;
|
else if (start_thread)
|
else if (start_thread)
|
next_state = 5'b11001;
|
next_state = `THRFSM_RDY;
|
else // all other interrupts ignored
|
else // all other interrupts ignored
|
next_state = thr_state[4:0];
|
next_state = thr_state[4:0];
|
end
|
end
|
|
|
5'b00010: // 5'b00010
|
`THRFSM_HALT: // 5'b00010
|
begin
|
begin
|
if (nuke_thread)
|
if (nuke_thread)
|
next_state = 5'b00000;
|
next_state = `THRFSM_IDLE;
|
else if (rst_thread | thaw_thread)
|
else if (rst_thread | thaw_thread)
|
next_state = 5'b00001;
|
next_state = `THRFSM_WAIT;
|
else if (int_activate | start_thread)
|
else if (int_activate | start_thread)
|
next_state = 5'b11001;
|
next_state = `THRFSM_RDY;
|
else
|
else
|
next_state = thr_state[4:0];
|
next_state = thr_state[4:0];
|
end
|
end
|
|
|
5'b11001: // 5'b11001
|
`THRFSM_RDY: // 5'b11001
|
begin
|
begin
|
if (stall)
|
if (stall)
|
// trap also kills inst_s2 and nir
|
// trap also kills inst_s2 and nir
|
// Ldmiss should not happen in this state
|
// Ldmiss should not happen in this state
|
next_state = 5'b00001;
|
next_state = `THRFSM_WAIT;
|
else if (schedule)
|
else if (schedule)
|
next_state = 5'b00101;
|
next_state = `THRFSM_RUN;
|
else
|
else
|
next_state = thr_state[4:0];
|
next_state = thr_state[4:0];
|
end // case: `THRFSM_RDY
|
end // case: `THRFSM_RDY
|
|
|
5'b00101: // 5'b00101
|
`THRFSM_RUN: // 5'b00101
|
begin
|
begin
|
if (stall | sw_cond)
|
if (stall | sw_cond)
|
// trap also kills inst_s2 and nir
|
// trap also kills inst_s2 and nir
|
// ldmiss should not happen in this state
|
// ldmiss should not happen in this state
|
next_state = 5'b00001;
|
next_state = `THRFSM_WAIT;
|
else if (switch_out)
|
else if (switch_out)
|
// on an interrupt or thread stall, the fcl has to
|
// on an interrupt or thread stall, the fcl has to
|
// switch out the thread and inform the fsm
|
// switch out the thread and inform the fsm
|
next_state = 5'b11001;
|
next_state = `THRFSM_RDY;
|
else
|
else
|
next_state = thr_state[4:0];
|
next_state = thr_state[4:0];
|
end // case: `THRFSM_RUN
|
end // case: `THRFSM_RUN
|
|
|
5'b00001: // 5'b00001
|
`THRFSM_WAIT: // 5'b00001
|
begin
|
begin
|
if (nuke_thread)
|
if (nuke_thread)
|
next_state = 5'b00000;
|
next_state = `THRFSM_IDLE;
|
else if (halt_thread) // exclusive with above
|
else if (halt_thread) // exclusive with above
|
next_state = 5'b00010;
|
next_state = `THRFSM_HALT;
|
else if (stall) // excl. with above
|
else if (stall) // excl. with above
|
next_state = 5'b00001;
|
next_state = `THRFSM_WAIT;
|
else if (spec_ld) // exclusive with above
|
else if (spec_ld) // exclusive with above
|
next_state = 5'b10011;
|
next_state = `THRFSM_SPEC_RDY;
|
else if (completion & ~halt_thread)
|
else if (completion & ~halt_thread)
|
next_state = 5'b11001;
|
next_state = `THRFSM_RDY;
|
else
|
else
|
next_state = thr_state[4:0];
|
next_state = thr_state[4:0];
|
end // case: `THRFSM_WAIT
|
end // case: `THRFSM_WAIT
|
|
|
5'b10011: // 5'b10011
|
`THRFSM_SPEC_RDY: // 5'b10011
|
begin
|
begin
|
if (stall)
|
if (stall)
|
next_state = 5'b00001;
|
next_state = `THRFSM_WAIT;
|
else if (schedule & ~ldhit) // exclusive
|
else if (schedule & ~ldhit) // exclusive
|
next_state = 5'b00111;
|
next_state = `THRFSM_SPEC_RUN;
|
else if (schedule & ldhit) // exclusive
|
else if (schedule & ldhit) // exclusive
|
next_state = 5'b00101;
|
next_state = `THRFSM_RUN;
|
else if (ldhit)
|
else if (ldhit)
|
next_state = 5'b11001;
|
next_state = `THRFSM_RDY;
|
else
|
else
|
next_state = thr_state[4:0];
|
next_state = thr_state[4:0];
|
end // case: `THRFSM_SPEC_RDY
|
end // case: `THRFSM_SPEC_RDY
|
|
|
5'b00111: // 5'b00111
|
`THRFSM_SPEC_RUN: // 5'b00111
|
begin
|
begin
|
if (stall | sw_cond)
|
if (stall | sw_cond)
|
next_state = 5'b00001;
|
next_state = `THRFSM_WAIT;
|
else if ((ldhit) & switch_out)
|
else if ((ldhit) & switch_out)
|
next_state = 5'b11001;
|
next_state = `THRFSM_RDY;
|
else if ((ldhit) & ~switch_out)
|
else if ((ldhit) & ~switch_out)
|
next_state = 5'b00101;
|
next_state = `THRFSM_RUN;
|
else if (~(ldhit) & switch_out)
|
else if (~(ldhit) & switch_out)
|
next_state = 5'b10011;
|
next_state = `THRFSM_SPEC_RDY;
|
// on an interrupt or thread stall, the fcl has to
|
// on an interrupt or thread stall, the fcl has to
|
// switch out the thread and inform the fsm
|
// switch out the thread and inform the fsm
|
else
|
else
|
next_state = thr_state[4:0];
|
next_state = thr_state[4:0];
|
end // case: `THRFSM_SPEC_RUN
|
end // case: `THRFSM_SPEC_RUN
|
Line 351... |
Line 177... |
//VCS coverage off
|
//VCS coverage off
|
default:
|
default:
|
begin
|
begin
|
// synopsys translate_off
|
// synopsys translate_off
|
// 0in <fire -message "thrfsm.v: Error! Invalid State"
|
// 0in <fire -message "thrfsm.v: Error! Invalid State"
|
|
`ifdef DEFINE_0IN
|
|
`else
|
|
`ifdef MODELSIM
|
|
$display("ILLEGAL_THR_STATE", "thrfsm.v: Error! Invalid State %b\n", thr_state);
|
|
`else
|
//$display("ILLEGAL_THR_STATE", "thrfsm.v: Error! Invalid State %b\n", thr_state);
|
$error("ILLEGAL_THR_STATE", "thrfsm.v: Error! Invalid State %b\n", thr_state);
|
|
`endif
|
|
`endif
|
// synopsys translate_on
|
// synopsys translate_on
|
if (rst_thread)
|
if (rst_thread)
|
next_state = 5'b00001;
|
next_state = `THRFSM_WAIT;
|
else if (nuke_thread)
|
else if (nuke_thread)
|
next_state = 5'b00000;
|
next_state = `THRFSM_IDLE;
|
else
|
else
|
next_state = thr_state[4:0];
|
next_state = thr_state[4:0];
|
end
|
end
|
//VCS coverage on
|
//VCS coverage on
|
endcase // casex({thr_state[4:0]})
|
endcase // casex({thr_state[4:0]})
|
end // always @ (...
|
end // always @ (...
|
|
|
// thread config register (tcr)
|
// thread config register (tcr)
|
dffr #(5) tcr(.din (next_state),
|
dffr_s #(5) tcr(.din (next_state),
|
.clk (clk),
|
.clk (clk),
|
.q (thr_state),
|
.q (thr_state),
|
.rst (reset),
|
.rst (reset),
|
.se (se), .so(), .si());
|
.se (se), .so(), `SIMPLY_RISC_SCANIN);
|
|
|
|
|
endmodule
|
endmodule
|
|
|
No newline at end of file
|
No newline at end of file
|