VHDL Order 0s and 1s

Status
Not open for further replies.

SGTheDreamer

New Member
Hey guys! I need to do something on VHDL.

The problems is this: I have a 8 bit input, and i have to order the bits of it.
The zeros to the right and the Ones to the left.
Example :
input <= "01100011"
output<= "11110000"
I need to count the number of zeros or ones but without foor loop.
With foor loop its something like this:
for i in 0 to 7 loop
if input(i) = '1' then
count <= count + 1;
end loop;
but i have to do it WITHOUT that sentence.
If you guys could give me ideas, I ll be so happy.
Nice day.
 
Here is a 32 bit implementation from StackExchange

C:
int CountOnesFromInteger(uint32_t i)
{
    i = i -((i >>1) & 0x55555555);
    i =(i & 0x33333333)+((i >>2) & 0x33333333);
    return(((i +(i >>4))& 0x0F0F0F0F)* 0x01010101)>>24;
}

It would be easy to run as 8 bit!!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…