Building a Full Adder Using NPN Transistors

Building upon the last two posts where I showed how to build NAND, NOR, AND, OR, NOT and XOR gates using NPN transistors, this post will show how these gates can be used to build a full adder. A full adder is one of the circuits used in an Arithmetic and Logic Unit (ALU) which a central component in a microprocessor. The screenshot below shows the full adder circuit using combinational logic running in Circuit Simulator.

Full Adder Circuit Using Combinational Logic

The next screen shot shows the same full adder circuit built using NPN transistors.

Full Adder Circuit Using NPN Transistors

As always, the code for the circuit is listed below. Just copy and import the code into the free Java Circuit Simulator to get a feeling for the circuit.

$ 1 5.0E-6 10.20027730826997 50 5.0 50
R 256 272 224 272 0 0 40.0 5.0 0.0 0.0 0.5
R 256 320 224 320 0 0 40.0 5.0 0.0 0.0 0.5
t 384 272 416 272 0 1 -4.781800412142671 0.009973798250449528 100.0
t 384 320 416 320 0 1 -0.11579281063261414 1.24026193119846E-9 100.0
w 416 288 416 304 0
r 336 272 384 272 0 10000.0
r 336 320 384 320 0 10000.0
s 256 272 304 272 0 1 false
s 256 320 304 320 0 1 false
r 416 208 416 256 0 100.0
R 416 208 384 208 0 0 40.0 5.0 0.0 0.0 0.5
g 416 336 416 352 0
g 304 368 304 384 0
r 304 320 304 368 0 10000.0
w 416 256 448 256 0
w 592 144 624 144 0
r 512 208 512 256 0 10000.0
g 512 256 512 272 0
g 592 224 592 240 0
R 592 96 560 96 0 0 40.0 5.0 0.0 0.0 0.5
r 592 96 592 144 0 100.0
r 512 208 560 208 0 10000.0
r 512 160 560 160 0 10000.0
w 592 176 592 192 0
t 560 208 592 208 0 1 0.5715875138926915 0.5718362726080916 100.0
t 560 160 592 160 0 1 -4.833247082563076 0.12551784992248802 100.0
t 560 384 592 384 0 1 -9.524538884475575E-4 0.01709394689525201 100.0
t 560 432 592 432 0 1 -4.890473074134587 1.245130965746674E-9 100.0
w 592 400 592 416 0
r 512 384 560 384 0 10000.0
r 512 432 560 432 0 10000.0
r 592 320 592 368 0 100.0
R 592 320 560 320 0 0 40.0 5.0 0.0 0.0 0.5
g 592 448 592 464 0
g 512 480 512 496 0
r 512 432 512 480 0 10000.0
w 592 368 624 368 0
w 448 256 464 256 0
w 464 256 464 208 0
w 464 208 512 208 0
w 464 256 464 384 0
w 464 384 512 384 0
t 720 272 752 272 0 1 -0.03456302003774714 0.668725982587211 100.0
t 720 320 752 320 0 1 0.4773295909383011 0.6689865696776216 100.0
w 752 288 752 304 0
r 672 272 720 272 0 10000.0
r 672 320 720 320 0 10000.0
r 752 208 752 256 0 100.0
R 752 208 720 208 0 0 40.0 5.0 0.0 0.0 0.5
g 752 336 752 352 0
g 672 368 672 384 0
r 672 320 672 368 0 10000.0
w 624 144 624 272 0
w 624 272 672 272 0
w 624 368 624 320 0
w 624 320 672 320 0
w 752 256 800 256 0
w 336 160 336 272 0
w 336 160 512 160 0
w 304 320 336 320 0
w 304 272 336 272 0
r 592 640 592 592 0 330.0
R 592 592 544 592 0 0 40.0 5.0 0.0 0.0 0.5
r 544 656 480 656 0 10000.0
r 544 704 480 704 0 10000.0
g 592 720 592 752 0
w 592 672 592 688 0
t 544 704 592 704 0 1 0.5109696961963799 0.5112184544839934 100.0
t 544 656 592 656 0 1 -0.6684621582153638 -2.4875703761353116E-4 100.0
t 592 640 624 640 0 1 0.6565549542877389 0.6684621594653638 100.0
r 592 592 640 592 0 330.0
w 640 592 640 624 0
w 624 624 640 624 0
w 624 656 624 720 0
w 624 720 592 720 0
w 1136 880 1168 880 0
w 1168 960 1120 960 0
w 1168 912 1168 960 0
w 1136 880 1136 928 0
w 1120 880 1136 880 0
w 1120 912 1168 912 0
w 1120 928 1136 928 0
t 1072 896 1120 896 0 1 -0.6565549537934822 0.011907205671584395 100.0
t 1072 944 1120 944 0 1 -0.6565549537934475 0.011907205671619018 100.0
g 1120 960 1120 992 0
r 1072 944 1008 944 0 10000.0
r 1072 896 1008 896 0 10000.0
R 1120 832 1072 832 0 0 40.0 5.0 0.0 0.0 0.5
r 1120 880 1120 832 0 330.0
w 1200 960 1168 960 0
w 1200 896 1200 960 0
w 1200 864 1216 864 0
w 1216 832 1216 864 0
r 1168 832 1216 832 0 330.0
t 1168 880 1200 880 0 1 0.6565549542873161 0.6684621594650666 100.0
w 1120 832 1168 832 0
w 768 560 800 560 0
w 304 432 336 432 0
w 976 720 800 720 0
w 800 608 800 720 0
w 800 448 976 448 0
w 800 448 800 560 0
w 1264 624 1216 624 0
w 1216 544 1264 544 0
162 1264 544 1264 624 1 2.1024259 1.0 0.0 0.0
w 1088 608 1136 608 0
w 1088 656 1088 608 0
w 1088 560 1136 560 0
w 1088 432 1088 560 0
r 1136 608 1136 656 0 10000.0
g 1136 656 1136 672 0
g 1216 624 1216 640 0
R 1216 496 1184 496 0 0 40.0 5.0 0.0 0.0 0.5
r 1216 496 1216 544 0 100.0
r 1136 608 1184 608 0 10000.0
r 1136 560 1184 560 0 10000.0
w 1216 576 1216 592 0
t 1184 608 1216 608 0 1 0.5070029211180633 0.6676112421332964 100.0
t 1184 560 1216 560 0 1 -0.2973174114364001 0.6673215045207006 100.0
w 928 672 976 672 0
w 928 544 928 672 0
w 928 496 976 496 0
w 928 544 928 496 0
w 912 544 928 544 0
w 1056 656 1088 656 0
r 976 720 976 768 0 10000.0
g 976 768 976 784 0
g 1056 736 1056 752 0
R 1056 608 1024 608 0 0 40.0 5.0 0.0 0.0 0.5
r 1056 608 1056 656 0 100.0
r 976 720 1024 720 0 10000.0
r 976 672 1024 672 0 10000.0
w 1056 688 1056 704 0
t 1024 720 1056 720 0 1 -4.890726766016432 1.2499999990092906E-9 100.0
t 1024 672 1056 672 0 1 -5.989404006161436E-4 0.01718028489306178 100.0
t 1024 448 1056 448 0 1 -4.066306801666734 0.599647965375327 100.0
t 1024 496 1056 496 0 1 0.5698226171593009 0.606519321552093 100.0
w 1056 464 1056 480 0
r 976 448 1024 448 0 10000.0
r 976 496 1024 496 0 10000.0
r 1056 384 1056 432 0 100.0
R 1056 384 1024 384 0 0 40.0 5.0 0.0 0.0 0.5
g 1056 512 1056 528 0
g 976 544 976 560 0
r 976 496 976 544 0 10000.0
w 1056 432 1088 432 0
w 880 544 912 544 0
r 304 432 304 480 0 10000.0
g 304 480 304 496 0
g 880 624 880 640 0
R 880 496 848 496 0 0 40.0 5.0 0.0 0.0 0.5
r 880 496 880 544 0 100.0
s 256 432 304 432 0 1 false
r 800 608 848 608 0 10000.0
r 800 560 848 560 0 10000.0
w 880 576 880 592 0
t 848 608 880 608 0 1 -0.8848093520815411 1.24999999900929E-9 100.0
t 848 560 880 560 0 1 -4.012961070298115 0.010136628527786407 100.0
R 256 432 224 432 0 0 40.0 5.0 0.0 0.0 0.5
w 800 256 800 416 0
w 800 416 768 416 0
w 768 416 768 560 0
w 336 320 336 384 0
w 336 432 384 432 0
w 624 944 592 944 0
w 624 880 624 944 0
w 624 848 640 848 0
w 640 816 640 848 0
r 592 816 640 816 0 330.0
t 592 864 624 864 0 1 0.6565549542876459 0.6684621594653054 100.0
t 544 880 592 880 0 1 -0.5426955493419798 0.009973798175330992 100.0
t 544 928 592 928 0 1 -0.11579281070773267 1.24026193121309E-9 100.0
w 592 896 592 912 0
g 592 944 592 976 0
r 544 928 480 928 0 10000.0
r 544 880 480 880 0 10000.0
R 592 816 544 816 0 0 40.0 5.0 0.0 0.0 0.5
r 592 864 592 816 0 330.0
w 800 608 736 608 0
w 736 608 736 528 0
w 736 528 384 528 0
w 384 432 384 528 0
w 384 528 384 560 0
w 384 560 480 560 0
w 480 560 480 656 0
w 768 560 512 560 0
w 512 560 512 608 0
w 512 608 448 608 0
w 448 608 448 704 0
w 448 704 480 704 0
w 416 384 416 432 0
w 336 384 416 384 0
w 416 432 512 432 0
w 416 432 416 880 0
w 416 880 416 928 0
w 416 928 480 928 0
w 432 880 432 416 0
w 432 416 320 416 0
w 320 416 320 288 0
w 320 288 336 288 0
w 336 288 336 272 0
w 432 880 480 880 0
162 1264 864 1264 944 1 2.1024259 1.0 0.0 0.0
w 1216 864 1264 864 0
w 1264 944 1264 960 0
w 1264 960 1200 960 0
w 640 624 688 624 0
w 688 624 688 752 0
w 688 752 880 752 0
w 880 752 880 896 0
w 880 896 1008 896 0
w 640 848 816 848 0
w 816 848 816 944 0
w 816 944 1008 944 0
x 179 281 196 287 0 24 A
x 179 328 193 334 0 24 B
x 156 440 195 446 0 24 Cin
x 1301 594 1314 600 0 24 S
x 1299 912 1355 918 0 24 Cout
x 885 199 1274 205 0 24 Full Adder Using NPN Transistors
Advertisements

Building a 4bit Counter Using JK Flip-Flops

This weekend’s electronics project with my son was to build a 4bit counter using JK flip-flops. Before implementing the circuit in hardware, I first explained the binary system and we then designed the counter using the free Circuit Simulator which I described in a previous post. Interestingly, he was amazed by the fact that adding just one more bit doubles the size of the counter – exponential growth is not intuitive ;-). The counter circuit, which chains together the flip-flops can be seen below: 

4bit Counter Using JK Flip-Flops

One important feature of the design is that we tie both J and K to +5v which turns the JK flip-flop into a T or Toggle flip-flop. Below is the code for the circuit. Copy and import the code into Circuit Simulator to get a better feeling of how the counter works – just press the switch to activate the next “tick” of the counter. 

$ 1 5.0E-6 10.20027730826997 50 5.0 50
162 496 272 496 208 1 2.1024259 1.0 0.0 0.0
g 320 208 320 176 0
w 320 208 496 208 0
r 496 272 496 352 0 330.0
r 544 272 544 352 0 330.0
162 544 272 544 208 1 2.1024259 1.0 0.0 0.0
r 592 272 592 352 0 330.0
162 592 272 592 208 1 2.1024259 1.0 0.0 0.0
r 640 272 640 352 0 330.0
162 640 272 640 208 1 2.1024259 1.0 0.0 0.0
w 496 208 544 208 0
w 544 208 592 208 0
w 592 208 640 208 0
156 368 464 432 464 0 5.0
R 288 432 256 432 0 0 40.0 5.0 0.0 0.0 0.5
w 288 432 288 464 0
w 288 464 368 464 0
w 288 464 288 528 0
w 288 528 368 528 0
s 288 432 352 432 0 1 true
w 368 496 352 496 0
w 352 496 352 432 0
156 528 464 560 464 0 0.0
w 528 464 512 464 0
w 512 464 512 528 0
w 512 528 528 528 0
w 512 528 512 576 0
w 512 576 288 576 0
w 288 576 288 528 0
w 464 464 480 464 0
w 480 496 528 496 0
w 640 352 640 416 0
w 640 416 464 416 0
w 624 464 624 384 0
w 624 384 624 352 0
w 624 352 592 352 0
156 704 464 736 464 0 5.0
w 512 576 672 576 0
w 688 528 688 576 0
w 672 576 688 576 0
w 688 528 704 528 0
w 704 464 688 464 0
w 688 464 688 528 0
w 624 464 640 464 0
w 640 464 640 496 0
w 640 496 704 496 0
w 800 464 800 368 0
w 800 368 544 368 0
w 544 368 544 352 0
156 864 464 896 464 0 5.0
w 688 576 864 576 0
w 864 576 864 528 0
w 864 528 848 528 0
w 848 528 848 480 0
w 848 480 848 464 0
w 848 464 864 464 0
w 800 464 816 464 0
w 816 464 816 496 0
w 816 496 864 496 0
w 496 352 496 384 0
w 496 384 960 384 0
w 960 464 960 384 0
w 464 416 464 464 0
w 480 464 480 496 0

The next step was to build the circuit using real JK flip-flops. We used dual HEF 4027BP JK flip-flops from NXP Semiconductors, 4 LEDs, 4 330 ohm resistors, a 10k resistor and a push button. Please note that these flip-flops are triggered on the rising edge and therefore, we chained them together via NOT Q and used Q to power the LEDs. As we used a push button to activate the clock on the first flip-flop, we pulled the clock pin down to 0v using a 10k resistor connected to ground. One last detail is that the Set and Reset pins for each flip-flop are connected to 0v. Below is the finished result built by Luke. 

4bit Counter

Amazing Java Circuit Simulation

Circuit Simulator is an amazing piece of free software. If you are in any way interested in electronics, download it from here and play around with it for an hour or so. I’m going to be using this application to publish the layouts for the cicuits we are working on in my future electronics related posts.

Circuit Simulator

If you want to see how the blinking LED circuit shown in the previous post works, paste the following into program using the import feature.

$ 1 5.0E-6 382.76258214399064 99 5.0 43
v 352 672 352 400 0 0 40.0 5.0 0.0 0.0 0.5
w 352 400 352 288 0
w 352 288 608 288 0
w 608 288 880 288 0
162 880 288 1008 288 1 2.1024259 1.0 0.0 0.0
r 1008 288 1008 320 0 500.0
w 1008 320 1008 336 0
w 1008 336 1120 336 0
w 1120 336 1120 832 0
w 1120 832 1104 832 0
r 1104 832 992 832 0 10000.0
w 992 832 816 832 0
t 528 400 608 400 0 1 -0.12632236495348304 0.5010407108474094 100.0
w 528 400 528 832 0
w 528 832 736 832 0
w 528 400 528 352 0
t 944 400 1008 400 0 1 0.5847909946260287 0.6273630758008925 100.0
w 1008 336 1008 352 0
w 1008 352 1008 384 0
w 1008 416 1008 672 0
w 800 352 800 400 0
w 800 400 944 400 0
w 1008 672 672 672 0
w 672 672 352 672 0
w 608 416 608 560 0
w 608 560 656 560 0
w 656 560 656 608 0
w 656 608 672 608 0
w 672 608 672 624 0
w 672 624 672 672 0
r 608 288 608 352 0 5000.0
w 608 352 608 384 0
r 608 352 528 352 0 5000.0
w 800 352 608 352 0
c 736 832 816 832 0 1.0E-5 0.21083170251411693