当前位置:网站首页>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
边栏推荐
- SAP-修改系统表数据的方法
- lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
- [allocation problem] 455 Distribute cookies
- Solon 框架如何方便获取每个请求的响应时间?
- Reverse one-way linked list of interview questions
- [to be continued] [depth first search] 547 Number of provinces
- 质量体系建设之路的分分合合
- Find a good teaching video for Solon framework test (Solon, lightweight application development framework)
- Embedded database development programming (VI) -- C API
- Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
猜你喜欢
Reverse one-way linked list of interview questions
Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail
Using HashMap to realize simple cache
lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
Pointnet++学习
Applet live + e-commerce, if you want to be a new retail e-commerce, use it!
[paper notes] multi goal reinforcement learning: challenging robotics environments and request for research
第六章 数据流建模—课后习题
Embedded database development programming (VI) -- C API
一个新的微型ORM开源框架
随机推荐
Under the national teacher qualification certificate in the first half of 2022
Yolov5 ajouter un mécanisme d'attention
使用Electron开发桌面应用
剑指 Offer 04. 二维数组中的查找
剑指 Offer 05. 替换空格
High precision subtraction
[转]:Apache Felix Framework配置属性
Reader writer model
Acwing 4301. Truncated sequence
Haut OJ 2021 freshmen week II reflection summary
Binary search basis
PMP candidates, please check the precautions for PMP examination in July
PMP考生,请查收7月PMP考试注意事项
服务熔断 Hystrix
National teacher qualification examination in the first half of 2022
object serialization
[转]MySQL操作实战(三):表联结
When will Wei Lai, who has been watched by public opinion, start to "build high-rise buildings" again?
Demonstration of using Solon auth authentication framework (simpler authentication framework)
搭建完数据库和网站后.打开app测试时候显示服务器正在维护.