/* Add1 circuit */

#include "Sim.h"

void simnet()
{
   Sig(sw0, 1);      // Switch 0 - input
   Sig(sw1, 1);      // Switch 1 - input
   Sig(o0,  1);      // Output signal 0
   Sig(o1,  1);      // Output signal 1
                     // Output signal 2 is one of the intermediate signals
 
   /* ==============================================================
      Computed (intermediate) signals)
      These don't need names, so I will use "Signal" to define them
      ============================================================== */
   Signal not_sw0, not_sw1;
   Signal and_1;              // This intermediate signal is also an output

   // If you want a name for the "and_1" signal, use this:
   //    Sig(and_1, 1);
 
   Signal and_2a, and_2b, and_3a, and_3b;

   Switch ( "aa", sw1, '1', Zero );
   Switch ( "ba", sw0, '0', Zero );


   Not ( "ab", sw1, not_sw1);
   Not ( "bb", sw0, not_sw0);

   /*------------------------- stage 1 ---------------------- */
   And ( "ac", (sw0,sw1),         and_1);
   
   And ( "bc", (not_sw1,sw0),     and_2a);
   And ( "bc", (sw1,not_sw0),     and_2b);
   
   And ( "cc", (sw1,not_sw0),     and_3a);
   And ( "cc", (not_sw1,not_sw0), and_3b);
   
   /*------------------------- stage 2 ---------------------- */
   
   Or ( "bd", (and_2a,and_2b),   o1);
   Or ( "cd", (and_3a,and_3b),   o0);
   
   /*------------------------- Probes ---------------------- */
    
/*
   ProbeH ( "ae-ag", (and_1,o1,o0));
*/
   Probe ( "ae", and_1);
   Probe ( "af", o1);
   Probe ( "ag", o0);
}


