utils.vhd

来自「用VHDL硬件描述语言开发的miniUART接口IP Core,用户可以将其嵌入」· VHDL 代码 · 共 87 行

VHD
87
字号
library IEEE,STD;use IEEE.std_logic_1164.all;entity synchroniser is   port (      C1 : in std_logic;-- Asynchronous signal      C :  in std_logic;-- Clock      O :  out std_logic);-- Synchronised signalend synchroniser;architecture Behaviour of synchroniser is   signal C1A : std_logic;   signal C1S : std_logic;   signal R : std_logic;begin   RiseC1A : process(C1,R)   begin      if Rising_Edge(C1) then         C1A <= '1';      end if;      if (R = '1') then         C1A <= '0';      end if;   end process;   SyncP : process(C,R)   begin      if Rising_Edge(C) then         if (C1A = '1') then            C1S <= '1';         else C1S <= '0';         end if;         if (C1S = '1') then            R <= '1';         else R <= '0';         end if;      end if;      if (R = '1') then         C1S <= '0';      end if;   end process;   O <= C1S;end Behaviour;--------------------------------------------------------------------------------- Counter--    This counter is a parametrizable clock divider.--    The count value is the generic parameter Count.--    It is CE enabled. (it will count only if CE is high).--    When it overflow, it will emit a pulse on O. --    It can be reseted to 0. -------------------------------------------------------------------------------library IEEE,STD;use IEEE.std_logic_1164.all;entity Counter is  generic(Count: INTEGER range 0 to 65535); -- Count revolution  port (     Clk      : in  std_logic;  -- Clock     Reset    : in  std_logic;  -- Reset input     CE       : in  std_logic;  -- Chip Enable     O        : out std_logic); -- Outputend Counter;architecture Behaviour of Counter isbegin  counter : process(Clk,Reset)     variable Cnt : INTEGER range 0 to Count-1;  begin     if Reset = '1' then        Cnt := Count - 1;        O <= '0';     elsif Rising_Edge(Clk) then        if CE = '1' then           if Cnt = 0 then              O <= '1';              Cnt := Count - 1;           else              O <= '0';              Cnt := Cnt - 1;           end if;        else O <= '0';        end if;     end if;  end process;end Behaviour;

⌨️ 快捷键说明

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