ECE 274 Digital Logic. Digital Design. Datapath Components Subtractors, Two s Complement, Overflow, ALUs, Register Files Digital Design

Similar documents
Chapter 3: part 3 Binary Subtraction

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

Chapter 4 Arithmetic

Digital Design. Chapter 9: Hardware Description Languages

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

Chapter 8: Programmable Processors

Let s put together a Manual Processor

REGISTER TRANSFER LANGUAGE

Binary Adders: Half Adders and Full Adders

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

UC Berkeley College of Engineering, EECS Department CS61C: Combinational Logic Blocks

UC Berkeley College of Engineering, EECS Department CS61C: Combinational Logic Blocks

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

Principles of Computer Architecture. Chapter 3: Arithmetic

Computer Architecture Set Four. Arithmetic

Chapter 4. Combinational Logic

Arithmetic Logic Unit. Digital Computer Design

ELEC 326: Class project

BUILDING BLOCKS OF A BASIC MICROPROCESSOR. Part 1 PowerPoint Format of Lecture 3 of Book

For Example: P: LOAD 5 R0. The command given here is used to load a data 5 to the register R0.

Chapter 3 Arithmetic for Computers

CARLETON UNIVERSITY. Laboratory 2.0

Chapter 10 Binary Arithmetics

CPE 335 Computer Organization. MIPS Arithmetic Part I. Content from Chapter 3 and Appendix B

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

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

60-265: Winter ANSWERS Exercise 4 Combinational Circuit Design

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

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

UNIT-III REGISTER TRANSFER LANGUAGE AND DESIGN OF CONTROL UNIT

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

Register Transfer Language and Microoperations (Part 2)

Representation of Non Negative Integers

Module 2: Computer Arithmetic

Digital Systems. John SUM Institute of Technology Management National Chung Hsing University Taichung, ROC. December 6, 2012

Arithmetic Logic Unit

Computer Architecture and Organization

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

Arithmetic-logic units

We are quite familiar with adding two numbers in decimal

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

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

COMBINATIONAL LOGIC CIRCUITS

CO Computer Architecture and Programming Languages CAPL. Lecture 9

ALU Design. 1-bit Full Adder 4-bit Arithmetic circuits. Arithmetic and Logic Unit Flags. Add/Subtract/Increament/Decrement Circuit

CHAPTER 5: Representing Numerical Data

Arithmetic Circuits. Design of Digital Circuits 2014 Srdjan Capkun Frank K. Gürkaynak.

Experiment 7 Arithmetic Circuits Design and Implementation

Computer Architecture and Organization: L04: Micro-operations

Slide Set 5. for ENCM 369 Winter 2014 Lecture Section 01. Steve Norman, PhD, PEng

Basic Arithmetic (adding and subtracting)

CSC 220: Computer Organization Unit 10 Arithmetic-logic units

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29

EXPERIMENT #8: BINARY ARITHMETIC OPERATIONS

Revision: August 31, E Main Suite D Pullman, WA (509) Voice and Fax

Chapter 2: Number Systems

LECTURE 4. Logic Design

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

4. Write a sum-of-products representation of the following circuit. Y = (A + B + C) (A + B + C)

Arithmetic Logic Unit (ALU)

Color quality guide. Quality menu. Color quality guide. Page 1 of 6

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

Chapter 1 Review of Number Systems

Microcomputers. Outline. Number Systems and Digital Logic Review


Register Transfer and Micro-operations

CS 31: Intro to Systems Binary Arithmetic. Kevin Webb Swarthmore College January 26, 2016

LOGIC CIRCUITS. Kirti P_Didital Design 1

Parallel logic circuits

CHW 261: Logic Design

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

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

Chapter 4 Arithmetic Functions

Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997

Dec Hex Bin ORG ; ZERO. Introduction To Computing

Slide Set 1. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

ITP 140 Mobile App Technologies. Colors

Submitted by 1

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS

CS429: Computer Organization and Architecture

ECE468 Computer Organization & Architecture. The Design Process & ALU Design

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

Combinational Logic Circuits

Chapter 1. Digital Systems and Binary Numbers

Lecture 2: Number Systems

Advanced Computer Architecture-CS501

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

EE 109 Unit 6 Binary Arithmetic

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 2, 2016

CS/COE 0447 Example Problems for Exam 2 Spring 2011

Chapter 6 Combinational-Circuit Building Blocks

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

IA Digital Electronics - Supervision I

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

REGISTER TRANSFER AND MICROOPERATIONS

REGISTER TRANSFER AND MICROOPERATIONS

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

This guide helps you understand how operations available on the printer can be used to adjust and customize color output.

CS 151 Midterm. (Last Name) (First Name)

Transcription:

ECE 27 Digital Logic Subtractors,, Overflow, ALUs, Register Files Digital Design..0 Digital Design Chapter : Slides to accompany the textbook Digital Design, First Edition, by Frank Vahid, John Wiley and Sons Publishers, 2007. http://www.ddvahid.com Copyright 2007 Frank Vahid Instructors of courses requiring Vahid's Digital Design textbook (published by John Wiley and Sons) have permission to modify and use these slides for customary course-related activities, subject to keeping this copyright notice in place and unmodified. These slides may be posted as unanimated pdf versions on publicly-accessible course websites.. PowerPoint source (or pdf with animations) may not be posted to publicly-accessible websites, but may be posted for students on internal protected sites or distributed directly to students by other electronic means. Instructors may make printouts of the slides available to students for a reasonable photocopying charge, without incurring royalties. Any other use requires explicit permission. Instructors may obtain PowerPoint source or obtain special use permissions from Wiley see http://www.ddvahid.com for information. Subtractor Subtractor Example: Color Space Converter RGB to CMY Can build subtractor as we built carry-ripple adder Mimic subtraction by hand Compute borrows from columns on left Use full-subtractor component: wi is borrow by column on right, wo borrow from column on left st c olumn 2nd c olumn 3 r d c olumn th c olumn 0 0 0 0 0 0 0 0 0 0 0 0 0-0 a3 b3 a b FS wi w o s w o s3 a2 b2 a b FS wi w o s - 0 s2 a b a b FS wi w o s - 0 0 a0 b0 wi a b FS wi w o s - 0 0 0 a3 a2 a a0 b3 b2 b b0 w o -bit subtractor s3 s2 s s0 s s0 ( b ) ( c ) wi a Color Often represented as weights of three colors: red, green, and blue (RGB) Perhaps bits each, so specific color is 2 bits White: R=, G=, B= Black: R=00000000, G=00000000, B=00000000 Other colors: values in between, e.g., R=00, G=00000000, B=0000 would be a reddish purple Good for computer monitors, which mix red, green, and blue lights to form all colors Printers use opposite color scheme Because inks absorb light Use complementary colors of RGB: Cyan (absorbs red), reflects green and blue, Magenta (absorbs green), and Yellow (absorbs blue) 3

Subtractor Example: Color Space Converter RGB to CMY R G B Printers must quickly convert 255 255 255 RGB to CMY C=255-R, M=255-G, Y=255-B Use subtractors as shown t o CMY - - - GB R C M Y Subtractor Example: Color Space Converter RGB to CMYK Try to save colored inks Expensive Imperfect mixing C, M, Y doesn t yield good-looking black Solution: Factor out the black or gray from the color, print that part using black ink e.g., CMY of (250,200,200)= (200,200,200) + (50,0,0). (200,200,200) is a dark gray use black ink 5 6 Subtractor Example: Color Space Converter RGB to CMYK Representing Negative Numbers: Call black part K (200,200,200): K=200 (Letter B already used for blue) Compute minimum of C, M, Y values Use MIN component designed earlier, using comparator and mux, to compute K Output resulting K value, and subtract K value from C, M, and Y values Ex: Input of (250,200,200) yields output of (50,0,0,200) R G B C R G B R GB t o CMY C M Y K - - - t o CM R GB M Y MIN MIN C2 M2 Y2 K K Y Negative numbers common How represent in binary? Signed-magnitude Use leftmost bit for sign bit So -5 would be: 0 using four bits 00000 using eight bits Better way: Two s complement Big advantage: Allows us to perform subtraction using addition Thus, only need adder component, no need for separate subtractor component! 7 2

Ten s Complement is Easy to Compute: Just Invert Bits and Add Before introducing two s complement, let s consider ten s complement Complements for each base ten number shown to right Complement is the number that when added results in 0 Nice feature of ten s complement Instead of subtracting a number, adding its complement results in answer exactly 0 too much So just drop the results in subtracting using addition only Hold on! Sure, adding the ten s complement achieves subtraction using addition only But don t we have to perform subtraction to determine the complement in the first place? True but in binary, two s complement can be computed easily Two s complement of 0 is 0, because 0 + 0 is 000 Could compute complement of 0 as 000 0 = 0 Easier method: Just invert all the bits, and add The complement of 0 is 00+ = 0 -- it works! - - 9 0 What is the -bit binary two s complement representation for the decimal number -5?. -00 2. 0 3. 00. 0 What is the 5-bit binary two s complement representation for the decimal number -5?. -000 2. 00 3. 00. 0 2 3

How many bits are needed to represent the number -2 in binary?. 3 2. 3. 5. Impossible! What is the 5-bit binary two s complement representation for the decimal number 7?. 00 2. 0 3. 00. Two s complement can only represent negative numbers 3 What is the decimal equivalent the two s complement binary number?. 2. 7 3. -. -3 What is the decimal equivalent the two s complement binary number 000?. 0 2. 3.. - 5 6

What is the decimal equivalent the two s complement binary number 00? What is the decimal equivalent the two s complement binary number?. 5 2. -5 3. -. Nothing. 2. - 3. Who cares?. I don t know! 7 Subtractor Built with an Adder Adder/Subtractor Using two s complement A B = A + (-B) = A + (two s complement of B) = A + invert_bits(b) + So build subtractor using adder by inverting B s bits, and setting carry in to A A Adder S B N-bit B cin Adder/subtractor: control input determines whether add or subtract Can use 2x mux sub input passes either B or inverted B Alternatively, can use XOR gates if sub input is 0, B s bits pass through; if sub input is, XORs invert B s bits 9 20 5

Overflow Sometimes result can t be represented with given number of bits Either too large magnitude of positive or negative e.g., -bit two s complement addition of 0+000 (7+=). But - bit two s complement can t represent number >7 0+000 = 000 WRONG answer, 000 in two s complement is -, not + Adder/subtractor should indicate when overflow has occurred, so result can be discarded Overflow: Detecting Overflow: Method Assuming -bit two s complement numbers, can detect overflow by detecting when the two numbers sign bits are the same but are different from the result s sign bit If the two numbers sign bits are different, overflow is impossible Adding a positive and negative can t exceed largest magnitude positive or negative Simple circuit overflow = a3 b3 s3 + a3b3s3 Include overflow output bit on adder/subtractor sign bits 0 + 0 0 0 + 0 0 0 0 0 0 + 0 0 0 0 overflow ( a ) 0 overflow ( b ) no overflow ( c ) If the numbers sign bits have the same value, which differs from the result s sign bit, overflow has occurred. 2 22 Overflow: Detecting Overflow: Method 2 Magnitude Comparator Example: Minimum of Two Numbers Even simpler method: Detect difference between carry-in to sign bit and carry-out from sign bit Yields simpler circuit: overflow = c3 xor c Design a combinational component that computes the minimum of two -bit signed numbers 0 + 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 overflow ( a ) overflow ( b ) no overflow ( c ) If the carry into the sign bit column differs from the carry out of that column, overflow has occurred. 23 2 6

Arithmetic-Logic Unit (ALU) Arithmetic-Logic Unit (ALU) ALU Component that can perform any of various arithmetic (add, subtract, increment, etc.) and logic (AND, OR, etc.) operations, based on control inputs Motivation: Suppose want multifunction calculator that not only adds and subtracts, but also increments, ANDs, ORs, XORs, etc. More efficient design uses ALU ALU design not just separate components multiplexed (same problem as previous slide!), Instead, ALU design uses single adder, plus logic in front of adder s A and B inputs Logic in front is called an arithmetic-logic extender Extender modifies the A and B inputs such that desired operation will appear at output of the adder 25 26 Arithmetic-Logic Extender in Front of ALU Register Files xyz=000: Want S=A+B just pass a to ia, b to ib, and set cin=0 xyz=00: Want S=A-B pass a to ia, b to ib, and set cin= xyz=00: Want S=A+ pass a to ia, set ib=0, and set cin= xyz=0: Want S=A pass a to ia, set ib=0, and set cin=0 xyz=000: Want S=A AND B set ia=a*b, b=0, and cin=0 others: likewise Based on above, create logic for ia(x,y,z,a,b) and ib(x,y,z,a,b) for each abext, and create logic for cin(x,y,z), to complete design of the AL-extender component 27 MxN Register File Provides efficient access er C C to M N-bit-wide registers er t d0 d0 If we have many registers? s t ompu ompu but only need access one om c the car 62 c om the car's F r d c e n t r al or two at a time, a a0 register file is more F r i0 c e n t r al efficient i3-i0 i a d2 Ex: Above-mirror display (earlier example), but this time having 6 -bit d3 registers d5 e e load Too many wires, and big load mux is too slow load load r eg0 r eg0 t oo much load fanout r eg load r eg2 load load r eg3 r eg5 T A I M a huge mux o the i0 i0 or mi disp o T mi T -bit -bit or r d 6 x r o i a v e o v y a d e d y - D D i2 c ongestion i5 i3 s s0 s3-s0 x y 2 7

Register Files Instead, want component that has one data input and one data output, and allows us to specify which internal register to write and which to read W_data W_addr R_data R_addr W_en R_en 6 register file a Register Files: Timing Diagram Can write one register and read one register each clock cycle May be same register 2 W_data W_addr R_data 2 R_addr W_en R_en x register file a 29 30