Instruction Decoding Optional icode ifun valC Instruction Format

Slides:



Advertisements
Similar presentations
Randal E. Bryant Carnegie Mellon University CS:APP CS:APP Chapter 4 Computer Architecture PipelinedImplementation Part II CS:APP Chapter 4 Computer Architecture.
Advertisements

University of Amsterdam Computer Systems – the processor architecture Arnoud Visser 1 Computer Systems The processor architecture.
Real-World Pipelines: Car Washes Idea  Divide process into independent stages  Move objects through stages in sequence  At any instant, multiple objects.
PipelinedImplementation Part I PipelinedImplementation.
Instructor: Erol Sahin
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.
Randal E. Bryant CS:APP Chapter 4 Computer Architecture SequentialImplementation CS:APP Chapter 4 Computer Architecture SequentialImplementation Slides.
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
1 Seoul National University Pipelined Implementation : Part I.
1 Naïve Pipelined Implementation. 2 Outline General Principles of Pipelining –Goal –Difficulties Naïve PIPE Implementation Suggested Reading 4.4, 4.5.
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.
Based on slides by Patrice Belleville CPSC 121: Models of Computation Unit 10: A Working Computer.
CSC 2405 Computer Systems II Advanced Topics. Instruction Set Architecture.
Computer Architecture I: Outline and Instruction Set Architecture
1 Sequential CPU Implementation. 2 Outline Logic design Organizing Processing into Stages SEQ timing Suggested Reading 4.2,4.3.1 ~
Computer Architecture adapted by Jason Fritts
1 SEQ CPU Implementation. 2 Outline SEQ Implementation Suggested Reading 4.3.1,
Randal E. Bryant Carnegie Mellon University CS:APP2e CS:APP Chapter 4 Computer Architecture PipelinedImplementation Part II CS:APP Chapter 4 Computer Architecture.
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.
Rabi Mahapatra CS:APP3e Slides are from Authors: Bryant and O Hallaron.
Real-World Pipelines Idea –Divide process into independent stages –Move objects through stages in sequence –At any given times, multiple objects being.
Sequential CPU Implementation Implementation. – 2 – Processor Suggested Reading - Chap 4.3.
1 Seoul National University Sequential Implementation.
CPSC 121: Models of Computation
Real-World Pipelines Idea Divide process into independent stages
CPSC 121: Models of Computation
Lecture 13 Y86-64: SEQ – sequential implementation
Lecture 14 Y86-64: PIPE – pipelined implementation
Course Outline Background Sequential Implementation Pipelining
Decode and Operand Read
Sequential Implementation
Design of the Control Unit for Single-Cycle Instruction Execution
Administrivia Midterm to be posted on Tuesday after class
Samira Khan University of Virginia Feb 14, 2017
Computer Architecture adapted by Jason Fritts then by David Ferry
Y86 Processor State Program Registers
Pipelined Implementation : Part I
Seoul National University
Seoul National University
Computer Organization “Central” Processing Unit (CPU)
Pipelined Implementation : Part II
Systems I Pipelining III
Design of the Control Unit for One-cycle Instruction Execution
Computer Architecture adapted by Jason Fritts
Systems I Pipelining II
Pipelined Implementation : Part I
Seoul National University
Fields in the FALCON-A Instruction
Pipeline Architecture I Slides from: Bryant & O’ Hallaron
Pipelined Implementation : Part I
Recap: Performance Comparison
Pipelined Implementation
Pipelined Implementation
Computer Architecture
Systems I Pipelining II
Chapter 4 Processor Architecture
Systems I Pipelining II
Pipelined Implementation
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.
CS/COE0447 Computer Organization & Assembly Language
Presentation transcript:

Instruction Decoding Optional icode ifun valC Instruction Format 5 rA rB D icode ifun valC Optional Instruction Format Instruction byte icode:ifun Optional register byte rA:rB Optional constant word valC

How CPU executes instructions ? 50 05 0c 00 00 00 mrmov 0xc(%ebp),%eax 50 15 08 00 00 00 mrmov 0x8(%ebp),%ecx 60 10 add %ecx, %eax 20 54 rrmov %ebp,%esp

How CPU executes instructions ? 50 05 0c 00 00 00 mrmov 0xc(%ebp),%eax 50 15 08 00 00 00 mrmov 0x8(%ebp),%ecx 60 10 add %ecx, %eax 20 54 rrmov %ebp,%esp Fetch -- PC has instruction address Decode -- IR Execute [Data memory] [Write Back to Reg] Update PC

SEQ: Sequential Machine newPC SEQ: Sequential Machine PC valE , valM Write back valM Data Data Memory memory memory Fetch Read instruction from instruction memory Decode Read program registers Execute Compute value or address Memory Read or write data Write Back Write program registers PC Update program counter Addr , Data valE CC CC Execute Bch ALU ALU aluA , aluB valA , valB Decode srcA , srcB dstA , dstB Register Register A A B B Register Register M M file file file file E E icode , ifun valP rA , rB valC Instruction Instruction PC PC Fetch memory memory increment increment PC

SEQ: Sequential Machine For EACH instruction Write down operations at each phase SEQ-2 At EACH phase Determine how to accommodate operations for ALL instructions

Stage Computation: Arith/Log. Ops OPl rA, rB icode:ifun  M1[PC] rA:rB  M1[PC+1] valP  PC+2 Fetch Read instruction byte Read register byte Compute next PC valA  R[rA] valB  R[rB] Decode Read operand A Read operand B valE  valB OP valA Set CC Execute Perform ALU operation Set condition code register Memory R[rB]  valE Write back Write back result PC  valP PC update Update PC Formulate instruction execution as sequence of simple steps Use same general form for all instructions

Stage Computation: rmmovl rmmovl rA, D(rB) icode:ifun  M1[PC] rA:rB  M1[PC+1] valC  M4[PC+2] valP  PC+6 Fetch Read instruction byte Read register byte Read displacement D Compute next PC valA  R[rA] valB  R[rB] Decode Read operand A Read operand B valE  valB + valC Execute Compute effective address M4[valE]  valA Memory Write value to memory Write back PC  valP PC update Update PC Use ALU for address computation

Stage Computation: popl popl rA icode:ifun  M1[PC] rA:rB  M1[PC+1] valP  PC+2 Fetch Read instruction byte Read register byte Compute next PC valA  R[%esp] valB  R [%esp] Decode Read stack pointer valE  valB + 4 Execute Increment stack pointer valM  M4[valA] Memory Read from stack R[%esp]  valE R[rA]  valM Write back Update stack pointer Write back result PC  valP PC update Update PC Use ALU to increment stack pointer Must update two registers Popped value New stack pointer

Stage Computation: Jumps jXX Dest icode:ifun  M1[PC] valC  M4[PC+1] valP  PC+5 Fetch Read instruction byte Read destination address Fall through address Decode Bch  Cond(CC,ifun) Execute Take branch? Memory Write back PC  Bch ? valC : valP PC update Update PC Compute both addresses Choose based on setting of condition codes and branch condition

Stage Computation: call call Dest icode:ifun  M1[PC] valC  M4[PC+1] valP  PC+5 Fetch Read instruction byte Read destination address Compute return point valB  R[%esp] Decode Read stack pointer valE  valB + –4 Execute Decrement stack pointer M4[valE]  valP Memory Write return value on stack R[%esp]  valE Write back Update stack pointer PC  valC PC update Set PC to destination Use ALU to decrement stack pointer Store incremented PC

Stage Computation: ret icode:ifun  M1[PC] Fetch Read instruction byte valA  R[%esp] valB  R[%esp] Decode Read operand stack pointer valE  valB + 4 Execute Increment stack pointer valM  M4[valA] Memory Read return address R[%esp]  valE Write back Update stack pointer PC  valM PC update Set PC to return address Use ALU to increment stack pointer Read return address from memory

SEQ: Sequential Machine For EACH instruction Write down operations at each phase SEQ-2 At EACH phase Determine how to accommodate operations for ALL instructions

Fetch Phase OPl rA, rB popl rA call Dest icode:ifun  M1[PC] rA:rB  M1[PC+1] valP  PC+2 icode:ifun  M1[PC] rA:rB  M1[PC+1] valP  PC+2 icode:ifun  M1[PC] valC  M4[PC+1] valP  PC+5 rmmovl rA, D(rB) jXX Dest ret icode:ifun  M1[PC] rA:rB  M1[PC+1] valC  M4[PC+2] valP  PC+6 icode:ifun  M1[PC] valC  M4[PC+1] valP  PC+5 icode:ifun  M1[PC]

Fetch Logic Predefined Blocks PC: Register containing PC Instruction memory: Read 6 bytes (PC to PC+5) Split: Divide instruction byte into icode and ifun Align: Get fields for rA, rB, and valC

Fetch Logic Control Logic Instr. Valid: Is this instruction valid? Need regids: Does this instruction have a register bytes? Need valC: Does this instruction have a constant word?

Fetch Control Logic bool need_regids = icode in { IRRMOVL, IOPL, IPUSHL, IPOPL, IIRMOVL, IRMMOVL, IMRMOVL }; bool instr_valid = icode in { INOP, IHALT, IRRMOVL, IIRMOVL, IRMMOVL, IMRMOVL, IOPL, IJXX, ICALL, IRET, IPUSHL, IPOPL };

A Source OPl rA, rB valA  R[rA] Decode Read operand A rmmovl rA, D(rB) popl rA valA  R[%esp] Read stack pointer jXX Dest No operand call Dest ret int srcA = [ icode in { IRRMOVL, IRMMOVL, IOPL, IPUSHL } : rA; icode in { IPOPL, IRET } : RESP; 1 : RNONE; # Don't need register ];

Decode Cycle valA  R[rA] valB  R[rB] OPl rA, rB valA  R[rA] Decode rmmovl rA, D(rB) valA  R[rA] valB  R[rB] Decode

Decode Logic Control Logic Predefined Blocks Register File Read ports A, B Write ports E, M Addresses are register IDs or F (no access) Control Logic srcA, srcB: read port addresses dstA, dstB: write port addresses

Register File Register File Multiple registers Two read ports

Register File Write port

E Destination None R[%esp]  valE Update stack pointer R[rB]  valE OPl rA, rB Write-back rmmovl rA, D(rB) popl rA jXX Dest call Dest ret Write back result int dstE = [ icode in { IRRMOVL, IIRMOVL, IOPL} : rB; icode in { IPUSHL, IPOPL, ICALL, IRET } : RESP; 1 : RNONE; # Don't need register ];

Execute Cycle valE  valB OP valA Set CC Bch  Cond(CC,ifun) Resources OPl rA, rB valE  valB OP valA Set CC Execute valE  valB OP valA Set CC Bch  Cond(CC,ifun) rmmovl rA, D(rB) valE  valB + valC Execute jXX Dest Bch  Cond(CC,ifun) Execute Resources ALU Implements 4 required functions Generates condition code values CC Register with 3 condition code bits bcond Computes branch flag

Execute Logic Set CC: Should condition code register be loaded? Control Logic Set CC: Should condition code register be loaded? ALU A: Input A to ALU ALU B: Input B to ALU ALU fun: What function should ALU compute?

ALU A Input valE  valB + –4 Decrement stack pointer No operation Increment stack pointer valE  valB + valC Compute effective address valE  valB OP valA Perform ALU operation OPl rA, rB Execute rmmovl rA, D(rB) popl rA jXX Dest call Dest ret int aluA = [ icode in { IRRMOVL, IOPL } : valA; icode in { IIRMOVL, IRMMOVL, IMRMOVL } : valC; icode in { ICALL, IPUSHL } : -4; icode in { IRET, IPOPL } : 4; # Other instructions don't need ALU ];

ALU Operation valE  valB + –4 Decrement stack pointer No operation Increment stack pointer valE  valB + valC Compute effective address valE  valB OP valA Perform ALU operation OPl rA, rB Execute rmmovl rA, D(rB) popl rA jXX Dest call Dest ret int alufun = [ icode == IOPL : ifun; 1 : ALUADD; ];

Memory Logic Memory Reads or writes memory word Control Logic Mem. read: should word be read? Mem. write: should word be written? Mem. addr.: Select address Mem. data.: Select data

Memory Address OPl rA, rB Memory rmmovl rA, D(rB) popl rA jXX Dest call Dest ret No operation M4[valE]  valA Write value to memory valM  M4[valA] Read from stack M4[valE]  valP Write return value on stack Read return address int mem_addr = [ icode in { IRMMOVL, IPUSHL, ICALL, IMRMOVL } : valE; icode in { IPOPL, IRET } : valA; # Other instructions don't need address ];

Memory Read OPl rA, rB Memory rmmovl rA, D(rB) popl rA jXX Dest call Dest ret No operation M4[valE]  valA Write value to memory valM  M4[valA] Read from stack M4[valE]  valP Write return value on stack Read return address bool mem_read = icode in { IMRMOVL, IPOPL, IRET };

PC Update OPl rA, rB rmmovl rA, D(rB) popl rA jXX Dest call Dest ret PC  valP PC update Update PC PC  Bch ? valC : valP PC  valC Set PC to destination PC  valM Set PC to return address int new_pc = [ icode == ICALL : valC; icode == IJXX && Bch : valC; icode == IRET : valM; 1 : valP; ];

PC Update Logic New PC Select next value of PC

SEQ Hardware Key Blue boxes: predesigned hardware blocks E.g., memories, ALU Gray boxes: control logic White ovals: labels for signals Thick lines: 32-bit word values Thin lines: 4-8 bit values Dotted lines: 1-bit values

SEQ Operation State PC register Cond. Code register Data memory Register file All updated as clock rises Combinational Logic ALU Control logic Memory reads Instruction memory

SEQ Operation #2 state set according to second irmovl instruction combinational logic starting to react to state changes

SEQ Operation #3 state set according to second irmovl instruction combinational logic generates results for addl instruction

SEQ Operation #4 state set according to addl instruction combinational logic starting to react to state changes

SEQ Operation #5 state set according to addl instruction combinational logic generates results for je instruction

SEQ H/W Structure State Program counter register (PC) newPC PC SEQ H/W Structure valE , valM Write back valM State Program counter register (PC) Condition code register (CC) Register File Memories Access same memory space Data: for reading/writing program data Instruction: for reading instructions Instruction Flow Read instruction at address specified by PC Process through stages Update program counter Data Data Memory memory memory Addr , Data valE CC CC Execute Bch ALU ALU aluA , aluB valA , valB Decode srcA , srcB dstA , dstB Register Register A A B B Register Register M M file file file file E E icode , ifun valP rA , rB valC Instruction Instruction PC PC Fetch memory memory increment increment PC

SEQ Summary Implementation Express every instruction as series of simple steps Follow same general flow for each instruction type Assemble registers, memories, predesigned combinational blocks Connect with control logic Limitations Too slow to be practical In one cycle, must propagate through instruction memory, register file, ALU, and data memory Would need to run clock very slowly Hardware units only active for fraction of clock cycle

Suppose that we want to add a new instruction iaddl into Y86, which adds a constant value to a register. Its instruction format is given as Describe the operation of SEQ control unit to implement this instruction.