Aigneryu
|
This is the chargepump model with finite reset delay (derived from the Ken's Hidden-state-free DFF)
`include "disciplines.vams" `include "constants.vams"
// // This model exhibits no jitter //
module pfd_cp (Icp, up, dn, ref, vco);
output Icp; electrical Icp; // current output output up; electrical up; // current output output dn; electrical dn; // current output electrical rst;
input ref; voltage ref; // positive input (edge triggered) input vco; voltage vco; // inverting input (edge triggered)
parameter real icpp=100u; // maximum sourcing current parameter real icpn=100u; // maximum sinking current parameter real vh=+1; // input voltage in high state parameter real vl=-1; // input voltage in low state parameter real vth=(vh+vl)/2; // threshold voltage at input parameter integer dir=1 from [-1:1] exclude 0; // dir=1 for positive edge trigger // dir=-1 for negative edge trigger parameter real tt=20p from (0:inf); // transition time of output signal parameter real td=1f from (0:inf); // average delay from input to output parameter real ttol=1f from (0:inf); // time tolerance parameter integer init_state=0 from [0:1];
integer actNow, out_ref, out_vco, state_ref, state_vco, state_rst;
analog begin // @(cross((V(ref)-vth), dir, ttol)) // if (state > -1) state = state - 1; // @(cross((V(vco)-vth), dir, ttol)) // if (state < 1) state = state + 1;
actNow = 0;
@(initial_step) begin actNow = 1; state_ref = init_state; state_vco = init_state; end
@(cross(V(ref) - vth, dir) or cross(V(rst) - 0.5, +1)) begin actNow = 1; state_ref = (V(rst) < 0.5); end
@(cross(V(vco) - vth, dir) or cross(V(rst) - 0.5, +1)) begin actNow = 1; state_vco = (V(rst) < 0.5); end
out_ref = idt(0, state_ref, actNow); out_vco = idt(0, state_vco, actNow); V(up) <+ transition(out_ref ? vh : vl, td, tt); V(dn) <+ transition(out_vco ? vh : vl, td, tt);
I(Icp)<+ transition(out_ref ? -icpp : 0, td, tt); I(Icp)<+ transition(out_vco ? icpn : 0, td, tt);
end endmodule
|