NAPA Library - Jul 20 2025

DOCUMENTATION ON THE GENERATORS
OF THE GENERIC NAPA LIBRARY

\Simulate\NapaDos\Gen\Source
Documentation in 'delays.c'

     Generator of a programmable delay structure

     GENERATOR to be used by NAPA compiler through a ANSI-C command 'system' or standalone to build a NAPA cell netlist.

     This file must be compiled, corresponding executable will be called by the NAPA compiler.
     In DOS,  executable must be called 'DELAYS.EXE',
     in UNIX, executable must be called 'delays'

     Here is an example of a call of this generator from a NAPA netlist:

       node out generator mydelay  <delays>  12 ctr in

     NB: once compiled, this generator can also be used as a standalone executable to generate a NAPA cell.
     The usage is then:

       delays "out_file"  num dummy_name  dummy_name

         - 'out_file' is the file which will contain the generated cell
         - 'num' is the max number of delays which can be chosen
         - 'dummy_name' is a dummy argument

                      _______               _______
                     |       |             |       |
       (in)-------+--| Delay  >-+- ... -+--| Delay  >-+
                  |  |_______|  |       |  |_______|  |
                __|_____________|___ ___|_____________|__
               | #0            #1     #num-1        #num |
       (ctr)---|     Multiplexer                          >---> (out)
               |____________________ ____________________|

Documentation in 'delays_r.c'

     Generator of a programmable delay structure with reset

     GENERATOR to be used by NAPA compiler through a ANSI-C command 'system' or standalone to build a NAPA cell netlist.

     This file must be compiled, corresponding executable will be called by NAPA compiler.
     In DOS,  executable must be called 'DELAYS_R.EXE',
     in UNIX, executable must be called 'delays_r'

     Here is an example of a call of this generator from a NAPA netlist:

       node out generator mydelay  <delays_r>  12 rst ctr in

     NB: once compiled, this generator can also be used as a standalone executable to generate a NAPA cell.
     The usage is then:

       delay_r "out_file"  num dummy_name dummy_name dummy_name

         - 'out_file' is the file which will contain the generated cell
         - 'num' is the max number of delays which can be chosen
         - 'dummy_name' are dummy arguments

       (rst)-----------+--------------------------+
                     __|__   _____              __|__   _____
                    |     | |     |            |     | |     |
       (in)-------+-|Relay|-|Delay >-+- ... -+-|Relay|-|Delay >-+
                  | |_____| |_____|  |       | |_____| |_____|  |
                __|__________________|___ ___|__________________|__
               | #0                 #1     #num-1             #num |
       (ctr)---|     Multiplexer                                    >--> (out)
               |_________________________ _________________________|

Documentation in 'difchain.c'

     Generator of a chain of differentiators

     GENERATOR to be used by NAPA compiler through a ANSI-C command 'system' or standalone to build a NAPA cell netlist.

     This file must be compiled, corresponding executable will be called by NAPA compiler.
     In DOS,  executable must be called 'DIFCHAIN.EXE',
     in UNIX, executable must be called 'difchain'

     Here is an example of a call of this generator from a NAPA netlist:

       node out generator dfch  <difchain>  4  in

     NB: once compiled, this generator can also be used as a standalone executable to generate a NAPA cell.
     The usage is then:

       difchain "out_file"  num dummy_name

         - 'out_file' is the file which will contain the generated cell
         - 'num' is the number of differentiators in the chain
         - 'dummy_name' is a dummy argument

                _______               _______
               |       |             |       |
       (in)----| Diff   >--  ... ----| Diff   >-- (out)
               |_______|             |_______|

Documentation in 'fir.c'

     Generator of FIR filter (analog or digital)
     Filter can be asymmetric, symmetric or antisymmetric.

     GENERATOR to be used by NAPA compiler through a ANSI-C command 'system' or standalone to build a NAPA cell netlist.

     This file must be compiled, as corresponding executable will be called by NAPA compiler.
     In DOS,  executable must be called 'FIR.EXE',
     in UNIX, executable must be called 'fir'

     Here is an example of a call of this generator from a NAPA netlist:

       node out_node generator acellname <fir> "afir.tap" in_node

     'in_node' and 'out_node' are resp. the input and the output of the filter.
     The string 'afir.tap' is the pathname of a file containing an ordered list of the taps of the FIR (see below).

     Structure of input file (see also examples below):

      ## .... is a comment line, can be placed anywhere, copied in the cell
      #  .... is a comment line, can be placed anywhere, not copied in the cell
      0      <a_tap_coefficient>
      1      <a_tap_coefficient>    // right-hand comment not copied in the cell
      2      <a_tap_coefficient>
      ....

     FIR type (analog or digital) is determined by the spelling of the numbers.
     The absence or the presence of decimal points determines the FIR type.
                _____         _____                     _____
               |     |       |     |                   |     |
      in ---+--|Delay >---+--|Delay >---+---  ..  --+--|Delay >---+
            |  |_____|    |  |_____|    |           |  |_____|    |
          __|__         __|__         __|__       __|__         __|__
         |     |       |     |       |     |     |     |       |     |
         |*h[0]|       |*h[1]|       |*h[2]|     |     |       |*h[n]|
         |_____|       |_____|       |_____|     |_____|       |_____|
            |             |             |           |             |
            +------------(+)-----------(+)--  ..  -(+)-----------(+)---> out

     Depending on the (anti)symmetry of the coefficients, simplification to the structure is automatically implemented:
     filter is then folded.
                _____                   _____            _____
               |     |                 |     |          |     |
      in ---+--|Delay >------+--- .. --|Delay >------+--|Delay >--+
            |  |_____|       |         |_____|       |  |_____|   |
            |        _____   |               _____   |            |
            |       |     |  |              |     |  |            |
            |   +--< Delay|------+--- .. --< Delay|------+--------+
            |   |   |_____|  |   |          |_____|  |   |
           _|___|_          _|___|_                 _|___|_   symmetry:     add
          |_______|        |_______|               |_______|  antisymmetry: sub
            __|__            __|__                   __|__
           |     |          |     |                 |     |
           |*h[0]|          |*h[1]|                 |*h[n]|
           |_____|          |_____|                 |_____|
              |                |                       |
              +---------------(+)---------------------(+)-------> out

     NB: Once compiled, this generator can also be used as standalone executable to generate a NAPA cell.

     Here is an example of a call of this generator as a standalone program:

       fir  output_file  tap_file  dummy_name

      - 'tap_file' is the name of a file containing all the taps of the filter to be generated in the format described above.
      - 'output_file' will contain the NAPA netlist of the cell
      - 'dummy_name' is a dummy argument

     example of input file (analog FIR)
      ## Passband ripple      = +/- 2.15 dB
      ## Stopband attenuation =    26.48 dB
      #
      0  3051.0
      1  5098.0
      2  7009.0
      3  9844.0
      4  10950.0    // any comment after double backslash is allowed.
      5  12043.0
      6  10950.0
      7  9844.0
      8  7009.0
      9  5098.0
      10 3051.0

     example of input file (digital FIR)
      ## Passband ripple      = +/- 2.15 dB
      ## Stopband attenuation =    26.48 dB
      #
      0  3051
      1  5098
      2  7009
      3  9844
      4  10950      // any comment after double backslash is allowed.
      5  12043
      6  10950
      7  9844
      8  7009
      9  5098
      10 3051

Documentation in 'iir.c'

     Generator of IIR filter (analog or digital)

     GENERATOR to be used by NAPA compiler through a ANSI-C command 'system' or standalone to build a NAPA cell netlist.

     This file must be compiled, as corresponding executable will be called by NAPA compiler.
     In DOS,  executable must be called 'IIR.EXE',
     in UNIX, executable must be called 'iir'

     Here is an example of a call of this generator from a NAPA netlist:

       node out_node generator acellname <iir> "aiir.tap" in_node

     'in_node' and 'out_node' are resp. the input and the output of the filter.
     The string 'aiir.tap' is the pathname of a file containing an ordered list of the taps of the IIR (see below).

     Structure of input file (see also examples below):

     DATA INPUT
      ## .... is a comment line, can be placed anywhere, copied in the cell
      #  .... is a comment line, can be placed anywhere, not copied in the cell
      #
      #      numerator            denominator
      0      <a_tap_coefficient>  <a_tap_coefficient>
      1      <a_tap_coefficient>  <a_tap_coefficient>   // right-hand comment
      2      <a_tap_coefficient>  <a_tap_coefficient>
      ....
                       -1       -2
              n0 + n1 z   + n2 z  + ...
      H(z) =  -------------------------
                       -1       -2            with d0 != 0.0 ( ANALOG FILTER)
              d0 + d1 z   + d2 z  + ...       with d0 == 1   (DIGITAL FILTER)

                       denominator         numerator
                                       s0           sa0
      in_node -->(+)-----------------+----->[* n0]----->(+)---> out_node
                  |                __|__                 |
                  |               |     |                |
                  |               |DELAY|                |
                  |               |_____|                |
                  |   sd1            | s1           sn1  |
                 (+)<----[* -d1]<----+----->[* n1]----->(+)
                  |                __|__                 |
                  |               |     |                |
                  |               |DELAY|                |
                  |               |_____|                |
                  |   sd2            | s2           sn2  |
                 (+)-----[* -d2]<----+----->[* n2]------(+)
                  |                  |                   |
                  .                  .                   .
                  .                  .                   .
                  |                __|__                 |
                  |               |     |                |
                  |               |DELAY|                |
                  |               |_____|                |
                  |   sdi            | si           sni  |
                  +------[* -di]<----+----->[* ni]-------+

                  feedback path          feedforward path

     IIR type (analog or digital) is determined by the spelling of the numbers.
     The absence or the presence of decimal points determines the IIR type.

     NB: Once compiled, this generator can also be used as standalone executable to generate a NAPA cell.

     Here is an example of a call of this generator as a standalone program:

       iir  output_file  tap_file  dummy_name

      - 'tap_file' is the name of a file containing all the taps of the filter to be generated in the format described above.
      - 'output_file' will contain the NAPA netlist of the cell
      - 'dummy_name' is a dummy argument

     example of input file (analog IIR)
      ## Butterworth IIR Filter
      #
      #  num      den
      0  0.2958   1.0000
      1  0.5876   0.2138               // some comment
      2  0.2958   0.4518

     example of input file (digital IIR)
      ## IIR Filter
      #
      #  num      den
      0  3        1
      1  6        2
      2  3        4                    // some comment

Documentation in 'iir2.c'

     Generator of IIR filter

     GENERATOR to be used by NAPA compiler through a ANSI-C command 'system' or standalone to build a NAPA cell netlist.

     This file must be compiled, as corresponding executable will be called by NAPA compiler.
     In DOS,  executable must be called 'IIR2.EXE',
     in UNIX, executable must be called 'iir2'

      node  out  generator  plsnam  <iir2>  numi order  in1..j   n1_0..order ... nj_0..order   d_0..order

        'numi' is the number of inputs, 'order' is the order of the filter.
        'in1..' and 'out' are resp. the inputs and the output of the filter.

      Example:   IIR  2 inputs, 1st order

                           n1_1 z + n1_0             n2_1 z + n2_0
            out  =   in1 * -------------   +   in2 * -------------         with d_1 != 0.0
                            d_1 z + d_0               d_1 z + d_0

                  denominator             numerator #1
                                 s1_1                         out1
      in1 -->(+)-------------------+---->[*n1_1/d_1]---->(+)-------+
              ^                    |                      ^        |
              |                    v                      |        |
              |                 [DELAY]                   |        |
              |                    |                      |        |
              +----[*-d_0/d_1]<----+---->[*n1_0/d_1]------+       (+)---> out
                                 s1_0                              |
                                                                   |
                  denominator             numerator #2             |
                                 s2_1                         out2 |
      in2 -->(+)-------------------+---->[*n2_1/d_1]---->(+)-------+
              ^                    |                      ^
              |                    v                      |
              |                 [DELAY]                   |
              |                    |                      |
              +----[*-d_0/d_1]<----+---->[*n2_0/d_1]------+
                                 s2_0

                  feedback path       feedforward path

      NB: Once compiled, this generator can also be used as standalone executable to generate a NAPA cell.

Documentation in 'intchain.c'

     Generator of a chain of non delayed integrators

     GENERATOR to be used by NAPA compiler through a ANSI-C command 'system' or standalone to build a NAPA cell netlist.

     This file must be compiled, corresponding executable will be called by NAPA compiler.
     In DOS,  executable must be called 'INTCHAIN.EXE',
     in UNIX, executable must be called 'intchain'

     Here is an example of a call of this generator from a NAPA netlist:

       node out generator intch  <intchain>  7  in

     NB: once compiled, this generator can also be used as a standalone executable to generate a NAPA cell.
     The usage is then:

       intchain "out_file"  num  dummy_name

         - 'out_file' is the file which will contain the generated cell
         - 'num' is the number of integrators in the chain
         - 'dummy_name' is a dummy argument

                _______               _______
               |       |             |       |
       (in)----|Integ.  >--  ... ----|Integ.  >--- (out)
               |_______|             |_______|

Documentation in 'intdchain.c'

     Generator of a chain of delayed integrators

     GENERATOR to be used by NAPA compiler through a ANSI-C command 'system' or standalone to build a NAPA cell netlist.

     This file must be compiled, corresponding executable will be called by NAPA compiler.
     In DOS,  executable must be called 'INTDCHAIN.EXE',
     in UNIX, executable must be called 'intdchain'

     Here is an example of a call of this generator from a NAPA netlist:

        node out generator intdch  <intdchain>  5  in

     NB: once compiled, this generator can also be used as a standalone
     executable to generate a NAPA cell. The usage is then:

        intdchain "out_file"  num  dummy_name

         - 'out_file' is the file which will contain the generated cell
         - 'num' is the number of delayed integrators in the chain
         - 'dummy_name' is a dummy argument

                ______               ______
               |      |             |      |
       (in)----|Integ. >--  ... ----|Integ. >--- (out)
               |______|             |______|
               &delayed             &delayed

Documentation in 'lfsr_f.c'

     Generator of a Linear Feedback Shift Register of maximum length implemented as
     a   'FIBONACCI LSFR'  , also called Simple Shift Register Generator (SSRG).

     It should be noted that this Fibonacci form is also referred to as a Simple Shift Register Generator (SSRG), and that the
     Galois form is referred to as a Multiple-Return Shift Register Generator (MRSRG) or Modular Shift Register Generator (MSRG).

     GENERATOR to be used by NAPA compiler through a ANSI-C command 'system' or standalone to build a NAPA cell netlist.

     This file must be compiled, corresponding executable will be called by NAPA compiler.
     In DOS,  executable must be called 'LFSR_F.EXE',
     in UNIX, executable must be called 'lfsr_f'

     Here is an example of a call of this generator from a NAPA netlist:

       node out  generator  psn  <lfsr_f>  8  array

       where n is a number inside the interval [2 .. 256] with a period of (2^n)-1

       PLEASE NOTE that  2^512 is a number larger than 1.3 10^154. We may think that it is really a big period.

     NB: once compiled, this generator can also be used as a standalone executable to generate a NAPA cell.
     The usage is then:

       lfsr_f "out_file"  dummy_name  n  array

         -  'out_file' is the file which will contain the generated cell
         -  'n'   is the number of bits of the structure
         -  'array'  is the array of bits produced by the generator
         -  'dummy_name' is a dummy argument

          +-------------+--------------> out
      ____|____      ___|___
     |         |    |       |
     |  XNOR   |    | Delay |
     |_ ___ _ _|    |___ ___|
       |   | |          |
       |   | |          |
       |   |            +------> b1
       |   |            |
       |   bi           |
                                               Fibonacci LFSR
                       ...

                        |
                        +------> bn-1
                     ___|___
                    |       |
                    | Delay |
                    |_______|
                        |
                        +------> bn

     Remark:  It is easy to recombine the output bits to form a decimal integer:

               node b    generator  psrnd  <lfsr_f>  8  b
               node n    btoi                        b.1..8    // b is an array

Documentation in 'lfsr_g.c'

     Generator of a Linear Feedback Shift Register of maximum length implemented as
     a   'GALOIS LSFR' , also called Multiple-Return Shift Register Generator (MRSRG).

     It should be noted that this Galois form is referred to as a Multiple-Return Shift Register Generator (MRSRG) or Modular
     Shift Register Generator (MSRG), and that the Fibonacci form is also referred to as a Simple Shift Register Generator (SSRG).

     GENERATOR to be used by NAPA compiler through a ANSI-C command 'system' or standalone to build a NAPA cell netlist.

     This file must be compiled, corresponding executable will be called by NAPA compiler.
     In DOS,  executable must be called 'LFSR_G.EXE',
     in UNIX, executable must be called 'lfsr_g'

     Here is an example of a call of this generator from a NAPA netlist:

       node out  generator  psn  <lfsr_g>  n  array

       where n is a number inside the interval [2 .. 512] with a period of (2^n)-1

       PLEASE NOTE that  2^512 is a number larger than 1.3 10^154. We may think that it is really a big period.

     NB: once compiled, this generator can also be used as a standalone executable to generate a NAPA cell.
     The usage is then:

       lfsr_g "out_file"  dummy_name  n array

         -  'out_file' is the file which will contain the generated cell
         -  'n'   is the number of bits of the structure
         -  'array'  is the array of bits produced by the generator
         -  'dummy_name' is a dummy argument

     +-------+--------------> out
     |       |
     |
     |      ...
     |
     |       |
     +---+   +------> bxx   (tap)
     |  _|___|_
     | |       |
     | |  XOR  |
     | |_____ _|
     |       V
     |    ___|___
     |   |       |
     |   | Delay |
     |   |___ ___|
     |       V
     |       |
     |                         Galois LFSR
     |      ...
     |
     |       |
     |       +------> byy   (no tap)
     |    ___|___
     |   |       |
     |   | Delay |
     |   |___ ___|
     |       V
     |       |
     |
     |      ...
     |
     |       |
     +-------+              This structure needs to force a node to 1 at initialization.

     Remark:  It is easy to recombine the output bits to form a decimal integer:

               node b    generator  psrnd  <lfsr_g>  8 b
               node n    btoi                        b.1..8    // b is an array

Documentation in 'SG.c'

     Generator of Savitzki-Golay FIR Analog Filter FIR

     GENERATOR to be used by NAPA compiler through a ANSI-C command 'system' or standalone to build a NAPA cell netlist.

     This file must be compiled, as corresponding executable will be called by NAPA compiler.
     In DOS,  executable must be called 'SG.EXE',
     in UNIX, executable must be called 'SG'

     Here is an example of a call of this generator from a NAPA netlist:

       node out_node generator acellname <SG> nleft nright  m  order  in_node

     'in_node' and 'out_node' are resp. the input and the output of the filter.

      nleft   is the number of leftward  (past)   data points used
      nright  is the number of rightward (future) data points used
      m       is the order of the smoothing polynomial, and is equal to the highest conserved moment
              [usual values are m=2 or m=4]
      order   is the order of the derivative
              [must be 0 for smoothing]

       ->   nleft  must be positive
       ->   nright must be positive
       ->   m      must be positive, cannot be larger than (nleft+nright)
       ->   order  must be positive, cannot be larger than  m

      This generator generates a cell file and a tap file. It calls the generator 'fir' to generate the final cell file.

      NB: Once compiled, this generator can also be used as standalone executable to generate a NAPA cell.

      Here is an example of a call of this generator as a standalone program:

        SG  nleft nright  m  order  dummy_name

           nleft   is the number of leftward  (past)   data points used
           nright  is the number of rightward (future) data points used
           m       is the order of the smoothing polynomial, and is equal to the highest conserved moment
                   [usual values are m = 2 or m = 4]
           order   is the order of the derivative
                   [must be 0 for smoothing]

End