# Cadence Waveform Import and Export

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

## Introduction

This guide describes how to add any given voltage or current waveform to a schematic simulation in Cadence. This technique is useful for simulating complicated digital control lines, adding a specific analogue signal as an input or adding noise to a simulation. The format of the waveform file is described as well as how it can be added to a schematic for simulation. In addition an example Matlab/Octave script which can be used to generate a 1/fbeta noise waveform file is described. The generation of other waveforms is not discussed, but is a simple task for anybody with a text editor and knowledge of Matlab/Octave. Section 4 introduces a method by which it is possible to split a large system into smaller blocks for simulation by saving the output of one block and using the output as a piecewise linear input to the next block.

## Waveform File

### Format

The waveform file has a very simple format. It consists of columns of time-voltage1 pairs separated by a tab or a space. Both values must be specified using scientific notation (or as simple numbers), but without using letter suffixes! An example file describing an x2 function (the first column shows time, the second shows the voltage).

```0 0
1e-9 1e-3
2e-9 4e-3
3e-9 9e-3
4e-9 16e-3
```

### Using in Cadence (Piecewise Linear Source)

To add an arbitrary waveform to a Cadence simulation a piecewise linear source can be used. A piecewise linear source takes a waveform definition that specifies signal values for given points in time and then generates a linear transition between each of these points. In effect it is “joining the dots” between the points specified. To add a piecewise linear source, use one of the analogLib cells vpwl, ipwl, vpwlf or ipwlf. The cells vpwl and ipwl allow the time-voltage pairs to be specified in the properties dialog and so are only really useful for simple waveforms, whereas vpwlf and ipwlf use waveform files as described above. There are two crucial properties to set in the properties dialog, these are PWL file name and Period of the PWL. Set the file name to the full path of the file you have created and the period to the period of the data within the file. These are the only properties that need to be set to use the piecewise linear sources, but other useful properties exist, such as Delay time and Offset voltage.

## Noise Example

### Getting the Scripts

The Matlab/Octave scripts used in this section are given in the appendices. They are also available on the Unix machines at: /eee/vlsi/Work/Matlab

### Using the Scripts

The only script you really need to use is pwl noise(). This function calls one fsyn() for you. The function is defined as:

```function noisedata=pwl_noise(N, ts, peak, beta, fname);
```

Where the arguments are as follows:

• N - number of samples
• ts - Time step between samples
• peak - Maximum value of noise
• beta - Spectral exponent (1/fbeta)
• fname - File name to export to

Choose N and ts such that the amount of time the noise lasts (N*ts) is longer than the simulation time. Doing this will remove any periodic waves from the signal. The data values will be distributed between zero and peak. If you need noise centred around zero then a simple change to one fsyn() will be required. Choose beta depending on what type of noise you wish to generate. A value of 0 produces white noise, a value of 1 produces 1/f noise and a value of 2 produces brownian noise. The array returned gives the noise data values but not the time values.

## Simulating a Large System

### Introduction

This section describes how to take a large system that would normally take a long time to simulate and split it into smaller pieces which can be simulated using the outputs of previous blocks as piecewise linear inputs. The method of saving the waveform data described in section can also be used to create data files for use in Matlab.

### First Steps

The first task is to split the system into logical blocks to be simulated. At what point in the system this partioning is carried out depends largely on the size and topology of the design. Obviously if there is a feedback loop in the design then the loop will need to be simulated as a whole and cannot be broken down. Start with the existing inputs to the system and start creating blocks from there. The blocks which are separated need to have piecewise linear inputs, as described in section 2.2. When all of the system has been split into blocks the initial simulation can be started.

### The Initial Simulation

Configure the simulation for the first block exactly as you want it to appear. Use Outputs->To Be Plotted->Select on Schematic for all of the outputs you need to save. Run the simulation so that you are sure the outputs are correct. Now go to the menu Session->Save Script... and choose an appropriate name. This creates an Ocean script file and opens it in a text editor. An example is shown below. This file contains all of the commands needed to run the simulation exactly as you defined, but without the Analog Artist interface. To save the output data we need to edit the Ocean file. At the very bottom of the file there will be the “plot” command. We don’t actually want to produce a plot but the command shows us all of the nets and nodes in which we are interested (which is why we selected them for plotting). Add the following line underneath the plot command for each net or node you wish to save, replacing the net and file names as appropriate:

```ocnPrint( v("/net_name") ?output "./file_name" ?numberNotation ’none ?precision 15 ?width 20)
```

So for the example in Appendix C this would be:

```ocnPrint( v("/Out") ?output "./out_pwl" ?numberNotation ’none ?precision 15 ?width 20 )
ocnPrint( v("/net6") ?output "./net6_pwl" ?numberNotation ’none ?precision 15 ?width 20)
ocnPrint( i("/I0/out") ?output "./i_out_pwl" ?numberNotation ’none ?precision 15 ?width 20)
```

The plot line can be removed if desired. To run the script, select the CIW (the main Cadence window) and in the text entry box type the following, substituting the file name for your own:

```load("./oceanFile.ocn")
```

Your simulation should now run and the details be shown in the CIW. Check the output files to ensure that they appear to be correct. They will appear similar to the following:

```time(s) v("/Out" ?result "tran") (V)
0 3.3
6.123e-12 3.3002
```

It is important that you remove the first two lines from each file so that the text information is not interpreted as data.

### Later Simulations

Now that the data from the first simulation has been saved, simply set the piecewise linear source properties in the next simulation as appropriate for the saved data (so period and filename) and then run the new simulation. This step can be run any number of times, generating an Ocean file for each simulation and using the saved data in the simulation afterwards.

## Matlab Noise Generation Script

```function x=one_fsyn(N,beta);
%Fractal motion synthesis using Fourier filtering method
%Saupe Random fractal algorithms
%N->number of samples (*2)
%beta->spectral exponent (1/f^(beta))

alea1=randn(1,N/2);
alea1=alea1+min(alea1);
alea2=rand(1,N/2);
phase=alea2.*(2*pi);
%B=phase;
%%%%%%%%%%%%%%%%%%%%%
for i=1:N/2,
temp=A.*(cos(((2*pi)./N)*i.*(1:N/2)))+B.*(sin(((2*pi)./N)*i.*(1:N/2)));
x(i)=sum(temp);
%i
end
%%%%%%%%%%%%%%%%%%%%%%
x=x./max(x);
```

## Matlab Noise Waveform File Generation Script

```function noisedata=pwl_noise(N, ts, peak, beta, fname);
% noisedata=pwl_noise(N, ts, peak, beta, fname)
%
% Create Piecewise Linear noise file
%
% N -> number of samples
% ts -> Time step between samples
% peak -> Maximum value of noise
% beta -> spectral exponent (1/f^(beta))
% fname -> file name to export to

% Generate noise data (more than needed)
noisedata = one_fsyn(N*4, beta

% Select the middle "N" part of the data to
% hopefully remove any periodicity created by
% the ifft part of one_fsyn()
noisedata = noisedata(N/2:N/2+N)*peak;

outfile = fopen(fname, "w");
curr_time = 0;
for i=1:N,
fprintf(outfile, "%e %e\n", curr_time, noisedata(i));
curr_time = curr_time + ts;
end
fclose(outfile);
```

## Example Ocean Script File

```simulator( ’spectre )
resultsDir( "/eee/simdata/ral/invt/spectre/schematic" )
modelFile(
’("/eee/vlsi/DesignKits/AMS/latest/spectre/c35/mcparams.scs" "")
’("/eee/vlsi/DesignKits/AMS/latest/spectre/c35/cmos53.scs" "cmostm")
’("/eee/vlsi/DesignKits/AMS/latest/spectre/c35/res.scs" "restm")
’("/eee/vlsi/DesignKits/AMS/latest/spectre/c35/cap.scs" "captm")
’("/eee/vlsi/DesignKits/AMS/latest/spectre/c35/bip.scs" "biptm")
’("/eee/vlsi/DesignKits/AMS/latest/spectre/c35/ind.scs" "indtm")
)
analysis(’tran ?stop "40u" )
saveOption( ’currents "all")
temp( 27 )
run()
selectResult( ’tran )
plot(getData("/net6") getData("/Out") getData("/I0/out") )
```
{"ft_lang_label":"__label__en","ft_lang_prob":0.81785816,"math_prob":0.8711019,"size":9095,"snap":"2019-51-2020-05","text_gpt3_token_len":2287,"char_repetition_ratio":0.11923881,"word_repetition_ratio":0.010570824,"special_character_ratio":0.24782848,"punctuation_ratio":0.1021814,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98502636,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-19T08:25:50Z\",\"WARC-Record-ID\":\"<urn:uuid:81ff57a0-ea92-405f-a1a7-866044288685>\",\"Content-Length\":\"31210\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:fe682f71-76b7-4b15-8375-f8ff7cd5359e>\",\"WARC-Concurrent-To\":\"<urn:uuid:2c3043fa-713b-415a-96a8-03ab9c3b7c3a>\",\"WARC-IP-Address\":\"128.243.74.2\",\"WARC-Target-URI\":\"http://optics.eee.nottingham.ac.uk/w/index.php?title=Cadence_Waveform_Import_and_Export&oldid=298\",\"WARC-Payload-Digest\":\"sha1:J5VN6QOQP6XD4R74OBY4336W4XHGVNFK\",\"WARC-Block-Digest\":\"sha1:7XPIBMWJ5FV3NE7JHM7PX53MIIZNSPKV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579250594333.5_warc_CC-MAIN-20200119064802-20200119092802-00314.warc.gz\"}"}