source: firmware/FTM/clock/FTM_clk_gen_2.vhd@ 13248

Last change on this file since 13248 was 10366, checked in by weitzel, 14 years ago
FTM trigger manager from MCSE added; DCM arrangement changed; changes in FTM ethernet module
File size: 3.9 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_2 - 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_2 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_2;
42
43architecture Behavioral of FTM_clk_gen_2 is
44
45 component FTM_dcm_40M_to_50M_2
46 port(
47 CLKIN_IN : in std_logic;
48 RST_IN : in std_logic;
49 CLKFX_OUT : out std_logic;
50 CLKIN_IBUFG_OUT : out std_logic;
51 LOCKED_OUT : out std_logic
52 );
53 end component;
54
55 component FTM_dcm_50M_to_250M_2
56 port(
57 CLKIN_IN : in std_logic;
58 RST_IN : in std_logic;
59 CLKFX_OUT : out std_logic;
60 CLKFX180_OUT : out std_logic;
61 CLK0_OUT : out std_logic;
62 LOCKED_OUT : out std_logic
63 );
64 end component;
65
66 component Clock_Divider
67 port(
68 clock_in : IN STD_LOGIC;
69 clock_out : OUT STD_LOGIC
70 );
71 end component;
72
73 signal clk_1M_sig : std_logic;
74 signal clk_50M_sig : std_logic;
75 signal clk_250M_sig : std_logic;
76 signal clk_250M_ps_sig : std_logic;
77
78 signal clk_50M_int_sig : std_logic;
79 signal dcm1_ibufg_sig : std_logic;
80
81 signal dcm1_locked : std_logic;
82 signal dcm2_locked : std_logic;
83
84begin
85
86 Inst_FTM_dcm_40M_to_50M_2 : FTM_dcm_40M_to_50M_2
87 port map(
88 CLKIN_IN => clk,
89 RST_IN => rst,
90 CLKFX_OUT => clk_50M_int_sig,
91 CLKIN_IBUFG_OUT => dcm1_ibufg_sig,
92 LOCKED_OUT => dcm1_locked
93 );
94
95 Inst_FTM_dcm_50M_to_250M_2 : FTM_dcm_50M_to_250M_2
96 port map(
97 CLKIN_IN => clk_50M_int_sig,
98 RST_IN => rst,
99 CLKFX_OUT => clk_250M_sig,
100 CLKFX180_OUT => clk_250M_ps_sig,
101 CLK0_OUT => clk_50M_sig,
102 LOCKED_OUT => dcm2_locked
103 );
104
105 Inst_Clock_Divider : Clock_Divider
106 port map (
107 clock_in => clk_50M_sig,
108 clock_out => clk_1M_sig
109 );
110
111 clk_1 <= clk_1M_sig;
112 clk_50 <= clk_50M_sig;
113 clk_250 <= clk_250M_sig;
114 clk_250_ps <= clk_250M_ps_sig;
115
116 ready <= dcm1_locked and dcm2_locked;
117
118end Behavioral;
119
120----------------------------------------------------------------------------------
121
122library IEEE;
123use IEEE.STD_LOGIC_1164.ALL;
124use IEEE.STD_LOGIC_ARITH.ALL;
125use IEEE.STD_LOGIC_UNSIGNED.ALL;
126
127library ftm_definitions;
128USE ftm_definitions.ftm_array_types.all;
129USE ftm_definitions.ftm_constants.all;
130
131entity Clock_Divider is
132 generic(
133 divider : integer := INT_CLK_FREQUENCY_1 / LOW_FREQUENCY
134 );
135 port(
136 clock_in : in std_logic;
137 clock_out : out std_logic := '0'
138 );
139end entity Clock_Divider;
140
141architecture RTL of Clock_Divider is
142
143begin
144
145 process (clock_in)
146 variable Z: integer range 0 to divider - 1;
147 begin
148 if rising_edge(clock_in) then
149 if (Z < divider - 1) then
150 Z := Z + 1;
151 else
152 Z := 0;
153 end if;
154 if (Z = 0) then
155 clock_out <= '1';
156 end if;
157 if (Z = divider / 2) then
158 clock_out <= '0';
159 end if;
160 end if;
161 end process;
162
163end architecture RTL;
Note: See TracBrowser for help on using the repository browser.