zoukankan      html  css  js  c++  java
  • 关于vhdl中integer消耗资源的一些讨论

    源程序:注意红色字体为之后对比的中将做改动的语句

    library ieee;

    use ieee.std_logic_1164.all;

    use ieee.std_logic_unsigned.all;

    use ieee.std_logic_arith.all;

    entity control is

    port(clk:in std_logic;

    dip1:in std_logic;

    --bcd:out std_logic_vector(3 downto 0);

    --bcd:out integer range 1 to 9 ;

    bcd:out integer ;

    en:out std_logic);

    end entity control;

    architecture behav of control is

    type state_type is (s0,s1);

    signal state:state_type;

    signal cnt:std_logic_vector(3 downto 0):="0001";

    --signal cnt:integer range 1 to 9 :=1;

    --signal cnt:integer :=1;

    begin

    process(clk)

    begin

    if rising_edge(clk) then

    if dip1='1' then

    case state is

    when s0 => if cnt>1 then cnt<=cnt-1;

    else cnt<=cnt+1;state<=s1;

    end if;

    when s1 => if cnt<9 then cnt<=cnt+1;

    else cnt<=cnt-1;state<=s0;

    end if;

    end case;

    end if;

    end if;

    end process;

    en <= '1';

    --bcd <= cnt;

    --bcd <= conv_std_logic_vector(cnt,4);

    bcd <= conv_integer(cnt);

    end behav;

    第一种: 端口处及内部信号都是用integer

    --bcd:out std_logic_vector(3 downto 0);

    --bcd:out integer range 1 to 9 ;

    bcd:out integer ;

    --signal cnt:std_logic_vector(3 downto 0):="0001";

    --signal cnt:integer range 1 to 9 :=1;

    signal cnt:integer :=1;

    bcd <= cnt;

    --bcd <= conv_std_logic_vector(cnt,4);

    --bcd <= conv_integer(cnt);

    编译时间最长,大概30~40秒吧,可能更长

    clip_image001_thumb1

    第二种: 端口处及内部信号都是用integer range 1 to 9

    --bcd:out std_logic_vector(3 downto 0);

    bcd:out integer range 1 to 9 ;

    --bcd:out integer ;

    --signal cnt:std_logic_vector(3 downto 0):="0001";

    signal cnt:integer range 1 to 9 :=1;

    --signal cnt:integer :=1;

    bcd <= cnt;

    --bcd <= conv_std_logic_vector(cnt,4);

    --bcd <= conv_integer(cnt);

    编译了13秒

    clip_image002_thumb1

    第三种: 端口处及内部信号都是用std_logic_vector(3 downto 0)

    bcd:out std_logic_vector(3 downto 0);

    --bcd:out integer range 1 to 9 ;

    --bcd:out integer ;

    signal cnt:std_logic_vector(3 downto 0):="0001";

    --signal cnt:integer range 1 to 9 :=1;

    --signal cnt:integer :=1;

    bcd <= cnt;

    --bcd <= conv_std_logic_vector(cnt,4);

    --bcd <= conv_integer(cnt);

    编译了11秒

    clip_image003_thumb2

    结论:对比前三种情况可知使用range range 1 to 9后,编译器可以对硬件资源使用进行优化,效果相当于使用std_logic_vector(3 downto 0),其消耗的资源相同

    第四种: 端口处使用integer 内部信号使用std_logic_vector(3 downto 0)

    --bcd:out std_logic_vector(3 downto 0);

    --bcd:out integer range 1 to 9 ;

    bcd:out integer ;

    signal cnt:std_logic_vector(3 downto 0):="0001";

    --signal cnt:integer range 1 to 9 :=1;

    --signal cnt:integer :=1;

    --bcd <= cnt;

    --bcd <= conv_std_logic_vector(cnt,4);

    bcd <= conv_integer(cnt);

    clip_image004_thumb1

    第五种: 端口处使用std_logic_vector(3 downto 0) 内部信号使用integer

    bcd:out std_logic_vector(3 downto 0);

    --bcd:out integer range 1 to 9 ;

    --bcd:out integer ;

    --signal cnt:std_logic_vector(3 downto 0):="0001";

    --signal cnt:integer range 1 to 9 :=1;

    signal cnt:integer :=1;

    --bcd <= cnt;

    bcd <= conv_std_logic_vector(cnt,4);

    --bcd <= conv_integer(cnt);

    clip_image005_thumb1

    结论 端口使用integer耗费管脚及一些内部宏单元 内部信号量使用integer耗费大量宏单元但不耗费管脚

  • 相关阅读:
    问题-[DelphiXE2]提示第三控件不存在
    问题-[DelphiXE2]编译程序体积大的问题
    问题-[delphi2007、2010]无法二次启动,报EditorLineEnds.ttr被占用,进程一直有bds.exe?
    问题-[VMware Workstation]断电后,重启电脑,之后就提示“内部错误”
    问题-[Delphi]通过Map文件查找内存地址出错代码所在行
    问题-[WIN8.132位系统]安装Win8.1 遇到无法升级.NET Framework 3.5.1
    问题-[DelphiXE7]新建的安桌模拟器运行程序闪退
    问题-[Delphi]用LoadLibrary加载DLL时返回0的错误
    问题-[Access]“无法打开工作组信息文件中的表 'MSysAccounts'”的问题的解决方法
    教程-Delphi 调用控制面板设置功能
  • 原文地址:https://www.cnblogs.com/maliqian/p/2290805.html
Copyright © 2011-2022 走看看