SlideShare a Scribd company logo
1 of 74
Download to read offline
Digital Arithmetic and
Arithmetic Circuits
 Signed Binary Number:
◦ A binary number of fixed length whose sign
(+/–) is represented by one bit (usually MSB)
and its magnitude by the remaining bits.
 Unsigned Binary Number:
◦ A binary number of fixed length whose sign is
not specified by a bit. All bits are magnitude
and the sign is assumed +.
2
 Sum:
◦ Result of an Addition Operation of two (or more)
binary numbers (operands).
 Carry:
◦ A digit (or bit) that is carried over to the next
most significant bit during an n-Bit addition
operation.
 The carry bit is a 1 if the result was too
large to be expressed in n bits.
3
One-Bit Unsigned Addition
4
11111
01110
10010
00000
CBAC outin





5
bitoutCarry
10100000111100
001001111010
1010111010010
1111nexttocarry1


bitoutCarry
10100000111100
001001111010
1010111010010
1111nexttocarry1


 Basic Subtraction of x = a – b, with a =
minuend, b = subtrahend, and x = difference
or result.
 Requires a Borrow Bit if a < b.
 There are other forms of subtraction such as
2’s Complement Addition used by
microprocessors (such as in a PC).
6
7
111-11
001-10
100-10
000-00
DiffBorrowin




BAB
8
10101
110101-
LSBtoripplesBorrow0111(10)10000
1010
11001001-
StageBorrow110(10)1110
 Sign Bit:
◦ A bit (usually the MSB) that indicates whether a
number is positive (= 0) or negative (= 1).
 Magnitude Bits:
◦ The bits of a signed binary number that tell how
large it is in value.
9
 True-Magnitude Form:
◦ A form of signed binary whose magnitude bits are
the TRUE binary form (not complements).
10
 1’s Complement:
◦ A form of signed binary in which negative
numbers are created by complementing all bits.
 2’s Complement:
◦ A form of signed binary in which the negative
numbers are created by complementing all the
bits and adding a 1 (1’s Complement + 1).
11
 5-Bit Numbers Negative Sign (S = 1)
 +25 = 011001 (Note sign bit (MSB) Sign =
0)
 –25 = 111001 (Same as +25 with sign = 1)
 +12 = 001100
 –12 = 101100
12
 8-Bit 1’s Complement Negative (S = 1)
 +57 = 00111001
 –57 = 11000110 (All Bits Inverted)
 +72 = 01001000
 –72 = 10110111
13
 Used in MPU (PC) Arithmetic
14
01111011
1
0110110057-
1001001157



10001011
1
0111101172-
1072


 000100
1’s complement
2’s complement
 Signed Addition Positive (S = 0)
 Similar to binary addition with a sign bit.
15
10010101
1011010075
1100000130


 Add the 1’s Complement and then Carry.
 Uses an End around carry addition
method.
16
11110000
1
111000001
65)Comps(1'1110101165)(0001010065-
0000010180)(0000010180



 Add 2’s Complement to Minuend.
ResultfromBitCarryDiscard
11110000111110101165
111110110001010065
000001010000010180




17
 If the True-Magnitude Form is used for
subtraction, the results are incorrect.
 If the result is from 1’s or 2’s Complement
and the result is negative (S = 1), the
magnitude is found by taking the
complement of the result.
18
 2’s Complement Negative Result
(65 – 80)
19
11110000)15(ResultFinal
11Add
11100000Invert
00011111
00000111C.)s(2'0000101180-
000101000001010065
10



 Range of Positive Numbers is 0 to 2n – 1 for
a number with n magnitude bits.
 Range of Negative Numbers is –1 to –2n for
a number with n magnitude bits.
 8-Bit Example:
8-Bit Number Range is –2n  x  +2n – 1
or –128 to +127
20
 Overflow:
◦ An erroneous carry into the sign bit of a signed
binary number
◦ Results from a sum or difference that is larger
than can be represented by the magnitude bits.
 Results in a False Positive or False Negative
Number.
21
 Addition of two 8-Bit Positive Numbers:
 Two positive numbers added with a result
greater than the range of +127 for 8-bit
numbers causes an overflow.
22
(False)NegativeisResult10111010
0000011096
1011010075


 Addition of two 8-Bit Negative Numbers:
 Two Negative numbers were added to
produce a False Positive Result due to
overflowing the negative range of 8-bit
numbers (0 to –127).
23
(False)PositiveisResult11110110
1111101165
0000101180


 Similar to decimal addition with a range of
digits of 0 to 9 and A to F.
 Examples:
F + 1 = 10
F + F = 1E
F + F + 1 = 1F
24
 For sums greater than 15, subtract 16 and carry 1
to the next position.
25
414FHHex
4)(15)(1)4)((
9)(12)1)(10)((
(11)(3)6)2)((
11Carry
5)(16)(20)(1(3)
9)(12)1)(10)((1A9CH
3)(11)(6)2)((26B3H
EquivalentDecimalHex



26
C17HHex
7)((1)0)(12)(
(12)(9)(10)(1)-
3)(10)(166)(1)(16
11Borrow
position.previousthefrom
)(1610Hborrowdigit,tsignificanleastthesubtractTo
(12)(1)(10)(9)1A9CH
(3)(2)(6)(11)26B3H
EquivalentDecimalHex
10




 BCD Code (Binary-Coded Decimal): A code
used to represent each decimal digit of a
number by a 4-Bit Binary Value.
 Valid Digits for 0 to 9 are 0000 to 1001.
◦ The binary codes 1010 to 1111 are invalid
 Called an 8421 Code due to the decimal
weight of each bit position.
27
 Each digit is a 4-Bit Binary group:
(84)10 = 1000 0100
(4987)10 = 0100 1001 1000 0111BCD
28
 A BCD Code formed by adding 3 (0011) to
its true 4-bit binary value.
 Excess-3 is a self-complementing code:
◦ A negative code equivalent can be found by
inverting the binary bits of the positive code
 Inverting the bits of the Excess-3 digit
yields 9’s Complement of the decimal
equivalent.
29
 3 = 0011 + 0011 = 0110 = 6 in E3.
 1 = 0001 + 0011 = 0100 = 4 in E3.
 If we complement 1 = 1011 in E3, this is the
code for an 8.
◦ 9’s Complement of 1 = (9 – 1) = 8 (Self-
Complement)
30
 A binary code that progresses so that only
one bit changes between two successive
codes.
31
 Binary: b3b2b1b0
 Gray: g3g2g1g0
 Gray code bits can be defined as follows:
g3 = b3
g2 = b3  b2
g1 = b2  b1
g0 = b1  b0
32
 American Standard Code for Information
Interchange.
 A seven-bit alphanumeric code used to
represent text letters, numerals, punctuation,
and special controls.
 An expanded 8-bit form is becoming more
widespread.
33
 Half Adder (HA): A circuit that will add two
bits and produce a sum bit and a carry bit.
 Full Adder (FA): A circuit that will add a carry
bit from another HA or FA and two operand
bits to produce a sum bit and a carry bit.
34
 Binary Two-Bit Addition Rules:
0 + 0 = 00
0 + 1 = 01
1 + 1 = 10
35
 Basic Equations: S = A XOR B, C = A and
B where S = Sum and C = Carry.
 Truth Table for HA Block:
36
1011
0101
0110
0000
OUTCBA Σ
OUT ABC
BABABA


37
 Adds a CIN input to the HA block.
 Equations are modified as follows:
 A FA can be made from two HA blocks and an
OR Gate.
38
IN
INOUT
)(
)(
CBA
A BCBAC



39
40
41
 A circuit, consisting of n full adders, that will
add n-bit binary numbers.
 The output consists of n sum bits and a carry
bit.
 COUT of one full adder is connected to CIN of
the next full adder.
42
43
 In the n-Bit Parallel Adder (FA Stages) the
Carryout is generated by the last stage (FAN).
 This is called a Ripple Carry Adder because
the final carryout (Last Stage) is based on a
ripple through each stage by CIN at the LSB
Stage.
44
 Each Stage will have a propagation delay on
the CIN to COUT of one AND Gate and one OR
Gate.
 A 4-Bit Ripple Carry Adder will then have a
propagation delay on the final COUT of 4  2 =
8 Gates.
 A 32-Bit adder such as in an MPU in a PC
could have a delay of 64 Gates.
45
46
 Fast Carry or Look-Ahead Carry:
◦ A combinational network that generates the final
COUT directly from the operand bits (A1 to An, B1 to
Bn).
◦ It is independent of the operations of each FA Stage
(as the ripple carry is).
47
 Fast Carry has a small propagation delay
compared to the ripple carry.
 The fast carry delay is 3 Gates for a 4-Bit
Adder compared to 8 for the Ripple Carry.
48
 Created in VHDL by using multiple instances
of a full adder component in the top-level file
of a VHDL design hierarchy.
49
50
ENTITY full_add IS
PORT(
a, b, c_in : IN STD_LOGIC;
c_out, sum : OUT STD_LOGIC;
END full_add;
ARCHITECTURE adder OF full_add IS
BEGIN
c_out <= ((a xor b) and c_in) or (a and b);
sum <= (a xor b) xor c_ini;
END adder;
51
 Requires a separate component file for a full
adder, saved in a folder where the compiler
can find it.
 A component declaration statement in the
top-level file of the design hierarchy.
 A component instantiation statement for each
instance of the full adder component.
52
ENTITY add4par IS
PORT(
c0 : IN STD_LOGIC;
a,b : IN STD_LOGIC_VECTOR (4 downto 1);
c4 : OUT STD_LOGIC;
sum : OUT STD_LOGIC_VECTOR (4 downto 1);
END add4par;
53
ARCHITECTURE adder OF add4par IS
-- Component declaration.
COMPONENT full_add
PORT(
a, b, c_in : IN STD_LOGIC;
c_out, sum : OUT STD_LOGIC;
END COMPONENT;
-- Define a signal for the internal carry bits
SIGNAL c : STD_LOGIC_VECTOR (3 downto 1);
54
BEGIN
-- four component instantiation statements.
adder1 : full_add
PORT MAP (a => a(1),
b => b(1),
c_in => c0,
c_out => c(1) -- connects to c_in of adder 2.
sum => sum(1));
• • •
• • •
END adder;
55
ENTITY add4gen IS
PORT(
c0 : IN STD_LOGIC;
a,b : IN STD_LOGIC_VECTOR (4 downto 1);
c4 : OUT STD_LOGIC;
sum : OUT STD_LOGIC_VECTOR (4 downto 1));
END add4gen;
56
ARCHITECTURE adder OF add4gen IS
-- Component declaration
COMPONENT full_add
PORT(
a, b, c_in :IN STD_LOGIC;
c_out, sum : OUT STD_LOGIC;
END COMPONENT;
- - Defining a signal for internal carry bits.
SIGNAL c : STD_LOGIC_VECTOR (4 downto 0);
57
BEGIN
c(0) <= c0; -- Input port c0 mapped to internal
signal (c0)
adders:
FOR i IN 1 to 4 GENERATE
-- Implicit port mapping.
adder : full_add PORT MAP (a(i), b(i), c(i-1), c(i), sum (i));
END GENERATE;
c4 <= c(4); -- Output port c4 mapped to internal
signal c(4)
END adder;
58
 The concept of Subtraction using 2’s
Complement addition allows a Parallel FA to
be used.
 This could be used in a MPU ALU (Arithmetic
Logic Unit) for Subtraction.
 The subtract operation involves adding the
inverse of the subtrahend to the minuend and
then adding a 1.
59
 This operation can be done in a parallel n-
Bit FA by inverting (B1 to Bn) and connecting
CIN at the LSB Stage to +5 V.
 The circuit can be modified to allow either
the ADD or SUBTRACT operation to be
performed.
60
1Difference  BABA
61
 XOR gates are used as programmable
inverters to pass binary numbers (e.g.,
B1B2B3B4) to the parallel adder in true or
complemented form.

62
form.trueitsinis0,/SUBADDWhen
ed.complementis1,/SUBADDWhen
B
B


63
64
ENTITY addsub4g IS
PORT(
sub : IN BIT;
a,b : IN BIT_VECTOR (4 downto 1);
c4 : OUT BIT;
sum : OUT BIT_VECTOR (4 downto 1));
END addsub4g;
65
ARCHITECTURE adder OF addsub4g IS
COMPONENT full_add
PORT(
a, b, c_in : IN BIT;
c_out : OUT BIT);
END COMPONENT;
- - Define a signal for internal carry bits
SIGNAL c : BIT_VECTOR (4 downto 0);
SIGNAL b_comp : BIT_VECTOR (4 downto 1);
BEGIN
66
- - add/subtract select to carry input (sub = 1 for subtract)
c(0) <= sub;
adders:
FOR i IN 1 to 4 GENERATE
--invert b for subtract function (b(i) xor 1,)
--do not invert b for add function (b(i) xor 0)
b_comp(i) <= b(i) xor sub;
adder: full_add PORT MAP (a(i), b_comp(i), c(I -1), c(i), sum (i));
END GENERATE;
C4 <= C(4);
END adder;
67
 If the sign bits of both operands are the same
and the sign bit of the sum is different from
the operand sign bits, an overflow has
occurred.
 Overflow is not possible if the sign bits of the
operands are different from each other.
68
 Adding two 8-bit negative numbers:
 Adding two 8-bit positive numbers:
)1overflow;bit(Sign000010000
00001000
H100
H80
00001000H80


V
)1overflow;bit(Sign00001000
00010000
H80
H01
11110111FH7


V
69
70
sum)ofbitSign(SSS
)ofbitSign(BBS
)ofbitSign(AAS
1234567
B1234567B
A1234567A



 SSSSSS
BSBBBBB
ASAAAAA
  SSSSSSV BABA
71
SA SB S V
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 0
72
AS BS S
  SSSSSSV BABA
 A Parallel Adder whose output sum is in
groups of 4 bits, each representing a BCD
(8421) Digit.
 Basic design is a 4-Bit Binary Parallel Adder to
generate a 4-Bit Sum of A + B.
 Sum is input to the four-bit input of a Binary-
to-BCD Code Converter.
73
74

More Related Content

What's hot

What's hot (20)

Adder ppt
Adder pptAdder ppt
Adder ppt
 
Bcd
BcdBcd
Bcd
 
flip flops
flip flops flip flops
flip flops
 
latches
 latches latches
latches
 
Logic gates - AND, OR, NOT, NOR, NAND, XOR, XNOR Gates.
Logic gates - AND, OR, NOT, NOR, NAND, XOR, XNOR Gates.Logic gates - AND, OR, NOT, NOR, NAND, XOR, XNOR Gates.
Logic gates - AND, OR, NOT, NOR, NAND, XOR, XNOR Gates.
 
Subtractor
SubtractorSubtractor
Subtractor
 
BOOLEAN ALGEBRA AND LOGIC GATE
BOOLEAN ALGEBRA AND LOGIC GATE BOOLEAN ALGEBRA AND LOGIC GATE
BOOLEAN ALGEBRA AND LOGIC GATE
 
Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)
 
Logic gates and NAND and NOR univarsal gates
Logic gates and NAND and NOR univarsal gatesLogic gates and NAND and NOR univarsal gates
Logic gates and NAND and NOR univarsal gates
 
Encoder and decoder
Encoder and decoderEncoder and decoder
Encoder and decoder
 
Multiplexers
MultiplexersMultiplexers
Multiplexers
 
Combinational circuits
Combinational circuits Combinational circuits
Combinational circuits
 
Combinational circuit
Combinational circuitCombinational circuit
Combinational circuit
 
Magnitude comparator
Magnitude comparatorMagnitude comparator
Magnitude comparator
 
Introduction to Counters
Introduction to CountersIntroduction to Counters
Introduction to Counters
 
Chapter 4: Combinational Logic
Chapter 4: Combinational LogicChapter 4: Combinational Logic
Chapter 4: Combinational Logic
 
sequential circuits
sequential circuitssequential circuits
sequential circuits
 
Logic gates
Logic gatesLogic gates
Logic gates
 
Registers
RegistersRegisters
Registers
 
Digital Logic Design
Digital Logic Design Digital Logic Design
Digital Logic Design
 

Similar to Digital Arithmetic and Circuits Guide

Computer organization and architecture lab manual
Computer organization and architecture lab manual Computer organization and architecture lab manual
Computer organization and architecture lab manual Shankar Gangaju
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptskatiarrahaman
 
Computer Organization And Architecture lab manual
Computer Organization And Architecture lab manualComputer Organization And Architecture lab manual
Computer Organization And Architecture lab manualNitesh Dubey
 
combinational-circuit (1).ppt
combinational-circuit (1).pptcombinational-circuit (1).ppt
combinational-circuit (1).pptThanmayiKumar
 
DLD Lecture No 20 Look Ahead Carry Generator, Binary Subtractors and BCD Add...
DLD Lecture No 20 Look Ahead Carry Generator, Binary Subtractors and  BCD Add...DLD Lecture No 20 Look Ahead Carry Generator, Binary Subtractors and  BCD Add...
DLD Lecture No 20 Look Ahead Carry Generator, Binary Subtractors and BCD Add...SaveraAyub2
 
UNIT - II.pptx
UNIT - II.pptxUNIT - II.pptx
UNIT - II.pptxamudhak10
 
COMPUTER ORGANIZATION NOTES Unit 6
COMPUTER ORGANIZATION NOTES Unit 6COMPUTER ORGANIZATION NOTES Unit 6
COMPUTER ORGANIZATION NOTES Unit 6Dr.MAYA NAYAK
 
Combinational and sequential logic
Combinational and sequential logicCombinational and sequential logic
Combinational and sequential logicDeepak John
 
Logic System Design KTU Chapter-4.ppt
Logic System Design KTU Chapter-4.pptLogic System Design KTU Chapter-4.ppt
Logic System Design KTU Chapter-4.pptAlbin562191
 
unit-i-number-systems.pdf
unit-i-number-systems.pdfunit-i-number-systems.pdf
unit-i-number-systems.pdfRameshK531901
 
Binary Adder Design(COA).ppt
Binary Adder Design(COA).pptBinary Adder Design(COA).ppt
Binary Adder Design(COA).pptRohitPaul71
 
Unit 4 combinational circuit
Unit 4 combinational circuitUnit 4 combinational circuit
Unit 4 combinational circuitKalai Selvi
 

Similar to Digital Arithmetic and Circuits Guide (20)

Computer organization and architecture lab manual
Computer organization and architecture lab manual Computer organization and architecture lab manual
Computer organization and architecture lab manual
 
Arithmetic circuits
Arithmetic circuitsArithmetic circuits
Arithmetic circuits
 
combinational-circuit (1).ppt
combinational-circuit (1).pptcombinational-circuit (1).ppt
combinational-circuit (1).ppt
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Computer Organization And Architecture lab manual
Computer Organization And Architecture lab manualComputer Organization And Architecture lab manual
Computer Organization And Architecture lab manual
 
Chapter-04.pdf
Chapter-04.pdfChapter-04.pdf
Chapter-04.pdf
 
Binary Adders.pdf
Binary Adders.pdfBinary Adders.pdf
Binary Adders.pdf
 
combinational-circuit (1).ppt
combinational-circuit (1).pptcombinational-circuit (1).ppt
combinational-circuit (1).ppt
 
DLD Lecture No 20 Look Ahead Carry Generator, Binary Subtractors and BCD Add...
DLD Lecture No 20 Look Ahead Carry Generator, Binary Subtractors and  BCD Add...DLD Lecture No 20 Look Ahead Carry Generator, Binary Subtractors and  BCD Add...
DLD Lecture No 20 Look Ahead Carry Generator, Binary Subtractors and BCD Add...
 
Lect 1 unit 2.pdf
Lect 1 unit 2.pdfLect 1 unit 2.pdf
Lect 1 unit 2.pdf
 
UNIT - II.pptx
UNIT - II.pptxUNIT - II.pptx
UNIT - II.pptx
 
COMPUTER ORGANIZATION NOTES Unit 6
COMPUTER ORGANIZATION NOTES Unit 6COMPUTER ORGANIZATION NOTES Unit 6
COMPUTER ORGANIZATION NOTES Unit 6
 
Combinational and sequential logic
Combinational and sequential logicCombinational and sequential logic
Combinational and sequential logic
 
Logic gates
Logic gatesLogic gates
Logic gates
 
Unit 4 dica
Unit 4 dicaUnit 4 dica
Unit 4 dica
 
Logic System Design KTU Chapter-4.ppt
Logic System Design KTU Chapter-4.pptLogic System Design KTU Chapter-4.ppt
Logic System Design KTU Chapter-4.ppt
 
unit-i-number-systems.pdf
unit-i-number-systems.pdfunit-i-number-systems.pdf
unit-i-number-systems.pdf
 
Binary Adder Design(COA).ppt
Binary Adder Design(COA).pptBinary Adder Design(COA).ppt
Binary Adder Design(COA).ppt
 
Unit 4 combinational circuit
Unit 4 combinational circuitUnit 4 combinational circuit
Unit 4 combinational circuit
 

More from SSE_AndyLi

Chapter 06 Combinational Logic Functions
Chapter 06 Combinational Logic FunctionsChapter 06 Combinational Logic Functions
Chapter 06 Combinational Logic FunctionsSSE_AndyLi
 
Chapter 5 introduction to VHDL
Chapter 5 introduction to VHDLChapter 5 introduction to VHDL
Chapter 5 introduction to VHDLSSE_AndyLi
 
Chapter 03 Boolean Algebra and Combinational Logic
Chapter 03 Boolean Algebra and Combinational LogicChapter 03 Boolean Algebra and Combinational Logic
Chapter 03 Boolean Algebra and Combinational LogicSSE_AndyLi
 
Chapter 02 Logic Functions and Gates
Chapter 02 Logic Functions and GatesChapter 02 Logic Functions and Gates
Chapter 02 Logic Functions and GatesSSE_AndyLi
 
Chapter 01 Basic Principles of Digital Systems
Chapter 01 Basic Principles of Digital SystemsChapter 01 Basic Principles of Digital Systems
Chapter 01 Basic Principles of Digital SystemsSSE_AndyLi
 
15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mst15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mstSSE_AndyLi
 
14 chapter9 graph_algorithmstopologicalsort_shortestpath
14 chapter9 graph_algorithmstopologicalsort_shortestpath14 chapter9 graph_algorithmstopologicalsort_shortestpath
14 chapter9 graph_algorithmstopologicalsort_shortestpathSSE_AndyLi
 
10 chapter6 heaps_priority_queues
10 chapter6 heaps_priority_queues10 chapter6 heaps_priority_queues
10 chapter6 heaps_priority_queuesSSE_AndyLi
 
9 chapter4 trees_avl
9 chapter4 trees_avl9 chapter4 trees_avl
9 chapter4 trees_avlSSE_AndyLi
 
8 chapter4 trees_bst
8 chapter4 trees_bst8 chapter4 trees_bst
8 chapter4 trees_bstSSE_AndyLi
 
7 chapter4 trees_binary
7 chapter4 trees_binary7 chapter4 trees_binary
7 chapter4 trees_binarySSE_AndyLi
 
6 chapter3 list_stackqueuepart3
6 chapter3 list_stackqueuepart36 chapter3 list_stackqueuepart3
6 chapter3 list_stackqueuepart3SSE_AndyLi
 
5 chapter3 list_stackqueuepart2
5 chapter3 list_stackqueuepart25 chapter3 list_stackqueuepart2
5 chapter3 list_stackqueuepart2SSE_AndyLi
 
4 chapter3 list_stackqueuepart1
4 chapter3 list_stackqueuepart14 chapter3 list_stackqueuepart1
4 chapter3 list_stackqueuepart1SSE_AndyLi
 
3 chapter2 algorithm_analysispart2
3 chapter2 algorithm_analysispart23 chapter2 algorithm_analysispart2
3 chapter2 algorithm_analysispart2SSE_AndyLi
 
2 chapter2 algorithm_analysispart1
2 chapter2 algorithm_analysispart12 chapter2 algorithm_analysispart1
2 chapter2 algorithm_analysispart1SSE_AndyLi
 
1 chapter1 introduction
1 chapter1 introduction1 chapter1 introduction
1 chapter1 introductionSSE_AndyLi
 

More from SSE_AndyLi (17)

Chapter 06 Combinational Logic Functions
Chapter 06 Combinational Logic FunctionsChapter 06 Combinational Logic Functions
Chapter 06 Combinational Logic Functions
 
Chapter 5 introduction to VHDL
Chapter 5 introduction to VHDLChapter 5 introduction to VHDL
Chapter 5 introduction to VHDL
 
Chapter 03 Boolean Algebra and Combinational Logic
Chapter 03 Boolean Algebra and Combinational LogicChapter 03 Boolean Algebra and Combinational Logic
Chapter 03 Boolean Algebra and Combinational Logic
 
Chapter 02 Logic Functions and Gates
Chapter 02 Logic Functions and GatesChapter 02 Logic Functions and Gates
Chapter 02 Logic Functions and Gates
 
Chapter 01 Basic Principles of Digital Systems
Chapter 01 Basic Principles of Digital SystemsChapter 01 Basic Principles of Digital Systems
Chapter 01 Basic Principles of Digital Systems
 
15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mst15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mst
 
14 chapter9 graph_algorithmstopologicalsort_shortestpath
14 chapter9 graph_algorithmstopologicalsort_shortestpath14 chapter9 graph_algorithmstopologicalsort_shortestpath
14 chapter9 graph_algorithmstopologicalsort_shortestpath
 
10 chapter6 heaps_priority_queues
10 chapter6 heaps_priority_queues10 chapter6 heaps_priority_queues
10 chapter6 heaps_priority_queues
 
9 chapter4 trees_avl
9 chapter4 trees_avl9 chapter4 trees_avl
9 chapter4 trees_avl
 
8 chapter4 trees_bst
8 chapter4 trees_bst8 chapter4 trees_bst
8 chapter4 trees_bst
 
7 chapter4 trees_binary
7 chapter4 trees_binary7 chapter4 trees_binary
7 chapter4 trees_binary
 
6 chapter3 list_stackqueuepart3
6 chapter3 list_stackqueuepart36 chapter3 list_stackqueuepart3
6 chapter3 list_stackqueuepart3
 
5 chapter3 list_stackqueuepart2
5 chapter3 list_stackqueuepart25 chapter3 list_stackqueuepart2
5 chapter3 list_stackqueuepart2
 
4 chapter3 list_stackqueuepart1
4 chapter3 list_stackqueuepart14 chapter3 list_stackqueuepart1
4 chapter3 list_stackqueuepart1
 
3 chapter2 algorithm_analysispart2
3 chapter2 algorithm_analysispart23 chapter2 algorithm_analysispart2
3 chapter2 algorithm_analysispart2
 
2 chapter2 algorithm_analysispart1
2 chapter2 algorithm_analysispart12 chapter2 algorithm_analysispart1
2 chapter2 algorithm_analysispart1
 
1 chapter1 introduction
1 chapter1 introduction1 chapter1 introduction
1 chapter1 introduction
 

Recently uploaded

Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIkoyaldeepu123
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 

Recently uploaded (20)

Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AI
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 

Digital Arithmetic and Circuits Guide

  • 2.  Signed Binary Number: ◦ A binary number of fixed length whose sign (+/–) is represented by one bit (usually MSB) and its magnitude by the remaining bits.  Unsigned Binary Number: ◦ A binary number of fixed length whose sign is not specified by a bit. All bits are magnitude and the sign is assumed +. 2
  • 3.  Sum: ◦ Result of an Addition Operation of two (or more) binary numbers (operands).  Carry: ◦ A digit (or bit) that is carried over to the next most significant bit during an n-Bit addition operation.  The carry bit is a 1 if the result was too large to be expressed in n bits. 3
  • 4. One-Bit Unsigned Addition 4 11111 01110 10010 00000 CBAC outin     
  • 6.  Basic Subtraction of x = a – b, with a = minuend, b = subtrahend, and x = difference or result.  Requires a Borrow Bit if a < b.  There are other forms of subtraction such as 2’s Complement Addition used by microprocessors (such as in a PC). 6
  • 9.  Sign Bit: ◦ A bit (usually the MSB) that indicates whether a number is positive (= 0) or negative (= 1).  Magnitude Bits: ◦ The bits of a signed binary number that tell how large it is in value. 9
  • 10.  True-Magnitude Form: ◦ A form of signed binary whose magnitude bits are the TRUE binary form (not complements). 10
  • 11.  1’s Complement: ◦ A form of signed binary in which negative numbers are created by complementing all bits.  2’s Complement: ◦ A form of signed binary in which the negative numbers are created by complementing all the bits and adding a 1 (1’s Complement + 1). 11
  • 12.  5-Bit Numbers Negative Sign (S = 1)  +25 = 011001 (Note sign bit (MSB) Sign = 0)  –25 = 111001 (Same as +25 with sign = 1)  +12 = 001100  –12 = 101100 12
  • 13.  8-Bit 1’s Complement Negative (S = 1)  +57 = 00111001  –57 = 11000110 (All Bits Inverted)  +72 = 01001000  –72 = 10110111 13
  • 14.  Used in MPU (PC) Arithmetic 14 01111011 1 0110110057- 1001001157    10001011 1 0111101172- 1072    000100 1’s complement 2’s complement
  • 15.  Signed Addition Positive (S = 0)  Similar to binary addition with a sign bit. 15 10010101 1011010075 1100000130  
  • 16.  Add the 1’s Complement and then Carry.  Uses an End around carry addition method. 16 11110000 1 111000001 65)Comps(1'1110101165)(0001010065- 0000010180)(0000010180   
  • 17.  Add 2’s Complement to Minuend. ResultfromBitCarryDiscard 11110000111110101165 111110110001010065 000001010000010180     17
  • 18.  If the True-Magnitude Form is used for subtraction, the results are incorrect.  If the result is from 1’s or 2’s Complement and the result is negative (S = 1), the magnitude is found by taking the complement of the result. 18
  • 19.  2’s Complement Negative Result (65 – 80) 19 11110000)15(ResultFinal 11Add 11100000Invert 00011111 00000111C.)s(2'0000101180- 000101000001010065 10   
  • 20.  Range of Positive Numbers is 0 to 2n – 1 for a number with n magnitude bits.  Range of Negative Numbers is –1 to –2n for a number with n magnitude bits.  8-Bit Example: 8-Bit Number Range is –2n  x  +2n – 1 or –128 to +127 20
  • 21.  Overflow: ◦ An erroneous carry into the sign bit of a signed binary number ◦ Results from a sum or difference that is larger than can be represented by the magnitude bits.  Results in a False Positive or False Negative Number. 21
  • 22.  Addition of two 8-Bit Positive Numbers:  Two positive numbers added with a result greater than the range of +127 for 8-bit numbers causes an overflow. 22 (False)NegativeisResult10111010 0000011096 1011010075  
  • 23.  Addition of two 8-Bit Negative Numbers:  Two Negative numbers were added to produce a False Positive Result due to overflowing the negative range of 8-bit numbers (0 to –127). 23 (False)PositiveisResult11110110 1111101165 0000101180  
  • 24.  Similar to decimal addition with a range of digits of 0 to 9 and A to F.  Examples: F + 1 = 10 F + F = 1E F + F + 1 = 1F 24
  • 25.  For sums greater than 15, subtract 16 and carry 1 to the next position. 25 414FHHex 4)(15)(1)4)(( 9)(12)1)(10)(( (11)(3)6)2)(( 11Carry 5)(16)(20)(1(3) 9)(12)1)(10)((1A9CH 3)(11)(6)2)((26B3H EquivalentDecimalHex   
  • 27.  BCD Code (Binary-Coded Decimal): A code used to represent each decimal digit of a number by a 4-Bit Binary Value.  Valid Digits for 0 to 9 are 0000 to 1001. ◦ The binary codes 1010 to 1111 are invalid  Called an 8421 Code due to the decimal weight of each bit position. 27
  • 28.  Each digit is a 4-Bit Binary group: (84)10 = 1000 0100 (4987)10 = 0100 1001 1000 0111BCD 28
  • 29.  A BCD Code formed by adding 3 (0011) to its true 4-bit binary value.  Excess-3 is a self-complementing code: ◦ A negative code equivalent can be found by inverting the binary bits of the positive code  Inverting the bits of the Excess-3 digit yields 9’s Complement of the decimal equivalent. 29
  • 30.  3 = 0011 + 0011 = 0110 = 6 in E3.  1 = 0001 + 0011 = 0100 = 4 in E3.  If we complement 1 = 1011 in E3, this is the code for an 8. ◦ 9’s Complement of 1 = (9 – 1) = 8 (Self- Complement) 30
  • 31.  A binary code that progresses so that only one bit changes between two successive codes. 31
  • 32.  Binary: b3b2b1b0  Gray: g3g2g1g0  Gray code bits can be defined as follows: g3 = b3 g2 = b3  b2 g1 = b2  b1 g0 = b1  b0 32
  • 33.  American Standard Code for Information Interchange.  A seven-bit alphanumeric code used to represent text letters, numerals, punctuation, and special controls.  An expanded 8-bit form is becoming more widespread. 33
  • 34.  Half Adder (HA): A circuit that will add two bits and produce a sum bit and a carry bit.  Full Adder (FA): A circuit that will add a carry bit from another HA or FA and two operand bits to produce a sum bit and a carry bit. 34
  • 35.  Binary Two-Bit Addition Rules: 0 + 0 = 00 0 + 1 = 01 1 + 1 = 10 35
  • 36.  Basic Equations: S = A XOR B, C = A and B where S = Sum and C = Carry.  Truth Table for HA Block: 36 1011 0101 0110 0000 OUTCBA Σ OUT ABC BABABA  
  • 37. 37
  • 38.  Adds a CIN input to the HA block.  Equations are modified as follows:  A FA can be made from two HA blocks and an OR Gate. 38 IN INOUT )( )( CBA A BCBAC   
  • 39. 39
  • 40. 40
  • 41. 41
  • 42.  A circuit, consisting of n full adders, that will add n-bit binary numbers.  The output consists of n sum bits and a carry bit.  COUT of one full adder is connected to CIN of the next full adder. 42
  • 43. 43
  • 44.  In the n-Bit Parallel Adder (FA Stages) the Carryout is generated by the last stage (FAN).  This is called a Ripple Carry Adder because the final carryout (Last Stage) is based on a ripple through each stage by CIN at the LSB Stage. 44
  • 45.  Each Stage will have a propagation delay on the CIN to COUT of one AND Gate and one OR Gate.  A 4-Bit Ripple Carry Adder will then have a propagation delay on the final COUT of 4  2 = 8 Gates.  A 32-Bit adder such as in an MPU in a PC could have a delay of 64 Gates. 45
  • 46. 46
  • 47.  Fast Carry or Look-Ahead Carry: ◦ A combinational network that generates the final COUT directly from the operand bits (A1 to An, B1 to Bn). ◦ It is independent of the operations of each FA Stage (as the ripple carry is). 47
  • 48.  Fast Carry has a small propagation delay compared to the ripple carry.  The fast carry delay is 3 Gates for a 4-Bit Adder compared to 8 for the Ripple Carry. 48
  • 49.  Created in VHDL by using multiple instances of a full adder component in the top-level file of a VHDL design hierarchy. 49
  • 50. 50
  • 51. ENTITY full_add IS PORT( a, b, c_in : IN STD_LOGIC; c_out, sum : OUT STD_LOGIC; END full_add; ARCHITECTURE adder OF full_add IS BEGIN c_out <= ((a xor b) and c_in) or (a and b); sum <= (a xor b) xor c_ini; END adder; 51
  • 52.  Requires a separate component file for a full adder, saved in a folder where the compiler can find it.  A component declaration statement in the top-level file of the design hierarchy.  A component instantiation statement for each instance of the full adder component. 52
  • 53. ENTITY add4par IS PORT( c0 : IN STD_LOGIC; a,b : IN STD_LOGIC_VECTOR (4 downto 1); c4 : OUT STD_LOGIC; sum : OUT STD_LOGIC_VECTOR (4 downto 1); END add4par; 53
  • 54. ARCHITECTURE adder OF add4par IS -- Component declaration. COMPONENT full_add PORT( a, b, c_in : IN STD_LOGIC; c_out, sum : OUT STD_LOGIC; END COMPONENT; -- Define a signal for the internal carry bits SIGNAL c : STD_LOGIC_VECTOR (3 downto 1); 54
  • 55. BEGIN -- four component instantiation statements. adder1 : full_add PORT MAP (a => a(1), b => b(1), c_in => c0, c_out => c(1) -- connects to c_in of adder 2. sum => sum(1)); • • • • • • END adder; 55
  • 56. ENTITY add4gen IS PORT( c0 : IN STD_LOGIC; a,b : IN STD_LOGIC_VECTOR (4 downto 1); c4 : OUT STD_LOGIC; sum : OUT STD_LOGIC_VECTOR (4 downto 1)); END add4gen; 56
  • 57. ARCHITECTURE adder OF add4gen IS -- Component declaration COMPONENT full_add PORT( a, b, c_in :IN STD_LOGIC; c_out, sum : OUT STD_LOGIC; END COMPONENT; - - Defining a signal for internal carry bits. SIGNAL c : STD_LOGIC_VECTOR (4 downto 0); 57
  • 58. BEGIN c(0) <= c0; -- Input port c0 mapped to internal signal (c0) adders: FOR i IN 1 to 4 GENERATE -- Implicit port mapping. adder : full_add PORT MAP (a(i), b(i), c(i-1), c(i), sum (i)); END GENERATE; c4 <= c(4); -- Output port c4 mapped to internal signal c(4) END adder; 58
  • 59.  The concept of Subtraction using 2’s Complement addition allows a Parallel FA to be used.  This could be used in a MPU ALU (Arithmetic Logic Unit) for Subtraction.  The subtract operation involves adding the inverse of the subtrahend to the minuend and then adding a 1. 59
  • 60.  This operation can be done in a parallel n- Bit FA by inverting (B1 to Bn) and connecting CIN at the LSB Stage to +5 V.  The circuit can be modified to allow either the ADD or SUBTRACT operation to be performed. 60 1Difference  BABA
  • 61. 61
  • 62.  XOR gates are used as programmable inverters to pass binary numbers (e.g., B1B2B3B4) to the parallel adder in true or complemented form.  62 form.trueitsinis0,/SUBADDWhen ed.complementis1,/SUBADDWhen B B  
  • 63. 63
  • 64. 64
  • 65. ENTITY addsub4g IS PORT( sub : IN BIT; a,b : IN BIT_VECTOR (4 downto 1); c4 : OUT BIT; sum : OUT BIT_VECTOR (4 downto 1)); END addsub4g; 65
  • 66. ARCHITECTURE adder OF addsub4g IS COMPONENT full_add PORT( a, b, c_in : IN BIT; c_out : OUT BIT); END COMPONENT; - - Define a signal for internal carry bits SIGNAL c : BIT_VECTOR (4 downto 0); SIGNAL b_comp : BIT_VECTOR (4 downto 1); BEGIN 66
  • 67. - - add/subtract select to carry input (sub = 1 for subtract) c(0) <= sub; adders: FOR i IN 1 to 4 GENERATE --invert b for subtract function (b(i) xor 1,) --do not invert b for add function (b(i) xor 0) b_comp(i) <= b(i) xor sub; adder: full_add PORT MAP (a(i), b_comp(i), c(I -1), c(i), sum (i)); END GENERATE; C4 <= C(4); END adder; 67
  • 68.  If the sign bits of both operands are the same and the sign bit of the sum is different from the operand sign bits, an overflow has occurred.  Overflow is not possible if the sign bits of the operands are different from each other. 68
  • 69.  Adding two 8-bit negative numbers:  Adding two 8-bit positive numbers: )1overflow;bit(Sign000010000 00001000 H100 H80 00001000H80   V )1overflow;bit(Sign00001000 00010000 H80 H01 11110111FH7   V 69
  • 71.   SSSSSSV BABA 71 SA SB S V 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 0
  • 72. 72 AS BS S   SSSSSSV BABA
  • 73.  A Parallel Adder whose output sum is in groups of 4 bits, each representing a BCD (8421) Digit.  Basic design is a 4-Bit Binary Parallel Adder to generate a 4-Bit Sum of A + B.  Sum is input to the four-bit input of a Binary- to-BCD Code Converter. 73
  • 74. 74