## Interview Question – BCD Digit, Multiplied by 5

December 21, 2008A while back, someone sent me the interview question I am about to describe, asking for help. I think it serves a very good example of observing patterns and not rushing into conclusions.

I will immediately post the answer after describing the problem. However, I urge you to try and solve it on your own and see what you came up with. On we go with the question…

Design a circuit **with minimum logic** that receives a single digit, coded BCD (4 wires) and as an output gives you the result multiplied by 5 – also BCD coded (8 wires).

So, I hope you got a solution ready at hand and you didn’t cheat ðŸ˜‰ .

Let’s first make some order and present the input and required outputs in a table (always a good habit).

Looking for some patterns we can see that we actually don’t need any logic at all to solve this problem!!

You will be amazed how many people get stuck with a certain solution and believe it is the minimal one. Especially when the outcome is one or two single gates. When you tell them it can be done with less, they will easily find the solution. IMHO there is nothing really clever or sophisticated about this problem, but it demonstrates beautifully how it is sometimes hard for us to escape our initial ideas and approaches about a problem.

Coming to think of it, this post was more about psychology and problem solving than digital design – please forgive…

This question was put to me @ infineon couple yrs back ðŸ™‚

by One Nanometer December 22, 2008 at 6:32 amand… did you fall in the trap or you saw past it?

by Nir Dahan December 22, 2008 at 3:04 pmI actually came up with a simple mathematical proof to the result

by Moe December 25, 2008 at 6:36 amnice Q.[:)]

by Rag December 26, 2008 at 6:42 am5*(8a3+4a2+2a1+a0)

=40a3+20a2+10a1+5a0

=40a3+20a2+10a1+4a0+a0

maps to

80b7+40b6+20b5+10b4 + 8b3+4b2+2b1+b0

if b6==a3, b5==a2, b4==a1, b2==a0 and b0=a0

by stefaan December 30, 2008 at 4:44 pmWe have to apply huge logic here to solve this.

by Jolly January 7, 2009 at 8:40 amIsn’t decimal 10 is 1010 and not 10000 – which would invalidate the whole design – since the second LSB will not be always 0?

by Mike February 5, 2009 at 9:48 pmNo. I guess, in BCD coded system each digit is coded independently. Kindly correct me if am wrong.

by Ramesh June 23, 2010 at 3:59 ammodule test(a,b);

input [3:0]a;

output [7:0]b;

wire [3:0]a;

reg [3:0]temp;

reg [7:0] b;

assign #1 a = 4’b0110;

initial

by shishira July 20, 2009 at 5:24 ambegin

#1

temp = a;

temp[0] = 0;

b[7:4] = temp>>1;

if(a[0])

b[3:0] = 4’b0101;

else

b[3:0] = 4’b0000;

$display(“The value of input a is %h”, a);

$display(“The value of output b is %h”, b);

end

endmodule

No gates are required to solve this problem

by Arnab August 2, 2010 at 2:04 pmwe can see that all even no have lsb=0 and odd have lsb=1 and for even the lower 4 bits are 0000 and for odd the lower 4 bits are 0101.Thus to generate the lower 4 bis just supply LSB of given no to bit position 2 and 4.This gives lower for bits.

To genertae upper 4 bits msb=0 always and just supply the 1st 3 bits of the number.

i am B.tech student, i dont know how to do ” BCD digit multiply by another BCD digit”, pls can u show me the complete hardware ( logic gates)

by ram kumar July 26, 2011 at 7:05 amIt can be sloved like this

by Nidhi September 14, 2011 at 5:49 amfor 4 bit input a3a2a1a0

8bit output will be b7b6b5b4b3b2b1b0

output bits will be related to input as

b7 = 0

b6 = a3

b5 = a2

b4 = a1

b3 = 0

b2 = a0

b1 = 0

b0 = a0

modulo 10 multiplier (shift 5 times to right ) and then use modulo 2 divider

by bhargav March 19, 2012 at 3:49 amif (a[0])

by banltc12 October 4, 2014 at 4:12 pmy = {a[3:1], 4’b0101};

else

y = {a[3:1],4’b0000};