VHDL-2008: 主要增强内容
引言:VHDL-2008的引入对 VHDL 大部分改动都是有用且重要的,但是相对来说改动都是在简化语法。所以,以下列出了一些主要的增强内容。
将PSL集成到VHDL中
VHDL早就支持了asset(断言)声明,其常常用来为VHDL模型添加一些简单的检查器。你可以assert一个表达式的值为TRUE,意味着你希望这个表达式满足这个值。如果assertion表达式的值实际上是FALSE,则模拟器输出error信息。
PSL(Property Specification Language)扩展了这个概念,它提供了一种语法来描述电路随时间的预期行为,并检查 VHDL 代码是否实现了这种行为。到目前为止,PSL声明只能作为meta-comments(编译器实际上可以将其解释为扩展语法的“comments”)添加到VHDL模型中,例如:
--psl assert always req -> next[2] (grant);
类似地,PSL 声明(例如,clocks、properties 和sequences )可以包含在 VHDL 声明区域中。
如果一个并行语句可以译为VHDL 断言语句或 PSL 指令,则会被译为VHDL:
例如下面这一句就被编译为VHDL,而不是PSL。
assert not (a and b);
一些PSL关键字现在还是在VHDL中保留着的关键字,例如property和sequence。其他PSL关键字只在PSL声明和指令中有特殊含义,例如 before 是一个PSL的关键字,而不是VHDL的关键字。
要了解有关PSL的更多信息,参阅 The Designer’s Guide to PSL。
Package 和 subprogram 支持generic
在VHDL中,entity始终允许使用generic,是你可以编写一个参数化的entity,例如一个N-bit计数器。VHDL-2008也允许在packages和subprograms使用generic,使我们更方便地编写一个灵活的、可重用的代码。例子见synthesizable fixed and floating point packages。
Generic 类型,subprograms 和 packages
VHDL中,generics都是常量(constans),而在VHDL-2008,他们也可以是type,subprograms或packages。下列是一个包含type generic(data_type)和一个subprogram generic(function increment)的例子。但我们不能用在architecture中对其使用“+”运算符,因为“+”运算符不一定支持自定义的data types。
library ieee;
use ieee.std_logic_1164.all;
entity incrementer is
generic (type data_type;
function increment (x: data_type) return data_type);
port (I : in data_type;
O : out data_type;
inc : in std_logic);
end entity incrementer;
architecture RTL of incrementer is
begin
O <= increment(I) when inc = '1';
end architecture RTL;
下列是如何实例化该entity:
incr_inst : entity work.incrementer
generic map ( data_type => std_logic_vector(7 downto 0),
increment => add_one )
port map ( I => I, O => O, inc => ena );
新增的可综合的定点和浮点算术包
这些扩展的generics的一个应用是在 VHDL-2008中新的定点和浮点算术包中发现的。
下列是 fixed_generic_pkg 的部分声明:
package fixed_generic_pkg is
generic (fixed_round_style : fixed_round_style_type := fixed_round;
fixed_overflow_style : fixed_overflow_style_type := fixed_saturate;
-- ...
下列是 fixed_pkg 的部分声明:
package fixed_pkg is new IEEE.fixed_generic_pkg
generic map (
fixed_round_style => IEEE.fixed_float_types.fixed_round,
fixed_overflow_style_type => -- ...
原文链接
由个人翻译,如有错误烦请指出