[RTLLM-p008] Arithmetic/Multiplier/multi_16bit


提交解答


分數: 5
時間限制: 2.0s
記憶體限制: 256M

作者:
題目代碼
題目類型
允許的語言
Verilog

16 位元 Shift-and-Accumulate 乘法器

題目說明

請設計一個名為 multi_16bit 的 Verilog 模組,實作一個使用 Shift-and-Accumulate 演算法的 16 位元無號乘法器。

此模組不是立即輸出結果,而是在 Clock 控制下逐步完成乘法。

當輸入:

start = 1

時開始乘法運算。

完成後:

done = 1

表示乘法結果有效。


模組介面

方向 位元寬度 描述
clk input 1 Clock
rst_n input 1 Active-low Reset
start input 1 啟動乘法
ain input 16 被乘數
bin input 16 乘數
yout output 32 乘法結果
done output 1 完成旗標

設計要求

  • 模組名稱:
multi_16bit
  • 使用 Shift-and-Accumulate 完成:
ain × bin
  • 不可直接使用:
*

運算流程

每個 Clock:

  1. 判斷目前 multiplier bit。
  2. 若 bit 為 1:
product += shifted multiplicand
  1. multiplicand 左移。
  2. multiplier 右移。
  3. 重複 16 次。

完成後:

done = 1

並輸出:

yout

程式設計模板

module multi_16bit (
    input clk,
    input rst_n,
    input start,

    input [15:0] ain,
    input [15:0] bin,

    output [31:0] yout,
    output done
);

    // 在此處填寫您的程式碼

endmodule

評論

目前沒有評論。