Computer Organization and Levels of Abstraction

Similar documents
Computer Organization and Levels of Abstraction

Software and Hardware

LECTURE 4. Logic Design

Lecture 10: Floating Point, Digital Design

Von Neumann Architecture

Propositional Calculus. Math Foundations of Computer Science

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

Lecture 10: Floating Point, Digital Design

Chapter 3. Boolean Algebra and Digital Logic

Introduction to Computer Science. Homework 1

Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

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

COMP combinational logic 1 Jan. 18, 2016

Introduction to Boole algebra. Binary algebra

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

Experimental Methods I

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

Henry Lin, Department of Electrical and Computer Engineering, California State University, Bakersfield Lecture 7 (Digital Logic) July 24 th, 2012

6.1 Combinational Circuits. George Boole ( ) Claude Shannon ( )

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 3, 2015

Computer Organization and Programming

QUESTION BANK FOR TEST

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

Midterm Exam Review. CS 2420 :: Fall 2016 Molly O'Neil

Binary Values. CSE 410 Lecture 02

Arab Open University. Computer Organization and Architecture - T103

Injntu.com Injntu.com Injntu.com R16

Dec Hex Bin ORG ; ZERO. Introduction To Computing

Binary Adders: Half Adders and Full Adders

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

Bawar Abid Abdalla. Assistant Lecturer Software Engineering Department Koya University


CS101 Lecture 25: The Machinery of Computation: Computer Architecture. John Magee 29 July 2013 Some material copyright Jones and Bartlett

2. BOOLEAN ALGEBRA 2.1 INTRODUCTION

Logic, Words, and Integers

Topics. Computer Organization CS Exam 2 Review. Infix Notation. Reverse Polish Notation (RPN)

Bits, Words, and Integers

Parallel logic circuits

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

Combinational Circuits

6. Combinational Circuits. Building Blocks. Digital Circuits. Wires. Q. What is a digital system? A. Digital: signals are 0 or 1.

Chapter 4. Operations on Data

CS 24: INTRODUCTION TO. Spring 2015 Lecture 2 COMPUTING SYSTEMS

Boolean Logic CS.352.F12

Digital Logic Design Exercises. Assignment 1

Lecture 10: Combinational Circuits

Computer Organisation CS303

6.1 Combinational Circuits. George Boole ( ) Claude Shannon ( )

CS 261 Fall Mike Lam, Professor. Combinational Circuits

Register Transfer and Micro-operations

LAB #1 BASIC DIGITAL CIRCUIT

CS/COE 0447 Example Problems for Exam 2 Spring 2011

ECE 341 Midterm Exam

Review. EECS Components and Design Techniques for Digital Systems. Lec 05 Boolean Logic 9/4-04. Seq. Circuit Behavior. Outline.

UNIT - V MEMORY P.VIDYA SAGAR ( ASSOCIATE PROFESSOR) Department of Electronics and Communication Engineering, VBIT

END-TERM EXAMINATION

The von Neumann Architecture. IT 3123 Hardware and Software Concepts. The Instruction Cycle. Registers. LMC Executes a Store.

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

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

Introduction to Computers and Programming. Numeric Values

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 01, SPRING 2013

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8

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

Integer Representation

Objectives: 1- Bolean Algebra. Eng. Ayman Metwali

Propositional Calculus. Math Foundations of Computer Science

Inf2C - Computer Systems Lecture 2 Data Representation

Computer Systems. Binary Representation. Binary Representation. Logical Computation: Boolean Algebra

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

ECEN 468 Advanced Logic Design

DIGITAL SYSTEM DESIGN

OCR H446 A-Level Computer Science

This podcast will demonstrate a logical approach as to how a computer adds through logical gates.

6: Combinational Circuits

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

1. Draw general diagram of computer showing different logical components (3)

Chapter 2 Basic Logic Circuits and VHDL Description

Number Systems and Computer Arithmetic

Register Transfer Language and Microoperations (Part 2)

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

Midterm Exam 2B Answer key

Introduction to Boolean logic and Logical Gates

The type of all data used in a C (or C++) program must be specified

COSC 243. Computer Architecture 1. COSC 243 (Computer Architecture) Lecture 6 - Computer Architecture 1 1

CS101 Lecture 04: Binary Arithmetic

Two-Level CLA for 4-bit Adder. Two-Level CLA for 4-bit Adder. Two-Level CLA for 16-bit Adder. A Closer Look at CLA Delay

The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Purpose of Chapter. External Representation of Information.


Department of Electrical Engineering McGill University ECSE 221 Introduction to Computer Engineering Assignment 2 Combinational Logic

Computer Architecture Set Four. Arithmetic

MACHINE LEVEL REPRESENTATION OF DATA

von Neumann Architecture Basic Computer System Early Computers Microprocessor Reading Assignment An Introduction to Computer Architecture

Basic Computer System. von Neumann Architecture. Reading Assignment. An Introduction to Computer Architecture. EEL 4744C: Microprocessor Applications

Lecture #21 March 31, 2004 Introduction to Gates and Circuits

EE292: Fundamentals of ECE

Level 2: The Hardware World Chapters 4 and 5 (topics of other cs courses)

Arithmetic-logic units

Transcription:

Computer Organization and Levels of Abstraction

Announcements Today: PS 7 Lab 8: Sound Lab tonight bring machines and headphones! PA 7 Tomorrow: Lab 9 Friday: PS8

Today (Short) Floating point review Boolean logic Combinational Circuits Levels of Abstraction

Floating point +/- Exponent Mantissa 1 bit 8 bits 23 bits Sign is a 0 or 1 Exponent is an binary integer Mantissa is a binary fraction

Floating point 1.0011101 x 2 01001011 +/- Exponent Mantissa 1 bit 8 bits 23 bits Sign is a 0 or 1 Exponent is an binary integer Mantissa is a binary fraction

Floating point Sign 1.0011101 x 2 01001011 0 +/- Exponent Mantissa 1 bit 8 bits 23 bits Sign is a 0 or 1

Exponent 1.0011101 x 2 01001011 Exponent 01001011 Is an unsigned integer But exponent can be negative how to distinguish? IEEE-754 specifies a bias: 127 This gives us a range of -126 to +127 Makes comparison easier (for large and small values)

Floating point Mantissa 1.0011101 x 2 01001011 0_ 11001010 0011101 +/- Exponent Mantissa 1 bit 8 bits 23 bits Pad the mantissa

Floating point Mantissa 1.0011101 x 2 01001011 0_ 11001010 00111010000000000000000 +/- Exponent Mantissa 1 bit 8 bits 23 bits Pad the mantissa

Floating point Mantissa 1.0011101 x 2 01001011 011001010 00111010000000000000000

11 You should be able to Identify basic gates Describe the behavior of a gate or circuit using Boolean expressions, truth tables, and logic diagrams Transform one Boolean expression into another given the laws of Boolean algebra

12 Conceptualizing bits and circuits ON or 1: true OFF or 0: false circuit behavior: expressed in Boolean logic or Boolean algebra

13 Boolean Logic (Algebra) Computer circuitry works based on Boolean Logic (Boolean Algebra) : operations on True (1) and False (0) values. A B A Λ B (A AND B) (conjunction) 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 1 A ν B (A OR B) (disjunction) A 0 1 1 0 A (NOT A) (negation) A and B in the table are Boolean variables, AND and OR are operations (also called functions).

14 Boolean Logic & Truth Tables Example: You can think of A Ù B below as 15110 is fun and 15110 is useful where A stands for the statement 15110 is fun, B stands for the statement 15110 is useful. A B A Λ B (A AND B) (conjunction) 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 1 A ν B (A OR B) (disjunction) A 0 1 1 0 A (NOT A) (negation)

15 Logic Gates A gate is a physical device that implements a Boolean operator by performing basic operations on electrical signals. Nowadays, gates are built from transistors. Physical behavior of circuits is beyond the scope of our course. A B A Ù B AND A B A Ú B OR A NOT

16 Combinational Circuits The logic states of inputs at any given time determine the state of the outputs. AND OR AND A Ù B B Ú C AND C Ù B OR (B Ú C) Ù (C Ù B) What is Q? (A Ù B) Ú ((B Ú C) Ù (C Ù B))

17 Truth Table of a Circuit AND OR OR AND AND Q = (A Ù B) Ú ((B Ú C) Ù (C Ù B)) A B C Q 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 How do I know that there should be 8 rows in the truth table? Describes the relationship between inputs and outputs of a device http://www.allaboutcircuits.com/vol_4/chpt_7/6.html

18 Truth Table of a Circuit AND OR OR AND AND Q = (A Ù B) Ú ((B Ú C) Ù (C Ù B)) A B C Q 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 Describes the relationship between inputs and outputs of a device http://www.allaboutcircuits.com/vol_4/chpt_7/6.html

19 Describing Behavior of Circuits Boolean expressions Circuit diagrams Equivalent notations Truth tables

20 Why manipulate circuits? The design process simplify a complex design for easier manufacturing, faster or cooler operation, Boolean algebra helps us find another design guaranteed to have same behavior

Logical Equivalence Q = (A Ù B) Ú ((B Ú C) Ù (C Ù B)) OR AND OR AND AND AND OR Q = B Ù (A Ú C) A B C Q 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 This smaller circuit is logically equivalent to the one above: they have the same truth table. By using laws of Boolean Algebra we convert a circuit to another equivalent circuit. 21

22 Laws for the Logical Operators Ù and Ú (Similar to and +) Commutative: A Ù B = B Ù A A Ú B = B Ú A Associative: A Ù B Ù C = (A Ù B) Ù C = A Ù (B Ù C) A Ú B Ú C = (A Ú B) Ú C = A Ú (B Ú C) Distributive: A Ù (B Ú B) = (A Ù B) Ú (A Ù C) A Ú (B Ù C) = (A Ú B) Ù (A Ú C) Identity: A Ù 1 = A A Ú 0 = A Dominance: A Ù 0 = 0 A Ú 1 = 1 Idempotence: A Ù A = A A Ú A = A Complementation: A Ù A = 0 A Ú A = 1 Double Negation: A = A

Laws for the Logical Operators Ù and Ú (Similar to and +) Commutative: A Ù B = B Ù A A Ú B = B Ú A Associative: A Ù B Ù C = (A Ù B) Ù C = A Ù (B Ù C) A Ú B Ú C = (A Ú B) Ú C = A Ú (B Ú C) Distributive: A Ù (B Ú C) = (A Ù B) Ú (A Ù C) A Ú (B Ù C) = (A Ú B) Ù (A Ú C) Not true for + and Identity: A Ù 1 = A A Ú 0 = A The A s and B s here are schematic variables! You can instantiate them with any expression that has a Boolean value: (x Ú y) Ù z = z Ù (x Ú y) (by commutativity) A Ù B = B Ù A

Applying Properties for Ù and Ú Showing (x Ù y) Ú ((y Ú z) Ù (z Ù y)) = y Ù (x or z) Commutativity A Ù B = B Ù A (x Ù y) Ú ((z Ù y) Ù (y Ú z)) Distributivity A Ù (B Ú C) = (A Ù B) Ú (A Ù C) (x Ù y) Ú (z Ù y Ù y) Ú(z Ù y Ù z) Associativity, Commutativity, Idempotence (x Ù y) Ú ((z Ù y) Ú (y Ù z)) Commutativity, idempotence A Ù A = A ( y Ù x) Ú (y Ù z) Distributivity (backwards) (A Ù B) Ú (A Ù C) = A Ù (B Ú C) y Ù (x Ú z) Conclusion: (x Ù y) Ú ((y Ú z) Ù (z Ù y)) = y Ù (x Ú z)

25 Extending the system more gates and DeMorgan s laws

More gates (NAND, NOR, XOR) A B A nand B A nor B 0 0 1 1 0 0 1 1 0 1 1 0 1 0 1 1 1 0 0 0 nand ( not and ): A nand B = not (A and B) A xor B A B (A Ù B) nor ( not or ): A nor B = not (A or B) xor ( exclusive or ): A xor B = (A and not B) or (B and not A) A B A B (A Ú B) A Å B 26

A curious fact Functional Completeness of NAND and NOR Any logical circuit can be implemented using NAND gates only Same applies to NOR

28 DeMorgan s Law Nand: (A Ù B) = A Ú B Nor: (A Ú B) = A Ù B

29 DeMorgan s Law Nand: (A Ù B) = A Ú B if not (x > 15 and x < 110):... is logically equivalent to if (not x > 15) or (not x < 110):... Nor: (A Ú B) = A Ù B if not (x < 15 or x > 110):... is logically equivalent to if (not x < 15) and (not x > 110):...

30 A circuit for parity checking Boolean expressions and circuits

The circuit 3-bit odd parity checker P = ( A Ù BÙ C) Ú ( A Ù B Ù C) Ú (A Ù BÙ C) Ú (A Ù B Ù C) A B C P 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1

The circuit 3-bit odd parity checker P = ( A Ù BÙ C) Ú ( A Ù B Ù C) Ú (A Ù BÙ C) Ú (A Ù B Ù C) A B C P 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 There are specific methods for obtaining canonical Boolean expressions from a truth table, such as writing it as a disjunction of conjunctions or as a conjunction of disjunctions. Note we have four subexpressions above each of them corresponding to exactly one row of the truth table where P is 1.

33 The circuit 3-bit odd parity checker P = ( A Ù BÙ C) Ú ( A Ù B Ù C) Ú (A Ù BÙ C) Ú (A Ù B Ù C) A B C P 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 A B P = (A Å B) Å C C P

Circuits for arithmetic

36 Adding Binary Numbers A: 0 0 1 1 B: 0 1 0 1 --- --- --- --- 0 1 1 1 0 Adding two 1-bit numbers without taking the carry into account A B Sum Sum = A Å B How can we handle the carry?

37 Adding Binary Numbers A: 0 0 1 1 B: 0 1 0 1 --- --- --- --- 0 1 1 1 0 A B Sum Carry Half Adder: adds two single digits

A Full Adder C out C in A B C in C out S 0 0 0 A B S 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1

A Full Adder C out C in A B S A B C in C out S 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1 S = A Å B Å C in C out = ((A Å B) Ù C in ) Ú (A Ù B)

A Full Adder S: 1 when there is an odd number of bits that are 1 C out C in A B C in C out S 0 0 0 0 0 A B S 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1 C out : 1 if both A and B are 1 or, one of the bits and the carry in are 1. S = A Å B Å C in C out = ((A Å B) Ù C in ) Ú (A Ù B)

Full Adder (FA) S = A Å B Å C in C out = ((A Å B) Ù C in ) Ú (A Ù B) A B C out 1-bit Full Adder S C in More abstract representation of the above circuit. Hides details of the circuit above.

8-bit Full Adder A 7 B 7 A 2 B 2 A 1 B 1 A 0 B 0 C out 1-bit Full Adder... 1-bit Full Adder 1-bit Full Adder 1-bit Full Adder C in S 7 S 2 A B S 1 S 0 8 8 C out 8-bit FA 8 S C in More abstract representation of the above circuit. Hides details of the circuit above.

Control Circuits In addition to circuits for basic logical and arithmetic operations, there are also circuits that determine the order in which operations are carried out and to select the correct data values to be processed.

44 Multiplexer (MUX) A multiplexer chooses one of its inputs. 2 n input lines, n selector lines, and 1 output line A B F D 1 D 2 D 3 D 4 MUX F 0 0 D 1 0 1 D 2 1 0 D 3 1 1 D 4 A B hides details of the circuit on the left http://www.cise.ufl.edu/~mssz/comporg/cdaintro.html

Arithmetic Logic Unit (ALU) OP 1 OP 0 Carry In & OP OP 0 OP 1 F 0 0 A Ù B 0 1 A Ú B 1 0 A 1 1 A + B http://cs-alb-pc3.massey.ac.nz/notes/59304/l4.html Depending on the OP code Mux chooses the result of one of the functions (and, or, identity, addition) 45

46 Building A Complete Computer from Parts

Computing Machines An instruction is a single arithmetic or logical operation. A program is a sequence of instructions that causes the desired function to be calculated. A computing system is a combination of program and machine (computer). How can we build a computing system that calculates the desired function specified by a program?

Stored Program Computer http://cse.iitkgp.ac.in/pds/notes/intro.html A stored program computer is electronic hardware that implements an instruction set. 48

49 Von Neumann Architecture Big idea: Data and instructions to manipulate the data are both bit sequences Modern computers built according to the Von Neumann Architecture includes separate units To process information (CPU): reads and executes instructions of a program in the order prescribed by the program To store information (memory)

50 Stored Program Computer adder, multiplier, multiplexor, etc. small amount of memory in the CPU http://cse.iitkgp.ac.in/pds/notes/intro.html

Central Processing Unit (CPU) A CPU contains: Arithmetic Logic Unit to perform computation Registers to hold information Instruction register (current instruction being executed) Program counter (to hold location of next instruction in memory) Accumulator (to hold computation result from ALU) Data register(s) (to hold other important data for future use) Control unit to regulate flow of information and operations that are performed at each instruction step 51

Memory The simplest unit of storage is a bit (1 or 0). Bits are grouped into bytes (8 bits). Memory is a collection of cells each with a unique physical address. We use the generic term cell rather than byte or word because the number of bits in each addressable location varies from machine one machine to another. A machine that can generate, for example, 32-bit addresses, can utilize a memory that contains up to 2 32 memory cells. 52

Memory Layout Address 100: 104: 108: 112: 116: Content 50 42 85 71 99 Address 01100100: 01101000: 01101100: 01110000: 01110100: Content 01100100 01010100 01010101 01000111 01100011 We saw this picture in Unit 6. It hid the bit representation for readability. Assumes that memory is byte addressable and each integer occupies 4 bytes. In this picture and in reality, addresses and memory contents are sequences of bits. 53

Stored Program Computer instruction fetch, decode, execute adder, multiplier, multiplexor, Etc. program counter, instruction register, Etc. Two specialized registers: the instruction register holds the current instruction to be executed and the program counter contains the address of the next instruction to be executed.

Processing Instructions Both data and instructions are stored in memory as bit patterns Instructions stored in contiguous memory locations Data stored in a different part of memory The address of the first instruction is loaded into the program counter and and the processing cycle starts. 55

Fetch-Decode-Execute Cycle Modern computers include control logic that implements the fetch-decode-execute cycle introduced by John von Neumann: Fetch next instruction from memory into the instruction register. Decode instruction to a control signal and get any data it needs (possibly from memory). Execute instruction with data in ALU and store results (possibly into memory). Repeat. Note that all of these steps are implemented with circuits of the kind we have seen in this unit. 56

Power of abstraction

58 Using Abstraction in Computer Design We can use layers of abstraction to hide details of the computer design. We can work in any layer, not needing to know how the lower layers work or how the current layer fits into the larger system. Low High transistors gates circuits (adders, multiplexors ) central processing units (ALU, registers ) computer A component at a higher abstraction layer uses components from a lower abstraction layer without having to know the details of how it is built. It only needs to know what it does.

59 Abstraction in Programming The set of all operations that can be executed by a processor is called its instruction set. Instructions are built into hardware: electronics of the CPU recognize binary representations of the specific instructions. That means each CPU has its own machine language that it understands. But we can write programs without thinking about on what machine our program will run. This is because we can write programs in high-level languages that are abstractions of machine level instructions.

A High-Level Program # This programs displays Hello, World! print( Hello world! )

A Low-Level Program

62 Obtaining Machine Language Instructions Programs are typically written in higher-level languages and then translated into machine language (executable code). A compiler is a program that translates code written in one language into another language. An interpreter translates the instructions one line at a time into something that can be executed by the computer s hardware.

Summary A computing system is a combination of program and machine (computer). In this lecture, we focused on how a machine can be designed using levels of abstraction: gates à circuits for elementary operations à basic processing units à computer