29 / 36 · 實作
移位暫存器模擬實作
同步追蹤序列輸入與 q。
單元可免費閱讀,註冊課程即可儲存學習進度。
準備範例
準備 Digital Design Studio Desktop 專案及執行權限。將各範例分別存入獨立資料夾的 rtl/top.sv。
module top (
input logic clk,
input logic rst,
input logic din,
output logic [2:0] q
);
// Old q[1:0] and din are captured together at each rising edge.
always_ff @(posedge clk)
if (rst) q <= 3'b000;
else q <= {q[1:0], din};
endmodule
執行範例
在 New analysis 選擇 Two-state single-clock v1,Clock port 設為 clk、週期 1000ps。使用下列值執行 Preflight,再執行 Run RTL simulation 並比較結果。
- 暫存器初始值(LSB 優先)
- [false,false,false]
- 重設埠
- rst · 高有效 · 1 週期
- 最大週期數/時間
- 5 / 5000ps
模擬輸入
此檔案設定各時間點的電路輸入值。展開檔名可查看內容,也可下載用於實作。
[
{
"inputs": {
"din": [
false
]
}
},
{
"inputs": {
"din": [
true
]
}
},
{
"inputs": {
"din": [
false
]
}
},
{
"inputs": {
"din": [
true
]
}
},
{
"inputs": {
"din": [
true
]
}
}
]
比較結果
5 週期後 q=011。上升緣序列為 000→001→010→101→011。
本實作使用二態、單時脈 RTL。請勿加入 #delay、initial 或 X/Z 測試平台。學習進度不代表已驗證模擬器執行。
✓ 已學習