Bug report - Issues with PWL repeat expressions

Hi,

  • QSPICE sometimes ignores the last point in a PWL repeat statement.
    If the last time/value point in a PWL repeat sequence has the same value as the previous point, QSPICE ignores that point. In the sequence pwl repeat for 3 0 1 1 2 2 1 5 1 endrepeat the last point is intended to space the repeated pulses out.
    The PWL sequence should result in:

    But produces:

  • A space before a closing parentheses causes the PWL expression to fail
    The statement pwl repeat for (3 0 1 1 2 2 1 5 1 ) endrepeat fails with: Fatal error: Trouble parsing “PWL REPEAT FOR…ENDREPEAT” syntax.
    If the space is removed it works.

  • Parameters in a PWL Repeat expression cause a fatal error
    Given parameters
    .param frequency = 100
    .param period 1/frequency
    .param mark 0.25
    .param t_rise 100µ
    .param t_fall 200µ
    .param t_high {mark * period-t_rise}
    .param t_low {(1-mark) * period-tfall}

    The expressions
    pwl repeat for 3 0 0 +t_rise 1 +t_high 1 +t_fall 0 +t_low 0 endrepeat,
    pwl repeat for 3 0 0 +(t_rise) 1 +(t_high) 1 +(t_fall) 0 +(t_low) 0 endrepeat,
    pwl repeat for 3 0 0 +{t_rise} 1 +{mark*period-t_rise} 1 +{t_fall} 0 +{(1-mark)*period-t_fall} 0 endrepeat ; Works in LTSpice
    all fail with the exception Fatal error: Trouble parsing “PWL REPEAT FOR…ENDREPEAT” syntax.

  • Not supported
    The author of QSPICE is not obliged to implement any of the other undocumented PWL statement forms that LTspice does; https://ltwiki.org/index.php?title=Undocumented_LTspice but it would be help a lot in porting LTspice simulations across to QSPICE, which is what I was busy with when I came across these issues. Of course, a lot of these constructs could be replaced with C++ or Verilog models :grinning:

This is Mike’s comment on repeated PWL when it was implemented on 10/30/2023.
Repeat PWL Source - QSPICE - Qorvo Tech Forum

  • last value of a repeated PWL will be ignored and forced to be equal to the first value

So in other words, the pause between cycles has to appear in front of the pulse.
pwl repeat for 3 0 1 1 2 2 1 5 1 has to become pwl repeat for 3 0 1 3 1 4 2 5 1 endrepeat which isn’t exactly the same thing:
image

QSPICE sometimes ignores the last point in a PWL repeat statement
Update Qspice can fix this : 02/12/2024 Corrected an errant PWL optimization regarded repeated passages.

Parameters in a PWL Repeat expression cause a fatal error
You got issue in 1st and 2nd expression only because a typo in .param


For the 3rd expression, Qspice seems not accepting a +sign outside curly bracket. But curly bracket is normally not required in Qspice.

Sorry about the noise due to the typo. With the latest release I can confirm that it is possible to construct proper pulse sequences. The turn around time and bug fix rate is simply amazing.

Thanks for the help.

1 Like