• 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. How to index spectre vector parameters (even possible?)...

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 125
  • Views 13146
  • 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

How to index spectre vector parameters (even possible?)?

drdanmc
drdanmc over 4 years ago

Is it possible to have a vector parameter as a top level design variable and then pick out elements from that inside of a subckt based on an index parameter?  The following shows what  tried and hopefully it is clear what the desired result would be.

simulator lang=spectre
global 0
parameters MYTOP=[3.3 2.7 1.8 5.0]
subckt my_subcell VOUT
parameters MYINDEX=0

  // this one gives an error:

  V0 (VOUT 0) vsource dc=MYTOP[MYINDEX] type=dc

  // no error on this, but of course that isn't what I was looking for.
  //V0 (VOUT 0) vsource dc=MYINDEX type=dc
ends my_subcell
I7 (OUT3) my_subcell MYINDEX=3
I6 (OUT2) my_subcell MYINDEX=2
I5 (OUT1) my_subcell MYINDEX=1
I4 (OUT0) my_subcell MYINDEX=0
R3 (OUT3 0) resistor r=1K
R2 (OUT2 0) resistor r=1K
R1 (OUT1 0) resistor r=1K
R0 (OUT0 0) resistor r=1K

dcOp dc write="spectre.dc" oppoint=screen

The above trial gives

Cannot run the simulation because syntax error `Unexpected identifier "MYINDEX". Expected integer or operator' was encountered at line 17, column 33. Correct the syntax error and rerun the simulation.

Thanks so much

-Dan

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 4 years ago

    Dan,

    This is not possible, as spectre doesn't have an array index operator for vectors in the netlist language. One approach would be to define a function like this:

    real getMYTOP(real myindex) {
        return myindex==0 ? 3.3 : \
    	myindex==1 ? 2.7 : \
    	myindex==2 ? 1.8 : \
    	5.0
    }
    

    and then use getMYTOP(2) or getMYTOP(1) etc to retrieve the value:

    R1 (n1 0) resistor r=getMYTOP(0)
    R2 (n2 0) resistor r=getMYTOP(1)
    R3 (n3 0) resistor r=getMYTOP(2)
    R4 (n4 0) resistor r=getMYTOP(3)

    My preference would be to not do a floating point comparison, so I would round to the  nearest before comparing (just in case):

    real getMYTOP(real myindex) {
        return round(myindex)==0 ? 3.3 : \
    	round(myindex)==1 ? 2.7 : \
    	round(myindex)==2 ? 1.8 : \
    	5.0
    }

    Andrew

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

    To close the loop on this, I ended up using a Verilog-A model instead of trying to directly do it with spectre primitives.  Verilog-A in spectre is able to accept a vector parameter and an index and then pick out the desired one.


    parameter integer slots = 4;
    parameter integer valArray[0:(slots-1)] = '{slots{0}};
    parameter integer valIndex = 0;

    Then I can use valArray[valIndex] to pick out values.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • drdanmc
    drdanmc over 4 years ago in reply to Andrew Beckett

    To close the loop on this, I ended up using a Verilog-A model instead of trying to directly do it with spectre primitives.  Verilog-A in spectre is able to accept a vector parameter and an index and then pick out the desired one.


    parameter integer slots = 4;
    parameter integer valArray[0:(slots-1)] = '{slots{0}};
    parameter integer valIndex = 0;

    Then I can use valArray[valIndex] to pick out values.

    • 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