home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p078 / 3.img / NETFORMS.PLB / SPICE.CF < prev    next >
Encoding:
Text File  |  1991-10-14  |  10.1 KB  |  444 lines

  1. /*
  2.     /2
  3.     /L Do not append sheet number to labels
  4.     /N Use node names
  5.     /I Include unconnected pins
  6.  */
  7.  
  8. /*  VERSION="1.10   14-OCT-91"
  9.  *      - Changed unconnected pins from net "0" to " "
  10.  *      - Added /I switch to allow unconnected pins to be given a net
  11.  *      - Changed so that the GND net is always "0", even with /N set
  12.  *      - Added warnings for names with illegal characters
  13.  *      - Made '$' a legal character (needed for digital simulation)
  14.  *      - Added Version message
  15.  *      - Corrected int to unsigned comparison
  16.  *
  17.  *  Capacities:
  18.  *      - Part Names are not checked for length
  19.  *      - Module Names are not checked for length
  20.  *      - Reference Strings are not checked for length
  21.  *      - Node Names are not checked for length
  22.  *      - Node Numbers are limited to 5 digits
  23.  *      - Pin Numbers are not checked for length
  24.  *
  25.  *  Characters:
  26.  *      - Node names are limited to { '_', '$', '0-9' , 'a-z', 'A-Z' } if /N is present
  27.  *
  28.  *      Even if your version of SPICE does not allow alphabetic node names,
  29.  *      you can still give nodes names if they represent numerical
  30.  *      values (such as '14').  These node 'numbers' will not
  31.  *      overlap with the system defined ones since system node numbers
  32.  *      begin at 10000 (except GND, which is always 0).
  33.  *
  34.  *      Unconnected pins will generate a warning and a space, " ", will
  35.  *      be output instead of a number.  If /I is present, then unconnected
  36.  *      pins will not generate a warning and will be given a net number
  37.  *      starting at 32767 and decreasing with each additional unconnected pin.
  38.  *
  39.  *      The .MAP file that is generated is only valid if the /N switch is
  40.  *      not used (since labels will be output to the netlist instead of
  41.  *      system created net numbers if /N is present).
  42.  */
  43.  
  44. int sw_L;
  45. int sw_N;
  46. int sw_I;
  47.  
  48. int net;
  49. int unet;
  50. int pos;
  51. int ch;
  52. int ok;
  53. int type;
  54. int new_type;
  55. int legal;
  56. int len;
  57.  
  58. /*-----------------------*/
  59.  
  60. Initialize()
  61. {
  62.     WriteString(0, "Creating Netlist...");
  63.     WriteCrLf(0);
  64.  
  65.     AddSymbol("SignalNameStr");
  66.     AddSymbol("Str");
  67.  
  68.     AddSymbol("GND");
  69.     SetSymbol(GND, "GND");
  70.  
  71.     unet = 32767;
  72.  
  73.     sw_L = SwitchIsSet("L");
  74.     sw_N = SwitchIsSet("N");
  75.     sw_I = SwitchIsSet("I");
  76.  
  77.     SetCharSet("_$0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
  78.     SetNumberWidth(1);
  79.  
  80.     WriteString(1, "* ");
  81.     CopySymbol(TitleString, Str);
  82.     PadSpaces(Str, 46);
  83.     WriteSymbol(1, Str);
  84.     WriteString(1, "Revised: ");
  85.     WriteSymbol(1, DateString);
  86.     WriteCrLf(1);
  87.     WriteString(1, "* ");
  88.     CopySymbol(DocumentNumber, Str);
  89.     PadSpaces(Str, 46);
  90.     WriteSymbol(1, Str);
  91.     WriteString(1, "Revision: ");
  92.     WriteSymbol(1, Revision);
  93.     WriteCrLf(1);
  94.     WriteString(1, "* ");
  95.     WriteSymbol(1, Organization);
  96.     WriteCrLf(1);
  97.     WriteString(1, "* ");
  98.     WriteSymbol(1, AddressLine1);
  99.     WriteCrLf(1);
  100.     WriteString(1, "* ");
  101.     WriteSymbol(1, AddressLine2);
  102.     WriteCrLf(1);
  103.     WriteString(1, "* ");
  104.     WriteSymbol(1, AddressLine3);
  105.     WriteCrLf(1);
  106.     WriteString(1, "* ");
  107.     WriteSymbol(1, AddressLine4);
  108.     WriteCrLf(1);
  109.  
  110.     FirstPipe();
  111.     ok = AccessKeyWord("SPICE");
  112.     while (ok == 1) {
  113.         PipeSPICE();
  114.         ok = AccessKeyWord("SPICE");
  115.     }
  116. }
  117.  
  118. /*-----------------------*/
  119.  
  120. WriteHeader()
  121. {
  122.     CreatePartDataBase();
  123. }
  124.  
  125. /*-----------------------*/
  126.  
  127. PipeSPICE()
  128. {
  129.     ok = NextPipe();
  130.     if (ok == 1)
  131.     {
  132.         ok = IsKeyWord();
  133.         ok = 1 - ok;
  134.     }
  135.  
  136.     while (ok == 1)
  137.     {
  138.         WriteSymbol(1, PipeLine);
  139.         WriteCrLf(1);
  140.  
  141.         ok = NextPipe();
  142.         if (ok == 1)
  143.         {
  144.             ok = IsKeyWord();
  145.             ok = 1 - ok;
  146.         }
  147.     }
  148. }
  149.  
  150. /*-----------------------*/
  151.  
  152. HandleNodeName()
  153. {
  154.     int num;
  155.  
  156.     AddSignalName();
  157.  
  158.     type = GetStandardSymbol(TypeCode);
  159.     if (type == 'L')
  160.     {
  161.         num = GetStandardSymbol(NetNumber);
  162.         num = num + 10000;
  163.         WriteInteger(2, num);
  164.  
  165.         WriteString(2, " ");
  166.  
  167.         if (sw_N == 0)
  168.         {
  169.             WriteSymbol(2, SignalNameString);
  170.         }
  171.         else
  172.         {
  173.             if (sw_L == 0)
  174.             {
  175.                 MakeLocalSignal("_");
  176.                 WriteSymbol(2, LocalSignal);
  177.             }
  178.             else
  179.             {
  180.                 WriteSymbol(2, SignalNameString);
  181.             }
  182.         }
  183.         WriteCrLf(2);
  184.     }
  185.  
  186.     if (type == 'P')
  187.     {
  188.         num = GetStandardSymbol(NetNumber);
  189.         num = num + 10000;
  190.         WriteInteger(2, num);
  191.  
  192.         WriteString(2, " ");
  193.  
  194.         WriteSymbol(2, SignalNameString);
  195.         WriteCrLf(2);
  196.     }
  197.  
  198.     if (type == 'S')
  199.     {
  200.         ok = CompareSymbol(GND, SignalNameString);
  201.         if (ok == 0)
  202.             { WriteString(2, "    0 "); }
  203.         else
  204.         {
  205.             num = GetStandardSymbol(NetNumber);
  206.             num = num + 10000;
  207.             WriteInteger(2, num);
  208.             WriteString(2, " ");
  209.         }
  210.  
  211.         WriteSymbol(2, SignalNameString);
  212.         WriteCrLf(2);
  213.     }
  214.  
  215.     if (type == 'S')
  216.     {
  217.         ok = CompareSymbol(GND, SignalNameString);
  218.         if (ok != 0)
  219.         {
  220.             /* separate the name from trailing characters */
  221.             CopySymbol(SignalNameString, SignalNameStr);
  222.  
  223.             ch = ' ';
  224.             pos = FindSymbolChar(ch, SignalNameStr);
  225.             if (pos != -1)
  226.             {
  227.                 pos = pos + 1;
  228.                 len = SymbolLength(SignalNameStr);
  229.                 len = len - 1;
  230.                 PackString(pos, len, SignalNameStr, Str);
  231.  
  232.                 pos = pos - 1;
  233.                 ch = 0;
  234.                 /* kill the trailing space */
  235.                 PutSymbolChar(pos, ch, SignalNameStr);
  236.             }
  237.             else
  238.             {
  239.                 SetSymbol(Str, "");
  240.             }
  241.  
  242.             ValidateNodeInfo();
  243.             if (legal != 1)
  244.             {
  245.                 net = GetStandardSymbol(NetNumber);
  246.                 net = net + 10000;
  247.  
  248.                 /* illegal character in the node name */
  249.                 WriteString(0, "WARNING: Name contains illegal characters '");
  250.                 WriteSymbol(0, SignalNameStr);
  251.                 WriteString(0, "', changed to ");
  252.                 WriteInteger(0, net);
  253.                 WriteCrLf(0);
  254.  
  255.                 SetSymbol(ExitType, "W");
  256.             }
  257.  
  258.             WriteSymbol(1, SignalNameStr);
  259.  
  260.             WriteString(1, " ");
  261.             if (new_type == 'S')
  262.                 { WriteSymbol(1, SignalNameStr); }
  263.             else
  264.                 { WriteSysNet(); }
  265.  
  266.             WriteString(1, " 0");
  267.  
  268.             len = SymbolLength(Str);
  269.             if (len > 0)
  270.             {
  271.                 WriteString(1, " ");
  272.                 WriteSymbol(1, Str);
  273.             }
  274.             WriteCrLf(1);
  275.         }
  276.     }
  277. }
  278.  
  279. /*-----------------------*/
  280.  
  281. WriteSysNet()
  282. {
  283.     net = GetStandardSymbol(NetNumber);
  284.     net = net + 10000;
  285.     WriteInteger(1, net);
  286. }
  287.  
  288. /*-----------------------*/
  289.  
  290. WriteNet()
  291. {
  292.     RecordNode();
  293. }
  294.  
  295. /*-----------------------*/
  296.  
  297. WriteNetEnding()
  298. {
  299. }
  300.  
  301. /*-----------------------*/
  302.  
  303. ProcessFieldStrings()
  304. {
  305. }
  306.  
  307. /*-----------------------*/
  308.  
  309. ValidateNodeInfo()
  310. {
  311.     legal = 1;
  312.  
  313.     type = GetStandardSymbol(TypeCode);
  314.     new_type = type;
  315.     if (sw_N == 1)
  316.     {
  317.         legal = SymbolInCharSet(SignalNameStr);
  318.  
  319.         if (legal != 1) { new_type = 'N'; }
  320.     }
  321.     else
  322.     {
  323.         if (type != 'U') { new_type = 'N'; }
  324.     }
  325. }
  326.  
  327. /*-----------------------*/
  328.  
  329. WriteNodeInfo()
  330. {
  331.     CopySymbol(SignalNameString, SignalNameStr);
  332.     ValidateNodeInfo();
  333.  
  334.     /* this one is special since GND is always 0 */
  335.     if (type == 'S')
  336.     {
  337.         ok = CompareSymbol(GND, SignalNameString);
  338.         if (ok == 0)
  339.             { WriteString(1, "0"); }
  340.         else
  341.         {
  342.             if (sw_N == 0)
  343.             {
  344.                 WriteSysNet();
  345.             }
  346.             else
  347.             {
  348.                 ch = ' ';
  349.                 pos = FindSymbolChar(ch, SignalNameStr);
  350.                 if (pos != -1)
  351.                 {
  352.                     ch = 0;
  353.                     /* kill the trailing space */
  354.                     PutSymbolChar(pos, ch, SignalNameStr);
  355.                 }
  356.                 WriteSymbol(1, SignalNameStr);
  357.             }
  358.         }
  359.     }
  360.     if (new_type == 'L')
  361.     {
  362.         if (sw_L == 0)
  363.         {
  364.             MakeLocalSignal("_");
  365.             WriteSymbol(1, LocalSignal);
  366.         }
  367.         else
  368.         {
  369.             WriteSymbol(1, SignalNameStr);
  370.         }
  371.     }
  372.     if (new_type == 'P')
  373.     {
  374.         WriteSymbol(1, SignalNameString);
  375.     }
  376.     if (new_type == 'N')
  377.     {
  378.         if (type != 'S')
  379.         {
  380.             WriteSysNet();
  381.  
  382.             if (legal != 1)
  383.             {
  384.                 /* illegal character in the node name */
  385.                 WriteString(0, "WARNING: Name contains illegal characters '");
  386.                 WriteSymbol(0, SignalNameStr);
  387.                 WriteString(0, "', changed to ");
  388.                 WriteInteger(0, net);
  389.                 WriteCrLf(0);
  390.             }
  391.         }
  392.     }
  393.     if (new_type == 'U')
  394.     {
  395.         if (sw_I == 1)
  396.         {
  397.             WriteInteger(1, unet);
  398.             unet = unet - 1;
  399.         }
  400.         else
  401.         {
  402.             WriteString(0, "WARNING: Pin '");
  403.             WriteSymbol(0, PinNameString);
  404.             WriteString(0, "' on Reference '");
  405.             WriteSymbol(0, ReferenceString);
  406.             WriteString(0, "' is unconnected");
  407.             WriteCrLf(0);
  408.  
  409.             SetSymbol(ExitType, "W");
  410.         
  411.             WriteString(1, " ");
  412.         }
  413.     }
  414. }
  415.  
  416. /*-----------------------*/
  417.  
  418. WriteNetListEnd()
  419. {
  420.     int i;
  421.  
  422.     SetFirst(ALL);
  423.     do {
  424.         WriteSymbol(1, ReferenceString);
  425.     
  426.         do {
  427.             WriteString(1, " ");
  428.             WriteNodeInfo();
  429.         } while (SetNext(NODES));
  430.  
  431.         WriteString(1, " ");
  432.         WriteSymbol(1, PartName);
  433.         WriteCrLf(1);
  434.     } while (SetNext(ALL));
  435.  
  436.     WriteString(1, ".END");
  437.     WriteCrLf(1);
  438.  
  439.     WriteString(0, "Done");
  440.     WriteCrLf(0);
  441. }
  442.  
  443.  
  444.