Creating an I / O module of an I / O module from a list

I would like to create an IO module interface from a specification that I have stored in a scala variable.

I would like to create a definition for this class:

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 how to build an AST and evaluate it using some reflection capabilities in scala. Has anyone done this and demonstrated an example?

+3


source to share


1 answer


Have a look at Record (parent Bundle class). They are a little more advanced because you need to implement the elements (instead of reflecting this to you in the Bundle) and you need to implement cloneType.



The Chisel tests have .

+1


source







All Articles