The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Simulators >> RF Simulators >> write output to file
https://designers-guide.org/forum/YaBB.pl?num=1051513345

Message started by Roky on Apr 28th, 2003, 12:02am

Title: write output to file
Post by Roky on Apr 28th, 2003, 12:02am

Hi everyone, I have some problems with hidden state in specteRF, I would like to simulate an GSM transmitter with envlp. analysis... I deceided to solve this problem with an data controled voltage source... But my problem is I dont know how to print the simulation results as data to the file. (Like in spice to the output file). I am an CADENCE beginner so I would be very happy if someone could help me...


Thanks a lot....                    
                               Roky

Title: Re: write output to file
Post by Eugene on Apr 28th, 2003, 2:11pm

I've included a module I use to sample an output voltage and write it out to a file in SPW format. The Spectre pwlf sources understand SPW format but SPW format is not necessary. Two columns, one time and one voltage, works too. Perhaps this will get you started.

I did not make the filename a parameter because I know of no way to pass a string to the module. That is one of my complaints about VerilogA. SpectreHDL lets you pass strings to modules.

The other thing to remember is that if you post process the data on a pc, you need to rename the file with a different name each time you overwrite the old one because of some caching problem with pc networks. This is, of course, moot if you are doing everything on a unix box.

// VerilogA for behavioral_models, SPW_signal_sink, veriloga

`include "constants.h"
`include "discipline.h"

module I_SPW_output_sink(in);
input in;
electrical in;

parameter real sample_rate = 1e6 from (0:inf];
parameter real sim_time = 0.001 from (0:inf];
parameter integer record = 1 from [0:1]; // 1 = record, 0 = don't.
integer fptr;
real period;
integer number_of_samples;

analog begin
  @ ( initial_step ) begin
     if (record ==1) begin
        fptr = $fopen("/home/phase_noise.ascsig");
        period = 1/sample_rate;
        number_of_samples = sim_time*sample_rate;
        $fstrobe(fptr, "$SIGNAL_FILE 9");
        $fstrobe(fptr, "$USER_COMMENT");
        $fstrobe(fptr, "data");
        $fstrobe(fptr, "$COMMON_INFO");
        $fstrobe(fptr, "SPW Version          = 4.50");
        $fstrobe(fptr, "System Type          = solaris2");
        $fstrobe(fptr, "Sampling Frequency   = %g", sample_rate);
        $fstrobe(fptr, "Starting Time        = 0");
        $fstrobe(fptr, "$DATA_INFO");
        $fstrobe(fptr, "Number of points     =        %d", number_of_samples);
        $fstrobe(fptr, "Signal Type          = Double");
        $fstrobe(fptr, "$DATA ASCII");
     end
  end

  if (record == 0) period = 1e6;
  @(timer(0, period)) begin
     if(record == 1) $fstrobe(fptr, "%g", V(in));
  end

  @ (final_step) begin
     $fclose(fptr);
  end
end
endmodule

Title: Re: write output to file
Post by Roky on Apr 28th, 2003, 2:37pm

Thanks for your help Eugene.... I' ll try it...

Regards...  Roky

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