Menu

#268 Netname is picked up at argument in .func statement

v1.0 (example)
closed-fixed
None
5
2014-01-01
2013-12-28
No

The example below explains and demonstrates the bug.

A working example in ngspice 25_release can be seen here:

http://www.ngspice.com/index.php?public_circuit=0RYEpA

This bug also affects more recent versions as used here:

http://easyeda.com/file_view_limit-test_0qke8qI0U.htm

(sorry but I don't know the exact ngspice version number used in EasyEDA)

The expected behaviour is that the choice of argument names in a .func definition should be completely unaffected by the signal or net names used within any instance of the function so defined.

This problem does not arise in LTspice (nor, I think, in PSpice).

  • If the name of the y or z argument in the LIMIT function defined as:
  • .func LIMIT(x,y,z) {min(max(x, y), z)}
  • coincides with a netname that is used in the x argument then the function fails
  • or throws an error.
  • To demonstrate this:
  • In the example netlist below, select any one Vn and Bn pair and plot V(out).

.tran 1u 1m 0

.func LIMIT(x,y,z) {min(max(x, y), z)}

V1 x GND SINE(0 2 1k)
B1 out GND V=LIMIT(V(x),-1,1) ; this instance works OK
V2 y GND SINE(0 2 1k)
B2 out GND V=LIMIT(V(y),0,1) ; this instance gives 0 output.
V3 y GND SINE(0 2 1k)
B3 out GND V=LIMIT(V(y),-1,1) ; this instance throws an error: no such function 'v'
V4 z GND SINE(0 2 1k)
B4 out GND V=LIMIT(V(z),-1,1) ; this instance fails transient solution

.END

Related

Bugs: #268

Discussion

  • Holger Vogt

    Holger Vogt - 2013-12-28
    • status: open --> open-accepted
    • assigned_to: Holger Vogt
     
  • Holger Vogt

    Holger Vogt - 2013-12-28

    I have a fix, needs some testing before upload.

    Thanks for the report.

    Holger

     
    • Andy Fierman

      Andy Fierman - 2013-12-28

      Holger,

      Many thanks. That is an amazing turnaround on a bug report. Especially at
      this time of year!!

      A very happy new Year to all of the ngspice developers.

      :)

      Cheers,

           Andy.
      

      signality.co.uk

      On 28 December 2013 11:03, Holger Vogt h_vogt@users.sf.net wrote:

      I have a fix, needs some testing before upload.

      Thanks for the report.

      Holger

      Status: open-accepted

      Created: Sat Dec 28, 2013 12:13 AM UTC by Andy Fierman
      Last Updated: Sat Dec 28, 2013 12:13 AM UTC
      Owner: Holger Vogt

      The example below explains and demonstrates the bug.

      A working example in ngspice 25_release can be seen here:

      http://www.ngspice.com/index.php?public_circuit=0RYEpA

      This bug also affects more recent versions as used here:

      http://easyeda.com/file_view_limit-test_0qke8qI0U.htm

      (sorry but I don't know the exact ngspice version number used in EasyEDA)

      The expected behaviour is that the choice of argument names in a .func
      definition should be completely unaffected by the signal or net names used
      within any instance of the function so defined.

      This problem does not arise in LTspice (nor, I think, in PSpice).

      • If the name of the y or z argument in the LIMIT function defined as:
      • .func LIMIT(x,y,z) {min(max(x, y), z)}
      • coincides with a netname that is used in the x argument then the
        function fails
      • or throws an error.
      • To demonstrate this:
      • In the example netlist below, select any one Vn and Bn pair and plot
        V(out).

      .tran 1u 1m 0

      .func LIMIT(x,y,z) {min(max(x, y), z)}

      V1 x GND SINE(0 2 1k)
      B1 out GND V=LIMIT(V(x),-1,1) ; this instance works OK

      V2 y GND SINE(0 2 1k) B2 out GND V=LIMIT(V(y),0,1) ; this instance
      gives 0 output.

      V3 y GND SINE(0 2 1k) B3 out GND V=LIMIT(V(y),-1,1) ; this instance
      throws an error: no such function 'v'

      V4 z GND SINE(0 2 1k) B4 out GND V=LIMIT(V(z),-1,1) ; this instance
      fails transient solution

      .END

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/ngspice/bugs/268/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #268

  • Holger Vogt

    Holger Vogt - 2013-12-28

    I have uploaded my fix.

    Please check!

    My test file was:

    bug 268
    .tran 1u 1m 0

    .func LIMIT(x,y,z) {min(max(x, y), z)}
    .func LIMIT2(x,y,v1) {min(max(x, y), v1)}
    .func LIMIT3(x,y,zz) {min(max(x, y), zz)}
    .func testfcnv(y) {y}

    V1 x GND SINE(0 2 1k)
    R1 x V1 1
    Vdc0 V1 GND dc 0
    B1 out1 GND V=LIMIT(V(x),-1,1) ; this instance works OK
    V2 y GND SINE(0 2 1k)
    B2 out2 GND V=LIMIT(V(y),0,1) ; this instance works OK
    B5 out5 GND V=LIMIT(testfcnv(V(y)),0,1) ; this instance works OK
    B3 out3 GND V=LIMIT(V(y),-1,1) ; this instance works OK
    V4 z GND SINE(0 2 1k)
    B4 out4 GND V=LIMIT(V(z),-1,1) ; this instance works OK
    B6 out6 GND V=LIMIT(V(0, z),-1,1) ; this instance works OK
    B7 out7 GND V=LIMIT2(I(V1),-1,I(V1)) ; this instance works OK
    B8 out8 GND V=LIMIT(V(y, 0),-1,1) ; this instance works OK
    V3 zz GND SINE(0.1 2 1k)
    B9 out9 GND V=LIMIT3(V(y, zz),-1,1) ; this instance works OK
    .END

    Holger

     
    • Andy Fierman

      Andy Fierman - 2013-12-28

      It will be two or three days before I can test your fix but I will let you
      know as soon as I have.

      We are using ngspice in an exciting new EDA tool suite:
      http://easyeda.combut it is undergoing a major update in the next few
      days, part of which
      will be to recomplie ngspice from your latest sources so it will be just
      after that when I can try the fix out.

      Cheers,

           Andy.
      

      signality.co.uk

      On 28 December 2013 17:00, Holger Vogt h_vogt@users.sf.net wrote:

      I have uploaded my fix.

      Please check!

      My test file was:

      bug 268
      .tran 1u 1m 0

      .func LIMIT(x,y,z) {min(max(x, y), z)}
      .func LIMIT2(x,y,v1) {min(max(x, y), v1)}
      .func LIMIT3(x,y,zz) {min(max(x, y), zz)}
      .func testfcnv(y) {y}

      V1 x GND SINE(0 2 1k)
      R1 x V1 1
      Vdc0 V1 GND dc 0
      B1 out1 GND V=LIMIT(V(x),-1,1) ; this instance works OK

      V2 y GND SINE(0 2 1k)
      B2 out2 GND V=LIMIT(V(y),0,1) ; this instance works OK
      B5 out5 GND V=LIMIT(testfcnv(V(y)),0,1) ; this instance works OK
      B3 out3 GND V=LIMIT(V(y),-1,1) ; this instance works OK

      V4 z GND SINE(0 2 1k)
      B4 out4 GND V=LIMIT(V(z),-1,1) ; this instance works OK
      B6 out6 GND V=LIMIT(V(0, z),-1,1) ; this instance works OK
      B7 out7 GND V=LIMIT2(I(V1),-1,I(V1)) ; this instance works OK
      B8 out8 GND V=LIMIT(V(y, 0),-1,1) ; this instance works OK
      V3 zz GND SINE(0.1 2 1k)
      B9 out9 GND V=LIMIT3(V(y, zz),-1,1) ; this instance works OK
      .END

      Holger

      Status: open-accepted

      Created: Sat Dec 28, 2013 12:13 AM UTC by Andy Fierman
      Last Updated: Sat Dec 28, 2013 11:03 AM UTC
      Owner: Holger Vogt

      The example below explains and demonstrates the bug.

      A working example in ngspice 25_release can be seen here:

      http://www.ngspice.com/index.php?public_circuit=0RYEpA

      This bug also affects more recent versions as used here:

      http://easyeda.com/file_view_limit-test_0qke8qI0U.htm

      (sorry but I don't know the exact ngspice version number used in EasyEDA)

      The expected behaviour is that the choice of argument names in a .func
      definition should be completely unaffected by the signal or net names used
      within any instance of the function so defined.

      This problem does not arise in LTspice (nor, I think, in PSpice).

      • If the name of the y or z argument in the LIMIT function defined as:
      • .func LIMIT(x,y,z) {min(max(x, y), z)}
      • coincides with a netname that is used in the x argument then the
        function fails
      • or throws an error.
      • To demonstrate this:
      • In the example netlist below, select any one Vn and Bn pair and plot
        V(out).

      .tran 1u 1m 0

      .func LIMIT(x,y,z) {min(max(x, y), z)}

      V1 x GND SINE(0 2 1k)
      B1 out GND V=LIMIT(V(x),-1,1) ; this instance works OK

      V2 y GND SINE(0 2 1k) B2 out GND V=LIMIT(V(y),0,1) ; this instance
      gives 0 output.

      V3 y GND SINE(0 2 1k) B3 out GND V=LIMIT(V(y),-1,1) ; this instance
      throws an error: no such function 'v'

      V4 z GND SINE(0 2 1k) B4 out GND V=LIMIT(V(z),-1,1) ; this instance
      fails transient solution

      .END

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/ngspice/bugs/268/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #268

  • Holger Vogt

    Holger Vogt - 2013-12-30
    • status: open-accepted --> open-fixed
     
    • Andy Fierman

      Andy Fierman - 2013-12-30

      I will run your example to check. I just need to wait for the developers at
      EasyEDA to update to the latest git version of ngspice.

      :)

      Cheers,

           Andy.
      

      signality.co.uk

      On 30 December 2013 13:29, Holger Vogt h_vogt@users.sf.net wrote:

      • status: open-accepted --> open-fixed

      Status: open-fixed

      Created: Sat Dec 28, 2013 12:13 AM UTC by Andy Fierman
      Last Updated: Sat Dec 28, 2013 05:00 PM UTC
      Owner: Holger Vogt

      The example below explains and demonstrates the bug.

      A working example in ngspice 25_release can be seen here:

      http://www.ngspice.com/index.php?public_circuit=0RYEpA

      This bug also affects more recent versions as used here:

      http://easyeda.com/file_view_limit-test_0qke8qI0U.htm

      (sorry but I don't know the exact ngspice version number used in EasyEDA)

      The expected behaviour is that the choice of argument names in a .func
      definition should be completely unaffected by the signal or net names used
      within any instance of the function so defined.

      This problem does not arise in LTspice (nor, I think, in PSpice).

      • If the name of the y or z argument in the LIMIT function defined as:
      • .func LIMIT(x,y,z) {min(max(x, y), z)}
      • coincides with a netname that is used in the x argument then the
        function fails
      • or throws an error.
      • To demonstrate this:
      • In the example netlist below, select any one Vn and Bn pair and plot
        V(out).

      .tran 1u 1m 0

      .func LIMIT(x,y,z) {min(max(x, y), z)}

      V1 x GND SINE(0 2 1k)
      B1 out GND V=LIMIT(V(x),-1,1) ; this instance works OK

      V2 y GND SINE(0 2 1k) B2 out GND V=LIMIT(V(y),0,1) ; this instance
      gives 0 output.

      V3 y GND SINE(0 2 1k) B3 out GND V=LIMIT(V(y),-1,1) ; this instance
      throws an error: no such function 'v'

      V4 z GND SINE(0 2 1k) B4 out GND V=LIMIT(V(z),-1,1) ; this instance
      fails transient solution

      .END

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/ngspice/bugs/268/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
      • Andy Fierman

        Andy Fierman - 2013-12-31

        Hi Holger,

        Deep joy!

        I have just verified your fix here:

        http://easyeda.com/file_view_limit-test-2_IibtnFXfx.htm

        Many thanks again and a very happy new year to you.

        Cheers,

             Andy.
        

        signality.co.uk

        On 30 December 2013 17:49, Andy Fierman signality@users.sf.net wrote:

        I will run your example to check. I just need to wait for the developers at
        EasyEDA to update to the latest git version of ngspice.

        :)

        Cheers,

         Andy.
        

        signality.co.uk

        On 30 December 2013 13:29, Holger Vogt h_vogt@users.sf.net wrote:

        • status: open-accepted --> open-fixed

        Status: open-fixed

        Created: Sat Dec 28, 2013 12:13 AM UTC by Andy Fierman
        Last Updated: Sat Dec 28, 2013 05:00 PM UTC
        Owner: Holger Vogt

        The example below explains and demonstrates the bug.

        A working example in ngspice 25_release can be seen here:

        http://www.ngspice.com/index.php?public_circuit=0RYEpA

        This bug also affects more recent versions as used here:

        http://easyeda.com/file_view_limit-test_0qke8qI0U.htm

        (sorry but I don't know the exact ngspice version number used in EasyEDA)

        The expected behaviour is that the choice of argument names in a .func
        definition should be completely unaffected by the signal or net names used
        within any instance of the function so defined.

        This problem does not arise in LTspice (nor, I think, in PSpice).

        • If the name of the y or z argument in the LIMIT function defined as:
        • .func LIMIT(x,y,z) {min(max(x, y), z)}
        • coincides with a netname that is used in the x argument then the
          function fails
        • or throws an error.
        • To demonstrate this:
        • In the example netlist below, select any one Vn and Bn pair and plot
          V(out).

        .tran 1u 1m 0

        .func LIMIT(x,y,z) {min(max(x, y), z)}

        V1 x GND SINE(0 2 1k)
        B1 out GND V=LIMIT(V(x),-1,1) ; this instance works OK

        V2 y GND SINE(0 2 1k) B2 out GND V=LIMIT(V(y),0,1) ; this instance
        gives 0 output.

        V3 y GND SINE(0 2 1k) B3 out GND V=LIMIT(V(y),-1,1) ; this instance
        throws an error: no such function 'v'

        V4 z GND SINE(0 2 1k) B4 out GND V=LIMIT(V(z),-1,1) ; this instance
        fails transient solution
        .END

        Sent from sourceforge.net because you indicated interest in
        https://sourceforge.net/p/ngspice/bugs/268/

        To unsubscribe from further messages, please visit
        https://sourceforge.net/auth/subscriptions/


        Status: open-fixed
        Created: Sat Dec 28, 2013 12:13 AM UTC by Andy Fierman
        Last Updated: Mon Dec 30, 2013 01:29 PM UTC
        Owner: Holger Vogt

        The example below explains and demonstrates the bug.

        A working example in ngspice 25_release can be seen here:

        http://www.ngspice.com/index.php?public_circuit=0RYEpA

        This bug also affects more recent versions as used here:

        http://easyeda.com/file_view_limit-test_0qke8qI0U.htm

        (sorry but I don't know the exact ngspice version number used in EasyEDA)

        The expected behaviour is that the choice of argument names in a .func
        definition should be completely unaffected by the signal or net names used
        within any instance of the function so defined.

        This problem does not arise in LTspice (nor, I think, in PSpice).

        • If the name of the y or z argument in the LIMIT function defined as:
        • .func LIMIT(x,y,z) {min(max(x, y), z)}
        • coincides with a netname that is used in the x argument then the
          function fails
        • or throws an error.
        • To demonstrate this:
        • In the example netlist below, select any one Vn and Bn pair and plot
          V(out).

        .tran 1u 1m 0

        .func LIMIT(x,y,z) {min(max(x, y), z)}

        V1 x GND SINE(0 2 1k)
        B1 out GND V=LIMIT(V(x),-1,1) ; this instance works OK

        V2 y GND SINE(0 2 1k) B2 out GND V=LIMIT(V(y),0,1) ; this instance
        gives 0 output.

        V3 y GND SINE(0 2 1k) B3 out GND V=LIMIT(V(y),-1,1) ; this instance
        throws an error: no such function 'v'

        V4 z GND SINE(0 2 1k) B4 out GND V=LIMIT(V(z),-1,1) ; this instance
        fails transient solution

        .END

        Sent from sourceforge.net because you indicated interest in
        https://sourceforge.net/p/ngspice/bugs/268/

        To unsubscribe from further messages, please visit
        https://sourceforge.net/auth/subscriptions/

         
  • Holger Vogt

    Holger Vogt - 2014-01-01
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB