Académique Documents
Professionnel Documents
Culture Documents
Course contents
Digital design Combinatorial circuits: without status Sequential circuits: with status FSMD design: hardwired processors Language based HW design: VHDL
VHDL
3/1
Sequential Circuits
The flip-flop as building block Design of synchronous sequential circuits Design of asynchronous sequential circuits Basic RTL building blocks
VHDL
3/2
Sequential Circuits
The flip-flop as building block Design of synchronous sequential circuits Design of asynchronous sequential circuits Basic RTL building blocks
VHDL
3/3
VHDL
3/4
VHDL
3/5
Sequential Circuits
The flip-flop as building block
SR Latch Gated SR Latch Gated D Latch Flip-flop sensitivity Flip-flop types
VHDL
Design of synchronous sequential circuits Design of asynchronous sequential circuits Basic RTL building blocks
3/6
Sequential Circuits
The flip-flop as building block
SR Latch Gated SR Latch Gated D Latch Flip-flop sensitivity Flip-flop types
VHDL
Design of synchronous sequential circuits Design of asynchronous sequential circuits Basic RTL building blocks
3/7
SR Latch
Set
S R 0 1 0 1 Q(next) Q 0 1 NA
Reset
0 0 1 1
VHDL
S R Q Q Undefined
3/8
SR Latch
Note that a Boolean signal now already consists of 5 values:
0: the logical signal 0 1: the logical signal 1 x: dont care Z: high impedant U: undefined
VHDL
The oscillation is called critical race The oscillation only happens when the delay of both gates is exactly equal When the delays are not equal, the fastest gates determines the end result: implementation and run-time dependent undefined
3/9
SR Latch
Set
S R 1 0 1 0 Q(next) Q 0 1 NA
Reset
1 1 0 0
VHDL
S R Q Q
3/10
Sequential Circuits
The flip-flop as building block
SR Latch Gated SR Latch Gated D Latch Flip-flop sensitivity Flip-flop types
VHDL
Design of synchronous sequential circuits Design of asynchronous sequential circuits Basic RTL building blocks
3/11
Gated SR Latch
Set Q Clock Q Reset
C 0 0 0 0 1 1 1 1 S 0 0 1 1 0 0 1 1 R 0 1 0 1 0 1 0 1 Q(next) Q Q Q Q Q 0 1 NA
VHDL
3/12
Sequential Circuits
The flip-flop as building block
SR Latch Gated SR Latch Gated D Latch Flip-flop sensitivity Flip-flop types
VHDL
Design of synchronous sequential circuits Design of asynchronous sequential circuits Basic RTL building blocks
3/13
Gated D Latch
D Q Clock Q C=1: follow input C=0: latch output
C 0 0 1 1 D 0 1 0 1 Q(next) Q Q 0 1
VHDL
3/14
Gated D Latch
D
S
Q
Clock R Q
VHDL
D must not change immediately before H-to-L of the clock (during the setup time); reason: clock changes between the switching of D and of D hence Set and Reset switch from H to L at the same time undefined (setup time = H-to-L of invertor) D C
S
D R
3/15
Gated D Latch
D
S
Q
Clock R Q
VHDL
When D switches at least setup time before the clock transition, S and R will not switch from H to L at the same time OK (S is longer high than R, hence Q will come high following the D input) D C
S
D R
3/16
Gated D Latch
D
S
Q
Clock R Q
Analogously, D may not switch immediately after H-to-L of the clock (during the hold time) Symbol D Q 5.2/3.8 C Q Given values: 5.2=C to QLH 3.8=C to QHL
VHDL
3/17
Sequential Circuits
The flip-flop as building block
SR Latch Gated SR Latch Gated D Latch Flip-flop sensitivity
VHDL
3/18
Design of synchronous sequential circuits Design of asynchronous sequential circuits Basic RTL building blocks
Sequential Circuits
The flip-flop as building block
SR Latch Gated SR Latch Gated D Latch Flip-flop sensitivity
VHDL
3/19
Design of synchronous sequential circuits Design of asynchronous sequential circuits Basic RTL building blocks
Level sensitive latches give problems for shift registers for example
The input signal may ripple through multiple stages during one clock-high phase making it very hard to meet setup/hold time requirements See next slide
VHDL
3/20
Clk
VHDL
3/21
Sequential Circuits
The flip-flop as building block
SR Latch Gated SR Latch Gated D Latch Flip-flop sensitivity
VHDL
3/22
Design of synchronous sequential circuits Design of asynchronous sequential circuits Basic RTL building blocks
Master-slave flip-flop
X Master D Qm1 4/3 C Slave D Qs1 4/3 C Q1 Master D Qm2 4/3 C Slave D Qs2 4/3 C Y
Clk
VHDL
Y
The master clocks at the falling clock edge The slave clocks at the rising edge
3/23
Sequential Circuits
The flip-flop as building block
SR Latch Gated SR Latch Gated D Latch Flip-flop sensitivity
VHDL
3/24
Design of synchronous sequential circuits Design of asynchronous sequential circuits Basic RTL building blocks
Edge-triggered flip-flop
A Set Latch Set Q Clk Reset B D Q Output Latch
Reset Latch
VHDL
Clk
D B A R S Q
3/25
Sequential Circuits
The flip-flop as building block
SR Latch Gated SR Latch Gated D Latch Flip-flop sensitivity Flip-flop types
VHDL
3/26
SR flip-flop JK flip-flop D flip-flop T flip-flop Asynchronous set and reset Design of synchronous sequential circuits Design of asynchronous sequential circuits
Sequential Circuits
The flip-flop as building block
SR Latch Gated SR Latch Gated D Latch Flip-flop sensitivity Flip-flop types
VHDL
3/27
SR flip-flop JK flip-flop D flip-flop T flip-flop Asynchronous set and reset Design of synchronous sequential circuits Design of asynchronous sequential circuits
SR flip-flop
Symbol
S Q Characteristic table (for design of SR flip-flop)
S 0 0 1 1 R 0 1 0 1 Q(next) Q 0 1 NA
VHDL
Negative edge-triggered
Positive level triggered Negative level triggered
3/28
Sequential Circuits
The flip-flop as building block
SR Latch Gated SR Latch Gated D Latch Flip-flop sensitivity Flip-flop types
VHDL
SR flip-flop JK flip-flop D flip-flop T flip-flop Asynchronous set and reset Design of synchronous sequential circuits Design of asynchronous sequential
3/29
JK flip-flop
Symbol
J Q Characteristic table (for design of JK flip-flop)
J 0 0 1 1 K 0 1 0 1 Q(next) Q 0 1 Q
Clk K Q
VHDL
Excitation table (for design with JK flip-flop) Circuits that use JK flip-flops are cheaper than those using SR flip-flops: more dont cares
Q 0 0 1 1 Q(next) 0 1 0 1 J 0 1 x x K x x 1 0
3/30
Sequential Circuits
The flip-flop as building block
SR Latch Gated SR Latch Gated D Latch Flip-flop sensitivity Flip-flop types
VHDL
SR flip-flop JK flip-flop D flip-flop T flip-flop Asynchronous set and reset Design of synchronous sequential circuits Design of asynchronous sequential
3/31
D flip-flop
Symbol
D Q Characteristic table (for design of D flip-flop)
D 0 1 Q(next) 0 1
Clk Q
VHDL
0 0 1 1
3/32
Sequential Circuits
The flip-flop as building block
SR Latch Gated SR Latch Gated D Latch Flip-flop sensitivity Flip-flop types
VHDL
SR flip-flop JK flip-flop D flip-flop T flip-flop Asynchronous set and reset Design of synchronous sequential circuits Design of asynchronous sequential
3/33
T flip-flop
Symbol
T Q Characteristic table (for design of T flip-flop)
T 0 1 Q(next) Q Q
Clk Q
VHDL
Clk Q
3/34
Sequential Circuits
The flip-flop as building block
SR Latch Gated SR Latch Gated D Latch Flip-flop sensitivity Flip-flop types
VHDL
SR flip-flop JK flip-flop D flip-flop T flip-flop Asynchronous set and reset Design of synchronous sequential circuits Design of asynchronous sequential
3/35
Clk
Reset D Clear Asynchronous set and reset are useful to put the flip-flop initially in a known state (see lab sessions) D PRS Q B Q
VHDL
Clk
CLR
3/36
VHDL
3/37
VHDL
preset
3/38
Implements an AND function (hence wired-or ...) with unlimited number of inputs: preset The bus is only 1 when all inputs to the bus are equal to 1
Sequential Circuits
The flip-flop as building block Design of synchronous sequential circuits Design of asynchronous sequential circuits Basic RTL building blocks
VHDL
3/39
Sequential Circuits
The flip-flop as building block Design of synchronous sequential circuits
Finite State Machine (FSM) State-based or Moore-type FSM Input-based or Mealy-type FSM Step 1: State diagram Step 2: State minimization Step 3: State encoding Step 4: Choice of the flip-flop type Step 5: Realization of the combinatorial logic Step 6: Timing analysis
VHDL
3/40
Sequential Circuits
The flip-flop as building block Design of synchronous sequential circuits
Finite State Machine (FSM) State-based or Moore-type FSM Input-based or Mealy-type FSM Step 1: State diagram Step 2: State minimization Step 3: State encoding Step 4: Choice of the flip-flop type Step 5: Realization of the combinatorial logic Step 6: Timing analysis
VHDL
3/41
VHDL
CE=1
CE=0
Count=3 CE=1
Count=2
CE=0
3/42
Transition to the next state happens at each rising clock edge (a synchronous FSM is clocked!). At each rising clock edge, exactly one transition condition should be true: for each input combination, a transition should be specified in each of the states. CE=0 CE=0 Count=0 CE=1 Count=1 CE=1 CE=0
VHDL
Count=2
3/43
1. We are in state Count=0 2. CE input equals 0: we are waiting at the tip of the edge 3. CE=1: wait at tip of other edge, but do not count yet! 4. Rising clock edge: go to Count=1, still with CE=1 5. CE input becomes 0: wait at tip of other edge 6. Rising clock edge: go to Count=1, with CE=0
CE=0
VHDL
Q1Q0=10
CE=0
3/44
VHDL
3/45
CE=1
Q1Q0=10 CE=0
VHDL
CE=1
3/46
VHDL
Q0 Q1n=D1 Q1 0 0 1 CE 0 1 0 1 1 CE Q0n=D0
Q0 Q1 0 1 1 0 1 0 0 1
3/47
D to be applied is identical to Qn
VHDL
D1
Q1
Q Q0 Q
Q0n
D0
3/48
D1
Q
Q0 Q
Q0n
D0
VHDL
Clk
CE
Q1
3/49
Q0
Sequential Circuits
The flip-flop as building block Design of synchronous sequential circuits
Finite State Machine (FSM) State-based or Moore-type FSM Input-based or Mealy-type FSM Step 1: State diagram Step 2: State minimization Step 3: State encoding Step 4: Choice of the flip-flop type Step 5: Realization of the combinatorial logic Step 6: Timing analysis
VHDL
3/50
VHDL
CE=1
3/51
VHDL
LE
CE
Register
Clk
Clocked
3/52
VHDL
3/53
CE=0 Q1Q0=00 Y=0 CE=1 CE=0 Q1Q0=11 Y=1 CE=1 Q1Q0=01 Y=0 CE=1 Q1Q0=10 Y=0
CE=0
VHDL
CE=0
CE=1
3/54
VHDL
3/55
CE=0 CE=1
Q1Q0=01 Y=0
CE=1 CE=0
Q1Q0=11 Y=1
CE=1
Q1Q0=10 Y=0
CE=0
VHDL
CE=1
3/56
Outputs Y 0 0 0 1
VHDL
Q0 Q1n=D1 Q1 0 0 1 CE 0 1 0 Y Q1 1 1 Q0 0 0 0 1 CE Q0n=D0
Q0 Q1 0 1 1 0 1 0 0 1
3/57
D to be applied is identical to Qn
CE Q1 Q0 Q1n
VHDL
D1
Q1
Q Q0 Q
Q0n
D0
3/58
D1
Q
Q0 Q
Q0n
D0
VHDL
Clk CE Q1 Q0
3/59
VHDL
This clocked circuit will unintentionally clock: harmful Hard to debug: glitch may disappear when probe is connected due to increased capacitance and hence also increased delay
When the output with the glitch is connected to a combinatorial circuit that eventually is the input of a register:
3/60
Not harmful, since the register looks at its input only at the clock edge Dissipates unnecessary power
Sequential Circuits
The flip-flop as building block Design of synchronous sequential circuits
Finite State Machine (FSM) State-based or Moore-type FSM Input-based or Mealy-type FSM Step 1: State diagram Step 2: State minimization Step 3: State encoding Step 4: Choice of the flip-flop type Step 5: Realization of the combinatorial logic Step 6: Timing analysis
VHDL
3/61
VHDL
3/62
VHDL
3/63
VHDL
CE
3/64
VHDL
3/65
CE=0/Y=0
VHDL
3/66
VHDL
3/67
CE=0/Y=0 CE=1/Y=0
Q1Q0=01
CE=1/Y=0
Q1Q0=10 CE=0/Y=0
VHDL
CE=1/Y=0
3/68
Next state/Outputs Q1nQ0n/Y CE=0 CE=1 00/0 01/0 01/0 10/0 10/0 11/0 11/0 00/1
Y does not only depend on the current state, but also on the inputs
Next state/Outputs Q1nQ0n/Y CE=0 CE=1 00/0 01/0 01/0 10/0 10/0 11/0 11/0 00/1 Q0
Q0
VHDL
Q1n=D1
Q1
0 0 1 1
Q0n=D0
Q1
0 1 1 0
CE Y
0 1 0 1 Q0
Q1 0 0 0 0 0 0 0 1
CE
1 0 0 1
3/69
D to be applied is identical to Qn
CE
CE Q1 Q0 Q1n
VHDL
D1
Q1
Q Q0 Q
Q0n
D0
3/70
D1
Q
Q0 Q
Q0n
D0
VHDL
Clk CE Q1 Q0
3/71
State-based model
Inputs I Clock D Clk S*=F(S,I) Outputs O Q Next State S* Current State S
D Clk
O=H(S)
VHDL
Clk
3/72
Input-based model
Clock Inputs I Next State S* Current State S
D Clk S*=F(S,I)
Q Outputs O
D Clk
O=H(S,I)
VHDL
Clk
3/73
Sequential Circuits
The flip-flop as building block Design of synchronous sequential circuits
Finite State Machine (FSM) State-based or Moore-type FSM Input-based or Mealy-type FSM Step 1: State diagram Step 2: State minimization Step 3: State encoding Step 4: Choice of the flip-flop type Step 5: Realization of the combinatorial logic Step 6: Timing analysis
VHDL
3/74
C=1: count C=0: do not count D=1: count down D=0: count up
Direction (D):
VHDL
Output (Y): Y=1 when (count equals 2 and we count up) or when (count equals 0 and we count down) What is the meaning of We count up?
3/75
Second step: construct the FSM starting from the first state, for each combination of inputs from each state
See next slide Note: when an output needs to remain high during several consecutive states, it should be assigned a high value in each of these states!! Each output should be assigned a value in each state!
VHDL
3/76
u0
CD=10 Y=1 CD=10 Y=0
CD=10 Y=0
u1
u2
CD=11 Y=0 CD=11 Y=1
VHDL
d0
CD=0X Y=0
CD=11 Y=0
CD=11 Y=0
CD=0X Y=0
d1
CD=11 Y=0
CD=0X Y=0
d2
CD=11 Y=1
3/77
Sequential Circuits
The flip-flop as building block Design of synchronous sequential circuits
Finite State Machine (FSM) State-based or Moore-type FSM Input-based or Mealy-type FSM Step 1: State diagram Step 2: State minimization Step 3: State encoding Step 4: Choice of the flip-flop type Step 5: Realization of the combinatorial logic Step 6: Timing analysis
VHDL
3/78
VHDL
3/79
VHDL
iI: h(sj,i)=h(sk,i): both states produce the same output for each combination of inputs and iI: f(sj,i)f(sk,i): the next states are equivalent for each input combination
3/80
VHDL
3/81
VHDL
u1
u2 d0 d1 d2
3/82
u0
u1
u2
d0
d1
VHDL
u1
u2 d0 d1 d2
3/83
u0
u1
u2
d0
d1
VHDL
u1
u2 d0 d1 d2
OK
OK OK u0 u1 u2 d0 d1
3/84
VHDL
PRESENT STATE s0 s1 s2
3/85
NEXT STATE / OUTPUT CD=0X CD=10 CD=11 s0/0 s1/0 s2/1 s1/0 s2/0 s0/0 s2/0 s0/1 s1/0
VHDL
s0
s1
s2
3/86
CD=11 Y=1
This could have been constructed from the begin -ning, but better 1 state too much than too little
VHDL
3/87
VHDL
s1
s2 s3 s4 s5
3/88
s0
s1
s2
s3
s4
VHDL
s1
s2 s3 s4 s5
3/89
s0
s1
s2
s3
s4
VHDL
s1
s2 s3 s4 s5
1-4 1-3
NEXT STATE / OUTPUT AB=00 AB=01 AB=10 s4/1 s2/0 s1/1 s2/0 s5/1 s4/1 s1/1 s0/0 s3/1 s2/0 s5/1 s4/1 s0/0 s5/1 s1/1 s2/0 s4/1 s2/1
3/90
s0
s1
s2
s3
s4
VHDL
s1
s2 s3 s4 s5
1-4: 1-4? 1-3:OK 1-3
NEXT STATE / OUTPUT AB=00 AB=01 AB=10 s4/1 s2/0 s1/1 s2/0 s5/1 s4/1 s1/1 s0/0 s3/1 s2/0 s5/1 s4/1 s0/0 s5/1 s1/1 s2/0 s4/1 s2/1
3/91
s0
s1
s2
s3
s4
VHDL
s1
s2 s3 s4 s5
1-4: ? 1-3:OK
NEXT STATE / OUTPUT AB=00 AB=01 AB=10 s4/1 s2/0 s1/1 s2/0 s5/1 s4/1 s1/1 s0/0 s3/1 s2/0 s5/1 s4/1 s0/0 s5/1 s1/1 s2/0 s4/1 s2/1
3/92
s0
s1
s2
s3
s4
VHDL
PRESENT STATE u0 u1 u2
3/93
NEXT STATE / OUTPUT AB=00 AB=01 AB=10 u1/1 u0/0 u1/1 u0/0 u2/1 u1/1 u0/0 u1/1 u0/1
Sequential Circuits
The flip-flop as building block Design of synchronous sequential circuits
Finite State Machine (FSM) State-based or Moore-type FSM Input-based or Mealy-type FSM Step 1: State diagram Step 2: State minimization Step 3: State encoding Step 4: Choice of the flip-flop type Step 5: Realization of the combinatorial logic Step 6: Timing analysis
VHDL
3/94
VHDL
3/95
VHDL
3/96
VHDL
Straightforward encoding is dangerous for glitches and leads to non-minimal area and power consumption: multiple bits have to change at each state transition
(multiple bit-changes seldomly happen concurrently; each bit-change requires some logic to implement it; each bit-change consumes power)
3/97
VHDL
PRESENT STATE 00 01 10
NEXT STATE / OUTPUT CD=0X CD=10 CD=11 00/0 01/0 10/1 01/0 10/0 00/0 10/0 00/1 01/0
3/98
VHDL
10
11
3/99
Straightforward
Minimum-bit-change
VHDL
2
PRESENT STATE 00 10 11
All transitions are equally likely Preferrably only 1 bit difference between each pair of transitions This can only be realised between two of the three pairs
3/100
NEXT STATE / OUTPUT CD=0X CD=10 CD=11 00/0 10/0 11/1 10/0 11/0 00/0 11/0 00/1 10/0
VHDL
3/101
VHDL
3/102
s0
CD=11 Y=1
s1
s2
VHDL
Q0 D
Q1 D
Q2 D
3/103
C D
VHDL
3/104
s0
CD=11 Y=1
s1
s2
VHDL
Q0 S R
Q1 S R
Q2 S R
C Y
3/105
C D
VHDL
3/106
Sequential Circuits
The flip-flop as building block Design of synchronous sequential circuits
Finite State Machine (FSM) State-based or Moore-type FSM Input-based or Mealy-type FSM Step 1: State diagram Step 2: State minimization Step 3: State encoding Step 4: Choice of the flip-flop type Step 5: Realization of the combinatorial logic Step 6: Timing analysis
VHDL
3/107
VHDL
SR flip-flop
Cheap flip-flop Difficult design Many dont cares: probably cheap (and fast) control logic Used when a different signal sets resp. resets the flip-flop
3/108
VHDL
T flip-flop
Cheap flip-flop Easy design No dont cares: probably most espensive (and slowest) combinatorial control logic Used for counters and frequency dividers: fast toggling
3/109
VHDL
3/110
Sequential Circuits
The flip-flop as building block Design of synchronous sequential circuits
Finite State Machine (FSM) State-based or Moore-type FSM Input-based or Mealy-type FSM Step 1: State diagram Step 2: State minimization Step 3: State encoding Step 4: Choice of the flip-flop type Step 5: Realization of the combinatorial logic Step 6: Timing analysis
VHDL
3/111
Q0 Q1 0 x 0 0 x 0 0 x 0
Y 0 D C 0 1
0 0 x 1 Q0
VHDL
Q0
Q1n=D1 Q1 1 0 0 Q0n=D0 0 C 0 1
Q1
0 0 x 1 D
C 0 0 x 1 0 x 0 1 x
0 1 x 0 D
1 x 0 0 x 1 0 x 0
3/112
D to be applied is identical to Qn
VHDL
Q1 D
Q0 D
Cost: 35
1.5 CLB
3/113
C D
Q0 Q1 0 x 0 0 x 0 0 x 0
Y 0 D C 0 1
0 0 x 1 Q0
VHDL
Q0
T1 Q1 T0 0 C 0 1
Q1
0 0 x 0 D
C 0 0 x 1 0 x 0 1 x 0 1 1
0 0 x 0 D
0 x 0 1 x 1 1 x 0
3/114
VHDL
Q1 T
Q0 T
Cost: 32
3/115
C D
VHDL
Q0
S1 Q1 R1 x C 0 x
Q0
Q1
0 0 x x D
C 0 0 x 1 0 x 0 1 x x 0 0
x x x 0 D
x x 0 x x 1 0 x 1
3/116
Q0 Q1 0 x 0 0 x 0 0 x 0
Y 0 D C 0 1
0 0 x 1 Q0
VHDL
Q0
S0 Q1 R0 x C x 0
Q1
0 x x 0 D
C 0 x x 0 0 x 1 0 x 0 1 0
x 0 x x D
0 x x 1 x 0 1 x x
3/117
VHDL
Q1 S R
Q0 S R
3/118
C D
VHDL
Q1 S R
Q0 S R
3/119
C D
VHDL
Q1 S R
Q0 S R
Cost: 32
3/120
C D
VHDL
Q0
J1 Q1 K1 x C x x
Q0
Q1
0 0 x x D
C 0 0 x 1 0 x 0 1 x x x x
x x x 0 D
x x 0 x x 1 x x 1
3/121
Q0 Q1 0 x 0 0 x 0 0 x 0
Y 0 D C 0 1
0 0 x 1 Q0
VHDL
Q0
J0 Q1 K0 x C x x
Q1
0 x x 0 D
C 0 x x 0 x x 1 x x 0 1 0
x 0 x x D
0 x x 1 x x 1 x x
3/122
VHDL
Q1 J K
Q0 J K
3/123
C D
VHDL
Q1 J K
Q0 J K
Cost: 26
3/124
C D
Sequential Circuits
The flip-flop as building block Design of synchronous sequential circuits
Finite State Machine (FSM) State-based or Moore-type FSM Input-based or Mealy-type FSM Step 1: State diagram Step 2: State minimization Step 3: State encoding Step 4: Choice of the flip-flop type Step 5: Realization of the combinatorial logic Step 6: Timing analysis
VHDL
3/125
VHDL
Q1 D
Clr
Q0 D
Clr
C D
3/126