In addition (once the jitter code has been removed or made inactive to ensure it's periodic) there genuinely is a hidden state in there (you are turning off the hidden state checks). The variable n is only being set within the @cross. You can avoid that simply by writing:
Code: @(cross(phase + `M_PI/2, +1, ttol, vtol) or cross(phase - `M_PI/2, +1, ttol, vtol));
n = (phase >= -`M_PI/2) && (phase < `M_PI/2);
There's no begin and end - simply put a semi-colon after the @(cross) as this then ensure's there's a timestep at (or close) to the transition. The variable n is then assigned on every step. If I do this, the code runs in PSS without needing the hidden state being ignored (note I removed that too from the code):
Code:`include "constants.vams"
`include "disciplines.vams"
module vco (vin, vout);
input vin;
output vout;
electrical vin, vout;
parameter real Vmin=0;
parameter real Vmax=Vmin+1.2 from (Vmin:inf);
parameter real Fmin=1.8e9 from (0:inf);
parameter real Fmax=3e9 from (Fmin:inf);
parameter real Vamp=1.2 from [0:inf);
parameter real ttol=1u/Fmax from (0:1/Fmax);
parameter real vtol=1e-9;
parameter integer min_pts_update=32 from [2:inf];
parameter real tran_time=10e-12 from (0:0.3/Fmax);
parameter real jitter_std_ui=0.002 from [0:1);
real freq, phase, jitter_rad, dphase, phase_ideal;
integer n, seed;
analog begin
@(initial_step) begin
// seed = 671;
n = 0;
// dphase=0;
// jitter_rad=jitter_std_ui*2* `M_PI;
end
freq = ((V(vin)-Vmin)*(Fmax-Fmin)/(Vmax-Vmin)) + Fmin;
$bound_step(1/(min_pts_update*freq));
if (freq>Fmax) freq = Fmax;
if (freq<Fmin) freq = Fmin;
phase_ideal = 2* `M_PI*idtmod(freq, 0.0, 1.0, -0.5);
phase=phase_ideal;
/*
phase = phase_ideal + dphase;
@(cross(phase_ideal + `M_PI/2, +1, ttol, vtol) or cross(phase_ideal - `M_PI/2, +1, ttol, vtol)) begin
dphase = $rdist_normal(seed, 0, jitter_rad);
end
*/
@(cross(phase + `M_PI/2, +1, ttol, vtol) or cross(phase - `M_PI/2, +1, ttol, vtol));
// begin
n = (phase >= -`M_PI/2) && (phase < `M_PI/2);
// end
V(vout) <+ transition(n?Vamp:0,0,tran_time);
end
endmodule
Andrew