【问题标题】:What does `vec type 'AnonymousBundle(IO io in <module>)' must be a Chisel type, not hardware` mean?`vec type 'AnonymousBundle(IO io in <module>)' must be a Chisel type, not hardware` 是什么意思?
【发布时间】:2022-01-18 14:12:27
【问题描述】:

以下代码行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 端口与它连接。我的目标是创建这些 SubTaylor 模块的 9 个实例,并使用它们的 IO 将它们链接在一起。为了解决上述问题,我认为可能需要将 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 数据类型。一种线数据类型是 Chisel 类型,另一种是硬件类型。我的理解正确吗?我应该如何将 Vector 定义为 Chisel 类型?

【问题讨论】:

    标签: module hdl chisel


    【解决方案1】:

    你要写的内容如下:

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

    该错误消息的意思是您在预期类型时提供了硬件而不是类型。我用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(&lt;n&gt;, &lt;type&gt;) 是您创建 Vec type 的方式。 VecInit(&lt;values&gt;) 是您创建 Vec 的方式。

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

    【讨论】:

      猜你喜欢
      • 2020-08-27
      • 1970-01-01
      • 1970-01-01
      • 2015-08-20
      • 2020-09-06
      • 2023-01-13
      • 2018-01-18
      • 2018-07-28
      • 2015-10-23
      相关资源
      最近更新 更多