0
\$\begingroup\$

I have one doubt. The error is: Range must be bounded by constant expression when compiling the below lines:

X=in[i+2 : i] +1'b1;
In[i]=-1;

Please tell how to resolve it.

ocrdu
9,34123 gold badges33 silver badges43 bronze badges
asked Sep 30, 2018 at 14:33
\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

The width of ranges must be a constant and must be written this way: in[i+:3]

See Accessing rows of an array using variable in Verilog

answered Sep 30, 2018 at 14:41
\$\endgroup\$
1
  • \$\begingroup\$ Thank you so much.... The code is compiled without error... \$\endgroup\$ Commented Sep 30, 2018 at 16:34
-1
\$\begingroup\$

Remember that Verilog is not a general purpose programming language, it is a hardware description language. Once the hardware is synthesized, or compiled, it generally does not change. So, the code you use to specify the hardware must specify fixed hardware.

Rather than use run-time variables to select the inputs to an adder you must use a multiplexer to select those inputs. The control signals for the multiplexer would be derived from whatever logic you use to choose the value of i in your original code.

answered Sep 30, 2018 at 15:28
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.