当前位置:网站首页>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
边栏推荐
- [interval problem] 435 Non overlapping interval
- [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
- Yolov5 ajouter un mécanisme d'attention
- Embedded database development programming (V) -- DQL
- [speed pointer] 142 circular linked list II
- Solon Logging 插件的添加器级别控制和日志器的级别控制
- Reverse one-way linked list of interview questions
- Shell Sort
- Acwing 4301. Truncated sequence
猜你喜欢
[转]: OSGI规范 深入浅出
YOLOv5-Shufflenetv2
Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail
Talking about JVM (frequent interview)
sync.Mutex源码解读
GBase数据库助力湾区数字金融发展
用STM32点个灯
对象的序列化
[speed pointer] 142 circular linked list II
lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
随机推荐
Web APIs DOM node
[merge array] 88 merge two ordered arrays
YOLOv5-Shufflenetv2
YOLOv5添加注意力機制
lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!
Binary search basis
Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
Download xftp7 and xshell7 (official website)
[speed pointer] 142 circular linked list II
High precision subtraction
[to be continued] [UE4 notes] L3 import resources and project migration
Haut OJ 1316: sister choice buys candy III
Solon Logging 插件的添加器级别控制和日志器的级别控制
Chapter 6 data flow modeling - after class exercises
剑指 Offer 58 - II. 左旋转字符串
剑指 Offer 53 - II. 0~n-1中缺失的数字
第六章 数据流建模—课后习题
sync.Mutex源码解读
[to be continued] [UE4 notes] L2 interface introduction