EmbDev.net

Forum: FPGA, VHDL & Verilog Very simple Verilog array error, fresh eyes appreciated.


von AlephOne (Guest)


Rate this post
useful
not useful
I'm designing a single-cycle CPU in Verilog, compiling using Chronologic 
VCS v. 2006 on a Sun Linux server. Below is a trimmed up version of the 
code that's giving me trouble, and the exact verbatim code below is 
still giving me the error:

Parsing design file 'test.v'
Error-[SE] Syntax error
"test.v", 5: token is '['
reg_array[0] = 134;
^
1 error
CPU time: 0 seconds to compile
1
module regfile;
2
  
3
  reg [31:0]  reg_array[0:31]; //array of 32-bit registers
4
5
  reg_array[0] = 134;
6
  reg_array[2] = 854;
7
  reg_array[6] = 223;
8
  reg_array[7] = 4878;
9
  reg_array[8] = 9855;
10
  reg_array[10] = 2;
11
  reg_array[20] = 0;
12
  reg_array[21] = 1;
13
  reg_array[31] = 5555;
14
15
endmodule

I assume it is a painfully simple solution but I am too tired and stupid 
to find it right now. Fresh eyes appreciated. Thanks all!

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
> I assume it is a painfully simple solution
I usually do VHDL, but what about the keywords initial or always?
At least this compiles fine:
1
module regfile;
2
  
3
  reg [31:0]  reg_array[0:31]; //array of 32-bit registers
4
5
  initial begin
6
    reg_array[0] = 134;
7
    :
8
    :
9
    reg_array[31] = 5555;
10
  end 
11
12
endmodule

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.