From 7096c63d508a8379d41c328dbdf857e7c1fdb86b Mon Sep 17 00:00:00 2001 From: Dolu1990 Date: Tue, 23 Oct 2018 17:46:31 +0200 Subject: [PATCH] Add more SimpleBus utilies --- .../scala/vexriscv/demo/MuraxUtiles.scala | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/main/scala/vexriscv/demo/MuraxUtiles.scala b/src/main/scala/vexriscv/demo/MuraxUtiles.scala index 213dc70..2827d85 100644 --- a/src/main/scala/vexriscv/demo/MuraxUtiles.scala +++ b/src/main/scala/vexriscv/demo/MuraxUtiles.scala @@ -34,9 +34,40 @@ case class SimpleBus(config : SimpleBusConfig) extends Bundle with IMasterSlave slave(rsp) } - def resizableAddress() : this.type = { - cmd.address.addTag(tagAutoResize) - this + def <<(m : SimpleBus) : Unit = { + val s = this + assert(m.config.addressWidth >= s.config.addressWidth) + assert(m.config.dataWidth == s.config.dataWidth) + s.cmd.valid := m.cmd.valid + s.cmd.wr := m.cmd.wr + s.cmd.address := m.cmd.address.resized + s.cmd.data := m.cmd.data + s.cmd.mask := m.cmd.mask + m.cmd.ready := s.cmd.ready + m.rsp.valid := s.rsp.valid + m.rsp.data := s.rsp.data + } + def >>(s : SimpleBus) : Unit = s << this + + def cmdM2sPipe(): SimpleBus = { + val ret = cloneOf(this) + this.cmd.m2sPipe() >> ret.cmd + this.rsp << ret.rsp + ret + } + + def cmdS2mPipe(): SimpleBus = { + val ret = cloneOf(this) + this.cmd.s2mPipe() >> ret.cmd + this.rsp << ret.rsp + ret + } + + def rspPipe(): SimpleBus = { + val ret = cloneOf(this) + this.cmd >> ret.cmd + this.rsp << ret.rsp.stage() + ret } }