Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > max and min

Reply
Thread Tools

max and min

 
 
qwerty321 qwerty321 is offline
Junior Member
Join Date: Dec 2009
Posts: 18
 
      12-13-2009
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
 
Reply With Quote
 
 
 
 
qwerty321 qwerty321 is offline
Junior Member
Join Date: Dec 2009
Posts: 18
 
      12-13-2009
I really need help here guys
 
Reply With Quote
 
 
 
 
joris joris is offline
Senior Member
Join Date: Jan 2009
Posts: 152
 
      12-13-2009
builtin < and > operators are defined to work on two's complement numbers.
 
Reply With Quote
 
qwerty321 qwerty321 is offline
Junior Member
Join Date: Dec 2009
Posts: 18
 
      12-13-2009
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
 
Reply With Quote
 
joris joris is offline
Senior Member
Join Date: Jan 2009
Posts: 152
 
      12-13-2009
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)
 
Reply With Quote
 
qwerty321 qwerty321 is offline
Junior Member
Join Date: Dec 2009
Posts: 18
 
      12-13-2009
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.
 
Reply With Quote
 
joris joris is offline
Senior Member
Join Date: Jan 2009
Posts: 152
 
      12-13-2009
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.
 
Reply With Quote
 
qwerty321 qwerty321 is offline
Junior Member
Join Date: Dec 2009
Posts: 18
 
      12-13-2009
it's ok i already did it
like u said also
 
Reply With Quote
 
CS_ CS_ is offline
Junior Member
Join Date: Dec 2009
Posts: 3
 
      12-14-2009
qwerty321 r u in QU ????
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When is min(a, b) != min(b, a)? Albert Hopkins Python 31 02-04-2008 07:37 PM
How to write min(a,b) instead of Math.min(a,b) juergen Java 3 09-20-2006 04:20 AM
CSS min-width, max-width, and min-height with display:inline Lois HTML 1 12-27-2004 03:03 AM
Converting hrs and min to just min carmen ASP General 4 08-10-2004 08:31 PM
Jdk 1.4.2 Error on setting heap min and max Aaron Boxer Java 3 07-07-2003 12:27 PM



Advertisments