Chapter 2 · 1 hour
Digital Logic
IOE past exam questions
Past questions and answers
27 questions set from this chapter, 5 of them more than once. Most asked first.
- Asked 3 times
- 2080 Bhadra · 2+3 marks
- 2080 Baisakh · 5+3 marks
- 2078 Bhadra · 2+4 marks
State and prove De-Morgan's theorems with necessary diagrams. Construct XOR gate using minimum number of NAND gates.
Answer
De Morgan's theorems
De Morgan's theorems tell how to complement a sum or a product of variables.
Theorem 1: The complement of a sum equals the product of the complements.
So a NOR gate equals a bubbled AND gate (AND with inverted inputs).
Theorem 2: The complement of a product equals the sum of the complements.
So a NAND gate equals a bubbled OR gate (OR with inverted inputs).
Proof by truth table
| A | B | ||||||
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 |
Column 4 = column 5 and column 7 = column 8 for every input, so both theorems are proved.
Algebraic proof of Theorem 1: if and , then and . Since and , Y is the complement of X. Theorem 2 follows by duality.
Diagrams
Theorem 1: NOR = bubbled AND
A --|‾‾‾\ A --o|‾‾‾\
| OR )o-- Y = | AND )-- Y
B --|___/ B --o|___/
Theorem 2: NAND = bubbled OR
A --|‾‾‾\ A --o|‾‾‾\
| AND )o-- Y = | OR )-- Y
B --|___/ B --o|___/
(o = inversion bubble)
XOR using minimum NAND gates
. It can be built with 4 two-input NAND gates:
A --+-------------[NAND G2]--+
| | |
+--[NAND G1]---+ +--[NAND G4]-- Y
| | |
B --+-------------[NAND G3]--+
G1 output feeds one input of both G2 and G3; A goes to G2, B goes to G3; G2 and G3 feed G4.
| A | B | G1 | G2 | G3 | Y |
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 0 |
| 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 0 |
- Asked 2 times
- 2079 Bhadra · 2+3 marks
- 2079 Baisakh · 6 marks
Define positive and negative logic and prove that positive X-OR is equivalent to negative X-NOR.
Answer
Positive and negative logic
- Positive logic: the higher voltage level represents logic 1 and the lower level represents logic 0. Example in TTL: +5 V = 1, 0 V = 0.
- Negative logic: the higher voltage level represents logic 0 and the lower level represents logic 1. Example: +5 V = 0, 0 V = 1 (or in a –5 V system, –5 V = 1, 0 V = 0).
The same physical circuit gives a different logic function depending on which convention is used. Changing from positive to negative logic means complementing every input and output bit.
Proof: positive XOR = negative XNOR
Take a gate working as XOR in positive logic. Its voltage table (H = high, L = low):
| A | B | Y |
|---|---|---|
| L | L | L |
| L | H | H |
| H | L | H |
| H | H | L |
Positive logic (H = 1, L = 0):
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
This is XOR: .
Negative logic (H = 0, L = 1) for the same circuit:
| A | B | Y |
|---|---|---|
| 1 | 1 | 1 |
| 1 | 0 | 0 |
| 0 | 1 | 0 |
| 0 | 0 | 1 |
Output is 1 when both inputs are equal, which is XNOR: .
Algebraic proof: in negative logic the function becomes the complement of positive XOR with complemented inputs:
(since ). Hence the positive-logic XOR gate is the same circuit as a negative-logic XNOR gate.
- Asked 2 times
- 2073 Shrawan · 5 marks
- 2072 Chaitra · 4 marks
Construct two input XOR gate using minimum number of 2-input NAND gates only.
Answer
An XOR gate gives . With NAND gates only, the minimum is four 2-input NAND gates.
Derivation
So the gates are:
Circuit
A --+-----------------|‾‾\
| |G2 |o--+
| |‾‾\ +----|__/ | |‾‾\
+--|G1 |o----+ +---|G4 |o-- Y
+--|__/ +----|‾‾\ +---|__/
| |G3 |o--+
B --+-----------------|__/
Verification
| A | B | Y | |||
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 0 |
| 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 0 |
Output Y is 1 only when the inputs differ, which is the XOR function. Total: 4 NAND gates.
- Asked 2 times
- 2082 Shrawan · 3 marks
- 2081 Baisakh · 2 marks
Explain a positive logic and the negative logic with suitable examples.
Answer
In a digital circuit the two logic states are shown by two voltage levels. Which level is called 1 decides whether the system uses positive or negative logic.
- Positive logic: HIGH voltage = logic 1, LOW voltage = logic 0. Example: in TTL, +5 V = 1 and 0 V = 0. Most systems use positive logic.
- Negative logic: HIGH voltage = logic 0, LOW voltage = logic 1. Example: +5 V = 0 and 0 V = 1; or in an ECL / –5 V system, –5 V = 1 and 0 V = 0.
Positive logic Negative logic
+5V ---- 1 +5V ---- 0
0V ---- 0 0V ---- 1
Example: a circuit has this voltage table:
| A | B | Y |
|---|---|---|
| L | L | L |
| L | H | L |
| H | L | L |
| H | H | H |
- In positive logic (H = 1): Y = 1 only when A = B = 1, so it is an AND gate.
- In negative logic (H = 0): Y = 0 only when A = B = 0, so it is an OR gate.
So positive AND = negative OR, and similarly positive OR = negative AND, positive NAND = negative NOR, positive XOR = negative XNOR. The physical gate is the same; only the meaning of the levels changes.
- Asked 2 times
- 2082 Shrawan · 2 marks
- 2076 Chaitra · 2 marks
State and prove De-Morgan's laws.
Answer
First theorem: the complement of a sum (OR) of variables equals the product (AND) of their complements.
Second theorem: the complement of a product (AND) of variables equals the sum (OR) of their complements.
In words: "break the bar and change the sign".
Proof by truth table
| A | B | ||||
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 | 0 |
For all four input combinations, column 3 equals column 4 and column 5 equals column 6, so both theorems are proved.
Algebraic proof (Theorem 1): let and . Then and . A variable that ORs with X to give 1 and ANDs with X to give 0 is , so . Theorem 2 follows by duality.
- 2081 Baisakh · 2+3 marks
What is the importance of De-Morgan's laws? Show how a two-input XOR gate can be constructed from a two-input NAND gate with required expressions.
Answer
Importance of De Morgan's laws
De Morgan's laws, and , are important because:
- They let us complement any Boolean expression (break the bar, change AND ↔ OR).
- They convert SOP forms to NAND-NAND and POS forms to NOR-NOR circuits, so any circuit can be built with one type of universal gate, which reduces IC types and cost.
- They show gate equivalences: NAND = bubbled OR, NOR = bubbled AND; useful for reading and drawing circuits with active-low signals.
- They help in simplifying expressions and in proving positive/negative logic equivalences.
XOR from 2-input NAND gates
needs four 2-input NAND gates.
Gates: , , , .
A --+---------------[NAND G2]--+
| | |
+--[NAND G1]--G1--+ +--[NAND G4]-- Y
| | |
B --+---------------[NAND G3]--+
| A | B | Y | |||
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 0 |
| 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 0 |
- 2080 Bhadra · 2+4 marks
Define positive and negative logic. Realize X-NOR gate using NAND gates only.
Answer
Positive and negative logic
- Positive logic: HIGH voltage = logic 1, LOW voltage = logic 0 (e.g. TTL: +5 V = 1, 0 V = 0).
- Negative logic: HIGH voltage = logic 0, LOW voltage = logic 1 (e.g. +5 V = 0, 0 V = 1).
The same physical gate performs a different logic function in the two systems, because changing the convention complements every input and output. Example: a gate whose output is HIGH only when both inputs are HIGH is an AND gate in positive logic but an OR gate in negative logic.
XNOR using NAND gates only
. First build XOR with 4 NAND gates, then invert it with a fifth NAND gate whose two inputs are tied together (). Minimum: 5 NAND gates.
A --+-----------[NAND G2]--+
| | |
+--[NAND G1]---+ +--[NAND G4]--+--[NAND G5]-- Y
| | | +--|
B --+-----------[NAND G3]--+ (inputs tied: NOT)
| A | B | Y | ||||
|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 0 | 1 |
| 0 | 1 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 | 1 | 0 |
| 1 | 1 | 0 | 1 | 1 | 0 | 1 |
Y is 1 when both inputs are equal, which is XNOR.
- 2079 Bhadra · 2+4 marks
State and prove De-Morgan's theorems with necessary diagrams and prove that positive NAND equivalent is equal to negative NOR.
Answer
De Morgan's theorems
First theorem: the complement of a sum (OR) of variables equals the product (AND) of their complements.
Second theorem: the complement of a product (AND) of variables equals the sum (OR) of their complements.
In words: "break the bar and change the sign".
Proof by truth table
| A | B | ||||
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 | 0 |
For all four input combinations, column 3 equals column 4 and column 5 equals column 6, so both theorems are proved.
Diagrams
Theorem 1: NOR = bubbled AND
A --|‾‾‾\ A --o|‾‾‾\
| OR )o-- Y = | AND )-- Y
B --|___/ B --o|___/
Theorem 2: NAND = bubbled OR
A --|‾‾‾\ A --o|‾‾‾\
| AND )o-- Y = | OR )-- Y
B --|___/ B --o|___/
(o = inversion bubble)
Positive NAND = negative NOR
Consider a gate whose voltage table is:
| A | B | Y |
|---|---|---|
| L | L | H |
| L | H | H |
| H | L | H |
| H | H | L |
Positive logic (H = 1, L = 0):
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Output is 0 only when both inputs are 1: a NAND gate.
Negative logic (H = 0, L = 1), same circuit:
| A | B | Y |
|---|---|---|
| 1 | 1 | 0 |
| 1 | 0 | 0 |
| 0 | 1 | 0 |
| 0 | 0 | 1 |
Output is 1 only when both inputs are 0: a NOR gate.
Algebraically: going to negative logic complements all inputs and the output:
Hence positive-logic NAND is equivalent to negative-logic NOR.
- 2076 Chaitra · 3+3 marks
State and prove the De-Morgan's theorem and perform the addition (-47+27) by using 2's complement method.
Answer
De Morgan's theorems
First theorem: the complement of a sum (OR) of variables equals the product (AND) of their complements.
Second theorem: the complement of a product (AND) of variables equals the sum (OR) of their complements.
In words: "break the bar and change the sign".
Proof by truth table
| A | B | ||||
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 | 0 |
For all four input combinations, column 3 equals column 4 and column 5 equals column 6, so both theorems are proved.
(−47) + (27) using 2's complement
Use 8-bit signed numbers (range −128 to +127).
Step 1: +47 and +27 in binary
Step 2: 2's complement of 47 (to get −47)
+47 = 0010 1111
1's complement = 1101 0000
add 1 = 1101 0001 (= -47)
Step 3: Add
-47 = 1101 0001
+ +27 = 0001 1011
-------------------
1110 1100
No carry out of the MSB, and the sign bit is 1, so the result is negative and is in 2's complement form.
Step 4: Find its magnitude (take 2's complement)
result = 1110 1100
1's complement = 0001 0011
add 1 = 0001 0100 = 20
Check: .
Answer: in 2's complement
- 2076 Asoj · 2+3 marks
Describe De' Morgan's laws with examples. Construct XOR gate using only 3-inputs NAND gates.
Answer
De Morgan's laws
First theorem: the complement of a sum (OR) of variables equals the product (AND) of their complements.
Second theorem: the complement of a product (AND) of variables equals the sum (OR) of their complements.
In words: "break the bar and change the sign".
Examples
- and (extended to 3 variables).
- .
- Check with A = 1, B = 0: and .
XOR gate using only 3-input NAND gates
A 3-input NAND gives . If one input is tied to logic 1 (HIGH, e.g. +5 V through a resistor), it behaves as a 2-input NAND: . (Tying the unused input to one of the used inputs also works, since .) So the 4-NAND XOR circuit is built with four 3-input NAND gates:
A --+-------------[NAND3 G2]--+
| | 1 -->|
+--[NAND3 G1]---+ +--[NAND3 G4]-- Y
| 1 -->| | | 1 -->|
B --+-------------[NAND3 G3]--+
1 -->|
(1 --> : third input tied to logic HIGH)
| A | B | Y | |||
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 0 |
| 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 0 |
- 2075 Asoj · 4 marks
Design half subtractor circuit using HDL.
Answer
A half subtractor subtracts one bit B from another bit A and gives a Difference (D) and a Borrow (Bo).
| A | B | D | Bo |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 |
A --+--[XOR]------------ D
B --+--|
A --[NOT]--[AND]-------- Bo
B ---------|
Verilog HDL description
// Half subtractor: gate-level (structural) model
module half_sub_gate (input A, B, output D, Bo);
wire An; // complement of A
xor g1 (D, A, B); // D = A XOR B
not g2 (An, A); // An = A'
and g3 (Bo, An, B); // Bo = A'B
endmodule
// Same circuit: dataflow model
module half_sub_df (input A, B, output D, Bo);
assign D = A ^ B; // difference
assign Bo = ~A & B; // borrow
endmodule
Test bench (simulation)
module tb;
reg A, B; wire D, Bo;
half_sub_df uut (A, B, D, Bo);
initial begin
$monitor("A=%b B=%b D=%b Bo=%b", A, B, D, Bo);
{A,B} = 2'b00; #10 {A,B} = 2'b01;
#10 {A,B} = 2'b10; #10 {A,B} = 2'b11;
#10 $finish;
end
endmodule
Simulation output matches the truth table, e.g. A=0 B=1 D=1 Bo=1 and A=1 B=1 D=0 Bo=0.
- 2074 Chaitra · 4+2 marks
State and prove De-Morgan's theorems with necessary diagrams. Prove that negative logic OR Gate is equivalent to positive logic AND Gate.
Answer
De Morgan's theorems
First theorem: the complement of a sum (OR) of variables equals the product (AND) of their complements.
Second theorem: the complement of a product (AND) of variables equals the sum (OR) of their complements.
In words: "break the bar and change the sign".
Proof by truth table
| A | B | ||||
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 | 0 |
For all four input combinations, column 3 equals column 4 and column 5 equals column 6, so both theorems are proved.
Algebraic proof (Theorem 1): let , . Then and , so . Theorem 2 follows by duality.
Diagrams
Theorem 1: NOR = bubbled AND
A --|‾‾‾\ A --o|‾‾‾\
| OR )o-- Y = | AND )-- Y
B --|___/ B --o|___/
Theorem 2: NAND = bubbled OR
A --|‾‾‾\ A --o|‾‾‾\
| AND )o-- Y = | OR )-- Y
B --|___/ B --o|___/
(o = inversion bubble)
Negative-logic OR = positive-logic AND
Take a gate whose output is HIGH only when both inputs are HIGH:
| A | B | Y |
|---|---|---|
| L | L | L |
| L | H | L |
| H | L | L |
| H | H | H |
Positive logic (H = 1): Y = 1 only for A = B = 1 → AND.
Negative logic (H = 0, L = 1):
| A | B | Y |
|---|---|---|
| 1 | 1 | 1 |
| 1 | 0 | 1 |
| 0 | 1 | 1 |
| 0 | 0 | 0 |
Y = 0 only when both inputs are 0 → OR.
Algebraically: a negative-logic OR, seen in positive logic, has all inputs and the output complemented:
So the negative-logic OR gate is the same circuit as the positive-logic AND gate.
- 2074 Asoj · 4 marks
What is the importance of De-morgan's laws? Show how a two-input NOR gate can be constructed from a two-input NAND gate.
Answer
Importance of De Morgan's laws
De Morgan's laws (, ) are used to:
- complement Boolean expressions easily;
- convert AND-OR (SOP) circuits to NAND-NAND and OR-AND (POS) circuits to NOR-NOR;
- build every gate from one universal gate (NAND or NOR), reducing chip types and cost;
- show gate equivalences such as NAND = bubbled OR and NOR = bubbled AND.
NOR gate from 2-input NAND gates
Required: . By De Morgan, , so:
Four NAND gates are needed: two as input inverters, one to make OR, and one as the output inverter.
A --[NAND G1]-- A' --+
(inputs tied) +--[NAND G3]-- A+B --[NAND G4]-- Y
B --[NAND G2]-- B' --+ (inputs tied)
| A | B | Y | |||
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 |
| 1 | 1 | 0 | 0 | 1 | 0 |
- 2072 Chaitra · 2+2 marks
Describe commutative and associative laws of Boolean algebra with examples and simplify A+A'B = A+B.
Answer
Commutative laws
The order of variables in an OR or AND operation does not change the result.
Example: ; with A = 1, B = 0: . In hardware, swapping the inputs of an AND or OR gate does not change its output.
Associative laws
The grouping of variables in an OR or AND operation does not change the result.
Example: with A = 1, B = 0, C = 1: and . So a 3-input AND can be built from two 2-input AND gates in any order.
Proof of
Using the distributive law :
Truth-table check:
| A | B | |||
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 |
- 2070 Chaitra · 5 marks
Prove that positive X-OR is equivalent to negative X-NOR.
Answer
In positive logic HIGH = 1 and LOW = 0; in negative logic HIGH = 0 and LOW = 1. Changing the convention complements every input and output bit of the same physical gate.
Take a gate that acts as XOR in positive logic. Its voltage table:
| A | B | Y |
|---|---|---|
| L | L | L |
| L | H | H |
| H | L | H |
| H | H | L |
Positive logic (H = 1, L = 0):
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Y = 1 when inputs differ: XOR, .
Negative logic (H = 0, L = 1), same circuit:
| A | B | Y |
|---|---|---|
| 1 | 1 | 1 |
| 1 | 0 | 0 |
| 0 | 1 | 0 |
| 0 | 0 | 1 |
Rearranged in normal order (00, 01, 10, 11) the output is 1, 0, 0, 1: Y = 1 when inputs are equal: XNOR.
Algebraic proof: complement inputs and output of the positive-logic XOR:
Hence positive-logic XOR is equivalent to negative-logic XNOR.
- 2069 Chaitra · 4 marks
Construct the given Boolean function: F = (A+B)(C+D)E using NOR gates only.
Answer
is a product of sums (POS). A POS form maps directly to a NOR-NOR circuit, using double inversion and De Morgan's law.
So:
- (2-input NOR)
- (2-input NOR)
- (NOR used as inverter)
- (3-input NOR)
A --[NOR G1]--(A+B)'--+
B --| |
C --[NOR G2]--(C+D)'--+--[NOR G4]-- F
D --| | (3-input)
E --[NOR G3]-- E' ----+
(inputs tied)
Total: 4 NOR gates (three 2-input, one 3-input). If only 2-input NORs are allowed, G4 can be replaced by: , (= ), , giving 6 gates.
Check: A = 1, B = 0, C = 0, D = 1, E = 1 → , , , F = 1; and .
- 2068 Chaitra · 2+2 marks
List out the name of universal gates and why they are called universal gate? Realise Ex-OR Gate using only NAND gates.
Answer
Universal gates
The universal gates are NAND and NOR. They are called universal because any Boolean function, and every other gate (NOT, AND, OR, XOR, XNOR), can be built using only NAND gates or only NOR gates. For example, with NAND only: NOT A = , AND = NAND followed by NOT, OR = . This lets a whole circuit be made from one type of IC (e.g. 7400), which simplifies manufacture and reduces cost.
XOR using only NAND gates
needs four 2-input NAND gates.
Gates: , , , .
A --+---------------[NAND G2]--+
| | |
+--[NAND G1]--G1--+ +--[NAND G4]-- Y
| | |
B --+---------------[NAND G3]--+
| A | B | Y | |||
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 0 |
| 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 0 |
- 2068 Baisakh · 4 marks
Why NAND and NOR gates are called Universal gates? Illustrate with examples.
Answer
NAND and NOR gates are called universal gates because each of them alone can realise the three basic operations NOT, AND and OR, and therefore any Boolean function. A complete circuit can thus be made using only one type of gate (e.g. 7400 quad NAND or 7402 quad NOR), which reduces inventory, cost and design effort.
Using NAND only
| Gate | Realisation | Gates |
|---|---|---|
| NOT | 1 | |
| AND | 2 | |
| OR | 3 |
NOT: A --[NAND]-- A' (inputs tied)
AND: A,B --[NAND]--[NAND]-- AB
OR : A --[NAND]-- A' --+
B --[NAND]-- B' --+--[NAND]-- A+B
Using NOR only
| Gate | Realisation | Gates |
|---|---|---|
| NOT | 1 | |
| OR | 2 | |
| AND | 3 |
NOT: A --[NOR]-- A'
OR : A,B --[NOR]--[NOR]-- A+B
AND: A --[NOR]-- A' --+
B --[NOR]-- B' --+--[NOR]-- AB
Example: can be done with three NAND gates: (NAND-NAND form of an SOP).
- 2068 Baisakh · 2+3 marks
What do you mean by HDL? Design a 2 to 4 line decoder circuit using HDL.
Answer
HDL
A Hardware Description Language (HDL) is a computer language used to describe the structure and behaviour of digital circuits in text form. The description can be simulated to check the design and synthesised into gates for an FPGA, CPLD or ASIC. Common HDLs are Verilog and VHDL. A design can be written at gate level (structural), dataflow (assign equations) or behavioural (always blocks) level.
2-to-4 line decoder
Inputs A1 A0 and enable E; exactly one output goes HIGH for each input code when E = 1.
| E | A1 | A0 | D3 | D2 | D1 | D0 |
|---|---|---|---|---|---|---|
| 0 | x | x | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
, , ,
Verilog (dataflow model)
module decoder2to4 (input A1, A0, E,
output D0, D1, D2, D3);
assign D0 = E & ~A1 & ~A0; // 00
assign D1 = E & ~A1 & A0; // 01
assign D2 = E & A1 & ~A0; // 10
assign D3 = E & A1 & A0; // 11
endmodule
Verilog (gate-level model)
module decoder2to4_g (input A1, A0, E,
output D0, D1, D2, D3);
wire n1, n0;
not (n1, A1); // A1'
not (n0, A0); // A0'
and (D0, E, n1, n0);
and (D1, E, n1, A0);
and (D2, E, A1, n0);
and (D3, E, A1, A0);
endmodule
With E = 1 and A1A0 = 10, simulation gives D3D2D1D0 = 0100.
- 2082 Shrawan · 3 marks
Realize 2 inputs XOR gates using NOR gates only.
Answer
. Build XNOR with 4 NOR gates and invert it with a fifth NOR (inputs tied). Minimum: 5 NOR gates.
A --+-----------[NOR G2]--+
| | |
+--[NOR G1]----+ +--[NOR G4]--[NOR G5]-- Y
| | | (inputs tied)
B --+-----------[NOR G3]--+
| A | B | Y | ||||
|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 | 0 | 1 |
| 1 | 0 | 0 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 0 | 1 | 0 |
- 2082 Baisakh · 2+4 marks
Define the positive and negative logic. State and verify 3-bits De Morgan's theorem.
Answer
Positive and negative logic
- Positive logic: HIGH voltage = logic 1, LOW voltage = logic 0 (e.g. TTL: +5 V = 1, 0 V = 0).
- Negative logic: HIGH voltage = logic 0, LOW voltage = logic 1 (e.g. +5 V = 0, 0 V = 1).
The same physical gate performs a different logic function in the two systems, because changing the convention complements every input and output. Example: a gate whose output is HIGH only when both inputs are HIGH is an AND gate in positive logic but an OR gate in negative logic.
De Morgan's theorem for 3 variables
Theorem 1:
Theorem 2:
Verification by truth table
| A | B | C | ||||
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 0 | 1 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 0 | 0 | 0 | 0 |
Columns 4 and 5 are identical, and columns 6 and 7 are identical for all 8 combinations, so both theorems hold for 3 variables.
Algebraic check (using the 2-variable law with ):
Similarly, .
3-input NOR = bubbled 3-input AND
3-input NAND = bubbled 3-input OR
- 2081 Bhadra · 2+3 marks
State De Morgan's Laws. Construct 2 input XNOR gate using only NOR gates.
Answer
De Morgan's laws
First theorem: the complement of a sum (OR) of variables equals the product (AND) of their complements.
Second theorem: the complement of a product (AND) of variables equals the sum (OR) of their complements.
In words: "break the bar and change the sign".
Example: and .
2-input XNOR using only NOR gates
needs four 2-input NOR gates (the dual of the 4-NAND XOR).
A --+---------------[NOR G2]--+
| | |
+--[NOR G1]---G1--+ +--[NOR G4]-- Y
| | |
B --+---------------[NOR G3]--+
| A | B | Y | |||
|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 | 0 | 1 |
Y = 1 only when A = B, which is the XNOR function.
- 2080 Baisakh · 2+3 marks
Describe positive and negative logic with an example. Construct Ex-NOR gate using only NOR gates.
Answer
Positive and negative logic
- Positive logic: HIGH voltage = 1, LOW voltage = 0. Example: TTL with +5 V = 1, 0 V = 0.
- Negative logic: HIGH voltage = 0, LOW voltage = 1. Example: +5 V = 0, 0 V = 1.
Example: a gate gives a HIGH output only when both inputs are HIGH (L L → L, L H → L, H L → L, H H → H).
- In positive logic this is 00→0, 01→0, 10→0, 11→1: an AND gate.
- In negative logic this is 11→1, 10→1, 01→1, 00→0: an OR gate.
So positive AND = negative OR (and positive NAND = negative NOR, positive XOR = negative XNOR).
Ex-NOR gate using only NOR gates
needs four 2-input NOR gates (the dual of the 4-NAND XOR).
A --+---------------[NOR G2]--+
| | |
+--[NOR G1]---G1--+ +--[NOR G4]-- Y
| | |
B --+---------------[NOR G3]--+
| A | B | Y | |||
|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 | 0 | 1 |
- 2078 Kartik · 2+2 marks
Define universal gates with example. Explain positive and negative logic.
Answer
Universal gates
A universal gate is a gate that alone can implement NOT, AND and OR, and hence any Boolean function. NAND and NOR are universal gates.
Examples with NAND only:
- NOT:
- AND: NAND followed by a NAND inverter,
- OR:
Examples with NOR only:
- NOT:
- OR: NOR followed by a NOR inverter
- AND:
OR from NAND:
A --[NAND]-- A' --+
B --[NAND]-- B' --+--[NAND]-- A+B
Positive and negative logic
- Positive logic: HIGH level = logic 1 and LOW level = logic 0 (e.g. +5 V = 1, 0 V = 0).
- Negative logic: HIGH level = logic 0 and LOW level = logic 1.
The same circuit changes its logic name when the convention changes. A gate with output HIGH only when both inputs are HIGH is AND in positive logic but OR in negative logic; similarly positive NAND = negative NOR.
- 2078 Kartik · 3 marks
Design three input exclusive NOR gate using NOR gates only.
Answer
A 3-input XNOR gives . Use the 4-NOR XNOR block twice and one NOR inverter.
Since , two XNOR blocks give XOR, and a final NOR inverter gives XNOR:
Each XNOR block: , , , out .
A --+
+--[XNOR: 4 NOR]-- P --+
B --+ +--[XNOR: 4 NOR]-- Q
C ---+ |
Y --[NOR, inputs tied]--------+
Total: 9 NOR gates.
| A | B | C | P | Q | Y |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 | 1 |
| 0 | 0 | 1 | 1 | 1 | 0 |
| 0 | 1 | 0 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 0 | 1 |
| 1 | 0 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 0 | 1 |
| 1 | 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 | 0 |
Y = 1 when an even number of inputs are 1.
- 2076 Chaitra · 3 marks
Realize 3 inputs XOR gates using NAND gates only.
Answer
A 3-input XOR gives . Each 2-input XOR needs 4 NAND gates, so cascade two 4-NAND XOR blocks: 8 NAND gates.
Block 1: , , ,
Block 2: , , ,
A --+-------[G2]--+
+--[G1]--+ +--[G4]--P--+-------[G6]--+
B --+-------[G3]--+ +--[G5]--+ +--[G8]-- Y
C --+-------[G7]--+
(all gates are 2-input NAND)
| A | B | C | P = A⊕B | Y |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 |
| 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 1 | 0 |
| 1 | 1 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 | 1 |
Y = 1 when an odd number of inputs are 1.
- 2075 Chaitra · 4+2 marks
State and prove De Morgan's theorem. Design X-NOR gate using anyone of universal gate.
Answer
De Morgan's theorems
De Morgan's theorems tell us how to complement a sum or a product of variables.
Theorem 1: The complement of a sum equals the product of the complements.
Theorem 2: The complement of a product equals the sum of the complements.
In words: to complement an expression, change every OR into AND (and every AND into OR) and complement each variable. So a NOR gate is the same as an AND gate with inverted inputs ("bubbled AND"), and a NAND gate is the same as an OR gate with inverted inputs ("bubbled OR").
Proof by truth table
| A | B | ||||||
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 |
Column 4 equals column 5 for all inputs, which proves Theorem 1. Column 7 equals column 8, which proves Theorem 2.
Algebraic proof of Theorem 1: if and , then is the complement of only if and .
So . Theorem 2 follows by duality.
X-NOR gate using NOR gates only
Four NOR gates are enough:
A ──┬──────────────┐
│ [NOR]── G2 ──┐
├──[NOR]── G1 ─┤ [NOR]── Y = A XNOR B
│ [NOR]── G3 ──┘
B ──┴──────────────┘
(G1 = NOR(A,B); G2 = NOR(A,G1); G3 = NOR(B,G1); Y = NOR(G2,G3).)
| A | B | G1 | G2 | G3 | Y |
|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 | 0 | 1 |
The output is 1 only when A = B, so the circuit is an X-NOR gate. (With NAND gates, four NANDs give X-OR and a fifth NAND used as an inverter gives X-NOR.)
Questions from Old Question Collection (EX 502) (IOE EX 502 exam papers (BEL/BEX/BCT II/I) from 2068 to 2081) and Old Question Collection (BEI, EX 401) (IOE EX 401 exam papers (BEI I/I) from 2075 to 2082). Answers are written for this site; check them against your class notes.
Chapter titles and hours from the IOE syllabus ↗