gpt4 book ai didi

scala - 类是抽象的;无法在凿子上实例化错误

转载 作者:行者123 更新时间:2023-12-02 10:45:06 25 4
gpt4 key购买 nike

我刚刚开始使用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)
}

这引发了一个错误,指出无法实例化类。请帮忙!!

最佳答案

您需要从自己的关键字中删除abstract并删除def Reverse(a: UInt) : UInt)或为其提供一些实现

看来Reverse is an object defined in the chisel utils-因此您只需要导入它,然后就可以io.z:= Reverse(io.x)

关于scala - 类是抽象的;无法在凿子上实例化错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51171692/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com