Skip to content

Commit

Permalink
来自 criwits 的 2022 春《计算方法》和 2021 秋《数字逻辑设计》笔记 (HITSZ-OpenCS#78)
Browse files Browse the repository at this point in the history
* 添加 2022 春计算方法笔记

* 添加 2021 秋《数字逻辑设计》笔记
  • Loading branch information
criwits authored Jun 6, 2022
1 parent 959f545 commit 1cfb951
Show file tree
Hide file tree
Showing 79 changed files with 2,160 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# 基本逻辑门

Logic gates are the basic building blocks of any digital system. A logic gate is a electronic circuit having one or more than one *input port(s)* and only one *output port*. The relationship between its input(s) and output is determined by a certain logic.

It’s necessary to memorise the function, symbol as well as algebraic expression of some common logic gates introduced in this chapter.

# Basic Operations

## AND Gate

The AND gate only outputs a positive signal when all of its inputs are getting positive signal.

Expression: $F=A\cdot B=AB$. Intuitively the AND logic can be treated as multiplication.

Symbol:

![Untitled](%E5%9F%BA%E6%9C%AC%E9%80%BB%E8%BE%91%E9%97%A8%20c5a80174c1ca46d7ae2c7190d0d77fa8/Untitled.png)

## OR Gate

The OR gate only outputs a negative signal when all of its inputs are getting negative signal.

Expression: $F=A+B$. Intuitively the OR logic can be treated as addition.

Symbol:

![Untitled](%E5%9F%BA%E6%9C%AC%E9%80%BB%E8%BE%91%E9%97%A8%20c5a80174c1ca46d7ae2c7190d0d77fa8/Untitled%201.png)

## NOT Gate

The NOT gate will produce a signal different from its input.

Expression: $F=\bar{A}=A'$.

Symbol:

![Untitled](%E5%9F%BA%E6%9C%AC%E9%80%BB%E8%BE%91%E9%97%A8%20c5a80174c1ca46d7ae2c7190d0d77fa8/Untitled%202.png)

# Other Operations

## NAND Gate

NAND = NOT + AND, i.e. $F=\overline{AB}$.

Symbol:

![Untitled](%E5%9F%BA%E6%9C%AC%E9%80%BB%E8%BE%91%E9%97%A8%20c5a80174c1ca46d7ae2c7190d0d77fa8/Untitled%203.png)

## NOR Gate

NOR = NOT + OR, i.e. $F=\overline{A+B}$.

Symbol:

![The symbol on the right side is so ugly that I’m wondering if my teacher drew it with line & curve tools in PowerPoint.](%E5%9F%BA%E6%9C%AC%E9%80%BB%E8%BE%91%E9%97%A8%20c5a80174c1ca46d7ae2c7190d0d77fa8/Untitled%204.png)

The symbol on the right side is so ugly that I’m wondering if my teacher drew it with line & curve tools in PowerPoint.

## AND-OR-NOT Gate

**This is not a common logic gate**.

This kind of logic gate has 4 input ports, wiring them with AND gate two by two and then connects the two outputs with a NOR gate.

Expression: $F=\overline{AB+CD}$.

Symbol:

![Untitled](%E5%9F%BA%E6%9C%AC%E9%80%BB%E8%BE%91%E9%97%A8%20c5a80174c1ca46d7ae2c7190d0d77fa8/Untitled%205.png)

The fact is, I hold the opinion that this is not a logic gate. It’s a kind of combinational logic block.

## XOR Gate

Exclusive OR gate, or XOR gate, outputs a positive signal only when its two input signals are different from each other.

Expression: $F=A\oplus B=\bar{A}B+A\bar{B}$.

Symbol:

![Untitled](%E5%9F%BA%E6%9C%AC%E9%80%BB%E8%BE%91%E9%97%A8%20c5a80174c1ca46d7ae2c7190d0d77fa8/Untitled%206.png)

## XNOR Gate

XNOR = NOT + XOR, i.e. $F=AB+\bar{A}\bar{B}$.

XNOR gate outputs a positive signal only when its two input signals are the same one.

Symbol:

![The bottom-left symbol is more or less... rough.](%E5%9F%BA%E6%9C%AC%E9%80%BB%E8%BE%91%E9%97%A8%20c5a80174c1ca46d7ae2c7190d0d77fa8/Untitled%207.png)

The bottom-left symbol is more or less... rough.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# 布尔代数

The Boolean algebra is used to describe certain logic design made up with several logic gates and wires connecting them.

# Laws and Theorems in Boolean Algebra

## Basic Theorems

- $A+B=B+A$, and $AB=BA$.
- $(A+B)+C=A+(B+C)$, and $(AB)C=A(BC)$.
- $A(B+C)=AB+AC$.
- $A+AB=A$, and $A(A+B)=A$.

This theorem shows that $B$ will be ‘absorbed’ in this form of expression.

- $AB+A\bar{B}=A$, and $(A+B)(A+\bar{B})=A$.
- $A+\bar{A}B=A+B$.

$A+\bar{A}B=A+AB+\bar{A}B=A+(A+\bar{A})B=A+B$.

- ${A+BC=(A+B)(A+C)}$

Why: $(A+B)(A+C)=A+AC+BA+BC$, and $A+AC+BA=A$.

- $AB+\bar{A}C+BC=AB+\bar{A}C$, and $AB+\bar{A}C+BCD=AB+\bar{A}C$.

Use $BC$ to absorb $BCD$.

- $\overline{A\bar{B}+\bar{A}B}=\bar{A}\bar{B}+AB$.

XNOR = XOR + NOT.


## DeMorgan’s Law

$$
\begin{align*}\overline{X_1X_2\cdots X_n}=\bar{X}_1+\bar{X}_2+\cdots+\bar{X}_n\\\overline{X_1+X_2+\cdots+X_n}=\bar{X}_1\bar{X}_2\cdots\bar{X}_n\end{align*}
$$

## Dual Rule

By changing operators in an expression in this way you get its dual expression:

- $+\leftrightarrow\cdot$
- $\oplus\leftrightarrow\odot$

For a equation it’s dual expression is still valid. For example:

$$
A+BCD=(A+B)(A+C)(A+D)\Leftrightarrow A(B+C+D)=AB+AC+AD
$$

# Maxterm and Minterm

It’s easy for us to realise that for a boolean expression containing some variables—say, $A$, $B$, $C$ and $D$—it can be written in this form: only several AND items added together, i.e. addiction of multiplications. An example:

$$
f(A, B, C, D)=AB+ACD+D
$$

And if we add invisible items (which is always 1) such as $(A+A')$ and $(D+D')$ to make each AND item has all four variables appear, then the formula can be expanded to:

$$
f(A,B,C,D)=AB(C+C')(D+D')+A(B+B')CD+(A+A')(B+B')(C+C')D
$$

Simplify this expression using the law $A(B+C)=AB+AC$, we will get

$$
f(A,B,C,D)=ABCD+ABCD'+ABC'D+ABC'D'+AB'CD+A'BCD+A'B'CD+A'BC'D+A'B'C'D
$$

If we use $1011$ to represent $AB'CD$, use $0110$ to represent $A'BCD'$, then the items in the formula above are:

$$
1111, 1110, 1101, 1100, 1011, 0111, 0011, 0101, 0001
$$

All of them are 4-bit binary numbers so we just transform them into decimal numbers. They are

$$
15, 14, 13, 12, 11, 7, 3, 5, 1
$$

Intuitively, the original boolean expression can be expressed with a series of numbers. This is called the *minterm* expression. More detailed, we use minterm expression in this algebraic way:

$$
f(A,B,C,D)=\sum m(1, 3, 5, 7, 11, 12, 13, 14, 15)
$$

Dually, an expression can also be written in this way:

$$
g(A, B, C)=(A'+B+C)(A+B+C')(A'+B'+C)
$$

Treat $(A'+B+C)$ as binary number $100$, then we have the *maxterm* expression. It is expressed in this way:

$$
g(A,B,C)=\prod M(1, 5, 6)
$$

According to the dual rule it’s easy for us to change an expression into the other one. For instance:

$$
f(A,B,C)=\sum m(1, 4, 5, 7)=\prod M(0, 2, 3, 6)
$$

This figure shows some interesting relationships.

![Untitled](%E5%B8%83%E5%B0%94%E4%BB%A3%E6%95%B0%2068f91aab71134af48483ec3eda18e153/Untitled.png)

# Karnaugh Map

Karnaugh Map (K. Map) is a powerful tool used in expression simplification and other scenarios.

K. Map is a table containing $2^n$ element cells. Each cell stands for a minterm. The cells are arranged in a Gray code way, which means the two cells next to each other have only one different bit. For 4 variables the K. Map usually likes this:

![Untitled](%E5%B8%83%E5%B0%94%E4%BB%A3%E6%95%B0%2068f91aab71134af48483ec3eda18e153/Untitled%201.png)

Steps when using K. Map to simplify logic expression:

## Fulfil the K. Map

To fulfil the K. Map you firstly transform your expression into the form ‘addiction of multiplications’. For example,

$$
F=\overline{A\oplus C\cdot\overline{\bar{B}(A\bar{C}\bar{D}+\bar{A}C\bar{D})}}=AC+\bar{A}\bar{C}+A\bar{B}\bar{C}\bar{D}+\bar{A}\bar{B}C\bar{D}
$$

Then for each multiplication fill its corresponding K. Map cells with 1. For example, for $\bar{A}\bar{C}$, we find the row where $A$ is 0, and mark 1 in those rows whose $C$ is 0. Finally we will have a K. Map like this:

![Untitled](%E5%B8%83%E5%B0%94%E4%BB%A3%E6%95%B0%2068f91aab71134af48483ec3eda18e153/Untitled%202.png)

*An interesting fact is that you can now read the minterm expression directly on this K. Map.*

## Circle the Prime Implicants in K. Map

Now, we make rectangular groups containing total terms in power of 2 and try to cover as many elements as you can in one group.

![Untitled](%E5%B8%83%E5%B0%94%E4%BB%A3%E6%95%B0%2068f91aab71134af48483ec3eda18e153/Untitled%203.png)

Note that the four red groups are the same group for the parallel edges and corners of such K. Map are connected together.

This kind of rectangular groups, or circles, are called ‘prime implicants’. ‘Implicant’ means the rectangular group only consists 1 and ‘prime’ means it has been expanded as large as possible.

## Get Simplified Expression from the Implicants

Each group in the figure above stands for a multiplication item. Just write them and add them together and you get a simplified addiction of multiplications.

Look at the figure above.

- For four elements in the red circle, they have both $B$ and $D$ as 0, while their $A$ and $C$ values differ. So for this group it’s implicant is $B'D'$.
- For four elements in the green circle, they have both $A$ and $C$ as 0, so this group represents $A'C'$.
- For four elements in the yellow circle, they have both $A$ and $C$ as 1, so this group represents $AC$.

So finally we can read out this expression:

$$
F=A'C'+AC+B'D'
$$

## Distinguished 1-Cell and Essential Prime Implicant

- Distinguished 1-cell means the cell in a K. map who is only covered by one prime implicant.
- Essential prime implicant means the prime implicant containing distinguished 1-cell.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1cfb951

Please sign in to comment.