The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
May 4th, 2024, 3:40pm
Pages: 1
Send Topic Print
exporting files from spectre to matlab ? (Read 2678 times)
City
Junior Member
**
Offline



Posts: 19

exporting files from spectre to matlab ?
Aug 17th, 2004, 1:35am
 
Hi,

is it possible to save a transient simulation result and
to export it to matlab for signal processing ? Can
anybody tell me how to do it ?

regards,

City
Back to top
 
 
View Profile   IP Logged
Eugene
Senior Member
****
Offline



Posts: 262

Re: exporting files from spectre to matlab ?
Reply #1 - Aug 17th, 2004, 11:34am
 
I do this all the time, in both directions. If you have already run the simulation, you can use the waveform calculator's "printvs" command to display the data. You will have to change the format from engineering to scientific units. You then click the "print" command and print to a file. You can only print 1000 or so points this way. For more points, you have to use the command line.

I prefer creating the file with VerilogA. I've included a piece of VerilogA code I use to create files. In Matlab, read the data in with aa=load('IinputCol'); You will have to make sure the path to the directory is in your Matlab path.

//=================================

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

module write1(in);
input in;
electrical in;

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

analog begin
  @ ( initial_step ) begin
     if (record ==1) begin
        fptr = $fopen("/home/rcvr_5GHz/IinputCol");
     end
     period = 1/sample_rate;
  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
Back to top
 
 
View Profile   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.