Frequency.vhd
资源名称:Music.rar [点击查看]
上传用户:jnxfc1
上传日期:2022-08-09
资源大小:363k
文件大小:3k
源码类别:
VHDL/FPGA/Verilog
开发平台:
Others
- ---------------------------------------------------------------------------------------------------
- --*************************************************************************************************
- -- CreateDate : 2007-07-12
- -- ModifData : 2007-07-12
- -- Description : Frequency
- -- Author : Explorer01
- -- Version : V1.0
- --*************************************************************************************************
- ---------------------------------------------------------------------------------------------------
- -- VHDL library Declarations
- LIBRARY IEEE;
- USE IEEE.std_logic_1164.ALL;
- USE IEEE.STD_LOGIC_ARITH.ALL;
- USE IEEE.std_logic_unsigned.ALL;
- ---------------------------------------------------------------------------------------------------
- ---------------------------------------------------------------------------------------------------
- -- The Entity Declarations
- ENTITY Frequency IS
- PORT
- (
- RESET: IN STD_LOGIC;
- GCLKP1: IN STD_LOGIC;
- GCLKP2: IN STD_LOGIC;
- ClockScan: OUT STD_LOGIC;
- CLK: OUT STD_LOGIC;
- CLK8Hz: OUT STD_LOGIC
- );
- END Frequency;
- ---------------------------------------------------------------------------------------------------
- ---------------------------------------------------------------------------------------------------
- -- The Architecture of Entity Declarations
- ARCHITECTURE Frequency_arch OF Frequency IS
- --Clock:
- SIGNAL Period1uS, Period1mS: STD_LOGIC;
- BEGIN
- -------------------------------------------------
- -- GCLK: 1MHz(1uS), 1KHz(1mS), 1Hz(1S)
- PROCESS( RESET, GCLKP1, Period1uS, Period1mS )
- VARIABLE Count : STD_LOGIC_VECTOR(3 DOWNTO 0);
- VARIABLE Count1 : STD_LOGIC_VECTOR(9 DOWNTO 0);
- VARIABLE Count2 : STD_LOGIC_VECTOR(9 DOWNTO 0);
- BEGIN
- ------------------------------------
- --Period: 1uS (Period1uS <= GCLKP1; )
- IF( GCLKP1'EVENT AND GCLKP1='1' ) THEN
- IF( Count>"1000" ) THEN Count := "0000";
- ELSE Count := Count + 1;
- END IF;
- Period1uS <= Count(3);
- END IF;
- ------------------------------------
- --Period: 1mS
- IF( Period1uS'EVENT AND Period1uS='1' ) THEN
- IF( Count1>"1111100110" ) THEN Count1 := "0000000000";
- ELSE Count1 := Count1 + 1;
- END IF;
- Period1mS <= Count1(9);
- CLK <= Count1(0); -- 1uS
- END IF;
- ------------------------------------
- --Period: 1S (1111100110: 998)
- IF( Period1mS'EVENT AND Period1mS='1' ) THEN
- IF( Count2>"1111100110" ) THEN Count2 := "0000000000";
- ELSE Count2 := Count2 + 1;
- END IF;
- -- Period1S <= Count2(9);
- ------------------------------------
- ClockScan <= Count2(1);
- CLK8Hz <= Count2(7);
- END IF;
- END PROCESS;
- END Frequency_arch;