Altifigence Academy

21 / 36 · 實作

計數器模擬實作

觀察重設後的遞增與回繞。

準備範例

準備 Digital Design Studio Desktop 專案及執行權限。將各範例分別存入獨立資料夾的 rtl/top.sv。

rtl/top.sv
module top (
    input logic clk,
    input logic rst,
    output logic [1:0] count
);
    // Active-high synchronous reset: sampled only at the rising clock edge.
    always_ff @(posedge clk)
        if (rst) count <= 2'b00;
        else count <= count + 2'b01;
endmodule

執行範例

在 New analysis 選擇 Two-state single-clock v1,Clock port 設為 clk、週期 1000ps。使用下列值執行 Preflight,再執行 Run RTL simulation 並比較結果。

暫存器初始值(LSB 優先)
[true,true]
重設埠
rst · 高有效 · 1 週期
最大週期數/時間
5 / 5000ps

模擬輸入

此檔案設定各時間點的電路輸入值。展開檔名可查看內容,也可下載用於實作。

比較結果

5 週期後 count=00。於 500、1500、2500、3500、4500ps 應觀察到 00→01→10→11→00。

本實作使用二態、單時脈 RTL。請勿加入 #delay、initial 或 X/Z 測試平台。學習進度不代表已驗證模擬器執行。

此選擇適用於本瀏覽器,隨時可從頁尾變更。