top of page

[Chisel/scala] Adding a hardware array to a bundle member


What want to do

As the title says, I want to add a chisel hardware array to a Bundle member. Situation is tat I want to implement multiple identical circuits and process them in parallel.

It's easy if it's an array of UInt, but I had a lot of trouble when the members of the array are hardware.


Premise
  • There are Scala types, chisel types, and chisel hardware.

    • Int and Seq are Scala types

    • UInt and Vec are chisel types

    • Wire and Reg are hardware

  • Only chisel types can be added to Bundle members.


How to do

Based on the above, the array should be a Vec, not a Seq.


So first I tried writing it like this:

class MyParts extends Module{
  ・・・
}

class MyBundle extends Bundle{
  val myVec :Vec[MyParts] = VecInit(4)(new Wire(MyParts))
}

This will result in the following error:

chisel3.package$ExpectedChiselTypeException: Bundle: MyBundle contains hardware fields: 

Since it was initialized with Wire(), the compiler recognized it as chisel hardware and gave me an error.


So when I remove the Wire, I get an error that says "Attach Wire"

vec element 'MyClass' must be hardware, not a bare Chisel type. Perhaps you forgot to wrap it in Wire(_) or IO(_)?

Hmm...

The arguments to VecInit must be hardware, but the members of a Bundle cannot be hardware...


So I wrote the following and got no compilation errors:

class MyBundle extends Bundle{
  val myVec :Vec[MyParts] = Vec(4, new MyParts)
}

The likely causes are speculated to be as follows:

  • VecInit() initializes a Vec with specific values. Therefore, it requires specific "hardware" as an argument.

  • Vec() initializes Vec with default values. Therefore (?), the arguments are not limited to hardware.

Honestly, the logic around '?' is unclear, so I can't say with any confidence...



Summary
class MyBundle extends Bundle{
  val myVec :Vec[MyParts] = Vec(4, new MyParts)
}

This is not officially stated, but simply means that if you do it this way, no errors will occur.

Recent Posts

See All

[chisel/scala] Create an array of Modules

What I want to do I have a class (parts) that I created and that inherits from Module. I want to place multiple instances (components) of this class in a circuit. What I tried I tried to create an arr

Comments


Let's do our best with our partner:​ ChatReminder

iphone6.5p2.png

It is an application that achieves goals in a chat format with partners.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png

Let's do our best with our partner:​ ChatReminder

納品:iPhone6.5①.png

It is an application that achieves goals in a chat format with partners.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png

Theme diary: Decide the theme and record for each genre

It is a diary application that allows you to post and record with themes and sub-themes for each genre.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png
bottom of page