• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC Design
  3. Matlab cds_srr DC sweep of Mosfet Parameters

Stats

  • Locked Locked
  • Replies 9
  • Subscribers 125
  • Views 18928
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Matlab cds_srr DC sweep of Mosfet Parameters

aravichandran
aravichandran over 7 years ago

Hi,

I am running cadence 6.1.7-64b along with MATLAB R2016b. I am trying to run a MATLAB script in which I perform a DC sweep on MOSFET parameters such as id, vt, igs, gm, gmb,... and store the parameters in a table.

My assignment of the cds_srr function and output are shown below:

struct_n = cds_srr(c.outfile, c.sweep, params_n{1})

c.sweep = 'dcOpInfo-info', params_n{1} = mn.mds.ids

The output is shown below:

cds_srr(c.outfile,c.sweep)
Total: 23 properties
  'PSFversion'   'BINPSF creation time'   'PSF style'   'PSF types'   'PSF sweeps'   'PSF sweep points'   'PSF sweep min'   'PSF sweep max'   'PSF groups'   'PSF traces'   'simulator'   'version'   'date'   'design'   'analysis type'   'analysis name'   'analysis description'   'xVecSorted'   'tolerance.relative'   'AnalysisName'   'AnalysisType'   'OpPointTemp.Value'   'OpPointTemp.Units'

Total: 0 type(s) of signals

struct_n =

  struct with fields:

        info: {'psp103'  'A'  'vbsp'  ''  'vdsp'  ''  'vgsp'  ''  'p_length'  ''  'n_length'  ''  'vsbn'  ''  'vgsn'  ''  'vdsn'  ''}
        vdsn: [0 1.5000 3]
        vgsn: [0 1.5000 3]
        vsbn: [0 1]
    n_length: [3.6000e-07 1.3600e-06]
    p_length: [3.6000e-07 1.3600e-06]
        vgsp: [0 1.5000 3]
        vdsp: [0 1.5000 3]
        vbsp: [2×1 double]
      psp103: [8-D double]

I am confused regarding the output because I expected to see all of the saved DC op quantities in the format shown below:

cds_srr('/home/username/simulation/NMOS_CHAR/spectre/schematic/psf','dc-dc')
Total: 26 properties
     'PSFversion'      'BINPSF creation time'      'PSF style'      'PSF types'      'PSF sweeps'      'PSF sweep points'      'PSF sweep min'      'PSF sweep max'      'PSF groups'      'PSF traces'      'simulator'      'version'      'date'      'design'      'analysis type'      'analysis name'      'analysis description'      'xVecSorted'      'tolerance.relative'      'reltol'      'abstol(V)'      'abstol(I)'      'temp'      'tnom'      'tempeffects'      'gmindc'

Total: 11 type(s) of signals
Signal type: F    Data type: Real
     'M1:cjd'      'M1:cjs'      'M1:cgg'      'M1:cgd'      'M1:cgs'      'M1:cgb'      'M1:cdg'      'M1:cdd'      'M1:cds'      'M1:cdb'      'M1:csg'      'M1:csd'      'M1:css'      'M1:csb'      'M1:cbg'      'M1:cbd'      'M1:cbs'      'M1:cbb'      'M1:cgsovl'      'M1:cgdovl'      'M1:cgbovl'      'M1:cddbi'      'M1:cssbi'      'M1:cggbi'      'M1:cgsbi'      'M1:cgdbi'      'M1:cbdbi'      'M1:cbsbi'
Signal type: V    Data type: Real
     'M1:vgs'      'M1:vds'      'M1:vbs'      'M1:vgb'      'M1:vdb'      'M1:vgd'      'M1:vth'      'M1:vdsat'      'M1:vgsteff'      'net1'      'net3'      'net7'
Signal type: I    Data type: Real
     'V0:p'      'V1:p'      'V2:p'
Signal type: enum    Data type: Real
     'M1:region'      'M1:reversed'
Signal type: A    Data type: Real
     'M1:ids'      'M1:isub'      'M1:id'      'M1:is'      'M1:ibulk'      'M1:ibs'      'M1:ibd'      'M1:i1'      'M1:i3'      'M1:i4'      'M1:igd'      'M1:igs'      'M1:igb'      'M1:igcs'      'M1:igcd'      'M1:igidl'      'M1:igisl'
Signal type: S    Data type: Real
     'M1:gm'      'M1:gds'      'M1:gmbs'      'M1:gbd'      'M1:gbs'
Signal type: A_V_2    Data type: Real
     'M1:betaeff'
Signal type: Coul    Data type: Real
     'M1:qb'      'M1:qg'      'M1:qd'      'M1:qbd'      'M1:qbs'      'M1:qinv'      'M1:qgi'      'M1:qsi'      'M1:qdi'      'M1:qbi'      'M1:qsrco'
Signal type: Ohm    Data type: Real
     'M1:ron'
Signal type: W    Data type: Real
     'M1:pwr'
Signal type: V    Data type: Real
     'M1:gmoverid'

Can someone please help me?

Sincerely,

Adithya

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 7 years ago

    Hi Adithya,

    It's not clear how you've set up the sweep in spectre, but I wouldn't expect the swept data to  be in the dcOpInfo-info results. I'd expect it to be in the dc-dc results - but then you'd have to save the operating point data for the transistor. If I do:

    //

    model nch psp102 type=n

    Vd (vd 0) vsource dc=1
    Vg (vg 0) vsource dc=1
    M1 (vd vg 0 0) nch w=1u l=0.2u

    save M1:oppoint
    dc dc oppoint=yes dev=Vd param=dc start=0 stop=2 step=0.1
    dcOpInfo info what=oppoint where=rawfile

    then in Matlab I can do:

    cds_srr('forum.raw','dc-dc','M1:gds')

    ans =

    struct with fields:

    info: {'Ohm' '' 'dc' 'V'}
    dc: [21×1 double]
    Ohm: [21×1 double]

    If I retrieve the value from dcOpInfo-info then it's just a single value. I'm slightly surprised because you seemed to be looking at mn.mds.ids in your expression - is that a single device?

    Hopefully the above example will give you some pointers...

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • aravichandran
    aravichandran over 7 years ago in reply to Andrew Beckett

    Hi Andrew,

    I am using the ADE-L GUI to set up the simulation. Here is my current simulation setup from the input.scs file

    // Library name: dualband_v1_adithya_ravichandran

    // Cell name: techsweep_config_bsim3_130nm

    // View name: schematic

    mn (vdsn vgsn vsn vbsn) n3p3fet w=10u l=(n_length)  nf=1 slices=1 cur=0 \

            m=1 as=4p ad=4p ps=20.8u pd=20.8u

    V15 (vbsp vdsp) vsource dc=vbsp type=dc

    V13 (vdsp vdp) vsource dc=vdsp type=dc

    V12 (vdp 0) vsource dc=0 type=dc

    V16 (vdsp vgsp) vsource dc=vgsp type=dc

    V3 (vdsn vsn) vsource dc=vdsn type=dc

    V1 (vsn 0) vsource dc=0 type=dc

    V0 (vgsn vsn) vsource dc=vgsn type=dc

    V4 (0 vbsn) vsource dc=vsbn type=dc

    mp (vdp vgsp vdsp vbsp) p3p3fet w=10u l=p_length nf=1 slices=1 cur=0 m=1 \

            as=4p ad=4p ps=20.8u pd=20.8u

    simulatorOptions options reltol=1e-3 vabstol=1e-6 iabstol=1e-12 temp=27 \

        tnom=27 scalem=1.0 scale=1.0 gmin=1e-12 rforce=1 \

        redefinedparams=warning maxnotes=5 maxwarns=5 digits=5 cols=80 \

        pivrel=1e-3 sensfile="../psf/sens.output" checklimitdest=both 

    dcOp dc write="spectre.dc" maxiters=150 maxsteps=10000 annotate=status

    dcOpInfo info what=oppoint where=rawfile

    dc dc param=vgsn start=0 stop=3.3 step=100m oppoint=rawfile maxiters=150 \

        maxsteps=10000 annotate=status

    modelParameter info what=models where=rawfile

    element info what=inst where=rawfile

    outputParameter info what=output where=rawfile

    designParamVals info what=parameters where=rawfile

    primitives info what=primitives where=rawfile

    subckts info what=subckts where=rawfile

    save mn:id mn:id mn:vth mn:vth mn:gm mn:gm mn:gds mn:gds mn:cgg mn:cgg \

        mn:cgs mn:cgs mn:cdd mn:cdd mn:css mn:css mn:cgd mn:cgd mn:cgb mn:cgb 

    saveOptions options save=all currents=all

    To perform the parametric sweep, I select Tools -> Parametric sweep and sweep the VGS, VDS, VSB, and L. When I click on Tools -> Results Broswer, the data is stored under the 

    folder called dcOpInfo -> mn -> mds. I don't have a 'dc-dc' option available.

    I see that the results are stored in /home/projects/dualband_v1/work_libs/adithya.ravichandran/cds/simulation/techsweep_config_bsim3_130nm/spectre/schematic/psf.

    I see that in your example, you have a file called 'forum.raw' as one of your arguments in the cds_srr() function. I see that my data is being stored in the psf folder in a file called rawfile.

    For some reason, I can't seem to find that file. Can you please provide some clarification?

    Thanks!

    Sincerely,

    Adithya

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to aravichandran

    Hi Adithya,

    OK, don't worry about the fact that my results were in a directory called 'forum.raw' and yours are in 'psf'. That's just because I ran from a netlist using spectre and let it pick the default result directory name. ADE invokes spectre with "-raw ../psf" which means that it puts the results into a directory called psf.

    I suspect your models are subckt models, and that the save statement at the end isn't doing anything. It will probably generate a bunch of warnings in the spectre output log like this:

    WARNING (SPECTRE-8061): `mn': Does not have a terminal named `id'.
    WARNING (SPECTRE-8287): Ignoring invalid item `mn:id' in save statement.
    WARNING (SPECTRE-8061): `mn': Does not have a terminal named `id'.
    WARNING (SPECTRE-8287): Ignoring invalid item `mn:id' in save statement.
    WARNING (SPECTRE-8061): `mn': Does not have a terminal named `vth'.
    WARNING (SPECTRE-8287): Ignoring invalid item `mn:vth' in save statement.
    WARNING (SPECTRE-8061): `mn': Does not have a terminal named `vth'.
    WARNING (SPECTRE-8287): Ignoring invalid item `mn:vth' in save statement.
    WARNING (SPECTRE-8061): `mn': Does not have a terminal named `gm'.
    Further occurrences of this warning will be suppressed.
    WARNING (SPECTRE-8287): Ignoring invalid item `mn:gm' in save statement.
    Further occurrences of this warning will be suppressed.

    That's because the transistor is probably actually called mn.mds (i.e. there's a subckt model with a transistor inside). I took your netlist and emulated this by adding models:

    subckt n3p3fet (d g s b)
      parameters w=1u l=1u nf=1
      mds (d g s b) n3p3fetint w=w l=l nf=nf
      model n3p3fetint psp102 type=n
    ends n3p3fet

    subckt p3p3fet (d g s b)
      parameters w=1u l=1u nf=1
      mds (d g s b) p3p3fetint w=w l=l nf=nf
      model p3p3fetint psp102 type=p
    ends p3p3fet

    If I do that, I get the same warnings above, and then I see the hierarchy in the results browser. You should see "dc" in the results browser, but it's unlikely you'll have any transistor data in it because of the malformed save statements.

    In my case I can access (for example): cds_srr('psf','dcOpInfo-info','mn.mds:ids') this returns a single number. It won't return anything from the dc sweep because the info analysis is always just from the initial operating point and not the swept results.

    If I change the save statement to:

    save mn.mds:id mn.mds:id mn.mds:vth mn.mds:vth mn.mds:gm mn.mds:gm mn.mds:gds mn.mds:gds mn.mds:cgg mn.mds:cgg \
      mn.mds:cgs mn.mds:cgs mn.mds:cdd mn.mds:cdd mn.mds:css mn.mds:css mn.mds:cgd mn.mds:cgd mn.mds:cgb mn.mds:cgb

    then I can access: cds_srr('psf','dc-dc','mn.mds:gm') (note I can't use :ids because that wasn't something you saved) - which is now a waveform as I mentioned before.

    If this isn't clear, I suggest you contact customer support as I think this will be far easier to explain via a webex session where we can actually see your data.

    Thanks,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • aravichandran
    aravichandran over 7 years ago in reply to Andrew Beckett

    Hi Andrew,


    That did it. I can now access the field members. I have one more question. These parameters are going into a 4x4 mapping table for quick look up via Matlab. I keep getting an "Array dimensions must match for binary array op" error in the last part of my script. I was wondering if you could please take a look and see why I am getting this error.
    Here are the matlab scripts below. The first script sets up the structure with member fields for the nch and pch devices. The second script below extracts the data for the nch and pch and creates a 4D array that can be accessed via a lookup table. I have bolded the line that causes the error.


    % Configuration for techsweep_spectre.m
    % Boris Murmann
    % Stanford University
    function c = techsweep_config_bsim3_130nm_spectre

    % Models and file paths
    c.modelfile = 'bsim3v3_130nm_spectre.txt';
    c.modelinfo = '130nm CMOS, BSIM3';
    c.corner = 'NOM';
    c.temp = 300;
    c.modeln = 'n3p3fet_bsim';
    c.modelp = 'p3p3fet_bsim';
    c.savefilen = '3p3_nch';
    c.savefilep = '3p3_pch';
    %c.simcmd = 'set path=($path /cad/cadence/IC615.06.15.502.lnx/tools/bin); /cad/cadence/MMSIM7.20.284.lnx86/tools/bin/spectre techsweep.scs >! techsweep.out';
    c.outfile = '/home/projects/dualband_v1/work_libs/adithya.ravichandran/cds/simulation/techsweep_config_bsim3_130nm/spectre/schematic/psf';
    c.sweep = 'dc-dc';

    % Sweep parameters
    c.VGS_step = 1%100e-3;
    c.VDS_step = 1%100e-3;
    c.VSB_step = 1%50e-3;
    c.VGS_max = 3.3;
    c.VDS_max = 3.3;
    c.VSB_max = 1;
    c.VGS = 0:c.VGS_step:c.VGS_max;
    c.VDS = 0:c.VDS_step:c.VDS_max;
    c.VSB = 0:c.VSB_step:c.VSB_max;
    c.LENGTH = [(0.3:1:2)];
    c.WIDTH = 10;
    c.NFING = 1;

    % Variable mapping
    c.outvars = {'ID','VT','IGD','IGS','GM','GMB','GDS','CGG','CGS','CSG','CGD','CDG','CGB','CDD','CSS'};
    c.n{1}= {'mn.mds:ids','A', [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.n{2}= {'mn.mds:vth','V', [0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.n{3}= {'mn.mds:igd','A', [0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.n{4}= {'mn.mds:igs','A', [0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.n{5}= {'mn.mds:gm', 'S', [0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 ]};
    c.n{6}= {'mn.mds:gmb','S', [0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 ]};
    c.n{7}= {'mn.mds:gds','S', [0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 ]};
    c.n{8}= {'mn.mds:cgg','F', [0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 ]};
    c.n{9}= {'mn.mds:cgs','F', [0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 ]};
    c.n{10}={'mn.mds:cgd','F', [0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 ]};
    c.n{11}={'mn.mds:cgb','F', [0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 ]};
    c.n{12}={'mn.mds:cdd','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ]};
    c.n{13}={'mn.mds:cdg','F', [0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 ]};
    c.n{14}={'mn.mds:css','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ]};
    c.n{15}={'mn.mds:csg','F', [0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 ]};
    c.n{16}={'mn.mds:cjd','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ]};
    c.n{17}={'mn.mds:cjs','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ]};
    %
    % {'ID','VT','IGD','IGS','GM','GMB','GDS','CGG','CGS','CSG','CGD','CDG','CGB','CDD','CSS'};
    c.p{1}= {'mp.mds:ids','A', [-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.p{2}= {'mp.mds:vth','V', [0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.p{3}= {'mp.mds:igd','A', [0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.p{4}= {'mp.mds:igs','A', [0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.p{5}= {'mp.mds:gm', 'S', [0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 ]};
    c.p{6}= {'mp.mds:gmb','S', [0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 ]};
    c.p{7}= {'mp.mds:gds','S', [0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 ]};
    c.p{8}= {'mp.mds:cgg','F', [0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 ]};
    c.p{9}= {'mp.mds:cgs','F', [0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 ]};
    c.p{10}={'mp.mds:cgd','F', [0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 ]};
    c.p{11}={'mp.mds:cgb','F', [0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 ]};
    c.p{12}={'mp.mds:cdd','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ]};
    c.p{13}={'mp.mds:cdg','F', [0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 ]};
    c.p{14}={'mp.mds:css','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ]};
    c.p{15}={'mp.mds:csg','F', [0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 ]};
    c.p{16}={'mp.mds:cjd','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ]};
    c.p{17}={'mp.mds:cjs','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ]};

    % Simulation netlist
    netlist = sprintf([...
    '//techsweep.scs \n'...
    'include %s\n'...
    'include "techsweep_params.scs" \n'...
    'save mn:all \n'...
    'save mp:all \n'...
    'parameters gs=0 ds=0 \n'...
    'vdsn (vdn 0) vsource dc=ds \n'...
    'vgsn (vgn 0) vsource dc=gs \n'...
    'vbsn (vbn 0) vsource dc=-sb \n'...
    'vdsp (vdp 0) vsource dc=-ds \n'...
    'vgsp (vgp 0) vsource dc=-gs \n'...
    'vbsp (vbp 0) vsource dc=sb \n'...
    '\n'...
    'mn (vdn vgn 0 vbn) n3p3fet l=length*1e-6 w=5e-6 multi=1 nf=1 _ccoflag=1\n'...
    'mp (vdp vgp 0 vbp) p3p3fet l=length*1e-6 w=5e-6 multi=1 nf=1 _ccoflag=1\n'...
    '\n'...
    'options1 options gmin=1e-13 reltol=1e-4 vabstol=1e-6 iabstol=1e-10 temp=%d tnom=27 rawfmt=psfbin rawfile="./techsweep.raw" \n'...
    'sweepvds sweep param=ds start=0 stop=%d step=%d { \n'...
    'sweepvgs dc param=gs start=0 stop=%d step=%d \n'...
    '}\n'...
    ], c.modelfile, ...
    c.temp-273, ...
    c.VGS_max, c.VGS_step, ...
    c.VDS_max, c.VDS_step);

    % Write netlist
    fid = fopen('techsweep.scs', 'w');
    fprintf(fid, netlist);
    fclose(fid);

    return

    % Matlab script for technology characterization
    % Boris Murmann, Stanford University
    clear all; close all;

    %setenv('LD_LIBRARY_PATH', '/opt/Cadence/installs/SPECTRE161/tools.lnx86/lib/64bit')
    %setenv('MATLABPATH', '/opt/Cadence/installs/SPECTRE161/tools.lnx86/spectre/matlab/64bit')

    % Load configuration
    c = techsweep_config_bsim3_130nm_spectre;

    % Write sweep info
    nch.INFO = c.modelinfo;
    nch.CORNER = c.corner;
    nch.TEMP = c.temp;
    nch.NFING = c.NFING;
    nch.L = c.LENGTH';
    nch.W = c.WIDTH;
    nch.VGS = c.VGS';
    nch.VDS = c.VDS';
    nch.VSB = c.VSB';
    %
    pch.INFO = c.modelinfo;
    pch.CORNER = c.corner;
    pch.TEMP = c.temp;
    pch.NFING = c.NFING;
    pch.L = c.LENGTH';
    pch.W = c.WIDTH;
    pch.VGS = c.VGS';
    pch.VDS = c.VDS';
    pch.VSB = c.VSB';

    % Simulation loop
    for i = 1:length(c.LENGTH)
    str=sprintf('L = %2.2f', c.LENGTH(i));
    disp(str);
    for j = 1:length(c.VSB)
    % Write simulation parameters
    fid=fopen('techsweep_params.scs', 'w');
    fprintf(fid,'parameters length = %d\n', c.LENGTH(i));
    fprintf(fid,'parameters sb = %d\n', c.VSB(j));
    fclose(fid);

    pause(5)

    % Run simulator
    %[status,result] = system(c.simcmd);
    %if(status)
    %disp('Simulation did not run properly. Check techsweep.out.')
    %return;
    %end

    % Initialize data blocks
    for m = 1:length(c.outvars)
    nch.(c.outvars{m})(i,:,:,j) = zeros(length(c.VGS), length(c.VDS));
    pch.(c.outvars{m})(i,:,:,j) = zeros(length(c.VGS), length(c.VDS));
    end

    % Read and store results
    for k = 1:length(c.n)
    params_n = c.n{k};
    struct_n = cds_srr(c.outfile, c.sweep, params_n{1});
    values_n = struct_n.(params_n{2});
    params_p = c.p{k};
    struct_p = cds_srr(c.outfile, c.sweep, params_p{1});
    values_p = struct_p.(params_p{2}); %params_p{2}
    for m = 1:length(c.outvars)
    nch.(c.outvars{m})(i,:,:,j) = squeeze(nch.(c.outvars{m})(i,:,:,j)) + values_n*params_n{3}(m);
    pch.(c.outvars{m})(i,:,:,j) = squeeze(pch.(c.outvars{m})(i,:,:,j)) + values_p*params_p{3}(m);
    end
    end
    end
    end

    save(c.savefilen, 'nch');
    save(c.savefilep, 'pch');

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • aravichandran
    aravichandran over 7 years ago in reply to Andrew Beckett

    Hi Andrew,


    That did it. I can now access the field members. I have one more question. These parameters are going into a 4x4 mapping table for quick look up via Matlab. I keep getting an "Array dimensions must match for binary array op" error in the last part of my script. I was wondering if you could please take a look and see why I am getting this error.
    Here are the matlab scripts below. The first script sets up the structure with member fields for the nch and pch devices. The second script below extracts the data for the nch and pch and creates a 4D array that can be accessed via a lookup table. I have bolded the line that causes the error.


    % Configuration for techsweep_spectre.m
    % Boris Murmann
    % Stanford University
    function c = techsweep_config_bsim3_130nm_spectre

    % Models and file paths
    c.modelfile = 'bsim3v3_130nm_spectre.txt';
    c.modelinfo = '130nm CMOS, BSIM3';
    c.corner = 'NOM';
    c.temp = 300;
    c.modeln = 'n3p3fet_bsim';
    c.modelp = 'p3p3fet_bsim';
    c.savefilen = '3p3_nch';
    c.savefilep = '3p3_pch';
    %c.simcmd = 'set path=($path /cad/cadence/IC615.06.15.502.lnx/tools/bin); /cad/cadence/MMSIM7.20.284.lnx86/tools/bin/spectre techsweep.scs >! techsweep.out';
    c.outfile = '/home/projects/dualband_v1/work_libs/adithya.ravichandran/cds/simulation/techsweep_config_bsim3_130nm/spectre/schematic/psf';
    c.sweep = 'dc-dc';

    % Sweep parameters
    c.VGS_step = 1%100e-3;
    c.VDS_step = 1%100e-3;
    c.VSB_step = 1%50e-3;
    c.VGS_max = 3.3;
    c.VDS_max = 3.3;
    c.VSB_max = 1;
    c.VGS = 0:c.VGS_step:c.VGS_max;
    c.VDS = 0:c.VDS_step:c.VDS_max;
    c.VSB = 0:c.VSB_step:c.VSB_max;
    c.LENGTH = [(0.3:1:2)];
    c.WIDTH = 10;
    c.NFING = 1;

    % Variable mapping
    c.outvars = {'ID','VT','IGD','IGS','GM','GMB','GDS','CGG','CGS','CSG','CGD','CDG','CGB','CDD','CSS'};
    c.n{1}= {'mn.mds:ids','A', [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.n{2}= {'mn.mds:vth','V', [0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.n{3}= {'mn.mds:igd','A', [0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.n{4}= {'mn.mds:igs','A', [0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.n{5}= {'mn.mds:gm', 'S', [0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 ]};
    c.n{6}= {'mn.mds:gmb','S', [0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 ]};
    c.n{7}= {'mn.mds:gds','S', [0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 ]};
    c.n{8}= {'mn.mds:cgg','F', [0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 ]};
    c.n{9}= {'mn.mds:cgs','F', [0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 ]};
    c.n{10}={'mn.mds:cgd','F', [0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 ]};
    c.n{11}={'mn.mds:cgb','F', [0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 ]};
    c.n{12}={'mn.mds:cdd','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ]};
    c.n{13}={'mn.mds:cdg','F', [0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 ]};
    c.n{14}={'mn.mds:css','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ]};
    c.n{15}={'mn.mds:csg','F', [0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 ]};
    c.n{16}={'mn.mds:cjd','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ]};
    c.n{17}={'mn.mds:cjs','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ]};
    %
    % {'ID','VT','IGD','IGS','GM','GMB','GDS','CGG','CGS','CSG','CGD','CDG','CGB','CDD','CSS'};
    c.p{1}= {'mp.mds:ids','A', [-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.p{2}= {'mp.mds:vth','V', [0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.p{3}= {'mp.mds:igd','A', [0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.p{4}= {'mp.mds:igs','A', [0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 ]};
    c.p{5}= {'mp.mds:gm', 'S', [0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 ]};
    c.p{6}= {'mp.mds:gmb','S', [0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 ]};
    c.p{7}= {'mp.mds:gds','S', [0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 ]};
    c.p{8}= {'mp.mds:cgg','F', [0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 ]};
    c.p{9}= {'mp.mds:cgs','F', [0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 ]};
    c.p{10}={'mp.mds:cgd','F', [0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 ]};
    c.p{11}={'mp.mds:cgb','F', [0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 ]};
    c.p{12}={'mp.mds:cdd','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ]};
    c.p{13}={'mp.mds:cdg','F', [0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 ]};
    c.p{14}={'mp.mds:css','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ]};
    c.p{15}={'mp.mds:csg','F', [0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 ]};
    c.p{16}={'mp.mds:cjd','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ]};
    c.p{17}={'mp.mds:cjs','F', [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ]};

    % Simulation netlist
    netlist = sprintf([...
    '//techsweep.scs \n'...
    'include %s\n'...
    'include "techsweep_params.scs" \n'...
    'save mn:all \n'...
    'save mp:all \n'...
    'parameters gs=0 ds=0 \n'...
    'vdsn (vdn 0) vsource dc=ds \n'...
    'vgsn (vgn 0) vsource dc=gs \n'...
    'vbsn (vbn 0) vsource dc=-sb \n'...
    'vdsp (vdp 0) vsource dc=-ds \n'...
    'vgsp (vgp 0) vsource dc=-gs \n'...
    'vbsp (vbp 0) vsource dc=sb \n'...
    '\n'...
    'mn (vdn vgn 0 vbn) n3p3fet l=length*1e-6 w=5e-6 multi=1 nf=1 _ccoflag=1\n'...
    'mp (vdp vgp 0 vbp) p3p3fet l=length*1e-6 w=5e-6 multi=1 nf=1 _ccoflag=1\n'...
    '\n'...
    'options1 options gmin=1e-13 reltol=1e-4 vabstol=1e-6 iabstol=1e-10 temp=%d tnom=27 rawfmt=psfbin rawfile="./techsweep.raw" \n'...
    'sweepvds sweep param=ds start=0 stop=%d step=%d { \n'...
    'sweepvgs dc param=gs start=0 stop=%d step=%d \n'...
    '}\n'...
    ], c.modelfile, ...
    c.temp-273, ...
    c.VGS_max, c.VGS_step, ...
    c.VDS_max, c.VDS_step);

    % Write netlist
    fid = fopen('techsweep.scs', 'w');
    fprintf(fid, netlist);
    fclose(fid);

    return

    % Matlab script for technology characterization
    % Boris Murmann, Stanford University
    clear all; close all;

    %setenv('LD_LIBRARY_PATH', '/opt/Cadence/installs/SPECTRE161/tools.lnx86/lib/64bit')
    %setenv('MATLABPATH', '/opt/Cadence/installs/SPECTRE161/tools.lnx86/spectre/matlab/64bit')

    % Load configuration
    c = techsweep_config_bsim3_130nm_spectre;

    % Write sweep info
    nch.INFO = c.modelinfo;
    nch.CORNER = c.corner;
    nch.TEMP = c.temp;
    nch.NFING = c.NFING;
    nch.L = c.LENGTH';
    nch.W = c.WIDTH;
    nch.VGS = c.VGS';
    nch.VDS = c.VDS';
    nch.VSB = c.VSB';
    %
    pch.INFO = c.modelinfo;
    pch.CORNER = c.corner;
    pch.TEMP = c.temp;
    pch.NFING = c.NFING;
    pch.L = c.LENGTH';
    pch.W = c.WIDTH;
    pch.VGS = c.VGS';
    pch.VDS = c.VDS';
    pch.VSB = c.VSB';

    % Simulation loop
    for i = 1:length(c.LENGTH)
    str=sprintf('L = %2.2f', c.LENGTH(i));
    disp(str);
    for j = 1:length(c.VSB)
    % Write simulation parameters
    fid=fopen('techsweep_params.scs', 'w');
    fprintf(fid,'parameters length = %d\n', c.LENGTH(i));
    fprintf(fid,'parameters sb = %d\n', c.VSB(j));
    fclose(fid);

    pause(5)

    % Run simulator
    %[status,result] = system(c.simcmd);
    %if(status)
    %disp('Simulation did not run properly. Check techsweep.out.')
    %return;
    %end

    % Initialize data blocks
    for m = 1:length(c.outvars)
    nch.(c.outvars{m})(i,:,:,j) = zeros(length(c.VGS), length(c.VDS));
    pch.(c.outvars{m})(i,:,:,j) = zeros(length(c.VGS), length(c.VDS));
    end

    % Read and store results
    for k = 1:length(c.n)
    params_n = c.n{k};
    struct_n = cds_srr(c.outfile, c.sweep, params_n{1});
    values_n = struct_n.(params_n{2});
    params_p = c.p{k};
    struct_p = cds_srr(c.outfile, c.sweep, params_p{1});
    values_p = struct_p.(params_p{2}); %params_p{2}
    for m = 1:length(c.outvars)
    nch.(c.outvars{m})(i,:,:,j) = squeeze(nch.(c.outvars{m})(i,:,:,j)) + values_n*params_n{3}(m);
    pch.(c.outvars{m})(i,:,:,j) = squeeze(pch.(c.outvars{m})(i,:,:,j)) + values_p*params_p{3}(m);
    end
    end
    end
    end

    save(c.savefilen, 'nch');
    save(c.savefilep, 'pch');

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to aravichandran

    I don't see anything in bold so I don't know which line is causing you problems. Given the length of the script and the fact that I don't have the input data to be able to test it, it would be useful to know what the data looks like on the line that has the error - using the debugger in Matlab ought to make this easy to figure out (especially as the error you describe is just a Matlab error, as far as I know).

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • aravichandran
    aravichandran over 7 years ago in reply to Andrew Beckett

    Hi Andrew,

    I have bolded the lines in the script causing the error.

     % Read and store results
            for k = 1:length(c.n)
                params_n = c.n{k};
                struct_n = cds_srr(c.outfile, c.sweep, params_n{1});
                values_n = struct_n.(params_n{2});
                params_p = c.p{k};
                struct_p = cds_srr(c.outfile, c.sweep, params_p{1});
                values_p = struct_p.(params_p{2}); %params_p{2}
                for m = 1:length(c.outvars)
                    nch.(c.outvars{m})(i,:,:,j)  = squeeze(nch.(c.outvars{m})(i,:,:,j)) + values_n*params_n{3}(m);
                    pch.(c.outvars{m})(i,:,:,j)  = squeeze(pch.(c.outvars{m})(i,:,:,j)) + values_p*params_p{3}(m);
                end
            end
        end
    end

    save(c.savefilen, 'nch');
    save(c.savefilep, 'pch');

    As I step through the code, here are the values for each variable.

    params_n = 1x3 cell {mn.mds.ids A [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]}

    struct_n =

     struct with fields:

             info: {1×20 cell}
             vdsn: [0 1 2 3]
             vgsn: [0 1 2 3]
             vsbn: [0 1]
         n_length: [3.0000e-07 1.3000e-06]
         p_length: [3.0000e-07 1.3000e-06]
             vgsp: [0 1 2 3]
             vdsp: [0 1 2 3]
             vbsp: [0 1]
        n_length1: [18×1 double]
                A: [9-D double]

    values_n = struct_n.(params_n{2});

    squeeze(nch.(c.outvars{m})(i,:,:,j))

    ans =

         0     0     0     0
         0     0     0     0
         0     0     0     0
         0     0     0     0

    values_n*params_n{3}(m) = values_n

    nch.(c.outvars{m})(i,:,:,j)  = squeeze(nch.(c.outvars{m})(i,:,:,j)) + values_n*params_n{3}(m);
    Array dimensions must match for binary array op.

    struct_p has the same format as the struct_n.

    I hope this helps.

    Sincerely,

    Adithya

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to aravichandran

    Hi Adithya,

    It's still really hard to see what the data looks like from what you've said above, but since this is actually a Matlab error which is nothing to do with the Cadence interfaces, you'd probably be better off asking this in a Matlab forum. In fact a Google search for "Array dimensions must match for binary array op" reveals a number of useful discussions on the Matlab site which talk about this. It essentially suggests that one of the operations (maybe the addition) doesn't have matching array dimensions. For example:

    y = rand(7, 5, 2);
    x = rand(3, 6, 2);
    y+x

    gives the same message: Array dimensions must match for binary array op.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to Andrew Beckett

    Hi, My questions were regarding my matlab script and the integration of the cds_srr() function. Mr. Andrew Beckett has been instrumental in helping me with my problem. I am glad to report that my scripts are now working and kindly request that my posts not be deleted. Sincerely, Adithya

    The above comment was from Adithya in response to a spam moderation (I just approved the post). The system had thought that the post was spam due to repeated text in the Matlab script. Anyway, glad the issue has been resolved.

    Regards,

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information