音乐发生器

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

《电子设计自动化技术A》

乐曲发生电路的设计

学院:微电子与固体电子学院

专业:集成电路与集成系统设计

姓名:崔云凯2012032030018

唐雄 2012032030024

一、设计要求

二、设计原理

三、使用器件

四、功能模块

五、顶层设计

六、FPGA仿真

七、总结

一、用FPGA实现8位计数器功能

在电子技术实验中,我们刚刚做了两位数码管显示计数器的实验,所以思路已经很清楚了。大的发方面主要是数码管扫描显示和计数器两个功能的实现,从细的方面讲有:时钟分频模块、计数模块和数码管扫描与显示模块。

8位计数器扫描电路原理:数码管显示由7段译码实现;扫描由位选同步显示实现。

1、时钟分频模块

计数时钟频率4HZ,扫描频率为50Hz,代码如下:

library IEEE;

use IEEE.STD_LOGIC_1164.all;

USE IEEE.STD_LOGIC_UNSIGNED.ALL;

entity div is

port(clk2,clr:in std_logic;

div400Hz: out std_logic;

div400Hz_16:out std_logic);

end div;

--}} End of automatically maintained section

architecture sing of div is

signal cnt24:std_logic_vector(23 downto 0);

begin

process(clk2,clr)

begin

if(clr='1')then

cnt24<="000000000000000000000000";

elsif(clk2'event and clk2='1')then

if( cnt24="100000010011001100000000")then --4Hz

cnt24<= "000000000000000000000000" ;

else

cnt24<=cnt24+1;

end if;

end if;

end process;

div400Hz<=cnt24(23); --4Hz

div400Hz_16<=cnt24(15); --400Hz

end sing;

3、计数模块

该模块很简单,用四位二进制实现0~9的计数功能和进位功能,代码如下:

library IEEE;

use IEEE.STD_LOGIC_1164.all;

use IEEE.STD_LOGIC_UNSIGNED.all;

entity count10en is

port(

clr : in STD_LOGIC;

clk : in STD_LOGIC;

en : in STD_LOGIC;

q:out STD_LOGIC_VECTOR(3 DOWNTO 0);

co : out STD_LOGIC );

end count10en;

--}} End of automatically maintained section

architecture try of count10en is

signal count_4:std_logic_vector(3 downto 0);

begin

q<=count_4;

co<=count_4(0) and count_4(3); --满9进位

process(clk,clr)

begin

if(clr='1')then

count_4<="0000";

elsif(clk'event and clk='1')then

if(en='1')then

if(count_4="1001")then

count_4<="0000";

else count_4<=count_4+1;

end if;

end if;

end if;

end process;

-- enter your statements here --

end try;

3、数码管扫描与显示模块

其功能是将计数器的四位输入转换为数码管0~9的显示,将数码管的数字用高频(50Hz)扫描的方式呈现。

LIBRARY IEEE;

USE IEEE.STD_LOGIC_1164.ALL;

USE IEEE.STD_LOGIC_UNSIGNED.ALL;

ENTITY scan IS

PORT(CLK,clr : IN STD_LOGIC;

led_in_0,led_in_1,led_in_2,led_in_3,led_in_4,led_in_5,led_in_6,led_in_7: in

STD_LOGIC_VECTOR(3 DOWNTO 0);

led_seg : OUT STD_LOGIC_VECTOR(6 DOWNTO 0);

led_bit : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)

);

END scan;

ARCHITECTURE rtl OF scan IS

相关文档
最新文档