**作者：Harkerbest**

**声明：本文章为原创文章，本文章永久链接：https://www.harkerbest.cn/p/994，** **转载请注明原文地址，盗版必究！！！**

## Lecture 4: From Transistors to Gates

**1. Key Historical Figure: Claude Shannon**

**Master’s Thesis (1937)**: Shannon proposed that electrical switches can perform Boolean logic, which was revolutionary for computing. His work is considered one of the most important master’s theses in history.

**2. From Switches to Boolean Logic**

**Switch States**:- Open = 0 (False)
- Closed = 1 (True)
**Relays and Vacuum Tubes**: Earlier technologies used to create circuits before transistors.**Transistors**: Tiny, cheap, and reliable electronic components that function like switches, replacing relays and vacuum tubes.

**3. Transistor Basics**

**Definition**: A transistor controls the flow of electrical signals by acting as a switch.**Water Flow Example**:- Gate on (transistor conducts) = water flows (1)
- Gate off (transistor blocks) = water stops (0)
**Types**:**N-type**: Conducts when the gate-source voltage (V_GS) is high.**P-type**: Conducts when the gate-source voltage (V_GS) is low.

**4. CMOS Transistors**

**Complementary Metal-Oxide-Semiconductor (CMOS)**: Combines both P-type and N-type transistors.**N-type**: Closed (conducting) when gate is on (1), open (insulating) when gate is off (0).**P-type**: Open (insulating) when gate is on (1), closed (conducting) when gate is off (0).

**5. From Transistors to Logic Gates**

**Logic Gates**: Devices that perform Boolean functions based on input values. Gates are built using transistors.**Basic Logic Gates**: NOT, OR/NOR, AND/NAND, XOR.**Transistors per Gate**: Typically, 1 to 6 transistors are used to construct a gate.

**6. Common Logic Gates**

**NOT Gate (Inverter)**:- Input 0 produces output 1.
**NOR Gate**:- Output is true only when both inputs are false.
**AND/NAND Gates**:- AND: Both inputs must be true for the output to be true.
- NAND: Produces the opposite result of AND.

**7. Universal Logical Gates**

**Universal Gate**: Can implement any Boolean function without the need for other types of gates.**NAND Gate**: A universal gate that can be used to build any other gate.**NOR Gate**: Another universal gate that functions similarly.

**8. Key Concepts**

**Information Representation**: Information can be represented by bits.**Binary Arithmetic**: Boolean algebra allows binary operations.**Shannon’s Contribution**: Boolean logic can be realized with electrical switches.**Transistors**: Essential components that switch electronic signals.**NAND/NOR Gates**: Both are universal gates, crucial in designing integrated circuits.

## Lecture 5: From Gates to Circuits I: Combinational Circuits

**1. From Gates to Circuits**

**Logic Gates**: Small electronic devices that compute functions using two-valued signals (0, 1).**Boolean Functions**: Can be represented in three forms:**Truth Table****Logic Expression****Logic Circuit**

**2. Logic Circuits**

**Definition**: A collection of gates connected together to implement Boolean functions.**Integrated Circuits (ICs)**: Tiny transistors integrated into a small chip, which are foundational to modern digital logic circuits.

**3. Two Types of Circuits**

**Combinational Logic Circuits**:- Output depends solely on the current input.
- No memory, “memoryless.”
**Sequential Logic Circuits**:- Output depends on both the current input and the current state (which stores previous input).
- Contains memory.

**4. Combinational Circuits**

**Key Features**:- No memory, multiple inputs, and multiple outputs.
- Each output is determined by a Boolean function.
- Described by:
- n-input, m-output truth tables.
- Logic diagrams.

**5. Binary Addition Circuits**

**Half Adder**:- Adds two single bits.
- Produces a sum (s) and a carry bit (c).
- Logic expressions and circuit diagrams are used to implement this function.
**Full Adder**:- Adds three bits (A, B, and Carry-in).
- Outputs a sum and a carry-out.
**4-bit Adder**(Ripple-Carry Adder):- A series of full adders can be used to add two 4-bit numbers.
- The carry-out of one adder feeds into the carry-in of the next adder.
- Slow in performance due to sequential carry propagation (ripple effect).

**6. Decoder**

**Definition**: Selects one specific output from a set of inputs.**Usage**: Commonly used to decode memory addresses in a computer.- For example, a
**2-4 Decoder**decodes 2 input bits into 4 possible output lines, where only one line is active (set to 1) at a time.

**7. Multiplexer**

**Definition**: Selects a single output from multiple inputs.**Control Lines**: The specific input chosen for output is determined by the values on control lines.- A
**4-to-1 Multiplexer**selects one input out of four based on two control lines (log₂ 4 = 2).

**8. Combinational Circuit Analysis**

- Analyze circuits by identifying the logic function that they implement using a combination of truth tables, Boolean expressions, and logic diagrams.

**9. Combinational Circuit Design Process**

**Steps**:

- From the design specification, create a truth table.
- Derive the Boolean expression in
**Sum of Products (SOP)**or**Product of Sums (POS)**form. - Use a
**Karnaugh Map**to simplify the Boolean expression. - Implement the simplified expression using logic gates.
- Verify the result.

**10. Example: Comparator Circuit Design**

- Design a circuit that compares two 1-bit numbers (A and B). The outputs are:
**G (Greater)**: 1 if A > B.**E (Equal)**: 1 if A = B.**L (Lesser)**: 1 if A < B.- The circuit design involves filling in a truth table, deriving the logic expressions, and simplifying them.

**Key Concepts to Remember**

**Combinational Circuits**:- No memory.
- Basic building blocks for more complex systems.
- Examples: Half adder, full adder, decoder, multiplexer, ALU.
**Design and Analysis**: Understand how to go from truth tables to Boolean expressions and simplified logic gate diagrams.

## Lecture 6: From Gates to Circuits II: Sequential Circuits

**1. Sequential Circuits Overview**

**Difference from Combinational Circuits**:**Combinational Circuits**: Output depends solely on current inputs (memoryless).**Sequential Circuits**: Output depends on current inputs**and**previous inputs (current state), meaning they have**memory**.

**2. Memory in Sequential Circuits**

**Definition**: Memory allows circuits to “hold” or “remember” a value.**Write**: You can change the stored value.**Hold**: The value can be retained.**Read**: The stored value can be retrieved.**One-Bit Memory**:- A basic unit capable of holding a single bit (0 or 1).
- It can be set (1) or reset (0).

**3. Feedback in Circuits**

**Feedback**: The output of a circuit is fed back into the circuit as input. This feedback mechanism is essential for memory in sequential circuits.

**4. SR Latch (Set-Reset Latch)**

**Building Block**: A fundamental unit in sequential circuits, analogous to gates in combinational circuits.**Characteristic Table**:**SR = 00**: Stores the previous value.**SR = 01**: Resets to 0.**SR = 10**: Sets to 1.**SR = 11**: Undefined (unstable).**Gated SR Latch**: Adds an enable input (EN) to control when the latch can change state.**SR-NAND Latch**: A variation of the SR latch using NAND gates.

**5. Clocking and Timing**

**Gate Delay**: The small time delay between input changes and output changes, called gate delay, can cause glitches.**Clock**: A clock circuit produces electrical pulses that control when the state of the circuit can change.**Clock Speed**: Measured in MHz (millions of pulses per second).**Edge-Triggered**: Changes states on the rising or falling edge of the clock signal.**Level-Triggered**: Changes states whenever the clock signal is high or low.**Latches vs. Flip-Flops**:**Latch**: Level-triggered.**Flip-Flop**: Edge-triggered.

**6. JK Flip-Flop**

**JK Flip-Flop**: A modified SR flip-flop that eliminates the undefined state by using feedback. Only one input (Set or Reset) is active at a time, preventing illegal states.

**7. D Flip-Flop (Data Flip-Flop)**

**Simplified Circuit**: Stores one bit of data.**Operation**: When the clock signal is high, whatever is on the D (data) input is stored in the Q (output).**Use**: A true representation of physical computer memory.

**8. Registers and Binary Counters**

**Register**:- A group of flip-flops that can store multiple bits (e.g., 4-bit register).
- Includes additional lines for power, ground, and a clear/reset line.
**Write Enable (WE)**: Allows data to be written into the register.**Binary Counter**:- A sequential circuit that outputs binary numbers in sequence (e.g., from 0000 to 1111).
- Implemented using a series of JK flip-flops.

**9. Memory Design and Addressing**

**4×3 Memory Example**: Represents a simple memory where each column holds a 3-bit word.**Decoder**: Selects the correct memory location based on input addresses.**Memory Addressing**: For a simple microprocessor with 1KB memory (10 address lines), memory chips are selected and addressed using decoders and specific lines (e.g., 128×8 memory chips).

**10. 7-Segment Display**

**Truth Table**: Used to display numbers (0-9) on a 7-segment display.**Design Question**: How to display numbers from 0 to 9 sequentially?

**Key Concepts to Remember**

**Sequential Circuits**: Can remember previous inputs due to feedback and memory elements.**Flip-Flops**: Key memory elements in sequential circuits (SR, JK, D flip-flops).**Clocking**: Clocks are used to control when sequential circuits update their states.**Registers and Counters**: Built using flip-flops to store and process multiple bits of data.**Memory**: Involves addressing and decoding circuits to read and write data efficiently.