Number Systems and Digital Circuits
What to remember
- A number system has a base (radix). Binary is base 2, octal base 8, decimal base 10, hexadecimal base 16. Conversions follow fixed methods.
- Basic gates are AND, OR, NOT; NAND and NOR are universal. Boolean algebra and De Morgan's laws simplify circuits.
- Combinational circuits (adders, multiplexers, decoders) have no memory; sequential circuits (flip-flops, counters, registers) have memory and use a clock.
1. Number systems
| System | Base | Digits |
|---|---|---|
| Binary | 2 | 0, 1 |
| Octal | 8 | 0 to 7 |
| Decimal | 10 | 0 to 9 |
| Hexadecimal | 16 | 0 to 9, A to F (A=10 ... F=15) |
Each digit has a place value that is a power of the base. Example: 1101₂ = 1×8 + 1×4 + 0×2 + 1×1 = 13.
Decimal to binary: divide by 2 repeatedly and read the remainders from bottom to top. 25: 25÷2=12 r1, 12÷2=6 r0, 6÷2=3 r0, 3÷2=1 r1, 1÷2=0 r1. Answer 11001₂.
Fraction to binary: multiply by 2 repeatedly and read the integer parts from top. 0.625 × 2 = 1.25 (1), 0.25 × 2 = 0.5 (0), 0.5 × 2 = 1.0 (1). So 0.625 = 0.101₂.
Binary to octal: group bits in threes from the point. 101110₂ = 101 | 110 = 56₈.
Binary to hex: group in fours. 11010110₂ = 1101 | 0110 = D6₁₆.
Hex to decimal: 2F₁₆ = 2×16 + 15 = 47.
Octal to decimal: 17₈ = 1×8 + 7 = 15.
2. Binary codes
- BCD (8421): each decimal digit is coded in 4 bits. 59 = 0101 1001. Codes 1010 to 1111 are invalid.
- Excess-3: BCD + 3; self-complementing.
- Gray code: only one bit changes between successive values. Binary to Gray: keep the MSB, then XOR each bit with the bit before it. 1011 → 1, 1⊕0=1, 0⊕1=1, 1⊕1=0 → 1110.
- ASCII: 7-bit code with 128 characters (extended ASCII uses 8 bits); 'A' = 65, 'a' = 97, '0' = 48. Unicode covers all world scripts, including Telugu.
- Parity bit: an extra bit for simple error detection (even or odd parity). It detects a single-bit error but cannot correct it. Hamming code can detect and correct a single-bit error.
3. Logic gates
| Gate | Output is 1 when | Expression |
|---|---|---|
| AND | all inputs are 1 | A·B |
| OR | any input is 1 | A + B |
| NOT | input is 0 | A′ |
| NAND | not all inputs are 1 | (A·B)′ |
| NOR | all inputs are 0 | (A + B)′ |
| XOR | inputs differ | A ⊕ B |
| XNOR | inputs are equal | (A ⊕ B)′ |
Universal gates: NAND and NOR, because any gate can be built from either one. NOT, AND, OR are the basic gates. XOR gives 1 for an odd number of 1s.
4. Boolean algebra
- Identity: A + 0 = A, A·1 = A. Null: A + 1 = 1, A·0 = 0.
- Idempotent: A + A = A, A·A = A. Complement: A + A′ = 1, A·A′ = 0.
- Double negation: (A′)′ = A. Absorption: A + AB = A.
- Distributive: A + BC = (A + B)(A + C).
- De Morgan's laws: (A + B)′ = A′·B′ and (A·B)′ = A′ + B′.
- Principle of duality: swap AND with OR and 0 with 1 to get the dual identity.
Forms: Sum of Products (SOP) uses minterms; Product of Sums (POS) uses maxterms. A minterm is an AND of all variables; a maxterm is an OR of all variables. With n variables there are 2ⁿ minterms.
Karnaugh map (K-map) simplifies Boolean functions by grouping adjacent 1s in groups of 1, 2, 4, 8 (powers of two). Larger groups give simpler terms. Cells are labelled in Gray code order. A "don't care" condition (X) may be used as 0 or 1 to help grouping.
Example: F = AB + AB′ = A(B + B′) = A.
5. Combinational circuits
Output depends only on the present input.
- Half adder: Sum = A ⊕ B, Carry = A·B. Full adder: adds A, B and carry-in. Half subtractor: Difference = A ⊕ B, Borrow = A′·B.
- Multiplexer (MUX): selects one of many inputs to one output. A 2ⁿ-to-1 MUX needs n select lines; 8-to-1 needs 3.
- Demultiplexer (DEMUX): sends one input to one of many outputs.
- Decoder: n inputs give up to 2ⁿ outputs (3-to-8 decoder). Encoder: the reverse; 2ⁿ inputs give n outputs. A priority encoder handles several active inputs by priority.
- Comparator: compares two numbers. Parity generator/checker makes or checks parity bits.
6. Sequential circuits
Output depends on present input and past state. They use a clock and memory elements called flip-flops. A flip-flop stores 1 bit.
| Flip-flop | Behaviour |
|---|---|
| SR | S=1 sets, R=1 resets, S=R=1 is invalid |
| D | Output follows D at the clock; a data (delay) flip-flop |
| JK | Like SR, but J=K=1 toggles; no invalid state |
| T | T=1 toggles, T=0 holds |
A latch is level-triggered; a flip-flop is edge-triggered. Race-around condition appears in a JK flip-flop with J=K=1 when the clock is long; it is removed by master-slave or edge triggering.
- Register: a group of flip-flops; n flip-flops store n bits. Shift register: moves bits left or right (SISO, SIPO, PISO, PIPO).
- Counter: counts clock pulses. Asynchronous (ripple) counters pass the clock from one stage to the next; synchronous counters clock all stages together and are faster. An n-bit binary counter has 2ⁿ states and its maximum count is 2ⁿ − 1. A mod-N counter counts N states. A 4-bit counter is mod-16.
- Frequency division: each flip-flop in a counter divides the frequency by 2. Three flip-flops divide by 8. A 16 kHz clock after 3 stages gives 2 kHz.
7. Memory and converters
Memory size = number of words × bits per word. Address lines for N words = log₂N. Example: 1K × 8 memory needs 10 address lines (2¹⁰ = 1024) and 8 data lines. A PLA/PAL is a programmable logic device. An ADC converts analog to digital; a DAC converts digital to analog. Number of levels of an n-bit ADC = 2ⁿ.
Logic families: TTL (transistor-transistor logic) is fast; CMOS uses low power. Fan-out is the number of gates an output can drive; noise margin shows resistance to noise.
Worked examples
- 1. Hex to binary: 3A₁₆ = 0011 1010₂. Binary to decimal: 101101₂ = 32 + 8 + 4 + 1 = 45.
- 2. Decimal to hex: 255 ÷ 16 = 15 remainder 15, so 255 = FF₁₆. 100 ÷ 16 = 6 remainder 4, so 100 = 64₁₆.
- 3. Simplify: F = A·B + A·B′ + A′·B = A + A′·B = A + B. (First two terms give A; then A + A′B = A + B.)
- 4. De Morgan: (A + B)′ for A = 1, B = 0 gives (1)′ = 0, and A′·B′ = 0·1 = 0. Both match.
- 5. NAND as NOT: Joining both inputs of a NAND gate gives A′, so a NAND with tied inputs works as a NOT gate.
- 6. Counter: A 3-bit ripple counter counts 000 to 111, that is 0 to 7; it repeats after 8 clock pulses. A 12-bit address can select 4,096 words, since 2¹² = 4,096.
- 7. Parity: The 7-bit data 1011001 has four 1s; even parity bit = 0 and odd parity bit = 1.
Exam traps
- NAND and NOR are universal; XOR and AND are not.
- F in hexadecimal is 15, not 16; the digits run from 0 to 15.
- In binary-to-Gray, the MSB is copied unchanged.
- JK with J=K=1 toggles; SR with S=R=1 is invalid.
- n flip-flops count up to 2ⁿ − 1, but have 2ⁿ states.
- Combinational circuits have no memory; sequential circuits do.
- Fractional conversion multiplies by 2; integer conversion divides by 2.
- A decoder expands lines; an encoder reduces lines.
One-liners
- 1. Binary base is 2; hexadecimal base is 16.
- 2. 1010₂ = 10 = A in hex.
- 3. NAND is a universal gate.
- 4. De Morgan: (A·B)′ = A′ + B′.
- 5. A full adder has three inputs.
- 6. An 8-to-1 MUX needs 3 select lines.
- 7. A D flip-flop stores one bit.
- 8. A T flip-flop toggles when T = 1.
- 9. Gray code changes only one bit at a time.
- 10. ASCII is a 7-bit code.
- 11. BCD uses 4 bits per decimal digit.
- 12. A mod-16 counter needs 4 flip-flops.
Practice questions
The base of the hexadecimal number system is
- 8
- 10
- 2
- 16
Answer
D. 16
Hexadecimal is base 16.
The decimal value of the binary number 1101 is
- 14
- 13
- 15
- 11
Answer
B. 13
8 + 4 + 0 + 1 = 13.
The decimal number 25 in binary is
- 11001
- 10011
- 11010
- 10101
Answer
A. 11001
25 = 16 + 8 + 1 = 11001.
The hexadecimal digit F represents the decimal value
- 15
- 16
- 10
- 14
Answer
A. 15
A = 10 ... F = 15.
Binary 11010110 in hexadecimal is
- B6
- D6
- 6D
- D3
Answer
B. D6
1101 = D, 0110 = 6.
The octal equivalent of binary 101110 is
- 65
- 46
- 27
- 56
Answer
D. 56
Groups 101 = 5 and 110 = 6.
The decimal number 255 in hexadecimal is
- FF
- 1F
- EE
- F0
Answer
A. FF
255 = 15 × 16 + 15 = FF.
The binary equivalent of 0.625 is
- 0.011
- 0.101
- 0.1001
- 0.110
Answer
B. 0.101
0.625 = 1/2 + 1/8 = 0.101.
Which gate gives output 1 only when all its inputs are 1?
- NOR
- XOR
- OR
- AND
Answer
D. AND
AND outputs 1 only if all inputs are 1.
Which gates are called universal gates?
- NAND and NOR
- AND and OR
- XOR and XNOR
- NOT and AND
Answer
A. NAND and NOR
Any gate can be built from NAND alone or NOR alone.
The output of an XOR gate is 1 when
- its inputs are the same
- its inputs are different
- both inputs are 1
- both inputs are 0
Answer
B. its inputs are different
XOR is 1 for an odd number of 1s.
According to De Morgan's law, (A + B)′ equals
- A′ + B′
- A + B′
- A′ · B′
- A · B
Answer
C. A′ · B′
The complement of a sum is the product of complements.
A NAND gate with both inputs joined together works as a
- OR gate
- XOR gate
- AND gate
- NOT gate
Answer
D. NOT gate
NAND(A, A) = A′.
The Boolean expression A + A′B simplifies to
- A · B
- A
- A + B
- A′ + B
Answer
C. A + B
A + A′B = (A + A′)(A + B) = A + B.
The expression AB + AB′ simplifies to
- A
- A + B
- AB
- B
Answer
A. A
AB + AB′ = A(B + B′) = A.
A K-map is used to
- add binary numbers
- simplify Boolean expressions
- store data bits
- count clock pulses
Answer
B. simplify Boolean expressions
Karnaugh maps group adjacent 1s to reduce expressions.
In a K-map, groups of adjacent 1s must have a size that is
- an odd number
- any number
- a multiple of three
- a power of two
Answer
D. a power of two
Valid groups are 1, 2, 4, 8 ... cells.
The BCD code of the decimal number 59 is
- 1001 0101
- 1011 1011
- 0101 0101
- 0101 1001
Answer
D. 0101 1001
Each digit is coded in 4 bits: 5 = 0101, 9 = 1001.
The Gray code of binary 1011 is
- 0110
- 1101
- 1110
- 1010
Answer
C. 1110
Keep 1, then 1⊕0 = 1, 0⊕1 = 1, 1⊕1 = 0.
Gray code is useful because
- it needs fewer bits than binary
- it is used for letters only
- only one bit changes between consecutive numbers
- it is self-correcting for all errors
Answer
C. only one bit changes between consecutive numbers
Single-bit change reduces errors in transitions.
The ASCII code is a
- 7-bit code
- 16-bit code
- 32-bit code
- 4-bit code
Answer
A. 7-bit code
Standard ASCII has 128 characters in 7 bits.
A parity bit is used for
- encryption
- error detection
- data compression
- addition
Answer
B. error detection
A parity bit can detect a single-bit error.
An 8-to-1 multiplexer has how many select lines?
- 2
- 3
- 4
- 8
Answer
B. 3
2^3 = 8, so 3 select lines.
A 3-to-8 decoder has how many outputs?
- 3
- 6
- 8
- 9
Answer
C. 8
n inputs give 2^n outputs.
The Difference output of a half subtractor is
- A AND B
- A OR B
- A NOR B
- A XOR B
Answer
D. A XOR B
Difference = A ⊕ B; Borrow = A′B.
Which of these is a sequential circuit?
- Counter
- Decoder
- Half adder
- Multiplexer
Answer
A. Counter
Counters use flip-flops and have memory.
A flip-flop can store how many bits?
- 2
- 1
- 4
- 8
Answer
B. 1
One flip-flop stores one bit.
In a JK flip-flop, J = K = 1 causes the output to
- toggle
- stay unchanged
- set
- reset
Answer
A. toggle
J = K = 1 toggles the state.
Which input condition is invalid for an SR flip-flop?
- S = 0 and R = 1
- S = 1 and R = 0
- S = 0 and R = 0
- S = 1 and R = 1
Answer
D. S = 1 and R = 1
S = R = 1 is the forbidden state.
A flip-flop that follows the input data at the clock edge is the
- D flip-flop
- SR flip-flop
- JK flip-flop
- T flip-flop
Answer
A. D flip-flop
The D (delay) flip-flop passes D to the output.
A 4-bit binary counter has how many states?
- 4
- 16
- 8
- 15
Answer
B. 16
2^4 = 16 states, counting 0 to 15.
A 3-bit counter driven by a 16 kHz clock gives, at its last stage, a frequency of
- 8 kHz
- 4 kHz
- 5.3 kHz
- 2 kHz
Answer
D. 2 kHz
Three stages divide by 2^3 = 8; 16/8 = 2 kHz.
A memory of 1K × 8 needs how many address lines?
- 11
- 8
- 10
- 1024
Answer
C. 10
1K = 1024 = 2^10.
The 7-bit data 1011001 has even parity bit
- 0
- 1
- 2
- Cannot be found
Answer
A. 0
There are four 1s (even), so the even parity bit is 0.
Consider these statements about gates. 1. NAND is a universal gate. 2. XOR is a universal gate. Which is/are correct?
- 1 only
- 2 only
- Both 1 and 2
- Neither 1 nor 2
Answer
A. 1 only
XOR is not universal.
Consider these statements about circuits. 1. Combinational circuits have memory. 2. Sequential circuits use flip-flops. Which is/are correct?
- 1 only
- 2 only
- Both 1 and 2
- Neither 1 nor 2
Answer
B. 2 only
Combinational circuits have no memory; only 2 is correct.
Consider these statements about counters. 1. In a synchronous counter all flip-flops get the clock together. 2. Ripple counters are faster than synchronous counters. Which is/are correct?
- 1 only
- 2 only
- Both 1 and 2
- Neither 1 nor 2
Answer
A. 1 only
Synchronous counters are faster; statement 2 is wrong.
Consider these statements about number systems. 1. Octal uses digits 0 to 7. 2. Hexadecimal uses digits 0 to 9 and letters A to F. Which is/are correct?
- 1 only
- 2 only
- Both 1 and 2
- Neither 1 nor 2
Answer
C. Both 1 and 2
Both are correct.
Consider these statements. 1. A decoder has n inputs and up to 2^n outputs. 2. An encoder has 2^n inputs and n outputs. Which is/are correct?
- 1 only
- 2 only
- Both 1 and 2
- Neither 1 nor 2
Answer
C. Both 1 and 2
Both describe the circuits correctly.
Consider these statements about Boolean algebra. 1. (A·B)′ = A′ + B′. 2. A + A = 2A. Which is/are correct?
- 1 only
- 2 only
- Both 1 and 2
- Neither 1 nor 2
Answer
A. 1 only
In Boolean algebra A + A = A, so 2 is wrong.
Match the gate with its output rule. P. NOR Q. XNOR R. NAND 1. 1 when inputs are equal 2. 1 only when all inputs are 0 3. 0 only when all inputs are 1
- P-3, Q-1, R-2
- P-2, Q-3, R-1
- P-1, Q-2, R-3
- P-2, Q-1, R-3
Answer
D. P-2, Q-1, R-3
NOR is 1 for all-zero inputs, XNOR for equal inputs, NAND is 0 only for all-one inputs.
Match the flip-flop with its feature. P. T Q. D R. JK 1. Output follows data input 2. Toggles when input is 1 3. No invalid input state
- P-1, Q-2, R-3
- P-2, Q-1, R-3
- P-3, Q-1, R-2
- P-2, Q-3, R-1
Answer
B. P-2, Q-1, R-3
T toggles, D follows data, JK has no invalid state.
Match the code with its property. P. Gray Q. BCD R. ASCII 1. Codes characters 2. Single-bit change between steps 3. Four bits per decimal digit
- P-1, Q-2, R-3
- P-2, Q-1, R-3
- P-3, Q-2, R-1
- P-2, Q-3, R-1
Answer
D. P-2, Q-3, R-1
Gray changes one bit; BCD uses 4 bits per digit; ASCII codes characters.
A circuit that converts an analog signal into digital form is an
- latch
- decoder
- ADC
- DAC
Answer
C. ADC
An ADC (analog to digital converter) does this.
In the binary 1101 + 0111 addition, the result is
- 11100
- 10100
- 10010
- 10101
Answer
B. 10100
13 + 7 = 20 = 10100.