当前位置:网站首页>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
边栏推荐
- Reverse one-way linked list of interview questions
- [turn to] MySQL operation practice (III): table connection
- [turn]: OSGi specification in simple terms
- 使用Room数据库报警告: Schema export directory is not provided to the annotation processor so we cannot expor
- SDEI初探-透过事务看本质
- [转]:Apache Felix Framework配置属性
- 每日一题-搜索二维矩阵ps二维数组的查找
- FVP和Juno平台的Memory Layout介绍
- The present is a gift from heaven -- a film review of the journey of the soul
- 远程升级怕截胡?详解FOTA安全升级
猜你喜欢
随机推荐
第六章 数据流建模—课后习题
[merge array] 88 merge two ordered arrays
FVP和Juno平台的Memory Layout介绍
YOLOv5-Shufflenetv2
[turn to] MySQL operation practice (I): Keywords & functions
Reader writer model
Developing desktop applications with electron
SAP-修改系统表数据的方法
[to be continued] [UE4 notes] L2 interface introduction
[paper notes] multi goal reinforcement learning: challenging robotics environments and request for research
PMP考生,请查收7月PMP考试注意事项
Pointnet++ learning
Optimization scheme of win10 virtual machine cluster
Haut OJ 1218: maximum continuous sub segment sum
[转]MySQL操作实战(一):关键字 & 函数
【ES实战】ES上的native realm安全方式使用
软件测试 -- 0 序
object serialization
剑指 Offer 05. 替换空格
[to be continued] [depth first search] 547 Number of provinces
![To be continued] [UE4 notes] L4 object editing](/img/0f/cfe788f07423222f9eed90f4cece7d.jpg)






