Lecture 4 - Adders
Half adder
The output is the binary representation of how many inputs are high.
This can only be 0, 1 or 2, so the outputs are 00, 01, or 10. The first
(leftmost) bit is the "sum" and the second bit (rightmost) is the "carry" bit.
{
"width":500,
"height":300,
"showToolbox":false,
"toolbox":[
],
"devices":[
{"type":"DC","id":"dev0","x":64,"y":112,"label":"DC"},
{"type":"Toggle","id":"dev1","x":168,"y":72,"label":"A"},
{"type":"Toggle","id":"dev2","x":168,"y":144,"label":"B"},
{"type":"LED","id":"dev3","x":368,"y":72,"label":"Sum"},
{"type":"LED","id":"dev4","x":368,"y":144,"label":"Carry"},
{"type":"EOR","id":"dev5","x":272,"y":72,"label":"EOR"},
{"type":"AND","id":"dev6","x":272,"y":144,"label":"AND"}
],
"connectors":[
{"from":"dev1.in0","to":"dev0.out0"},
{"from":"dev2.in0","to":"dev0.out0"},
{"from":"dev3.in0","to":"dev5.out0"},
{"from":"dev4.in0","to":"dev6.out0"},
{"from":"dev5.in0","to":"dev1.out0"},
{"from":"dev5.in1","to":"dev2.out0"},
{"from":"dev6.in0","to":"dev1.out0"},
{"from":"dev6.in1","to":"dev2.out0"}
]
}
Full adder
The output is again the binary representation of how many inputs are high, but
now we have an incomming carry bit, so there can be 0, 1, 2 or 3.
{
"width":700,
"height":400,
"showToolbox":false,
"devices":[
{"type":"Toggle","id":"dev0","x":168,"y":72,"label":"A"},
{"type":"EOR","id":"dev1","x":272,"y":72,"label":"EOR"},
{"type":"LED","id":"dev2","x":512,"y":80,"label":"Sum"},
{"type":"EOR","id":"dev3","x":376,"y":80,"label":"EOR"},
{"type":"Toggle","id":"dev4","x":168,"y":272,"label":"CarryIn"},
{"type":"Toggle","id":"dev5","x":168,"y":160,"label":"B"},
{"type":"DC","id":"dev6","x":64,"y":160,"label":"DC"},
{"type":"AND","id":"dev7","x":272,"y":128,"label":"AND"},
{"type":"OR","id":"dev8","x":448,"y":168,"label":"OR"},
{"type":"AND","id":"dev9","x":376,"y":200,"label":"AND"},
{"type":"LED","id":"dev10","x":512,"y":168,"label":"CarryOut"}
],
"connectors":[
{"from":"dev0.in0","to":"dev6.out0"},
{"from":"dev1.in0","to":"dev0.out0"},
{"from":"dev1.in1","to":"dev5.out0"},
{"from":"dev2.in0","to":"dev3.out0"},
{"from":"dev3.in0","to":"dev1.out0"},
{"from":"dev3.in1","to":"dev4.out0"},
{"from":"dev4.in0","to":"dev6.out0"},
{"from":"dev5.in0","to":"dev6.out0"},
{"from":"dev7.in0","to":"dev0.out0"},
{"from":"dev7.in1","to":"dev5.out0"},
{"from":"dev8.in0","to":"dev7.out0"},
{"from":"dev8.in1","to":"dev9.out0"},
{"from":"dev9.in0","to":"dev1.out0"},
{"from":"dev9.in1","to":"dev4.out0"},
{"from":"dev10.in0","to":"dev8.out0"}
]
}
Full adder
Same as above, but with the numbers decoded so that you can see how
this actually adds numbers.
{
"width":700,
"height":400,
"showToolbox":false,
"devices":[
{"type":"Toggle","id":"dev0","x":168,"y":72,"label":"A"},
{"type":"EOR","id":"dev1","x":272,"y":72,"label":"EOR"},
{"type":"LED","id":"dev2","x":512,"y":80,"label":"Sum"},
{"type":"EOR","id":"dev3","x":376,"y":80,"label":"EOR"},
{"type":"Toggle","id":"dev4","x":168,"y":272,"label":"CarryIn"},
{"type":"DC","id":"dev5","x":64,"y":160,"label":"DC"},
{"type":"AND","id":"dev6","x":272,"y":128,"label":"AND"},
{"type":"OR","id":"dev7","x":448,"y":168,"label":"OR"},
{"type":"AND","id":"dev8","x":376,"y":200,"label":"AND"},
{"type":"LED","id":"dev9","x":512,"y":168,"label":"CarryOut"},
{"type":"Toggle","id":"dev10","x":168,"y":160,"label":"B"},
{"type":"4bit7seg","id":"dev11","x":224,"y":288,"label":"4bit7seg"},
{"type":"4bit7seg","id":"dev12","x":392,"y":288,"label":"4bit7seg"},
{"type":"4bit7seg","id":"dev13","x":312,"y":288,"label":"4bit7seg"},
{"type":"4bit7seg","id":"dev14","x":512,"y":288,"label":"4bit7seg"}
],
"connectors":[
{"from":"dev0.in0","to":"dev5.out0"},
{"from":"dev1.in0","to":"dev0.out0"},
{"from":"dev1.in1","to":"dev10.out0"},
{"from":"dev2.in0","to":"dev3.out0"},
{"from":"dev3.in0","to":"dev1.out0"},
{"from":"dev3.in1","to":"dev4.out0"},
{"from":"dev4.in0","to":"dev5.out0"},
{"from":"dev6.in0","to":"dev0.out0"},
{"from":"dev6.in1","to":"dev10.out0"},
{"from":"dev7.in0","to":"dev6.out0"},
{"from":"dev7.in1","to":"dev8.out0"},
{"from":"dev8.in0","to":"dev1.out0"},
{"from":"dev8.in1","to":"dev4.out0"},
{"from":"dev9.in0","to":"dev7.out0"},
{"from":"dev10.in0","to":"dev5.out0"},
{"from":"dev11.in0","to":"dev4.out0"},
{"from":"dev12.in0","to":"dev10.out0"},
{"from":"dev13.in0","to":"dev0.out0"},
{"from":"dev14.in0","to":"dev3.out0"},
{"from":"dev14.in1","to":"dev7.out0"}
]
}
Ripple carry adder
Adds together two 3-bit numbers A2A1A0 and B2B1B0. Outcome is stored
in S3S2S1S0
{
"width":700,
"height":600,
"showToolbox":false,
"devices":[
{"type":"Toggle","id":"dev0","x":168,"y":72,"label":"A0"},
{"type":"Toggle","id":"dev1","x":168,"y":120,"label":"B0"},
{"type":"Toggle","id":"dev2","x":168,"y":216,"label":"A1"},
{"type":"Toggle","id":"dev3","x":168,"y":360,"label":"A2"},
{"type":"Toggle","id":"dev4","x":168,"y":264,"label":"B1"},
{"type":"Toggle","id":"dev5","x":168,"y":408,"label":"B2"},
{"type":"DC","id":"dev6","x":40,"y":240,"label":"DC"},
{"type":"FullAdder","id":"dev7","x":232,"y":80,"label":"FullAdder"},
{"type":"FullAdder","id":"dev8","x":320,"y":224,"label":"FullAdder"},
{"type":"FullAdder","id":"dev9","x":400,"y":368,"label":"FullAdder"},
{"type":"LED","id":"dev10","x":496,"y":88,"label":"S0"},
{"type":"LED","id":"dev11","x":496,"y":232,"label":"S1"},
{"type":"LED","id":"dev12","x":496,"y":368,"label":"S2"},
{"type":"LED","id":"dev13","x":496,"y":440,"label":"S3"}
],
"connectors":[
{"from":"dev0.in0","to":"dev6.out0"},
{"from":"dev1.in0","to":"dev6.out0"},
{"from":"dev2.in0","to":"dev6.out0"},
{"from":"dev3.in0","to":"dev6.out0"},
{"from":"dev4.in0","to":"dev6.out0"},
{"from":"dev5.in0","to":"dev6.out0"},
{"from":"dev7.in1","to":"dev0.out0"},
{"from":"dev7.in2","to":"dev1.out0"},
{"from":"dev8.in0","to":"dev7.out1"},
{"from":"dev8.in1","to":"dev2.out0"},
{"from":"dev8.in2","to":"dev4.out0"},
{"from":"dev9.in0","to":"dev8.out1"},
{"from":"dev9.in1","to":"dev3.out0"},
{"from":"dev9.in2","to":"dev5.out0"},
{"from":"dev10.in0","to":"dev7.out0"},
{"from":"dev11.in0","to":"dev8.out0"},
{"from":"dev12.in0","to":"dev9.out0"},
{"from":"dev13.in0","to":"dev9.out1"}
]
}
Ripple carry adder with number decoders
Same as above, but with extra junk to display the encoded numbers.
{
"width":700,
"height":600,
"showToolbox":false,
"devices":[
{"type":"Toggle","id":"dev0","x":168,"y":72,"label":"A0"},
{"type":"Toggle","id":"dev1","x":168,"y":120,"label":"B0"},
{"type":"Toggle","id":"dev2","x":168,"y":216,"label":"A1"},
{"type":"Toggle","id":"dev3","x":168,"y":264,"label":"B1"},
{"type":"Toggle","id":"dev4","x":168,"y":408,"label":"B2"},
{"type":"DC","id":"dev5","x":40,"y":240,"label":"DC"},
{"type":"FullAdder","id":"dev6","x":232,"y":80,"label":"FullAdder"},
{"type":"FullAdder","id":"dev7","x":320,"y":224,"label":"FullAdder"},
{"type":"FullAdder","id":"dev8","x":400,"y":368,"label":"FullAdder"},
{"type":"LED","id":"dev9","x":496,"y":88,"label":"S0"},
{"type":"LED","id":"dev10","x":496,"y":232,"label":"S1"},
{"type":"LED","id":"dev11","x":496,"y":368,"label":"S2"},
{"type":"LED","id":"dev12","x":496,"y":440,"label":"S3"},
{"type":"4bit7seg","id":"dev13","x":232,"y":160,"label":"A"},
{"type":"4bit7seg","id":"dev14","x":248,"y":296,"label":"B"},
{"type":"Toggle","id":"dev15","x":168,"y":360,"label":"A2"},
{"type":"4bit7seg","id":"dev16","x":504,"y":288,"label":"S"}
],
"connectors":[
{"from":"dev0.in0","to":"dev5.out0"},
{"from":"dev1.in0","to":"dev5.out0"},
{"from":"dev2.in0","to":"dev5.out0"},
{"from":"dev3.in0","to":"dev5.out0"},
{"from":"dev4.in0","to":"dev5.out0"},
{"from":"dev6.in1","to":"dev0.out0"},
{"from":"dev6.in2","to":"dev1.out0"},
{"from":"dev7.in0","to":"dev6.out1"},
{"from":"dev7.in1","to":"dev2.out0"},
{"from":"dev7.in2","to":"dev3.out0"},
{"from":"dev8.in0","to":"dev7.out1"},
{"from":"dev8.in1","to":"dev15.out0"},
{"from":"dev8.in2","to":"dev4.out0"},
{"from":"dev9.in0","to":"dev6.out0"},
{"from":"dev10.in0","to":"dev7.out0"},
{"from":"dev11.in0","to":"dev8.out0"},
{"from":"dev12.in0","to":"dev8.out1"},
{"from":"dev13.in0","to":"dev0.out0"},
{"from":"dev13.in1","to":"dev2.out0"},
{"from":"dev13.in2","to":"dev15.out0"},
{"from":"dev14.in0","to":"dev1.out0"},
{"from":"dev14.in1","to":"dev3.out0"},
{"from":"dev14.in2","to":"dev4.out0"},
{"from":"dev15.in0","to":"dev5.out0"},
{"from":"dev16.in0","to":"dev6.out0"},
{"from":"dev16.in1","to":"dev7.out0"},
{"from":"dev16.in2","to":"dev8.out0"},
{"from":"dev16.in3","to":"dev8.out1"}
]
}
Sand box
Build your own circuits here
{
"width":700,
"height":500,
"showToolbox":true,
"toolbox":[
{"type":"In"},
{"type":"Out"},
{"type":"DC"},
{"type":"LED"},
{"type":"PushOff"},
{"type":"PushOn"},
{"type":"Toggle"},
{"type":"BUF"},
{"type":"NOT"},
{"type":"AND"},
{"type":"NAND"},
{"type":"OR"},
{"type":"NOR"},
{"type":"EOR"},
{"type":"ENOR"},
{"type":"OSC"},
{"type":"7seg"},
{"type":"16seg"},
{"type":"4bit7seg"},
{"type":"RotaryEncoder"},
{"type":"BusIn"},
{"type":"BusOut"},
{"type":"RS-FF"},
{"type":"JK-FF"},
{"type":"T-FF"},
{"type":"D-FF"},
{"type":"8bitCounter"},
{"type":"HalfAdder"},
{"type":"FullAdder"},
{"type":"4bitAdder"},
{"type":"2to4BinaryDecoder"},
{"type":"3to8BinaryDecoder"},
{"type":"4to16BinaryDecoder"}
],
"devices":[
{"type":"Toggle","id":"dev0","x":168,"y":72,"label":"A"},
{"type":"EOR","id":"dev1","x":272,"y":72,"label":"EOR"},
{"type":"LED","id":"dev2","x":512,"y":80,"label":"Sum"},
{"type":"EOR","id":"dev3","x":376,"y":80,"label":"EOR"},
{"type":"Toggle","id":"dev4","x":168,"y":272,"label":"CarryIn"},
{"type":"Toggle","id":"dev5","x":168,"y":160,"label":"B"},
{"type":"DC","id":"dev6","x":64,"y":160,"label":"DC"},
{"type":"AND","id":"dev7","x":272,"y":128,"label":"AND"},
{"type":"OR","id":"dev8","x":448,"y":168,"label":"OR"},
{"type":"AND","id":"dev9","x":376,"y":200,"label":"AND"},
{"type":"LED","id":"dev10","x":512,"y":168,"label":"CarryOut"}
],
"connectors":[
{"from":"dev0.in0","to":"dev6.out0"},
{"from":"dev1.in0","to":"dev0.out0"},
{"from":"dev1.in1","to":"dev5.out0"},
{"from":"dev2.in0","to":"dev3.out0"},
{"from":"dev3.in0","to":"dev1.out0"},
{"from":"dev3.in1","to":"dev4.out0"},
{"from":"dev4.in0","to":"dev6.out0"},
{"from":"dev5.in0","to":"dev6.out0"},
{"from":"dev7.in0","to":"dev0.out0"},
{"from":"dev7.in1","to":"dev5.out0"},
{"from":"dev8.in0","to":"dev7.out0"},
{"from":"dev8.in1","to":"dev9.out0"},
{"from":"dev9.in0","to":"dev1.out0"},
{"from":"dev9.in1","to":"dev4.out0"},
{"from":"dev10.in0","to":"dev8.out0"}
]
}