# Logic Circuit - Find the first set bit in 4 bit number

Discussion in 'Homework Help' started by Mora, Apr 26, 2017.

1. ### Mora Thread Starter New Member

Apr 26, 2017
2
0
Hello,

I need to design a logic circuit:

4 inputs
2 output of the place of the first set bit
1 output if there is any set bit (or between the inputs)

What can I do to find the place of the first set bit?

by the way, after that I need to design a circuit to find the place of the most left set bit, so I will be happy if you'll help with that too.
Thanks.

2. ### WBahn Moderator

Mar 31, 2012
23,578
7,214
Since this is Homework Help and not Homework Done For You, YOU need to make some attempt to work YOUR homework. Show you best attempt and then we can provide hints and suggestions about where you are going wrong and how you might get back on track.

Consider if I gave you a random truth table for a function of four inputs. Could you design a logic circuit that implemented that truth table? If so, can you apply that concept to this problem?

3. ### Mora Thread Starter New Member

Apr 26, 2017
2
0
Hey,

Sure I can do 2 truth tables for Y0 and Y1 (Yes?) , I thought maybe I can use other components (like mux,adder..) and not only logic gates.

Just to say, I don't want you to do my homework.. Hints will help me the solve it .

4. ### WBahn Moderator

Mar 31, 2012
23,578
7,214
What are Y0 and Y1? If you are going to use a term (or signal name), you really need to define what it is. Don't make your audience guess -- engineering is not about guessing.

There are a number of ways to solve a problem like this, ranging from a look-up table to a sequential state machine and several approaches in between. For instance, if you want to consider using an adder, describe how the adder would be helpful in solving the problem.

We have no idea what you have learned or what topics are fair game for this particular problem in this particular course, which is a big reason why it works best for you to show your best attempt -- it provides us with a lot of useful information about the context in which you are solving the problem and about the skill level you are bringing to the table.

5. ### dl324 AAC Fanatic!

Mar 30, 2015
7,963
1,901
Start by drawing a truth table.

EDIT: And the complete text of the problem. How do you handle the situation where multiple bits are set?

Last edited: Apr 26, 2017
6. ### WBahn Moderator

Mar 31, 2012
23,578
7,214
I think that's conceptually well defined -- he is to report the position of the "first" bit that is set.

But there is the question of which end the bit positions are numbered. Usually (and it's the guessing game, again) the lsb is considered position 0. The TS really needs to confirm that, though.

7. ### RBR1317 Senior Member

Nov 13, 2010
417
81
Since the requirement is to design for indication of SET bits, if there are no bits set, ie. '0000', will that be considered a "don't care" condition?

8. ### WBahn Moderator

Mar 31, 2012
23,578
7,214
More than likely, since the third output provides the information needed to know that whatever the other two bits say is meaningless.