0% found this document useful (0 votes)
29 views27 pages

Chapter 05 Sequential Circuits

This document discusses sequential circuits and provides examples of RS latches, JK flip-flops, D latches, D flip-flops, T flip-flops, shift registers, and counters implemented using Verilog HDL. Shift registers are demonstrated with both serial input/serial output and serial input/parallel output configurations. Counters are shown using T flip-flops. Module instantiation techniques including connection by name and ordered connection are also reviewed.

Uploaded by

Nguyen Yen Nhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views27 pages

Chapter 05 Sequential Circuits

This document discusses sequential circuits and provides examples of RS latches, JK flip-flops, D latches, D flip-flops, T flip-flops, shift registers, and counters implemented using Verilog HDL. Shift registers are demonstrated with both serial input/serial output and serial input/parallel output configurations. Counters are shown using T flip-flops. Module instantiation techniques including connection by name and ordered connection are also reviewed.

Uploaded by

Nguyen Yen Nhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Chapter 5: Sequential Circuits

Trương Ngọc Sơn, Ph.D


RS Latch

2 Combinational circuit
RS Latch
• Verilog HDL
module RS_LATCH(
input wire R,S,CLK,
output reg Q,Qb
);
always @(R,S,CLK) begin
if/*((CLK==1)&&(S==0)&&(R==1))*/({CLK,S,R}
==3'b101) begin Q=0;Qb=1;end
else if ((CLK==1)&&(S==1)&&(R==0)) begin
Q=1;Qb=0;end
end
endmodule
3 Combinational circuit
JK Flip Flop
Input Output
Pre CLR CLK J K Q QD
0 0 x x x 1 1
0 1 x x x 1 0
1 0 x x x 0 1
1 1 0 x x Qo QDo
1 1 0 0 Qo QDo
1 1 0 1 0 1
1 1 1 0 1 0
1 1 1 1 NOT Q NOT QD

4 Combinational circuit
JK Flip Flop
• Verilog HDL

5 Combinational circuit
D Latch

6 Combinational circuit
D Latch
• Verilog HDL

7 Combinational circuit
D Flip-Flop

8 Combinational circuit
D Flip-Flop
• The difference between a latch and a flip-flop is
that a latch is asynchronous, and the outputs can
change as soon as the inputs do (or at least after a
small propagation delay). A flip-flop, on the other
hand, is edge-triggered and only changes state
when a control signal goes from high to low or
low to high

9 Combinational circuit
10 Verilog HDL Basics
T Flip-Flop

11 Combinational circuit
T Flip-Flop

module T_FF(
input wire t, clk,
output reg q, qb );
initial
begin
q=1 ;
qb=0;
end
always @( posedge clk)
if (t) begin
q = ~q ;
qb = !qb;
end
endmodule

12 Combinational circuit
Shift Register

13 Combinational circuit
Shift Register
• Instance shift register using D-FF.
module DFF(
input wire d,clk,
output reg q );
always @(posedge clk)
q=d;
endmodule
// Serial input - serial output using DFF
module SISO(
input wire in, clk,
output wire out) ;
// signal declaration
wire q1,q2,q3 ;
//module instance
DFF ff1 (in,clk,q1);
DFF ff2 (q1,clk,q2);
DFF ff3 (q2,clk,q3);
DFF ff4 (q3,clk,out);
endmodule
14 Combinational circuit
Module instance review
• Modules can be instantiated from within other modules.
When a module is instantiated, connections to the ports
of the module must be specified.
• There are two ways to make port connections.
– Connection by name, in which variables connected to each of
module inputs or outputs are specified in a set of parenthesis
following the name of the ports. In this method order of
connections is not significant.
– Ordered connection. In this method the order of the ports must
match the order appearing in the instantiated module.

15 Combinational circuit
Module instance review
• Connection by name
module dff (
input wire clk, d,
output reg q );
top
always @(posedge clk) q = d; d_in
endmodule Inst_1 q_out
Inst_2
n1
d q d q
module top (
clk
input wire d_in, clk, clk clk
output wire q_out);

wire n1;
dff Inst_1 (.d(d_in), .q(n1), .clk(clk));
dff Inst_2 (.clk(clk), .d(n1), .q(q_out));
endmodule

16 Combinational circuit
Module instance review
• Connection by order
module dff (
input wire clk, d,
top
output reg q );
d_in
always @(posedge clk) q = d;
Inst_1 q_out
Inst_2
endmodule n1
d q d q
module top ( clk
input wire d_in, clk, clk clk
output wire q_out);
wire n1;

dff Inst_1 (clk, d_in, n1);


dff Inst_2 (clk, n1, q_out);
endmodule

17 Combinational circuit
Thanasis Oikonomou 18 Verilog HDL Basics
Shift Register – Serial input, parallel outputs
• Instance the shift register using D-FF

19 Combinational circuit
Shift Register – Serial input parallel outputs
module DFF(
input wire d,clk,
output reg q );
always @(posedge clk)
q=d;
endmodule
// Serial input - parallel output using DFF
module SIPO(
input wire in, clk,
output wire [3:0] q) ;
// signal declaration

//module instance
DFF ff1 (in,clk,q[0]);
DFF ff2 (q[0],clk,q[1]);
DFF ff3 (q[1],clk,q[2]);
DFF ff4 (q[2],clk,q[3]);
endmodule

20 Combinational circuit
Counter

21 Combinational circuit
Asynchronous Counter

22 Combinational circuit
Counter
• Instance counter with T-FF

23 Combinational circuit
Synchronous counter

Thanasis Oikonomou 24 Verilog HDL Basics


Counter
• Instance counter with T-FF

25 Combinational circuit
26 Verilog HDL Basics
Homework
• Design a circuit to control 8 LEDs
– Light LEDS sequentially from left to right then turn 8
LEDs off sequentially from left to right (one-by-one).
– The frequency is adjusted by two switches
– The input clock is 50Mhz

27 Verilog HDL Basics

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy