1 | library IEEE;
|
2 | use IEEE.STD_LOGIC_1164.ALL;
|
3 | use IEEE.Numeric_std.ALL;
|
4 |
|
5 | entity Sinc_filt is
|
6 | generic (
|
7 | DECIMATOR_M_BIT_SIZE : natural := 8); -- M = 2^DECIMATOR_M_BIT_SIZE
|
8 | Port ( Mclk : in STD_LOGIC;
|
9 | Mdata : in STD_LOGIC;
|
10 | rst : in STD_LOGIC;
|
11 | DataRate_clk : out STD_LOGIC; -- in fifo abspeichern
|
12 | DataOut : out STD_LOGIC_VECTOR (15 downto 0));
|
13 | end Sinc_filt;
|
14 |
|
15 | architecture Behavioral of Sinc_filt is
|
16 |
|
17 | constant DATA_BIT_SIZE : natural := 3*DECIMATOR_M_BIT_SIZE + 1; -- intern DatenBus Sinc3
|
18 |
|
19 | ----------------------------------------------------------------------------------
|
20 | -- signal
|
21 | ----------------------------------------------------------------------------------
|
22 |
|
23 | -- integrator @ Mclk
|
24 | signal acc1 : signed (DATA_BIT_SIZE - 1 downto 0) := (others => '0');
|
25 | signal acc2 : signed (DATA_BIT_SIZE - 1 downto 0) := (others => '0');
|
26 | signal acc3 : signed (DATA_BIT_SIZE - 1 downto 0) := (others => '0');
|
27 |
|
28 | -- diffirentiator @ Mclk/DECIMATOR_M
|
29 | signal diff_clk : std_logic := '0';
|
30 |
|
31 | signal diff1 : signed (DATA_BIT_SIZE - 1 downto 0) := (others => '0');
|
32 | signal diff2 : signed (DATA_BIT_SIZE - 1 downto 0) := (others => '0');
|
33 | signal diff3 : signed (DATA_BIT_SIZE - 1 downto 0) := (others => '0');
|
34 | signal acc3_d : signed (DATA_BIT_SIZE - 1 downto 0) := (others => '0');
|
35 | signal diff1_d : signed (DATA_BIT_SIZE - 1 downto 0) := (others => '0');
|
36 | signal diff2_d : signed (DATA_BIT_SIZE - 1 downto 0) := (others => '0');
|
37 |
|
38 | -- clk divider ->> Mclk/DECIMATOR_M
|
39 | signal clk_div_cnt : std_logic_vector(DECIMATOR_M_BIT_SIZE-1 downto 0) := (others => '0');
|
40 |
|
41 | begin
|
42 |
|
43 | ----------------------------------------------------------------------------------
|
44 | -- Integrator @ Mclk
|
45 | ----------------------------------------------------------------------------------
|
46 | Integ_pro: process
|
47 | begin
|
48 | wait until rising_edge(Mclk); -- falling Mclk ->> data valid
|
49 |
|
50 | if rst = '1' then
|
51 | acc1 <= (others => '0');
|
52 | acc2 <= (others => '0');
|
53 | acc3 <= (others => '0');
|
54 | else
|
55 | if Mdata = '1' then
|
56 | acc1 <= acc1 + x"1";
|
57 | end if;
|
58 | acc2 <= acc2 + acc1;
|
59 | acc3 <= acc3 + acc2;
|
60 | end if;
|
61 | end process Integ_pro;
|
62 |
|
63 | ----------------------------------------------------------------------------------
|
64 | -- clk divider @ Mclk --> Mclk/DECIMATOR_M
|
65 | ----------------------------------------------------------------------------------
|
66 | clk_div_pro: process
|
67 | begin
|
68 | wait until rising_edge(Mclk);
|
69 | if rst = '1' then
|
70 | clk_div_cnt <= (others => '0');
|
71 | else
|
72 | clk_div_cnt <= std_logic_vector(unsigned(clk_div_cnt) + x"1");
|
73 | end if;
|
74 | end process clk_div_pro;
|
75 |
|
76 | -- wired
|
77 | diff_clk <= clk_div_cnt(DECIMATOR_M_BIT_SIZE-1); -- MSB
|
78 | DataRate_clk <= diff_clk;
|
79 |
|
80 | ----------------------------------------------------------------------------------
|
81 | -- differenciator @ falling diff_clk
|
82 | ----------------------------------------------------------------------------------
|
83 | Diff_pro: process
|
84 | begin
|
85 | wait until falling_edge(diff_clk); -- Falling Edge!
|
86 |
|
87 | if rst = '1' then
|
88 | diff1 <= (others => '0');
|
89 | diff2 <= (others => '0');
|
90 | diff3 <= (others => '0');
|
91 | acc3_d <= (others => '0');
|
92 | diff1_d <= (others => '0');
|
93 | diff2_d <= (others => '0');
|
94 | else
|
95 | diff1 <= acc3 - acc3_d;
|
96 | diff2 <= diff1 - diff1_d;
|
97 | diff3 <= diff2 - diff2_d;
|
98 |
|
99 | acc3_d <= acc3;
|
100 | diff1_d <= diff1;
|
101 | diff2_d <= diff2;
|
102 | end if;
|
103 | end process Diff_pro;
|
104 |
|
105 |
|
106 | ----------------------------------------------------------------------------------
|
107 | -- 16- bit DataOutput
|
108 | ----------------------------------------------------------------------------------
|
109 |
|
110 | DataOut <= std_logic_vector(diff3(DATA_BIT_SIZE-1 downto DATA_BIT_SIZE-16)); -- 16-Bit DataOut
|
111 |
|
112 | end Behavioral;
|