Menu

#508 PSPICE mode: allow comma as delimiter

v1.0 (example)
closed-fixed
None
5
2020-08-11
2020-08-05
Ferdy
No

(Just copying this discussion https://forum.kicad.info/t/subcircuit-for-lm7805/16095/8?u=ferdymercury to the bug tracker)

PSPICE circuits like http://espice.ugr.es/espice/src/modelos_subckt/spice_complete/cadlab.lib lead to errors in ngspice because commas are used instead of spaces as delimiters. Manually replacing commas with spaces in the library file solves the problem, but it could be nicer to auto-detect delimiters so that one does not need to modify the original libraries.

Related

Bugs: #508

Discussion

  • marcel hendrix

    marcel hendrix - 2020-08-06

    On 2020-08-05 23:48, Ferdy wrote:


    ** [bugs:#508] PSPICE mode: allow comma as delimiter**

    Status: open
    Group: v1.0 (example)
    Created: Wed Aug 05, 2020 09:48 PM UTC by Ferdy
    Last Updated: Wed Aug 05, 2020 09:48 PM UTC
    Owner: nobody

    (Just copying this discussion
    https://forum.kicad.info/t/subcircuit-for-lm7805/16095/8?u=ferdymercury
    to the bug tracker)

    PSPICE circuits like
    http://espice.ugr.es/espice/src/modelos_subckt/spice_complete/cadlab.lib
    lead to errors in ngspice because commas are used instead of spaces as
    delimiters. Manually replacing commas with spaces in the library file
    solves the problem, but it could be nicer to auto-detect delimiters so
    that one does not need to modify the original libraries.

    Taken in isolation, what do you want this to mean: " 1,000,000, 000 "?

    -marcel

     

    Related

    Bugs: #508

  • Holger Vogt

    Holger Vogt - 2020-08-06

    You cannot take this in isolation. The question is: Is there a chance that after the 'params:' statement in X or .subckt lines a comma may occur with any other meaning than being a separator between tokens like
    params: par1={mypar} , par2={mypar2} , par3=8.1
    ?

     

    Last edit: Holger Vogt 2020-08-06
    • marcel hendrix

      marcel hendrix - 2020-08-07

      On 2020-08-06 08:37, Holger Vogt wrote:

      You cannot take this in isolation. The question is: Is there a chance
      that after params: in X or .subckt lines a comma may occur with any
      other meaning than being a separator between tokens like par1={mypar}
      , par2={mypar2}?

      Yes. My point is that if we accept this as something to be fixed, we
      must
      look at EVERY possible location a "," can appear and make a context
      sensitive
      CHOICE what to do with it. It is too late for (NG)SPICE to worry about
      this,
      but I thought I should mention it.

      Note that with XSPICE 'par1' can be a variable-sized array, and thus
      mypar
      is a list of items.

      -marcel

       
      • Holger Vogt

        Holger Vogt - 2020-08-07

        No, we just look at lines either starting with X or .subckt, then these lines have to have the 'params:' statement, if yes, we replace every ',' by ' ' in this line after the 'params:' statement.

        Of course, if there is a chance that a comma is used exactly in this situation in another context, not being a delimiter, we have to be more careful. Currently I do not see this happening, but... Therefore my question.

        Holger

         
        • Holger Vogt

          Holger Vogt - 2020-08-07

          Can you give an example line with such a XSPICE statement (just to refresh my view)?

           

          Last edit: Holger Vogt 2020-08-07
          • marcel hendrix

            marcel hendrix - 2020-08-08

            On 2020-08-07 09:52, Holger Vogt wrote:

            Can you give an example lione with such a XSPICE statement (just to
            refresh my view)?

            I have 1200 files here. Examples from a simple regexp:

            D:\spice\mhx\bug94\statefilter.cir(40): alter @vexc[sin] = [ 0 1 10kHz ]
            D:\spice\mhx\bugalter\alter.cir(10): alter @v1[sin] = [ 0 1 100meg ]
            D:\spice\mhx\bug_coremodel\clyde.cir(16): + B_array = [-3.13m -2.63m
            -2.33m -1.93m -1.5m -0.625m -0.25m 0 0.25m 0.625m 1.5m 1.93m 2.33m 2.63m
            3.13m]

            D:\spice\mhx\ci2out\CI2OUT.cir(38): .model pulse1 square(cntl_array =
            [0.9fswitch 1.1fswitch] freq_array=[0.9fswitch 1.1fswitch] out_low=0
            out_high=1 duty_cycle=0.02 rise_time=10e-9 fall_time=10e-9)
            D:\spice\mhx\scratch\altersource.cir(7): alter @Vd[pulse] = [ 0v 6v 0
            10n 10n 4.99u 10u ]

            D:\spice\mhx\scratch\altersource.cir(12): alter @Vd[pulse] = [ 0 0 0 0
            0 0 0 ]

            D:\spice\mhx\vecparms\vecp.cir(10): A_genlut [in0 in1] [outlut] genlut
            D:\spice\mhx\vecparms\vecp.cir(19): A_ADC [sine vss] [no1 dss] ADC
            D:\spice\mhx\vecparms\vecp.cir(22): A_DAC [no1 dss] [mon1 mon2] DAC
            D:\spice\mhx\zdomain\delay.cir(11): A2 [isone in clk] [enable din dclk]
            adc_buff

            IIRC, in XSPICE ( ) is equivalent to [ ], and arrays can be mixed and
            nested.

            -marcel

             
            • Holger Vogt

              Holger Vogt - 2020-08-08

              Marcel,

              I am talking about an example line that starts with

              X1 n1 n2 mysub params: <something with="" comma="" not="" as="" a="" delimiter=""></something>

              or

              .subckt mysub n1 n2 params: <something with="" comma="" not="" as="" a="" delimiter=""></something>

              I am totally focused on this specific bug 508.

               
  • Ferdy

    Ferdy - 2020-08-08

    Maybe I was not very clear in my description, which was the source of the confusion, because I just pointed to a link in the Kicad forum discussion where it was explained more in depth. So the relevant problem was the following. In the file: http://espice.ugr.es/espice/src/modelos_subckt/spice_complete/cadlab.lib I want to use circuit ua7812C, defined as:

    .SUBCKT UA7812C Input Output Ground
       x1 Input Output Ground x_LM78XX PARAMS:
    
    +     Av_feedback=694, R1_Value=2448
    

    This gives however an error. Thus I need to edit manually the file to:

    .SUBCKT UA7812C Input Output Ground
       x1 Input Output Ground x_LM78XX PARAMS:
    
    +     Av_feedback=694 R1_Value=2448
    

    so that it works.

    Maybe, in order to prevent potential backward compatibility errors, this auto-conversion of commas to spaces should be done only, as Holger says, when pspice mode is enabled, and when we are within a list after the 'PARAMS:' keyword. Or do this conversion as the very last step before raising an error, so that it does not 'overwrite' any other possible interpretation / template matching in the steps before.

     
    • marcel hendrix

      marcel hendrix - 2020-08-08

      On 2020-08-08 17:26, Ferdy wrote:

      Maybe I was not very clear in my description, which was the source of
      the confusion, because I just pointed to a link in the Kicad forum
      discussion where it was explained more in depth. So the relevant
      problem was the following. In the file:
      http://espice.ugr.es/espice/src/modelos_subckt/spice_complete/cadlab.lib
      I want to use circuit ua7812C, defined as:

      I understand. As long as this is a request with a single well-defined
      context in mind, and certainly when the comma's are a fallback or need
      an explicit switch, my uneasiness goes away.

      -marcel

       
  • Holger Vogt

    Holger Vogt - 2020-08-11

    A fix is pushed to branch pre-master.

     
    ❤️
    1
  • Holger Vogt

    Holger Vogt - 2020-08-11
    • status: open --> closed-fixed
    • assigned_to: Holger Vogt
     

Log in to post a comment.

Monday.com Logo