systemverilog 当前时间写入文件

systemverilog 当前时间写入文件

使用SV系统函数$system(" [terminal_command_line]")

$system的本质是调用 C system()函数。 C system()函数执行传递给它的参数,效果同终端执行的一样。 $system 可以作为任务或函数调用。 当作为函数调用时,它返回调用 system() 的返回值,数据类型为 int。 如果调用 $system 时没有字符串参数,则 C system() 函数将使用 NULL 字符串调用。

如下面例子,将design.v文件名改为adder.v:

module top;
	initial $system("mv design.v adder.v");
endmodule

显示当前系统时间:

initial  begin
	$system("date");
end

当前时间写入文件

基于VCS-MX2018, 低版本VCS貌似不支持$system("")

module top;
    integer fd;

    function string get_localtime();    
        int fdt,flag;
        string current_time;
        $system("date > localtime"); // temp file
        fdt = $fopen("localtime", "r");
        flag = $fgets(current_time, fdt); 
        $fclose(fdt);
        $system("rm localtime"); // delete file
        return current_time; 
    endfunction

    initial begin
        $fopen(fd,"time.txt","w+");
        $fdisplay(fd,"%s",get_localtime());
        $fdisplay(fd,"write current to time.txt");
        $fclose(fd);
    end

endmodule

其他办法 DPI-C

#include <time.h>
wallclock() {
   time_t t;
   t = time(NULL);
   return (ctime(&t));
   //return time(NULL);
}
import "DPI-C" function string wallclock();

module try;

   //int unsigned   t;
   string t;

   initial begin
      t = wallclock();
      $write("time=%0s\n", t);
   end
endmodule
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
source insight是一款非常强大的源代码编辑器,可以支持多种编程语言,包括SystemVerilog语言。在使用source insight进行SystemVerilog代码开发时,可以通过配置clf文件来实现代码的自动补全、语法高亮和代码导航等功能。 clf文件是source insight中的配置文件,用于定义各种编程语言的语法结构和特定关键字。当我们使用source insight打开一个SystemVerilog代码文件时,source insight会根据配置的clf文件来识别该代码文件的语法结构,并根据配置文件中的设置进行相应的代码补全和语法高亮等操作。 在配置SystemVerilog语言的clf文件时,我们需要定义该语言的关键字、运算符、函数和宏等元素的规则,以便source insight能够正确地识别和处理这些元素。配置文件中的规则包括正则表达式、语法规则和关键字列表等。通过正确配置clf文件,source insight可以根据用户的输入或光标位置来提供代码补全、语法检查和自动导航等功能,提高代码开发的效率和准确性。 除了配置SystemVerilog语言的clf文件外,还可以通过source insight的相关功能进行个性化的配置,如设置代码风格、自定义快捷键、定义代码模板等,以满足不同开发者的需求。 总之,通过配置source insight的clf文件,可以使其对SystemVerilog语言的代码具备自动补全、语法高亮和代码导航等强大功能,提高代码开发的效率和质量。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值