0

How can I have an array of constant value or array of parameter? I want to use this array for select the part of an register, so It should be constant. Because I want to assign these parts to the input of a function that is generated in a for loop, I need an array to use index.

This is the part of my code which I have problem with, because in each iteration of i, I need a new encoderOut.

generate
  for ( i=0; i<row ; i=i+1) begin:hi
    for ( j=0; j<column ; j=j+1) begin:ji
      oneBitBlock #(choicesBit,selBit,funcBit,funcCount,(j+1)*row-1)U (rst,muxChoices[encoderOut-1:0],gene[pack*(i*row + j) +: encoderOut],gene[pack*(i*row + j)+encoderOut +: encoderOut],gene[pack*(i*row + j)+2*(encoderOut) +: funcBit],out[i*row + j]);
    end
  end
endgenerate

1 Answer 1

0

There is no direct way to make an array of parameters, sadly. However, if your parameter values are limited, say to 32 bits, then you can concatenate those values and extract them using shifts and masks:

parameter TABLE = {32'd12,32'd45,32'd11}, // parameter values (value1,value2,value3...)
parameter TABLE_N   = 4, // number of entries in a table

Now, replace encoderOut with

((TABLE >> (32*(TABLE_N - i - 1 ))) & {32{1'b1}})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.