Convert a range of a Bits variable into BigInt in a simulation

189 views
Skip to first unread message

Roberto Cattaneo

unread,
Nov 22, 2019, 9:39:52 AM11/22/19
to SpinalHDL (Hardware Description Language)
Dear SpinalHDL user or developers,
I'm extensively using spinalHDL and i think it is really great project.
Right now i found myself stuck with a problem:
I am testing a module which has an output Bits port of 21 bits generating data every clock cycle. However, i have to take just a portion of it (lets say 19 downto 10), assign it to a BigInt, and check that it has some specific values.
When i try to do this the compiler throws an exception: "next on empty iterator".
By debugging the problem i figured out that, when you try to get a range or even just a bit of a Bits object, it sees it as a list and tries to iterate over it, which may explain why the iterator is failing.
Do you have any solution to this problem? because otherwise i should use standard operations to obtain the range of values i want, which sucks...
Thank you for the help,
Cattaneo Roberto

Charles Papon

unread,
Nov 24, 2019, 7:13:04 PM11/24/19
to SpinalHDL (Hardware Description Language)
Hi,

You can't use myBits(19 downto 10).toInt, as it will ask SpinalHDL to infer some hardware wire and then ask the sim to translate into Int. In other words, only simulation requrest are accepted in sim.

You should (myBits.toInt >> 10) & 0x3FFF.

Sorry for the inconveniance :)

Regards
Charles
Reply all
Reply to author
Forward
0 new messages