简体   繁体   English

常量值的verilog数组

[英]verilog array of constant value

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. 因为我想将这些部分分配给在for循环中生成的函数的输入,所以我需要一个数组来使用索引。

This is the part of my code which I have problem with, because in each iteration of i , I need a new encoderOut . 这是我的代码中有问题的部分,因为在i每次迭代中,我都需要一个新的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

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: 但是,如果将参数值限制为32位,则可以将这些值连接起来并使用shift和mask提取它们:

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 现在,将encoderOut替换为

((TABLE >> (32*(TABLE_N - i - 1 ))) & {32{1'b1}})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM