我有一个函数 f()
,在 Verilog 模块 M1
中定义。我想在不同的模块 M2
中重用相同的函数。
是否可以在不重新定义M2
中的函数的情况下执行此操作?
--- M1.v ---
module M1();
function f;
//do stuff
endfunction
endmodule
--- M2.v -----
module M2();
// Use f() here
endmodule
最佳答案
您可以将该函数放入单独的文件中,并使用`include编译器指令将该函数包含在两个模块中:
--- M1.v ---
module M1();
`include "functions.v"
endmodule
--- M2.v -----
module M2();
`include "functions.v"
// Use f() here
endmodule
关于function - 在 2 个 Verilog 模块中重用相同的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16133610/