How to create a Vec literal from a Seq[Bool]

457 Views Asked by At

For testing inputs/outputs specified as vectors, I need to be able to programmatically create the desired Vec[Bool] for poke and expect. Seq[Bool] is a convient structure to create either directly (e.g., Seq.tabulate(n) {i => (i%2==0).B}) or from a UInt (e.g., 5.U(6.W).toBools).

In a chiseltest, how can I use this Seq[Bool] for poke and expect? Vec.Lit(Seq[Bool]) doesn't seem to be supported.

1

There are 1 best solutions below

0
On

In a chiseltest, how can I use this Seq[Bool] for poke and expect? Vec.Lit(Seq[Bool]) doesn't seem to be supported.

I honestly have not been able to figure this out myself. We recently added convenience methods to directly peek/poke/expect some of the basic Chisel types with Scala values directly (PR 480).

This could be extended to e.g., be able to peek/poke/expect a Vec[UInt] with a Seq[BigInt] or a Vec[Bool] with a Seq[Boolean]. Feel free to open a PR on this. We just need someone to write the code.