0
votes

I have, tab=Array(1.U, 6.U, 5.U, 2.U, 4.U, 3.U) and Y=Seq(b,g,g,g,b,g), tab is an array of UInt. I want to do a map on tab as follows:

tab.map(case idx=>Y(idx))

But I keep getting the error: found chisel3.core.UInt, required Int. I tried using the function peek() to convert idx to an Int by doing

tab.map(case idx=>Y(peek(idx).toInt)

but I get peek not found. I also saw that I cannot convert a chisel UInt to an Int here but did not understand the use of peek well with the example given. So please, is there another approach to do the above? Thanks!

1

1 Answers

0
votes

The immediate problem is that you cannot access the elements of scala collections using a hardware construct like UInt or SInt. It should work if you wrap Y in a Vec. Depending on your overall module this would probably look like

val YVec = VecInit(Y)
val mappedY = tab.map { case idx => YVec(idx) }