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


沒有留言:

張貼留言

2026 作業3 RFID+ Telegram 練習

 2026 作業3  RFID+ Telegram  練習 (Wokwi 與 Telegram 二者溝通訊息反映比較慢 ) 歡迎 Alex 使用 RFID 控制系統 /on : 開啟 LED /off : 關閉 LED /flash : 閃爍模式 /timer : 開啟 5 秒 ...