nick wrote:
> i find the code witten by me is quite big..
What means "big" here?
> check if the difference between two integers
Are those two integers unsigned integers (aka naturals)?
nick wrote:
> if((unsigned(a)>unsigned(b))and((unsigned(a)-unsigned(b))>=500)) or
> ((unsigned(a)<unsigned(b)) and ((unsigned(b)-unsigned(a))>=500))then
> ---my code
> end if;
With integers simply this:
1 | if abs(a-b)>=500 then
|
2 | ...
|
3 | end if;
|
Boris O. wrote:
> If you need to be certain of clock cycles: do it in assembler
We are in real hardware here. It is done in one clock cycle... ;-)
H-G S. wrote:
> and then somehow ignore the possible negative sign
Have a closer look at the chapter "twos complement and integers". There
is no such thing like a "negative sign" on a integer. All of the bits
are "signs". So you cannot "cut away" or "simply ignore" the sign. Look
at this "8-bit-integer":
2 = 00000010
1 = 00000001
0 = 00000000
-1 = 11111111
-2 = 11111110
See it: you don't see a "negative sign"