+ All Categories
Home > Documents > L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls...

L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls...

Date post: 14-Mar-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
19
Work on this while you wait! 1001 (9) x 0011 (3)
Transcript
Page 1: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

Work on this while you wait!

1001 (9)

x 0011 (3)

Page 2: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

More Finite State Machines: Multiplication as an Example

Lab 3 part 2!

Page 3: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

Learning Objectives Design a Finite State Machine that controls a datapathUse Register Transfer Language to describe how state is modified each clock cycle

Page 4: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

Step 1: Understand your problem

Page 5: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

You try another example

1001 (9)

x 0011 (3)

1001

1001

0000

+0000 .

00011011 (27)

Page 6: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

int shift_add_multiply(unsigned short X, unsigned short Y) {unsigned int A = (unsigned int) X;unsigned short B = Y;unsigned int P = 0;

while (B != 0) {if ((B & 1) == 1) {

P = P + A;}B = B >> 1;A = A << 1;

}return P;

}

Page 7: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

Step 2: Understand the datapath

Page 8: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

Identify needed state components from variables (what state is stored?)

int shift_add_multiply(…) {unsigned int A = (unsigned int) X;unsigned short B = Y;unsigned int P = 0;

return P;}

Page 9: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

A (2N‐bit reg) END

QB (N‐bit reg)

EN

D

Q

P (2N‐bit reg) END

Q

Identify how we modify that state

while (B != 0) {if ((B & 1) == 1) {P = P + A;

}B = B >> 1;A = A << 1;

}

Page 10: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

X Y

ALUOP

A B

A (2N‐bit reg) END

QB (N‐bit reg)

EN

D

Q

P (2N‐bit reg) END

Q

0   1 1   0<<1

>>1

Define specification for control FSMwhile (B != 0) {if ((B & 1) == 1) {P = P + A;

}B = B >> 1;A = A << 1;

}

Page 11: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

int shift_add_multiply(…) {unsigned int A = (unsigned int) X;unsigned short B = Y;unsigned int P = 0;

while (B != 0) {if ((B & 1) == 1) {P = P + A;

}B = B >> 1;A = A << 1;

}return P;

}

Page 12: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

Control FSM has 3 inputs and 7 outputs

B is zero (Z) B_Q[0] is 1 (B[0]) START

Load A (LA) Shift A (SA) Load B (LB) Shift B (SB) Add when 1/Zero when 0 (OP) Load P (LP) DONE

Page 13: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

Control FSM

X Y

ALUOP

A B

=0?

A (2N‐bit reg) END

QB (N‐bit reg)

EN

D

Q

P (2N‐bit reg) END

Q

START

DONE

B_Q[0]

0   1 1   0<<1 >>1

Controland Datapath

Page 14: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

Step 3: Design your FSM (don’t forget timing!)

Page 15: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

int shift_add_multiply(…) {unsigned int A = (unsigned int) X;unsigned short B = Y;unsigned int P = 0;

while (B != 0) {if ((B & 1) == 1) {P = P + A;

}B = B >> 1;A = A << 1;

}return P;

}

Page 16: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

Register transfers show source state elements, operations, and destination state elements

A = X

B = Y

P = 0

A = A << 1

B = B >> 1

P = P + A

Control FSM

X Y

ALUOP

A B

=0?

A (2N‐bit reg) END

QB (N‐bit reg)

EN

D

Q

P (2N‐bit reg) END

Q

START

DONE

B_Q[0]

0   1 1   0<<1 >>1

Page 17: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

Start, Zero, B[0] WaitA = X, B = Y, 

P = 0

DoNothing

ShiftA = A << 1, B = B >> 1 

Shift‐AddA = A << 1, B = B >> 1,P = P+A

DoneDONE = 1

A B

C D

E

clk 10

X 10

Y 10

START10

A 10

B 10

P 10

STATE10

? 9 ?

? 5 ?

?

?

?

WAIT

A =

B =

Page 18: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

Translate register transfers into control signals

Control FSM

X Y

ALUOP

A B

=0?

A (2N‐bit reg) END

QB (N‐bit reg)

EN

D

Q

P (2N‐bit reg) END

Q

START

DONE

B_Q[0]

0   1 1   0<<1 >>1

WaitA = X, B = Y, 

P = 0

Wait

ShiftA = A << 1, B = B >> 1 

Shift

DoNothing

DoNothing

LA LB

OP

LP

SA SB

Page 19: L08-FSM-Shift Add Multiplier-AL2 · Learning Objectives Design a Finite State Machine that controls a datapath Use Register Transfer Language to describe how state is modified

WaitA = X, B = Y, 

P = 0

DoNothing

ShiftA = A << 1, B = B >> 1 

Shift‐AddA = A << 1, B = B >> 1,P = P+A

DoneDONE = 1

clk 10

X 10

Y 10

START10

A 10

B 10

P 10

STATE10

LA 10

SA 10

LB 10

SB 10

LP 10

OP 10

? 9 ?

? 5 ?

?

?

?

WAIT

1

0

1

0

1

0

9

5

18

2

36

1

72

0

0 9 45

D SA D S D SA D DONE

B[0]Z’

B[0]’Z’

B[0]Z’

B[0]’Z


Recommended