3
\$\begingroup\$

While working on Digital logic, I encountered the problem of using a BCD switch to enter a binary number. For example, using a BCD switch, I can enter the number 117, which would be inserted into the system as 0001 0001 0111. How do I convert this number to binary such that the input via BCD switch is treated as binary? I previously built a 2-digit BCD to binary convertor, which converts, for example, a number like 77 = 0111 0111 in BCD to binary (1001101). This 2-digit BCD to binary convertor took up four 4-bit adders. The task obviously becomes much more tedious when I move onto 3-digit and even 4-digit BCD to binary convertors, which is what I am interested in.

How do I simplify this task without using any advanced methods e.g microcontrollers? My research caused me to stumble on ROM ICs, but I would like to know specifically how I can utilize this to develop a 3 or 4-digit BCD to binary convertor (e.g. (177)bcd --> (177)binary). To sum it up, I would like a solution involving ICs that is not extremely tedious, like the adder approach, and not too advanced. I guess ROM is the closest approach, but I would like a more in depth explanation of it.

\$\endgroup\$
5
  • \$\begingroup\$ A simple solution using a ROM would obviously be a 1:1 mapping for all values. That requires a ROM with 10000 3-byte words, though. \$\endgroup\$ Commented Oct 20 at 15:23
  • 2
    \$\begingroup\$ @PMF Not sure I understand your calculation. For a 4 decimal digit input, one would need a ROM with 16 bit addressing (4 digits x 4 bits -- though many values would be unused) and (at least) 11-bit words (maximum value is 9999 which requires 11 bits in binary), or did I miss something? \$\endgroup\$ Commented Oct 20 at 15:31
  • \$\begingroup\$ You can use something like SN74184 TTL circuits ... \$\endgroup\$ Commented Oct 20 at 16:17
  • \$\begingroup\$ note that most people would consider programming a ROM or a PAL more "advanced" than using a microcontroller to handle user input. If this is for a retrocomputer: this sounds like you want to implement an IO controller, anyways, a small processor that does things like BCD calculations, in software. \$\endgroup\$ Commented Oct 20 at 16:21
  • \$\begingroup\$ @jcaron You are right. "only" 10.000 entries is not enough. \$\endgroup\$ Commented Oct 20 at 19:58

3 Answers 3

4
\$\begingroup\$

You can program a ROM so that each BCD value, entered as the ROM address, generates the corresponding binary output.
For 4 digits (9999 max decimal), this would require a minimum 14-bit output ROM.

For a discrete logic, serial conversion approach, you can load a BCD counter with the BCD value and have it count down to zero.
With the same clock, have a binary counter, count up from zero.
When the BCD counter reaches zero, the binary counter will contain the equivalent binary value.

For 4 digits, that would require four BDC counters, and four 4-bit binary counters.

\$\endgroup\$
4
  • \$\begingroup\$ What specifically interests me (project-wise) is a BCD to binary converter, where the maximum BCD is 177 (0001 0111 0111). What size ROM will that require? \$\endgroup\$ Commented Oct 20 at 15:52
  • \$\begingroup\$ 177 requires 9 bits in BCD: one one bit digit , and two 4 bit digits.. And the result is greater than 128 but less than 256 so the output is 8 bits wide. So its a 512x8 ROM. I wont recommend the MM5204Q. Any programmable memory chip will do, its actually probably cheapest to use a microcontroller these days. \$\endgroup\$ Commented Oct 20 at 15:56
  • \$\begingroup\$ @ocelot I understand the fact that microcontroller is better, but it's not possible in my situation. I looked up the best ROM ICs to use and I have two choices: AT28C16 and AT28C64. Their sizes are perfect. \$\endgroup\$ Commented Oct 20 at 16:14
  • \$\begingroup\$ How will you be programming the ROM? \$\endgroup\$ Commented Oct 20 at 20:55
1
\$\begingroup\$

Maybe you don’t want to use a microcontroller. But if you’re familiar with the algorithms and logic already, one idea that comes up is to compute each digit based on an adder, some logic and a finite state machine to compute and update each digit. Your three digits would take three clock cycles.

\$\endgroup\$
1
\$\begingroup\$

There is an alternative if "time" is important. Use SN74184 circuits.

ROM alternative is another solution (with enough inputs and outputs...).
You can also split into some ROM with 4 or 8 bits outputs.

enter image description here

\$\endgroup\$
4
  • \$\begingroup\$ uff, at that point, a PAL, or a CPLD, would seem the easier variant. Also, could you please tell us where that figure is from? \$\endgroup\$ Commented Oct 20 at 16:22
  • 2
    \$\begingroup\$ @MarcusMüller From SN74184 datasheet applications. \$\endgroup\$ Commented Oct 20 at 16:23
  • \$\begingroup\$ The SN74184 IC is obsolete and generally difficult/expensive to find. \$\endgroup\$ Commented Oct 20 at 17:47
  • 1
    \$\begingroup\$ you have the "internal" function ... you can then use it in a CPLD ... as macro. \$\endgroup\$ Commented Oct 20 at 19:29

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.