gpt4 book ai didi

chisel - 如何做一个模块向量?

转载 作者:行者123 更新时间:2023-12-04 13:59:05 46 4
gpt4 key购买 nike

我想实例化一个元素的一维数组,元素扩展模块。我该怎么做?如果我说我最好的猜测,那就是:

val elements = Vec( 64, new element )

我收到以下错误消息:
[error] /Users/mykland/work/chisel/array.scala:20: overloaded method value apply with alternatives:
[error] [T <: Chisel.Data](n: Int, gen: => T)Chisel.Vec[T] <and>
[error] [T <: Chisel.Data](elt0: T, elts: T*)Chisel.Vec[T] <and>
[error] [T <: Chisel.Data](gen: => T, n: Int)Chisel.Vec[T]
[error] cannot be applied to (Int, ascenium.element)
[error] val elements = Vec( 64, new element )
[error] ^

提前感谢您提供的任何帮助。

最佳答案

编辑:我正在添加我认为生成模块向量的更好方法:

val my_args = Seq(1,2,3,4)
val exe_units = for (i <- 0 until num_units) yield
{
val exe_unit = Module(new AluExeUnit(args = my_args(i)))
// any wiring or other logic can go here
exe_unit
}

请注意,此方法允许您以不同方式单独定制每个单元,并返回 Chisel 模块的 Seq()。它也会产生更好看的硬件。

但是,如果您真的需要能够动态索引到您的模块数组,您可以像这样提取 IO 的 Vec() :
val exe_units_io = Vec(exe_units.map(_.io))

(这是旧的建议,我认为不太好)。

您可以按如下方式创建模块的 Vec:
val vec_of_elements = Vec.fill(n) {Module(new MyElement(my_args)).io }

但请注意,Vec 实际上只能是 Wire 或 Registers,所以我们实际上只是创建了 IO Wire 的 Vec,它恰好创建了我们在此过程中关心的模块。

关于chisel - 如何做一个模块向量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33621533/

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