我目前正在尝试在我的Verilog设计中使用某些遗留的VHDL代码。虽然可以在Verilog中实例化VHDL模块,但我找不到在Verilog中调用VHDL函数的方法。(除了将其包装在VHDL模块中并实例化该模块之外)。有没有办法在Verilog中直接调用VHDL函数?
发布于 2016-09-28 21:08:26
这可能取决于模拟器。例如,在Modelsim PE v10.2c中,不支持直接从Verilog/SystemVerilog调用VHDL函数
从Verilog/SystemVerilog作用域对VHDL语言对象的
分层引用
支持的对象
唯一可以引用的VHDL对象类型是:信号、共享变量、常量和未在进程中声明的泛型。不支持VHDL函数、过程和类型,也不能读取VHDL过程变量
Modelsim PE用户手册v10.2c,第297页
您可以在SystemVerilog / VHDL模块之间使用带有import关键字的公共包,但同样不支持VHDL函数。
你最好参考你的模拟器手册,看看它是否被支持,因为显然没有普遍接受的方法来做它。
发布于 2017-12-03 08:16:01
正如@Ivoudour所指出的,对此功能的支持依赖于模拟器。然而,对于那些需要这样做的人来说,用法应该大体相同。这意味着您可以简单地将基于VHDL的组件视为另一个模块。这假设您将设计编译到同一个库中。
下面的示例使用具有以下结构的ModelSim Altera Edition v10.4b : and_tb (VHDL) -> and_bits (verilog) -> and2 (VHDL)
and2.vhd
library ieee ;
use ieee.std_logic_1164.all ;
entity and2 is
port (
a : in std_logic;
b : in std_logic;
c : out std_logic
);
end and2;
architecture behavior of and2 is
begin
c <= a and b;
end behavior ;and_bits.v
`default_nettype none
`timescale 1ns/1ns
module and_bits #(
parameter W = 5
) (
input wire [W-1:0] a,
input wire [W-1:0] b,
output wire [W-1:0] c
);
genvar i;
for (i=0; i<=W-1; i=i+1) begin: AND_GENERATE
and2 u_and2 (
.a (a[i]),
.b (b[i]),
.c (c[i])
);
end
endmodule
`resetalland_tb.vhd
library ieee ;
use ieee.std_logic_1164.all ;
entity and_tb is
end and_tb;
architecture tb of and_tb is
signal a : std_logic_vector(3 downto 0) := "0110";
signal b : std_logic_vector(3 downto 0) := "1111";
signal c : std_logic_vector(3 downto 0);
component and_bits
generic ( W : integer );
port (
a : in std_logic_vector(W-1 downto 0);
b : in std_logic_vector(W-1 downto 0);
c : out std_logic_vector(W-1 downto 0)
);
end component;
begin
dut: and_bits
generic map (W => 4)
PORT MAP(a=>a, b=>b, c=>c);
end tb ;模拟
在ModelSim控制台中键入以下内容
vlib work
vcom and2.vhd
vlog and_bits.v
vcom and_tb.vhd像往常一样模拟。
https://stackoverflow.com/questions/36758494
复制相似问题