The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Aug 15th, 2024, 12:22pm
Pages: 1
Send Topic Print
Recording Data in DC sweep (Read 1625 times)
makelo
Community Member
***
Offline



Posts: 34
Hillsboro, OR
Recording Data in DC sweep
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
-------------------------------------------------------------------
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: Recording Data in DC sweep
Reply #1 - 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.
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.