Computer Architecture I: Digital Design Dr. Robert D. Kent Logic Design Medium Scale Integration and Programmable Logic Devices Part II.

Slides:



Advertisements
Similar presentations
Functions and Functional Blocks
Advertisements

Number Bases Informatics INFO I101 February 9, 2004 John C. Paolillo, Instructor.
PHY 201 (Blum) 1 Adders, Digital to Analog Conversion Ch. 8 in Digital Principles (Tokheim)
DPSD This PPT Credits to : Ms. Elakya - AP / ECE.
Arithmetic Operations and Circuits
Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design.
ECE 331 – Digital System Design
Computer Arithmetic, Multiplexers Prof. Sin-Min Lee Department of Computer Science.
Chapter 10-Arithmetic-logic units
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
Design of Arithmetic Circuits – Adders, Subtractors, BCD adders
1 COMP541 Arithmetic Circuits Montek Singh Mar 20, 2007.
Overview Iterative combinational circuits Binary adders
ECE 301 – Digital Electronics
ECE 301 – Digital Electronics
Lecture 3. Boolean Algebra, Logic Gates
Chapter 5 Arithmetic Logic Functions. Page 2 This Chapter..  We will be looking at multi-valued arithmetic and logic functions  Bitwise AND, OR, EXOR,
Propositional Calculus Math Foundations of Computer Science.
Part 2: DESIGN CIRCUIT. LOGIC CIRCUIT DESIGN x y z F F = x + y’z x y z F Truth Table Boolean Function.
Chapter 7 Arithmetic Operations and Circuits Hexadecimal Arithmetic 4 binary bits represent a single hexadecimal digit Addition –Add the digits.
Logic Gates Combinational Circuits
Building Adders & Sub tractors Dr Ahmed Telba. Introducing adder circuits Adder circuits are essential inside microprocessors as part of the ALU, or arithmetic.
CS 105 Digital Logic Design
Logic Design CS221 1 st Term combinational circuits Cairo University Faculty of Computers and Information.
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
3-1 Chapter 3 - Arithmetic Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer Architecture.
Logical Circuit Design Week 8: Arithmetic Circuits Mentor Hamiti, MSc Office ,
Chap 3. Chap 3. Combinational Logic Design. Chap Combinational Circuits l logic circuits for digital systems: combinational vs sequential l Combinational.
Basic Arithmetic (adding and subtracting)
CS1Q Computer Systems Lecture 9 Simon Gay. Lecture 9CS1Q Computer Systems - Simon Gay2 Addition We want to be able to do arithmetic on computers and therefore.
Digital Arithmetic and Arithmetic Circuits
Computer Architecture I: Digital Design Dr. Robert D. Kent Logic Design Medium Scale Integration and Programmable Logic Devices Part I.
IKI a-Combinatorial Components Bobby Nazief Semester-I The materials on these slides are adopted from those in CS231’s Lecture Notes.
Chapter 4 – Arithmetic Functions and HDLs Logic and Computer Design Fundamentals.
Fall 2004EE 3563 Digital Systems Design EE 3563 Comparators  Comparators determine if two binary inputs are equal  Some will signal greater than/less.
Chapter 6-1 ALU, Adder and Subtractor
Topic: Arithmetic Circuits Course: Digital Systems Slide no. 1 Chapter # 5: Arithmetic Circuits.
CHAPTER 4 Combinational Logic
Logic Gates Logic gates are electronic digital circuit perform logic functions. Commonly expected logic functions are already having the corresponding.
Logic Design CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
1 Lecture 6 BOOLEAN ALGEBRA and GATES Building a 32 bit processor PH 3: B.1-B.5.
EE2174: Digital Logic and Lab Professor Shiyan Hu Department of Electrical and Computer Engineering Michigan Technological University CHAPTER 8 Arithmetic.
Combinational Circuits
CS 105 DIGITAL LOGIC DESIGN Chapter 4 Combinational Logic 1.
Logic Gates Informatics INFO I101 February 3, 2003 John C. Paolillo, Instructor.
Computer Architecture I: Digital Design Dr. Robert D. Kent Logic Design Decoders and Multiplexers.
COMP541 Arithmetic Circuits
Logic Design CS221 1 st Term combinational circuits Cairo University Faculty of Computers and Information.
Arithmetic-logic units1 An arithmetic-logic unit, or ALU, performs many different arithmetic and logic operations. The ALU is the “heart” of a processor—you.
CHAPTER 2 Digital Combinational Logic/Arithmetic Circuits
1 Fundamentals of Computer Science Combinational Circuits.
Digital Logic Design Basics Combinational Circuits Sequential Circuits Pu-Jen Cheng Adapted from the slides prepared by S. Dandamudi for the book, Fundamentals.
Addition and multiplication Arithmetic is the most basic thing you can do with a computer, but it’s not as easy as you might expect! These next few lectures.
1 CS 151 : Digital Design Chapter 4: Arithmetic Functions and Circuits 4-3 : Binary Subtraction.
ECE DIGITAL LOGIC LECTURE 15: COMBINATIONAL CIRCUITS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 10/20/2015.
President UniversityErwin SitompulDigital Systems 7/1 Lecture 7 Digital Systems Dr.-Ing. Erwin Sitompul President University
LOGIC CIRCUITLOGIC CIRCUIT. Goal To understand how digital a computer can work, at the lowest level. To understand what is possible and the limitations.
Logic Design (CE1111 ) Lecture 4 (Chapter 4) Combinational Logic Prepared by Dr. Lamiaa Elshenawy 1.
ETE 204 – Digital Electronics Combinational Logic Design Single-bit and Multiple-bit Adder Circuits [Lecture: 9] Instructor: Sajib Roy Lecturer, ETE,ULAB.
Arithmetic Circuits I. 2 Iterative Combinational Circuits Like a hierachy, except functional blocks per bit.
Addition and multiplication1 Arithmetic is the most basic thing you can do with a computer, but it’s not as easy as you might expect! These next few lectures.
Chapter 6. Digital Arithmetic: Operations and Circuits
Chap 3. Combinational Logic Design
Fundamentals & Ethics of Information Systems IS 201
FUNCTION OF COMBINATIONAL LOGIC CIRCUIT
Basics Combinational Circuits Sequential Circuits
ECE 331 – Digital System Design
Week 7: Gates and Circuits: PART II
Overview Part 1 – Design Procedure Part 2 – Combinational Logic
ECE 352 Digital System Fundamentals
Presentation transcript:

Computer Architecture I: Digital Design Dr. Robert D. Kent Logic Design Medium Scale Integration and Programmable Logic Devices Part II

Review At the outset of designing a complex system, such as a modern computer or network, it is clear that design is extraordinarily difficult and computationally challenging when performed at the level of fundamental Boolean logic gates. For these reasons modern design approaches are based on hierarchical, component based methods. –Leading to simplified, localized component design, –lowering of design costs, –shifting some aspects of design to the component interface (the compatibility problem). We now continue our study of MSI circuits to better understand this process of MSI design.

Goals We continue our study of simple, but functional Combinational circuits: –we continue constructing a small library of useful components –through study of the solution process using Boolean algebra and Boolean calculus (simplification, etc.) we better understand the meaning of SSI design –we seek to identify these components for their re-use potential –through our study we will better understand how MSI increases the level of abstraction in solving problems - SSI design is relatively concrete.

Circuit # 4 : Binary Subtractor

Before proceeding to design a subtractor circuit, consider a few examples of the operation D = X - Y: Example 1 : X Y ======= D Considered “easy” because: 1-1 = 0 is easy 1-0 = 1 is easy 0-0 = 0 is easy But.....

Circuit # 4 : Binary Subtractor Example 2 : –This is not straightforward – it requires the concept of “borrowing” from the column on the left. –Use a trick – add zero! Introduce a borrow constant, B. For an L-bit representation, B = 2 L. Example 2 : B= X Y ======= D This is not a mathematical zero. Rather, it is a practical zero since we only use the low-order 4 bits.

Circuit # 4 : Binary Subtractor Example 2 : –This is not straightforward – it requires the concept of “borrowing” from the column on the left. –Use a trick – add zero! Introduce a borrow constant, B. For an L-bit representation, B = 2 L. Example 2 : B= X Y ======= D Instead of X K – Y K, we have recast this in the form B K + X K – Y K. NOTE: By borrowing from the left, each successive borrow digit becomes a 1 until the column which forces the first borrow. This specific borrow digit has the value 2 (binary 10). B=

Circuit # 4 : Binary Subtractor Example 2 : –This is not straightforward – it requires the concept of “borrowing” from the column on the left. –Use a trick – add zero! Introduce a borrow constant, B. For an L-bit representation, B = 2 L. Example 2 : B= X Y ======= D Now we note that we have already borrowed from this column (in the next-to-right column). But we also had to borrow from the next-to-left column. Hence, we borrow a ‘2’ from the left, then borrow ‘1’ from this ‘2’ to the right, the net result is to add ‘1’ to the current column. The rest of the subtraction ( )=1 is easy. B=

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K+1 X K and Y K are the inputs for (X K -Y K ) and D K is the difference (within the K’th column) B K refers to the amount of borrowing already performed (in order to carry out a subtraction in the next-to-right column) B K+1 refers to the amount of borrowing that must be done from the next-to-left column (in order to carry out a subtraction in the current K’th column) NOTE: It is understood that a ‘1’ denotes a borrow of ‘2’ in the current K’th column.

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K X K minuend - 0 Y K subtrahend 0 D K difference

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K There is no need to perform a “borrow” operation. 0 X K minuend - 0 Y K subtrahend 0 D K difference

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K X K minuend - 0 Y K subtrahend - 1 B K prior borrow 1 D K difference 1 B K+1 next borrow

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K X K minuend - 0 Y K subtrahend - 1 B K prior borrow 1 D K difference 1 B K+1 next borrow Assume that a “borrow” was required in a previous column subtraction - then we must subtract 1 from the minuend in this column.

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K X K minuend - 0 Y K subtrahend - 1 B K prior borrow 1 D K difference 1 B K+1 next borrow If the subtraction cannot be performed, then we must “borrow” from the next column. We note this borrow as B K+1, and then use the value 2 (!) for the minuend, X K. 2

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K X K minuend - 1 Y K subtrahend 1 D K difference 1 B K+1 next borrow

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K X K minuend - 1 Y K subtrahend 1 D K difference 1 B K+1 next borrow If the subtraction cannot be performed, then we must “borrow” from the next column. We note this borrow as B K+1, and then use the value 2 (!) for the minuend, X K. 2

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K X K minuend - 1 Y K subtrahend - 1 B K prior borrow 0 D K difference 1 B K+1 next borrow

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K X K minuend - 1 Y K subtrahend - 1 B K prior borrow 0 D K difference 1 B K+1 next borrow If the subtraction cannot be performed, then we must “borrow” from the next column. We note this borrow as B K+1, and then use the value 2 (!) for the minuend, X K. 2

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K X K minuend - 0 Y K subtrahend - 0 B K prior borrow 1 D K difference 0 B K+1 next borrow There is no need to perform a “borrow” operation.

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K X K minuend - 0 Y K subtrahend - 1 B K prior borrow 0 D K difference 0 B K+1 next borrow There is no need to perform a “borrow” operation.

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K X K minuend - 1 Y K subtrahend - 0 B K prior borrow 0 D K difference 0 B K+1 next borrow There is no need to perform a “borrow” operation.

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K X K minuend - 1 Y K subtrahend - 1 B K prior borrow 1 D K difference 1 B K+1 next borrow If the subtraction cannot be performed, then we must “borrow” from the next column. We note this borrow as B K+1, and then use the value 2 (!) for the minuend, X K. 2

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K The circuit expressions for the outputs are derived:

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K The circuit expressions for the outputs are derived: D K = X K ’Y K ’B K + X K ’Y K B K ’ + X K Y K ’B K ’ + X K Y K B K

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K The circuit expressions for the outputs are derived: D K = X K ’Y K ’B K + X K ’Y K B K ’ + X K Y K ’B K ’ + X K Y K B K = B K xor X K xor Y K

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K D K = B K xor X K xor Y K The circuit expressions for the outputs are derived:

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K D K = B K xor X K xor Y K The circuit expressions for the outputs are derived: B K+1 = X K ’Y K ’B K + X K ’Y K B K ’ + X K ’Y K B K + X K Y K B K

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K D K = B K xor X K xor Y K The circuit expressions for the outputs are derived: B K+1 = X K ’Y K ’B K + X K ’Y K B K ’ + X K ’Y K B K + X K Y K B K = X K ’Y K (B K + B K ’) + X K ’(Y K + Y K ’ ) B K + ( X K + X K ’)Y K B K

Circuit # 4 : Binary Subtractor We begin the design by constructing a 3-input/2-output truth table: X K Y K B K D K B K D K = B K xor X K xor Y K B K+1 = X K ’Y K + X K ’B K + Y K B K The circuit expressions for the outputs are derived: B K+1 = X K ’Y K ’B K + X K ’Y K B K ’ + X K ’Y K B K + X K Y K B K = X K ’Y K (B K + B K ’) + X K ’(Y K + Y K ’ ) B K + ( X K + X K ’)Y K B K

Circuit # 4 : Binary Subtractor This leads to the expressions: D K = B K xor X K xor Y K B K+1 = X K ’Y K + X K ’B K + Y K B K These have the logic gate realizations:

Circuit # 4 : Binary Subtractor This leads to the expressions: D K = B K xor X K xor Y K B K+1 = X K ’Y K + X K ’B K + Y K B K These have the logic gate realizations: BKXKYKBKXKYK D K B K+1 FS

Circuit # 4 : Binary Subtractor This leads to the expressions: D K = B K xor X K xor Y K B K+1 = X K ’Y K + X K ’B K + Y K B K These have the logic gate realizations: BKXKYKBKXKYK D K B K+1 FS Full Subtractor Binary Full Subtractor BKXKYKBKXKYK D K B K+1 FS

Circuit # 4 : Binary Subtractor We can now employ the 1-bit Full Subtractor to construct a multi- bit subtractor –we use a FS with B 0 = 0 for the first bit. –this can be replaced with a specialized Half-Subtractor circuit. BKXKYKBKXKYK D K B K+1 FS

Circuit # 4 : Binary Subtractor We can now employ the 1-bit Full Subtractor to construct a multi- bit subtractor –we use a FS with B 0 = 0 for the first bit. (This can be replaced with a specialized Half-Subtractor circuit). Y X B in B out S Y X B in B out S Y X B in B out S Y X B in B out S Y 0 X 0 Y 1 X 1 Y 2 X 2 Y 3 X 3 S0S0 S1S1 S3S3 S2S2 B out 0 4-bit MSI: Ripple Subtractor

Circuit # 4 : Binary Subtractor We can now employ the 1-bit Full Subtractor to construct a multi- bit subtractor –we use a FS with B 0 = 0 for the first bit. This can be replaced with a specialized Half-Subtractor circuit. Y X B in B out D Y X B in B out D Y X B in B out D Y X B in B out D Y 0 X 0 Y 1 X 1 Y 2 X 2 Y 3 X 3 D0D0 D1D1 D3D3 D2D2 B out 0 4-bit MSI: Ripple Subtractor Y 3 Y 2 Y 1 Y 0 X 3 X 2 X 1 X 0 B out B in D 3 D 2 D 1 D 0 4-bit MSI: Full Ripple Subtractor

Circuit # 4 : Binary Subtractor Note that the Full Adder and Full Subtractor are identical, except for a single inverter applied to the first input (A or X): BKXKYKBKXKYK D K B K+1 FS Full Subtractor Binary Full Subtractor BKXKYKBKXKYK D K B K+1 FS C in A B S C out FA Binary Full Adder CKXKYKCKXKYK D K C K+1 FA

Circuit # 4 : Binary Subtractor There are alternative methods to performing subtraction, based on 1’s and 2’s complement representations.

Circuit # 4 : Binary Subtractor There are alternative methods to performing subtraction, based on 1’s and 2’s complement representations. Since (X - Y) is the same as (X+Y’+1) using 2’s complement arithmetic, we can use the adder to perform subtraction by adding inverters to the Y inputs and setting the input carry bit to 1.

Circuit # 4 : Binary Subtractor There are alternative methods to performing subtraction, based on 1’s and 2’s complement representations. Since (X - Y) is the same as (X+Y’+1) using 2’s complement arithmetic, we can use the adder to perform subtraction by adding inverters to the Y inputs and setting the input carry bit to 1. Y 3 Y 2 Y 1 Y 0 X 3 X 2 X 1 X 0 C out C in S 3 S 2 S 1 S 0 4-bit MSI Full Ripple Adder 1

Circuit # 5 : Binary Adder/Subtractor

Finally, we note the following facts about the xor gate:

Circuit # 5 : Binary Adder/Subtractor Finally, we note the following facts about the xor gate: A xor 1 = A’

Circuit # 5 : Binary Adder/Subtractor Finally, we note the following facts about the xor gate: A xor 1 = A’Proof: 0 xor 1 = 1 = 0’ 1 xor 1 = 0 = 1’

Circuit # 5 : Binary Adder/Subtractor Finally, we note the following facts about the xor gate: A xor 1 = A’Proof: 0 xor 1 = 1 = 0’ 1 xor 1 = 0 = 1’ A xor 0 = A

Circuit # 5 : Binary Adder/Subtractor Finally, we note the following facts about the xor gate: A xor 1 = A’Proof: 0 xor 1 = 1 = 0’ 1 xor 1 = 0 = 1’ A xor 0 = AProof: 0 xor 0 = 0 1 xor 0 = 1

Circuit # 5 : Binary Adder/Subtractor Finally, we note the following facts about the xor gate: A xor 1 = A’Proof: 0 xor 1 = 1 = 0’ 1 xor 1 = 0 = 1’ A xor 0 = AProof: 0 xor 0 = 0 1 xor 0 = 1 These properties of the xor gate allow us to construct a circuit that can perform either addition or subtraction:

Circuit # 5 : Binary Adder/Subtractor Finally, we note the following facts about the xor gate: A xor 1 = A’Proof: 0 xor 1 = 1 = 0’ 1 xor 1 = 0 = 1’ A xor 0 = AProof: 0 xor 0 = 0 1 xor 0 = 1 These properties of the xor gate allow us to construct a circuit that can perform either addition or subtraction: S 3 S 2 S 1 S 0 4-bit MSI Full Ripple Adder/Subtractor Add(0)/ Sub(1) Y 3 Y 2 Y 1 Y 0 X 3 X 2 X 1 X 0

Circuit # 5 : Binary Adder/Subtractor Finally, we note the following facts about the xor gate: A xor 1 = A’Proof: 0 xor 1 = 1 = 0’ 1 xor 1 = 0 = 1’ A xor 0 = AProof: 0 xor 0 = 0 1 xor 0 = 1 These properties of the xor gate allow us to construct a circuit that can perform either addition or subtraction: S 3 S 2 S 1 S 0 4-bit MSI Full Ripple Adder/Subtractor Add(0)/ Sub(1) Y 3 Y 2 Y 1 Y 0 X 3 X 2 X 1 X 0 The input carry bit is used as a toggle to control the choice of addition or subtraction. +/- +/-

Circuit # 5 : Binary Adder/Subtractor Now that it has been demonstrated that subtraction can be carried out using addition circuits, we may henceforth treat only addition cases, without any loss of generality. S 3 S 2 S 1 S 0 4-bit MSI Full Ripple Adder/Subtractor Add(0)/ Sub(1) Y 3 Y 2 Y 1 Y 0 X 3 X 2 X 1 X 0 +/- +/-

Circuit # 6 : Carry Lookahead Adder

The representation of the Carry-out circuit for the full adder is: C K+1 = X K Y K + C K X K + C K Y K = X K Y K + C K (X K + Y K )

Circuit # 6 : Carry Lookahead Adder The representation of the Carry-out circuit for the full adder is: C K+1 = X K Y K + C K X K + C K Y K = X K Y K + C K (X K + Y K ) Define terms: g K = X K Y K and, p K = (X K + Y K ) We may now write: C K+1 = g K + C K p K

Circuit # 6 : Carry Lookahead Adder The representation of the Carry-out circuit for the full adder is: C K+1 = X K Y K + C K X K + C K Y K = X K Y K + C K (X K + Y K ) Define terms: g K = X K Y K and, p K = (X K + Y K ) We may now write: C K+1 = g K + C K p K Also, recall that the sum bit is generated using the expression: S K = C K xor A K xor B K

Circuit # 6 : Carry Lookahead Adder Using the expressions: C K+1 = g K + C K p K S K = C K xor A K xor B K We define the Sigma-block circuit: X K Y K C K PKGKPKGK SKSK

Circuit # 6 : Carry Lookahead Adder Using the expressions: C K+1 = g K + C K p K S K = C K xor A K xor B K We define the Sigma-block circuit: This may be abbreviated as the MSI component: X K Y K C K PKGKPKGK SKSK PKGKPKGK SKSK SIG

Circuit # 6 : Carry Lookahead Adder Using the expressions: C K+1 = g K + C K p K S K = C K r A K r B K We define the Sigma-block circuit: This may be abbreviated as the MSI component: X K Y K C K PKGKPKGK SKSK PKGKPKGK SKSK Note that both P and G only require evaluation of one logic gate. SIG

Circuit # 6 : Carry Lookahead Adder These results suggest that the previous ripple-adder circuit may be replaced by the following circuit, using Sigma-blocks: P0G0P0G0 S0S0 X 0 Y 0 C 0 P1G1P1G1 S1S1 X 1 Y 1 C 1 P3G3P3G3 S3S3 X 3 Y 3 C 3 P2G2P2G2 S2S2 X 2 Y 2 C 2 Carry lookahead network C4C4 C0C0 SIG

Circuit # 6 : Carry Lookahead Adder Expanding the carry terms for a 4-bit adder: C 1 = g 0 + C 0 p 0 C 2 = g 1 + C 1 p 1 = g 1 + (g 0 + C 0 p 0 )p 1 = g 1 + g 0 p 1 + C 0 p 0 p 1 C 3 = g 2 + C 2 p 2 = g 2 + g 1 p 2 + g 0 p 1 p 2 + C 0 p 0 p 1 p 2 C 4 = g 3 + C 3 p 3 = g 3 + g 2 p 3 + g 1 p 2 p 3 + g 0 p 1 p 2 p 3 + C 0 p 0 p 1 p 2 p 3

Circuit # 6 : Carry Lookahead Adder Expanding the carry terms for a 4-bit adder: C 1 = g 0 + C 0 p 0 C 2 = g 1 + C 1 p 1 = g 1 + (g 0 + C 0 p 0 )p 1 = g 1 + g 0 p 1 + C 0 p 0 p 1 C 3 = g 2 + C 2 p 2 = g 2 + g 1 p 2 + g 0 p 1 p 2 + C 0 p 0 p 1 p 2 C 4 = g 3 + C 3 p 3 = g 3 + g 2 p 3 + g 1 p 2 p 3 + g 0 p 1 p 2 p 3 + C 0 p 0 p 1 p 2 p 3 Note that all the carry expressions require only two evaluation stages (one for the and, the other for the or).

Circuit # 6 : Carry Lookahead Adder These results can now be used to complete the Carry lookahead network portion of the 4-bit adder: P0G0P0G0 S0S0 X 0 Y 0 C 0 P1G1P1G1 S1S1 X 1 Y 1 C 1 P3G3P3G3 S3S3 X 3 Y 3 C 3 P2G2P2G2 S2S2 X 2 Y 2 C 2 Carry lookahead network C4C4 C0C0 SIG

Circuit # 6 : Carry Lookahead Adder These results can now be used to complete the Carry lookahead network portion of the 4-bit adder:

Circuit # 6 : Carry Lookahead Adder These results can now be used to complete the Carry lookahead network portion of the 4-bit adder: Now it is clear that evaluation of each carry requires, at most, 3 logic gates. Thus, each sum digit requires at most 4 logic gates.

Circuit # 6 : Carry Lookahead Adder This brings us back to the basic, 4-bit MSI Adder/Subtractor, which may now be assumed to be optimized with carry lookahead circuits. These may be used, in turn, to develop more powerful multi-bit adder/subtractors. C out C in S 3 S 2 S 1 S 0 4-bit MSI Full Adder/Subtractor Add(0)/ Sub(1) Y 3 Y 2 Y 1 Y 0 X 3 X 2 X 1 X 0

Circuit # 7 : Decimal Adder

There are many situations where it is useful to employ decimal arithmetic on decimal representations (e.g. BCD: 8421). –BCD: , 0001, 0010, …, 0111, 1000, 1001 Remind yourself that BCD uses a 4-bit representation to store the values of digits 0..9, but this leaves wastage of some bit patterns (unused patterns).

Circuit # 7 : Decimal Adder There are many situations where it is useful to employ decimal arithmetic on decimal representations (e.g. BCD: 8421). –BCD: , 0001, 0010, …, 0111, 1000, 1001 To illustrate some of the issues we consider one example of decimal addition of single digits, leading to a full decimal adder. –This design will be based on the use of the binary adder.

Circuit # 7 : Decimal Adder Note that the problem of adding two decimal digits together, in general, also requires accounting for an input carry and an output carry. Minimum Sum:Maximum Sum: 0 (No carry) 1 (Carry) (No Carry out) DECIMAL ARITHMETIC(Carry out) Note also that the maximum number of distinct sums is 20.

Circuit # 7 : Decimal Adder Note that the problem of adding two decimal digits together, in general, also requires accounting for an input carry and an output carry. Minimum Sum:Maximum Sum: 0 (No carry) 1 (Carry) DECIMAL ARITHMETIC(Carry out) Note that the maximum number of distinct sums is 20. Consider the example: Carry ==== Sum 1998

Circuit # 7 : Decimal Adder We can obtain the sums in two stages.

Circuit # 7 : Decimal Adder We can obtain the sums in two stages. First, list all possible outputs from the direct sum of the decimal digits, then ….. K P 3 P 2 P 1 P Direct sum of decimal digits, ranging from 0 to 19 10, represented in 5- bit form with high- order bit K.

Circuit # 7 : Decimal Adder We can obtain the sums in two stages. First, list all possible outputs from the direct sum of the decimal digits, then ….. Beside each sum place the expected values of the sum bits and the carry out bit. K P 3 P 2 P 1 P 0 C S 3 S 2 S 1 S Expected outputs, with sum bits S J and carry-out bit C.

Circuit # 7 : Decimal Adder The first-stage sums divide into two groups: –the first ten sums produce the correct final sum and carry bit patterns K P 3 P 2 P 1 P 0 C S 3 S 2 S 1 S

Circuit # 7 : Decimal Adder The first-stage sums divide into two groups: –the first ten sums produce the correct final sum and carry bit patterns –the last ten sums are all incorrect by the same amount, they should have 6 added to them to produce the correct final bit patterns. K P 3 P 2 P 1 P 0 C S 3 S 2 S 1 S

Circuit # 7 : Decimal Adder The first-stage sums divide into two groups: –the first ten sums produce the correct final sum and carry bit patterns –the last ten sums are all incorrect by the same amount, they should have 6 added to them to produce the correct final bit patterns. K P 3 P 2 P 1 P 0 C S 3 S 2 S 1 S =

Circuit # 7 : Decimal Adder The condition used to identify and control the correction process is expressed in terms of the carry-out bit, C: C = K + P 3 P 2 + P 3 P 1 K P 3 P 2 P 1 P 0 C S 3 S 2 S 1 S

Circuit # 7 : Decimal Adder The condition used to identify and control the correction process is expressed in terms of the carry-out bit, C: C = K + P 3 P 2 + P 3 P 1 Thus, if C = 0 then no correction is applied. K P 3 P 2 P 1 P 0 C S 3 S 2 S 1 S

Circuit # 7 : Decimal Adder The condition used to identify and control the correction process is expressed in terms of the carry-out bit, C: C = K + P 3 P 2 + P 3 P 1 Thus, if C = 0 then no correction is applied. If C = 1, then 6 is added directly to the initial sum bits P J. K P 3 P 2 P 1 P 0 C S 3 S 2 S 1 S = This is referred to as the “Excess-64” technique for BCD addition.

Circuit # 7 : Decimal Adder The condition used to identify and control the correction process is expressed in terms of the carry-out bit, C: C = K + P 3 P 2 + P 3 P 1 A decimal full-adder circuit follows using a two-stage 4-bit binary adder MSI circuit and Uses the carry bit value directly to generate the value 6 10, or S 3 S 2 S 1 S 0 x 3 x 2 x 1 x 0 y 3 y 2 y 1 y 0 C 4 4-bit binary adder C 0 s 3 s 2 s 1 s 0 P 3 P 2 P 1 P 0 A 3 A 2 A 1 A 0 B 3 B 2 B 1 B 0 C in K x 3 x 2 x 1 x 0 y 3 y 2 y 1 y 0 C 4 4-bit binary adder C 0 s 3 s 2 s 1 s 0 C out 0 Add 6

Circuit # 7 : Decimal Adder This MSI circuit is used to form the basis for a multi-decade decimal adder. S 3 S 2 S 1 S 0 x 3 x 2 x 1 x 0 y 3 y 2 y 1 y 0 C 4 4-bit binary adder C 0 s 3 s 2 s 1 s 0 P 3 P 2 P 1 P 0 A 3 A 2 A 1 A 0 B 3 B 2 B 1 B 0 C in K x 3 x 2 x 1 x 0 y 3 y 2 y 1 y 0 C 4 4-bit binary adder C 0 s 3 s 2 s 1 s 0 C out 0 Add 6 A 3 A 2 A 1 A 0 B 3 B 2 B 1 B 0 x 3 x 2 x 1 x 0 y 3 y 2 y 1 y 0 C 4 BCD Decade adder C 0 s 3 s 2 s 1 s 0 S 3 S 2 S 1 S 0

Time out for some Design Philosophy!

Time out for some Philosophy! In software design and construction the programmer/analyst becomes familiar with identifying different aspects of the problem in terms of abstract models. Some of these models are quite concrete (bottom-up design) while others are relatively more abstract and require gradual expression of their detail (top-down design).

Time out for some Philosophy! Increasingly, modern Software Design is expressed in terms of components (functions, classes/objects, templates, metaprogramming) and focuses on software component re-use. One critical problem of software re-use lies in the proper, robust, flexible and standards-based design of the component interfaces. Other issues arise in the contexts of software complexity, performance, cost and other factors.

Time out for some Philosophy! Differential layering of abstraction in design also has its place in hardware design. SSI: Boolean algebra / Simplification / Logic gates MSI: Interconnection networks / Iterative re-use / Components These differences have been demonstrated in each of the circuits/components that we have considered so far.

Time out for some Philosophy! Differential layering of abstraction in design also has its place in hardware design. SSI: Boolean algebra / Simplification / Logic gates MSI: Interconnection networks / Iterative re-use / Components These differences have been demonstrated in each of the circuits/components that we have considered so far. S 3 S 2 S 1 S 0 x 3 x 2 x 1 x 0 y 3 y 2 y 1 y 0 C 4 4-bit binary adder C 0 s 3 s 2 s 1 s 0 P 3 P 2 P 1 P 0 A 3 A 2 A 1 A 0 B 3 B 2 B 1 B 0 C in K x 3 x 2 x 1 x 0 y 3 y 2 y 1 y 0 C 4 4-bit binary adder C 0 s 3 s 2 s 1 s 0 C out 0 Add 6 C in A B S C out FA Binary Full Adder

Circuit # 8 : Comparator

The comparison of two (binary) numbers is of considerable importance. –if ( A < B ) then … –while ( A > B ) do...

Circuit # 8 : Comparator The comparison of two (binary) numbers is of considerable importance. –if ( A < B ) then … –while ( A > B ) do... It is possible to design a comparator circuit that establishes whether two input binary strings, A and B, satisfy the conditions: A = B A > B A < B

Circuit # 8 : Comparator The comparison of two (binary) numbers is of considerable importance. –if ( A < B ) then … –while ( A > B ) do... It is possible to design a comparator circuit that establishes whether two input binary strings, A and B, satisfy the conditions: A = B A > B A < B These conditions may be encoded using 3 flag bits: E = 1 G = 1 L = 1

Circuit # 8 : Comparator One strategy is to perform the comparison bit-wise and from right to left.

Circuit # 8 : Comparator One strategy is to perform the comparison bit-wise and from right to left. Express the two bit strings to be compared, A and B: A N … A K A K-1 … A 1 A 0 and B N … B K B K-1 … B 1 B 0

Circuit # 8 : Comparator One strategy is to perform the comparison bit-wise and from right to left. Express the two bit strings to be compared, A and B: A N … A K A K-1 … A 1 A 0 and B N … B K B K-1 … B 1 B 0 Now, restrict attention to the substrings: A K A K-1 … A 1 A 0 and B K B K-1 … B 1 B 0

Circuit # 8 : Comparator We begin with three distinct, possible assumptions:

Circuit # 8 : Comparator We begin with three distinct, possible assumptions: A K-1 … A 1 A 0 = B K-1 … B 1 B 0 E K-1 = 1, G K-1 = 0, L K-1 = 0

Circuit # 8 : Comparator We begin with three distinct, possible assumptions: A K-1 … A 1 A 0 = B K-1 … B 1 B 0 E K-1 = 1, G K-1 = 0, L K-1 = 0 A K-1 … A 1 A 0 > B K-1 … B 1 B 0 E K-1 = 0, G K-1 = 1, L K-1 = 0

Circuit # 8 : Comparator We begin with three distinct, possible assumptions: A K-1 … A 1 A 0 = B K-1 … B 1 B 0 E K-1 = 1, G K-1 = 0, L K-1 = 0 A K-1 … A 1 A 0 > B K-1 … B 1 B 0 E K-1 = 0, G K-1 = 1, L K-1 = 0 A K-1 … A 1 A 0 < B K-1 … B 1 B 0 E K-1 = 0, G K-1 = 0, L K-1 = 1

Circuit # 8 : Comparator We begin with three distinct, possible assumptions: A K-1 … A 1 A 0 = B K-1 … B 1 B 0 E K-1 = 1, G K-1 = 0, L K-1 = 0 A K-1 … A 1 A 0 > B K-1 … B 1 B 0 E K-1 = 0, G K-1 = 1, L K-1 = 0 A K-1 … A 1 A 0 < B K-1 … B 1 B 0 E K-1 = 0, G K-1 = 0, L K-1 = 1 Note that only one of E K-1, G K-1 or L K-1 may have value 1 at a time.

Circuit # 8 : Comparator We begin with three distinct, possible assumptions: A K-1 … A 1 A 0 = B K-1 … B 1 B 0 E K-1 = 1, G K-1 = 0, L K-1 = 0 A K-1 … A 1 A 0 > B K-1 … B 1 B 0 E K-1 = 0, G K-1 = 1, L K-1 = 0 A K-1 … A 1 A 0 < B K-1 … B 1 B 0 E K-1 = 0, G K-1 = 0, L K-1 = 1 Note that only one of E K-1, G K-1 or L K-1 may have value 1 at a time. Our goal is to derive expressions for outputs E K, G K and L K based on the inputs A K, B K, E K-1, G K-1 and L K-1.

Circuit # 8 : Comparator Construct an abbreviated truth-table: A K B K E K-1 G K-1 L K-1 E K G K L K Note that all other (missing) rows are represented using don’t care output values.

Circuit # 8 : Comparator Construct an abbreviated truth-table: A K B K E K-1 G K-1 L K-1 E K G K L K Note that all other (missing) rows are represented using don’t care output values. Condition is not altered when A K = B K

Circuit # 8 : Comparator Construct an abbreviated truth-table: A K B K E K-1 G K-1 L K-1 E K G K L K Note that all other (missing) rows are represented using don’t care output values. Condition L K = 1 always applies when A K < B K

Circuit # 8 : Comparator Construct an abbreviated truth-table: A K B K E K-1 G K-1 L K-1 E K G K L K Note that all other (missing) rows are represented using don’t care output values. Condition G K = 1 always applies when A K > B K

Circuit # 8 : Comparator This leads to Boolean expressions for the outputs (using don’t cares): A K B K E K-1 G K-1 L K-1 E K G K L K G K = A K B K + A K G K-1 + B K G K-1 E K = A K B K E K-1 + A K B K E K-1 L K = A K B K + A K L K-1 + B K L K-1

Circuit # 8 : Comparator The 1-bit comparator circuit is expressed: A K B K GKEKLKGKEKLK G K-1 E K-1 L K-1

Circuit # 8 : Comparator The 1- bit comparator circuit is expressed in MSI form: A K B K G K G K-1 E K E K-1 L K L K-1 1-bit C o m p a r a t o r

Circuit # 8 : Comparator The 1- bit comparator circuit is expressed in MSI form: As with previous circuits, the 1-bit comparator circuit can be extended to form multi-bit, MSI ripple comparators. A K B K G K G K-1 E K E K-1 L K L K-1 1-bit C o m p a r a t o r A K-1 B K-1 G K-2 E K-2 L K-2 1-bit C o m p a r a t o r

Summary - Part II We continue to study logic design in the contexts of Small Scale Integration (SSI) and Medium Scale Integration (MSI) of gate devices and programmable logic devices (PLD). We have studied the design of a number of specific, practical functional circuits with a view to re-using those circuits as components in MSI design. Adders Subtractors Comparator We note the differing design approaches, or emphases, effected by differential layering of abstraction. (The same design issue arises in the context of software engineering as well.) SSI: Boolean algebra / Simplification / Logic gates MSI: Interconnection networks / Iterative re-use / Components