当前位置:网站首页>Control Unit 控制部件
Control Unit 控制部件
2022-07-05 05:27:00 【李峻枫】
Control Unit 控制部件
在控制部件中,通过对指令编码的 op 、func 字段进行逻辑运算,来输出对应的控制信号。此模块仍然采用了门级实现,门级实现的代码虽然较为繁琐冗长,但是其更有利于我们理解电路内部的逻辑。
module CONUNIT(Z, Op, Func, Regrt, Se, Reg2reg, Pcsrc, Wmem, Aluc, Aluqb, Wreg);
input Z;
input [5:0] Op, Func;
output Regrt, Se, Wreg, Aluqb, Wmem, Reg2reg;
output [1:0] Pcsrc, Aluc;
wire R_type, I_add, I_sub, I_and, I_or, I_addi, I_andi, I_ori, I_lw, I_sw, I_beq, I_bne, I_J;
wire [5:0] Op_n,Func_n;
not (Op_n[0],Op[0]);
not (Op_n[1],Op[1]);
not (Op_n[2],Op[2]);
not (Op_n[3],Op[3]);
not (Op_n[4],Op[4]);
not (Op_n[5],Op[5]);
not (Func_n[0],Func[0]);
not (Func_n[1],Func[1]);
not (Func_n[2],Func[2]);
not (Func_n[3],Func[3]);
not (Func_n[4],Func[4]);
not (Func_n[5],Func[5]);
and (R_type, Op_n[5], Op_n[4], Op_n[3], Op_n[2], Op_n[1], Op_n[0]);
//R型指令,op字段全面为0
and (I_add, R_type, Func[5], Func_n[4], Func_n[3], Func_n[2], Func_n[1], Func_n[0]);
and (I_sub, R_type, Func[5], Func_n[4], Func_n[3], Func_n[2], Func[1], Func_n[0]);
and (I_and, R_type, Func[5], Func_n[4], Func_n[3], Func[2], Func_n[1], Func_n[0]);
and (I_or, R_type, Func[5], Func_n[4], Func_n[3], Func[2], Func_n[1], Func[0]);
and (I_addi, Op_n[5], Op_n[4], Op[3], Op_n[2], Op_n[1], Op_n[0]);
and (I_andi, Op_n[5], Op_n[4], Op[3], Op[2], Op_n[1], Op_n[0]);
and (I_ori, Op_n[5], Op_n[4], Op[3], Op[2], Op_n[1], Op[0]);
and (I_lw, Op[5], Op_n[4], Op_n[3], Op_n[2], Op[1], Op[0]);
and (I_sw, Op[5], Op_n[4], Op[3], Op_n[2], Op[1], Op[0]);
and (I_beq, Op_n[5], Op_n[4], Op_n[3], Op[2], Op_n[1], Op_n[0]);
and (I_bne, Op_n[5], Op_n[4], Op_n[3], Op[2], Op_n[1], Op[0]);
and (I_J, Op_n[5], Op_n[4], Op_n[3], Op_n[2], Op[1], Op_n[0]);
//j型指令,跳转
wire beq_Z, bne_Z_n, Z_n;
or (Regrt, I_addi, I_andi, I_ori, I_lw, I_sw, I_beq, I_bne, I_J);
//根据指令类型确定目的寄存器的类型:R型指令目的寄存器rd存放在[15:11],I型指令的目的寄存器rt存放在[20:16],
//此信号是控制多路选择器mux1
or (Se, I_addi, I_lw, I_sw, I_beq, I_bne);
//16->32位扩展,用于含有立即数的指令,控制ext
or (Wreg, I_add, I_sub, I_and, I_or, I_addi, I_andi, I_ori, I_lw);
//寄存器堆使能信号,当指令需要写入的时候,该值为1
or (Aluqb, I_add, I_sub, I_and, I_or, I_beq, I_bne, I_J);
//根据指令是否有立即数来控制多路选择器,对于R型指令,其结果为1,表示选择寄存器输出的值,否则为0,表示选择立即数
//控制mux2
or (Aluc[1], I_and, I_or, I_andi, I_ori);//1表示逻辑运算,0表示算数运算
or (Aluc[0], I_sub, I_or, I_ori, I_beq, I_bne);
//控制ALU的计算类型,控制alu
and (Wmem, I_sw, I_sw);
//储存器写使能信号,1的时候表示能写入
and (beq_Z, I_beq, Z);
not (Z_n, Z);
and (bne_Z_n, I_bne, Z_n);
or (Pcsrc[1], beq_Z, bne_Z_n, I_J);
and (Pcsrc[0], I_J, I_J);
//分支跳转信号,控制多路选择器mux4
or (Reg2reg, I_add, I_sub, I_and, I_or, I_addi, I_andi, I_ori, I_sw, I_beq, I_bne, I_J);
//输出信号控制,选择从ALU输出还是从储存器输出
endmodule
边栏推荐
- A new micro ORM open source framework
- Optimization scheme of win10 virtual machine cluster
- 剑指 Offer 04. 二维数组中的查找
- Csp-j-2020-excellent split multiple solutions
- 读者写者模型
- Haut OJ 1352: string of choice
- 一个新的微型ORM开源框架
- [转]: OSGI规范 深入浅出
- [speed pointer] 142 circular linked list II
- [sum of two numbers] 169 sum of two numbers II - enter an ordered array
猜你喜欢
![[turn to] MySQL operation practice (III): table connection](/img/70/20bf9b379ce58761bae9955982a158.png)
[turn to] MySQL operation practice (III): table connection

对象的序列化

Chapter 6 data flow modeling - after class exercises

Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!

挂起等待锁 vs 自旋锁(两者的使用场合)

YOLOv5添加注意力机制
![[speed pointer] 142 circular linked list II](/img/f8/222a360c01d8ef120b61bdd2025044.jpg)
[speed pointer] 142 circular linked list II

Embedded database development programming (zero)

剑指 Offer 05. 替换空格

Fragment addition failed error lookup
随机推荐
Improvement of pointnet++
[speed pointer] 142 circular linked list II
利用HashMap实现简单缓存
Reflection summary of Haut OJ freshmen on Wednesday
[转]MySQL操作实战(一):关键字 & 函数
kubeadm系列-02-kubelet的配置和启动
Applet live + e-commerce, if you want to be a new retail e-commerce, use it!
SSH password free login settings and use scripts to SSH login and execute instructions
Haut OJ 1352: string of choice
剑指 Offer 35.复杂链表的复制
Developing desktop applications with electron
SDEI初探-透过事务看本质
Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail
Solon Logging 插件的添加器级别控制和日志器的级别控制
[turn]: Apache Felix framework configuration properties
Acwing 4301. Truncated sequence
软件测试 -- 0 序
剑指 Offer 04. 二维数组中的查找
Under the national teacher qualification certificate in the first half of 2022
Haut OJ 1401: praise energy