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

Subversion Repositories gfir

[/] [gfir/] [trunk/] [vhdl/] [src/] [fir_filter_stage_TF.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 transposed-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 firTF.png "Transposed-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_TF 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_TF;
33
 
34
--
35
ARCHITECTURE struct OF fir_filter_stage_TF 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-1)*width_out-1 downto 0);   --! Internal signal holding multiplier's outputs and adder's inputs
68
signal add_delay   : std_logic_vector((order-2)*width_out-1 downto 0);   --! Internal signal holding adder's outputs and delay's inputs
69
signal delay_add   : std_logic_vector((order-1)*width_out-1 downto 0);   --! Internal signal holding delay's output and adder's inputs
70
signal multi_delay : std_logic_vector(width_out-1 downto 0);             --! internal signal for the left most multiplier since it is connected directly to delay
71
 
72
BEGIN
73
 
74
COEFFMULTIs: for i in 0 to order-1 generate      --! Generate the filter multipliers set 
75
    LastMULT: if i = order-1 generate
76
    MULTI: multiplier_gen
77
      generic map(multi_width_const => width_const,
78
               multi_width_in => width_in)
79
      port map(multiplier_const  => conv_std_logic_vector(coeff(i), width_const),
80
            multiplier_in     => fir_in,
81
            multiplier_out    => multi_delay);
82
          end generate;
83
  InterMULTs: if i < order-1 generate
84
  MULTIs: multiplier_gen
85
    generic map(multi_width_const => width_const,
86
             multi_width_in => width_in)
87
    port map(multiplier_const  => conv_std_logic_vector(coeff(i), width_const),
88
          multiplier_in     => fir_in,
89
          multiplier_out    => multi_add((i+1)*width_out-1 downto i*width_out));
90
        end generate;
91
      end generate;
92
 
93
  COEFFDELAY: for i in 0 to order-2 generate     --! Generate the filter delays set 
94
  DELAY:  if i = order-2 generate
95
  LastDELAY: delay_gen
96
    generic map(delay_width => width_out)
97
    port map(clk  => fir_clk,
98
          clr  => fir_clr,
99
          delay_in  => multi_delay,
100
          delay_out => delay_add((i+1)*width_out-1 downto i*width_out));
101
        end generate;
102
  InterDElAYs: if i < order-2 generate
103
  DELAYs: delay_gen
104
    generic map(delay_width => width_out)
105
    port map(clk  => fir_clk,
106
          clr  => fir_clr,
107
          delay_in  => add_delay((i+1)*width_out-1 downto i*width_out),
108
          delay_out => delay_add((i+1)*width_out-1 downto i*width_out));
109
        end generate;
110
      end generate;
111
 
112
  COEFFADD: for i in 0 to order-2 generate       --! Generate the filter adders set 
113
  FirstADDER: if i = 0 generate
114
  ADDER0: adder_gen
115
  generic map(add_width => width_out)
116
    port map(
117
          add_a_in => multi_add((i+1)*width_out-1 downto i*width_out),
118
          add_b_in => delay_add((i+1)*width_out-1 downto i*width_out),
119
          add_out => fir_out);
120
        end generate;
121
  InterADDER: if i > 0 generate
122
  ADDERs: adder_gen
123
  generic map(add_width => width_out)
124
    port map(
125
          add_a_in => multi_add((i+1)*width_out-1 downto i*width_out),
126
          add_b_in => delay_add((i+1)*width_out-1 downto i*width_out),
127
          add_out => add_delay(i*width_out-1 downto (i-1)*width_out));
128
        end generate;
129
      end generate;
130
 
131
-- Internal debugging signals
132
g_multi_add   <= multi_add;
133
g_add_delay   <= add_delay;
134
g_delay_add   <= delay_add;
135
g_multi_delay <= multi_delay;
136
 
137
END ARCHITECTURE struct;

powered by: WebSVN 2.1.0

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