• No results found

ECE 545 Lecture 10. Structure of a Typical Digital System Data Inputs. Datapath vs. controllers. Required reading. Design of Controllers Part 1

N/A
N/A
Protected

Academic year: 2022

Share "ECE 545 Lecture 10. Structure of a Typical Digital System Data Inputs. Datapath vs. controllers. Required reading. Design of Controllers Part 1"

Copied!
10
0
0

Loading.... (view fulltext now)

Full text

(1)

George Mason University

ECE 545 Lecture 10

Design of Controllers Part 1

1

2

Required reading

P. Chu, RTL Hardware Design using VHDL

Chapter 10, Finite State Machine:

Principle & Practice

2

3 ECE 448 – FPGA and ASIC Design with VHDL

Datapath vs.

Controller

3

Structure of a Typical Digital System

Datapath (Execution

Unit)

Controller (Control

Unit)

Data Inputs

Data Outputs

Control & Status Inputs

Control & Status Outputs Control

Signals

Status Signals

4

5

Controller (Control Unit)

• Controls data movements in the Datapath by switching multiplexers and enabling or disabling resources

Example: enable signals for registers Example: select signals for muxes

• Provides signals to activate various processing tasks in the Datapath

• Determines the sequence of operations performed by the Datapath

• Follows Some ‘Program’ or Schedule

6

Programmable vs. Non-Programmable Controller

• Controller can be programmable or non-programmable

• Programmable

§ Has a program counter which points to the next instruction

§ Instructions are held in a RAM or ROM

§ Microprocessor is an example of a programmable controller

• Non-Programmable

§ Once designed, implements the same functionality

§ Another term is a “hardwired state machine,” or “hardwired FSM,” or “hardwired instructions”

§ In this course we will be focusing on non- programmable controllers.

(2)

7

Finite State Machines

• Digital Systems and especially their Controllers can be described as Finite State Machines (FSMs)

• Finite State Machines can be represented using

State Diagrams and State Tables- suitable for simple digital systems with a relatively few inputs and outputs

Algorithmic State Machine (ASM) Charts- suitable for complex digital systems with a large number of inputs and outputs

• All these descriptions can be easily translated to the corresponding synthesizable VHDL code

7

8

Hardware Design with RTL VHDL

Pseudocode

Datapath Controller

Block diagram

ASM chart

VHDL code VHDL code

Interface

8

1. Text description 2. Interface 3. Pseudocode

4. Block diagram of the Datapath

5. Interface divided into the Datapath and Controller 6. ASM chart of the Controller

7. RTL VHDL code of the Datapath, Controller, and Top-level Unit

8. Testbench for the Datapath, Controller, and Top-Level Unit

9. Functional simulation and debugging 10. Synthesis and post-synthesis simulation 11. Implementation and timing simulation 12. Experimental testing using FPGA board

Steps of the Design Process Introduced in Class Today

9

9

10

Finite State Machines Refresher

10

11

Finite State Machines (FSMs)

• An FSM is used to model a system that transits among a finite number of internal states. The transitions depend on the current state and external input.

• The main application of an FSM is to act as the controller of a medium to large digital system

• Design of FSMs involves

• Defining states

• Defining next state and output functions

• Optimization / minimization

• Manual optimization/minimization is practical for small FSMs only

12

Moore FSM

• output is a function of the state only

state register next-state

logic

output logic input

state_next

output state_reg

resetclk

(3)

13

Mealy FSM

• output is a function of the state and input signals

state register next-state

logic

output logic input

state_next

output resetclk

state_reg

13

14

State Diagrams

14

15

Moore Machine

state 1/ output 1

state 2/ output 2 transition

condition 1

transition condition 2

15

16

Mealy Machine

state 1 state 2

transition condition 1/ output 1

transition condition 2/ output 2

16

17

Moore FSM - Example 1

• Moore FSM that Recognizes Sequence “10”

S0 / 0 S1 / 0 S2 / 1

0 0

0 1

1 1

reset

Meaning of states:

S0: No elements of the sequence observed

S1: “1”

observed

S2: “10”

observed

18

Mealy FSM - Example 1

• Mealy FSM that Recognizes Sequence

“10”

S0 S1

0 / 0 1 / 0 1 / 0

0 / 1 reset

Meaning of states:

S0: No elements of the sequence observed

S1: “1”

observed

(4)

19

Algorithmic State Machine (ASM) Charts

19

20

Algorithmic State Machine

Algorithmic State Machine –

representation of a Finite State Machine suitable for FSMs with a larger number of inputs and outputs compared to FSMs expressed using state diagrams and state tables.

20

21

ASM Chart

– Flowchart-like diagram

– Provides the same info as a state diagram – More descriptive, better for complex description

21

22

ASM describing generalized FSM

• Algorithmic state machines can model both Mealy and Moore Finite State Machines

• They can also model generalized machines that are of the mixed type

22

23

Elements used in ASM charts (1)

Output signals or actions (Moore type) State name

Condition expression

0 (False) 1 (True)

Conditional outputs or actions (Mealy type)

(a) State box (b) Decision box

(c) Conditional output box

24

State Box

State box– represents a state.

• Equivalent to a node in a state diagram or a row in a state table.

• Contains register transfer actions or output signals

Moore-type outputs are listed inside of the box.

• It is customary to write only the name of the signal that has to be asserted in the given state, e.g., z instead of z<=1.

• Also, it might be useful to write an action to be taken, e.g., count <= count + 1, and only later translate it to asserting a control signal that causes a given action to take place (e.g., enable signal of a counter).

Output signals or actions (Moore type) State name

(5)

25

Decision Box

Decision box

– indicates that a given condition is to be tested and the exit path is to be chosen accordingly.

The condition expression may include one or more inputs to the FSM.

Condition expression

0 (False) 1 (True)

25

26

Conditional Output Box

Conditional output box

Denotes output signals that are of the Mealy type.

• The condition that determines whether such outputs are generated is specified in the decision box.

Conditional outputs or actions (Mealy type)

26

27

Simple Example: Datapath

eni clk

== k-1

zi m i

en ld ldi

m 0

27

28

Simple Example: Interface

28

29

Example: Counter – Controller

30

ASM Block

• One state box

• One or more (optional) decision boxes:

with T (1) or F (0) exit paths

• One or more (optional) conditional output boxes:

for Mealy outputs

(6)

31

ASM Chart Rules

Based on RTL Hardware Design by P. Chu

• Difference between a regular flowchart and an ASM chart:

– Transition governed by clock

– Transition occurs between ASM blocks

• Basic rules:

– For a given input combination, there is one

unique exit path

from the current ASM block – Any closed loop in an ASM chart must

include a state box

31

32

Incorrect ASM Charts

Based on RTL Hardware Design by P. Chu

32

33

Correct ASM Chart

33

34

State Diagram of Moore FSM

• Moore FSM that Recognizes Sequence “10”

S0 / 0 S1 / 0 S2 / 1

0 0

0 1

1 1

reset

Meaning of states:

S0: No elements of the sequence observed

S1: “1”

observed S2: “10”

observed

34

35

ASM Chart of Moore FSM

S0 reset

input S1

S2 input

input 0

1

0 1

1 0

output

36

State Diagram of Mealy FSM

• Mealy FSM that Recognizes Sequence

“10”

S0 S1

0 / 0 1 / 0 1 / 0

0 / 1 reset

Meaning of states:

S0: No elements of the sequence observed

S1: “1”

observed

(7)

37

ASM Chart of Mealy Machine

S0

S1 reset

input

input

output 0

1

1 0

37

38

Moore & Mealy FSMs without delays

clock input Moore

Mealy

0 1 0 0 0

S0 S0 S1 S2 S0 S0

S0 S0 S1 S0 S0 S0 state

output state output

38

39

Moore & Mealy FSMs with delays

clock input Moore

Mealy

0 1 0 0 0

S0 S0 S1 S2 S0 S0

S0 S0 S1 S0 S0 S0 state

output state output

39

40

Moore vs. Mealy FSM (1)

• Moore and Mealy FSMs Can Be Functionally Equivalent

• Equivalent Mealy FSM can be derived from Moore FSM and vice versa

• Mealy FSM Has Richer Description and Usually Requires Smaller Number of States

• Smaller circuit area

40

41

Moore vs. Mealy FSM (2)

• Mealy FSM Computes Outputs as soon as Inputs Change

• Mealy FSM responds one clock cycle sooner than equivalent Moore FSM

• Moore FSM Has No Combinational Path Between Inputs and Outputs

Moore FSM is less likely to affect the critical path of the entire circuit

42

Moore FSM

• output is a function of the state only

state register next-state

logic

output logic input

state_next

output state_reg

resetclk

(8)

43

Mealy FSM

• output is a function of the state and input signals

state register next-state

logic

output logic input

state_next

output resetclk

state_reg

43

44

Which Way to Go?

Safer.

Less likely to affect the critical path.

Mealy FSM Moore FSM

Lower Area

Responds one clock cycle earlier Fewer states

44

45

ASMs representing simple FSMs

• Algorithmic state machines can model both Mealy and Moore Finite State Machines

• They can also model machines that are of the mixed type

45

46

Generalized FSM

Based on RTL Hardware Design by P. Chu Next State Present State

46

47

Examples of Controllers

Class Exercise 1

STATISTICS

(9)

Pseudocode

no_1 = no_2 = no_3 = sum = 0 for i=0 to k-1 do

sum = sum + din if din > no_1 then

no_3 = no_2 no_2 = no_1 no_1 = din elseif (din > no_2) then

no_3 = no_2 no_2 = din elseif (din > no_3) then

no_3 = din end if end for avr = sum / k

49

Circuit Interface

n n

2 clk

reset din

go

done

dout dout_mode Statistics

50

Interface Table

Port Width Meaning

clk 1 System clock.

reset 1 System reset.

din n Input Data.

go 1 Control signal indicating that the first input is ready.

Active for one clock cycle.

done 1 Signal set to high after the output is ready.

dout n Output dependent on the dout_mode input.

dout_mode 2 Control signal determining value available at the output.

00: avr, 01: no_1, 10: no_2, 11: no_3.

51

en clk rst

0

1 s2

reset en1

en clk rstreset enc

clk

== k-1

zi n

m n

Block diagram of the Datapath

en clk rst

0

1 s3

reset en2

n n

en clk rstreset en3

no_1

no_2

no_3

i din

A>B A B

gt1

A>B A B

gt2

A>B A B

gt3 clk

clk

clk en

clk rstreset esum

n+m clk sum n+m

n+m

>> m

n

n n

n+m

n avr

00 01 10 11

no_1 no_2 no_3 dout_mode dout

2 n

n

n n n

52

n

clk reset

dout

n

go

done

en1 en2 en3 esum enc s2 s3

Datapath Controller

dout_mode

2

gt2

Interface with the division into the Datapath and Controller

din

gt1 gt3 zi

Pseudocode

no_1 = no_2 = no_3 = sum = 0 for i=0 to k-1 do

sum = sum + din if din > no_1 then

no_3 = no_2 no_2 = no_1 no_1 = din elseif (din > no_2) then

no_3 = no_2 no_2 = din elseif (din > no_3) then

no_3 = din end if end for avr = sum / k

(10)

ASM Charts

55

en clk rst

0

1 s2

reset en1

en clk rstreset enc

clk

== k-1

zi n

m n

Block diagram of the Datapath

enclk rst

0

1 s3

reset en2

n n

enclk rstreset en3

no_1

no_2

no_3

i din

A>B A B

gt1

A>B A B

gt2

A>B A B

gt3 clk

clk

clk en

clk rstreset esum

n+m clk sum n+m

n+m

>> m

n

n n

n+m

n avr

00 01 10 11

no_1 no_2 no_3 dout_mode dout

2 n

n

n n n

56

References

Related documents

The maximum likelihood/ sA weighted 2 F obs@ F calc electron density map (gray) is contoured at 1.0 sigma. D) Structure of raIDUA complexed with a fragment of ABP 3 , illustrating

After describing the growth of algorithmic trading in this market since its introduction in 2003, we study its e¤ect on two measures of price e¢ ciency, the frequency of

Similar to flax/tannin composites in Chapter 5, mechanical properties of flax/bio- epoxy composites, including tension, flexural, shear, damage resistance, were

She has been longing for this moment for so long that her 'HELLO' is resounding like the loudest of

In order to study the effect of a moisture content gradient on the smouldering spread behaviour we designed a simpli fied milled peat system that allows the natural sources of

Отже, нами встановлено, що відсутність вітаміну А в організмі з пухлиною, порівняно з онкогенезом за нормальної забезпеченості цим есенціальним нутрієнтом,

Good old-fashioned smart PR and a communications strategy that relies on the magnification effect of early adopters and key influentials to amplify launch noise via