
/* Decoder: translates n-control signal to exactly 1 output */

#include "Sim.h"

void simnet()
{
   Signal c1, c0;
   Signal not_c1, not_c0;

   Sig(out_0, 1);
   Sig(out_1, 1);
   Sig(out_2, 1);
   Sig(out_3, 1);

   Switch("fa", c1, '1', Zero);
   Not("fb", c1, not_c1);
   Switch("ga", c0, '0', Zero);
   Not("gb", c0, not_c0);

   And("ac", (c1, c0),         out_3);
   And("bc", (c1, not_c0),     out_2);
   And("cc", (not_c1, c0),     out_1);
   And("dc", (not_c1, not_c0), out_0);

   Probe("ad", out_3);
   Probe("bd", out_2);
   Probe("cd", out_1);
   Probe("dd", out_0);
}
