⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 divider.vhd

📁 用VHDL编写的实现二、三、四分频
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity divider is
  port(clk,clr:in std_logic;
       div2,div3,div4:out std_logic);
end entity;

architecture behavior of divider is
  signal pos_cnt:std_logic_vector(1 downto 0);
  signal neg_cnt:std_logic_vector(1 downto 0);
  signal count:std_logic_vector(1 downto 0);
begin
  process(clk,clr)
  begin
    if clr='1' then count<="00";
    elsif clk'event and clk='1' then
      if count="11" then
         count<="00";
      else
         count<=count+1;
      end if;
    end if;
  end process;
  process(clk,clr)
  begin
    if clr='1' then pos_cnt<="00";
    elsif clk'event and clk='1' then
       case pos_cnt is
         when "00" => pos_cnt<="01";
         when "01" => pos_cnt<="10";
         when "10" => pos_cnt<="00";
         when others=> pos_cnt<="00";
       end case;
    end if;
  end process;
  process(clk,clr)
  begin
    if clr='1' then neg_cnt<="00";
    elsif clk'event and clk='0' then
       case neg_cnt is
         when "00" => neg_cnt<="01";
         when "01" => neg_cnt<="10";
         when "10" => neg_cnt<="00";
         when others => neg_cnt<="00";
       end case;
    end if;
  end process;
  div2<=count(0);
  div3<=not(pos_cnt(1) or neg_cnt(1));
  div4<=count(1);
end; 

⌨️ 快捷键说明

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