当前位置:网站首页>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
边栏推荐
- What is the agile proportion of PMP Exam? Dispel doubts
- 剑指 Offer 53 - I. 在排序数组中查找数字 I
- kubeadm系列-00-overview
- Development error notes
- Zheng Qing 21 ACM is fun. (3) part of the problem solution and summary
- Romance of programmers on Valentine's Day
- 剑指 Offer 09. 用两个栈实现队列
- YOLOv5添加注意力機制
- 剑指 Offer 35.复杂链表的复制
- Learning notes of "hands on learning in depth"
猜你喜欢

剑指 Offer 05. 替换空格

剑指 Offer 04. 二维数组中的查找
![[to be continued] [UE4 notes] L2 interface introduction](/img/0f/268c852b691bd7459785537f201a41.jpg)
[to be continued] [UE4 notes] L2 interface introduction

Learning notes of "hands on learning in depth"

GBase数据库助力湾区数字金融发展
![[turn to] MySQL operation practice (I): Keywords & functions](/img/b1/8b843014f365b786e310718f669043.png)
[turn to] MySQL operation practice (I): Keywords & functions

Web APIs DOM节点

Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail

YOLOv5-Shufflenetv2

A new micro ORM open source framework
随机推荐
动漫评分数据分析与可视化 与 IT行业招聘数据分析与可视化
[to be continued] [UE4 notes] L3 import resources and project migration
The next key of win generates the timestamp file of the current day
[turn]: Apache Felix framework configuration properties
Csp-j-2020-excellent split multiple solutions
Count sort
room数据库的使用
Find a good teaching video for Solon framework test (Solon, lightweight application development framework)
Warning using room database: schema export directory is not provided to the annotation processor so we cannot export
Introduction to memory layout of FVP and Juno platforms
软件测试 -- 0 序
Summary of Haut OJ 2021 freshman week
sync. Interpretation of mutex source code
每日一题-搜索二维矩阵ps二维数组的查找
[es practice] use the native realm security mode on es
Insert sort
C language Essay 1
[to be continued] I believe that everyone has the right to choose their own way of life - written in front of the art column
Solon Auth 认证框架使用演示(更简单的认证框架)
YOLOv5添加注意力機制