CPE 335 CPE 335 Computer Organization MIPS ISA
- Dr. Iyad Jafar
Adapted from Dr. Gheith Abandah Slides http://www.abandah.com/gheith/Courses/CPE335_S08/index.html
CPE 232 MIPS ISA 1
CPE 335 CPE 335 Computer Organization MIPS ISA Dr. Iyad Jafar - - PowerPoint PPT Presentation
CPE 335 CPE 335 Computer Organization MIPS ISA Dr. Iyad Jafar Adapted from Dr. Gheith Abandah Slides http://www.abandah.com/gheith/Courses/CPE335_S08/index.html CPE 232 MIPS ISA 1 (vonNeumann) Processor Organization Control needs to
CPE 232 MIPS ISA 1
1.
CPU Control Memory Devices Input
2.
Control Datapath Input Output
Fetch
3.
Decode Exec
components – the functional units and
interconnects - components connected so that the instructions can
CPE 232 MIPS ISA 2
CPE 232 MIPS ISA 3
CPE 232 MIPS ISA 4
fixed instruction lengths load-store instruction sets limited addressing modes limited operations limited operations
CPE 232 MIPS ISA 5
Computational
Load/Store Jump and Branch
Floating Point
Memory Management Special
CPE 232 MIPS ISA 6
31 30 29 . . . 3 2 1 0 bit position 231 230 229 . . . 23 22 21 20 bit weight
CPE 232 MIPS ISA 7
ASCII Ch ASCII Ch ASCII Ch ASCII Ch ASCII Ch ASCII Ch ASCII Char ASCII Char ASCII Char ASCII Char ASCII Char ASCII Char
Null 32 space 48 64 @ 96 ` 112 p 1 33 ! 49 1 65 A 97 a 113 q 2 34 “ 50 2 66 B 98 b 114 r 2 34 50 2 66 B 98 b 114 r 3 35 # 51 3 67 C 99 c 115 s 4 EOT 36 $ 52 4 68 D 100 d 116 t 5 37 % 53 5 69 E 101 e 117 u 5 37 % 53 5 69 E 101 e 117 u 6 ACK 38 & 54 6 70 F 102 f 118 v 7 39 ‘ 55 7 71 G 103 g 119 w 8 bksp 40 ( 56 8 72 H 104 h 120 x 8 bksp 40 ( 56 8 72 H 104 h 120 x 9 tab 41 ) 57 9 73 I 105 i 121 y 10 LF 42 * 58 : 74 J 106 j 122 z 11 43 + 59 ; 75 K 107 k 123 { 11 43 + 59 ; 75 K 107 k 123 { 12 FF 44 , 60 < 76 L 108 l 124 | 15 47 / 63 ? 79 O 111
DEL
CPE 232 MIPS ISA 8
5 / 63 9 O
32 bits
32 5
Two read ports and
32 locations 5 5
One write port
32 32
Faster than main memory
Easier for a compiler to use
Can hold variables so that
CPE 232 MIPS ISA 9
CPE 232 MIPS ISA 10
CPE 232 MIPS ISA 11
CPE 232 MIPS ISA 12
CPE 232 MIPS ISA 13
CPE 232 MIPS ISA 14
CPE 232 MIPS ISA 15
CPE 232 MIPS ISA 16
A 16-bit field meaning access is limited to memory locations A 16 bit field meaning access is limited to memory locations
Note that the offset can be positive or negative
CPE 232 MIPS ISA 17
Note that the offset can be positive or negative
10
CPE 232 MIPS ISA 18
The memory address of a word must be a multiple of 4
CPE 232 MIPS ISA 19
load byte places the byte from memory in the rightmost 8 bits of
store byte takes the byte from the rightmost 8 bits of a register
CPE 232 MIPS ISA 20
CPE 232 MIPS ISA 21
CPE 232 MIPS ISA 22
Ex:
Ex:
CPE 232 MIPS ISA 23
which register? Instruction Address Register (the PC)
limits the branch distance to -215 to +215-1 instructions from the
ff t
16
from the low order 16 bits of the branch instruction
00
sign-extend PC
Add 32 32 32 32 32
branch dst address
Add 4
CPE 232 MIPS ISA 24
32
4 32
CPE 232 MIPS ISA 25
CPE 232 MIPS ISA 26
less than
less than or equal to
greater than
great than or equal to
Its why the assembler needs a reserved register ($at)
CPE 232 MIPS ISA 27
Its why the assembler needs a reserved register ($at)
26
from the low order 26 bits of the jump instruction
00
PC
4 32 00
CPE 232 MIPS ISA 28
PC
32
CPE 232 MIPS ISA 29
CPE 232 MIPS ISA 30
uses a stack – a last-in-first-out queue – in memory for passing
high addr
add data onto the stack – push
high addr
add data onto the stack – push
$sp top of stack
remove data from the stack – pop
low addr
CPE 232 MIPS ISA 31
put “typical constants” in memory and load them create hard-wired registers (like $zero) for constants like 1
have special instructions that contain constants !
CPE 232 MIPS ISA 32
Immediate format limits values to the range +215–1 to -215
CPE 232 MIPS ISA 33
1 1100
Register File
read/write 1…1100
src1 addr src2 addr dst addr src1 data 32 registers ($zero $ra) 32 5 5
230 words read/write addr
dst addr write data 32 bits src2 data ($zero - $ra) 32 32 32 5
read data
32 PC 32 32 Add 32 Add 32 32 branch offset
write data 0000 0…0100 0…1000 0…1100
32 ALU 32 1 2 3 7 6 5 4 Fetch PC = PC+4 D d E 32 32 4 32 bits
word address (binary) 0…0000
ALU 32 32 1 2 3 byte address (big Endian) Decode Exec
CPE 232 MIPS ISA 34
(big Endian)
Register relative (indirect) with 0($a0) Pseudo-direct with addr($zero)
CPE 232 MIPS ISA 35
CPE 232 MIPS ISA 36
fixed size instructions – 32-bits small number of instruction formats
three instruction formats
limited instruction set limited number of registers in register file limited number of addressing modes
arithmetic operands from the register file (load-store machine)
CPE 232 MIPS ISA 37
allow instructions to contain immediate operands
Category Instr Op Code Example Meaning
Arithmetic (R & I add 0 and 32 add $s1, $s2, $s3 $s1 = $s2 + $s3 subtract 0 and 34 sub $s1, $s2, $s3 $s1 = $s2 - $s3 (R & I format) add immediate 8 addi $s1, $s2, 6 $s1 = $s2 + 6
13
$s1 = $s2 v 6 Data load word 35 lw $s1 24($s2) $s1 = Memory($s2+24) Data Transfer (I format) load word 35 lw $s1, 24($s2) $s1 Memory($s2+24) store word 43 sw $s1, 24($s2) Memory($s2+24) = $s1 load byte 32 lb $s1, 25($s2) $s1 = Memory($s2+25) store byte 40 sb $s1 25($s2) Memory($s2+25) $s1 store byte 40 sb $s1, 25($s2) Memory($s2+25) = $s1 load upper imm 15 lui $s1, 6 $s1 = 6 * 216 Cond. Branch br on equal 4 beq $s1, $s2, L if ($s1==$s2) go to L Branch (I & R format) br on not equal 5 bne $s1, $s2, L if ($s1 !=$s2) go to L set on less than 0 and 42 slt $s1, $s2, $s3 if ($s2<$s3) $s1=1 else $s1=0 t l th 10 lti $ 1 $ 2 6 if ($ 2 6) $ 1 1 l set on less than immediate 10 slti $s1, $s2, 6 if ($s2<6) $s1=1 else $s1=0 Uncond. Jump jump 2 j 2500 go to 10000 j i t d 8 j $t1 t $t1
CPE 232 MIPS ISA 38
Jump (J & R format) jump register 0 and 8 jr $t1 go to $t1 jump and link 3 jal 2500 go to 10000; $ra=PC+4
CPE 232 MIPS ISA 39
CPE 232 MIPS ISA 40
CPE 232 MIPS ISA 41
0x00af8020 0x0c001101
CPE 232 MIPS ISA 42
What is the address of the instruction to be executed after the
What is the content of the $ra register after executing
What is the address of the instruction if the condition checked by
CPE 232 MIPS ISA 43
CPE 232 MIPS ISA 44