verilator/test_regress/t/t_time_passed.v
Wilson Snyder d4f7f5297a
Support IEEE time units and time precisions, #234. (#2253)
Includes `timescale, $printtimescale, $timeformat.
VL_TIME_MULTIPLIER, VL_TIME_PRECISION, VL_TIME_UNIT have been removed
and the time precision must now match the SystemC time precision.
To get closer behavior to older versions, use e.g. --timescale-override
"1ps/1ps".
2020-04-15 19:39:03 -04:00

65 lines
1.3 KiB
Systemverilog

// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under The Creative Commons Public Domain, for
// any use, without warranty, 2020 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
`timescale 1ns/1ps
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
integer cyc = 0;
time in;
// verilator lint_off REALCVT
initial in = 5432109876.543210ns; // Will round to time units
// verilator lint_on REALCVT
// This shows time changes when passed between modules with different units
// See also discussion in uvm_tlm2_time.svh
ps ps (.*);
ns ns (.*);
always @ (posedge clk) begin
cyc <= cyc + 1;
if (cyc == 60) begin
$write("*-* All Finished *-*\n");
$finish;
end
end
endmodule
`timescale 1ps/1ps
module ps
(input clk,
input integer cyc,
input time in);
always @ (posedge clk) begin
if (cyc == 10) begin
$timeformat(-9, 6, "ns", 16);
$write("%m: Input time %t %d\n", in, in);
end
end
endmodule
`timescale 1ns/1ps
module ns
(input clk,
input integer cyc,
input time in);
always @ (posedge clk) begin
if (cyc == 20) begin
$timeformat(-9, 6, "ns", 16);
$write("%m: Input time %t %d\n", in, in);
end
end
endmodule