当前位置:网站首页>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
边栏推荐
- 剑指 Offer 53 - I. 在排序数组中查找数字 I
- 2022上半年全国教师资格证下
- Add level control and logger level control of Solon logging plug-in
- Research on the value of background repeat of background tiling
- Haut OJ 1243: simple mathematical problems
- kubeadm系列-02-kubelet的配置和启动
- National teacher qualification examination in the first half of 2022
- 剑指 Offer 09. 用两个栈实现队列
- PMP candidates, please check the precautions for PMP examination in July
- 挂起等待锁 vs 自旋锁(两者的使用场合)
猜你喜欢

object serialization

质量体系建设之路的分分合合

Optimization scheme of win10 virtual machine cluster

Double pointer Foundation

YOLOv5-Shufflenetv2

第六章 数据流建模—课后习题

SAP-修改系统表数据的方法

Hang wait lock vs spin lock (where both are used)

Reverse one-way linked list of interview questions
![[turn to] MySQL operation practice (III): table connection](/img/70/20bf9b379ce58761bae9955982a158.png)
[turn to] MySQL operation practice (III): table connection
随机推荐
kubeadm系列-02-kubelet的配置和启动
26、 File system API (device sharing between applications; directory and file API)
xftp7与xshell7下载(官网)
MySQL数据库(一)
[转]MySQL操作实战(三):表联结
Use of room database
Haut OJ 1241: League activities of class XXX
Learning notes of "hands on learning in depth"
剑指 Offer 06.从头到尾打印链表
FVP和Juno平台的Memory Layout介绍
Web APIs DOM节点
剑指 Offer 58 - II. 左旋转字符串
对象的序列化
剑指 Offer 04. 二维数组中的查找
Haut OJ 1316: sister choice buys candy III
[binary search] 34 Find the first and last positions of elements in a sorted array
The next key of win generates the timestamp file of the current day
Haut OJ 1221: a tired day
[turn to] MySQL operation practice (I): Keywords & functions
On-off and on-off of quality system construction