The circuit shows a two bit multiplication circuit.
If you create a truth table for the circuit you see it easily.
A B X
00 00 0000 0 x 0 = 0
01 00 0000 1 x 0 = 0
10 00 0000 2 x 0 = 0
11 00 0000 3 x 0 = 0
00 01 0000 0 x 1 = 0
01 01 0001 1 x 1 = 1
10 01 0010 2 x 1 = 2
11 01 0011 3 x 1 = 3
00 10 0000 0 x 2 = 0
01 10 0010 1 x 2 = 2
10 10 0100 2 x 2 = 4
11 10 0110 3 x 2 = 6
00 11 0000 0 x 3 = 0
01 11 0011 1 x 3 = 3
10 11 0110 2 x 3 = 6
11 11 1001 3 x 3 = 9
You can separate the circuit into four parts.
- Pass the A value to the output if B0 is one
- Pass the A value, shifted one bit (x2) to the output, if B1 is one.
- Detect an “overflow”, if A = 11 and B = 11.
- “Add” the results of part 1, 2 and 3.
In a programming language, e.g. Python, you could write the four parts like this:
a = 3
b = 2
# Part 1
ab0 = (a if (b & 0b1) else 0)
# Part 2
ab1 = ((a << 1) if (b & 0b10) else 0)
# Part 3
ab_overflow = (0b1100 if (a == 0b11 and b == 0b11) else 0)
# Part 4
x = ab0 ^ ab1 ^ ab_overflow
It is no exact logic representation of the circuit, because the input and output bits are kept combined in the variables.