当前位置:网站首页>【基础知识】~ 半加器 & 全加器
【基础知识】~ 半加器 & 全加器
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
其实这是一道公司笔试题目,大家可以点击这里
参考文献
边栏推荐
- Daily practice (22): maximum sum of continuous subarrays
- 京东618会议平板排行榜公布,新锐黑马品牌会参谋角逐前三名,向国货老大华为学习
- Accounting standards for business enterprises application [5]
- Vulnhub Vegeta: 1
- Push markdown format information to the nailing robot
- 案例解析:用「度量」提升企业研发效能|ONES Talk
- Construction equipment [4]
- Non single file component
- How should we measure agile R & D projects?
- 力扣解法汇总515-在每个树行中找最大值
猜你喜欢
大厂面试必问:如何解决TCP可靠传输问题?8张图带你详细学习
02_ Springboot starter case
Paddledtx v1.0 has been released, and its security and flexibility have been comprehensively improved!
vulnhub Vegeta: 1
Non single file component
How to integrate Huawei cloud function services in fluent
Canvas to add watermark to pictures
shopee开店入驻流水如何提交?
canvas 实现图片新增水印
[text data mining] Chinese named entity recognition: HMM model +bilstm_ CRF model (pytoch) [research and experimental analysis]
随机推荐
2022 safety officer-a certificate examination questions and answers
京东618会议平板排行榜公布,新锐黑马品牌会参谋角逐前三名,向国货老大华为学习
A big factory interview must ask: how to solve the problem of TCP reliable transmission? 8 pictures for you to learn in detail
Attackg: constructing technical knowledge graph from cyber thread intelligence reports
关于某手滑块的一些更新(6-18,js逆向)
Source code reading | the process of reading text format STL by openmesh
Research Report on market supply and demand and strategy of ceiling power supply device industry in China
力扣解法汇总515-在每个树行中找最大值
laravel 宝塔安全配置
剑指 Offer 42. 连续子数组的最大和
win10或win11打印机无法打印
Introduction to machine learning compilation course learning notes lesson 1 overview of machine learning compilation
vulnhub Vegeta: 1
是否需要提高代码阅读能力?这有技巧
2022 safety officer-b certificate examination question bank and answers
EPICS记录参考3 -- 所有记录都有的字段
What kind of processor architecture is ARM architecture?
laravel model 注意事项
Selection (025) - what is the output of the following code?
2022 simulated 100 questions and simulated examination of high-altitude installation, maintenance and demolition