A good way to encode a 1024 one-hot vector into binary?

Discussion in 'VHDL' started by Anthony J Bybell, Jan 28, 2005.

1. Anthony J BybellGuest

> I have a 1024 one-hot input that I am trying to encode. I've looked at
> examples converting the 1024 to an unsigned integer, but 2^1024 seems
> to not be working with the synthesis tool. I'm wondering if anyone has
> a good loop for encoding a one-hot number without sending the whole
> thing to an integer.

You didn't give any design constraints such as combinatorial only, or
how much latency to get to the result.

For a simple solution, think of what those bits represent in a
position sense. Let's try one-hot for 8 bits, the same applies for
1024:

01234567
aaaa enc[2] = v[4] OR v[5] OR v[6] OR v[7]
bb bb enc[1] = v[2] OR v[3] OR v[6] OR v[7]
c c c c enc[0] = v[1] OR v[3] OR v[5] OR v[7]

....likewise you can nor across the zero bits. 1024 bits to encode is
quite excessive though. In the very least, even a naive solution
stepping through each input serially and comparing it to '1' is going
to burn a lot of gates. Why are you trying to do this?

-t

Anthony J Bybell, Jan 28, 2005