The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Simulators >> Circuit Simulators >> Getting convergence info from Spectre
https://designers-guide.org/forum/YaBB.pl?num=1190297332

Message started by Marq Kole on Sep 20th, 2007, 7:08am

Title: Getting convergence info from Spectre
Post by Marq Kole on Sep 20th, 2007, 7:08am

Hi,

I would like to verify the performance of a behavioral model in transient by checking out how much time the simulation that I use it in needs for the implicit DC, as well as how many Newton iterations it performs during each transient step. Is there a way to get that information from Spectre? I tried to search the documentation that comes through spectre -h, but couldn't find any reference.

Marq

Title: Re: Getting convergence info from Spectre
Post by Geoffrey_Coram on Sep 24th, 2007, 9:02am

Hi, Marq -
I've had success in some simulators using the $debug system task, which prints something for every newton iteration.  Pipe the output to a file and use the unix "wc" to count the lines that contain your magic string.  $strobe prints on convergence; you'd probably need a perl script to count how many $debugs happen between successive $strobes.

-Geoffrey

Title: Re: Getting convergence info from Spectre
Post by Marq Kole on Sep 24th, 2007, 11:53pm

Hi Geoffrey,

Thanks - I had already considered that approach, but I had hoped there might be some built-in debug output from Spectre that could help me. The Verilog-A $debug approach will obviously have an effect on throughput time. I guess I will have to try the $debug approach.

Marq.

Title: Re: Getting convergence info from Spectre
Post by Geoffrey_Coram on Sep 25th, 2007, 4:18am

You could try "audit=full" on the options line.  Do spectre -help options and scroll down to the Annotation parameters section.

Title: Re: Getting convergence info from Spectre
Post by Marq Kole on Sep 26th, 2007, 1:18am

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
}

Title: Re: Getting convergence info from Spectre
Post by jorobins on Sep 29th, 2007, 6:00am

Thanks Marq. This looks fantastic. I'll try it out and see how it works for me.

Jose [smiley=thumbsup.gif]

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.