Integer arithmetic

N

nfirtaps

Guest
Can you do signend arithmetic with integer type. I am negating it here
and seem to be getting strange results.

subtype POINTER is integer range 0 to 16383;
subtype BYTECOUNT is integer range 0 to 16383;

signal readpointer : POINTER;
signal writepointer : POINTER;
signal diffpointer : BYTECOUNT;

.....

if (writepointer >= readpointer) then
diffpointer <= writepointer - readpointer;
else
diffpointer <= (16383-readpointer)+writepointer;
end if;
 
"nfirtaps" <lloyd.rochester@gmail.com> wrote in message
news:1165003338.290948.321840@j72g2000cwa.googlegroups.com...
Can you do signend arithmetic with integer type. I am negating it here
and seem to be getting strange results.

subtype POINTER is integer range 0 to 16383;
subtype BYTECOUNT is integer range 0 to 16383;

signal readpointer : POINTER;
signal writepointer : POINTER;
signal diffpointer : BYTECOUNT;

....

if (writepointer >= readpointer) then
diffpointer <= writepointer - readpointer;
else
diffpointer <= (16383-readpointer)+writepointer;
end if;
Try this...
subtype POINTER is integer range 0 to 16383;
subtype BYTECOUNT is integer range -16383 to 16383;

signal readpointer : POINTER;
signal writepointer : POINTER;
signal diffpointer : BYTECOUNT;
....
diffpointer <= writepointer - readpointer;

KJ
 

Welcome to EDABoard.com

Sponsor

Back
Top