《数字逻辑系统设计》设计报告格式
- 格式:doc
- 大小:326.50 KB
- 文档页数:14
JIU JIANG UNIVERSITY数字逻辑系统课程设计报告设计课题:简易电子琴专业:电子信息工程班级学号:20学生姓名:陈长源指导教师:盛健设计时间:2012.12.24~2012.12.28简易电子琴1.设计任务与要求1.1通过对一个简易的八音符电子琴的设计,进一步加深对计算机原理以及数字电路应用技术方面的了解与认识,进一步熟悉数字电路系统设计、制作与调试的方法和步骤1.2设计简易的八音符电子琴,它可通过按键输入来控制音响。
1.3演奏时可以选择是手动演奏(由键盘输入)还是自动演奏已存入的乐曲。
1.4能够自动演奏多首乐曲,且每首乐曲可重复演奏2.方案设计及主要技术思路2.1方案一、本设计可有两种方案实现,他们的程序一样,但是所利用逻辑元件不同,其一是将产生的32M频率模块,自动|手动控制模块,音节产生模块,分频模块依次连接。
2.2方案二、利用顶层设计将各个程序整合,再生成相应的图形文件,利用这个图形元件再接上外围即可实现功能。
2.3优劣分析及方案选定方案一层次分明,逻辑元件连接清晰,易于理解。
反观方案二,虽然结构简单,但是不易理解。
2.4 采用的硬件平台及主要技术2.4.1 EDA技术是以计算机为工具,根据硬件描述语言HDL (Hardware Description language)完成的设计文件,自动地完成逻辑编译、化简、分割、综合及优化、布局布线、仿真以及对于特定目标芯片的适配编译和编程下载等工作。
2.4.2 VHDL主要用于描述数字系统的结构,行为,功能和接口。
除了含有许多具有硬件特征的语句外,VHDL的语言形式和描述风格与句法是十分类似于一般的计算机高级语言。
VHDL的程序结构特点是将一项工程设计,或称设计实体(可以是一个元件,一个电路模块或一个系统)分成外部(或称可是部分,及端口)和内部(或称不可视部分),既涉及实体的内部功能和算法完成部分。
在对一个设计实体定义了外部界面后,一旦其内部开发完成后,其他的设计就可以直接调用这个实体。
这种将设计实体分成内外部分的概念是VHDL系统设计的基本点。
3.模块设计过程及仿真3.1 A模块的设计本设计主要分为四个模块,分别为32M频率产生模块,手动|自动模块,音节产生模块,分频模块3.1.1A模块要实现的具体功能,引脚。
32M频率产生模块的功能是要将100M频率变为32M,手动|自动模块是实现自动控制或手动控制,音调发生模块的作用是产生音阶的分频预置值,数控分频模块是对时基脉冲进行分频,得到与1、2、3、4、5、6、7七个音符相对应的频率。
3.1.2 A模块的设计思路和设计方法及关键设计语句说明。
音乐有两个重要因素,一个是音节,一个是音调。
简单来说就是低音还是高音,每个音持续多久,即为频率。
本设计主要就是依据这个思路来实现的,设计方法采用的是自顶而下的设计方法。
关键设计语句在后面的具体程序有详细描述。
3.1.3A模块的设计过程中遇到的问题及解决方法本设计遇到的主要问题是如何产生32M的频率,由于程序要求的是32M,然而开发板上并没有32M的信号。
开发板上有48M和100M的,在分析计算后,发现用100M产生32M结果更精确。
3.1.4A模块实现的具体功能、仿真分析、模块符号图。
(3)数控分频模块(2)音调发生模块的仿真1.自动手动模块符号图3.1.5 A模块代码见附录,代码必须有注释。
自动手动控制library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity automusic isPort ( clk,Auto : in std_logic; --系统时钟;键盘输入/自动演奏index2 : in std_logic_vector(7 downto 0); --键盘输入信号index0 : out std_logic_vector(7 downto 0)); --音符信号输出end automusic;architecture Behavioral of automusic issignal count0:integer range 0 to 31;--changesignal clk2:std_logic;beginpulse0:process(clk,Aut0) --此进程完成对系统时钟8M的分频,得到4Hz的信号clk2variable count:integer range 0 to 8000000;beginif Auto='1' then count:=0;clk2<='0';elsif clk'event and clk='1' then count:=count+1;if count=4000000(4) then clk2<='1';elsif count=8000000 (8)then clk2<='0';count:=0;end if;end if;end process;music:process(clk2) --此进程完成自动演奏部分曲的地址累加beginif clk2'event and clk2='1' thenif count0=31 then count0<=0;else count0<=count0+1;end if;end if;end process;com1:process(count0,Auto,index2)beginif Auto='0' thencase count0 is --此case语句:存储自动演奏部分的曲when 0 => index0<="00000100"; --3when 1 => index0<="00000100"; --3when 2 => index0<="00000100"; --3when 3 => index0<="00000100"; --3when 4 => index0<="00010000"; --5when 5 => index0<="00010000"; --5when 6 => index0<="00010000"; --5when 7 => index0<="00100000"; --6when 8 => index0<="10000000"; --8when 9 => index0<="10000000"; --8when 10 =>index0<="10000000"; --8when 11=> index0<="00000100"; --3when 12=> index0<="00000010"; --2when 13=> index0<="00000010"; --2when 14=> index0<="00000001"; --1when 15=> index0<="00000001"; --1when 16=> index0<="00010000"; --5when 17=> index0<="00010000"; --5when 18=> index0<="00001000"; --4when 19=> index0<="00001000"; --4when 20=> index0<="00001000"; --4when 21=> index0<="00000100"; --3when 22=> index0<="00000010"; --2when 23=> index0<="00000010"; --2when 24=> index0<="00010000"; --5when 25=> index0<="00010000"; --5when 26=> index0<="00001000"; --4when 27=> index0<="00001000"; --4when 28=> index0<="00000100"; --3when 29=> index0<="00000100"; --3when 30=> index0<="00000010"; --2when 31=> index0<="00000010"; --2when others => null;end case;else index0<=index2; --键盘输入音符信号输出end if;end process;end Behavioral;音调产生模块library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity tone isPort ( index : in std_logic_vector(7 downto 0); --音符输入信号code : out std_logic_vector(6 downto 0); --音符显示信号high : out std_logic; --高低音显示信号tone0 : out integer range 0 to 2047); --音符的分频系数end tone;architecture Behavioral of tone isbeginsearch :process(index) --此进程完成音符到音符的分频系数译码,音符的显示,高低音阶begincase index iswhen "00000001" => tone0<=773;code<="1001111";high<='1';when "00000010"=> tone0<=912;code<="0010010";high<='1';when "00000100" => tone0<=1036;code<="0000110";high<='1';when "00001000" => tone0<=1116;code<="1001100";high<='1';when "00010000" => tone0<=1197;code<="0100100";high<='1';when "00100000" => tone0<=1290;code<="0100000";high<='0';when "01000000" => tone0<=1372;code<="0001111";high<='0';when "10000000" => tone0<=1410;code<="0000000";high<='0';when others => tone0<=2047;code<="0000001";high<='0';end case;end process;end Behavioral;分频模块library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity speaker isPort ( clk1 : in std_logic; --系统时钟tone1 : in integer range 0 to 30624; --音符分频系数spks : out std_logic); --驱动扬声器的音频信号end speaker;architecture Behavioral of speaker issignal preclk,fullspks:std_logic;beginpulse1:process(clk1) --此进程对系统时钟进行4分频variable count:integer range 0 to 8;beginif clk1'event and clk1='1' then count:=count+1;if count=2 then preclk<='1';elsif count=4 then preclk<='0';count:=0;end if;end if;end process pulse1;genspks:process(preclk,tone1) --此进程按照tone1输入的分频系数对8MHz 的脉冲再次分频,得到所需要的音符频率variable count11:integer range 0 to 30624;beginif preclk'event and preclk='1' thenif count11<tone1 then count11:=count11+1;fullspks<='1';else count11:=0;fullspks<='0';end if;end if;end process;delaysps:process(fullspks) --此进程对fullspks进行2分频variable count2 :std_logic:='0';beginif fullspks'event and fullspks='1' then count2:=not count2;if count2='1' then spks<='1';else spks<='0';end if;end if;end process;end Behavioral;顶层VHDL程序library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity top is Port ( clk32MHz :in std_logic; --32MHz系统时钟 handTOauto : in std_logic; --键盘输入/自动演奏code1 :out std_logic_vector(6 downto 0); --音符显示信号index1 :in std_logic_vector(7 downto 0); --键盘输入信号high1 :out std_logic; --高低音节信号spkout :out std_logic); --音频信号end top;architecture Behavioral of top iscomponent automusicPort ( clk :in std_logic;Auto: in std_logic;index2:in std_logic_vector(7 downto 0);index0 : out std_logic_vector(7 downto 0));end component;component tonePort ( index : in std_logic_vector(7 downto 0);code : out std_logic_vector(6 downto 0);high : out std_logic;tone0 : out integer range 0 to 2047);end component;component speakerPort ( clk1 : in std_logic;tone1 : in integer range 0 to 2047;spks : out std_logic);end component;signal tone2: integer range 0 to 2047;signal indx:std_logic_vector(7 downto 0);begin u0:automusic portmap(clk=>clk32MHZ,index2=>index1,index0=>indx,Auto=>handtoAuto); u1:tone port map(index=>indx,tone0=>tone2,code=>code1,high=>high1);u2: speaker port map(clk1=>clk32MHZ,tone1=>tone2,spks=>spkout);end Behavioral;3.2 B模块的设计乐曲自动演奏模块的作用是产生8位发生控制输入信号。