rohd
rohd copied to clipboard
Better support for `Logic` based indexing of `List<Logic>`
Motivation
In SystemVerilog, it's easy to index an entry in an array of signals:
logic [8:0] a [4:0];
logic b [4:0];
logic[8:0] c;
assign c = a[b];
ROHD doesn't have a synthesizable array type, instead encouraging usage of List<Logic>
. However, this makes it much more verbose to access an index of an array based on another Logic
.
Desired solution
Some sort of function or operation which reduces the effort required to do this sort of operation.
Alternatives considered
It is possible by looping through possible values manually and generating comparisons and or
ing them together, but that's more verbose.
Maybe a function on Logic
called select
or something that operates on an indexable Iterable<Logic>
that automatically generates the hardware to select the right one?
Hey Max, I will start working on this one :)
An example of an equivalent API in ROHD could be:
List<Logic> a; // length of list is 5, each element width is 9 bits
Logic b; // width is 3 bits
Logic c; // width is 9 bits
// two potential options:
c <= a.selectIndex(b); // order matches closer to array indexing, but requires extension on `List<Logic>`
c <= b.selectFrom(a); // order is less intuitive, but only requires new function on `Logic`
Working on this issue...
Fixed in #438