CO Computer Architecture and Programming Languages CAPL. Lecture 9

Similar documents
Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS

EE 109 Unit 6 Binary Arithmetic

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

*Instruction Matters: Purdue Academic Course Transformation. Introduction to Digital System Design. Module 4 Arithmetic and Computer Logic Circuits

Arithmetic Logic Unit. Digital Computer Design

Microcomputers. Outline. Number Systems and Digital Logic Review

LOGIC CIRCUITS. Kirti P_Didital Design 1

Computer Organization

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 3 DLD P VIDYA SAGAR

Chapter 4. Combinational Logic

Experiment 7 Arithmetic Circuits Design and Implementation

COMBINATIONAL LOGIC CIRCUITS

DIGITAL TECHNICS. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute

Basic Arithmetic (adding and subtracting)

D I G I T A L C I R C U I T S E E

Principles of Computer Architecture. Chapter 3: Arithmetic

Chapter 3: part 3 Binary Subtraction

Chapter Three. Digital Components

Korea University of Technology and Education

Combinational Logic with MSI and LSI

COMPUTER ARCHITECTURE AND ORGANIZATION Register Transfer and Micro-operations 1. Introduction A digital system is an interconnection of digital

2. (a) Compare the characteristics of a floppy disk and a hard disk. (b) Discuss in detail memory interleaving. [8+7]

Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm. Nathan Pihlstrom.

BINARY SYSTEM. Binary system is used in digital systems because it is:

Chapter 1. Digital Systems and Binary Numbers

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University

Chapter 4 Arithmetic Functions

Binary Adders: Half Adders and Full Adders

II/IV B.Tech (Regular/Supplementary) DEGREE EXAMINATION. Answer ONE question from each unit.

Department of Electrical and Computer Engineering University of Wisconsin - Madison. ECE/CS 352 Digital System Fundamentals.

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

EE292: Fundamentals of ECE

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

COMPUTER ARITHMETIC (Part 1)

Number Systems Base r

Lecture (03) Binary Codes Registers and Logic Gates

Chapter 10 Binary Arithmetics

Chapter 10 - Computer Arithmetic

Chapter 3 Part 2 Combinational Logic Design

Combinational Circuits

(+A) + ( B) + (A B) (B A) + (A B) ( A) + (+ B) (A B) + (B A) + (A B) (+ A) (+ B) + (A - B) (B A) + (A B) ( A) ( B) (A B) + (B A) + (A B)

Real Digital Problem Set #6

Arithmetic Circuits. Nurul Hazlina Adder 2. Multiplier 3. Arithmetic Logic Unit (ALU) 4. HDL for Arithmetic Circuit

DIGITAL ELECTRONICS. P41l 3 HOURS

Digital Systems and Binary Numbers

Number Systems. Readings: , Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Lecture (02) Operations on numbering systems

CS 121 Digital Logic Design. Chapter 1. Teacher Assistant. Hadeel Al-Ateeq

Chapter 5 Design and Implementation of a Unified BCD/Binary Adder/Subtractor

Combinational Logic. Prof. Wangrok Oh. Dept. of Information Communications Eng. Chungnam National University. Prof. Wangrok Oh(CNU) 1 / 93

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

Code No: R Set No. 1

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

Chapter 4 Arithmetic

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

Advanced Computer Architecture-CS501

Chapter 3 Arithmetic for Computers

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Computer Organization

CS/EE1012 INTRODUCTION TO COMPUTER ENGINEERING SPRING 2013 HOMEWORK I. Solve all homework and exam problems as shown in class and sample solutions

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Digital Systems and Binary Numbers

UNIT IV: DATA PATH DESIGN

CSE140 L. Instructor: Thomas Y. P. Lee January 18,2006. CSE140L Course Info

CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS

Chapter 2: Number Systems

ECE/Comp Sci 352 Digital Systems Fundamentals. Charles R. Kime Section 2 Fall Logic and Computer Design Fundamentals

Computer Architecture Set Four. Arithmetic

Number System. Introduction. Decimal Numbers

Lecture 6: Signed Numbers & Arithmetic Circuits. BCD (Binary Coded Decimal) Points Addressed in this Lecture

carry in carry 1101 carry carry

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Combinational Logic II

Ripple Counters. Lecture 30 1

REGISTER TRANSFER LANGUAGE

Digital Fundamentals

Addition and multiplication

Digital Fundamentals. Lab 6 2 s Complement / Digital Calculator

Chapter 1 Review of Number Systems

ELCT 501: Digital System Design

Injntu.com Injntu.com Injntu.com R16

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

CHW 261: Logic Design

To design a 4-bit ALU To experimentally check the operation of the ALU

ECE 341 Midterm Exam

1. Mark the correct statement(s)

B.Tech II Year I Semester (R13) Regular Examinations December 2014 DIGITAL LOGIC DESIGN

We are quite familiar with adding two numbers in decimal

Binary Addition & Subtraction. Unsigned and Sign & Magnitude numbers

EXPERIMENT NUMBER 11 REGISTERED ALU DESIGN

Code No: R Set No. 1

Lecture 3: Binary Subtraction, Switching Algebra, Gates, and Algebraic Expressions

Transcription:

CO20-320241 Computer Architecture and Programming Languages CAPL Lecture 9 Dr. Kinga Lipskoch Fall 2017

A Four-bit Number Circle CAPL Fall 2017 2 / 38

Functional Parts of an ALU CAPL Fall 2017 3 / 38

Addition in the 2 s Complement System Perform normal binary addition of magnitudes The sign bits are added with the magnitude bits If addition results in a carry of the sign bit, the carry bit is ignored If the result is positive then it is in pure binary form If the result is negative then it is in 2 s complement form If the result of the addition exceeds the number of magnitude bits an overflow occurs CAPL Fall 2017 4 / 38

Typical Binary Addition Process CAPL Fall 2017 5 / 38

Addition in the 2 s Complement System: Case 1 and 2 Case 1: Two positive numbers Case 2: Positive number and smaller negative number CAPL Fall 2017 6 / 38

Addition in the 2 s Complement System: Case 3 and 4 Case 3: Positive number and larger negative number Case 4: Two negative numbers CAPL Fall 2017 7 / 38

Addition in the 2 s Complement System: Case 5 Case 5: Equal and opposite numbers CAPL Fall 2017 8 / 38

Overflow during Addition Overflow can occur only when two positive or two negative numbers are being added, and it always produces an incorrect result Overflow can be detected by checking to see that the sign bit of the result is the same as the sign bits of the numbers being added CAPL Fall 2017 9 / 38

Subtraction in the 2 s Complement System The number subtracted (subtrahend) is negated The result is added to the minuend The result of the addition represents the difference If the result of the addition exceeds the number of magnitude bits an overflow occurs CAPL Fall 2017 10 / 38

BCD Addition (1) If the sum of each decimal digit is less than 9 then the operation is the same as normal binary addition If the sum of each decimal digit is greater than 9 then a binary 6 is added, this will always cause a carry 4 bits are used per digit BCD subtraction a more complicated operation will not be discussed here CAPL Fall 2017 11 / 38

BCD Addition (2) Seems to work just as normal binary addition Another example 5 (BCD for 5) +4 + (BCD for 4) 9 (BCD for 9) 45 (BCD for 45) +33 + (BCD for 33) 78 (BCD for 78) Both examples do not create carries CAPL Fall 2017 12 / 38

BCD Addition (3) Seems to work just as normal binary addition Another example 5 0101 (BCD for 5) +4 +0100 (BCD for 4) 9 1001 (BCD for 9) 45 0100 0101 (BCD for 45) +33 +0011 0011 (BCD for 33) 78 0111 1000 (BCD for 78) Both examples do not create carries CAPL Fall 2017 13 / 38

BCD Addition (4) But does not work if sum > 9 6 0110 (BCD for 6) +7 +0111 (BCD for 7) 13 1101 invalid code group 0110 (BCD for 6) +0111 (BCD for 7) 1101 invalid sum 0110 add 6 for correction 0001 0011 (BCD for 13) 0110 is added to the invalid sum, produces carry CAPL Fall 2017 14 / 38

Hexadecimal Arithmetic (1) Hex addition: Add the hex digits in decimal If the sum is 15 or less then express it directly in hex digits If the sum is greater than 15 then subtract 16 and carry 1 to the next position 58 +4B CAPL Fall 2017 15 / 38

Hexadecimal Arithmetic (2) Hex subtraction use the same method as for binary numbers (hex binary 2 s complement hex) A quicker method to get 2 s complement is illustrated below Find 2 s complement for 73A: F F F 7 3 A 8 C 5 +1 8 C 6 CAPL Fall 2017 16 / 38

Hexadecimal Representation of Negative Numbers Negative number: Highest bit is 1 (binary) Positive number: Highest bit is 0 (binary) If the MSD (Most Significant Digit) in a hex number is 8 or greater then the number is negative If the MSD is 7 or less then the number is positive CAPL Fall 2017 17 / 38

Arithmetic Circuits (1) An arithmetic/logic unit (ALU) accepts data stored in memory and executes arithmetic and logic operations as instructed by the control unit Contains at least two flip-flop registers: B register Accumulator register CAPL Fall 2017 18 / 38

Arithmetic Circuits (2) Typical sequence of operations: Control unit is instructed to add a specific number from a memory location to a number stored in the accumulator register The number is transferred from memory to the B register Number in the B register and accumulator register are added in the logic circuit, with sum sent to the accumulator for storage The new number remains in the accumulator for further operations or can be transferred to memory for storage Register accumulates the sums when performing successive additions CAPL Fall 2017 19 / 38

Parallel Binary Adder The A and B variables represent two 5-bit numbers to be added The C variables are the carries The S variables are the sum bits CAPL Fall 2017 20 / 38

Design of a Full Adder Construct a truth table of 3 inputs (2 numbers to be added and carry in) and 2 outputs (sum and carry out) Parallel adder: all bits of the augend and addend are present and are fed into the adder circuit simultaneously CAPL Fall 2017 21 / 38

Design of a Full Adder: Truth Table Augend Addend Carry bit Sum bit Carry bit bit input bit input input output output A B C IN S C OUT 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 Two outputs, circuitry needs to be designed for each individually CAPL Fall 2017 22 / 38

Desgin of a Full Adder: The Logic Circuit Augend Addend Carry bit Sum bit Carry bit bit input bit input input output output A B C IN S C OUT 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 S = A B C IN + A B C IN + A B C IN + A B C IN S = A (B C IN + B C IN ) + A (B C IN + B C IN ) S = A (B C IN ) + A (B C IN ) CAPL Fall 2017 23 / 38

Sum Bit Output S = A (B C IN ) + A (B C IN ) Note X = B C IN S = A X + A X = A X S = A (B C IN ) CAPL Fall 2017 24 / 38

Carry Bit Output C OUT = A B C IN + A B C IN + A B C IN + A B C IN Use A B C IN three times, since it has common factors with each other terms C OUT = B C IN (A + A) + A C IN (B + B) + A B(C IN + C IN ) = B C IN + A C IN + A B CAPL Fall 2017 25 / 38

Logic Circuit for Full Adder S = A (B C IN ) COUT = BC IN + AC IN + AB CAPL Fall 2017 26 / 38

K-maps for the Full Adder Outputs CAPL Fall 2017 27 / 38

Complete Parallel Adder With Registers (1) Register notation to indicate the contents of a register we use brackets: [A] = 1011 is the same as A 3 = 1, A 2 = 0, A 1 = 1, A 0 = 1 A transfer of data to or from a register is indicated with an arrow [B] [A] means the contents of register B have been transferred to register A This is a common form of notation CAPL Fall 2017 28 / 38

Complete Parallel Adder With Registers (2) Augend bits A 3 through A 0 are stored in the accumulator [A] Addend B 3 through B 0 in [B] Contents of [A] is added to [B] by four FAs and sum is produced at outputs S 3 through S 0 C 4 carry of fourth FA, can be used as overflow or as C IN for fifth FA Sum outputs connected to D inputs so sum can be stored in [A] [A] can be transferred elsewhere CAPL Fall 2017 29 / 38

Complete Parallel Adder With Registers (3) The following describes adding binary 1001 and 0101 using the circuit on right A CLEAR pulse is applied at t 1 The first binary number 1001 is transferred from memory to [B] at t 2 The sum of 1001 and 0000 is transferred to the [A] at t 3 0101 is transferred from memory to the [B] at t 4 The sum outputs are transferred to the [A] at t 5 The sum of the two numbers is now present in the accumulator CAPL Fall 2017 30 / 38

Carry Propagation Parallel adder speed is limited by carry propagation (also called carry ripple) Carry propagation results from having to wait for the carry bits to ripple through the device Additional bits will introduce more delay Various techniques have been developed to reduce the delay The look-ahead carry, using logic gates to look at lower order bits of augend and addend to see if higher-order carry is to be generated, is commonly used in high speed devices CAPL Fall 2017 31 / 38

Integrated Circuit Parallel Adder (1) The most common parallel adder is a 4 bit device with 4 interconnected FAs and look-ahead carry circuits The A and B lines each represent 4 bit numbers to be added The C 0 is the carry in, the C 4 is the carry out, and the lines are the sum of the 2 numbers symbol (greek for sigma) is used for S outputs CAPL Fall 2017 32 / 38

Integrated Circuit Parallel Adder (2) Parallel adders may be cascaded together as shown to add larger numbers, in this case two 8 bit numbers CAPL Fall 2017 33 / 38

2 s Complement System An adder can be used to perform addition and subtraction by designing a way to take the 2 s complement for subtraction as described in figure Addition of negative and positive numbers using adders is done by placing the negative number into 2 s complement form and performing normal addition Subtraction is done by converting the number to be subtracted (subtrahend) to 2 s complement and adding to the minuend CAPL Fall 2017 34 / 38

Subtraction with a Parallel Adder Parallel adder used to perform subtraction (A B) using the 2 s-complement system The bits of the subtrahend (B) are inverted, and C 0 = 1 to produce the 2 s complement CAPL Fall 2017 35 / 38

Subtracting 6 from 4 A = 0100 4 10 B = 0110 6 10 B is inverted and fed with carry C 0 = 1 into adder 1 C 0 0100 A 1001 B 1110 S = A B CAPL Fall 2017 36 / 38

Combined Circuit to Perform Addition or Subtraction (1) Controlled by two control signals ADD and SUB Circuits like adder/subtractor are used in computers S output lines are usually then transferred into the accumulator Accomplished by TRANSFER pulse to the CLK input of register A CAPL Fall 2017 37 / 38

Combined Circuit to Perform Addition or Subtraction (2) Addition ADD = 1, SUB = 0 SUB = 0 inhinbits AND gates 2, 4, 6, 8 holding their outputs at 0 ADD = 1 enables AND gates 1, 3, 5, 7 allowing outputs to pass to Bx levels B 0 to B 3 pass through OR gate into adder Sum appears at the outputs S 0 to S 3, SUB = 0 causes carry C 0 = 0 Subtraction ADD = 0 and SUB = 1 ADD = 0 inhibits AND gates 1, 3, 5, 7 SUB = 1 enables AND gates 2, 4, 6 and 8 so outputs pass the B 0, B 1, B 2, B 3 levels B 0, B 1, B 2, B 3 pass through OR gates into adder to be added C 0 = 1, B now contains 2 s complement, difference appears at the outputs S 0 to S 3 CAPL Fall 2017 38 / 38