chipyard icon indicating copy to clipboard operation
chipyard copied to clipboard

Diplomacy error while implementing TLRegisterRouter

Open crystalbreezy1 opened this issue 5 years ago • 2 comments

Currently I'm trying to design a MMIO DMA device, and while compiling the code, I have seen the following error:

[warn] there were 10 feature warnings; re-run with -feature for details [warn] one warning found [info] running chipyard.Generator --target-dir /home/caoyue/yuecao/chipyard_test/chipyard/sims/verilator/generated-src/chipyard.TestHarness.ScratchpadOnlyDMARocketConfig --name chipyard.TestHarness.ScratchpadOnlyDMARocketConfig --top-module chipyard.TestHarness --legacy-configs chipyard:ScratchpadOnlyDMARocketConfig Elaborating design... Interrupt map (1 harts 1 interrupts): [1, 1] => uart_0

:104.28-109.5: Warning (simple_bus_reg): /soc/subsystem_pbus_clock: missing or empty reg/ranges property [error] java.lang.IllegalArgumentException: requirement failed: Diplomacy has detected a problem with your graph: [error] At the following node, the number of outward ports should equal the number of produced outward parameters. [error] source frontend.intnode node: [error] parents: frontend/mydma/system/chiptop [error] locator: (DMADevice.scala:268:28) [error] [error] 0 outward ports connected: [] [error] 0 inward ports connected: [] [error] [error] Downstreamed inward parameters: [] [error] Produced outward parameters: [IntSourcePortParameters(List(IntSourceParameters(IntRange(0,1),List(Resource(freechips.rocketchip.tilelink.TLRegisterRouterBase$$anon$1@6c7eb69a,int)),List())))] [error] [error] ... [error] at freechips.rocketchip.diplomacy.MixedNode.liftedTree2$1(Nodes.scala:1159) [error] at freechips.rocketchip.diplomacy.MixedNode.doParams$lzycompute(Nodes.scala:1148) [error] at freechips.rocketchip.diplomacy.MixedNode.doParams(Nodes.scala:1147) [error] at freechips.rocketchip.diplomacy.MixedNode.edgesOut$lzycompute(Nodes.scala:1188) .....

The mentioned 'frontend' module is defined in the following way. Does this issue caused by my interrupt definition? If yes, what should be the correct way of defining interrupt as finish signal?

case class DMADeviceFrontendParams(address: BigInt, beatBytes: Int)

trait DMADeviceFrontendBundle extends Bundle with HasDMADeviceParameters{ val complete = Decoupled(Flipped(Bool())) val addr_sp = Output(UInt(pAddrBits.W)) val addr_mmio = Output(UInt(pAddrBits.W)) val len = Output(UInt(lenBits.W)) val write = Output(Bool()) val input_valid = Output(Bool()) }

trait DMADeviceFrontendModule extends HasRegMap with HasDMADeviceParameters {

implicit val p: Parameters val io: DMADeviceFrontendBundle def params: DMADeviceFrontendParams val dataBits = dataBitsPerBeat

require (max_len <= 1024) require (pAddrBits <= 64) val addr_sp_reg = Reg(UInt(pAddrBits.W)) val addr_mmio_reg = Reg(UInt(pAddrBits.W)) val len_reg = Reg(UInt(lenBits.W)) val write_reg = Reg(Bool()) //means write scratch pad data to mmio val complete_reg = Reg(Bool()) val ready_status = Wire(Bool())

io.addr_sp := addr_sp_reg io.addr_mmio := addr_mmio_reg io.len := len_reg io.write := write_reg io.input_valid := (addr_sp_reg=/=0.U) && (addr_mmio_reg=/=0.U) //Use two address status (non-zero) as the general valid status, so write these two address at last io.complete.ready := io.input_valid complete_reg := io.complete.valid interrupts(0) := io.complete.valid

ready_status := (addr_sp_reg===0.U) && (addr_mmio_reg===0.U)

when(complete_reg) { addr_sp_reg := 0.U addr_mmio_reg := 0.U }

printf("yc-log: addr_sp_reg = %x, addr_mmio_reg = %x, len_reg = %d, write_reg = %d, complete_reg = %d ready_status = %d\n", addr_sp_reg, addr_mmio_reg, len_reg, write_reg, complete_reg, ready_status)

regmap( 0x00 -> Seq(RegField(pAddrBits, addr_sp_reg)), 0x08 -> Seq(RegField(pAddrBits, addr_mmio_reg)), 0x10 -> Seq(RegField.w(lenBits, len_reg)), 0x12 -> Seq(RegField.w(1, write_reg)), 0x13 -> Seq(RegField.r(1, complete_reg)), 0x14 -> Seq(RegField.r(1, ready_status))) }

class DMADeviceFrontend(c: DMADeviceFrontendParams)(implicit p: Parameters) extends TLRegisterRouter( c.address, "dmadev-controller", Seq("yc,dmadev"), interrupts = 1, beatBytes = c.beatBytes)( new TLRegBundle(c, _) with DMADeviceFrontendBundle)( new TLRegModule(c, _, _) with DMADeviceFrontendModule)

..... class MyDMA(c: DMADeviceFrontendParams)(implicit p:Parameters) extends LazyModule{ val frontend = LazyModule(new DMADeviceFrontend(c)) val device = LazyModule(new DMADevice)

lazy val module = new LazyModuleImp(this) { frontend.module.io <> device.module.io.req } } trait CanHavePeripheryMyDMA { this: BaseSubsystem => implicit val p: Parameters

private val address = 0x2000 private val portName = "mydma"

p(DMADeviceKey).map { k => val mydma = LazyModule(new MyDMA(DMADeviceFrontendParams(address, pbus.beatBytes))(p))

pbus.toVariableWidthSlave(Some(portName)) { mydma.frontend.node }
fbus.fromPort(Some(portName))() :=* mydma.device.node_sp
pbus.fromPort(Some(portName))() :=* mydma.device.node_mmio

} }

crystalbreezy1 avatar Nov 08 '21 09:11 crystalbreezy1

By filtering the error, I find that the previous error is caused by that I'm trying to create an interrupt. Since I didn't find much detail on creating interrupt in the design (the current implementation is imitated based on BlockDevice.scala), could you please give me some suggestion on the interrupt creation?

crystalbreezy1 avatar Nov 12 '21 10:11 crystalbreezy1

Find the way to add the interrupt, I should connect the frontend intnode to ibus. Will close the ticket.

crystalbreezy1 avatar Nov 19 '21 14:11 crystalbreezy1