3

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.