2012-02-09 06:43:45 +01:00
|
|
|
package Top
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2011-11-09 23:52:17 +01:00
|
|
|
import Chisel._;
|
2011-10-26 08:02:47 +02:00
|
|
|
import Node._;
|
|
|
|
import Constants._;
|
2012-02-09 06:43:45 +01:00
|
|
|
import hwacha._
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2011-11-10 06:54:11 +01:00
|
|
|
class ioDebug(view: List[String] = null) extends Bundle(view)
|
2011-10-26 08:02:47 +02:00
|
|
|
{
|
2012-01-18 19:28:48 +01:00
|
|
|
val error_mode = Bool(OUTPUT);
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class ioRocket extends Bundle()
|
|
|
|
{
|
|
|
|
val debug = new ioDebug();
|
2012-02-20 08:15:45 +01:00
|
|
|
val host = new ioHTIF();
|
2011-10-26 08:02:47 +02:00
|
|
|
val imem = new ioImem().flip();
|
2012-02-15 08:34:57 +01:00
|
|
|
val vimem = new ioImem().flip();
|
2011-10-26 08:02:47 +02:00
|
|
|
val dmem = new ioDmem().flip();
|
|
|
|
}
|
|
|
|
|
2012-02-23 04:30:03 +01:00
|
|
|
class rocketProc(resetSignal: Bool = null) extends Component(resetSignal)
|
2011-10-26 08:02:47 +02:00
|
|
|
{
|
|
|
|
val io = new ioRocket();
|
2011-11-09 23:52:17 +01:00
|
|
|
|
2011-10-26 08:02:47 +02:00
|
|
|
val ctrl = new rocketCtrl();
|
2011-11-02 01:59:27 +01:00
|
|
|
val dpath = new rocketDpath();
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2011-11-10 09:23:29 +01:00
|
|
|
val dtlb = new rocketDTLB(DTLB_ENTRIES);
|
2011-11-09 23:52:17 +01:00
|
|
|
val itlb = new rocketITLB(ITLB_ENTRIES);
|
2012-02-15 08:34:57 +01:00
|
|
|
val vitlb = new rocketITLB(ITLB_ENTRIES);
|
2011-11-09 23:52:17 +01:00
|
|
|
val ptw = new rocketPTW();
|
|
|
|
val arb = new rocketDmemArbiter();
|
|
|
|
|
2011-11-02 01:59:27 +01:00
|
|
|
ctrl.io.dpath <> dpath.io.ctrl;
|
2012-01-23 18:51:35 +01:00
|
|
|
dpath.io.host <> io.host;
|
|
|
|
dpath.io.debug <> io.debug;
|
2011-11-10 09:50:09 +01:00
|
|
|
|
2011-11-15 09:11:22 +01:00
|
|
|
// FIXME: try to make this more compact
|
|
|
|
|
2011-11-10 08:27:29 +01:00
|
|
|
// connect ITLB to I$, ctrl, dpath
|
2011-11-15 09:11:22 +01:00
|
|
|
itlb.io.cpu.invalidate := dpath.io.ptbr_wen;
|
2011-11-09 23:52:17 +01:00
|
|
|
itlb.io.cpu.status := dpath.io.ctrl.status;
|
2011-11-10 08:27:29 +01:00
|
|
|
itlb.io.cpu.req_val := ctrl.io.imem.req_val;
|
2011-11-09 23:52:17 +01:00
|
|
|
itlb.io.cpu.req_asid := Bits(0,ASID_BITS); // FIXME: connect to PCR
|
2012-01-24 09:15:17 +01:00
|
|
|
itlb.io.cpu.req_vpn := dpath.io.imem.req_addr(VADDR_BITS,PGIDX_BITS);
|
2011-11-12 09:25:06 +01:00
|
|
|
io.imem.req_idx := dpath.io.imem.req_addr(PGIDX_BITS-1,0);
|
|
|
|
io.imem.req_ppn := itlb.io.cpu.resp_ppn;
|
|
|
|
io.imem.req_val := ctrl.io.imem.req_val;
|
2012-02-09 10:32:52 +01:00
|
|
|
io.imem.invalidate := ctrl.io.dpath.flush_inst;
|
2011-11-09 23:52:17 +01:00
|
|
|
ctrl.io.imem.resp_val := io.imem.resp_val;
|
2011-11-10 09:50:09 +01:00
|
|
|
dpath.io.imem.resp_data := io.imem.resp_data;
|
|
|
|
ctrl.io.xcpt_itlb := itlb.io.cpu.exception;
|
2011-11-12 09:25:06 +01:00
|
|
|
io.imem.itlb_miss := itlb.io.cpu.resp_miss;
|
2011-11-12 03:48:34 +01:00
|
|
|
|
2011-11-10 09:23:29 +01:00
|
|
|
// connect DTLB to D$ arbiter, ctrl+dpath
|
2011-11-14 13:13:13 +01:00
|
|
|
dtlb.io.cpu.invalidate := dpath.io.ptbr_wen;
|
2011-11-10 09:23:29 +01:00
|
|
|
dtlb.io.cpu.status := dpath.io.ctrl.status;
|
2011-12-10 04:42:58 +01:00
|
|
|
dtlb.io.cpu.req_val := ctrl.io.dtlb_val;
|
2012-01-12 01:56:40 +01:00
|
|
|
dtlb.io.cpu.req_kill := ctrl.io.dtlb_kill;
|
2011-11-10 09:23:29 +01:00
|
|
|
dtlb.io.cpu.req_cmd := ctrl.io.dmem.req_cmd;
|
|
|
|
dtlb.io.cpu.req_asid := Bits(0,ASID_BITS); // FIXME: connect to PCR
|
2012-01-24 09:15:17 +01:00
|
|
|
dtlb.io.cpu.req_vpn := dpath.io.dmem.req_addr(VADDR_BITS,PGIDX_BITS);
|
2011-11-10 09:50:09 +01:00
|
|
|
ctrl.io.xcpt_dtlb_ld := dtlb.io.cpu.xcpt_ld;
|
|
|
|
ctrl.io.xcpt_dtlb_st := dtlb.io.cpu.xcpt_st;
|
2011-12-10 04:42:58 +01:00
|
|
|
ctrl.io.dtlb_rdy := dtlb.io.cpu.req_rdy;
|
2011-11-10 09:50:09 +01:00
|
|
|
ctrl.io.dtlb_miss := dtlb.io.cpu.resp_miss;
|
2011-11-13 09:03:17 +01:00
|
|
|
ctrl.io.xcpt_ma_ld := io.dmem.xcpt_ma_ld;
|
|
|
|
ctrl.io.xcpt_ma_st := io.dmem.xcpt_ma_st;
|
2011-11-10 09:23:29 +01:00
|
|
|
|
2011-11-10 08:27:29 +01:00
|
|
|
// connect page table walker to TLBs, page table base register (from PCR)
|
|
|
|
// and D$ arbiter (selects between requests from pipeline and PTW, PTW has priority)
|
2011-11-10 09:23:29 +01:00
|
|
|
ptw.io.dtlb <> dtlb.io.ptw;
|
2011-11-09 23:52:17 +01:00
|
|
|
ptw.io.itlb <> itlb.io.ptw;
|
|
|
|
ptw.io.ptbr := dpath.io.ptbr;
|
|
|
|
arb.io.ptw <> ptw.io.dmem;
|
2012-01-23 18:51:35 +01:00
|
|
|
arb.io.mem <> io.dmem
|
2011-11-09 23:52:17 +01:00
|
|
|
|
2011-11-10 09:50:09 +01:00
|
|
|
// connect arbiter to ctrl+dpath+DTLB
|
2011-11-12 03:18:47 +01:00
|
|
|
arb.io.cpu.req_val := ctrl.io.dmem.req_val;
|
2011-11-09 23:52:17 +01:00
|
|
|
arb.io.cpu.req_cmd := ctrl.io.dmem.req_cmd;
|
|
|
|
arb.io.cpu.req_type := ctrl.io.dmem.req_type;
|
2011-12-12 15:49:16 +01:00
|
|
|
arb.io.cpu.req_kill := ctrl.io.dmem.req_kill;
|
2011-11-12 03:18:47 +01:00
|
|
|
arb.io.cpu.req_idx := dpath.io.dmem.req_addr(PGIDX_BITS-1,0);
|
|
|
|
arb.io.cpu.req_ppn := dtlb.io.cpu.resp_ppn;
|
2011-11-09 23:52:17 +01:00
|
|
|
arb.io.cpu.req_data := dpath.io.dmem.req_data;
|
|
|
|
arb.io.cpu.req_tag := dpath.io.dmem.req_tag;
|
2011-11-10 09:23:29 +01:00
|
|
|
ctrl.io.dmem.req_rdy := dtlb.io.cpu.req_rdy && arb.io.cpu.req_rdy;
|
2011-11-09 23:52:17 +01:00
|
|
|
ctrl.io.dmem.resp_miss := arb.io.cpu.resp_miss;
|
2012-01-02 11:51:30 +01:00
|
|
|
ctrl.io.dmem.resp_replay:= arb.io.cpu.resp_replay;
|
2011-12-10 09:42:09 +01:00
|
|
|
ctrl.io.dmem.resp_nack := arb.io.cpu.resp_nack;
|
2011-11-09 23:52:17 +01:00
|
|
|
dpath.io.dmem.resp_val := arb.io.cpu.resp_val;
|
2012-01-02 11:51:30 +01:00
|
|
|
dpath.io.dmem.resp_miss := arb.io.cpu.resp_miss;
|
|
|
|
dpath.io.dmem.resp_replay := arb.io.cpu.resp_replay;
|
2012-02-13 08:31:50 +01:00
|
|
|
dpath.io.dmem.resp_type := io.dmem.resp_type;
|
2011-11-09 23:52:17 +01:00
|
|
|
dpath.io.dmem.resp_tag := arb.io.cpu.resp_tag;
|
2011-11-10 09:23:29 +01:00
|
|
|
dpath.io.dmem.resp_data := arb.io.cpu.resp_data;
|
2011-12-12 15:49:16 +01:00
|
|
|
dpath.io.dmem.resp_data_subword := io.dmem.resp_data_subword;
|
2011-11-10 09:23:29 +01:00
|
|
|
|
2012-02-08 08:54:25 +01:00
|
|
|
if (HAVE_FPU)
|
|
|
|
{
|
2012-02-14 09:32:25 +01:00
|
|
|
val fpu = new rocketFPU(4,6)
|
2012-02-08 08:54:25 +01:00
|
|
|
dpath.io.fpu <> fpu.io.dpath
|
2012-02-12 13:36:01 +01:00
|
|
|
ctrl.io.fpu <> fpu.io.ctrl
|
2012-02-08 08:54:25 +01:00
|
|
|
}
|
2012-02-13 05:12:53 +01:00
|
|
|
else
|
|
|
|
ctrl.io.fpu.dec.valid := Bool(false)
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2012-02-09 07:30:45 +01:00
|
|
|
ctrl.io.ext_mem.req_val := Bool(false)
|
|
|
|
dpath.io.ext_mem.req_val := Bool(false)
|
|
|
|
|
2012-02-09 06:43:45 +01:00
|
|
|
if (HAVE_VEC)
|
|
|
|
{
|
2012-02-15 22:30:22 +01:00
|
|
|
dpath.io.vec_ctrl <> ctrl.io.vec_dpath
|
|
|
|
|
2012-02-09 06:43:45 +01:00
|
|
|
val vu = new vu()
|
|
|
|
|
2012-02-15 22:30:22 +01:00
|
|
|
// hooking up vector I$
|
2012-02-15 08:34:57 +01:00
|
|
|
vitlb.io.cpu.invalidate := dpath.io.ptbr_wen
|
|
|
|
vitlb.io.cpu.status := dpath.io.ctrl.status
|
|
|
|
vitlb.io.cpu.req_val := vu.io.imem_req.valid
|
|
|
|
vitlb.io.cpu.req_asid := Bits(0,ASID_BITS) // FIXME: connect to PCR
|
|
|
|
vitlb.io.cpu.req_vpn := vu.io.imem_req.bits(VADDR_BITS,PGIDX_BITS).toUFix
|
|
|
|
io.vimem.req_idx := vu.io.imem_req.bits(PGIDX_BITS-1,0)
|
|
|
|
io.vimem.req_ppn := vitlb.io.cpu.resp_ppn
|
|
|
|
io.vimem.req_val := vu.io.imem_req.valid
|
|
|
|
io.vimem.invalidate := ctrl.io.dpath.flush_inst
|
2012-02-15 11:28:07 +01:00
|
|
|
vu.io.imem_req.ready := Bool(true)
|
2012-02-15 08:34:57 +01:00
|
|
|
vu.io.imem_resp.valid := io.vimem.resp_val
|
|
|
|
vu.io.imem_resp.bits := io.vimem.resp_data
|
|
|
|
// handle vitlb.io.cpu.exception
|
|
|
|
io.vimem.itlb_miss := vitlb.io.cpu.resp_miss
|
|
|
|
|
2012-02-15 22:30:22 +01:00
|
|
|
// hooking up vector command queues
|
|
|
|
vu.io.vec_cmdq.valid := ctrl.io.vec_iface.vcmdq_valid
|
|
|
|
vu.io.vec_cmdq.bits := dpath.io.vec_iface.vcmdq_bits
|
|
|
|
vu.io.vec_ximm1q.valid := ctrl.io.vec_iface.vximm1q_valid
|
|
|
|
vu.io.vec_ximm1q.bits := dpath.io.vec_iface.vximm1q_bits
|
|
|
|
vu.io.vec_ximm2q.valid := ctrl.io.vec_iface.vximm2q_valid
|
|
|
|
vu.io.vec_ximm2q.bits := dpath.io.vec_iface.vximm2q_bits
|
|
|
|
|
|
|
|
ctrl.io.vec_iface.vcmdq_ready := vu.io.vec_cmdq.ready
|
|
|
|
ctrl.io.vec_iface.vximm1q_ready := vu.io.vec_ximm1q.ready
|
|
|
|
ctrl.io.vec_iface.vximm2q_ready := vu.io.vec_ximm2q.ready
|
2012-02-16 02:53:24 +01:00
|
|
|
ctrl.io.vec_iface.vackq_valid := vu.io.vec_ackq.valid
|
|
|
|
vu.io.vec_ackq.ready := ctrl.io.vec_iface.vackq_ready
|
2012-02-15 08:34:57 +01:00
|
|
|
|
2012-02-15 22:30:22 +01:00
|
|
|
// hooking up vector memory interface
|
2012-02-15 08:34:57 +01:00
|
|
|
ctrl.io.ext_mem.req_val := vu.io.dmem_req.valid
|
|
|
|
ctrl.io.ext_mem.req_cmd := vu.io.dmem_req.bits.cmd
|
|
|
|
ctrl.io.ext_mem.req_type := vu.io.dmem_req.bits.typ
|
|
|
|
|
|
|
|
dpath.io.ext_mem.req_val := vu.io.dmem_req.valid
|
|
|
|
dpath.io.ext_mem.req_idx := vu.io.dmem_req.bits.idx
|
|
|
|
dpath.io.ext_mem.req_ppn := vu.io.dmem_req.bits.ppn
|
|
|
|
dpath.io.ext_mem.req_data := vu.io.dmem_req.bits.data
|
2012-02-15 11:28:07 +01:00
|
|
|
dpath.io.ext_mem.req_tag := vu.io.dmem_req.bits.tag
|
2012-02-15 08:34:57 +01:00
|
|
|
|
|
|
|
vu.io.dmem_resp.valid := dpath.io.ext_mem.resp_val
|
|
|
|
vu.io.dmem_resp.bits.nack := ctrl.io.ext_mem.resp_nack
|
|
|
|
vu.io.dmem_resp.bits.data := dpath.io.ext_mem.resp_data
|
|
|
|
vu.io.dmem_resp.bits.tag := dpath.io.ext_mem.resp_tag
|
2012-02-22 03:20:32 +01:00
|
|
|
vu.io.dmem_resp.bits.typ := dpath.io.ext_mem.resp_type
|
2012-02-09 06:43:45 +01:00
|
|
|
}
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|