The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> Recording Data in DC sweep
https://designers-guide.org/forum/YaBB.pl?num=1182433992

Message started by makelo on Jun 21st, 2007, 6:53am

Title: Recording Data in DC sweep
Post by makelo on Jun 21st, 2007, 6:53am

How does one write data to a text file in a DC sweep?  I have attached the code I frequently use for writing data in transient analysis.  It works great.  The difference is that in a DC sweep I can't use the @timer function.  If I use a similar code in a DC sweep without the timer line then I just get one data point.  Can someone suggest modifications that will record the entire DC sweep?

-------------------------------------------------------------------
`include "disciplines.vams"
`include "constants.vams"

module sink1(v1);
   electrical v1;                                                  //node voltage to write
   parameter string file_name = "filename.tbl";     //file name to write to
                                                                        //strings only work in some versions of verilogA
                                                                        //hardcode the filename if necessary
   parameter real T_step = 1e-9;                         //time step for writing data.
   parameter real T_off = 0;                                //time to wait before starting
   integer file_ptr;                                               //pointer to file_name

   analog begin
       @( initial_step ) begin
          file_ptr=$fopen(file_name);
       end

       @(timer(T_off,T_step)) begin                        //at each T_step write the node voltage
         $fwrite(file_ptr, "%e %e\n", $abstime, V(v1));
       end

       @ (final_step) begin
         $fclose(file_ptr);
       end
   end
endmodule
-------------------------------------------------------------------

Title: Re: Recording Data in DC sweep
Post by Geoffrey_Coram on Jun 21st, 2007, 10:13am

You could write an if statement that tests if the current point is a multiple of, say 0.1V, and then $strobe the output.  Or just $strobe it all the time and tell your simulator what steps you want it to take.

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