Chisel:嵌套 Vecs 中丢失的解耦方向性

Chisel: Decoupled directionality lost in nested Vecs

我有一个 Vec[Decoupled[UInt]],我想根据 select 信号连接到 Vec[Decoupled[UInt]]Vec。但是,一旦 Decoupled 嵌套了两层深,它的方向性似乎就会丢失,所以它不会让我初始化就绪信号或用输入驱动输出。

例如,Chisel 允许我实例化这个:

class Example extends Module {
  val io = IO(new Bundle {
    val in = Vec(3, Flipped(Decoupled(UInt(3.W))))
    val out = Vec(3, Decoupled(UInt(3.W)))
  })
  io.in.foreach(_.ready := false.B) // Only here for consistency
  io.out <> io.in
}

但这会产生一个错误:

class Example extends Module {
  val io = IO(new Bundle {
    val sel = Input(UInt(4.W))
    val in = Vec(10, Vec(3, Flipped(Decoupled(UInt(3.W)))))
    val out = Vec(3, Decoupled(UInt(3.W)))
  })
  io.in.foreach(_.foreach(_.ready := false.B))
  io.out <> io.in(io.sel)
}

后者给出的错误是

Sink is unwriteable by current module (line 7)
Both left and right are drivers (line 8)

这是 Chisel 的错误还是我遗漏了什么?我该如何解决这个问题?

这……很奇怪。我还没有找到原因,但我已经确认了您所看到的错误行为。幸运的是,有一个简单的解决方法,将 Flipped 放在 Vec 之外。

class Example extends Module {
  val io = IO(new Bundle {
    val sel = Input(UInt(4.W))
    val in = Flipped(Vec(10, Vec(3, Decoupled(UInt(3.W)))))
    val out = Vec(3, Decoupled(UInt(3.W)))
  })
  io.in.foreach(_.foreach(_.ready := false.B))
  io.out <> io.in(io.sel)
}

我已提交 an issue on the Chisel repo 以跟踪此错误。