Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17267 Discussions

using MOD in a if-generate

Altera_Forum
Honored Contributor II
1,698 Views

Hello all, 

 

I have some trouble getting this next piece of code to work. I don't know if this is valid code because the simulation result is always 'U', unless I enter a fixed number. 

This doesn't work: 

for x in 0 to (someConstant MOD 2) generate  

This does: 

for x in 0 to 3 generate  

 

 

If this is not valid code, what is the correct way to do this?
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
901 Views

its a little tricky to understand what you are doing without the proper code, but (someconstant mod 2) can only return 1 or 0, depending on the constant. so it's not the same as the loop below it.

0 Kudos
Altera_Forum
Honored Contributor II
901 Views

Doesn't REM 2 only return 0 or 1? 

 

I use it to generate a number of multiplexors.
0 Kudos
Altera_Forum
Honored Contributor II
901 Views

if both inputs are positive, then mod and rem do the same thing.

0 Kudos
Altera_Forum
Honored Contributor II
901 Views

Thanks, I think I was a bit too quick asking this question. Should have read a bit further on these operators than I did.

0 Kudos
Reply