A
Andrew FPGA
Guest
Hi,
I like using a restricted range natural type for counters. e.g.
variable TimeslotCount : natural range 0 to TIMESLOTS_PER_FRAME-1;
...
TimeslotCount := (TimeslotCount+1) mod TIMESLOTS_PER_FRAME;
...
When the count variable is a power of 2 range, e.g. TIMESLOTS_PER_FRAME
= 16 then Modelsim 6.0d is happy and ISE 8.1isp2 is happy.
But, when the count variable is not a power of 2 range, e.g.
TIMESLOTS_PER_FRAME = 20 then Modelsim is happy but XST(xilinx
synthesizer) can't handle this.
"ERROR:Xst:1775 - Unsupported modulo value 10 found in expression at
line 277. The modulo should be a power of 2."
An alternative would be
if TimeslotCount < (TIMESLOTS_PER_FRAME-1) then
TimeslotCount := TimeslotCount +1;
else
TimeslotCount := 0;
end if;
but this doesn't seem as nice as when using the mod operator?
Can anyone suggest a more elegant solution for a Synthesizable non
power of 2 natural type counter?
Regards
Andrew
I like using a restricted range natural type for counters. e.g.
variable TimeslotCount : natural range 0 to TIMESLOTS_PER_FRAME-1;
...
TimeslotCount := (TimeslotCount+1) mod TIMESLOTS_PER_FRAME;
...
When the count variable is a power of 2 range, e.g. TIMESLOTS_PER_FRAME
= 16 then Modelsim 6.0d is happy and ISE 8.1isp2 is happy.
But, when the count variable is not a power of 2 range, e.g.
TIMESLOTS_PER_FRAME = 20 then Modelsim is happy but XST(xilinx
synthesizer) can't handle this.
"ERROR:Xst:1775 - Unsupported modulo value 10 found in expression at
line 277. The modulo should be a power of 2."
An alternative would be
if TimeslotCount < (TIMESLOTS_PER_FRAME-1) then
TimeslotCount := TimeslotCount +1;
else
TimeslotCount := 0;
end if;
but this doesn't seem as nice as when using the mod operator?
Can anyone suggest a more elegant solution for a Synthesizable non
power of 2 natural type counter?
Regards
Andrew