LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
entity zhongbiao is
port (clk: in std_logic;
jian1: in std_logic;
jian2: in std_logic;
jian3: in std_logic;
jian4: in std_logic;
jian5: in std_logic;
jian6: in std_logic;
jian7: in std_logic;
jian8: in std_logic;
led7s1: out std_logic_vector(6 downto 0);
led7s2: out std_logic_vector(6 downto 0);
led7s3: out std_logic_vector(6 downto 0);
led7s4: out std_logic_vector(6 downto 0);
led7s5: out std_logic_vector(6 downto 0);
led7s6: out std_logic_vector(6 downto 0);
led7s7: out std_logic_vector(6 downto 0);
led7s8: out std_logic_vector(6 downto 0));
end;
architecture behav of zhongbiao is
begin
process(clk,jian8,jian1,jian2,jian3,jian4,jian5,jian6,jian7)
variable q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11,q12,q13: integer range 9 downto 0;
variable qnz1,qnz2,qnz3,qnz4,qnz5: integer range 1 downto 0;
variable qyz,qnz,qng1,qns1,qnb1: integer range 1 downto 0;
variable qd: integer range 31 downto 1;
variable qng,qns,qnb,qnq: integer range 9 down to 0;
variable qy: integer range 12 downto 1;
begin
if clk'event and clk='1' then --共用部分(秒个加一)
if(q1<9) then
q1:=q1+1;q2:=0;
else q1:=0;q2:=1;
end if;
end if;
if q2=1 then --秒十加一
if (q3<5) then
q3:=q3+1;q4:=0;
else q3:=0;q4:=1;
end if;
else q4:=0;
end if;
if q4=1 then --分个加一
if q5<9 then
q5:=q5+1;q6:=0;
else q5:=0;q6:=1;
end if;
else q6:=0;
end if;
if q6=1 then --分十加一
if q7<5 then
q7:=q7+1;q8:=0;
else q7:=0;q8:=1;
end if;
else q8:=0;
end if;
if q8=1 then --小时个加一
if q9<9 then
q9:=q9+1;q10:=0;
else q9:=0;q10:=1;
end if;
else q10:=0;
end if;
if (q8=1) then --小时十加一 应该是是错误的应该是是错误的应该是是错误的应该是是错误的
if q10=1 then
if q11<2 then
q11:=q11+1;q12:=0;
end if;
else if(q11=2 and q9=4) then
q11:=0;q12:=1;q9:=0;
else q12:=0;
end if;
end if;
if q12=1 then --周加一
if q13<7 then
q13:=q13+1;
else q13:=1;
end if;
end if;
if(q12=1) then --日加一
case qy is
when 1 => if (qd<31) then qd:=qd+1;qyz:=0; else qd:=1;qyz:=1; end if;
when 2 => if (qd<29) then qd:=qd+1;qyz:=0; else qd:=1;qyz:=1; end if;
when 3 => if (qd<31) then qd:=qd+1;qyz:=0; else qd:=1;qyz:=1; end if;
when 4 => if (qd<30) then qd:=qd+1;qyz:=0; else qd:=1;qyz:=1; end if;
when 5 => if (qd<31) then qd:=qd+1;qyz:=0; else qd:=1;qyz:=1; end if;
when 6 => if (qd<30) then qd:=qd+1;qyz:=0; else qd:=1;qyz:=1; end if;
when 7 => if (qd<31) then qd:=qd+1;qyz:=0; else qd:=1;qyz:=1; end if;
when 8 => if (qd<31) then qd:=qd+1;qyz:=0; else qd:=1;qyz:=1; end if;
when 9 => if (qd<30) then qd:=qd+1;qyz:=0; else qd:=1;qyz:=1; end if;
when 10 => if (qd<31) then qd:=qd+1;qyz:=0; else qd:=1;qyz:=1; end if;
when 11 => if (qd<30) then qd:=qd+1;qyz:=0; else qd:=1;qyz:=1; end if;
when 12 => if (qd<31) then qd:=qd+1;qyz:=0; else qd:=1;qyz:=1; end if;
when others => null;
end case;
else qyz:=0;
end if;
if qyz=1 then --日加一
if qy<12 then
qy:=qy+1; qnz:=0;
end if;
else qnz:=0;
end if;
if qnz=1 then --年个加一
if qng<9 then
qng:=qng+1; qng1:=0;
else qng:=0; qng1:=1;
end if;
else qng1:=0;
end if;
if qng1=1 then --年十加一
if qns<9 then
qns:=qns+1; qns1:=0;
else qns:=0; qns1:=1;
end if;
else qns1:=0;
end if;
if qns1=1 then --年百加一
if qnb<9 then
qnb:=qnb+1; qnb1:=0;
else qnb:=0; qnb1:=1;
end if;
else qnb1:=0;
end if;
if qnb1=1 then --年千加一
if qnq<9 then
qnq:=qnq+1;
else qnq:=0;
end if;
end if;
if jian8='0' then
if jian7='0' then ----用case语句来进行各功能部分;
----显示时分秒周
case q1 is --显示秒
when 0 => led7s1(6 downto 0)<= "0111111";
when 1 => led7s1(6 downto 0)<= "0000110";
when 2 => led7s1(6 downto 0)<= "1011011";
when 3 => led7s1(6 downto 0)<= "1001111";
when 4 => led7s1(6 downto 0)<= "1100110";
when 5 => led7s1(6 downto 0)<= "1111101";
when 7 => led7s1(6 downto 0)<= "0000111";
when 8 => led7s1(6 downto 0)<= "1111111";
when 9 => led7s1(6 downto 0)<= "1101111";
when others => null;
end case;
case q3 is
when 0 => led7s2(6 downto 0)<= "0111111";
when 1 => led7s2(6 downto 0)<= "0000110";
when 2 => led7s2(6 downto 0)<= "1011011";
when 3 => led7s2(6 downto 0)<= "1001111";
when 4 => led7s2(6 downto 0)<= "1100110";
when 5 => led7s2(6 downto 0)<= "1101101";
when 6 => led7s2(6 downto 0)<= "1111101";
when 7 => led7s2(6 downto 0)<= "0000111";
when 8 => led7s2(6 downto 0)<= "1111111";
when 9 => led7s2(6 downto 0)<= "1101111";
when others => null;
end case;
case q5 is --显示分
when 0 => led7s3(6 downto 0)<= "0111111";
when 1 => led7s3(6 downto 0)<= "0000110";
when 2 => led7s3(6 downto 0)<= "1011011";
when 3 => led7s3(6 downto 0)<= "1001111";
when 4 => led7s3(6 downto 0)<= "1100110";
when 5 => led7s3(6 downto 0)<= "1101101";
when 6 => led7s3(6 downto 0)<= "1111101";
when 7 => led7s3(6 downto 0)<= "0000111";
when 8 => led7s3(6 downto 0)<= "1111111";
when 9 => led7s3(6 downto 0)<= "1101111";
when others => null;
end case;
case q7 is
when 0 => led7s4(6 downto 0)<= "0111111";
when 1 => led7s4(6 downto 0)<= "0000110";
when 2 => led7s4(6 downto 0)<= "1011011";
when 3 => led7s4(6 downto 0)<= "1001111";
when 4 => led7s4(6 downto 0)<= "1100110";
when 5 => led7s4(6 downto 0)<= "1101101";
when 6 => led7s4(6 downto 0)<= "1111101";
when 7 => led7s4(6 downto 0)<= "0000111";
when 8 => led7s4(6 downto 0)<= "1111111";
when 9 => led7s4(6 downto 0)<= "1101111";
when others => null;
end case;
case q9 is --显示小时
when 0 => led7s5(6 downto 0)<= "0111111";
when 1 => led7s5(6 downto 0)<= "0000110";
when 2 => led7s5(6 downto 0)<= "1011011";
when 3 => led7s5(6 downto 0)<= "1001111";
when 4 => led7s5(6 downto 0)<= "1100110";
when 5 => led7s5(6 downto 0)<= "1101101";
when 6 => led7s5(6 downto 0)<= "1111101";
when 7 => led7s5(6 downto 0)<= "0000111";
when 8 => led7s5(6 downto 0)<= "1111111";
when 9 => led7s5(6 downto 0)<= "1101111";
when others => null;
end case;
case q11 is
when 0 => led7s6(6 downto 0)<= "0111111";
when 1 => led7s6(6 downto 0)<= "0000110";
when 2 => led7s6(6 downto 0)<= "1011011";
when 3 => led7s6(6 downto 0)<= "1001111";
when 4 => led7s6(6 downto 0)<= "1100110";
when 5 => led7s6(6 downto 0)<= "1101101";
when 6 => led7s6(6 downto 0)<= "1111101";
when 7 => led7s6(6 downto 0)<= "0000111";
when 8 => led7s6(6 downto 0)<= "1111111";
when 9 => led7s6(6 downto 0)<= "1101111";
when others => null;
end case;
case q13 is --显示星期
when 0 => led7s7(6 downto 0)<= "0111111";
when 1 => led7s7(6 downto 0)<= "0000110";
when 2 => led7s7(6 downto 0)<= "1011011";
when 3 => led7s7(6 downto 0)<= "1001111";
when 4 => led7s7(6 downto 0)<= "1100110";
when 5 => led7s7(6 downto 0)<= "1101101";
when 6 => led7s7(6 downto 0)<= "1111101";
when 7 => led7s7(6 downto 0)<= "0000111";
when 8 => led7s7(6 downto 0)<= "1111111";
when 9 => led7s7(6 downto 0)<= "1101111";
when others => null;
end case;
else if jian7='1' then --闹钟
case qnz1 is
when 0 => led7s3(6 downto 0)<="0111111";
when 1 => led7s3(6 downt