CSE502: Computer Architecture Basic Instruction Decode.

Slides:



Advertisements
Similar presentations
CSE502: Computer Architecture Superscalar Decode.
Advertisements

1 B. Bruidegom Computer Architecture Top down approach B. Bruidegom AMSTEL-instituut.
CS/COE1541: Introduction to Computer Architecture Datapath and Control Review Sangyeun Cho Computer Science Department University of Pittsburgh.
Lab 4 Design a processor to implement the Fibonacci sequence
MIPS Assembly Tutorial
ITEC 352 Lecture 13 ISA(4).
ISA Issues; Performance Considerations. Testing / System Verilog: ECE385.
1 Lecture 3: Instruction Set Architecture ISA types, register usage, memory addressing, endian and alignment, quantitative evaluation.
EECC551 - Shaaban #1 Lec # 2 Fall Instruction Set Architecture (ISA) “... the attributes of a [computing] system as seen by the programmer,
1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
10/9: Lecture Topics Starting a Program Exercise 3.2 from H+P Review of Assembly Language RISC vs. CISC.
ELEN 468 Advanced Logic Design
CSE 340 Computer Architecture Spring 2014 MIPS ISA Review
INTRODUCTION TO THE ARM PROCESSOR – Microprocessor Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
Datorteknik DatapathControl bild 1 Designing a Single Cycle Datapath & Datapath Control.
MIPS Architecture CPSC 321 Computer Architecture Andreas Klappenecker.
Midterm Wednesday Chapter 1-3: Number /character representation and conversion Number arithmetic Combinational logic elements and design (DeMorgan’s Law)
CSE502: Computer Architecture Instruction Decode.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 4:
ITEC 352 Lecture 20 JVM Intro. Functions + Assembly Review Questions? Project due today Activation record –How is it used?
Princess Sumaya Univ. Computer Engineering Dept. Chapter 5:
Computer Architecture CSE 3322 Lecture 2 NO CLASS MON Sept 1 Course WEB SITE crystal.uta.edu/~jpatters.
Electrical and Computer Engineering University of Cyprus LAB 2: MIPS.
Crosscutting Issues: The Rôle of Compilers Architects must be aware of current compiler technology Compiler Architecture.
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
MS108 Computer System I Lecture 3 ISA Prof. Xiaoyao Liang 2015/3/13 1.
Computer Architecture Lecture 10 MIPS Control Unit Ralph Grishman Oct NYU.
Our programmer needs to do this !
Machine Instructions Instruction Formats. Machine Instructions u Internal Signals in computer have high and low voltages which represent values 0 and.
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Single-Cycle Datapath and Control.
COM181 Computer Hardware Lecture 6: The MIPs CPU.
MIPS Processor.
Instruction Set Architectures Continued. Expanding Opcodes & Instructions.
ECE/CS 552: Single Cycle Control Path
Access the Instruction from Memory
EE204 Computer Architecture
MIPS Assembly.
Electrical and Computer Engineering University of Cyprus
CS161 – Design and Architecture of Computer Systems
Immediate Addressing Mode
COMPUTER ARCHITECTURE & OPERATIONS I
6/16/2018 CIS-550 Advanced Computer Architecture Lecture 4: ISA Tradeoffs (Continued) and MIPS ISA Dr. Muhammad Abid DCIS, PIEAS Spring
Choices in Designing an ISA
IT 251 Computer Organization and Architecture
ELEN 468 Advanced Logic Design
Processor Architecture: Introduction to RISC Datapath (MIPS and Nios II) CSCE 230.
Prof. Sirer CS 316 Cornell University
Instruction Format MIPS Instruction Set.
School of Computing and Informatics Arizona State University
Computer Architecture & Operations I
Super Quick Architecture Review
Control Path Catholic University PUCRS.
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
CSCI206 - Computer Organization & Programming
The University of Adelaide, School of Computer Science
COMS 361 Computer Organization
Instruction encoding The ISA defines Format = Encoding
Prof. Sirer CS 316 Cornell University
COMP541 Datapaths I Montek Singh Mar 18, 2010.
Instruction Format MIPS Instruction Set.
Instruction encoding The ISA defines Format = Encoding
Review Fig 4.15 page 320 / Fig page 322
Instruction encoding The ISA defines Format = Encoding
Data Path Diagrams.
CPU Structure CPU must:
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
Processor: Datapath and Control
Presentation transcript:

CSE502: Computer Architecture Basic Instruction Decode

CSE502: Computer Architecture RISC ISA Format Fixed-length – MIPS all insts are 32-bits/4 bytes Few formats – MIPS has 3: R (reg, reg, reg), I (reg, reg, imm), J (addr) – Alpha has 5: Operate, Op w/ Imm, Mem, Branch, FP Regularity across formats (when possible/practical) – MIPS & Alpha opcode in same bit-position for all formats – MIPS rs & rt fields in same bit-position for R and I formats – Alpha ra/fa field in same bit-position for all 5 formats

CSE502: Computer Architecture RISC Decode (MIPS) opcode 6 other 21 func 5 R-format only opcode[5,3] opcode[2,0] funcrtjjalbeqbneblezbgtz 001addiaddiusltisltiuandiorixorilui 010rs lblhlwllwlbulhulwr 101sbshswlswswr 110lwc0lwc1lwc2lwc3 111swc0swc1swc2swc3 1xxxxx = Memory (1x0: LD, 1x1: ST) 1xxxxx = Memory (1x0: LD, 1x1: ST) 001xxx = Immediate 000xxx = Br/Jump (except for ) 000xxx = Br/Jump (except for )

CSE502: Computer Architecture PLA Decoders (1/2) PLA = Programmable Logic Array Simple logic to transform opcode to control signals – is_jump = !op5 & !op4 & !op3 & (op2 | op1 | op0) – use_funct = !op5 & !op4 & !op3 & !op2 & !op1 & !op0 – use_imm = op5 | !op5 & !op4 & op3 – is_load = op5 & !op3 – is_store = op5 & op3

CSE502: Computer Architecture PLA Decoders (2/2) op 5 op 4 op 3 op 2 op 1 op 0 is_store is_load use_imm use_funct is_jump is_mem AND Array AND Array OR Array OR Array 4-input AND gate 2-input OR gate

CSE502: Computer Architecture CISC ISA RISC focus on fast access to information – Easy decode, many registers, fast caches CISC focus on max expressiveness per min space – Designed in era with fewer transistors – Each memory access very expensive Pack as much work into as few bytes as possible More expressive instructions – Better potential code generation in theory – More complex code generation in practice

CSE502: Computer Architecture ModeExampleMeaning RegisterADD R4, R3, R2R4 <= R3 + R2 ADD in RISC ISA

CSE502: Computer Architecture ModeExampleMeaning RegisterADD R4, R3R4 <= R4 + R3 ImmediateADD R4, #3R4 <= R4 + 3 Register IndirectADD R4, (R1)R4 <= R4 + Mem[R1] DisplacementADD R4, 100(R1)R4 <= R4 + Mem[100+R1] Indexed/BaseADD R3, (R1+R2)R3 <= R3 + Mem[R1+R2] Direct/AbsoluteADD R1, (1234)R1 <= R1 + Mem[1234] Memory IndirectADD <= R1 + Mem[Mem[R3]] Auto-IncrementADD R1,(R2)+R1 <= R1 + Mem[R2]; R2++ Auto-DecrementADD R1, -(R2)R2--; R1 <= R1 + Mem[R2] ADD in CISC ISA

CSE502: Computer Architecture x86 CISC, stemming from the original 4004 (~1971) Example: Move instructions – General Purpose data movement R R, M R, R M, I R, I M – Exchanges EAX ECX, byte order within a register – Stack Manipulation push / pop R Stack, pusha/popa (removed in 64-bit, thankfully) – Type Conversion – Conditional Moves Many ways to do the same/similar operation

CSE502: Computer Architecture x86 Encoding x86 Instruction Format: Opcode indicates if Mod R/M is present –Many (not all) instructions use the Mod R/M byte –Mod R/M specifies if optional SIB byte is used –Mod R/M and SIB may specify additional constants –Displacement, Immediate Prefixes 0-4 bytes Prefixes 0-4 bytes Opcode 1-2 bytes Opcode 1-2 bytes Mod R/M 0-1 bytes Mod R/M 0-1 bytes SIB 0-1 bytes SIB 0-1 bytes Displacement 0/1/2/4 bytes Displacement 0/1/2/4 bytes Immediate 0/1/2/4 bytes Immediate 0/1/2/4 bytes Longest Inst: 15 bytesShortest Inst: 1 byte Instruction length not known until after decode

CSE502: Computer Architecture x86 Mod R/M Byte Mode = 00: No-displacement, use Mem[Rmmm] Mode = 01: 8-bit displacement, Mem[Rmmm+disp)] Mode = 10: 32-bit displacement (similar to previous) Mode = 11: Register-to-Register, use Rmmm M M M M r r r r r r m m m m m m ModeRegisterR/M 1 of 8 registers ADD EBX, ECX Mod R/M ADD EBX, [ECX] Mod R/M

CSE502: Computer Architecture x86 Mod R/M Exceptions Mod=00, R/M = 5 get operand from 32-bit imm – Add EDX = EDX+Mem[0cff1234] Mod=00, 01, or 10, R/M = 4 use the SIB byte – SIB = Scale/Index/Base cff Mod R/M ss iii bbb SIB bbb 5: use reg bbb bbb = 5: use 32-bit imm (Mod = 00 only) iii 4: use si iii = 4: use 0 si = reg iii << ss

CSE502: Computer Architecture x86 Opcode Confusion There are different opcodes for A B and B A If Opcode = 0F, then use next byte as opcode If Opcode = D8-DF, then FP instruction MOV EAX, EBX MOV EBX, EAX MOV EAX, EBX R/M FP opcode

CSE502: Computer Architecture x86 Decode Example struct { long a; long b; long c;} myobj[5]; myobj[2]->b = 0xF001234; MOV 0xF001234,0x8(%ebx,%eax,8) MOV reg imm (store 32-bit Imm in reg ptr, use Mod R/M) opcode Mod=2(10) (use 32-bit Disp) R/M = 4(100) (use SIB) reg ignored Mod R/M SIB ss=3(11) Scale by 8 use EAX, EBX DispImm *( (EAX<<3) + EBX + Disp ) = Imm Total: 11 byte instruction Note: Add 4 prefixes, and you reach the max size

CSE502: Computer Architecture RISC (MIPS) vs CISC (x86) lui R1, Disp[31:16] ori R1, R1, Disp[15:0] add R1, R1, R2 shli R3, R3, 3 add R3, R3, R1 lui R1, Imm[31:16] ori R1, R1, Imm[15:0] st [R3], R1 MOV Imm, Disp(%EBX,%EAX,8) 8 insns. at 32 bits each vs 1 insn. at 88 bits: 2.9x!

CSE502: Computer Architecture x86-64 / EM64T 8 16 general purpose registers – But we only used to have 3-bit register fields... Registers extended from bits each Default: instructions still 32-bit – New REX prefix byte to specify additional information 0100 m m R R I I B B opcode m=0 32-bit mode m=1 64-bit mode md rrr mrm R R rrr ss iii bbb iii I I bbb B B REX

CSE502: Computer Architecture 64-bit Extensions to IA32 IA32+64-bit exts IA32 CPU architect (Taken from Bob Colwells Eckert-Mauchly Award Talk, ISCA 2005) Ugly? Scary? But it works…

CSE502: Computer Architecture Decoded x86 Format RISC: easy to expand union of needed info – Generalized opcode (not too hard) – reg1, reg2, reg3, immediate (possibly extended) – Some fields ignored CISC: union of all possible info is huge – Generalized opcode (too many options) – Up to 3 regs, 2 immediates Too expensive to decode x86 into control bits

CSE502: Computer Architecture x86 RISC-like mops x86 decoded into uops(Intel) or ROPs(AMD) … (micro-ops or RISC-ops) – Each uop is RISC-like – uops have limitations to keep union of info practical ADD EAX, EBX 1 uop ADD EAX, [EBX] LOAD tmp = [EBX] ADD EAX, tmp 2 uops ADD [EAX], EBX LOAD tmp = [EAX] ADD tmp, EBX STA EAX STD tmp 4 uops