( ESNUG 330 Item 5 ) --------------------------------------------- [9/30/99]
Subject: ( ESNUG 326 #7 329 #7 ) Getting *Signed* Comparitors w/ DC 99.05
> An old collegue in the Netherlands, Rob van der Valk, gave me a hint on
> how to do the signed comparisons after he saw my letter in ESNUG. The
> trick is to invert the MSB's of the operands and do an unsigned
> comparison on that. So instead of:
>
> op_a[n:0] > op_b[n:0]
> do:
> {~op_a[n],op_a[n-1:0]} > {~op_b[n],op_b[n-1:0]}
>
> That's easier and smaller in logic than the functions I wrote.
>
> - Menno Spijker
> Mitel Semiconductor Kanata, Canada
From: Charutosh Dixit <charu@lsil.com>
John,
The solution given for above for signed comparators looks flawed to me. The
correct solution is: If we have two signed numbers to be compared, we swap
the MSBs of the two numbers and then perform the regular magnitude
comparison. The scheme works as follows:
a. When the two numbers have the same sign, MSB swapping does not have any
effect and the regular magnitude comparison is done
b. When the two numbers have opposite sign, like for example A=0011 and
B=1001, then the positive number (A) is the bigger number. By swapping
the MSB we get A=1011 and B=0001, and thus the positive number is made
bigger in magnitude (1011 > 0001), for the magnitude comparison that
follows this process.
Hope this helps your ESNUG readers.
- Charu Dixit
LSI Logic Milpitas, CA
|
|