1 |
13 |
arif_endro |
-- $Id: fm.vhdl,v 1.2 2005-02-21 06:54:44 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 |
|
|
-- Last update : 2005/01/03
|
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 |
|
|
use IEEE.STD_LOGIC_arith.ALL;
|
45 |
|
|
|
46 |
|
|
entity fm is
|
47 |
|
|
port (
|
48 |
|
|
CLK : in bit;
|
49 |
|
|
RESET : in bit;
|
50 |
|
|
FMIN : in bit_vector (07 downto 0);
|
51 |
|
|
DMOUT : out bit_vector (11 downto 0)
|
52 |
|
|
);
|
53 |
|
|
end fm;
|
54 |
|
|
|
55 |
|
|
architecture structural of fm is
|
56 |
|
|
component nco
|
57 |
|
|
port (
|
58 |
|
|
clock : in bit;
|
59 |
|
|
clear : in bit;
|
60 |
|
|
input_nco : in bit_vector (17 downto 0);
|
61 |
|
|
offset : in bit_vector (17 downto 0);
|
62 |
|
|
output_nco : out bit_vector (07 downto 0)
|
63 |
|
|
);
|
64 |
|
|
end component;
|
65 |
|
|
component loop_filter
|
66 |
|
|
port (
|
67 |
|
|
input_loop : in bit_vector (07 downto 0);
|
68 |
|
|
clock : in bit;
|
69 |
|
|
output_loop : out bit_vector (11 downto 0);
|
70 |
|
|
clear : in bit
|
71 |
|
|
);
|
72 |
|
|
end component;
|
73 |
|
|
component phase_detector
|
74 |
|
|
port (
|
75 |
|
|
clock : in bit;
|
76 |
|
|
signal_input : in bit_vector (07 downto 0);
|
77 |
|
|
signal_nco : in bit_vector (07 downto 0);
|
78 |
|
|
phase_output : out bit_vector (07 downto 0)
|
79 |
|
|
);
|
80 |
|
|
end component;
|
81 |
|
|
component fir
|
82 |
|
|
port (
|
83 |
|
|
clock : in bit;
|
84 |
|
|
clear : in bit;
|
85 |
|
|
fir_in : in bit_vector (11 downto 0);
|
86 |
|
|
dmout : out bit_vector (11 downto 0)
|
87 |
|
|
);
|
88 |
|
|
end component;
|
89 |
|
|
-- internal signal
|
90 |
|
|
signal loop_out : bit_vector (11 downto 0);
|
91 |
|
|
signal input_nco : bit_vector (17 downto 0);
|
92 |
|
|
signal offset : bit_vector (17 downto 0);
|
93 |
|
|
signal output_nco : bit_vector (07 downto 0);
|
94 |
|
|
signal phase_output : bit_vector (07 downto 0);
|
95 |
|
|
|
96 |
|
|
begin
|
97 |
|
|
-- offset values 1/16 equ B"000100000000000000" <18,0,u>
|
98 |
|
|
offset (17) <= '0' ;
|
99 |
|
|
offset (16) <= '0' ;
|
100 |
|
|
offset (15) <= '0' ;
|
101 |
|
|
offset (14) <= '1' ;
|
102 |
|
|
offset (13) <= '0' ;
|
103 |
|
|
offset (12) <= '0' ;
|
104 |
|
|
offset (11) <= '0' ;
|
105 |
|
|
offset (10) <= '0' ;
|
106 |
|
|
offset (9) <= '0' ;
|
107 |
|
|
offset (8) <= '0' ;
|
108 |
|
|
offset (7) <= '0' ;
|
109 |
|
|
offset (6) <= '0' ;
|
110 |
|
|
offset (5) <= '0' ;
|
111 |
|
|
offset (4) <= '0' ;
|
112 |
|
|
offset (3) <= '0' ;
|
113 |
|
|
offset (2) <= '0' ;
|
114 |
|
|
offset (1) <= '0' ;
|
115 |
|
|
offset (0) <= '0' ;
|
116 |
|
|
|
117 |
|
|
-- The constant that have great effect on the loop
|
118 |
|
|
-- it's a 1/16 divider it's has 5 step to change the output state with little
|
119 |
|
|
-- oscillation. it's can be make good shape by reducing the constant e.g 1/32
|
120 |
|
|
-- but it's has slower response time than 1/16 about 2 times e.g approx 10 step
|
121 |
|
|
-- to change the output state. if it's too big e.g (1) then there is no output
|
122 |
|
|
-- only oscilation if it's is to small e.g (1/1024) then output never return to
|
123 |
|
|
-- zero, so it's didn't change the output state.
|
124 |
|
|
|
125 |
|
|
input_nco (17) <= loop_out(11); -- 1
|
126 |
|
|
input_nco (16) <= loop_out(11); -- 1/2
|
127 |
|
|
input_nco (15) <= loop_out(11); -- 1/4
|
128 |
|
|
input_nco (14) <= loop_out(11); -- 1/8
|
129 |
|
|
input_nco (13) <= loop_out(11); -- 1/16
|
130 |
|
|
input_nco (12) <= loop_out(10); -- 1/32
|
131 |
|
|
input_nco (11) <= loop_out(09); -- 1/64
|
132 |
|
|
input_nco (10) <= loop_out(08); -- 1/128
|
133 |
|
|
input_nco (09) <= loop_out(07); -- 1/256
|
134 |
|
|
input_nco (08) <= loop_out(06); -- 1/512
|
135 |
|
|
input_nco (07) <= loop_out(05); -- 1/1024
|
136 |
|
|
input_nco (06) <= loop_out(04);
|
137 |
|
|
input_nco (05) <= loop_out(03);
|
138 |
|
|
input_nco (04) <= loop_out(02);
|
139 |
|
|
input_nco (03) <= loop_out(01);
|
140 |
|
|
input_nco (02) <= loop_out(00);
|
141 |
|
|
input_nco (01) <= loop_out(11);
|
142 |
|
|
input_nco (00) <= loop_out(11);
|
143 |
|
|
|
144 |
|
|
-- end divider
|
145 |
|
|
mynco : nco
|
146 |
|
|
port map (
|
147 |
|
|
clock => CLK,
|
148 |
|
|
clear => RESET,
|
149 |
|
|
input_nco => input_nco,
|
150 |
|
|
offset => offset,
|
151 |
|
|
output_nco ( 7 downto 0) => output_nco
|
152 |
|
|
);
|
153 |
|
|
myfir : fir
|
154 |
|
|
port map (
|
155 |
|
|
clock => CLK,
|
156 |
|
|
clear => RESET,
|
157 |
|
|
fir_in => loop_out,
|
158 |
|
|
dmout (11 downto 0) => DMOUT
|
159 |
|
|
);
|
160 |
|
|
myphase : phase_detector
|
161 |
|
|
port map (
|
162 |
|
|
clock => CLK,
|
163 |
|
|
signal_input => FMIN,
|
164 |
|
|
signal_nco => output_nco,
|
165 |
|
|
phase_output ( 7 downto 0) => phase_output
|
166 |
|
|
);
|
167 |
|
|
myloop : loop_filter
|
168 |
|
|
port map (
|
169 |
|
|
input_loop => phase_output,
|
170 |
|
|
clock => CLK,
|
171 |
|
|
output_loop (11 downto 0) => loop_out,
|
172 |
|
|
clear => RESET
|
173 |
|
|
);
|
174 |
|
|
end structural;
|