正如你已经发现,在“图像属性只申报标量类型,不是数组或记录:通常的做法是创建一个自己的测试实用程序库包括在一个包to_string
或image
功能开始设计,并在整个过程中使用它。
将这些库进行标准化是完全可能的,你可能会发现很多潜在的“测试工具”包,但没有一个真正适合成为标准。
这就是说,你可能会发现下面的包是一个有用的起点。
它封装了一些自定义数据类型,并对它们进行操作。没有泛型,但是由于超载,您可以像使用通用函数一样使用该包。 (你会注意到函数体是不完整的!)扩展它并添加类型很容易,大多数情况下都是粘贴&;它使主设计保持了很多混乱。
将类型declns和(仅限testbench)函数分离为两个单独的包可能会更好; Types
和Types_Test_Utils
。然后在整个设计中使用类型,而测试实用程序仅暴露于测试平台。
library IEEE;
use IEEE.numeric_std.all;
package Types is
subtype SmallNum is UNSIGNED(7 DOWNTO 0);
subtype BiggerNum is UNSIGNED(19 DOWNTO 0);
subtype Bits is BIT_VECTOR(7 DOWNTO 0);
-- and operations on these types
-- Simulate generic procedures using overloading
function to_string(N : Unsigned) return String;
function to_string(N : Bits) return String;
procedure eq_checker (name : string; sig,should : SmallNum; at : time);
procedure eq_checker (name : string; sig,should : Bits; at : time);
end Types;
package body Types is
function to_string(N : Unsigned) return String is
variable temp : string(1 to (N'length + 3)/4) := (others => 'x');
begin
-- not finished!
return temp;
end to_string;
function to_string(N : Bits) return String is
begin
return "hello";
end to_string;
procedure eq_checker(name : string; sig,should : SmallNum; at : time) is
begin
if (at = now) then
if sig = should then
report to_string(sig) & "has same value" severity note;
else
report to_string(sig) & "has not same value as " & to_string(should) severity note;
end if;
end if;
end procedure eq_checker;
procedure eq_checker(name : string; sig,should : Bits; at : time) is
begin
null;
end procedure eq_checker;
end Types;
和一个简单的测试吧...
use Work.Types.all;
ENTITY tester IS
END tester;
ARCHITECTURE behavior OF tester IS
Signal a,b : SmallNum := X"AA";
Signal c : BiggerNum := X"ABCDE";
SIGNAL x,y : Bits := X"BB";
BEGIN
process(a,x) is
begin
report "value: " & to_string(X) severity note;
report "and this one: " & to_string(a) severity note;
report "this one too: " & to_string(c) severity note;
end process;
END;
+1开始使用亚型...... – 2013-03-14 12:05:57
的任择议定书要求的转换串。另一方面是写/写。看到布赖恩的帖子转换为字符串 – 2015-10-06 14:58:06
好吧,一个'行'只是被定义为'访问'类型'字符串'。所以,可以将其转换为函数并返回'li.all'。 – PlayDough 2016-03-17 21:48:55