我刚开始使用chisel3,但我想反转数字。这是测试平台的代码:
class LengthTest(c: Length) extends PeekPokeTester(c) {
poke(c.io.x, 12)
expect(c.io.z, 21)
}
abstract class LengthTester extends ChiselFlatSpec {
behavior of "Length"
backends foreach { backend =>
it should s"demonstrate usage of functions that generate code in $backend" in {
Driver(() => new Length, backend)((c) => new LengthTest(c)) should be (true)
}
}
}
这是主要代码
abstract class Length extends Module {
val io = IO(new Bundle {
val x = Input(UInt(16.W))
val z = Output(UInt(16.W))
})
def Reverse(a: UInt) : UInt
io.z := Reverse(io.x)
}
这引发了一个错误,指出无法实例化类。请帮忙!
答案 0 :(得分:2)
您需要从自己的关键字中删除abstract
并删除def Reverse(a: UInt) : UInt)
或为其提供一些实现
似乎Reverse is an object defined in the chisel utils-因此,您只需要导入它,然后就可以io.z:= Reverse(io.x)