COUNT24.VHD
上传用户:dgjihui88
上传日期:2013-07-23
资源大小:43k
文件大小:1k
源码类别:

VHDL/FPGA/Verilog

开发平台:

MultiPlatform

  1. Library IEEE;
  2. Use IEEE.std_logic_1164.all;
  3. Use ieee.std_logic_unsigned.all;
  4. Use IEEE.std_logic_arith.all;
  5. Entity count24 is
  6.   Port(carry: in std_logic;--from 1Hz input clock or the full_index of second/minute
  7.          Rst: in std_logic;--initialization
  8.        times: out integer range 0 to 23;
  9.         full: out std_logic);-- carry_out signal
  10. end count24;
  11. architecture arch of count24 is
  12. --input:rst,carry
  13. --output:times,full
  14.   signal time : integer range 0 to 23;
  15. begin
  16. ----process for 60 seconds counting
  17.   process (rst,carry)
  18.   begin
  19.     if rst='1' then time <= 0; full<='0';
  20.     elsif rising_edge(carry) then
  21.           if time=23 then time<=0;--over 24
  22.                           full<='1';--carry_out signal
  23.                      else time<= time + 1;--keep counting 
  24.                           full<='0';
  25.           end if;     
  26.     end if;
  27.   end process;
  28.   times<=time;
  29. end arch;