kannan2590
Member level 4
- Joined
- Sep 1, 2012
- Messages
- 77
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- india
- 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
for subfilta
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: