SlideShare a Scribd company logo
1 of 66
Download to read offline
1
Chapter 6 Registers and Counter
n The filp-flops are essential component in
clocked sequential circuits.
n Circuits that include filp-flops are usually
classified by the function they perform. Two
such circuits are registers and counters.
n An n-bit register consists of a group of n flip-
flops capable of storing n bits of binary
information.
2
6-1 Registers
n In its broadest definition, a register consists
a group of flip-flops and gates that effect
their transition.
n The flip-flops hold the binary information.
n The gates determine how the information is
transferred into the register.
n Counters are a special type of register.
n A counter goes through a predetermined
sequence of states.
3
6-1 Registers
n Fig 6-1 shows a
register constructed
with four D-type
filpflops.
n “Clock” triggers all flip-
folps on the positive
edge of each pulse.
n “Clear” is useful for
clearing the register to
all 0’s prior to its
clocked operation.
4
Register with Parallel Load
n A clock edge applied to the C inputs of the
register of Fig. 6-1 will load all four inputs in
parallel.
n For synchronism, it is advisable to control
the operation of the register with the D
inputs rather than controlling the clock in the
C inputs of the flip-flops.
n A 4-bit register with a load control input that
is directed through gates and into the D
inputs of the flip-flops si shown in Fig. 6-2.
5
Register with Parallel Load
6
Register with Parallel Load
n When the load input is 1 , the data in the
four inputs are transferred into the register
with next positive edge of the clock.
n When the load input is 0 ,the outputs of the
flip-flops are connected to their respective
inputs.
n The feedback connection from output to
input is necessary because the D flip-flops
does not have a “no change” condition.
7
6-2 Shift Registers
n A register capable of shifting its binary
information in one or both direction is called
a shift register.
n All flip-flops receive common clock pulses,
which activate the shift from one stage to
the next.
n The simplest possible shift register is one
that uses only flip-flops, as shown in Fig. 6-3.
8
Shift Registers
9
Shift Registers
n Each clock pulse shifts the contents of the
register one bit position to the right.
n The serial input determines what goes into
the leftmost flip-flop during the shift.
n The serial output is taken from the output of
the rightmost flip-flop.
10
Serial Transfer
n A digital system is said tp operate in a serial
mode when information is transferred and
manipulated one bit at a time.
n This in contrast to parallel transfer where all
the bits of the register are transferred at the
same time.
n The serial transfer us done with shift
registers, as shown in the block diagram of
Fig. 6-4(a).
11
Serial Transfer
12
Serial Transfer
n To prevent the loss of information stored in
the source register, the information in
register A is made to circulate by connecting
the serial output to its serial input.
n The shift control input determines when and
how many times the registers are shifted.
This is done with an AND gate that allows
clock pulses to pass into the CLK terminals
only when the shift control is active. [Fig. 6-
4(a)].
13
Serial Transfer
14
Serial Transfer
n The shift control signal is synchronized with
the clock and changes value just after the
negative edge of the clock.
n Each rising edge of the pulse causes a shift
in both registers. The fourth pulse changes
the shift control to 0 and the shift registers
are disabled.
15
Serial Transfer
Table 6-1
Serial-Transfer Example
1 0 0 1
1 1 0 1
After T1
0 0 1 0
1 0 1 1
Initial value
1 0 1 1
1 0 1 1
After T4
0 1 1 0
0 1 1 1
After T3
1 1 0 0
1 1 1 0
After T2
Shift Register B
Shift Register A
Timing Pulse
16
Serial Transfer
n In the parallel mode, information is available
from all bits can be transferred
simultaneously during one clock pulse.
n In the serial mode, the registers have a
single serial input and a single serial output.
The information us transferred one bit at a
time while the registers are shifted in the
same direction.
17
Serial Addition
n Operations in digital computers are usually
done in parallel because this is a faster
mode of operation.
n Serial operations are slower, but have the
advantage of requiring less equipment.
n The two binary numbers to be added serially
are stored in two shift registers.
n Bits are added one pair at a time through a
single full adder. [Fig. 6-5]
18
Serial Addition
19
Serial Addition
n By shifting the sum into A while the bits of A
are shifted out, it is possible to use one
register for storing both the augend and sum
bits.
n The carry out of the full adder is transferred
to a D flip-flop.
n The output of the D flip-flop is then used as
carry input for the next pair of significant
bits.
20
Serial Addition
n To show that serial operations can be
designed by means of sequential circuit
procedure, we will redesign the serial adder
using a state table.
n The serial outputs from registers are
designated by x and y.
n The sequential circuit proper has two inputs,
x and y, that provide a pair of significant bits,
an output S that generates the sum bit, and
flip-flop Q for storing the carry. [Table. 6-2]
21
Serial Addition
Table 6-2
State Table for serial Adder
0
X
1
1
1
1
1
0
X
0
1
0
1
1
0
X
0
1
1
0
1
1
X
1
0
0
0
1
X
1
0
1
1
1
0
X
0
1
0
0
1
0
X
0
1
0
1
0
0
X
0
0
0
0
0
0
KQ
JQ
S
Q
y
X
Q
Flip-Flop
Inputs
Output
Next State
Inputs
Present
State
22
Serial Addition
n The two flip-flop input equations and the
output equation can be simplified by means
of map to obtain
n JQ=xy
n KQ=x’y’=(x+y)’
n S=x⊕y⊕Q
n The circuit diagram is shown in [Fig. 6-6]
23
Serial Addition
24
Universal Shift Register
n A clear control to clear the register to 0.
n A clock input to synchronize the operations.
n A shift-right control to enable the shift
operation and the serial input and output lines
associated with the shift right.
n A shift-left control to enable the shift
operation and the serial input and output lines
associated with the shift left.
25
Universal Shift Register
n A parallel-load control to enable a parallel transfer
and the n input lines associated with the parallel
transfer.
n n parallel output lines.
n A control state that leaves the information in the
register unchanged in the presence of the clock.
n If the register has both shifts and parallel load
capabilities, it is referred to as a universal shift
register.
26
Universal Shift Register
27
Universal Shift Register
Parallel load
1
1
Shift Left
0
1
Shift right
1
0
No Change
0
0
S0
S1
Register Operation
Mode Control
Table 6-3
Function Table for the Register of Fig. 6-7
28
Universal Shift Register
n Shift registers are often used to interface
digital system situated remotely from each
other.
n If the distance is far, it will be expensive to
use n lines to transmit the n bits in parallel.
n Transmitter performs a parallel-to-serial
conversion of data and the receiver does a
serial-to-parallel conversion.
29
6-3 Ripple Counters
n A register that goes through a prescribed
sequence of states upon the application of
input pulse is called a counter.
n A counter that follows the binary number
sequence is called a binary counter.
n Counters are available in two categories
n Ripple counters
n Synchronous counters
30
Binary Ripple Counter
n The output of each flip-flop is connected to
the C input of the next flip-flop in sequence.
n The flip-flop holding the last significant bit
receives the incoming count pulse.
n A complementing flip-flop can be obtained
from:
n JK flip-flop with the J and K inputs tied together.
n T flip-flop
n D flip-flop with the complement output
connected to the D input. [Fig. 6-8]
31
Binary Ripple Counter
32
Binary Ripple Counter
1
1
1
0
0
0
0
1
0
1
1
0
1
0
1
0
0
0
1
0
1
1
0
0
0
1
0
0
1
0
0
0
0
0
0
0
A0
A1
A2
A3
Table 6-3
Function Table for the Register of Fig. 6-7
33
BCD Ripple Counter
n A decimal counter follows a sequence of ten
states and returns to 0 after the count of 9.
n This is similar to a binary counter, except
that the state after 1001 is 0000.
n The operation of the counter can be
explained by a list of conditions for flip-flop
transitions.
34
BCD Ripple Counter
35
BCD Ripple Counter
n The four outputs are
designated by the
letter symbol Q with a
numeric subscript
equal to the binary
weight of the
corresponding bit in
the BCD code.
36
BCD Ripple Counter
n The BCD counter of [Fig. 6-9] is a decade
counter.
n To count in decimal from 0 to 999, we need
a three-decade counter. [Fig. 6-11]
n Multiple decade counters can be constructed
by connecting BCD counters ic cascade, one
for each decade.
37
BCD Ripple Counter
38
6-4 Synchronous Counters
n Synchronous counters are different from
ripple counters in that clock pulses are
applied to the inputs of all flip-flops.
n A common clock triggers all flip-flops
simultaneously rather than one at a time in
succession as in a ripple counter.
39
Binary Counter
n The design of a
synchronous binary
counter is so simple that is
no need to go through a
sequential logic design
process.
n Synchronous binary
counters have a regular
pattern and can be
constructed with
complementing flip-flop
and gates
40
Up-Down Binary Counter
n The two operations can
be combined in one
circuit to form a
counter capable of
counting up or down.
n It has an up control
input and down control
input.
41
BCD Counter
n Because of the return to 0 after a count of 9,
a BCD counter does not have a regular
pattern as in a straight binary count.
n To derive the circuit of a BCD synchronous
counter, it is necessary to go through a
sequential circuit design procedure.
42
BCD Counter
Table 6-5
State Table for BCD Counter
1
0
0
0
1
0
0
0
0
1
0
0
1
1
0
0
0
0
1
0
0
1
0
0
0
1
1
1
1
1
0
0
0
0
1
1
1
1
0
1
0
0
0
0
1
1
1
0
0
1
1
0
1
1
0
0
0
0
1
1
0
1
0
1
0
1
0
0
0
0
1
0
1
0
0
0
1
0
1
1
1
0
0
0
0
1
0
1
1
0
0
1
0
0
0
0
1
1
0
0
0
1
0
0
1
1
0
0
0
0
1
0
0
1
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
TQ1
TQ2
TQ4
TQ8
Y
Q1
Q2
Q4
Q8
Q1
Q2
Q4
Q8
Flip-Flop inputs
Output
Next State
Present State
43
BCD Counter
n The flip flop input equations can be
simplified by means of maps. The simplified
functions are
n TQ1=1
n TQ2=Q8’
Q1
n TQ4=Q2Q1
n TQ8=Q8Q1+Q4Q2Q1
n y=Q8Q1
n The circuit can be easily drawn with four T
flip-flops, five AND gates, and one OR gate.
44
Binary Counter with Parallel Load
n Counters employed in digital systems quite
often require a parallel load capability for
transferring an initial binary number into the
counter prior to count operation.
n The input load control when equal to 1
disables the count operation and causes a
transfer of data from the four data inputs
into the four flip-flops [Fig. 6-14]
45
Binary Counter with Parallel Load
46
Binary Counter with Parallel Load
0
0
1
X
Load
No change
0
↑
1
Count next binary state
1
↑
1
Load inputs
X
↑
1
Clear to 0
X
X
0
Function
Count
CLK
Clear
Table 6-6
Function Table for the Counter of Fig. 6-14
47
Binary Counter with Parallel Load
n A counter with parallel load can be used to
generate any desire count sequence.
n [Fig.6-15] shows two ways in which a
counter with parallel load is used to generate
the BCD count.
48
Binary Counter with Parallel Load
49
6-5 Other Counters
n Counters can be designed generate any
desire sequence of states.
n Counters are used to generate riming signals
to control the sequence of operations in a
digital system.
n Counters can be constructed also by means
of shift registers.
50
Counter with Unused States
n Once the circuit is designed and constructed,
outside interference may cause the circuit to
enter one of the unused state.
n If the unused states are treated as don’t-
care conditions, then once the circuit is
designed, it must be investigated to
determine the effect of the unused states
n The next state from an unused state can be
determined from the analysis of the circuit
after it is design.
51
Counter with Unused States
X
0
1
X
1
X
0
0
0
0
1
1
1
X
X
1
0
X
0
1
1
1
0
1
X
1
X
0
0
X
1
0
1
0
0
1
X
0
1
X
X
1
0
0
1
0
1
0
1
X
X
1
X
0
0
1
0
1
0
0
X
1
X
0
X
0
1
0
0
0
0
0
KC
JC
KB
JB
KA
JA
C
B
A
C
B
A
Flip-Flop Inputs
Next state
Present State
Table 6-7
State Table for Counter
52
Counter with Unused States
n The count has a repeated sequence of six
states.
n The simplified equations are:
n JA=B KA=B
n JB=C KB=1
n JC=B’ KC=1
n The logic diagram and state diagram is
shown in [Fig. 6-16]
53
Counter with Unused States
54
Ring Counter
n A ring counter is a circular shift register with
only one flip-flop being set at any particular
time, all others are cleared.
n The single bit is shifted from one flip-flop to
the next to produce the sequence of timing
signals. [Fig. 6-17(a)] [Fig. 6-17(c)]
n The decoder shown in [Fig. 6-17(b)]
decodes the four states of the counter and
generates the required sequence of timing
signals
55
Ring Counter
56
Johnson Counter
n Generate the timing signals with a
combination of a shift register and a decoder,
which is called a Johnson counter.
n The number of states can be double if the
shift register is connect as a switch-tail ring
counter. [Fig. 6-18(a)]
n Starting from a cleared state, the switch-tail
ring counter goes through a sequence of
eight states, as shown in [Fig. 6-18(b)].
57
Johnson Counter
58
Johnson Counter
n A Johnson counter is a k-bit switch-tail ring
counter with 2k decoding gates to provide
outputs for 2k timing signals.
n The decoding of a k-bit switch-tail ring
counter to obtain 2k timing signals follows a
regular pattern.
n Johnson counters can be constructed for any
number of timing sequences.
59
6-6 HDL for Registers and
Counters
n Registers and counters can be describe in
HDL at either the behavioral or the structural
level.
n The various components are instantiated to
form a hierarchical description of the design
similar to a representation of a logic diagram.
60
Shift Register
//Behavioral description of universal shift register Fig. 6-7 and Table 6-3
Module shftreg (s1,s0,Pin,lfin,rtin,A,CLK,Clr);
input s1,s0 //Select inputs
input lfin, rtin; //Serial inputs
input CLk, clr; //Clock and Clear
input [3:0] Pin; //Parallel input
output [3:0] A; //Register output
reg [3:0] A;
always @ (posedge CLK or negedge Clr)
if (~Clr) A = 4’ b0000’
else
case ({s1,s0}) //No change
2’ b00: A = A; //Shift right
2’ b01: A = {rtin,A[3:1]}; //Shift left
2’ b10: A = {A[2:0],lfin}; //Parallel load input
2’ b11: A =Pin;
endcase
endmodule
61
Shift Register
//Structural description of Universal shift register(see Fig.6-7)
module SHFTREG (I,select,lfin,rtin,A,CLK,Clr);
input [3:0] I; //Parallel input
input [1:0] select; //Mode select
input lfin,rtin,CLK,Clr; //Serial inputs,clock,clear
output [3:0] A; //Parallel output
//Instantiate the four stages
stage ST0 (A[0],A[1],lfin,I[0],A[0],select,CLK,Clr);
stage ST1 (A[1],A[2],A[0],I[1],A[1],select,CLK,Clr);
stage ST2 (A[2],A[3],A[1],I[2],A[2],select,CLK,Clr);
stage ST3 (A[3],rtin,A[2],I[3],A[3],select,CLK,Clr);
endmodule
62
Shift Register
//One stage of shift register
module stage(i0,i1,i2,i3,Q,select,CLK,Clr);
input i0,i1,i2,i3,CLK,Clr;
input [1:0] select;
output Q;
reg Q;
reg D;
//4x1 multiplexer
always @ (i0 or i1 or i2 or i3 or select)
case (select)
2'b00: D = i0;
2'b01: D = i1;
2'b10: D = i2;
2'b11: D = i3;
endcase
//D flip-flop
always @ (posedge CLK or negedge Clr)
if (~Clr) Q = 1'b0;
else Q = D;
endmodule
63
Synchronous Counter
//Binary counter with parallel load See Figure 6-14 and Table 6-6
module counter (Count,Load,IN,CLK,Clr,A,CO);
input Count,Load,CLK,Clr;
input [3:0] IN; //Data input
output CO; //Output carry
output [3:0] A; //Data output
reg [3:0] A;
assign CO = Count & ~Load & (A == 4'b1111);
always @ (posedge CLK or negedge Clr)
if (~Clr) A = 4'b0000;
else if (Load) A = IN;
else if (Count) A = A + 1'b1;
else A = A; // no change, default condition
endmodule
64
Ripple Counter
//Ripple counter (See Fig. 6-8(b))
module ripplecounter (A0,A1,A2,A3,Count,Reset);
output A0,A1,A2,A3;
input Count,Reset;
//Instantiate complementing flip-flop
CF F0 (A0,Count,Reset);
CF F1 (A1,A0,Reset);
CF F2 (A2,A1,Reset);
CF F3 (A3,A2,Reset);
endmodule
//Complementing flip-flop with delay
//Input to D flip-flop = Q'
module CF (Q,CLK,Reset);
output Q;
input CLK,Reset;
reg Q;
always @ (negedge CLK or posedge Reset)
if (Reset) Q = 1'b0;
else Q = #2 (~Q); // Delay of 2 time units
endmodule
65
Ripple Counter
//Stimulus for testing ripple counter
module testcounter;
reg Count;
reg Reset;
wire A0,A1,A2,A3;
//Instantiate ripple counter
ripplecounter RC (A0,A1,A2,A3,Count,Reset);
always
#5 Count = ~Count;
initial
begin
Count = 1'b0;
Reset = 1'b1;
#4 Reset = 1'b0;
#165 $finish;
end
endmodule
66
Ripple Counter

More Related Content

Similar to Sequential circuits Sequential circuits1

digital elctronics
digital elctronicsdigital elctronics
digital elctronicsAsif Iqbal
 
Digital Electronics – Unit III.pdf
Digital Electronics – Unit III.pdfDigital Electronics – Unit III.pdf
Digital Electronics – Unit III.pdfKannan Kanagaraj
 
Digital Logic Counter.ppt
Digital Logic Counter.pptDigital Logic Counter.ppt
Digital Logic Counter.pptRaziyaSultana30
 
EET107_Chapter 3_SLD(part2.1)-edit1.ppt
EET107_Chapter 3_SLD(part2.1)-edit1.pptEET107_Chapter 3_SLD(part2.1)-edit1.ppt
EET107_Chapter 3_SLD(part2.1)-edit1.pptBeautyKumar1
 
lec17-130220024438-phpapp02 (1).pdf
lec17-130220024438-phpapp02 (1).pdflec17-130220024438-phpapp02 (1).pdf
lec17-130220024438-phpapp02 (1).pdfssuser1b2fab
 
14827 shift registers
14827 shift registers14827 shift registers
14827 shift registersSandeep Kumar
 
2 marks DPCO.pdf
2 marks DPCO.pdf2 marks DPCO.pdf
2 marks DPCO.pdfVhhvf
 
Digital_Electronics_Module_4_Sequential_Circuits v0.6.pptx
Digital_Electronics_Module_4_Sequential_Circuits v0.6.pptxDigital_Electronics_Module_4_Sequential_Circuits v0.6.pptx
Digital_Electronics_Module_4_Sequential_Circuits v0.6.pptxUtsavDas21
 
Digital Electronics Unit_4_new.pptx
Digital Electronics Unit_4_new.pptxDigital Electronics Unit_4_new.pptx
Digital Electronics Unit_4_new.pptxThapar Institute
 
counters and resister presentations.pptx
counters and resister presentations.pptxcounters and resister presentations.pptx
counters and resister presentations.pptxarushika2211
 
Unit_5 – Sequential Circuits.pptx
Unit_5 – Sequential Circuits.pptxUnit_5 – Sequential Circuits.pptx
Unit_5 – Sequential Circuits.pptxDrashtiPatel275412
 
Synchronous down counter
Synchronous down counterSynchronous down counter
Synchronous down counterRONAK SUTARIYA
 
Digital design slides for engineering
Digital  design   slides for engineeringDigital  design   slides for engineering
Digital design slides for engineeringkasheen2803
 

Similar to Sequential circuits Sequential circuits1 (20)

digital elctronics
digital elctronicsdigital elctronics
digital elctronics
 
Digital Electronics – Unit III.pdf
Digital Electronics – Unit III.pdfDigital Electronics – Unit III.pdf
Digital Electronics – Unit III.pdf
 
Basics Counters
Basics Counters Basics Counters
Basics Counters
 
Digital Logic Counter.ppt
Digital Logic Counter.pptDigital Logic Counter.ppt
Digital Logic Counter.ppt
 
EET107_Chapter 3_SLD(part2.1)-edit1.ppt
EET107_Chapter 3_SLD(part2.1)-edit1.pptEET107_Chapter 3_SLD(part2.1)-edit1.ppt
EET107_Chapter 3_SLD(part2.1)-edit1.ppt
 
lec17-130220024438-phpapp02 (1).pdf
lec17-130220024438-phpapp02 (1).pdflec17-130220024438-phpapp02 (1).pdf
lec17-130220024438-phpapp02 (1).pdf
 
Dns module3 p3
Dns module3 p3Dns module3 p3
Dns module3 p3
 
Dns module3 p3_shift registers
Dns module3 p3_shift registersDns module3 p3_shift registers
Dns module3 p3_shift registers
 
14827 shift registers
14827 shift registers14827 shift registers
14827 shift registers
 
G. ripple counter
G. ripple counterG. ripple counter
G. ripple counter
 
2 marks DPCO.pdf
2 marks DPCO.pdf2 marks DPCO.pdf
2 marks DPCO.pdf
 
Digital_Electronics_Module_4_Sequential_Circuits v0.6.pptx
Digital_Electronics_Module_4_Sequential_Circuits v0.6.pptxDigital_Electronics_Module_4_Sequential_Circuits v0.6.pptx
Digital_Electronics_Module_4_Sequential_Circuits v0.6.pptx
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Digital Electronics Unit_4_new.pptx
Digital Electronics Unit_4_new.pptxDigital Electronics Unit_4_new.pptx
Digital Electronics Unit_4_new.pptx
 
COUNTERS.pptx
COUNTERS.pptxCOUNTERS.pptx
COUNTERS.pptx
 
counters and resister presentations.pptx
counters and resister presentations.pptxcounters and resister presentations.pptx
counters and resister presentations.pptx
 
Unit_5 – Sequential Circuits.pptx
Unit_5 – Sequential Circuits.pptxUnit_5 – Sequential Circuits.pptx
Unit_5 – Sequential Circuits.pptx
 
Synchronous down counter
Synchronous down counterSynchronous down counter
Synchronous down counter
 
Digital design slides for engineering
Digital  design   slides for engineeringDigital  design   slides for engineering
Digital design slides for engineering
 
Chapter5 dek3133
Chapter5 dek3133Chapter5 dek3133
Chapter5 dek3133
 

Recently uploaded

Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 

Sequential circuits Sequential circuits1

  • 1. 1 Chapter 6 Registers and Counter n The filp-flops are essential component in clocked sequential circuits. n Circuits that include filp-flops are usually classified by the function they perform. Two such circuits are registers and counters. n An n-bit register consists of a group of n flip- flops capable of storing n bits of binary information.
  • 2. 2 6-1 Registers n In its broadest definition, a register consists a group of flip-flops and gates that effect their transition. n The flip-flops hold the binary information. n The gates determine how the information is transferred into the register. n Counters are a special type of register. n A counter goes through a predetermined sequence of states.
  • 3. 3 6-1 Registers n Fig 6-1 shows a register constructed with four D-type filpflops. n “Clock” triggers all flip- folps on the positive edge of each pulse. n “Clear” is useful for clearing the register to all 0’s prior to its clocked operation.
  • 4. 4 Register with Parallel Load n A clock edge applied to the C inputs of the register of Fig. 6-1 will load all four inputs in parallel. n For synchronism, it is advisable to control the operation of the register with the D inputs rather than controlling the clock in the C inputs of the flip-flops. n A 4-bit register with a load control input that is directed through gates and into the D inputs of the flip-flops si shown in Fig. 6-2.
  • 6. 6 Register with Parallel Load n When the load input is 1 , the data in the four inputs are transferred into the register with next positive edge of the clock. n When the load input is 0 ,the outputs of the flip-flops are connected to their respective inputs. n The feedback connection from output to input is necessary because the D flip-flops does not have a “no change” condition.
  • 7. 7 6-2 Shift Registers n A register capable of shifting its binary information in one or both direction is called a shift register. n All flip-flops receive common clock pulses, which activate the shift from one stage to the next. n The simplest possible shift register is one that uses only flip-flops, as shown in Fig. 6-3.
  • 9. 9 Shift Registers n Each clock pulse shifts the contents of the register one bit position to the right. n The serial input determines what goes into the leftmost flip-flop during the shift. n The serial output is taken from the output of the rightmost flip-flop.
  • 10. 10 Serial Transfer n A digital system is said tp operate in a serial mode when information is transferred and manipulated one bit at a time. n This in contrast to parallel transfer where all the bits of the register are transferred at the same time. n The serial transfer us done with shift registers, as shown in the block diagram of Fig. 6-4(a).
  • 12. 12 Serial Transfer n To prevent the loss of information stored in the source register, the information in register A is made to circulate by connecting the serial output to its serial input. n The shift control input determines when and how many times the registers are shifted. This is done with an AND gate that allows clock pulses to pass into the CLK terminals only when the shift control is active. [Fig. 6- 4(a)].
  • 14. 14 Serial Transfer n The shift control signal is synchronized with the clock and changes value just after the negative edge of the clock. n Each rising edge of the pulse causes a shift in both registers. The fourth pulse changes the shift control to 0 and the shift registers are disabled.
  • 15. 15 Serial Transfer Table 6-1 Serial-Transfer Example 1 0 0 1 1 1 0 1 After T1 0 0 1 0 1 0 1 1 Initial value 1 0 1 1 1 0 1 1 After T4 0 1 1 0 0 1 1 1 After T3 1 1 0 0 1 1 1 0 After T2 Shift Register B Shift Register A Timing Pulse
  • 16. 16 Serial Transfer n In the parallel mode, information is available from all bits can be transferred simultaneously during one clock pulse. n In the serial mode, the registers have a single serial input and a single serial output. The information us transferred one bit at a time while the registers are shifted in the same direction.
  • 17. 17 Serial Addition n Operations in digital computers are usually done in parallel because this is a faster mode of operation. n Serial operations are slower, but have the advantage of requiring less equipment. n The two binary numbers to be added serially are stored in two shift registers. n Bits are added one pair at a time through a single full adder. [Fig. 6-5]
  • 19. 19 Serial Addition n By shifting the sum into A while the bits of A are shifted out, it is possible to use one register for storing both the augend and sum bits. n The carry out of the full adder is transferred to a D flip-flop. n The output of the D flip-flop is then used as carry input for the next pair of significant bits.
  • 20. 20 Serial Addition n To show that serial operations can be designed by means of sequential circuit procedure, we will redesign the serial adder using a state table. n The serial outputs from registers are designated by x and y. n The sequential circuit proper has two inputs, x and y, that provide a pair of significant bits, an output S that generates the sum bit, and flip-flop Q for storing the carry. [Table. 6-2]
  • 21. 21 Serial Addition Table 6-2 State Table for serial Adder 0 X 1 1 1 1 1 0 X 0 1 0 1 1 0 X 0 1 1 0 1 1 X 1 0 0 0 1 X 1 0 1 1 1 0 X 0 1 0 0 1 0 X 0 1 0 1 0 0 X 0 0 0 0 0 0 KQ JQ S Q y X Q Flip-Flop Inputs Output Next State Inputs Present State
  • 22. 22 Serial Addition n The two flip-flop input equations and the output equation can be simplified by means of map to obtain n JQ=xy n KQ=x’y’=(x+y)’ n S=x⊕y⊕Q n The circuit diagram is shown in [Fig. 6-6]
  • 24. 24 Universal Shift Register n A clear control to clear the register to 0. n A clock input to synchronize the operations. n A shift-right control to enable the shift operation and the serial input and output lines associated with the shift right. n A shift-left control to enable the shift operation and the serial input and output lines associated with the shift left.
  • 25. 25 Universal Shift Register n A parallel-load control to enable a parallel transfer and the n input lines associated with the parallel transfer. n n parallel output lines. n A control state that leaves the information in the register unchanged in the presence of the clock. n If the register has both shifts and parallel load capabilities, it is referred to as a universal shift register.
  • 27. 27 Universal Shift Register Parallel load 1 1 Shift Left 0 1 Shift right 1 0 No Change 0 0 S0 S1 Register Operation Mode Control Table 6-3 Function Table for the Register of Fig. 6-7
  • 28. 28 Universal Shift Register n Shift registers are often used to interface digital system situated remotely from each other. n If the distance is far, it will be expensive to use n lines to transmit the n bits in parallel. n Transmitter performs a parallel-to-serial conversion of data and the receiver does a serial-to-parallel conversion.
  • 29. 29 6-3 Ripple Counters n A register that goes through a prescribed sequence of states upon the application of input pulse is called a counter. n A counter that follows the binary number sequence is called a binary counter. n Counters are available in two categories n Ripple counters n Synchronous counters
  • 30. 30 Binary Ripple Counter n The output of each flip-flop is connected to the C input of the next flip-flop in sequence. n The flip-flop holding the last significant bit receives the incoming count pulse. n A complementing flip-flop can be obtained from: n JK flip-flop with the J and K inputs tied together. n T flip-flop n D flip-flop with the complement output connected to the D input. [Fig. 6-8]
  • 33. 33 BCD Ripple Counter n A decimal counter follows a sequence of ten states and returns to 0 after the count of 9. n This is similar to a binary counter, except that the state after 1001 is 0000. n The operation of the counter can be explained by a list of conditions for flip-flop transitions.
  • 35. 35 BCD Ripple Counter n The four outputs are designated by the letter symbol Q with a numeric subscript equal to the binary weight of the corresponding bit in the BCD code.
  • 36. 36 BCD Ripple Counter n The BCD counter of [Fig. 6-9] is a decade counter. n To count in decimal from 0 to 999, we need a three-decade counter. [Fig. 6-11] n Multiple decade counters can be constructed by connecting BCD counters ic cascade, one for each decade.
  • 38. 38 6-4 Synchronous Counters n Synchronous counters are different from ripple counters in that clock pulses are applied to the inputs of all flip-flops. n A common clock triggers all flip-flops simultaneously rather than one at a time in succession as in a ripple counter.
  • 39. 39 Binary Counter n The design of a synchronous binary counter is so simple that is no need to go through a sequential logic design process. n Synchronous binary counters have a regular pattern and can be constructed with complementing flip-flop and gates
  • 40. 40 Up-Down Binary Counter n The two operations can be combined in one circuit to form a counter capable of counting up or down. n It has an up control input and down control input.
  • 41. 41 BCD Counter n Because of the return to 0 after a count of 9, a BCD counter does not have a regular pattern as in a straight binary count. n To derive the circuit of a BCD synchronous counter, it is necessary to go through a sequential circuit design procedure.
  • 42. 42 BCD Counter Table 6-5 State Table for BCD Counter 1 0 0 0 1 0 0 0 0 1 0 0 1 1 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 1 0 0 0 0 1 1 1 1 0 1 0 0 0 0 1 1 1 0 0 1 1 0 1 1 0 0 0 0 1 1 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 0 1 0 1 1 1 0 0 0 0 1 0 1 1 0 0 1 0 0 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 TQ1 TQ2 TQ4 TQ8 Y Q1 Q2 Q4 Q8 Q1 Q2 Q4 Q8 Flip-Flop inputs Output Next State Present State
  • 43. 43 BCD Counter n The flip flop input equations can be simplified by means of maps. The simplified functions are n TQ1=1 n TQ2=Q8’ Q1 n TQ4=Q2Q1 n TQ8=Q8Q1+Q4Q2Q1 n y=Q8Q1 n The circuit can be easily drawn with four T flip-flops, five AND gates, and one OR gate.
  • 44. 44 Binary Counter with Parallel Load n Counters employed in digital systems quite often require a parallel load capability for transferring an initial binary number into the counter prior to count operation. n The input load control when equal to 1 disables the count operation and causes a transfer of data from the four data inputs into the four flip-flops [Fig. 6-14]
  • 45. 45 Binary Counter with Parallel Load
  • 46. 46 Binary Counter with Parallel Load 0 0 1 X Load No change 0 ↑ 1 Count next binary state 1 ↑ 1 Load inputs X ↑ 1 Clear to 0 X X 0 Function Count CLK Clear Table 6-6 Function Table for the Counter of Fig. 6-14
  • 47. 47 Binary Counter with Parallel Load n A counter with parallel load can be used to generate any desire count sequence. n [Fig.6-15] shows two ways in which a counter with parallel load is used to generate the BCD count.
  • 48. 48 Binary Counter with Parallel Load
  • 49. 49 6-5 Other Counters n Counters can be designed generate any desire sequence of states. n Counters are used to generate riming signals to control the sequence of operations in a digital system. n Counters can be constructed also by means of shift registers.
  • 50. 50 Counter with Unused States n Once the circuit is designed and constructed, outside interference may cause the circuit to enter one of the unused state. n If the unused states are treated as don’t- care conditions, then once the circuit is designed, it must be investigated to determine the effect of the unused states n The next state from an unused state can be determined from the analysis of the circuit after it is design.
  • 51. 51 Counter with Unused States X 0 1 X 1 X 0 0 0 0 1 1 1 X X 1 0 X 0 1 1 1 0 1 X 1 X 0 0 X 1 0 1 0 0 1 X 0 1 X X 1 0 0 1 0 1 0 1 X X 1 X 0 0 1 0 1 0 0 X 1 X 0 X 0 1 0 0 0 0 0 KC JC KB JB KA JA C B A C B A Flip-Flop Inputs Next state Present State Table 6-7 State Table for Counter
  • 52. 52 Counter with Unused States n The count has a repeated sequence of six states. n The simplified equations are: n JA=B KA=B n JB=C KB=1 n JC=B’ KC=1 n The logic diagram and state diagram is shown in [Fig. 6-16]
  • 54. 54 Ring Counter n A ring counter is a circular shift register with only one flip-flop being set at any particular time, all others are cleared. n The single bit is shifted from one flip-flop to the next to produce the sequence of timing signals. [Fig. 6-17(a)] [Fig. 6-17(c)] n The decoder shown in [Fig. 6-17(b)] decodes the four states of the counter and generates the required sequence of timing signals
  • 56. 56 Johnson Counter n Generate the timing signals with a combination of a shift register and a decoder, which is called a Johnson counter. n The number of states can be double if the shift register is connect as a switch-tail ring counter. [Fig. 6-18(a)] n Starting from a cleared state, the switch-tail ring counter goes through a sequence of eight states, as shown in [Fig. 6-18(b)].
  • 58. 58 Johnson Counter n A Johnson counter is a k-bit switch-tail ring counter with 2k decoding gates to provide outputs for 2k timing signals. n The decoding of a k-bit switch-tail ring counter to obtain 2k timing signals follows a regular pattern. n Johnson counters can be constructed for any number of timing sequences.
  • 59. 59 6-6 HDL for Registers and Counters n Registers and counters can be describe in HDL at either the behavioral or the structural level. n The various components are instantiated to form a hierarchical description of the design similar to a representation of a logic diagram.
  • 60. 60 Shift Register //Behavioral description of universal shift register Fig. 6-7 and Table 6-3 Module shftreg (s1,s0,Pin,lfin,rtin,A,CLK,Clr); input s1,s0 //Select inputs input lfin, rtin; //Serial inputs input CLk, clr; //Clock and Clear input [3:0] Pin; //Parallel input output [3:0] A; //Register output reg [3:0] A; always @ (posedge CLK or negedge Clr) if (~Clr) A = 4’ b0000’ else case ({s1,s0}) //No change 2’ b00: A = A; //Shift right 2’ b01: A = {rtin,A[3:1]}; //Shift left 2’ b10: A = {A[2:0],lfin}; //Parallel load input 2’ b11: A =Pin; endcase endmodule
  • 61. 61 Shift Register //Structural description of Universal shift register(see Fig.6-7) module SHFTREG (I,select,lfin,rtin,A,CLK,Clr); input [3:0] I; //Parallel input input [1:0] select; //Mode select input lfin,rtin,CLK,Clr; //Serial inputs,clock,clear output [3:0] A; //Parallel output //Instantiate the four stages stage ST0 (A[0],A[1],lfin,I[0],A[0],select,CLK,Clr); stage ST1 (A[1],A[2],A[0],I[1],A[1],select,CLK,Clr); stage ST2 (A[2],A[3],A[1],I[2],A[2],select,CLK,Clr); stage ST3 (A[3],rtin,A[2],I[3],A[3],select,CLK,Clr); endmodule
  • 62. 62 Shift Register //One stage of shift register module stage(i0,i1,i2,i3,Q,select,CLK,Clr); input i0,i1,i2,i3,CLK,Clr; input [1:0] select; output Q; reg Q; reg D; //4x1 multiplexer always @ (i0 or i1 or i2 or i3 or select) case (select) 2'b00: D = i0; 2'b01: D = i1; 2'b10: D = i2; 2'b11: D = i3; endcase //D flip-flop always @ (posedge CLK or negedge Clr) if (~Clr) Q = 1'b0; else Q = D; endmodule
  • 63. 63 Synchronous Counter //Binary counter with parallel load See Figure 6-14 and Table 6-6 module counter (Count,Load,IN,CLK,Clr,A,CO); input Count,Load,CLK,Clr; input [3:0] IN; //Data input output CO; //Output carry output [3:0] A; //Data output reg [3:0] A; assign CO = Count & ~Load & (A == 4'b1111); always @ (posedge CLK or negedge Clr) if (~Clr) A = 4'b0000; else if (Load) A = IN; else if (Count) A = A + 1'b1; else A = A; // no change, default condition endmodule
  • 64. 64 Ripple Counter //Ripple counter (See Fig. 6-8(b)) module ripplecounter (A0,A1,A2,A3,Count,Reset); output A0,A1,A2,A3; input Count,Reset; //Instantiate complementing flip-flop CF F0 (A0,Count,Reset); CF F1 (A1,A0,Reset); CF F2 (A2,A1,Reset); CF F3 (A3,A2,Reset); endmodule //Complementing flip-flop with delay //Input to D flip-flop = Q' module CF (Q,CLK,Reset); output Q; input CLK,Reset; reg Q; always @ (negedge CLK or posedge Reset) if (Reset) Q = 1'b0; else Q = #2 (~Q); // Delay of 2 time units endmodule
  • 65. 65 Ripple Counter //Stimulus for testing ripple counter module testcounter; reg Count; reg Reset; wire A0,A1,A2,A3; //Instantiate ripple counter ripplecounter RC (A0,A1,A2,A3,Count,Reset); always #5 Count = ~Count; initial begin Count = 1'b0; Reset = 1'b1; #4 Reset = 1'b0; #165 $finish; end endmodule