OpenCores
URL https://opencores.org/ocsvn/mcu8/mcu8/trunk

Subversion Repositories mcu8

[/] [mcu8/] [trunk/] [src/] [EXAMPLES/] [generic_freq_div.vhd] - Blame information for rev 24

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimo
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
 
5
 
6
entity generic_freq_div is
7
  generic( factor : integer := 1000); --factor have to be an even number
8
  port( clk_in : in std_logic;
9
        clk : out std_logic );
10
end generic_freq_div;
11
 
12
 
13
architecture behavioral of generic_freq_div is
14
begin
15
div: process(clk_in)
16
    variable count : integer range 0 to factor/2-1;
17
    variable tmp : std_logic := '0';
18
  begin
19
    if clk_in'event and clk_in='1' then
20
      if count>=factor/2-1 then
21
        count := 0;
22
        tmp := not tmp;
23
      else
24
        count := count + 1;
25
      end if;
26
    end if;
27
    clk <= tmp;
28
  end process;
29
end behavioral;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.