完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我写了一个滤波器的程序,但是仿真的结果不符合,我找不到错误,有没有人能抽空帮我看一下。 滤波器的系数为-12 9 -12 -22 -3 -1 -38 -32 61 124 61 -32 -38 -1 -3 -22 -12 9 -12
程序如下,其中constant为滤波器的系数 library ieee; use ieee.std_logic_arith.all; use ieee.std_logic_1164.all; entity filter is port( clk,reset :in std_logic; sample_in :in signed (8 downto 0); result_out :out signed(21 downto 0)); end filter; architecture behave of filter is type coef_arr is array(0 to 18) of signed (7 downto 0); constant coefs : coef_arr:=("10001100","00001001","10001100","10010110","10000011", "10000001","10100110","10100000","00111101","01111110","00111101","10010000","10100110", "10000001","10000011","10010110","10001100","00001001","10001100"); begin process(clk,reset) type shift_register is array (18 downto 0) of signed (8 downto 0); variable shift : shift_register; variable temp : signed(8 downto 0); variable mul_value :signed(16 downto 0); variable acc_value : signed (21 downto 0); begin if(reset='0')then for i in 0 to 17 loop shift(i):="000000000"; end loop; result_out<="0000000000000000000000"; elsif (clk'event and clk='1')then temp:=sample_in; mul_value:=temp*coefs(0); acc_value:=conv_signed(mul_value,22); for i in 17 downto 0 loop mul_value:=shift(i)*coefs(i+1); acc_value:=acc_value+conv_signed(mul_value,22); shift(i+1):=shift(i); end loop; shift(0):=temp; end if; result_out<=acc_value; end process; end behave; 我输入一个从1到10的序列仿真的结果如下: 但是我用matlab进行卷积的结果为 din=[1:1:10]; >> h=[-12,9,-12,-22,-3,-1,-38,-32,61,124,61,-32,-38,-1,-3,-22,-12,9,-12]; >> conv(h,din) ans = Columns 1 through 8 -12 -15 -30 -67 -107 -148 -227 -338 Columns 9 through 16 -388 -314 -47 -31 169 490 621 711 Columns 17 through 24 1197 1664 1128 -162 -883 -642 -303 -333 Columns 25 through 28 -340 -135 -18 -120
|
|
相关推荐 |
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
基于 DSP5509 进行数字图像处理中 Sobel 算子边缘检测的硬件连接电路图
2530 浏览 0 评论
707 浏览 0 评论
普中科技F28335开发板中,如何使用aic23播放由代码生成的正弦波
2965 浏览 0 评论
3730 浏览 1 评论
1226 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-29 01:11 , Processed in 0.371117 second(s), Total 43, Slave 35 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号