How to display the system date in $display or $write?

| Sunday, August 23, 2009


(Answers contributed by Swapnajit Mittra and Noman Hassan)

Support of $system() task in Verilog-XL, NC-Verilog and VCS not only allows you to display the system date but also gives you the ability to call any command that you would normally type on the UNIX prompt (C executable, script, standard UNIX command etc.), and would make sense in executing from within Verilog source code.

$system is not an IEEE Standard(1364-1995), but is supported by both XL and VCS.

You could read back in the output of $system, by writing it to another file and reading it back in using $readmemh() as illustrated in following example.

module top;

reg [23:0] today [0:1];

initial
begin
$system("date +%m%d%y > date_file");
// output is 073199 for july 31st 1999
$readmemh("date_file", today);
$display("Today is: %x", today[0]);
end
endmodule

0 comments:

Post a Comment