Adi*_*Adi 2 fopen relative-path system-verilog
我需要在我的系统 verilog 代码中打开一个文件,我需要知道它对我的相对路径才能使用 $fopen。所以首先,我需要知道我的立场。有没有办法知道我当前的目录路径?(通过使用 $display 或其他东西)
基于另一个问题how-do-i-read-an-environment-variable-in-verilog-system-verilog:
import "DPI-C" function string getenv(input string env_name);
module top;
initial begin
$write("env = %s\n", {getenv("HOME"), "/FileName"});
end
endmodule
Run Code Online (Sandbox Code Playgroud)
工作目录应在 $PWD 中,因此对于您的问题,您可以使用getenv("PWD").