📄 jianzhong.vhd
字号:
entity jianzhong is
port(clk,clr,s0,s1,s2,s3,s4,s5,s6:in bit;
ds:buffer bit_vector (3 downto 0);
y:buffer bit_vector (7 downto 0));
end jianzhong;
architecture zhong of jianzhong is
signal a,c:integer range 0 to 9;
signal b,d:integer range 0 to 5;
signal f:bit_vector (2 downto 0);
begin
x1:process(s0,s1,s2,s3,s4,s5,s6,clr)
variable i:integer range 0 to 1000;
begin
-- if clk'event and clk='1' and clk'last_value='0' then
-- if i<1000 then i:=i+1;
-- else i:=0;
if s0='0' then f<="001";
elsif s1='0' then f<="010";
elsif s2='0' then f<="011";
elsif s3='0' then f<="100";
elsif s4='0' then f<="101";
elsif s5='0' then f<="110";
elsif s6='0' then f<="111";
elsif clr='0' then f<="000";
end if;
-- end if;
-- end if;
end process;
x2:process(clk,clr)
variable i:integer range 0 to 1000;
begin
if clr='0' then a<=0;b<=0;c<=0;d<=0;
elsif clk'event and clk'last_value='0' and clk='1' then
if i<1000 then i:=i+1;
else i:=0;
if a<9 then a<=a+1;
else a<=0;
if b<5 then b<=b+1;
else b<=0;
if c<9 then c<=c+1;
else c<=0;
if d<5 then d<=d+1;
else d<=0;
end if;
end if;
end if;
end if;
end if;
end if;
end process;
x3:process(clk,f)
variable t: integer range 0 to 3;
begin
if f="001" then y<="11111101" ;ds<="0000";
elsif f="010" then y<="01100001";ds<="0000";
elsif f="011" then y<="11011011";ds<="0000";
elsif f="100" then y<="11110011";ds<="0000";
elsif f="101" then y<="01100111";ds<="0000";
elsif f="110" then y<="10110111";ds<="0000";
elsif f="111" then y<="10111111";ds<="0000";
elsif f="000" then
if clk'event and clk'last_value='0' and clk='1' then
t:=t+1;
if t=1 then
if a=0 then y<="11111101" ;ds<="1110";
elsif a=1 then y<="01100001" ;ds<="1110";
elsif a=2 then y<="11011011" ;ds<="1110";
elsif a=3 then y<="11110011" ;ds<="1110";
elsif a=4 then y<="01100111" ;ds<="1110";
elsif a=5 then y<="10110111" ;ds<="1110";
elsif a=6 then y<="10111111" ;ds<="1110";
elsif a=7 then y<="11100001" ;ds<="1110";
elsif a=8 then y<="11111111" ;ds<="1110";
elsif a=9 then y<="11110111" ;ds<="1110";
end if;
elsif t=2 then
if b=1 then y<="01100001" ;ds<="1101";
elsif b=2 then y<="11011011" ;ds<="1101";
elsif b=3 then y<="11110011" ;ds<="1101";
elsif b=4 then y<="01100111" ;ds<="1101";
elsif b=5 then y<="10110111" ;ds<="1101";
elsif b=0 then y<="11111101" ;ds<="1101";
end if;
elsif t=3 then
if c=1 then y<="01100001" ;ds<="1011";
elsif c=2 then y<="11011011" ;ds<="1011";
elsif c=3 then y<="11110011" ;ds<="1011";
elsif c=4 then y<="01100111" ;ds<="1011";
elsif c=5 then y<="10110111" ;ds<="1011";
elsif c=6 then y<="10111111" ;ds<="1011";
elsif c=7 then y<="11100001" ;ds<="1011";
elsif c=8 then y<="11111111" ;ds<="1011";
elsif c=9 then y<="11110111" ;ds<="1011";
elsif c=0 then y<="11111101" ;ds<="1011";
end if;
else
if d=1 then y<="01100001" ;ds<="0111";
elsif d=2 then y<="11011011" ;ds<="0111";
elsif d=3 then y<="11110011" ;ds<="0111";
elsif d=4 then y<="01100111" ;ds<="0111";
elsif d=5 then y<="10110111" ;ds<="0111";
elsif d=0 then y<="11111101" ;ds<="0111";
end if;
end if;
end if;
end if;
end process;
end zhong;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -