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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [techmap/] [stratixiii/] [alt/] [apll.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
LIBRARY ieee;
2
USE ieee.std_logic_1164.all;
3
 
4
LIBRARY altera_mf;
5
USE altera_mf.all;
6
 
7
ENTITY apll IS
8
  generic (
9
    freq    : integer := 200;
10
    mult    : integer := 8;
11
    div     : integer := 5;
12
    rskew   : integer := 0
13
  );
14
        PORT
15
        (
16
    areset      : IN STD_LOGIC  := '0';
17
    inclk0      : IN STD_LOGIC  := '0';
18
    phasestep   : IN STD_LOGIC  := '0';
19
    phaseupdown : IN STD_LOGIC  := '0';
20
    scanclk     : IN STD_LOGIC  := '1';
21
                c0              : OUT STD_LOGIC ;
22
                c1              : OUT STD_LOGIC ;
23
                c2              : OUT STD_LOGIC ;
24
                c3              : OUT STD_LOGIC ;
25
                c4              : OUT STD_LOGIC ;
26
                locked          : OUT STD_LOGIC;
27
                phasedone               : OUT STD_LOGIC
28
        );
29
END apll;
30
 
31
 
32
ARCHITECTURE SYN OF apll IS
33
 
34
        SIGNAL sub_wire0        : STD_LOGIC_VECTOR (9 DOWNTO 0);
35
        SIGNAL sub_wire1        : STD_LOGIC ;
36
        SIGNAL sub_wire2        : STD_LOGIC ;
37
        SIGNAL sub_wire3        : STD_LOGIC ;
38
        SIGNAL sub_wire4        : STD_LOGIC ;
39
        SIGNAL sub_wire5        : STD_LOGIC ;
40
        SIGNAL sub_wire6        : STD_LOGIC ;
41
        SIGNAL sub_wire7        : STD_LOGIC ;
42
        SIGNAL sub_wire8        : STD_LOGIC_VECTOR (1 DOWNTO 0);
43
        SIGNAL sub_wire9_bv     : BIT_VECTOR (0 DOWNTO 0);
44
        SIGNAL sub_wire9        : STD_LOGIC_VECTOR (0 DOWNTO 0);
45
 
46
  signal phasecounter_reg : std_logic_vector(3 downto 0);
47
  attribute syn_keep : boolean;
48
  attribute syn_keep of phasecounter_reg : signal is true;
49
  attribute syn_preserve : boolean;
50
  attribute syn_preserve of phasecounter_reg : signal is true;
51
 
52
  constant period : integer := 1000000/freq;
53
 
54
  function set_phase(freq : in integer) return string is
55
    variable s : string(1 to 4) := "0000";
56
    variable f,r : integer;
57
  begin
58
    f := freq;
59
    while f /= 0 loop
60
      r := f mod 10;
61
      case r is
62
        when 0 => s := "0" & s(1 to 3);
63
        when 1 => s := "1" & s(1 to 3);
64
        when 2 => s := "2" & s(1 to 3);
65
        when 3 => s := "3" & s(1 to 3);
66
        when 4 => s := "4" & s(1 to 3);
67
        when 5 => s := "5" & s(1 to 3);
68
        when 6 => s := "6" & s(1 to 3);
69
        when 7 => s := "7" & s(1 to 3);
70
        when 8 => s := "8" & s(1 to 3);
71
        when 9 => s := "9" & s(1 to 3);
72
        when others =>
73
      end case;
74
      f := f / 10;
75
    end loop;
76
    return s;
77
  end function;
78
 
79
  type phasevec is array (1 to 3) of string(1 to 4);
80
  type phasevecarr is array (10 to 21) of phasevec;
81
 
82
  constant phasearr : phasevecarr := (
83
          ("2500", "5000", "7500"), ("2273", "4545", "6818"),   -- 100 & 110 MHz
84
          ("2083", "4167", "6250"), ("1923", "3846", "5769"),   -- 120 & 130 MHz
85
          ("1786", "3571", "5357"), ("1667", "3333", "5000"),   -- 140 & 150 MHz
86
          ("1563", "3125", "4688"), ("1471", "2941", "4412"),   -- 160 & 170 MHz
87
          ("1389", "2778", "4167"), ("1316", "2632", "3947"),   -- 180 & 190 MHz
88
          ("1250", "2500", "3750"), ("1190", "2381", "3571"));  -- 200 & 210 MHz
89
 
90
  --constant pshift_90  : string := phasearr((freq*mult)/(10*div))(1);
91
  constant pshift_90  : string := set_phase(100000/((4*freq*mult)/(10*div)));
92
  --constant pshift_180 : string := phasearr((freq*mult)/(10*div))(2);
93
  constant pshift_180 : string := set_phase(100000/((2*freq*mult)/(10*div)));
94
  --constant pshift_270 : string := phasearr((freq*mult)/(10*div))(3);
95
  constant pshift_270 : string := set_phase(300000/((4*freq*mult)/(10*div)));
96
 
97
  constant pshift_rclk : string := set_phase(rskew);
98
 
99
        COMPONENT altpll
100
        GENERIC (
101
                bandwidth_type          : STRING;
102
                clk0_divide_by          : NATURAL;
103
                clk0_duty_cycle         : NATURAL;
104
                clk0_multiply_by                : NATURAL;
105
                clk0_phase_shift                : STRING;
106
                clk1_divide_by          : NATURAL;
107
                clk1_duty_cycle         : NATURAL;
108
                clk1_multiply_by                : NATURAL;
109
                clk1_phase_shift                : STRING;
110
                clk2_divide_by          : NATURAL;
111
                clk2_duty_cycle         : NATURAL;
112
                clk2_multiply_by                : NATURAL;
113
                clk2_phase_shift                : STRING;
114
                clk3_divide_by          : NATURAL;
115
                clk3_duty_cycle         : NATURAL;
116
                clk3_multiply_by                : NATURAL;
117
                clk3_phase_shift                : STRING;
118
                clk4_divide_by          : NATURAL;
119
                clk4_duty_cycle         : NATURAL;
120
                clk4_multiply_by                : NATURAL;
121
                clk4_phase_shift                : STRING;
122
                compensate_clock                : STRING;
123
                inclk0_input_frequency          : NATURAL;
124
                intended_device_family          : STRING;
125
                lpm_hint                : STRING;
126
                lpm_type                : STRING;
127
                operation_mode          : STRING;
128
                pll_type                : STRING;
129
                port_activeclock                : STRING;
130
                port_areset             : STRING;
131
                port_clkbad0            : STRING;
132
                port_clkbad1            : STRING;
133
                port_clkloss            : STRING;
134
                port_clkswitch          : STRING;
135
                port_configupdate               : STRING;
136
                port_fbin               : STRING;
137
                port_fbout              : STRING;
138
                port_inclk0             : STRING;
139
                port_inclk1             : STRING;
140
                port_locked             : STRING;
141
                port_pfdena             : STRING;
142
                port_phasecounterselect         : STRING;
143
                port_phasedone          : STRING;
144
                port_phasestep          : STRING;
145
                port_phaseupdown                : STRING;
146
                port_pllena             : STRING;
147
                port_scanaclr           : STRING;
148
                port_scanclk            : STRING;
149
                port_scanclkena         : STRING;
150
                port_scandata           : STRING;
151
                port_scandataout                : STRING;
152
                port_scandone           : STRING;
153
                port_scanread           : STRING;
154
                port_scanwrite          : STRING;
155
                port_clk0               : STRING;
156
                port_clk1               : STRING;
157
                port_clk2               : STRING;
158
                port_clk3               : STRING;
159
                port_clk4               : STRING;
160
                port_clk5               : STRING;
161
                port_clk6               : STRING;
162
                port_clk7               : STRING;
163
                port_clk8               : STRING;
164
                port_clk9               : STRING;
165
                port_clkena0            : STRING;
166
                port_clkena1            : STRING;
167
                port_clkena2            : STRING;
168
                port_clkena3            : STRING;
169
                port_clkena4            : STRING;
170
                port_clkena5            : STRING;
171
                self_reset_on_loss_lock         : STRING;
172
                using_fbmimicbidir_port         : STRING;
173
                width_clock             : NATURAL
174
        );
175
        PORT (
176
                        phasestep       : IN STD_LOGIC ;
177
                        phaseupdown     : IN STD_LOGIC ;
178
                        inclk   : IN STD_LOGIC_VECTOR (1 DOWNTO 0);
179
                        phasecounterselect      : IN STD_LOGIC_VECTOR (3 DOWNTO 0);
180
                        locked  : OUT STD_LOGIC ;
181
                        phasedone       : OUT STD_LOGIC ;
182
                        areset  : IN STD_LOGIC ;
183
                        clk     : OUT STD_LOGIC_VECTOR (9 DOWNTO 0);
184
                        scanclk : IN STD_LOGIC
185
        );
186
        END COMPONENT;
187
 
188
BEGIN
189
        sub_wire9_bv(0 DOWNTO 0) <= "0";
190
        sub_wire9    <= To_stdlogicvector(sub_wire9_bv);
191
        sub_wire5    <= sub_wire0(4);
192
        sub_wire4    <= sub_wire0(3);
193
        sub_wire3    <= sub_wire0(2);
194
        sub_wire2    <= sub_wire0(1);
195
        sub_wire1    <= sub_wire0(0);
196
        c0    <= sub_wire1;
197
        c1    <= sub_wire2;
198
        c2    <= sub_wire3;
199
        c3    <= sub_wire4;
200
        c4    <= sub_wire5;
201
        locked    <= sub_wire6;
202
        sub_wire7    <= inclk0;
203
        sub_wire8    <= sub_wire9(0 DOWNTO 0) & sub_wire7;
204
 
205
  -- quartus bug, cant be constant
206
  process(scanclk)
207
  begin
208
    if rising_edge(scanclk) then
209
      phasecounter_reg <= "0110"; --phasecounter;
210
    end if;
211
  end process;
212
 
213
        altpll_component : altpll
214
        GENERIC MAP (
215
                bandwidth_type => "AUTO",
216
                clk0_divide_by => div,--5,
217
                clk0_duty_cycle => 50,
218
                clk0_multiply_by => mult,--8,
219
                clk0_phase_shift => "0",
220
                clk1_divide_by => div,--5,
221
                clk1_duty_cycle => 50,
222
                clk1_multiply_by => mult,--8,
223
                clk1_phase_shift => pshift_90,--"1250",
224
                clk2_divide_by => div,--5,
225
                clk2_duty_cycle => 50,
226
                clk2_multiply_by => mult,--8,
227
                clk2_phase_shift => pshift_180,--"2500",
228
                clk3_divide_by => div,--5,
229
                clk3_duty_cycle => 50,
230
                clk3_multiply_by => mult,--8,
231
                clk3_phase_shift => pshift_270,--"3750",
232
                clk4_divide_by => div,
233
                clk4_duty_cycle => 50,
234
                clk4_multiply_by => mult,
235
                clk4_phase_shift => pshift_rclk,--"0",
236
                compensate_clock => "CLK0",
237
                inclk0_input_frequency => period,--8000,
238
                intended_device_family => "Stratix III",
239
                lpm_hint => "CBX_MODULE_PREFIX=apll",
240
                lpm_type => "altpll",
241
                operation_mode => "NORMAL",
242
                pll_type => "AUTO",
243
                port_activeclock => "PORT_UNUSED",
244
                port_areset => "PORT_USED",
245
                port_clkbad0 => "PORT_UNUSED",
246
                port_clkbad1 => "PORT_UNUSED",
247
                port_clkloss => "PORT_UNUSED",
248
                port_clkswitch => "PORT_UNUSED",
249
                port_configupdate => "PORT_UNUSED",
250
                port_fbin => "PORT_UNUSED",
251
                port_fbout => "PORT_UNUSED",
252
                port_inclk0 => "PORT_USED",
253
                port_inclk1 => "PORT_UNUSED",
254
                port_locked => "PORT_USED",
255
                port_pfdena => "PORT_UNUSED",
256
                port_phasecounterselect => "PORT_USED",
257
                port_phasedone => "PORT_USED",
258
                port_phasestep => "PORT_USED",
259
                port_phaseupdown => "PORT_USED",
260
                port_pllena => "PORT_UNUSED",
261
                port_scanaclr => "PORT_UNUSED",
262
                port_scanclk => "PORT_USED",
263
                port_scanclkena => "PORT_UNUSED",
264
                port_scandata => "PORT_UNUSED",
265
                port_scandataout => "PORT_UNUSED",
266
                port_scandone => "PORT_UNUSED",
267
                port_scanread => "PORT_UNUSED",
268
                port_scanwrite => "PORT_UNUSED",
269
                port_clk0 => "PORT_USED",
270
                port_clk1 => "PORT_USED",
271
                port_clk2 => "PORT_USED",
272
                port_clk3 => "PORT_USED",
273
                port_clk4 => "PORT_USED",
274
                port_clk5 => "PORT_UNUSED",
275
                port_clk6 => "PORT_UNUSED",
276
                port_clk7 => "PORT_UNUSED",
277
                port_clk8 => "PORT_UNUSED",
278
                port_clk9 => "PORT_UNUSED",
279
                port_clkena0 => "PORT_UNUSED",
280
                port_clkena1 => "PORT_UNUSED",
281
                port_clkena2 => "PORT_UNUSED",
282
                port_clkena3 => "PORT_UNUSED",
283
                port_clkena4 => "PORT_UNUSED",
284
                port_clkena5 => "PORT_UNUSED",
285
                self_reset_on_loss_lock => "ON",
286
                using_fbmimicbidir_port => "OFF",
287
                width_clock => 10
288
        )
289
        PORT MAP (
290
                phasestep => phasestep,
291
                phaseupdown => phaseupdown,
292
                inclk => sub_wire8,
293
                phasecounterselect => phasecounter_reg,
294
                areset => areset,
295
                scanclk => scanclk,
296
                clk => sub_wire0,
297
                locked => sub_wire6,
298
    phasedone => phasedone
299
        );
300
 
301
END SYN;
302
 

powered by: WebSVN 2.1.0

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