BCS302 Module2
BCS302 Module2
III Semester
2022 Scheme
Prepared By:
Prof Padmasree N.
Prepared by
Padmasree N
Department of Computer Science and Engineering RVITM,
Bengaluru - 560076
Email: [Link]@[Link]
Pavithra M N
Department of Computer Science and Engineering RVITM,
Bengaluru - 560076
Email: [Link]@[Link]
Madhuri H D
Department of Computer Science and Engineering RVITM,
Bengaluru - 560076
Email: [Link]@[Link]
Module 2
Combinational Logic and Sequential logic
syllabus
Combinational Logic: Introduction, Combinational Circuits, Design Procedure, Binary Adder- Subtractor,
Decoders, Encoders, Multiplexers. HDL Models of Combinational Circuits – Adder, Multiplexer, Encoder.
Sequential Logic: Introduction, Sequential Circuits, Storage Elements: Latches, Flip-Flops.
Text book 1: 4.1, 4.2, 4.4, 4.5, 4.9, 4.10, 4.11, 4.12, 5.1, 5.2, 5.3, 5.4.
Multiplexers
It is a digital circuit with many inputs but only 1 output. By applying control-signals, we can steer any input
to output. Thus, it is also called a data-selector and control inputs are termed select inputs (Fig 3.1). The
circuit has n input signals, m control signals and 1 output signal. m control signals can select at the most 2m
input signals thus n ≤ 2m .
4:1 Multiplexer
• Depending on control inputs A and B, one of the 4 inputs D0 to D3 is steered to output Y as specified in Fig
3.14.
• The logic equation of the circuit (Fig: 3.1c) gives a SOP representation.
• Here, each AND gate generates a minterm which are finally summed by OR gate.
Page 3 of 33
In other words, for AB=00, the first AND gate to which D0 is connected remains active and equal to D0 and
all other AND gate are inactive with output held at logic 0. If D0=0, Y=0 and if D0=1, Y=1.
Similarly, for AB=01, second AND gate will be active and all other AND gates remain inactive. Thus,
output Y=D1.
Fig 3.14 a) Multiplexer Block Diagram, (b) 4-to-1 multiplexer truth table, (c) Its logic circuit
Page 4 of 33
Commercial multiplexer ICs come in integer power of 2, e.g. 2-to-1, 4-to-1, 8-to-1, 16-to-1 multiplexers.
16-to-1 multiplexer
Fig 3.15 shows a 16-to-1 multiplexer. The input bits are labeled D0 to D15. Only one of these is transmitted
to the output. It depends on the value of ABCD, the control input. For instance, when ABCD= 0000
the upper AND gate is enabled while all other AND gates are disabled. Therefore, data bit D0 is transmitted
to the output, giving Y=D0. If D0 is low, Y is low; if D0 is high, Y is high. The output can be written as
Page 5 of 33
Multiplexer logic
• Two standard methods for implementing a truth table are SOP and POS solutions. The third method is the
multiplexer solution. For example to use a 74150 to implement Table 3.1, complement each Y output to get
the corresponding data input.
D0=1'=0
D1=0'=1
….
….
D15=1'=0
• D0 is grounded, D1 is connected to +5V, D2 is grounded and so forth (Fig 3.16).
When ABCD=0000, D0 is the selected input. Since D0 is low, Y is high.
When ABCD=0001, D1 is the selected input. Since D1 is high, Y is low.
• The multiplexer is active (enabled) when the STROBE is low and inactive (disabled) when it is high. Because
of this, the STROBE is called an active low signal; it causes something to happen when it is low rather than
when it is high.
Page 6 of 33
Fig 3.17 Multiplexer as Universal Logic Circuit and Truth Table
Nibble Multiplexers
Sometimes, we want to select 1 of two input nibbles. In this case, we can use a nibble multiplexer.
The control signal labeled SELECT determines which input nibble is transmitted to output (Fig: 3.18).
When SELECT=low, the four NAND gates on the left are activated. Therefore
Y3Y2Y1Y0=A3A2A1A0
When SELECT=high, the four NAND gates on the right are activated.
Therefore Y3Y2Y1Y0=B3B2B1B0
Demultiplexers
It is a digital circuit with 1 input and many outputs (Fig: 3.19). By applying control signals, we can steer the
input signal to one of the output lines. The circuit has 1 input signal, m control or select signals and n output
signals where n ≤ 2m.
Page 7 of 33
1:16 Demultiplexer
The input data bit (D) is transmitted to the data bit of output lines depending on the value of ABCD, the control
input. When ABCD=0000, the upper AND gate is enabled while other AND gates are disabled. Therefore,
data bit D is transmitted only to the Y0 output, giving Y0=D. If D=low, Y0=low. If D=high, Y0=high. If the
control nibble is changed to ABCD=1111, all gates are disabled except the bottom AND [Link], D is
transmitted only to the Y15 output and Y15=D.
Page 8 of 33
Fig 3.20 74154 is a 1-to-16 demultiplexer
Decoders
• It is a multiple-input, multiple-output logic circuit which converts coded inputs into coded outputs, where
the input and output codes are different (Figure: 3.10). It is similar to a demultiplexer with one exception that
there is no data input. The only inputs are the control bits.
1-of-16 Decoder
• 1-of-16 decoder is called so because only 1 of the 16 output lines is high.
• For instance, when ABCD=0001, only the Y1 AND gate has all inputs high, therefore only the Y1 output
is high. If ABCD=0100, only the Y4 AND gate has all inputs high, as a result Y4=high. For all combinations,
the subscript of the high output always equals the decimal equivalent of ABCD. Hence this circuit is called as
binary-to-decimal decoder.
IC 74154 is called a decoder-demultiplexer, because it can be used either as a decoder or as a demultiplexer.
To use this IC as decoder, we have to ground the DATA and STROBE inputs as shown in fig 3.11. Then, the
selected output line is in the low state. This is why bubbles are shown on the output lines. It means the output
line is low when it is active or selected. For instance, if the binary input is
Page 9 of 33
ABCD= 0111
Then the Y7 output is low, while all other- outputs are high.
Page 10 of 33
Fig. 3.22 BCD to Decimal Decoders
The 7445
TTL IC 7445 is available to convert BCD to decimal as shown in fig 3.33. Pin 16 connects to supply voltage
VCC and pin 8 is grounded. Pins 12 to 15 are for the BCD input (ABCD), while pins 1 to 7 and 9 to 11 are
for the outputs. Here the active output line is in the low state. All the other output lines are in the high
state as shown in table 3.3. Invalid BCD input(1010 to 1111) forces all output lines into the high state.
Page 11 of 33
LED emits radiation when forward biased. This is because when free electrons recombine with holes near the
junction. As the free electrons fall from a higher energy level to a lower one, they give up energy in the form
of heat and light. The elements like gallium, arsenic, and phosphorus can emit red, green, yellow, blue, orange
and infrared (invisible) light.
Seven Segment Indicator
Fig 3.14 shows a seven segment indicator, i.e seven LEDs labeled a through g. By forward-biasing different
LEDs we can display digits from 0 to 9.
For example, to display 0, we need to light up segments a, b, c, d, e, and f.
To display 5, we need to light up segments a, c, d, f, and g.
Seven segment indicators may be the common-anode type where all anodes are connected together as in fig
3.15a or the common-cathode type where all cathodes are connected together as in fig 3.15b. With common
anode type, a current limiting resistor has to be connected between each LED and ground. The size of the
resistor determines how many current flows through the LED.
The typical LED current is between 1 and 50 mA. The common cathode type uses a current limiting resistor
between each LED and +VCC.
Page 12 of 33
Fig 3.16b shows 7448 driving a common cathode indicator. The internal logic converts the BCD input to the
required output. When the BCD input is 0100, the internal logic forces the LEDs b, c, f, and g to conduct. The
seven segment indicator then displays a 4. 7448 has its own current limiting resistor on the chip.
Page 13 of 33
Fig. 3.26 Decimal to BCD Encoders
The 74147
Fig 3.37a shows the pinout diagram for 74147, a decimal to BCD encoder. The decimal input X1 to
X9, connect to pins 1 to 5, and 10 to 13. The BCD output comes from pins 14, 6, 7, and 9. Pin 16 is for
the supply voltage, and pin 8 is grounded. The label NC on pin 15 means no connection.
Fig 3.19b shows how to draw a 74147. The bubbles indicate active-low inputs and outputs. Table 3.4 gives
the truth table. When all X inputs are high, all outputs are high. When X9 is low, the ABCD output is
LHHL(complement of 1001 (9)). When X8 is the only low input, ABCD is LHHH etc.
Page 14 of 33
The 74147 is called a priority encoder because it gives priority to the highest-order input. If all inputs X1
through X9 are low, highest of these, X9 has got highest priority and it is encoded. When X9 is high, X8 has
got next priority; it is encoded, if it is low.
Exclusive-OR Gates
This has a high output only when an odd number of inputs is high (Figure: 3.20).
• The upper AND gate forms the product A'B, while the lower one produces AB'. Therefore, the output of the
OR gate is Y=A'B+AB'
• This gate always produces an output 1 only when n-bit input has an odd number of 1s
Page 15 of 33
Arithmetic Building Blocks
Half-Adder
Half adder performs binary addition. It adds two bits. The following figure shows the circuit of half adder.
The output of EX-OR gate is called the SUM, while the output of AND gate is the CARRY.
The expression for SUM = B̅ + A ̅= A ⊕B
CARRY = AB
General representation of full-adder which adds i-th bit Ai and Bi of two numbers A and B and takes carry
from (i-1)th bit could be represented as below:
Ci = AiBi + BiCi-1 + AiCi-1
Ci = AiBi + (Ai + Bi)Ci-1
Si= Ai⊕Bi⊕Ci-1
Page 28 of 33
HDL Models of Combinational Circuits – Adder, Multiplexer, Encoder.
A combinational circuit that performs the addition of two bits is called a half-adder. This circuit needs two binary
inputs and produces two binary outputs. One of the input variables designates the augend and other designates
the addend. The output variables produce the sum and the [Link] simplified Boolean functions of the two
outputs can be obtained as below:
Sum S = x’y + xy’
Carry C = xy
Procedure:
1. The half-adder circuit is designed and the Boolean function is found out.
2. The VHDL program source code for the circuit is written.
3. It is implemented in xilinx and simulated.
4. Signals are provided and output Waveforms are viewed.
Program:
Behavioral Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity habeh1 is
Port ( a,b: in STD_LOGIC;
s,c: out STD_LOGIC;
architecture behavioral of habeh1 is
begin
begin
if a = '1' then
s<= not b;
c <= b;
else
s<= b;
c<= '0';
end if;
end process ha;
end behavioral;
Dataflow Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity haf1 is
port ( a : in std_logic;
b : in std_logic;
s : out std_logic;
c : out std_logic);
Page 29 of 33
end haf1;
architecture dataflow of haf1 is
begin
s<= a xor b;
c<= a and b;
end dataflow;
Structural Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity has1 is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
s : out STD_LOGIC;
c : out STD_LOGIC);
end has1;
end component;
component and_gate
begin
end structure
Page 30 of 33
Logic Diagram:
MULTIPLEXER
A digital multiplexer is a combinational circuit that selects binary information from one of many input lines and
directs it to a single output line. Multiplexing means transmitting a large number of information units over a
smaller number of channels or lines. The selection of a particular input line is controlled by a set of selection
lines. Normally, there are 2n input lines and n selection lines whose bit combinations determine which input is
selected. In general, a 2n – to – 1 line multiplexer is constructed from an n – to 2ndecoder by adding to it 2n input
lines, one to each AND gate. The outputs of the AND gates are applied to a single OR gate to provide the 1 – line
output.
Procedure:
1. The multiplexer circuit is designed and the Boolean function is found out.
2. The VHDL program source code for the circuit is written.
3. It is implemented in xilinx and simulated.
4. Signals are provided and Output Waveforms are viewed.
Program:
Behavioral Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity mux is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
c : in STD_LOGIC;
d : in STD_LOGIC;
s0 : in STD_LOGIC;
s1 : in STD_LOGIC;
y : out STD_LOGIC);
end mux;
architecture behavioral of mux is
Page 31 of 33
begin
process (a,b,c,d,s0,s1) is
begin
if (s0 ='0' and s1 = '0') then
y <= a;
elsif (s0 ='1' and s1 = '0') then
y <= b;
elsif (s0 ='0' and s1 = '1') then
y <= c;
else
y <= d;
end if;
end process;
end behavioral;
Data Flow Model:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity muxd is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
c : in STD_LOGIC;
d : in STD_LOGIC;
s0 : in STD_LOGIC;
s1 : in STD_LOGIC;
y : out STD_LOGIC);
end muxd;
architecture Behavioral of muxd is
begin
y <= ((not s0) and (not s1) and a) or
((not s0) and s1 and b) or
(s0 and (not s1) and c) or
(s0 and s1 and d);
end behavioral;
Structural model:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity muxs is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
Page 32 of 33
c : in STD_LOGIC;
d : in STD_LOGIC;
s0 : in STD_LOGIC;
s1 : in STD_LOGIC;
y : out STD_LOGIC);
end muxs;
architecture behavioral of muxs is
component mux21 is
port(a: in std_logic;
b: in std_logic;
s: in std_logic;
y: out std_logic);
end component;
signal p,q: std_logic;
begin
u1:mux21 port map (a,b,s1,p);
u2: mux21 port map (c,d,s1,q);
u3:mux21 port map (p,q,s0,y);
end behavioral;
Logic Diagram:
Truth Table:
Page 33 of 33
ENCODER
An Encoder is a combinational circuit that performs the reverse operation of [Link] has maximum of 2^n
input lines and 'n' output lines, hence it encodes the information from 2^n inputs into an n-bit code. It will
produce a binary code equivalent to the input, which is active high.
Procedure:
1. The encoder circuit is designed and the Boolean function is found out.
2. The VHDL program source code for the circuit is written.
3. It is implemented in xilinx and simulated.
4. Signals are provided and Output Waveforms are viewed.
Program:
Data Flow Model:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity encoder is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
c : in STD_LOGIC;
d : in STD_LOGIC;
y0 : out STD_LOGIC;
y1 : out STD_LOGIC);
end encoder;
architecture behavioral of encoder is
begin
y0<=((not a)and (not b))and (c xor d);
y1<=((not a)and (not c))and (b xor d);
end behavioral;
Behavioral Model:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity ec is
Port ( a : in STD_LOGIC_VECTOR (3 downto 0);
y : out STD_LOGIC_VECTOR (1 downto 0));
end ec;
architecture behavioral of ec is
begin
process(a) is
begin
if (a="0000") then
Page 34 of 33
y<= "00";
elsif (a="0001") then
y<="01";
elsif (a="0010") then
y<="10";
else
y<="11";
end if;
end process;
end behavioral;
Logic Diagram:
Truth Table:
Page 35 of 33
SEQUENTAIL CIRCUITS:
A sequential circuit refers to a special type of circuit. It consists of a series of various inputs and outputs. Here,
the outputs depend on a combination of both the present inputs as well as the previous outputs. This previous
output gets treated in the form of the present state. Thus, the sequential circuit consists of the combinational
circuit along with its memory storage elements. It doesn’t need to consist of a combinational circuit all the
time. A sequential circuit can basically contain only the memory element.
The asynchronous sequential circuits don’t make use of the clock signals. This type of circuit is operated
through various pulses. Thus, the changes in our input can easily make a change in the state of our circuit.
Clock pulses are not used in the case of asynchronous circuits. Here, the internal state gets altered whenever
there is a change in the input variable. The time-delayed or the unclocked flip-flops form the memory elements
of the asynchronous sequential circuits. This type of circuit is very similar to that of the combinational circuits
along with the feedback.
The clock signal performs the synchronization of the state of memory elements in the case of synchronous
sequential circuits. The output, in this case, is either stored in latches (memory devices) or flip-flops. The
output gets synchronized with the clock’s only positive edges or only the negative edges.
sequential circuit produces an output based on current input and previous output variables. That means
sequential circuits include memory elements that are capable of storing binary information. That binary
information defines the state of the sequential circuit at that time. A latch capable of storing one bit of
information.
Advantages of Sequential Circuits:
1. Memory: Sequential circuits have the ability to store binary values, which makes them ideal for
applications that require memory elements, such as timers and counters.
2. Timing: Sequential circuits are commonly used to implement timing and synchronization in
digital systems, making them essential for real-time control applications.
Page 36 of 33
3. State machine implementation: Sequential circuits can be used to implement state machines,
which are useful for controlling complex digital systems and ensuring that they operate as
intended.
4. Error detection: Sequential circuits can be designed to detect errors in digital systems and
respond accordingly, improving the reliability of digital systems.
1. Complexity: Sequential circuits are typically more complex than combinational circuits and
require more components to implement.
2. Timing constraints: The design of sequential circuits can be challenging due to the need to ensure
that the timing of the inputs and outputs is correct.
3. Testing and debugging: Testing and debugging sequential circuits can be more difficult compared
to combinational circuits due to their complex structure and state-dependant outputs.
In conclusion, sequential circuits have their advantages and disadvantages, but they play an important role in
digital systems design due to their ability to store and use binary values, implement timing and
synchronization, and implement state machines.
Page 37 of 33
A simple latch can be constructed by introducing feedback into a NOR-gate circuit, as given in the following
Figure (a). As indicated, if the inputs are S = R = 0, the circuit can assume a stable state with Q =0 and P =
1.
second gate are 0; therefore Q will change to 1, leading to the stable state.
If S = R = 1, the latch will not operate properly, as shown in above Fig 4.14 (c). Note that, when S and R are
both l, P and Q are both 0. Therefore, P is not equal to Q’, and this violates a basic rule of latch operation.
The following Figure shows a timing diagram for the S-R latch. Note that when S changes to 1 at time tl, Q
Page 38 of 30
changes to 1 a short time (ɛ - response time or delay time of latch) later. At time t2, when S changes back to
0, Q does not change. At time t3, R changes to 1, and Q changes back to 0 a short time (ɛ) later.
The duration of the S (or R) input pulse must normally be at least as great as ɛ in order for a change in the
state of Q to occur as in Fig 4.15.
Page 39 of 30
These equations are mapped in the next-state and output tables as given in the following Table. The stable
states of the latch are circled. Note that for all stable states, P = Q except when S = R = 1. Making S = R =
1, a don‟t-care combination allows simplifying the next-state equation.
Fig 4.16
An equation that expresses the next state of a latch in terms of its present state and inputs will be referred to
as a next-state equation, or characteristic equation.
An alternative form of the S-R latch uses NAND gates, as shown in the following Fig 4.17.
Page 40 of 30
change state. The timing diagram shows what happens when the switch is flipped from a to b. As the switch
leaves a, bounces occur at the R input; when the switch reaches b, bounces occur at the S input. After the
switch reaches b, the first time S becomes 1, after a short delay the latch switches to the Q = 1 state and
remains there. Thus Q is free of all bounces even though the switch contacts bounce.
GATED D LATCH:
A gated D latch (given in Fig 4.18 below) has two inputs—a data input (D) and a gate input (G). The D latch
can be constructed from an S-R latch and gates. When G = 0, S = R = 0, so Q does not change. WhenG = 1
and D = 1, S = 1 and R = 0, so Q is set to 1. When G = 1 and D = 0, S = 0 and R = 1, so Q is reset to
0. In other words, when G = 1, the Q output follows the D input, and when G = 0, the Q output holds the last
value of D (no state change). This type of latch is also referred to as a transparent latch because when G = 1,
the Q output is the same as the D input. From the truth table, the characteristic equation for the latch is + = ′
+ GD
Page 41 of 30
EDGE-TRIGGERED D FLIP-FLOP:
A D flip-flop has two inputs, D (data) and Ck (clock). The small arrowhead on the flip-flop symbol identifies
the clock input. Unlike the D latch, the flip-flop output changes only in response to the clock, not to a change
in D.
o If the output can change in response to a 0 to 1 transition on the clock input, we say that the flipflop is
triggered on the rising edge (or positive edge) of the clock.
o If the output can change in response to a 1 to 0 transition on the clock input, we say that the flipflop is
triggered on the falling edge (or negative edge) of the clock.
o An inversion bubble on the clock input indicates a falling-edge trigger (Fig 4.19 (b)), and no bubble
indicates a rising-edge trigger (Figure (a)).
The term active edge refers to the clock edge (rising or falling) that triggers the flip-flop state change.
Fig 4.19 D FF
Since, the Q output of the flip-flop is the same as the D input, except that the output changes are delayed until
after the active edge of the clock pulse, as illustrated in the following Fig 4.20.
Page 42 of 30
Fig 4.21 D flip-flop
When CLK = 0, G1 = 1, and the first latch is transparent so that the P output follows the D input. Because G2
= 0, the second latch holds the current value of Q. When CLK changes to 1, G1 changes to 0, and the current
value of D is stored in the first latch. Because G2 = 1, the value of P flows through the second latch to the Q
output. When CLK changes back to 0, the second latch takes on the value of P and holds it and, then, the first
latch starts following the D input again. If the first latch starts following the D input before the second latch
takes on the value of P, the flip-flop will not function properly. Therefore, the circuit designers must pay
careful attention to timing issues when designing edge-triggered flip-flops. With this circuit, output state
changes occur only following the rising edge of the clock. The value of D at the time of the rising edge of the
clock determines the value of Q, and any extra changes in D that occur between rising clock edges have no
effect on Q.
A flip-flop changes state only on the active edge of the clock, the propagation delay of a flip-flop is the time
between the active edge of the clock and the resulting change in the output. However, there are also timing
issues associated with the D input.
To function properly, the D input to an edge-triggered flip-flop must be held at a constant value for a period
of time before and after the active edge of the clock. If D changes at the same time as the active edge, the
behavior is unpredictable.
The amount of time that the D input must be stable before the active edge is called the setup time (tsu), and
the amount of time that the D input must hold the same value after the active edge is the hold time (th). The
times at which D is allowed to change during the clock cycle are shaded in the timing diagram of the following
Fig 4.22.
Page 43 of 30
Fig 4.22 Set Up Time and Hold Time
The propagation delay (tp) from the time the clock changes until the Q output changes is also indicated in the
above Figure. Using these timing parameters, we can determine the minimum clock period for a circuit which
will not violate the timing constraints. Consider the circuit of following Fig 4.23 (a). Suppose the inverter has
a propagation delay of 2 ns, and suppose the flip-flop has a propagation delay of 5 ns and a setup time of 3 ns.
(The hold time does not affect this calculation). Suppose, as in following Figure (b), that the clock periodis 9
ns, i.e., 9 ns is the time between successive active edges (rising edges for this figure). Then, 5 ns after a clock
edge, the flip-flop output will change, and 2 ns after that, the output of the inverter will change. Therefore, the
input to the flip-flop will change 7 ns after the rising edge, which is 2 ns before the next risingedge. But the
setup time of the flip-flop requires that the input be stable 3 ns before the rising edge; therefore,the flip-flop
may not take on the correct value. Suppose instead that the clock period were15 ns, as in following Figure (c).
Again, the input to the flipflop will change 7 ns after the rising edge. However, becausethe clock is slower,
this is 8 ns before the next rising edge. Therefore, the flip-flop will work properly. Note in Figure (c) that there
is 5 ns of extra time between the time the D input is correct and the time when it mustbe correct for the setup
time to be satisfied. Therefore, we can use a shorter clock period, and have less extratime, or no extra time.
Figure (d) shows that 10 ns is the minimum clock period which will work for this circuit.
Page 44 of 30
Fig 4.23 propagation delay (tp) from the time the clock
S-R FLIP-FLOP:
An S-R flip-flop (following Fig 4.24) is similar to an S-R latch in that S = 1 sets the Q output to 1, and R =
1 resets the Q output to 0. The essential difference is that the flip-flop has a clock input, and the Q output can
change only after an active clock edge.
Page 45 of 30
the clock changes from 0 to 1, the value of P is held in the master latch and this value is transferred to the
slave latch. The master latch holds the value of P while CLK = 1, and, hence, Q does not change. When the
clock changes from 1 to 0, the Q value is latched in the slave, and the master can process new inputs. Figure
(b) shows the timing diagram. Initially, S = 1 and Q changes to 1 at t1. Then R = 1 and Q changes to 0 at t3.
Page 46 of 30
simultaneously to J and K, in which case the flip-flop changes state after the active clock edge. When J = K
= 1, the active edge will cause Q to change from 0 to 1, or from 1 to 0. The next-state table and
characteristic equation for the J-K flip-flop are given in Figure (b).
Fig 4.26
Figure 4.26 (c) shows the timing for a J-K flip-flop. This flip-flop changes state a short time (tp) after the
rising edge of the clock pulse, provided that J and K have appropriate values. If J = 1 and K = 0 when Clock
= 0, Q will be set to 1 following the rising edge. If K = 1 and J = 0 when Clock = 0, Q will be set to 0 after
the rising edge. Similarly, if J = K = 1, Q will change state after the rising edge. Referring to Figure 11- 20(c),
because Q = 0, J = l, and K = 0 before the first rising clock edge, Q changes to 1 at t1. Because Q = 1,J = 0,
and K = 1 before the second rising clock edge, Q changes to 0 at t2. Because Q = 0, J = 1, and K = 1 before
the third rising clock edge, Q changes to 1 at t3. One way to realize the J-K flip-flop is with two S-R latches
connected in a master-slave arrangement, as shown in the following Figure.
Page 47 of 30
Fig 4.27 Master Slave JK FF
This is the same circuit as for the S-R master-slave flip-flop; except S and R have been replaced with J and K,
and the Q and Q outputs are feeding back into the input gates. Because S = JQ’Clk’ and R = K’QClk’, onlyone
of S and R inputs to the first latch can be 1 at any given time. If Q = 0 and J = 1, then S = 1 and R
= 0, regardless of the value of K. If Q = 1 and K = 1, then S = 0 and R = 1, regardless of the value of J.
T FLIP-FLOP:
The T flip-flop, also called the toggle flip-flop, is frequently used in building counters. Most CPLDs and
FPGAs can be programmed to implement T flip-flops. The T flip-flop (shown in the following Fig 4.28) has
a T input and a clock input. When T = 1 the flipflop changes state after the active edge of the clock. When T
= 0, no state change occurs. The next-state table and characteristic equation for the T flip-flop are given in
Figure (b). The characteristic equation states that the next state of the flip-flop (Q+) will be 1 iff the present
state (Q) is 1 and T = 0 or the present state is 0 and T = 1.
Page 48 of 30
Fig 4.29 T FF Timing Diagram
One way to implement a T flip-flop is to connect the J and K inputs of a J-K flip-flop together, as shown in
the following Figure (a). Substituting T for J and K in the J-K characteristic equation gives; + = ′ + ′
= ′ + ′ which is the characteristic equation for the T flip-flop. Another way to realize a T flip-flop is with a D flip-flop and an exclusive-
OR gate [Figure (b)]. The D input is Q ⊕ T, so Q+ = Q ⊕ TQ’ + T’Q, which is the characteristic equation for the T flip-flop.
Page 23 of 30
Fig 4.30 FLIP-FLOPS WITH ADDITIONAL INPUTS
The above table (Figure (b)) summarizes the flip-flop operation. In the table, c indicates a rising clock edge, and
X is a don‟t-care. The last row of the table indicates that if Clk is held at 0, held at 1, or has a falling edge, Q does
not change. The following Figure illustrates the operation of the clear and preset inputs. At t1, ClrN
= 0 holds the Q output at 0, so the rising edge of the clock is ignored. At t2 and t3, normal state changes occur
because ClrN and PreN are both 1. Then, Q is set to 1 by PreN = 0, but Q is cleared at t4 by the rising edge
of the clock because D = 0 at that time.
Page 24 of 30
synchronization. Rather than gating the clock, a better way is to use a flip-flop with a clock enable (CE). Such
flip-flops are commonly used in CPLDs and FPGAs. Figure (b) shows a D flip-flop with a clock enable, which
we will call a D-CE flip-flop. When CE = 0, the clock is disabled and no state change occurs, so Q+ = Q.
When CE = 1, the flip-flop acts like a normal D flip-flop, so Q+ = D. Therefore, the characteristic equation is
Q+ = Q•CE’ + D•CE. The D-CE flip-flop is easily implemented using a D flip- flop and a multiplexer (Figure
(c)). For this circuit, the MUX output is Q+ = D + Q•CE + Din•CE. Since, there is no gate in the clock line;
this cannot cause a synchronization problem.
Characteristic Equations of Flip-Flop:
The characteristics equations of flip-flops are useful in analyzing circuits made of them. Here, next output,
Qn+1, is expressed as a function of present output Qn and the input to the flip-flops. Karnaugh map can be
used to get the optimized expression.
S R Flip Flop
Page 26 of 26