Input matrix in verilog

Status
Not open for further replies.

akipro

Newbie level 6
Joined
Mar 14, 2013
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,361
Hey, I want to input a n*m (n and m are defined) matrix in verilog (where each element is of 32 bit length), but the compiler gives an error. Is there any direct way to do so? I don't want to write n*m separate input elements.

This is what I tried:

Code:
 input reg [31:0] matrix [0:9][0:12]

Anything wrong here?

Thanks
 
Last edited by a moderator:

Verilog doesn't support arrays in the module port declaration. You'll need to concatenate the busses together.

Input [10*13*32-1:0] matrix

In the body of your code you can include a for loop to extact slices and assign them to a wire array.

reg cannot be used as the type for an input.

Regars
 

Can I use verilog code in system verilog, it seems we can use 2D matrix as input in system verilog?
 

I'm not sure as I mostly use Verilog. I can't check as I don't have the IEEE spec handy. You can download it for free on IEEE's we site.
 

For the most part System Verilog is backwards compatible with Verilog
 

Verilog is now a subset of SystemVerilog.
At least in SystemVerilog, you can:
PHP:
input reg [0:9][0:12][31:0] matrix ;

This will give you a 10*13 matrix, in which each element is 32 bit register.
if you define it as row=10, column=13, then matrix[2][3] means the element at row[2] and column[3].
 
Last edited:

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…