Silly script: Create OCEAN desVars

As we are now ramping up some of the projects for the TSTE16 course at our university, I wanted to just propose a small snippet to get your design variables from MATLAB into Cadence (or more exactly the OCEAN-script for simulating Spectre). The idea is to have MATLAB as master in these projects. This also implies that you want to set any design variables using MATLAB rather than hacking multiple files and risking loosing track of what you’ve been doing.

There are many ways to do this:
(1) One option is to use the simulink interface provided by MATLAB and Cadence, but is a bit over the top in this case.
(2) Another option is to create all the required netlists in the Cadence ADE environment. This will actually generate multiple files in your simulation directory. The “full” file which will be used for spectre is normally called “input.scs” . Further on, if you play that play button (Cadence 6) and study the log file, you actually see in the text which spectre command that is run. (Further on, this command is also stored in the runSimulation “script” stored by Cadence in that directory). The input.scs file is just a concatenation of several files, such as netlistHeader, netlist, netlistFooter — but also some dot-files, like .modelFiles and .designVariables. The latter is a text version of your variables that you could alter if you like. Then concatenate the files into the input.scs accordingly. And run. Requires some more hands on and have less post-processing options.

(3) Or assume we have already generated the Cadence test bench and generated an OCEAN script with a bunch of desVar definitions in it. We can replace those rows with a load command, e.g.

(loadi "tste16ProjDesVars.il")

which you have stored accessible somewhere.
Then make sure you can change that file with MATLAB. Like for example:


desVar(1).Name = 'vccr12';
desVar(1).Value = 1.2;

desVar(2).Name = 'vLo';
desVar(2).Value = 0.1;

desVar(3).Name = 'vHi';
desVar(3).Value = 1.1;

desVar(4).Name = 'compGain';
desVar(4).Value = 1000;

fClk = 1e6;
desVar(5).Name = 'fClk';
desVar(5).Value = fClk;

sigLength = 8;
desVar(6).Name = 'sigLength';
desVar(6).Value = sigLength;

desVar(7).Name = 'tStop';
desVar(7).Value = sigLength/fClk;

desVar(8).Name = 'daisyDemoTopReadFile';
desVar(8).Value = '/home/jacobw/TSTE16/testIn.txt';

desVar(9).Name = 'daisyDemoTopWriteFile';
desVar(9).Value = '/home/jacobw/TSTE16/testOut.txt';

%% This part would then be in a separate function.
fid = fopen('tste16ProjDesVar.il','w');
fprintf(fid, ';; ==================================== \n');
fprintf(fid, ';; Design variables generated by MATLAB \n');
fprintf(fid, ';; ==================================== \n');
for M = 1:length(desVar);
if isstr(desVar(M).Value)
fprintf(fid, '(desVar "%s" "\\"%s\\"")\n', desVar(M).Name, ...
desVar(M).Value);
else
fprintf(fid, '(desVar "%s" %f)\n', desVar(M).Name, ...
desVar(M).Value);
end
end;
fprintf(fid, ';; ==================================== \n');
close(fid);

Where I have used structs to store the intermediate design variables. You can also store strings into the design variables to pass on file names or similar to verilog A blocks in Cadence.
This gives you a file like


;; ====================================
;; Design variables generated by MATLAB
;; ====================================
(desVar "vccr12" 1.200000)
(desVar "vLo" 0.100000)
(desVar "vHi" 1.100000)
(desVar "compGain" 1000.000000)
(desVar "fClk" 1000000.000000)
(desVar "sigLength" 8.000000)
(desVar "tStop" 0.000008)
(desVar "daisyDemoTopReadFile" "\"/home/jacobw/TSTE16/testIn.txt\"")
(desVar "daisyDemoTopWriteFile" "\"/home/jacobw/TSTE16/testOut.txt\"")
;; ====================================

Happy hacking!

Advertisements

5 thoughts on “Silly script: Create OCEAN desVars

  1. I am trying to use this, but ocean doesnt seem to set any desVars from the saved file.
    looks like it just ignores all the ( desVar “… ) lines in the .il file…
    to debug, I added some printf statements in the .il file and they seem to work fine..
    any comments?

    • Could you please tell me what was wrong with your script? I’m trying to follow the same thing but desVar() is always being skipped.

  2. That’s quite odd indeed… I tried it successfully the other day. So a question: does the simulation abort due to the desVar’s not being set? Or does it continue to simulate anyway? If the latter — is your run() command before or after your desVar settings?

    If it aborts – then you can debug a bit further by running from virtuoso (CIW) rather than ocean:

    Take the ocean code and paste it into your virtuoso (CIW). If you paste half (or so) of the code, until your desVar load file to kind of initiate the simulation.

    Then (a) paste the desVar lines from the desVar file. Execute the run() command or whatever you might have left in your original ocean file or (b) type the (loadi "...") thingie.

    Then you can check the variable settings with VAR(“variableName”) – correct or not?

    Hope it helps.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s