#### Shosa

##### Newbie level 3

Hi

How i can find 1's in 32 bits binary number using verilog?

for eg: if 32 bit number is 10110010101100110001110010011000 then i need to shift first three zeroes from lsb in one clock cycle and 11 will take 2 cycles

in short consecutive zeroes should shift in one clock cycle and each 1's will take one clock cycle

somebody suggested me to use casex for 32 cases like

how can use this to find 1's and shift cycles accordingly?

kindly help..

How i can find 1's in 32 bits binary number using verilog?

for eg: if 32 bit number is 10110010101100110001110010011000 then i need to shift first three zeroes from lsb in one clock cycle and 11 will take 2 cycles

in short consecutive zeroes should shift in one clock cycle and each 1's will take one clock cycle

somebody suggested me to use casex for 32 cases like

Code Verilog - [expand] 1 2 3 4 5 6 7 8 casex(abc) 32'bxxxxxxxxxxxxxxxxxxxxxxxxxxxxx10 32'bxxxxxxxxxxxxxxxxxxxxxxxxxxxx100 ... ... upto 32 32'b1000000000000000000000000000000

how can use this to find 1's and shift cycles accordingly?

kindly help..

Last edited by a moderator: