2021年4月23日 星期五

HBLbits_Verilog Basic_Popcount3

 HBLbits_Verilog Basic_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.



module top_module( 
    input [2:0] in,
    output [1:0] out );
    
    reg [1:0]temp;
    integer i;
    always @(*) begin 
        temp=2'd0;
    for (i=0;i<=2;i=i+1) begin
            temp=temp+in[i];
    end
    end
    assign out=temp;
endmodule

沒有留言:

張貼留言

2024產專班 作業2 (純模擬)

2024產專班 作業2  (純模擬) 1) LED ON,OFF,TIMER,FLASH 模擬 (switch 控制) 2)RFID卡號模擬 (buttom  模擬RFID UID(不從ESP32) Node-Red 程式 [{"id":"d8886...