1 i206: Lecture 4: The CPU, Instruction Sets, and How Computers Work Marti Hearst Spring 2012.

Slides:



Advertisements
Similar presentations
Chapter 2: Data Manipulation
Advertisements

Control path Recall that the control path is the physical entity in a processor which: fetches instructions, fetches operands, decodes instructions, schedules.
ISA Issues; Performance Considerations. Testing / System Verilog: ECE385.
Chapter 2 Machine Language.
 Suppose for a moment that you were asked to perform a task and were given the following list of instructions to perform:
1 Microprocessor History. 2 The date is the year that the processor was first introduced. Many processors are re- introduced at higher clock speeds for.
Snick  snack A Working Computer Slides based on work by Bob Woodham and others.
Room: E-3-31 Phone: Dr Masri Ayob TK 2123 COMPUTER ORGANISATION & ARCHITECTURE Lecture 5: CPU and Memory.
Computer Organization Boolean Logic and the CPU i206 Fall 2010 John Chuang Some slides adapted from Marti Hearst, Brian Hayes, or Glenn Brookshear.
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 4: Operating Systems.
1 Foundations of Software Design Lecture 3: How Computers Work Marti Hearst Fall 2002.
The Analytical Engine Module 6 Program Translation.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Computer Processing CSCE 110 J. Michael Moore.
1 Foundations of Software Design Lecture 2: How Computers Work Marti Hearst Fall 2002.
Chapter 4 Processor Technology and Architecture. Chapter goals Describe CPU instruction and execution cycles Explain how primitive CPU instructions are.
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ input/output and clock inputs Sequence of control signal combinations.
Henry Hexmoor1 Chapter 10- Control units We introduced the basic structure of a control unit, and translated assembly instructions into a binary representation.
GCSE Computing - The CPU
J. Michael Moore Computer Processing CSCE 110. J. Michael Moore ProcessorInputOutput Memory Storage.
16/07/2015CSE1303 Part B lecture notes 1 Hardware Implementation Lecture B17 Lecture notes section B17.
Computer Structure.
The CPU The Central Presentation Unit Main Memory and Addresses Address bus and Address Space Data Bus Control Bus The Instructions set Mnemonics Opcodes.
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. 
CS1Q Computer Systems Lecture 9 Simon Gay. Lecture 9CS1Q Computer Systems - Simon Gay2 Addition We want to be able to do arithmetic on computers and therefore.
D75P 34R HNC Computer Architecture 1 Week 9 The Processor, Busses and Peripherals © C Nyssen/Aberdeen College 2003 All images © C Nyssen /Aberdeen College.
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Information Representation: Machine Instructions
Computer Systems Organization CS 1428 Foundations of Computer Science.
Finite State Machines (FSMs) and RAMs and inner workings of CPUs COS 116, Spring 2010 Guest: Szymon Rusinkiewicz.
Microcode Source: Digital Computer Electronics (Malvino and Brown)
1 Arithmetic Logic Unit ALU. 2 The Bus Concept 3 CPU Building Blocks  Registers (IR, PC, ACC)  Control Unit (CU)  Arithmetic Logic Unit (ALU)
Finite State Machines (FSMs) and RAMs and CPUs COS 116, Spring 2011 Sanjeev Arora.
Computer Architecture And Organization UNIT-II General System Architecture.
Lecture 14 Today’s topics MARIE Architecture Registers Buses
CS 111 – Sept. 15 Chapter 2 – Manipulating data by performing instructions “What is going on in the CPU?” Commitment: –Please read through section 2.3.
Important Concepts  Parts of the CPU  Arithmetic/Logic Unit  Control Unit  Registers  Program Counter  Instruction Register  Fetch/Decode/Execute.
PHY 201 (Blum)1 Microcode Source: Digital Computer Electronics (Malvino and Brown)
IT253: Computer Organization Lecture 9: Making a Processor: Single-Cycle Processor Design Tonga Institute of Higher Education.
CS 1308 – Computer Literacy and the Internet Building the CPU.
Stored Programs In today’s lesson, we will look at: what we mean by a stored program computer how computers store and run programs what we mean by the.
1 Central Processing Unit (CPU) Consists of complex set of electronic circuitry Executes stored program instructions Three components –Registers –Control.
20 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Introduction to Computing Systems and Programming Digital Logic Structures.
CBP 2002ITY 270 Computer Architecture1 Module Structure Whirlwind Review – Fetch-Execute Simulation Instruction Set Architectures RISC vs x86 How to build.
CMSC 104, Lecture 061 Stored Programs A look at how programs are executed.
Control units In the last lecture, we introduced the basic structure of a control unit, and translated our assembly instructions into a binary representation.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
Logic Gates Dr.Ahmed Bayoumi Dr.Shady Elmashad. Objectives  Identify the basic gates and describe the behavior of each  Combine basic gates into circuits.
BASIC COMPUTER ARCHITECTURE HOW COMPUTER SYSTEMS WORK.
1 Chapter 1 Basic Structures Of Computers. Computer : Introduction A computer is an electronic machine,devised for performing calculations and controlling.
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ read/write and clock inputs Sequence of control signal combinations.
Dr.Ahmed Bayoumi Dr.Shady Elmashad
CS 270: Mathematical Foundations of Computer Science
Edexcel GCSE Computer Science Topic 15 - The Processor (CPU)
5 - How Computers Calculate - the ALU
CS149D Elements of Computer Science
CSCE Fall 2013 Prof. Jennifer L. Welch.
Branch instructions We’ll implement branch instructions for the eight different conditions shown here. Bits 11-9 of the opcode field will indicate the.
CSCE Fall 2012 Prof. Jennifer L. Welch.
Black Boxes and Abstraction or A quick run through how computers work
Control units In the last lecture, we introduced the basic structure of a control unit, and translated our assembly instructions into a binary representation.
Review: The whole processor
Digital Circuits and Logic
Information Representation: Machine Instructions
Presentation transcript:

1 i206: Lecture 4: The CPU, Instruction Sets, and How Computers Work Marti Hearst Spring 2012

2 Summary from Last Time Quick Binary Exercise Boolean Logic –deMorgan’s Law Relating Boolean Logic to Circuits –Logic gates Special gates: –Flip Flops –Adders –Decoders

3 Revisit DeMorgan’s Laws A B = A B The inverse or complement of any Boolean expression can be found by successively applying the following theorems: (x + y)' = x'y' (xy)' = x' + y’

4 How fast is a logic gate? “Computers used to work in milliseconds (1,000ths), then moved up to microseconds (millionths), and now are approaching nanoseconds (billionths) for logic operations - and picoseconds (trillionths!) for the switches and gates in chips.” A nanosecond (ns) is one billionth of a second, 10^-9 seconds.

5 Example; Linking Boolean to Circuits Lighting up a digital clock

6 7 Segment LEDs: How to set the digits Images from Need a lot of gates to implement this truth table.

7 7 segment Digital Display How to turn on only 1 of the 4 digits at a time? Images from a b c d e f g p i1 i2 i3 i4

8 n-bit Decoder: Takes as input n inputs; turns on 1 (and only 1) of outputs Righthand image from AB W X Y Z a b c d e f g p w x y z

9 n-bit Decoder: Takes as input n inputs; turns on 1 (and only 1) of outputs Righthand image from AB W X Y Z What else could you use this for? How about selecting between 4 kinds of instructions? (add, subtract, multiply, divide)

10 How a Flip Flop Works: Try out this tool:

11 The CPU Central Processing Unit

12 The CPU Registers –Are basically rows of latches –Store values –Can be used to hold values of variables as well as memory addresses. Special registers –PC (program counter) Points to the location in memory that has the current instruction. –Instruction Register Holds the current instruction. –Accumulator Hold the current value of the ALU

13 The CPU ALU (Arithmetic Logic Unit) –Made of a long series of adder units –Addition, Subtraction (Mult, Div) –Lots of gates, so often the slowest circuit in the CPU Image from

14 Circuits for Binary Addition Full Adder Images from

15 Circuits for Binary Addition Full Adder, 4 bit output + carry Can link up an arbitrary number of input bits Can modify this easily to do subtraction Can also modify to do multiplication –How? –Usually division is done with a special floating point chip Images from

16 Arithmetic Logic Unit (ALU) Add, Subtract, and Logic Operations

17 A key computer science concept: Code and data can be represented in the same way.

18 The Stored-Program Concept Programs (code) are represented in the same way that data is. This way, both code and data can be stored in the same place as well. This is a key concept for understanding how the CPU works.

19 Computer Memory We represent data as 0 ’ s and 1 ’ s (bits) –8 bits in a byte –2 to 4 bytes in a word –Words represented schematically as rows in memory –Each word has High order bit (most significant bit) Low order bit (least significant bit) We also represent locations as 0 ’ s and 1 ’ s –These locations are called addresses

20 RAM (Random Access Memory) One set of wires activates the appropriate location Another set of wires –reads the data value from that location or –writes the data value to that location RAM is arranged as a grid –Each column is a word (or some number of bytes) –First activate the correct column –Then either Read the word ’ s values into the row output, or Write the row ’ s values into the word Read: get the value (don ’ t change it) Write: set the value (change it)

21 How DRAM Works This example memory holds 8 bytes. Say we want to change the contents of memory address number 0101 (which is the fifth one from the right) Image adapted from First, activate the column that corresponds to this address Converting 0101 to requires circuitry (not shown)

22 How DRAM Works Saw we want to set this memory address to contain the value When two activated lines cross, the cell at the intersection gets turned on. Image adapted from

23 How DRAM Works Now we ’ ve set the value. Reading moves the data the other direction, onto the row (a special control wire, not shown, tells the circuit whether to read or write). Image adapted from

24 Machine Language Only a very few unique instructions (commands) are needed for all CPU functionality. Called: –Machine instructions –Machine language –Machine code Represented in binary Assembly language: the human-readable version –Each statement of assembly language corresponds to one machine instruction. Need an assembler program to convert assembly language to machine code.

25 Machine Language Why so few instructions? (Nearly) everything is built up from: –Add/subtract/compare values (for jumps) –Load (into registers from memory) –Store (from registers into memory) –Get next instruction (or jump to another instruction)

26 Relation to High Level Languages Java, Python, C are all high level programming languages. They are translated to assembly language by a compiler and/or an interpreter.

27 Instructions and Their Representation Images from The op-code area holds operations. How many unique op-codes can this setup support?

28 Instructions and Their Representation Images from

29 Instructions and Their Representation Images from The Operand area holds memory addresses and data values = = 63 What is the largest memory address?

30 The CPU Images from Bus: bundles of wires connecting things. Instruction Register: holds instructions. Program Counter: points to the current memory location of the executing program. RAM: stores the code (instructions) and the data.

31 The CPU Images from MUX: multiplexer – chose 1 out of N (ALU or RAM in this case) ALU: adds, subtracts, compares two numbers (it has 2 words of storage, on the left and the right) Accumulator: stores ALU ’ s output Decoder: uses the 3-bit op- code and the number bit to control the MUX and the ALU and the memory buses.

32 Machine code to add two numbers that are stored in memory (locations 13 and 14) and then store the result into memory (location 15). The Program Counter starts at memory location 0. Image adapted from

33 Images from The Program Counter starts at memory location 0. (Notice: the instructions and the data are both stored in the RAM.) This instruction moves along the bus into the instruction register. The decoder checks the number bit to see how to handle the op- code.

34 Images from If the op-code number bit = 0, we want the operand to be used as a memory address. So the decoder switches the MUX to connect the operand to the RAM. If the bit were 1, the MUX would connect the operand to the ALU. The green wires do the addressing of the RAM. The blue wires do the reading to and writing from the RAM.

35 Images from The Decoder tells the ALU this is a LOAD instruction. The memory location 13 is activated, and its value placed on the blue bus. This goes through the multiplexer into the ALU. It also trickles down into the Accumulator (Load is implemented as an ADD value to 0). The last step (always, except for a jump) is for the Program Counter to get incremented. Now it points to memory location 1.

36 Images from Instruction: ADD 14 Similar to Load 13, except the ALU is given the ADD operation. The contents of the Accumulator are fed into the left hand operand, and the contents of memory location 14 becomes the right hand operand. Results of the AND end up in the Accumulator. The Program Counter increments.

37 Images from Instruction: STORE 15 Memory address 15 is activated via the green bus. The contents of the Accumulator are written to RAM in location 15 using the blue bus. The Program Counter increments. The next instruction is HALT.

38 CPU Performance CPU cycles are not the whole story The number of INSTRUCTIONS per second play a big role. –Each operation on the computer requires some instructions e.g., about 6 instructions required for the loop part of a simple for-loop. –Each instruction takes some number of cycles to execute. –So … a CPU with an instruction set and circuit design that requires fewer cycles to get operations done might have better performance than a CPU with a faster clock but more complicated circuitry.

39 Measuring CPU Performance MIPS: –millions of instructions per second –“ meaningless indicator of performance ” (a joke) –Some instructions require more time than others –No standard way to measure MIPS FLOPS: –floating-point operations per second –Measures the speed of the floating point unit A special circuit that does math on real numbers So, doesn ’ t measure performance on non-numeric applications Benchmark: –A test used to compare performance of hardware and/or software. –Different benchmarks measure different aspects of performance SPEC: –Standard Performance Evaluation Corporation –A set of standardized tasks (benchmarks) that CPUs are run on in order to assess their performance. Adapted form

40 CPU Performance CPU clocks are related to another commonly used term… Real Time –Means regular clock time as opposed to CPU clock time –Other factors also prevent a program from running in real time CPU scheduling, discussed in today ’ s lecture In common usage today, –Real time means right now, as I ’ m talking, as opposed to –Offline, when I have to think on my own, or when we ’ re not in the middle of a timed event with others listening.

41 Summary Boolean logic is used to make logic gates, which build up into circuits. Binary is used to represent both code and data in memory, in instruction registers, and in the arithmetic logic unit. Binary instructions move through the circuits, controlling the computer’s operation and also doing the operations themselves. –Adding, subtracting, moving locations. This is pretty much what it takes to do computation! –After you write the program, compile it, and load it into the CPU and memory.