Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.std_logic_unsigned.all;
- entity zadatak is
- port(
- iCLK: in std_logic;
- iRST: in std_logic;
- iGO: in std_logic;
- iSTOP: in std_logic;
- oSEC : out std_logic_vector (6 downto 0);
- oMUXROW: out std_logic_vector(1 downto 0)
- );
- end entity;
- architecture Behavior of zadatak is
- signal sCNT: std_logic_vector(23 downto 0);
- signal sSEC: std_logic_vector(7 downto 0);
- signal sTC: std_logic;
- signal sEN: std_logic;
- signal sTC1: std_logic;
- signal sDES: std_logic_vector(7 downto 0);
- signal sEN1: std_logic;
- signal sGO: std_logic;
- signal sGO_OLD: std_logic;
- signal s7SEGM: std_logic_vector(6 downto 0);
- begin
- process (iCLK, iRST) begin
- if (iRST = '1') then
- sCNT <= (others=>'0');
- elsif (iCLK'event and iCLK = '1') then
- if(sGO='1') then
- if(sCNT="101101110001101100000000") then
- sCNT<=(others=>'0'); --reset
- sTC<='1';
- else
- sCNT<=sCNT+'1';
- sTC<='0';
- end if;
- end if;
- end if;
- sGO_OLD<=sGO;
- sEN<=sTC;
- end process;
- -- sekunde
- process (iCLK, iRST) begin
- if (iRST = '1') then
- sSEC <= "00000000";
- elsif (iCLK'event and iCLK = '1') then
- if(sEN='1') then
- sSEC <= sSEC + 1;
- if(sSEC=9) then
- sSEC<=(others=>'0');--reset
- sTC1<='1';
- else
- sTC1<='0';
- end if;
- end if;
- end if;
- sEN1<=sTC1;
- end process;
- -- desetice
- process(iCLK,iRST) begin
- if(iRST='1') then
- sDES<="00000000";
- elsif(iCLK'event and iCLK='1') then
- if(sEN1='1') then
- if(sCNT="000000000000000000000001") then
- sDES<=sDES+'1';
- if(sDES=5) then
- sDES<=(others=>'0');
- end if;
- end if;
- end if;
- end if;
- end process;
- -- aktivnost stoperice --
- process(iCLK,iRST) begin
- if(iRST='1') then
- sGO<='0';
- elsif(iGO='1') then
- sGO<='1';
- elsif(iSTOP='1') then
- sGO<='0';
- else
- sGO<=sGO_OLD;
- end if;
- end process;
- process(s7SEGM) begin
- if(sCNT(15)='1') then
- oMUXROW<="01";
- if(sDES=0) then
- s7SEGM <= "0000001";
- elsif(sDES=1) then
- s7SEGM<="1001111";
- elsif(sDES=2) then
- s7SEGM<="0010010";
- elsif(sDES=3) then
- s7SEGM<="0000110";
- elsif(sDES=4) then
- s7SEGM<="1001100";
- else
- s7SEGM<="0100100";
- end if;
- else
- oMUXROW<="00";
- if(sSEC=0) then
- s7SEGM <= "0000001";
- elsif(sSEC=1) then
- s7SEGM<="1001111";
- elsif(sSEC=2) then
- s7SEGM<="0010010";
- elsif(sSEC=3) then
- s7SEGM<="0000110";
- elsif(sSEC=4) then
- s7SEGM<="1001100";
- elsif(sSEC=5) then
- s7SEGM<="0100100";
- elsif(sSEC=6) then
- s7SEGM<="0100000";
- elsif(sSEC=7) then
- s7SEGM<="0001111";
- elsif(sSEC=8) then
- s7SEGM<="0000000";
- else
- s7SEGM<="0000100";
- end if;
- end if;
- oSEC(6 downto 0)<=s7SEGM;
- end process;
- end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement