2016-11-28 01:16:37 +01:00
|
|
|
// See LICENSE.Berkeley for license details.
|
|
|
|
// See LICENSE.SiFive for license details.
|
2014-09-13 03:06:41 +02:00
|
|
|
|
2017-02-09 22:59:09 +01:00
|
|
|
package tile
|
2013-09-13 07:34:38 +02:00
|
|
|
|
|
|
|
import Chisel._
|
2016-11-18 23:05:14 +01:00
|
|
|
import config._
|
2017-01-17 03:24:08 +01:00
|
|
|
import coreplex._
|
|
|
|
import diplomacy._
|
2017-02-09 22:59:09 +01:00
|
|
|
import rocket._
|
2017-01-17 03:24:08 +01:00
|
|
|
import uncore.tilelink2._
|
2013-09-13 07:34:38 +02:00
|
|
|
|
2016-02-25 07:39:00 +01:00
|
|
|
case object RoccNPTWPorts extends Field[Int]
|
2017-02-09 22:59:09 +01:00
|
|
|
case object BuildRoCC extends Field[Seq[RoCCParams]]
|
2017-01-17 03:24:08 +01:00
|
|
|
|
2017-02-09 22:59:09 +01:00
|
|
|
case class RoCCParams(
|
2017-01-17 03:24:08 +01:00
|
|
|
opcodes: OpcodeSet,
|
2017-06-22 21:07:09 +02:00
|
|
|
generator: Parameters => LazyRoCC,
|
2017-01-17 03:24:08 +01:00
|
|
|
nPTWPorts : Int = 0,
|
|
|
|
useFPU: Boolean = false)
|
2015-03-13 00:27:40 +01:00
|
|
|
|
2013-09-15 00:31:50 +02:00
|
|
|
class RoCCInstruction extends Bundle
|
|
|
|
{
|
|
|
|
val funct = Bits(width = 7)
|
2013-09-22 12:18:06 +02:00
|
|
|
val rs2 = Bits(width = 5)
|
|
|
|
val rs1 = Bits(width = 5)
|
2013-09-15 00:31:50 +02:00
|
|
|
val xd = Bool()
|
|
|
|
val xs1 = Bool()
|
|
|
|
val xs2 = Bool()
|
2013-09-22 12:18:06 +02:00
|
|
|
val rd = Bits(width = 5)
|
2013-09-15 00:31:50 +02:00
|
|
|
val opcode = Bits(width = 7)
|
|
|
|
}
|
|
|
|
|
2015-10-06 06:48:05 +02:00
|
|
|
class RoCCCommand(implicit p: Parameters) extends CoreBundle()(p) {
|
2013-09-15 00:31:50 +02:00
|
|
|
val inst = new RoCCInstruction
|
2015-02-02 05:04:13 +01:00
|
|
|
val rs1 = Bits(width = xLen)
|
|
|
|
val rs2 = Bits(width = xLen)
|
2016-07-19 02:40:50 +02:00
|
|
|
val status = new MStatus
|
2013-09-15 00:31:50 +02:00
|
|
|
}
|
|
|
|
|
2015-10-06 06:48:05 +02:00
|
|
|
class RoCCResponse(implicit p: Parameters) extends CoreBundle()(p) {
|
2013-09-15 00:31:50 +02:00
|
|
|
val rd = Bits(width = 5)
|
2015-02-02 05:04:13 +01:00
|
|
|
val data = Bits(width = xLen)
|
2013-09-15 00:31:50 +02:00
|
|
|
}
|
|
|
|
|
2017-01-17 03:24:08 +01:00
|
|
|
class RoCCCoreIO(implicit p: Parameters) extends CoreBundle()(p) {
|
2013-09-15 00:31:50 +02:00
|
|
|
val cmd = Decoupled(new RoCCCommand).flip
|
|
|
|
val resp = Decoupled(new RoCCResponse)
|
2016-11-30 03:49:40 +01:00
|
|
|
val mem = new HellaCacheIO
|
2014-01-29 07:13:16 +01:00
|
|
|
val busy = Bool(OUTPUT)
|
|
|
|
val interrupt = Bool(OUTPUT)
|
2017-01-17 03:24:08 +01:00
|
|
|
val exception = Bool(INPUT)
|
2016-11-30 03:49:40 +01:00
|
|
|
|
2017-01-17 03:24:08 +01:00
|
|
|
override def cloneType = new RoCCCoreIO()(p).asInstanceOf[this.type]
|
|
|
|
}
|
|
|
|
|
2017-06-22 21:07:09 +02:00
|
|
|
/** Base classes for Diplomatic TL2 RoCC units **/
|
|
|
|
abstract class LazyRoCC(implicit p: Parameters) extends LazyModule {
|
|
|
|
val module: LazyRoCCModule
|
|
|
|
|
|
|
|
val atlNode: TLMixedNode = TLOutputNode()
|
|
|
|
val tlNode: TLMixedNode = TLOutputNode()
|
|
|
|
}
|
|
|
|
|
|
|
|
class RoCCIO(outer: LazyRoCC)(implicit p: Parameters) extends RoCCCoreIO()(p) {
|
|
|
|
val atl = outer.atlNode.bundleOut
|
|
|
|
val tl = outer.tlNode.bundleOut
|
|
|
|
// Should be handled differently, eventually
|
2016-02-25 07:39:00 +01:00
|
|
|
val ptw = Vec(p(RoccNPTWPorts), new TLBPTWIO)
|
2015-04-02 10:30:11 +02:00
|
|
|
val fpu_req = Decoupled(new FPInput)
|
|
|
|
val fpu_resp = Decoupled(new FPResult).flip
|
2017-06-22 21:07:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class LazyRoCCModule(outer: LazyRoCC) extends LazyModuleImp(outer) {
|
|
|
|
val io = new RoCCIO(outer)
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Mixins for including RoCC **/
|
|
|
|
|
|
|
|
trait HasLazyRoCC extends CanHaveSharedFPU with CanHavePTW with HasTileLinkMasterPort {
|
|
|
|
implicit val p: Parameters
|
|
|
|
val module: HasLazyRoCCModule
|
|
|
|
|
|
|
|
val roccs = p(BuildRoCC).zipWithIndex.map { case (accelParams, i) =>
|
|
|
|
accelParams.generator(p.alterPartial({
|
|
|
|
case RoccNPTWPorts => accelParams.nPTWPorts
|
|
|
|
}))}
|
|
|
|
|
|
|
|
roccs.map(_.atlNode).foreach { atl => tileBus.node :=* atl }
|
|
|
|
roccs.map(_.tlNode).foreach { tl => masterNode :=* tl }
|
|
|
|
|
|
|
|
nPTWPorts += p(BuildRoCC).map(_.nPTWPorts).foldLeft(0)(_ + _)
|
|
|
|
nDCachePorts += roccs.size
|
|
|
|
}
|
2016-01-13 00:36:16 +01:00
|
|
|
|
2017-06-22 21:07:09 +02:00
|
|
|
trait HasLazyRoCCModule extends CanHaveSharedFPUModule
|
|
|
|
with CanHavePTWModule
|
|
|
|
with HasCoreParameters
|
|
|
|
with HasTileLinkMasterPortModule {
|
|
|
|
val outer: HasLazyRoCC
|
|
|
|
val roccCore = Wire(new RoCCCoreIO()(outer.p))
|
|
|
|
|
|
|
|
val buildRocc = outer.p(BuildRoCC)
|
|
|
|
val usingRocc = !buildRocc.isEmpty
|
|
|
|
val nRocc = buildRocc.size
|
|
|
|
val nFPUPorts = buildRocc.filter(_.useFPU).size
|
|
|
|
val roccOpcodes = buildRocc.map(_.opcodes)
|
|
|
|
|
|
|
|
if(usingRocc) {
|
|
|
|
val respArb = Module(new RRArbiter(new RoCCResponse()(outer.p), nRocc))
|
|
|
|
roccCore.resp <> respArb.io.out
|
|
|
|
val cmdRouter = Module(new RoccCommandRouter(roccOpcodes)(outer.p))
|
|
|
|
cmdRouter.io.in <> roccCore.cmd
|
|
|
|
|
|
|
|
outer.roccs.zipWithIndex.foreach { case (rocc, i) =>
|
|
|
|
ptwPorts ++= rocc.module.io.ptw
|
|
|
|
rocc.module.io.cmd <> cmdRouter.io.out(i)
|
|
|
|
rocc.module.io.exception := roccCore.exception
|
|
|
|
val dcIF = Module(new SimpleHellaCacheIF()(outer.p))
|
|
|
|
dcIF.io.requestor <> rocc.module.io.mem
|
|
|
|
dcachePorts += dcIF.io.cache
|
|
|
|
respArb.io.in(i) <> Queue(rocc.module.io.resp)
|
|
|
|
}
|
|
|
|
roccCore.busy := cmdRouter.io.busy || outer.roccs.map(_.module.io.busy).reduce(_ || _)
|
|
|
|
roccCore.interrupt := outer.roccs.map(_.module.io.interrupt).reduce(_ || _)
|
|
|
|
|
|
|
|
fpuOpt foreach { fpu =>
|
|
|
|
if (usingFPU && nFPUPorts > 0) {
|
|
|
|
val fpArb = Module(new InOrderArbiter(new FPInput()(outer.p), new FPResult()(outer.p), nFPUPorts))
|
|
|
|
val fp_rocc_ios = outer.roccs.zip(buildRocc)
|
|
|
|
.filter { case (_, params) => params.useFPU }
|
|
|
|
.map { case (rocc, _) => rocc.module.io }
|
|
|
|
fpArb.io.in_req <> fp_rocc_ios.map(_.fpu_req)
|
|
|
|
fp_rocc_ios.zip(fpArb.io.in_resp).foreach {
|
|
|
|
case (rocc, arb) => rocc.fpu_resp <> arb
|
|
|
|
}
|
|
|
|
fpu.io.cp_req <> fpArb.io.out_req
|
|
|
|
fpArb.io.out_resp <> fpu.io.cp_resp
|
|
|
|
} else {
|
|
|
|
fpu.io.cp_req.valid := Bool(false)
|
|
|
|
fpu.io.cp_resp.ready := Bool(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-15 00:31:50 +02:00
|
|
|
}
|
|
|
|
|
2017-06-22 21:07:09 +02:00
|
|
|
class AccumulatorExample(implicit p: Parameters) extends LazyRoCC {
|
|
|
|
override lazy val module = new AccumulatorExampleModule(this)
|
2013-09-15 00:31:50 +02:00
|
|
|
}
|
|
|
|
|
2017-06-22 21:07:09 +02:00
|
|
|
class AccumulatorExampleModule(outer: AccumulatorExample, n: Int = 4)(implicit p: Parameters) extends LazyRoCCModule(outer)
|
|
|
|
with HasCoreParameters {
|
2015-11-25 23:04:28 +01:00
|
|
|
val regfile = Mem(n, UInt(width = xLen))
|
|
|
|
val busy = Reg(init = Vec.fill(n){Bool(false)})
|
2013-09-15 00:31:50 +02:00
|
|
|
|
2013-09-15 07:34:53 +02:00
|
|
|
val cmd = Queue(io.cmd)
|
|
|
|
val funct = cmd.bits.inst.funct
|
2015-11-25 23:04:28 +01:00
|
|
|
val addr = cmd.bits.rs2(log2Up(n)-1,0)
|
2013-09-15 07:34:53 +02:00
|
|
|
val doWrite = funct === UInt(0)
|
|
|
|
val doRead = funct === UInt(1)
|
|
|
|
val doLoad = funct === UInt(2)
|
|
|
|
val doAccum = funct === UInt(3)
|
|
|
|
val memRespTag = io.mem.resp.bits.tag(log2Up(n)-1,0)
|
|
|
|
|
|
|
|
// datapath
|
|
|
|
val addend = cmd.bits.rs1
|
2013-09-15 00:31:50 +02:00
|
|
|
val accum = regfile(addr)
|
2013-09-15 07:34:53 +02:00
|
|
|
val wdata = Mux(doWrite, addend, accum + addend)
|
2013-09-15 00:31:50 +02:00
|
|
|
|
2013-09-15 07:34:53 +02:00
|
|
|
when (cmd.fire() && (doWrite || doAccum)) {
|
2013-09-15 00:31:50 +02:00
|
|
|
regfile(addr) := wdata
|
|
|
|
}
|
|
|
|
|
2013-09-15 07:34:53 +02:00
|
|
|
when (io.mem.resp.valid) {
|
|
|
|
regfile(memRespTag) := io.mem.resp.bits.data
|
2016-08-04 20:17:13 +02:00
|
|
|
busy(memRespTag) := Bool(false)
|
2013-09-15 07:34:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// control
|
|
|
|
when (io.mem.req.fire()) {
|
|
|
|
busy(addr) := Bool(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
val doResp = cmd.bits.inst.xd
|
|
|
|
val stallReg = busy(addr)
|
|
|
|
val stallLoad = doLoad && !io.mem.req.ready
|
|
|
|
val stallResp = doResp && !io.resp.ready
|
|
|
|
|
2013-09-24 19:54:09 +02:00
|
|
|
cmd.ready := !stallReg && !stallLoad && !stallResp
|
2013-09-23 09:21:43 +02:00
|
|
|
// command resolved if no stalls AND not issuing a load that will need a request
|
|
|
|
|
2013-09-25 01:32:49 +02:00
|
|
|
// PROC RESPONSE INTERFACE
|
2013-09-24 19:54:09 +02:00
|
|
|
io.resp.valid := cmd.valid && doResp && !stallReg && !stallLoad
|
|
|
|
// valid response if valid command, need a response, and no stalls
|
2013-09-15 07:34:53 +02:00
|
|
|
io.resp.bits.rd := cmd.bits.inst.rd
|
2013-09-25 01:32:49 +02:00
|
|
|
// Must respond with the appropriate tag or undefined behavior
|
|
|
|
io.resp.bits.data := accum
|
|
|
|
// Semantics is to always send out prior accumulator register value
|
2013-09-15 07:34:53 +02:00
|
|
|
|
2013-09-25 01:32:49 +02:00
|
|
|
io.busy := cmd.valid || busy.reduce(_||_)
|
|
|
|
// Be busy when have pending memory requests or committed possibility of pending requests
|
2013-09-15 00:31:50 +02:00
|
|
|
io.interrupt := Bool(false)
|
2013-09-25 01:32:49 +02:00
|
|
|
// Set this true to trigger an interrupt on the processor (please refer to supervisor documentation)
|
2013-09-15 07:34:53 +02:00
|
|
|
|
2013-09-25 01:32:49 +02:00
|
|
|
// MEMORY REQUEST INTERFACE
|
2013-09-24 19:54:09 +02:00
|
|
|
io.mem.req.valid := cmd.valid && doLoad && !stallReg && !stallResp
|
2013-09-15 07:34:53 +02:00
|
|
|
io.mem.req.bits.addr := addend
|
2013-09-24 19:54:09 +02:00
|
|
|
io.mem.req.bits.tag := addr
|
2017-06-22 21:07:09 +02:00
|
|
|
io.mem.req.bits.cmd := uncore.constants.M_XRD // perform a load (M_XWR for stores)
|
2013-09-15 07:34:53 +02:00
|
|
|
io.mem.req.bits.typ := MT_D // D = 8 bytes, W = 4, H = 2, B = 1
|
|
|
|
io.mem.req.bits.data := Bits(0) // we're not performing any stores...
|
2017-06-22 21:07:09 +02:00
|
|
|
io.mem.req.bits.phys := Bool(false)
|
|
|
|
io.mem.invalidate_lr := Bool(false)
|
|
|
|
}
|
2014-05-15 01:17:39 +02:00
|
|
|
|
2017-06-22 21:07:09 +02:00
|
|
|
class TranslatorExample(implicit p: Parameters) extends LazyRoCC {
|
|
|
|
override lazy val module = new TranslatorExampleModule(this)
|
2013-09-15 00:31:50 +02:00
|
|
|
}
|
2015-11-26 01:02:27 +01:00
|
|
|
|
2017-06-22 21:07:09 +02:00
|
|
|
class TranslatorExampleModule(outer: TranslatorExample)(implicit p: Parameters) extends LazyRoCCModule(outer)
|
|
|
|
with HasCoreParameters {
|
2015-11-26 01:02:27 +01:00
|
|
|
val req_addr = Reg(UInt(width = coreMaxAddrBits))
|
|
|
|
val req_rd = Reg(io.resp.bits.rd)
|
|
|
|
val req_offset = req_addr(pgIdxBits - 1, 0)
|
|
|
|
val req_vpn = req_addr(coreMaxAddrBits - 1, pgIdxBits)
|
2016-03-03 08:29:58 +01:00
|
|
|
val pte = Reg(new PTE)
|
2015-11-26 01:02:27 +01:00
|
|
|
|
|
|
|
val s_idle :: s_ptw_req :: s_ptw_resp :: s_resp :: Nil = Enum(Bits(), 4)
|
|
|
|
val state = Reg(init = s_idle)
|
|
|
|
|
|
|
|
io.cmd.ready := (state === s_idle)
|
|
|
|
|
|
|
|
when (io.cmd.fire()) {
|
|
|
|
req_rd := io.cmd.bits.inst.rd
|
|
|
|
req_addr := io.cmd.bits.rs1
|
|
|
|
state := s_ptw_req
|
|
|
|
}
|
|
|
|
|
2016-02-25 07:39:00 +01:00
|
|
|
private val ptw = io.ptw(0)
|
2015-11-26 01:02:27 +01:00
|
|
|
|
2016-02-25 07:39:00 +01:00
|
|
|
when (ptw.req.fire()) { state := s_ptw_resp }
|
|
|
|
|
|
|
|
when (state === s_ptw_resp && ptw.resp.valid) {
|
2016-03-03 08:29:58 +01:00
|
|
|
pte := ptw.resp.bits.pte
|
2015-11-26 01:02:27 +01:00
|
|
|
state := s_resp
|
|
|
|
}
|
|
|
|
|
|
|
|
when (io.resp.fire()) { state := s_idle }
|
|
|
|
|
2016-02-25 07:39:00 +01:00
|
|
|
ptw.req.valid := (state === s_ptw_req)
|
|
|
|
ptw.req.bits.addr := req_vpn
|
2015-11-26 01:02:27 +01:00
|
|
|
|
|
|
|
io.resp.valid := (state === s_resp)
|
|
|
|
io.resp.bits.rd := req_rd
|
2016-08-04 20:17:13 +02:00
|
|
|
io.resp.bits.data := Mux(pte.leaf(), Cat(pte.ppn, req_offset), SInt(-1, xLen).asUInt)
|
2015-11-26 01:02:27 +01:00
|
|
|
|
|
|
|
io.busy := (state =/= s_idle)
|
|
|
|
io.interrupt := Bool(false)
|
|
|
|
io.mem.req.valid := Bool(false)
|
|
|
|
}
|
|
|
|
|
2017-06-22 21:07:09 +02:00
|
|
|
class CharacterCountExample(implicit p: Parameters) extends LazyRoCC {
|
|
|
|
override lazy val module = new CharacterCountExampleModule(this)
|
|
|
|
override val atlNode = TLClientNode(TLClientParameters("CharacterCountRoCC"))
|
|
|
|
}
|
|
|
|
|
|
|
|
class CharacterCountExampleModule(outer: CharacterCountExample)(implicit p: Parameters) extends LazyRoCCModule(outer)
|
|
|
|
with HasCoreParameters
|
|
|
|
with HasL1CacheParameters {
|
|
|
|
val cacheParams = tileParams.icache.get
|
2015-11-26 01:02:27 +01:00
|
|
|
|
2017-06-22 21:07:09 +02:00
|
|
|
private val blockOffset = blockOffBits
|
|
|
|
private val beatOffset = log2Up(cacheDataBits/8)
|
2015-11-26 01:02:27 +01:00
|
|
|
|
|
|
|
val needle = Reg(UInt(width = 8))
|
|
|
|
val addr = Reg(UInt(width = coreMaxAddrBits))
|
|
|
|
val count = Reg(UInt(width = xLen))
|
|
|
|
val resp_rd = Reg(io.resp.bits.rd)
|
|
|
|
|
|
|
|
val addr_block = addr(coreMaxAddrBits - 1, blockOffset)
|
|
|
|
val offset = addr(blockOffset - 1, 0)
|
|
|
|
val next_addr = (addr_block + UInt(1)) << UInt(blockOffset)
|
|
|
|
|
|
|
|
val s_idle :: s_acq :: s_gnt :: s_check :: s_resp :: Nil = Enum(Bits(), 5)
|
|
|
|
val state = Reg(init = s_idle)
|
|
|
|
|
2017-06-22 21:07:09 +02:00
|
|
|
val tl_out = io.atl.head
|
|
|
|
val gnt = tl_out.d.bits
|
|
|
|
val recv_data = Reg(UInt(width = cacheDataBits))
|
|
|
|
val recv_beat = Reg(UInt(width = log2Up(cacheDataBeats+1)), init = UInt(0))
|
2015-11-26 01:02:27 +01:00
|
|
|
|
2017-06-22 21:07:09 +02:00
|
|
|
val data_bytes = Vec.tabulate(cacheDataBits/8) { i => recv_data(8 * (i + 1) - 1, 8 * i) }
|
2015-11-26 01:02:27 +01:00
|
|
|
val zero_match = data_bytes.map(_ === UInt(0))
|
|
|
|
val needle_match = data_bytes.map(_ === needle)
|
|
|
|
val first_zero = PriorityEncoder(zero_match)
|
|
|
|
|
|
|
|
val chars_found = PopCount(needle_match.zipWithIndex.map {
|
|
|
|
case (matches, i) =>
|
2017-06-22 21:07:09 +02:00
|
|
|
val idx = Cat(recv_beat - UInt(1), UInt(i, beatOffset))
|
2015-11-26 01:02:27 +01:00
|
|
|
matches && idx >= offset && UInt(i) <= first_zero
|
|
|
|
})
|
|
|
|
val zero_found = zero_match.reduce(_ || _)
|
|
|
|
val finished = Reg(Bool())
|
|
|
|
|
|
|
|
io.cmd.ready := (state === s_idle)
|
|
|
|
io.resp.valid := (state === s_resp)
|
|
|
|
io.resp.bits.rd := resp_rd
|
|
|
|
io.resp.bits.data := count
|
2017-06-22 21:07:09 +02:00
|
|
|
tl_out.a.valid := (state === s_acq)
|
|
|
|
tl_out.a.bits := outer.atlNode.edgesOut(0).Get(
|
|
|
|
fromSource = UInt(0),
|
|
|
|
toAddress = addr_block << blockOffset,
|
|
|
|
lgSize = UInt(lgCacheBlockBytes))._2
|
|
|
|
tl_out.d.ready := (state === s_gnt)
|
2015-11-26 01:02:27 +01:00
|
|
|
|
|
|
|
when (io.cmd.fire()) {
|
|
|
|
addr := io.cmd.bits.rs1
|
|
|
|
needle := io.cmd.bits.rs2
|
|
|
|
resp_rd := io.cmd.bits.inst.rd
|
|
|
|
count := UInt(0)
|
|
|
|
finished := Bool(false)
|
|
|
|
state := s_acq
|
|
|
|
}
|
|
|
|
|
2017-06-22 21:07:09 +02:00
|
|
|
when (tl_out.a.fire()) { state := s_gnt }
|
2015-11-26 01:02:27 +01:00
|
|
|
|
2017-06-22 21:07:09 +02:00
|
|
|
when (tl_out.d.fire()) {
|
|
|
|
recv_beat := recv_beat + UInt(1)
|
2015-11-26 01:02:27 +01:00
|
|
|
recv_data := gnt.data
|
|
|
|
state := s_check
|
|
|
|
}
|
|
|
|
|
|
|
|
when (state === s_check) {
|
|
|
|
when (!finished) {
|
|
|
|
count := count + chars_found
|
|
|
|
}
|
|
|
|
when (zero_found) { finished := Bool(true) }
|
2017-06-22 21:07:09 +02:00
|
|
|
when (recv_beat === UInt(cacheDataBeats)) {
|
2015-11-26 01:02:27 +01:00
|
|
|
addr := next_addr
|
|
|
|
state := Mux(zero_found || finished, s_resp, s_acq)
|
|
|
|
} .otherwise {
|
|
|
|
state := s_gnt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
when (io.resp.fire()) { state := s_idle }
|
|
|
|
|
|
|
|
io.busy := (state =/= s_idle)
|
|
|
|
io.interrupt := Bool(false)
|
|
|
|
io.mem.req.valid := Bool(false)
|
2017-06-22 21:07:09 +02:00
|
|
|
// Tie off unused channels
|
|
|
|
tl_out.b.ready := Bool(true)
|
|
|
|
tl_out.c.valid := Bool(false)
|
|
|
|
tl_out.e.valid := Bool(false)
|
2015-11-26 01:02:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
class OpcodeSet(val opcodes: Seq[UInt]) {
|
|
|
|
def |(set: OpcodeSet) =
|
|
|
|
new OpcodeSet(this.opcodes ++ set.opcodes)
|
|
|
|
|
|
|
|
def matches(oc: UInt) = opcodes.map(_ === oc).reduce(_ || _)
|
|
|
|
}
|
|
|
|
|
|
|
|
object OpcodeSet {
|
2017-01-31 22:54:02 +01:00
|
|
|
def custom0 = new OpcodeSet(Seq(Bits("b0001011")))
|
|
|
|
def custom1 = new OpcodeSet(Seq(Bits("b0101011")))
|
|
|
|
def custom2 = new OpcodeSet(Seq(Bits("b1011011")))
|
|
|
|
def custom3 = new OpcodeSet(Seq(Bits("b1111011")))
|
|
|
|
def all = custom0 | custom1 | custom2 | custom3
|
2015-11-26 01:02:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
class RoccCommandRouter(opcodes: Seq[OpcodeSet])(implicit p: Parameters)
|
|
|
|
extends CoreModule()(p) {
|
|
|
|
val io = new Bundle {
|
|
|
|
val in = Decoupled(new RoCCCommand).flip
|
|
|
|
val out = Vec(opcodes.size, Decoupled(new RoCCCommand))
|
|
|
|
val busy = Bool(OUTPUT)
|
|
|
|
}
|
|
|
|
|
|
|
|
val cmd = Queue(io.in)
|
|
|
|
val cmdReadys = io.out.zip(opcodes).map { case (out, opcode) =>
|
|
|
|
val me = opcode.matches(cmd.bits.inst.opcode)
|
|
|
|
out.valid := cmd.valid && me
|
|
|
|
out.bits := cmd.bits
|
|
|
|
out.ready && me
|
|
|
|
}
|
|
|
|
cmd.ready := cmdReadys.reduce(_ || _)
|
|
|
|
io.busy := cmd.valid
|
|
|
|
|
|
|
|
assert(PopCount(cmdReadys) <= UInt(1),
|
|
|
|
"Custom opcode matched for more than one accelerator")
|
|
|
|
}
|