Use an integer variable
active that you set/unset based on any condition you require, and have the counter only count when
active is set.
Code:parameter real tstart = 1u from [0:inf);
integer active;
analog begin
if ($abstime > tstart)
active = 1;
@(cross(V(in)-0.5, +1))
if (active)
count = count + 1;
end
The code that sets
active can be anything, also a number of counts made, a signal on a terminal, etc.