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

Subversion Repositories esoc

[/] [esoc/] [trunk/] [Sources/] [logixa/] [esoc_port_mal_clock.vhd] - Blame information for rev 56

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 42 lmaarsen
--------------------------------------------------------------------------------
2 53 lmaarsen
--
3
-- This VHDL file was generated by EASE/HDL 7.4 Revision 4 from HDL Works B.V.
4
--
5
-- Ease library  : work
6
-- HDL library   : work
7
-- Host name     : S212065
8
-- User name     : df768
9
-- Time stamp    : Tue Aug 19 08:05:18 2014
10
--
11
-- Designed by   : L.Maarsen
12
-- Company       : LogiXA
13
-- Project info  : eSoC
14
--
15 42 lmaarsen
--------------------------------------------------------------------------------
16 53 lmaarsen
 
17 42 lmaarsen
--------------------------------------------------------------------------------
18
-- Object        : Entity work.esoc_port_mal_clock
19
-- Last modified : Mon Apr 14 12:49:01 2014.
20
--------------------------------------------------------------------------------
21
 
22
 
23
 
24
library ieee, std, work;
25
use ieee.std_logic_1164.all;
26
use std.textio.all;
27
use ieee.numeric_std.all;
28
use work.package_esoc_configuration.all;
29
 
30
entity esoc_port_mal_clock is
31
  port(
32
    clk_control    : in     STD_LOGIC;
33
    clk_rgmii      : out    std_logic;
34
    clk_rgmii_125m : in     std_logic;
35
    clk_rgmii_25m  : in     std_logic;
36
    clk_rgmii_2m5  : in     std_logic;
37
    ena_10         : in     STD_LOGIC;
38
    eth_mode       : in     STD_LOGIC;
39
    reset          : in     STD_LOGIC;
40
    set_10         : out    STD_LOGIC := '0'; -- '0'
41
    set_1000       : out    STD_LOGIC := '0');
42
end entity esoc_port_mal_clock;
43
 
44
--------------------------------------------------------------------------------
45
-- Object        : Architecture work.esoc_port_mal_clock.esoc_port_mal_clock
46
-- Last modified : Mon Apr 14 12:49:01 2014.
47
--------------------------------------------------------------------------------
48
 
49
 
50
architecture esoc_port_mal_clock of esoc_port_mal_clock is
51
 
52
constant clk_off: std_logic := '1';
53
constant clk_on: std_logic := '0';
54
 
55
signal clk125m: std_logic;
56
signal clk125_stop: std_logic;
57
signal clk125_stopped: std_logic;
58
signal clk125_stop_reg: std_logic_vector(1 downto 0);
59
signal clk125_stopped_reg: std_logic_vector(1 downto 0);
60
constant clk125m_reset: std_logic := clk_off;
61
 
62
signal clk25m: std_logic;
63
signal clk25_stop: std_logic;
64
signal clk25_stopped: std_logic;
65
signal clk25_stop_reg: std_logic_vector(1 downto 0);
66
signal clk25_stopped_reg: std_logic_vector(1 downto 0);
67
constant clk25m_reset: std_logic := clk_on;
68
 
69
signal clk2m5: std_logic;
70
signal clk2m5_stop: std_logic;
71
signal clk2m5_stopped: std_logic;
72
signal clk2m5_stop_reg: std_logic_vector(1 downto 0);
73
signal clk2m5_stopped_reg: std_logic_vector(1 downto 0);
74
constant clk2m5_reset: std_logic := clk_off;
75
 
76
type speeds is (none, s10m, s100m, s1000m);
77
signal speed_setting: speeds;
78
signal speed_current: speeds;
79
 
80
type switch_states is (idle, wait_for_stop);
81
signal switch_state: switch_states;
82
 
83
begin
84
 
85
-- Define unused speed control signals
86
set_10 <= '0';
87
set_1000 <= '0';
88
 
89
-- Create speed select signals
90
speed_setting <=  s1000m when reset = '1'  else
91
                  s10m when eth_mode = '0' and ena_10 = '1' else
92
                  s100m when eth_mode = '0' and ena_10 = '0' else
93
                  s1000m;
94
 
95
-- Clock control 125MHz
96
clk125ctl:  process (clk_rgmii_125m, reset)
97
            begin
98
                if reset = '1' then
99
                    clk125_stop_reg <= (others => clk125m_reset);
100
 
101
                -- synchronize stop input command with clock   
102
                elsif clk_rgmii_125m'event and clk_rgmii_125m = '1' then
103
                    clk125_stop_reg <= clk125_stop & clk125_stop_reg(clk125_stop_reg'high downto 1);
104
 
105
                end if;
106
            end process clk125ctl;
107
 
108
            -- use synchronized stop commando to switch on/off clock, reply with stopped indication
109
            clk125m         <= clk_rgmii_125m when clk125_stop_reg(0) = '0' else '1';
110
            clk125_stopped  <= clk125_stop_reg(0);
111
 
112
-- Clock control 25MHz
113
clk25ctl:  process (clk_rgmii_25m, reset)
114
            begin
115
                if reset = '1' then
116
                    clk25_stop_reg <= (others => clk25m_reset);
117
 
118
                -- synchronize stop input command with clock       
119
                elsif clk_rgmii_25m'event and clk_rgmii_25m = '1' then
120
                    clk25_stop_reg <= clk25_stop & clk25_stop_reg(clk25_stop_reg'high downto 1);
121
 
122
                end if;
123
            end process clk25ctl;
124
 
125
            -- use synchronized stop commando to switch on/off clock, reply with stopped indication
126
            clk25m        <= clk_rgmii_25m when clk25_stop_reg(0) = '0' else '1';
127
            clk25_stopped <= clk25_stop_reg(0);
128
 
129
-- Clock control 2.5MHz
130
clk2m5ctl:  process (clk_rgmii_2m5, reset)
131
            begin
132
                if reset = '1' then
133
                    clk2m5_stop_reg <= (others => clk2m5_reset);
134
 
135
                -- synchronize stop input command with clock       
136
                elsif clk_rgmii_2m5'event and clk_rgmii_2m5 = '1' then
137
                    clk2m5_stop_reg <= clk2m5_stop & clk2m5_stop_reg(clk2m5_stop_reg'high downto 1);
138
 
139
                end if;
140
            end process clk2m5ctl;
141
 
142
            -- use synchronized stop commando to switch on/off clock, reply with stopped indication
143
            clk2m5 <= clk_rgmii_2m5 when clk2m5_stop_reg(0) = '0' else '1';
144
            clk2m5_stopped <= clk2m5_stop_reg(0);
145
 
146
-- Clock switch
147
clkswitch:  process (clk_control, reset)
148
            begin
149
                if reset = '1' then
150
                    clk125_stop        <= clk125m_reset;
151
                    clk25_stop         <= clk25m_reset;
152
                    clk2m5_stop        <= clk2m5_reset;
153
                    clk125_stopped_reg <= (others => clk125m_reset);
154
                    clk25_stopped_reg  <= (others => clk25m_reset);
155
                    clk2m5_stopped_reg <= (others => clk2m5_reset);
156
                    speed_current      <= s1000m;
157
                    switch_state       <= idle;
158
 
159
                elsif clk_control'event and clk_control = '1' then
160
                    -- store speed setting for change detection
161
                    speed_current <= speed_setting;
162
 
163
                    -- synchronize stopped indication with clock 
164
                    clk125_stopped_reg <= clk125_stopped & clk125_stopped_reg(clk125_stopped_reg'high downto 1);
165
                    clk25_stopped_reg <= clk25_stopped & clk25_stopped_reg(clk25_stopped_reg'high downto 1);
166
                    clk2m5_stopped_reg <= clk2m5_stopped & clk2m5_stopped_reg(clk2m5_stopped_reg'high downto 1);
167
 
168
                    case switch_state is
169
                        when idle   =>          -- Send stop command to all clock source when setting changed
170
                                                if speed_current /= speed_setting then
171
                                                    clk125_stop <= '1';
172
                                                    clk25_stop <= '1';
173
                                                    clk2m5_stop <= '1';
174
                                                    switch_state <= wait_for_stop;
175
                                                end if;
176
 
177
                        when wait_for_stop =>   -- When setting is stable, wait for stopped indication of all clock sources
178
                                                if speed_current /= speed_setting then
179
                                                    NULL;
180
 
181
                                                elsif clk125_stopped_reg(0) = '1' and clk25_stopped_reg(0) = '1' and clk2m5_stopped_reg(0) = '1' then
182
                                                    -- enable only the required clock source by deasserting its stop input
183
                                                    if speed_setting = s10m then
184
                                                        clk2m5_stop <= '0';
185
                                                    elsif speed_setting = s100m then
186
                                                        clk25_stop <= '0';
187
                                                    elsif speed_setting = s1000m then
188
                                                        clk125_stop <= '0';
189
                                                    end if;
190
 
191
                                                    switch_state <= idle;
192
                                                end if;
193
 
194
                        when others       =>    switch_state <= idle;
195
                    end case;
196
 
197
                end if;
198
            end process clkswitch;
199
 
200
            -- Drive RGMII interface clock, push/force clock onto clock network (if not done by tool)
201
            clk_rgmii <= clk125m and clk25m and clk2m5;
202
            --clk_rgmii <= clk_rgmii_125m;
203
 
204
end architecture esoc_port_mal_clock ; -- of esoc_port_mal_clock

powered by: WebSVN 2.1.0

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