Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

about the checking of code

Status
Not open for further replies.

kannan2590

Member level 4
Member level 4
Joined
Sep 1, 2012
Messages
77
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
india
Visit site
Activity points
2,321
below is the code in vhdl for polyphase filters and the different components inside polyphase are the subfilters.The question is whether this is a good programming practice or is it better to use for generate statements.Also is this code good on implementing on fpga .Is for generate statements good for more than 20 coefficients.

for polyphase


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
library IEEE;
 use IEEE.STD_LOGIC_1164.ALL;
 use IEEE.STD_LOGIC_ARITH.ALL;
 use IEEE.STD_LOGIC_SIGNED.ALL;
 
---- Uncomment the following library declaration if instantiating
 ---- any Xilinx primitives in this code.
 library UNISIM;
 use UNISIM.VComponents.all;
 
entity polyphase is
 Port ( clk : in STD_LOGIC;
 
clk_120mbps: in std_logic;
 reset : in STD_LOGIC;
 din : in STD_LOGIC_vector(7 downto 0);
 ifiltout : out STD_LOGIC_vector(23 downto 0)
 );
 end polyphase;
 
architecture Behavioral of polyphase is
 
component subfilta
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 
component subfiltb
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 ---- 
component subfiltc
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 ---- 
component subfiltd
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 ----
 component subfilte
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component; 
--
 component subfiltf
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component; 
---- 
component subfiltg
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 -- 
component subfilth
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 ---- 
component subfilti
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 
component subfiltj
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 
component subfiltk
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 ---- 
component subfiltl
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 ---- 
component subfiltm
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 ------
 component subfiltn
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component; 
--
 component subfilto
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component; 
-- 
component subfiltp
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 
component subfiltq
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 
component subfiltr
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 ---- 
component subfilts
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 ---- 
component subfiltt
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 ----
 component subfiltu
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component; 
--
 component subfiltv
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component; 
-- 
component subfiltw
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 -- 
component subfiltx
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 ---- 
component subfilty
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 
component subfiltz
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 
component subfiltaa
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 ---- 
component subfiltbb
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 ---- 
component subfiltcc
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component;
 ----
 component subfiltdd
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component; 
--
 component subfiltee
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component; 
-- 
component subfiltff
 port( dout:out std_logic_vector(23 downto 0);
 clk:in std_logic;
 
reset:in std_logic;
 din:in std_logic_vector(7 downto 0)
 );
 end component; 
 
 
signal ifilterout0,ifilterout1,ifilterout2,ifilterout3:ST D_LOGIC_vector(23 downto 0):=(others =>'0');
 signal ifilterout4,ifilterout5,ifilterout6,ifilterout7:ST D_LOGIC_vector(23 downto 0):=(others =>'0');
 
signal ifilterout8,ifilterout9,ifilterout10,ifilterout11: STD_LOGIC_vector(23 downto 0):=(others =>'0');
 signal ifilterout12,ifilterout13,ifilterout14,ifilterout1 5:STD_LOGIC_vector(23 downto 0):=(others =>'0');
 
signal ifilterout16,ifilterout17,ifilterout18,ifilterout1 9:STD_LOGIC_vector(23 downto 0):=(others =>'0');
 signal ifilterout20,ifilterout21,ifilterout22,ifilterout2 3:STD_LOGIC_vector(23 downto 0):=(others =>'0');
 
signal ifilterout24,ifilterout25,ifilterout26,ifilterout2 7:STD_LOGIC_vector(23 downto 0):=(others =>'0');
 signal ifilterout28,ifilterout29,ifilterout30,ifilterout3 1:STD_LOGIC_vector(23 downto 0):=(others =>'0');
 --
 
begin
 subfilt0a: subfilta port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout0);
 subfilt0b: subfiltb port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout1);
 subfilt0c: subfiltc port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout2);
 subfilt0d: subfiltd port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout3);
 subfilt0e: subfilte port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout4);
 subfilt0f: subfiltf port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout5);
 subfilt0g: subfiltg port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout6);
 subfilt0h: subfilth port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout7);
 
subfilt0i: subfilti port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout8);
 subfilt0j: subfiltj port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout9);
 subfilt0k: subfiltk port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout10);
 subfilt0l: subfiltl port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout11);
 subfilt0m: subfiltm port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout12);
 subfilt0n: subfiltn port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout13);
 subfilt0o: subfilto port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout14);
 subfilt0p: subfiltp port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout15);
 
subfilt0q: subfiltq port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout16);
 subfilt0r: subfiltr port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout17);
 subfilt0s: subfilts port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout18);
 subfilt0t: subfiltt port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout19);
 subfilt0u: subfiltu port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout20);
 subfilt0v: subfiltv port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout21);
 subfilt0w: subfiltw port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout22);
 subfilt0x: subfiltx port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout23);
 
subfilt0y: subfilty port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout24);
 subfilt0z: subfiltz port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout25);
 subfilt0aa: subfiltaa port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout26);
 subfilt0bb: subfiltbb port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout27);
 subfilt0cc: subfiltcc port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout28);
 subfilt0dd: subfiltdd port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout29);
 subfilt0ee: subfiltee port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout30);
 subfilt0ff: subfiltff port map( Reset=> Reset, Clk=>Clk, din => din, dout => ifilterout31);
 
--
 P20:PROCESS(clk_120mbps,RESET)
 VARIABLE CNT:STD_LOGIC_VECTOR(5 DOWNTO 0):="000000";
 BEGIN
 
 
IF RESET='0' THEN
 CNT:="000000";
 ifiltout <=(others =>'0');
 ELSIF clk_120mbps='1' AND clk_120mbps'EVENT THEN
 CNT := CNT +1;
 CASE CNT IS 
WHEN "000001"=> ifiltout <=ifilterout0;
 WHEN "000010"=> ifiltout <=ifilterout1;
 WHEN "000011"=> ifiltout <=ifilterout2;
 WHEN "000100"=> ifiltout <=ifilterout3;
 WHEN "000101"=> ifiltout <=ifilterout4;
 WHEN "000110"=> ifiltout <=ifilterout5;
 
WHEN "000111"=> ifiltout <=ifilterout6;
 WHEN "001000"=> ifiltout <=ifilterout7;
 
WHEN "001001"=> ifiltout <=ifilterout8;
 WHEN "001010"=> ifiltout <=ifilterout9;
 WHEN "001011"=> ifiltout <=ifilterout10;
 WHEN "001100"=> ifiltout <=ifilterout11;
 WHEN "001101"=> ifiltout <=ifilterout12;
 WHEN "001110"=> ifiltout <=ifilterout13;
 ---- 
WHEN "001111"=> ifiltout <=ifilterout14;
 WHEN "010000"=> ifiltout <=ifilterout15;
 
WHEN "010001"=> ifiltout <=ifilterout16;
 WHEN "010010"=> ifiltout <=ifilterout17;
 WHEN "010011"=> ifiltout <=ifilterout18;
 WHEN "010100"=> ifiltout <=ifilterout19;
 WHEN "010101"=> ifiltout <=ifilterout20;
 WHEN "010110"=> ifiltout <=ifilterout21;
 
WHEN "010111"=> ifiltout <=ifilterout22;
 WHEN "011000"=> ifiltout <=ifilterout23;
 
WHEN "011001"=> ifiltout <=ifilterout24;
 WHEN "011010"=> ifiltout <=ifilterout25;
 WHEN "011011"=> ifiltout <=ifilterout26;
 WHEN "011100"=> ifiltout <=ifilterout27;
 WHEN "011101"=> ifiltout <=ifilterout28;
 WHEN "011110"=> ifiltout <=ifilterout29;
 
WHEN "011111"=> ifiltout <=ifilterout30;
 WHEN "100000"=> ifiltout <=ifilterout31;
 -- 
 
-- 
CNT := "000000";
 
WHEN OTHERS => ifiltout <="000000000000000000000000";
 END CASE;
 --CNT <= CNT +1;
 END IF;
 END PROCESS P20;
 
 
 
end Behavioral;




for subfilta

Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
library IEEE;
 use IEEE.STD_LOGIC_1164.ALL;
 use IEEE.STD_LOGIC_ARITH.ALL;
 use IEEE.STD_LOGIC_SIGNED.ALL;
 
 
---- Uncomment the following library declaration if instantiating
 ---- any Xilinx primitives in this code.
 --library UNISIM;
 --use UNISIM.VComponents.all;
 
entity subfilta is
 Port ( dout : out STD_LOGIC_vector(23 downto 0);
 clk : in STD_LOGIC;
 
reset : in STD_LOGIC;
 din : in STD_LOGIC_vector(7 downto 0));
 end subfilta;
 
architecture Behavioral of subfilta is
 
--component DFF is 
-- port(
 -- q : out STD_LOGIC_vector(27 downto 0); --output connected to the adder
 -- Clk :in std_logic; -- Clock input
 -- d :in STD_LOGIC_vector(27 downto 0) -- Data input from the MCM block.
 -- );
 --end component; 
 
component DFFa is 
port(
 q : out STD_LOGIC_vector(7 downto 0); --output connected to the adder
 Clk :in std_logic; -- Clock input
 d :in STD_LOGIC_vector(7 downto 0) -- Data input from the MCM block.
 );
 end component; 
 
 
 
signal H00,H032,H064 : STD_LOGIC_vector(15 downto 0) := (others => '0');
 --signal MCM00,MCM01,MCM02,MCM03 : STD_LOGIC_vector(31 downto 0) := (others => '0');
 signal add_out01: STD_LOGIC_vector(23 downto 0) := (others => '0');
 --signal Q01,Q02,Q03 : STD_LOGIC_vector(31 downto 0) := (others => '0');
 signal din1,din2:std_logic_vector(7 downto 0):=(others =>'0');
 --signal Q0100 : STD_LOGIC_vector(27 downto 0) := (others => '0');
 --signal Q01000 : STD_LOGIC_vector(27 downto 0) := (others => '0');
 begin
 
H00 <= "1111110110101011";
 
H032<= "0011111010011010";
 
H064<= "0000001100010010";
 
add_out01 <=(din*H00)+(din1*H032)+(din2*H064);
 
dffaa : DFFa port map(q=>din1,clk=>clk,d=>din);
 dffbb : DFFa port map(q=>din2,clk=>clk,d=>din1);
 
 
 
p01000:process(Clk,reset)
 begin
 if reset='0' then
 dout <= "000000000000000000000000";
 elsif clk'event and clk='1' then
 
dout <= add_out01;
 
end if;
 end process p01000;
 
 
 
end Behavioral;
 
 
about DFFA
 
library IEEE;
 use IEEE.STD_LOGIC_1164.ALL;
 use IEEE.STD_LOGIC_ARITH.ALL;
 use IEEE.STD_LOGIC_SIGNED.ALL;
 
---- Uncomment the following library declaration if instantiating
 ---- any Xilinx primitives in this code.
 --library UNISIM;
 --use UNISIM.VComponents.all;
 
entity DFFa is
 Port ( Q : out std_logic_vector(7 downto 0);
 CLK : in STD_LOGIC;
 
D : in std_logic_vector(7 downto 0));
 end DFFa;
 
architecture Behavioral of DFFa is
 
 
signal qt1 : std_logic_vector(7 downto 0) := (others => '0');
 
begin 
 
Q <= qt1;
 --
 p10:process(Clk)
 begin 
if ( rising_edge(Clk) ) then 
qt1 <= D; 
end if; 
 
 
 
 
end process p10; 
 
 
 
end Behavioral;

 
Last edited by a moderator:

yuck - pretty hideous code.

Using a few arrays and the like you could probably cut the whole lot down to <50 lines of code. Why are the DFFs their own component? why not just make a DFF in a process?
Why have you got 30+ components that probably do the same thing? yes you should use a for..generate.
 

He's probably got so many of the sub-filters because each one has different coefficients...should make one sub-filter with parameterized coefficients. :p
 

My eyes!!! @_@

May I suggest using for generate?

Can you suggest me for the use of for generate statement. Actually i am avoiding the for generate statement because 96 coefficients polyphase filter the fpga system will become slow. Again if you have any idea from the given code you please write the the code which i have written using for generate statement .But different subfilters have different coefficients. Again tell me what is the meaning of parameterized coefficients
 

I highly suggest a VHDL tutorial. or a good VHDL reference manual.

The Doulos Golden reference guide for VHDL is great (but its not for learning VHDL from).
 

Again if you have any idea from the given code you please write the the code which i have written using for generate statement .But different subfilters have different coefficients. Again tell me what is the meaning of parameterized coefficients

Sure. Just send me your billing address. :p

make a module for the sub-filters. make an array with the coefficients in them. make a for generate that instantiates the parameterized modules based on the coefficients in the parameter array. It should do the same as your very loooooooong piece of code, but then suddenly be more readable.
 

Sure. Just send me your billing address. :p

make a module for the sub-filters. make an array with the coefficients in them. make a for generate that instantiates the parameterized modules based on the coefficients in the parameter array. It should do the same as your very loooooooong piece of code, but then suddenly be more readable.

please can you do the same thing with your own example with 96 coefficients using for genearate statement.Actually the coefficients is from coe file and it is 16 bit wide and in hexadecimal representation.Actually on coefficient i can give you as an example is ffee in hexadecimal.like this you can create your own 96 coefficients in hexadecimal format arbitrarily and tell me how to write for generate statement and tell me howmake an array with the coefficients .Can you please write the code and tell me the meaning of parameterized modules based on the coefficients in the parameter array by writing the code please.
 

... tell me how to write for generate statement and tell me howmake an array with the coefficients ...

I suggest you:
1 - read a vhdl book of your choice
2 - try a few examples
3 - rewrite your current code in the manner suggested in previous posts
4 - profit!
 

I suggest you:
1 - read a vhdl book of your choice
2 - try a few examples
3 - rewrite your current code in the manner suggested in previous posts
4 - profit!

Actually i can read books but i am in lack of time so i please suggest you to do as i have written in the previous post.i have read the books and i know the for generate statement but from your side please explain me the thing with a code
 


He's probably got so many of the sub-filters because each one has different coefficients...should make one sub-filter with parameterized coefficients. :p

Is this you expected from me.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_SIGNED.ALL;


entity filter10 is
Port ( clk : in STD_LOGIC;

clk_120mbps: in std_logic;
reset : in STD_LOGIC;
din : in STD_LOGIC_vector(7 downto 0);
ifiltout : out STD_LOGIC_vector(23 downto 0)
);
end filter10;

architecture Behavioral of filter10 is

signal H00,H032,H064 : STD_LOGIC_vector(15 downto 0) := (others => '0');

signal MCM00, add_out01, add_out02,MCM01, MCM02: STD_LOGIC_vector(23 downto 0) := (others => '0');


--signal Q01,Q02,Q03 : STD_LOGIC_vector(31 downto 0) := (others => '0');
signal Q1,Q2:std_logic_vector(23 downto 0):=(others =>'0');



begin
P20:pROCESS(clk,RESET)
VARIABLE CNT:STD_LOGIC_VECTOR(5 DOWNTO 0):="000000";
BEGIN


IF RESET='0' THEN
CNT:="000000";
add_out02<="000000000000000000000000";
ELSIF clk='1' AND clk'EVENT THEN


CNT := CNT +1;
CASE CNT IS
WHEN "000001"=> H00 <= "1111111110101011";
H032<= "0011111010011011";
H064<= "0000001100000010";


WHEN "000010"=> H00 <= "0111110100100100";
H032<= "0100000111111101";
H064<= "0000000100001111";


WHEN "000011"=> H00 <= "1011110010011111";
H032<= "0100010100000111";
H064<= "1111111101011000";


WHEN "000100"=> H00 <= "1111110000100001";
H032<= "0100011110101100";
H064<= "1111110111110001";


WHEN "000101"=> H00 <= "1011101110101101";
H032<= "0100100111100110";
H064<= "1111110011010011";



WHEN "000110"=> H00 <= "1011101101001100";
H032<= "0100101110101110";
H064<= "1111101111111011";


WHEN "000111"=> H00 <= "0111101100000011";
H032<= "0100110011110101";
H064<= "1111101101100000";


WHEN "001000"=> H00 <= "1011101011011010";
H032<= "0100110110111010";
H064<= "1111101100000011";

WHEN "001001"=> H00 <= "1011101011010111";
H032<= "0100110111111100";
H064<= "1111101011010110";


WHEN "001010"=> H00 <= "1011101100000010";
H032<= "0100110110111010";
H064<= "1111101011011011";


WHEN "001011"=> H00 <= "1011101101100000";
H032<= "0100110011110101";
H064<= "1111101100000010";


WHEN "001100"=> H00 <= "1011101111111001";
H032<= "0100101110101101";
H064<= "1111101101001101";


WHEN "001101"=> H00 <= "1011110011010010";
H032<= "0100100111100101";
H064<= "1111101110101111";


WHEN "001110"=>H00 <= "0111110111110000";
H032<= "0100011110101101";
H064<= "1111110000100001";

----
WHEN "001111"=> H00 <= "0111111101011001";
H032<= "0100010100000111";
H064<= "1111110010011110";


WHEN "010000"=> H00 <= "0100000100001111";
H032<= "0100000111111101";
H064<= "1111110100100101";


WHEN "010001"=> H00 <= "0100001100010010";
H032<= "0011111010011011";
H064<= "1111110110101010";


WHEN "010010"=> H00 <= "0100010101100110";
H032<= "0011101011101111";
H064<= "1000000000000000";



WHEN "010011"=> H00 <= "0000100000001001";
H032<= "0011011100000011";
H064<= "0100000000000000";


WHEN "010100"=> H00 <= "0000101011111000";
H032<= "0011001011100111";
H064<= "1000000000000000";


WHEN "010101"=> H00 <= "0000111000110011";
H032<= "0010111010101111";
H064<= "1000000000000000";



WHEN "010110"=> H00 <= "0001000110101110";
H032<= "0010101001010110";
H064<= "0000000001000000";


WHEN "010111"=> H00 <= "1001010101101010";
H032<= "0010010111111110";
H064<= "0000000000000001";



WHEN "011000"=> H00 <= "0101010101101010";
H032<= "0010010111111111";
H064<= "0000000100000000";


WHEN "011001"=> H00 <= "0001110101110100";
H032<= "0001110101101100";
H064<= "0100000000000000";


WHEN "011010"=> H00 <= "0010000110101001";
H032<= "0001100101011010";
H064<= "1000000000000000";


WHEN "011011"=> H00 <= "0010010111111101";
H032<= "0001010101101011";
H064<= "1000000000000000";


WHEN "011100"=> H00 <= "0010101001010110";
H032<= "0001000110101101";
H064<= "0000000000000001";


WHEN "011101"=> H00 <= "0110111010101000";
H032<= "0000111000110110";
H064<= "1000000000000000";


WHEN "011110"=> H00 <= "0011001011101010";
H032<= "0000101011111010";
H064<= "0000000010000000";


WHEN "011111"=> H00 <= "0111011100000010";
H032<= "0000100000001101";
H064<= "0110000000000000";


WHEN "100000"=> H00 <= "0011101011101100";
H032<= "0000010101100100";
H064<= "0000000000000010";

--
CNT := "000000";
when others => H00 <= "0000000000000000";
H032<= "0000000000000000";
H064<= "0000000000000000";


END CASE;
--CNT <= CNT +1;
END IF;
END PROCESS P20;

P40:pROCESS(clk,RESET)
BEGIN
IF RESET='0' THEN

Q1<="000000000000000000000000";
Q2<="000000000000000000000000";
ELSIF clk'EVENT AND clk='1' THEN


MCM00 <= (din*H064);
MCM01 <= (din*H032);
MCM02 <= (din*H00);
add_out01 <= Q1+MCM01;
add_out02 <= Q2+MCM02;
Q1<=MCM00;
Q2<=add_out01;

END IF;
END PROCESS P40;

According to the code for each count values we have different values of H00,H032,H064.So If i want to use the values of H00,H032,H064 for every count value and assign it to Multiplication with din and assign it to MCM00,MCM01,MCM02 .How to do it can you explain it to me now?
 

He's probably got so many of the sub-filters because each one has different coefficients...should make one sub-filter with parameterized coefficients. :p

can you explain with vhdl code to make one sub-filter with parameterized coefficients.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top