makelo
Community Member
![* *](https://designers-guide.org/forum/Templates/Forum/default/stargold.gif) ![* *](https://designers-guide.org/forum/Templates/Forum/default/stargold.gif)
Offline
Posts: 34
Hillsboro, OR
|
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 -------------------------------------------------------------------
|