2021年4月22日 星期四

HBLbits_Verilog Basic_Popcount255

HBLbits_Verilog Basic_Popcount255 

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


module top_module( 
    input [254:0] in,
    output [7:0] out );
    integer i;
    always@(*)begin
        out = 0;
        for(i=0;i<=254;i=i+1)begin
            if (in[i])
                out=out+1;
        end
    end
endmodule


沒有留言:

張貼留言

WOKWI DHT22 & LED , Node-Red + SQLite database

 WOKWI DHT22 & LED , Node-Red + SQLite database Node-Red程式 [{"id":"6f0240353e534bbd","type":"comment&...