I finally solved this problem.
Here's the code:
Code:`include "disciplines.vams"
module current_limiter(in,out);
inout in, out;
electrical in, out;
parameter imax = 3e-3;
analog
begin
@(cross(I(in,out)+V(in,out)-imax,0))
;
if(I(in,out)+V(in,out) > imax)
I(in,out) <+ imax;
else
V(in,out) <+ 0;
end
endmodule
By using a way similar to the diode model(p73, Ken's book), I cut on a diagonal in the IV plane and get the condition: I(in,out)+V(in,out) > imax, then the problem could be solved.
But I still don't know why I should not cut twice as before: I(in,out) >= imax && V(in,out) >= 0. Does it cause convergence problems?
thanks.