2

How do you test modules with IO input port of type Vec, Bundle, or composition of these?

In other words, using PeekPokeTester, how do you properly poke() a port that is of type Vec, Bundle, or more complex composition of these two types? Thanks!

apen
  • 672
  • 4
  • 14

2 Answers2

2

You can always write special helper functions that just specify each individual field to poke, but it is not very general.

Better solution is to use the newer chisel unit test library ChiselTest. It has support for poking, peeking and expecting Bundle literals. Specifically check out the examples in ChiselTest unittest BundleLiteralsSpec.

VectorLiterals are still a work in progress in Chisel but they are easier than bundles to write more generic helper functions for.

Chick Markley
  • 4,023
  • 16
  • 17
  • I tried to use the library. I can compile and run the provided examples, but when I try to add tests on my own code, I was unable to get `.Lit()` function working on my custom data type. Very strange and confusing. – apen Jun 27 '20 at 02:28
2

The PeekPokeTester has poke methods for Bundle and Vec, but I don't think they have handling for nested versions.

From the ScalaDoc (all Chisel-related ScalaDoc can be found at https://www.chisel-lang.org/):

def poke(signal: Aggregate, value: IndexedSeq[BigInt]): Unit
def poke(signal: Bundle, map: Map[String, BigInt]): Unit

These accept types analogous to Bundle and Vec, but unfortunately it doesn't appear to be nested which isn't ideal.

Jack Koenig
  • 5,840
  • 15
  • 21