fpq.vhd

来自「ISP实验分频器源程序」· VHDL 代码 · 共 100 行

VHD
100
字号
------------------------------------------------------------------------------------ Company: -- Engineer: -- -- Create Date:    14:55:07 03/08/2009 -- Design Name: -- Module Name:    fpq - Behavioral -- Project Name: -- Target Devices: -- Tool versions: -- Description: ---- Dependencies: ---- Revision: -- Revision 0.01 - File Created-- Additional Comments: ------------------------------------------------------------------------------------library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;---- Uncomment the following library declaration if instantiating---- any Xilinx primitives in this code.--library UNISIM;--use UNISIM.VComponents.all;entity fpq is    Port ( clk : in  STD_LOGIC;           reset : in  STD_LOGIC;            clk_1MHz : out  STD_LOGIC;           clk_1KHz : out  STD_LOGIC;           clk_1Hz : out  STD_LOGIC);end fpq;architecture Behavioral of fpq is 
 signal count_MHz:std_logic_vector(7 downto 0);
 signal count_KHz:std_logic_vector(17 downto 0);
 signal count_Hz:std_logic_vector(26 downto 0); signal MHz,KHz,Hz:std_logic;begin
gen_MHz:process (clk,reset) is
begin
if reset='0' then
MHz<='0';count_MHz<=(others=>'0');
elsif rising_edge(clk) then
count_MHz<=count_MHz+'1';
if count_MHz>=40 then
count_MHz<=(others=>'0');
end if;
if count_MHz>=20 then
 MHz<='1';
 else
 MHz<='0';
 end if;
 end if;
 end process gen_MHz;
 clk_1MHz<=MHz;
 
 gen_KHz:process (clk,reset) isbeginif reset='0' thenKHz<='0';count_KHz<=(others=>'0');elsif rising_edge(clk) thencount_KHz<=count_KHz+'1';if count_KHz>=40000 then
count_KHz<=(others=>'0');end if;if count_KHz>=20000 then KHz<='1'; elseKHz<='0'; end if; end if; end process gen_KHz;
 clk_1KHz<=KHz;
 
gen_Hz:process (clk,reset) isbeginif reset='0' thenHz<='0';count_Hz<=(others=>'0');elsif rising_edge(clk) thencount_Hz<=count_Hz+'1';if count_Hz>=40000000 then
count_Hz<=(others=>'0');end if;if count_Hz>=20000000 then Hz<='1'; elseHz<='0'; end if; end if;
 end process gen_Hz;clk_1Hz<=Hz;end Behavioral;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?