网站首页
IC库存
IC展台
电子资讯
技术资料
PDF文档
我的博客
IC72论坛
ic72 logo
搜索关键字: 所有资讯 行业动态 市场趋势 政策法规 新品发布 技术资讯 价格快报 展会资讯
  • 达普IC芯片交易网 > 新闻中心 > 技术信息 > 正文
  • RSS
  • 编了个计数器程序与TESTBENCH
    http://www.ic72.com 发布时间:2007/4/29 9:50:18
    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.std_logic_arith.all;
    use ieee.std_logic_unsigned.all;

    entity counters is
    port(
    reset : in std_logic;
    cs : in std_logic;
    clk : in std_logic;
    q : out std_logic_vector(11 downto 0)
    );
    end counters;

    architecture bev of counters is
    signal one,ten,hun : std_logic_vector(3 downto 0);

    begin
    a: process(clk, reset, cs)
    begin
    if(reset = '1')then
    one<="0000";
    elsif cs = '1' then
    if clk'event and clk = '1' then
    if(one="1001")then
    one<="0000";
    else
    one<=one+1;
    end if;
    end if;
    end if;
    end process;

    b: process(clk, reset, cs, one)
    begin
    if(reset = '1')then
    ten<="0000";
    elsif cs = '1' then
    if clk'event and clk = '1' then
    if(ten="1001" and one="1001")then
    ten<="0000";
    elsif(one="1001")then
    ten<=ten+1;
    end if;
    end if;
    end if;
    end process;

    c: process(clk, reset, cs, one, ten)
    begin
    if(reset = '1')then
    hun<="0000";
    elsif cs = '1' then
    if clk'event and clk = '1' then
    if(hun="1001" and ten="1001" and one="1001")then
    hun<="0000";
    elsif(ten="1001" and one="1001")then
    hun<=hun+1;
    end if;
    end if;
    end if;
    end process ;
    q<=hun&ten&one;
    end bev;


    --********************************************************************
    --* This automatically generated Test Bench template has been created*
    --* By ACTIVE-HDL <TBgen v1.11>. Copyright (C) ALDEC Inc. *
    --* *
    --* This file was generated on: 10:56, 01-12-18 *
    --* Tested entity name: counters *
    --* File name contains tested entity: $DSN\src\counter10.vhd *
    --********************************************************************

    library ieee;
    use ieee.std_logic_unsigned.all;
    use ieee.std_logic_arith.all;
    use ieee.std_logic_1164.all;

    -- Add your library and packages declaration here ...

    entity counters_tb is
    end counters_tb;

    architecture TB_ARCHITECTURE of counters_tb is
    -- Component declaration of the tested unit
    component counters
    port(
    reset : in std_logic;
    cs : in std_logic;
    clk : in std_logic;
    q : out std_logic_vector(11 downto 0) );
    end component;

    -- Stimulus signals - signals mapped to the input and inout ports of tested entity
    signal reset : std_logic;
    signal cs : std_logic;
    signal clk : std_logic;
    -- Observed signals - signals mapped to the output ports of tested entity
    signal q : std_logic_vector(11 downto 0);

    -- Add your code here ...
    constant clk_cycle : time := 10 ns;
    begin

    -- Unit Under Test port map
    UUT : counters
    port map
    (reset => reset,
    cs => cs,
    clk => clk,
    q => q );

    -- Add your stimulus here ...
    rstp : process
    begin
    reset <= '1';
    wait for 10 ns;
    reset <= '0';
    cs <= '1';
    wait;
    end process;

    clkp : process
    begin
    clk <= '1';
    wait for clk_cycle;
    clk <= '0';
    wait for clk_cycle;
    end process;

    end TB_ARCHITECTURE;

    configuration TESTBENCH_FOR_counters of counters_tb is
    for TB_ARCHITECTURE
    for UUT : counters
    use entity work.counters(bev);
    end for;
    end for;
    end TESTBENCH_FOR_counters;


    www.ic72.com 达普IC芯片交易网
  • 行业动态
  • 市场趋势
  • 政策法规
  • 新品发布
  • Baidu

    IC快速检索:abcdefghijklmnopqrstuvwxyz0123456789
    COPYRIGHT:(1998-2010) IC72 达普IC芯片交易网
    客户服务:service@IC72.com 库存上载:IC72@IC72.com
    (北京)联系方式: 在线QQ咨询:点击这里给我发消息 联系电话:010-82614113 传真:010-82614123
    京ICP备06008810号-21 京公网安备 11010802032910 号 企业资质