Logic Circuit 2080
Logic Circuit 2080
The reflected binary code or Gray code is an ordering of the binary numeral system such that two successive
values differ in only one bit (binary digit). Gray codes are very useful in the normal sequence of binary
numbers generated by the hardware that may cause an error or ambiguity during the transition from one
number to the next. So, the Gray code can eliminate this problem easily since only one bit changes its value
during any transition between two numbers.
Gray code is not weighted that means it does not depends on positional value of digit. This is cyclic variable
code that means every transition from one value to the next value involves only one bit change.
Gray code also known as reflected binary code, because the first (n/2) values compare with those of the last
(n/2) values, but in reverse order.
Computer Instructions
Computer instructions are a set of machine language instructions that a particular processor understands and
executes. A computer performs tasks on the basis of the instruction provided.
An instruction comprises of groups called fields. These fields include:
1. The Operation code (Opcode) field which specifies the operation to be performed.
In Memory-reference instruction, 12 bits of memory is used to specify an address and one bit to specify the
addressing mode 'I'.
Register - reference instruction:
The Register-reference instructions are represented by the Opcode 111 with a 0 in the leftmost bit (bit 15) of
the instruction.
Input-Output instruction:
Just like the Register-reference instruction, an Input-Output instruction does not need a reference to memory
and is recognized by the operation code 111 with a 1 in the leftmost bit of the instruction. The remaining 12
bits are used to specify the type of the input-output operation or test performed.
Alphanumeric characters:
Alphanumeric characters comprise the combination of the twenty-six characters of the alphabet (from A to Z)
and the numbers 0 to 9. Therefore, 1, 2, q, f, m, p, and 10 are all examples of alphanumeric characters.
Symbols like *, & and @ are also considered alphanumeric characters.
These characters can also be used in combination. Examples of alphanumeric characters made of the
combination of special symbols, numbers, and the characters of the alphabet are &AF54hh, jjHF47, @qw99O.
Since computers (or central processing units, to be specific) use machine language in the form of numbers to
communicate, computer programmers need to write their instructions using numbers rather than alphabet
characters. To do this, programmers use numeric representations of what humans see as alphabet characters.
You’ve probably seen or heard of binary code that uses only 0s and 1s to represent an alphanumeric
character. Computer programmers can use a series of 0s and 1s to represent any character they wish. For
example, in binary, the letter ‘A’ would be written as 01000001.
Another way computer programmers represent alphanumeric characters is to use ASCII. ASCII stands for
American Standard Code for Information Interchange.
Modulo:
When we divide two integers we will have an equation that looks like the following:
A/B = Q remainder R
Where,
A is the dividend
B is the divisor
Q is the quotient
R is the remainder
In modulo 2, the remainders from 0 and changes to 1. Again 1 changes to 0. This cycle sequence repeats for
the n number of integer.
In programming we use % to check the remainder using given modulo. For the 0 to 5 numbers, remainder will
be using modulo2.
0%2 = 0
1%2 = 0
2%2 = 1
2%2 = 0
3%2 = 1
4%2 = 0
5%2 = 1
Note: Modulo 2 arithmetic is performed digit by digit on binary numbers. Binary arithmetic is also known as modulo2
arithmetic.
It is a form of binary encoding where each digit in a decimal number is represented in the form of
bits.
This encoding can be done in either 4-bit or 8-bit (usually 4-bit is preferred).
It is a fast and efficient system that converts the decimal numbers into binary numbers as
compared to the existing binary system.
These are generally used in digital displays where is the manipulation of data is quite a task.
Thus BCD plays an important role here because the manipulation is done treating each digit as a
separate single sub-circuit.
Consider the following truth table and focus on how these are represented.
Truth Table for Binary Coded Decimal
DECIMAL NUMBER BCD
0 0000
1 0001
In the BCD numbering system, the given decimal number is segregated into chunks of four bits for each
decimal digit within the number. Each decimal digit is converted into its direct binary form (usually
represented in 4-bits).
It is noticeable that the BCD is nothing more than a binary representation of each digit of a decimal number.
It cannot be ignored that the BCD representation of the given decimal number uses extra bits, which makes it
heavy-weighted.
Whenever a message is transmitted, it may get scrambled by noise or data may get corrupted. To avoid this,
we use error-detecting codes which are additional data added to a given digital message to help us detect if an
error occurred during transmission of the message. A simple example of error-detecting code is parity check.
To detect and correct the errors, additional bits are added to the data bits at the time of transmission.
The additional bits are called parity bits. They allow detection or correction of the errors.
The data bits along with the parity bits form a code word.
Even parity: Even parity means the number of 1's in the given word including the parity bit should be even
(2,4,6,....).
Odd parity: Odd parity means the number of 1's in the given word including the parity bit should be odd
(1,3,5,....).
The parity bit can be set to 0 and 1 depending on the type of the parity required.
For even parity, this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word is even.
For odd parity, this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word is odd.
Parity checking at the receiver can detect the presence of an error if the parity of the receiver signal is
different from the expected parity. That means, if it is known that the parity of the transmitted signal is always
going to be "even" and if the received signal has an odd parity, then the receiver can conclude that the
received signal is not correct. If an error is detected, then the receiver will ignore the received byte and
request for retransmission of the same byte to the transmitter.
Boolean Laws:
There are six types of Boolean Laws.
1. Commutative law
Commutative law states that changing the sequence of the variables does not have any effect on the
output of a logic circuit.
2. Associative law
This law states that the order in which the logic operations are performed is irrelevant as their effect is the
same.
3. Distributive law
Distributive Law states that the multiplication of two variables and adding the result with a variable will
result in the same value as multiplication of addition of the variable with individual variables.
A+(B.C) = (A+B).(A+C)
4. AND law
These laws use the AND operation. Therefore they are called as AND laws.
5. OR law
These laws use the OR operation. Therefore they are called as OR laws.
DeMorgan’s Theorem:
DeMorgan’s Theorems are basically two sets of rules or laws developed from the Boolean expressions of
AND, OR and NOT using two input variables, A and B. These two rules or theorems allow the input variables to
be negated and converted from one form of a Boolean function into an opposite form.
DeMorgan’s First Theorem: DeMorgan’s First theorem proves that when two (or more) input variables
are AND’ed and negated, they are equivalent to the OR of the complements of the individual variables. Thus
the equivalent of the NAND function will be a negative-OR function, proving that (A.B)’ = A’+B’. We can show
this operation using the following table.
Verifying DeMorgan’s First Theorem using Truth Table
Inputs Truth Table Outputs For Each Term
B A A.B (A.B)’ A’ B’ A’ + B’
0 0 0 1 1 1 1
0 1 0 1 0 1 1
1 0 0 1 1 0 1
1 1 1 0 0 0 0
We can also show that (A.B)’ = A’+B’ using logic gates as shown.
The top logic gate arrangement of: (A.B)’ can be implemented using a standard NAND gate with
inputs A and B. The lower logic gate arrangement first inverts the two inputs producing A’ and B’. These then
become the inputs to the OR gate. Therefore the output from the OR gate becomes: A’+B’
DeMorgan’s Second Theorem: DeMorgan’s Second theorem proves that when two (or more) input variables
are OR’ed and negated, they are equivalent to the AND of the complements of the individual variables. Thus
the equivalent of the NOR function is a negative-AND function proving that (A+B)’ = A’.B’, and again we can
show operation this using the following truth table.
Verifying DeMorgan’s Second Theorem using Truth Table
Inputs Truth Table Outputs For Each Term
B A A+B (A+B)’ A’ B’ A’.B’
0 0 0 1 1 1 1
0 1 1 0 0 1 0
1 0 1 0 1 0 0
1 1 1 0 0 0 0
We can also show that (A+B)’ = A’.B’ using the following logic gates example.
DeMorgan’s Second Law Implementation using Logic Gates
The top logic gate arrangement of: (A+B)’ can be implemented using a standard NOR gate function using
inputs A and B. The lower logic gate arrangement first inverts the two inputs, thus producing A’ and B’. Thus
then become the inputs to the AND gate. Therefore the output from the AND gate becomes: A’.B’
Then we can see that a standard AND gate function with inverters (NOT gates) on each of its inputs produces
an equivalent output condition to a standard NOR gate function, and an individual NOR gate can be
represented in this way as the equivalency of a NOR gate is a negative-AND.
2. AND gate using only NAND gate: The below diagram is of an AND gate made from NAND gate.
3. OR gate using only NAND gate: The below diagram is of an OR gate made from combinations of NAND
gates, arranged in a proper manner.
2. AND gate using only NOR gate: The above diagram as the name suggests is of AND gate using only NOR
gate.
3. OR gate using only NOR gate: The below diagram is of an OR gate made by only using NOR gates. The
output of this gate is exactly similar to that of a single OR gate.
Tristate Logic:
In digital electronics three-state, tri-state, or 3-state logic allows an output port to assume a high
impedance state, effectively removing the output from the circuit, in addition to the 0 and 1 logic levels.
A tristate buffer can be thought of as a switch. If B is on, the switch is closed. If B is off, the switch is open.
Venn diagram:
A Venn diagram is a visual representation of the outputs of a logic gate with different inputs. A Venn
diagram can be easily created with the truth tables.
Venn diagrams look exactly like the traditional Venn diagram.
Each space represents the input type and each circle represents an input of 1. The area that is not
inside either of the circles is 00. The area inside one circle would be 10 and 01. The area inside both the circles
then would be 11. This is the layout for a two input logic gate.
Test Vector:
Test vectors mean a listing of all possible inputs and their expected outputs in order to check the
correctness of a system. Logic gates may generate a wrong output signal because of a fault in the circuitry that
implements the gate.
Most circuits use logic gates as the basic building blocks. A good model for representing faults in such
circuits is to assume that all faults appear as some wires (input and output of gates) being permanently stuck
at logic value 0 or 1. Consider a wire w has an undesirable signal that always corresponds to the logic value 0
Step-4: Constructing circuit using Boolean function obtained from third step.
For sum, we have obtained (A XOR B) so we will connect A and B to the inputs of XOR gate and take its
output as a sum. For carry, we have obtained (A AND B) so we will connect A and B to the inputs of AND
gate and take its output as a carry.
It is an arithmetic combinational logic circuit designed to perform addition of two single bits. It contain
two inputs and produces two outputs. Inputs are called Augend and Added bits and Outputs are called Sum
and Carry.
Since 1+1=10, the result must be two bit output. So, Above can be rewritten as,
0+0=00
0+1=01
1+0=01
1+1=10
The result of 1+1 is 10, where ‘1’ is carry-output (Cout) and ‘0’ is Sum-output (Normal Output).
Limitations:
Adding of Carry is not possible in half adder.
Full Adder:
To overcome the above limitation faced with Half adders, Full Adders are implemented. It is a
arithmetic combinational logic circuit that performs addition of three single bits. It contains three inputs (A, B,
Cin) and produces two outputs (Sum and Cout). Where, Cin -> Carry In and Cout -> Carry Out
It is a combinational logic circuit designed to perform subtraction of two single bits. It contains two
inputs (A and B) and produces two outputs (Difference and Borrow-output).
Truth Table of Half Subtractor:
Full Subtractor
It is a Combinational logic circuit designed to perform subtraction of three single bits. It contains three
inputs (A, B, Bin) and produces two outputs (D, Bout). Where, A and B are
called Minuend and Subtrahend bits. And, Bin -> Borrow-In and Bout -> Borrow-Out
The converter has 5 outputs D0, D1, D2, D3 and D4. From the truth table, the minterms can be obtained
for each output.
D4 = ∑m(10, 11, 12, 13, 14, 15)
D3 = ∑m(8, 9)
D2 = ∑m(4, 5, 6, 7, 14, 15)
D1 = ∑m(2, 3, 6, 7, 12, 13)
D0 = ∑m(1, 3, 5, 7, 9, 11, 13, 15)
The minterms are plotted in the karnaugh map and the simplified boolean expressions are obtained.
The digital logic circuit for Binary to BCD code converter is designed from the simplified output
expressions obtained from karnaugh map.
From the truth table, the minterms are obtained for each outputs(E3, E2, E1, E0).
E3 = ∑m(5, 6, 7, 8, 9)
E2 = ∑m(1, 2, 3, 4, 9)
E1 = ∑m(0, 3, 4, 7, 8)
E0 = ∑m(0, 2, 4, 6, 8)
The minterms of each output in plotted in k-map and simplified expression is obtained.
From the minterms of each output G3, G2, G1, G0, the karnaugh map is implemented to simplify the
function.
G3 = ∑m(8, 9) + d(10,11,12,13,14,15)
The code converter circuit for BCD to gray code is drawn as below from the obtained expression.
(A’.B’.C’ ) = (A + B + C )’
INVERT-AND symbol consists of AND gate with a bubble at each input for complementation
(inversion). These symbols are used for converting a circuit into NOR gates.
To implement a Boolean function using NOR gate, there are basically three step;
1. Product of Sum Form: First, you need to have a simplified Product of Sum expression for the function you need
to implement. Simplified Product of Sum expression can be made using Karnaugh Map (K-map).
Suppose we have simplified POS expression.
F = (A+B)(C+D)
Draw its logic diagram using AND-OR NOT gates as shown in the figure given below.
2. Mixed Notation: Next step is to draw the above-mentioned logic diagram using OR-Invert and Invert-AND gates.
OR-Invert should replace OR gates and invert-AND replaces AND gates. This schematic is said to be in mixed
notation and its schematic is given below.
A bubble means complement. Two bubbles along a line mean double complementation and they cancel
each other. However, a single bubble along a line should be compensated by making a complemented input if
available.
Example:
F = (A+B)(B+C)D
This function is in simplified Product of Sum form. First, we need to draw its OR-AND schematic.
Now we convert the above-given schematic into mixed notation by converting OR gate into OR-INVERT and AND
gate into INVERT-AND.
Input line D to the input of AND gate has a single bubble. To compensate this bubble we need complement the
input D. Now replace every OR-Invert and Invert-AND with NOR gate as shown in the figure given below.
First, we will draw its schematic using AND, OR, NOT gates.
Notice the OR-AND pattern like two-level implementation. It can be easily converted since the bubble cancels each
other.
The two bubbles along a single line cancel each other. However, there is a single bubble at the 2nd level gate’s input. So
we will complement the input B to compensate the bubble.
Now redraw the whole schematic replacing OR-Invert and Invert-AND with NOR gate symbol as shown in the figure
below.
INVERT-OR
INVERT-OR means Inverter (NOT gate) connected to the input of OR gate. According to DE Morgan’s law, Inverting the
inputs to the OR gate makes it a NAND gate. So INVERT-OR symbol represents NAND gate and it is given in the figure
below.
Two-Level Implementation using NAND Gate: Two-level implementation means that any path from input
to output contains maximum two levels hence the name two-level for the two levels of gates.
Implementing a two-level schematic with NAND gates require the expression to be in Sum of Product (SOP)
form. In Sum of Product form, the 1st level of the gate is AND gate and the 2nd level of the gate is OR gate. It can be
easily converted into NAND gates.
To convert any function into two-level NAND schematic there are 3 steps;
Sum of Product Form: First, you need to have simplified Sum of Product (SOP) form for the Boolean function.
Karnaugh map (K-map) or Boolean algebraic theorems can be used to get a Simplified SOP expression.
Suppose an SOP function F = A B + C D
This SOP function is in Simplified SOP form and its AND-OR schematic is given below.
Mixed Notation: 2nd step is to convert the AND-OR schematic into mixed notation. In mixed notation for NAND
gate, AND gate is converted into AND-invert and OR gate is converted into INVERT-OR. Mixed notation design
for the above function is given below.
Example
Suppose a function F = A B + B C + D to be implemented using NAND gates
This function is in simplified Sum of Product form. First, we need to draw its AND-OR schematic.
Now we convert the above-given schematic into mixed notation by converting AND gate into AND-INVERT and OR gate
into INVERT-OR.
Notice the single input D line to the OR gate. There is one bubble on this line. To compensate this bubble we need to
complement the input D. Then convert AND-INVERT and INVERT-OR symbol into NAND symbol as shown in the figure.
MULTI-LEVEL Implementation using NAND Gate: Schematic having more than two levels of gates is known
as a multi-level schematic. We can implement multi-level SOP expression using NAND gate. The conversion of multi-level
expression into NAND gate has the same method as two-level implementation.
The multi-level expression can be converted into two-level expression but for the sake of realization, we will
implement a multi-level expression.
Suppose a multi-level function be;
F = A ( B + CD ) + BD’
This is a four-level function
Notice the AND-OR pattern. So it can be easily converted into NAND gates. Now we will convert this into mixed notation
i.e. AND gate will be converted into AND-INVERT and OR will be converted into INVERT-OR as shown in the figure given
below.
Notice the 3rd line of input B, there is a single bubble. To compensate this bubble, either an inverter should be added or
the input B should be complimented.
Then redraw the whole schematic using all NAND gates by replacing AND-INVERT and INVERT-OR with NAND gates as
shown in the figure below.
Parity Generator:
Let us assume that a 3-bit message is to be transmitted with an even parity bit. Let the three inputs A, B and C are
applied to the circuit and output bit is the parity bit P. The total number of 1s must be even, to generate the even parity
bit P.
The above expression can be implemented by using two Ex-OR gates. The logic diagram of even parity generator with
two Ex – OR gates is shown below. The three bit message along with the parity generated by this circuit which is
transmitted to the receiving end where parity checker circuit checks whether any error is present or not.
To generate the even parity bit for a 4-bit data, three Ex-OR gates are required to add the 4-bits and their sum will be
the parity bit.
In odd parity bit scheme, the parity bit is ‘1’ if there are even number of 1s in the data stream and the parity bit is ‘0’ if
there are odd number of 1s in the data stream. Let us discuss both even and odd parity generators.
The above Boolean expression can be implemented by using one Ex-OR gate and one Ex-NOR gate in order to design a 3-
bit odd parity generator.
Parity Checker:
It is a logic circuit that checks for possible errors in the transmission. This circuit can be an even parity checker or odd
parity checker depending on the type of parity generated at the transmission end. When this circuit is used as even
parity checker, the number of input bits must always be even.
The below table shows the truth table for the Even Parity
Checker in which PEC = 1 if the error occurs, i.e., the four
bits received have odd number of 1s and PEC = 0 if no error
occurs, i.e., if the 4-bit message has even number of 1s.
The below figure shows the truth table for odd parity generator
where CP =1 if the 4-bit message received consists of even
number of 1s (hence the error occurred) and CP= 0 if the
message contains odd number of 1s (that means no error).
The expression for the odd parity checker can be designed by using
three Ex-NOR gates as shown below.
This Circuit requires prerequisite knowledge of XOR Gate, Binary Addition and Subtraction, Full Adder.
Lets consider two 4-bit binary numbers A and B as inputs to the Digital Circuit for the operation with digits
A3 A2 A1 A0 for A
B3 B2 B1 B0 for B
The circuit consists of 4 full adders since we are performing operation on 4-bit numbers. There is a control line
K that holds a binary value of either 0 or 1 which determines that the operation being carried out is addition or
subtraction.
As shown in the figure, the first full adder has control line directly as its carry input (Cin), the input A0 is
directly input in the full adder. The third input is the XOR of B0 and K. The two outputs produced are
Sum/Difference (S0) and Carry (C0).
̅.
Similarly, If the value of K=1, the output of B XOR K=𝑩
B K B XOR K = 𝑩 ̅
0 1 1
1 1 0
Then C0 is serially passed to another full adder as one of its output. The sum/difference S0 is recorded as the
least significant bit of the sum/difference. A1, A2, A3 are direct inputs to the second, third and fourth full
adders. Then the third input is the B1, B2, B3 XORed with K to the second, third and fourth full adder
respectively. The carry C1, C2 are serially passed to the successive full adder as one of the inputs. C3 becomes
the total carry to the sum/difference. S1, S2, S3 are recorded to form the result with S0.
For an n-bit binary adder-Subtractor, we use n number of full adders.
Example: Perform binary addition and subtraction of given 4-bit binary value using binary adder and
Subtractor. A = 1001 and B = 0011.
Solution:
From the above table, it is clear that if the produced sum from 1 to 9 in the Binary and the BCD code is same.
But for 10 to 19 decimal numbers, both the codes are different. In the above table, the binary sum
combinations from 10 to 19 give invalid BCD. There are the following points that help the circuit to identify the
invalid BCD.
1. It is obvious from the table that a correction is needed when the 'Binary Sum' has an output carry K=1.
2. The other six combinations from 10 to 15 need correction in which the bit on the Z8 position is 1.
3. In the Binary sum of 8 and 9, the bit on the Z8 position is also 1. So, the second step fails, and we need
to modify it.
4. To distinguish these two numbers, we specify that the bit on the Z4 or Z2 position also needs to be 1
with the bit of Z8.
5. The condition for a correction and an output carry can be expressed by the Boolean function:
C=K+Z8.Z4+Z8.Z2
Once the circuit found the invalid BCD, the circuit adds the binary number of 6 into the invalid BCD
code to make it valid.
1-bit Magnitude Comparator: A comparator that compares two binary bits and produces three outputs based
on the relative magnitudes of given binary bits is called a 1-bit magnitude comparator.
Truth Table:
A B A<B A>B A=B
0 0 0 0 1
0 1 1 0 0
1 0 0 1 0
1 1 0 0 1
The truth table derives the expressions of A<B, A>B and A=B as below
A<B = A’B
A>B = AB’
A=B = A’B’+AB = A XNOR B
From the above truth table K-map for each output can be drawn as follows:
From the above K-maps logical expressions for each output can be expressed as follows:
A > B: A1.B1’ + A0.B1’.B0’ + A1.A0.B0’
A = B: A1’.A0’.B1’.B0’ + A1’.A0.B1’.B0 + A1.A0.B1.B0 + A1.A0’.B1.B0’
: A1’.B1’ (A0’.B0’ + A0.B0) + A1.B1 (A0.B0 + A0’.B0’)
: (A0.B0 + A0’.B0’) (A1.B1 + A1’.B1’)
: (A0 EX-NOR B0) (A1 EX-NOR B1)
A < B: A1’.B1 + A0’.B1.B0 + A1.’A0’.B0
4-bit Magnitude Comparator: A comparator that compares two binary numbers (each number having 4 bits)
and produces three outputs based on the relative magnitudes of given binary bits is called a 4-bit magnitude
comparator.
The input bits can be termed as A = A3 A2 A1 A0 and B = B3 B2 B1 B0
In a 4-bit comparator the condition of A>B can be possible in the following four cases:
1. If A3 = 1 and B3 = 0
2. If A3 = B3 and A2 = 1 and B2 = 0
3. If A3 = B3, A2 = B2 and A1 = 1 and B1 = 0
4. If A3 = B3, A2 = B2, A1 = B1 and A0 = 1 and B0 = 0
Similarly the condition for A<B can be possible in the following four cases:
1. If A3 = 0 and B3 = 1
2. If A3 = B3 and A2 = 0 and B2 = 1
3. If A3 = B3, A2 = B2 and A1 = 0 and B1 = 1
4. If A3 = B3, A2 = B2, A1 = B1 and A0 = 0 and B0 = 1
The condition of A=B is possible only when all the individual bits of one number exactly coincide with
corresponding bits of another number.
1. (A = B) = (A3 Ex-Nor B3) (A2 Ex-Nor B2) (A1 Ex-Nor B1)(A0 Ex-Nor B0)
Decoder and Encoder: Binary code of N digits can be used to store 2N distinct elements of coded
information. This is what encoders and decoders are used for.
Encoder: An Encoder is a combinational circuit that performs the reverse operation of Decoder. It has
maximum of 2N 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.
8: 3 Encoder (Octal to Binary): The 8 to 3 Encoder or octal to Binary encoder consists of 8 inputs, Y7 to Y0
and 3 outputs, A2, A1 & A0. Each input line corresponds to each octal digit and three outputs generate
corresponding binary code.
Decimal to BCD Encoder: The decimal to binary encoder usually consists of 10 input lines and 4 output lines.
Each input line corresponds to the each decimal digit and 4 outputs correspond to the BCD code. This encoder
accepts the decoded decimal data as an input and encodes it to the BCD output which is available on the
output lines. The figure below shows the logic symbol of decimal to BCD encoder:
Priority Encoder: A 4 to 2 priority encoder has 4 inputs, Y3, Y2, Y1 & Y0 and 2 outputs, A1 & A0. Here, the
input, Y3 has the highest priority, whereas the input, Y0 has the lowest priority. In this case, even if more than
one input is ‘1’ at the same time, the output will be the (binary) code corresponding to the input, which is
having higher priority.
The truth table for priority encoder is as follows:
Decoders: A decoder does the opposite job of an encoder. It is a combinational circuit that converts n lines of input
into 2n lines of output.
Truth Table: The logical expression of the term Y0, Y0, Y2, and Y3 is
as follows:
Y3=E.A1.A0
Y2=E.A1.A0'
Y1=E.A1'.A0
Y0=E.A1'.A0'
Multiplexer: A multiplexer is a combinational circuit that has 2n input lines and a single output line. Simply,
the multiplexer is a multi-input and single-output combinational circuit. The binary information is received
from the input lines and directed to the output line. On the basis of the values of the selection lines, one of
these data inputs will be connected to the output.
Unlike encoder and decoder, there are n selection lines and 2n input lines. So, there is a total of 2N possible
combinations of inputs. A multiplexer is also treated as Mux.
There are various types of the multiplexer which are as follows:
2x1 Multiplexer: In 2x1 multiplexer, there are only two inputs,
i.e., A0 and A1, 1 selection line, i.e., S0 and single outputs, i.e., Y.
On the basis of the combination of inputs which are present at
the selection line S0, one of these 2 inputs will be connected to
the output. The block diagram and the truth table of the 2×1
multiplexer are given below.
4×1 Multiplexer: In the 4×1 multiplexer, there is a total of four inputs, i.e.,
A0, A1, A2, and A3, 2 selection lines, i.e., S0 and S1 and single output, i.e., Y.
On the basis of the combination of inputs that are present at the selection
lines S0 and S1, one of these 4 inputs are connected to the output. The block
diagram and the truth table of the 4×1 multiplexer are given below.
Truth Table:
8 to 1 Multiplexer: In the 8 to 1 multiplexer, there are total eight inputs, i.e., A0, A1, A2, A3, A4, A5, A6, and A7,
3 selection lines, i.e., S0, S1and S2 and single output, i.e., Y. On the basis of
the combination of inputs that are present at the selection lines S 0, S1, and
S2, one of these 8 inputs are connected to the output. The block diagram
and the truth table of the 8×1 multiplexer are given below.
Truth Table:
De-multiplexer: A De-multiplexer is a combinational circuit that has only 1 input line and 2N output lines.
Simply, the multiplexer is a single-input and multi-output combinational circuit. The information is received
from the single input lines and directed to the output line. On the basis of the values of the selection lines, the
input will be connected to one of these outputs. De-multiplexer is opposite to the multiplexer.
Unlike encoder and decoder, there are n selection lines and 2n outputs. So, there is a total of 2n possible
combinations of outputs. De-multiplexer is also treated as De-mux.
There are various types of De-multiplexer which are as follows:
1×2 De-multiplexer: In the 1 to 2 De-multiplexer, there are
only two outputs, i.e., Y0, and Y1, 1 selection lines, i.e., S0, and
single input, i.e., A. On the basis of the selection value, the
input will be connected to one of the outputs. The block
diagram and the truth table of the 1×2 multiplexer are given
below.
ROM: Its non-volatile memory, i.e., the information stored in it, is not lost even if the
power supply goes off. It’s used for the permanent storage of information. A stored
array of binary data which can be read only, but not changed.
For each combination of inputs on the ‘n’ input lines, the corresponding pattern
of 0’s and 1’s (a word) is generated on the ‘m’ output lines.
2n x m ROM:
Here, the inputs of AND gates are programmable. That means each AND gate has both normal and
complemented inputs of variables. So, based on the requirement, we can program any of those inputs. So, we
can generate only the required product terms by using these AND gates.
Here, the inputs of OR gates are also programmable. So, we can program any number of required product
terms, since all the outputs of AND gates are applied as inputs to each OR gate. Therefore, the outputs of PAL
will be in the form of sum of products form.
Solution:
Create truth table for above Boolean functions,
Inputs Outputs
A B C F1 F2
0 0 0 1 1
0 0 1 1 0
0 1 0 1 0
0 1 1 0 0
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 0 1
PLA Implementation
Event Driven Model: Event driven sequential circuits differ from combinatorial circuits in that the outputs of
the circuit depend not only on the present state of the inputs but also on the past history of the inputs. Thus a
sequential circuit has memory. Memory is provided for each bit needed to define a state by using a bit storage
device such as a flip-flop.
Flip-Flop: Flip-flop is a circuit that maintains a state until directed by input to change the state. A basic flip-
flop can be constructed using four-NAND or four-NOR gates.
Types of flip-flops:
1. SR Flip Flop
2. JK Flip Flop
3. D Flip Flop
4. T Flip Flop
1. SR Flip Flop: The Clocked SR flip flop consists of 4 NAND gates, two inputs(S and R) and two outputs (Q and
Q’). The clock pulse is given at the inputs of gate A and B.
2. JK Flip Flop: One of the most useful and versatile flip flop is the JK flip flop the unique features of a JK flip
flop are:
If the J and K input are both at 1 and the clock pulse is applied, then the output will change state,
regardless of its previous condition.
If both J and K inputs are at 0 and the clock pulse is applied there will be no change in the output.
There is no indeterminate condition, in the operation of JK flip flop i.e. it has no ambiguous state. The
circuit diagram for a JK flip flop is shown in Figure :
These J and K inputs disable the NAND gates, therefore clock pulse have no effect on the flip flop. In other
words, Q returns it last value.
When J = 0 and K = 1: The upper NAND gate is disabled the lower NAND gate is enabled if Q is 1 therefore, flip
flop will be reset (Q = 0, Q =1) if not already in that state. So, Q+1 = 0.
When J = 1 and K = 0: The lower NAND gate is disabled and the upper NAND gate is enabled if Q is at 1, As a
result we will be able to set the flip flop (Q = 1, Q = 0) if not already set. So, Q+1 = 1.
When J = 1 and K = 1: If Q = 0 the lower NAND gate is disabled the upper NAND gate is enabled. This will set
the flip flop and hence Q will be 1. On the other hand if Q = 1, the lower NAND gate is enabled and flip flop will
be reset and hence Q will be 0. In other words, when J and K are both high, the clock pulses cause the JK flip
flop to toggle. Truth table of JK is shown below:
Master Slave Flip Flop: The Master-Slave Flip-Flop is basically a combination of two JK flip-flops connected
together in a series configuration. Out of these, one acts as the “master” and the other as a “slave”. The
output from the master flip flop is connected to
the two inputs of the slave flip flop whose output
is fed back to inputs of the master flip flop.
In addition to these two flip-flops, the circuit also
includes an inverter. The inverter is connected to
clock pulse in such a way that the inverted clock
pulse is given to the slave flip-flop. In other words
if CP=0 for a master flip-flop, then CP=1 for a
slave flip-flop and if CP=1 for master flip flop then
it becomes 0 for slave flip flop.
When the clock pulse goes to 1, the slave is isolated. The slave flip-flop is isolated until the CP goes to
0. When the CP goes back to 0, information is passed from the master flip-flop to the slave and output
is obtained.
Firstly the master flip flop is positive level triggered and the slave flip flop is negative level triggered, so
the master responds before the slave.
If J=0 and K=1, the high Q’ output of the master goes to the K input of the slave and the clock forces
the slave to reset, thus the slave copies the master.
If J=1 and K=0, the high Q output of the master goes to the J input of the slave and the Negative
transition of the clock sets the slave, copying the master.
If J=1 and K=1, it toggles on the positive transition of the clock and thus the slave toggles on the
negative transition of the clock.
If J=0 and K=0, the flip flop is disabled and Q remains unchanged.
For J-K flip-flop, if J=K=1, and if clk=1 for a long period of time, then output Q will toggle as long as CLK remains
high which makes the output unstable or uncertain. This is called a race around condition in J-K flip-flop. We
can overcome this problem by making the clock =1 for very less duration. The circuit used to overcome race
around conditions is called the Master Slave JK flip flop.
Stable Table: The information contained in the state diagram is transformed into a table called a state table or
state synthesis table. Although the state diagram describes the behavior of the sequential circuit, in order to
implement it in the circuit, it has to be transformed into the tabular form.
The below table shows the state table for Mealy state machine model. As you can see, it has the
present state, next state and output. The present state is the state before the occurrence of the clock pulse.
State Reduction: While designing a sequential circuit, it is very important to remove the redundant states. The
removal of redundant states will reduce the number of flip flops and logic gates, thereby reducing the cost and
size of the sequential circuit.
The two states are said to be redundant if the output and the next state produced for each and every
input are the same. In that case, one of the redundant states can be removed without altering the input-
output relationship. This method is called the state elimination method.
Let us learn with examples here.
In the above stable table1, state a & e found to be having similar states. Here we have found, states b
and e are redundant. Replace e by b and remove the state e. Which is shown in stable table2.
Block Diagram of Synchronous Sequential Circuit Block Diagram of Asynchronous Sequential Circuit
The transition from one state to another takes place The transition from one state to another takes place
only by the application of specified clock signal*, even immediately once the inputs change.
if the inputs change.
Synchronous sequential circuits are also known
as clocked sequential circuit.
The states of synchronous sequential circuits are There are chances for the asynchronous circuits to
always predictable and thus reliable. enter into a wrong state because of the time
difference between the arrivals of inputs. This is
called as race condition.
Triggering
Triggering basically means switching. The way in which a switch or an event is triggered can be
different, based on the user's requirements.
Edge and Level Triggering, are both common terms when using sequential circuits (flip flops) triggered
by an external or internal clock signal.
Level Triggering:
You can notice two voltage levels, VH and VL. Those are the two levels at which the event can be
triggered. Consider you want to turn on an LED at the positive clock level. What it means is that the LED can
turn on at any moment when the voltage is at VH. This is known as level triggering, where the event is
triggered whenever a clock level is encountered. The event may start at any moment during the time for
which the clock signal is at the given level.
EDGE TRIGGERING:
In the image you notice two edges, Rising Edge and Falling Edge, respectively. When an event is triggered at a
rising/falling edge, it is said to be edge triggered.
Consider the LED you wanted to turn on, but now by (rising) edge triggering. It means that the LED
turns on every time the clock makes a transition from VH to VL, and not when it is at the respective levels. The
voltage level of the clock doesn't matter much and the LED turns on the moment there is a transition from low
voltage level to high voltage level.
Registers:
Registers are a type of computer memory used to quickly accept, store, and transfer data and
instructions that are being used immediately by the CPU. The registers used by the CPU are often termed as
Processor registers.
Shift Registers:
Flip flops can be used to store a single bit of binary data (1or 0). However, in order to store multiple
bits of data, we need multiple flip flops. N flip flops are to be connected in an order to store n bits of data. A
Register is a device which is used to store such information. It is a group of flip flops connected in series used
to store multiple bits of data.
The information stored within these registers can be transferred with the help of shift registers. Shift
Register is a group of flip flops used to store multiple bits of data. The bits stored in such registers can be
made to move within the registers and in/out of the registers by applying clock pulses. An n-bit shift register
can be formed by connecting n flip-flops where each flip flop stores a single bit of data.
Shift registers are basically of 4 types. These are:
1. Serial In Serial Out shift register
2. Serial In parallel Out shift register
3. Parallel In Serial Out shift register
4. Parallel In parallel Out shift register
1. Serial In Parallel Out Register (SIPO): The shift register, which allows serial input (one bit after the
other through a single data line) and produces a parallel output is known as Serial-In Parallel-Out shift
register.
The logic circuit given below shows a serial-in-parallel-out shift register. The circuit consists of
four D flip-flops which are connected. The clear (CLR) signal is connected in addition to the clock signal
to all the 4 flip flops in order to RESET them. The output of the first flip flop is connected to the input of
the next flip flop and so on. All these flip-flops are synchronous with each other since the same clock
signal is applied to each flip flop.
2. Serial In Parallel Out (SIPO): The shift register, which allows serial input (one bit after the other
through a single data line) and produces a parallel output is known as Serial-In Parallel-Out shift
register.
The logic circuit given below shows a serial-in-parallel-out shift register. The circuit consists of
four D flip-flops which are connected. The clear (CLR) signal is connected in addition to the clock signal
to all the 4 flip flops in order to RESET them. The output of the first flip flop is connected to the input of
3. Parallel In Serial Out (PISO): The shift register, which allows parallel input (data is given separately to
each flip flop and in a simultaneous manner) and produces a serial output is known as Parallel-In Serial-
Out shift register.
The logic circuit given below shows a parallel-in-serial-out shift register. The circuit consists of
four D flip-flops which are connected. The clock input is directly connected to all the flip flops but the
input data is connected individually to each flip flop through a multiplexer at the input of every flip
flop. The output of the previous flip flop and parallel data input are connected to the input of the MUX
and the output of MUX is connected to the next flip flop. All these flip-flops are synchronous with each
other since the same clock signal is applied to each flip flop.
4. Parallel In Serial Out (PISO): The shift register, which allows parallel input (data is given separately to
each flip flop and in a simultaneous manner) and also produces a parallel output is known as Parallel-In
parallel-Out shift register.
The logic circuit given below shows a parallel-in-parallel-out shift register. The circuit consists of
four D flip-flops which are connected. The clear (CLR) signal and clock signals are connected to all the 4
flip flops. In this type of register, there are no interconnections between the individual flip-flops since
no serial shifting of the data is required. Data is given as input separately for each flip flop and in the
same way, output also collected individually from each flip flop.
A Parallel in Parallel out (PIPO) shift register is used as a temporary storage device and like SISO Shift
register it acts as a delay element.
Counter
A Counter is a device which stores (and sometimes displays) the number of times a particular event or
process has occurred, often in relationship to a clock signal. Counters are used in digital electronics for
counting purpose, they can count specific event happening in the circuit. For example, in UP counter a counter
increases count for every rising edge of clock. Not only counting, a counter can follow the certain sequence
based on our design like any random sequence 0, 1,3,2… .They can also be designed with the help of flip flops.
Counters are broadly divided into two categories;
1. Asynchronous counter
2. Synchronous counter
It is evident from timing diagram that Q0 is changing as soon as the falling edge of clock pulse is
encountered, Q1 is changing when rising edge of Q0 is encountered(because Q0 is like clock pulse for
second flip flop) and so on. In this way ripples are generated through Q0, Q1, Q2, Q3 hence it is also
called RIPPLE counter.
2. Synchronous counter: Unlike the asynchronous counter, synchronous counter has one global clock
which drives each flip flop so output changes in parallel. The one advantage of synchronous counter
over asynchronous counter is, it can operate on higher frequency than asynchronous counter as it does
not have cumulative delay because of same clock is given to each flip flop.
Ripple Counter
Ripple counter is a special type of Asynchronous counter in which the clock pulse ripples through the
circuit. The N-MOD ripple counter forms by combining n number of flip-flops. The N-MOD ripple counter can
count 2n states, and then the counter resets to its initial value.
Based on their circuitry design, the counters are classified into the following types:
1. Up counter: The Up counter counts the state in ascending order (0, 1, 2, 3, 4, 5, ……).
2. Down counter: The Up counter counts the state in ascending order (……., 5, 4, 3, 2, 1).
In the circuit design of the binary ripple counter, two JK flip flops are used. The high voltage signal is
passed to the inputs of both flip flops. This high voltage input maintains the flip flops at a state 1. In JK flip
flops, the negative triggered clock pulse use.
The outputs Q0 and Q1 are the LSB and MSB bits, respectively. The truth table of JK flip flop helps us to
understand the functioning of the counter.
When the high voltage to the inputs of the flip flops, the fourth condition is of the JK flip flop occurs.
The flip flops will be at the state 1 when we apply high voltage to the input of the flip-flop. So, the states of the
flip flops passes are toggled at the negative going end of the clock pulse. In simple words, the flip flop toggle
when the clock pulse transition takes place from 1 to 0.
Modulus Counters
MOD counters are defined based on the number of states that the counter will sequence through
before returning back to its original value. For example, a 2-bit counter that counts from (00)2 to (11)2 in
binary, that is 0 to 3 in decimal, has a modulus value of 4 ( 00 → 01 → 10 → 11, and return back to 00 ) so
would therefore be called a modulo-4, or mod-4, counter. Note also that it has taken four clock pulses to get
from 00 to 11.
As in this simple example there are only two bits, (n = 2) then the maximum number of possible output
states (maximum modulus) for the counter is: 2n = 22 or 4. However, counters can be designed to count to any
number of 2n states in their sequence by cascading together multiple counting stages to produce a single
modulus or MOD-N counter.
Step 4: Using the excitation table of JK flip-flop, we need to obtain the flip-flop inputs for each state that we
obtained in the third step and now we will enter it into a table as:
Step 5: Making K-Map for each input combination and simplifying it to get the minimized Boolean expression.
Example 2: Design a mod-10 synchronous counter/ Decade counter/ BCD counter using T flip-flop.
Solution,
A mod-10 counter counts from 0 to 9. Thus, following the steps given in the article - designing of
synchronous counter, a mod-10 counter can be designed as:
Step 1: The number of flip-flops required to design a mod-10 counter can be calculated using the
formula: N<=2n, where n is equal to no. of flip-flop and N is the mod number. In this case, the
possible value on n which satisfies the above equation is 4. Hence, the required number of flip-
flops is 4.
Step 3: Draw the state diagram for mod-10 counter describing the state flow in current and next state
as:
Step 4: Using the excitation table of T flip-flop, we need to obtain the flip-flop inputs for each state
that we obtained in the third step and now we will enter it into a table as:
Step 6: Using the Boolean expressions obtained in step 5, now we will draw the required counter
circuit which can be shown as:
Step 1: The number of flip-flops required to design a mod-12 counter can be calculated using the
formula: N<=2n, where n is equal to no. of flip-flop and N is the mod number. In this case, the possible
value on n which satisfies the above equation is 4. Hence, the required number of flip-flops is 4.
Step 2: The type of flip-flop required to design the counter is T flip-flop.
Step 4: Using the excitation table of T flip-flop, we need to obtain the flip-flop inputs for each state that we
obtained in third step and now we will enter it into a table as:
Step 6: Using the Boolean expressions obtained in step 5, now we will draw the required counter circuit which
can be shown as:
Johnson Counter
Johnson counter also known as creeping counter, is an example of synchronous counter. In Johnson
counter, the complemented output of last flip flop is connected to input of first flip flop and to implement n-
bit Johnson counter we require n flip-flop. It is one of the most important type of shift register counter. It is
formed by the feedback of the output to its own input. Johnson counter is a ring with an inversion. Another
name of Johnson counter are: creeping counter, twisted ring counter, walking counter, mobile counter and
switch tail counter.
Truth Table:
Timing Diagram:
Address bus: An element in a computer that transmits the location of stored information. The address
bus allows the CPU to send the address to RAM, and the data bus allows the actual data transfer to the
CPU.
𝐑/𝐖̅ : It performs Read operation, when 1 is applied and performs Write operation when 0 is applied.
Chip Selection Lines: Chip select (CS) is the name of a control line in digital electronics used to select
one (or a set) of integrated circuits (commonly called "chips") out of several connected to the same
computer bus.
Data bus: It is a group of conducting wires which carries Data only. Data bus is bidirectional because
data flow in both directions, from CPU to memory or Input/Output devices and from memory or
Input/Output devices to CPU.
Read/Write operation in Memory: A memory unit stores binary information in groups of bits called words.
Data input lines provide the information to be stored into the memory, Data output lines carry the
information out from the memory. The control lines Read and write specifies the direction of transfer of data.
Basically, in the memory organization, there are memory locations indexing from 0 to 𝟐𝒍 − 𝟏 where 𝒍 is the
address buses. We can describe the memory in terms of the bytes using the following formula:
𝑵 = 𝟐𝒍 𝑩𝒚𝒕𝒆𝒔
Where,
𝒍 is the total address buses
N is the memory in bytes
Memory Address Register (MAR) is the address register which is used to store the address of the memory
location where the operation is being performed.
In the above diagram initially, MDR can contain any garbage value and MAR is containing 2003 memory
address. After the execution of read instruction, the data of memory location 2003 will be read and the MDR
will get updated by the value of the 2003 memory location (3D).
In the above diagram, the MAR contains 2003 and MDR contains 3D. After the execution of write instruction
3D will be written at 2003 memory location.
Timing Waveforms: The operation of the memory unit is controlled by an external device such as a central
processing unit (CPU). The CPU is usually synchronized by its own clock .The memory however doesn’t employ
an internal clock. Instead it’s read and write operations are specified by control inputs.
The access time of memory is the time required to select a word and read it. The cycle time of memory
is the time required to complete a write operation.
enable is activated. The CPU can transfer the data into one of its internal registers during the negative transition
of T3.The next T1 cycle is available for another memory request.
For a write operation, the CPU must provide the address and input data to the memory. This is done at
the beginning of TI. The memory enable and the read/write signals must be activated after the signals in the
address lines are stable in order to avoid destroying data in other memory words.
The memory enable signal switches to the high level and the read/write signal switches to the low level
to indicate a write operation. The two control signals must stay active for at least 50 ns. The address and data
signals must remain stable for a short time after the control signals are deactivated. At the completion of the
third clock cycle, the memory write operation is completed and the CPU can access the memory again with the
next TI cycle.
Memory Decoding
In addition to requiring storage components in a memory unit, there is a need for decoding circuits to
select the memory word specified by the input address.
The storage part of the cell is modeled by an SR latch with associated gate s to form a D latch. Actually,
the cell is an electronic circuit with four to six transistors. The select input enables the cell for reading or
The logical construction of a small RAM consists of four words of four bits each and Word X total of 16
binary cells. The small blocks labeled BC represent the binary cell with its three inputs and one output. A
memory with four words needs two address lines. The two address inputs go through a 2:4 decoder to select
one of the four words. The decoder is enabled with the memory-enable input.
When the memory enable is 0, all outputs of the decoder are 0 and none of the memory words are
selected. With the memory select at 1, one of the four words is selected, dictated by the value in the two
address lines.
Once a word has been selected, the read/write input determines the operation. During the read
operation the four bits of the selected word go through OR gates to the output terminals.
During the write operation, the data available in the input lines arc transferred into the four binary
cells of the selected word. The binary cells that are not selected are disabled and their previous binary values
remain unchanged.
Output Hazard
A hazard, if exists, in a digital circuit causes a temporary fluctuation in output of the circuit. In other
words, a hazard in a digital circuit is a temporary disturbance in ideal operation of the circuit which if given
some time, gets resolved itself. These disturbances or fluctuations occur when different paths from the input
to output have different delays and due to this fact, changes in input variables do not change the output
instantly but do appear at output after a small delay caused by the circuit building elements, i.e., logic gates.
There are three different kinds of hazards found in digital circuits,
1. Static hazard
2. Dynamic hazard
3. Functional hazard
The pair of 1’s encircled as green are not part of the grouping/pairing provided by the output of this
Boolean function. This will cause a static-1 hazard in this circuit.
Note that there is no difference in number of minterms of this function. The reason is that the static-1
hazards are based on how we group 1’s (or 0’s for static-0 hazard) for a given set of 1’s in K-map. Thus it does
not make any difference in number of 1’s in K-map. The circuit would look like as shown below with the
change made for removal of static-1 hazard.
Similarly for Static-0 Hazards we need to consider 0’s instead of 1’s and if any adjacent 0’s in K-map are
not grouped into same group that may cause a static-0 hazard. The method to detect and resolve the static-0
hazard is completely same as the one we followed for static-1 hazard except that instead of SOP, POS will be
used as we are dealing with 0’s in this case.
Status Register
It also known as flag register, program status word, and condition code register — is defined as a
collective of flag bits inside a processor. A register is a processor circuit and is much like a memory location,
meaning data could be written and read from it. Types of flag,
1. Carry Flag (CY): After performing the addition of any two 8-bit numbers, the carry generated can be
either 0 or 1. That is only 1-bit. Thus to store the carry information 1-bit storage is enough.
2. Sign Flag (S): The S flag is set to 1, when the result thus produced against any logical or arithmetic
operations is negative, indicated by MS bit of 8-bit result being 1. It is reset to 0 otherwise if the result
is positive, indicated by MS bit of 8-bit result being 0.
3. Parity Flag (P): The P flag is set to 1, if the 8-bit result thus produced against any logical and arithmetic
operation has an even number of 1's in it. If there are odd number of 1's in the 8-bit result, the P flag is
reset to 0.
4. Zero flag (Z): The P flag is set to 1, if the 8-bit result thus produced against any logical and arithmetic
operation has an even number of 1's in it. If there are odd number of 1's in the 8-bit result, the P flag is
reset to 0.
Initially,
Assumption: Each instruction will use the result of the previous instruction for registers. Following is the
description of each instruction with register content and flag status:
Instruction-1: SUB A, instruction will subtract the content of the accumulator itself. It is used to clear
the content of the accumulator. After this operation the content of the registers and flags will be like
figure given below.
Instruction-2: MOV B, A will copy the content from source register (A) to the destination register (B).
Since it is the Data Transfer instruction so it will not affect any flag. After this operation the content of
the registers and flags will be like figure given below.
Instruction-3: DCR B, will decrease the content of the register B by 1. DCR operation doesn’t affect
Carry flag (CY).
B-00H 0 0 0 0 0 0 0 0
For DCR B takes the 2’s complement of the 01H, 2’s Complement of 01H:
0000 0001
1 1 1 1 1 1 1 0 (1's complement)
+1
-------------------
1111 1111
-------------------
Instruction-4: INR B will increase the content of the register B by 1. INR operation will affect Carry
flag (CY).
B(FFH)
1111 1111
+(01) 0000 0001
------------------
CY=1 0000 0000
------------------
(0 0 0 0 0 0 0 0) will be the content of the register B. So after this operation the content of the registers
and flag will be like figure given below.
Fig: Eight operations obtained by controlling one set of inputs to a parallel adder
The conventional logic diagram of 4 bit arithmetic circuit is shown in figure below. The circuit that controls the
input B to provide various type of operation shown in figure 4 consists of two NAND gates, one OR gate and
one NOT gate. The circuit is called a true/complement, one/zero element.
From the above figure, we can see that the parallel adder constitutes of four full adder .The carry into
the first stage is the input carry. The carry out of the fourth stage is the output carry. The selection variables
are S1, S0 and Cin. Variables S1S0 control all the B inputs to the full adder circuits. The A inputs go directly to the
other inputs of the full adder. The arithmetic circuit operation is given below in table.
Function Select B input Output Function
S1 S0 Cin
0 0 0 0 F=A Transfer A
0 0 1 0 F=A+1 Increment A
0 1 0 B F=A+B Add B to A
0 1 1 B F=A+B+1 Add B to A plus 1
1 0 0 B’ F=A+B’ Add 1’s complement of B to A
1 0 1 B’ F=A+B’+1 Add 2’s complement of B to A
1 1 0 All 1’s F=A-1 Decrement A
1 1 1 All 1’s F=A Transfer A
The conditional branch instruction checks the conditions for branching using the status bits. Some of
the commonly used conditional branch instructions are shown in the table.
Thus, when the status condition is true, the program control is transferred to the address specified in
the instruction, otherwise, the control continues with the instructions that are in the subsequent locations.
The conditional instructions are also associated with the program control instructions such as jump, call, or
return.
The zero status bit checks if the result of the ALU is zero or not. The carry bit checks if the most
significant bit position of the ALU has a carryout. It is also used with rotate instruction to check whether or not
the bit is shifted from the end position of a register into a carry position.
The sign bit indicates the state of the most significant bit of the output from the ALU (S = 0 denotes
positive sign and S = 1 denotes negative sign). The branch if plus and branch if minus is used to check whether
the value of the most significant bit represents a sign or not. The overflow and underflow instructions are used
in conjunction with arithmetic operations performed on signed numbers.
The higher and lower words are used to denote the relations between unsigned numbers, whereas the
greater and lesser words are used to denote the relations between signed numbers.