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

Subversion Repositories gfir

[/] [gfir/] [trunk/] [vhdl/] [src/] [fir_pkg.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 supporting package. \b "JUST EDIT THIS FILE"
4
----------
5
library ieee;
6
use ieee.std_logic_1164.all;
7
use ieee.std_logic_arith.all;
8
 
9
package fir_pkg is
10
 
11
        type int_vector is array (natural range <>) of integer;
12
 
13
        constant coeff : int_vector := (-51,25,128,77,-203,-372,70,1122,2047,2047,1122,70,-372,-203,77,128,25,-51); --! Filter coefficients defined in the fir_pkg.vhd
14
        -- Q 12, N 18
15
        constant quantization   : positive := 12; --! Filter quantization bit-width
16
        constant order          : natural  := coeff'length;
17
        constant width_out      : natural  := 15;
18
 
19
        -- Global signals for internal debugging
20
        signal g_multi_add   : std_logic_vector((order-1)*width_out-1 downto 0);
21
        signal g_add_delay   : std_logic_vector((order-2)*width_out-1 downto 0);
22
        signal g_delay_add   : std_logic_vector((order-1)*width_out-1 downto 0);
23
        signal g_multi_delay : std_logic_vector(width_out-1 downto 0);
24
 
25
        function binary_width (
26
                x : natural)
27
        return natural;
28
 
29
        function EOp (
30
                M : positive
31
                )
32
        return natural;
33
 
34
        function EOn (
35
                M : positive
36
                )
37
        return natural;
38
 
39
end fir_pkg;
40
 
41
package body fir_pkg is
42
 
43
        function binary_width (
44
                x : natural)
45
        return natural is
46
                variable y      : integer;
47
                variable count  : natural;
48
                begin
49
 
50
                y := abs(x);
51
                count := 0;
52
                while y > 0 loop
53
                        y := y/2;
54
                        count := count + 1;
55
                end loop;
56
 
57
                return count;
58
 
59
                end function;
60
 
61
        function EOp (
62
                M : positive
63
                )
64
        return natural is
65
                begin
66
                        if (M mod 2) = 0 then
67
                                return M/2-1;
68
                        else
69
                                return M/2;
70
                        end if;
71
                end function;
72
 
73
        function EOn (
74
                M : positive
75
                )
76
        return natural is
77
                begin
78
                        if (M mod 2) = 0 then
79
                                return M/2-1;
80
                        else
81
                                return M/2-1;
82
                        end if;
83
                end function;
84
 
85
end fir_pkg;

powered by: WebSVN 2.1.0

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