1 |
16 |
arif_endro |
-- $Id: fm.vhdl,v 1.4 2005-03-12 04:18:37 arif_endro Exp $
|
2 |
2 |
arif_endro |
-------------------------------------------------------------------------------
|
3 |
|
|
-- Title : FM core component
|
4 |
|
|
-- Project : FM Receiver
|
5 |
|
|
-------------------------------------------------------------------------------
|
6 |
|
|
-- File : fm.vhdl
|
7 |
|
|
-- Author : "Arif E. Nugroho" <arif_endro@yahoo.com>
|
8 |
|
|
-- Created : 2004/12/06
|
9 |
16 |
arif_endro |
-- Last update : 2005/03/11
|
10 |
13 |
arif_endro |
-- Simulators :
|
11 |
2 |
arif_endro |
-- Synthesizers:
|
12 |
|
|
-- Target :
|
13 |
|
|
-------------------------------------------------------------------------------
|
14 |
|
|
-- Description : FM core component to connect all other component
|
15 |
|
|
-------------------------------------------------------------------------------
|
16 |
13 |
arif_endro |
-- Copyright (C) 2004 Arif E. Nugroho
|
17 |
2 |
arif_endro |
-- This VHDL design file is an open design; you can redistribute it and/or
|
18 |
|
|
-- modify it and/or implement it after contacting the author
|
19 |
|
|
-------------------------------------------------------------------------------
|
20 |
13 |
arif_endro |
-------------------------------------------------------------------------------
|
21 |
|
|
--
|
22 |
|
|
-- THIS SOURCE FILE MAY BE USED AND DISTRIBUTED WITHOUT RESTRICTION
|
23 |
|
|
-- PROVIDED THAT THIS COPYRIGHT STATEMENT IS NOT REMOVED FROM THE FILE AND THAT
|
24 |
|
|
-- ANY DERIVATIVE WORK CONTAINS THE ORIGINAL COPYRIGHT NOTICE AND THE
|
25 |
|
|
-- ASSOCIATED DISCLAIMER.
|
26 |
|
|
--
|
27 |
|
|
-------------------------------------------------------------------------------
|
28 |
|
|
--
|
29 |
|
|
-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
30 |
|
|
-- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
31 |
|
|
-- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
32 |
|
|
-- EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
33 |
|
|
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
34 |
|
|
-- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
35 |
|
|
-- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
36 |
|
|
-- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
37 |
|
|
-- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
38 |
|
|
-- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
39 |
|
|
--
|
40 |
|
|
-------------------------------------------------------------------------------
|
41 |
2 |
arif_endro |
|
42 |
|
|
library IEEE;
|
43 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
44 |
|
|
|
45 |
|
|
entity fm is
|
46 |
|
|
port (
|
47 |
|
|
CLK : in bit;
|
48 |
|
|
RESET : in bit;
|
49 |
|
|
FMIN : in bit_vector (07 downto 0);
|
50 |
|
|
DMOUT : out bit_vector (11 downto 0)
|
51 |
|
|
);
|
52 |
|
|
end fm;
|
53 |
|
|
|
54 |
|
|
architecture structural of fm is
|
55 |
|
|
component nco
|
56 |
|
|
port (
|
57 |
|
|
clock : in bit;
|
58 |
|
|
clear : in bit;
|
59 |
|
|
input_nco : in bit_vector (17 downto 0);
|
60 |
|
|
offset : in bit_vector (17 downto 0);
|
61 |
|
|
output_nco : out bit_vector (07 downto 0)
|
62 |
|
|
);
|
63 |
|
|
end component;
|
64 |
|
|
component loop_filter
|
65 |
|
|
port (
|
66 |
|
|
input_loop : in bit_vector (07 downto 0);
|
67 |
|
|
clock : in bit;
|
68 |
|
|
output_loop : out bit_vector (11 downto 0);
|
69 |
|
|
clear : in bit
|
70 |
|
|
);
|
71 |
|
|
end component;
|
72 |
|
|
component phase_detector
|
73 |
|
|
port (
|
74 |
|
|
clock : in bit;
|
75 |
|
|
signal_input : in bit_vector (07 downto 0);
|
76 |
|
|
signal_nco : in bit_vector (07 downto 0);
|
77 |
|
|
phase_output : out bit_vector (07 downto 0)
|
78 |
|
|
);
|
79 |
|
|
end component;
|
80 |
|
|
component fir
|
81 |
|
|
port (
|
82 |
|
|
clock : in bit;
|
83 |
|
|
clear : in bit;
|
84 |
|
|
fir_in : in bit_vector (11 downto 0);
|
85 |
|
|
dmout : out bit_vector (11 downto 0)
|
86 |
|
|
);
|
87 |
|
|
end component;
|
88 |
|
|
-- internal signal
|
89 |
|
|
signal loop_out : bit_vector (11 downto 0);
|
90 |
|
|
signal input_nco : bit_vector (17 downto 0);
|
91 |
|
|
signal offset : bit_vector (17 downto 0);
|
92 |
|
|
signal output_nco : bit_vector (07 downto 0);
|
93 |
|
|
signal phase_output : bit_vector (07 downto 0);
|
94 |
|
|
|
95 |
|
|
begin
|
96 |
|
|
-- offset values 1/16 equ B"000100000000000000" <18,0,u>
|
97 |
|
|
offset (17) <= '0' ;
|
98 |
|
|
offset (16) <= '0' ;
|
99 |
|
|
offset (15) <= '0' ;
|
100 |
|
|
offset (14) <= '1' ;
|
101 |
|
|
offset (13) <= '0' ;
|
102 |
|
|
offset (12) <= '0' ;
|
103 |
|
|
offset (11) <= '0' ;
|
104 |
|
|
offset (10) <= '0' ;
|
105 |
|
|
offset (9) <= '0' ;
|
106 |
|
|
offset (8) <= '0' ;
|
107 |
|
|
offset (7) <= '0' ;
|
108 |
|
|
offset (6) <= '0' ;
|
109 |
|
|
offset (5) <= '0' ;
|
110 |
|
|
offset (4) <= '0' ;
|
111 |
|
|
offset (3) <= '0' ;
|
112 |
|
|
offset (2) <= '0' ;
|
113 |
|
|
offset (1) <= '0' ;
|
114 |
|
|
offset (0) <= '0' ;
|
115 |
|
|
|
116 |
16 |
arif_endro |
-- The constant that have big effect on the PLL loop.
|
117 |
|
|
-- This constant have big effect on system response, high values. (e.g 1/16),
|
118 |
|
|
-- will make the system have fast response time (e.g. quickly change state).
|
119 |
|
|
-- Otherwise if low values applied to this (e.g 1/32) will make the system
|
120 |
|
|
-- little slow response time but have smooth look's. Change it's as you like
|
121 |
|
|
-- to see the effect's. ^_^
|
122 |
2 |
arif_endro |
|
123 |
|
|
input_nco (17) <= loop_out(11); -- 1
|
124 |
|
|
input_nco (16) <= loop_out(11); -- 1/2
|
125 |
|
|
input_nco (15) <= loop_out(11); -- 1/4
|
126 |
|
|
input_nco (14) <= loop_out(11); -- 1/8
|
127 |
|
|
input_nco (13) <= loop_out(11); -- 1/16
|
128 |
16 |
arif_endro |
input_nco (12) <= loop_out(11); -- 1/32
|
129 |
|
|
input_nco (11) <= loop_out(10); -- 1/64
|
130 |
|
|
input_nco (10) <= loop_out(09); -- 1/128
|
131 |
|
|
input_nco (09) <= loop_out(08); -- 1/256
|
132 |
|
|
input_nco (08) <= loop_out(07); -- 1/512
|
133 |
|
|
input_nco (07) <= loop_out(06); -- 1/1024
|
134 |
|
|
input_nco (06) <= loop_out(05);
|
135 |
|
|
input_nco (05) <= loop_out(04);
|
136 |
|
|
input_nco (04) <= loop_out(03);
|
137 |
|
|
input_nco (03) <= loop_out(02);
|
138 |
|
|
input_nco (02) <= loop_out(01);
|
139 |
|
|
input_nco (01) <= loop_out(00);
|
140 |
2 |
arif_endro |
input_nco (00) <= loop_out(11);
|
141 |
|
|
|
142 |
|
|
-- end divider
|
143 |
|
|
mynco : nco
|
144 |
|
|
port map (
|
145 |
|
|
clock => CLK,
|
146 |
|
|
clear => RESET,
|
147 |
|
|
input_nco => input_nco,
|
148 |
|
|
offset => offset,
|
149 |
|
|
output_nco ( 7 downto 0) => output_nco
|
150 |
|
|
);
|
151 |
|
|
myfir : fir
|
152 |
|
|
port map (
|
153 |
|
|
clock => CLK,
|
154 |
|
|
clear => RESET,
|
155 |
|
|
fir_in => loop_out,
|
156 |
|
|
dmout (11 downto 0) => DMOUT
|
157 |
|
|
);
|
158 |
|
|
myphase : phase_detector
|
159 |
|
|
port map (
|
160 |
|
|
clock => CLK,
|
161 |
|
|
signal_input => FMIN,
|
162 |
|
|
signal_nco => output_nco,
|
163 |
|
|
phase_output ( 7 downto 0) => phase_output
|
164 |
|
|
);
|
165 |
|
|
myloop : loop_filter
|
166 |
|
|
port map (
|
167 |
|
|
input_loop => phase_output,
|
168 |
|
|
clock => CLK,
|
169 |
|
|
output_loop (11 downto 0) => loop_out,
|
170 |
|
|
clear => RESET
|
171 |
|
|
);
|
172 |
|
|
end structural;
|