#include "Sim.h"
void MyMux (const SD &coord, const Signal &i, const Signal &c, const Signal &out);

void MyMux (const SD &coord, const Signal &i, const Signal &c, const Signal &out)
{
	Module( coord, "MyMux", (i, c), out );
	Signal not_c0(1, "not_c0");
	Signal not_c1(1, "not_c1");
	Signal out_1(1, "out_1");
	Signal out_2(1, "out_2");
	Signal out_3(1, "out_3");
	Signal out_4(1, "out_4");
	Not ( SD(coord, "1b"), c[0], not_c0);
	Not ( SD(coord, "2b"), c[1], not_c1);
	And ( SD(coord, "1c"), (i[0], not_c1, not_c0), out_1);
	And ( SD(coord, "2c"), (i[1], not_c1, c[0]), out_2);
	And ( SD(coord, "3c"), (i[2], c[1], not_c0), out_3);
	And ( SD(coord, "4c"), (i[3], c[1], c[0]), out_4);
	Or ( SD(coord, "3d"), (out_1, out_2, out_3, out_4), out);
}
int simnet()
{
	Signal d1(1, "d1");
	Signal d0(1, "d0");
	Signal c1(1, "c1");
	Signal c0(1, "c0");
	Signal b1(1, "b1");
	Signal b0(1, "b0");
	Signal a1(1, "a1");
	Signal a0(1, "a0");
	Signal sw1(1, "sw1");
	Signal sw0(1, "sw0");
	Signal out0(1, "out0");
	Signal out1(1, "out1");
	Switch ("aa", d1, '7', One);
	Switch ("ab", d0, '6', One);
	Switch ("ba", c1, '5', Zero);
	Switch ("bb", c0, '4', One);
	Switch ("ca", b1, '3', One);
	Switch ("cb", b0, '2', Zero);
	Switch ("da", a1, '1', Zero);
	Switch ("db", a0, '0', Zero);
	Switch ("ed", sw1, '9', Zero);
	Switch ("ee", sw0, '8', Zero);
	MyMux("ad-be", (d0, c0, b0, a0), (sw1, sw0), (out0));
	MyMux("cd-de", (d1, c1, b1, a1), (sw1, sw0), (out1));
	Probe ("bf", out1);
	Probe ("bg", out0);
}
