Tests: update style

This commit is contained in:
Wilson Snyder 2024-04-13 08:02:25 -04:00
parent 1012c054e6
commit 8e44487354
3 changed files with 25 additions and 36 deletions

View File

@ -239,7 +239,7 @@ static inline double VL_ISTOR_D_Q(int lbits, QData lhs) VL_MT_SAFE {
VL_SET_WQ(lwp, lhs); VL_SET_WQ(lwp, lhs);
return VL_ISTOR_D_W(lbits, lwp); return VL_ISTOR_D_W(lbits, lwp);
} }
// Return QData from double (numeric) // Return IData truncated from double (numeric)
static inline IData VL_RTOI_I_D(double lhs) VL_PURE { return static_cast<int32_t>(VL_TRUNC(lhs)); } static inline IData VL_RTOI_I_D(double lhs) VL_PURE { return static_cast<int32_t>(VL_TRUNC(lhs)); }
// Sign extend such that if MSB set, we get ffff_ffff, else 0s // Sign extend such that if MSB set, we get ffff_ffff, else 0s

View File

@ -911,7 +911,7 @@ class TimingControlVisitor final : public VNVisitor {
} }
} }
// Replace self with a 'co_await dlySched.delay(<valuep>)' // Replace self with a 'co_await dlySched.delay(<valuep>)'
auto* const delayMethodp = new AstCMethodHard{ AstCMethodHard* const delayMethodp = new AstCMethodHard{
flp, new AstVarRef{flp, getCreateDelayScheduler(), VAccess::WRITE}, "delay", valuep}; flp, new AstVarRef{flp, getCreateDelayScheduler(), VAccess::WRITE}, "delay", valuep};
delayMethodp->dtypeSetVoid(); delayMethodp->dtypeSetVoid();
addProcessInfo(delayMethodp); addProcessInfo(delayMethodp);

View File

@ -11,6 +11,9 @@
** For 32ns $time should return 3 ** For 32ns $time should return 3
**/ **/
`define stop $stop
`define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0);
module t (); module t ();
timeunit 10ns; timeunit 10ns;
timeprecision 1ns; timeprecision 1ns;
@ -18,52 +21,38 @@ module t ();
longint should_be_2, should_be_3; longint should_be_2, should_be_3;
real should_be_1p6, should_be_3p2; real should_be_1p6, should_be_3p2;
initial initial begin : initial_blk1
begin : initial_blk1 should_be_2 = 0;
should_be_2 = 0; should_be_3 = 0;
should_be_3 = 0; #(16ns);
#(16ns); $display("$time=%0t=%0d, $realtime=%g", $time(), $time(), $realtime());
$display("$time=%d, $realtime=%g", $time(), $realtime()); should_be_2 = $time();
should_be_2 = $time(); should_be_1p6 = $realtime();
should_be_1p6 = $realtime(); #(16ns);
#(16ns); $display("$time=%0t=%0d, $realtime=%g", $time(), $time(), $realtime());
$display("$time=%d, $realtime=%g", $time(), $realtime()); should_be_3 = $time();
should_be_3 = $time(); should_be_3p2 = $realtime();
should_be_3p2 = $realtime(); #(16ns);
#(16ns); $finish(1);
$finish(1);
end end
initial
begin : initial_blk2 initial begin : initial_blk2
#(100ns); #(100ns);
$display("%%Error: We should not get here"); $display("%%Error: We should not get here");
$finish(1); $stop;
end end
function bit real_chk(input real tvar, input real evar); function bit real_chk(input real tvar, input real evar);
begin
real diff; real diff;
diff = tvar - evar; diff = tvar - evar;
return (diff < 1e-9) && (diff > -1e-9); return (diff < 1e-9) && (diff > -1e-9);
end
endfunction endfunction
final final begin : last_blk
begin : last_blk
if (should_be_2 != 2)
begin
$display("%%Error: should_be_2 = %0d",
should_be_2);
$stop;
end
if (should_be_3 != 3)
begin
$display("%%Error: should_be_3 = %0d",
should_be_3);
$stop;
end
$display("Info: should_be_2 = %0d", should_be_2); $display("Info: should_be_2 = %0d", should_be_2);
$display("Info: should_be_3 = %0d", should_be_3); $display("Info: should_be_3 = %0d", should_be_3);
`checkd(should_be_2, 2);
`checkd(should_be_3, 3);
chk_2 : assert(should_be_2 == 2); chk_2 : assert(should_be_2 == 2);
chk_3 : assert(should_be_3 == 3); chk_3 : assert(should_be_3 == 3);