9 / 36 · 實作
MUX 模擬實作
使用提供的原始碼及輸入檔案比較輸出。
單元可免費閱讀,註冊課程即可儲存學習進度。
準備範例
準備 Digital Design Studio Desktop 專案及執行權限。將各範例分別存入獨立資料夾的 rtl/top.sv。
module top (
input logic clk,
input logic a,
input logic b,
input logic sel,
output logic y,
output logic sampled_y
);
assign y = sel ? b : a;
// Explicit observation register: y remains purely combinational.
// The register makes this design eligible for logic-netlist-1 simulation.
always_ff @(posedge clk) sampled_y <= y;
endmodule
執行範例
在 New analysis 選擇 Two-state single-clock v1,Clock port 設為 clk、週期 1000ps。使用下列值執行 Preflight,再執行 Run RTL simulation 並比較結果。
- 暫存器初始值(LSB 優先)
- [false]
- 重設埠
- 留空
- 最大週期數/時間
- 8 / 8000ps
模擬輸入
此檔案設定各時間點的電路輸入值。展開檔名可查看內容,也可下載用於實作。
[
{
"inputs": {
"a": [
false
],
"b": [
false
],
"sel": [
false
]
}
},
{
"inputs": {
"a": [
false
],
"b": [
false
],
"sel": [
true
]
}
},
{
"inputs": {
"a": [
false
],
"b": [
true
],
"sel": [
false
]
}
},
{
"inputs": {
"a": [
false
],
"b": [
true
],
"sel": [
true
]
}
},
{
"inputs": {
"a": [
true
],
"b": [
false
],
"sel": [
false
]
}
},
{
"inputs": {
"a": [
true
],
"b": [
false
],
"sel": [
true
]
}
},
{
"inputs": {
"a": [
true
],
"b": [
true
],
"sel": [
false
]
}
},
{
"inputs": {
"a": [
true
],
"b": [
true
],
"sel": [
true
]
}
}
]
比較結果
8 週期後 y=1、sampled_y=1。於 3000ps 比較 y=1 與 sampled_y=0。
本實作使用二態、單時脈 RTL。請勿加入 #delay、initial 或 X/Z 測試平台。學習進度不代表已驗證模擬器執行。
✓ 已學習