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 and and three outputs , , . The outputs report whether , , or , 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 and and indicates which is greater, which is lesser, and whether they are equal.
- Equality detector (): is the exclusive-NOR (XNOR) of and , so it is 1 exactly when .
- Less-than output (): is 1 only for , , i.e. .
- Greater-than output (): is 1 only for , , i.e. .
- Shared intermediate signal: One NOR gate with inputs and produces (by De Morgan); this signal is fed forward into the gates producing and .
- Mutually exclusive outputs: Only one output is 1 at a time; the other two are 0.
How it works
- Take inputs and ; the circuit uses only NOR gates.
- Identify as the XNOR of and : .
- Feed and into one NOR gate to obtain the intermediate term .
- Produce with a NOR gate whose inputs are and : .
- Produce with a NOR gate whose inputs are and : .
- Interpret the outputs: tells whether , whether , whether .
Truth table ():
| (equal) | () | () | ||
|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 | 0 |
Formulas
-
— XNOR; equality; 1 when
-
— 1 when
-
— 1 when
-
— intermediate term, by De Morgan
-
— simplification used inside
-
— simplification used inside
-
Symbols: = the two input bits; = complement (NOT); = OR; juxtaposition = AND.
Worked examples
Example 1 — Derive : [distributive law] [] [De Morgan]
Example 2 — Derive : [distributive law] [] [De Morgan]
Example 3 — Inputs 0,0: ; ; → equal.
Example 4 — Inputs 0,1: ; ; → .
Example 5 — Inputs 1,0: ; ; → .
Example 6 — Inputs 1,1: ; ; → equal.
Comparison
| Output | Expression | Condition detected | Value when true |
|---|---|---|---|
| (XNOR) | 1 | ||
| 1 | |||
| 1 |
Revision summary
- The circuit uses NOR gates only, with 2 inputs (, ) and 3 outputs (, , ).
- is the XNOR equality detector.
- detects ; detects .
- The shared intermediate signal is , produced by one NOR gate and fed to the and gates.
- The three outputs are mutually exclusive: exactly one output is 1 for every input combination.
- Truth table rows: 00 → ; 01 → ; 10 → ; 11 → .
Previous-year exam insights
- An n-to- decoder has n input lines and output lines; to address a memory of W words, the number of address/decoder input lines is , 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- decoders needed for an n-to- decoder is 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 positions, so its resolution is 360°/.
Asked inISRO 2007