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.

\$\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

\$\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.

\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.