OpenCores
URL https://opencores.org/ocsvn/gfir/gfir/trunk

Subversion Repositories gfir

[/] [gfir/] [trunk/] [vhdl/] [src/] [fir_filter_stage_DF.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 ahmed.shah
---------------------------------------------------------------------------------------------------
2
--! @file
3
--! @brief This is the top-level design for a direct-form FIR digital filter.                   \n
4
--! @details It instantiate the three major components for constructing a digital filter such as;\n
5
--! adder (adder_gen), multiplier (multiplier_gen), and delay (delay_gen).                      \n
6
--! The top-level is a structural description in a generic/scalable form.                       \n
7
--! The filter coefficients and the quantization bit width should be edited/pasted              \n
8
--! into the fir_pkg.vhd. The filter coefficients should be given in integer format.            \n
9
--! Design specs:                                                                               \n
10
--! Unsigned single/multi-bit input (fir_in)                                                    \n
11
--! Signed multi-bit output (fir_out)                                                           \n
12
--! Active high asynchronous reset  (fir_clr)                                                   \n
13
--! Rising edge clock (fir_clk)                                                                 \n
14
--
15
--! @image html firDF.png "Direct-form FIR Filter Structure" 
16
--
17
--! @author Ahmed Shahein
18
--! @email ahmed.shahein@ieee.org
19
--! @date 04.2012
20
---------------------------------------------------------------------------------------------------
21
LIBRARY ieee;
22
USE ieee.std_logic_1164.all;
23
USE ieee.std_logic_arith.all;
24
USE ieee.std_logic_unsigned.all;
25
USE work.fir_pkg.all;
26
 
27
ENTITY fir_filter_stage_DF IS
28
  port (fir_clk         : in  std_logic;                        --! Rising edge clock
29
        fir_clr         : in  std_logic;                        --! Active high asynchronous reset
30
        fir_in          : in  std_logic_vector(0 downto 0);       --! Unsigned single/multi-bit input
31
        fir_out         : out std_logic_vector(14 downto 0));    --! Signed multi-bit output
32
END ENTITY fir_filter_stage_DF;
33
 
34
--
35
ARCHITECTURE struct OF fir_filter_stage_DF IS
36
-- COMPONENT DECLARATION
37
component multiplier_gen
38
    generic (multi_width_const : natural;
39
             multi_width_in    : natural);
40
    port (multiplier_const  : in std_logic_vector(multi_width_const-1 downto 0);
41
          multiplier_in     : in std_logic_vector(multi_width_in-1 downto 0);
42
          multiplier_out    : out std_logic_vector((multi_width_const+multi_width_in)+1 downto 0));
43
end component;
44
 
45
component adder_gen
46
  generic (add_width : natural);
47
    port (add_a_in : in std_logic_vector(add_width-1 downto 0);
48
          add_b_in : in std_logic_vector(add_width-1 downto 0);
49
          add_out  : out std_logic_vector(add_width-1 downto 0));
50
end component;
51
 
52
component delay_gen
53
    generic (delay_width : natural);
54
    port (clk, clr  : in  std_logic;
55
          delay_in  : in  std_logic_vector(delay_width-1 downto 0);
56
          delay_out : out std_logic_vector(delay_width-1 downto 0));
57
end component;
58
 
59
-- CONSTANT DECLARATION
60
constant coeff          : int_vector    := fir_coeff_thirdstage;        --! Filter coefficients defined in the fir_pkg.vhd
61
constant width_in       : natural       := fir_in'length;               --! Input bit-width
62
constant width_out      : natural       := fir_out'length;              --! Output bit-width
63
constant width_const    : positive      := quantization;                --! Quantization bit-width defined in the fir_pkg.vhd
64
constant order          : natural       := coeff'length;                --! Filter length
65
 
66
-- SIGNAL DECLARATION
67
signal multi_add        : std_logic_vector(order*width_out-1 downto 0);          --! Internal signal holding multiplier's outputs and adder's inputs
68
signal add_add          : std_logic_vector((order-1)*width_out-1 downto 0);      --! Internal signal holding preced adder output and proceed adder input
69
signal delay_multi      : std_logic_vector((order-1)*width_in-1 downto 0);       --! Internal signal holding delay's output and multiplier's inputs
70
 
71
BEGIN
72
 
73
COEFFMULTIs: for i in 0 to order-1 generate                      --! Generate the filter multipliers set 
74
    FirstMULT: if i = 0 generate
75
    MULTI: multiplier_gen
76
      generic map(multi_width_const => width_const,
77
               multi_width_in => width_in)
78
        port map(
79
                multiplier_const        => conv_std_logic_vector(coeff(i), width_const),
80
                multiplier_in           => fir_in,
81
                multiplier_out          => multi_add((i+1)*width_out-1 downto i*width_out)
82
                );
83
          end generate;
84
  InterMULTs: if i > 0 generate
85
  MULTIs: multiplier_gen
86
        generic map(multi_width_const => width_const,
87
             multi_width_in => width_in)
88
        port map(
89
                multiplier_const        => conv_std_logic_vector(coeff(i), width_const),
90
                multiplier_in           => delay_multi(i*width_in-1 downto (i-1)*width_in),
91
                multiplier_out          => multi_add((i+1)*width_out-1 downto i*width_out)
92
                );
93
       end generate;
94
      end generate;
95
 
96
  COEFFDELAY: for i in 1 to order-1 generate                    --! Generate the filter delays set 
97
  DELAY:  if i = 1 generate
98
  FirstDELAY: delay_gen
99
        generic map(delay_width => width_in)
100
        port map(
101
                clr             => fir_clr,
102
                delay_in        => fir_in,
103
                delay_out       => delay_multi(i*width_in-1 downto (i-1)*width_in),
104
                clk             => fir_clk
105
                );
106
        end generate;
107
  InterDElAYs: if i > 1 generate
108
  DELAYs:  delay_gen
109
        generic map(delay_width => width_in)
110
        port map(
111
                clr             => fir_clr,
112
                delay_in        => delay_multi((i-1)*width_in-1 downto (i-2)*width_in),
113
                delay_out       => delay_multi(i*width_in-1 downto (i-1)*width_in),
114
                clk             => fir_clk
115
                );
116
        end generate;
117
      end generate;
118
 
119
  COEFFADD: for i in 1 to order-1 generate                      --! Generate the filter adders set 
120
  FirstADDER: if i = 1 generate
121
  ADDER0: adder_gen
122
        generic map(add_width => width_out)
123
        port map(
124
                add_a_in        => multi_add((i+1)*width_out-1 downto i*width_out), -- from multipliers
125
                add_b_in        => multi_add(i*width_out-1 downto (i-1)*width_out),
126
                add_out         => add_add(i*width_out-1 downto (i-1)*width_out)
127
                );
128
        end generate;
129
  InterADDER: if i > 1 generate
130
  ADDERs: adder_gen
131
        generic map(add_width => width_out)
132
        port map(
133
                add_a_in        => multi_add((i+1)*width_out-1 downto i*width_out), -- from multipliers
134
                add_b_in        => add_add((i-1)*width_out-1 downto (i-2)*width_out),
135
                add_out         => add_add(i*width_out-1 downto (i-1)*width_out)
136
                );
137
        end generate;
138
      end generate;
139
 
140
fir_out <= add_add((order-1)*width_out-1 downto (order-1)*width_out-width_out);
141
 
142
END ARCHITECTURE struct;

powered by: WebSVN 2.1.0

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