rohd icon indicating copy to clipboard operation
rohd copied to clipboard

Better support for `Logic` based indexing of `List<Logic>`

Open mkorbel1 opened this issue 2 years ago • 1 comments

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 oring them together, but that's more verbose.

mkorbel1 avatar Apr 07 '22 14:04 mkorbel1

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?

mkorbel1 avatar Aug 19 '22 17:08 mkorbel1

Hey Max, I will start working on this one :)

RPG-coder-intc avatar Feb 08 '23 18:02 RPG-coder-intc

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`

mkorbel1 avatar Feb 17 '23 19:02 mkorbel1

Working on this issue...

RPG-coder-intc avatar Apr 06 '23 17:04 RPG-coder-intc

Fixed in #438

mkorbel1 avatar Dec 14 '23 21:12 mkorbel1