`vec type 'AnonymousBundle(IO io in <module>)' must be a Chisel type, not hardware` 是什么意思?

What does `vec type 'AnonymousBundle(IO io in <module>)' must be a Chisel type, not hardware` mean?

下面的代码行 val mod_subexp_array = Vec(9, Module(new SubTaylor(fepar)).io) 产生以下错误:

chisel3.package$ExpectedChiselTypeException: vec type 'AnonymousBundle(IO io in SubTaylor)' must be a Chisel type, not hardware

模块SubTaylor是我写的一个模块,我通过IO口与它交互。我的 objective 是创建这些 SubTaylor 模块的 9 个实例,并使用它们的 IOs 将它们链接在一起。为了解决上面的问题,我想也许 SubTaylor 模块需要被包裹在一个 Wire 中:

val mod_subexp_array = Vec(9, Wire(Module(new SubTaylor(fepar))).io)

但是,错误消息更改为 wire type 'AnonymousBundle(IO io in SubTaylor)' must be a Chisel type, not hardware。据我目前了解,有两种不同的 Wire 数据类型。一种 wire 数据类型是 Chisel 类型,另一种是硬件类型。我的理解正确吗?我应该如何将 Vector 定义为 Chisel 类型?

你要写的是:

val mod_subexp_array = VecInit(Seq.fill(9, Module(new SubTaylor(fepar))).io))

该错误消息的意思是,您提供了一个硬件 value 而不是 type 而需要一个类型。我会类比解释 C:

// This is how you make an Array of 10 ints
int my_array[10];
// This is analogous to Vec(9, Wire(Module(new SubTaylor(fepar))).io)
3 my_array[10]; /*
^ An int value instead of a type
*/

我知道这种区别在 C 中比在 Chisel 中更明显(因为 Chisel 是一个生成器元编程框架),但实际上是一样的。 Vec(<n>, <type>) 是创建 Vec type 的方式。 VecInit(<values>) 是创建 Vec value.

的方式

您可能想知道我们为什么使用 Seq.fillSeq 是 Scala 类型,我们正在使用工厂方法来消除模块的 9 个实例。 VecInit 接受您正在创建的任何硬件类型的 Seq,因此它将采用这 9 个实例并将其转换为硬件值。