OK, for the benefit of the community here is the $debug Verilog-A code as well as a very kludgy shell script that does the extraction of the iteration data. It now returns the average number of iterations and the maximum number of iterations. With a little more work the variation (in terms of a Poisson distribution, of course) could be extracted as well.
This is the Verilog-A code of a simple module that writes the data out to the logfile in case of Spectre.
Code:module stepcount;
integer count;
analog
begin
if (analysis("static")) begin
$debug("MINOR (DC)");
$strobe("MAJOR (DC) %d", count);
end
else
if (analysis("tran") && !analysis("static")) begin
$debug("MINOR (TRAN)");
$strobe("MAJOR (TRAN) %d", count);
end
count = count + 1;
end
endmodule // stepcount
And this is a function in Korn shell (/bin/ksh) style that extracts the data from the log file and creates a number of local variables that can be written out at a later stage. With some minor effort this can be turned into a more efficient Perl or Python script that does all of it and more.
Code:IterationCount() { # count the number of major and minor steps in
# the logfile $2 and number of accepted steps $3
# if the flag $1 is 1.
if [[ $1 -gt 0 ]]
then \
(( hasstepcount=1-$(grep -q -e '^MAJOR ' $2 ; echo $?) ))
if [[ ${hasstepcount} -gt 0 ]]
then \
(( nminordc=$(grep -c -e '^MINOR (DC)' $2) ))
(( nmajordc=$(grep -c -e '^MAJOR (DC)' $2) ))
(( nminortr=$(grep -c -e '^MINOR (TRAN)' $2) ))
(( nmajortr=$(grep -c -e '^MAJOR (TRAN)' $2) ))
(( aveminortr=${nminortr}*1.0/${nmajortr} ))
(( maxminortr=0 ))
linetext0=$(grep -n -m 1 -e '^MINOR (TRAN)' $2)
(( linenr0=$(python -c 'import sys ; s=sys.argv[1] ; r1=s.split(":")[0] ; print r1,' ${linetext0})-1 ))
for (( count=1 ; $3-${count} ; count=${count}+1 ))
do \
findtext="^MAJOR (TRAN) ${count}"
linetext1=$(grep -n -m 1 -e "${findtext}" $2)
(( linenr1=$(python -c 'import sys ; s=sys.argv[1] ; r1=s.split(":")[0] ; print r1,' ${linetext1}) ))
(( nlines=${linenr1}-${linenr0}-1 ))
if [[ ${maxminortr} -lt ${nlines} ]]
then \
(( maxminortr=${nlines} ))
fi
(( linenr0=${linenr1} ))
done
else \
IterationCount 0 $2 $3
fi
else \
(( nminordc=0 ))
(( nmajordc=1 ))
(( nminortr=0 ))
(( nmajortr=$3 ))
(( aveminortr=0.0 ))
(( maxminortr=0 ))
fi
}