Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Overflow in subtraction

Status
Not open for further replies.

Binome

Full Member level 3
Joined
Nov 16, 2009
Messages
152
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Location
Lyon, France
Activity points
2,405
Hi,
my problem is the overflow detection when subtracting:
There are two unsigned integer 4-bit numbers (a and b), so we have 0≦a,b≦15.
I want to subtract a-b, then -15≦a-b≦15.
This result is a signed integer 4-bit number then -8≦s≦7.
I want the operator to be able to detect an overflow. How should I build my circuit? (I have to use adders knowing a-b=a+not(b)+1).
Thanks.
 

When I worked with assembly language, I seem to remember I had to set the carry bit every time before doing a subtraction. If the carry bit is zero afterward, then a borrow occurs.
 

Binome,

The CF will be set if there is a carry out or a borrow in of the most significant bit (MSB). Use a "full-subtractor" to implement this. Any good logic book should tell you how to build one.

Ratch
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top