我正在学习Chisel3。
我有一些关于密码的问题。
val myVec = Wire(Vec(5, SInt(width = 23))) // Vector of 5 23-bit signed integers.我想如果我声明一个向量,我需要写"Wire",但当我看到这些代码时,我错了。
class BigBundle extends Bundle {
val myVec = Vec(5, SInt(width = 23)) // Vector of 5 23-bit signed integers.
val flag = Bool()
// Previously defined bundle.
val f = new MyFloat
}它突然打在我的脸上,所以我想知道我什么时候用"Wire"?
提前谢谢。
发布于 2016-11-29 03:35:52
这里的关键是Chisel3中“类型”和“值”之间的区别。
Vec、Bundle、UInt、SInt和Bool都是“类型”的示例。
Wire、Reg、Input、Output和Mem都是“值”的示例。
使用上面的BigBundle:
class BigBundle extends Bundle {
val myVec = Vec(5, SInt(23.W)) // Vector of 5 23-bit signed integers.
val flag = Bool()
val f = new MyFloat // Previously defined bundle.
}正如Vec(5, SInt(23.W))是一种“类型”一样,BigBundle也是一种“类型”。
如果您希望使用这些类型,您可以创建这些类型之一的Wire,例如。
val myVecWire = Wire(Vec(5, SInt(23.W)))
val myBundleWire = Wire(new BigBundle)编辑:针对现代chisel3样式进行更新
发布于 2016-11-27 12:51:18
可以将Wire用于任何可能重新指定其值的切槽节点。
val a = Wire(Bool())
a := Bool(false)
...https://stackoverflow.com/questions/40816397
复制相似问题