max and min

Joined
Dec 9, 2009
Messages
18
Reaction score
0
Hello
I have 2 8 bit vectors A and B and i need to write a vhdl code to find the maximum and minimum bewtween A and B but the comparison is to be done for two’s complement number so I can't use the built in < and > operators..any idea guys?

Thank you
 
Joined
Dec 9, 2009
Messages
18
Reaction score
0
yeah but what i mean is:

if i have A=11000011 and B=00011001 then using the operator i will have A>B but because these are 2's complement B is greater than A because A is negative and B positive
 
Joined
Jan 29, 2009
Messages
152
Reaction score
0
in that case you're (incorrectly) interpreting them as unsigned,
you should be able to "cast" an unsigned value to a signed value (2nd complement interpretation), like,
signed(A) > signed(B)

Or only use signed instead of unsigned in the design (depending on your needs, one may be a better solution than the other)
 
Joined
Dec 9, 2009
Messages
18
Reaction score
0
i did not understand what you said

the question says:

8-bit Comparison Operations

Control Signals C Operation
0101 Minimum of A and B
0110 Maximum of A and B
The comparison is to be done for two’s complement numbers and you are supposed to implement it yourself, so do not use the built in > and < available for standard logic vectors.
 
Joined
Jan 29, 2009
Messages
152
Reaction score
0
You didn't say that before;

I don't think anyone here is going to solve your homework for you;
I'll just say this. Looking at the binary representations,

- Assuming both numbers are positive, how can you see which is bigger?
- Assuming both numbers are negative, how can you see which is bigger?
- Assuming one is positive, one is negative, how can you see which is bigger?

Try and answer those, case by case, then try and implement it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Min() max() and clamp() 2
Why no min / max 14
VHDL Subtraction two’s complement 0
min-max template 3
min max from tuples in list 23
min/max: "stable" invariant? 1
Min max program 10
Max Min 1

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top