如果我模拟以下模块:
<ul *ngFor="let item of menu">
<li> {{ item.name }} </li>
<li> {{ item.description}} </li>
....
</ul>
module test;
longint seconds;
initial begin
seconds = $system("date +%s");
$display("Seconds: %0d", seconds);
$finish;
end
endmodule
和ncsim
的输出为:
vsim
所以我可以看到1571172006
Seconds: 0
调用正在以秒为单位$system
打印时间,但是变量1571172006
的值为{{1}因此,我没有保存该值。
我有办法保存这一价值吗? (最好不使用DPI)
谢谢。
答案 0 :(得分:1)
这太可怕了,但是您可以将Linux命令的输出通过管道传输到一个文件中,然后读取该文件:
div =
{
id: (changeable value),
html = 'div id="divName'+getId()+'"></div>',
getId()
{
return this.id;
},
}
$system("date +%s | tee date.txt");
fd = $fopen("date.txt","r");
count=($fgets(s, fd) == 0); assert(count == 0);
count=($sscanf(s,"%d", seconds)); assert(count == 1);
$display("Seconds: %0d", seconds);
答案 1 :(得分:1)
我不知道您为什么不想使用DPI。比马修的方法简单得多。 ?
module test;
import "DPI-C" function longint date();
longint seconds;
initial begin
seconds = date();
$display("Seconds: %0d", seconds);
$finish;
end
endmodule
#include <time.h>
long int date() {
return time(NULL);
}