Digital LogicUnit 18 min read
Digital Logic Basics: Number Systems, Complements, and Binary Arithmetic
Unit 1 of Digital Logic covers foundational concepts including digital vs. analog systems, binary/decimal/octal/hexadecimal conversions, signed number representations (magnitude, 1’s/2’s complement), and arithmetic operations—essential for designing circuits and solving TU exam problems.
1. Introduction to Digital Logic
1.1 Digital vs. Analog Systems
- Digital Systems: Represent data as discrete values (0s and 1s). Used in computers, digital clocks, and microcontrollers.
- Analog Systems: Represent data as continuous signals (e.g., voltage levels). Used in thermometers, audio signals.
- Advantages of Digital Systems:
- Noise immunity (less error-prone).
- Easier storage and processing.
- Scalability (e.g., binary logic scales to complex circuits).
1.2 Binary Number System
- Base-2 System: Uses digits 0 and 1.
- Weighted Positional Notation:
- Example: Convert to decimal:
2. Number System Conversions
2.1 Decimal to Binary (Fractional and Integer Parts)
Integer Part (Division by 2)
- Divide the number by 2, record the remainder.
- Repeat until the quotient is 0.
- Read remainders in reverse order.
Example: Convert to binary:
13 ÷ 2 = 6 (remainder 1)
6 ÷ 2 = 3 (remainder 0)
3 ÷ 2 = 1 (remainder 1)
1 ÷ 2 = 0 (remainder 1)
Result:
Fractional Part (Multiplication by 2)
- Multiply the fraction by 2, record the integer part.
- Repeat until the fraction becomes 0 or reaches desired precision.
Example: Convert to binary:
0.625 × 2 = 1.25 → 1
0.25 × 2 = 0.5 → 0
0.5 × 2 = 1.0 → 1
Result:
Combined Example: Convert to binary:
- Integer part:
- Fractional part: Final Result:
2.2 Binary to Decimal
Use weighted summation:
2.3 Octal (Base-8) and Hexadecimal (Base-16) Systems
| Base | Digits | Conversion Method |
|---|---|---|
| Octal | 0–7 | Group binary into sets of 3 bits (LSB first), convert each group. |
| Hex | 0–9, A–F (A=10, ..., F=15) | Group binary into sets of 4 bits, convert each group. |
Example: Convert to octal and hexadecimal.
- Octal:
Group:
1 011 011 001→1 3 3 1→ - Hexadecimal:
Group:
1011 0110 0100→B 6 4→
Decimal to Octal/Hex:
- Convert decimal to binary.
- Group into 3/4 bits and convert.
Example: Convert to hexadecimal.
- Binary: → Group:
0010 0101→2 5→
3. Signed Number Representations
3.1 Signed Magnitude
- Format: Most significant bit (MSB) = 0 (positive), 1 (negative).
- Example: Represent in 8-bit signed magnitude:
- Drawback: Two representations for zero ( and ).
3.2 1’s Complement
- Negative Numbers: Invert all bits of the positive number.
- Example: in 8-bit 1’s complement:
- Positive 6:
- Negative 6:
- Addition/Subtraction:
- For , if is negative, add and 's complement of , then add end-around carry.
- Example: in 4-bit 1’s complement:
- ,
- Sum: (end-around carry: → )
- Error: Incorrect due to limited bits (overflow).
3.3 2’s Complement
- Negative Numbers: Add 1 to the 1’s complement.
- Example: in 8-bit 2’s complement:
- Positive 6:
- 1’s complement:
- 2’s complement:
- Advantages:
- Single representation for zero.
- Simplified arithmetic (no end-around carry for subtraction).
- Example: in 4-bit 2’s complement:
- ,
- Sum: (correct).
Comparison Table:
| Method | Positive 6 | Negative 6 | Zero Representations | Arithmetic Simplicity |
|---|---|---|---|---|
| Signed Magnitude | 00000110 |
10000110 |
Two (, ) | Complex |
| 1’s Complement | 00000110 |
11111001 |
Two | Requires end-around carry |
| 2’s Complement | 00000110 |
11111010 |
One | Simplest (no carry issues) |
4. Arithmetic Operations in Binary
4.1 Binary Addition and Subtraction
- Addition Rules:
0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0 (carry 1) - Subtraction Rules:
- Use 2’s complement for negative numbers.
- Example: in 4-bit:
- ,
- Sum: (correct).
4.2 Multiplication and Division
- Multiplication: Shift-and-add method.
Example: in binary:
0011 (3) × 0101 (5) ----- 0000 (0) 0011 (3, shifted left 1) 0000 (0, shifted left 2)
0011 (3, shifted left 3)
01111 (15)
- Division: Repeated subtraction.
Example: :
- , , , , → 5 times.
5. Complements in Digital Logic
5.1 9’s and 10’s Complement (BCD)
- Used in Binary-Coded Decimal (BCD) arithmetic.
- 9’s Complement: Subtract each digit from 9. Example: 's complement of :
- 10’s Complement: Add 1 to 9’s complement. Example: 's complement of :
Application: Simplifies subtraction in BCD systems. Example: using 10’s complement:
- Find 10’s complement of : .
- Add to : .
- Discard the overflow digit: → .
6. Exam Tips
Common Pitfalls
- Forgetting End-Around Carry in 1’s Complement: Always add the carry to the LSB.
- Incorrect Grouping in Octal/Hex Conversion: Group from the right (LSB first).
- Sign Bit Errors: Ensure the MSB is correctly set for negative numbers in signed representations.
- Overflow in 2’s Complement: If the result exceeds the bit limit, it wraps around (e.g., in 4-bit).
High-Scoring Strategies
- Show All Steps: For conversions, write intermediate binary groupings.
- Use Tables: For signed arithmetic, list the binary representations clearly.
- Practice Complements: Master 1’s and 2’s complement for subtraction problems.
- Diagrams for BCD: Draw the logic circuit for 9’s/10’s complement generators if asked.
- Time Management: Allocate 10–15 minutes for this unit in exams (typically 10–15 marks).
Past Exam Patterns
- Direct Conversions: Expect 2–3 decimal-to-binary/octal/hex questions (5–10 marks).
- Arithmetic: 1’s/2’s complement subtraction or addition (5–8 marks).
- Complements in BCD: Design circuits for 9’s/10’s complement (8–10 marks).
- Theoretical Questions: Compare signed representations or explain overflow (3–5 marks).
Practice Problems (TU-Style)
- Convert to:
- Binary:
- Octal:
- Hexadecimal:
- Perform in 8-bit 2’s complement.
- ,
- Sum: → (correct).
- Design a circuit to generate the 9’s complement of a 4-bit BCD input.
- Use 4 NOT gates (one per bit) and 4 XOR gates with a constant
1for each digit.
- Use 4 NOT gates (one per bit) and 4 XOR gates with a constant
- Explain why 2’s complement is preferred over 1’s complement for arithmetic operations.
- Answer: Eliminates the need for end-around carry and provides a unique zero representation, simplifying hardware design.
Based on the TU BSc CSIT syllabus for Digital Logic (CSC116), unit 1.
Discussion
Loading…