这似乎在 Chisel 2 中有效,但现在不起作用:
class TestX extends Module
{
val io = IO(new Bundle {
val a = Output(UInt(width=2))
})
io.a(1, 0) := UInt(0)
}
错误:[模块 TestX] 表达式 T_4 用作 FEMALE,但只能用作 MALE。
此更改的修复方法是什么?
最佳答案
Chisel3 目前不支持子字分配。不过,该错误消息非常没有帮助,我已经提交了一个问题:https://github.com/ucb-bar/chisel3/issues/399 .
您可以通过使用提取和串联来解决此问题:
class TestX extends Module {
val io = IO(new Bundle {
val a = Input(UInt(4.W))
val b = Output(UInt(4.W))
})
io.b := Cat(io.a(3, 2), 0.U(2.W))
}
编辑:用现代语法更新
关于Chisel 3 分配给位范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40950073/