Lecture 6 Review Question #1 Calculate 999000999d * 3d 2997002997 - - PowerPoint PPT Presentation

lecture 6 review question 1
SMART_READER_LITE
LIVE PREVIEW

Lecture 6 Review Question #1 Calculate 999000999d * 3d 2997002997 - - PowerPoint PPT Presentation

Lecture 6 Review Question #1 Calculate 999000999d * 3d 2997002997 Booth's Algorithm Use Booth's Algorithm to find 14d * -5d, in binary 01110 A = 01110 We need x 11011 B = 11011 5 + 5 = -B = 00101 10 bits A: 00000


slide-1
SLIDE 1

Lecture 6 Review

slide-2
SLIDE 2

Question #1

§ Calculate 999000999d * 3d § à 2997002997

slide-3
SLIDE 3

§ Use Booth's Algorithm to find 14d * -5d, in

binary

§ We need

5 + 5 = 10 bits

§ à -70

Booth's Algorithm

01110 A = 01110 x 11011 B = 11011

  • B = 00101

A: 0000001110 (extend to 10 bits)

  • 1110110000

add +B (sign extend) +0000001010 add –B (sign extend)

  • 1110111010
slide-4
SLIDE 4

Lecture 7 Review

slide-5
SLIDE 5

Question #1

What is the Datapath of an r-type instruction

Address (PC) Instruction Memory Instruction +4 Register File Sign ext. Mux Mux Data Memory Mux ALU Mux

slide-6
SLIDE 6

Question #1

What is the Datapath of an r-type instruction

Address (PC) Instruction Memory +4 Sign ext. Data Memory ALU Mux Instruction Register File Mux Mux Mux ALU

slide-7
SLIDE 7

Question #2: Incrementing PC

§ Given the datapath above, what signals would

the control unit turn on and off to increment the program counter by 4?

Read reg 1 Read reg 2 Write reg Write data Read data 1 Read data 2 Registers ALU result Zero

A B

ALU 1 1 2 3 4 A B

Instruction [31-26] Instruction Register Instruction [25-21] Instruction [20-16] Instruction [15-0]

1 1

Memory data register Memory data

Memory

Address Write data

ALU Out 1 2 Shift left 2 1 PC PCWriteCond PCWrite IorD MemRead MemWrite MemtoReg IRWrite PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst Opcode

Control Unit

Shift left 2 Sign extend

slide-8
SLIDE 8

Controlling the signals

§ Need to understand the

role of each signal, and what value they need to have in order to perform the given operation.

§ So, what’s the best approach

to make this happen?

Control Unit

PCWriteCond PCWrite IorD MemRead MemWrite MemtoReg IRWrite PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst

Opcode

slide-9
SLIDE 9

Basic approach to datapath

  • 1. Figure out the data source(s) and destination.
  • 2. Determine the path of the data.
  • 3. Deduce the signal values that cause this path:

a)

Start with Read & Write signals (at most one can be high at a time).

b)

Then, mux signals along the data path.

c)

Non-essential signals get an X value.

slide-10
SLIDE 10

Question #2: Incrementing PC

§ Step #1: Determine data source and destination.

ú Program counter provides source, ú Program counter is also destination.

Read reg 1 Read reg 2 Write reg Write data Read data 1 Read data 2 Registers ALU result Zero

A B

ALU 1 1 2 3 4 A B

Instruction [31-26] Instruction Register Instruction [25-21] Instruction [20-16] Instruction [15-0]

1 1

Memory data register Memory data

Memory

Address Write data

ALU Out 1 2 Shift left 2 1 PC PCWriteCond PCWrite IorD MemRead MemWrite MemtoReg IRWrite PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst Opcode

Control Unit

Shift left 2 Sign extend

slide-11
SLIDE 11

Question #2: Incrementing PC

§ Step #2: Determine path for data

ú Operand A for ALU: Program counter ú Operand B for ALU: Literal value 4 ú Destination path: Through mux, back to PC

Read reg 1 Read reg 2 Write reg Write data Read data 1 Read data 2 Registers ALU result Zero

A B

ALU 1 1 2 3 4 A B

Instruction [31-26] Instruction Register Instruction [25-21] Instruction [20-16] Instruction [15-0]

1 1

Memory data register Memory data

Memory

Address Write data

ALU Out 1 2 Shift left 2 1 PC PCWriteCond PCWrite IorD MemRead MemWrite MemtoReg IRWrite PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst Opcode

Control Unit

Shift left 2 Sign extend

slide-12
SLIDE 12

Question #3: Incrementing PC

§ Setting signals for this datapath:

1.

Read & Write signals:

PCWrite is high, all others are low.

Read reg 1 Read reg 2 Write reg Write data Read data 1 Read data 2 Registers ALU result Zero

A B

ALU 1 1 2 3 4 A B

Instruction [31-26] Instruction Register Instruction [25-21] Instruction [20-16] Instruction [15-0]

1 1

Memory data register Memory data

Memory

Address Write data

ALU Out 1 2 Shift left 2 1 PC PCWriteCond PCWrite IorD MemRead MemWrite MemtoReg IRWrite PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst Opcode

Control Unit

Shift left 2 Sign extend

slide-13
SLIDE 13

Question #3: Incrementing PC

§ Setting signals for this datapath:

2.

Mux signals:

PCSource is 0, AlUSrcA is 0, ALUSrcB is 1 all others are “don’t cares”.

Read reg 1 Read reg 2 Write reg Write data Read data 1 Read data 2 Registers ALU result Zero

A B

ALU 1 1 2 3 4 A B

Instruction [31-26] Instruction Register Instruction [25-21] Instruction [20-16] Instruction [15-0]

1 1

Memory data register Memory data

Memory

Address Write data

ALU Out 1 2 Shift left 2 1 PC PCWriteCond PCWrite IorD MemRead MemWrite MemtoReg IRWrite PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst Opcode

Control Unit

Shift left 2 Sign extend

slide-14
SLIDE 14

Question #2: Incrementing PC

§ Other signals for this datapath:

ú ALUOp is 'ADD' (from chart on Slide 15 of Processor notes) ú PCWriteCond is X when PCWrite is 1 Otherwise it is 0 except when branching.

Read reg 1 Read reg 2 Write reg Write data Read data 1 Read data 2 Registers ALU result Zero

A B

ALU 1 1 2 3 4 A B

Instruction [31-26] Instruction Register Instruction [25-21] Instruction [20-16] Instruction [15-0]

1 1

Memory data register Memory data

Memory

Address Write data

ALU Out 1 2 Shift left 2 1 PC PCWriteCond PCWrite IorD MemRead MemWrite MemtoReg IRWrite PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst Opcode

Control Unit

Shift left 2 Sign extend

slide-15
SLIDE 15

Question #2 (final signals)

§ PCWrite = 1 § PCWriteCond = X § IorD = X § MemRead = 0 § MemWrite = 0 § MemToReg = X § IRWrite = 0 § PCSource = 0 § ALUOp = 'ADD' (001) § ALUSrcA = 0 § ALUSrcB = 01 § RegWrite = 0 § RegDst = X

slide-16
SLIDE 16

Question #3

0000 0000 0110 0101 0100 0000 0010 0111

  • What is the type of this instruction?
  • What does it do?
  • Which register stores the result?
slide-17
SLIDE 17

MIPS instruction types

§ R-type: § I-type: § J-type:

  • pcode

rs rt 6 5 rd 5 shamt 5 funct 5 6

  • pcode

rs rt 6 5 immediate 5 16

  • pcode

address 6 26

slide-18
SLIDE 18

Instruction Op/Func

add 100000 addu 100001 addi 001000 addiu 001001 div 011010 divu 011011 mult 011000 multu 011001 sub 100010 subu 100011 and 100100 andi 001100 nor 100111

  • r

100101

  • ri

001101 xor 100110 xori 001110 sll 000000 sllv 000100 sra 000011

Instruction Op/Func

srav 000111 srl 000010 srlv 000110 beq 000100 bgtz 000111 blez 000110 bne 000101 j 000010 jal 000011 jalr 001001 jr 001000 lb 100000 lbu 100100 lh 100001 lhu 100101 lw 100011 sb 101000 sh 101001 sw 101011 mflo 010010

0000 0000 0110 0101 0100 0000 0010 0111

slide-19
SLIDE 19

Question #4

Give the binary representation of the op-code to add 0x4027 (‭in decimal: 16423‬d) to the value

  • f r3, and put the result in r5
slide-20
SLIDE 20

Instruction Op/Func

add 100000 addu 100001 addi 001000 addiu 001001 div 011010 divu 011011 mult 011000 multu 011001 sub 100010 subu 100011 and 100100 andi 001100 nor 100111

  • r

100101

  • ri

001101 xor 100110 xori 001110 sll 000000 sllv 000100 sra 000011

Instruction Op/Func

srav 000111 srl 000010 srlv 000110 beq 000100 bgtz 000111 blez 000110 bne 000101 j 000010 jal 000011 jalr 001001 jr 001000 lb 100000 lbu 100100 lh 100001 lhu 100101 lw 100011 sb 101000 sh 101001 sw 101011 mflo 010010

r5 ß r3 + 17 addi $5, $3, 16423 00100000 01100101 01000000 00100111

slide-21
SLIDE 21

MIPS instruction types

§ R-type: § I-type: § J-type:

  • pcode

rs rt 6 5 rd 5 shamt 5 funct 5 6

  • pcode

rs rt 6 5 immediate 5 16

  • pcode

address 6 26

slide-22
SLIDE 22

addi $5, $3, 16423 00100000 01100101 01000000 00100111 00000000 01100101 01000000 00100111

Pay Attention!

§ Very similar encodings produce difference

results

nor $8, $3, $5