/* Full adder. Syntax: Full_Adder a b c_in | c_out s; Effect: Adds binary numbers a + b with carry. */ Define Full_Adder a b CarryIn | CarryOut Sum; Xor aa a b x; Xor ab x CarryIn Sum; And bb a b y; And cb CarryIn x z; Or bc-cc y z CarryOut; Endef; /* ------------------------- MAIN ------------------------- */ /* Put up first input number */ Switch aa x3 '3' ZERO; Switch ab x2 '2' ZERO; Switch ac x1 '1' ZERO; Switch ad x0 '0' ZERO; /* Put up second input number */ Switch af y3 '9' ZERO; Switch ag y2 '8' ZERO; Switch ah y1 '7' ZERO; Switch ai y0 '6' ZERO; Full_Adder cb x3 y3 c3 | c4 s3; Full_Adder cd x2 y2 c2 | c3 s2; Full_Adder cf x1 y1 c1 | c2 s1; Full_Adder ch x0 y0 ZERO | c1 s0; /* Probe the outputs */ Probe ea c4; Probe ed s3; Probe ee s2; Probe ef s1; Probe eg s0;