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

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

CS 31: Intro to Systems Digital Logic

CS429: Computer Organization and Architecture

Dec Hex Bin ORG ; ZERO. Introduction To Computing

REGISTER TRANSFER LANGUAGE

Systems Architecture

Parallel logic circuits

EE 3170 Microcontroller Applications

COMPUTER ORGANIZATION AND DESIGN

Topics of this Slideset. CS429: Computer Organization and Architecture. Digital Signals. Truth Tables. Logic Design

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

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

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

CS 101, Mock Computer Architecture

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

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

Chapter 4. Instruction Execution. Introduction. CPU Overview. Multiplexers. Chapter 4 The Processor 1. The Processor.

Reference Sheet for C112 Hardware

Class Notes. Dr.C.N.Zhang. Department of Computer Science. University of Regina. Regina, SK, Canada, S4S 0A2

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

Chapter 4. The Processor

Chapter 5: Computer Systems Organization. Invitation to Computer Science, C++ Version, Third Edition

Chapter 5: Computer Systems Organization

Von Neumann Architecture

CC411: Introduction To Microprocessors

COSC 122 Computer Fluency. Computer Organization. Dr. Ramon Lawrence University of British Columbia Okanagan

ELEC 5200/6200 Computer Architecture and Design Spring 2017 Lecture 4: Datapath and Control

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

CHAPTER 4: Register Transfer Language and Microoperations

REGISTER TRANSFER AND MICROOPERATIONS

CPU ARCHITECTURE. QUESTION 1 Explain how the width of the data bus and system clock speed affect the performance of a computer system.

Chapter 4. The Processor

LECTURE 4. Logic Design

REGISTER TRANSFER AND MICROOPERATIONS

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

Chapter 4 The Processor 1. Chapter 4A. The Processor

Computer Organization and Levels of Abstraction

Combinational and sequential circuits (learned in Chapters 1 and 2) can be used to create simple digital systems.

16.1. Unit 16. Computer Organization Design of a Simple Processor

Chapter 4. The Processor

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

Memory General R0 Registers R1 R2. Input Register 1. Input Register 2. Program Counter. Instruction Register

ECE260: Fundamentals of Computer Engineering

Chapter 5: The Processor: Datapath and Control

COMPUTER ORGANIZATION AND DESIGN

Processing Unit CS206T

Show how to connect three Full Adders to implement a 3-bit ripple-carry adder

Digital Logic the Bare Minimum

Levels in Processor Design

CENG 3420 Computer Organization and Design. Lecture 06: MIPS Processor - I. Bei Yu

The Processor. Z. Jerry Shi Department of Computer Science and Engineering University of Connecticut. CSE3666: Introduction to Computer Architecture

Hardware Design I Chap. 10 Design of microprocessor

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

Mark Redekopp, All rights reserved. EE 352 Unit 8. HW Constructs

CS 31: Intro to Systems Caching. Martin Gagne Swarthmore College March 23, 2017

Basic Processing Unit: Some Fundamental Concepts, Execution of a. Complete Instruction, Multiple Bus Organization, Hard-wired Control,

Overview. Memory Classification Read-Only Memory (ROM) Random Access Memory (RAM) Functional Behavior of RAM. Implementing Static RAM

Computers and Microprocessors. Lecture 34 PHYS3360/AEP3630

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

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

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

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

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

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

Computer Organization and Levels of Abstraction

COMPUTER ORGANIZATION

Chapter 4 The Von Neumann Model

Digital System Design Using Verilog. - Processing Unit Design

Chapter 5 12/2/2013. Objectives. Computer Systems Organization. Objectives. Objectives (continued) Introduction. INVITATION TO Computer Science 1

Electricity: Voltage. Gate: A signal enters the gate at a certain voltage. The gate performs operations on it, and sends it out was a new signal.

Chapter 4. Computer Organization

CS222: Processor Design

Number Systems and Computer Arithmetic

ECE 341 Midterm Exam

CS 2630 Computer Organization. Meeting 13: Faster arithmetic and more operations Brandon Myers University of Iowa

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Microcomputers. Outline. Number Systems and Digital Logic Review

Lecture Objectives. Introduction to Computing Chapter 0. Topics. Numbering Systems 04/09/2017

CPE300: Digital System Architecture and Design

Chapter 4. The Processor

The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:

CS 61C: Great Ideas in Computer Architecture. MIPS CPU Datapath, Control Introduction

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

Chapter 4. The Processor. Instruction count Determined by ISA and compiler. We will examine two MIPS implementations

The MIPS Processor Datapath

Introduction to Computer Engineering. CS/ECE 252 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin Madison

Computer Organization

Computer Architecture and Assembly Language. Spring

Register Transfer and Micro-operations

Machine Architecture. or what s in the box? Lectures 2 & 3. Prof Leslie Smith. ITNP23 - Autumn 2014 Lectures 2&3, Slide 1

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Data Paths and Microprogramming

CS 2461: Computer Architecture I

Topic #6. Processor Design

CPU Design John D. Carpinelli, All Rights Reserved 1

Microcomputer Architecture and Programming

Basic Computer Architecture

CPU Structure and Function

CS 24: INTRODUCTION TO. Spring 2018 Lecture 3 COMPUTING SYSTEMS

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

The Processor (1) Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Transcription:

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

Reading Quiz

Today Hardware basics Machine memory models Digital signals Logic gates Circuits: Borrow some paper if you need to! Manipulating/Representing values in hardware Adders Storage & memory (latches)

Hardware Models (1940 s) Harvard Architecture: Program Memory CPU (Control and Arithmetic) Data Memory Input/Output Von Neumann Architecture: CPU (Control and Arithmetic) Program and Data Memory Input/Output

Von Neumann Architecture Model Computer is a generic computing machine: Based on Alan Turing s Universal Turing Machine Stored program model: computer stores program rather than encoding it (feed in data and instructions) No distinction between data and instructions memory 5 parts connected by buses (wires): Memory, Control, Processing, Input, Output Memory Cntrl Unit Processing Unit Input/Output addr bus cntrl bus data bus

Memory MAR MDR CPU: Cntrl Unit PC IR Input/Output Memory: data and instructions are stored in memory memory is addressable: addr 0, 1, 2, Memory Address Register: address to read/write Memory Data Register: value to read/write Processing Unit: executes instrs selected by cntrl unit Register ALU (artithmetic logic unit): simmple functional units: ADD, SUB Registers: temporary storage directly accessible by instructions Control unit: determines Small, very order vast in storage which space. instrs execute Fixed size (e.g., 32 bits). addr bus cntrl bus data bus PC: program counter: address of next instruction IR: holds current instruction clock based instr by instr control: clock signal+ir trigger state changes Stores what is currently being worked on. Input/Output: keyboard (can trigger actions), terminal, disk, ALU registers

Digital Computers All input is discrete (driven by periodic clock) All signals are binary (0: no voltage, 1: voltage) data, instructions, control signals, arithmetic, clock To run program, need different types of circuits Circuits to execute program instructions that act on program data CPU ALU, Cntrl, Storage RAM Cntrl & Storage bus Circuits to store program data and instructions and support reading and writing addressable storage locations

Goal: Build a CPU (model) Three main classifications of HW circuits: 1. ALU: implement arithmetic & logic functionality (ex) adder to add two values together 2. Storage: to store binary values (ex) Register File: set of CPU registers, Also: main memory (RAM) 3. Control: support/coordinate instruction execution (ex) fetch the next instruction to execute

Abstraction User / Programmer Wants low complexity Applications Specific functionality Software library Reusable functionality Operating system Manage resources Complex devices Compute & I/O

Abstraction Hardware Circuits Logic Gates Transistors Complex devices Compute & I/O Here be dragons. (Electrical Engineering) (Physics)

Logic Gates Input: Boolean value(s) (high and low voltages for 1 and 0) Output: Boolean value result of boolean function Always present, but may change when input changes And Or Not a b out a b out a out out = a & b out = a b out = ~a A B A & B A B ~A 0 0 0 0 1 0 1 0 1 1 1 0 0 1 0 1 1 1 1 0

NAND More Logic Gates NOR Note the circle on the output. This means negate it. a b out a b out out = ~(a & b) out = ~(a b) A B A NAND B A NOR B 0 0 1 1 0 1 1 0 1 0 1 0 1 1 0 0

Combinational Logic Circuits Build up higher level processor functionality from basic gates Acyclic Network of Gates Inputs Outputs Outputs are boolean functions of inputs Outputs continuously respond to changes to inputs

What does this circuit output? And Or Not X Y Output Clicker Choices X Y Out A Out B Out C Out D Out E 0 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 1 1 0

What can we do with these? Build-up XOR from basic gates (AND, OR, NOT) A B A ^ B 0 0 0 0 1 1 1 0 1 1 1 0 Q: When is A^B ==1?

Which of these is an XOR circuit? And Or Not Draw an XOR circuit using AND, OR, and NOT gates. I ll show you the clicker options after you ve had some time.

Which of these is an XOR circuit? A B A: B: A B A B C: D: A B E: None of these are XOR.

XOR Circuit: Abstraction A^B == (~A & B) (A & ~B) A B out = A^B = A:0 B:0 A^B: A:0 B:1 A^B: A:1 B:0 A^B: A:1 B:1 A^B:

Digital Circuits - Building a CPU Three main classifications of HW circuits: 1. ALU: implement arithmetic & logic functionality (ex) adder to add two values together 2. Storage: to store binary values (ex) Register File: set of CPU registers 3. Control: support/coordinate instruction execution (ex) fetch the next instruction to execute HW Circuits Logic Gates Transistor

Digital Circuits - Building a CPU Three main classifications of HW circuits: 1. ALU: implement arithmetic & logic functionality (ex) adder to add two values together Start with ALU components (e.g., adder) Combine into ALU! HW Circuits Logic Gates Transistor

1 bit adder: A+B Two outputs: Arithmetic Circuits 1. Obvious one: the sum 2. Other one:?? A B Sum(A+B) Cout 0 0 0 1 1 0 1 1

Which of these circuits is a one-bit adder? A B Sum(A+B) Cout 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 A B A: B: Sum A B Sum C out C out A B C: D: Sum A B Sum C out C out

More than one bit? When adding, sometimes have carry in too 0011010 + 0001111

One-bit (full) adder Need to include: Carry-in & Carry-out A B Cin Sum Cout 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 1 1 0 0 1 0 0 1 1 0 0 1 1 0 1 1 0 1 0 1 1 1 1 1 1 C in = 1-bit A B adder Sum C out

Multi-bit Adder (Ripple-carry Adder) 0 A 0 1-bit B 0 Sum adder 0 A 3 1-bit B 3 Sum adder 3 A 1 C out 1-bit B 1 Sum adder 1 C out A 2 C out 1-bit B 2 Sum adder 2 A N-1 1-bit B N-1 Sum adder N-1 C out C out

Three-bit Adder (Ripple-carry Adder) 0 0 1 1-bit adder Carry in 010 (2) 1 = + 011 (3) 1-bit 3-bit 1 adder 0 0 1-bit adder A 0 A 1 A 2 B 0 B 1 B 2 adder Carry out Sum 0 Sum 1 Sum 2

Arithmetic Logic Unit (ALU) One component that knows how to manipulate bits in multiple ways Addition Subtraction Multiplication / Division Bitwise AND, OR, NOT, etc. Built by combining components Take advantage of sharing HW when possible (e.g., subtraction using adder)

Simple 3-bit ALU: Add and bitwise OR 3-bit inputs A and B: A 0 A 1 A 2 3-bit adder Sum 0 Sum 1 Sum 2 B 0 B 1 B 2 Or 0 At any given time, we only want the output from ONE of these! Or 1 Or 2

Simple 3-bit ALU: Add and bitwise OR 3-bit inputs A and B: A 0 A 1 A 2 3-bit adder Extra input: control signal to select Sum vs. OR Sum 0 Sum 1 Sum 2 B 0 B 1 B 2 Or 0 Or 1 Circuit that takes in Sum 0-2 / Or 0-2 and only outputs one of them, based on control signal. Or 2

Which of these circuits lets us select between two inputs? Input 1 Control Signal Input 2 A: B: Input 1 Control Signal Input 2 Input 1 Control Signal Input 2 C:

Multiplexor: Chooses an input value Inputs: 2 N data inputs, N signal bits Output: is one of the 2 N input values s 1 bit 2-way MUX b a out out = (s & a) (~s &b) Control signal s, chooses the input for output When s is 1: choose a, when s is 0: choose b

N-Way Multiplexor Choose one of N inputs, need log 2 N select bits s1 s0 4-Way Multiplexor s1 s0 choose 0 0 D0 0 1 D1 1 0 D2 1 1 D3 D0 D1 D2 MUX4 Out s1 s0 S Input to choose D0 D3 D0.........

Simple 3-bit ALU: Add and bitwise OR 3-bit inputs A and B: A 0 A 1 A 2 B 0 B 1 B 2 3-bit adder Extra input: control signal to select Sum vs. OR Sum 0 Sum 1 Sum 2 Or 0 Multiplexer! Or 1 Or 2

CPU Instruction: ALU: Arithmetic Logic Unit ADD 2 3 Y X Arithmetic and logic circuits: ADD, SUB, NOT, Control circuits: use op bits to select output Circuits around ALU: Select input values X and Y from instruction or register Select op bits from instruction to feed into ALU Feed output somewhere A L U op bits: selects which op to output OF X op Y Output flags: set as a side effect of op (e.g., overflow detected)

Digital Circuits - Building a CPU Three main classifications of HW circuits: 1. ALU: implement arithmetic & logic functionality (ex) adder to add two values together 2. Storage: to store binary values (ex) Register File: set of CPU registers 3. Control: support/coordinate instruction execution (ex) fetch the next instruction to execute Circuits are built from Logic Gates which are built from transistors HW Circuits Logic Gates Transistor

Digital Circuits - Building a CPU Three main classifications of HW circuits: 2. Storage: to store binary values (ex) Register File: set of CPU registers Give the CPU a scratch space to perform calculations and keep track of the state its in. HW Circuits Logic Gates Transistor

CPU so far We can perform arithmetic! Storage questions: Where to the ALU input values come from? Where do we store the result? What does this register thing mean??? A L U?

Memory Circuit Goals: Starting Small Store a 0 or 1 Retrieve the 0 or 1 value on demand (read) Set the 0 or 1 value on demand (write)

R-S Latch: Stores Value Q When R an S are both 1: Store a value R and S are never both simultaneously 0 S R-S Latch R b a Q (value stored) ~Q To write a new value: Set S to 0 momentarily (R stays at 1): to write a 1 Set R to 0 momentarily (S stays at 1): to write a 0

Gated D Latch Controls S-R latch writing, ensures S & R never both 0 D S R-S Latch Q (value stored) R ~Q D: into top NAND, ~D into bottom NAND : write-enabled, when set, latch is set to value of D Latches used in registers (up next) and SRAM (caches, later) Fast, not very dense, expensive DRAM: capacitor-based:

Registers Fixed-size storage (8-bit, 32-bit, etc.) Gated D latch lets us store one bit Connect N of them to the same write-enable wire! N-bit input wires (bus): Bit 0 N-bit Register Write-enable: Bit 1 Bit N-1

Register file A set of registers for the CPU to store temporary values. This is (finally) something you will interact with! 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX Instructions of form: add R1 + R2, store result in R3 Register File

Memory Circuit Summary Lots of abstraction going on here! Gates hide the details of transistors. Build R-S Latches out of gates to store one bit. Combining multiple latches gives us N-bit register. Grouping N-bit registers gives us register file. Register file s simple interface: Read R x s value, use for calculation Write R y s value to store result

Digital Circuits - Building a CPU Three main classifications of HW circuits: 1. ALU: implement arithmetic & logic functionality (ex) adder to add two values together 2. Storage: to store binary values (ex) Register File: set of CPU registers 3. Control: support/coordinate instruction execution (ex) fetch the next instruction to execute Circuits are built from Logic Gates which are built from transistors HW Circuits Logic Gates Transistor

Digital Circuits - Building a CPU Three main classifications of HW circuits: 3. Control: support/coordinate instruction execution (ex) fetch the next instruction to execute Keep track of where we are in the program. Execute instruction, move to next. HW Circuits Logic Gates Transistor

CPU so far We know how to store data (in register file). We know how to perform arithmetic on it, by feeding it to ALU. Remaining questions: Which register(s) do we use as input to ALU? Which operation should the ALU perform? To which register should we store the result? 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U All this info comes from our program: a series of instructions. Register File

Recall: Von Neumann Model We re building this. Our program (instructions) live here. We ll assume for now that we can access it like an array. CPU (Control and Arithmetic) Input/Output Program and Data Memory Mem Addresses (buckets) 0: 1: 2: 3: 4: N-1:

CPU Game Plan Fetch instruction from memory Decode what the instruction is telling us to do Tell the ALU what it should be doing Find the correct operands Execute the instruction (arithmetic, etc.) Store the result

Program State Let s add two more special registers (not in register file) to keep track of program. Program Counter (PC): Memory address of next instr 0: (Memory) Instruction Register (IR): Instruction contents (bits) 1: 2: 3: 4: 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U N-1: Register File

Fetching instructions. Load IR with the contents of memory at the address stored in the PC. Program Counter (PC): Address 0 0: (Memory) Instruction Register (IR): Instruction at Address 0 1: 2: 3: 4: 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U N-1: Register File

Decoding instructions. Interpret the instruction bits: What operation? Which arguments? Program Counter (PC): Address 0 Instruction Register (IR): OP Code Reg A Reg B Result 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U 0: 1: 2: 3: 4: N-1: (Memory) Register File

Decoding instructions. Interpret the instruction bits: What operation? Which arguments? Program Counter (PC): Address 0 0: (Memory) Instruction Register (IR): OP Code Reg A Reg B Result 1: 2: 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U OP Code tells ALU which operation to perform. 3: 4: N-1: Register File

Decoding instructions. Interpret the instruction bits: What operation? Which arguments? Program Counter (PC): Address 0 0: (Memory) Instruction Register (IR): OP Code Reg A Reg B Result 1: 2: 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U Register ID # s specify input arguments. 3: 4: N-1: Register File

Executing instructions. Interpret the instruction bits: What operation? Which arguments? Program Counter (PC): Address 0 0: (Memory) Instruction Register (IR): OP Code Reg A Reg B Result 1: 2: 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U Let the ALU do its thing. (e.g., Add) 3: 4: N-1: Register File

Storing results. We ve just computed something. Where do we put it? Program Counter (PC): Address 0 0: (Memory) Instruction Register (IR): OP Code Reg A Reg B Result 1: 2: 3: 4: 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U Result location specifies where to store ALU output. N-1: Register File

Why do we need a program counter? Can t we just start at 0 and count up one at a time from there? A. We don t, it s there for convenience. B. Some instructions might skip the PC forward by more than one. C. Some instructions might adjust the PC backwards. D. We need the PC for some other reason(s).

Storing results. Interpret the instruction bits: What operation? Which arguments? Program Counter (PC): Address 0 Instruction Register (IR): OP Code Reg A Reg B Result 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U 0: 1: 2: 3: 4: N-1: (Memory) Result might be: Memory Register PC Register File

Recap CPU Model Four stages: fetch instruction, decode instruction, execute, store result Program Counter (PC): Memory address of next instr 0: (Memory) Instruction Register (IR): Instruction contents (bits) 1: 2: 3: 4: 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U N-1: Register File

Fetching instructions. Load IR with the contents of memory at the address stored in the PC. Program Counter (PC): Address 0 0: (Memory) Instruction Register (IR): Instruction at Address 0 1: 2: 3: 4: 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U N-1: Register File

Decoding instructions. Interpret the instruction bits: What operation? Which arguments? Program Counter (PC): Address 0 Instruction Register (IR): OP Code Reg A Reg B Result 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U 0: 1: 2: 3: 4: N-1: (Memory) Register File

Decoding instructions. Interpret the instruction bits: What operation? Which arguments? Program Counter (PC): Address 0 0: (Memory) Instruction Register (IR): OP Code Reg A Reg B Result 1: 2: 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U OP Code tells ALU which operation to perform. 3: 4: N-1: Register File

Decoding instructions. Interpret the instruction bits: What operation? Which arguments? Program Counter (PC): Address 0 0: (Memory) Instruction Register (IR): OP Code Reg A Reg B Result 1: 2: 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U Register ID # s specify input arguments. 3: 4: N-1: Register File

Executing instructions. Interpret the instruction bits: What operation? Which arguments? Program Counter (PC): Address 0 0: (Memory) Instruction Register (IR): OP Code Reg A Reg B Result 1: 2: 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U Let the ALU do its thing. (e.g., Add) 3: 4: N-1: Register File

Storing results. Interpret the instruction bits: Store result in register, memory, PC. Program Counter (PC): Address 0 Instruction Register (IR): OP Code Reg A Reg B Result 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U 0: 1: 2: 3: 4: N-1: (Memory) Result might be: Memory Register PC Register File

Clocking Need to periodically transition from one instruction to the next. It takes time to fetch from memory, for signal to propagate through wires, etc. Too fast: don t fully compute result Too slow: waste time

Clock Driven System Everything in is driven by a discrete clock clock: an oscillator circuit, generates hi low pulse clock cycle: one hi-low pair Clock 1 0 1 0 1 0 1 0 1 0 1 cycle Clock determines how fast system runs Processor can only do one thing per clock cycle Usually just one part of executing an instruction 1GHz processor: 1 billion cycles/second 1 cycle every nanosecond

Clock and Circuits Clock Edges Triggers events Circuits have continuous values Rising Edge: trigger new input values Falling Edge: consistent output ready to read Between rising and falling edge can have inconsistent state as new input values flow through circuit Clock: ^ new input ^ output ready ^ new input

Cycle Time: Laundry Analogy Discrete stages: fetch, decode, execute, store Analogy (laundry): washer, dryer, folding, dresser W Dy F Dr 4 Hours You have big problems if you have millions of loads of laundry to do.

Laundry W Dy F Dr 4 Hours W Dy F Dr 4 Hours 4-hour cycle time. Finishes a laundry load every cycle. W Dy F Dr 4 Hours (6 laundry loads per day)

Pipelining (Laundry) 1 Hour 1 st hour: W 2 nd hour: W Dy 3 rd hour: W Dy F 4 th hour: W Dy F Dr 5 th hour: W Dy F Dr Steady state: One load finishes every hour! (Not every four hours like before.)

1 Nanosecond Pipelining (CPU) 1 st nanosecond: F CPU Stages: fetch, decode, execute, store results 2 nd nanosecond: F D 3 rd nanosecond: F D E 4 th nanosecond: F D E S 5 th nanosecond: F D E S Steady state: One instruction finishes every nanosecond! (Clock rate can be faster.)

Pipelining (For more details about this and the other things we talked about here, take architecture.)

Up next Talking to the CPU: Assembly language