当前位置:网站首页>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
边栏推荐
- [sum of two numbers] 169 sum of two numbers II - enter an ordered array
- Zheng Qing 21 ACM is fun. (3) part of the problem solution and summary
- Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail
- A problem and solution of recording QT memory leakage
- Summary of Haut OJ 2021 freshman week
- YOLOv5-Shufflenetv2
- sync. Interpretation of mutex source code
- Solon Auth 认证框架使用演示(更简单的认证框架)
- 剑指 Offer 05. 替换空格
- 二十六、文件系统API(设备在应用间的共享;目录和文件API)
猜你喜欢
To the distance we have been looking for -- film review of "flying house journey"
Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
To be continued] [UE4 notes] L4 object editing
Yolov5 ajouter un mécanisme d'attention
Talking about JVM (frequent interview)
[转]: OSGI规范 深入浅出
Hang wait lock vs spin lock (where both are used)
Gbase database helps the development of digital finance in the Bay Area
[speed pointer] 142 circular linked list II
Merge sort
随机推荐
lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
MySQL数据库(一)
Haut OJ 1245: large factorial of CDs --- high precision factorial
Embedded database development programming (VI) -- C API
lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
二十六、文件系统API(设备在应用间的共享;目录和文件API)
2022上半年全国教师资格证下
PMP candidates, please check the precautions for PMP examination in July
kubeadm系列-01-preflight究竟有多少check
Software test -- 0 sequence
[to be continued] [UE4 notes] L3 import resources and project migration
SDEI初探-透过事务看本质
Programmers' experience of delivering takeout
[to be continued] [depth first search] 547 Number of provinces
Add level control and logger level control of Solon logging plug-in
[转]: OSGI规范 深入浅出
Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!
Web APIs DOM节点
Developing desktop applications with electron
Optimization scheme of win10 virtual machine cluster