【正文】
tor(7 downto 0))。architecture one of notetabs is begin t8:process(clk,counter) begin if counter =138 then counter =00000000。event and clk=39。) then counter =counter+1。 end process。(3)仿真波形(4)波形分析由波形可看出來,CLK為輸入時(shí)鐘信號,八位輸出二進(jìn)制信號在時(shí)鐘上升沿加一,經(jīng)分析,該模塊的功能正確。(1)模塊圖像(2)程序;LIBRARY IEEE。 USE 。 b:out STD_LOGIC_vector(3 downto 0)。 Q1:IN STD_LOGIC_vector(4 downto 0)。Q3:IN STD_LOGIC_vector(4 downto 0))。 ARCHITECTURE a OF choice IS BEGIN PROCESS (a,Q1,Q2,Q3) BEGIN CASE a IS WHEN 0001 = b=0001。 WHEN 0011 = b=0010。 WHEN 0010 = b=0011。 WHEN OTHERS = null。 END PROCESS。(3)波形圖(4)波形分析由波形分析可知,當(dāng)a輸入為0001時(shí),輸出信號b與Q1信號相同,即播放第一首樂曲,此時(shí)b的信號輸出為0001,因此該模塊的功能符合要求。Tonetaba模塊的功能首先是為speakera提供決定所發(fā)音符的分頻預(yù)置數(shù),而此數(shù)在speakera輸入口停留的時(shí)間即為此音符的節(jié)拍值。(1)模塊圖像(2)程序library ieee。entity tonetaba is port (index:in std_logic_vector(4 downto 0)。 high: out std_logic。 end。code=00001。039。code=00010。039。code=00011。039。code=00100。039。code=00101。039。code=00110。039。code=00111。039。code=01000。139。code=01001。139。code=01010。139。code=01011。139。code=01100。139。code=01101。139。code=01110。139。code=10001。139。code=10010。139。code=10011。139。code=10100。139。code=10101。139。code=10110。139。code=10111。139。end case。end。音符的頻率由speakera模塊獲得,這是一個(gè)數(shù)控分頻器。Speakera對CLK輸入信號的分頻比由11位預(yù)置數(shù)tone決定。例如在tonetaba模塊中若取tone=1036,將發(fā)音符為“3”音的信號頻率。use 。entity speakera is port ( clk : in std_logic。 spks : out std_logic)。architecture one of speakera is signal preclk, fullspks : std_logic。 begin preclk = 39。 if count411 then preclk = 39。 count4 := 0000。event and clk = 39。 then count4 :=count4+1。 end process。begin if preclk39。139。 fullspks = 39。 else count11 := count11+1。039。 end if。 delayspks : process(fullspks) variable count2 : std_logic。event and fullspks = 39。 then count2 := not count2。139。139。039。 end if。end。 :(1)《梁祝 》 width = 5。address_radix = dec。content begin00: 3。02: 3。04: 5。06: 5。08: 8。10: 8。12: 6。14: 5。16: 12。18: 12。20: 13。22: 10。24:9。26:9。28:9。30:9。32:9。34:9。36:7。38:6。40:5。42:5。44:8。46:9。48:3。50:8。52:6。54:6。56:5。58:5。60:5。62:5。64:10。66:10。68:7。70:9。72:6。74:5。76:5。78:5。80:3。82:3。84:5。86:7。88:6。90:6。92:6。94:5。96:8。98:8。100:12。102:12。104:9。106:10。108:8。110:6。112:3。114:3。116:8。118:8。120:6。122:6。124:3。126:6。128:5。130:5。132:5。134:5。136:0。1