可编程逻辑实验
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
一:实验目的
1、通过一个简单的反相器的实现,初步了解CPLD开发的全过程;
2、学会利用软件仿真和硬件实现对数字电路的逻辑功能进行验证和分析;
3、能够通过CPLD开发实现具有反相器功能的数字电路。
二:实验内容
用图形编辑器实现反相器的CPLD开发
三:实验记录
CPLD开发的过程
1、在磁盘中新建一个实验所需文件夹,用英文字母命名;
2、启动MAX+plusΠ软件;
3、在所建文件夹目录下创建一个新的工程,并确定新工程的名称;
4、使用原理图编辑器,Graphic Editor file, .gdf格式;
5、编辑原理图;
6、保存、编译原理图;
7、启动波形图编译器,Waveform Editor file, .scf格式;
8、设置、编辑波形图;
9、保存、仿真原理图;
10、指定、设置CPLD芯片;
11、下载实现;
12、模型生成。
四:实验心得
此次试验是第一次上机利用MAXPLUS进行操作,通过实验,我了解了该软件的简单操作,初步掌握了CPLD开发的全过程。
学会了利用软件仿真及硬件实现对数字电路逻辑功能的分析和验证。
在进行实验操作时,应当注意管脚分配时,CPLD实验板上的开关和发光二极管等输入/输出变量同CPLD芯片管脚的对应关系,保证其一一对应。
一:实验目的
1、通过各种常见门电路的实现,进一步熟悉CPLD开发的全过程;
2、认识各种常见的门电路,并掌握它们的逻辑功能;
3、能够通过CPLD的开发实现具有门电路的数字电路。
二:实验内容
1、常见逻辑门的认识
基本逻辑门电路:与门,或门,非门。
复合逻辑门电路:与非门,或非门,异或门,同或门。
2、完成以上逻辑门的VHDL描述。
三:实验记录
1、与门
(1)逻辑表达式:F1=a&b
(2)真值表
输入输出
a b F1
0 0 0
0 1 0
1 0 0
1 1 1 (3)源程序
Library ieee;
Use ieee.std_logic_1164.all;
Entity yumen is
Port(a,b:in std_logic;
y:out std_logic);
End;
Architecture rel_1 of yumen is
Begin
Y <=a and b;
End;
2、或门
(1)逻辑表达式:F2=a+b
(2)真值表
输入输出
a b F2
0 0 0
0 1 1
1 0 1
1 1 1 (3)源程序
Library ieee;
Use ieee.std_logic_1164.all;
Entity huomen is
Port(a,b:in std_logic;
y:out std_logic);
Architecture rel_1 of huomen is
Begin
Y<=a or b;
End;
3、与非门
(1)逻辑表达式:F3=/(a&b)
(2)真值表
输入输出
a b F3
0 0 1
0 1 1
1 0 1
1 1 0 (3)源程序
Library ieee;
Use ieee.std_logic_1164.all;
Entity yufeimen is
Port(a,b:in std_logic;
y:out std_logic);
End;
Architecture rel_1 of yufeimen is
Begin
Y <=a nand b;
End;
4、或非门
(1)逻辑表达式:F4=/(a+b)
(2)真值表
输入输出
a b F4
0 0 1
0 1 0
1 0 0
1 1 0 (3)源程序
Library ieee;
Use ieee.std_logic_1164.all;
Entity huofeimen is
Port(a,b:in std_logic;
y:out std_logic);
end;
Architecture rel_1 of huofeimen is
Begin
Y<=a nor b;
End;
5、异或门
(1)逻辑表达式:F5=a⊕b
(2)真值表
输入输出
a b F5
0 0 0
0 1 1
1 0 1
1 1 0 (3)源程序
Library ieee;
Use ieee.std_logic_1164.all;
Entity yihuomen is
Port(a,b:in std_logic;
y:out std_logic);
end;
Architecture rel_1 of yihuomen is
Begin
Y<=a xor b;
end;
6、同或门
(1)逻辑表达式:F6=a⊙b=/F5
(2)真值表
输入输出 a b F6
0 0 1
0 1 0
1 0 0
1 1 1
(3)源程序
Library ieee;
Use ieee.std_logic_1164.all;
Entity tonghuomen is
Port(a,b:in std_logic;
y:out std_logic);
end;
Architecture rel_1 of tonghuomen is
Begin
Y<=a xnor b;
end;
四:实验心得
实验二的主要内容是用文本输入法设计门电路。
这次实验运用VHDL语言编写源程序,从而实现数字电路。
这是第一次接触硬件描述语言,在实验时,只要掌握了VHDL语言的基本结构,就能够编较容易编写出各数字电路的源程序。
但是,需要注意的是,实体所定义的结构名必须与文件名一致,否则无法进行实验编程。
实验名称实验三组合电路设计(一)
一:实验目的
1、掌握设计组合逻辑电路的方法;
2、通过开发CPLD来实现组合逻辑电路的功能。
二:实验内容
1、多数表决电路设计
2、代码转换电路设计
三:实验记录
1、多数表决电路设计
(一)逻辑表达式:F=ABC+ABD+ACD+BCD
(二)真值表
输入输出输入输出
A B C D F A B C D F
0 0 0 0 0 1 0 0 0 0
0 0 0 1 0 1 0 0 1 0
0 0 1 0 0 1 0 1 0 0
0 0 1 1 0 1 0 1 1 1
0 1 0 0 0 1 1 0 0 0
0 1 0 1 0 1 1 0 1 1
0 1 1 0 0 1 1 1 0 1
0 1 1 1 1 1 1 1 1 1
(三)源程序
Library ieee;
Use ieee.std_logic_1164.all;
Entity shiyan3 is
Port(a:in std_logic_vector(3 downto 0);
y:out std_logic);
End;
Architecture bhv of shiyan3 is
Begin
Process(a)
begin
Case a is
When"0000"=>y<='0'; When"0001"=>y<='0'; When"0010"=>y<='0'; When"0011"=>y<='0'; When"0100"=>y<='0'; When"0101"=>y<='0'; When"0110"=>y<='0'; When"0111"=>y<='1'; When"1000"=>y<='0'; When"1001"=>y<='0'; When"1010"=>y<='0'; When"1011"=>y<='1'; When"1100"=>y<='0'; When"1101"=>y<='1'; When"1110"=>y<='1'; When"1111"=>y<='1'; When others=>y<='0'; End case; End process; End;
(四)波形图
2、代码转换电路设计 (一)逻辑表达式:
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
___
123312021031023012300
123012321031320012311
320312021031023012320
12301230123012301233X X X X X X X X X X X X X X X X X X X X Y X X X X X X X X X X X X X X X X X X X X Y X X X X X X X X X X X X X X X X X X X X Y X X X X X X X X X X X X X X X X X X X X Y ++++=++++=++++=++++=
(二)真值表
数字
输入输出数
字
输入输出
8421BCD码余3码 8421BCD码余3码
X3 X2 X1 X0 Y3 Y2 Y1 Y0 X3 X2 X1 X0 Y3 Y2 Y1 Y0
0 0 0 0 0 0 0 1 1 5 0 1 0 1 1 0 0 0
1 0 0 0 1 0 1 0 0 6 0 1 1 0 1 0 0 1
2 0 0 1 0 0 1 0 1 7 0 1 1 1 1 0 1 0
3 0 1 0 0 0 1 1 1 8 1 0 0 0 1 0 1 1
4 0 1 0 0 0 1 1 1 9 1 0 0 1 1 1 0 0
(三)源程序
library ieee;
use ieee.std_logic_1164.all;
entity zhuanhuan is
port(a:in std_logic_vector(3 downto 0);
y:out std_logic_vector(3 downto 0));
end;
architecture rtl of zhuanhuan is
begin
process(a)
variable comb:std_logic_vector(3 downto 0);
begin
case a is
when"0000"=>y<="0011";
when"0001"=>y<="0100";
when"0010"=>y<="0101";
when"0011"=>y<="0110";
when"0100"=>y<="0111";
when"0101"=>y<="1000";
when"0110"=>y<="1001";
when"0111"=>y<="1010";
when"1000"=>y<="1011";
when"1001"=>y<="1100";
when others=>y<="ZZZZ";
end case;
end process;
end;
(四
四:实验心得
这次实验内容为编写多数表决器及代码转换器的VHDL程序,并用MAX-plus 软件进行仿真。
多数表决器及代码转换器的相关内容在数字逻辑设计课程当中已经学过,在实验中,用卡诺图的方法写出逻辑表达式。
通过实验,我学会了用VHDL语言编写其程序,需要注意的是,在程序编写过程中,要清晰各个运算符,否则会出错。
这次实验用到了时序仿真的知识,只要认真操作,就可以实现仿真。
实验名称 实验四 组合电路设计(二)
一:实验目的
1、掌握设计组合逻辑电路的方法;
2、通过开发CPLD 来实现组合逻辑电路的功能。
二:实验内容
一位二进制全减器电路设计。
三:实验记录
一位二进制全减器电路设计 (一)逻辑表达式:
i i __
__
__
i __
__i
__
i ____
__
i __
__A Co A ABC BC A C B C B A ABC
C B A C B C B A F i i +++=+++=
(二)真值表
输入
输出 A B Ci F Co 0 0 0 0 0 0 0 1 1 1 0 1 0 1 1 0 1 1 0 1 1 0 0 1 0 1 0 1 0 0 1 1 0 0 0 1 1 1 1
1
(三)源程序 Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all; entity quanjianqi is
port(A,B,Ci:in std_logic; F,Co:out std_logic); end;
architecture hbv of quanjianqi is begin
process(A,B,Ci) Begin
If(A='0'and B='0'and Ci='0')then
F<='0';
Co<='0';
elsif(A='0'and B='0'and Ci='1')then F<='1';
Co<='1';
elsif(A='0'and B='1'and Ci='0')then F<='1';
Co<='1';
elsif(A='0'and B='1'and Ci='1')then F<='0';
Co<='1';
elsif(A='1'and B='0'and Ci='0')then F<='1';
Co<='0';
elsif(A='1'and B='0'and Ci='1')then F<='0';
Co<='0';
elsif(A='1'and B='1'and Ci='0')then F<='0';
Co<='0';
else
F<='1';
Co<='1';
end if;
end process;
end;
(四)波形图
四:实验心得
做实验的过程中,应先分析在不同输入的情况下,输出结果都有哪些,写出真值表和逻辑表达式。
用MAX+PLUS II软件进行仿真时,熟练掌握VHDL语言,再在分析的基础上进行编写,编写过程应细心。
通过这次试验,无论是自己的编写代码的能力还是差错能力都有所提高,特别是进行结果仿真的能力。
实验名称实验六触发器设计
一:实验目的
1、认识JK触发器、D触发器;
2、掌握JK触发器、D触发器的逻辑功能和动作特点;
3、能够通过CPLD开发实现具有触发器功能的数字电路。
二:实验内容
1、JK触发器设计;
2、D触发器设计。
三:实验记录
1、JK触发器
(一)JK触发器功能表
/PRN /CLRN CP J K Q
0 1 X X X 1
1 0 X X X 0
0 0 X X X 1
1 1 ↑0 0 保持
1 1 ↑ 1 0 1
1 1 ↑0 1 0
1 1 ↑ 1 1 翻转
(二)源程序
Library ieee;
Use ieee.std_logic_1164.all;
Entity jk_ff is
Port (j,k,clk,PRN,CLRN: in std_logic;
q,qb: out std_logic);
End;
Architecture jk1 of jk_ff is
signal q_temp,qb_temp:std_logic;
Begin
Process(clk,PRN,CLRN)
Begin
if PRN = '0' then
q_temp<='1';
qb_temp<='0';
elsif CLRN ='0' then
q_temp<='0';
qb_temp<='1';
elsif(clk'event and clk='1')then
if(j='0'and k='0') then
q_temp<=q_temp;
qb_temp<=qb_temp;
elsif(j='1'and k='0') then
q_temp<='1';
qb_temp<='0';
elsif(j='0'and k='1') then
q_temp<='0';
qb_temp<='1';
elsif(j='1'and k='1') then
q_temp<=not q_temp;
qb_temp<=not qb_temp;
end if;
end if;
end process;
q<=q_temp;
qb<=qb_temp;
End;
(三)波形图
2、D触发器
(一)D触发器功能表
/PRN /CLRN CLK D Q
0 1 X X 1
1 0 X X 0
0 0 X X 1
1 1 ↑ 1 1
1 1 ↑0 0
1 1 0 X 保持
(二)源程序
Library ieee;
Use ieee.std_logic_1164.all;
Entity d_ff is
Port (d,clk,Rd,Sd: in std_logic;
q,qb: out std_logic);
End;
Architecture d1 of d_ff is
signal q_temp,qb_temp:std_logic;
Begin
Process(clk)
Begin
if Rd ='0'then
q_temp<='0';
qb_temp<='1';
elsif Sd ='0' then
q_temp <='1';
qb_temp<='0';
elsif (clk'event and clk='1')then
q_temp<=d;
qb_temp<=not q_temp;
end if ;
end process;
q<=q_temp;
qb<=qb_temp;
End;
(三)波形图
四:实验心得
这次实验内容为JK触发器及D触发器的设计。
所设计的均为异步置位、异步复位。
所以在编写VHDL语言时,需要弄明白触发器的工作原理,才能正确编写出语言,从而进行时序仿真。
在仿真过程中,起初,我将复位及置位端频繁变换,在明白其工作状态时,改正过来,实现仿真。
通过实验,我对JK触发器和D触发器有了进一步的理解。
对以后的学习有了帮助。
实验名称实验七移位寄存器及计数器的下载
一:实验目的
1、掌握移位寄存器电路设计的方法;
2、能够通过CPLD开发实现时序逻辑电路的功能。
二:实验内容
1、设计一个同步带清零、带有进位输出端的模16计数器,且能够自启动及具有进位输出端,通过硬件下载实现,结果用发光二极管显示;
2、设计一个节日彩灯电路,要求当输入连续脉冲时,4个彩灯(发光二极管)既可以从右向左逐位亮继而逐位灭,又可以从左向右逐位亮继而逐位灭。
三:实验记录
1、模16计数器
(一)源程序
Library ieee;
Use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
Entity mo16 is
Port(SD,RD,clk,ep,et:in std_logic;
d:in std_logic_vector(3 downto 0);
q:out std_logic_vector(3 downto 0);
co:out std_logic);
End;
Architecture rt16 of mo16 is
Signal dl,y:std_logic_vector(3 downto 0);
Begin
Process(clk,ep,et,SD,RD)
Begin
dl <= d;
if RD='0'then
y<="0000";
co<='0';
elsif(clk'event and clk='1')then
if SD='0'then
y<=d;
elsif(ep='0' and et='1')then
y<=y;
elsif(et='0')then
y<=y;
co<='0';
elsif(ep='1' and et='1')then
if(y=15)then
y<="0000";
co<='1';
else
y<=y+1;
co<='0';
end if;
end if;
end if;
end process;
q<=y;
End;
(二)管脚连接图
2、节日彩灯电路
(一)源程序
library IEEE;
use IEEE.std_logic_1164.all;
entity caideng is
port (
clk : in std_logic;
shift : in std_logic;
q : out std_logic_vector(3 downto 0)); end entity;
architecture shft_reg_arch of caideng is signal temp : std_logic_vector(3 downto 0);
begin
q<=temp;
process(clk)
begin
if (clk'event and clk='1') then
if shift='1' then
case temp is
when "0000"=>temp<="1000";
when "1000"=>temp<="1100";
when "1100"=>temp<="1110";
when "1110"=>temp<="1111"; when "1111"=>temp<="0111"; when "0111"=>temp<="0011"; when "0011"=>temp<="0001"; when "0001"=>temp<="0000"; when others=>temp<="0000";
end case;
else
case temp is
when "0000"=>temp<="0001";
when "0001"=>temp<="0011";
when "0011"=>temp<="0111"; when "0111"=>temp<="1111"; when "1111"=>temp<="1110"; when "1110"=>temp<="1100"; when "1100"=>temp<="1000"; when "1000"=>temp<="0000";
when others=>temp<="0000";
end case;
end if;
end if;
end process ;
end architecture;
(二)管脚连接图
四:实验心得
这次实验内容为模16计数器及节日彩灯电路下载实现。
上次实验已经编写好模16计数器的VHDL语言,在做实验时,要明白设计编译的过程。
需要注意的是,在编译时,必须将字节调整好,否则无法编译成功。
对于节日彩灯的实现,只要将VHDL语言编写正确,按照设计编译步骤进行,就能够完成实验。
实验名称实验八计数器设计
一:实验目的
1、掌握计数器电路设计的方法;
2、能够通过CPLD开发实现时序逻辑电路的功能。
二:实验内容
设计一个同步带清零、带有进位输出端的模16计数器,且能够自启动及具有进位输出端。
三:实验记录
模16计数器
(一)源程序
Library ieee;
Use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
Entity mo16 is
Port(SD,RD,clk,ep,et:in std_logic;
d:in std_logic_vector(3 downto 0);
q:out std_logic_vector(3 downto 0);
co:out std_logic);
End;
Architecture rt16 of mo16 is
Signal dl,y:std_logic_vector(3 downto 0);
Begin
Process(clk,ep,et,SD,RD)
Begin
dl <= d;
if RD='0'then
y<="0000";
co<='0';
elsif(clk'event and clk='1')then
if SD='0'then
y<=d;
elsif(ep='0' and et='1')then
y<=y;
elsif(et='0')then
y<=y;
co<='0';
elsif(ep='1' and et='1')then
if(y=15)then
y<="0000";
co<='1';
else
y<=y+1;
co<='0';
end if;
end if;
end if;
end process;
q<=y;
End;
(二)波形图
四:实验心得
这次实验内容为模16计数器的设计。
通过实验,我对同步计数器有了进一步的理解。
对以后的学习有了帮助。