OpenCores
URL https://opencores.org/ocsvn/802154phycore/802154phycore/trunk

Subversion Repositories 802154phycore

[/] [802154phycore/] [trunk/] [rtl/] [tx_fir.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 entactogen
-- Copyright (c) 2010 Antonio de la Piedra
2
 
3
-- This program is free software: you can redistribute it and/or modify
4
-- it under the terms of the GNU General Public License as published by
5
-- the Free Software Foundation, either version 3 of the License, or
6
-- (at your option) any later version.
7
 
8
-- This program is distributed in the hope that it will be useful,
9
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
10
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
-- GNU General Public License for more details.
12
 
13
-- You should have received a copy of the GNU General Public License
14
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
16
-- A VHDL model of the IEEE 802.15.4 physical layer.
17
 
18
-- Half-cosine pulse shapping filter [1] implemented as FIR structure.
19
-- FIR implementation based on [2].
20
 
21
-- [1] IEEE, 802.15.4. Part 15.4: Wireless Medium Access Control (MAC) and Physical Layer (PHY)
22
--     Specifications for Low-Rate Wireless Personal Area Networks (LR-WPANs).
23
 
24
-- [2] Volnei A. Pedroni. Circuit Design with VHDL.
25
 
26
 
27
-- Filter coefficientes represented over 10 bits in 2's complement.
28
 
29
        -- h0 = 0       -> 0000000000
30
        -- h1 = 0.3826  -> 0000001100
31
        -- h2 = 0.7071  -> 0000010111
32
        -- h3 = 0.9238  -> 0000011110
33
        -- h4 = 1       -> 0000100000
34
        -- h5 = 0.9238  -> 0000011110
35
        -- h6 = 0.7071  -> 0000010111
36
        -- h7 = 0.3826  -> 0000001100
37
 
38
library IEEE;
39
use IEEE.STD_LOGIC_1164.ALL;
40
use IEEE.numeric_std.ALL;
41
use IEEE.STD_LOGIC_UNSIGNED.ALL;
42
 
43
 
44
entity tx_fir is
45
 
46
        port (mfilter_input: in std_logic_vector(1 downto 0);
47
                        mfilter_clk:   in std_logic;
48
                        mfilter_rst:   in std_logic;
49
                        mfilter_output: out std_logic_vector(9 downto 0));
50
 
51
end tx_fir;
52
 
53
architecture Behavioral of tx_fir is
54
        type registers is array (6 downto 0) of signed(1 downto 0);
55
        type coefficients is array (7 downto 0) of signed(9 downto 0);
56
 
57
        signal reg: registers;
58
        signal output_temp: std_logic_vector(9 downto 0);
59
 
60
        constant coef: coefficients := ("0000001100",
61
                                                                                          "0000010111",
62
                                                                                          "0000011110",
63
                                                                                          "0000100000",
64
                                                                                          "0000011110",
65
                                                                                          "0000010111",
66
                                                                                          "0000001100",
67
                                                                                          "0000000000");
68
 
69
        begin
70
                process (mfilter_clk, mfilter_rst)
71
                        variable acc: signed(9 downto 0) := (others => '0');
72
                begin
73
 
74
                        if (mfilter_rst = '1') then
75
                                for i in 6 downto 0 loop
76
                                                reg(i) <= (others => '0');
77
                                end loop;
78
 
79
                        elsif rising_edge(mfilter_clk) then
80
 
81
                                if (mfilter_input = "01") then
82
                                        acc := resize(coef(0), acc'length);
83
                                elsif (mfilter_input = "11") then
84
                                        acc := resize(-coef(0), acc'length);
85
                                else
86
                                        acc := (others => '0');
87
                                end if;
88
 
89
                                for i in 1 to 7 loop
90
                                        if (reg(7-i) = "01") then
91
                                                acc := resize(acc + coef(i), acc'length);
92
                                        elsif (reg(7-i)= "11") then
93
                                                acc := resize(acc - coef(i), acc'length);
94
                                        end if;
95
                                end loop;
96
 
97
                                reg <= signed(mfilter_input) & reg(6 DOWNTO 1);
98
 
99
 
100
                        end if;
101
                output_temp <= std_logic_vector(acc);
102
 
103
        end process;
104
 
105
        mfilter_output <= output_temp;
106
 
107
end Behavioral;
108
 

powered by: WebSVN 2.1.0

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