Unit 3 - Notes
ECE249
Unit 3: Introduction to number system and logic gates
1. Number Systems
A number system defines a set of values used to represent quantity.
1.1 Classification of Number Systems
| System | Base (Radix) | Symbols Used | Example |
|---|---|---|---|
| Binary | 2 | 0, 1 | |
| Octal | 8 | 0, 1, 2, 3, 4, 5, 6, 7 | |
| Decimal | 10 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 | |
| Hexadecimal | 16 | 0-9, A(10), B(11), C(12), D(13), E(14), F(15) |
1.2 Number System Conversions
Decimal to Any Base (r)
- Integer Part: Perform repeated division by the destination base and record the remainders. Read remainders from bottom to top.
- Fractional Part: Perform repeated multiplication by the destination base and record the integer part. Read integers from top to bottom.
Example:
- Integer (25):
- (rem 1)
- (rem 0)
- (rem 0)
- (rem 1)
- (rem 1) Read up: $11001$
- Fraction (0.625):
- (Int: 1)
- (Int: 0)
- (Int: 1) Read down: $.101$
- Result:
Any Base (r) to Decimal
Use the Positional Weight Method. Sum the product of each digit and its positional weight ().
Example:
- (Note: A=10)
Binary to Octal / Hexadecimal
- Binary to Octal: Group bits in 3s starting from the radix point (L-R for fractions, R-L for integers).
- Ex:
- Binary to Hex: Group bits in 4s.
- Ex:
2. Binary Codes
2.1 BCD (Binary Coded Decimal / 8421 Code)
- Each decimal digit (0-9) is represented by a 4-bit binary group.
- Valid codes: 0000 to 1001.
- Invalid codes: 1010 to 1111 (10 to 15).
- Example: in BCD is . (In pure binary, it is $11001$).
2.2 Excess-3 Code (XS-3)
- A non-weighted code.
- Derived by adding 3 () to the BCD code of each digit.
- Self-complementing property: The 9's complement of a decimal number can be obtained by inverting the bits of its Excess-3 code.
- Example: Convert decimal 4 to XS-3.
- (XS-3)
2.3 Gray Code (Reflected Code)
- Unit Distance Code: Only one bit changes between successive numbers.
- Used in rotary encoders and error correction.
- Unweighted code.
Binary to Gray Conversion (B to G)
Rule:
- Record the MSB (Most Significant Bit) as is.
- Add the MSB of binary to the next bit of binary (perform XOR operation).
- Continue for all bits.
- (MSB)
Example: Convert Binary $1011$ to Gray
- MSB: 1
- Result: $1110$ (Gray)
Gray to Binary Conversion (G to B)
Rule:
- Record the MSB of Gray as the MSB of Binary.
- XOR the previous binary bit calculated with the current Gray bit.
- (MSB)
Example: Convert Gray $1110$ to Binary
- MSB: 1
- Result: $1011$ (Binary)
3. Complements and Binary Arithmetic
3.1 Types of Complements
- 1's Complement: Invert every bit (0 becomes 1, 1 becomes 0).
- Ex:
- 2's Complement: 1's Complement + 1.
- Ex:
3.2 Binary Arithmetic
Binary Addition Rules
- (Sum 0, Carry 1)
- (Sum 1, Carry 1)
Subtraction using 2's Complement
To perform , we perform .
Steps:
- Ensure both numbers have the same number of bits (pad with 0s if necessary).
- Find the 2's complement of the subtrahend (B).
- Add A to the 2's complement of B.
- Check for Carry:
- If a carry is generated: The result is Positive. Discard the carry.
- If NO carry is generated: The result is Negative. Take the 2's complement of the sum to get the magnitude and add a negative sign.
Example 1: (Result Positive)
- ,
- 2's comp of 5:
- Add:
- Carry generated ($1$). Discard it.
- Result: $0010$ ()
Example 2: (Result Negative)
- ,
- 2's comp of 7:
- Add:
- No carry. Result is negative.
- Magnitude = 2's comp of .
- Result: ()
4. Boolean Algebra and Logic Gates
4.1 Basic Logic Gates
| Gate | Symbol | Expression | Logic |
|---|---|---|---|
| AND | D-shape | Output high only if all inputs are high. | |
| OR | Curved back | Output high if any input is high. | |
| NOT | Triangle + bubble | Inverter. Output opposite of input. |
4.2 Universal Gates
Gates that can implement any Boolean function without using other types of gates.
- NAND (NOT-AND):
- Expression:
- Output is low only if all inputs are high.
- NOR (NOT-OR):
- Expression:
- Output is high only if all inputs are low.
4.3 Special Gates
- XOR (Exclusive-OR):
- Expression:
- Output high if inputs are different (odd number of 1s).
- XNOR (Exclusive-NOR):
- Expression:
- Output high if inputs are the same (Equality detector).
4.4 Boolean Algebra Laws
- Identity: ;
- Null: ;
- Idempotent: ;
- Inverse: ;
- Commutative:
- Associative:
- Distributive: ;
4.5 De Morgan's Theorems
Used to simplify boolean expressions and convert between NAND/NOR logic.
- Theorem 1: The complement of a product is the sum of the complements.
- Theorem 2: The complement of a sum is the product of the complements.
5. SOP and POS Forms
5.1 Sum of Products (SOP)
- The expression is a sum (OR) of product (AND) terms.
- Canonical SOP: Each product term contains all variables (Minterms).
- Minterm (): A product term where variables corresponding to logic 1 are written as and logic 0 as .
- Example: means output is 1 at indices 1 and 3.
5.2 Product of Sums (POS)
- The expression is a product (AND) of sum (OR) terms.
- Canonical POS: Each sum term contains all variables (Maxterms).
- Maxterm (): A sum term where variables corresponding to logic 0 are written as and logic 1 as .
- Example: .
6. Karnaugh Maps (K-Map)
K-Map is a graphical method to minimize Boolean expressions. It arranges truth table values so that adjacent cells differ by only one bit (Gray Code ordering).
6.1 Structure
- 2-Variable ( cells): Variables A, B.
- 3-Variable ( cells): Variables A, B, C.
- 4-Variable ( cells): Variables A, B, C, D.
| 4-Variable Cell Numbering (Format AB \ CD): | AB \ CD | 00 | 01 | 11 | 10 |
|---|---|---|---|---|---|
| 00 | 0 | 1 | 3 | 2 | |
| 01 | 4 | 5 | 7 | 6 | |
| 11 | 12 | 13 | 15 | 14 | |
| 10 | 8 | 9 | 11 | 10 |
6.2 Grouping Rules
- Group adjacent 1s (for SOP) or 0s (for POS).
- Group sizes must be powers of 2 (1, 2, 4, 8, 16).
- Pair (2): Eliminates 1 variable.
- Quad (4): Eliminates 2 variables.
- Octet (8): Eliminates 3 variables.
- Rolling: The map wraps around (top connects to bottom, left connects to right).
- Overlapping: Groups can overlap to create larger groups.
6.3 Don't Care Conditions (X or d)
- Input combinations that never occur or where the output doesn't matter.
- Can be treated as 1 or 0 to help form larger groups for better simplification.
- Do not group 'X's if they don't help cover a '1'.
6.4 Steps to Solve K-Map
- Draw the grid based on the number of variables.
- Fill the cells with 1s (for SOP) based on the minterms given.
- Fill 'X' for don't cares.
- Form the largest possible groups of 1s (using X if helpful).
- Write the simplified expression for each group (write the variables that do not change state within the group).
- Sum the expressions.
Example (SOP):
Given for 4 variables ().
- Cells 0, 1, 4, 5 form a Quad. Variables constant: .
- Cell 12 ($1100$) stands alone? No, combine with 4 ($0100$). Pair: .
- Better yet, if 8 and 13 are not used, check for corners or edges.
- Assuming standard grouping: Quad (0,1,4,5) is . Pair (4, 12) is .
- Simplified: .