1 |
23 |
arif_endro |
-- $Id: fir.vhdl,v 1.5 2008-06-26 06:16:04 arif_endro Exp $
|
2 |
2 |
arif_endro |
-------------------------------------------------------------------------------
|
3 |
|
|
-- Title : FIR Low pass filter
|
4 |
|
|
-- Project : FM Receiver
|
5 |
|
|
-------------------------------------------------------------------------------
|
6 |
|
|
-- File : fir.vhdl
|
7 |
|
|
-- Author : "Arif E. Nugroho" <arif_endro@yahoo.com>
|
8 |
|
|
-- Created : 2004/10/30
|
9 |
16 |
arif_endro |
-- Last update : 2005/03/11
|
10 |
12 |
arif_endro |
-- Simulators :
|
11 |
2 |
arif_endro |
-- Synthesizers:
|
12 |
|
|
-- Target :
|
13 |
|
|
-------------------------------------------------------------------------------
|
14 |
|
|
-- Description : FIR low pass filter
|
15 |
|
|
-------------------------------------------------------------------------------
|
16 |
12 |
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 |
12 |
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 fir is
|
46 |
|
|
port(
|
47 |
|
|
clock : in bit;
|
48 |
|
|
clear : in bit;
|
49 |
|
|
fir_in : in bit_vector (11 downto 0); -- <12,4,t>
|
50 |
|
|
dmout : out bit_vector (11 downto 0) -- <12,4,t>
|
51 |
|
|
);
|
52 |
|
|
end fir;
|
53 |
|
|
|
54 |
|
|
architecture structural of fir is
|
55 |
|
|
component adder_15bit
|
56 |
|
|
port (
|
57 |
|
|
addend_15bit : in bit_vector (14 downto 0);
|
58 |
|
|
augend_15bit : in bit_vector (14 downto 0);
|
59 |
|
|
adder15_output : out bit_vector (15 downto 0)
|
60 |
|
|
);
|
61 |
|
|
end component;
|
62 |
|
|
component adder_14bit
|
63 |
|
|
port (
|
64 |
|
|
addend_14bit : in bit_vector (13 downto 0);
|
65 |
|
|
augend_14bit : in bit_vector (13 downto 0);
|
66 |
|
|
adder14_output : out bit_vector (14 downto 0)
|
67 |
|
|
);
|
68 |
|
|
end component;
|
69 |
|
|
component adder_13bit
|
70 |
|
|
port (
|
71 |
|
|
addend_13bit : in bit_vector (12 downto 0);
|
72 |
|
|
augend_13bit : in bit_vector (12 downto 0);
|
73 |
|
|
adder13_output : out bit_vector (13 downto 0)
|
74 |
|
|
);
|
75 |
|
|
end component;
|
76 |
|
|
component adder_12bit
|
77 |
|
|
port (
|
78 |
|
|
addend_12bit : in bit_vector (11 downto 0);
|
79 |
|
|
augend_12bit : in bit_vector (11 downto 0);
|
80 |
|
|
adder12_output : out bit_vector (12 downto 0)
|
81 |
|
|
);
|
82 |
|
|
end component;
|
83 |
|
|
|
84 |
|
|
signal fir_out : bit_vector (11 downto 0);
|
85 |
|
|
signal fir_in_01 : bit_vector (11 downto 0);
|
86 |
|
|
signal fir_in_02 : bit_vector (11 downto 0);
|
87 |
|
|
signal fir_in_03 : bit_vector (11 downto 0);
|
88 |
|
|
signal fir_in_04 : bit_vector (11 downto 0);
|
89 |
|
|
signal fir_in_05 : bit_vector (11 downto 0);
|
90 |
|
|
signal fir_in_06 : bit_vector (11 downto 0);
|
91 |
|
|
signal fir_in_07 : bit_vector (11 downto 0);
|
92 |
|
|
signal fir_in_08 : bit_vector (11 downto 0);
|
93 |
|
|
signal fir_in_09 : bit_vector (11 downto 0);
|
94 |
|
|
signal fir_in_10 : bit_vector (11 downto 0);
|
95 |
|
|
signal fir_in_11 : bit_vector (11 downto 0);
|
96 |
|
|
signal fir_in_12 : bit_vector (11 downto 0);
|
97 |
|
|
signal fir_in_13 : bit_vector (11 downto 0);
|
98 |
|
|
signal fir_in_14 : bit_vector (11 downto 0);
|
99 |
|
|
signal fir_in_15 : bit_vector (11 downto 0);
|
100 |
|
|
signal fir_in_16 : bit_vector (11 downto 0);
|
101 |
|
|
signal result_adder01 : bit_vector (12 downto 0);
|
102 |
|
|
signal result_adder02 : bit_vector (12 downto 0);
|
103 |
|
|
signal result_adder03 : bit_vector (12 downto 0);
|
104 |
|
|
signal result_adder04 : bit_vector (12 downto 0);
|
105 |
|
|
signal result_adder05 : bit_vector (12 downto 0);
|
106 |
|
|
signal result_adder06 : bit_vector (12 downto 0);
|
107 |
|
|
signal result_adder07 : bit_vector (12 downto 0);
|
108 |
|
|
signal result_adder08 : bit_vector (12 downto 0);
|
109 |
|
|
signal result_adder09 : bit_vector (13 downto 0);
|
110 |
|
|
signal result_adder10 : bit_vector (13 downto 0);
|
111 |
|
|
signal result_adder11 : bit_vector (13 downto 0);
|
112 |
|
|
signal result_adder12 : bit_vector (13 downto 0);
|
113 |
|
|
signal result_adder13 : bit_vector (14 downto 0);
|
114 |
|
|
signal result_adder14 : bit_vector (14 downto 0);
|
115 |
|
|
signal result_adder15 : bit_vector (15 downto 0);
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
begin
|
119 |
|
|
fir_in_01 <= fir_in;
|
120 |
|
|
|
121 |
|
|
adder01 : adder_12bit
|
122 |
|
|
port map (
|
123 |
|
|
addend_12bit(11 downto 0) => fir_in_01,
|
124 |
|
|
augend_12bit(11 downto 0) => fir_in_02,
|
125 |
|
|
adder12_output => result_adder01
|
126 |
|
|
);
|
127 |
|
|
|
128 |
|
|
adder02 : adder_12bit
|
129 |
|
|
port map (
|
130 |
|
|
addend_12bit(11 downto 0) => fir_in_03,
|
131 |
|
|
augend_12bit(11 downto 0) => fir_in_04,
|
132 |
|
|
adder12_output => result_adder02
|
133 |
|
|
);
|
134 |
|
|
|
135 |
|
|
adder03 : adder_12bit
|
136 |
|
|
port map (
|
137 |
|
|
addend_12bit(11 downto 0) => fir_in_05,
|
138 |
|
|
augend_12bit(11 downto 0) => fir_in_06,
|
139 |
|
|
adder12_output => result_adder03
|
140 |
|
|
);
|
141 |
|
|
|
142 |
|
|
adder04 : adder_12bit
|
143 |
|
|
port map (
|
144 |
|
|
addend_12bit(11 downto 0) => fir_in_07,
|
145 |
|
|
augend_12bit(11 downto 0) => fir_in_08,
|
146 |
|
|
adder12_output => result_adder04
|
147 |
|
|
);
|
148 |
|
|
|
149 |
|
|
adder05 : adder_12bit
|
150 |
|
|
port map (
|
151 |
|
|
addend_12bit(11 downto 0) => fir_in_09,
|
152 |
|
|
augend_12bit(11 downto 0) => fir_in_10,
|
153 |
|
|
adder12_output => result_adder05
|
154 |
|
|
);
|
155 |
|
|
|
156 |
|
|
adder06 : adder_12bit
|
157 |
|
|
port map (
|
158 |
|
|
addend_12bit(11 downto 0) => fir_in_11,
|
159 |
|
|
augend_12bit(11 downto 0) => fir_in_12,
|
160 |
|
|
adder12_output => result_adder06
|
161 |
|
|
);
|
162 |
|
|
|
163 |
|
|
adder07 : adder_12bit
|
164 |
|
|
port map (
|
165 |
|
|
addend_12bit(11 downto 0) => fir_in_13,
|
166 |
|
|
augend_12bit(11 downto 0) => fir_in_14,
|
167 |
|
|
adder12_output => result_adder07
|
168 |
|
|
);
|
169 |
|
|
|
170 |
|
|
adder08 : adder_12bit
|
171 |
|
|
port map (
|
172 |
|
|
addend_12bit(11 downto 0) => fir_in_15,
|
173 |
|
|
augend_12bit(11 downto 0) => fir_in_16,
|
174 |
|
|
adder12_output => result_adder08
|
175 |
|
|
);
|
176 |
|
|
|
177 |
|
|
adder09 : adder_13bit
|
178 |
|
|
port map (
|
179 |
|
|
addend_13bit(12 downto 0) => result_adder01,
|
180 |
|
|
augend_13bit(12 downto 0) => result_adder02,
|
181 |
|
|
adder13_output => result_adder09
|
182 |
|
|
);
|
183 |
|
|
|
184 |
|
|
adder10 : adder_13bit
|
185 |
|
|
port map (
|
186 |
|
|
addend_13bit(12 downto 0) => result_adder03,
|
187 |
|
|
augend_13bit(12 downto 0) => result_adder04,
|
188 |
|
|
adder13_output => result_adder10
|
189 |
|
|
);
|
190 |
|
|
|
191 |
|
|
adder11 : adder_13bit
|
192 |
|
|
port map (
|
193 |
|
|
addend_13bit(12 downto 0) => result_adder05,
|
194 |
|
|
augend_13bit(12 downto 0) => result_adder06,
|
195 |
|
|
adder13_output => result_adder11
|
196 |
|
|
);
|
197 |
|
|
|
198 |
|
|
adder12 : adder_13bit
|
199 |
|
|
port map (
|
200 |
|
|
addend_13bit(12 downto 0) => result_adder07,
|
201 |
|
|
augend_13bit(12 downto 0) => result_adder08,
|
202 |
|
|
adder13_output => result_adder12
|
203 |
|
|
);
|
204 |
|
|
|
205 |
|
|
adder13 : adder_14bit
|
206 |
|
|
port map (
|
207 |
|
|
addend_14bit(13 downto 0) => result_adder09,
|
208 |
|
|
augend_14bit(13 downto 0) => result_adder10,
|
209 |
|
|
adder14_output => result_adder13
|
210 |
|
|
);
|
211 |
|
|
|
212 |
|
|
adder14 : adder_14bit
|
213 |
|
|
port map (
|
214 |
|
|
addend_14bit(13 downto 0) => result_adder11,
|
215 |
|
|
augend_14bit(13 downto 0) => result_adder12,
|
216 |
|
|
adder14_output => result_adder14
|
217 |
|
|
);
|
218 |
|
|
|
219 |
|
|
adder15 : adder_15bit
|
220 |
|
|
port map (
|
221 |
|
|
addend_15bit(14 downto 0) => result_adder13,
|
222 |
|
|
augend_15bit(14 downto 0) => result_adder14,
|
223 |
|
|
adder15_output => result_adder15
|
224 |
|
|
);
|
225 |
|
|
|
226 |
16 |
arif_endro |
-- FIR constants that have effect on output trasition.
|
227 |
|
|
-- This constant if set to low values (e.g x < 1/8 ) will make
|
228 |
|
|
-- the transition output more looks like steps, noise will be reduced
|
229 |
|
|
-- but it's loss of fidelity of output signal.
|
230 |
|
|
-- for example:
|
231 |
|
|
-- set values to 1/16 will make the output trasition more look's like step
|
232 |
|
|
-- than an curve.
|
233 |
|
|
-- Just try another values to see the result. ^_^
|
234 |
|
|
|
235 |
12 |
arif_endro |
fir_out(11) <= (result_adder15(15)); -- 1
|
236 |
16 |
arif_endro |
fir_out(10) <= (result_adder15(14)); -- 1/2
|
237 |
|
|
fir_out(09) <= (result_adder15(13)); -- 1/4
|
238 |
|
|
fir_out(08) <= (result_adder15(12)); -- 1/8
|
239 |
|
|
fir_out(07) <= (result_adder15(11)); -- 1/16
|
240 |
|
|
fir_out(06) <= (result_adder15(10));
|
241 |
|
|
fir_out(05) <= (result_adder15(09));
|
242 |
|
|
fir_out(04) <= (result_adder15(08));
|
243 |
|
|
fir_out(03) <= (result_adder15(07));
|
244 |
|
|
fir_out(02) <= (result_adder15(06));
|
245 |
|
|
fir_out(01) <= (result_adder15(05));
|
246 |
|
|
fir_out(00) <= (result_adder15(04));
|
247 |
2 |
arif_endro |
|
248 |
23 |
arif_endro |
-- 20080625
|
249 |
|
|
-- fixme
|
250 |
|
|
-- how to enable clear signal in here... :(
|
251 |
2 |
arif_endro |
|
252 |
23 |
arif_endro |
-- process (clock, clear)
|
253 |
|
|
process (clock)
|
254 |
|
|
|
255 |
12 |
arif_endro |
begin
|
256 |
|
|
|
257 |
23 |
arif_endro |
-- if (clear = '1') then
|
258 |
|
|
if ((clock = '1') and clock'event) then
|
259 |
12 |
arif_endro |
|
260 |
23 |
arif_endro |
-- dmout <= (others => '0');
|
261 |
12 |
arif_endro |
|
262 |
23 |
arif_endro |
-- elsif (((clock = '1') and (not(clear) = '1')) and clock'event) then
|
263 |
12 |
arif_endro |
|
264 |
2 |
arif_endro |
fir_in_02 <= fir_in_01;
|
265 |
|
|
fir_in_03 <= fir_in_02;
|
266 |
|
|
fir_in_04 <= fir_in_03;
|
267 |
|
|
fir_in_05 <= fir_in_04;
|
268 |
|
|
fir_in_06 <= fir_in_05;
|
269 |
|
|
fir_in_07 <= fir_in_06;
|
270 |
|
|
fir_in_08 <= fir_in_07;
|
271 |
|
|
fir_in_09 <= fir_in_08;
|
272 |
|
|
fir_in_10 <= fir_in_09;
|
273 |
|
|
fir_in_11 <= fir_in_10;
|
274 |
|
|
fir_in_12 <= fir_in_11;
|
275 |
|
|
fir_in_13 <= fir_in_12;
|
276 |
|
|
fir_in_14 <= fir_in_13;
|
277 |
|
|
fir_in_15 <= fir_in_14;
|
278 |
|
|
fir_in_16 <= fir_in_15;
|
279 |
|
|
|
280 |
|
|
dmout <= fir_out;
|
281 |
|
|
|
282 |
|
|
end if;
|
283 |
12 |
arif_endro |
|
284 |
|
|
end process;
|
285 |
|
|
|
286 |
2 |
arif_endro |
end structural;
|