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_ARITH.ALL;
- use IEEE.STD_LOGIC_UNSIGNED.ALL;
- entity Count10UpDn is
- Port(CLR,DIR,p127 : in STD_LOGIC;
- com : out STD_LOGIC_VECTOR (3 downto 0);
- Y : out STD_LOGIC_VECTOR (6 downto 0));
- end Count10UpDn;
- architecture Behavioral of Count10UpDn is
- component BCD7seg
- Port (A : in STD_LOGIC_VECTOR (3 downto 0);
- Y : out STD_LOGIC_VECTOR (6 downto 0));
- end component;
- signal Q0T,Q1T : STD_LOGIC_VECTOR (3 downto 0):="0000";
- signal X : STD_LOGIC_VECTOR (3 downto 0);
- signal xx : STD_LOGIC_VECTOR (9 downto 0);
- signal modc : STD_LOGIC_VECTOR (26 downto 0):="000000000000000000000000000";
- signal sent : STD_LOGIC_VECTOR (1 downto 0):="00";
- signal tick : STD_LOGIC ;
- begin
- process(tick,CLR)
- begin
- if CLR='1' then
- Q0T <= "0000";
- Q1T <= "0000";
- elsif tick'event and tick='1' then
- if DIR='1' then
- if Q0T>=9 then
- Q0T <="0000";
- Q1T <= Q1T+1;
- if Q1T>=9 then
- Q1T <= "0000";
- end if;
- else Q0T <= Q0T+1;
- end if;
- elsif DIR='0' then
- if Q0T<=0 then
- Q0T <="1001";
- if Q1T <=0 then
- Q1T <= "1001";
- else Q1T <=Q1T-1;
- end if;
- else Q0T <= Q0T-1;
- end if;
- end if;
- end if;
- end process;
- ---------------clock 1hz----------------
- process(p127)
- begin
- if p127'event and p127 ='1' then
- if modc<=12499999 then
- modc <= modc+1;
- tick <= '0';
- else
- tick <='1';
- modc<= "000000000000000000000000000";
- end if;
- end if;
- end process;
- -----------------------------------------
- ----------------mod clock----------------
- process(p127)
- begin
- if p127'event and p127 ='1' then
- if xx>1000 then xx<= "0000000000";
- if sent>=4 then sent<="00";
- else sent<=sent+1;
- end if;
- else xx<=xx+1;
- end if;
- end if;
- end process;
- -------------- mux2to1 --------------
- X<= Q0T when sent ="01" else
- Q1T when sent ="10" else
- "0000";
- -------------- 1to2decoder-------------
- com <= "1110" when sent ="01" else
- "1101" when sent ="10" else
- "1111" ;
- --------------7segment-------------
- Display : BCD7seg port map(A=>X,Y=>Y);
- end Behavioral;
Add Comment
Please, Sign In to add comment