Project

General

Profile

Download (6.3 KB) Statistics
| Branch: | Tag: | Revision:
1
---------------------------------------------------------------------------------------------------
2
-- Filename    : mt_fir_symmetric_slow.vhd
3
-- Project     : maintech filter toolbox
4
-- Purpose     : Symmetric FIR filter
5
--               - multiplexed input/output for all data-channels
6
--               - single MAC-cell for all calculations
7
---------------------------------------------------------------------------------------------------
8

    
9
-----------------------------------------------------------------------------------
10
-- Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany --
11
-- written by Matthias Kleffel                                                   --
12
--                                                                               --
13
-- This program is free software; you can redistribute it and/or modify          --
14
-- it under the terms of the GNU General Public License as published by          --
15
-- the Free Software Foundation as version 3 of the License, or                  --
16
--                                                                               --
17
-- This program is distributed in the hope that it will be useful,               --
18
-- but WITHOUT ANY WARRANTY; without even the implied warranty of                --
19
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  --
20
-- GNU General Public License V3 for more details.                               --
21
--                                                                               --
22
-- You should have received a copy of the GNU General Public License             --
23
-- along with this program. If not, see <http://www.gnu.org/licenses/>.          --
24
-----------------------------------------------------------------------------------
25

    
26
library ieee;
27
	use ieee.std_logic_1164.all;
28
	use ieee.numeric_std.all;
29
library work;
30
	use work.all;
31
	use work.mt_toolbox.all;
32
	use work.mt_filter.all;
33

    
34
entity mt_fir_symmetric_slow is
35
	generic (
36
		CHANNELS   : natural;				-- number of data channels
37
		TAPS       : natural;				-- number of filter taps (AFTER folding)
38
		COEFFS     : fir_coefficients;		-- coefficent sets
39
		RAMSTYLE   : string;				-- ram style for inferred memories
40
		ROMSTYLE   : string					-- ram style for coefficent rom
41
	);
42
	port(
43
		-- common
44
		clk        : in  std_logic;
45
		reset      : in  std_logic;
46
		
47
		-- input port
48
		in_clk     : in  std_logic;
49
		in_ack     : out std_logic;
50
		in_chan    : in  unsigned(log2(CHANNELS)-1 downto 0);
51
		in_data    : in  fir_dataword18;
52
		
53
		-- output port
54
		out_clk    : out std_logic;
55
		out_chan   : out unsigned(log2(CHANNELS)-1 downto 0);
56
		out_data   : out fir_dataword18
57
	);
58
end mt_fir_symmetric_slow;
59

    
60
architecture rtl of mt_fir_symmetric_slow is	
61

    
62
	-- internal types
63
	subtype chan_t is unsigned(log2(CHANNELS)-1 downto 0);
64
	type chan_array_t is array(natural range<>) of chan_t;
65

    
66
	-- control signals
67
	signal active   : std_logic;
68
	signal shiftcnt : unsigned(log2(TAPS)-1 downto 0);
69
	signal ochan    : chan_array_t(3 downto 0);
70
	
71
	-- storage ports
72
	signal st_chan   : chan_t;
73
	signal st_start  : std_logic;
74
	signal st_stop   : std_logic;
75
	signal st_active : std_logic;
76
	signal st_din    : fir_dataword18;
77
	
78
	-- storage <-> MAC
79
	signal st_mac_start  : std_logic;
80
	signal st_mac_stop   : std_logic;
81
	signal st_mac_active : std_logic;
82
	signal st_mac_dout1  : fir_dataword18;
83
	signal st_mac_dout2  : fir_dataword18;
84
	signal st_mac_coeff  : fir_dataword18;
85
	
86
	-- MAC output
87
	signal mac_dnew : std_logic;
88
	signal mac_dout : fir_dataword18;
89
	
90
begin
91
	
92
	-- control logic
93
	process(clk, reset)
94
	begin
95
		if reset='1' then
96
			active     <= '0';
97
			shiftcnt   <= (others=>'0');
98
			ochan      <= (others=>(others=>'0'));
99
			st_start   <= '0';
100
			st_stop    <= '0';
101
			st_active  <= '0';
102
			in_ack     <= '0';
103
			out_clk    <= '0';
104
			out_data   <= (others=>'0');
105
			out_chan   <= (others=>'0');
106
		elsif rising_edge(clk) then
107
			-- set default values
108
			in_ack    <= '0';
109
			out_clk   <= '0';
110
			st_start  <= '0';
111
			st_stop   <= '0';
112
			st_active <= '0';
113
			
114
			-- get current status
115
			if active='0' then
116
				--> idle
117
				
118
				-- check for new request
119
				if in_clk='1' then
120
					--> input new sample and start burst from storage to MAC cell
121
					shiftcnt  <= to_unsigned(TAPS-1, shiftcnt'length);
122
					st_start  <= '1';
123
					st_active <= '1';
124
					active    <= '1';
125
				end if;
126
			else
127
				--> active
128
				
129
				-- control storage
130
				if shiftcnt/=0 then
131
					--> continue with burst
132
					shiftcnt  <= shiftcnt-1;
133
					st_active <= '1';
134
					if shiftcnt=1 then
135
						-- last cycle of burst
136
						st_stop <= '1';
137
						in_ack  <= '1'; 
138
						active  <= '0';
139
					end if;
140
				end if;
141
			end if;
142
			
143
			-- check if new result is ready
144
			if mac_dnew='1' then
145
				--> MAC done, update output
146
				out_clk  <= '1';
147
				out_chan <= ochan(ochan'left);
148
				out_data <= mac_dout;
149
			end if;
150
			
151
			-- delay channel-number to compensate for MAC delay
152
			ochan <= ochan(ochan'left-1 downto 0) & ochan(0);
153
			if st_mac_start='1' then
154
				ochan(0) <= in_chan;
155
			end if;
156
		end if;
157
	end process;
158
	
159
	-- connect storage input
160
	st_chan <= in_chan;
161
	st_din	<= in_data;
162
	
163
	-- data storage
164
	st: entity mt_fil_storage_slow
165
		generic map (
166
			COEFFS     => COEFFS,
167
			DCHAN      => CHANNELS,
168
			TAPS       => TAPS,
169
			RAMSTYLE   => RAMSTYLE,
170
			ROMSTYLE   => ROMSTYLE
171
		)
172
		port map (
173
			-- common
174
			clk        => clk,
175
			reset 	   => reset,
176
			
177
			-- config
178
			chan       => st_chan,
179
			
180
			-- input
181
			in_load	   => st_start,
182
			in_start   => st_start,
183
			in_stop    => st_stop,
184
			in_active  => st_active,
185
			in_data	   => st_din,
186
			
187
			-- output
188
			out_load   => open,
189
			out_start  => st_mac_start,
190
			out_stop   => st_mac_stop,
191
			out_active => st_mac_active,
192
			out_data1  => st_mac_dout1,
193
			out_data2  => st_mac_dout2,
194
			out_coeff  => st_mac_coeff
195
		);
196
		
197
	-- do create MAC cell
198
	mac: entity mt_fil_mac_slow
199
		port map (
200
			-- common
201
			clk    => clk,
202
			reset  => reset,
203
			
204
			-- control-path
205
			start  => st_mac_start,
206
			active => st_mac_active,
207
			presub => '0',
208
			
209
			-- data input
210
			smp1   => st_mac_dout1,
211
			smp2   => st_mac_dout2,
212
			coeff  => st_mac_coeff,
213
			
214
			-- data output
215
			dnew   => mac_dnew,
216
			dout   => mac_dout
217
		);
218
	
219
end rtl;
(4-4/4)
Add picture from clipboard (Maximum size: 48.8 MB)