Reputation: 319
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?
Upvotes: 3
Views: 262
Reputation: 6064
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.
Upvotes: 1