Docsity

Understanding Branch Instructions and Data Hazards in the MIPS Processor - Prof. Ming-Hsua, Study notes of Computer Architecture and Organization

Partial preview of the text

Download Understanding Branch Instructions and Data Hazards in the MIPS Processor - Prof. Ming-Hsua and more Study notes Computer Architecture and Organization in PDF only on Docsity!

Chapter 4

The Processor

Five Classic Components

Goal

See how the ISA determines aspects of

the implementation

How the choice of various implementation

strategies affect the clock cycle and CPI

Design principle

Make the common case fast

Simplicity favors regularity

Instruction Execution

For every instruction

1. PC  instruction memory, fetch instruction

2. Register numbers  register file, read registers

Depending on instruction class

Use ALU to calculate

Arithmetic result

Memory address for load/store

Branch target address

Access data memory for load/store

PC  target address or PC + 4

Multiplexers

 Can’t just join

wires together

 Use multiplexers

Control

Instruction Fetch

32-bit

register

Increment by

4 for next

instruction

R-Format Instructions

Read two register operands

Perform arithmetic/logical operation

Write register result

0 rs rt rd shamt funct

R-type

Branch Instructions

Read register operands

Compare operands

Use ALU, subtract and check Zero output

Calculate target address

Sign-extend displacement

Shift left 2 places (word displacement)

Add to PC + 4

Already calculated by instruction fetch

Use this value for computing the branch address

4 rs rt address

Branch

Branch Instructions

Just

re-routes

wires

Sign-bit wire

replicated

R-Type/Load/Store Datapath

Two MUXs are needed

Full Datapath

Add one

additional MUX

ALU Control

Assume 2-bit ALUOp derived from opcode

Combinational logic derives ALU control

opcode ALUOp Operation funct ALU function ALU control

lw 00 load word XXXXXX add 0010

sw 00 store word XXXXXX add 0010

beq 01 branch equal XXXXXX subtract 0110

R-type 10 add 100000 add 0010

subtract 100010 subtract 0110

AND 100100 AND 0000

OR 100101 OR 0001

set-on-less-than 101010 set-on-less-than 0111

ALUOp 00 or 01, the desired ALU action does not depend on funct

Truth Table of ALU

opcode ALUOp Operation funct ALU function ALU control lw 00 load word XXXXXX add 0010 sw 00 store word XXXXXX add 0010 beq 01 branch equal XXXXXX subtract 0110 R-type 10 add 100000 add 0010 subtract 100010 subtract 0110 AND 100100 AND 0000 OR 100101 OR 0001 set-on-less-than 101010 set-on-less-than 0111