instruction set architecture
play

Instruction Set Architecture C P U C oprocessor 1 (FP U ) of R - PowerPoint PPT Presentation

MIPS Processor CSE 675.02: Introduction to Computer Architecture M em ory Instruction Set Architecture C P U C oprocessor 1 (FP U ) of R egiste rs R egisters $ 0 $0 MIPS Processor $31 $ 31 Control A rithm etic M ultiply Logic unit


  1. MIPS Processor CSE 675.02: Introduction to Computer Architecture M em ory Instruction Set Architecture C P U C oprocessor 1 (FP U ) of R egiste rs R egisters $ 0 $0 MIPS Processor $31 $ 31 Control A rithm etic M ultiply Logic unit divide Arithmetic Prog. Counter unit Lo H i Presentation B C oprocessor 0 (tra ps a nd m e m ory) R egiste rs Slides by BadV Addr C a use Status E P C Gojko Babi ć Figure A.10.1 06/21/2005 g. babic Presentation B 2 MIPS Registers MIPS Registers (continued) • CPU: • Coprocessor 0 – CP0 is incorporated on the MIPS CPU chip and it provides functions necessary to support operating – 32 32-bit general purpose registers – GPRs (r0 – r31); system: exception handling, memory management scheduling r0 has fixed value of zero. Attempt to writing into r0 is not and control of critical resources. illegal, but its value will not change; – two 32-bit registers – Hi & Lo, hold results of integer • Coprocessor 0 (CP0) registers (partial list): multiply and divide – Status register (CP0reg12) – processor status and control; – 32-bit program counter – PC; – Cause register (CP0reg13) – cause of the most recent • Floating Point Processor – FPU (Coprocessor 1 – CP1): exception; – 32 32-bit floating point registers – FPRs (f0 – f31); – EPC register (CP0reg14) – program counter at the last – five control registers; exception; – BadVAddr register (CP0reg08) – the address for the most recent address related exception; g. babic Presentation B 3 g. babic Presentation B 4

  2. MIPS Data Types MIPS arithmetic • MIPS operates on: • All instructions have 3 operands • Operand order is fixed (destination first) – 32-bit (unsigned or 2’s complement) integers, – 32-bit (single precision floating point) real numbers, Example: – 64-bit (double precision floating point) real numbers; C code: a = b + c • bytes and half words loaded into GPRs are either zero or sign MIPS ‘code’: add a, b, c bit expanded to fill the 32 bits; “The natural number of operands for an operation like • only 32-bit units can be loaded into FPRs; 32-bit real numbers addition is three…requiring every instruction to have are stored in even numbered FPRs. exactly three operands, no more and no less, conforms to the philosophy of keeping the hardware simple” • 64-bit real numbers are stored in two consecutive FPRs, starting with even-numbered register. g. babic Presentation B 5 MIPS arithmetic Registers vs. Memory • Design Principle: simplicity favors regularity. • Arithmetic instructions operands must be • Of course this complicates some things... registers, — only 32 registers provided C code: a = b + c + d; • Compiler associates variables with registers MIPS code: add a, b, c • What about programs with lots of variables add a, a, d • Operands must be registers, only 32 registers provided Control Input • Each register contains 32 bits Memory Datapath Output • Design Principle: smaller is faster. Why? Processor I/O

  3. MIPS Addressing Modes Memory Organization • register addressing; • immediate addressing; • Viewed as a large, single-dimension array, • only one memory data addressing: with an address. – register content plus offset (register indexed); • A memory address is an index 0 8 bits of data • since r0 always contains value 0: 1 8 bits of data – r0 + offset � absolute addressing; into the array 2 8 bits of data • offset = 0 � register indirect; • "Byte addressing" means that 3 8 bits of data • MIPS supports byte addressability: 4 8 bits of data the index points to a byte of – it means that a byte is the smallest unit with its address; 5 8 bits of data memory. 6 8 bits of data • MIPS supports 32-bit addresses: ... – it means that an address is given as 32-bit unsigned integer; g. babic Presentation B 10 MIPS Alignment Memory Organization • MIPS restricts memory accesses to be aligned as follows: • Bytes are nice, but most data items use larger "words" – 32-bit word has to start at byte address that is multiple of 4; • For MIPS, a word is 32 bits or 4 bytes. 32-bit word at address 4n includes four bytes with addresses 4n, 4n+1, 4n+2, and 4n+3. 0 32 bits of data Registers hold 32 bits of data 4 32 bits of data – 16-bit half word has to start at byte address that is multiple 8 32 bits of data of 2; 12 32 bits of data 16-bit word at address 2n includes two bytes with addresses ... • 2 32 bytes with byte addresses from 0 to 2 32 -1 2n and 2n+1. • 2 30 words with byte addresses 0, 4, 8, ... 2 32 -4 • Words are aligned i.e., what are the least 2 significant bits of a word address? g. babic Presentation B 12

  4. MIPS Instructions Our First Example • 32-bit fixed format instruction and 3 formats; • register – register and register-immediate computational • Can we figure out the code? Guess!!! instructions; swap(int v[], int k); { int temp; • single address mode for load/store instructions: temp = v[k] v[k] = v[k+1]; – register content + offset (called base addressing); v[k+1] = temp; swap: } • simple branch conditions; muli $2, $5, 4 add $2, $4, $2 – branch instructions use PC relative addressing; lw $15, 0($2) lw $16, 4($2) – branch address = [PC] + 4 + 4×offset sw $16, 0($2) sw $15, 4($2) • jump instructions with: jr $31 – 28-bit addresses (jumps inside 256 megabyte regions), or – absolute 32-bit addresses. g. babic Presentation B 13 MIPS Instruction (continued) Stored Program Concept • Instructions that move data: – load to register from memory, • Instructions are bits – store from register to memory, • Programs are stored in memory – move between registers in same and different — to be read or written just like data coprocessors memory for data, programs, • ALU integer instructions, compilers, editors, etc. Processor Memory • Floating point instructions, • Control-related instructions, • Fetch & Execute Cycle – Instructions are fetched and put into a special register • Special control-related instructions. – Bits in the register "control" the subsequent actions – Fetch the “next” instruction and continue g. babic Presentation B 15

  5. MIPS Instruction Layout CPU Load & Store Instructions • lw rt, offset(rs) ; load 32-bits: • MIPS instructions are an example of fixed field decoding Regs[rt] � Mem [offset+Regs[rs]] • sw rt, offset(rs) ; store 32-bits: Mem [offset+Regs[rs]] � Regs[rt] /ft /offset • lb rt, offset(rs) ; load 8-bits (byte): Regs[rt] � 24-bit sign-extend || Mem [offset+Regs[rs]] Note: || means concatenation. /ft /fs /fd • lbu rt, offset(rs) ; load 8-bits (byte) unsigned: and fd � fs funct ft Regs[rt] � 24-bit zero-extend || Mem [offset+Regs[rs]] • sh rt, offset(rs) ; store 16-bits: jump_target Mem [offset+Regs[rs]] � Regs[rt] (16 least significant bits taken from the register) Plus: sb, lh, & lhu g. babic Presentation B 17 g. babic Presentation B 18 FP Load, Store & Move Instructions Move Instructions • lwc1 ft, offset(rs) ; load into FP register: • mfc1 rt, fs ; move from FPU to CPU: Regs[rt] � Regs[fs] Regs[ft] � Mem [offset+Regs[rs]] • mtc1 rt, fs ; move from CPU to FPU: Regs[fs] � Regs[rt] • swc1 ft, offset(rs) ; store from FP register: Mem [offset+Regs[rs]] � Regs[ft] • mfc0 rt, rd ; move from CP0 to CPU: Regs[rt] � CP0 Regs[rd] • mov.d fd, fs ; move FP double precision between FPRs: Regs[fd] || Regs[fd+1] � Regs[fs] || Regs[fs+1] • mtc0 rt, rd ; move from CPU to CP0: CP0 Regs[rd] � Regs[rt] • mov.s fd, fs ; move FP single precision between FPRs: Regs[fd] � Regs[fs] Regs[rd] � Hi; • mfhi rd ; move from Hi: Regs[rd] � Lo; • mflo rd ; move from Lo: g. babic Presentation B 19 g. babic Presentation B 20

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend