Presentation is loading. Please wait.

Presentation is loading. Please wait.

Datapath and Control Exceptions

Similar presentations


Presentation on theme: "Datapath and Control Exceptions"— Presentation transcript:

1 Datapath and Control Exceptions
5.6

2 Goal Build an architecture to support the following instructions
Arithmetic: add, sub, addi,slt Memory references: lw, sw Branches: jump, beq

3 Process Design basic framework that is needed by all instructions
Build a computer for each individually Add MUXes to choose between different operations Add control signals to control the MUXes

4 MIPS trends Get an ____________ from memory using the ______________ (___) Read ____ or _____ registers each instruction _____ register: _____ registers:

5 MIPS trends All instructions use ______ after reading regs Some instructions also access _______ Write result to ________

6 Framework Use ALU Get instruction from memory Read from register file
Access memory Write register file

7 What *exactly* is memory?
Interface: reads: input output writes: Variation Multi-ported May read or write multiple items at the same time Must add inputs / outputs

8 Instruction Fetch Where are instructions stored? ________
How do we know where to fetch and instruction? ___________ What happens to the PC each instruction? ____________ By how much does the PC change? _____ What determines this amount? _________ Is the PC one of the 32 regs? Why or why not?

9 Get Instruction

10 “Add” instruction Where does the instruction tell what registers to read? Where does the instruction tell what register to write?

11 “Add” Instruction Operation rs rt rd shamt funct # meaning add 3 5 2
32 # $2 <- $3 + $5 Read Addr Out Data Instruction Memory PC 4 op/fun rs rt rd imm src src1data src src2data Register File destreg destdata Instruction

12

13 “Addi” Instruction Operation rs rt imm # meaning addi $5,$3,6 3 5 6
# $5 <- $3 + 6 Read Addr Out Data Instruction Memory PC 4 op/fun rs rt rd imm src src1data src src2data Register File destreg destdata Instruction

14

15 Sign Extension How do we go from 16-bit number to 32-bit number?
How about 4-bit to 8-bit. 0111 = 7 = ________ 1110 = -2 = ________ So, how do we do it?

16 Reading/Write Registers
When does register get written? What would happen if we allowed write to occur at any time?

17 Putting them together Instruction Memory op/fun rs rt rd imm
Read Addr Out Data Instruction Memory PC 4 op/fun rs rt rd imm src src1data src src2data Register File destreg destdata Instruction

18

19 Putting them together Control Unit 4 Register File PC op/fun rs rt rd
ALUOp ALUSrc 4 RegDest src src1data src src2data Register File destreg destdata PC op/fun rs rt rd imm Read Addr Out Data Instruction Memory Inst M U X M U X 16 Sign Ext 32

20 Machine Speed What determines the clock rate of a machine? _____________________ Making something bigger makes it:

21 Load Word (lw) Operation rs rt imm # meaning lw $5,8($3) 3 5 8
Read Addr Out Data Instruction Memory PC 4 op/fun rs rt rd imm src src1data src src2data Register File destreg destdata Instruction

22 Addr Out Data Data Memory In Data

23 Store Word (sw) Operation rs rt imm # meaning sw $5,8($3) 3 5 8
Read Addr Out Data Instruction Memory PC 4 op/fun rs rt rd imm src src1data src src2data Register File destreg destdata Instruction 16 Sign Ext 32

24 Address calculation identical to load word
Out Data Data Memory In Data

25 Putting them together Instruction Memory op/fun rs rt rd imm
Read Addr Out Data Instruction Memory PC 4 op/fun rs rt rd imm src src1data src src2data Register File destreg destdata Instruction 16 Sign Ext 32

26 Addr Out Data Data Memory In Data

27 Putting them together Data Memory Control Unit 4 Register File PC
MemWr MemRd ALUOp 4 RegWrite Addr Out Data Data Memory In Data src src1data src src2data Register File destreg destdata PC op/fun rs rt rd imm Read Addr Out Data Instruction Memory Inst 16 Sign Ext 32

28 Ld/St Questions Are the data and instruction memory the same thing? How do they differ?

29 Ld/St Questions What is the advantage to split memory?
What is the advantage to unified memory?

30 Beq What ALU operation are we going to perform?
We add a ______ bit as an output to the ALU. To perform a jump, we need to change the ________

31 beq Operation rs rt imm # meaning Beq $3,$5,lp 3 5 6
# if ($3 == $5) goto lp Read Addr Out Data Instruction Memory PC 4 op/fun rs rt rd imm src src1data src src2data Register File destreg destdata Instruction

32

33 Beq The immediate field is the number of _____________ to advance.
The address is expressed in ___________. Each instruction is _____ bytes We need to multiply the # instructions by ______ or shift left by _____

34 Jump Instruction The absolute address is stored in the target – do not add to current address Absolute address is only ______ bits PC is ______ 32 We get the top bits by Sign extending target? Concatenating target?

35 j (jump) Operation Target address # meaning J loop 0x0174837
# goto loop Read Addr Out Data Instruction Memory PC 4 op/fun rs rt rd imm src src1data src src2data Register File destreg destdata Instruction

36 The Whole Shebang Data Memory << 2 << 2 4 Register File PC
Addr Out Data Data Memory In Data src src1data src src2data Register File destreg destdata PC op/fun rs rt rd imm Read Addr Out Data Instruction Memory Inst 16 Sign Ext 32

37 Exceptions 5.6

38 Unexpected Events Internal External

39 Definitions Anything unexpected happens PowerPC External event occurs
Internal event occurs Change in control flow Exception Interrupt PowerPC Intel MIPS

40 Exception-Handling Stop Transfer control to OS Tell OS what happened
Begin executing where we left off

41 1. Detect Exception Add control lines to detect errors

42 Step 2: Store PC into EPC Data Memory << 2 << 2 4
Addr Out Data Data Memory In Data src src1data src src2data Register File destreg destdata PC op/fun rs rt rd imm Read Addr Out Data Instruction Memory Inst 16 Sign Ext 32

43 Step 3: Tell OS the problem
Store error code in the _________ Use vectored interrupts Use error code to determine _________

44 Cause Register Set a flag in the cause register
How does the OS find out if an overflow occurred if the bit corresponding to an overflow is bit 5?

45 Vectored Interrupts The address of trap handler is determined by cause
Exception type Exception vector address (in hex) Undefined Instruction C hex Arithmetic Overflow C hex

46 Cause Register – Go to OS
Handler PC << 2 -4 Cause << 2 4 EPC Addr Out Data Data Memory In Data src src1data src src2data Register File destreg destdata PC op/fun rs rt rd imm Read Addr Out Data Instruction Memory Inst 16 Sign Ext 32

47 Vectored Interrupt – Go to OS
Cause Vector Table << 2 << 2 -4 4 EPC Addr Out Data Data Memory In Data src src1data src src2data Register File destreg destdata PC op/fun rs rt rd imm Read Addr Out Data Instruction Memory Inst 16 Sign Ext 32


Download ppt "Datapath and Control Exceptions"

Similar presentations


Ads by Google