一、实验目的
1 学习并掌握用VHDL语言、语法规则 2 掌握VHDL语言进行二进制计数器的设计 3 掌握译码显示电路的设计 4 掌握顶层文件的设计
5 掌握综合性电路的设计、仿真、下载、调试方法。 二 实验仪器设备 1 PC机一台
2 EDA教学实验系统,1套 3 CPLD实验装置,1套 三 实验内容 实验内容:
(1) 设计7段译码显示电路程序;(参考实验一) (2) 设计四位二进制计数器,进行计数; (3) 进行顶层电路设计;
(4) 对计数值,用7段显示器进行显示; (5) 进行电路功能仿真与下载。 四. 实验操作步骤
1 开机,进入MAX+PLUSⅡ CPLD开发系统。
2 在主菜单中选NEW,从输入文件类型选择菜单中选文本编辑文件输入方式,进行文本编辑。对7段译码显示电路、四位二进制计数器、顶层电路分别进行编辑、保存与仿真。
3 打开Assign主菜单,选择计划使用的CPLD芯片。 4 点击编译按钮,对顶层电路进行编译。
5 点击Floorplan Editor子菜单,为设计的电路分配芯片引脚。 6进行芯片下载与硬件测试。
建议输入信号引脚为:
时钟信号:73脚或31脚(8K板) 42脚或44脚(10K板)
使能信号、复位信号选,第一组DIP开关或第二组DIP开关或第三组DIP开关,相应引脚参考讲义;
LED七段(a,b,c,d,e,f,g)输出分配也必须与实验装置的相关端匹配,具体引脚
参考实验讲义。(见表功,如可选引脚13、14、15、16、18、19、20(8K板)或16、17、18、19、21、22、23(10K板))。设计参考框图如下:
五. 实验程序
1、四位二进制计数器译码程序
library IEEE;
use IEEE.std_logic_1164.all;
entity sysegd is
port (x: in std_logic_vector(3 downto 0); s : out std_logic_vector (6 downto 0) );
end entity;
architecture bin27seg_arch of sysegd is begin process(x) begin
case x(3 downto 0) is
when \"0000\" => s <= \"1111110\"; -- 0 when \"0001\" => s <= \"0110000\"; -- 1 when \"0010\" => s <= \"1101101\"; -- 2 when \"0011\" => s <= \"1111001\"; -- 3 when \"0100\" => s <= \"0110011\"; -- 4 when \"0101\" => s <= \"1011011\"; -- 5
when \"0110\" => s <= \"1011111\"; -- 6 when \"0111\" => s <= \"1110000\"; -- 7 when \"1000\" => s <= \"1111111\"; -- 8 when \"1001\" => s <= \"1111011\"; -- 9 when \"1010\" => s <= \"1110111\"; -- A when \"1011\" => s <= \"0011111\"; -- b when \"1100\" => s <= \"1001110\"; -- c when \"1101\" => s <= \"0111101\"; -- d when \"1110\" => s <= \"1001111\"; -- E when \"1111\" => s <= \"1000111\"; -- F when others => NULL; end case; end process; end architecture;
2、四位二进制计数器计数程序
library IEEE;
use IEEE.std_logic_1164.all; use ieee.std_logic_unsigned.all;
entity segd7 is
port (clk,en : in std_logic;
x : buffer std_logic_vector (3 downto 0)); end entity;
architecture one of segd7 is begin
process(clk) begin
IF (CLK'EVENT AND clk='1') then if en='1' then
IF (x=\"1111\") THEN
x<=\"0000\"; ELSE
x <= x+'1'; END IF; end if; end if; end process; end architecture;
3、四位二进制计数器顶层文件 library ieee;
use ieee.std_logic_1164.all;
entity segdtop is
port(clk,en :in std_logic;
architecture behave of segdtop is
signal temp1:std_logic_vector(3 downto 0);
component segd7
port(clk,en : in std_logic;
x : buffer std_logic_vector (3 downto 0)); end component;
component sysegd
port (x: in std_logic_vector(3 downto 0); s : out std_logic_vector (6 downto 0) );
end component;
s : out std_logic_vector (6 downto 0)); end segdtop;
begin
u0:segd7 port map(clk,en,temp1); u1:sysegd port map(temp1,s); end behave; 六. 实验结果
图1、四位二进制计数器译码程序
图2、四位二进制计数器计数程序
图3、四位二进制计数器顶层文件
因篇幅问题不能全部显示,请点此查看更多更全内容