One of the exercises in my Logic Design coursebook requires me to create a circuit that handles following micro-operations on 4-bit registers R1 and R2.

  • R1 + R2
  • R1 - R2
  • R2 – R1
  • R1 – 1
  • -(R1 + 1)
  • 0
  • -1

However, the constraints are that I can only use a 4-bit adder, 4 to 1 MUX, and 2 to 1 MUX in the procedure of doing so. I have tried various configurations but I cannot wrap my head around it.

Edit: Register storage is not required.

  • \$\begingroup\$ Well..you know how to use the adder for the first operation right? For subtraction and negative numbers in general, have you heard of twos compliment? \$\endgroup\$
    – DKNguyen
    May 10 '20 at 0:29
  • \$\begingroup\$ Yes, I do. However, the problem is that I have to operate this whole circuit using MUX selection lines. I can't seem to figure out how it will all be configured. \$\endgroup\$
    – KodeRex
    May 10 '20 at 0:32
  • \$\begingroup\$ I think you are supposed to use the 2-1 mux as a comparator to flip bits and use the 4-1 mux to scan that through all 4 bits? \$\endgroup\$
    – DKNguyen
    May 10 '20 at 0:35
  • \$\begingroup\$ @KodeRex Do you have access to Q and /Q of each bit in the registers? \$\endgroup\$
    – jonk
    May 10 '20 at 1:30
  • \$\begingroup\$ @KodeRex If not, you can still achieve the same thing. But I just wondered if you do. It makes only a small difference. \$\endgroup\$
    – jonk
    May 10 '20 at 4:43

I think you already understand 2's complement notation and know that to subtract, it's convenient to realize that negation of a register is \$-R=1+\overline{R}\$.

Assuming that you do not have access to both \$Q\$ and \$\overline{Q}\$ for your registers, the first thing you need to do is to create this option with muxes that can invert a value.

Another thing is to consider your operations carefully:

R1 =   R1 + R2
R2 =   R1 - R2
R1 = – R1 + R2
R1 =   R1 – 1
R2 = - R1 - 1
?? = 0
?? = -1

Let's assume that ?? is just the output of the adder. But in some cases you are redirecting that output to either R1 or R2. But in the last two cases you don't do that. It's possible.

You can easily see from the above list of operations that the R2 input to the adder can either be R2 or else -1. But also that the R1 input to the adder can be either R1 or 1. Then the operations turn into:

000: R1 = (0 +  R1 +  R2) =  R1 + R2
001: R2 = (1 +  R1 + ~R2) =  R1 - R2
010: R1 = (1 + ~R1 +  R2) = -R1 + R2
011: R2 = (1 + ~R1 + ~00) = -R1 - 1
100:  X = (X +  R1 +  00) =   X
101: R1 = (0 +  R1 + ~00) =  R1 - 1
110: ?? = (1 + ~00 +  00) =   0
111: ?? = (1 + ~00 + ~00) = - 1

At this point you can see that you either select R1 or else 0; and also, you either select R2 or else ~0. This is pretty cool because you only need to mux between R1 and 0 on one of the adder inputs and between R2 and ~0 one the other adder input.

The above choices aren't the only possible ones, by the way. They are just the ones I picked without much effort.

At this point, it shouldn't be too difficult for you to work out the muxes required to achieve the desired results.

This isn't a completed example, as it doesn't perform the register store operation from the result. It also requires you to figure out the bus widths and how that gets implemented with the 2x1 and 4x1 muxes. But it should give you an idea.

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.