Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Third Edition.

Slides:



Advertisements
Similar presentations
The Binary Numbering Systems
Advertisements

Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, Java Version, Third Edition.
Invitation to Computer Science, C++ Version, Third Edition
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Third & Fourth Edition Spring 2008:
Data Representation COE 205
Assembly Language and Computer Architecture Using C++ and Java
Chapter 3 Data Representation.
Introduction to Programming with Java, for Beginners
Assembly Language and Computer Architecture Using C++ and Java
Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation.
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Third Edition.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Fourth Edition.
CHAPTER 4 CS BUILDING BLOCKS: BINARY NUMBERS, BOOLEAN LOGIC, GATES.
Operations on data CHAPTER 4.
4 Operations On Data Foundations of Computer Science ã Cengage Learning.
CS 105 Digital Logic Design
Introduction to Computing Systems from bits & gates to C & beyond Chapter 2 Bits, Data Types & Operations Integer Representation Floating-point Representation.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Chapter 5 Data representation.
Simple Data Type Representation and conversion of numbers
Binary System and Logical Gates
Binary Representation. Binary Representation for Numbers Assume 4-bit numbers 5 as an integer  as an integer  How? 5.0 as a real number  How?
Computers Organization & Assembly Language
1 CHAPTER 4: PART I ARITHMETIC FOR COMPUTERS. 2 The MIPS ALU We’ll be working with the MIPS instruction set architecture –similar to other architectures.
CPSC 171 Introduction to Computer Science Boolean Logic, Gates, & Circuits.
CSU0014 Assembly Languages Homepage: Textbook: Kip R. Irvine, Assembly Language for Intel-Based Computers,
CS 1308 – Computer Literacy and the Internet. It’s Not Magic  The goal of the next series of lectures is to show you exactly how a computer works. 
Test #1 rescheduled to next Tuesday, 09/20/05 The contents will cover chapter 1, 2, and part of Chapter 4. The contents will cover chapter 1, 2, and part.
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
Chapter 4 The Building Blocks: Binary Numbers, Boolean Logic, and Gates.
Assembly Language for x86 Processors 7th Edition
Click to edit Master title style Click to edit Master text styles –Second level Third level –Fourth level »Fifth level 1 Today’s Topics How information.
1 Modified from  Modified from 1998 Morgan Kaufmann Publishers Chapter Three: Arithmetic for Computers citation and following credit line is included:
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits I.
CSCI-235 Micro-Computers in Science Hardware Design Part I.
Basic Arithmetic (adding and subtracting)
Invitation to Computer Science 5th Edition
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Bits, Data Types, and Operations Slides based on set prepared by Gregory T. Byrd, North Carolina State University.
Invitation to Computer Science 6th Edition Chapter 4 The Building Blocks: Binary Numbers, Boolean Logic, and Gates.
1 Lecture 3 ENGRE 254 1/14/09. 2 Lecture 1 review Digital signals assume two values represented by “0” and “1”. Typically a “0” represents a voltage near.
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
CSCI-100 Introduction to Computing Hardware Design Part I.
Tutorial: ITI1100 Dewan Tanvir Ahmed SITE, UofO
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science,
CS 1308 – Computer Literacy and the Internet Building the CPU.
1. Computing Systems Lecture 3 Binary Representation & Boolean Logic Binary and Logic 2.
CPSC 171 Introduction to Computer Science Binary.
ECE 2110: Introduction to Digital Systems
1 Ethics of Computing MONT 113G, Spring 2012 Session 4 Binary Addition.
ELECTRICAL ENGINEERING: PRINCIPLES AND APPLICATIONS, Third Edition, by Allan R. Hambley, ©2005 Pearson Education, Inc. Chapter 7 Logic Circuits.
Computing Systems Lecture 3 Binary Representation & Boolean Logic Binary and Logic 1.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Invitation to Computer Science, C++ Version, Fourth Edition
Hardware (Part A) Reading Materials: OUTLINE
Lec 3: Data Representation
Everything is a number Everything in a computer memory and on storages is a number. Number  Number Characters  Number by ASCII code Sounds  Number.
Fundamentals & Ethics of Information Systems IS 201
Invitation to Computer Science, Java Version, Third Edition
Invitation to Computer Science, C++ Version, Third Edition
Chapter 2 Bits, Data Types & Operations Integer Representation
The Building Blocks: Binary Numbers, Boolean Logic, and Gates
Invitation to Computer Science 6th Edition
Presentation transcript:

Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Third Edition

Invitation to Computer Science, C++ Version, Third Edition 2 Objectives In this chapter, you will learn about: The binary numbering system Boolean logic and gates Building computer circuits Control circuits

Invitation to Computer Science, C++ Version, Third Edition 3 Introduction Chapter 4 focuses on hardware design (also called logic design)  How to represent and store information inside a computer  How to use the principles of symbolic logic to design gates  How to use gates to construct circuits that perform operations such as adding and comparing numbers, and fetching instructions

Invitation to Computer Science, C++ Version, Third Edition 4 The Binary Numbering System A computer’s internal storage techniques are different from the way people represent information in daily lives Information inside a digital computer is stored as a collection of binary data

Invitation to Computer Science, C++ Version, Third Edition 5 Binary numbering system  Base-2  Built from ones and zeros  Each position is a power of = 1 x x x x 2 0 Decimal numbering system  Base-10  Each position is a power of = 3 x x x x 10 0 Binary Representation of Numeric and Textual Information

Invitation to Computer Science, C++ Version, Third Edition 6 Figure 4.2 Binary-to-Decimal Conversion Table

Invitation to Computer Science, C++ Version, Third Edition 7 Representing integers  Decimal integers are converted to binary integers  Given k bits, the largest unsigned integer is 2 k - 1 Given 4 bits, the largest is = 15  Signed integers must also represent the sign (positive or negative) Binary Representation of Numeric Information

Invitation to Computer Science, C++ Version, Third Edition 8 Representation of Numbers Signed integer representation  Sign/magnitude notation 1 bit to represent the sign N bits to represent the integer  Example: if n= is represented as is represented as is represented as is represented as What about 0? + 0 is represented as is represented as Big Problem!!! There are two representations for 0!!! Sign Magnitude

Invitation to Computer Science, C++ Version, Third Edition 9 Representation of Numbers Signed integer representation  Two’s complement representation A positive number follows the sign/magnitude notation A negative number is obtained from the corresponding positive number in two steps: 1. Flip all the bits (0 becomes 1 and 1 becomes 0) 2. Add one to the result  Example: if n= is represented as {flip +33 (i.e ) and add 1 to it} = - 33 Question: What about 0 this time?

Invitation to Computer Science, C++ Version, Third Edition 10 Representation of Numbers Advantages of the two’s complement representation  One representation for the zero  Easy subtractions Subtractions are simply additions  The sign is embedded in the number! Example: Suppose we use 8 bits precision Two’s complement overflow

Invitation to Computer Science, C++ Version, Third Edition 11 Representation of Numbers Question 1:  Given n bits, what is the interval I of numbers that we can represent? Answer: With sign/magnitude I = (-2 n-1, 2 n-1 )  Note: the interval is open on both sides!  There are 2 distinct representations of the 0! With two’s complement I = [-2 n-1, 2 n-1 )  Note: the interval is open on one side! Question 2:  With n bits, how many distinct numbers do we represent? Answer: 2 n distinct numbers

Invitation to Computer Science, C++ Version, Third Edition 12 Representation of Numbers Representation of Decimal numbers  Real numbers may be put into binary Scientific notation  Mantissa  Bases  Exponent  Number then normalized so that first significant digit is immediately to the right of the binary point Example: Consider Binary number: = is Normalized as:  2 3

Invitation to Computer Science, C++ Version, Third Edition 13 Physical Representation of Numbers Assume that a number is stored in 16 bits 1 bit for the sign 9 bits for the mantissa 1 bit for the sign of the exponent 5 bits for the exponent = =  2 3 has  0 for the sign  1101 for the mantissa  0 for the sign of the exponent  3 for the exponent and in a 16 bits storage location is represented as Decimal point Sign Mantissa Sign Exponent

Invitation to Computer Science, C++ Version, Third Edition 14 Physical Representation of Numbers: Examples 3/16 10 = 1/8+1/16 10 = =  2 -2 has  0 for the sign  11 for the mantissa  1 for the sign of the exponent  2 for the exponent and in a 16 bits storage location is represented as /64 10 = 1/4+1/32+1/64 10 = =  2 -1 has  1 for the sign  for the mantissa  1 for the sign of the exponent  1 for the exponent and in a 16 bits storage location is represented as Sign Mantissa Sign Exponent Sign Mantissa Sign Exponent

Invitation to Computer Science, C++ Version, Third Edition 15 Characters are mapped onto binary numbers  ASCII code set (look for the code in your book) 8 bits per character; 256 character codes  UNICODE code set 16 bits per character; 65,536 character codes Text strings are sequences of characters in some encoding Binary Representation of Numeric and Textual Information (continued)

Invitation to Computer Science, C++ Version, Third Edition 16 Binary Representation of Sound and Images Multimedia data is sampled to store a digital form, with or without detectable differences Representing sound data  Sound data must be digitized for storage in a computer  Digitizing means periodic sampling of amplitude values

Invitation to Computer Science, C++ Version, Third Edition 17 Binary Representation of Sound and Images (continued)  From samples, original sound may be approximated  To improve the approximation: Sample more frequently Use more bits for each sample value

Invitation to Computer Science, C++ Version, Third Edition 18 Figure 4.5 Digitization of an Analog Signal (a) Sampling the Original Signal (b) Recreating the Signal from the Sampled Values

Invitation to Computer Science, C++ Version, Third Edition 19 Representing image data  Images are sampled by reading color and intensity values at even intervals across the image  Each sampled point is a pixel  Image quality depends on number of bits at each pixel Binary Representation of Sound and Images (continued)

Invitation to Computer Science, C++ Version, Third Edition 20 The Reliability of Binary Representation Electronic devices are most reliable in a bistable environment Bistable environment  Distinguishing only two electronic states Current flowing or not Direction of flow Computers are bistable: hence binary representations

Invitation to Computer Science, C++ Version, Third Edition 21 Magnetic core  Historic device for computer memory  Tiny magnetized rings: flow of current sets the direction of magnetic field  Binary values 0 and 1 are represented using the direction of the magnetic field Binary Storage Devices

Invitation to Computer Science, C++ Version, Third Edition 22 Figure 4.9 Using Magnetic Cores to Represent Binary Values

Invitation to Computer Science, C++ Version, Third Edition 23 Transistors  Solid-state switches: either permits or blocks current flow  A control input causes state change  Constructed from semiconductors Binary Storage Devices (continued)

Invitation to Computer Science, C++ Version, Third Edition 24 Figure 4.11 Simplified Model of a Transistor

Invitation to Computer Science, C++ Version, Third Edition 25 Boolean Logic and Gates: Boolean Logic Boolean logic describes operations on true/false values True/false maps easily onto bistable environment Boolean logic operations on electronic signals may be built out of transistors and other electronic devices

Invitation to Computer Science, C++ Version, Third Edition 26 Boolean Logic (continued) Boolean operations  a AND b True only when a is true and b is true  a OR b True when either a is true or b is true, or both are true  NOT a True when a is false, and vice versa

Invitation to Computer Science, C++ Version, Third Edition 27 Boolean expressions  Constructed by combining together Boolean operations Example: (a AND b) OR ((NOT b) AND (NOT a)) Truth tables capture the output/value of a Boolean expression  A column for each input plus the output  A row for each combination of input values Boolean Logic (continued)

Invitation to Computer Science, C++ Version, Third Edition 28 abValue Example: (a AND b) OR ((NOT b) and (NOT a)) From Boolean Expression to Truth Table

Invitation to Computer Science, C++ Version, Third Edition 29 Gates  Hardware devices built from transistors to mimic Boolean logic AND gate  Two input lines, one output line  Outputs a 1 when both inputs are 1

Invitation to Computer Science, C++ Version, Third Edition 30 Gates (continued) OR gate  Two input lines, one output line  Outputs a 1 when either input is 1 NOT gate  One input line, one output line  Outputs a 1 when input is 0 and vice versa

Invitation to Computer Science, C++ Version, Third Edition 31 Figure 4.15 The Three Basic Gates and Their Symbols

Invitation to Computer Science, C++ Version, Third Edition 32 Abstraction in hardware design  Map hardware devices to Boolean logic  Design more complex devices in terms of logic, not electronics  Conversion from logic to hardware design may be automated Gates (continued)

Invitation to Computer Science, C++ Version, Third Edition 33 Building Computer Circuits: Introduction A circuit is a collection of logic gates:  Transforms a set of binary inputs into a set of binary outputs  Values of the outputs depend only on the current values of the inputs Combinational circuits have no cycles in them (no outputs feed back into their own inputs)

Invitation to Computer Science, C++ Version, Third Edition 34 Figure 4.19 Diagram of a Typical Computer Circuit

Invitation to Computer Science, C++ Version, Third Edition 35 A Circuit Construction Algorithm Sum-of-products algorithm is one way to design circuits:  Step1: From Truth Table to Boolean Expression  Step 2: From Boolean Expression to Gate Layout

Invitation to Computer Science, C++ Version, Third Edition 36 Figure 4.21 The Sum-of-Products Circuit Construction Algorithm

Invitation to Computer Science, C++ Version, Third Edition 37 Sum-of-products algorithm  Truth table captures every input/output possible for circuit  Repeat process for each output line Build a Boolean expression using AND and NOT for each 1 of the output line Combine together all the expressions with ORs Build circuit from whole Boolean expression A Circuit Construction Algorithm (continued)

Invitation to Computer Science, C++ Version, Third Edition 38 An application of Step 1 of the SOP algorithm: From Truth Table to Boolean Expression 1.Ignore rows where the output is 0. 2.Create the product of the selections in this way: for each row with output 1: - if the input is 1, select the variable name. - if the input is 0, select the NOT of the variable name. 3.Create the Boolean expression for the circuit by summing each of the products created in step 2. ==> This is the Boolean expression for the circuit to be constructed. a b a XOR b ab’+a’b Note: a’=NOT a b’=NOT b

Invitation to Computer Science, C++ Version, Third Edition 39 Another example a b c output a'b'c' + a'b’c + ab'c' + abc' + abc or output = a'b'c' + a'b’c +ab'c' + abc' + abc

Invitation to Computer Science, C++ Version, Third Edition 40 Examples Of Circuit Design And Construction Compare-for-equality circuit Addition circuit Both circuits can be built using the sum-of- products algorithm

Invitation to Computer Science, C++ Version, Third Edition 41 Compare-for-equality circuit  CE compares two unsigned binary integers for equality Given two n-bit numbers, a = a 0 a 1 a 2 …a n-1 and b = b 0 b 1 b 2 …b n-1 output 1 if the numbers are the same and 0 if they are not  Built by combining together 1-bit comparison circuits (1- CE)  Integers are equal if corresponding bits are equal (AND together 1-CD circuits for each pair of bits) A Compare-for-equality Circuit

Invitation to Computer Science, C++ Version, Third Edition 42 1-CE circuit truth table Or output = a’b’+ab abOutput A Compare-for-equality Circuit (continued)

Invitation to Computer Science, C++ Version, Third Edition 43 Figure 4.22 One-Bit Compare for Equality Circuit

Invitation to Computer Science, C++ Version, Third Edition 44 1-CE Boolean expression  First case: (NOT a) AND (NOT b)  Second case: a AND b  Combined: ((NOT a) AND (NOT b)) OR (a AND b) A Compare-for-equality Circuit (continued)

Invitation to Computer Science, C++ Version, Third Edition 45 A Compare-for-equality Circuit (cont.) 1-CE Generalize the process by AND-ing together 1-CD circuits for each pair of bits The 1-CE circuit is represented by the box o o o o a 0 b 0 a 1 b 1 a 2 b 2 a n-1 b n-1 out 1-CE

Invitation to Computer Science, C++ Version, Third Edition 46 An Addition Circuit Addition circuit  Adds two unsigned binary integers, setting output bits and an overflow  Built from 1-bit adders (1-ADD)  Starting with rightmost bits, each pair produces A value for that order (i.e. s i =a i +b i ) A carry bit for next place to the left (i.e. c i )

Invitation to Computer Science, C++ Version, Third Edition 47 1-ADD truth table  Input One bit from each input integer One carry bit (always zero for rightmost bit)  Output One bit for output place value One “carry” bit An Addition Circuit (continued)

Invitation to Computer Science, C++ Version, Third Edition 48 Figure 4.24 The 1-ADD Circuit and Truth Table

Invitation to Computer Science, C++ Version, Third Edition 49 The 1-bit adder

Invitation to Computer Science, C++ Version, Third Edition 50 Put rightmost bits into 1-ADD, with zero for the input carry Send 1-ADD’s output value to output, and put its carry value as input to 1-ADD for next bits to left. Repeat process for all bits. Building the full adder o o o o 1-ADD c 0 =0 a 0 b 0 a 1 b 1 a 2 b 2 a n-1 b n-1 s 0 =a 0 +b 0 s 2 = a 1 +b 1 s 2 = a 2 +b 2 s n-1 = a n-1 +b n-1 s n = c n c1c1 c2c2 c n-1 c3c3

Invitation to Computer Science, C++ Version, Third Edition 51 Control Circuits Do not perform computations Choose order of operations or select among data values Major types of controls circuits  Decoders Sends a 1 on one output line, based on what input line indicates  Multiplexors Select one of inputs to send to output We will use these control circuits while studying next chapter.

Invitation to Computer Science, C++ Version, Third Edition 52 Decoder  Form N input lines 2 N output lines  N input lines indicate a binary number, which is used to select one of the output lines  Selected output sends a 1, all others send 0 Control Circuits (Decoder)

Invitation to Computer Science, C++ Version, Third Edition 53 Decoder purpose  Given a number code for some operation, trigger just that operation to take place  Numbers might be codes for arithmetic: add, subtract, etc.  Decoder signals which operation takes place next Control Circuits (continued)

Invitation to Computer Science, C++ Version, Third Edition 54 Figure 4.29 A 2-to-4 Decoder Circuit

Invitation to Computer Science, C++ Version, Third Edition 55 Decoder Circuit A decoder is a control circuit which has  N input and 2 N output A 3 to 2 3 example of decoder a b c o0 o1 o2 o3 o4 o5 o6 o a b c

Invitation to Computer Science, C++ Version, Third Edition 56 Multiplexor form  2 N regular input lines  N selector input lines  1 output line Multiplexor purpose  Given a code number for some input, selects that input to pass along to its output  Used to choose the right input value to send to a computational circuit Control Circuits (Multiplexor)

Invitation to Computer Science, C++ Version, Third Edition 57 Figure 4.28 A Two-Input Multiplexor Circuit

Invitation to Computer Science, C++ Version, Third Edition 58 Multiplexor Circuit with N input multiplexor circuit 2 N input lines N -1 N selector lines output Interpret the selector lines as a binary number. Suppose that the selector line write the number 00….01 which is equal to 1. For our example, the output is the value on the line numbered

Invitation to Computer Science, C++ Version, Third Edition 59 Summary Digital computers use binary representations of data: numbers, text, multimedia Binary values create a bistable environment, making computers reliable Boolean logic maps easily onto electronic hardware Circuits are constructed using Boolean expressions as an abstraction Computational and control circuits may be built from Boolean gates