数字秒表
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity alarm is
port(clk,I:in std_logic;
q:out std_logic);
end alarm;
architecture speaker of alarm is
signal n:integer range 0 to 9;
signal q0:std_logic;
begin
process(clk,I)
begin
if clk'event and clk='1' then
if i<='0' then q0<='0';n<=0;
elsif (i='1' and n<=9 )then
q0<='1';n<=n+1;
else q0<='0';
end if;
end if;
end process;
q<=q0;
end speaker;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity count6 is
port(clk,clr,start:in std_logic;
cout:out std_logic;
daout:buffer std_logic_vector(3 downto 0));
end count6;
architecture behave of count6 is
begin
process(clk,clr,start)
begin
if(clr='1') then
daout<="0000";
elsif rising_edge(clk) then
if(start='1')then
if daout="0101" then
daout<="0000";cout<='1';
else
daout<=daout+'1';cout<='0';
end if;
end if;
end if;
end process;
end behave;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity count10 is
port(clk: in std_logic;
clr,start: in std_logic;
cout:out std_logic;
daout:buffer std_logic_vector(3 downto 0));
end count10;
architecture behave of count10 is
begin
process(clk,clr,start)
begin
if(clr='1') then
daout<="0000";
elsif rising_edge(clk) then
if(start='1') then
if daout="1001" then
daout<="0000";cout<='1';
else
daout<=daout+'1';cout<='0';
end if;
end if;
end if;
end process;
end behave;
library ieee;
use ieee.std_logic_1164.all;
entity deled is
port(num:in bit_vector(3 downto 0);
led:out bit_vector(6 downto 0));
end;
architecture one of deled is
begin
process(num)
begin
case num(3 downto 0) is
when "0000"=>led<="0111111";
when "0001"=>led<="0000110";
when "0010"=>led<="1011011";
when "0011"=>led<="1001111";
when "0100"=>led<="1100110";
when "0101"=>led<="1101101";
when "0110"=>led<="1111101";
when "0111"=>led<="0000111";
when "1000"=>led<="1111111";
when "1001"=>led<="1101111";
when "1010"=>led<="1110111";
when "1011"=>led<="1111100";
when "1100"=>led<="0111001";
when "1101"=>led<="1011110";
when "1110"=>led<="1111001";
when "1111"=>led<="1110001";
when others=>NULL;
END CASE;
END PROCESS;
END ONE;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity divclk is
port(clk: in std_logic;
clk0:out std_logic);
end divclk;
architecture behave of divclk is
signal count:integer range 0 to 100000;
signal q0: std_logic;
begin
process(clk)
begin
if rising_edge(clk) then
if count=100000 then
count<=0;
q0<=not q0;
else
count<=count+1;
end if;
end if;
end process;
clk0<=q0;
end behave;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity divclk1000 is
port(clk: in std_logic;
clk1:out std_logic);
end divclk1000;
architecture behave of divclk1000 is
signal count:integer range 0 to 1000;
signal q0: std_logic;
begin
process(clk)
begin
if rising_edge(clk) then
if count=1000 then
count<=0;
q0<=not q0;
else
count<=count+1;
end if;
end if;
end process;
clk1<=q0;
end behave;
LIBRARY ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
ENTITY seltime IS
PORT(
clk, clr: INSTD_LOGIC;
DAIN1,DAIN2,DAIN3,DAIN4,DAIN5,DAIN6: INSTD_LOGIC_VECTOR(3 downto 0);
sel : out std_logic_vector ( 2 downto 0);
DAOUT:out STD_LOGIC_VECTOR(3 downto 0));
END seltime;
ARCHITECTURE fun OF seltime IS
SIGNAL count: STD_LOGIC_vector ( 2 downto 0);
BEGIN
sel <= count;
process ( clk)
begin
if (clk 'event and clk='1') then
if ( count >= "101") then
count <= "000";
else
count <= count + 1;
end if;
end if;
end process;
process(count,DAIN1,DAIN2,DAIN3,DAIN4,DAIN5,DAIN6)
begin
if clr='1' then
daout<="0000";
else
case count is
when "000" => daout <= DAIN1(3 downto 0);
when "001" => daout <= DAIN2(3 downto 0);
when "010" => daout <= DAIN3(3 downto 0);
when "011" => daout <= DAIN4(3 downto 0);
when "100" => daout <= DAIN5(3 downto 0);
when "101" => daout <= DAIN6(3 downto 0);
when others => daout <= null;
end case;
end if;
end process;
end fun;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity alarm is
port(clk,I:in std_logic;
q:out std_logic);
end alarm;
architecture speaker of alarm is
signal n:integer range 0 to 9;
signal q0:std_logic;
begin
process(clk,I)
begin
if clk'event and clk='1' then
if i<='0' then q0<='0';n<=0;
elsif (i='1' and n<=9 )then
q0<='1';n<=n+1;
else q0<='0';
end if;
end if;
end process;
q<=q0;
end speaker;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity count6 is
port(clk,clr,start:in std_logic;
cout:out std_logic;
daout:buffer std_logic_vector(3 downto 0));
end count6;
architecture behave of count6 is
begin
process(clk,clr,start)
begin
if(clr='1') then
daout<="0000";
elsif rising_edge(clk) then
if(start='1')then
if daout="0101" then
daout<="0000";cout<='1';
else
daout<=daout+'1';cout<='0';
end if;
end if;
end if;
end process;
end behave;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity count10 is
port(clk: in std_logic;
clr,start: in std_logic;
cout:out std_logic;
daout:buffer std_logic_vector(3 downto 0));
end count10;
architecture behave of count10 is
begin
process(clk,clr,start)
begin
if(clr='1') then
daout<="0000";
elsif rising_edge(clk) then
if(start='1') then
if daout="1001" then
daout<="0000";cout<='1';
else
daout<=daout+'1';cout<='0';
end if;
end if;
end if;
end process;
end behave;
library ieee;
use ieee.std_logic_1164.all;
entity deled is
port(num:in bit_vector(3 downto 0);
led:out bit_vector(6 downto 0));
end;
architecture one of deled is
begin
process(num)
begin
case num(3 downto 0) is
when "0000"=>led<="0111111";
when "0001"=>led<="0000110";
when "0010"=>led<="1011011";
when "0011"=>led<="1001111";
when "0100"=>led<="1100110";
when "0101"=>led<="1101101";
when "0110"=>led<="1111101";
when "0111"=>led<="0000111";
when "1000"=>led<="1111111";
when "1001"=>led<="1101111";
when "1010"=>led<="1110111";
when "1011"=>led<="1111100";
when "1100"=>led<="0111001";
when "1101"=>led<="1011110";
when "1110"=>led<="1111001";
when "1111"=>led<="1110001";
when others=>NULL;
END CASE;
END PROCESS;
END ONE;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity divclk is
port(clk: in std_logic;
clk0:out std_logic);
end divclk;
architecture behave of divclk is
signal count:integer range 0 to 100000;
signal q0: std_logic;
begin
process(clk)
begin
if rising_edge(clk) then
if count=100000 then
count<=0;
q0<=not q0;
else
count<=count+1;
end if;
end if;
end process;
clk0<=q0;
end behave;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity divclk1000 is
port(clk: in std_logic;
clk1:out std_logic);
end divclk1000;
architecture behave of divclk1000 is
signal count:integer range 0 to 1000;
signal q0: std_logic;
begin
process(clk)
begin
if rising_edge(clk) then
if count=1000 then
count<=0;
q0<=not q0;
else
count<=count+1;
end if;
end if;
end process;
clk1<=q0;
end behave;
LIBRARY ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
ENTITY seltime IS
PORT(
clk, clr: INSTD_LOGIC;
DAIN1,DAIN2,DAIN3,DAIN4,DAIN5,DAIN6: INSTD_LOGIC_VECTOR(3 downto 0);
sel : out std_logic_vector ( 2 downto 0);
DAOUT:out STD_LOGIC_VECTOR(3 downto 0));
END seltime;
ARCHITECTURE fun OF seltime IS
SIGNAL count: STD_LOGIC_vector ( 2 downto 0);
BEGIN
sel <= count;
process ( clk)
begin
if (clk 'event and clk='1') then
if ( count >= "101") then
count <= "000";
else
count <= count + 1;
end if;
end if;
end process;
process(count,DAIN1,DAIN2,DAIN3,DAIN4,DAIN5,DAIN6)
begin
if clr='1' then
daout<="0000";
else
case count is
when "000" => daout <= DAIN1(3 downto 0);
when "001" => daout <= DAIN2(3 downto 0);
when "010" => daout <= DAIN3(3 downto 0);
when "011" => daout <= DAIN4(3 downto 0);
when "100" => daout <= DAIN5(3 downto 0);
when "101" => daout <= DAIN6(3 downto 0);
when others => daout <= null;
end case;
end if;
end process;
end fun;