Prof. Dr. Nizamettin AYDIN

[email protected] MIPS ISA - I [email protected]

http://www.yildiz.edu.tr/~naydin

1 2

Outline Computer Architecture

• Overview of the MIPS architecture • can be viewed as – ISA vs ? – the machine language the CPU implements – CISC vs RISC • Instruction set architecture (ISA) – Basics of MIPS – Built in data types (integers, floating point numbers) – Components of the MIPS architecture – Fixed set of instructions – Fixed set of on- variables (registers) – and – Interface for reading/writing memory – Memory – Mechanisms to do input/output – Memory addressing issue – how the ISA is implemented – Other components of the datapath • Microarchitecture – Control unit

3 4

Computer Architecture MIPS Architecture

• Microarchitecture • MIPS – An acronym for without Interlocking Pipeline Stages – Not to be confused with a unit of speed equivalent to a Million • MIPS processor – born in the early 1980s from the work done by John Hennessy and his students at Stanford University • exploring the architectural concept of RISC – Originally used in Unix workstations, – now mainly used in small devices • Play Station, routers, printers, robots, cameras

5 6

Copyright 2000 N. AYDIN. All rights reserved. 1 MIPS Architecture CISC vs RISC

• Designer MIPS Technologies, Imagination Technologies • Advantages of CISC Architecture: • Bits 64-bit (32 → 64) • Introduced 1985; – Microprogramming is easy to implement and much • Version MIPS32/64 Release 6 (2014) less expensive than hard wiring a control unit. • Design RISC – It is easy to add new commands into the chip without • Type Register-Register changing the structure of the instruction set as the • Encoding Fixed architecture uses general-purpose hardware to carry out • Branching Compare and branch commands. • BigEndian – This architecture makes the efficient use of main • Page size 4 KB memory since the complexity (or more capability) of • Extensions MDMX, MIPS-3D instruction allows to use less number of instructions to • Open No • Registers achieve a given task. – General purpose 32 – The compiler need not be very complicated, as the – Floating point 32 microprogram instruction sets can be written to match the constructs of high level languages. • Source: wikipedia

7 8

CISC vs RISC CISC vs RISC

• Disadvantages of CISC Architecture: • Advantages of RISC Architecture: – The performance of RISC processors is often two to four – A new or succeeding versions of CISC processors times than that of CISC processors because of simplified consists early generation processors in their subsets. instruction set. • Therefore, chip hardware and instruction set became complex – This architecture uses less chip space due to reduced with each generation of the processor. instruction set. – The overall performance of the machine is reduced due • This makes to place extra functions like floating point arithmetic to the different amount of clock time required by units or memory management units on the same chip. – The per-chip cost is reduced by this architecture that uses different instructions. smaller chips consisting of more components on a single – This architecture necessitates on-chip hardware to be silicon wafer. continuously reprogrammed. – RISC processors can be designed more quickly than CISC – The complexity of hardware and on-chip software processors due to its simple architecture. – The execution of instructions in RISC processors is high included in CISC design to perform many functions. due to the use of many registers for holding and passing the instructions as compared to CISC processors.

9 10

CISC vs RISC MIPS Basics

• Disadvantages of RISC Architecture: • Instructions – The performance of a RISC processor depends on – 4 bytes (32 bits) the code that is being executed. – 4-byte aligned (i.e., they start at addresses that are • The processor spends much time waiting for first a multiple of 4 --0x0000, 0x0004, etc.) Memory addresses and Actual MIPS memory addresses and instruction result before it proceeds with next contents of memory at those locations contents of memory for those words subsequent instruction, when a compiler makes a poor job of scheduling instruction execution. – RISC processors require very fast memory systems to feed various instructions. • Typically, a large memory is provided on the chip in most RISC based systems. – Instructions operate on memory and registers

11 12

Copyright 2000 N. AYDIN. All rights reserved. 2 Bytes and WordsAddressData MIPS Basics

• In modern ISAs memory is byte addressable • Memory Data types (also aligned) Byte addresses Half Word Addresses Word addresses – Bytes (8 bits) – Half words (16 bits) – Words (32 bits) – Memory is denoted as M • e.g., M[0x10] is the byte at address 0x10 • Registers – 32 4-byte registers in the – Denoted as R • e.g., R[2] is register 2 • In MIPS, half words and words are aligned.

13 14

Components of the MIPS architecture Components of the MIPS architecture

• Major hardware components of the instruction • Major components of the datapath: cycle – program (PC) – Datapath • path of instructions and data through the processor – instruction register (IR) • components connected by buses – register file – [- parallel path for transmitting values] – [in MIPS, usually 32 bits wide] – arithmetic and logic unit (ALU) – Control unit – memory • controls the components of the datapath • determines how data moves through the datapath • receives condition signals from the components • Control unit • sends control signals to the components

between buses with http://www.cise.ufl.edu/~mssz/CompOrg/Figure4.3-MIPSarch2.gif

15 16

Components of the MIPS architecture Components of the MIPS architecture

• Memory • Memory • In MIPS, programs are separated from data in memory – Text segment • instruction memory • part of memory that stores the program (machine code) • read only – Data segment • Distinction may or may not be reflected in the • data memory hardware: • part of memory that stores data manipulated by program – (single, shared memory) • read/write – (physically separate memories)

17 18

Copyright 2000 N. AYDIN. All rights reserved. 3 Components of the MIPS architecture Components of the MIPS architecture

• Memory addressing in MIPS • (PC) – Memory address computed as base+offset for – Register that stores the address of the next reading/writing the data segment instruction to fetch • base is obtained from a register • also called the • offset is given directly as an integer instruction pointer (IP) – Load word (read word from memory into register): lw $t1, 8($t2)  $t1 := Memory[$t2+8]

– Store word (write word from register into • Program memory): – a sequence of machine instructions in the text segment sw $t1, 4($t2)  Memory[$t2+4] := $t1

19 20

Components of the MIPS architecture Components of the MIPS architecture

• Instruction register (IR) • Register file – Register that holds the instruction currently being – MIPS register file contains 32 registers decoded

• Register – component that stores a 32-bit value

21 22

The MIPS Register File Components of the MIPS architecture

• All registers are the same • Arithmetic and logic unit (ALU) – where a register is needed any register will work – Implements binary arithmetic and logic operations • By convention, we use them for particular tasks – Argument passing – Temporaries, etc. • $zero is the zero register – It is always zero. • Inputs: • Outputs: – Writes to it have no effect. – operands (2×32-bit) – result (1×64-bit) – operation (control signals) – status (condition signals)

23 24

Copyright 2000 N. AYDIN. All rights reserved. 4 Components of the MIPS architecture Components of the MIPS architecture

• Control unit • Control unit – Controls components of datapath to implement – Condition signals – Implemented as a finite state machine • from IR – decode operation, arguments, result location • from ALU – overflow, divide-by-zero, . . . – Control signals • to multiplexors – buses to select • to each register – load new value • to ALU – operation to perform • to all – – clock signal • ensures that outputs are not used until ready • Inputs: • Outputs: • synchronizes the components in the data path – the faster the clock, the faster the program executes – condition signals – control signals • is limited by the slowest component!

25 26

MIPS data path with control signals

http://fourier.eng.hmc.edu/e85/lectures/figures/MIPS_datapath_control.gif

27 28

Copyright 2000 N. AYDIN. All rights reserved. 5