S
Ste_ee
Guest
Hi to all! I did this filter: 128 order, with 8 bit input and 16 bit coefficients (2 complement).
But i don't understand because the multiplication doesn't work. My VHDL is very simple and behavioral:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_signed.ALL;
use IEEE.STD_LOGIC_arith.ALL;
entity fir128 is
port(
input: in std_logic_vector(7 downto 0);
clk : in std_logic;
output: out std_logic_vector(200 downto 0)
);
end fir128;
architecture Behavioral of fir128 is
type mult_type is array (128 downto 0) of std_logic_vector(23 downto 0);
signal sig_coeff : mult_type;
type add_type is array (128 downto 0) of std_logic_vector(200 downto 0);
signal sig_add : add_type;
type memory is array (128 downto 0) of std_logic_vector(15 downto 0);
signal coeff : memory :=(
"0000000000000111",
"0000000000000101",
"0000000000000001",
"1111111111111100",
"1111111111111001",
"1111111111111000",
"1111111111111100",
"0000000000000010",
"0000000000001001",
"0000000000001100",
"0000000000001001",
"0000000000000001",
"1111111111110110",
"1111111111101111",
"1111111111101111",
"1111111111111001",
"0000000000001000",
"0000000000010111",
"0000000000011011",
"0000000000010010",
"1111111111111110",
"1111111111100110",
"1111111111011000",
"1111111111011101",
"1111111111110110",
"0000000000011000",
"0000000000110100",
"0000000000111001",
"0000000000100000",
"1111111111110010",
"1111111111000100",
"1111111110101110",
"1111111111000001",
"1111111111110111",
"0000000000111011",
"0000000001101010",
"0000000001101000",
"0000000000101111",
"1111111111010101",
"1111111110000011",
"1111111101100111",
"1111111110010111",
"0000000000000110",
"0000000010000011",
"0000000011001110",
"0000000010111000",
"0000000000111101",
"1111111110001101",
"1111111011111101",
"1111111011011100",
"1111111101010010",
"0000000000111011",
"0000000100110100",
"0000000110111011",
"0000000101101111",
"0000000001000111",
"1111111010100101",
"1111110101000110",
"1111110011111101",
"1111111001011100",
"0000000101110100",
"0000010110110011",
"0000101000001101",
"0000110101001110",
"0000111010000010",
"0000110101001110",
"0000101000001101",
"0000010110110011",
"0000000101110100",
"1111111001011100",
"1111110011111101",
"1111110101000110",
"1111111010100101",
"0000000001000111",
"0000000101101111",
"0000000110111011",
"0000000100110100",
"0000000000111011",
"1111111101010010",
"1111111011011100",
"1111111011111101",
"1111111110001101",
"0000000000111101",
"0000000010111000",
"0000000011001110",
"0000000010000011",
"0000000000000110",
"1111111110010111",
"1111111101100111",
"1111111110000011",
"1111111111010101",
"0000000000101111",
"0000000001101000",
"0000000001101010",
"0000000000111011",
"1111111111110111",
"1111111111000001",
"1111111110101110",
"1111111111000100",
"1111111111110010",
"0000000000100000",
"0000000000111001",
"0000000000110100",
"0000000000011000",
"1111111111110110",
"1111111111011101",
"1111111111011000",
"1111111111100110",
"1111111111111110",
"0000000000010010",
"0000000000011011",
"0000000000010111",
"0000000000001000",
"1111111111111001",
"1111111111101111",
"1111111111101111",
"1111111111110110",
"0000000000000001",
"0000000000001001",
"0000000000001100",
"0000000000001001",
"0000000000000010",
"1111111111111100",
"1111111111111000",
"1111111111111001",
"1111111111111100",
"0000000000000001",
"0000000000000101",
"0000000000000111");
signal zero : std_logic_vector(200 downto 0):=(others=>'0');
begin
process(clk)
begin
if clk'event and clk='1' then
sig_add(128)<= zero + sig_coeff(128);
for i in 128 downto 0 loop
sig_coeff(i)<= input*coeff(i);
if i = 0 then
sig_add(0) <= sig_add(1)+sig_coeff(0);
else
sig_add(i-1)<=sig_add(i)+sig_coeff(i-1);
end if;
end loop;
end if;
end process;
output<=sig_add(0);
end Behavioral;
But i don't understand because the multiplication doesn't work. My VHDL is very simple and behavioral:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_signed.ALL;
use IEEE.STD_LOGIC_arith.ALL;
entity fir128 is
port(
input: in std_logic_vector(7 downto 0);
clk : in std_logic;
output: out std_logic_vector(200 downto 0)
);
end fir128;
architecture Behavioral of fir128 is
type mult_type is array (128 downto 0) of std_logic_vector(23 downto 0);
signal sig_coeff : mult_type;
type add_type is array (128 downto 0) of std_logic_vector(200 downto 0);
signal sig_add : add_type;
type memory is array (128 downto 0) of std_logic_vector(15 downto 0);
signal coeff : memory :=(
"0000000000000111",
"0000000000000101",
"0000000000000001",
"1111111111111100",
"1111111111111001",
"1111111111111000",
"1111111111111100",
"0000000000000010",
"0000000000001001",
"0000000000001100",
"0000000000001001",
"0000000000000001",
"1111111111110110",
"1111111111101111",
"1111111111101111",
"1111111111111001",
"0000000000001000",
"0000000000010111",
"0000000000011011",
"0000000000010010",
"1111111111111110",
"1111111111100110",
"1111111111011000",
"1111111111011101",
"1111111111110110",
"0000000000011000",
"0000000000110100",
"0000000000111001",
"0000000000100000",
"1111111111110010",
"1111111111000100",
"1111111110101110",
"1111111111000001",
"1111111111110111",
"0000000000111011",
"0000000001101010",
"0000000001101000",
"0000000000101111",
"1111111111010101",
"1111111110000011",
"1111111101100111",
"1111111110010111",
"0000000000000110",
"0000000010000011",
"0000000011001110",
"0000000010111000",
"0000000000111101",
"1111111110001101",
"1111111011111101",
"1111111011011100",
"1111111101010010",
"0000000000111011",
"0000000100110100",
"0000000110111011",
"0000000101101111",
"0000000001000111",
"1111111010100101",
"1111110101000110",
"1111110011111101",
"1111111001011100",
"0000000101110100",
"0000010110110011",
"0000101000001101",
"0000110101001110",
"0000111010000010",
"0000110101001110",
"0000101000001101",
"0000010110110011",
"0000000101110100",
"1111111001011100",
"1111110011111101",
"1111110101000110",
"1111111010100101",
"0000000001000111",
"0000000101101111",
"0000000110111011",
"0000000100110100",
"0000000000111011",
"1111111101010010",
"1111111011011100",
"1111111011111101",
"1111111110001101",
"0000000000111101",
"0000000010111000",
"0000000011001110",
"0000000010000011",
"0000000000000110",
"1111111110010111",
"1111111101100111",
"1111111110000011",
"1111111111010101",
"0000000000101111",
"0000000001101000",
"0000000001101010",
"0000000000111011",
"1111111111110111",
"1111111111000001",
"1111111110101110",
"1111111111000100",
"1111111111110010",
"0000000000100000",
"0000000000111001",
"0000000000110100",
"0000000000011000",
"1111111111110110",
"1111111111011101",
"1111111111011000",
"1111111111100110",
"1111111111111110",
"0000000000010010",
"0000000000011011",
"0000000000010111",
"0000000000001000",
"1111111111111001",
"1111111111101111",
"1111111111101111",
"1111111111110110",
"0000000000000001",
"0000000000001001",
"0000000000001100",
"0000000000001001",
"0000000000000010",
"1111111111111100",
"1111111111111000",
"1111111111111001",
"1111111111111100",
"0000000000000001",
"0000000000000101",
"0000000000000111");
signal zero : std_logic_vector(200 downto 0):=(others=>'0');
begin
process(clk)
begin
if clk'event and clk='1' then
sig_add(128)<= zero + sig_coeff(128);
for i in 128 downto 0 loop
sig_coeff(i)<= input*coeff(i);
if i = 0 then
sig_add(0) <= sig_add(1)+sig_coeff(0);
else
sig_add(i-1)<=sig_add(i)+sig_coeff(i-1);
end if;
end loop;
end if;
end process;
output<=sig_add(0);
end Behavioral;