source: firmware/FTM/clock/FTM_clk_gen.vhd@ 10697

Last change on this file since 10697 was 10227, checked in by weitzel, 14 years ago
first version of FTM firmware including ethernet and FTU interface; still some debugging needed
File size: 3.6 KB
Line 
1----------------------------------------------------------------------------------
2-- Company: ETH Zurich, Institute for Particle Physics
3-- Engineer: Q. Weitzel
4--
5-- Create Date: February 28, 2011
6-- Design Name:
7-- Module Name: FTM_clk_gen - Behavioral
8-- Project Name:
9-- Target Devices:
10-- Tool versions:
11-- Description: interface to different DCMs and clk dividers for FMU board
12-- add here more DCMs if needed
13--
14-- Dependencies:
15--
16-- Revision:
17-- Revision 0.01 - File Created
18-- Additional Comments:
19--
20----------------------------------------------------------------------------------
21library IEEE;
22use IEEE.STD_LOGIC_1164.ALL;
23use IEEE.STD_LOGIC_ARITH.ALL;
24use IEEE.STD_LOGIC_UNSIGNED.ALL;
25
26---- Uncomment the following library declaration if instantiating
27---- any Xilinx primitives in this code.
28--library UNISIM;
29--use UNISIM.VComponents.all;
30
31entity FTM_clk_gen is
32 Port (
33 clk : IN STD_LOGIC;
34 rst : IN STD_LOGIC;
35 clk_1 : OUT STD_LOGIC;
36 clk_50 : OUT STD_LOGIC;
37 clk_250 : OUT STD_LOGIC;
38 clk_250_ps : OUT STD_LOGIC;
39 ready : OUT STD_LOGIC
40 );
41end FTM_clk_gen;
42
43architecture Behavioral of FTM_clk_gen is
44
45 component FTM_dcm_40M_to_50M
46 port(
47 CLKIN_IN : in std_logic;
48 RST_IN : in std_logic;
49 CLKFX_OUT : out std_logic;
50 LOCKED_OUT : out std_logic
51 );
52 end component;
53
54 component FTM_dcm_40M_to_250M
55 port(
56 CLKIN_IN : in std_logic;
57 RST_IN : in std_logic;
58 CLKFX_OUT : out std_logic;
59 CLKFX180_OUT : out std_logic;
60 LOCKED_OUT : out std_logic
61 );
62 end component;
63
64 component Clock_Divider
65 port(
66 clock_in : IN STD_LOGIC;
67 clock_out : OUT STD_LOGIC
68 );
69 end component;
70
71 signal clk_1M_sig : std_logic;
72 signal clk_50M_sig : std_logic;
73 signal clk_250M_sig : std_logic;
74 signal clk_250M_ps_sig : std_logic;
75
76 signal dcm1_locked : std_logic;
77 signal dcm2_locked : std_logic;
78
79begin
80
81 Inst_FTM_dcm_40M_to_50M : FTM_dcm_40M_to_50M
82 port map(
83 CLKIN_IN => clk,
84 RST_IN => rst,
85 CLKFX_OUT => clk_50M_sig,
86 LOCKED_OUT => dcm1_locked
87 );
88
89 Inst_FTM_dcm_40M_to_250M : FTM_dcm_40M_to_250M
90 port map(
91 CLKIN_IN => clk,
92 RST_IN => rst,
93 CLKFX_OUT => clk_250M_sig,
94 CLKFX180_OUT => clk_250M_ps_sig,
95 LOCKED_OUT => dcm2_locked
96 );
97
98 Inst_Clock_Divider : Clock_Divider
99 port map (
100 clock_in => clk_50M_sig,
101 clock_out => clk_1M_sig
102 );
103
104 clk_1 <= clk_1M_sig;
105 clk_50 <= clk_50M_sig;
106 clk_250 <= clk_250M_sig;
107 clk_250_ps <= clk_250M_ps_sig;
108
109 ready <= dcm1_locked and dcm2_locked;
110
111end Behavioral;
112
113----------------------------------------------------------------------------------
114
115library IEEE;
116use IEEE.STD_LOGIC_1164.ALL;
117use IEEE.STD_LOGIC_ARITH.ALL;
118use IEEE.STD_LOGIC_UNSIGNED.ALL;
119
120library ftm_definitions;
121USE ftm_definitions.ftm_array_types.all;
122USE ftm_definitions.ftm_constants.all;
123
124entity Clock_Divider is
125 generic(
126 divider : integer := INT_CLK_FREQUENCY_1 / LOW_FREQUENCY
127 );
128 port(
129 clock_in : in std_logic;
130 clock_out : out std_logic := '0'
131 );
132end entity Clock_Divider;
133
134architecture RTL of Clock_Divider is
135
136begin
137
138 process (clock_in)
139 variable Z: integer range 0 to divider - 1;
140 begin
141 if rising_edge(clock_in) then
142 if (Z < divider - 1) then
143 Z := Z + 1;
144 else
145 Z := 0;
146 end if;
147 if (Z = 0) then
148 clock_out <= '1';
149 end if;
150 if (Z = divider / 2) then
151 clock_out <= '0';
152 end if;
153 end if;
154 end process;
155
156end architecture RTL;
Note: See TracBrowser for help on using the repository browser.