Chisel 分配给 UInt 的各个位

标签 chisel

有人可以告诉我为什么下面的代码在Chisel中不会详细说明吗?看来我无法分配给 UInt 中的各个位。这是设计使然吗?

我确实看到了 Jack 对类似问题的回答,但是跨链位的以下逻辑类型在 SV 等中很常见并且很容易参数化。我可以看到创建 bool 向量以及各个位,但是仍然是如何回到 UInt 的问题...

  def ffo(pwidth:Int, in:UInt) : UInt = {
    val rval = Wire(UInt(width=pwidth))
    rval(0) := in(0)
    for(w <- 1 until pwidth) {
      rval(w) := in(w) & !( in(w-1,0).orR() )
    }
    rval
  }

结果:

firrtl.passes.CheckGenders$WrongGender:  @[Misc.scala 21:13:@5808.4]: [module IuIrRename]  Expression T_1824 is used as a FEMALE but can only be used as a MALE.
firrtl.passes.CheckGenders$WrongGender:  @[Misc.scala 23:15:@5815.4]: [module IuIrRename]  Expression T_1826 is used as a FEMALE but can only be used as a MALE.
firrtl.passes.CheckGenders$WrongGender:  @[Misc.scala 23:15:@5822.4]: [module IuIrRename]  Expression T_1834 is used as a FEMALE but can only be used as a MALE.
firrtl.passes.CheckGenders$WrongGender:  @[Misc.scala 23:15:@5829.4]: [module IuIrRename]  Expression T_1842 is used as a FEMALE but can only be used as a MALE.
firrtl.passes.CheckGenders$WrongGender:  @[Misc.scala 21:13:@5834.4]: [module IuIrRename]  Expression T_1851 is used as a FEMALE but can only be used as a MALE.

最佳答案

经过继续实验(并查看生成的 Verilog 后),以下代码相当于我正在寻找的代码:

  def ffo(pwidth:Int, in:UInt) : UInt = {
    val ary = Wire(Vec(pwidth, Bool()))
    ary(0) := in(0)
    for(w <- 1 until pwidth) {
      ary(w) :=   in(w) && !( in(w-1,0).orR() )
    }
    val rval = Reverse(Cat(ary))
    rval
  }

关于Chisel 分配给 UInt 的各个位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41581661/

相关文章:

scala - Scala/Chisel 中的函数循环

riscv - 在 VCD 中显示 Chisel 信号

simulation - 模拟用 Chisel 编写的 CPU 设计

chisel - Chisel 模块中的条件端口

hdl - 如何用iotesters计算凿子的时间?

scala - Chisel 中的 <> 运算符是什么?

chisel - 如何使用Chisel C++模拟器

Chisel编译成功但无法正确生成verilog

chisel - firrtl_interpreter.InterpreterException : error: ConcreteSInt(303, 9) 宽度错误 9 需要 10

chisel - 如何为最终 Verilog 文件中模块序列中的每个元素指定唯一名称