📄 top.vhd
字号:
library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity musicdec is Port ( spkout0 : out std_logic;
spkout1 : out std_logic;
sysclk : in std_logic );end musicdec;architecture Behavioral of musicdec is
signal addr : std_logic_vector ( 23 downto 0);
signal tonestep : std_logic_vector (9 downto 0);
signal tonecode : std_logic_vector (7 downto 0);
signal divcounter : integer range 0 to 999999;
signal f : std_logic;begin
spkout0<= f;spkout1<= f;
process (sysclk)
begin
if sysclk'event and sysclk= '1' then
if divcounter = 65535 then
f<= not f;
divcounter<=0;
else
divcounter<=divcounter+1;
end if;
end if;
end process;
end Behavioral;
--state_machine: process(musicclk)--begin-- if musicclk'event and musicclk='1' then-- case prestate is-- when idle=>-- if musickey='0' then -- tonecode<=x"00";-- prestate<=playmusic; -- elsif tonekey/="11111" then-- tonecode<=x"00";-- prestate<=playtone;-- else-- tonecode<=x"00";-- codeaddr1<=0;-- codeaddr2<=0;-- codeaddr3<=0;-- prestate<=idle;-- end if;-- -- when playtone=>-- if tonekey/="11111" then-- case tonekey is -- when "11110"=> tonecode<=x"08";-- when "11101"=> tonecode<=x"09";-- when "11011"=> tonecode<=x"0a";-- when "10111"=> tonecode<=x"0b";-- when "01111"=> tonecode<=x"0c";-- when others=> tonecode<=x"00";-- end case;-- prestate<=playtone;-- else-- tonecode<=x"00";-- prestate<=idle; -- end if;-- when playmusic=>-- if tonekey/="11111" then-- prestate<=playtone;-- else -- case musicno is-- when "00" => tonecode<=music1(codeaddr1);-- if codeaddr1=255 then-- codeaddr1<=0;-- else-- codeaddr1<=codeaddr1+1;-- end if;-- codeaddr2<=0;-- codeaddr3<=0;-- when "01" => tonecode<=music2(codeaddr2);-- if codeaddr2=447 then-- codeaddr2<=0;-- else-- codeaddr2<=codeaddr2+1;-- end if;-- codeaddr1<=0;-- codeaddr3<=0;-- -- when "10" => tonecode<=music3(codeaddr3);-- if codeaddr3=495 then-- codeaddr3<=0;-- else-- codeaddr3<=codeaddr3+1;-- end if;-- codeaddr2<=0;-- codeaddr1<=0;-- when "11"=> prestate<=idle;-- tonecode<=x"00";-- codeaddr1<=0;-- codeaddr2<=0;-- codeaddr3<=0;-- when others=>null;-- end case;---- if tonecode/=x"ff" then -- prestate<=playmusic;-- else-- prestate<=idle;-- end if;-- end if;-- when others=> null;-- end case;-- end if; --end process;;------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -