Docsity

Embedded Processors - Embedded System Design - Lecture Slides, Slides of Computer Science

Partial preview of the text

Download Embedded Processors - Embedded System Design - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

2-Hardware Design Basics of

Embedded Processors

(cont.)

Outline

• Introduction

• Combinational logic

• Sequential logic

• Custom single-purpose processor design

• RT-level custom single-purpose processor

design

Example: greatest common divisor

• First create algorithm

• Convert algorithm to “complex”

state machine

  • Known as FSMD: finite-state

machine with datapath

  • Can use templates to perform such

conversion

GCD

(a) black-box

view

x_i y_i

d_o

go_i

0: int x, y;

1: while (1) {

2: while (!go_i);

3: x = x_i;

4: y = y_i;

5: while (x != y) {

6: if (x < y)

7: y = y - x;

else

8: x = x - y;

9: d_o = x;

(b) desired functionality

7: y = y -x 8: x = x - y

6-J:

x!=y

5: !(x!=y)

x<y !(x<y)

5-J:

3: x = x_i

4: y = y_i

2-J:

!go_i

!(!go_i)

d_o = x

1-J:

(c) state

diagram

State diagram templates

Assignment statement

a = b

next statement

a = b

next

statement

Loop statement

while (cond) {

loop-body-

statements }

next statement

loop-body-

statements

cond

next

statement

!cond

J:

C:

Branch statement

if (c1)

c1 stmts

else if c c2 stmts

else

other stmts

next statement

c

c2 stmts

!c1c2 !c1!c

next

statement

c1 stmts others

J:

C:

Creating the controller’s FSM

• Same structure as FSMD

• Replace complex actions/conditions

with datapath configurations

7: y = y -x 8: x = x - y

6-J:

x!=y

5: !(x!=y)

x<y !(x<y)

5-J:

3: x = x_i

4: y = y_i

2-J:

!go_i

!(!go_i)

d_o = x

1-J:

y_sel = 1 y_ld = 1

7: x_sel = 1 x_ld = 1

6-J:

x_neq_y

!x_neq_y

x_lt_y !x_lt_y

5-J:

d_ld = 1

1-J:

x_sel = 0 3: x_ld = 1

y_sel = 0 4: y_ld = 1

2-J:

!go_i

!(!go_i)

go_i

Controller

subtractor subtractor 5: x!=y 6: x<y 8: x-y 7: y-x

x_i y_i

d_o

0: x 0: y

9: d

n-bit 2x1 n-bit 2x

x_sel

y_sel x_ld

y_ld

x_neq_y

x_lt_y d_ld

5: x!=y

Datapath

Splitting into a controller and datapath

y_sel = 1 y_ld = 1

7: x_sel = 1 x_ld = 1

6-J:

x_neq_y=

x_neq_y=

x_lt_y=1 x_lt_y=

5-J:

d_ld = 1

1-J:

x_sel = 0 3: x_ld = 1

y_sel = 0 4: y_ld = 1

2-J:

!go_i

!(!go_i)

go_i

Controller implementation model^ Controller

y_sel

x_sel Combinational logic

Q3 Q

State register

go_i

x_neq_y x_lt_y

x_ld y_ld

d_ld

Q2 Q

I3 I2 I1 I

subtractor subtractor 5: x!=y 6: x<y 8: x-y 7: y-x

x_i y_i

d_o

0: x 0: y

9: d

n-bit 2x1 n-bit 2x

x_sel

y_sel x_ld

y_ld

x_neq_y

x_lt_y d_ld

5: x!=y

(b) Datapath

Completing the GCD custom single-

purpose processor design

• We finished the

datapath

• We have a state table

for the next state and

control logic

– All that’s left is

combinational logic

design

• This is not an

optimized design,

a view inside the controller and datapath

controller datapath

state

register

next-state

and

control

logic

registers

functional

units

RT-level custom single-purpose

processor design

• We often start with a state machine

  • Rather than algorithm
  • Cycle timing often too central to

functionality

• Example

  • Bus bridge that converts 4-bit bus to

8-bit bus

  • Start with FSMD
  • Known as register-transfer (RT) level
  • Exercise: complete the design

Problem Specification

Bridge A single-purpose processor that converts two 4-bit inputs, arriving one at a time over data_in along with a rdy_in pulse, into one 8-bit output on data_out along with a rdy_out pulse.

Sende r

data_in(4)

rdy_in (^) rdy_out

data_out(8)

Rece iver

clock

FSMD

WaitFirst4 RecFirst4Start data_lo=data_in

WaitSecond

rdy_in=

rdy_in=

RecFirst4End

rdy_in=

RecSecond4Start data_hi=data_in

RecSecond4End

rdy_in=0 rdy_in= rdy_in=

rdy_in=

Send8Start data_out=data_hi & data_lo rdy_out=

Send8End rdy_out=

Bridge

rdy_in= Inputs rdy_in: bit; data_in: bit[4]; Outputs rdy_out: bit; data_out:bit[8] Variables data_lo, data_hi: bit[4];

Optimizing single-purpose

processors

• Optimization is the task of making design

metric values the best possible

• Optimization opportunities

– original program

– FSMD

– datapath

– FSM

Optimizing the original program

• Analyze program attributes and look for areas

of possible improvement

– number of computations

– size of variable

– time and space complexity

– operations used

• multiplication and division very expensive

Optimizing the FSMD

• Areas of possible improvements

– merge states

• states with constants on transitions can be eliminated ,

transition taken is already known

• states with independent operations can be merged

– separate states

• states which require complex operations (abc*d) can

be broken into smaller states to reduce hardware size

– scheduling

Optimizing the FSMD (cont.)

int x, y;

go_i !go_i x = x_i y = y_i

xy y = y -x x = x - y

9: d_o = x

7: y = y -x 8: x = x - y

6-J:

x!=y

5: !(x!=y)

x<y !(x<y)

5-J:

x = x_i

4: y = y_i

2-J:

!go_i

!(!go_i)

d_o = x

1-J:

int x, y;

original FSMD optimized FSMD

eliminate state 1 – transitions have constant values

merge state 2 and state 2J – no loop operation in

between them

merge state 3 and state 4 – assignment operations are

independent of one another

merge state 5 and state 6 – transitions from state 6 can

be done in state 5

eliminate state 5J and 6J – transitions from each state

can be done from state 7 and state 8, respectively

eliminate state 1-J – transition from state 1-J can be

done directly from state 9

Optimizing the FSM

• State encoding

– task of assigning a unique bit pattern to each state

in an FSM

– size of state register and combinational logic vary

– can be treated as an ordering problem

• State minimization

– task of merging equivalent states into a single

state

• state equivalent if for all possible input combinations

the two states generate the same outputs and

transitions to the next same state

Summary

• Custom single-purpose processors

– Straightforward design techniques

– Can be built to execute algorithms

– Typically start with FSMD

– HDL tools are of great assistance