In the chipyard example, GCD.scala, the underlying module implementation is selected based on a `useBlackBox` parameter. The I/O for this module is then passed to `val impl_io` for connection to signals within GCDTL.
One challenge I am facings is `what if my IO definitions for my underlying modules were different?`.
In my code, one version of my IO has six additional signals. While I know my conditional module instantiation is correct (again, borrowed from GCD.scala), errors occur when performing the connections in the higher level modules.
Some example code to make the point:
Module A:
class moduleA() extends BlackBox with HasBlackBoxResource {
val io = IO(new Bundle {
// Clock and Reset
val clk = Input(Clock())
val rst = Input(Reset())
// Inputs
val start = Input(Bool())
val valid = Output(Bool())
})
}
Module B:
class moduleB() extends BlackBox with HasBlackBoxResource {
val io = IO(new Bundle {
// Clock and Reset
val clk = Input(Clock())
val rst = Input(Reset())
// Inputs
val start = Input(Bool())
})
}
val myModule_io = if (useModuleA) {
val impl = Module(new
moduleA ())
impl.io
} else {
val impl = Module(new
moduleB ())
impl.io
}
Connections:
if (useModuleA) {
myModule_io .clk := clock
myModule_io .rst := reset
myModule_io.start := start
valid := myModule_io.valid
} else {
myModule_io .clk := clock
myModule_io .rst := reset
myModule_io.start := start
}
During compilation, it will complains that valid is not a member of myModule_io, despite being sure that useModuleA is defined.