6–4 Comparators

本文介绍了如何使用异或门构建基本比较器,比较两个二进制数的相等性,并通过级联74HC85扩展到多位。还详细讲解了如何通过XNOR和AND门结合判断不等性和使用VHDL设计4位幅度比较器。
摘要由CSDN通过智能技术生成

比较器的基本功能是比较两个二进制量的大小,以确定这些量之间的关系。在其最简单的形式中,比较器电路确定两个数字是否相等。 完成本节后,您应该能够

  • 使用异或门作为基本比较器
  • 分析具有相等和不等输出的幅度比较器的内部逻辑
  • 应用74HC85比较器来比较两个4位数的大小
  • 级联74HC85以将比较器扩展到八位或更多位
  • 使用VHDL描述一个4位幅度比较器

Equality

As you learned in Chapter 3, the exclusive-NOR gate can be used as a basic comparator because its output is a 0 if the two input bits are not equal and a 1 if the input bits are equal. Figure 6–18 shows the exclusive-NOR gate as a 2-bit comparator.

 In order to compare binary numbers containing two bits each, an additional exclusiveNOR gate is necessary. The two least significant bits (LSBs) of the two numbers are compared by gate G1, and the two most significant bits (MSBs) are compared by gate G2, as shown in Figure 6–19. If the two numbers are equal, their corresponding bits are the same, and the output of each exclusive-NOR gate is a 1. If the corresponding sets of bits are not equal, a 0 occurs on that exclusive-NOR gate output

为了比较包含两个位的二进制数,需要额外的异或门。两个数字的最低有效位(LSB)由门 G1 进行比较,而两个数字的最高有效位(MSB)由门 G2 进行比较,如图6-19所示。如果两个数字相等,则它们对应的位是相同的,每个异或门的输出为1。如果相应的位不相等,则该异或门输出为0。

 

 

为了产生一个单一的输出,指示两个数字的相等或不相等,可以将一个 AND 门与 XNOR 门结合起来,如图6-19所示。每个异或门的输出被应用于 AND 门的输入。当每个异或门的两个输入位相等时,数字的相应位相等,产生一个1应用于 AND 门的两个输入位,因此在输出上产生一个1。当两个数字不相等时,至少有一个或两个相应位不相等,AND 门的至少一个输入上会出现一个0,从而产生一个输出为0。因此,AND 门的输出表示两个数字的相等(1)或不相等(0)。示例6-5说明了这种操作的两种特定情况。 

Inequality

To determine an inequality of binary numbers A and B, you first examine the highestorder bit in each number. The following conditions are possible:

1. If A3 = 1 and B3 = 0, number A is greater than number B.

2. If A3 = 0 and B3 = 1, number A is less than number B.

3. If A3 = B3, then you must examine the next lower bit position for an inequality

 

比较器的工作原理如下:

  1. 将A和B的各个位进行比较。对于每一位,如果A的对应位大于B的对应位,则设置一个标志位“A > B”;如果A的对应位小于B的对应位,则设置一个标志位“A < B”;如果两个对应位相等,则设置一个标志位“A = B”。
  2. 如果任何一组对应位发现A > B 或 A < B,则停止比较并输出相应的结果。如果所有对应位都相等,则输出"A = B"。

这样,4位幅度比较器可以有效地比较两个4位二进制数的大小,并且在只需一次比较操作的情况下就可以确定它们的相对大小关系。

 

  • 22
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值