0

I have written two verilog modules. The first one is named topmodule.v and the second one is tx.v. The module topmodule.v pass a parameter data[31:0] to tx.v. I want to take the variables Rmax and Cmax from data[31:0]. After that I want to make Rmax and Cmax to be the width of a bus. Moreover, I want to define a reg matrix called Mat with dimensions Cmax-x-Rmax. I receive the error at the 6th line of the code, "Range must be bounded by constant expression". Kindly help me to resolve this problem. The code is given below.

tx (data, output)
input [31:0] data;
reg [15:0] Rmax, Cmax;
assign Rmax [15:0] = data [31:16];
assign Cmax [15:0] = data [15:0];
reg [Rmax-1:0] Matrix [0:Cmax-1];

2 Answers 2

2

The error means pretty much what it says, you cannot have a variable size bus or array.

Declare your matrix to be the maximum size that you ever need, and if you want to use a smaller one, then just use a subsection of it while leaving the rest vacant.

Remember that the width of buses are physical objects, they can't change when the circuit is running, only during synthesis.

Sign up to request clarification or add additional context in comments.

Comments

0

If you really want these to be parameters then use that:

module tx #(parameter DATA=32'h00000000) (
  // inputs and outputs here
  );

  reg [DATA[31:16]-1:0] Matrix [0:DATA[15:0]-1];

However, I'm not really sure of what you are trying to accomplish. Show some more pseudo code and get a more useful answer.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.