当前位置:网站首页>【基础知识】~ 半加器 & 全加器
【基础知识】~ 半加器 & 全加器
2022-06-24 19:42:00 【AI很不错呦】
1. 半加器
1.1 定义
半加器,就是不考虑进位的加法器,只有两个输入和两个输出:输入A和B,输出和数sum和进位cout,半加器真值表如下:
1.2 关系表达式

1.3 电路设计

1.4 代码实现
module add_half(
input A ,
input B ,
output wire S ,
output wire C
);
assign S = A ^ B;
assign C = A & B;
endmodule
2. 全加器
2.1 定义
全加器就是在半加器的基础上引入一个进位输入,总共三个输入两个输出。全加器真值表如下:
2.2 关系表达式
这里的输出一共有两个,一个sum,一个进位cout。sum的值是A+B+cin然后去掉进位得到的,也就是说A、B、cin 中,如果输入1的个数是奇数,则sum为1,输入1的个数为偶数(含零)则sum为0。根据这个奇偶判定,可以想到用异或操作,所以得到表达式:
cout的值也好分析,cout是加和出来的进位,也就是说,如果A、B、cin三个数中,有两个及以上个1,则cout为1,这个容易得到表达式:
2.3 电路设计
2.4 代码实现
module add_full(
input A ,
input B ,
input Ci ,
output wire S ,
output wire Co
);
assign S = A ^ B ^ Ci;
assign Co = A&B | A&Ci | B&Ci;
endmodule
3. 两个半加器 实现 一个全加器
3.1 设计电路图

3.2 代码实现
`timescale 1ns/1ns
module add_half(
input A ,
input B ,
output wire S ,
output wire C
);
assign S = A ^ B;
assign C = A & B;
endmodule
/***************************************************************/
module add_full(
input A ,
input B ,
input Ci ,
output wire S ,
output wire Co
);
wire [1:0] s, c;
add_half m1 (
.A(A),
.B(B),
.S(s[0]),
.C(c[0]));
add_half m2 (
.A(s[0]),
.B(Ci),
.S(s[1]),
.C(c[1]));
assign S = s[1];
assign Co = c[0] | c[1];
endmodule
其实这是一道公司笔试题目,大家可以点击这里
参考文献
边栏推荐
- A big factory interview must ask: how to solve the problem of TCP reliable transmission? 8 pictures for you to learn in detail
- Recommended movies: Northeast tiger, licorice pizza
- Stop using it indiscriminately. This is the real difference between @validated and @valid!!!
- Construction equipment [4]
- laravel 添加helper文件
- 记录一下MySql update会锁定哪些范围的数据
- Epics record reference 2 -- epics process database concept
- Cat write multiline content to file
- canvas 实现图片新增水印
- 关于某手滑块的一些更新(6-18,js逆向)
猜你喜欢

记录一下MySql update会锁定哪些范围的数据

02_SpingBoot 入门案例
![[untitled]](/img/ed/847e678e5a652da74d04722bbd99ff.jpg)
[untitled]

Analyze the implementation process of oauth2 distributed authentication and authorization based on the source code

Environment configuration | vs2017 configuring openmesh source code and environment

研究生宿舍大盘点!令人羡慕的研究生宿舍来了!

机器学习编译入门课程学习笔记第一讲 机器学习编译概述

动态菜单,自动对齐

Attention, postgraduate candidates! They are the easiest scams to get caught during the preparation period?!

双亲委派机制
随机推荐
JD 618 conference tablet ranking list announced that the new dark horse brand staff will compete for the top three, learning from Huawei, the leader of domestic products
Parental delegation mechanism
2022年高压电工考试模拟100题及在线模拟考试
【Laravel系列7.9】测试
Solve the problem of port occupation
Recommended course: workplace writing training
The extra points and sharp tools are worthy of the trust | know that Chuangyu won the letter of thanks from the defense side of the attack and defense drill!
Research Report on market supply and demand and strategy of China's solar charging controller industry
Theoretical analysis of countermeasure training: adaptive step size fast countermeasure training
Recommended movies: Northeast tiger, licorice pizza
【nvm】
C#学习两年的增删改查和C#导入导出(去重)案例
Accounting standards for business enterprises application [5]
【武汉大学】考研初试复试资料分享
A big factory interview must ask: how to solve the problem of TCP reliable transmission? 8 pictures for you to learn in detail
Docker installation redis- simple without pit
监听 Markdown 文件并热更新 Next.js 页面
23研考生注意啦!备考期间最容易中招的骗局,居然是它们?!
Research Report on research and investment prospects of China's container coating industry (2022 Edition)
Talk about GC mechanism often asked in interview