Full Adder on a breadboard - Page 1
Forum section: electronics / projects

author: ziptol
author_rank: Contributor
timestamp: December 08, 2019, 12:12:22 am
content: I've been working on making a full adder for a bit, let me know what you think!I want to build 4 bit computer and hopefully this is the first step.Tested using Arduino data pins.

author: intabits
author_rank: Frequent Contributor
timestamp: December 08, 2019, 10:12:39 am
content: Nine NOR gates for one bit of the adder, each consisting of a transistor and three resistors, and all discrete components.It's sure going to be a huge number of parts to make a computer this way!Are you planning to breadboard it all, or make some PCBs (SMD?) to ease the workload (and improve reliability)?And if you do go for PCBs, it may then become practical to make it an 8 bit processor, which could be much more capable.I also wonder if there is any opportunity for optimization of the parts count for a specific logic block such as this. Maybe some resistors can be eliminated by partially merging some gates together. I haven't tried to analyze for this, so I don't know if it can be done.And I think it would be great to add LEDs at strategic points throughout, say in the collectors of Q8 and Q9. EG: a LED and 270R in series, across R22 and R27. But they would be indicating negative logic, so maybe add another transistor to get a positive logic display?Good luck!

author: donmr
author_rank: Regular Contributor
timestamp: December 08, 2019, 07:24:02 pm
content: One of the first computers I worked with was made of this type of logic, Resistor-Transistor-Logic, RTL. It was a DEC PDP-10 KA10 model. They had small boards with one or two gates, or a flip-flop, etc. The boards were plugged onto backplanes that filled several 6' high 19" wide racks. So it can be done, but I'd much rather use at least 7400 series ICs, or maybe some FPGAs.

author: ziptol
author_rank: Contributor
timestamp: December 08, 2019, 09:20:00 pm
content: I'd like to use this as a way to introduce myself to digital electronics, and help build up my knowledge and skills along the way. (I'm still a noobie and I've got a lot to learn) I'm going to start out with just doing an adder, a couple registers and some control on breadboards cause there's something really calming/cathartic for me to building things out on a breadboard, although it would be cool to try making some blocks on pcbs.

author: magic
author_rank: Super Contributor
timestamp: December 08, 2019, 10:34:55 pm
content: Perfboards are OK for small projects where it doesn't make sense to design custom PCB but you want mechanical robustness of soldered connections and full flexibility in placement and routing.Smaller transistors like 2N3904/2N3906 would be sufficient here.As for LEDs, I recommend looking for ones with built-in series resistors. They aren't very common but they exist and they make life much easier. Look for LEDs rated for standard voltages like 5V or 12V rather than the usual oddball voltages of LEDs such as 1.9V, 2.7V or 3.2V.

author: LeoTech
author_rank: Regular Contributor
timestamp: December 09, 2019, 03:59:05 pm
content: This does definitely sound like an interesting project.What CPU architecture are you planning on using? I am not certain about this, but the amount of 4-bit CPU architectures out there is probably pretty limited, so you will probably have to design your own. Which I can from personal experience assure you is pretty fun, and you will definitely learn a lot by doing it.When designing/choosing an architecture keep in mind, that if you are using a conventional architecture, where everything is connected to the same wBus, then you need tri-state buffers for each connection, which might be a challenge to implement.On the account of bread boarding, if you find it relaxing - which I can relate to - and enjoy it, then just do it. It might be tedious, but also very rewarding.Good luck on your project, and if you need any help designing an architecture, I would gladly help!Leo

author: ziptol
author_rank: Contributor
timestamp: December 09, 2019, 08:48:17 pm
content: I'm currently waiting for more parts to arrive, so I've been spending some time researching computer architecture and I think I've got a simple setup I can work on. I'm planning on using D flip-flops for my registers, and to start off by using a 555 IC for the clock, but then switch to one that I build out myself. Let me know what you think! Is there anything that I might be missing/overlooking/getting wrong in my design?

author: Renate
author_rank: Super Contributor
timestamp: December 10, 2019, 01:25:14 am
content: That looks like a neat little project.I cut my teeth on RTL.Have you already read the classic "RTL Cookbook"?It's a free download from the author directly:https://www.tinaja.com/ebooks/rtlcb.pdfHmm, unless I'm holding my tablet upside-down this is using negative logic.I mean that ground is a "1" and voltage is a "0".That's fine, as long as you know it.Quote from: LeoTech on December 09, 2019, 03:59:05 pmI think that I'd just use open collector buses, it's much easier.As far as the clock goes, a two transistor astable is one of the first circuits people build.

author: ziptol
author_rank: Contributor
timestamp: December 10, 2019, 02:41:06 am
content: I haven't read that, thanks for linking it!I don't believe that this is using negative logic, 1's came out as 1's and 0's came out as 0's.I'll look into the two transistor astable, thanks for letting me know. I'm only a couple of months into electronics, so I've still got a long way to go

author: Renate
author_rank: Super Contributor
timestamp: December 10, 2019, 02:06:07 pm
content: Err, I was confusing myself.I did an emulation of it and convinced myself.A change of sense changes a NOR into a NAND and vice versa.A change of sense does nothing to an inverter or a (full) adder.A change of sense changes a XOR into an XNOR and vice versa.Jeez, I hope that I finally have this straight!

author: Renate
author_rank: Super Contributor
timestamp: December 10, 2019, 11:29:35 pm
content: If you'll excuse a little trip down the rabbit hole, you might find this interesting...You can take a logic circuit and put an inverter on each of the inputs and each of the outputs.It will do something now, but will it be the same?Let's take a piece of wire (an "IS" gate) and put one inverter on the input and one inverter on the output.Does it react the same still? Yup, it's an "IS" gate.We can do this with an inverter too, making 3 inverters in a row, still an inverter.If we take a NAND gate and put an inverter on each input and one on the output we actually get a NOR gate.You can verify this for yourself.https://en.wikipedia.org/wiki/De_Morgan%27s_lawsSo, either inverting all inputs and outputs OR inverting the sense of what you are calling a "1" or "0" amounts to the same thing.In the breadboarded circuit, Q1-Q4 form a half adder, that is a 2 input adder.Normally you need a 3 input adder to deal with carries.So we have Q1-Q4 cascaded into another half adder (Q5-Q8) to accept that incoming carry.My problem/confusion/stupidity was thinking that a half adder couldn't live with inverters on input and output.Since Q1 has to detect the carry (if Q1-Q4 were operating in isolation) then they had to be using negative logic, that is, Gnd is a "1".Why? Because Q1 normally would be considered a NOR, but we need something in the AND family.But! Since this is all part of a 3 input adder, it all comes out in the wash.The breadboarded circuit is fine if you consider Gnd a "1" or if you consider Vcc a "1" or if you invert all inputs and outputs!Let's look at some adders, starting with a 1 input adder.A 1 input adder??? Sure it follows the rules of all adders, it counts ones.We fill out the truth table, then we change all 1's to 0's, then we put it in order and see if it's the same as the original.Code:inv revA X A X A X0 0 --> 1 1 --> 0 0 GOOD!1 1 0 0 1 1So that works!What about a 0 input adder? It counts ones. Obviously, there are zero of them.Code:inv revX X X0 --> 1 --> 1 BAD!Ok, now we're at the half adder, a 2 input adder.Code:inv revA B X Y A B X Y A B X Y0 0 0 0 1 1 1 1 0 0 0 10 1 0 1 --> 1 0 1 0 --> 0 1 1 0 BAD!1 0 0 1 0 1 1 0 1 0 1 01 1 1 0 0 0 0 1 1 1 1 1Well, what about a 3 input adder (like the breadboard)?Code:inv revA B C X Y A B C X Y A B C X Y0 0 0 0 0 1 1 1 1 1 0 0 0 0 00 0 1 0 1 1 1 0 1 0 0 0 1 0 10 1 0 0 1 1 0 1 1 0 0 1 0 0 10 1 1 1 0 --> 1 0 0 0 1 --> 0 1 1 1 0 GOOD!1 0 0 0 1 0 1 1 1 0 1 0 0 0 11 0 1 1 0 0 1 0 0 1 1 0 1 1 01 1 0 1 0 0 0 1 0 1 1 1 0 1 01 1 1 1 1 0 0 0 0 0 1 1 1 1 1And since you've gotten all the way down here, I can tell you that the next adder that works with DeMorganizing is the 7 input adder.

author: ziptol
author_rank: Contributor
timestamp: December 11, 2019, 12:23:24 am
content: This is really interesting, thanks!Admittedly, after getting shaky results from making an adder out of AND gates and OR gates, I was looking online and found that you could make an adder out of both NAND and NOR gates. I picked the NOR adder because it would take fewer transistors and in my haste to get an adder on a breadboard, I neglected to actually find out why both worked and left it up to some logic wizardry. Working through how these things is the whole reason I took up this project, so this is super helpful for me!

author: LeoTech
author_rank: Regular Contributor
timestamp: December 13, 2019, 03:58:48 pm
content: Quote from: Renate on December 10, 2019, 01:25:14 amThat seems like a far better solution, indeed. Although I have to admit, that I do not know to much about it.Quote from: ziptol on December 09, 2019, 08:48:17 pmYour design will undoubtedly work, but I might use an architecture along the lines of:This will save you quite some Logic Gates, as you do not need as many control signals and the accompanying logic.Besides that, it will also save you one clock cycle for each add machine cycle. (May depend on the rest of the architecture, but it will not increase the number of clock cycles at least.)The way it works, is that you load one of the numbers you want to add into the B register from the input - which I just realized, I forgot to draw - after that the second number will be present on the wBus, aka the input register will be enabled. The ALU then automatically add these two numbers together, and if you set the write signal for the A register high, then the result will be stored in there. After that the output of A reg can be enabled and the write signal for the output register will be high.I sincerely hope, that this explanation makes sense. It can be summarized as:Code:0:Enable input, Write B,1:Enable input, Write A, //Remember to enter a new number into the input for this step, if you wish to add something else than the same number twice2:Enable A, Write OutputBtw, your post has inspired me to try and create a 4 bit CPU architecture for an FPGA based CPU myself, thank you(Sorry for the delayed response, I have been traveling.)

author: ziptol
author_rank: Contributor
timestamp: December 14, 2019, 12:32:34 am
content: Update:I received my shipment of parts from DigiKey yesterday and put together the rest of the full adder. I removed the test connections from the adders so the whole thing would be easy to see, but it's been tested and works perfectly!Next up is the registers. I've designed some D Flip Flops, but it's a total of 7 transistors per Flip Flop plus 2 transistors for the activation, so if anyone has any suggestions for how to make it more efficiently, that would be much appreciated.

author: intabits
author_rank: Frequent Contributor
timestamp: December 16, 2019, 10:57:38 am
content: Have you considered DTL rather than RTL?I've always thought that the former was supposed to be be superior, though I can't justify that statement just of the top of my head right now.(No more complex than RTL? Better logic level integrity?)Seven transistors for a flop-flop does seem excessive to me, I always thought 2 or 4 would cover most use cases.See P27 of:-http://bitsavers.org/pdf/ibm/logic/223-2618_DDTL_Component_Circuits_CEMI_Sep1963.pdf(IBM called flip-flops "triggers")Some more good reads from IBM:-http://bitsavers.org/pdf/ibm/logic/Walsh_-_IBM_Current_Mode_Transistor_Logical_Circuits_1958.pdfEarly stuff (vaccum tubes), but still valid principles:-http://bitsavers.org/pdf/ibm/logic/223-6746-1_700_Series_Data_Processing_Systems_Component_Circuits_Apr1959.pdfStandard Modular System (SMS) - I have hundreds of these, maybe I'll try something simlar one day...http://ibm-1401.info/IBM-StandardModularSystem-Neff7.pdfHow they are used to make a computer:-http://www.bitsavers.org/pdf/ibm/1620/fe/227-5751-1_1620_Model_1_Customer_Engineering_Manual_of_Instruction_Aug63.pdfMy very old SMS card page:-http://members.optushome.com.au/intaretro/SMSCards.htmAnd others:-https://hackaday.io/project/8449-hackaday-ttlers/log/130460-bizarre-dtl-logic-levels-the-discrete-component-pdp-8https://bootlicker.party/posts/ibm-sms-logic/IBM used odd terminology, and weird voltage levels (compared to +5v). The above manuals were for internal use, so a fairly heavy proprietary slant, but still interesting and informative.

author: David Hess
author_rank: Super Contributor
timestamp: December 16, 2019, 04:24:30 pm
content: Quote from: intabits on December 16, 2019, 10:57:38 amRTL has lower noise margin. When integrated, it takes up more space than the alternatives.I have thought about doing a logic project using discrete transistors to implementintegrated injection logicwhich takes more transistors but fewer resistors than RTL.

author: intabits
author_rank: Frequent Contributor
timestamp: December 16, 2019, 07:22:00 pm
content: Quote from: David Hess on December 16, 2019, 04:24:30 pm^ the words I was looking for when I said DTL has "better logic level integrity", and also that DTL can handle many inputs easily (better fan-in)

author: intabits
author_rank: Frequent Contributor
timestamp: December 16, 2019, 07:50:29 pm
content: You may be able to save some transistors in your adder (and other compound circuits) by using 2 levels of diode logic.Looking at P20 of 223-2618_DDTL_Component_Circuits_CEMI_Sep1963.pdf, linked to above:-Diode logic AND-OR, and OR-AND can be used (but not AND-AND or OR-OR) with just one transistor.Once again, I haven't dug into the nitty gritty of this, so I'm just throwing it out there.It may be that this is only possible because of the dual supplies, and oddball logic levels that IBM used.

author: intabits
author_rank: Frequent Contributor
timestamp: December 17, 2019, 10:36:19 am
content: How about a full adder using just 6 transistors?By choosing logic elements to avoid NANDs, the ANDs feed to the inputs of NORs, which allows 2 level diode logic, thus eliminating the need for some transistors.The Carry output inverter might also be eliminated by some bodge of the NOR to make an OR. (Emitter follower or PNP transistor?)Timing diagrams:-LTSPice schematic attached.To run the simulation, the logic equivalent circuit can be deleted, or the library it uses can be installed as described in:-