通常は必要のない選択可能な機能があります。ただし、この機能をサポートするには、元のモジュール I/O ポートにいくつかの I/O ポートを追加する必要があります。
私はこのようにしています:
import Chisel._
class TestModule extends Module {
class IOBundle extends Bundle {
val i = Bool(INPUT)
val o = Bool(OUTPUT)
}
class IOBundle_EXT extends IOBundle {
val o_ext = Bool(OUTPUT)
}
val io = if(true) new IOBundle_EXT else new IOBundle;
io.o := io.i
io.o_ext := io.i
}
sbt "run TestModule --backend c --compile --test --genHarness" を実行した後、コンパイラは次のように文句を言います:
[error] xxxx/test/condi_port.scala:17: value o_ext is not a member of TestModule.this.IOBundle
[error] io.o_ext := io.i
[error] ^
[error] one error found
[error] (compile:compile) Compilation failed
したがって、if ステートメントは効果がありません。val io は、拡張された IOBoundle_EXT ではなく IOBundle にまだ割り当てられているため、意味がありません。