Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

Pre-Emphasis with IIR Filter

Hello!

I want to do a classic Pre-Emphasis with VHDL. Normally this is implemented with an IIR-Filter. I tried to do this in VHDL with the following formula I found in the web: y(i)=x(i)-(x(i-1)*k) . "k" is a factor between 0.95....0.97.

When I do this the higher frequencies of an audio-signal have to rise in the magnitude.

In my case only all frequencies are attenuated...what am I doing wrong??

Here is my code:

begin

if (rst = '0') then

xi := (others => '0');

xi1 := (others => '0');

yn_tmp := (others => '0');

yn_tmp2 := (others => '0');

b0_var := ("01100001"); --97

div := ("01100100"); --100

elsif (clk'event and clk = '1') then

x <= input;

yn_tmp := xi1 * b0_var;

yn_tmp2 := yn_tmp / div;

yn := resize(xi, yn_tmp2'length) - yn_tmp2;

output <= resize(yn, output'length);

xi1 := resize(yn, xi1'length);

xi := x;

end if;

Thanks for your help!

Tobias

11 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You can increase dc gain by rescaling the coeffs.

    The following scaling may be useful:

    h =[16 -15.5].

    this should give you some 20dB more near dc.

    To implement that you need to multiply inpyt by 16, use shift by 4 bits instead of multiplication and thats why I chose this value. The other coeff will be -15.5 = 155/10.

    You can also avoid division by scaling 155/10 to ?/16 then just truncate 4 bits.

    But be warned that this gain could be too much for high frequencies and lead to clipping/overflow, in that case keep coming down.