📄 新建 文本文档 (3).txt
字号:
when 41=>d2<=6061;
if cnt2<1 then
cnt2:=cnt2+1;
else
cnt2:=0;
n:=42;
end if;
when 42=>d2<=7634;
if cnt2<2 then
cnt2:=cnt2+1;
else
cnt2:=0;
n:=43;
end if;
when 43=>d2<=9050;
if cnt2<2 then
cnt2:=cnt2+1;
else
cnt2:=0;
n:=44;
end if;
when 44=>d2<=10204;
if cnt2<1 then
cnt2:=cnt2+1;
else
cnt2:=0;
n:=45;
end if;
when 45=>d2<=7634;
if cnt2<5 then
cnt2:=cnt2+1;
else
cnt2:=0;
n:=0;
end if;
end case;
end if;
end if;
end process;
end mus_arc;
4、 计时器:
library ieee;
use ieee.std_logic_1164.all;
entity jishi is
port(clk,preset:in std_logic;
b:out integer range 0 to 55);
end jishi;
architecture ji_arc of jishi is
begin
process(clk,preset)
variable cnt:integer range 0 to 1000000;
variable tmp:integer range 0 to 55;
begin
if preset='1'then
cnt:=0;tmp:=0;
elsif clk'event and clk='1'then
if cnt<1000000 then
cnt:=cnt+1;
else
cnt:=0;
if tmp=55 then
tmp:=0;
else
tmp:=tmp+1;
end if;
end if;
end if;
b<=tmp;
end process;
end ji_arc;
5、 列选择器:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity liexz is
port(clk,preset:in std_logic;
sel:out std_logic_vector(3 downto 0));
end liexz;
architecture lie_arc of liexz is
begin
process(clk,preset)
variable tmp:std_logic_vector(3 downto 0);
begin
if preset='1'then
tmp:="0000";
elsif clk'event and clk='1'then
if tmp="1111" then
tmp:="0000";
else
tmp:=tmp+1;
end if;
end if;
sel<=tmp-1;
end process;
end lie_arc;
6、 播放器:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity play is
port(cs:in std_logic;
d1,d2:in integer range 0 to 10204;
sel:in std_logic_vector(3 downto 0);
b:in integer range 0 to 55;
q:out std_logic_vector(15 downto 0);
do:out integer range 0 to 10204);
end play;
architecture pla_arc of play is
begin
process(cs,sel)
variable cnt1:integer range 0 to 1000000;
variable cnt2:integer range 0 to 7;
begin
case cs is
when'1'=>do<=d2;
case b is
when 0=>
case sel is
when"0000"=>q<="0010000000000000"; when"0001"=>q<="0001100000100000"; when"0010"=>q<="0000000000010000"; when"0011"=>q<="0111000000001000"; when"0100"=>q<="0100000000000111"; when"0101"=>q<="0100011111111100";
when"0110"=>q<="0100100100100100"; when"0111"=>q<="0101000100100100"; when"1000"=>q<="0111000100100100"; when"1001"=>q<="0100000100100100"; when"1010"=>q<="0100000110110100"; when"1011"=>q<="0111000100100100"; when"1100"=>q<="0000000000000110"; when"1101"=>q<="0000100000000010"; when"1110"=>q<="0011000000001100"; when"1111"=>q<="0000000000000000";
when others=>null;
end case;
if cnt2<1 then
cnt2:=cnt2+1;
else
cnt2:=0;
end if;
when 1=>
case sel is
when"0000"=>q<="0000000000010000"; when"0001"=>q<="1111111111011000"; when"0010"=>q<="0000100101010100"; when"0011"=>q<="0100100101010011"; when"0100"=>q<="1000100101010000"; when"0101"=>q<="0111111111011100"; when"0110"=>q<="0000000000110000"; when"0111"=>q<="0000000000000000"; when"1000"=>q<="0111111001111111"; when"1001"=>q<="1001000010010000"; when"1010"=>q<="1000100010001000"; when"1011"=>q<="1000010010000100"; when"1100"=>q<="1000011010000110"; when"1101"=>q<="1000000011100000"; when"1110"=>q<="1110000000000000"; when"1111"=>q<="0000000000000000";
when others=>null;
end case;
if cnt2<2 then
cnt2:=cnt2+1;
else
cnt2:=0;
end if;
when 2=>
case sel is
when"0000"=>q<="0010000000000100"; when"0001"=>q<="0001100000000100"; when"0010"=>q<="0000000000000100"; when"0011"=>q<="0011110011111100"; when"0100"=>q<="0100000010000100"; when"0101"=>q<="0100000010000100"; when"0110"=>q<="0100001010000101"; when"0111"=>q<="0100010010000110"; when"1000"=>q<="0101100010000100"; when"1001"=>q<="0100000010000100"; when"1010"=>q<="0100000010000100"; when"1011"=>q<="0111000011000100"; when"1100"=>q<="0000000010000100"; when"1101"=>q<="0001000000000110"; when"1110"=>q<="0011000000000100"; when"1111"=>q<="0000000000000000";
when others=>null;
end case;
when 3=>
case sel is
when"0000"=>q<="0000000001000000"; when"0001"=>q<="0000000001000000"; when"0010"=>q<="0000000001000010"; when"0011"=>q<="0111111111001100"; when"0100"=>q<="0001000000000000"; when"0101"=>q<="0001000000000100"; when"0110"=>q<="0001111110000100"; when"0111"=>q<="0100000010000100"; when"1000"=>q<="0100000010000100"; when"1001"=>q<="0100000010000100"; when"1010"=>q<="0100000010000100"; when"1011"=>q<="0100000010000100"; when"1100"=>q<="0100000111111110"; when"1101"=>q<="0100000000000100"; when"1110"=>q<="0111100000000000"; when"1111"=>q<="0000000000000000";
when others=>null;
end case;
if cnt2<1 then
cnt2:=cnt2+1;
else
cnt2:=0;
end if;
when 4=>
case sel is
when"0000"=>q<="0000000000000000"; when"0001"=>q<="0000000000000000"; when"0010"=>q<="1111111111111110"; when"0011"=>q<="0000000000000000"; when"0100"=>q<="0000000000000000"; when"0101"=>q<="0000000000000000"; when"0110"=>q<="0111111111111100"; when"0111"=>q<="0010000010000100"; when"1000"=>q<="0010000010000100"; when"1001"=>q<="0010000010000100"; when"1010"=>q<="0010000010000100"; when"1011"=>q<="0010000010000100"; when"1100"=>q<="0010000010000100"; when"1101"=>q<="0111111111111110"; when"1110"=>q<="0000000000000010"; when"1111"=>q<="0000000000000000";
when others=>null;
end case;
if cnt2<1 then
cnt2:=cnt2+1;
else
cnt2:=0;
end if;
when 5=>
case sel is
when"0000"=>q<="0000000000000000"; when"0001"=>q<="0000000000000000"; when"0010"=>q<="0000000000000000"; when"0011"=>q<="0111111111111110"; when"0100"=>q<="0010000010000010"; when"0101"=>q<="0010000010000010"; when"0110"=>q<="0010000010000010"; when"0111"=>q<="0010000010000010"; when"1000"=>q<="0010000010000010"; when"1001"=>q<="0010000010000010"; when"1010"=>q<="0010000010000010"; when"1011"=>q<="0111111111111111"; when"1100"=>q<="0000000000000010"; when"1101"=>q<="0000000000000000"; when"1110"=>q<="0000000000000000"; when"1111"=>q<="0000000000000000";
when others=>null;
end case;
if cnt2<2 then
cnt2:=cnt2+1;
else
cnt2:=0;
end if;
when 6=>
case sel is
when"0000"=>q<="1000000000000000"; when"0001"=>q<="0110000000000000"; when"0010"=>q<="0001111111111110"; when"0011"=>q<="0000001000100010"; when"0100"=>q<="0010001000100010"; when"0101"=>q<="0100001000100010"; when"0110"=>q<="0011111111111111"; when"0111"=>q<="1000000000000010"; when"1000"=>q<="0110000000000000"; when"1001"=>q<="0001111111111110"; when"1010"=>q<="0000001000100010"; when"1011"=>q<="0010001000100010"; when"1100"=>q<="0100001000100010"; when"1101"=>q<="0011111111111111"; when"1110"=>q<="0000000000000010"; when"1111"=>q<="0000000000000000";
when others=>null;
end case;
when 7=>
case sel is
when"0000"=>q<="0001000000001000"; when"0001"=>q<="1000100000001000"; when"0010"=>q<="1000010000001000"; when"0011"=>q<="0100001100001000"; when"0100"=>q<="0100000011001000"; when"0101"=>q<="0010000101111111"; when"0110"=>q<="0010001001001000"; when"0111"=>q<="0001010001001000"; when"1000"=>q<="0000100001001000"; when"1001"=>q<="0001010001001000"; when"1010"=>q<="0010001101001000"; when"1011"=>q<="0010000011001000"; when"1100"=>q<="0100000000001000"; when"1101"=>q<="1100000000001100"; when"1110"=>q<="0100000000001000"; when"1111"=>q<="0000000000000000";
when others=>null;
end case;
if cnt2<1 then
cnt2:=cnt2+1;
else
cnt2:=0;
end if;
when 8=>
case sel is
whe0n"0000"=>q<="0000010000000000"; when"0001"=>q<="0000001000000000"; when"0010"=>q<="0000000111000000"; when"0011"=>q<="0000000000000000"; when"0100"=>q<="0011111111110000"; when"0101"=>q<="0100000000000000"; when"0110"=>q<="0100000000000001"; when"0111"=>q<="0100000000000010"; when"1000"=>q<="0100000000011100"; when"1001"=>q<="0100000000001000"; when"1010"=>q<="0100000000000000"; when"1011"=>q<="0111000000000000"; when"1100"=>q<="0000000001000000"; when"1101"=>q<="0000000010000000"; when"1110"=>q<="0000011100000000"; when"1111"=>q<="0000000000000000";
when others=>null;
end case;
if cnt2<1 then
cnt2:=cnt2+1;
else
cnt2:=0;
end if;
when 9=>
case sel is
when"0000"=>q<="0000000000000000"; when"0001"=>q<="0000001111111000"; when"0010"=>q<="0000000100001000"; when"0011"=>q<="0000000100001000"; when"0100"=>q<="0000000100001000"; when"0101"=>q<="0000000100001000"; when"0110"=>q<="0000000100001000"; when"0111"=>q<="1111111111111111"; when"1000"=>q<="0000000100001000"; when"1001"=>q<="0000000100001000"; when"1010"=>q<="0000000100001000"; when"1011"=>q<="0000000100001000"; when"1100"=>q<="0000000100001000"; when"1101"=>q<="0000001111111100"; when"1110"=>q<="0000000000001000"; when"1111"=>q<="0000000000000000";
when others=>null;
end case;
if cnt2<2 then
cnt2:=cnt2+1;
else
cnt2:=0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -