# 2.1 Digital Logic

### 1. **Number Systems, Logic Levels, Logic Gates, Boolean Algebra**

1. **Number Systems**

Number systems are fundamental to both mathematics and computing, serving as the foundation for performing calculations and representing data. Different number systems use various **bases**, and each has specific uses depending on the application.

* **Binary System**: It is the **foundation of digital electronics** and computing. Every piece of data in computers (such as images, text, and sound) is eventually broken down into **binary code**, which consists of sequences of **0s and 1s**.
* **Decimal System**: It is the standard system used in everyday life for counting and arithmetic. It's a **base-10** system, meaning it uses 10 digits (0-9).
* **Octal System**: A base-8 number system using digits `0-7`. It is often used in computing as a shorthand for binary numbers.
* **Hexadecimal System**: A base-16 number system using digits `0-9` and letters `A-F` (representing values 10-15). It is commonly used in programming to represent binary data more compactly.

***

2. **Logic Levels**

In digital electronics and computing, **logic levels** represent binary states, which are fundamental to how information is processed and stored in digital circuits.

* **High (1)**: Represents a logic high or "true" state, typically corresponding to a voltage near the supply voltage (e.g., 5V).
* **Low (0)**: Represents a logic low or "false" state, typically corresponding to a ground or low voltage (e.g., 0V).

***

3. **Logic Gates**

Logic gates are the basic building blocks of digital circuits. They perform logical operations on one or more binary inputs to produce a binary output.

* **AND Gate**: Output is `1` only if both inputs are `1`.
* **OR Gate**: Output is `1` if at least one input is `1`.
* **NOT Gate (Inverter)**: Output is the inverse of the input. If input is `1`, output is `0`, and vice versa.
* **NAND Gate**: Output is the inverse of the AND gate. Output is `1` except when both inputs are `1`.
* **NOR Gate**: Output is the inverse of the OR gate. Output is `1` only when both inputs are `0`.
* **XOR Gate**: Output is `1` if the inputs are different.
* **XNOR Gate**: Output is `1` if the inputs are the same.

***

4. **Boolean Algebra**

Boolean algebra is a mathematical framework used to handle binary variables and logic operations. It forms the foundation for designing and analyzing digital circuits, computer algorithms, and programming logic. Boolean algebra involves variables that can have only two possible states: **0** (false) and **1** (true).

* **Boolean Variables**: These variables represent two possible states, `0` and `1`.
* **Basic Operations**:
  * **AND**: `A * B` or `A AND B`
  * **OR**: `A + B` or `A OR B`
  * **NOT**: `¬A` or `NOT A`
* **Boolean Laws**:
  * **Commutative**: `A + B = B + A`, `A * B = B * A`
  * **Associative**: `(A + B) + C = A + (B + C)`, `(A * B) * C = A * (B * C)`
  * **Distributive**: `A * (B + C) = (A * B) + (A * C)`
  * **Identity**: `A + 0 = A`, `A * 1 = A`
  * **Null**: `A + 1 = 1`, `A * 0 = 0`
  * **Complement**: `A + ¬A = 1`, `A * ¬A = 0`

***

### **2. Sum-of-Products and Product-of-Sums Methods**

1. **Sum-of-Products (SOP)**

SOP is a Boolean expression where several product terms (AND operations) are summed (OR operations).

* **Example**: The Boolean expression `A * B + C` is in SOP form. The terms `A * B` and `C` are the product terms, and they are summed with the OR operator.
* **Application**: SOP is often used in designing digital circuits with AND and OR gates.

***

2. **Product-of-Sums (POS)**

POS is a Boolean expression where several sum terms (OR operations) are multiplied (AND operations).

* **Example**: The Boolean expression `(A + B) * (C + D)` is in POS form. The terms `(A + B)` and `(C + D)` are sum terms, and they are multiplied with the AND operator.
* **Application**: POS is used in digital circuit design when the expression needs to be implemented with NAND gates.

***

### **3. Truth Tables and Karnaugh Maps**

1. **Truth Tables**

A **truth table** is a tabular representation of all possible input combinations and their corresponding outputs for a Boolean function or logic circuit.

* **Steps to Create a Truth Table**:
  1. List all possible input combinations.
  2. Determine the output for each combination based on the Boolean expression or circuit.
  3. Present the results in a table format.
* **Example** for a 2-input AND gate:

| A | B | Output(A and B) |
| - | - | --------------- |
| 0 | 0 | 0               |
| 0 | 1 | 0               |
| 1 | 0 | 0               |
| 1 | 1 | 1               |

***

2. **Karnaugh Maps (K-map)**

A **Karnaugh map** is a graphical representation used to simplify Boolean expressions. It helps identify patterns in the truth table to minimize the Boolean expression.

* **Steps to Use K-map**:
  1. Construct a K-map grid with cells representing all possible input combinations.
  2. Place the output values from the truth table into the corresponding cells.
  3. Group adjacent cells with `1`s in powers of two (1, 2, 4, 8, etc.).
  4. Write the simplified Boolean expression based on the grouped cells.
* **Example** for a 2-variable K-map:

| A\B | 0 | 1 |
| --- | - | - |
| 0   | 0 | 1 |
| 1   | 1 | 1 |

The simplified Boolean expression for this K-map is: **A + B**.

***

**Example: 2-Variable K-map**

Let's work through an example to demonstrate the steps involved in simplifying a Boolean function using a K-map.

**Given Boolean Expression:**

F(A,B)=A′B+AB′

We need to simplify this expression using a K-map.

**Step 1: Construct the K-map Grid**

For a 2-variable Boolean function, the K-map will have four cells. Here's how it looks:

| A\B   | 0    | 1   |
| ----- | ---- | --- |
| **0** | A'B' | A'B |
| **1** | AB'  | AB  |

**Step 2: Fill in the Output Values**

Now, we need to fill in the K-map with the values from the given Boolean expression.

* A′B means A is 0 and B is 1, so place a 1 in the cell corresponding to A = 0 and B = 1.
* AB′ means A is 1 and B is 0, so place a 1 in the cell corresponding to A = 1 and B = 0.

The K-map looks like this:

| A\B   | 0 | 1 |
| ----- | - | - |
| **0** | 0 | 1 |
| **1** | 1 | 0 |

**Step 3: Group Adjacent 1s**

Now, let's group the 1s:

* We have two 1s in the K-map: one at A=0,B=1 and one at A=1,B=0.
* These two 1s form a pair. This is a "2-cell" group.

**Step 4: Write the Simplified Boolean Expression**

For the 2-cell group, look at the variables:

* (A is 0 in one cell and 1 in the other), so we **include A**.
* (B is 0 in one cell and 1 in the another).so we **include B** too.

Thus, the simplified expression is **A + B**.

***

**Benefits of Using K-maps:**

* **Simplification**: K-maps provide a straightforward method for minimizing Boolean expressions, especially when dealing with 2-4 variables.
* **Reduction in Circuit Complexity**: The simplified Boolean expressions result in fewer logic gates, making digital circuits more efficient and cost-effective.
* **Visualization**: K-maps provide a visual way to group terms and easily spot patterns that lead to simplifications.

**Generalization for More Variables:**

K-maps can be expanded to more variables, such as 3-variable (8 cells) and 4-variable (16 cells). K-maps, which work in the same way but involve larger grids and more complex groupings. The process remains the same: fill in the K-map, group adjacent 1s, and write the simplified Boolean expression based on those groups. Simplified Boolean expression means, minimum gates involved to design.

***

### Conclusion

Understanding number systems, logic levels, gates, and Boolean algebra is fundamental to digital electronics. Sum-of-Products (SOP) and Product-of-Sums (POS) methods simplify logic expressions for circuit design. Truth tables outline all input-output possibilities, while Karnaugh maps minimize Boolean expressions, optimizing circuit efficiency. These concepts enable the design of reliable and efficient digital systems.
