How to instantiate item of Bundle on some condition?

46 views
Skip to first unread message

San Rise

unread,
May 15, 2015, 4:01:09 AM5/15/15
to chisel...@googlegroups.com
With Chisel 2.2.19 i can do following:

class MyBundle(withB : Boolean) extends Bundle {
val inA = Bool(INPUT)
val inB = if(withB) Bool(INPUT) else null
val out = Bool(OUTPUT)
}

class MyModule extends Module {
val io = new MyBundle(false) // OK - only on 2.2.19
io.out := io.inA
// val io = new MyBundle(true) // always OK
// io.out := io.inA & io.inB
}

With such result:
// module MyModule(input io_inA, output io_out); //new MyBundle(false)
// assign io_out = io_inA;
// endmodule
// or
// module MyModule(input io_inA, input io_inB, output io_out); //new MyBundle(true)
// wire T0;
// assign io_out = T0;
// assign T0 = io_inA & io_inB;
// endmodule

When I try this on Chisel > 2.2.19 i receive:
// Exception in thread "main" java.lang.IllegalArgumentException: Flat hash tables cannot contain null elements.
...
// at Chisel.Bundle$$anonfun$calcElements$2.apply(Bundle.scala:68)
...
// at Chisel.Module$.Chisel$Module$$init(Module.scala:60)
// at Chisel.Module$.apply(Module.scala:48)
Reply all
Reply to author
Forward
0 new messages