• 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. Spectre and Simulink cosimulation - Problem on defining...

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 125
  • Views 1959
  • 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

Spectre and Simulink cosimulation - Problem on defining cosimulation inputs

Milad M
Milad M over 10 years ago

Dear All,

     I have done a successful Spectre/Simulink cosimulation. Then, I used Optimization Toolbox of MATLAB to find the best value of the cosimulation input in order to minimize the cosimulation output. I will explain the MATLAB codes if someone is interested.

     Now, I want to use this method to optimize the parameters of a sample circuit. I'd like to define cosimulation inputs some different things such as the value of a resistor or a capacitor or even the pulse width of a pulse voltage source in the circuit. But, looking at the tutorials, it is only possible to define cosimulation inputs the instance sources such as Vin:wave.

    How can I define cosimulation inputs something different? 

Sincerely Yours,

Milad

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    Hi Milad,

    I don't think this is really possible. You could of course use some kind of voltage-controlled resistor or capacitor (a vccr can be a voltage-controlled resistor, for example) and do it that way.

    If you only want to optimise the component values once for each simulation, you'd be better off having Matlab create some include file with parameter values that the main netlist could reference. Something like that.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Milad M
    Milad M over 10 years ago

    Dear Andrew,

        Thanks for your reply. It's really surprising for me. I hope the interface "SpectreRF Engine", with all these huge tasks, be able to consider any other inputs on the next versions.

        Fortunately, I've just done a successful optimization using a direct approach (not using the interface). I'd like to share the MATLAB script here to be useful for the other users with the same problem:

        It is a circuit with a dc voltage (1 volt) and two series resistor (R1=1k and R0=?). The optimization is going to find the value of R0 in order to have V0 = 0.5 volt.

    function [P] = lsqspectre     % lsqspectre demonstrates using fminbnd with spectre.

    Var = fminbnd(@tracklsq, 10, 2000);

    P = Var;

    function F = tracklsq(Var)

    % Track the output of input.scs to a signal of 0.5

    P = Var;

    % Read input.scs into cell A
    fid = fopen('input.scs','r');
    i = 1;
    tline = fgetl(fid);
    A{i} = tline;
    while ischar(tline)
    i = i+1;
    tline = fgetl(fid);
    A{i} = tline;
    end
    fclose(fid);

    % Change cell A
    A{19} = sprintf('R0 (Vout 0) resistor r=%d',P);

    % Write cell A into txt
    fid = fopen('input.scs', 'w');
    for i = 1:numel(A)
    if A{i+1} == -1
    fprintf(fid,'%s', A{i});
    break
    else
    fprintf(fid,'%s\n', A{i});
    end
    end


    % Run spectre and compute function value
    !spectre input.scs;
    signal = cds_srr('input.raw','tran-tran','Vout');
    F1 = signal.V(end) - 0.5;
    F = abs(F1);

    end
    end

        I will be pleased to explain more about this approach for any one who is interested.

    Sincerely Yours,

    Milad

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    Milad,

    The simulink flow is primarily intended for simulating a system simulation with a mixed-signal implementation. It's not been designed with optimization by Matlab in mind (we have our own optimizer for circuit optimization). Consequently, passing information other than normal signals was not part of the design brief and there are no plans to change this as far as I know.

    The Simulink-AMS or Simulink-Spectre interface is great for when you want to model your encoding scheme (e.g. OFDM modulation etc) through a receiver and then decode the received OFDM and so on and look at BER and similar metrics. All those communication blocks in Simulink become very useful.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Milad M
    Milad M over 10 years ago

    Dear Andrew,

        Many thanks for your explanation. You mentioned something about your own "optimizer". May I know more about it and the methodology you use for any kind of circuit optimization problems?

    Sincerely Yours,

    Milad

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    Milad,

    Please read the Analog Design Environment GXL documentation. You can also look at the Rapid Adoption Kits page on the support site, and look at the "Statistical Analysis" rapid adoption kit, which I believe (if my memory is correct) covers some aspects of circuit optimization. Otherwise contact customer support as we should have another workshop example that takes you through global and local optimization.

    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