Hallo,
ich bin ein vhdl anfäger und habe folgende code um ein digitales filter
zu implementieren.nun zeigt er zwar keine fehler an bei compilieren aber
wenn ich die koefficiennten tausche...versteht es jemand...bzw kann mir
bitte jemand erklären ob man die berechnete coefficienten umrechnen
musst?und wie?
danke im vorraus
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
entity filter is
--generic ( FILTERLAENGE :natural:=6;
-- FILTERKOEFF :array (natural range 0 to FILTERLAENGE - 1) of
signed( 7 downto 0) :=(-1,-1,-1,-1,-1,-1)
-- );
port (
clk : IN STD_LOGIC;
reset : IN STD_LOGIC;
filterGO : IN STD_LOGIC;
filterEingang : IN STD_LOGIC_VECTOR (15 downto 0);
filterAusgang : OUT STD_LOGIC_VECTOR (15 downto 0)
);
end;
architecture beh of filter is
constant FILTERLAENGE: natural := 6;
type t_memory is array (natural range 0 to FILTERLAENGE - 1) of
signed(15 downto 0);
type t_Koeff is array (natural range 0 to FILTERLAENGE - 1) of signed(
7 downto 0);
constant FILTERKOEFF: t_Koeff := (to_signed(1, 8), to_signed(1, 8),
to_signed(1, 8),
to_signed(1, 8), to_signed(1, 8), to_signed(1, 8));
signal Speicher: t_memory;
begin
process(clk, reset)
variable filterMult: signed(23 downto 0) := (others => '0');
variable filterSumme: signed(24 downto 0) := (others => '0');
begin
if (reset = '0') then
filterAusgang <= (others => '0');
Speicher <= (others => (others => '0'));
elsif (rising_edge(clk)) then
if (filterGO = '1') then
-- held samples from "filterEingang" stored in Speicher
for I in 0 to FILTERLAENGE - 2
loop
Speicher(I) <= Speicher(I + 1);
end loop;
Speicher(FILTERLAENGE - 1) <= signed(filterEingang);
-- filter operation y(n) = b0*x(n) + b1*x(n - 1) + ... + bn*x(0)
filterSumme := (others => '0');
for I in 0 to FILTERLAENGE - 1
loop
filterMult := FILTERKOEFF(I)*Speicher(FILTERLAENGE - (I + 1));
filterSumme:= filterSumme + resize(filterMult, 25);
end loop;
-- current filter result in "filterSumme" has 25 bits width
-- needed y(n) has to be a 16 bits data
filterAusgang <= std_logic_vector(resize(filterSumme, 16));
end if;
end if;
end process;
end beh;
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.