CPSC 121: Models of Computation

Slides:



Advertisements
Similar presentations
University of Amsterdam Computer Systems – the processor architecture Arnoud Visser 1 Computer Systems The processor architecture.
Advertisements

The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.
Pipeline Enhancements for the Y86 Architecture
Randal E. Bryant Carnegie Mellon University CS:APP2e CS:APP Chapter 4 Computer Architecture SequentialImplementation CS:APP Chapter 4 Computer Architecture.
PipelinedImplementation Part I CSC 333. – 2 – Overview General Principles of Pipelining Goal Difficulties Creating a Pipelined Y86 Processor Rearranging.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Lecture Notes from Randal E. Bryant, CMU CS:APP Chapter 4 Computer Architecture Instruction Set Architecture CS:APP Chapter 4 Computer Architecture Instruction.
Instruction Set Architecture CSC 333. – 2 – Instruction Set Architecture Assembly Language View Processor state Registers, memory, … Instructions addl,
Computer ArchitectureFall 2008 © Sep 3 rd, 2008 Majd F. Sakr CS-447– Computer Architecture.
Randal E. Bryant CS:APP Chapter 4 Computer Architecture SequentialImplementation CS:APP Chapter 4 Computer Architecture SequentialImplementation Slides.
Computer Organization Chapter 4
Datapath Design II Topics Control flow instructions Hardware for sequential machine (SEQ) Systems I.
Pipelining III Topics Hazard mitigation through pipeline forwarding Hardware support for forwarding Forwarding to mitigate control (branch) hazards Systems.
David O’Hallaron Carnegie Mellon University Processor Architecture PIPE: Pipelined Implementation Part I Processor Architecture PIPE: Pipelined Implementation.
Y86 Processor State Program Registers
CS:APP2e CS:APP Chapter 4 Computer Architecture Instruction Set Architecture.
Processor Architecture: The Y86 Instruction Set Architecture
Randal E. Bryant adapted by Jason Fritts CS:APP2e CS:APP Chapter 4 Computer Architecture Instruction Set Architecture CS:APP Chapter 4 Computer Architecture.
1 Seoul National University Pipelined Implementation : Part I.
Chapter 4: Processor Architecture How does the hardware execute the instructions? We’ll see by studying an example system  Based on simple instruction.
Instructor: Erol Sahin
Randal E. Bryant Carnegie Mellon University CS:APP CS:APP Chapter 4 Computer Architecture SequentialImplementation CS:APP Chapter 4 Computer Architecture.
Randal E. Bryant adapted by Jason Fritts CS:APP2e CS:APP Chapter 4 Computer Architecture SequentialImplementation CS:APP Chapter 4 Computer Architecture.
Datapath Design I Topics Sequential instruction execution cycle Instruction mapping to hardware Instruction decoding Systems I.
1 ICS 51 Introductory Computer Organization Fall 2009.
Based on slides by Patrice Belleville CPSC 121: Models of Computation Unit 10: A Working Computer.
1 Sequential CPU Implementation. 2 Outline Logic design Organizing Processing into Stages SEQ timing Suggested Reading 4.2,4.3.1 ~
1 Processor Architecture. Coverage Our Approach –Work through designs for particular instruction set Y86---a simplified version of the Intel IA32 (a.k.a.
Chapter 4: Processor Architecture
October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003.
1 SEQ CPU Implementation. 2 Outline SEQ Implementation Suggested Reading 4.3.1,
1 Assembly Language: Function Calls Jennifer Rexford.
Sequential Hardware “God created the integers, all else is the work of man” Leopold Kronecker (He believed in the reduction of all mathematics to arguments.
Sequential CPU Implementation Implementation. – 2 – Processor Suggested Reading - Chap 4.3.
1 Seoul National University Sequential Implementation.
Real-World Pipelines Idea Divide process into independent stages
CPSC 121: Models of Computation
Samira Khan University of Virginia Feb 2, 2017
IA32 Processors Evolutionary Design
Lecture 13 Y86-64: SEQ – sequential implementation
Homework Reading Labs PAL, pp
Lecture 14 Y86-64: PIPE – pipelined implementation
Module 10: A Working Computer
Aaron Miller David Cohen Spring 2011
Sequential Implementation
Ch. 2 Two’s Complement Boolean vs. Logical Floating Point
Samira Khan University of Virginia Feb 14, 2017
Computer Architecture adapted by Jason Fritts then by David Ferry
asum.ys A Y86 Programming Example
Y86 Processor State Program Registers
Instructor: David Ferry
Processor Architecture: The Y86-64 Instruction Set Architecture
Seoul National University
Instruction Decoding Optional icode ifun valC Instruction Format
Systems I Pipelining III
Systems I Pipelining II
Fundamentals of Computer Organisation & Architecture
Processor Architecture: The Y86-64 Instruction Set Architecture
Machine-Level Representation of Programs III
Homework Reading Machine Projects Labs PAL, pp
Pipelined Implementation : Part I
Recap: Performance Comparison
Systems I Pipelining II
Chapter 4 Processor Architecture
Systems I Pipelining II
Disassembly תרגול 7 ניתוח קוד.
Real-World Pipelines: Car Washes
Sequential CPU Implementation
CS-447– Computer Architecture M,W 10-11:20am Lecture 5 Instruction Set Architecture Sep 12th, 2007 Majd F. Sakr
Sequential Design תרגול 10.
Presentation transcript:

CPSC 121: Models of Computation Unit 10: A Working Computer CPSC 121 – 2010W T2

Unit 10: A Working Computer The 10th online quiz is due Sunday, March 27th at 21:00. Assigned reading for the quiz: Epp, 4th edition: 6.1 Epp, 3rd edition: 5.1 Rosen, 6th edition: 2.1 Assignment #6: for practice only (and exercises learning goals we haven't reached yet!) CPSC 121 – 2010W T2

Unit 10: A Working Computer Unit Summary: Implementing a working computer in Logisim Appendices CPSC 121 – 2010W T2

Unit 10: A Working Computer Von-Neumann architecture Memory (contains both programs and data). CPU Input/Output CPSC 121 – 2010W T2

Unit 10: A Working Computer Memory Contains both instructions and data. Divided into a number of memory locations Think of positions in a list: (list-ref mylist pos) Or in an array: myarray[pos] Each memory location contains (usually) 8 bits Values longer than 8 bits use up several neighbouring memory locations. CPSC 121 – 2010W T2

Unit 10: A Working Computer CPU Decides which instructions to execute (“fetches” it) Determines what needs to be done for that instruction (“decodes” it) Executes the instruction And then decides on the next instruction to execute... CPSC 121 – 2010W T2

Unit 10: A Working Computer Our working computer: Implements the design presented in the textbook by Bryant and O'Hallaron (used for CPSC 213/313). A small subset of the IA32 (Intel 32-bit) architecture. It has 12 types of instructions. One program counter register (PC) contains the address of the next instruction. 8 more 32-bits registers each of them contains one 32 bit value. used for values that we are currently working with. stores a single multi-bit value. CPSC 121 – 2010W T2

Unit 10: A Working Computer Example instruction 1: subl %eax, %ecx The subl instruction subtracts its arguments. The names %eax and %ecx refer to two registers. This instruction takes the value contained in %eax, subtracts it from the value contained in %ecx, and stores the result back in %ecx. Example instruction 2: irmovl $1A, %ecx This instruction stores a constant in a register. In this case, the value 1A (hexadecimal) is stored in %ecx. CPSC 121 – 2010W T2 Sorry for the dumb register names! They're an artifact of the long Intel Architecture history!

Unit 10: A Working Computer Example instruction 3: jge $1000 This is a conditional jump instruction. It checks to see if the result of the last arithmetic or logic operation was zero or positive (Greater than or Equal to 0). If so, the next instruction is the instruction stored in memory address 1000 (hexadecimal). If not, the next instruction is the instruction that follows the jge instruction. Without jumps, we'd have no loops and no recursion! CPSC 121 – 2010W T2

Unit 10: A Working Computer How does the computer know which instruction does what? Each instruction is a sequence of 16 to 48 bits† Some of the bits tell it which instruction it is. Other bits tell it what operands to use. These bits are used as select input for several multiplexers. Modified slightly from the Y86 presented in the textbook by Bryant and O'Hallaron CPSC 121 – 2010W T2

Unit 10: A Working Computer Example: CPSC 121 – 2010W T2

Unit 10: A Working Computer Example 1: subl %eax, %ecx Represented by 6101 (hexadecimal) %ecx %eax subtraction arithmetic or logic operation (for the “Arithmetic Logic Unit: ALU”) CPSC 121 – 2010W T2

Unit 10: A Working Computer Example 2: jge $1000 Represented by 758800001000 (hexadecimal) $1000 ignored (there are only registers 0 through 7!) “greater than or equal to” (vs. “no matter what”, “less than”, ...) jump CPSC 121 – 2010W T2

Unit 10: A Working Computer How is an instruction executed? This CPU divides the execution into 6 stages: Fetch: read instruction and decide on new PC value CPSC 121 – 2010W T2

Unit 10: A Working Computer Six stages of execution (continued) Decode: read values from registers Execute: use the ALU to perform computations Some of them are obvious from the instruction (e.g. subl) Other instructions use the ALU as well (e.g., some memory operations do addition/subtraction) Memory: read data from or write data to memory (we won't play with memory, to keep things simple) Write-back: store value(s) into register(s). PC update: store the new PC value. Not all stages do something for every instruction. CPSC 121 – 2010W T2

Unit 10: A Working Computer Sample program: irmovl $500,%eax irmovl $decade, %ecx subl %eax, %ecx CPSC 121 – 2010W T2

Unit 10: A Working Computer Example 1: subl %eax, %ecx Fetch: current instruction ← 6101 next PC value ← current PC value + 2 Decode: valA ← value of %eax valB ← value of %ecx Execute: valE ← valB - valA Memory: nothing needs to be done. Write-back: %ecx ← valE PC update: PC ← next PC value CPSC 121 – 2010W T2

Unit 10: A Working Computer Example 2: irmovl $500, %eax Fetch: current instruction ← 308000000500 next PC value ← current PC value + 6 Decode: valC ← 00000500 Execute: valE ← valC + 0 Memory: nothing to do Write-back: %eax ← valE PC update: PC ← next PC value CPSC 121 – 2010W T2

Unit 10: A Working Computer Unit Summary: A little bit of history Implementing a working computer in Logisim Appendices (do NOT try to memorize, just for your reference in lab if it's helpful!) CPSC 121 – 2010W T2

Unit 10: A Working Computer Registers (32 bits each): Instructions that only need one register use 8 or F (or anything in between) for the second register. %esp is used as “stack pointer” (for implementing function calls... we'll ignore!). Memory contains 232 bytes; all memory accesses load/store 32 bits at a time. 1 2 3 %eax %esp %ecx %ebp %edx %esi %ebx %edi 4 5 6 7 CPSC 121 – 2010W T2

Unit 10: A Working Computer Instruction types: register/memory transfers: rmmovl rA, D(rB) M[D + R[rB]] ← R[rA] Example: rmmovl %edx, 20(%esi) mrmovl D(rB), rA R[rA] ← M[D + R[rB]] CPSC 121 – 2010W T2

Unit 10: A Working Computer Instruction types: Other data transfer instructions rrmovl rA, rB R[rB] ← R[rA] irmovl V, rB R[rB] ← V Arithmetic instructions addl rA, rB R[rB] ← R[rB] + R[rA] subl rA, rB R[rB] ← R[rB] − R[rA] andl rA, rB R[rB] ← R[rB] ∧ R[rA] xorl rA, rB R[rB] ← R[rB]  R[rA] CPSC 121 – 2010W T2

Unit 10: A Working Computer Instruction types: Unconditional jumps jmp Dest PC ← Dest Conditional jumps jle Dest PC ← Dest if last result ≤ 0 jl Dest PC ← Dest if last result < 0 je Dest PC ← Dest if last result = 0 jne Dest PC ← Dest if last result ≠ 0 jge Dest PC ← Dest if last result ≥ 0 jg Dest PC ← Dest if last result > 0 CPSC 121 – 2010W T2

Unit 10: A Working Computer Instruction types: Procedure calls and return support call Dest R[%esp]←R[%esp]-4; M[R[%esp]]←PC; PC←Dest; ret PC←M[R[%esp]]; R[%esp]←R[%esp]+4 pushl rA R[%esp]←R[%esp]-4; M[R[%esp]]←R[rA] popl rA R[rA]←M[R[%esp]]; R[%esp]←R[%esp]+4 Others halt nop CPSC 121 – 2010W T2

Unit 10: A Working Computer Instructions format 1 2 3 4 5 nop halt rrmovl rA, rB irmovl V, rB rmmovl rA, D(rB) mrmovl D(rB), rA OPI rA, rB jXX Dest call Dest ret pushl rA popl rA 1 2 rA rB 3 F rB V 4 rA rB D 5 rA rB D 6 fn rA rB 7 fn Dest 8 Dest 9 A rA F CPSC 121 – 2010W T2 B rA F

Unit 10: A Working Computer Instructions format: Arithmetic instructions: addl → fn = 0 subl → fn = 1 andl → fn = 2 xorl → fn = 3 Conditional jumps and moves: jump → fn = 0 jle → fn = 1 jl → fn = 2 je → fn = 3 jne → fn = 4 jge → fn = 5 je → fn = 6 CPSC 121 – 2010W T2