Let’ say I have a ROM module like this:
module myROM (
input address[5],
output out[4],
)
{
const DATA = { 0,1,2,3,4,5,6,7,8,9,10 };
always {
out = DATA[address];
}
For this ROM, address 0 yields an out value of 10.
But suppose I want address 0 to output 0, i.e. read them is forward order instead of reverse. I could count the members: count = 11. Then I can use xAddr = (count-1) - address. Now xAddr will give me the values in the reverse order like I want. This works!
But there is a function that seems to do exactly that already: $reverse(a). I think I should be able to use $reverse(address) to get the result I want (without having to keep track of the number of items in the array), but it doesn’t seem to work. What is it I don’t understand here? Thank you!