phase 1 – lecture – 2/25/2013

63
Phase 1 – Lecture – 2/25/2013

Upload: varick

Post on 18-Feb-2016

30 views

Category:

Documents


0 download

DESCRIPTION

Phase 1 – Lecture – 2/25/2013. Background. Background. Design Process. Identify a problem and define solution requirements Break problem into smaller pieces Research all possible solutions Design all pieces to solution Prove functionality of each piece separately - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Phase 1 – Lecture – 2/25/2013

Phase 1 – Lecture – 2/25/2013

Page 2: Phase 1 – Lecture – 2/25/2013

Background

1

Page 3: Phase 1 – Lecture – 2/25/2013

Background

2

Page 4: Phase 1 – Lecture – 2/25/2013

Design Process

3

1. Identify a problem and define solution requirements2. Break problem into smaller pieces3. Research all possible solutions4. Design all pieces to solution5. Prove functionality of each piece separately6. Integrate all pieces into working unit

Page 5: Phase 1 – Lecture – 2/25/2013

Process

4

Page 6: Phase 1 – Lecture – 2/25/2013

Research

Determine components used for each individual stage of our Pipelined CPU

Transition components to be used with other team’s stages of our Pipelined CPUWhat are Reg Files?What is Pipelining?

5

Page 7: Phase 1 – Lecture – 2/25/2013

Pipelining

6Computer Organization and Design, 4th Ed, D. A. Patterson and J. L. Hennessey

Page 8: Phase 1 – Lecture – 2/25/2013

Pipelining Our CPU

Stage Instruction For

IF Instruction fetch from memory

all

ID Instruction decode & register read

Decode for all

EX Execute operation or calculate address

All but j

MEM Access memory operand

lw, sw

WB Write result back to register

lw, R-type

7

Page 9: Phase 1 – Lecture – 2/25/2013

Our CPU

8

Page 10: Phase 1 – Lecture – 2/25/2013

Front EndThe United States Postal Service

9

Page 11: Phase 1 – Lecture – 2/25/2013

Research - Roles Park Lamerton – Lead Engineer Nik Marinov – Intra Team Relations Taylor Foster – Team Worker Kelle McCan – Wiki Specialist Melissa Allee - Historian

10

Page 12: Phase 1 – Lecture – 2/25/2013

Research - Timeline

11

Page 13: Phase 1 – Lecture – 2/25/2013

Front End

Collect the mail. Fetch instruction from memory.

Sort the mail. Decode instruction. Distribute data to desired locations.

Process replies. Write back to destination register.

Front end mimics a mailing service

12

Page 14: Phase 1 – Lecture – 2/25/2013

Instruction Fetch

PC tells MEMORY what instruction to fetch.

PC controlled by two multiplexers.

One instruction fetched at a time.

Collecting the Mail

13

Page 15: Phase 1 – Lecture – 2/25/2013

Instruction Encoding

OPCODE RS RT RD SHAMT FUNCT

OPCODE RS RT IMMEDIATE (offset, int, bit sequence)

32 26 21 16 0

OPCODE JUMP ADDRESS

32 26 0

32 26 21 16 11 6 0

R-TYPE

I-TYPE

J-TYPE

Types of instructions on the MIPS processor

14

Page 16: Phase 1 – Lecture – 2/25/2013

Instruction DecodeSort the mail

Distribute data to proper locations.

Sign or Zero extend immediate value.

Forward register data to execution.

Write back computed results into desired register.

15

Page 17: Phase 1 – Lecture – 2/25/2013

Register File Read Data Registers contain

previously written or default values.

Mux forwards data based on the 5-bit register address.

All logic operations are performed on the rising edge of clock.

Sort the mail

16

Page 18: Phase 1 – Lecture – 2/25/2013

Register File Write Back Decode write back

address. Wait for control bit. Write data to

destination register. All logic operations are

performed on the falling edge of clock.

Process replies

17

Page 19: Phase 1 – Lecture – 2/25/2013

ExecutionThe Executives

18

Page 20: Phase 1 – Lecture – 2/25/2013

The Team Michael Bowman – Lead Engineer Laly Vang – Wiki Specialist Matt Goranson – Intra Team Relations Darryle Parker – Intra Team Relations Matthew Horton – Report Compiler Austin O’Neil – Historian

19

Page 21: Phase 1 – Lecture – 2/25/2013

Phase 1 Schedule

20

Page 22: Phase 1 – Lecture – 2/25/2013

Exposition

Responsible for instruction execution and address calculation

Topics: ALU Branch/Jump

21

Page 23: Phase 1 – Lecture – 2/25/2013

22

Page 24: Phase 1 – Lecture – 2/25/2013

Branch Logic

Why?

What?

Where?

23

Page 25: Phase 1 – Lecture – 2/25/2013

Branch Logic

BEQ

BNE

Opcode Rs Rt Address/Immediate6 bits 5 bits 5 bits 16 bits

0001 00 xxxxx xxxxx xxxx xxxx xxxx

Opcode Rs Rt Address/Immediate6 bits 5 bits 5 bits 16 bits

0001 01 xxxxx xxxxx xxxx xxxx xxxx

24

Page 26: Phase 1 – Lecture – 2/25/2013

Branch Logic

Depends on 3 signals Zero BNE Control BEQ Control

PC + 4 is the default case (No branching/jumping)

25

Page 27: Phase 1 – Lecture – 2/25/2013

Jump Register

It can take you places…

Opcode Rs Rt Rd Shamt Function

6 bits 5 bits 5 bits 5 bits 5 bits 6 bits

0000 0 xxxxx 00000 00000 00000 001000

R-type

.org 0x1000000

here:lui $t0 0xdeadori $t0 $t0 0xbeefjr $t0nop

26

Page 28: Phase 1 – Lecture – 2/25/2013

Jump… and Link Register

Hey! Listen!Go places… and remember where we were (sort of).

Opcode Rs Rt Rd Shamt Function

6 bits 5 bits 5 bits 5 bits 5 bits 6 bits

0000 0 xxxxx 00000 xxxxx 00000 001001

R-type

.org 0x1000000

here:li $t0 joyjalr $ra $t0nop

done:j done

joy:jr $ra

27

Page 29: Phase 1 – Lecture – 2/25/2013

Jump and Link Register

Logic Required Jump control signal – allows a jump Jump register control – allows a jump from register New address (register value) – where we’re going Link control signal – pass a linked address to a register

Resultants New PC address – where we’re going PC control signal – allows update of PC Next instruction address (PC+4) for write back – the linked

address

28

Page 30: Phase 1 – Lecture – 2/25/2013

Jump

Very much like Jump Register, only we’re jumping to an immediate

But we’re limited. Instructions are 32 bits with the most significant six bits being the operation code. We’ve only got 26 bits to work with, but we can use up to 28. First two bits 0 next 26 bits from the jump address field and upper

four bits from the old PC value

Jump logic Jump Immediate – allows an immediate jump to a new location Value from register – the new address Jump Control – to allow a jump

29

Page 31: Phase 1 – Lecture – 2/25/2013

Jump and Link

Similar to JALR but uses the same address scheme used in Jump

Saves address for future use

Jump logic Jump Immediate – allows an immediate jump to a new location Jump Register Control Signal – allows register value to be taken Value from register – the new address Link Control Signal – to pass a linked address to a register

30

Page 32: Phase 1 – Lecture – 2/25/2013

ALU Main math unit

31

Page 33: Phase 1 – Lecture – 2/25/2013

Exposition: ALU

“Arithmetic and Logic Unit” Performs arithmetic and logical operations. Does any calculations necessary to execute an instruction

32

Page 34: Phase 1 – Lecture – 2/25/2013

Encoding

Operation Encoding SubADD 0000 0

SUB 0000 1

SLT 0001 1

SLTU 0010 1

AND 0011 0

NOR 0100 0

OR 0101 0

SRL 0110 0

SLL 0111 0

LUI 1000 0

MULLO 1001 0

MULHI 1010 0

5-bits: 4-bit encoding with extra Sub bit12 Operations

33

Page 35: Phase 1 – Lecture – 2/25/2013

Adder/SubtractorOperation Encoding Sub

ADD 0000 0

SUB 0000 1

ADDResult = Op1 + Op2

SUBResult = Op1 - Op2 = Op1 + (!Op2 + 1) = (Op1 +!Op2) + 1

34

Page 36: Phase 1 – Lecture – 2/25/2013

SLTEasy

SLTUSimilar, but a caveat

SLT/SLTU

Operation Encoding

Sub

SLT 0001 1

SLTU 0010 1

35

Page 37: Phase 1 – Lecture – 2/25/2013

Simple LogicOperation Encoding Sub

AND 0011 0

NOR 0100 0

OR 0101 0

36

Page 38: Phase 1 – Lecture – 2/25/2013

Logical ShiftsOperation Encoding Sub

SRL 0110 0

SLL 0111 0

SLL SRL

37

Page 39: Phase 1 – Lecture – 2/25/2013

LUIOperation Encoding Sub

LUI 1000 0

38

Page 40: Phase 1 – Lecture – 2/25/2013

MULLO/MULHI

Operation Encoding Sub

MULLO 1001 0

MULHI 1010 0

39

Page 41: Phase 1 – Lecture – 2/25/2013

ControlsControlling your life, everyday.

40

Page 42: Phase 1 – Lecture – 2/25/2013

The Team Kory Teague – Lead Engineer Kyle Lawler – Wiki Specialist Andres Vega – Intra Team Relations Bryan Rogers – Team Worker Michael Oltmanns - Historian

41

Page 43: Phase 1 – Lecture – 2/25/2013

Responsibilities Manage the Control Path

All non-hazard control logic Memory Stage Writeback Stage

42

Page 44: Phase 1 – Lecture – 2/25/2013

Processor Design

43

Page 45: Phase 1 – Lecture – 2/25/2013

Control Signals

44

Page 46: Phase 1 – Lecture – 2/25/2013

Declared Signals

45

Page 47: Phase 1 – Lecture – 2/25/2013

Signal Definitions

46

Page 48: Phase 1 – Lecture – 2/25/2013

X ≡ 0 on all signals except SE, where X ≡ 1Research47

Page 49: Phase 1 – Lecture – 2/25/2013

Control Unit Design

48

Page 50: Phase 1 – Lecture – 2/25/2013

ALUControl Unit Design

49

Page 51: Phase 1 – Lecture – 2/25/2013

MEM and WB Provided Allow for data flow MemRead, MemWrite LW, data first appears in

MEM Requires stall Hazards

Writes to Reg File MemToReg, RegWrite

50

Page 52: Phase 1 – Lecture – 2/25/2013

HAZARDSThe Hazarding

51

Page 53: Phase 1 – Lecture – 2/25/2013

Team Introduction Spencer Hood – Lead Engineer Jessie Monterroso – Wiki Specialist Zach Smith Max Jeter – Report Compilations Evan Novotny

52

Page 54: Phase 1 – Lecture – 2/25/2013

IntroductionOne down side of the pipeline is hazardsIf hazards aren’t properly handled then the processor will behave in unexpected ways and can lower throughput

There are three types of hazards that will be covered in this presentation

53

Page 55: Phase 1 – Lecture – 2/25/2013

Types of HazardsData HazardsControl HazardsStructural Hazards

54

Page 56: Phase 1 – Lecture – 2/25/2013

Data HazardsRAR (Read after Read)RAW (Read after Write)WAR (Write after Read)WAW (Write after Write)RAW is the only one of the above hazards that effects the MIPS pipeline

Load use

55

Page 57: Phase 1 – Lecture – 2/25/2013

Example of RAW HazardADD $t0, $t1, $t2SUB $t3, $t0, $t4

Register $t0 is used in the instruction immediately after it is written to

56

Page 58: Phase 1 – Lecture – 2/25/2013

Solution for RAW HazardForwarding

http://cs-alb-pc3.massey.ac.nz/notes/59304/Image168.gif

57

Page 59: Phase 1 – Lecture – 2/25/2013

Example of Load use Hazard

lw $t0, 4($t1)addiu $t2, $t0, 0x0badbeefMemory is the fourth stage of the pipeline

58

Page 60: Phase 1 – Lecture – 2/25/2013

Solution for Load use Hazard Stall the pipeline

http://upload.wikimedia.org/wikipedia/commons/thumb/d/d0/Data_Forwarding_%28Two_Stage%29.svg/370px-Data_Forwarding_%28Two_Stage%29.svg.png

59

Page 61: Phase 1 – Lecture – 2/25/2013

Control HazardsConditional Branching

Branch predictionAssume branch is always takenWhen its not taken flush the pipeline

60

Page 62: Phase 1 – Lecture – 2/25/2013

61

Page 63: Phase 1 – Lecture – 2/25/2013

Questions?