Connecting AXI Stream to StreamFifo

313 Views Asked by At

I want connect AXI Stream Master to Stream Fifo. I need only payload, valid and ready signals. Idea is to load FIFO with data and push it via AXI Stream to other part of logic.

Simple example:

case class AxiWithFifo() extends Component {

  val io = new Bundle {
    val axis_s = slave(
      Axi4Stream(Axi4StreamConfig(dataWidth = 32))
    )
    val axis_m = master(
      Axi4Stream(Axi4StreamConfig(dataWidth = 32))
    )
  }

  val fifo = StreamFifo(dataType = Bits(256 bits), depth = 128)
  fifo.io.push << io.axis_s.toBitStream()
  io.axis_m.toBitStream() << fifo.io.pop
}

Sadly there is complaint about hierarchy violation:

[#25] HIERARCHY VIOLATION : (toplevel/io_axis_m_ready : in Bool) is driven by (toplevel/??? :  Bool), but isn't accessible in the toplevel component.
[#25]     spinal.lib.Stream.arbitrationFrom(Stream.scala:304)
[#25]     spinal.lib.bus.amba4.axis.Axi4Stream$Axi4StreamRich.toBitStream(Axi4Stream.scala:131)
[#25]     spinalhdlexample.AxiWithFifo.<init>(AxiWithFifo.scala:40)
[#25]     spinalhdlexample.AxiWithFifo$.$anonfun$main$1(AxiWithFifo.scala:47)
[#25]     spinal.sim.JvmThread.run(SimManager.scala:51)

Any ideas how to fix it?

1

There are 1 best solutions below

0
On

So partial solution is to make Flow from Stream and manually connect Stream signals.

case class AxiWithFifo() extends Component {

  val io = new Bundle {
    val axis_s = slave(
      Axi4Stream(Axi4StreamConfig(dataWidth = 32))
    )
    val axis_m = master(
      Axi4Stream(Axi4StreamConfig(dataWidth = 32))
    )
  }

  noIoPrefix()

  val fifo =
    StreamFifo(
      dataType = Bits(256 bits),
      depth = 128
    )

  fifo.io.push << io.axis_s.toBitStream()

  val fifoFlow = fifo.io.pop.toFlow
  when(fifo.io.pop.valid) {
    io.axis_m.valid := True
  }.otherwise {
    io.axis_m.valid := False
    fifoFlow.setIdle()
  }

  when(io.axis_m.ready) {
    fifo.io.pop.ready := True
  }.otherwise {
    fifo.io.pop.ready := False
  }
  io.axis_m.payload.data <> fifoFlow.payload
}

Vivado RTL Schematics