当前位置:网站首页>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
边栏推荐
猜你喜欢

Double pointer Foundation

读者写者模型

Reverse one-way linked list of interview questions

SAP-修改系统表数据的方法

一个新的微型ORM开源框架

lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
![[转]MySQL操作实战(一):关键字 & 函数](/img/b1/8b843014f365b786e310718f669043.png)
[转]MySQL操作实战(一):关键字 & 函数

Introduction to tools in TF-A
![[turn]: OSGi specification in simple terms](/img/54/d73a8d3e375dfe430c2eca39617b9c.png)
[turn]: OSGi specification in simple terms

YOLOv5-Shufflenetv2
随机推荐
Animation scoring data analysis and visualization and it industry recruitment data analysis and visualization
A new micro ORM open source framework
xftp7与xshell7下载(官网)
[to be continued] [UE4 notes] L3 import resources and project migration
Add level control and logger level control of Solon logging plug-in
Embedded database development programming (V) -- DQL
SAP method of modifying system table data
[paper notes] multi goal reinforcement learning: challenging robotics environments and request for research
Embedded database development programming (zero)
Bucket sort
Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
Optimization scheme of win10 virtual machine cluster
[turn]: Apache Felix framework configuration properties
[to be continued] [UE4 notes] L1 create and configure items
Developing desktop applications with electron
Development error notes
The next key of win generates the timestamp file of the current day
YOLOv5-Shufflenetv2
Haut OJ 1241: League activities of class XXX
National teacher qualification examination in the first half of 2022