-
Notifications
You must be signed in to change notification settings - Fork 3
/
adpll.vhd
173 lines (126 loc) · 3.88 KB
/
adpll.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
-- ****************************************************
-- Program: pfd.vhd
-- Description: DivFreq and PFD circuits to test
-- Input: clk_sys,dco_out - reference clock (50 MHz) and DCO output
-- Output: up,down - Phase Frequency Detector outputs
--
-- Author: Wellington W. F. Sarmento, Paulo de T. C. Pequeno e Rodrigo Ciarlini
-- Date: 24/08/2021
-- State: not tested
-- ****************************************************
library ieee;
use ieee.std_logic_1164.all;
library work;
entity adpll IS
port
(
clk_sys : in std_logic;
idclock : in std_logic;
kclock : in std_logic;
b_in : in std_logic;--pino para proposito de teste
divfreq_in : in std_logic;--pino para proposito de teste
-- kcounter_carr_out: out std_logic; --pino para proposito de teste
-- kcounter_borr_out: out std_logic; --pino para proposito de teste
adpll_out : out std_logic;
adpll_sine_out: out natural range 0 to 255
);
end adpll;
architecture adpll_arch of adpll is
-- Frequency divider to create 60Hz to Ref Frequency
component divfreq
port(
clk : in std_logic;
ref : out std_logic
);
end component;
-- Sine Generator
component sine_wave_gen
port(
clk : in std_logic;
dataout : out natural range 0 to 255
);
end component;
-- Phase Detector
component pfd
port(
a : in std_logic;
b : in std_logic;
out_up : out std_logic;
out_down : out std_logic
);
end component;
-- Loop Filter
component k_counter
port (
in_up: in std_logic;
in_down: in std_logic;
-- downup: in std_logic;
kclock: in std_logic; -- M multiple of Fo
carry: out std_logic;
borrow: out std_logic);
end component;
-- Controlled Oscillator
component dco
port(
carry, borrow, clock : in std_logic;
dco_out : out std_logic
);
end component;
signal link_divfreq_sine,link_up_kcounter,link_down_kcounter,link_carr_dco,link_borr_dco,link_dco_out : std_logic; --sdownup
signal test_in_divfreq,test_pfd_up_out,test_pfd_down_out,test_kcounter_carr_out,test_kcounter_borr_out: std_logic; -- sinais para proposito de teste
signal test_dataout : natural range 0 to 255; -- sinais para proposito de teste
begin
adpll_out <= link_dco_out;
-- Frequency divider to create smallest frequency from 50MHz frequency signal(ex.; 200KHz,60Hz,120Hz)
divfreq_inst : divfreq
port map(
clk => clk_sys,
ref => link_divfreq_sine
);
test_in_divfreq<= divfreq_in OR link_divfreq_sine; -- pin to test divfreq
-- Sine Wave Generator
sine_wave_gen_inst: sine_wave_gen
port map(
clk => link_divfreq_sine,
dataout => test_dataout --link_swg_pfd,
);
-- Phase Detector
pfd_inst : pfd
port map(
a => test_in_divfreq, -- link_swg_pfd,
b => link_dco_out, -- Saida do DCO entra em PFD -- b_in,
out_up => link_up_kcounter,
out_down => link_down_kcounter
);
-- test_pfd_up_out<=link_up_kcounter;
-- test_pfd_down_out<=link_down_kcounter;
--- sdownup<= link_down_kcounter OR link_up_kcounter;
-- -- Loop Filter
k_counter_inst : k_counter
port map(
in_up => link_up_kcounter,
in_down => link_down_kcounter,
-- downup => sdownup,
kclock => kclock,
carry => link_carr_dco,
borrow => link_borr_dco
);
-- test_kcounter_carr_out<=link_carr_dco;
-- test_kcounter_borr_out<=link_borr_dco;
-- -- Controlled Oscillator
dco_inst :dco
port map(
carry => link_carr_dco,
borrow => link_borr_dco,
clock => idclock,
dco_out => link_dco_out
);
-- -- Sine Wave Generator
--
-- sine_wave_gen_inst2: sine_wave_gen
-- port map(
-- clk => link_dco_out,
-- dataout => adpll_sine_out,
--
-- );
end adpll_arch;