Sequential Circuit Description: Unit 5
Sequential Circuit Description: Unit 5
Sequential Circuit Description: Unit 5
1
Sequential Models
2
Sequential Models
Sequential
Models
Verilog Digital 3
System Design
Feedback Model
Sequential
Models
Verilog Digital 4
System Design
Feedback Model
A two-state (one-bit)
Memory element
S
Q
R
Feedback Line
Basic Feedback
Verilog Digital 5
System Design
Capacitive Model
Sequential
Models
Verilog Digital 6
System Design
Capacitive Model
When c becomes 1 the value of D
is saved in the input gate of the
inverter and when c becomes 0
this value will be saved until the
next time that c becomes 1 again.
C The complement
of the stored data
D Q
Capacitive Storage
Verilog Digital 7
System Design
Implicit Model
Sequential
Models
Verilog Digital 8
System Design
Implicit Model
Feedback and capacitive models Verilog offers language constructs
are technology dependent and that are technology independent
have the problem of being too and allow much more efficient
detailed and too slow to simulate. simulation of circuits with a large
number of storage elements.
1S Q
1R
C1
An SR-Latch Notation
Verilog Digital 9
System Design
Basic Memory Components
Basic Memory
Components
User Defined
Gate Level Primitives
Sequential Primitives
Memory Vectors
Flip-flop Timing
and Arrays
Verilog Digital 10
System Design
Gate Level Primitives
Basic Memory
Components
User Defined
Gate Level Primitives
Sequential Primitives
Memory Vectors
Flip-flop Timing
and Arrays
Verilog Digital 11
System Design
Gate Level Primitives
r g2
q
g4
r g2 q_b
_r
Verilog Digital 14
System Design
Gate Level Primitives
Delay values can be
controlled when the latch
`timescale 1ns/100ps is instantiated.
g1 ( _s, s, c ),
g2 ( _r, r, c ),
g3 ( q, _s, q_b ),
g4 ( q_b, _r, q );
endmodule
Verilog Digital 16
System Design
Gate Level Primitives
Master Slave
master_slave
d
latch qm latch q
c
~c q_b
~d qm_b
Master-Slave D Flip-Flop
Verilog Digital 17
System Design
Gate Level Primitives
`timescale 1ns/100ps
module master_slave (input d, c, output q, q_b );
wire qm, qm_b;
defparam master.tplh=4, master.tphl=4,
Hierarchical Naming
slave.tplh=4, slave.tphl=4;
latch_p
master ( d, ~d, c, qm, qm_b ),
slave ( qm, qm_b, ~c, q, q_b );
endmodule
Verilog Digital 18
System Design
User Defined
Sequential Primitives
Basic Memory
Components
User Defined
Gate Level Primitives
Sequential Primitives
Memory Vectors
Flip-flop Timing
and Arrays
Verilog Digital 19
System Design
User Defined
Sequential Primitives
Verilog Digital 20
System Design
User Defined Sequential Primitives
primitive latch( q, s, r, c );
output q;
reg q;
input s, r, c;
initial q=1'b0;
table
// s r c q q+ ;
// ------:---:----;
? ? 0 : ? : - ; Table defining the latch
0 0 1 : ? : - ; output
0 1 1 : ? : 0 ;
1 0 1 : ? : 1 ;
endtable
endprimitive
User Defined
Gate Level Primitives
Sequential Primitives
Memory Elements
Memory Elements Behavioral
Using Assignments Memory Elements
Memory Vectors
Flip-flop Timing
and Arrays
Verilog Digital 23
System Design
Memory Elements Using
When a block’s
clock input is 0,
Assignments
it puts its output master_slave
back
to itself (feedback),
and when its clock is
1 it puts its data
input
into its output. d qm q
c
~c
Verilog Digital 25
System Design
Behavioral Memory Elements
Basic Memory
Components
User Defined
Gate Level Primitives
Sequential Primitives
Verilog Digital 26
System Design
Behavioral Memory Elements
Behavioral Coding:
A more abstract and easier way of writing Verilog code for a latch or
flip-flop.
The storage of data and its sensitivity to its clock and other control
inputs will be implied in the way model is written.
Verilog Digital 27
System Design
Behavioral Memory Elements
Behavioral
Memory
Elements
Latch Flip-flop
Modeling Modeling
Flip-flop Other
with Set-Reset Storage Element
Control Modeling Styles
Verilog Digital 28
System Design
Latch Modeling
Behavioral
Memory
Elements
Latch
Latch Flip-flop
Modeling
Modeling Modeling
Flip-flop Other
with Set-Reset Storage Element
Control Modeling Styles
Verilog Digital 29
System Design
While c is 1
Latch Modeling
changes on d directly affect
q and q_b outputs.
A Storage unit
Level Sensitive to c :
`timescale 1ns/100ps A Latch
Latch Flip-flop
Flip-flop
Modeling Modeling
Modeling
Flip-flop Other
with Set-Reset Storage Element
Control Modeling Styles
Verilog Digital 33
System Design
Flip-flop Modeling
With each clock edge,
the entire procedural block
is executed once from begin A basic edge trigger
to end. flip-flop model at the
behavioral level
`timescale 1ns/100ps
Verilog Digital 35
System Design
Flip-flop with Set-Reset Control
Behavioral
Memory
Elements
Latch Flip-flop
Modeling Modeling
Flip-flop
Flip-flop Other
with Set-Reset
with Set-Reset Storage Element
Control
Control Modeling Styles
Verilog Digital 36
System Design
Flip-flop With Set-Reset Control
`timescale 1ns/100ps
Latch Flip-flop
Modeling Modeling
Flip-flop Other
Other Storage
with Set-Reset Element Modeling
Storage Element
Control StyleStyles
Modeling
Verilog Digital 44
System Design
Other Storage Element
Modeling Styles A latch using a wait
statement instead of an
`timescale 1ns/100ps event control statement
Basic Memory
Components
User Defined
Gate Level Primitives
Sequential Primitives
Memory Vectors
Flip-flop
Flip-flop Timing
Timing
and Arrays
Verilog Digital 46
System Design
Flip-flop Timing
Flip-flop
Timing
Width
Setup Hold
And
Time Time
Period
Verilog Digital 47
System Design
Setup Time
Flip-flop
Timing
Width
Setup Hold
And
Time Time
Period
Verilog Digital 48
System Design
Setup Time
Setup Time
The Minimum necessary time that a data input requires to setup
before it is clocked into a flip-flop.
Verilog construct for checking the setup time: $setup task
The $setup task:
Takes flip-flop data input, active clock edge and the setup time as
its parameters.
Is used within a specify block.
Verilog Digital 49
System Design
Setup Time Continuously checks timing
distance between changes on d
$setup task within a specify block and the positive edge of clk.
If this distance is less than 5ns,
`timescale 1ns/100ps a violation message will be issued.
module d_ff ( input d, clk, s, r, output reg q, q_b
);
specify
$setup ( d, posedge clk, 5 );
endspecify
always @( posedge clk or posedge s or posedge r )
begin
.............. Positive edge trigger flip-flop
end and Asynchronous set and
reset controls
endmodule
Flip-Flop with Setup Time
Verilog Digital 50
System Design
Setup Time
...................................
always @( posedge clk or posedge s or posedge r )
begin
if( s ) begin
q <= #4 1'b1;
q_b <= #3 1'b0;
end else if( r ) begin
q <= #4 1'b0;
q_b <= #3 1'b1;
end else begin
q <= #4 d;
q_b <= #3 ~d;
end
end
endmodule
Verilog Digital 52
System Design
Hold Time
Flip-flop
Timing
Width
Setup Hold
And
Time Time
Period
Verilog Digital 53
System Design
Hold Time
Hold Time
The Minimum necessary time a flip-flop data input must stay
stable (holds its value) after it is clocked.
Verilog construct for checking the setup time: $hold task
The $setup task:
Takes flip-flop data input, active clock edge and the required hold
time as its parameters.
Is used within a specify block.
Verilog Digital 54
System Design
Hold Time
`timescale 1ns/100ps
Verilog Digital 55
System Design
Hold Time
The clock samples the d value
of 1 at 20ns. At 22ns, d changes.
This violates the minimum
required hold time of 3ns.
Verilog Digital 56
System Design
Hold Time
The Verilog $setuphold task combines setup and hold timing checks.
Example:
$setuphold (posedge clk, d, 5, 3)
Verilog Digital 57
System Design
Width And Period
Flip-flop
Timing
Width
Setup Hold
And
Time Time
Period
Verilog Digital 58
System Design
Width And Period
Verilog $width and $period check for minimum pulse width and period.
Verilog Digital 59
System Design
Width And Period
specify
$setuphold ( posedge clk, d, 5, 3 );
$width (posedge r, 4);
$width (posedge s, 4);
$period (negedge clk, 43);
endspecify
Component
Description
Data
Controllers
Controllers
Components
Verilog Digital 61
System Design
Controllers
Decisions
Based on :Inputs ,
Outputs ,State
Go to Next State
Controller Outline
Verilog Digital 62
System Design
Controllers
Controller:
Is wired into data part to control its flow of data.
Monitors its inputs and makes decisions as to when and what output
signals to assert.
Keeps the history of circuit data by switching to appropriate states.
Sequence Detector
Verilog Digital 63
System Design
Controllers
Controllers
Sequence
Synchronizer
Detector
Verilog Digital 64
System Design
Synchronizer
Controllers
Sequence
Synchronizer
Synthesizer
Detector
Verilog Digital 65
System Design
Synchronizer
Clk
adata
synched
Synchronizing adata
Verilog Digital 66
System Design
Synchronizer
`timescale 1ns/100ps
Verilog Digital 67
System Design
Sequence Detector
Controllers
Sequence
Sequence
Synthesizer
Detector
Detector
Verilog Digital 68
System Design
Sequence Detector
When the sequence
Searches on is detected, the w
it’s a input Output becomes 1
for the and stays 1 for a
110 Sequence complete clock cycle
If 110 is detected
a on a, then w gets w
1, else w gets 0.
clk
State Machine Description
Verilog Digital 69
System Design
Sequence Detector
A Moore Machine
Sequence Detector
States are named: The State in which
s0 , s1 , s2 , s3 the 110 sequence is
detected.
0 1
reset
1 1 0
S0 S1 S2 S3
0 0 0 0 1
1
Initia
l 0
State
It Takes at least
3 clock periods to
get to the s3 state
Sequence Detector State Machine
Verilog Digital 70
System Design
Sequence Detector
module Detector110 (input a, clk, reset, output w);
parameter [1:0] s0=2'b00, s1=2'b01, s2=2'b10, s3=2'b11;
reg [1:0] current;
endmodule
State Machine
Coding
A ROM Based
Controller
Verilog Digital 72
System Design
Moore Machines
State Machine
Coding
A ROM Based
Controller
Verilog Digital 73
System Design
Moore Machines
Moore Machine :
A state machine in which all outputs are carefully synchronized
with the circuit clock.
In the state diagram form, each state of the machine specifies its
outputs independent of circuit inputs.
In Verilog code of a state machine, only circuit state variables
participate in the output expression of the circuit.
Verilog Digital 74
System Design
Mealy Machines
State Machine
Coding
A ROM Based
Controller
Verilog Digital 75
System Design
Mealy Machines
Mealy Machine :
Is different from a Moore machine in that its output depends on its
current state and inputs while in that state.
State transitions and clocking and resetting the machine are no
different from those of a Moore machine. The same coding
techniques are used.
Verilog Digital 76
System Design