集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 1519|回复: 3

我写的IIR 滤波器程序,输入正弦波,出来却是方波,求高手帮忙查找一下问题!谢了!

[复制链接]
lu1990 发表于 2011-8-24 09:54:28 | 显示全部楼层 |阅读模式
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
use ieee.std_logic_arith.all;

entity IIR is
port(clk,reset:in std_logic;
         data_in:in std_logic_vector(9 downto 0);
         data_outut std_logic_vector(11 downto 0));
end entity;

architecture beh of IIR is
signal data_out_x: std_logic_vector(11 downto 0);
signal x0,x1,x2,y0,y1,y2:std_logic_vector(10 downto 0);
signal x0_result,x1_result,x2_result,y0_result,y1_result,y2_result:std_logic_vector(24 downto 0);
signal foward_feedback,afterward_feedback:std_logic_vector(24 downto 0);
signal data:std_logic_vector(24 downto 0);

constant a1:std_logic_vector(13 downto 0):=conv_std_logic_vector(-7644,14);
constant a2:std_logic_vector(13 downto 0):=conv_std_logic_vector(3549,14);
constant b0:std_logic_vector(13 downto 0):=conv_std_logic_vector(273,14);
--constant b1:std_logic_vector(12 downto 0):=conv_std_logic_vector(0,14);
constant b2:std_logic_vector(13 downto 0):=conv_std_logic_vector(-273,14);

component lpm_mult0 IS
        PORT
        (
                dataa                : IN STD_LOGIC_VECTOR (13 DOWNTO 0);
                datab                : IN STD_LOGIC_VECTOR (10 DOWNTO 0);
               
                result                : OUT STD_LOGIC_VECTOR (24 DOWNTO 0)
        );
END component;

begin
process(reset,clk)
begin
if rising_edge(clk)then
        if(reset='0')then
        x0<=(others=>'0');
        x1<=(others=>'0');
        x2<=(others=>'0');
    else
        x0<=data_in(9)&data_in;
        x1<=x0;
        x2<=x1;
        end if;
end if;
end process;
u1:lpm_mult0 port map(b0,x0,x0_result);
--u2:lpm_mult0 port map (b1,x1,x1_result);
u3:lpm_mult0 port map (b2,x2,x2_result);
foward_feedback<=x0_result+x2_result;--x1_result+

process(reset,clk)
begin
if rising_edge(clk)then
        if(reset='0')then
        y0<=(others=>'0');
        y1<=(others=>'0');
        y2<=(others=>'0');
    else
        y0<=data(24 downto 14);
        y1<=y0;
        y2<=y1;
        end if;
end if;
end process;

u5:lpm_mult0 port map (a1,y1,y1_result);
u6:lpm_mult0 port map (a2,y2,y2_result);
afterward_feedback<=y2_result+y1_result;--+y0_result;

data<=foward_feedback+afterward_feedback;

process(clk,reset)
begin
if rising_edge(clk)then
        if reset='0' then
        data_out_x<=(others=>'0');
        else
        data_out_x<=data(24 downto 13);
        end if;
end if;
end process;

data_out<=data_out_x;
end;
 楼主| lu1990 发表于 2011-8-24 10:20:44 | 显示全部楼层
自己顶一下,急求高手帮忙!
 楼主| lu1990 发表于 2011-8-24 20:39:48 | 显示全部楼层
为什么就没有哪位大侠帮一下啊!
liujilei311 发表于 2011-8-25 08:41:27 | 显示全部楼层
建议你根据仿真模型图,认真的梳理一下程序,另外和你的测试文件可能也有关系的!!!!!!!
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-4-29 12:04 , Processed in 0.075798 second(s), 24 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表