首页 > 微波/射频 > RFIC设计学习交流 > Cadence to Matlab Tutorial

Cadence to Matlab Tutorial

录入:edatop.com    阅读:
【经常需要转数据的朋友可以借鉴一下,写成脚本非常方便】
This file describes the process of outputting data from Cadence to Matlab.  First, the data from Cadence must be written to a file.  Then, Matlab can import the data from the written file.  This tutorial assumes the user is comfortable with Cadence and Matlab.

Step 1:
Set up your Cadence schematic and simulation.  Prepare the analyses as you normally would.

Step 2:
In the Cadence Analog Design Environment Window, select Sessions -> Save Script
Save and name the script to what ever name you desire.

Step 3:
The script will now open in a text editor.  Here is an example of what you might see:

simulator( 'spectre )
design(   "/auto/fsc/apg7/cadence/simulation/exp3/spectre/schematic/netlist/netlist")
resultsDir( "/auto/fsc/apg7/cadence/simulation/exp3/spectre/schematic" )
modelFile(
    '("/ee2/Cadence/NCSU/local/models/spectre/standalone/tsmc25N.m" "")
)
analysis('tran ?stop "60m"  )
desVar(    "RI" 10K         )
desVar(    "RF" 40K         )

temp( 27 )
run()

The file contains all of the information required to run your simulation.  It lists the simulator, design directory, required model files, analyses (can have more than 1), design variables, etc.  The 'run()' command is the command that actually runs the simulation.

In order to write data to a file, one has to create the file first. After the simulation is complete, some commands must be included in the script to retrieve the results before they can be printed to the file.  Then, they can be printed to the file.  The example below is the same example as above, but with the added commands to print the data to the output file 'paramResults.out':

simulator( 'spectre )
design(   "/auto/fsc/apg7/cadence/simulation/exp3/spectre/schematic/netlist/netlist")
resultsDir( "/auto/fsc/apg7/cadence/simulation/exp3/spectre/schematic" )
modelFile(
    '("/ee2/Cadence/NCSU/local/models/spectre/standalone/tsmc25N.m" "")
)
analysis('tran ?stop "60m"  )
desVar(    "RI" 10K         )
desVar(    "RF" 40K         )

temp( 27 )
out = outfile("./paramResults.out" "w")  ; name the output file and open it for write access
run()                                                        ; run the file
results()                                                 ; open up the results
selectResults(`tran)                                            ; Select the transient results
outputs()                                                               ; View the outputs
;Below, voltage measurements of VOUT_tran node are found at time points 0 to
;50 msec by increments of 1 msec.
for(tt 1 51
    time = tt*0.001 - 1*0.001
    fprintf(out "%5.3f    " time)    ; Print the time stamp
    fprintf(out "%1.6e \n" value(VT("/VOUT_tran"),time))                ; Print the voltage associate with the time
  stamp
)

close(out)

Step 4:
Once your script is ready, save it.  Then, from the Command Interpreter Window (CIW - the main window), type:

load("filename")

If your script has been saved in another directory, make sure you list the whole path between the quotes in the load command.  The script listed in the example above was named 'oceanScript.ocn' and saved in the cadence root directory.  In that case, you would type:

load("oceanScript.ocn")

This command runs your script.  Now your output data file has been created.

Step 5:
Start Matlab, and copy your output data file to your work directory in Matlab.  To retrieve the data from the output file, a Matlab script was written:

%Example for retrieval of paramResults.out data.

clear

filename = 'paramResults.out';
fid = fopen(filename,'r');

Z = fscanf(fid,'%g %g',[2 inf])';
t = Z(:,1);
y = Z(:,2);

fclose(fid);


The above script will have to be modified for different cases, such as having more data.  In this case though, we need to retrieve the time and voltage and put them in time vector 't' and the voltage vector 'y', respectively.  Any Matlab post-processing can be executed on the retrieved data once it has been imported, using the above script, into Matlab.

HAHA,已看

看看了额

I thinks it is pretty good!

好东西   看看

申明:网友回复良莠不齐,仅供参考。如需专业解答,请学习本站推出的微波射频专业培训课程

上一篇:关于cosmoscope看图软件……
下一篇:Calibre LVS 无法通过!

射频和天线工程师培训课程详情>>

  网站地图