﻿ Binary subtraction and adder-subtractor circuit Discussion with examples. 2's complement with carry.
Home Verilog Digital Design Digital Basics Python RF Basics
Chip Designing for ASIC/ FPGA Design engineers and Students
FULLCHIPDESIGN
Digital-logic Design...  Dream for many students… start learning front-end…
Topics @TYH :- 4G LTE Tutorial, GVIM editor,
Custom Search

Feedback ? Send it to admin@fullchipdesign.com or join me at fullchip@gmail.com

Binary Numbers 1s_complement 2s_complement Binary Subtraction Binary Sub. Ex's Sign_magnitude SignM EX Gray Coding BCD coding Digital gates NAND NOR & XNOR Theorems Boolean Functions BFunc Examples Minterm Maxterm Sum of Minterms Prdt of Maxterms 2 var K-map 3 var K-map 4 var K-map 5 var K-map Prime Implicant PI example K-map Ex's KMap minimization 2 var EX

Binary numbers addition is straight forward, while binary subtractions involve three fundamental steps. Detailed discussions on these steps are discussed next:

Binary subtraction and add-subtractor circuit.

Digital Logic fundamentals topics
Digital basics tutorial
Binary number discussion, 1 and 2 complement discussion,
Digital logic gates basic (AND, OR, XOR, NOT) and derived (NAND, NOR and XNOR). Drive XOR from NAND gates. Drive XOR from NOR gates
Discussion of Boolean Algebra with examples.
Duality Principle, Huntington Postulates, Theorems of Boolean Algebra - discussion with examples, Boolean Functions, Canonical and Standard Forms, Minterms and Maxterms

(valid for most EDA flows)

How to implement a(ICG) cell from vendor library.

SystemVerilog

Binary Subtraction: Suppose, M is Minuend and  N is subtrahend, Then, M – N can be done based on following three steps:

Step 1: Take 2’s complement of N and add it to M.

M – N = M + (2^n – N)

Step 2: If M is greater than or equal to N then end carry is discarded from the result.

M –N = M + (2^n – N) – 2^n

Step 3: If M is less than N then take 2’s complement of the result and append negative ‘-‘ sign in front.

M-N = (-) [2^n – (M + (2^n -1))]

Two solved examples are shown below.

Example 1 : Perform binary subtraction of two binary numbers M = 10101010 and N = 00111000

Example 2 : Perform binary subtraction of two binary numbers N = 10101010 and M = 00111000

Discard end carry from the subtraction

Answer. Binary subtraction of M and N = 01110010

1

End carry

10101010                                                         10101010

-   00111000                                                       +11001000

01110010

00111000                                                   00111000

-   10101010                                                + 01010110

Result     =    10001110

No end carry in result

2’s complement of result = 01110010

Answer. Binary subtraction of M and N = - (2’s complement of result) = -01110010

Binary addition or subtraction can be implemented using a single circuit as discussed below. With this implementation any length (no of bits = N) of binary numbers can be used to calculate the results by using  N number of full-adders and N number of XOR gates.

Circuit is very similar to the discussed earlier except for a XOR gate at second input of full-adders.
A0
A3
A2
A1
S3
S2
S1
S0
C2
C3
C0
C1
C4
Switch Mode
(SM)
Discussion of Adder-subtractor circuit above: Switch Mode (SM) is a control input to the circuit to switch between addition or subtraction operations.