aelPushSignifDigits(3) :设置显示有效位数;

双击label,可以设置label显示的有效位数;

----

Cadence to Matlab Tutorial

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.

=================

matlab figure data from

Lets say u run the spectre

simulation and plot the AC gain in dB from 10Hz to 50MHz.

1. Invoke the calculator from the plot window

2. now press the "wave" button in the calculator and choose the AC

dB plot to bring it into the calculator!

3. press the "printvs" button which will bring up a dialog box to

print values from the plot according to your wish.

4. now fill in the range u want to plot and the increment.

example:

from- 10

to-50000000

mode-"linear" or "log"

By 100

5. this will display all values of the gain neatly in a tabular

fashion in another windoew

6. In this "Results Display Window" goto the "Window" menu and

press the "print" button

7. in the new "Print" dialog box set the "Print to" option to file

and enter a path as /home/......./spectretomatlab. txt.

8. u will get the values printed into the text file which u can

read into matlab now.

==================

Hi,

If you have a recent version of Cadence, you may also use the

Spectre toolbox in Matlab. See Andrew's post on this here:

http://news.elektroda.net/cadence-matlab-data-transfer-t107674.html

"The Spectre Toolbox is shipped in MMSIM61, and is in:

/tools/spectre/matlab

It's covered in

/doc/spectreRFTheory/spectreRFTheory.pdf

- chapter 1.

Essentially, it gives you the matlab function cds_srr for reading

psf/sst2

simulation results databases. "

Paul

=======================================

我自己算snr的小脚本:

QOUT= csvread('C:\mysim_data\qout.txt',1,1,[1 1

4096 1]);

fft_QOUT = abs(fft(QOUT));

fft_QOUT_inband = fft_QOUT(2:51,1);

fft_QOUT_db = 20*log10(fft_QOUT);

figure(1); plot([2:2014],fft_QOUT_db(2:2014,1)); grid on ;

signal_power = max(fft_QOUT_inband);

signal_power_db = 20*log10(signal_power);

noise_pow = sum(fft_QOUT_inband)-signal_power;

noise_pow_db = 20*log10(noise_pow);

snr = signal_power_db - noise_pow_db

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐