推荐组合逻辑控制单元设计 精品.docx
- 文档编号:4085317
- 上传时间:2022-11-27
- 格式:DOCX
- 页数:19
- 大小:223.03KB
推荐组合逻辑控制单元设计 精品.docx
《推荐组合逻辑控制单元设计 精品.docx》由会员分享,可在线阅读,更多相关《推荐组合逻辑控制单元设计 精品.docx(19页珍藏版)》请在冰豆网上搜索。
推荐组合逻辑控制单元设计精品
一、实验课题
实验要求:
按照题目要求用硬布线(组合逻辑)控制法设计一个简单模型机的控制单元CU(微操作信号产生电路),决定外部的端口(名称、有效电平)和内部各元件的连接,画出系统框图和逻辑图,设计仿真数据,用VHDL编程和仿真。
主要元件设计:
1.指令译码器
功能要求:
3-8译码器。
2.控制单元
功能要求:
假设该模型机有8条不同类型的指令。
包括:
算术运算、逻辑运算、移位、数据传送、访存操作、转移等。
根据每条指令的功能和时序,分析其执行过程中需要在各个阶段产生的全部微操作,导出产生这些微操作控制信号的逻辑。
3.用层次结构设计的方法设计一个控制单元CU(微操作控制信号产生电路)。
包括指令译码器和控制单元。
功能要求:
能够正确产生8条不同指令在执行过程中(每个机器周期、每拍)发出的全部微操作。
二、逻辑设计
写该实验的逻辑设计,包括:
顶层系统框图,下层各主要元件的系统框图。
顶层和下层各主要元件的端口(引脚)描述:
端口名称、功能、有效电平、位数等。
逻辑图,必须在图中清楚地标出每个内部连接线的Signal(与VHDL程序中的Signal一致)。
根据所用的描述方式,可能还需要有:
真值表/功能表/逻辑函数等。
1、3-8译码器:
系统框图:
S是工作信号,当S=1时,3-8译码器工作;当S=0时,3-8译码器不工作。
A是输入信号,Y是输出信号
SA2A1A0Y7Y6Y5Y4Y3Y2Y1Y0
100000000001加法
100100000010与
101000000100或
101100001000左移
110000010000右移
110100100000数据传送
111001000000取数
111110000000无条件转移
0×××00000000
Y(0)<=Sand(notA
(2))and(notA
(1))and(notA(0));
Y
(1)<=Sand(notA
(2))and(notA
(1))andA(0);
Y
(2)<=Sand(notA
(2))andA
(1)and(notA(0));
Y(3)<=Sand(notA
(2))andA
(1)andA(0);
Y(4)<=SandA
(2)and(notA
(1))and(notA(0));
Y(5)<=SandA
(2)and(notA
(1))andA(0);
Y(6)<=SandA
(2)andA
(1)and(notA(0));
Y(7)<=SandA
(2)andA
(1)andA(0);
2、控制单元:
设计过程:
把每条指令的实现分成取指令、分析指令、执行指令三个步骤,每一步由一个机器周期实现,一条指令的实现需要三个机器周期,即M1(取指周期)、M2(分析周期)、M3(执行周期);每个机器周期由三个节拍组成,即T0、T1、T2。
如下图所示:
1、加法指令:
寄存器R1中的一个数与寄存器R0中的一个数相加,结果放在R1中。
即实现(R0)+(R1)→R1
2、与指令:
寄存器R1中的一个数与寄存器R0中的一个数,结果放在R1中。
即实现(R1)and(R0)→R1
3、或指令:
寄存器R1中的一个数或寄存器R0中的一个数,结果放在R1中。
即实现(R1)or(R0)→R1
4、逻辑左移指令:
寄存器R1中的数左移,移动位数存放在寄存器R0中,结果放在R1中。
即实现(R1)
R1
5、逻辑右移指令:
寄存器R1中的数左移,移动位数存放在寄存器R0中,结果放在R1中。
即实现(R1)
R1
6、数据传送指令:
寄存器R0中的数据送到寄存器R1中。
即实现(R0)→R1。
7、取数指令:
取出存储器中的一个数(地址在寄存器R0中)送到寄存器R1中。
即实现
((R0))→(R1)
8、无条件转移指令:
寄存器R1中的地址送到PC中。
即实现(R1)→PC
8条指令的微操作如下表所示,以教材P122的CPU控制图(省去了M/
、ADS)为例:
由于每条指令取指周期的微操作是一样的,所以可以先设计取指周期微操作的节拍安排。
取指周期:
T0:
PC→AB,W/
=0
T1:
DB→IR
T2:
PC+1
T0
T1
T2
加法
M1
rs1→GR
(rs1)→ALU
rd→GR
(rd)→ALU
M2
+
ALU→GR
与
M1
rs1→GR
(rs1)→ALU
rd→GR
(rd)→ALU
M2
∧
ALU→GR
或
M1
rs1→GR
(rs1)→ALU
rd→GR
(rd)→ALU
M2
∨
ALU→GR
左移
M1
rs1→GR
(rs1)→ALU
rd→GR
(rd)→ALU
M2
←
ALU→GR
右移
M1
rs1→GR
(rs1)→ALU
rd→GR
(rd)→ALU
M2
→
ALU→GR
数据传送
M1
rs1→GR
(rs1)→ALU
M2
+
ALU→GR
取数
M1
rs1→GR
(rs1)→ALU
+
ALU→AR,AR→AB
W/
=0
DB→DR
M2
DR→ALU
+
ALU→GR
无条件转移
M1
rs1→GR
(rs1)→ALU
M2
+
ALU→PC
系统框图:
工作
周期
节拍
微操作命令
加法
与
或
左移
右移
数据
传送
取数
无条件转移
ADD
AND
OR
SAL
SAR
MOV
LDA
JMP
取指周期
T0
PC→AB
1
1
1
1
1
1
1
1
W/
=0
1
1
1
1
1
1
1
1
T1
DB→IR
1
1
1
1
1
1
1
1
T2
PC+1
1
1
1
1
1
1
1
1
分析周期
T0
rs1→GR
1
1
1
1
1
1
1
1
(rs1)→ALU
1
1
1
1
1
1
1
1
+
1
T1
ALU→AR
1
AR→AB
1
W/
=0
1
T2
rd→GR
1
1
1
1
1
(rd)→ALU
1
1
1
1
1
DB→DR
1
执行周期
T0
DR→ALU
1
T1
+
1
1
1
1
∧
1
∨
1
←
1
→
1
T2
ALU→GR
1
1
1
1
1
1
1
ALU→PC
1
所有指令:
PC→AB=M0·T0
W/
=0=M0·T0+M1·T1·取数
DB→IR=M0·T1
PC+1=M0·T2
rs1→GR=M1·T0
(rs1)→ALU=M1·T0
+=M1·T0·取数+M2·T1·(加+传送+取数+转移)
ALU→AR=M1·T1·取数
AR→AB=M1·T1·取数
rd→GR=M1·T2·(加法+与+或+左移+右移)
(rd)→ALU=M1·T2·(加法+与+或+左移+右移)
DB→DR=M1·T2·取数
DR→ALU=M2·T0·取数
∧=M2·T1·与
∨=M2·T1·或
←=M2·T1·左移
→=M2·T1·右移
ALU→GR=M2·T2·(加法+与+或+左移+右移+数据传送+取数)
ALU→PC=M2·T2·转移
3、层次结构控制单元:
逻辑图:
三、VHDL程序
--3-8译码器
libraryieee;
useieee.std_logic_1164.all;
entitydecoder38is
port(S:
instd_logic;
A:
instd_logic_vector(2downto0);
Y:
outstd_logic_vector(7downto0));
enddecoder38;
architecturebehaveofdecoder38is
begin
process(S)
begin
ifS='1'then
Y(0)<=(notA
(2))and(notA
(1))and(notA(0));
Y
(1)<=(notA
(2))and(notA
(1))andA(0);
Y
(2)<=(notA
(2))andA
(1)and(notA(0));
Y(3)<=(notA
(2))andA
(1)andA(0);
Y(4)<=A
(2)and(notA
(1))and(notA(0));
Y(5)<=A
(2)and(notA
(1))andA(0);
Y(6)<=A
(2)andA
(1)and(notA(0));
Y(7)<=A
(2)andA
(1)andA(0);
elseY<="00000000";
endif;
endprocess;
endbehave;
--控制单元
--3-8译码器
libraryieee;
useieee.std_logic_1164.all;
entityCUis
port(m:
instd_logic_vector(2downto0);
t:
instd_logic_vector(2downto0);
d:
instd_logic_vector(7downto0);
q:
outstd_logic_vector(18downto0));
endCU;
architecturebehaveofCUis
signaliq:
std_logic_vector(7downto0);
begin
iq(0)<=notd(7)andnotd(6)andnotd(5)andnotd(4)andnotd(3)andnotd
(2)andnotd
(1)andd(0);
iq
(1)<=notd(7)andnotd(6)andnotd(5)andnotd(4)andnotd(3)andnotd
(2)andd
(1)andnotd(0);
iq
(2)<=notd(7)andnotd(6)andnotd(5)andnotd(4)andnotd(3)andd
(2)andnotd
(1)andnotd(0);
iq(3)<=notd(7)andnotd(6)andnotd(5)andnotd(4)andd(3)andnotd
(2)andnotd
(1)andnotd(0);
iq(4)<=notd(7)andnotd(6)andnotd(5)andd(4)andnotd(3)andnotd
(2)andnotd
(1)andnotd(0);
iq(5)<=notd(7)andnotd(6)andd(5)andnotd(4)andnotd(3)andnotd
(2)andnotd
(1)andnotd(0);
iq(6)<=notd(7)andd(6)andnotd(5)andnotd(4)andnotd(3)andnotd
(2)andnotd
(1)andnotd(0);
iq(7)<=d(7)andnotd(6)andnotd(5)andnotd(4)andnotd(3)andnotd
(2)andnotd
(1)andnotd(0);
q(0)<=notm
(2)andnotm
(1)andm(0)andnott
(2)andnott
(1)andt(0);
q
(1)<=(notm
(2)andnotm
(1)andm(0)andnott
(2)andnott
(1)andt(0))
or(notm
(2)andm
(1)andnotm(0)andnott
(2)andt
(1)andnott(0)andiq(6));
q
(2)<=notm
(2)andnotm
(1)andm(0)andnott
(2)andt
(1)andnott(0);
q(3)<=notm
(2)andnotm
(1)andm(0)andt
(2)andnott
(1)andnott(0);
q(4)<=notm
(2)andm
(1)andnotm(0)andnott
(2)andnott
(1)andt(0);
q(5)<=notm
(2)andm
(1)andnotm(0)andnott
(2)andnott
(1)andt(0);
q(6)<=(notm
(2)andm
(1)andnotm(0)andnott
(2)andnott
(1)andt(0)andiq(6))or
(m
(2)andnotm
(1)andnotm(0)andnott
(2)andt
(1)andnott(0)and(iq(0)oriq(5)oriq(6)oriq(7)));
q(7)<=notm
(2)andm
(1)andnotm(0)andnott
(2)andt
(1)andnott(0)andiq(6);
q(8)<=notm
(2)andm
(1)andnotm(0)andnott
(2)andt
(1)andnott(0)andiq(6);
q(9)<=notm
(2)andm
(1)andnotm(0)andt
(2)andnott
(1)andnott(0)and
(iq(0)oriq
(1)oriq
(2)oriq(3)oriq(4));
q(10)<=notm
(2)andm
(1)andnotm(0)andt
(2)andnott
(1)andnott(0)and
(iq(0)oriq
(1)oriq
(2)oriq(3)oriq(4));
q(11)<=notm
(2)andm
(1)andnotm(0)andt
(2)andnott
(1)andnott(0)andiq(6);
q(12)<=m
(2)andnotm
(1)andnotm(0)andnott
(2)andnott
(1)andt(0)andiq(6);
q(13)<=m
(2)andnotm
(1)andnotm(0)andnott
(2)andt
(1)andnott(0)andiq
(1);
q(14)<=m
(2)andnotm
(1)andnotm(0)andnott
(2)andt
(1)andnott(0)andiq
(2);
q(15)<=m
(2)andnotm
(1)andnotm(0)andnott
(2)andt
(1)andnott(0)andiq(3);
q(16)<=m
(2)andnotm
(1)andnotm(0)andnott
(2)andt
(1)andnott(0)andiq(4);
q(17)<=m
(2)andnotm
(1)andnotm(0)andt
(2)andnott
(1)andnott(0)
and(iq(0)oriq
(1)oriq
(2)oriq(3)oriq(4)oriq(5)oriq(6));
q(18)<=m
(2)andnotm
(1)andnotm(0)andt
(2)andnott
(1)andnott(0)andiq(7);
endbehave;
--层次结构控制单元
libraryieee;
useieee.std_logic_1164.all;
entityHCUis
port(S:
instd_logic;
A:
instd_logic_vector(2downto0);
M:
instd_logic_vector(2downto0);
T:
instd_logic_vector(2downto0);
Q:
outstd_logic_vector(18downto0));
endHCU;
architecturestructofHCUis
signali:
std_logic_vector(7downto0);
ponentdecoder38
port(S:
instd_logic;
A:
instd_logic_vector(2downto0);
Y:
outstd_logic_vector(7downto0));
endponent;
ponentCU
port(m:
instd_logic_vector(2downto0);
t:
instd_logic_vector(2downto0);
d:
instd_logic_vector(7downto0);
q:
outstd_logic_vector(18downto0));
endponent;
begin
G1:
decoder38portmap
(S=>S,A=>A,Y=>i);
G2:
CUportmap
(d=>i,t=>T,m=>M,q=>Q);
endstruct;
四、仿真设计
3-8译码器仿真设计:
设计数据,输出3-8译码器的译码后的8种编码。
S
1
1
1
1
1
1
1
1
0
A
000
001
010
011
100
101
110
111
101
Y
00000001
00000010
00000100
00001000
00010000
00100000
01000000
10000000
00000000
控制成员仿真设计:
设计仿真数据使每一个微操作都可以有效输出:
m
001
001
001
010
100
t
001
010
100
001
010
d
00010000
00100000
10000000
01000000
00000001
q
0000000000000000011
0000000000000000100
0000000000000001000
0000000000001110000
0000000000001000000
m
010
010
010
100
100
t
010
100
100
001
010
d
01000000
00001000
01000000
01000000
00000010
q
0000000000110000010
0000000011000000000
0000000100000000000
0000001000000000000
0000010000000000000
m
100
100
100
100
100
t
010
010
010
100
100
d
00000100
00001000
00010000
00000010
10000000
q
0000100000000000000
0001000000000000000
0010000000000000000
010*********
1000000000000000000
层次控制单元仿真设计:
设计数据依次输出8条指令的微操作:
例如:
若要输出加法指令需要的所有微操作,则需设置数据如下:
S
1
1
1
1
A
000
000
000
000
M
001
001
001
010
T
001
010
100
001
Q
0000000000000000011
0000000000000000100
0000000000000001000
0000000000000110000
S
1
1
1
A
000
000
000
M
010
100
100
T
100
010
100
Q
0000000011000000000
0000000000001000000
010*********
由于每条指令都有取指令这个微指令,因此在下面的测试数据中将不再测试取指令的微操作。
与:
S
1
1
1
1
A
001
001
001
001
M
010
010
100
100
T
001
100
010
100
Q
0000000000000110000
0000000011000000000
0000010000000000000
010*********
或:
S
1
1
1
1
A
010
010
010
010
M
010
010
100
100
T
001
100
010
100
Q
0000000000000110000
0000000011000000000
0000100000000000000
010*********
左移:
S
1
1
1
1
A
011
011
011
011
M
010
010
100
100
T
001
100
010
100
Q
0000
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 推荐组合逻辑控制单元设计 精品 推荐 组合 逻辑 控制 单元 设计
![提示](https://static.bdocx.com/images/bang_tan.gif)