







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
this helps in Digital Logic Design
Typology: Cheat Sheet
1 / 13
This page cannot be seen from the preview
Don't miss anything!








nd
Nam e Reg. No. Mar ks
5.1 Objectives The objectives of this experiment are: ๏ท To analyze the performance of XOR and XNOR gates ICs and draw their truth tables ๏ท To implement XOR and XNOR using basic gates only ๏ท To implement XOR and XNOR using NAND gates only 5.2 Theory In the previous labs, we saw that by using the three principal gates, the AND Gate, the OR Gate and the NOT Gate, we can build many other types of logic gate functions, such as a NAND Gate and a NOR Gate or any other type of digital logic functions. But there are two other types of digital logic gates which although they are not a basic gate as they are constructed by combining together other logic gates, their output Boolean function is important enough to be considered as complete logic gates. These two โhybridโ logic gates are called the Exclusive-OR (Ex-OR) Gate and its complement the Exclusive-NOR (Ex-NOR) Gate.
A 2-input OR gate, if A = โ1โ, OR B = โ1โ, OR BOTH A + B = โ1โ then the output from the digital gate must also be at a logic level โ1โ and because of this, this type of logic gate is known as an Inclusive-OR function. The logic gate gets its name from the fact that it includes the case of Q = โ1โ when both A and B = โ1โ. If, however, a logic output โ1โ is obtained when ONLY A = โ1โ or when ONLY B = โ1โ but NOT both together at the same time, giving the binary inputs of โ01โ or โ10โ, then the output will be โ1โ. This type of gate is known as an Exclusive-OR function or more commonly an Ex-Or function for short. This is because its Boolean expression excludes the โOR BOTHโ case of Q = โ1โ when both A and B = โ1โ. In other words, the output of an Exclusive-OR gate ONLY goes โHIGHโ when its two input terminals are at โDIFFERENTโ logic levels with respect to each other. An odd number of logics โ1โsโ on its inputs gives a logic โ1โ at the output. These two inputs can be at logic level โ1โ or at logic level โ0โ giving us the Boolean expression of: Q = (A โ B) = A.B + A.B The Exclusive-OR Gate function, or Ex-OR for short, is achieved by combining standard logic gates together to form more complex gate functions that are used extensively in building arithmetic logic circuits, computational logic comparators and error detection circuits. The two-input โExclusive-ORโ gate is basically a modulo two adders, since it gives the sum of two binary numbers and as a result are more complex in design than other basic types of logic gate. The truth table, logic symbol and implementation of a 2-input Exclusive-OR gate is shown in Figure 5.1. Figure 5.1 2-input Ex-OR gate.
Figure 5.4 2-input Ex-NOR gate The Ex-NOR function is a combination of different basic logic gates Ex-OR and a NOT gate, and by using the 2-input truth table above, we can expand the Ex-NOR function to: Q = A โ B = (A.B) + (A.B) which means we can realize this new expression using the following individual gates. Figure 5.5 2-input Ex-OR gate plus a NOT gate The Exclusive-NOR Gate, also written as: โEx-NORโ or โXNORโ, function is achieved by combining standard/basic gates together to form more complex gate functions and an example of a 2-input Exclusive-NOR gate is given in Figure 5.6. Figure 5.6 Ex-NOR gate equivalence circuit One of the main disadvantages of implementing the Ex-NOR function above is that it contains three different types of logic gates the AND, NOT and finally an OR gate within its basic design. One easier way of producing the Ex-NOR function from a single gate type is to use NAND gates as shown in Figure 5.7. Figure 5.7 Ex-NOR Function implementation using NAND gates
5.3 Equipment ๏ท DC Power Source / Power Supply ๏ท Prototype Development Board ๏ท Connecting Wires 5.4 Components ๏ท ICs (7400, 7404, 7408, 7432, 7486, 74266) ๏ท 330 ฮฉ / 1 kฮฉ resistor ยผ watt Measured: 328 ฮฉ ๏ท LEDs 5.5 ICs Pin Diagrams Figure 5.8 2-input Logic XOR Gate IC Pin Diagram 5.6 Procedu re Figure 5.9 2-input Logic XNOR Gate IC Pin Diagram
Table 5.3 Observation of XOR implementation using Basic Gates
Logic / State Logic / State Logic / State Logic / State Logic / State Logic / State 0 0 0 0 1 0 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 0 0 0 0 0 1 0 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 0 0 1 1 0 1 1 1 0 1 0 1 1 Table 5.4 Observation of XOR implementation using NAND Gates
Logic / State Logic / State Logic / State Logic / State Logic / State Logic / State 0 0 1 1 1 0 0 1 1 1 0 1 1 0 1 0 1 1 1 1 0 1 1 0 0 0 1 1 1 0 0 1 1 1 0 1 1 0 1 0 1 1 1 1 0 1 1 0 0 1 1 1 0 1 1 0 1 0 1 1
Table 5.5 Observation of XNOR implementation using Basic Gates
Logic / State Logic / State Logic / State Logic / State Logic / State Logic / State Logic / State 0 0 1 1 0 1 1 0 1 1 0 0 0 0 1 0 0 1 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 1 0 0 0 0 1 0 0 1 0 0 0 1 1 0 0 1 0 1 0 1 1 0 0 0 0 1 0 0 1 0 0 0 Table 5.6 Observation of XNOR implementation using NAND Gates
Logic / State Logic / State Logic / State Logic / State Logic / State Logic / State Logic / State 0 0 1 1 0 1 1 0 1 1 0 1 1 0 1 0 0 1 1 1 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 1 0 1 1 0 1 0 0 1 1 1 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 1 0 0 1 1 1 0 5.9 Results Table 5.7 Truth table of XOR
Ans: When any ONE input of an XOR gate is HIGH (logic 1) and the other is LOW (logic 0), the output is HIGH (logic 1). However, if BOTH inputs are HIGH simultaneously, the output is LOW (logic 0). XOR outputs HIGH only when the inputs are DIFFERENT. So a single HIGH input gives output = 1, but two HIGH inputs give output = 0.
This report presents the Verilog-based simulation of XOR and XNOR gates using three approaches: (1) minimum number of gates, (2) basic gates only (AND, OR, NOT), and (3) universal gates only (NAND gates). Truth tables are verified for all implementations.
2.1 Minimum Gate Implementation (4 NAND Gates) The XOR function can be implemented using only 4 NAND gates. This is the minimum gate count for XOR using a single gate type. The Boolean derivation is: A XOR B = NAND(NAND(A, NAND(A,B)), NAND(B, NAND(A,B))) Verilog Code โ XOR using 4 NAND Gates: module xor_4nand(input A, B, output Y);
wire C, D, E; nand(C, A, B); // Gate 1: C = NAND(A,B) nand(D, A, C); // Gate 2: D = NAND(A,C) nand(E, B, C); // Gate 3: E = NAND(B,C) nand(Y, D, E); // Gate 4: Y = NAND(D,E) = A XOR B endmodule // Testbench module tb_xor_4nand; reg A, B; wire Y; xor_4nand uut(.A(A),.B(B),.Y(Y)); initial begin $monitor("A=%b B=%b Y=%b", A, B, Y); A=0;B=0; #10; A=0;B=1; #10; A=1;B=0; #10; A=1;B=1; #10; $finish; end endmodule Simulation Output (Truth Table Verification): A=0, B=0 โ Y=0 (correct) | A=0, B=1 โ Y=1 (correct) | A=1, B=0 โ Y=1 (correct) | A=1, B=1 โ Y=0 (correct) 2.2 XOR Using Basic Gates Only (AND, OR, NOT) Boolean expression: Y = AโB + ABโ = (A+B).(Aโ+Bโ) = (A+B).NAND(A,B). Implemented using AND, OR, and NOT gates as verified in Table 5.3. Verilog Code โ XOR using Basic Gates: module xor_basic(input A, B, output Y); wire An, Bn, t1, t2; not(An, A); // NOT gate: An = A' not(Bn, B); // NOT gate: Bn = B' and(t1, A, Bn); // AND gate: t1 = A.B' and(t2, An, B); // AND gate: t2 = A'.B or(Y, t1, t2); // OR gate: Y = A.B' + A'.B endmodule
3.1 Minimum Gate Implementation (5 NAND Gates) XNOR = NOT(XOR). Using the 4-NAND XOR and adding one more NAND gate as inverter (by tying both inputs together) gives XNOR in 5 NAND gates total. Boolean expression: A XNOR B = AB + AโBโ Verilog Code โ XNOR using 5 NAND Gates: module xnor_5nand(input A, B, output Y); wire C, D, E, Xor_out; nand(C, A, B); // Gate 1 nand(D, A, C); // Gate 2 nand(E, B, C); // Gate 3 nand(Xor_out, D, E); // Gate 4: XOR output nand(Y, Xor_out, Xor_out); // Gate 5: NOT(XOR) = XNOR endmodule Simulation Output (Truth Table Verification): A=0, B=0 โ Y=1 (correct) | A=0, B=1 โ Y=0 (correct) | A=1, B=0 โ Y=0 (correct) | A=1, B=1 โ Y=1 (correct) 3.2 XNOR Using Basic Gates Only (AND, OR, NOT) Boolean expression: Y = AB + AโBโ. Requires 2 NOT gates, 2 AND gates, and 1 OR gate ( gates total). Verified in Table 5.5. Verilog Code โ XNOR using Basic Gates: module xnor_basic(input A, B, output Y); wire An, Bn, t1, t2; not(An, A); // An = A' not(Bn, B); // Bn = B' and(t1, A, B); // t1 = A.B and(t2, An, Bn); // t2 = A'.B' or(Y, t1, t2); // Y = A.B + A'.B' = XNOR endmodule
As required by Analysis Question 2, XOR can also be implemented using NOR gates (universal gates other than NAND). The implementation uses 5 NOR gates as verified in the Analysis section. Verilog Code โ XOR using 5 NOR Gates:
Assessment Rubrics CSC-105L โ Digital Logic Design โ Lab 05
Method: Lab reports, viva, and instructor observation during lab sessions. Outcome Assessed:
Date: