/* How to make your own component correctly !!! */

#include "Sim.h"


/* -----
   NewComp: our own component
   ----- */
void NewComp ( const SD &coord, 
	       const Signal &a, const Signal &b, const Signal &c, 
	       const Signal &d, const Signal &z)
{
   Sig(x,1);
   Sig(y,1);

   Module( coord, "NewCompName", (a,b,c,d), z); 
                            // Make module with (a,b,c,d) as input
                            // and z as output

   And( SD(coord,"bb") , (a,b), x );
   And( SD(coord,"bb") , (c,d), y );

   Or ( SD(coord,"bb") , (x,y), z);

}


/* -----
   Set up circuit that uses "NewComp"
   ----- */
void simnet()
{
   Sig(in0,1);
   Sig(in1,1);
   Sig(in2,1);
   Sig(in3,1);
   Sig(out,1);

   /* The input bits to the mux */
   Switch ( "aa", in0, '0', Zero );
   Switch ( "ba", in1, '1', Zero );
   Switch ( "ca", in2, '2', Zero );
   Switch ( "da", in3, '3', Zero );

   NewComp( "bb", in0, in1, in2, in3, out );

   Probe ( "ce", out );
}

