chisel - 使用动态索引时如何显示我的线路名称?

标签 chisel

运行类似的东西时

class Foo extends Module {
  val io = IO(new Bundle {
    val in = Input(Vec(4, Bool()))
    val idx = Input(UInt(2.W))
    val en = Input(Bool())
    val out = Output(Bool())
  })

  val x = io.in(io.idx)
  val y = x && io.en
  io.out := y
}

生成的 Verilog 丢失了 x 名称:

module Foo(
  input        clock,
  input        reset,
  input        io_in_0,
  input        io_in_1,
  input        io_in_2,
  input        io_in_3,
  input  [1:0] io_idx,
  input        io_en,
  output       io_out
);
  wire  _GEN_1; // @[main.scala 15:13]
  wire  _GEN_2; // @[main.scala 15:13]
  wire  _GEN_3; // @[main.scala 15:13]
  assign _GEN_1 = 2'h1 == io_idx ? io_in_1 : io_in_0; // @[main.scala 15:13]
  assign _GEN_2 = 2'h2 == io_idx ? io_in_2 : _GEN_1; // @[main.scala 15:13]
  assign _GEN_3 = 2'h3 == io_idx ? io_in_3 : _GEN_2; // @[main.scala 15:13]
  assign io_out = _GEN_3 & io_en; // @[main.scala 16:10]
endmodule

如何确保显示电线名称?

最佳答案

这可以通过创建连线并将动态索引连接到连线来解决:

val x = WireInit(io.in(io.idx))

应该返回:

module Foo(
  input        clock,
  input        reset,
  input        io_in_0,
  input        io_in_1,
  input        io_in_2,
  input        io_in_3,
  input  [1:0] io_idx,
  input        io_en,
  output       io_out
);
  wire  _GEN_1;
  wire  _GEN_2;
  wire  x;
  assign _GEN_1 = 2'h1 == io_idx ? io_in_1 : io_in_0;
  assign _GEN_2 = 2'h2 == io_idx ? io_in_2 : _GEN_1;
  assign x = 2'h3 == io_idx ? io_in_3 : _GEN_2;
  assign io_out = x & io_en; // @[main.scala 16:10]
endmodule

关于chisel - 使用动态索引时如何显示我的线路名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61329497/

相关文章:

chisel - Chisel/FIRRTL 工具链是否进行 bool 表达式优化?

scala - 在新类 [Scala Chisel] 中使用现有的 Scala 类

scala - 安装凿子

runtime-error - 出现意外错误 : "Attempted reassignment of binding to chisel3.core.UInt@29a" when declaring a Module's io

scala - 如何处理ActiveLow复位/改变隐式时钟频率?

Chisel 3 分配给位范围

scala - 使用 UInt 在 Seq 中获取项目

chisel - 单独编译模块并链接