当前位置:网站首页>【基础知识】~ 半加器 & 全加器
【基础知识】~ 半加器 & 全加器
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
其实这是一道公司笔试题目,大家可以点击这里
参考文献
边栏推荐
- 02_ Springboot starter case
- canvas 实现图片新增水印
- Parental delegation mechanism
- China Sky Lantern market trend report, technical dynamic innovation and market forecast
- Financial management [6]
- Learn about redlock
- Financial management [2]
- 【Mongodb】READ_ ME_ TO_ RECOVER_ YOUR_ Data, the database is deleted maliciously
- 剑指 Offer 13. 机器人的运动范围
- Epics record reference 3 -- fields common to all records
猜你喜欢

vulnhub Vegeta: 1

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

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

双亲委派机制

Recommended movies: Northeast tiger, licorice pizza

花房集团二次IPO:成于花椒,困于花椒

2022年高压电工考试模拟100题及在线模拟考试

Environment configuration | vs2017 configuring openmesh source code and environment
Paddledtx v1.0 has been released, and its security and flexibility have been comprehensively improved!

Beijiafu (p+f) R2000 modified radar IP
随机推荐
【文本数据挖掘】中文命名实体识别:HMM模型+BiLSTM_CRF模型(Pytorch)【调研与实验分析】
Research Report on market supply and demand and strategy of China's solar charging controller industry
Cases of addition, deletion, modification and search of C # learning for two years and C # import and export (de duplication)
案例解析:用「度量」提升企业研发效能|ONES Talk
Environment configuration | vs2017 configuring openmesh source code and environment
2022年安全员-A证考题及答案
Daily practice (22): maximum sum of continuous subarrays
laravel 宝塔安全配置
京东618会议平板排行榜公布,新锐黑马品牌会参谋角逐前三名,向国货老大华为学习
监听 Markdown 文件并热更新 Next.js 页面
Introduction to machine learning compilation course learning notes lesson 1 overview of machine learning compilation
糖豆人登录报错解决方案
Research and investment strategy report on China's building steel structure anticorrosive coating industry (2022 Edition)
Spark 离线开发框架设计与实现
Selection (025) - what is the output of the following code?
Parental delegation mechanism
C#学习两年的增删改查和C#导入导出(去重)案例
EPICS record Reference 3 - - field available for all Records
03_SpingBoot 核心配置文件
Paddledtx v1.0 has been released, and its security and flexibility have been comprehensively improved!