|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY clock IS
PORT
(
clk : IN STD_LOGIC;
keyin : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
diode : OUT STD_LOGIC_vector(5 downto 0);
led : out std_logic_vector(7 downto 0);
cs : out std_logic_vector(3 downto 0);
buzz_out : OUT STD_LOGIC
);
END clock;
ARCHITECTURE a OF clock IS
SIGNAL q : STD_LOGIC_vector(19 downto 0);
SIGNAL second : STD_LOGIC_vector(5 downto 0);
SIGNAL minl : STD_LOGIC_vector(3 downto 0);
SIGNAL minh : STD_LOGIC_vector(2 downto 0);
SIGNAL hourl : STD_LOGIC_vector(3 downto 0);
SIGNAL hourh,scan : STD_LOGIC_vector(1 downto 0);
signal led_code,minl_code,minh_code,hourl_code,hourh_code : std_logic_vector(7 downto 0);
signal hourl_codebuf :std_logic_vector(7 downto 0);
BEGIN
diode <= "111111";
buzz_out <= '0';
process(clk)
begin
if(clk'event and clk = '1') then
q <= q+1;
end if;
end process;
process(q(14))
begin
if(q(14)'event and q(14)='1') then
if second<"111011" then
second <= second+1;
else
second <="000000";
if minl < "1001" then
minl <= minl+1;
else
minl <= "0000";
if minh < "101" then
minh <= minh+1;
else
minh <="000";
if hourh <"10" then
if hourl < "1001" then
hourl <= hourl+1;
else
hourl <= "0000";
hourh <= hourh+1;
end if;
else if hourh = "10" then
if hourl <"0011" then
hourl <= hourl+1;
else
hourl <= "0000";
hourh <= "00";
end if;
end if;
end if;
end if;
end if;
end if;
end if;
end process;
scan <= q(7 downto 6);
cs <= "0001" when scan=0 else
"0010" when scan=1 else
"0100" when scan=2 else
"1000" when scan=3 else
"0000";
led_code <= minl_code when scan=0 else
minh_code when scan=1 else
hourl_codebuf when scan=2 else
hourh_code when scan=3 else
"00000000";
led <= led_code;
b1: block
begin
minl_code <= "11000000" when minl = 0 else
"11111001" when minl = 1 else
"10100100" when minl = 2 else
"10110000" when minl = 3 else
"10011001" when minl = 4 else
"10010010" when minl = 5 else
"10000010" when minl = 6 else
"11111000" when minl = 7 else
"10000000" when minl = 8 else
"10010000" when minl = 9 else
"11111111";
end block b1;
b2: block
begin
minh_code <= "11000000" when minh = 0 else
"11111001" when minh = 1 else
"10100100" when minh = 2 else
"10110000" when minh = 3 else
"10011001" when minh = 4 else
"10010010" when minh = 5 else
"11111111";
end block b2;
b3: block
begin
hourl_code <= "01000000" when hourl = 0 else
"01111001" when hourl = 1 else
"00100100" when hourl = 2 else
"00110000" when hourl = 3 else
"00011001" when hourl = 4 else
"00010010" when hourl = 5 else
"00000010" when hourl = 6 else
"01111000" when hourl = 7 else
"00000000" when hourl = 8 else
"00010000" when hourl = 9 else
"11111111";
end block b3;
b4: block
begin
hourh_code <= "11000000" when hourh = 0 else
"11111001" when hourh = 1 else
"10100100" when hourh = 2 else
"11111111";
end block b4;
process(q(14))
begin
if q(14) = '1' then
hourl_codebuf <= hourl_code and "01111111";
else
hourl_codebuf <= hourl_code or "10000000";
end if;
END process;
END a;
我想问一下,这个程序中的SIGNAL q信号是根据什么变化的半天我也没看出来? |
|