Chapter 8 Sequential Circuit Design:...

53
Chapter 8 Sequential Circuit Design: Principle ECOM 4311 Digital System Design using VHDL

Transcript of Chapter 8 Sequential Circuit Design:...

Page 1: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

Chapter 8

Sequential Circuit Design:

Principle

ECOM 4311

Digital System Design using VHDL

Page 2: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

2

Outline

1. Overview on sequential circuits

2. Synchronous circuits

3. Danger of synthesizing asynchronous circuit

4. Inference of basic memory elements

5. Simple design examples

6. Timing analysis

7. Alternative one-segment coding style

8. Use of variable for sequential circuit

Page 3: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

3

Overview on sequential circuit

Combinational vs sequential circuit

• Sequential circuit: output is a function of

current input and state (memory)

Basic memory elements

• D latch

• D FF (Flip-Flop)

• RAM

Synchronous vs asynchronous circuit

Page 4: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

4

Overview on sequential circuit

Page 5: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

5

Overview on sequential circuit

Page 6: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

6

• Timing of a D FF:

D Flip Flop

Clock-to-q delay (Tcq): Delay required for sampled d value to show up on q

Setup time (Tsetup): time interval that d must be stable for before the rising edge

of clock

Hole time (Thold): time interval that d must be stable for after the rising edge.

Page 7: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

7

Synch vs asynch circuits

Globally synchronous circuit: all memory

elements (D FFs) controlled (synchronized) by

a common global clock signal

Globally asynchronous but locally synchronous

circuit (GALS): Used in cases in which the

components of the design are spread too far

apart to allow a single synchronous clock.

Globally asynchronous circuit

• Use D FF but not a global clock

• Use no clock signal

Page 8: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

8

2. Synchronous circuit

Basic Block diagram:

State registers (state_reg) represent the memory

elements

Next state logic represent the combinational circuit that

determines state_next

Output logic represent the combinational circuit that

generates the external output signal.

Page 9: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

10

• Operation o At the rising edge of the clock, state_next sampled

and stored into the register (and becomes the new value of state_reg

o The next-state logic determines the new value (new state_next) and the output logic generates the output

o At the rising edge of the clock, the new value of state_next sampled and stored into the register

• Note that the clock period needs to be large enough to

accommodate the propagation delay of the next-state logic, the clock-to-q delay and the setup time of the FFs

Synchronous circuit

Page 10: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

11

Advantages of synchronous design

A single global clock makes the task of

satisfying the timing constraints of a design

with of thousands of FFs manageable.

The synchronous model separates the

combinational components from the memory

elements, making it possible to treat the

combinational part by itself

Propagation delay anomalies such as

hazards can be dealt with easily by focusing

on the worst case timing behavior

Page 11: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

12

Types of synchronous circuits

Regular sequential circuit

• State representation, transitions and next-state logic

have a simple, regular pattern, as in an incrementor or

shift register.

Random sequential circuit (FSM)

• More complicated state and no special relationship

between st ates transitions and their binary

representations -- next-state logic is random

Combined sequential circuit (FSM with a Data

path, FSMD -- RTL)

• Combines regular sequential circuit and an FSM, with

FSM acting as control for the sequential circuit

Page 12: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

13

Danger of synthesizing asynchronous

circuit

Consider the D Latch described earlier

We can write VHDL code as follows to represent

it

Page 13: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

14

Danger of synthesizing asynchronous

circuit

•Here we see the

implementation is

combinational except for

that the output is looped

around as an input

•Unfortunately, there is a

serious timing problem with

this circuit

Page 14: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

15

Inference of basic memory elements

VHDL code should be clear so that the pre-

designed cells can be inferred

VHDL code

• D Latch

• Positive edge-triggered D FF

• Negative edge-triggered D FF

• D FF with asynchronous reset

Page 15: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

16

D Latch

• No else branch

• D latch will be

inferred

Page 16: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

17

Pos edge-triggered D FF

Page 17: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

18

Neg edge-triggered D FF

Page 18: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

19

D FF with async reset

Page 19: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

20

Register

•Multiple D FFs

with same clock

and reset

Page 20: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

21

5. Simple design examples

• Follow the block diagram

oRegister

oNext-state logic (combinational circuit)

oOutput logic (combinational circuit)

Page 21: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

22

D FF with sync enable

• Note that the en is controlled by clock

Page 22: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

23

D FF with sync enable Conceptual diagram

Page 23: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

24

T FF

Page 24: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

25

T FF

Page 25: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

26

Free-running shift right register

Page 26: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

27

Free-running shift right register

Page 27: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

28

Free-running shift right register

Page 28: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

29

Universal shift register

• 4 ops: parallel load, shift right, shift left, pause

Page 29: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

30

Universal shift register

Page 30: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

31

Universal shift register

Page 31: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

32

Arbitrary sequence counter

Page 32: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

33

Arbitrary sequence counter

Page 33: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

34

Free-running binary counter • Count in binary sequence

• With a max_pulse output: asserted when

counter is in “11…11” state

Page 34: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

35

Free-running binary counter

Page 35: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

36

• Wrapped around automatically

• Poor practice:

Free-running binary counter

Page 36: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

37

Featured Binary counter

Page 37: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

38

Featured Binary counter

Page 38: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

39

Featured Binary counter

Page 39: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

40

Decade (mod-10) counter

Page 40: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

41

Decade (mod-10) counter

Page 41: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

42

Programmable mod-m counter

Page 42: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

43

Programmable mod-m counter

Page 43: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing
Page 44: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

45

Programmable mod-m counter more efficient

implementation

Page 45: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

46

6. Timing analysis

Combinational circuit:

• characterized by propagation delay

Sequential circuit:

• Has to satisfy setup/hold time constraint

• Characterized by maximal clock rate

(e.g., 200 MHz counter, 2.4 GHz Pentium II)

• Setup time and clock-to-q delay of register and

the propagation delay of next-state logic are

embedded in clock rate

Page 46: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

47

• Setup time violation and maximal clock rate

Page 47: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing
Page 48: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

49

• E.g., shift register; let Tcq=1.0ns Tsetup=0.5ns

Page 49: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

50

• E.g., Binary counter; let Tcq=1.0ns Tsetup=0.5ns

Page 50: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

51

Page 51: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

52

• Hold time violation

Page 52: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

53

Page 53: Chapter 8 Sequential Circuit Design: Principlesite.iugaza.edu.ps/.../files/2013/09/lecture8_sequential.pdf1. Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing

54

Using Variables in Sequential

Circuit Descriptions

A variable can also be assigned under the

clk’event and clk = ’1’ condition, but

whether a FF is created or not depends on

how it is used

If a variable is assigned a value before it is

used, it will get a value on each invocation

of the process and therefore, there is not

need to remember its previous value