In Half 1 of this two-part binary coded decimal (BCD) extravaganza, we launched a bunch of bodacious ideas, together with the binary (base-2) quantity system, binary logic, binary computer systems, and bits, adopted by the ternary (aka trinary) (base-3) quantity system, ternary logic, ternary computer systems, and trits (attempt saying that sentence ten occasions shortly).
We additionally mentioned the senary (aka heximal or seximal) (base-6), decimal (aka denary or decanary) (base-10), duodecimal (aka dozenal) (base-12), vigesimal (base-20), and sexagesimal (aka sexagenary) (base-60) quantity techniques.
All of this led us to the ideas of the hexadecimal (base-16) quantity system and binary coded decimal (BCD). There are a number of BCD encoding potentialities, however we began by contemplating BCD 8421, which can even be known as pure BCD (NBCD) or easy BCD (SBCD).
We left Half 1 with a mission, which was to ponder how we’d go about creating single digit BCD 8421 adder; that’s, a logic operate that may settle for two BCD 8421 digits, together with a carry-in bit from a earlier stage, after which use these values to generate a 4-bit BCD sum together with a carry-out bit to the subsequent stage.
There are a number of methods by which we’d set about doing this. For instance, we might do what we do with easier capabilities, which is to deal with it as a black field, write out the reality desk, after which use Karnaugh maps, Boolean algebra, and—probably—De Morgan’s transformations to determine what mixture of primitive logic gates will finest serve our function.
Like many issues, this sounds simple if you say it shortly and loudly, particularly if you happen to wave your arms round whereas doing so, nevertheless it’s not so easy in observe. Let’s name our two 4-bit BCD enter digits A and B. Every of those will be in one among ten states, which suggests we’ve 10 x 10 combos, which equates to 100 strains in our reality desk. However wait, there’s extra, as a result of we even have our Cin (“Carry In”) enter, which will be 0 or 1, which suggests our reality desk could have 200 strains. Now, I’m not saying that producing the logic for our adder from this reality desk can’t be achieved. What I am saying is that I’m not going to be the one to do it.
One other risk can be to create a look-up desk utilizing some type of non-volatile reminiscence, equivalent to programmable read-only reminiscence (PROM). On this case, we’re going to have 9 enter (tackle) bits (two 4-bit BCD digits plus our 1-bit Cin), which equates to 29 = 512 phrases of reminiscence. On the intense aspect, it will present a quick adder operate. On the draw back, since six of the attainable binary combos stay unused for every BCD digit, we’re going to have numerous unused (wasted) phrases in our reminiscence. Even with the phrases we’re utilizing, we require solely a 5-bit output (one 4-bit BCD sum plus our 1-bit Cout), however reminiscence gadgets are usually introduced in 8-bit widths, which suggests we’ve three unused (wasted) bits in every phrase.
Fortunately, there’s one other manner by which we are able to go about this. Since every of our BCD digits can have a worth from 0 to 9, the 2 excessive circumstances for our adder are 0 + 0 = 0 and 9 + 9 = 18. If we additionally think about our Cin bit, which will be 0 or 1, this implies we’ve solely 20 completely different circumstances to think about, from 0 + 0 + 0 = 0 to 9 + 9 + 1 = 19.
Check out the diagram under. On the left, we present a desk whose left-hand column represents the decimal equal of the 0 to 19 attainable circumstances ensuing from us including two BCD digits (plus carry in). To the suitable of this desk, we present what we wish to see popping out of our single digit BCD adder. And on the suitable of the picture as an entire, we depict the logic we want as a “blob.” So, all we have to do now could be determine what goes in our “blob.”
Put together to gasp in astonishment on the crafty plan we’re going to deploy. Certainly, it is a plan so crafty we might pin a tail on it and name it a weasel (as Blackadder would say). What we’re going to do is make use of an ordinary 4-bit binary adder. Really, we’re going to use two of those little rascals as proven under.
The desk we’ve added exhibits the outcomes generated by our first (higher) binary adder for the 0 to 19 circumstances related to our including two BCD digits plus the carry in bit. Let’s begin by contemplating the BCD Cout sign within the right-hand desk. That is 0 for circumstances 0 to 9 and 1 for circumstances 10 to 19.
A clue to the best way by which we are able to generate this sign is offered by the purple, blue, and inexperienced highlighted areas within the desk. What this tells us is that Cout within the right-hand desk will be generated as an OR of those highlighted areas within the left-hand desk. That’s, Cout = Co (purple) OR (S3 AND S2) (blue) OR (S3 AND S1) (inexperienced). We are able to see this depicted in our logic gate implementation with the purple, blue, and inexperienced wires on the suitable.
Now we flip our consideration to the second (decrease) binary adder. When Cout is 0, the outputs from this adder (R3, R2, R1, and R0) are similar to the outputs from the primary adder (S3, S2, S1, and S0). By comparability, when Cout is 1, the outputs from the decrease adder (R3, R2, R1, and R0) (the values highlighted in yellow) are equal to the outputs from the primary adder (S3, S2, S1, and S0) plus 6 in decimal (0110 in binary). We are able to obtain all of this by tying the Ci enter to the second adder to 0, additionally tying bits 0 and three of the adder’s second set of inputs to 0, after which connecting bits 1 and a pair of of the adder’s second set of inputs to Cout.
I don’t find out about you, however I really feel a moderately rambunctious “Tra-la” is so as. After I was first launched to this answer, I used to be blown away by its class and (relative) simplicity. Fairly aside from the rest, this method has sparked all kinds of concepts to handle different logical conundrums which have come my manner. What say you? Do you might have any ideas you’d care to share about something you’ve seen right here?