EEE 213 - v9
EEE 213 - v9
• Additional Resource:
• senolgulgonul/introductiontologic: Introduction to
Logic Design Lecture Files (github.com)
• Logic Simulator (hneemann/Digital: A digital logic
designer and circuit simulator. (github.com))
• Tinkercad (https://www.tinkercad.com/)
WHY
• Electronics
• Analog: RLC, Transistors, Amplifiers, Filters, Electromagnetic, Antenna etc.
• Digital: Logic Gates, Logic IC’s, Microcontrollers, FPGA etc.
Week Subject
SYLLABUS 1
2
Boolean Algebra and Logic Gates
Gate Level Minimization
3 Combinational Logic
4 Combinational Logic
5 Combinational Logic
6 Midterm
7 Sequential Logic
8 Sequential Logic
9 Registers Counter
10 Registers Counter
11 Memory and Programmable Logic
12 Microcontroller Architecture
13 Microcontroller Architecture
14 Final
15 Final
16
HISTORY OF LOGIC
• ‘Logic’ originates from Greek word ‘logos’, means ‘reason’
1. Categories
2. On Interpretation
3. Prior Analytics
4. Posterior Analytics
5. Topics
6. On Sophistical Refutations
EXAMPLES OF ARISTOTELES LOGIC
Aristotle’s central observation was to check validity of arguments based on their logical
structure. Aristotle, in his work "Sophistical Refutations," aimed to expose and
demonstrate the invalidity of various fallacies used by sophists.
Claude Shannon introduced the use of Boolean algebra in the analysis and design of
switching circuits in 1936 (Master Thesis).
SHANON APPLICATION OF BOOLEAN ALGEBRA
Open=1, Close=0 : X.Y
Open=1, Close=0 : X + Y
Cahit ARF: Can a machine think?
• Using only relays Boolean
algebra can be implemented
completely
/2
/2
/2
/2
/2
/2
DECIMAL to BINARY
• We can convert numbers to binary 0,1 and perform arithmetic operations using logic gates.
• Converting integer numbers to binary
• divide to 2 till 1 or 0, write remainders in REVERSE order
• LEFTMOST BIT is the MOST SIGNIFICANT BIT of the number
BINARY to DECIMAL
• While converting from binary to decimal: multiply and add binary value of bit and decimal value of
the bit position
32 16 8 4 2 1 2^x
1 0 1 0 0 1 Binary
32 0 8 0 0 1 =41
LOGIC GATES to COMPUTERS
While Claude Shannon showed how to map logic onto the physical world, Alan Turing showed how
to design computers in the language of mathematical logic. In 1945, he wrote the specification of the
EDVAC—the first stored program, logic-based computer—which is generally considered the
definitive source guide for modern computer design.
Two-Valued Boolean Algebra
One can formulate many Boolean algebras, depending on the choice of elements of
B and the rules of operation. In our subsequent work, we deal only with a two-valued
Boolean algebra (i.e., a Boolean algebra with only two elements).
two binary operators + and . as shown in the following operator tables (the rule
for the complement operator is for verification of postulate 5)
AND OR NOT
Huntington Postulates
Huntington introduced a set of postulates known as "Huntington's Postulates" that describe the
fundamental properties of Boolean algebra in 1904. These postulates provide a basis for
manipulating logical expressions and establishing the laws of Boolean algebra
Huntington postulates are valid for the set B = {0, 1} and the two binary operators + and .
Huntington Postulates
1. That the structure is CLOSED with respect to the two operators is obvious from the
tables, since the result of each operation is either 1 or 0 and 1, 0 ∈ B.
5. For every element x ∈ B, there exists an element x′ ∈ B called the complement of x such that
(a) x + x′ = 1
(b) x . x′ = 0
6. There exist at least two elements x, y ∈ B such that x ≠ y, x=1, y=0 and 1 ≠0
Huntington Postulates
• Table 2.1 lists six theorems of Boolean algebra and four of its postulates.
• The notation is simplified by omitting ‘.’
• The theorems and postulates listed are the most basic relationships in Boolean algebra.
• The theorems, like the postulates, are listed in pairs; each relation is the dual of the one paired with it.
• The postulates are basic axioms of the algebraic structure and need no proof.
• The theorems must be proven from the postulates.
Postulates and Theorems of Boolean Algebra
The theorems of Boolean algebra can be proven by means of
truth tables
• THEOREM 1(a): x + x = x
• THEOREM 1(b): x . x = x
• THEOREM 2(a): x + 1 = 1
• THEOREM 2(b): x . 0 = 0
F1 = x + y′z
X’ i called as :
• X’s complement,
• X prime
• not X
Truth Table to Algebraic Expression (Minterms)
• Given the truth table of F2, Find logical expression of F2
x y z F
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
Truth Table to Algebraic Expression (catch odd)
• design a logic which catches odd decimal numbers (1,3,5,7), 3-bit input
Dec x y z F
0 0 0 0 0
1 0 0 1 1
2 0 1 0 0
3 0 1 1 1
4 1 0 0 0
5 1 0 1 1
6 1 1 0 0
7 1 1 1 1
ANALOG to DIGITAL Converters (ADC)
x y z F
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0 F=xy’z + xyz’ + xyz
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
2.7. Other Logical Operations
• We are not limited to AND OR NOT Gates, other Gates are also may help to reduce
number of gates
• Let us evaluate all possible truth table combinations of two variable functions
• This task is well understood, but is difficult to execute by manual methods when the logic has more
than a few inputs.
• Fortunately, this dilemma has been solved by computer-based logic synthesis tools that minimize a
large set of Boolean equations efficiently and quickly.
y’ y y’ y
x’ x’ 1 1 1 1
x 1 1 1 1 x
z’ z z’ z’ z z’
• F1=x • F2=x’
Three Variable Karnaugh Map
• FIND THE COMMON VARIABLE(S) OF ADJACENT SQUARES
y’ y
y’ y
x’ 1 1
x’ 1 1
x 1 1
x 1 1
z’ z z’
z’ z z’
• F1=y • F2=y’
Three Variable Karnaugh Map
• FIND THE COMMON VARIABLE(S) OF ADJACENT SQUARES
y’ y y’ y
x’ 1 1 x’ 1 1
x 1 1 x 1 1
z’ z z’ z’ z z’
• F1=z • F2=z’
Three Variable Karnaugh Map
• FIND THE COMMON VARIABLE(S) OF ADJACENT SQUARES
y’ y y’ y
x’ 1 1 x’
x x 1 1
z’ z z’ z’ z z’
• F1=x’y’ • F2=xy
Three Variable Karnaugh Map
• FIND THE COMMON VARIABLE(S) OF ADJACENT SQUARES
y’ y y’ y
x’ 1 x’ 1
x 1 x 1
z’ z z’ z’ z z’
• F1=y’z’ • F2=y’z
Three Variable Karnaugh Map
• Simplify the Boolean function F =x’yz’ + x’yz + xy’z’ + xy’z
• Focus on only 1’s
x y z F
F = x’y’z’ + x’yz’ + xy’z’ + xy’z +xyz’
0 0 0 1
0 0 1
0 1 0 1 y’ y
0 1 1 x’ 1 1
1 0 0 1 x 1 1 1 F = z’ + xy’
1 0 1 1 z’ z z’
1 1 0 1
1 1 1
Three Variable Karnaugh Map
if expression is given we dont need to create to the truth table we can fill Karnaugh Map
x y z F
0 0 0 0
0 0 1 0
F = x’yz + xy’z + xyz’ + xyz
0 1 0 0 y’ y
0 1 1 1 x’ 1
1 0 0 0 x 1 1 1
F = yz + xz + xy
1 0 1 1 z’ z z’
1 1 0 1
1 1 1 1
Dont Care Conditions
• In practice, in some applications the function is not specified for certain combinations of the
variables
• These don’t-care conditions can be used on a map to provide further simplification of the Boolean
expression. So you can assume 1 or 0 as you like for further simplification
• Consider following example
x y z F
F =x’y’z’ + x’y’z + x’yz’ +x’yz + xy’z’ + xy’z
0 0 0 X=1
0 0 1 X=1
y’ y
0 1 0 1 if X=0 F=xy’+x’y but if Xdontcare=1 we
x’ X X 1 1
0 1 1 1 can further sımplify to
x 1 1
1 0 0 1
z’ z z’ F=y’+x’y
1 0 1 1
1 1 0 0
1 1 1 0
Four Variable Karnaugh Map
• Maps for more than three variables are difficult to use and will not be considered in the lecture.
NAND Gate
• The NAND gate is said to be a universal gate because any logic circuit can be implemented with it.
To show that any Boolean function can be implemented with NAND gates, we need only to show
that the logical operations of AND, OR, and complement can be obtained with NAND gates alone
NAND Gate: Implementation
• The implementation of two-level Boolean
functions with NAND gates requires that
the functions be in sum-of-products form
• F=AB + CD
The three bits in the message, together with the parity bit,
are transmitted to their destination, where they are
applied to a parity-checker circuit to check for possible
errors in the transmission. Since the information was
transmitted with even parity, the four bits received must
have an even number of 1’s. An error occurs during the
transmission if the four bits received have an odd number
of 1’s, indicating that one bit has changed in value during
transmission
F = xz + xy
Inside of Logic Gate
Logic Gates Applications (AND gate)
Logic Gates Applications (AND gate)
Logic Gates Applications (OR gate)
Logic Gates Applications (XOR gate)
Logic Gates Applications (XOR gate)
Logic Gates Applications (XOR gate)
Logic Gates Applications (XOR gate)
Inside of Logic Gate
Voltage Levels
Voltage Levels
For example, let's say you have a shift register that has a chip enable pin, CE. If you see the CE pin anywhere
in the datasheet with a line over it like this, 𝐶𝐸, then that pin is active-low. The CE pin would need to be
pulled to GND in order for the chip to become enabled. If, however, the CE pin doesn't have a line over it,
then it is active high, and it needs to be pulled HIGH in order to enable the pin.
Many ICs will have both active-low and active-high pins intermingled. Just be sure to double check for pin
names that have a line over them. The line is used to represent NOT (also known as bar). When something
is NOTTED, it changes to the opposite state. So if an active-high input is NOTTED, then it is now active-low.
Simple as that!
• The logic diagram of a combinational circuit has logic gates with no feedback paths or memory
elements.
Logic Diagram to Expression
Starting from input to output, construct the expression
F = ABC + (A+B+C)(AB+AC+BC)’
ABC
A+B+C
AB (AB+AC+BC)’
AC AB+AC+BC
BC
Logic Diagram to Expression
DESIGN GUIDE
1. Description of function
/2
/2
/2
/2
/2
/2
DECIMAL to BINARY
• We can convert numbers to binary 0,1 and perform arithmetic operations using logic gates.
• Converting integer numbers to binary
• divide to 2 till 1 or 0, write remainders in REVERSE order
• LEFTMOST BIT is the MOST SIGNIFICANT BIT of the number
BINARY ARITHMETIC
• We can convert numbers to binary 0,1 and perform arithmetic operations using logic gates.
• Converting integer numbers to binary
• Arithmetic operations with numbers in base 2 follow the same rules as for decimal numbers.
• full adder with carry, augend and addend
carry 𝑐𝑘+1 𝑐𝑘 … 𝑐3 𝑐2 𝑐1
5 𝑎𝑘 … 𝑎3 𝑎2 𝑎1 𝑎0
augend 1 0 1 2 𝑏𝑘 … 𝑏3 𝑏2 𝑏1 𝑏0
addend 0 1 0 +___ +______________________
sum 1 1 1 7 𝑐𝑘+1 𝑠𝑘 … 𝑠3 𝑠2 𝑠1 𝑠0
BINARY ARITHMETIC
carry 1 4 𝑐𝑘+1 𝑐𝑘 … 𝑐3 𝑐2 𝑐1
augend 1 0 0 𝑎𝑘 … 𝑎3 𝑎2 𝑎1 𝑎0
5 𝑏𝑘 … 𝑏3 𝑏2 𝑏1 𝑏0
addend 1 0 1
sum 1 0 0 1 +____ +______________________
𝑐𝑘+1 𝑠𝑘 … 𝑠3 𝑠2 𝑠1 𝑠0
9
carry 1 1 1
7
augend 1 1 1 5
addend 1 0 1 +____
sum 1 1 0 0
12
HALF ADDER = 2bit adder
• A combinational circuit that performs the addition of two bits is called a half adder
DEC
0
1
1
2
Full Adder = 3bit adder
• A full adder is a combinational circuit that forms the arithmetic sum of
three bits.
• It consists of three inputs and two outputs.
• Two of the input variables, denoted by x and y, represent the two
significant bits to be added. DEC
• The third input, z, represents the carry from the previous lower
0
significant position.
1
• The two outputs are designated by the symbols S for sum and C for
1
carry.
2
3
Electric Adder to the Base Two
• We can convert numbers to binary 0,1 and perform arithmetic operations using logic gates.
• Idea has been presented in Shannon 1938 thesis
Full Adder (three bits adder)
• A full adder is a combinational circuit that forms the arithmetic sum of three bits.
• It consists of three inputs and two outputs.
• Two of the input variables, denoted by x and y, represent the two significant bits to be added.
• The third input, z, represents the carry from the previous lower significant position.
• The two outputs are designated by the symbols S for sum and C for carry.
DEC
0
1
1
2
1
2
2
3
FULL ADDER
• One that performs the addition of three
bits (two significant bits and a previous
carry) is a full-adder.
Half Adder → Full Adder
• It can also be implemented with two half adders and one OR gate, as shown in Fig. 4.8.
4-bit Binary Adder
• 4-bit binary adder is a digital circuit that produces the arithmetic sum of two binary numbers.
• It can be constructed with full adders connected in cascade, with the output carry from each full
adder connected to the input carry of the next full adder in the chain
𝑐𝑘+1 𝑐𝑘 … 𝑐3 𝑐2 𝑐1
𝑎𝑘 … 𝑎3 𝑎2 𝑎1 𝑎0
𝑏𝑘 … 𝑏3 𝑏2 𝑏1 𝑏0
+______________________
𝑐𝑘+1 𝑠𝑘 … 𝑠3 𝑠2 𝑠1 𝑠0
Full Adder
• Full adder implementation from truth table
Comparison of Different Implementations
• Full adder implementation from truth table
4-bit Binary Adder
• 4-bit binary adder is a digital circuit that produces the arithmetic sum of two binary numbers.
• It can be constructed with full adders connected in cascade, with the output carry from each full
adder connected to the input carry of the next full adder in the chain
4-bit Binary Adder
• To demonstrate with a specific example, consider the two binary numbers A = 1011 and B = 0011.
Their sum S = 1110 is formed with the four-bit adder as follows:
• Co=0
carry 1 1 11
augend 1 0 1 1
3
addend 0 0 1 1
sum 1 1 1 0 +____
14
4-bit Binary Adder
• To demonstrate with a specific example, consider the two binary numbers A = 1011 (11) and B =
0011 (3). Their sum S = 1110 (14) is formed with the four-bit adder as follows:
• Co=0, C4=0
carry 1 1 11
augend 1 0 1 1
3
addend 0 0 1 1
sum 1 1 1 0 +____
14
4-bit Binary Adder
• if sum exceeding 4bits=15, overflow will occur C4=1, and 4 bit sum will be wrapped around
• so we need to stay within number of bits, otherwise unexpected results may seen
carry 1 1 1 0 11
augend 1 0 1 1
9
addend 1 0 0 1
sum 1 0 1 0 0 +____
4
4-bit Binary Adder
• if sum exceeding 4bits=15, overflow will occur C4=1, and 4 bit sum will be wrapped around
• so we need to stay within number of bits, otherwise unexpected results may seen
carry 1 1 1 0 11
augend 1 0 1 1
9
addend 1 0 0 1
sum 1 0 1 0 0 +____
4
8-bit Binary Adder in Arduino with overflow
• if sum exceeding 4bits=15, overflow will occur C4=1, and 4 bit sum will be wrapped around
• so we need to stay within number of bits, otherwise unexpected results may seen
Carry Propagation
• C2 waits for C1, C3 waits for C2, C4 waits for C3, this causes a propagation delay which directly
defines performance of the adder.
• The most widely used technique employs the principle of carry lookahead logic.
• C3 does not have to wait for C2 and C1 to propagate;
Carry Propagation
Gi is called a carry generate.
Pi is called a carry propagate
• first number input A1,A2,A3,A4
• second number input B1,B2,B3,B4
• C0 is carry input
• S1,S2,S3,S4 are output
• C4 is resultant carry output
• NOTE: Input conditions at A1, B1, A2, B2, and C0 are used to
determine outputs Σ1and Σ2 and the value of the internal carry C2.
• The values at C2, A3, B3, A4, and B4 are then used to determine
outputs Σ3, Σ4, and C4
• Can be connected cascade to create higher bit adders (8,16,32)
• Fast Carry means carry lookahead. We can observe ‘carry lookahead’ part in
the datasheet
• notice that:
• M=0; B XOR 0=B
• M=1; B XOR 1=B’ (1’s complement, add 1=C0=M)
• A-B=A + (B XOR 1) +1
Binary Subtractor (2’s Complement)
• The subtraction of unsigned binary numbers can be done most conveniently by means of complements
• subtraction A - B can be done by taking the 2’s complement of B and adding it to A
• The 2’s complement can be obtained by taking the 1’s complement and adding 1.
• Second way of 2’s complement: start from left to the first 1. copy/paste. invert other numbers to the right
dec=6 0 1 1 0 C 1 1 10
1’s comp 1 0 0 1 10 1 0 1 0 -6
add 1 1 -6 1 0 1 0 -____
2’s comp=-6 1 0 1 0 4 1 0 1 0 0 4
Binary Subtractor (2’s Complement)
• if A>B, A-B is positive and no overflow can occur
9 1 0 0 1 C 1 1 12
1’s comp 0 1 1 0 12 1 1 0 0 -9
add 1 1 -9 0 1 1 1 -____
2’s comp=-9 0 1 1 1 3 1 0 0 1 1 3
Binary Subtractor (2’s Complement)
• if B>A, A-B will result a negative number, which is 2’s complement of a positive number
9 1 0 0 1
1’s comp 0 1 1 0
add 1 1
2’s comp=-9 0 1 1 1 C 1 1
2-9=-7 (=9) 2 0 0 1 0
7 0 1 1 1 -9 0 1 1 1
1’s comp 1 0 0 0 -7 or 9 1 0 0 1
add 1 1
2’s comp=-7 1 0 0 1
Overflow
• When two numbers with n digits each are added and the sum is a number occupying n + 1 digits, we
say that an overflow occurred.
• When two unsigned numbers are added, an overflow is detected from the end carry out of the most
significant position
Overflow Examples in Arduino
4.7. Binary Multiplier
• Multiplication of binary numbers is performed in the same way as multiplication of decimal numbers.
• The multiplicand is multiplied by each bit of the multiplier, starting from the least significant bit.
• Each such multiplication forms a partial product.
• Successive partial products are shifted one position to the left.
• The final product is obtained from the sum of the partial products.
• The multiplication of two bits such as A0 and B0 produces a 1 if both bits are 1; otherwise, it produces
a 0. This is identical to an AND operation.
X 1 1 0 1
Y 1 1 0
multiply 0 0 0 0
1 1 0 1
1 1 0 1
sum 1 0 0 1 1 1 0
4.7. Binary Multiplier A0 x B3B2B1B0
A1 x B3B2B1B0
• The multiplicand is multiplied by each bit of the
multiplier, starting from the least significant bit.
• Each such multiplication forms a partial product.
• Successive partial products are shifted one position to
the left.
• The final product is obtained from the sum of the partial
products.
A2 x B3B2B1B0
B3B2B1B0 1 1 0 1
A2A1A0 1 1 0
A0x 0 0 0 0
A1x 1 1 0 1
A2x 1 1 0 1
sum 1 0 0 1 1 1 0
ARITHMETIC LOGIC UNIT
ARITHMETIC LOGIC UNIT
ARITHMETIC LOGIC UNIT
ARITHMETIC LOGIC UNIT
• M=L for Arithmetic, Cn=1 no carry
• S0=1, S3=1 for addition: A plus B
ALU_EEE213
• Lets develop an 16-bit ALU_EEE213 with 4 functions: add, sub, increment, decrement
• SEL is 2-bits. the first bit is Carry inputs of add or sub
• SEL second bit is selection of add or sub functions 0=add, 1=sub
• if SEL=10 add=A+B+1 if SEL=11, sub=A-B-1, increment, decrement
• Cout is carry of add or sub functions
• MUX select results of add or sub according to the first bit of SEL 0=add, 1=sub
• Example: SEL=00 for addition, 4 + 7= 11 = B
• Xi=Ai ⊙ Bi
Comparator
• (A=B) = (A0 ⊙ B0)(A1 ⊙ B1)(A2 ⊙ B2)(A3 ⊙ B3)
Comparator
• The outcome of the comparison is specified by three binary variables that indicate whether A > B, A =
B, or A < B.
• x2=(A2’B2+A2B2’)’=(A2+B2’)(A2’+B2)=A2A2’+A2B2+B2’A2’+B2’B2=A2B2+A2’B2’
• YES
Two-bit Comparator using digital sw
• design using Digital sw, starting from truth map
Two-bit Comparator using digital sw
• design using Digital sw, starting from truth map
DECODER
• Decoder is a combinational circuit that converts
binary information from n input lines to a maximum
of 2^n unique output lines.
• As an example, consider the three-to-eight-line
decoder circuit of Fig. 4.18
• Do=x’y’z’, D1=x’y’z …
DECODER-APPLICATIONS
• The SN74LVC1G139 2-line to 4-line decoder is designed to be used in high-performance memory
decoding or data-routing applications
DECODER/DEMULTIPLEXER
• A decoder with enable input can function as a
demultiplexer—a circuit that receives information
from a single line and directs it to one of 2^n
possible output lines.
• The selection of a specific output is controlled by the
bit combination of n selection lines.
• The decoder of Fig. 4.19 can function as a one-to-
four-line demultiplexer when E is taken as a data
input line and A and B are taken as the selection
inputs.
• For example, if the selection lines AB = 10, output D2
will FOLLOW the input value E, while all other
outputs are maintained at 1
DEMULTIPLEXER Applications
DECODER APPLICATIONS
BCD to 7 SEGMENT DECODER
LUT2
4.11 Multiplexer
• A multiplexer is a combinational circuit that selects binary information from one of many input lines and
directs it to a single output line.
• The selection of a particular input line is controlled by a set of selection lines.
• Normally, there are 2^n input lines and n selection lines whose bit combinations determine which input is
selected.
Applications: Multiplexer
4.11 Multiplexer
• A multiplexer is a combinational circuit that selects binary information from one of many input lines and
directs it to a single output line.
• The selection of a particular input line is controlled by a set of selection lines.
• Normally, there are 2^n input lines and n selection lines whose bit combinations determine which input is
selected.
3-State Gates
• Two of the states are signals equivalent to logic 1 and logic 0 as in a conventional gate.
• The third state is a high-impedance state (Z) in which the logic behaves like an open circuit, which means that
the output appears to be disconnected
• Because of this feature, a large number of three-state gate outputs can be connected with wires to form a
common line without endangering loading effects
ALU+COMPARATOR+DECODER/DEMUX
• decoder inside MCU takes the instruction bits,
decode it and route to control lines
5.2. Sequential Circuits
• Combinational circuits are ONE WAY, no loop
• It consists of a combinational circuit to which memory elements are connected to form a feedback path
• The memory elements are devices capable of storing binary information
• The block diagram demonstrates that the outputs in a sequential circuit are a function not only of the inputs
but also of the present state of the storage elements.
• The next state of the storage elements is also a function of external inputs and the present state.
• Thus, a sequential circuit is specified by a time sequence of inputs, outputs, and internal states.
• In contrast, the outputs of combinational logic depend on only the present values of the inputs
5.2. Sequential Circuits
• There are two main types of sequential circuits, and their classification is a function of the timing of their
signals
• A synchronous sequential circuit employs signals that affect the storage elements at only discrete instants of
time. Synchronization is achieved by a timing device called a clock generator, which provides a clock signal
having the form of a periodic sequence of clock pulses. The clock signal is commonly denoted by the
identifiers clock and clk
• The behavior of an asynchronous sequential circuit depends upon the input signals at any instant of time and
the order in which the inputs change.
5.3. Storage Elements: Latches
• A storage element in a digital circuit can maintain a binary state indefinitely (as long as power is delivered to
the circuit), until directed by an input signal to switch states.
• Storage elements that operate with signal levels (rather than signal transitions) are referred to as latches;
those controlled by a clock transition are flip-flops.
• Latches are said to be level-sensitive devices; flip-flops are edge-sensitive devices.
• The two types of storage elements are related because latches are the basic circuits from which all flip-flops
are constructed.
SR Latch
• When output Q = 1 and Q′ = 0, the latch is said to be in the set state. S=1, R=0
• When Q = 0 and Q′ = 1, it is in the reset state. S=0, R=1
• However, when both inputs are equal to 1 at the same time, a condition in which both outputs are equal to 0
(rather than be mutually complementary) occurs.
• If both inputs are then switched to 0 simultaneously, the device will enter an unpredictable or undefined state
or a metastable state.
• Consequently, in practical applications, setting both inputs to 1 is forbidden
SR Latch (SN74279)
• three state of output 1,0,KEEP
• S’=0, R’=0 is not allowed, non stable
D Latch (Transparent Latch)
• One way to eliminate the undesirable condition of the indeterminate state in the SR latch is to ensure that
inputs S and R are never equal to 1, S’R’=00 at the same time. This is done in the D latch, shown in Fig. 5.6.
• The binary information present at the data input of the D latch is transferred to the Q output when the enable
input is asserted.
• The output follows changes in the data input as long as the enable input is asserted. This situation provides a
path from input D to the output, and for this reason, the circuit is often called a transparent latch
D Latch
• D latch is a 1-bit register
• First EN=1, then write D-data to register, either 1 or 0
• then EN=0, keeps the value in Q like write protection
Problems of Latches
• Clock signal used for Enable
• While clock is ON if D changes then Y output will be changed which is NOT something we want
• Because of this unreliable operation, the output of a latch cannot be applied directly or through combinational
logic to the input of the same or another latch when all the latches are triggered by a common clock source.
D Flip Flops (Falling Edge)
• Flip-flop circuits are constructed in such a way as to make them operate properly when they are part of a
sequential circuit that employs a common clock
• The construction of a D flip-flop with two D latches and an inverter is shown in Fig. 5.9.
• a change in the output of the flip-flop can be triggered only by and during the transition of the clock from 1 to
0 (Falling Edge)
• The slave latch is enabled, and its output Q is equal to the master output Y. The master latch is disabled
because Clk = 0.
• When the input (Clk) pulse changes to the logic-1 level, the data from the external D input are transferred to
the master. The slave, however, is disabled
• like two doors entrance, only one person=D can pass, if you are inside the first door is closed
• There are Rising Edge D Flip-Flops, too.
D Flip Flops (Falling Edge)
• D flipflop is constructed by two Dlatch, En signal became Clock
• Q takes the value of D at falling edge of Clk
D Flip Flops: Applications
• to the Q output on the low to high transition, Rising Edge of the CLOCK input (CP).
• The MR=‘Master Reset’ input, when low, sets all outputs to a low state.
JK Flip Flops
• With only a single input, the D flip-flop can set or reset the output,
• the JK flip-flop has two inputs and performs three functions : Set it to 1, reset it to 0, or complement its
output
• The J input sets the flip-flop to 1, the K input resets it to 0, and when both inputs are enabled, the output is
complemented.
• This can be verified by investigating the circuit applied to the D input:
• D = JQ′ + K′Q
T Flip Flops
• The T (toggle) flip-flop is a complementing flip-flop and can be obtained from a JK flip-flop when inputs J and K
are tied together. This is shown in Fig. 5.13(a).
• When T = 0 (J = K = 0), a clock edge does not change the output. When T = 1 (J = K = 1), a clock edge
complements the output. The complementing flip-flop is useful for designing binary counters.
6.1. Registers with Parallel Load
• A register is a group of flip-flops, each one of which shares a common clock and is capable of storing
one bit of information
• Registers with parallel load are a fundamental building block in digital systems
• If all the bits of the register are loaded simultaneously with a common clock pulse, we say that the
loading is done in parallel
• Performing logic with clock pulses inserts variable delays and may cause the system to go out of
synchronism
6.1. Registers
• A four-bit data-storage register with a load control
input that is directed through gates and into the D
inputs of the flip-flops is shown in Fig. 6.2.
• The additional gates implement a two-channel mux
whose output drives the input to the register with
either the data bus or the output of the register
• The load input to the register determines the
action to be taken with each clock pulse.
• When the load input is 1, the data at the four
external inputs are transferred into the register
with the next positive edge of the clock. Write
enable
• When the load input is 0, the outputs of the flip-
flops are connected to their respective inputs
• The feedback connection from output to input is
necessary because a D flip-flop does not have a “no
change” condition
6.1. Registers
• Load=1, write enable, input transferred into
register at rising edge of clock
• Load=0 write protect. register values are
kept
6.1. Registers
• Load=1, write enable, input transferred into
register at rising edge of clock
• Load=0 write protect. register values are
kept
• The MC14076B 4−Bit Register consists of four D−type flip−flops
operating synchronously from a common clock.
• OR gated output−disable inputs force the outputs into a
high−impedance state for use in bus organized systems.
• OR gated data−disable inputs cause the Q outputs to be fed back
to the D inputs of the flip−flops.
• Thus they are inhibited from changing state while the clocking
process remains undisturbed
6.2. Shift Registers
• A register capable of shifting the binary information held in each cell to its neighboring cell, in a selected
direction, is called a shift register
• The logical configuration of a shift register consists of a chain of flip-flops in cascade, with the output of one
flip-flop connected to the data input of the next flip-flop. All flip-flops receive common clock pulses, which
activate the shift of data from one stage to the next.
• Each clock pulse shifts the contents of the register one bit position to the right
6.2. Shift Registers
• Si=1 reaches So after 4 clock cycle
• Serial input 4-bit Parallel output
6.2. Shift Registers
Applications: Shift Registers
Applications: Shift Registers
Address Output
A1 A0 F3 F2 F1 F0
0 0 0 0 1 1
0 1 0 1 1 0
1 0 1 1 0 0
1 1 1 1 1 1
Read-Only Memory (ROM)
• We can represent any combinatorial circuit with truth table MEANS that we can represent any combinatorial
circuit with ROM
• lets have a look half adder
Address Output
A1 A0 C S
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
Read-Only Memory (ROM)