简体   繁体   中英

Generating Chisel Module IO Interface From a List

I would like to generate a Module IO interface from a spec I have stored in a scala variable.

I would like to produce this class definition:

class AddIfc extends Module {
   val io = IO(new Bundle {
     val a = Input(UInt(8.W))
     val b = Input(UInt(8.W))
     val o = Output(UInt(8.W))
   })
}

from something like a list of tuples:

List( ("a", "in", 8), ("b", "in", 8), ("o", "out", 8))

I can imagine building an AST and evaluating it using some of the reflection capabilities in scala. Has anyone done this and have an example to show?

Take a look at Record (the parent class of Bundle). They're a bit more advanced because you have to implement elements (rather than reflection doing it for you in Bundle), and you have to implement cloneType.

There is an example in the Chisel tests .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM