Verlogic3 Chapter5
Verlogic3 Chapter5
Flip-Flops, Registers, and Counters
Set
Sensor
Memory On ⁄ Off
Alarm
element
Reset
Set Q
t1 t2 t3 t4 t5 t6 t7 t8 t9 t 10
1
R
0
1
S
0
1
Qa ?
0
1
Qb ?
0
Time
(c) Timing diagram
Clk
Q
R
Clk
P1
2
5 Q
Clock
P2 6 Q
3
D Q
4 P4 Clock Q
D
Clock
(a) Circuit
J K Q ( t + 1)
0 0 Q (t) J Q
0 1 0
1 0 1
K Q
1 1 Q (t )
Clock Q Q Q Q
(a) Circuit
In Q1 Q2 Q3 Q4 = Out
t0 1 0 0 0 0
t1 0 1 0 0 0
t2 1 0 1 0 0
t3 1 1 0 1 0
t4 1 1 1 0 1
t5 0 1 1 1 0
t6 0 0 1 1 1
t7 0 0 0 1 1
Clock Q Q Q
Q0 Q1 Q2
(a) Circuit
Clock
Q0
Q1
Q2
Count 0 1 2 3 4 5 6 7 0
Clock Q Q Q
Q0 Q1 Q2
(a) Circuit
Clock
Q0
Q1
Q2
Count 0 7 6 5 4 3 2 1 0
(a) Circuit
Clock
Q0
Q1
Q2
Q3
Count 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1
Clock Q Q Q Q
Clear_n
(a) Circuit
Clock
Q0
Q1
Q2
Count 0 1 2 3 4 5 0 1
Clock Q Q Q
(a) Circuit
Clock
Q0
Q1
Q2
Count 0 1 2 3 4 5 0 1 2
Latch
endmodule
endmodule
endmodule
Clock Q
D Q Q2
endmodule
Clock Q Q
endmodule
x1 D Q g
x2
Q
D Q f
Clock Q
endmodule
x1
D Q f
x2
Clock Q
endmodule
endmodule
endmodule
endmodule
Figure 5.47. Code for a D flip-flop with a 2-to-1 multiplexer on the D input.
module muxdff (D0, D1, Sel, Clock, Q);
input D0, D1, Sel, Clock;
output reg Q;
!
wire D;
assign D = Sel ? D1 : D0;
!
always @(posedge Clock)
Q <= D;
endmodule
Figure 5.48. Alternative code for a D flip-flop with a 2-to-1 multiplexer on the D input.
module shift4 (R, L, w, Clock, Q);
input [3:0] R;
input L, w, Clock;
output [3:0] Q;
wire [3:0] Q;
endmodule
endmodule
endmodule
endmodule
endmodule
endmodule
endmodule
endmodule
endmodule
Figure 5.62. Code for the two-digit BCD counter in Figure 5.27.
Figure 5.63. Code for the BCD-to-7-segment decoder.
Figure 5.64. Code for the reaction timer.
Figure 5.65. Simulation of the reaction-timer circuit.
Figure 5.66. A simple flip-flop circuit.
Please see “portrait orientation” PowerPoint file for Chapter 5
endmodule
1 T Q T Q T Q
Clock Q Q Q
K R Q R Q Q
Interval
100 ns
Clock
Q
A
Clock 1
0
1
D
0
A 1
0
Q 1
0
1
Start
0
1
f
0
1
g
0
endmodule
endmodule
endmodule
endmodule