Creating arbitrary waveforms with vpwlf and MATLAB

MATLAB is a very powerful tool for signal processing, data analysis and much more. The Cadence suite is a powerful tool for circuit design and simulation. Lets put them together.

The first step is to create a waveform of your choice in MATLAB. Create two vectors, one for time and one for data. The output of 'whos' should have at least these variables:

>> whos















Given your two vectors, next we will save them as ASCII files. From the matlab command window: {{{save time.mat time -ascii save voltage.mat voltage -ascii}}}

Now the vpwlf source in Cadence wants a text file in the format of one ordered pair of time voltage on each line. However MATLAB has dumped a each vector with the entries separated by spaces. Saving both variables to one file gives us all the values of one variable separated by spaces then a newline then the next variables values separated by spaces. So, to convert these differently formatted text files download the handy python script attached to the page. Lets assume you have saved the two .mat files in your home directory and just downloaded the script. From a terminal:

Now run the script, the first argument is the script, the second is the time file, third is voltage file, and fourth is new file in Cadence vpwlf format.

bash-3.1$ python time.mat voltage.mat vpwlf1.txt

Now that you have your file, insert the vpwlf source from NCSU_Analog_Parts. In the object properties under "PWL file name" place the file name (with full path). Run a transient simulation, watch your waveform, and smile :)

{i} A few notes about this method. The script has no error checking, make sure both vectors are the same size. If your circuit is intended for real analog use (not on sampled data) construct the MATLAB waveform with a high sample rate.

{i} This instructional assumes you are on the VLSI machines however it should be able to run on any computer with MATLAB and python installed.

{i} A matlab file has also been created, it's not faster but it's more convenient. To use, Save the .m file below to your matlab path and use the command

>> mlab2pwl(time,signal,[filename])

where filename is optional. This script includes basic error checking and was written on linux.


/!\ Script updated 4/24/08, error fixed

/!\ 4/26/08 Script changed to python, bash script to slow due to re-running awk over and over

/!\ 5/29/08 Added Matlab script

Moin: Cadence/Vpwlf (last edited 2008-09-11 18:40:07 by dfreedma)