[RTLLM-p008] Arithmetic/Multiplier/multi_16bit
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:
- 判斷目前 multiplier bit。
- 若 bit 為 1:
product += shifted multiplicand
- multiplicand 左移。
- multiplier 右移。
- 重複 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
評論