• 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
Parents
  • 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
Reply
  • 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
Children
No Data

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