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

powered by: WebSVN 2.1.0

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