+ All Categories
Home > Documents > 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is...

4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is...

Date post: 13-Mar-2020
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
19
4. Program Counter Design Olle Seger Andreas Ehliar Jian Wang
Transcript
Page 1: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

4. Program Counter Design

Olle SegerAndreas Ehliar

Jian Wang

Page 2: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

A pipelinedCPU

* similar (but not identical) to Senior

0: add1: jmp.eq ds0 52: xxx3: yyy4: zzz5: and6: www

IR3

JT

JT = jump takenjmpdec = jump decoded

Page 3: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

PC FSM

•The PC FSM must be a Mealy machine• in : decoded IR => Is it a jump instruction? What kind?• in : jump taken = JT• out : next PC• out: should the IR be nopped?

• The following instructions should be implemented• jump ds0/ds1 addr• jump.eq ds0/ds1 addr

λ

δ D

inout

state

next state

Page 4: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

0: add1: jmp.eq ds0 52: xxx3: yyy4: zzz5: and6: www

PC IR IR1 IR2 IR3 ...01 add2 jmp add2 nop jmp add2 nop nop jmp add5 nop nop nop jmp6 and nop nop nop

PC IR IR1 IR2 IR3 ...01 add2 jmp add2 nop jmp add2 nop nop jmp add3 xxx nop nop jmp4 yyy xxx nop nop

Page 5: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

A pipelinedCPU

* similar (but not identical) to Senior

0: add1: jmp.eq ds1 52: xxx3: yyy4: zzz5: and6: www

IR3

JT

JT = jump taken

Page 6: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

0: add1: jmp.eq ds1 52: xxx3: yyy4: zzz5: and6: www

PC IR IR1 IR2 IR3 ...01 add2 jmp add3 xxx jmp add3 nop xxx jmp add5 nop nop xxx jmp6 and nop nop xxx

PC IR IR1 IR2 IR3 ...01 add2 jmp add3 xxx jmp add3 nop xxx jmp add4 yyy nop xxx jmp5 zzz yyy nop xxx

Page 7: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

State graph

0

1 2

ds0(nop,stall PC)

-(nop,stall PC)JT(nop,PC=Target)JT(PC++)

3

-(PC++)

4

jmp(PC

++)

ds1(PC++)

-(nop,stall PC)

jmp inIR1 jmp in

IR2jmp inIR3

Page 8: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

State graph (simplified)

0

1 2ds0(nop,stall PC) -(nop,stall PC)

JT(nop,PC=Target)JT(PC++)

jmp(PC++)

ds1(PC++)

Page 9: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

1.

Page 10: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

1.

Page 11: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

0: jmp 51: xxx2: yyy3:4:5: zzz

jmp 5

1

5

1a

xxx will be executed1 delay slot

Page 12: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

add r3,r0,r1

nop

add r3,r2,r3

add r3,r0,r1nopadd r3,r2,r3

1b

If RF is SRAM1 nop

Page 13: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

nop

jmp.lt

nop

5

1c

0:set r2,101:nop2:jump.lt r0,r2,203:nop ; Delay slot 14:nop ; Delay slot 25:nop ; Delay slot 3…20:

Page 14: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

1c

Page 15: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

1c

Page 16: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

0

1 2

jmp(PC++)

3

jmpdec = PFC_OP[4]JT = PFC_OP2[4]*(PC_FSM_EQUAL*(PFC_OP2[1:0]==0) + …)

jmp(PC++)

-(PC++)

JT(PC=PFC_DATA_2)

JT(PC++)

-(PC++)

0JT(PC++)

JT(PC=PFC_DATA_2)

Page 17: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

+1

1 0

PC

21

0

&PFC_OP[4]

PFC_OP[1:0]

jump decision

1d

ProgramCounterModule

Page 18: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

2

Page 19: 4. Program Counter Design · PC FSM •The PC FSM must be a Mealy machine • in : decoded IR => Is it a jump instruction? What kind? • in : jump taken = JT • out : next PC

2


Recommended