您的当前位置:首页正文

七段译码显示电路的设计

2023-01-25 来源:欧得旅游网
浙江万里学院实验报告

课程名称:可编程逻辑器件应用 实验名称:七段译码显示电路的设计

成绩: 教师: 施 炯 专业班级:通信093姓名:申屠思凡学号:2009017402实验日期:2011.4.12

一、实验目的:

1、掌握并行连接的七段数码管译码器工作原理,频率分频原理,掌握计数器的原理及设计方法; 2、设计一个60进制计数器;

3、利用实验二的七段数码管电路进行显示; 4、学会运用波形仿真测试检验程序的正确性; 二、实验要求:

1、用VHDL 语言进行描写; 2、进行波形仿真测试; 3、严格按照实验流程进行;

4、管脚映射按芯片要求进行,在数码管上显示译码后的数字; 5、查看资料,描述七段译码器的工作原理; 三、实验结果:

1. 分频器VHDL程序

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity fp5 is

port(clk50M:in std_logic; clk1:out std_logic); end fp5;

architecture rt of fp5 is

signal t:INTEGER RANGE 0 TO 6; signal clk:std_logic; begin

process(clk50M) begin

1

if rising_edge(clk50M) then

if t=5 then t<=0;

clk<=not clk; else t<=t+1;

end if; end if; end process; clk1<=clk;

end rt;

2. 计数器VHDL程序

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity cnt60 is

port (

clk:in std_logic;

outlow:buffer std_logic_vector(3 downto 0); outhigh:buffer std_logic_vector(3 downto 0) );

end cnt60;

architecture behav of cnt60 is begin process (clk)

begin

if clk'event and clk='1'then

if outhigh=\"0101\"and outlow=\"1001\"then outhigh<=\"0000\"; outlow<=\"0000\"; elsif outlow=\"1001\"then outhigh<=outhigh+1;

2

outlow<=\"0000\"; else outlow<=outlow+1; end if; end if; end process; end behav;

3. 七段译码器VHDL程序 library ieee;

use ieee.std_logic_1164.all; entity shuma is

port(din:in std_logic_vector(3 downto 0); seg:out std_logic_vector(6 downto 0)); end shuma;

architecture deng of shuma is begin

process(din) begin case din is

when\"0000\"=>seg<=\"0111111\";--\"0\" when\"0001\"=>seg<=\"0000110\";--\"1\" when\"0010\"=>seg<=\"1011011\";--\"2\" when\"0011\"=>seg<=\"1001111\";--\"3\" when\"0100\"=>seg<=\"1100110\";--\"4\" when\"0101\"=>seg<=\"1101101\";--\"5\"

3

when\"0110\"=>seg<=\"1111101\";--\"6\" when\"0111\"=>seg<=\"0100111\";--\"7\" when\"1000\"=>seg<=\"1111111\";--\"8\" when\"1001\"=>seg<=\"1101111\";--\"9\" when others=>seg<=\"1111001\";--\"E\" end case; end process; end deng;

4. 程序包

LIBRARY IEEE;

USE IEEE.STD_LOGIC_1164.ALL; PACKAGE my_pkg IS Component shama

PORT (din:in std_logic_vector(3 downto 0 );

seg:out std_logic_vector(6 downto 0) );

4

END Component; Component CNT60 PORT ( clk:IN STD_LOGIC;

outlow:BUFFER STD_LOGIC_VECTOR(3 DOWNTO 0); outhigh:BUFFER STD_LOGIC_VECTOR(3 DOWNTO 0)

);

END Component; Component fp5 PORT ( clk50M : IN STD_LOGIC; clk1 : OUT STD_LOGIC );

END Component;

END my_pkg;

5.顶层实体

LIBRARY IEEE;

USE IEEE.STD_LOGIC_1164.ALL; USE work.my_pkg.ALL;

5

ENTITY lsh IS

PORT (CLKIN: IN STD_LOGIC;

LEDLOW,LEDHIGH: OUT STD_LOGIC_VECTOR(6 downto 0));

END lsh;

ARCHITECTURE behv OF lsh IS SIGNAL CLKTEMP: STD_LOGIC;

SIGNAL LEDLOWTEMP,LEDHIGHTEMP:STD_LOGIC_VECTOR(3 downto 0); BEGIN

u1:fp5 PORT MAP(CLKIN,CLKTEMP); u2:CNT60 PORT

MAP(clk=>CLKTEMP,outlow=>LEDLOWTEMP,outhigh=>LEDHIGHTEMP);

u3:shuma PORT MAP(LEDLOWTEMP,LEDLOW);

u4:shuma PORT MAP(LEDHIGHTEMP,LEDHIGH);

END behv;

6. 仿真结果以及说明

元件例化仿真结果

6

7. 程序下载及运行情况说明

四、实验总结:

通过本次实验,我了解到VHDL语言真的没那么简单,很多地方都弄不懂,要靠同学才能完整的写出程序,不过这样还是让我学到很多,也进一步学会了使用VHDL语言。

7

因篇幅问题不能全部显示,请点此查看更多更全内容