Design of a combinational circuit with 3 inputs, x, y, z, and 3 outputs, A, B, C. When binary input is 0, 1, 2, or 3, the binary output is twice the input. When binary input is 4, 5, 6, or 7, binary output is half the input. How can 5 and 7, the outputs of which are 2.5 and 3.5, respectively, be represented in the truth table? Here is the truth table that I have filled out as much as possible.
-
1\$\begingroup\$ I don't think there's a bright-line answer -- or an objective reality -- that could tell you how to handle it. Either you are supposed to truncate, or round according to some rules. And if you round, by which of several possible rules? So you will have to decide the matter, I think. For us, it would only be an array of differing "opinions." You are in a better place to decide this. \$\endgroup\$– periblepsisCommented Mar 31 at 4:44
-
3\$\begingroup\$ As given, this homework cannot be done. There is such a thing like a fixed-point binary, but it needs 4 bits, as the largest value is 6 and the resolution is 0.5. 3 bits will be left to the point and 1 right to it. If you are supposed to round, you cannot differentiate between results. Please get back to your teacher and ask for clarification. \$\endgroup\$– the busybeeCommented Mar 31 at 10:38
-
\$\begingroup\$ I'd guess your instructor is getting you to realize the limitations of binary math. I'd go with 2 and 3. \$\endgroup\$– StainlessSteelRatCommented Mar 31 at 17:44
-
\$\begingroup\$ @thebusybee I will seek clarification and re-edit the question to hopefully get it re-opened, as given it is a question from a textbook (Digital Design with RTL Design, VHTL, and Verilog, 2nd Edition, by Frank Vahid), it doesn't seem like they would include a question which cannot be done. \$\endgroup\$– eutectic_codswallopCommented Apr 1 at 4:54
-
\$\begingroup\$ Well, books have errors, by far the most of them are written by humans. :-D You might want to search for errata. -- Which exercise in what chapter is it? -- Did you look for a solution? Many books have an appendix or separate booklet with answers. -- Please add such clarifications to your question by editing it. \$\endgroup\$– the busybeeCommented Apr 1 at 9:28
2 Answers
To design this circuit, you need to understand how binary division and multiplication by 2 work. For binary numbers, division by 2 is equivalent to shifting the bits to the right by 1 position, effectively removing the least significant bit. Similarly, multiplication by 2 is equivalent to shifting the bits to the left by 1 position, adding a 0 as the least significant bit.
So, the decimal number 5 (101) divided by 2 = 010 (2) [from 2.5]
Decimal number 7 (111) divided by 2 = 011 (3) [from 3.5]
This leaves the finished truth table as follows:
Since you're dealing with integers, you can't represent 2.5 or 3.5 unless you come up with some non-standard coding schema.
Some assert that this problem is underspecified. I suggest, though, that you handle such cases as simple integer divides, where "half" simply means "divided by 2". Thus, half of three is 3/2= 1 when integer dividing.
-
\$\begingroup\$ You might want to add that it is only a non-standard coding schema, if only 3 bits are used for the output. \$\endgroup\$ Commented Apr 1 at 17:57