wildgoat的个人空间 https://blog.eetop.cn/wildgoat [收藏] [复制] [分享] [RSS]

空间首页 动态 记录 日志 相册 主题 分享 留言板 个人资料

日志

[ZZ] Cadence to Matlab Tutorial

已有 2249 次阅读| 2011-7-28 21:16 |个人分类:Cadence

link : http://ece451web.groups.et.byu.net/cadence-help/cadTOmat.html

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( 
    '("/opt/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( 
    '("/opt/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.

 


点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 关注TA
  • 加好友
  • 联系TA
  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 0

    关注
  • 122

    粉丝
  • 42

    好友
  • 274

    获赞
  • 118

    评论
  • 22104

    访问数
关闭

站长推荐 上一条 /1 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-12 15:04 , Processed in 0.035705 second(s), 15 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部