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.

Problem in Verilog Array

Status
Not open for further replies.

manik045

Newbie level 6
Joined
Feb 16, 2010
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Dinajpur
Activity points
1,404
Hello

I have the following code in Modelsim 10.1b.

Code:
module TwoD_Array ();
  
  reg  array [3:0] [7:0]; //={1010, 1110, 1111,1011};
  
 initial begin
   
   array [0][1]=11001101; //{{11001101}|{11110101}|{10101111}|{11100111}};
   //array = '{{8'b0},{8'b1},{8'b0},{8'b1}};
//$display ("array[0][0]= %b", array[0][0]);
$display ("array [0][1]=%b", array[0][1]);
end 
endmodule

I have the following output.

# array [0][1]=1

Why it's happening? Here should be 11001101. I do not understand. Please help to input the values in the 2D array. I know that verilog does not support packed array. But if i want to put multiple values at a time in verilog what should i do?

Any help regarding this issue very helpful. Please give an example of related fault.

Thanks in advance.
 

If you are being restricted to using Verilog, not SystemVerilog, you can only access one bit at a time. The only way to make an assignment to a 2D unpacked array is to nested for-loop. Maybe you meant to declare your array as

Code:
reg [7:0] array [3:0];

array[0] = 8'11001101;
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top