2012-02-26 02:09:26 +01:00
|
|
|
package rocket
|
2011-10-26 08:02:47 +02:00
|
|
|
|
|
|
|
import Chisel._
|
2012-10-08 05:15:54 +02:00
|
|
|
import Node._
|
2011-10-26 08:02:47 +02:00
|
|
|
import Constants._
|
|
|
|
import Instructions._
|
2012-11-16 11:39:33 +01:00
|
|
|
import Util._
|
2012-02-09 06:43:45 +01:00
|
|
|
import hwacha._
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2012-11-06 08:52:32 +01:00
|
|
|
class Datapath(implicit conf: RocketConfiguration) extends Component
|
2011-10-26 08:02:47 +02:00
|
|
|
{
|
2012-11-06 08:52:32 +01:00
|
|
|
val io = new Bundle {
|
|
|
|
val host = new ioHTIF(conf.ntiles)
|
|
|
|
val ctrl = new ioCtrlDpath().flip
|
|
|
|
val dmem = new ioHellaCache()(conf.dcache)
|
2012-11-06 17:13:44 +01:00
|
|
|
val ptw = new IODatapathPTW().flip
|
2012-11-06 08:52:32 +01:00
|
|
|
val imem = new IOCPUFrontend()(conf.icache)
|
|
|
|
val fpu = new ioDpathFPU();
|
|
|
|
val vec_ctrl = new ioCtrlDpathVec().flip
|
|
|
|
val vec_iface = new ioDpathVecInterface()
|
|
|
|
val vec_imul_req = new io_imul_req
|
|
|
|
val vec_imul_resp = Bits(INPUT, hwacha.Constants.SZ_XLEN)
|
|
|
|
}
|
2011-10-26 08:02:47 +02:00
|
|
|
|
|
|
|
// execute definitions
|
2012-01-02 01:09:40 +01:00
|
|
|
val ex_reg_pc = Reg() { UFix() };
|
2012-02-09 10:28:16 +01:00
|
|
|
val ex_reg_inst = Reg() { Bits() };
|
|
|
|
val ex_reg_raddr1 = Reg() { UFix() };
|
2012-01-02 01:09:40 +01:00
|
|
|
val ex_reg_raddr2 = Reg() { UFix() };
|
2012-02-08 15:47:26 +01:00
|
|
|
val ex_reg_op2 = Reg() { Bits() };
|
2012-01-02 01:09:40 +01:00
|
|
|
val ex_reg_rs2 = Reg() { Bits() };
|
|
|
|
val ex_reg_rs1 = Reg() { Bits() };
|
|
|
|
val ex_reg_waddr = Reg() { UFix() };
|
|
|
|
val ex_reg_ctrl_fn_dw = Reg() { UFix() };
|
|
|
|
val ex_reg_ctrl_fn_alu = Reg() { UFix() };
|
|
|
|
val ex_reg_ctrl_sel_wb = Reg() { UFix() };
|
2012-10-17 01:32:35 +02:00
|
|
|
val ex_wdata = Bits()
|
2012-11-05 01:40:14 +01:00
|
|
|
val ex_reg_kill = Reg() { Bool() }
|
2011-11-02 01:59:27 +01:00
|
|
|
|
2011-11-02 03:05:27 +01:00
|
|
|
// memory definitions
|
2012-01-02 01:09:40 +01:00
|
|
|
val mem_reg_pc = Reg() { UFix() };
|
2012-02-09 10:28:16 +01:00
|
|
|
val mem_reg_inst = Reg() { Bits() };
|
|
|
|
val mem_reg_rs2 = Reg() { Bits() };
|
2012-01-02 01:09:40 +01:00
|
|
|
val mem_reg_waddr = Reg() { UFix() };
|
|
|
|
val mem_reg_wdata = Reg() { Bits() };
|
2012-02-09 10:28:16 +01:00
|
|
|
val mem_reg_raddr1 = Reg() { UFix() };
|
2012-01-02 01:09:40 +01:00
|
|
|
val mem_reg_raddr2 = Reg() { UFix() };
|
2012-11-05 01:40:14 +01:00
|
|
|
val mem_reg_kill = Reg() { Bool() }
|
2011-11-02 01:59:27 +01:00
|
|
|
|
2011-11-02 03:05:27 +01:00
|
|
|
// writeback definitions
|
2012-01-03 00:42:39 +01:00
|
|
|
val wb_reg_pc = Reg() { UFix() };
|
2012-02-09 10:28:16 +01:00
|
|
|
val wb_reg_inst = Reg() { Bits() };
|
|
|
|
val wb_reg_rs2 = Reg() { Bits() };
|
2012-02-25 21:21:10 +01:00
|
|
|
val wb_reg_waddr = Reg() { UFix() }
|
|
|
|
val wb_reg_wdata = Reg() { Bits() }
|
|
|
|
val wb_reg_vec_waddr = Reg() { UFix() }
|
|
|
|
val wb_reg_vec_wdata = Reg() { Bits() }
|
2012-02-09 10:28:16 +01:00
|
|
|
val wb_reg_raddr1 = Reg() { UFix() };
|
2012-01-03 00:42:39 +01:00
|
|
|
val wb_reg_raddr2 = Reg() { UFix() };
|
2012-02-08 13:21:05 +01:00
|
|
|
val wb_reg_ll_wb = Reg(resetVal = Bool(false));
|
2012-05-24 19:33:15 +02:00
|
|
|
val wb_wdata = Bits();
|
2011-11-02 01:59:27 +01:00
|
|
|
|
2011-10-26 08:02:47 +02:00
|
|
|
// instruction decode stage
|
2012-10-10 06:35:03 +02:00
|
|
|
val id_inst = io.imem.resp.bits.data
|
|
|
|
val id_pc = io.imem.resp.bits.pc
|
|
|
|
debug(id_inst)
|
|
|
|
debug(id_pc)
|
2012-11-05 01:40:14 +01:00
|
|
|
|
|
|
|
val regfile_ = Mem(31){Bits(width = 64)}
|
2012-11-05 10:30:57 +01:00
|
|
|
def readRF(a: UFix) = regfile_(~a)
|
2012-11-05 01:40:14 +01:00
|
|
|
def writeRF(a: UFix, d: Bits) = regfile_(~a) := d
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2012-10-10 06:35:03 +02:00
|
|
|
val id_raddr1 = id_inst(26,22).toUFix;
|
|
|
|
val id_raddr2 = id_inst(21,17).toUFix;
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2011-11-02 01:59:27 +01:00
|
|
|
// bypass muxes
|
2012-11-05 10:30:57 +01:00
|
|
|
val id_rs1_dmem_bypass = id_raddr1 != UFix(0) &&
|
2012-03-17 02:34:40 +01:00
|
|
|
Mux(io.ctrl.ex_wen && id_raddr1 === ex_reg_waddr, Bool(false),
|
|
|
|
Mux(io.ctrl.mem_wen && id_raddr1 === mem_reg_waddr, io.ctrl.mem_load,
|
|
|
|
Bool(false)))
|
2011-10-26 08:02:47 +02:00
|
|
|
val id_rs1 =
|
2012-11-05 10:30:57 +01:00
|
|
|
Mux(id_raddr1 === UFix(0), UFix(0),
|
2012-02-08 13:21:05 +01:00
|
|
|
Mux(io.ctrl.ex_wen && id_raddr1 === ex_reg_waddr, ex_wdata,
|
2012-03-17 02:34:40 +01:00
|
|
|
Mux(io.ctrl.mem_wen && id_raddr1 === mem_reg_waddr, mem_reg_wdata,
|
2012-02-08 13:21:05 +01:00
|
|
|
Mux((io.ctrl.wb_wen || wb_reg_ll_wb) && id_raddr1 === wb_reg_waddr, wb_wdata,
|
2012-11-05 10:30:57 +01:00
|
|
|
readRF(id_raddr1)))))
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2012-11-05 10:30:57 +01:00
|
|
|
val id_rs2_dmem_bypass = id_raddr2 != UFix(0) &&
|
2012-03-17 02:34:40 +01:00
|
|
|
Mux(io.ctrl.ex_wen && id_raddr2 === ex_reg_waddr, Bool(false),
|
|
|
|
Mux(io.ctrl.mem_wen && id_raddr2 === mem_reg_waddr, io.ctrl.mem_load,
|
|
|
|
Bool(false)))
|
2012-11-05 10:30:57 +01:00
|
|
|
val id_rs2 = Mux(id_raddr2 === UFix(0), UFix(0),
|
2012-02-08 13:21:05 +01:00
|
|
|
Mux(io.ctrl.ex_wen && id_raddr2 === ex_reg_waddr, ex_wdata,
|
2012-03-17 02:34:40 +01:00
|
|
|
Mux(io.ctrl.mem_wen && id_raddr2 === mem_reg_waddr, mem_reg_wdata,
|
2012-02-08 13:21:05 +01:00
|
|
|
Mux((io.ctrl.wb_wen || wb_reg_ll_wb) && id_raddr2 === wb_reg_waddr, wb_wdata,
|
2012-11-05 10:30:57 +01:00
|
|
|
readRF(id_raddr2)))))
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2012-02-08 15:47:26 +01:00
|
|
|
// immediate generation
|
|
|
|
val id_imm_bj = io.ctrl.sel_alu2 === A2_BTYPE || io.ctrl.sel_alu2 === A2_JTYPE
|
|
|
|
val id_imm_l = io.ctrl.sel_alu2 === A2_LTYPE
|
|
|
|
val id_imm_zero = io.ctrl.sel_alu2 === A2_ZERO || io.ctrl.sel_alu2 === A2_RTYPE
|
|
|
|
val id_imm_ibz = io.ctrl.sel_alu2 === A2_ITYPE || io.ctrl.sel_alu2 === A2_BTYPE || id_imm_zero
|
2012-10-10 06:35:03 +02:00
|
|
|
val id_imm_sign = Mux(id_imm_bj, id_inst(31),
|
|
|
|
Mux(id_imm_l, id_inst(26),
|
2012-02-08 15:47:26 +01:00
|
|
|
Mux(id_imm_zero, Bits(0,1),
|
2012-10-10 06:35:03 +02:00
|
|
|
id_inst(21)))) // IMM_ITYPE
|
2012-02-08 15:47:26 +01:00
|
|
|
val id_imm_small = Mux(id_imm_zero, Bits(0,12),
|
2012-10-10 06:35:03 +02:00
|
|
|
Cat(Mux(id_imm_bj, id_inst(31,27), id_inst(21,17)), id_inst(16,10)))
|
2012-02-08 15:47:26 +01:00
|
|
|
val id_imm = Cat(Fill(32, id_imm_sign),
|
2012-10-10 06:35:03 +02:00
|
|
|
Mux(id_imm_l, Cat(id_inst(26,7), Bits(0,12)),
|
2012-02-08 15:47:26 +01:00
|
|
|
Mux(id_imm_ibz, Cat(Fill(20, id_imm_sign), id_imm_small),
|
2012-10-10 06:35:03 +02:00
|
|
|
Cat(Fill(7, id_imm_sign), id_inst(31,7))))) // A2_JTYPE
|
2012-02-08 15:47:26 +01:00
|
|
|
|
2012-03-17 02:34:40 +01:00
|
|
|
val id_op2_dmem_bypass = id_rs2_dmem_bypass && io.ctrl.sel_alu2 === A2_RTYPE
|
2012-02-08 15:47:26 +01:00
|
|
|
val id_op2 = Mux(io.ctrl.sel_alu2 === A2_RTYPE, id_rs2, id_imm)
|
|
|
|
|
2012-10-10 06:35:03 +02:00
|
|
|
io.ctrl.inst := id_inst
|
|
|
|
io.fpu.inst := id_inst
|
2011-10-26 08:02:47 +02:00
|
|
|
|
|
|
|
// execute stage
|
2012-11-05 01:40:14 +01:00
|
|
|
ex_reg_kill := io.ctrl.killd
|
|
|
|
when (!io.ctrl.killd) {
|
|
|
|
ex_reg_pc := id_pc
|
|
|
|
ex_reg_inst := id_inst
|
|
|
|
ex_reg_raddr1 := id_raddr1
|
|
|
|
ex_reg_raddr2 := id_raddr2
|
|
|
|
ex_reg_op2 := id_op2
|
|
|
|
ex_reg_waddr := Mux(io.ctrl.sel_wa === WA_RD, id_inst(31,27).toUFix, RA)
|
|
|
|
ex_reg_ctrl_fn_dw := io.ctrl.fn_dw.toUFix
|
|
|
|
ex_reg_ctrl_fn_alu := io.ctrl.fn_alu
|
|
|
|
ex_reg_ctrl_sel_wb := io.ctrl.sel_wb
|
|
|
|
when (io.ctrl.ren1) { ex_reg_rs1 := id_rs1 }
|
|
|
|
when (io.ctrl.ren2) { ex_reg_rs2 := id_rs2 }
|
|
|
|
}
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2012-11-16 11:39:33 +01:00
|
|
|
val dmem_resp_data = if (conf.fastLoadByte) io.dmem.resp.bits.data_subword else io.dmem.resp.bits.data
|
|
|
|
val ex_rs1 = Mux(Reg(id_rs1_dmem_bypass), dmem_resp_data, ex_reg_rs1)
|
|
|
|
val ex_rs2 = Mux(Reg(id_rs2_dmem_bypass), dmem_resp_data, ex_reg_rs2)
|
|
|
|
val ex_op2 = Mux(Reg(id_op2_dmem_bypass), dmem_resp_data, ex_reg_op2)
|
2012-03-17 02:34:40 +01:00
|
|
|
|
2012-11-16 11:39:33 +01:00
|
|
|
val alu = new ALU
|
|
|
|
alu.io.dw := ex_reg_ctrl_fn_dw;
|
|
|
|
alu.io.fn := ex_reg_ctrl_fn_alu;
|
|
|
|
alu.io.in2 := ex_op2.toUFix
|
|
|
|
alu.io.in1 := ex_rs1.toUFix
|
2011-10-26 08:02:47 +02:00
|
|
|
|
|
|
|
// divider
|
2012-10-10 06:35:03 +02:00
|
|
|
val div = new rocketDivider(earlyOut = true)
|
|
|
|
div.io.req.valid := io.ctrl.div_val
|
|
|
|
div.io.req.bits.fn := Cat(ex_reg_ctrl_fn_dw, io.ctrl.div_fn)
|
2012-03-17 02:34:40 +01:00
|
|
|
div.io.req.bits.in0 := ex_rs1
|
2012-11-05 01:40:14 +01:00
|
|
|
div.io.req.bits.in1 := ex_op2
|
2012-02-25 04:22:35 +01:00
|
|
|
div.io.req_tag := ex_reg_waddr
|
2012-10-10 06:35:03 +02:00
|
|
|
div.io.req_kill := io.ctrl.div_kill
|
2012-11-16 11:39:33 +01:00
|
|
|
div.io.resp_rdy := Bool(true)
|
2012-02-25 04:22:35 +01:00
|
|
|
io.ctrl.div_rdy := div.io.req.ready
|
|
|
|
io.ctrl.div_result_val := div.io.resp_val
|
2011-10-26 08:02:47 +02:00
|
|
|
|
|
|
|
// multiplier
|
2012-10-10 06:35:03 +02:00
|
|
|
var mul_io = new rocketMultiplier(unroll = 4, earlyOut = true).io
|
2012-02-25 04:22:35 +01:00
|
|
|
if (HAVE_VEC)
|
|
|
|
{
|
|
|
|
val vu_mul = new rocketVUMultiplier(nwbq = 1)
|
|
|
|
vu_mul.io.vu.req <> io.vec_imul_req
|
|
|
|
vu_mul.io.vu.resp <> io.vec_imul_resp
|
|
|
|
mul_io = vu_mul.io.cpu
|
|
|
|
}
|
2012-10-10 06:35:03 +02:00
|
|
|
mul_io.req.valid := io.ctrl.mul_val
|
|
|
|
mul_io.req.bits.fn := Cat(ex_reg_ctrl_fn_dw, io.ctrl.mul_fn)
|
2012-03-17 02:34:40 +01:00
|
|
|
mul_io.req.bits.in0 := ex_rs1
|
2012-11-05 01:40:14 +01:00
|
|
|
mul_io.req.bits.in1 := ex_op2
|
2012-02-25 04:22:35 +01:00
|
|
|
mul_io.req_tag := ex_reg_waddr
|
2012-10-10 06:35:03 +02:00
|
|
|
mul_io.req_kill := io.ctrl.mul_kill
|
2012-11-16 11:39:33 +01:00
|
|
|
mul_io.resp_rdy := Bool(true)
|
2012-02-25 04:22:35 +01:00
|
|
|
io.ctrl.mul_rdy := mul_io.req.ready
|
|
|
|
io.ctrl.mul_result_val := mul_io.resp_val
|
2011-11-02 01:59:27 +01:00
|
|
|
|
2012-11-16 11:39:33 +01:00
|
|
|
io.fpu.fromint_data := ex_rs1
|
|
|
|
io.ctrl.ex_waddr := ex_reg_waddr
|
|
|
|
|
|
|
|
def vaSign(a0: Bits, ea: Bits) = {
|
|
|
|
// efficient means to compress 64-bit VA into VADDR_BITS+1 bits
|
|
|
|
// (VA is bad if VA(VADDR_BITS) != VA(VADDR_BITS-1))
|
|
|
|
val a = a0 >> VADDR_BITS-1
|
|
|
|
val e = ea(VADDR_BITS,VADDR_BITS-1)
|
|
|
|
Mux(a === UFix(0) || a === UFix(1), e != UFix(0),
|
|
|
|
Mux(a === Fix(-1) || a === Fix(-2), e === Fix(-1),
|
|
|
|
Bool(false)))
|
|
|
|
}
|
|
|
|
val ex_effective_address = Cat(vaSign(ex_rs1, alu.io.adder_out), alu.io.adder_out(VADDR_BITS-1,0)).toUFix
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2011-11-02 01:59:27 +01:00
|
|
|
// D$ request interface (registered inside D$ module)
|
|
|
|
// other signals (req_val, req_rdy) connect to control module
|
2012-11-06 17:13:44 +01:00
|
|
|
io.dmem.req.bits.addr := ex_effective_address
|
2012-05-02 03:23:04 +02:00
|
|
|
io.dmem.req.bits.data := Mux(io.ctrl.mem_fp_val, io.fpu.store_data, mem_reg_rs2)
|
|
|
|
io.dmem.req.bits.tag := Cat(ex_reg_waddr, io.ctrl.ex_fp_val)
|
2012-11-06 08:52:32 +01:00
|
|
|
require(io.dmem.req.bits.tag.getWidth >= 6)
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2011-11-02 01:59:27 +01:00
|
|
|
// processor control regfile read
|
2012-11-16 11:39:33 +01:00
|
|
|
val pcr = new rocketDpathPCR()
|
2012-03-24 21:03:31 +01:00
|
|
|
pcr.io.r.en := io.ctrl.pcr != PCR_N
|
|
|
|
pcr.io.r.addr := wb_reg_raddr1
|
2011-11-10 09:50:09 +01:00
|
|
|
|
2012-02-20 08:15:45 +01:00
|
|
|
pcr.io.host <> io.host
|
2012-11-16 11:39:33 +01:00
|
|
|
pcr.io <> io.ctrl
|
|
|
|
pcr.io.pc := wb_reg_pc
|
|
|
|
io.ctrl.pcr_replay := pcr.io.replay
|
2012-11-06 17:13:44 +01:00
|
|
|
|
|
|
|
io.ptw.ptbr := pcr.io.ptbr
|
|
|
|
io.ptw.invalidate := pcr.io.ptbr_wen
|
|
|
|
io.ptw.status := pcr.io.status
|
2011-11-02 01:59:27 +01:00
|
|
|
|
2011-10-26 08:02:47 +02:00
|
|
|
// branch resolution logic
|
2012-10-12 01:50:15 +02:00
|
|
|
io.ctrl.jalr_eq := ex_reg_rs1 === id_pc.toFix && ex_reg_op2(id_imm_small.getWidth-1,0) === UFix(0)
|
2012-11-16 11:39:33 +01:00
|
|
|
io.ctrl.ex_br_taken :=
|
|
|
|
Mux(io.ctrl.ex_br_type === BR_EQ, ex_rs1 === ex_rs2,
|
|
|
|
Mux(io.ctrl.ex_br_type === BR_NE, ex_rs1 != ex_rs2,
|
|
|
|
Mux(io.ctrl.ex_br_type === BR_LT, ex_rs1.toFix < ex_rs2.toFix,
|
|
|
|
Mux(io.ctrl.ex_br_type === BR_GE, ex_rs1.toFix >= ex_rs2.toFix,
|
|
|
|
Mux(io.ctrl.ex_br_type === BR_LTU, ex_rs1 < ex_rs2,
|
|
|
|
Mux(io.ctrl.ex_br_type === BR_GEU, ex_rs1 >= ex_rs2,
|
|
|
|
io.ctrl.ex_br_type === BR_J))))))
|
|
|
|
|
|
|
|
val ex_pc_plus4 = ex_reg_pc + UFix(4)
|
|
|
|
val ex_branch_target = ex_reg_pc + Cat(ex_reg_op2(VADDR_BITS-1,0), Bits(0,1)).toUFix
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2011-11-16 11:04:28 +01:00
|
|
|
// time stamp counter
|
|
|
|
val tsc_reg = Reg(resetVal = UFix(0,64));
|
2012-02-12 02:20:33 +01:00
|
|
|
tsc_reg := tsc_reg + UFix(1);
|
2012-01-02 06:28:38 +01:00
|
|
|
// instructions retired counter
|
|
|
|
val irt_reg = Reg(resetVal = UFix(0,64));
|
2012-02-23 23:43:49 +01:00
|
|
|
when (io.ctrl.wb_valid) { irt_reg := irt_reg + UFix(1); }
|
2011-11-16 11:04:28 +01:00
|
|
|
|
2011-10-26 08:02:47 +02:00
|
|
|
// writeback select mux
|
|
|
|
ex_wdata :=
|
2012-10-12 01:50:15 +02:00
|
|
|
Mux(ex_reg_ctrl_sel_wb === WB_PC, ex_pc_plus4.toFix,
|
2011-11-16 11:04:28 +01:00
|
|
|
Mux(ex_reg_ctrl_sel_wb === WB_TSC, tsc_reg,
|
2012-01-02 06:28:38 +01:00
|
|
|
Mux(ex_reg_ctrl_sel_wb === WB_IRT, irt_reg,
|
2012-11-16 11:39:33 +01:00
|
|
|
alu.io.out))).toBits // WB_ALU
|
2012-02-12 10:35:55 +01:00
|
|
|
|
2011-11-02 01:59:27 +01:00
|
|
|
// memory stage
|
2012-11-05 01:40:14 +01:00
|
|
|
mem_reg_kill := ex_reg_kill
|
|
|
|
when (!ex_reg_kill) {
|
|
|
|
mem_reg_pc := ex_reg_pc
|
|
|
|
mem_reg_inst := ex_reg_inst
|
2012-11-06 08:52:32 +01:00
|
|
|
mem_reg_rs2 := StoreGen(io.ctrl.ex_mem_type, Bits(0), ex_rs2).data
|
2012-11-05 01:40:14 +01:00
|
|
|
mem_reg_waddr := ex_reg_waddr
|
|
|
|
mem_reg_wdata := ex_wdata
|
|
|
|
mem_reg_raddr1 := ex_reg_raddr1
|
|
|
|
mem_reg_raddr2 := ex_reg_raddr2
|
|
|
|
}
|
2011-11-02 01:59:27 +01:00
|
|
|
|
2011-11-02 05:25:52 +01:00
|
|
|
// for load/use hazard detection (load byte/halfword)
|
|
|
|
io.ctrl.mem_waddr := mem_reg_waddr;
|
|
|
|
|
2012-02-12 13:36:01 +01:00
|
|
|
// writeback arbitration
|
2012-05-02 03:23:04 +02:00
|
|
|
val dmem_resp_xpu = !io.dmem.resp.bits.tag(0).toBool
|
|
|
|
val dmem_resp_fpu = io.dmem.resp.bits.tag(0).toBool
|
|
|
|
val dmem_resp_waddr = io.dmem.resp.bits.tag.toUFix >> UFix(1)
|
2012-11-16 11:39:33 +01:00
|
|
|
val dmem_resp_replay = io.dmem.resp.bits.replay && dmem_resp_xpu
|
|
|
|
|
|
|
|
val mem_ll_wdata = Bits()
|
|
|
|
mem_ll_wdata := mul_io.resp_bits
|
|
|
|
io.ctrl.mem_ll_waddr := mul_io.resp_tag
|
|
|
|
io.ctrl.mem_ll_wb := mul_io.resp_val
|
|
|
|
when (div.io.resp_val) {
|
|
|
|
mul_io.resp_rdy := Bool(false)
|
|
|
|
mem_ll_wdata := div.io.resp_bits
|
|
|
|
io.ctrl.mem_ll_waddr := div.io.resp_tag
|
|
|
|
io.ctrl.mem_ll_wb := Bool(true)
|
|
|
|
}
|
|
|
|
when (dmem_resp_replay) {
|
|
|
|
mul_io.resp_rdy := Bool(false)
|
|
|
|
div.io.resp_rdy := Bool(false)
|
|
|
|
mem_ll_wdata := io.dmem.resp.bits.data_subword
|
|
|
|
io.ctrl.mem_ll_waddr := dmem_resp_waddr
|
|
|
|
io.ctrl.mem_ll_wb := Bool(true)
|
|
|
|
}
|
2011-11-02 01:59:27 +01:00
|
|
|
|
2012-05-02 03:23:04 +02:00
|
|
|
io.fpu.dmem_resp_val := io.dmem.resp.valid && dmem_resp_fpu
|
|
|
|
io.fpu.dmem_resp_data := io.dmem.resp.bits.data
|
|
|
|
io.fpu.dmem_resp_type := io.dmem.resp.bits.typ
|
2012-02-12 13:36:01 +01:00
|
|
|
io.fpu.dmem_resp_tag := dmem_resp_waddr
|
|
|
|
|
|
|
|
// writeback stage
|
2012-11-05 01:40:14 +01:00
|
|
|
when (!mem_reg_kill) {
|
|
|
|
wb_reg_pc := mem_reg_pc
|
|
|
|
wb_reg_inst := mem_reg_inst
|
|
|
|
wb_reg_rs2 := mem_reg_rs2
|
|
|
|
wb_reg_vec_waddr := mem_reg_waddr
|
|
|
|
wb_reg_vec_wdata := mem_reg_wdata
|
|
|
|
wb_reg_raddr1 := mem_reg_raddr1
|
|
|
|
wb_reg_raddr2 := mem_reg_raddr2
|
|
|
|
wb_reg_waddr := mem_reg_waddr
|
|
|
|
wb_reg_wdata := Mux(io.ctrl.mem_fp_val && io.ctrl.mem_wen, io.fpu.toint_data, mem_reg_wdata)
|
|
|
|
}
|
2012-11-16 11:39:33 +01:00
|
|
|
wb_reg_ll_wb := io.ctrl.mem_ll_wb
|
|
|
|
when (io.ctrl.mem_ll_wb) {
|
|
|
|
wb_reg_waddr := io.ctrl.mem_ll_waddr
|
2012-11-05 01:40:14 +01:00
|
|
|
wb_reg_wdata := mem_ll_wdata
|
|
|
|
}
|
2011-11-02 01:59:27 +01:00
|
|
|
|
2012-02-15 22:30:22 +01:00
|
|
|
if (HAVE_VEC)
|
|
|
|
{
|
|
|
|
// vector datapath
|
|
|
|
val vec = new rocketDpathVec()
|
|
|
|
|
|
|
|
vec.io.ctrl <> io.vec_ctrl
|
|
|
|
io.vec_iface <> vec.io.iface
|
|
|
|
|
2012-03-21 23:08:48 +01:00
|
|
|
vec.io.valid := io.ctrl.wb_valid && pcr.io.status(SR_EV)
|
2012-02-15 22:30:22 +01:00
|
|
|
vec.io.inst := wb_reg_inst
|
2012-02-25 21:21:10 +01:00
|
|
|
vec.io.waddr := wb_reg_vec_waddr
|
2012-02-15 22:30:22 +01:00
|
|
|
vec.io.raddr1 := wb_reg_raddr1
|
|
|
|
vec.io.vecbank := pcr.io.vecbank
|
|
|
|
vec.io.vecbankcnt := pcr.io.vecbankcnt
|
2012-02-25 21:21:10 +01:00
|
|
|
vec.io.wdata := wb_reg_vec_wdata
|
2012-02-15 22:30:22 +01:00
|
|
|
vec.io.rs2 := wb_reg_rs2
|
|
|
|
|
2012-03-14 22:15:28 +01:00
|
|
|
pcr.io.vec_irq_aux := vec.io.irq_aux
|
2012-03-14 06:21:26 +01:00
|
|
|
pcr.io.vec_appvl := vec.io.appvl
|
|
|
|
pcr.io.vec_nxregs := vec.io.nxregs
|
|
|
|
pcr.io.vec_nfregs := vec.io.nfregs
|
|
|
|
|
2012-02-15 22:30:22 +01:00
|
|
|
wb_wdata :=
|
|
|
|
Mux(vec.io.wen, Cat(Bits(0,52), vec.io.appvl),
|
2012-11-16 11:39:33 +01:00
|
|
|
Mux(io.ctrl.wb_load, io.dmem.resp.bits.data_subword,
|
2012-02-25 21:21:10 +01:00
|
|
|
wb_reg_wdata))
|
2012-02-15 22:30:22 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-14 22:15:28 +01:00
|
|
|
pcr.io.vec_irq_aux := UFix(0)
|
2012-03-14 06:21:26 +01:00
|
|
|
pcr.io.vec_appvl := UFix(0)
|
|
|
|
pcr.io.vec_nxregs := UFix(0)
|
|
|
|
pcr.io.vec_nfregs := UFix(0)
|
|
|
|
|
2012-02-15 22:30:22 +01:00
|
|
|
wb_wdata :=
|
2012-11-16 11:39:33 +01:00
|
|
|
Mux(io.ctrl.wb_load, io.dmem.resp.bits.data_subword,
|
2012-02-25 21:21:10 +01:00
|
|
|
wb_reg_wdata)
|
2012-02-15 22:30:22 +01:00
|
|
|
}
|
2012-02-09 11:35:09 +01:00
|
|
|
|
2012-11-05 01:40:14 +01:00
|
|
|
val rf_wen = io.ctrl.wb_wen || wb_reg_ll_wb
|
|
|
|
val rf_waddr = wb_reg_waddr
|
|
|
|
val rf_wdata = Mux(io.ctrl.wb_wen && io.ctrl.pcr != PCR_N, pcr.io.r.data, wb_wdata)
|
|
|
|
List(rf_wen, rf_waddr, rf_wdata).map(debug _)
|
|
|
|
when (rf_wen) { writeRF(rf_waddr, rf_wdata) }
|
2012-02-09 07:30:45 +01:00
|
|
|
|
2012-02-25 21:21:10 +01:00
|
|
|
io.ctrl.wb_waddr := wb_reg_waddr
|
2012-02-09 10:28:16 +01:00
|
|
|
|
2011-11-02 01:59:27 +01:00
|
|
|
// scoreboard clear (for div/mul and D$ load miss writebacks)
|
2012-11-16 11:39:33 +01:00
|
|
|
io.ctrl.fp_sboard_clr := io.dmem.resp.bits.replay && dmem_resp_fpu
|
|
|
|
io.ctrl.fp_sboard_clra := dmem_resp_waddr
|
2012-04-01 07:23:51 +02:00
|
|
|
|
2011-11-02 01:59:27 +01:00
|
|
|
// processor control regfile write
|
2012-03-24 21:03:31 +01:00
|
|
|
pcr.io.w.addr := wb_reg_raddr1
|
|
|
|
pcr.io.w.en := io.ctrl.pcr === PCR_T || io.ctrl.pcr === PCR_S || io.ctrl.pcr === PCR_C
|
|
|
|
pcr.io.w.data := Mux(io.ctrl.pcr === PCR_S, pcr.io.r.data | wb_reg_wdata,
|
|
|
|
Mux(io.ctrl.pcr === PCR_C, pcr.io.r.data & ~wb_reg_wdata,
|
|
|
|
wb_reg_wdata))
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2012-11-16 11:39:33 +01:00
|
|
|
// hook up I$
|
|
|
|
io.imem.req.bits.currentpc := ex_reg_pc
|
|
|
|
io.imem.req.bits.pc :=
|
|
|
|
Mux(io.ctrl.sel_pc === PC_EX4, ex_pc_plus4,
|
|
|
|
Mux(io.ctrl.sel_pc === PC_EX, Mux(io.ctrl.ex_jalr, ex_effective_address, ex_branch_target),
|
|
|
|
Mux(io.ctrl.sel_pc === PC_PCR, Cat(pcr.io.evec(VADDR_BITS-1), pcr.io.evec).toUFix,
|
|
|
|
wb_reg_pc))) // PC_WB
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|