大家好,又見面了,我是你們的朋友全棧君。
注意:verilog中不能調用vhdl的parameter package,即vhdl中定義的parameter 不能被頂層verilog調用
今天在編譯一個Verilog檔案,其中嵌入了VHDL的子產品,其VHDL子產品如下:
entity vhdl_module is
generic (
PARA1 : boolean := false; -- boolean型
PARA2 : boolean := false; -- integral型
);
port (
PORT_A: out std_logic;
PORT_B: in std_logic;
);
end vhdl_module;
architecture synth of vhdl_module is
-- 此處省略
end synth;
複制
在Verilog檔案中做如下調用:
module top(
clock,
res_n,
test
);
input clock;
input res_n;
output test;
vhdl_module
#(
.PARA1(1),
.PRRA2(1)
)
vhdl_module_ins (
.PORT_A(res_n),
.PORT_B(clock)
);
endmodule
複制
Quartus II 編譯後報錯:
Error: VHDL type mismatch error at <component_name>.vhd: boolean type does not match integer literal
經查閱後得知,Quartus II在翻譯VHDL中的boolean類型是用false和true傳遞的,而Synplify和ISE卻用的是1和0傳遞的。故在此處會報錯,需要改成如下方式:
module top(
clock,
res_n,
test
);
input clock;
input res_n;
output test;
vhdl_module
#(
.PARA1("true"), // 此處修改,若false則填入“false”,需加引号,否則任然會報錯!
.PRRA2(1)
)
vhdl_module_ins (
.PORT_A(res_n),
.PORT_B(clock)
);
endmodule
複制
小小技巧,分享給大家。
ps:希望以後不同編譯工具能夠統一該調用參數的格式。
VHDL調用Verilog子產品的時候,要在執行個體化子產品前,加上“verilogmodelGM: ”
VHDL調用verlog:
verilog module:
module m(a,b,c);
input a,b;
output c;
…
endmodule
調用如下:
compoent m
port(
a: in std_logic;
b: in std_logic;
c: out std_logic
);
end compoent
begin
verilogmodelGE: m //我自己實驗的不用也可以,用了反而有錯誤,估計是軟體變聰明了~
port map
(…
)
…
end
在VHDL裡調用Verilog的話:例化+映射
在Verilog裡調用VHDL的話:隻要映射
釋出者:全棧程式員棧長,轉載請注明出處:https://javaforall.cn/192824.html原文連結:https://javaforall.cn