1. Gyanastra
  2. Digital Logic
  3. Decoders, Encoders and Comparators
  4. 2-Bit Magnitude Comparator Using NOR Gates
Free lesson, no account needed 6 min read 8 practice questions after it
Asked in past papers9 times
  • GATE CSE202020132007
  • ISRO2020201420112007
  • UGC NET20222019

Digital Logic · Decoders, Encoders and Comparators

2-Bit Magnitude Comparator Using NOR Gates

Overview

A 2-bit magnitude comparator built entirely from NOR gates is a combinational circuit with two inputs PP and QQ and three outputs F1F_1, F2F_2, F3F_3. The outputs report whether P=QP = Q, P<QP < Q, or P>QP > Q, and exactly one of them is 1 for every input combination.

Key concepts

  • 2-bit magnitude comparator: A multi-input, multi-output combinational circuit that compares two bits PP and QQ and indicates which is greater, which is lesser, and whether they are equal.
  • Equality detector (F2F_2): F2F_2 is the exclusive-NOR (XNOR) of PP and QQ, so it is 1 exactly when P=QP = Q.
  • Less-than output (F1F_1): F1=P′QF_1 = P'Q is 1 only for P=0P = 0, Q=1Q = 1, i.e. P<QP < Q.
  • Greater-than output (F3F_3): F3=PQ′F_3 = PQ' is 1 only for P=1P = 1, Q=0Q = 0, i.e. P>QP > Q.
  • Shared intermediate signal: One NOR gate with inputs PP and QQ produces (P+Q)′=P′Q′(P + Q)' = P'Q' (by De Morgan); this signal is fed forward into the gates producing F1F_1 and F3F_3.
  • Mutually exclusive outputs: Only one output is 1 at a time; the other two are 0.

How it works

  1. Take inputs PP and QQ; the circuit uses only NOR gates.
  2. Identify F2F_2 as the XNOR of PP and QQ: F2=P′Q′+PQF_2 = P'Q' + PQ.
  3. Feed PP and QQ into one NOR gate to obtain the intermediate term (P+Q)′=P′Q′(P + Q)' = P'Q'.
  4. Produce F1F_1 with a NOR gate whose inputs are PP and P′Q′P'Q': F1=(P+P′Q′)′=P′QF_1 = (P + P'Q')' = P'Q.
  5. Produce F3F_3 with a NOR gate whose inputs are QQ and P′Q′P'Q': F3=(Q+P′Q′)′=PQ′F_3 = (Q + P'Q')' = PQ'.
  6. Interpret the outputs: F2F_2 tells whether P=QP = Q, F1F_1 whether P<QP < Q, F3F_3 whether P>QP > Q.

Truth table (P,Q→F2,F1,F3P, Q \rightarrow F_2, F_1, F_3):

PPQQF2=P′Q′+PQF_2 = P'Q' + PQ (equal)F1=P′QF_1 = P'Q (P<QP < Q)F3=PQ′F_3 = PQ' (P>QP > Q)
00100
01010
10001
11100

Formulas

  • F2=P′Q′+PQF_2 = P'Q' + PQ — XNOR; equality; 1 when P=QP = Q

  • F1=P′QF_1 = P'Q — 1 when P<QP < Q

  • F3=PQ′F_3 = PQ' — 1 when P>QP > Q

  • (P+Q)′=P′Q′(P + Q)' = P'Q' — intermediate term, by De Morgan

  • P+P′Q′=P+Q′P + P'Q' = P + Q' — simplification used inside F1F_1

  • Q+P′Q′=Q+P′Q + P'Q' = Q + P' — simplification used inside F3F_3

  • Symbols: P,QP, Q = the two input bits; ′' = complement (NOT); ++ = OR; juxtaposition = AND.

Worked examples

Example 1 — Derive F1F_1: F1=(P+P′Q′)′F_1 = (P + P'Q')' =((P+P′)(P+Q′))′= ((P + P')(P + Q'))' [distributive law] =(1⋅(P+Q′))′= (1 \cdot (P + Q'))' [P+P′=1P + P' = 1] =(P+Q′)′= (P + Q')' =P′Q= P'Q [De Morgan]

Example 2 — Derive F3F_3: F3=(Q+P′Q′)′F_3 = (Q + P'Q')' =((Q+P′)(Q+Q′))′= ((Q + P')(Q + Q'))' [distributive law] =((Q+P′)⋅1)′= ((Q + P') \cdot 1)' [Q+Q′=1Q + Q' = 1] =(Q+P′)′= (Q + P')' =PQ′= PQ' [De Morgan]

Example 3 — Inputs 0,0: F2=0′⋅0′+0⋅0=1⋅1+0=1F_2 = 0'\cdot0' + 0\cdot0 = 1\cdot1 + 0 = 1; F1=0′⋅0=0F_1 = 0'\cdot0 = 0; F3=0⋅0′=0F_3 = 0\cdot0' = 0 → equal.

Example 4 — Inputs 0,1: F2=0′⋅1′+0⋅1=1⋅0+0=0F_2 = 0'\cdot1' + 0\cdot1 = 1\cdot0 + 0 = 0; F1=0′⋅1=1F_1 = 0'\cdot1 = 1; F3=0⋅1′=0F_3 = 0\cdot1' = 0 → P<QP < Q.

Example 5 — Inputs 1,0: F2=1′⋅0′+1⋅0=0⋅1+0=0F_2 = 1'\cdot0' + 1\cdot0 = 0\cdot1 + 0 = 0; F1=1′⋅0=0F_1 = 1'\cdot0 = 0; F3=1⋅0′=1F_3 = 1\cdot0' = 1 → P>QP > Q.

Example 6 — Inputs 1,1: F2=1′⋅1′+1⋅1=0+1=1F_2 = 1'\cdot1' + 1\cdot1 = 0 + 1 = 1; F1=1′⋅1=0F_1 = 1'\cdot1 = 0; F3=1⋅1′=0F_3 = 1\cdot1' = 0 → equal.

Comparison

OutputExpressionCondition detectedValue when true
F2F_2P′Q′+PQP'Q' + PQ (XNOR)P=QP = Q1
F1F_1P′QP'QP<QP < Q1
F3F_3PQ′PQ'P>QP > Q1

Revision summary

  • The circuit uses NOR gates only, with 2 inputs (PP, QQ) and 3 outputs (F1F_1, F2F_2, F3F_3).
  • F2=P′Q′+PQF_2 = P'Q' + PQ is the XNOR equality detector.
  • F1=P′QF_1 = P'Q detects P<QP < Q; F3=PQ′F_3 = PQ' detects P>QP > Q.
  • The shared intermediate signal is P′Q′=(P+Q)′P'Q' = (P + Q)', produced by one NOR gate and fed to the F1F_1 and F3F_3 gates.
  • The three outputs are mutually exclusive: exactly one output is 1 for every input combination.
  • Truth table rows: 00 → F2F_2; 01 → F1F_1; 10 → F3F_3; 11 → F2F_2.

Previous-year exam insights

  • An n-to-2n2^{n} decoder has n input lines and 2n2^{n} output lines; to address a memory of W words, the number of address/decoder input lines is log⁡2(W)\log_{2}(W), and the decoder output lines equal the number of words (or word-select lines).
    Asked inGATE 2020ISRO 2014
  • A decoder with an enable input can be expanded: to build a larger decoder from smaller ones, the low-order inputs drive all small decoders in parallel and the high-order inputs feed an extra decoder whose outputs drive the enables; the number of k-to-2k2^{k} decoders needed for an n-to-2n2^{n} decoder is (2n−1)/(2k−1)(2^{n} - 1)/(2^{k} - 1) when no other gates are allowed.
    Asked inGATE 2007ISRO 2011
  • A priority encoder outputs the binary index of the highest-priority active input and asserts a valid output only when at least one input is active; an octal-to-binary encoder simply converts the active input line index to binary and is not a priority device.
    Asked inGATE 2013UGC NET 2022UGC NET 2019
  • For a 2-bit magnitude comparator on X = X1X0 and Y = Y1Y0: X>Y iff (X1>Y1) or (X1=Y1 and X0>Y0);
    X<Y iff (X1<Y1) or (X1=Y1 and X0<Y0);
    X=Y iff both bits equal, i.e. (X1 XNOR Y1)(X0 XNOR Y0).
    Asked inISRO 2020
  • The number of RAM chips needed to build a memory is (total words / chip words) × (word width / chip width); the chip-select decoding uses a decoder whose size is determined by the number of chip rows (word expansion), while bit expansion needs no decoder.
    Asked inGATE 2013ISRO 2014
  • An optical (shaft) encoder with n output bits divides a full revolution into 2n2^{n} positions, so its resolution is 360°/2n2^{n}.
    Asked inISRO 2007
Pages 1–2 of 2