当前位置:网站首页>ALU逻辑运算单元
ALU逻辑运算单元
2022-07-05 05:27:00 【李峻枫】
ALU逻辑运算单元
根据(二)中对单周期 CPU 的定义,该模块需要实现以下 4 类运算:加、减、按位与、按位或。因此需要 2 bit 的控制信号 Aluc 来控制 ALU 的运算类型。
信号的对应关系:
表 4 1 Aluc编码及对应功能
Aluc 编码 实现功能 运算类型
00 加 算数运算
01 减 算术运算
10 按位与 逻辑运算
11 按位或 逻辑运算
加减法可以使用 32 位全加器ADDSUB_32实现,按位与使用了AND32,按位或使用了OR32,对功能的选择使用了32位二选一多路选择器MUX2X32实现,返回了结果R,以及ALU的运算结果是否为0的判断Z(若R=0,Z=1;),Z主要是用于beq、bne指令。
代码
module ALU(X,Y,Aluc,R,Z);
input [31:0]X,Y;
input [1:0] Aluc;
output [31:0]R;
output Z;
wire [31:0]d_as,d_and,d_or,d_and_or;
ADDSUB_32 as32(X,Y,Aluc[0],d_as);
AND32 a32(X,Y,d_and);
OR32 o32(X,Y,d_or);
MUX2X32 select1(d_and,d_or,Aluc[0],d_and_or);
MUX2X32 select2(d_as,d_and_or,Aluc[1],R);
isZero i1(R,Z);
endmodule
边栏推荐
- Zheng Qing 21 ACM is fun. (3) part of the problem solution and summary
- [转]MySQL操作实战(一):关键字 & 函数
- Yolov5 ajouter un mécanisme d'attention
- YOLOv5-Shufflenetv2
- Research on the value of background repeat of background tiling
- Haut OJ 1401: praise energy
- [turn to] MySQL operation practice (III): table connection
- Use of room database
- 对象的序列化
- Shell Sort
猜你喜欢
C language Essay 1
Research on the value of background repeat of background tiling
Binary search basis
YOLOv5添加注意力机制
[to be continued] [UE4 notes] L3 import resources and project migration
Learning notes of "hands on learning in depth"
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
远程升级怕截胡?详解FOTA安全升级
Gbase database helps the development of digital finance in the Bay Area
lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
随机推荐
Developing desktop applications with electron
Haut OJ 1352: string of choice
Haut OJ 1357: lunch question (I) -- high precision multiplication
Service fusing hystrix
2022上半年全国教师资格证下
[turn]: OSGi specification in simple terms
Using HashMap to realize simple cache
26、 File system API (device sharing between applications; directory and file API)
GBase数据库助力湾区数字金融发展
支持多模多态 GBase 8c数据库持续创新重磅升级
PMP考生,请查收7月PMP考试注意事项
To the distance we have been looking for -- film review of "flying house journey"
[trans]: spécification osgi
数仓项目的集群脚本
Embedded database development programming (V) -- DQL
[to be continued] [depth first search] 547 Number of provinces
sync.Mutex源码解读
Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail
[binary search] 69 Square root of X
Web APIs DOM节点