1 |
2 |
dimamali |
------------------------------------------------------------------------------
|
2 |
|
|
-- This file is a part of the GRLIB VHDL IP LIBRARY
|
3 |
|
|
-- Copyright (C) 2003, Gaisler Research
|
4 |
|
|
--
|
5 |
|
|
-- This program is free software; you can redistribute it and/or modify
|
6 |
|
|
-- it under the terms of the GNU General Public License as published by
|
7 |
|
|
-- the Free Software Foundation; either version 2 of the License, or
|
8 |
|
|
-- (at your option) any later version.
|
9 |
|
|
--
|
10 |
|
|
-- This program is distributed in the hope that it will be useful,
|
11 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
|
|
-- GNU General Public License for more details.
|
14 |
|
|
--
|
15 |
|
|
-- You should have received a copy of the GNU General Public License
|
16 |
|
|
-- along with this program; if not, write to the Free Software
|
17 |
|
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18 |
|
|
-------------------------------------------------------------------------------
|
19 |
|
|
|
20 |
|
|
library ieee;
|
21 |
|
|
use ieee.std_logic_1164.all;
|
22 |
|
|
-- pragma translate_off
|
23 |
|
|
library altera_mf;
|
24 |
|
|
use altera_mf.altpll;
|
25 |
|
|
library grlib;
|
26 |
|
|
use grlib.stdlib.all;
|
27 |
|
|
-- pragma translate_on
|
28 |
|
|
library techmap;
|
29 |
|
|
use techmap.gencomp.all;
|
30 |
|
|
|
31 |
|
|
entity altera_eek_clkgen is
|
32 |
|
|
generic (
|
33 |
|
|
clk0_mul : integer := 1;
|
34 |
|
|
clk0_div : integer := 1;
|
35 |
|
|
clk1_mul : integer := 1;
|
36 |
|
|
clk1_div : integer := 1;
|
37 |
|
|
clk_freq : integer := 25000);
|
38 |
|
|
port (
|
39 |
|
|
inclk0 : in std_ulogic;
|
40 |
|
|
clk0 : out std_ulogic;
|
41 |
|
|
clk0x3 : out std_ulogic;
|
42 |
|
|
clksel : in std_logic_vector(1 downto 0);
|
43 |
|
|
locked : out std_ulogic);
|
44 |
|
|
end;
|
45 |
|
|
|
46 |
|
|
architecture rtl of altera_eek_clkgen is
|
47 |
|
|
|
48 |
|
|
component altpll
|
49 |
|
|
generic (
|
50 |
|
|
intended_device_family : string := "CycloneIII" ;
|
51 |
|
|
operation_mode : string := "NORMAL" ;
|
52 |
|
|
compensate_clock : string := "clock0";
|
53 |
|
|
inclk0_input_frequency : positive;
|
54 |
|
|
width_clock : positive := 6;
|
55 |
|
|
clk0_multiply_by : positive := 1;
|
56 |
|
|
clk0_divide_by : positive := 1;
|
57 |
|
|
clk1_multiply_by : positive := 1;
|
58 |
|
|
clk1_divide_by : positive := 1;
|
59 |
|
|
clk2_multiply_by : positive := 1;
|
60 |
|
|
clk2_divide_by : positive := 1;
|
61 |
|
|
clk3_multiply_by : positive := 1;
|
62 |
|
|
clk3_divide_by : positive := 1
|
63 |
|
|
);
|
64 |
|
|
port (
|
65 |
|
|
inclk : in std_logic_vector(1 downto 0);
|
66 |
|
|
clkena : in std_logic_vector(5 downto 0);
|
67 |
|
|
clk : out std_logic_vector(width_clock-1 downto 0);
|
68 |
|
|
locked : out std_logic
|
69 |
|
|
);
|
70 |
|
|
end component;
|
71 |
|
|
|
72 |
|
|
signal clkena : std_logic_vector (5 downto 0);
|
73 |
|
|
signal clkout : std_logic_vector (4 downto 0);
|
74 |
|
|
signal inclk : std_logic_vector (1 downto 0);
|
75 |
|
|
|
76 |
|
|
constant clk_period : integer := 1000000000/clk_freq;
|
77 |
|
|
constant CLK0_MUL3X : integer := clk0_mul * 3;
|
78 |
|
|
constant CLK1_MUL3X : integer := clk1_mul * 3;
|
79 |
|
|
|
80 |
|
|
constant VERSION : integer := 1;
|
81 |
|
|
|
82 |
|
|
attribute syn_keep : boolean;
|
83 |
|
|
attribute syn_keep of clkout : signal is true;
|
84 |
|
|
|
85 |
|
|
begin
|
86 |
|
|
|
87 |
|
|
clkena(5 downto 4) <= (others => '0');
|
88 |
|
|
clkena(0) <= '1';
|
89 |
|
|
clkena(1) <= '1';
|
90 |
|
|
clkena(2) <= '1';
|
91 |
|
|
clkena(3) <= '1';
|
92 |
|
|
|
93 |
|
|
inclk <= '0' & inclk0;
|
94 |
|
|
|
95 |
|
|
clk_select: process (clkout, clksel)
|
96 |
|
|
begin -- process clk_select
|
97 |
|
|
case clksel is
|
98 |
|
|
when "00" => clk0 <= clkout(0); clk0x3 <= clkout(1);
|
99 |
|
|
when "01" => clk0 <= clkout(2); clk0x3 <= clkout(3);
|
100 |
|
|
when others => clk0 <= '0'; clk0x3 <= '0';
|
101 |
|
|
end case;
|
102 |
|
|
end process clk_select;
|
103 |
|
|
|
104 |
|
|
altpll0 : altpll
|
105 |
|
|
generic map (
|
106 |
|
|
intended_device_family => "Cyclone III",
|
107 |
|
|
operation_mode => "NO_COMPENSATION", inclk0_input_frequency => clk_period,
|
108 |
|
|
width_clock => 5, compensate_clock => "CLK1",
|
109 |
|
|
clk0_multiply_by => clk0_mul, clk0_divide_by => clk0_div,
|
110 |
|
|
clk1_multiply_by => CLK0_MUL3X, clk1_divide_by => clk0_div,
|
111 |
|
|
clk2_multiply_by => clk1_mul, clk2_divide_by => clk1_div,
|
112 |
|
|
clk3_multiply_by => CLK1_MUL3X, clk3_divide_by => clk1_div)
|
113 |
|
|
port map (clkena => clkena, inclk => inclk,
|
114 |
|
|
clk => clkout, locked => locked);
|
115 |
|
|
|
116 |
|
|
-- pragma translate_off
|
117 |
|
|
bootmsg : report_version
|
118 |
|
|
generic map (
|
119 |
|
|
"clkgen_cycloneiii" & ": altpll lcd/vga clock generator, version " & tost(VERSION)
|
120 |
|
|
);
|
121 |
|
|
-- pragma translate_on
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
end;
|
125 |
|
|
|
126 |
|
|
|