Connect with us

SPICE syntax and grammer

Discussion in 'Electronic Design' started by [email protected], Sep 28, 2005.

Scroll to continue with content
  1. Guest

    Hi, does anyone know where I can get a formal Backus-Naur style syntax
    and/or grammar definition for any of the various SPICEs out there?

    Specifically, hspice, pspice, or berkeley spice. What is the
    difference from a grammar/syntax perspective?


    thanks
    ms
     
  2. Jim Thompson

    Jim Thompson Guest

    I have no idea what "a formal Backus-Naur style syntax" is.

    Are you speaking of "commands" such as .TRAN, etc?

    If that is what you are after, the various SPICE's have the same
    command line structure, except that HSpice has a few additional ones,
    ..ALTER for instance, that I wish PSpice had :-(

    ...Jim Thompson
     
  3. Guest

    Hi,

    The backus-naur grammar format specifies exactly how a spice parser
    would read in the text file and create the data structures representing
    the circuit.

    For instance, a parameter list would be something like:

    PARMLST:=PARMLST TUPLE | TUPLE

    TUPLE:= VAR '=' NUM

    VAR = non-keyword
    NUM = number

    So this means a PARMLIST consists of another parmlist and a tuple, or
    just a tuple. A tuple is a variable followed by an equals sign
    followed by a number. With these rules it's possible to describe most
    computer languages and stuff. I'm sure SPICE has one, but I haven't
    been able to find it.

    thanks
    ms
     
  4. Jim Thompson

    Jim Thompson Guest

    Seems that would be a function of how closely the software writers
    adhered to the original Berkeley approach which, IIRC, was written in
    Fortran. I know that PSpice was re-written in C. I don't know about
    other SPICE's.

    ...Jim Thompson
     
  5. I doubt that you can. I had a look some time ago, and one stumbling block is the
    fact that tokens can mean different things depending on where they occur. While
    it is possible to describe grammers with this property in some scanner/parser
    generator systems, I doubt that BFN or its ilks will do.

    Consider

    R R 0 R

    which describes a resistor (line starts with 'R') from node R to node 0 with the
    value R. This is legal in hspice input language and other extensions of the
    Berkeley Spice input language (expecting a defintion of the value of the
    parameter 'R,' of course) but makes scanning/parsing a challenge.

    I would love to see such a grammar, but didn't find one when I was looking for
    it.

    That said, the original Berkely Spice 2 accepted such a simple input language
    that a formal description should be possible.

    Best Regards

    Jens
     
  6. Fred Bartoli

    Fred Bartoli Guest

    We once developped a library maintaining tool and went to exactly the same
    conclusion.

    OTOH I just googled for "spice grammar" + parser and found a message (dated
    03/2005) from somebody trying to write one using ANTLR. Maybe you can
    contact him : simon at icmethods dot com
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-