clockdiv4.vhd

来自「speaker code,for thinx cpld」· VHDL 代码 · 共 37 行

VHD
37
字号
library ieee;
use ieee.std_logic_1164.all;

entity clockdiv4 is
  port(
    clockin : in std_logic;
    clockout : out std_logic );
end clockdiv4;

architecture behavioural of clockdiv4 is

signal clock_int : std_logic;

begin

clockout <= clock_int;

  count : process(clockin)
    constant MAX : integer := 8000000;
    variable counter : integer range 0 to max;
  begin
    if rising_edge(clockin) then
      if counter = MAX then
        if clock_int = '0' then
        	clock_int <= '1';
        else
        	clock_int <= '0';
        end if;
        counter := 0;
      else
      	counter := counter + 1;
      end if;
    end if;
  end process count;
end behavioural;

⌨️ 快捷键说明

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