FboDigit
Member level 1
Hi all,
In verilog/systemverilog, is there a way to write in a reg'size with a variable ?
Example of what I want to do/say
the part I want to do is : EndVar= MyVar[((i*4)+3) : (i*4)];
I constantly get the error : # Error: VCP5116 fakefile.v : (3290, 46): Expected a constant as index: i*4+3.
and # Error: VCP5116 pci_exp_usrapp_tx.v : (3290, 46): Expected a constant as index: i*4.
with Aldec Actve-HDL 9.1
Please help me !! It is probably a small detail but i can't see it!
- - - Updated - - -
I have found my problem AND it was a small detail after all.
Declare the var "i" as parameter and everything is ok
But that brings me a new problem... the var "i" cannot be use in the for loop.
I could use two "i" variable,
But the compiler say :# Error: VCP2858 fakefile.v : (3283, 25): i_p is not a valid left-hand side of a procedural assignment.
In a simple and direct question : Is there a wat to assign the value of a "parameter" to a "reg"
In verilog/systemverilog, is there a way to write in a reg'size with a variable ?
Example of what I want to do/say
Code:
integer i;
[B]reg [63:0] MyVar;[/B]
reg [3:0] EndVar
begin
for (i=0; i<10 ; i =i+1) begin
EndVar= MyVar[[B]((i*4)+3) : (i*4)[/B]];
...
...
...
end //for
the part I want to do is : EndVar= MyVar[((i*4)+3) : (i*4)];
I constantly get the error : # Error: VCP5116 fakefile.v : (3290, 46): Expected a constant as index: i*4+3.
and # Error: VCP5116 pci_exp_usrapp_tx.v : (3290, 46): Expected a constant as index: i*4.
with Aldec Actve-HDL 9.1
Please help me !! It is probably a small detail but i can't see it!
- - - Updated - - -
I have found my problem AND it was a small detail after all.
Declare the var "i" as parameter and everything is ok
But that brings me a new problem... the var "i" cannot be use in the for loop.
I could use two "i" variable,
Code:
parameter i_p =10;
integer i_r;
[B]reg [63:0] MyVar;[/B]
reg [3:0] EndVar
begin
i_r = i_p;
for (i_r=0; i_r<10 ; i_r =i_r+1) begin
[B] i_p =i_r;[/B] //THIS IS THE PROBLEMATIC LINE !!! (3283)
EndVar= MyVar[[B]((i_p*4)+3) : (i_p*4)[/B]];
...
...
...
end //for
But the compiler say :# Error: VCP2858 fakefile.v : (3283, 25): i_p is not a valid left-hand side of a procedural assignment.
In a simple and direct question : Is there a wat to assign the value of a "parameter" to a "reg"
Last edited: