Physics — Logic: controlled adder/subtractor
A mode bit turns a full adder into a subtractor.
Make it your own.
title "Adder / subtractor (controlled)"
type gates
input A at (0,0)
input B at (0,2)
input Mode at (0,4)
gate XOR G1 at (3,2)
gate XOR G2 at (6,1)
gate AND G3 at (6,3)
output Sum at (9,1)
output Carry at (9,3)
wire B G1
wire Mode G1
wire A G2
wire G1 G2
wire A G3
wire G1 G3
wire G2 Sum
wire G3 Carry