Chapter 4 - HDL Modelling of Sequential Logic Circuit
Chapter 4 - HDL Modelling of Sequential Logic Circuit
VERILOG DESIGN of
SEQUENTIAL LOGIC
Dr. Ahmad Fariz Bin Hasan
Electronic Engineering Programme, FKTEN
1
Verilog Design of Sequential Logic 2023/2024
2
Verilog Design of Sequential Logic 2023/2024
changes in the data input will change the state of the latch.
o A flipflop (FF) is an edge-triggered memory device.
3
Verilog Design of Sequential Logic 2023/2024
D Latch
4
Verilog Design of Sequential Logic 2023/2024
• The always blocks are sensitive to the levels of the signals that
appear in the sensitivity list.
• FF changes only as a result of a clock transition of the clock
signal, rather than its level.
• Verilog uses event qualifier posedge and negedge
o E.g. always @ (posedge clock).
5
Verilog Design of Sequential Logic 2023/2024
module FF (CLK, d, q) ;
input CLK, d ;
output q ; d D
reg q ; f/f Q q
CLK
always @ (posedge CLK) q
=d;
endmodule
8
Verilog Design of Sequential Logic 2023/2024
9
Verilog Design of Sequential Logic 2023/2024
D C B A
d q d q d q
clk
10
Verilog Design of Sequential Logic 2023/2024
Recommendation:
11
Verilog Design of Sequential Logic 2023/2024
12
Verilog Design of Sequential Logic 2023/2024
CLK
always @ (posedge CLK) C
endmodule
13
Verilog Design of Sequential Logic 2023/2024
Registers
15
Verilog Design of Sequential Logic 2023/2024
clk
pst
rst
load
17
Verilog Design of Sequential Logic 2023/2024
Shift registers
module shiftLreg8 (clk, rst, en, ldsh, w, always @ (negedge rst or posedge clk)
d, q) ; begin if
input [7:0] d ; ( !rst )
input clk, rst, en, ldsh, w ; q <= 0 ;
output [7:0] q ; else if ( en )
integer k; if ( ldsh )
q <= d;
.... else
begin
q[0] <= w;
for ( k = 1; k <8; k = k+1 )
q[k] <= q[k – 1];
end
end
endmodule
18
Verilog Design of Sequential Logic 2023/2024
...
for ( k = 0; k < 7; k = k+1 )
q[k] <= q[k + 1] ;
q[7] <= w ;
...
19
Verilog Design of Sequential Logic 2023/2024
...
module univShiftReg (MSBin, LSBin, always @ (negedge clock)
s1, s0, clock, rst, DataIn, MSBout, begin
LSBout, DataOut) if ( rst ) // synchronous reset
input MSBin, LSBin, s1, s0 ; DataOut <= 0 ;
input clock, rst ; else
input [3:0] Datain ; case ( {s1, s0} )
output MSBout, LSBout ; 2’b00 : DataOut <= DataOut ; // hold
output [3:0] Dataout ; // shift right
2’b01 : DataOut <= { MSBin,DataOut[3:1] } ;
reg [3:0] Dataout ; // shift left
2’b10 : DataOut <= { DataOut[2:0], LSBin };
assign MSBout = DataOut[3] ; 2’b11 : DataOut <= DataIn ; // parallel load
assign LSBout = DataOut[0] ; endcase
... end
endmodule
20
Verilog Design of Sequential Logic 2023/2024
Exercise:
⋅
21
Verilog Design of Sequential Logic 2023/2024
Synchronous Counters
Exercise: Provide the I/O block diagram, and derive the operations
table for this counter.
24
Verilog Design of Sequential Logic 2023/2024
Example:
25
Verilog Design of Sequential Logic 2023/2024
Example:
begin
Q1 <= PB; PB_Pulse
Q2 <= Q1;
end
26
Verilog Design of Sequential Logic 2023/2024
27
Verilog Design of Sequential Logic 2023/2024
28