Popcount3

Popcount3

A "population count" circuit counts the number of '1's in an input vector. Build a population count circuit for a 3-bit input vector.

solution

1
2
3
4
5
6
7
8
9
10
module top_module( 
input [2:0] in,
output [1:0] out );
always @(*) begin
out = 0;
for (integer i=0;i<3;i++) begin
if (in[i]) out = out + in[i];
end
end
endmodule

Popcount3
http://456-xiao.github.io/2024/09/07/Popcount3/
作者
xyh
发布于
2024年9月7日
许可协议