Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Array assignements in verilog

Status
Not open for further replies.

sujithchakra

Junior Member level 1
Joined
Apr 30, 2007
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,422
verilog array slice

Could any one please help me..... whats wrong in the following statements?

reg [7:0] a [0:7];

a[1][0]<=1'b1; // I GET "SYNTAX ERROR" here when I try to assign "1" to

element indexed [1][0] .I am using Cadence Verilog - XL to compile the code.

I find the syntax right.Could anyone please correct me if I am wrong?


Thank you
 

sujithchakra said:
Could any one please help me..... whats wrong in the following statements?

reg [7:0] a [0:7];

a[1][0]<=1'b1; // I GET "SYNTAX ERROR" here when I try to assign "1" to

element indexed [1][0] .I am using Cadence Verilog - XL to compile the code.

I find the syntax right.Could anyone please correct me if I am wrong?


Thank you

Verilog doesn't allow array/mem slicing beyond 1-D. Try:

Code:
reg [7:0]  a [0:7];
reg [7:0] a_temp;


a_temp = a[1];       
a_temp[0] = 1'b1;
a[1] = a_temp;

Basically slice it into an intermediate variable and slice it as you like.

BTW - if you move to SystemVerilog, this is allowed as per your original code, but Verilog-XL won't support it, move to NC.

Cheers
Ajeetha, CVC
www.noveldv.com
 
Hi....

I think u have declare a one-dimensional array and assigning to two dimensional array that's why it's giving an syntax error.

What u hv declare is 1-D array of width 8bit.....
For 2-D array: it is
reg [7:0] arr [7:0][7:0];[/code]
 

verma.ind,
I am afraid you've got it wrong my friend. The original code(sujithchakra) was correct but as Aji explained it is not possible in verilog to do this kind of assingment , systemverilog however does allow you to write this.

If you have absoultely got to do this then try this.

reg [7:0] a [0:7];
a[1] = a[1] | 8'b1 ;

This would work fine (For simulation only)
 

aji_vlsi said:
sujithchakra said:
Could any one please help me..... whats wrong in the following statements?

reg [7:0] a [0:7];

a[1][0]<=1'b1; // I GET "SYNTAX ERROR" here when I try to assign "1" to

element indexed [1][0] .I am using Cadence Verilog - XL to compile the code.

I find the syntax right.Could anyone please correct me if I am wrong?


Thank you

Verilog doesn't allow array/mem slicing beyond 1-D. Try:

That is not correct. Verilog-2001 allows 2-D unpacked array slicing (at least on the right-hand side of an assignment-operation), I use it all the time. But Verilog-XL is not Verilog-2001 compliant, so it will not recognize Verilog-2001 syntax.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top