要测试的设计是用VHDL编写的,并使用这样的无约束记录作为其端口:
type forward_stream is record
data : std_ulogic_vector;
-- further members
...
end record;
现在应该从systemverilog测试平台驱动这些端口 . 有没有办法使用vhdl记录类型的测试平台信号?如果是这样,我如何约束systemverilog中的记录?
或者我是否必须创建一个约束记录的VHDL包并将其作为要在测试平台中使用的类型提供?
由于HDL支持在不同工具之间变化很大,我问的是questasim(modelsim的大哥,同样的供应商因此有点向下兼容) .
更新
我从Questa SIM用户手册中收集了以下内容:
- 记录映射到struct / packed结构(表9-5)
_999_表9-5中未提及子类型
我试过了:
-
使用系统verilog中的子类型连接到无约束类型的端口
-
使用系统verilog中的子类型连接到具有约束的无约束类型的端口
-
使用系统verilog中的子类型连接到子类型的端口
-
使用系统verilog中的无约束类型(无约束)连接到具有约束的无约束类型的端口 .
示例代码:
VHDL:
library IEEE;
use IEEE.std_logic_1164.all;
package module_crosslanguage_pkg is
type t is record
s : std_ulogic_vector(2 downto 0);
c : std_logic_vector;
end record;
subtype t_s is t(c(1 downto 0));
end package;
use work.module_crosslanguage_pkg.all;
entity dummy_test is
port(a : in t); -- 1.
port(a : in t(c(1 downto 0))); -- 2.
port(a : in t_s); -- 3.
port(a : in t(c(1 downto 0))); -- 4.
end entity;
architecture a of dummy_test is
begin
end;
系统Verilog
module modulebay_testbench();
import module_crosslanguage_pkg::*;
t_s testsignal;
t testsignal2;
dummy_test u(.a(testsignal)); -- 1., 2., 3.
dummy_test u(.a(testsignal2)); -- 4.
endmodule;
错误总是 Fatal: (vsim-3362) The type of VHDL port 'a' is invalid for Verilog connection (1st connection).
1 回答
是的,请参阅Questa用户手册中的 Sharing User-Defined Types . 它显示了如何导入以一种语言定义的包并在另一种语言中使用/导入它们 .