I have a one-hot line that I want to use to select a range of wires. So for example if my selector line is 0001 I want to select some_wire[2:0], if it’s 0010 I want to select some_wire[5:3], if it’s 0100 I want to select some_wire[8:6], etc. Currently I’m doing this with a huge case statement however this doesn’t scale if for example I want to parameterize the module. Is there a more succinct way of doing this?
I have a one-hot line that I want to use to select a range
Share
Barrel shifters can be efficiently synthesized so it might be worth comparing any solution against the baseline where you convert the selector back into a binary encoding and use a shift.
For example, something like:
Alternatively, you could use a for loop to compute each bit independently via: