Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Expected a constant as index error in Verilog

I’m trying to do some projects on Verilog and I have a problem with constant index errors.

integer k=32;
reg[k-1:0] inputs;

In this part, the Verilog compiler gives me "Expected a constant as index error in Verilog" message.
I must use integer k in this project. How can I solve this problem?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

integer is a variable type. As the error message states, you need a constant type, such as parameter:

parameter k=32;
reg[k-1:0] inputs;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading