Professional Documents
Culture Documents
http://www.syssec.ethz.ch/education/Digitaltechnik_17
1
Adapted from Digital Design and Computer Architecture, David Money Harris & Sarah L. Harris ©2007 Elsevier
Carnegie Mellon
2
Carnegie Mellon
Introduction
¢ Outputs of sequential logic depend on current and prior
input values – it has memory.
¢ Sequential Circuits:
§ Give sequence to events which allows ordering of operations
§ Need a special circuit to store the current state of circuit
3
Carnegie Mellon
outputs
inputs
Combinational
Circuit
Memory
Element
0 1 0 = State 0
5
Carnegie Mellon
1 0 1 = State 1
6
Carnegie Mellon
7
Carnegie Mellon
8
Carnegie Mellon
The D Latch
¢ D Latch is the basic bi-stable circuit used in modern CMOS.
§ The clock controls the switches. Only one is active at a time.
§ Traditionally the input is called D (Data) and the output Q
𝑫 𝑸
𝑪𝒍𝒌
9
Carnegie Mellon
𝑫 𝑸 𝑸 𝑸
10
Carnegie Mellon
𝑫 𝑸 𝑸 𝑸
𝑫 𝑫 𝑫 𝑫
11
Carnegie Mellon
Summary D Latch
¢ Simple bi-stable circuit
§ Can be used to store a 0 or a 1.
12
Carnegie Mellon
13
Carnegie Mellon
14
Carnegie Mellon
¢ D passes through to Q
15
Carnegie Mellon
Registers
¢ Multiple parallel flip-flops that store more than 1 bit
CLK
D0 D Q Q0
CLK
D1 D Q Q1
4 4
D3:0 Q3:0
D2 D Q Q2
D3 D Q Q3
16
Carnegie Mellon
Enabled Flip-Flops
¢ Inputs: CLK, D, EN
§ The enable input (EN) controls when new data (D) is stored
¢ Function
§ EN = 1: D passes through to Q on the clock edge
§ EN = 0: the flip-flop retains its previous state
Internal
Circuit Symbol
EN CLK
0
D Q Q D Q
D 1
EN
17
Carnegie Mellon
Resettable Flip-Flops
¢ Inputs: CLK, D, Reset
§ The Reset is used to set the output to 0.
¢ Function:
§ Reset = 1: Q is forced to 0
§ Reset = 0: the flip-flop behaves like an ordinary D flip-flop
Symbols
D Q
r
Reset
18
Carnegie Mellon
Resettable Flip-Flops
¢ Two types:
§ Synchronous: resets at the clock edge only
§ Asynchronous: resets immediately when Reset = 1
19
Carnegie Mellon
Resettable Flip-Flops
¢ Two types:
§ Synchronous: resets at the clock edge only
§ Asynchronous: resets immediately when Reset = 1
D
D Q Q
Reset
20
Carnegie Mellon
Settable Flip-Flops
¢ Inputs: CLK, D, Set
¢ Function:
§ Set = 1: Q is set to 1
§ Set = 0: the flip-flop behaves like an ordinary D flip-flop
Symbols
D Q
s
Set
21
Carnegie Mellon
23
Carnegie Mellon
24
Carnegie Mellon
CLK
M next
next k state k output N
inputs state
state
outputs
logic
logic
Mealy FSM
CLK
M next
next k state k state output N
inputs state outputs
logic
logic
25
Carnegie Mellon
Dining
Hall
LB
LA TB
LA
Academic TA TA Ave.
Labs TB LB Dorms
Blvd.
Fields
26
Carnegie Mellon
¢ Outputs: LA, LB
CLK
TA Traffic LA
Light
TB Controller LB
Reset
27
Carnegie Mellon
28
Carnegie Mellon
Dining S0 TA S1
Hall LA: green LA: yellow
LB LB: red LB: red
LA TB
LA
Academic TA TA Ave.
Labs TB LB Dorms S3 S2
LA: red LA: red
LB: yellow LB: green
Blvd.
TB
Fields TB
29
Carnegie Mellon
30
Carnegie Mellon
31
Carnegie Mellon
32
Carnegie Mellon
33
Carnegie Mellon
36
Carnegie Mellon
37
Carnegie Mellon
38
Carnegie Mellon
LA1 = S1
LA0 = S1 · S0
LB1 = S1
LB0 = S1 · S0
39
Carnegie Mellon
S'0 S0
r
Reset
state register
40
Carnegie Mellon
TA S'0 S0
r
TB Reset
S1 S0
41
Carnegie Mellon
TA S'0 S0
LB1
r
TB Reset
S1 S0 LB0
42
Carnegie Mellon
TA
Reset
S3 S2
LA: red LA: red
LB: yellow LB: green
TB
TB
Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10
CLK
Reset
TA
TB
0 5 10 15 20 25 30 35 40 45 t (sec)
43
Carnegie Mellon
¢ One-hot encoding
§ One state bit per state
§ Only one state bit is HIGH at once
§ I.e., for four states, 0001, 0010, 0100, 1000
§ Requires more flip-flops
§ Often next state and output logic is simpler
44
Carnegie Mellon
CLK
M next
next k state k output N
inputs state
state
outputs
logic
logic
Mealy FSM
CLK
M next
next k state k state output N
inputs state outputs
logic
logic
45
Carnegie Mellon
S0 S1 S2 S3 S4
0 0 0 0 1
0
1 0 0
0
S0 S1 S2 S3
0/0 1/0 0/0
0/0
46
Carnegie Mellon
http://www.syssec.ethz.ch/education/Digitaltechnik_17
48
Adapted from Digital Design and Computer Architecture, David Money Harris & Sarah L. Harris ©2007 Elsevier
Carnegie Mellon
This week
¢ Sequential circuit description in Verilog
outputs
inputs
Combinational
Circuit
Memory
Element
51
Carnegie Mellon
52
Carnegie Mellon
Example: D Flip-Flop
module flop(input clk,
input [3:0] d,
output reg [3:0] q);
endmodule
53
Carnegie Mellon
Example: D Flip-Flop
module flop(input clk,
input [3:0] d,
output reg [3:0] q);
endmodule
54
Carnegie Mellon
Example: D Flip-Flop
module flop(input clk,
input [3:0] d,
output reg [3:0] q);
endmodule
55
Carnegie Mellon
Example: D Flip-Flop
module flop(input clk,
input [3:0] d,
output reg [3:0] q);
endmodule
¢ The name reg does not necessarily mean that the value is
a register. (It could be, it does not have to be).
56
Carnegie Mellon
57
Carnegie Mellon
Example: D Latch
module latch (input clk,
input [3:0] d,
output reg [3:0] q);
always @ (clk, d)
if (clk) q <= d; // latch is transparent when
// clock is 1
endmodule
lat
[3:0] [3: 0]
d[3:0] D[3:0] [3:0] [ 3: 0]
Q[ 3:0] q[3:0]
clk C
q[3:0]
62
Carnegie Mellon
63
Carnegie Mellon
66
Carnegie Mellon
67
Carnegie Mellon
endmodule
68
Carnegie Mellon
endmodule
70
Carnegie Mellon
endmodule
71
Carnegie Mellon
endmodule
72
Carnegie Mellon
73
Carnegie Mellon
75
Carnegie Mellon
76
Carnegie Mellon
¢ At the end, s = 1
77
Carnegie Mellon
78
Carnegie Mellon
79
Carnegie Mellon
80
Carnegie Mellon
81
Carnegie Mellon
82
Carnegie Mellon
CLK
M next
next k state k output N
inputs state
state
outputs
logic
logic
83
Carnegie Mellon
84
Carnegie Mellon
The output Y is HIGH for one clock cycle out of every 3. In other
words, the output divides the frequency of the clock by 3.
85
Carnegie Mellon
parameter S0 = 2'b00;
parameter S1 = 2'b01;
parameter S2 = 2'b10;
86
Carnegie Mellon
S’ S
Next Current
State State
87
Carnegie Mellon
88
Carnegie Mellon
89
Carnegie Mellon
parameter S0 = 2'b00;
parameter S1 = 2'b01;
parameter S2 = 2'b10;
90
Carnegie Mellon
Moore
Mealy
91
Carnegie Mellon
parameter S0 = 2'b00;
parameter S1 = 2'b01;
parameter S2 = 2'b10;
parameter S3 = 2’b11;
a/y
92
Carnegie Mellon
93
Carnegie Mellon
94
Carnegie Mellon
95
Carnegie Mellon
96
Carnegie Mellon
¢ Always statement
§ Is needed for defining memorizing elements (flip-flops, latches)
§ Can also be used to define combinational circuits
¢ Writing FSMs
§ Next state calculation
§ Determining outputs
§ State assignment
97
Carnegie Mellon
Tomorrow…
¢ Timing in Combinational circuits
§ Propagation and Contamination Delays
99