• 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. when cross() fails

Stats

  • Locked Locked
  • Replies 8
  • Subscribers 125
  • Views 13596
  • 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

when cross() fails

Karev11
Karev11 over 4 years ago

Hi,

In my sim, I sweep code A and check output B, and use cross() function to find the code A so that B = B_target

Understandably, when there is no crossing, cross() returns nothing. My question is, if B vs code A is monotonic, is there a way to output max(code A) when max (B) < B_target and vice versa?

thanks,

Kevin

btw, it doesn't look like calculator accepts logic expressions. i.e, this one doesn't work output = (B<B_target)*max(code A) + cross()

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

    It's really not clear to me what you want here, since the cross() function returns a time, and the maximum of a value (max doesn't work on waveforms, but that's beside the point) would return a voltage or current. Rather than guessing, can you please show some waveforms and pictures to explain your requirement more clearly?

    It is (sort of) possible to include conditions in expressions, although that has to be done with care because such operators/functions don't necessarily extend to work with waveforms - so it may make sense to use a custom SKILL function to do this instead. However, I can't really answer that unless I really know what you want!

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 4 years ago

    It's really not clear to me what you want here, since the cross() function returns a time, and the maximum of a value (max doesn't work on waveforms, but that's beside the point) would return a voltage or current. Rather than guessing, can you please show some waveforms and pictures to explain your requirement more clearly?

    It is (sort of) possible to include conditions in expressions, although that has to be done with care because such operators/functions don't necessarily extend to work with waveforms - so it may make sense to use a custom SKILL function to do this instead. However, I can't really answer that unless I really know what you want!

    Andrew.

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

    Dear Kevin,

    Karev11 said:
    My question is, if B vs code A is monotonic, is there a way to output max(code A) when max (B) < B_target and vice versa

    If I understand your question correctly, and I may not be as Andrew suggests it is not totally clear, I think the answer is no. The reason is that you are looking to do a search - which the cross() function definitely will not do. There are two ways to approach this. One way is to run your simulation and then post-process its results using an ocean script that will examine each value of code A, use the time at which code A occurs (from the cross function) and then find the corresponding value of B. Save the latest value of B and when the cross function for A returns nil as A i increasing , choose the last value of B and output its value with the corresponding previous value of A. This can be done using a simple while() loop. I have used this technique countless number of times to, for example, find the input threshold of a simple CMOS inverter where the output crosses VDD/2.

    Does this help Kevin? Maybe I still do not understand your question?

    Shawn

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Karev11
    Karev11 over 4 years ago in reply to ShawnLogan

    thanks Andrew and Shawn for the reply.  I also realized that original question wasn't very clear, sorry.. 

    Below is a picture, output_B goes up as a result of input code_A, when there is crossing, I can use value() function to find corresponding code_A,  when there is no crossing between output_B and B_target, cross() returns nil .  The question is, can there be an expression that ouputs max(code_A) instead of nil in this case?

      

    thanks,

    Kevin

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ShawnLogan
    ShawnLogan over 4 years ago in reply to Karev11

    Dear Kevin,

    Karev11 said:
    Below is a picture, output_B goes up as a result of input code_A, when there is crossing, I can use value() function to find corresponding code_A,  when there is no crossing between output_B and B_target, cross() returns nil .  The question is, can there be an expression that ouputs max(code_A) instead of nil in this case?

    The picture is quite useful - thank you!!

    I think I may have understood your original question as I believe my comment is still applicable. Basically, you need to do a search to determine the last value of A that results in a non-nil cross() function with B as its waveform argument and a threshold of B_target. There can not be a single expression as, if Code A has N transitions and if Code B has M where M<=N, there need to be at M "tests" (i.e. evaluating M expressions of code B with the cross() function.

    The example I mentioned requires the same algorithm as what I believe you need. in my example, you sweep the DC input voltage of an inverter from 0 to VDD in some increment delta_V. At each input voltage value, you examine the output of the cross function whose arguments are the CMOS inverter output voltage with a crossing threshold of VDD/2 and a "falling" slope (i.e, direction). You save the last input voltage value and when the cross() function returns a non-nil value (since the output voltage first crosses VDD/2 with a negative slope), you have bounded the input threshold to the current value of vin and the prior value at vin-delta_V. If you are familiar with ocean Kevin, the code to so this is pretty straightforward. 

    In reality, the inverter threshold determination problem can also be studied using a new expression defined as the slope of the ratio of vout/vin. In this case, when the slope of the ratio of vout/vin becomes -1.0 the first time, the input voltage corresponds to the input threshold. In your case, if you know the relationship that should exist between B and A, you might consider the same approach. The slope will become undefined when B no longer crosses the target value and hence the slope will be undefined. Hence, you could search the expression you create to find its last non-nil value and this will locate the last value of A where B does achieve its expected value.

    Do either of these approaches help or, at least, provide some insight Kevin?

    Shawn

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Karev11
    Karev11 over 4 years ago in reply to ShawnLogan

    Hi Shawn,

    thanks for the detailed answer.  I get the idea, but I'm not familiar with ocean syntax unfortunately...

    is ocean the only solution?

    Kevin

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Karev11
    Karev11 over 4 years ago in reply to Karev11

    a bit more background: I'm running two tests in series: test1 finds the code, test2 runs another simulation based on that code using calcval() function. so returning nil will cause test2 to fail.

    I cannot keep widening the range of codeA in test1 because of simulation time, I can however, tolerate a bit if the code is not that accurate. i.e. max out is fine in this case

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

    Hi Kevin,

    I can't think of any other way of doing this other than some custom function. It's going to be something like:

    procedure(MyCross(waveB waveA threshold)
      cond(
        (drIsWaveform(waveB)
           let((crossTime)
             crossTime=cross(waveB threshold 1 "rising") ; or whatever you want
             ; the if will return either the value on waveform A or the maximum of waveform A
             if(crossTime then
               value(waveA crossTime)
             else
               ymax(waveA)
             )
          )
        )
        (famIsFamily(waveB)
          famMap('MyCross waveB waveA threshold)
        )
        (t
          error("MyCross: can't handle %L\n" waveB)
        )
      )
    )

    Note that I have not tested this in any way - I just typed it into the forum post. You can put this in a file, and then using the "fx" button in the calculator, add it into the calculator and define the prompts etc. Most of the code in there is to deal with data being waveforms or family waveforms and iterating appropriately - the main logic is simple though (if I understood your requirements properly).

    Having added it into the calculator, it will be registered so that it gets loaded each time, and can be used in the ADE outputs like any built-in function.

    Andrew.

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

    Thanks so much 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