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

A

Anthony J Bybell

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top