timer30bit.vhd

来自「基于spartan3e的LCD显示程序,可直接将其bit文件烧写到spartan」· VHDL 代码 · 共 178 行

VHD
178
字号
------------------------------------------------------------------------------------ Company: -- Engineer: -- -- Create Date:    09:28:16 06/26/2006 -- Design Name: -- Module Name:    timer30bit - 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 timer30bit is    Port ( timerout : out  STD_LOGIC;           Clock : in  STD_LOGIC;           Enable : in  STD_LOGIC;           Data : in  STD_LOGIC_VECTOR (29 downto 0);           Load : in  STD_LOGIC);end timer30bit;architecture Behavioral of timer30bit is	signal tmr0 :std_logic_vector (29 downto 0);
	signal precarry29:std_logic;
	signal precarry23:std_logic;	signal precarry15:std_logic;	signal precarry7:std_logic;	signal precarry7a:std_logic;	signal timerout_ctrl:std_logic;	begin
 process( Clock ) is  begin		if Clock'event and Clock = '1' then      if Reset = '1' then-------------------reset        tmr0(7 downto 0) <= (others=>'0');		elsif Load = '1' or (precarry29 = '1' and precarry23= '1' and precarry15= '1' and precarry7= '1') then-----------------preset and auto-load		  tmr0(7 downto 0) <= Data(7 downto 0);      elsif Enable= '1' then-------------------enable		  tmr0(7 downto 0)<= tmr0(7 downto 0)+1;      end if;		end if;  end process;  --timer0---15:8 process( Clock ) is  begin		if Clock'event and Clock = '1' then      if Reset = '1' then-------------------reset        tmr0(15 downto 8) <= (others=>'0');		elsif Load = '1' or (precarry27 = '1' and precarry23= '1' and precarry15= '1' and precarry7= '1') then-----------------preset and auto-load		  tmr0(15 downto 8) <= Data(15 downto 8);      elsif Enable= '1' and precarry7= '1' then-------------------enable		  tmr0(15 downto 8)<= tmr0(15 downto 8)+1;      end if;		end if;  end process; --timer0---23:16 process( Clock ) is  begin		if Clock'event and Clock = '1' then      if Reset = '1' then-------------------reset        tmr0(23 downto 16) <= (others=>'0');		elsif Load = '1' or (precarry27 = '1' and precarry23= '1' and precarry15= '1' and precarry7= '1') then-----------------preset and auto-load		  tmr0(23 downto 16) <= Data(23 to 16);      elsif Enable= '1' and precarry15 = '1' and precarry7= '1' then-------------------enable		  tmr0(23 downto 16)<= tmr0(23 downto 16)+1;      end if;		end if;  end process;  --timer0---29:24 process( Clock ) is  begin		if Clock'event and Clock = '1' then      if Reset = '1' then-------------------reset        tmr0(29 downto 24) <= (others=>'0');		elsif Load = '1' or (precarry27 = '1' and precarry23= '1' and precarry15= '1' and precarry7= '1') then-----------------preset and auto-load		  tmr0(29 downto 24) <= Data(29 downto 24);      elsif Enable= '1' and precarry23= '1' and precarry15= '1' and precarry7= '1' then-------------------enable		  tmr0(29 downto 24)<= tmr0(29 downto 24)+1;      end if;		end if;		  end process;  --Precarry---precarry29/precarry23/precarry15/precarry7 process( Clock) is  begin		if Clock'event and Clock = '1' then      		if Reset = '1' then-------------------reset        precarry29 <= '0';		elsif tmr0(29 downto 24) = "1111" then		  precarry279 <= '1';		else		  precarry29 <= '0';				end if;				if Reset = '1' then-------------------reset        precarry23 <= '0';		elsif tmr0(23 downto 16) = "11111111"  then		  precarry23 <= '1';		else		  precarry23 <= '0';		end if;				if Reset = '1' then-------------------reset        precarry15 <= '0';		elsif tmr0(15 downto 8) = "11111111"  then		  precarry15 <= '1';		else		  precarry15 <= '0';		end if;				if Reset = '1' then-------------------reset        precarry7 <= '0';		elsif tmr0(7 downto 0) = "11111110"  then		  precarry7 <= '1';		else		  precarry7 <= '0';		end if;				if Reset = '1' then-------------------reset        precarry7a <= '0';		elsif tmr0(7 downto 0) = "11111101"  then		  precarry7a <= '1';		else		  precarry7a <= '0';		end if;				end if;  end process;  process( Clock ) is  begin		if Clock'event and Clock = '1' then      if Reset = '1' or timeout_ctrl='1' then-------------------reset        timerout <= '0';		elsif precarry7a = '1' then		  timerout<= '1';      end if;		end if;  end process;
   process( Clock ) is  begin		if Clock'event and Clock = '1' then      if Reset = '1' then-------------------reset        timerout_ctrl <= '0';		else		  timerout_ctrl<= timerout;      end if;		end if;  end process;  
  
  end Behavioral;

⌨️ 快捷键说明

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