2

This Chisel code works ok:

chiselMainTest(Array[String]("--backend", "c", "--genHarness"), () => Module( new Cache(nways = 16, nsets = 32)  )){c => new CacheTests(c)}

However this one - a small variation - produces run-time error:

val cache_inst = new Cache(nways = 16, nsets = 32)
chiselMainTest(Array[String]("--backend", "c", "--genHarness"), () => Module(cache_inst)){c => new CacheTests(c)}


[error] (run-main) java.util.NoSuchElementException: head of empty list
java.util.NoSuchElementException: head of empty list
    at scala.collection.immutable.Nil$.head(List.scala:337)
    at scala.collection.immutable.Nil$.head(List.scala:334)

1 Answers1

1

Any instantiation of a module must be wrapped with "Module()".

This is just a guess, but give this a try:

val cache_inst = Module(new Cache(nways = 16, nsets = 32))
ChiselMainTest(.....),() => (cache_inst){....}

The reason for this, IIRC, is that "Module()" helps Chisel understand the parentage of wires/objects created within your Cache object (essentially pushing and popping the Module stack as the graph is constructed).

Chris
  • 3,827
  • 22
  • 30
  • Unfortunately still doesn't work, though the error message has changed: [error] (run-main) java.util.NoSuchElementException: key not found: /*? in class Cache*/ Chisel.UInt(OUTPUT, width=64, connect to 0 inputs: ()) java.util.NoSuchElementException: key not found: /*? in class Cache*/ Chisel.UInt(OUTPUT, width=64, connect to 0 inputs: ()) – Alexander Samoilov Sep 12 '13 at 14:22
  • This variant works for me: val cache_inst = () => Module(new Cache(nways = 16, nsets = 32)) chiselMainTest(Array[String]("--backend", "c", "--genHarness"), cache_inst ){c => new CacheTests(c)} Thanks! – Alexander Samoilov Sep 12 '13 at 15:20