-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdivfreq.vhd
executable file
·50 lines (41 loc) · 1.14 KB
/
divfreq.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
-- ****************************************************
-- Program: divfreq.vhd
-- Description: Frequency divider from clock of 50 MHz to 1Hz, 60/135, 1 KHz
-- Input: clk (extern clock)
-- Output: freq_1Hz
-- Author: Wellington, Paulo e Rodrigo
-- Date: 16/06/2021
-- State: No errors known
-- ****************************************************
-- Counter is 25000000 to 1 Hz (1 sample)
-- Counter is 416667 to +/- 60Hz (to 135 samples) = 3087
-- Counter is 208373 to +/- 120 Hz
-- counter is 25000 to 1 kHz
-- Counter is 1000 to 25KHz
-- Counter is 125 to 200KHz
-- Counter is 50 to 500KHz
-- Counter is 25 to 1MHz
-- Remove Counter to 25 MHz
library ieee;
use ieee.std_logic_1164.all;
entity divfreq is
port(
clk: in std_logic;
ref: out std_logic);
end divfreq;
architecture divfreq_arch of divfreq is
signal count: natural:=0; -- range 0 to 3090
signal ot: std_logic:='0';
begin
ref<=ot;
divfreq_logic: process(clk)
begin
if (clk'event and clk='1') then
count<=count+1;
if (count=416667) then
count<=0;
ot<=not ot;
end if;
end if;
end process;
end divfreq_arch;