常见组合逻辑器原理和设计详解

本文将详细介绍各种组合逻辑器的基本原理,以及具体的实现方案。每一种逻辑器件将通过三种方式来展示如何实现该器件的功能,分别是:

  • 真值表
  • 逻辑门电路
  • Mos管电路
提示
可通过侧边栏目录快速查看 👉

逻辑门

如果说逻辑是现实世界的基础,那么逻辑门就是数字电路的核心。因此,理解并能够适当运用各种逻辑门的不同功能对于学好数字电路至关重要。常用逻辑门主要包括以下10种:

缓冲器(Buffer)

  • 符号:A
  • 真值表:
    A Buffer A
    0 0
    1 1

非门(Not Gate)

  • 符号:\lnot A / \overline{A}
  • 真值表:
    A Not A
    0 1
    1 0

与门(And Gate)

  • 符号:A \land B / A \cdot B
  • 真值表:
    A B A and B
    0 0 0
    0 1 0
    1 0 0
    1 1 1

与非门(Nand Gate)

  • 符号:\lnot(A \land B) / \overline{A \cdot B}
  • 真值表:
    A B A nand B
    0 0 1
    0 1 1
    1 0 1
    1 1 0

或门(Or Gate)

  • 符号:A \lor B / A + B
  • 真值表:
    A B A or B
    0 0 0
    0 1 1
    1 0 1
    1 1 1

或非门(Nor Gate)

  • 符号:\lnot(A \lor B) / \overline{A + B}
  • 真值表:
    A B A nor B
    0 0 1
    0 1 0
    1 0 0
    1 1 0

异或门(Xor Gate)

  • 符号:A \oplus B
  • 真值表:
    A B A xor B
    0 0 0
    0 1 1
    1 0 1
    1 1 0

同或门(Xnor Gate)

  • 符号:\lnot(A \oplus B) / \overline{A \oplus B}
  • 真值表:
    A B A xnor B
    0 0 1
    0 1 0
    1 0 0
    1 1 1

蕴涵门(Imply Gate)

  • 符号:A \to B
  • 真值表:
    A B A imply B
    0 0 1
    0 1 1
    1 0 0
    1 1 1

蕴涵非(Nimply Gate)

  • 符号:\lnot(A \to B) / \overline{A \to B}
  • 真值表:
    A B A nimply B
    0 0 0
    0 1 0
    1 0 1
    1 1 0

加法器

数字加法器是用于计算二进制加法的组合逻辑器件。分为半加器和全加器,具体详情如下:

半加器

半加器不包含进位,因此只有两个输入,结构非常简单,一个异或门用于输出结果,另一个与门用于输出进位。
  • 电路图

全加器

全加器是半加器的升级版,解决了半加器不兼容进位的问题。通过两个半加器相连,最后使用一个或门输出进位。
  • 电路图

减法器

减法器是专用于减法的逻辑器,除了真值表与加法器类似,结构也与加法器有异曲同工之处。

  • 真值表

    A B C.in C.out S
    0 0 0 0 0
    0 0 1 1 1
    0 1 0 1 1
    0 1 1 1 0
    1 0 0 0 1
    1 0 1 0 0
    1 1 0 0 0
    1 1 1 1 1

根据减法器的真值表,可以发现对于 C.out 和 S 分别有四组组合等于1。因此,我们可以得到以下逻辑代数组合:

\begin{array}{} \text{C.out} \left\{ \begin{array}{l} \lnot A \land \lnot B \land C \\ \lnot A \land B \land \lnot C \\ \lnot A \land B \land C \\ A \land B \land C \\ \end{array} \right. \end{array}
\begin{array}{} \text{S} \left\{ \begin{array}{l} \lnot A \land \lnot B \land C \\ \lnot A \land B \land \lnot C \\ A \land \lnot B \land \lnot C \\ A \land B \land C \end{array} \right. \end{array}

取或,然后根据C(这里可以是任意输入,A和B都可以)的值进行分组和化简:

  • C.out 输出

    \lnot A \land \lnot B \land C \textcolor{red}{\lor} \lnot A \land B \land \lnot C \textcolor{red}{\lor} \lnot A \land B \land C \textcolor{red}{\lor} A \land B \land C

    C = 0:
    \lnot A \land B \land \textcolor{red}{\lnot C} \\ 👇 \\ \textcolor{lime}{\lnot C \land (\lnot A \land B)}

    C = 1:
    \lnot A \land \lnot B \land \textcolor{red}{C} \\ \lor \\ A \land B \land \textcolor{red}{C} \\ \lor \\ \lnot A \land B \land \textcolor{red}{C}
    提取共因子:
    C \land [( \lnot A \land \lnot B ) \lor (A \land B) \lor (\lnot A \land B)] \\ 👇 \\ C \land [( \lnot A \land (\lnot B \lor B) \lor (A \land B)] \\ 👇 \\ C \land [( \lnot A \lor (A \land B)] \\ 👇 \\ C \land [( \lnot A \lor A) \land ( \lnot A \lor B)] \\

¬A ∨ A = 1, ¬B ∨ B = 1

👇 \\ \textcolor{lime}{C \land ( \lnot A \lor B)}

C.out 输出的最终表达式:
(\lnot C \land (\lnot A \land B)) \lor (C \land ( \lnot A \lor B)) \\ 👇 \\ (\lnot C \land \lnot A \land B) \lor (C \land \lnot A) \lor (C \land B) \\ 👇 \\ \lnot A \land ((\lnot C \land B) \lor C) \lor (C \land B) \\ 👇 \\ \lnot A \land ((\lnot C \lor C) \land (B \lor C)) \lor (C \land B) \\ 👇 \\ \textcolor{lime}{\lnot A \land (B \lor C) \lor (C \land B)}

  • S 输出

    \lnot A \land \lnot B \land C \textcolor{red}{\lor} \lnot A \land B \land \lnot C \textcolor{red}{\lor} A \land \lnot B \land \lnot C \textcolor{red}{\lor} A \land B \land C

    C = 0:
    \lnot A \land B \land \textcolor{red}{\lnot C} \\ \lor \\ A \land \lnot B \land \textcolor{red}{\lnot C} \\
    提取共因子:
    \lnot C \land [( \lnot A \land B ) \lor (A \land \lnot B)] \\ 👇 \\ ( \lnot A \land B ) \lor (A \land \lnot B) \underset{等价于}{\Rightarrow}{A \oplus B} \\ 👇 \\ \textcolor{lime}{\lnot C \land (A \oplus B)}

    C = 1:
    \lnot A \land \lnot B \land \textcolor{red}{C} \\ \lor \\ A \land B \land \textcolor{red}{C}
    提取共因子:
    C \land [( \lnot A \land \lnot B ) \lor (A \land B)] \\ 👇 \\ ( \lnot A \land \lnot B ) \lor (A \land B) \underset{等价于}{\Rightarrow}{A \odot B} \\ 👇 \\ \textcolor{lime}{C \land (A \odot B)}

S 输出的最终表达式:
\lnot C \land (A \oplus B)) \lor (C \land (A \odot B)) \\ 👇 \\ \lnot C \land \lnot (A \odot B)) \lor (C \land (A \odot B)) \\ 👇 \\ \lnot C \land \lnot (A \odot B)) \lor (C \land (A \odot B)) \underset{等价于}{\Rightarrow}{C \odot (A \odot B)} \\ 👇 \\ \textcolor{lime}{A \odot B \odot C}

发现个有意思的地方,因为A⊙B⊙C相当于A⊕B⊕C的连续两次反转,所以A⊕B⊕C = A⊙B⊙C

根据得到的表达式,我们可以获得以下减法器电路:

以上是根据简化后的逻辑表达式得出的电路,与全加器的结构非常类似,上面的电路可能不太看得出来。因此我单独设计了以下等价电路,可以很明显的看出来与全加器的相似之处。两者之间唯一的区别在于减法器使用的是蕴含非门和异或门用于计算和输出进位。

比较器

在数字电路中,比较器用于对两个或多个数据项进行比较,以确定它们是否相等,或确定它们之间的大小关系及排列顺序。以下是常见的一位比较器真值表:

A B A > B A < B A = B
0 0 0 0 1
0 1 0 1 0
1 0 1 0 0
1 1 0 0 1

可以看到,当A=B,结果与同或门一致。而当A<B或A>B时,结果可以用蕴含非门表示。

因此,我们可以得到以下电路:

多位比较器可以通过串联多个一位比较器进行比较,比特位越高,其优先级越高。以下是一个三位比极器示例:

这里使用了与门充当一个开关的角色,只有当高位相等时才允许进行低位比较。

编码器

编码器 (Encoders) 是组合逻辑器件的一种,用于将 2^n个输入信号编码成 n 位二进制输出。需要注意的是:2^n个输入里只能有一个为1,因此,如果有多位输入为1,必须引入错误处理机制或者使用优先编码器,否则会输出错误信号。

根据输入的1的位置,我们可以获得对应的二进制输出。比如4-2编码器,当第三位为高电平时,对应的输出为10。基于这个特性,编码器很适合用于按键编码和存储地址编码。

我们可以先从4-2编码器分析运作方式,以下是对应真值表:

D C B A Out.1 Out.0
0 0 0 1 0 0
0 0 1 0 0 1
0 1 0 0 1 0
1 0 0 0 1 1

可以很清晰的看到:

  • 右边的输出位只有当第二和第四位输入为1时才为1。
  • 左边的输出位只有当第三和第四位输入为1时才为1。
  • 其余情况为0。

根据以上这些条件,可以得到以下关系式:

Out.0 = (\textcolor{red}{A} \land \lnot B \land \lnot C \land \lnot D) \lor (\lnot A \land \lnot B \land \textcolor{red}{C} \land \lnot D) \\ Out.1 = (\textcolor{red}{A }\land \lnot B \land \lnot C \land \lnot D) \lor (\lnot A \land \textcolor{red}{B} \land \lnot C \land \lnot D)

化简:

  • Out.0:

(\lnot A \land \textcolor{red}{B} \land \lnot C \land \lnot D) \lor (\lnot A \land \lnot B \land \lnot C \land \textcolor{red}{D}) \\ \Downarrow{} \\ (\lnot A \land \lnot C) \land ((\textcolor{red}{B} \land \lnot D) \lor (\lnot B \land \textcolor{red}{D})) \\ \Downarrow{} \\ (\textcolor{red}{B} \land \lnot D) \lor (\lnot B \land \textcolor{red}{D}) \underset{等价于}\Rightarrow B \oplus D \\ \Downarrow{} \\ \textcolor{lime}{\lnot A \land \lnot C \land (B \oplus D)}

  • Out.1:

(\lnot A \land \lnot B \land \textcolor{red}{C} \land \lnot D) \lor (\lnot A \land \lnot B \land \lnot C \land \textcolor{red}{D}) \\ \Downarrow{} \\ (\lnot A \land \lnot B) \land ((\textcolor{red}{C} \land \lnot D) \lor (\lnot C \land \textcolor{red}{D})) \\ \Downarrow{} \\ (\textcolor{red}{C} \land \lnot D) \lor (\lnot C \land \textcolor{red}{D}) \underset{等价于}\Rightarrow C \oplus D \\ \Downarrow{} \\ \textcolor{lime}{\lnot A \land \lnot B \land (C \oplus D)}

因此,根据获得的表达式可以获得下面左边的电路。但是在思考过后,发现虽然电路运行正常,但是总觉得哪里有点奇怪,查找资料后,发现实现4-2编码器到最小门级电路如下面右边的电路所示。其对应的表达式为:

  • Out.0 = B \lor D
  • Out.1 = C \lor D

目前观察到的几点是:

  1. 左边的电路有一点优先编码器的影子,因为限制了A和C的输入,而右边则假定输入只有一位为1。
  2. 左右两边都没有优先选择机制,但是左边电路相比右边电路附带错误检测机制:
    • 左边电路输入只能有一位为1,如果多位为1,无论数量多少,两个输出都只会输出0。因此如果连接一个或非门就可以知道是否存在输入错误。
    • 右边电路如果多位输入为1,两个输出都会为1。

解码器

解码器是另一种常见的组合逻辑器件,个人感觉相对于编码器,解码器的结构相对简单。因为每个输出只有一种可能,因此直接按照真值表就可以构建电路。这里以2-4解码器作为例子,以下是其对应的真值表:

B A Out.4 Out.3 Out.2 Out.1
0 0 0 0 0 1
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1 0 0 0

根据真值表,可以得到:

Out.1 = \lnot A \land \lnot B \\ Out.2 = \lnot A \land B \\ Out.3 = A \land \lnot B \\ Out.4 = A \land B

对应电路图:

复用器

复用器又被称为选择器,是一种可以从多个输入信号中选择一个信号进行输出的组合逻辑器件。可以通过控制端来选择其中一个信号作为输出。以下是4:1复用器的真值表:

S2 S1 Out
0 0 In.0
0 1 In.1
1 0 In.2
1 1 In.3

这里与其它逻辑器件不同的是,它并不会像其它逻辑器那样输出依赖于输入,而是输出与输入一致。因为输出只是根据信号的值将指定输入的数据传输到输出。

根据以上特性,我们可以使用与门来传输数据,因为当与门的一个输入等于1时,输出等于另一个输入。因此,我们可以得到以下逻辑表达式:

In.0 = \lnot S1 \land \lnot S2 \land In.0 \\ In.1 = S1 \land \lnot S2 \land In.1 \\ In.2 = \lnot S1 \land S2 \land In.2 \\ In.3 = S1 \land S2 \land In.3

然后,我们便能得到以下电路:

解复用器

解复用器与复用器正好相反,它将一个输入信号,通过信号输入控制,输出到多个输出中的一个。以下是1:4解复用器的真值表:

S2 S1 Out
0 0 Out.0
0 1 Out.1
1 0 Out.2
1 1 Out.3

我们可以看到,解复用器的真值表与复用器的真值表几乎没有什么区别。因此,表达式和电路也没有太大的变化。

  • 表达式:
    Out.0 = \lnot S1 \land \lnot S2 \land Input \\ Out.1 = S1 \land \lnot S2 \land Input \\ Out.2 = \lnot S1 \land S2 \land Input \\ Out.3 = S1 \land S2 \land Input

✍️ 作者:𝓜.𝓦𝓱𝓲𝓽𝓮

📄 共享协议: CC 4.0协议

🔗 原文链接: https://www.alloworld.me/archives/combinational-logic-circuits-design

评论