2014-09-13 03:06:41 +02:00
|
|
|
// See LICENSE for license details.
|
|
|
|
|
2012-02-26 02:09:26 +01:00
|
|
|
package rocket
|
2011-10-26 08:02:47 +02:00
|
|
|
|
|
|
|
import Chisel._
|
|
|
|
import Instructions._
|
2013-07-24 05:26:17 +02:00
|
|
|
import uncore.constants.MemoryOpConstants._
|
2012-10-10 06:35:03 +02:00
|
|
|
import ALU._
|
2013-04-03 02:37:21 +02:00
|
|
|
import Util._
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2015-02-02 05:04:13 +01:00
|
|
|
class CtrlDpathIO extends CoreBundle
|
2011-10-26 08:02:47 +02:00
|
|
|
{
|
2011-11-02 01:59:27 +01:00
|
|
|
// outputs to datapath
|
2014-01-14 06:43:56 +01:00
|
|
|
val sel_pc = UInt(OUTPUT, 3)
|
2015-01-05 00:21:17 +01:00
|
|
|
val killd = Bool(OUTPUT)
|
|
|
|
val killm = Bool(OUTPUT)
|
2013-12-10 00:06:13 +01:00
|
|
|
val ren = Vec.fill(2)(Bool(OUTPUT))
|
2015-01-03 22:34:38 +01:00
|
|
|
val ex_ctrl = new IntCtrlSigs().asOutput
|
2015-01-05 00:21:17 +01:00
|
|
|
val mem_ctrl = new IntCtrlSigs().asOutput
|
2015-03-14 10:49:07 +01:00
|
|
|
val csr_cmd = UInt(OUTPUT, CSR.SZ)
|
2014-04-08 00:58:49 +02:00
|
|
|
val ex_valid = Bool(OUTPUT)
|
2014-01-14 06:43:56 +01:00
|
|
|
val wb_wen = Bool(OUTPUT)
|
2013-12-10 00:06:13 +01:00
|
|
|
val bypass = Vec.fill(2)(Bool(OUTPUT))
|
|
|
|
val bypass_src = Vec.fill(2)(Bits(OUTPUT, SZ_BYP))
|
|
|
|
val ll_ready = Bool(OUTPUT)
|
2011-11-10 11:46:09 +01:00
|
|
|
// exception handling
|
2013-11-25 13:35:15 +01:00
|
|
|
val retire = Bool(OUTPUT)
|
2014-01-14 06:43:56 +01:00
|
|
|
val exception = Bool(OUTPUT)
|
2015-02-02 05:04:13 +01:00
|
|
|
val cause = UInt(OUTPUT, xLen)
|
2011-11-02 01:59:27 +01:00
|
|
|
// inputs from datapath
|
2014-01-14 06:43:56 +01:00
|
|
|
val inst = Bits(INPUT, 32)
|
2014-04-08 00:58:49 +02:00
|
|
|
val mem_br_taken = Bool(INPUT)
|
|
|
|
val mem_misprediction = Bool(INPUT)
|
2015-03-14 10:49:07 +01:00
|
|
|
val mem_npc_misaligned = Bool(INPUT)
|
2012-12-12 11:22:47 +01:00
|
|
|
val div_mul_rdy = Bool(INPUT)
|
2013-12-10 00:06:13 +01:00
|
|
|
val ll_wen = Bool(INPUT)
|
|
|
|
val ll_waddr = UInt(INPUT, 5)
|
|
|
|
val ex_waddr = UInt(INPUT, 5)
|
2014-04-08 00:58:49 +02:00
|
|
|
val mem_rs1_ra = Bool(INPUT)
|
2013-12-10 00:06:13 +01:00
|
|
|
val mem_waddr = UInt(INPUT, 5)
|
|
|
|
val wb_waddr = UInt(INPUT, 5)
|
2015-03-14 10:49:07 +01:00
|
|
|
val status = new MStatus().asInput
|
2014-01-14 06:43:56 +01:00
|
|
|
val fp_sboard_clr = Bool(INPUT)
|
|
|
|
val fp_sboard_clra = UInt(INPUT, 5)
|
2015-03-14 10:49:07 +01:00
|
|
|
// inputs from csr file
|
2013-11-25 13:35:15 +01:00
|
|
|
val csr_replay = Bool(INPUT)
|
2015-05-19 03:23:58 +02:00
|
|
|
val csr_stall = Bool(INPUT)
|
2015-03-14 10:49:07 +01:00
|
|
|
val csr_xcpt = Bool(INPUT)
|
2015-03-17 08:14:32 +01:00
|
|
|
val eret = Bool(INPUT)
|
2015-03-14 10:49:07 +01:00
|
|
|
val interrupt = Bool(INPUT)
|
|
|
|
val interrupt_cause = UInt(INPUT, xLen)
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 08:52:32 +01:00
|
|
|
abstract trait DecodeConstants
|
2012-03-09 08:31:57 +01:00
|
|
|
{
|
2014-01-14 06:43:56 +01:00
|
|
|
val xpr64 = Y
|
2012-03-09 08:31:57 +01:00
|
|
|
|
|
|
|
val decode_default =
|
2015-01-05 00:21:17 +01:00
|
|
|
// jal renf1 fence.i
|
2015-03-14 10:49:07 +01:00
|
|
|
// | jalr | renf2 |
|
|
|
|
// fp_val| | renx2 | | renf3 |
|
|
|
|
// | rocc| | | renx1 s_alu1 mem_val | | | wfd |
|
|
|
|
// val | | br| | | | s_alu2 | imm dw alu | mem_cmd mem_type| | | | div |
|
|
|
|
// | | | | | | | | | | | | | | | | | | | | | wxd | fence
|
|
|
|
// | | | | | | | | | | | | | | | | | | | | | | csr | | amo
|
|
|
|
// | | | | | | | | | | | | | | | | | | | | | | | | | |
|
|
|
|
List(N, X,X,X,X,X,X,X,A2_X, A1_X, IMM_X, DW_X, FN_X, N,M_X, MT_X, X,X,X,X,X,X,CSR.X,X,X,X)
|
2014-11-17 07:04:33 +01:00
|
|
|
|
2013-08-12 19:39:11 +02:00
|
|
|
val table: Array[(UInt, List[UInt])]
|
2012-10-06 00:50:42 +02:00
|
|
|
}
|
|
|
|
|
2015-01-03 22:34:38 +01:00
|
|
|
class IntCtrlSigs extends Bundle {
|
|
|
|
val legal = Bool()
|
|
|
|
val fp = Bool()
|
|
|
|
val rocc = Bool()
|
|
|
|
val branch = Bool()
|
|
|
|
val jal = Bool()
|
|
|
|
val jalr = Bool()
|
2015-01-05 00:21:17 +01:00
|
|
|
val rxs2 = Bool()
|
|
|
|
val rxs1 = Bool()
|
2015-01-03 22:34:38 +01:00
|
|
|
val sel_alu2 = Bits(width = A2_X.getWidth)
|
|
|
|
val sel_alu1 = Bits(width = A1_X.getWidth)
|
|
|
|
val sel_imm = Bits(width = IMM_X.getWidth)
|
|
|
|
val alu_dw = Bool()
|
|
|
|
val alu_fn = Bits(width = FN_X.getWidth)
|
|
|
|
val mem = Bool()
|
|
|
|
val mem_cmd = Bits(width = M_SZ)
|
|
|
|
val mem_type = Bits(width = MT_SZ)
|
2015-01-05 00:21:17 +01:00
|
|
|
val rfs1 = Bool()
|
|
|
|
val rfs2 = Bool()
|
|
|
|
val rfs3 = Bool()
|
|
|
|
val wfd = Bool()
|
2015-01-03 22:34:38 +01:00
|
|
|
val div = Bool()
|
2015-01-05 00:21:17 +01:00
|
|
|
val wxd = Bool()
|
2015-01-03 22:34:38 +01:00
|
|
|
val csr = Bits(width = CSR.SZ)
|
|
|
|
val fence_i = Bool()
|
|
|
|
val fence = Bool()
|
|
|
|
val amo = Bool()
|
|
|
|
|
|
|
|
def decode(inst: UInt, table: Iterable[(UInt, List[UInt])]) = {
|
|
|
|
val decoder = DecodeLogic(inst, XDecode.decode_default, table)
|
2015-01-05 00:21:17 +01:00
|
|
|
Vec(legal, fp, rocc, branch, jal, jalr, rxs2, rxs1, sel_alu2, sel_alu1,
|
|
|
|
sel_imm, alu_dw, alu_fn, mem, mem_cmd, mem_type,
|
2015-03-14 10:49:07 +01:00
|
|
|
rfs1, rfs2, rfs3, wfd, div, wxd, csr, fence_i, fence, amo) := decoder
|
2015-01-03 22:34:38 +01:00
|
|
|
this
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-06 08:52:32 +01:00
|
|
|
object XDecode extends DecodeConstants
|
2012-10-06 00:50:42 +02:00
|
|
|
{
|
|
|
|
val table = Array(
|
2015-01-05 00:21:17 +01:00
|
|
|
// jal renf1 fence.i
|
2015-03-14 10:49:07 +01:00
|
|
|
// | jalr | renf2 |
|
|
|
|
// fp_val| | renx2 | | renf3 |
|
|
|
|
// | rocc| | | renx1 s_alu1 mem_val | | | wfd |
|
|
|
|
// val | | br| | | | s_alu2 | imm dw alu | mem_cmd mem_type| | | | div |
|
|
|
|
// | | | | | | | | | | | | | | | | | | | | | wxd | fence
|
|
|
|
// | | | | | | | | | | | | | | | | | | | | | | csr | | amo
|
|
|
|
// | | | | | | | | | | | | | | | | | | | | | | | | | |
|
|
|
|
BNE-> List(Y, N,N,Y,N,N,Y,Y,A2_RS2, A1_RS1, IMM_SB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M_X, MT_X, N,N,N,N,N,N,CSR.N,N,Y,N),
|
|
|
|
FENCE_I-> List(Y, N,N,N,N,N,N,N,A2_X, A1_X, IMM_X, DW_X, FN_X, N,M_X, MT_X, N,N,N,N,N,N,CSR.N,Y,N,N),
|
|
|
|
|
2015-05-19 03:23:58 +02:00
|
|
|
SFENCE_VM-> List(Y, N,N,N,N,N,N,X,A2_X, A1_X, IMM_X, DW_X, FN_X, N,M_X, MT_X, N,N,N,N,N,N,CSR.I,N,N,N),
|
|
|
|
SCALL-> List(Y, N,N,N,N,N,N,X,A2_X, A1_X, IMM_X, DW_X, FN_X, N,M_X, MT_X, N,N,N,N,N,N,CSR.I,N,N,N),
|
|
|
|
SBREAK-> List(Y, N,N,N,N,N,N,X,A2_X, A1_X, IMM_X, DW_X, FN_X, N,M_X, MT_X, N,N,N,N,N,N,CSR.I,N,N,N),
|
|
|
|
SRET-> List(Y, N,N,N,N,N,N,X,A2_X, A1_X, IMM_X, DW_X, FN_X, N,M_X, MT_X, N,N,N,N,N,N,CSR.I,N,N,N),
|
|
|
|
MRTS-> List(Y, N,N,N,N,N,N,X,A2_X, A1_X, IMM_X, DW_X, FN_X, N,M_X, MT_X, N,N,N,N,N,N,CSR.I,N,N,N),
|
|
|
|
WFI-> List(Y, N,N,N,N,N,N,X,A2_X, A1_X, IMM_X, DW_X, FN_X, N,M_X, MT_X, N,N,N,N,N,N,CSR.I,N,N,N),
|
2015-03-14 10:49:07 +01:00
|
|
|
CSRRW-> List(Y, N,N,N,N,N,N,Y,A2_ZERO,A1_RS1, IMM_X, DW_XPR,FN_ADD, N,M_X, MT_X, N,N,N,N,N,Y,CSR.W,N,N,N),
|
|
|
|
CSRRS-> List(Y, N,N,N,N,N,N,Y,A2_ZERO,A1_RS1, IMM_X, DW_XPR,FN_ADD, N,M_X, MT_X, N,N,N,N,N,Y,CSR.S,N,N,N),
|
|
|
|
CSRRC-> List(Y, N,N,N,N,N,N,Y,A2_ZERO,A1_RS1, IMM_X, DW_XPR,FN_ADD, N,M_X, MT_X, N,N,N,N,N,Y,CSR.C,N,N,N),
|
|
|
|
CSRRWI-> List(Y, N,N,N,N,N,N,N,A2_IMM, A1_ZERO,IMM_Z, DW_XPR,FN_ADD, N,M_X, MT_X, N,N,N,N,N,Y,CSR.W,N,N,N),
|
|
|
|
CSRRSI-> List(Y, N,N,N,N,N,N,N,A2_IMM, A1_ZERO,IMM_Z, DW_XPR,FN_ADD, N,M_X, MT_X, N,N,N,N,N,Y,CSR.S,N,N,N),
|
|
|
|
CSRRCI-> List(Y, N,N,N,N,N,N,N,A2_IMM, A1_ZERO,IMM_Z, DW_XPR,FN_ADD, N,M_X, MT_X, N,N,N,N,N,Y,CSR.C,N,N,N))
|
2012-10-06 00:50:42 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 08:52:32 +01:00
|
|
|
object FDecode extends DecodeConstants
|
2012-10-06 00:50:42 +02:00
|
|
|
{
|
|
|
|
val table = Array(
|
2015-01-05 00:21:17 +01:00
|
|
|
// jal renf1 fence.i
|
2015-03-14 10:49:07 +01:00
|
|
|
// | jalr | renf2 |
|
|
|
|
// fp_val| | renx2 | | renf3 |
|
|
|
|
// | rocc| | | renx1 s_alu1 mem_val | | | wfd |
|
|
|
|
// val | | br| | | | s_alu2 | imm dw alu | mem_cmd mem_type| | | | div |
|
|
|
|
// | | | | | | | | | | | | | | | | | | | | | wxd | fence
|
|
|
|
// | | | | | | | | | | | | | | | | | | | | | | csr | | amo
|
|
|
|
// | | | | | | | | | | | | | | | | | | | | | | | | | |
|
|
|
|
FCVT_S_D-> List(Y, Y,N,N,N,N,N,N,A2_X, A1_X, IMM_X, DW_X, FN_X, N,M_X, MT_X, Y,N,N,Y,N,N,CSR.N,N,N,N),
|
|
|
|
FCVT_D_S-> List(Y, Y,N,N,N,N,N,N,A2_X, A1_X, IMM_X, DW_X, FN_X, N,M_X, MT_X, Y,N,N,Y,N,N,CSR.N,N,N,N),
|
|
|
|
FSGNJ_S-> List(Y, Y,N,N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2_X, A1_RS1, IMM_X, DW_X, FN_X, N,M_X, MT_X, N,N,N,Y,N,N,CSR.N,N,N,N),
|
|
|
|
FCVT_D_LU-> List(Y, Y,N,N,N,N,N,Y,A2_X, A1_RS1, IMM_X, DW_X, FN_X, N,M_X, MT_X, N,N,N,Y,N,N,CSR.N,N,N,N),
|
|
|
|
FLW-> List(Y, Y,N,N,N,N,N,Y,A2_IMM, A1_RS1, IMM_I, DW_XPR,FN_ADD, Y,M_XRD, MT_W, N,N,N,Y,N,N,CSR.N,N,N,N),
|
|
|
|
FLD-> List(Y, Y,N,N,N,N,N,Y,A2_IMM, A1_RS1, IMM_I, DW_XPR,FN_ADD, Y,M_XRD, MT_D, N,N,N,Y,N,N,CSR.N,N,N,N),
|
|
|
|
FSW-> List(Y, Y,N,N,N,N,N,Y,A2_IMM, A1_RS1, IMM_S, DW_XPR,FN_ADD, Y,M_XWR, MT_W, N,Y,N,N,N,N,CSR.N,N,N,N),
|
|
|
|
FSD-> List(Y, Y,N,N,N,N,N,Y,A2_IMM, A1_RS1, IMM_S, DW_XPR,FN_ADD, Y,M_XWR, MT_D, N,Y,N,N,N,N,CSR.N,N,N,N))
|
2012-10-06 00:50:42 +02:00
|
|
|
}
|
2012-03-09 08:31:57 +01:00
|
|
|
|
2015-04-05 01:39:17 +02:00
|
|
|
object FDivSqrtDecode extends DecodeConstants
|
|
|
|
{
|
|
|
|
val table = Array(
|
|
|
|
FDIV_S-> List(Y, Y,N,N,N,N,N,N,A2_X, A1_X, IMM_X, DW_X, FN_X, N,M_X, MT_X, Y,Y,N,Y,N,N,CSR.N,N,N,N),
|
|
|
|
FDIV_D-> List(Y, Y,N,N,N,N,N,N,A2_X, A1_X, IMM_X, DW_X, FN_X, N,M_X, MT_X, Y,Y,N,Y,N,N,CSR.N,N,N,N),
|
|
|
|
FSQRT_S-> List(Y, Y,N,N,N,N,N,N,A2_X, A1_X, IMM_X, DW_X, FN_X, N,M_X, MT_X, Y,Y,N,Y,N,N,CSR.N,N,N,N),
|
|
|
|
FSQRT_D-> List(Y, Y,N,N,N,N,N,N,A2_X, A1_X, IMM_X, DW_X, FN_X, N,M_X, MT_X, Y,Y,N,Y,N,N,CSR.N,N,N,N))
|
|
|
|
}
|
|
|
|
|
2013-09-13 07:34:38 +02:00
|
|
|
object RoCCDecode extends DecodeConstants
|
2012-10-06 00:50:42 +02:00
|
|
|
{
|
|
|
|
val table = Array(
|
2015-01-05 00:21:17 +01:00
|
|
|
// jal renf1 fence.i
|
2015-03-14 10:49:07 +01:00
|
|
|
// | jalr | renf2 |
|
|
|
|
// fp_val| | renx2 | | renf3 |
|
|
|
|
// | rocc| | | renx1 s_alu1 mem_val | | | wfd |
|
|
|
|
// val | | br| | | | s_alu2 | imm dw alu | mem_cmd mem_type| | | | div |
|
|
|
|
// | | | | | | | | | | | | | | | | | | | | | wxd | fence
|
|
|
|
// | | | | | | | | | | | | | | | | | | | | | | csr | | amo
|
|
|
|
// | | | | | | | | | | | | | | | | | | | | | | | | | |
|
|
|
|
CUSTOM0-> List(Y, N,Y,N,N,N,N,N,A2_ZERO,A1_RS1, IMM_X, DW_XPR,FN_ADD, N,M_X, MT_X, N,N,N,N,N,N,CSR.N,N,N,N),
|
|
|
|
CUSTOM0_RS1-> List(Y, N,Y,N,N,N,N,Y,A2_ZERO,A1_RS1, IMM_X, DW_XPR,FN_ADD, N,M_X, MT_X, N,N,N,N,N,N,CSR.N,N,N,N),
|
|
|
|
CUSTOM0_RS1_RS2-> List(Y, N,Y,N,N,N,Y,Y,A2_ZERO,A1_RS1, IMM_X, DW_XPR,FN_ADD, N,M_X, MT_X, N,N,N,N,N,N,CSR.N,N,N,N),
|
|
|
|
CUSTOM0_RD-> List(Y, N,Y,N,N,N,N,N,A2_ZERO,A1_RS1, IMM_X, DW_XPR,FN_ADD, N,M_X, MT_X, N,N,N,N,N,Y,CSR.N,N,N,N),
|
|
|
|
CUSTOM0_RD_RS1-> List(Y, N,Y,N,N,N,N,Y,A2_ZERO,A1_RS1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N,Y,A2_ZERO,A1_RS1, IMM_X, DW_XPR,FN_ADD, N,M_X, MT_X, N,N,N,N,N,Y,CSR.N,N,N,N),
|
|
|
|
CUSTOM3_RD_RS1_RS2->List(Y, N,Y,N,N,N,Y,Y,A2_ZERO,A1_RS1, IMM_X, DW_XPR,FN_ADD, N,M_X, MT_X, N,N,N,N,N,Y,CSR.N,N,N,N))
|
2012-03-09 08:31:57 +01:00
|
|
|
}
|
|
|
|
|
2015-02-02 05:04:13 +01:00
|
|
|
class Control extends CoreModule
|
2011-10-26 08:02:47 +02:00
|
|
|
{
|
2012-11-06 08:52:32 +01:00
|
|
|
val io = new Bundle {
|
2013-01-07 22:38:59 +01:00
|
|
|
val dpath = new CtrlDpathIO
|
2014-08-08 21:23:02 +02:00
|
|
|
val imem = new CPUFrontendIO
|
|
|
|
val dmem = new HellaCacheIO
|
2013-01-07 22:38:59 +01:00
|
|
|
val fpu = new CtrlFPUIO
|
2013-09-15 00:31:50 +02:00
|
|
|
val rocc = new RoCCInterface().flip
|
2012-11-06 08:52:32 +01:00
|
|
|
}
|
2012-02-08 08:54:25 +01:00
|
|
|
|
2012-11-06 08:52:32 +01:00
|
|
|
var decode_table = XDecode.table
|
2014-08-08 21:23:02 +02:00
|
|
|
if (!params(BuildFPU).isEmpty) decode_table ++= FDecode.table
|
2015-04-05 01:39:17 +02:00
|
|
|
if (!params(BuildFPU).isEmpty && params(FDivSqrt)) decode_table ++= FDivSqrtDecode.table
|
2014-08-08 21:23:02 +02:00
|
|
|
if (!params(BuildRoCC).isEmpty) decode_table ++= RoCCDecode.table
|
2012-03-09 08:31:57 +01:00
|
|
|
|
2015-07-16 05:24:18 +02:00
|
|
|
val id_ctrl = Wire(new IntCtrlSigs()).decode(io.dpath.inst, decode_table)
|
2015-01-03 22:34:38 +01:00
|
|
|
val ex_ctrl = Reg(new IntCtrlSigs)
|
2015-01-05 00:21:17 +01:00
|
|
|
val mem_ctrl = Reg(new IntCtrlSigs)
|
|
|
|
val wb_ctrl = Reg(new IntCtrlSigs)
|
2015-01-03 22:34:38 +01:00
|
|
|
|
2014-04-02 00:01:27 +02:00
|
|
|
val ex_reg_xcpt_interrupt = Reg(Bool())
|
|
|
|
val ex_reg_valid = Reg(Bool())
|
|
|
|
val ex_reg_btb_hit = Reg(Bool())
|
2015-07-16 02:30:50 +02:00
|
|
|
val ex_reg_btb_resp = Reg(io.imem.btb_resp.bits)
|
2014-04-02 00:01:27 +02:00
|
|
|
val ex_reg_xcpt = Reg(Bool())
|
2015-01-05 01:40:16 +01:00
|
|
|
val ex_reg_flush_pipe = Reg(Bool())
|
2014-04-02 00:01:27 +02:00
|
|
|
val ex_reg_load_use = Reg(Bool())
|
2013-08-12 19:39:11 +02:00
|
|
|
val ex_reg_cause = Reg(UInt())
|
|
|
|
|
2014-04-02 00:01:27 +02:00
|
|
|
val mem_reg_xcpt_interrupt = Reg(Bool())
|
|
|
|
val mem_reg_valid = Reg(Bool())
|
2014-04-08 00:58:49 +02:00
|
|
|
val mem_reg_btb_hit = Reg(Bool())
|
2015-07-16 02:30:50 +02:00
|
|
|
val mem_reg_btb_resp = Reg(io.imem.btb_resp.bits)
|
2014-04-02 00:01:27 +02:00
|
|
|
val mem_reg_xcpt = Reg(Bool())
|
|
|
|
val mem_reg_replay = Reg(Bool())
|
2015-01-05 01:40:16 +01:00
|
|
|
val mem_reg_flush_pipe = Reg(Bool())
|
2013-08-12 19:39:11 +02:00
|
|
|
val mem_reg_cause = Reg(UInt())
|
|
|
|
val mem_reg_slow_bypass = Reg(Bool())
|
|
|
|
|
2014-04-02 00:01:27 +02:00
|
|
|
val wb_reg_valid = Reg(Bool())
|
|
|
|
val wb_reg_xcpt = Reg(Bool())
|
|
|
|
val wb_reg_replay = Reg(Bool())
|
2013-08-12 19:39:11 +02:00
|
|
|
val wb_reg_cause = Reg(UInt())
|
2015-03-12 06:33:03 +01:00
|
|
|
val wb_reg_rocc_pending = Reg(init=Bool(false))
|
2012-01-03 00:42:39 +01:00
|
|
|
|
2015-07-16 05:24:18 +02:00
|
|
|
val take_pc_wb = Wire(Bool())
|
2015-01-05 01:40:16 +01:00
|
|
|
val mem_misprediction = io.dpath.mem_misprediction && mem_reg_valid && (mem_ctrl.branch || mem_ctrl.jalr || mem_ctrl.jal)
|
2015-03-14 10:49:07 +01:00
|
|
|
val want_take_pc_mem = mem_reg_valid && (mem_misprediction || mem_reg_flush_pipe)
|
|
|
|
val take_pc_mem = want_take_pc_mem && !io.dpath.mem_npc_misaligned
|
2014-04-08 00:58:49 +02:00
|
|
|
val take_pc_mem_wb = take_pc_wb || take_pc_mem
|
|
|
|
val take_pc = take_pc_mem_wb
|
2015-07-16 05:24:18 +02:00
|
|
|
val ctrl_killd = Wire(Bool())
|
|
|
|
val ctrl_killx = Wire(Bool())
|
|
|
|
val ctrl_killm = Wire(Bool())
|
2012-03-19 09:02:06 +01:00
|
|
|
|
2013-09-21 15:32:40 +02:00
|
|
|
val id_raddr3 = io.dpath.inst(31,27)
|
|
|
|
val id_raddr2 = io.dpath.inst(24,20)
|
|
|
|
val id_raddr1 = io.dpath.inst(19,15)
|
|
|
|
val id_waddr = io.dpath.inst(11,7)
|
2015-07-16 05:24:18 +02:00
|
|
|
val id_load_use = Wire(Bool())
|
2013-09-13 01:07:30 +02:00
|
|
|
val id_reg_fence = Reg(init=Bool(false))
|
|
|
|
|
2015-01-03 22:34:38 +01:00
|
|
|
val id_csr_en = id_ctrl.csr != CSR.N
|
2015-03-14 10:49:07 +01:00
|
|
|
val id_system_insn = id_ctrl.csr === CSR.I
|
|
|
|
val id_csr_ren = (id_ctrl.csr === CSR.S || id_ctrl.csr === CSR.C) && id_raddr1 === UInt(0)
|
|
|
|
val id_csr = Mux(id_csr_ren, CSR.R, id_ctrl.csr)
|
|
|
|
val id_csr_addr = io.dpath.inst(31,20)
|
|
|
|
// this is overly conservative
|
|
|
|
val safe_csrs = CSRs.sscratch :: CSRs.sepc :: CSRs.mscratch :: CSRs.mepc :: CSRs.mcause :: CSRs.mbadaddr :: Nil
|
|
|
|
val legal_csrs = collection.mutable.LinkedHashSet(CSRs.all:_*)
|
|
|
|
val id_csr_flush = id_system_insn || (id_csr_en && !id_csr_ren && !DecodeLogic(id_csr_addr, safe_csrs, legal_csrs -- safe_csrs))
|
2012-03-19 09:02:06 +01:00
|
|
|
|
2015-03-14 10:49:07 +01:00
|
|
|
val id_illegal_insn = !id_ctrl.legal ||
|
|
|
|
id_ctrl.fp && !io.dpath.status.fs.orR ||
|
|
|
|
id_ctrl.rocc && !io.dpath.status.xs.orR
|
2013-09-13 01:07:30 +02:00
|
|
|
// stall decode for fences (now, for AMO.aq; later, for AMO.rl and FENCE)
|
2013-09-21 15:32:40 +02:00
|
|
|
val id_amo_aq = io.dpath.inst(26)
|
|
|
|
val id_amo_rl = io.dpath.inst(25)
|
2015-01-03 22:34:38 +01:00
|
|
|
val id_fence_next = id_ctrl.fence || id_ctrl.amo && id_amo_rl
|
2015-01-05 00:21:17 +01:00
|
|
|
val id_mem_busy = !io.dmem.ordered || io.dmem.req.valid
|
2014-08-12 03:36:23 +02:00
|
|
|
val id_rocc_busy = Bool(!params(BuildRoCC).isEmpty) &&
|
2015-01-05 00:21:17 +01:00
|
|
|
(io.rocc.busy || ex_reg_valid && ex_ctrl.rocc ||
|
|
|
|
mem_reg_valid && mem_ctrl.rocc || wb_reg_valid && wb_ctrl.rocc)
|
2014-02-06 21:01:49 +01:00
|
|
|
id_reg_fence := id_fence_next || id_reg_fence && id_mem_busy
|
2015-01-03 22:34:38 +01:00
|
|
|
val id_do_fence = id_rocc_busy && id_ctrl.fence ||
|
2015-03-14 10:49:07 +01:00
|
|
|
id_mem_busy && (id_ctrl.amo && id_amo_aq || id_ctrl.fence_i || id_reg_fence && (id_ctrl.mem || id_ctrl.rocc) || id_csr_en)
|
|
|
|
|
|
|
|
def checkExceptions(x: Seq[(Bool, UInt)]) =
|
|
|
|
(x.map(_._1).reduce(_||_), PriorityMux(x))
|
2013-09-13 01:07:30 +02:00
|
|
|
|
2012-11-05 01:40:14 +01:00
|
|
|
val (id_xcpt, id_cause) = checkExceptions(List(
|
2015-03-14 10:49:07 +01:00
|
|
|
(io.dpath.interrupt, io.dpath.interrupt_cause),
|
2014-01-22 00:01:54 +01:00
|
|
|
(io.imem.resp.bits.xcpt_if, UInt(Causes.fault_fetch)),
|
2015-03-14 10:49:07 +01:00
|
|
|
(id_illegal_insn, UInt(Causes.illegal_instruction))))
|
2012-11-05 01:40:14 +01:00
|
|
|
|
2015-01-05 04:46:01 +01:00
|
|
|
ex_reg_valid := !ctrl_killd
|
|
|
|
ex_reg_xcpt := !ctrl_killd && id_xcpt
|
2015-03-14 10:49:07 +01:00
|
|
|
ex_reg_xcpt_interrupt := io.dpath.interrupt && !take_pc && io.imem.resp.valid
|
2012-11-05 01:40:14 +01:00
|
|
|
when (id_xcpt) { ex_reg_cause := id_cause }
|
|
|
|
|
2015-01-05 04:46:01 +01:00
|
|
|
when (!ctrl_killd) {
|
2015-01-03 22:34:38 +01:00
|
|
|
ex_ctrl := id_ctrl
|
2015-03-14 10:49:07 +01:00
|
|
|
ex_ctrl.csr := id_csr
|
2014-04-02 00:01:27 +02:00
|
|
|
ex_reg_btb_hit := io.imem.btb_resp.valid
|
|
|
|
when (io.imem.btb_resp.valid) { ex_reg_btb_resp := io.imem.btb_resp.bits }
|
2015-01-05 01:40:16 +01:00
|
|
|
ex_reg_flush_pipe := id_ctrl.fence_i || id_csr_flush
|
2013-09-13 01:07:30 +02:00
|
|
|
ex_reg_load_use := id_load_use
|
2012-11-05 01:40:14 +01:00
|
|
|
ex_reg_xcpt := id_xcpt
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|
2012-02-24 10:42:33 +01:00
|
|
|
|
2012-11-16 11:39:33 +01:00
|
|
|
// replay inst in ex stage
|
2015-01-05 00:21:17 +01:00
|
|
|
val wb_dcache_miss = wb_ctrl.mem && !io.dmem.resp.valid
|
|
|
|
val replay_ex_structural = ex_ctrl.mem && !io.dmem.req.ready ||
|
|
|
|
ex_ctrl.div && !io.dpath.div_mul_rdy
|
2015-01-05 01:40:16 +01:00
|
|
|
val replay_ex_load_use = wb_dcache_miss && ex_reg_load_use
|
|
|
|
val replay_ex = ex_reg_valid && (replay_ex_structural || replay_ex_load_use)
|
|
|
|
ctrl_killx := take_pc_mem_wb || replay_ex || !ex_reg_valid
|
2013-04-04 07:15:39 +02:00
|
|
|
// detect 2-cycle load-use delay for LB/LH/SC
|
2015-01-05 00:21:17 +01:00
|
|
|
val ex_slow_bypass = ex_ctrl.mem_cmd === M_XSC || Vec(MT_B, MT_BU, MT_H, MT_HU).contains(ex_ctrl.mem_type)
|
2012-11-05 01:40:14 +01:00
|
|
|
|
|
|
|
val (ex_xcpt, ex_cause) = checkExceptions(List(
|
|
|
|
(ex_reg_xcpt_interrupt || ex_reg_xcpt, ex_reg_cause),
|
2015-01-05 00:21:17 +01:00
|
|
|
(ex_ctrl.fp && io.fpu.illegal_rm, UInt(Causes.illegal_instruction))))
|
2015-01-05 01:40:16 +01:00
|
|
|
|
|
|
|
mem_reg_valid := !ctrl_killx
|
2014-04-08 00:58:49 +02:00
|
|
|
mem_reg_replay := !take_pc_mem_wb && replay_ex
|
2015-01-05 01:40:16 +01:00
|
|
|
mem_reg_xcpt := !ctrl_killx && ex_xcpt
|
|
|
|
mem_reg_xcpt_interrupt := !take_pc_mem_wb && ex_reg_xcpt_interrupt
|
2012-11-05 01:40:14 +01:00
|
|
|
when (ex_xcpt) { mem_reg_cause := ex_cause }
|
|
|
|
|
2015-01-05 01:40:16 +01:00
|
|
|
when (!ctrl_killx) {
|
2015-01-05 00:21:17 +01:00
|
|
|
mem_ctrl := ex_ctrl
|
2014-04-08 00:58:49 +02:00
|
|
|
mem_reg_btb_hit := ex_reg_btb_hit
|
|
|
|
when (ex_reg_btb_hit) { mem_reg_btb_resp := ex_reg_btb_resp }
|
2015-01-05 01:40:16 +01:00
|
|
|
mem_reg_flush_pipe := ex_reg_flush_pipe
|
2013-04-04 07:15:39 +02:00
|
|
|
mem_reg_slow_bypass := ex_slow_bypass
|
2012-11-05 01:40:14 +01:00
|
|
|
mem_reg_xcpt := ex_xcpt
|
2011-11-02 01:59:27 +01:00
|
|
|
}
|
2012-11-05 01:40:14 +01:00
|
|
|
|
|
|
|
val (mem_xcpt, mem_cause) = checkExceptions(List(
|
2015-01-05 00:21:17 +01:00
|
|
|
(mem_reg_xcpt_interrupt || mem_reg_xcpt, mem_reg_cause),
|
2015-03-14 10:49:07 +01:00
|
|
|
(want_take_pc_mem && io.dpath.mem_npc_misaligned, UInt(Causes.misaligned_fetch)),
|
2015-01-05 00:21:17 +01:00
|
|
|
(mem_reg_valid && mem_ctrl.mem && io.dmem.xcpt.ma.st, UInt(Causes.misaligned_store)),
|
|
|
|
(mem_reg_valid && mem_ctrl.mem && io.dmem.xcpt.ma.ld, UInt(Causes.misaligned_load)),
|
|
|
|
(mem_reg_valid && mem_ctrl.mem && io.dmem.xcpt.pf.st, UInt(Causes.fault_store)),
|
|
|
|
(mem_reg_valid && mem_ctrl.mem && io.dmem.xcpt.pf.ld, UInt(Causes.fault_load))))
|
|
|
|
|
|
|
|
val dcache_kill_mem = mem_reg_valid && mem_ctrl.wxd && io.dmem.replay_next.valid // structural hazard on writeback port
|
|
|
|
val fpu_kill_mem = mem_reg_valid && mem_ctrl.fp && io.fpu.nack_mem
|
2014-01-14 13:02:43 +01:00
|
|
|
val replay_mem = dcache_kill_mem || mem_reg_replay || fpu_kill_mem
|
|
|
|
val killm_common = dcache_kill_mem || take_pc_wb || mem_reg_xcpt || !mem_reg_valid
|
2012-11-16 11:39:33 +01:00
|
|
|
ctrl_killm := killm_common || mem_xcpt || fpu_kill_mem
|
2012-11-05 01:40:14 +01:00
|
|
|
|
2015-01-05 00:21:17 +01:00
|
|
|
wb_reg_valid := !ctrl_killm
|
|
|
|
when (!ctrl_killm) { wb_ctrl := mem_ctrl }
|
2012-11-16 11:39:33 +01:00
|
|
|
wb_reg_replay := replay_mem && !take_pc_wb
|
2013-04-03 02:37:21 +02:00
|
|
|
wb_reg_xcpt := mem_xcpt && !take_pc_wb
|
2012-11-05 01:40:14 +01:00
|
|
|
when (mem_xcpt) { wb_reg_cause := mem_cause }
|
2012-01-03 00:42:39 +01:00
|
|
|
|
2015-01-05 00:21:17 +01:00
|
|
|
val wb_set_sboard = wb_ctrl.div || wb_dcache_miss || wb_ctrl.rocc
|
2014-11-17 07:04:33 +01:00
|
|
|
val replay_wb_common =
|
2014-01-14 13:02:43 +01:00
|
|
|
io.dmem.resp.bits.nack || wb_reg_replay || io.dpath.csr_replay
|
2015-01-05 00:21:17 +01:00
|
|
|
val wb_rocc_val = wb_reg_valid && wb_ctrl.rocc && !replay_wb_common
|
|
|
|
val replay_wb = replay_wb_common || wb_reg_valid && wb_ctrl.rocc && !io.rocc.cmd.ready
|
2012-11-05 01:40:14 +01:00
|
|
|
|
2015-03-12 06:33:03 +01:00
|
|
|
when (wb_rocc_val) { wb_reg_rocc_pending := !io.rocc.cmd.ready }
|
|
|
|
when (wb_reg_xcpt) { wb_reg_rocc_pending := Bool(false) }
|
|
|
|
|
2013-01-25 03:00:39 +01:00
|
|
|
class Scoreboard(n: Int)
|
2012-11-16 11:39:33 +01:00
|
|
|
{
|
2013-08-16 00:28:15 +02:00
|
|
|
def set(en: Bool, addr: UInt): Unit = update(en, _next | mask(en, addr))
|
2013-12-10 00:06:13 +01:00
|
|
|
def clear(en: Bool, addr: UInt): Unit = update(en, _next & ~mask(en, addr))
|
|
|
|
def read(addr: UInt): Bool = r(addr)
|
|
|
|
def readBypassed(addr: UInt): Bool = _next(addr)
|
|
|
|
|
|
|
|
private val r = Reg(init=Bits(0, n))
|
|
|
|
private var _next = r
|
|
|
|
private var ens = Bool(false)
|
2013-08-12 19:39:11 +02:00
|
|
|
private def mask(en: Bool, addr: UInt) = Mux(en, UInt(1) << addr, UInt(0))
|
|
|
|
private def update(en: Bool, update: UInt) = {
|
2013-08-16 00:28:15 +02:00
|
|
|
_next = update
|
2012-11-16 11:39:33 +01:00
|
|
|
ens = ens || en
|
2013-08-16 00:28:15 +02:00
|
|
|
when (ens) { r := _next }
|
2012-11-16 11:39:33 +01:00
|
|
|
}
|
|
|
|
}
|
2011-12-10 04:42:58 +01:00
|
|
|
|
2013-01-25 03:00:39 +01:00
|
|
|
val sboard = new Scoreboard(32)
|
2013-12-10 00:06:13 +01:00
|
|
|
sboard.clear(io.dpath.ll_wen, io.dpath.ll_waddr)
|
2011-11-02 21:32:32 +01:00
|
|
|
|
2014-08-08 21:23:02 +02:00
|
|
|
val id_stall_fpu = if (!params(BuildFPU).isEmpty) {
|
2013-01-25 03:00:39 +01:00
|
|
|
val fp_sboard = new Scoreboard(32)
|
2015-01-05 00:21:17 +01:00
|
|
|
fp_sboard.set((wb_dcache_miss && wb_ctrl.wfd || io.fpu.sboard_set) && io.dpath.retire, io.dpath.wb_waddr)
|
2012-11-16 11:39:33 +01:00
|
|
|
fp_sboard.clear(io.dpath.fp_sboard_clr, io.dpath.fp_sboard_clra)
|
|
|
|
fp_sboard.clear(io.fpu.sboard_clr, io.fpu.sboard_clra)
|
2012-02-16 02:49:12 +01:00
|
|
|
|
2013-11-25 13:35:15 +01:00
|
|
|
id_csr_en && !io.fpu.fcsr_rdy ||
|
2013-12-10 00:06:13 +01:00
|
|
|
io.fpu.dec.ren1 && fp_sboard.read(id_raddr1) ||
|
|
|
|
io.fpu.dec.ren2 && fp_sboard.read(id_raddr2) ||
|
|
|
|
io.fpu.dec.ren3 && fp_sboard.read(id_raddr3) ||
|
|
|
|
io.fpu.dec.wen && fp_sboard.read(id_waddr)
|
2012-11-16 11:39:33 +01:00
|
|
|
} else Bool(false)
|
2012-01-31 02:15:42 +01:00
|
|
|
|
2014-01-14 06:43:56 +01:00
|
|
|
// write CAUSE CSR on an exception
|
|
|
|
io.dpath.exception := wb_reg_xcpt
|
|
|
|
io.dpath.cause := wb_reg_cause
|
2015-03-14 10:49:07 +01:00
|
|
|
val wb_xcpt = wb_reg_xcpt || io.dpath.csr_xcpt
|
2012-11-05 01:40:14 +01:00
|
|
|
|
|
|
|
// control transfer from ex/wb
|
2015-03-17 08:14:32 +01:00
|
|
|
take_pc_wb := replay_wb || wb_xcpt || io.dpath.eret
|
2012-01-31 02:15:42 +01:00
|
|
|
|
2011-11-02 01:59:27 +01:00
|
|
|
io.dpath.sel_pc :=
|
2015-04-11 11:16:44 +02:00
|
|
|
Mux(wb_xcpt || io.dpath.eret, PC_CSR, // exception or [m|s]ret
|
2015-01-05 00:21:17 +01:00
|
|
|
Mux(replay_wb, PC_WB, // replay
|
2015-03-14 10:49:07 +01:00
|
|
|
PC_MEM))
|
2014-04-08 00:58:49 +02:00
|
|
|
|
2015-03-14 10:49:07 +01:00
|
|
|
io.imem.btb_update.valid := mem_reg_valid && !io.dpath.mem_npc_misaligned && io.dpath.mem_misprediction && ((mem_ctrl.branch && io.dpath.mem_br_taken) || mem_ctrl.jalr || mem_ctrl.jal) && !take_pc_wb
|
2014-04-08 00:58:49 +02:00
|
|
|
io.imem.btb_update.bits.prediction.valid := mem_reg_btb_hit
|
|
|
|
io.imem.btb_update.bits.prediction.bits := mem_reg_btb_resp
|
2015-01-05 00:21:17 +01:00
|
|
|
io.imem.btb_update.bits.isJump := mem_ctrl.jal || mem_ctrl.jalr
|
|
|
|
io.imem.btb_update.bits.isReturn := mem_ctrl.jalr && io.dpath.mem_rs1_ra
|
2014-11-17 07:02:27 +01:00
|
|
|
|
2015-01-05 04:59:18 +01:00
|
|
|
io.imem.bht_update.valid := mem_reg_valid && mem_ctrl.branch && !take_pc_wb
|
2014-11-17 07:02:27 +01:00
|
|
|
io.imem.bht_update.bits.taken := io.dpath.mem_br_taken
|
|
|
|
io.imem.bht_update.bits.mispredict := io.dpath.mem_misprediction
|
|
|
|
io.imem.bht_update.bits.prediction.valid := mem_reg_btb_hit
|
|
|
|
io.imem.bht_update.bits.prediction.bits := mem_reg_btb_resp
|
|
|
|
|
2015-03-14 10:49:07 +01:00
|
|
|
io.imem.ras_update.valid := io.imem.btb_update.bits.isJump && !io.dpath.mem_npc_misaligned && !take_pc_wb
|
2015-01-05 05:00:08 +01:00
|
|
|
io.imem.ras_update.bits.isCall := mem_ctrl.wxd && io.dpath.mem_waddr(0)
|
2015-01-05 04:59:18 +01:00
|
|
|
io.imem.ras_update.bits.isReturn := mem_ctrl.jalr && io.dpath.mem_rs1_ra
|
2014-11-11 12:34:05 +01:00
|
|
|
io.imem.ras_update.bits.prediction.valid := mem_reg_btb_hit
|
|
|
|
io.imem.ras_update.bits.prediction.bits := mem_reg_btb_resp
|
2014-11-17 07:02:27 +01:00
|
|
|
|
2015-01-05 00:21:17 +01:00
|
|
|
io.imem.req.valid := take_pc
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2013-12-10 00:06:13 +01:00
|
|
|
val bypassDst = Array(id_raddr1, id_raddr2)
|
|
|
|
val bypassSrc = Array.fill(NBYP)((Bool(true), UInt(0)))
|
2015-01-05 00:21:17 +01:00
|
|
|
bypassSrc(BYP_EX) = (ex_reg_valid && ex_ctrl.wxd, io.dpath.ex_waddr)
|
|
|
|
bypassSrc(BYP_MEM) = (mem_reg_valid && mem_ctrl.wxd && !mem_ctrl.mem, io.dpath.mem_waddr)
|
|
|
|
bypassSrc(BYP_DC) = (mem_reg_valid && mem_ctrl.wxd, io.dpath.mem_waddr)
|
2013-12-10 00:06:13 +01:00
|
|
|
|
|
|
|
val doBypass = bypassDst.map(d => bypassSrc.map(s => s._1 && s._2 === d))
|
|
|
|
for (i <- 0 until io.dpath.bypass.size) {
|
|
|
|
io.dpath.bypass(i) := doBypass(i).reduce(_||_)
|
|
|
|
io.dpath.bypass_src(i) := PriorityEncoder(doBypass(i))
|
|
|
|
}
|
|
|
|
|
2015-04-11 11:16:44 +02:00
|
|
|
// stall for RAW/WAW hazards on CSRs, loads, AMOs, and mul/div in execute stage.
|
2015-01-05 00:21:17 +01:00
|
|
|
val id_renx1_not0 = id_ctrl.rxs1 && id_raddr1 != UInt(0)
|
|
|
|
val id_renx2_not0 = id_ctrl.rxs2 && id_raddr2 != UInt(0)
|
|
|
|
val id_wen_not0 = id_ctrl.wxd && id_waddr != UInt(0)
|
|
|
|
val ex_cannot_bypass = ex_ctrl.csr != CSR.N || ex_ctrl.jalr || ex_ctrl.mem || ex_ctrl.div || ex_ctrl.fp || ex_ctrl.rocc
|
|
|
|
val data_hazard_ex = ex_ctrl.wxd &&
|
2014-01-25 00:59:11 +01:00
|
|
|
(id_renx1_not0 && id_raddr1 === io.dpath.ex_waddr ||
|
|
|
|
id_renx2_not0 && id_raddr2 === io.dpath.ex_waddr ||
|
|
|
|
id_wen_not0 && id_waddr === io.dpath.ex_waddr)
|
2015-01-05 00:21:17 +01:00
|
|
|
val fp_data_hazard_ex = ex_ctrl.wfd &&
|
2012-02-12 13:36:01 +01:00
|
|
|
(io.fpu.dec.ren1 && id_raddr1 === io.dpath.ex_waddr ||
|
|
|
|
io.fpu.dec.ren2 && id_raddr2 === io.dpath.ex_waddr ||
|
|
|
|
io.fpu.dec.ren3 && id_raddr3 === io.dpath.ex_waddr ||
|
|
|
|
io.fpu.dec.wen && id_waddr === io.dpath.ex_waddr)
|
2015-01-05 00:21:17 +01:00
|
|
|
val id_ex_hazard = ex_reg_valid && (data_hazard_ex && ex_cannot_bypass || fp_data_hazard_ex)
|
2014-11-17 07:04:33 +01:00
|
|
|
|
2015-04-11 11:16:44 +02:00
|
|
|
// stall for RAW/WAW hazards on CSRs, LB/LH, and mul/div in memory stage.
|
2012-11-25 07:01:08 +01:00
|
|
|
val mem_mem_cmd_bh =
|
2014-08-12 03:36:23 +02:00
|
|
|
if (params(FastLoadWord)) Bool(!params(FastLoadByte)) && mem_reg_slow_bypass
|
2013-04-04 07:15:39 +02:00
|
|
|
else Bool(true)
|
2015-01-05 00:21:17 +01:00
|
|
|
val mem_cannot_bypass = mem_ctrl.csr != CSR.N || mem_ctrl.mem && mem_mem_cmd_bh || mem_ctrl.div || mem_ctrl.fp || mem_ctrl.rocc
|
|
|
|
val data_hazard_mem = mem_ctrl.wxd &&
|
2014-01-25 00:59:11 +01:00
|
|
|
(id_renx1_not0 && id_raddr1 === io.dpath.mem_waddr ||
|
|
|
|
id_renx2_not0 && id_raddr2 === io.dpath.mem_waddr ||
|
|
|
|
id_wen_not0 && id_waddr === io.dpath.mem_waddr)
|
2015-01-05 00:21:17 +01:00
|
|
|
val fp_data_hazard_mem = mem_ctrl.wfd &&
|
2012-02-12 13:36:01 +01:00
|
|
|
(io.fpu.dec.ren1 && id_raddr1 === io.dpath.mem_waddr ||
|
|
|
|
io.fpu.dec.ren2 && id_raddr2 === io.dpath.mem_waddr ||
|
|
|
|
io.fpu.dec.ren3 && id_raddr3 === io.dpath.mem_waddr ||
|
|
|
|
io.fpu.dec.wen && id_waddr === io.dpath.mem_waddr)
|
2015-01-05 00:21:17 +01:00
|
|
|
val id_mem_hazard = mem_reg_valid && (data_hazard_mem && mem_cannot_bypass || fp_data_hazard_mem)
|
|
|
|
id_load_use := mem_reg_valid && data_hazard_mem && mem_ctrl.mem
|
2012-01-02 09:25:11 +01:00
|
|
|
|
|
|
|
// stall for RAW/WAW hazards on load/AMO misses and mul/div in writeback.
|
2015-01-05 00:21:17 +01:00
|
|
|
val data_hazard_wb = wb_ctrl.wxd &&
|
2014-04-16 06:26:54 +02:00
|
|
|
(id_renx1_not0 && id_raddr1 === io.dpath.wb_waddr ||
|
|
|
|
id_renx2_not0 && id_raddr2 === io.dpath.wb_waddr ||
|
|
|
|
id_wen_not0 && id_waddr === io.dpath.wb_waddr)
|
2015-01-05 00:21:17 +01:00
|
|
|
val fp_data_hazard_wb = wb_ctrl.wfd &&
|
2012-02-12 13:36:01 +01:00
|
|
|
(io.fpu.dec.ren1 && id_raddr1 === io.dpath.wb_waddr ||
|
|
|
|
io.fpu.dec.ren2 && id_raddr2 === io.dpath.wb_waddr ||
|
|
|
|
io.fpu.dec.ren3 && id_raddr3 === io.dpath.wb_waddr ||
|
|
|
|
io.fpu.dec.wen && id_waddr === io.dpath.wb_waddr)
|
2015-01-05 00:21:17 +01:00
|
|
|
val id_wb_hazard = wb_reg_valid && (data_hazard_wb && wb_set_sboard || fp_data_hazard_wb)
|
2012-11-16 11:39:33 +01:00
|
|
|
|
|
|
|
val id_sboard_hazard =
|
2014-01-25 00:59:11 +01:00
|
|
|
(id_renx1_not0 && sboard.readBypassed(id_raddr1) ||
|
|
|
|
id_renx2_not0 && sboard.readBypassed(id_raddr2) ||
|
|
|
|
id_wen_not0 && sboard.readBypassed(id_waddr))
|
2012-01-02 09:25:11 +01:00
|
|
|
|
2014-04-16 06:26:54 +02:00
|
|
|
sboard.set(wb_set_sboard && io.dpath.wb_wen, io.dpath.wb_waddr)
|
|
|
|
|
2011-11-02 01:59:27 +01:00
|
|
|
val ctrl_stalld =
|
2012-11-16 11:39:33 +01:00
|
|
|
id_ex_hazard || id_mem_hazard || id_wb_hazard || id_sboard_hazard ||
|
2015-01-03 22:34:38 +01:00
|
|
|
id_ctrl.fp && id_stall_fpu ||
|
|
|
|
id_ctrl.mem && !io.dmem.req.ready ||
|
2015-03-12 06:33:03 +01:00
|
|
|
Bool(!params(BuildRoCC).isEmpty) && wb_reg_rocc_pending && id_ctrl.rocc && !io.rocc.cmd.ready ||
|
2015-05-19 03:23:58 +02:00
|
|
|
id_do_fence ||
|
|
|
|
io.dpath.csr_stall
|
2015-03-14 10:49:07 +01:00
|
|
|
val ctrl_draind = io.dpath.interrupt
|
2013-04-03 02:37:21 +02:00
|
|
|
ctrl_killd := !io.imem.resp.valid || take_pc || ctrl_stalld || ctrl_draind
|
2012-11-05 01:40:14 +01:00
|
|
|
|
2013-04-03 02:37:21 +02:00
|
|
|
io.dpath.killd := take_pc || ctrl_stalld && !ctrl_draind
|
2014-03-24 12:36:12 +01:00
|
|
|
io.imem.resp.ready := !ctrl_stalld || ctrl_draind
|
2015-01-05 00:21:17 +01:00
|
|
|
io.imem.invalidate := wb_reg_valid && wb_ctrl.fence_i
|
2011-11-02 01:59:27 +01:00
|
|
|
|
2015-01-05 00:21:17 +01:00
|
|
|
io.dpath.ren(1) := id_ctrl.rxs2
|
|
|
|
io.dpath.ren(0) := id_ctrl.rxs1
|
2015-01-03 22:34:38 +01:00
|
|
|
io.dpath.ex_ctrl := ex_ctrl
|
2015-01-05 00:21:17 +01:00
|
|
|
io.dpath.mem_ctrl := mem_ctrl
|
2014-04-08 00:58:49 +02:00
|
|
|
io.dpath.ex_valid := ex_reg_valid
|
2015-01-05 00:21:17 +01:00
|
|
|
io.dpath.ll_ready := !(wb_reg_valid && wb_ctrl.wxd)
|
2015-03-14 10:49:07 +01:00
|
|
|
io.dpath.retire := wb_reg_valid && !replay_wb && !io.dpath.csr_xcpt
|
2015-01-05 00:21:17 +01:00
|
|
|
io.dpath.wb_wen := io.dpath.retire && wb_ctrl.wxd
|
2015-03-14 10:49:07 +01:00
|
|
|
io.dpath.csr_cmd := Mux(wb_reg_valid, wb_ctrl.csr, CSR.N)
|
2015-01-05 00:21:17 +01:00
|
|
|
io.dpath.killm := killm_common
|
2011-12-10 04:42:58 +01:00
|
|
|
|
2015-01-03 22:34:38 +01:00
|
|
|
io.fpu.valid := !ctrl_killd && id_ctrl.fp
|
2012-11-05 01:40:14 +01:00
|
|
|
io.fpu.killx := ctrl_killx
|
2012-10-10 06:35:03 +02:00
|
|
|
io.fpu.killm := killm_common
|
2012-02-12 13:36:01 +01:00
|
|
|
|
2015-01-05 00:21:17 +01:00
|
|
|
io.dmem.req.valid := ex_reg_valid && ex_ctrl.mem
|
2012-11-06 17:13:44 +01:00
|
|
|
io.dmem.req.bits.kill := killm_common || mem_xcpt
|
2015-01-05 00:21:17 +01:00
|
|
|
io.dmem.req.bits.cmd := ex_ctrl.mem_cmd
|
|
|
|
io.dmem.req.bits.typ := ex_ctrl.mem_type
|
2012-11-06 17:13:44 +01:00
|
|
|
io.dmem.req.bits.phys := Bool(false)
|
2015-04-11 11:26:33 +02:00
|
|
|
io.dmem.invalidate_lr := wb_xcpt
|
2013-09-15 00:31:50 +02:00
|
|
|
|
2013-12-10 00:06:13 +01:00
|
|
|
io.rocc.cmd.valid := wb_rocc_val
|
2015-03-17 13:08:19 +01:00
|
|
|
io.rocc.exception := wb_xcpt && io.dpath.status.xs.orR
|
|
|
|
io.rocc.s := io.dpath.status.prv.orR // should we just pass all of mstatus?
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|