Forum Discussion
Altera_Forum
Honored Contributor
16 years agoto find out the number of "1"
hi,everyone i need to find out the number of "1" in a input (a), now ,i thik i could add every bit of input (a) to get the resut, just like : assign b=a[0]+a[0]+a[1]+a[2]+a[3]+a[4]; ----...
Altera_Forum
Honored Contributor
16 years agoHi,
I don't know Verilog In VHDL, you can use "variable" for counters you can use "function" or "procedure" to find out the number of '1'. This function will be something likefor(i=0;i<IN_WIDTH;i=i+1)
a<=a+data_in;
end