Signed 8-bit Comparator

A

ATran

Guest
I have an unsigned 8-bit comparator in verilog, How would I change it
to become a signed 8-bit comparator?
 
st0p@hotmail.com (ATran) wrote in message news:<425982b8.0411212030.29fb1a19@posting.google.com>...
I have an unsigned 8-bit comparator in verilog, How would I change it
to become a signed 8-bit comparator?
if eqn is (a>b)?
well you can use the two sign bits and make 2 to 1 mux with
if both are positive select the comparator output,
if both are negetive invert the comparator ouput,
if they are different and a is +ve then select comparator output.
if they are different and b is +ve then select not of comparator output.
 
Neo wrote:

st0p@hotmail.com (ATran) wrote in message news:<425982b8.0411212030.29fb1a19@posting.google.com>...

I have an unsigned 8-bit comparator in verilog, How would I change it
to become a signed 8-bit comparator?

if eqn is (a>b)?
well you can use the two sign bits and make 2 to 1 mux with
if both are positive select the comparator output,
if both are negetive invert the comparator ouput,
if they are different and a is +ve then select comparator output.
if they are different and b is +ve then select not of comparator output.
Shouldn't it be the positive one is greater if the signs are different?

Anyway, invert the sign bits and do an unsigned compare.

If this is homework, reference the newsgroup as a source.

Did you know that the 8080 and Z80 don't have signed compare
instructions?

-- glen
 
glen herrmannsfeldt <gah@ugcs.caltech.edu> wrote in message news:<co2j30$is3$1@gnus01.u.washington.edu>...
Anyway, invert the sign bits and do an unsigned compare.
Or I think you could save the inverters by feeding the sign bit
of operand a in as the MSB of operand b, and vice versa.
 
Steven Sharp wrote:

glen herrmannsfeldt <gah@ugcs.caltech.edu> wrote in message news:<co2j30$is3$1@gnus01.u.washington.edu>...

Anyway, invert the sign bits and do an unsigned compare.

Or I think you could save the inverters by feeding the sign bit
of operand a in as the MSB of operand b, and vice versa.
In FPGA designs, inverters are free in just about every case,
though exchanging bits shouldn't be too slow.

In software, exchanging sign bits is expensive, but, yes,
in non-FPGA logic you could exchange them. There might be
some routing cost, but it should be small.

-- glen
 

Welcome to EDABoard.com

Sponsor

Back
Top