在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
芯片精品文章合集(500篇!) 创芯人才网--重磅上线啦!
查看: 3351|回复: 8

[原创] DSP设计范例:FIR程序设计(VHDL)

[复制链接]
发表于 2006-1-25 05:19:26 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
本帖最后由 cjsb37 于 2013-4-29 09:19 编辑

---------------------------------------------------------------
-- FIR Digital Filter Design (DSP example)
--
-- VHDL Data-Flow modeling
-- KEYWORD:
-- generate, array, range, constant and subtype
---------------------------------------------------------------
library IEEE;-- declare the library
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
---------------------------------------------------------------
entity FIR_filter is
port(rst:instd_logic;
clk:instd_logic;
coef_ld:instd_logic;
start:instd_logic;
o_enable:instd_logic;
bypass:instd_logic;
Xn_in:in std_logic_vector(3 downto 0);
Yn_in:instd_logic_vector(15 downto 0);
Xn_oututstd_logic_vector(3 downto 0);
Yn_oututstd_logic_vector(15 downto 0)
);
end FIR_filter;
architecture BEH of FIR_filter is
    constant K:integer := 4;-- circuit has four stages
    -- use type and subtype to define the complex signals
    subtype bit4 isstd_logic_vector(3 downto 0);
    subtype bit8 isstd_logic_vector(7 downto 0);
    subtype bit16 isstd_logic_vector(15 downto 0);
    type klx4isarray (K downto 0) of bit4;
    type kx8isarray (K-1 downto 0) of bit8;
    type klx8is      array (K downto 0) of bit8;
    type kx16isarray (K-1 downto 0) of bit16;
    type klx16isarray (K downto 0) of bit16;
    -- define signal in type of arrays
    signalREG1, REG2, COEF: klx4;
    signalMULT8: kx8;
    signalMULT16: kx16;
    signalSUM: klx16;
    signalXn_tmp: bit4;
    signalYn_tmp: bit16;
begin
    -- initialize the first stage
of FIR circuit
    REG2(K)<= Xn_in when (start='1')
else (REG2(K)'range => '0');
    REG1(K) <= (REG1(K)'range => '0');
    SUM(K)  <= Yn_in;
    COEF(K) <= Xn_in;
    -- start the computation, use generate to obtain the  
    -- multiple stages
    gen8:for j in K-1 downto 0 generate
        stages:process (rst, clk)
        begin
        
            if (rst='0') then
        REG1(j) <= (REG1(j)'range => '0');
        REG2(j) <= (REG2(j)'range => '0');
        COEF(j) <= (COEF(j)'range => '0');
        MULT16(j) <= (MULT16(j)'range => '0');
        SUM(j) <= (SUM(j)'range => '0');
    elsif (clk'event and clk ='1') then
        REG1(j) <= REG2(j+1);
        REG2(j) <= REG1(j);
        if (coef_ld = '1') then
            COEF(j) <= COEF(j+1);
          end if;
                MULT8(j) <= signed(REG1(j))*signed(COEF(j));
        MULT16(j)(7 downto 0) <= MULT8(j);   
        if (MULT8(j)(7)='0') then
            MULT16(j)(15 downto 8) <= "00000000";
        else
            MULT16(j)(15 downto 8)  <=  "11111111";
        end if;
        SUM(j) <= signed(MULT16(j))+signed(SUM(j+1));
    end if;
        end process;
    end generate;
    -- control the outputs by concurrent statements
    Xn_tmp <= Xn_inwhen bypass = '1' else
REG2(0) when coef_ld = '0' else
COEF(0);
    Yn_tmp <= Yn_inwhen bypass = '1' else
SUM(0);
    Xn_out <= Xn_tmpwhen o_enable = '0' else
(Xn_out'range => 'Z');
    Yn_out <= Yn_tmpwhen o_enable = '0' else
(Yn_out'range => 'Z');  
end BEH;
------------------------------------------------------------------








发表于 2006-11-1 19:13:30 | 显示全部楼层
顶一下!!
发表于 2006-11-15 16:27:11 | 显示全部楼层
顶一下。。
发表于 2006-11-16 14:27:33 | 显示全部楼层
路过...
发表于 2007-7-7 20:32:52 | 显示全部楼层
特意路过
发表于 2009-2-22 10:48:05 | 显示全部楼层
eetop
发表于 2009-2-22 10:49:32 | 显示全部楼层
eetop
发表于 2009-9-4 22:15:13 | 显示全部楼层
顶一下,赞!
发表于 2009-9-4 22:16:33 | 显示全部楼层
有没有VERILOG的啊?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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


小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-11-15 10:34 , Processed in 0.028427 second(s), 10 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表