I was asked to design a digital system that receives an 8-bit binary input and outputs the binary position of the third '1' bit from the right (LSB side).
The output should be a 3-bit binary number representing the index (starting from 0 for the rightmost bit).
For example:
Input: 10110011
The '1' bits are at positions 0, 1, 4, and 7 (counting from right to left)
The third '1' from the right is at position 4
Therefore, the output should be: 100 (which is 4 in binary)
If there are fewer than 3 bits set to 1, the output can be zero.
My idea is to design two counters:
The first counter increments every time a '1' bit is detected, starting from the LSB and moving toward the MSB. Once it reaches a count of 3, it activates a signal indicating that the third '1' was found.
The second counter simply increments on each bit position as we scan from LSB to MSB. This counter keeps track of the current bit index.
At the moment when the first counter reaches 3, the value of the second counter (i.e., the current position) is saved as the output. If the third '1' is never found, the output should be 0.
I plan to implement this using basic logic components (e.g., counters and a MUX).
The first counter’s “reached 3” signal will serve as the select input to a MUX.
The MUX will choose between:
the current value of the position counter (if the third '1' was found), or a default value (e.g., 0) if it was not.
I'm struggling with the first part of the counter. I know how to build a circuit that counts the number of 1s in an 8-bit input — it can be done using Full Adders and Half Adders. The problem is how to make it stop once it reaches three 1s, and then output a 1 at that exact moment or output 0 if it didn’t reach that count.
Regarding comments asking for the 8bit counter:




