在VHDL中常用的 预定义程序包有哪几个,怎样使用这些程序包

在VHDL中常用的 预定义程序包有哪几个,怎样使用这些程序包,第1张

LIBRARY ieee

USE ieee.std_logic_1164.all

USE ieee.std_logic_arith.all

USE ieee.std_logic_unsigned.all

跟C类似,把这些库象头文件一样加到程序前面

1.std_logic_1164 IEEE的标准库,仅定义了std_ulogic, std_ulogic_vector, std_logic, std_logic_vector等类型以及他们的逻辑 *** 作(and, or, xor, not, nand, nxor, nor)

2.numeric_std IEEE的标准库,定义了unsigend/signed以及他们的算术运算(包括与integer),+,-,*,/, rem, mod, abs ,to_integer/to_signed/to_unsigned也都在这个库里面定义。

3.std_logic_arith 是synopsys的一个扩展,定义了unsigned, signed与integer, std_ulogic之间的算术运算、关系运算(>, <, >=, <=, =, /=)算术运算返回类型可以是signed, unsigned或std_logic_vector还定义了unsigned, signed, integer, std_logic_vector机种类型之间的转换函数CONV_STD_LOGIC_VECTOR, CONV_INTEGER, CONV_SIGNED, CONV_UNSIGNED

4.std_logic_unsigned 是synopsys的一个扩展,定义了基于std_logic_vector与std_logic_vector、std_logic_vector与integer之间的算术运算, >, <, >=, <=, =, /=返回类型是std_logic_vector或boolean注意这里面的function的运算都是基于unsigned,就是说std_logic_vector和integer都变成unsigned之后再用std_logic_arith库中的function完成

  std_logic_signed跟std_logic_unsigned类似,唯一的差别是,这里面的function都是先把 *** 作数(std_logic_vector或integer类型)都转换成signed之后再用std_logic_arith库中的function完成

在用这些库的时候,基本原则是要知道你想要EDA软件实现什么样的运算。大部分情况下,std_logic_vector应该作为unsigned参与运算。如果一定要std_logic_vector作为signed参与运算,最好用显示的to_integer来做。

Tips: 看到有人说, std_ulogic比std_logic好的地方在于,simulator能报告多个driver shorted together的bug。其他方面,std_ulogic与std_logic完全兼容。

VHDL的信号声明(也可以叫定义)语句放在结构体的首部,即ARCHITECTURE .......... IS与BEGIN之间,而变量声明则放在进程的首部,PROCESS与BEGIN之间,如果是在子程序(过程或者函数)中声明变量,则放在子程序的首部,即子程序的BEGIN之前。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/8091376.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-13
下一篇 2023-04-13

发表评论

登录后才能评论

评论列表(0条)

保存