Hi Vishal,
<
[email protected]> wrote in message
news:
[email protected] ups.com...
> Hi Ben
>
> Thanks a lot for the mail...Yes thermometric representation means a
> sequence of 1s followed by 0s.
> What I need to do here is to count number of 1s in the given vector.
> I need the output to be available as quickly as possible.
I had an interesting idea about this. Given the constraint that the input
vector has no "holes" in it (i.e. you get "11111000000" or "110000000" but
never "111001111"), you can do a very efficient parallel bit-count without
any adders.
First notice this: if you XOR together all the bits, this tells you whether
the bitcount is even (0) or odd (1). That gives you bit 0 of your result.
Now, if you XOR together every second bit, starting with the second bit,
you'll get bit 1 of your result. (When the thermometer reaches '2', the
value goes to 1; when it reaches '4', it goes back to 0; when it reaches
'6', it goes back to 1 again). Here I'm assuming the input vector starts at
1 - this makes more sense, since "1000" = 1, "1100" = 2, "1110" = 3, and so
on.
Carrying this pattern forward, you can XOR together every fourth bit
(starting with the fourth) to get bit 2, every eighth bit to get bit 3, and
so on until you have enough bits to represent the maximum value. The total
size of the circuit is roughly 2N xor gates (where N is the vector length).
The low-order bits take the most logic (and time) to implement. Still, while
a 96-bit XOR operation isn't free, it is pretty cheap and fast in most
technologies. The benefit of this scheme is that there are no carries
involved; each bit can be calculated in parallel, so it can go pretty fast.
Whatever you choose to do, good luck with your design!
-Ben-