模擬已儲存的RTL並保留結果
儲存有上限的RTL模擬請求,以admit和preflight檢查後執行,再於專案中儲存、列出並重新開啟結果。
在Linux上使用Altifigence CLI 0.1.9,透過隨附的RTL引擎模擬已儲存的SystemVerilog。admit、preflight與run模擬命令各自會讀取專案內的一個請求檔案並輸出JSON。若要讀取四值多時脈模擬合約,請執行alti rtl simulate-v2 capabilities。
儲存模擬請求
建立專案資料夾,並將此請求以sim.json儲存在其中。請確實使用這四個頂層鍵。請求包含SystemVerilog原始碼、時脈埠與週期、選用的重設、暫存器初始值,以及每個週期一個輸入向量。
mkdir -p "$HOME/alti-projects/demo-project"
PROJECT="$(cd "$HOME/alti-projects/demo-project" && pwd -P)"{
"schema": "altifigence.rtl.operation-request.v1",
"version": 1,
"operationId": "altifigence.rtl.simulate.v1",
"request": {
"top": "top",
"sources": [
{
"path": "workspace/top.sv",
"source": "module top(\n input logic clk,\n input logic rst,\n input logic d,\n output logic q\n);\n always_ff @(posedge clk or posedge rst)\n if (rst) q <= 1'b0;\n else q <= d;\nendmodule\n"
}
],
"clock": {
"port": "clk",
"periodPs": 1000
},
"initialRegisterValues": [
false
],
"cycles": [
{
"inputs": {
"d": [
false
]
}
},
{
"inputs": {
"d": [
true
]
}
},
{
"inputs": {
"d": [
true
]
}
},
{
"inputs": {
"d": [
false
]
}
}
],
"limits": {
"maxCycles": 4,
"maxTimePs": 4000
},
"reset": {
"port": "rst",
"activeLevel": "active_high",
"assertCycles": 1
}
}
}請為每個週期提供除時脈與重設以外的每個頂層輸入,由最低有效位元開始。引擎會驅動時脈,並在前assertCycles個週期使重設有效。請將clock.periodPs維持在2到1000000000之間。將limits.maxCycles設為從週期數起至32768為止的值,並將limits.maxTimePs設為從週期數 × periodPs起至1000000000000為止的值。請求檔案最大可達272629760位元組。
執行前先檢查請求
alti rtl simulate admit --project "$PROJECT" sim.json
alti rtl simulate preflight --project "$PROJECT" sim.json > "$PROJECT/preflight.json"
jq -c '[.outputPorts[].name]' "$PROJECT/preflight.json"請確認每個命令的結束狀態皆為0。Admit會檢查請求的結構與限制,並傳回admitted為true的altifigence.rtl.simulation-admission.v1;對此請求,它會回報cycleCount為4、transitionStepCount為8、simulatedTimePs為4000。Preflight還會將原始碼合成為邏輯網表,並傳回含有輸入埠、輸出埠與暫存器的altifigence.rtl.simulation-preflight.v1。jq這一行會輸出:
["q"]Admit與preflight是預先檢查。模擬只會透過run執行。
執行模擬
alti rtl simulate run --project "$PROJECT" sim.json > "$PROJECT/result.json"
jq -c '.artifact.payload.summaryArtifact.payload.finalOutputsLsb0' "$PROJECT/result.json"
jq -r '.artifact.payload.waveformArtifact.payload' "$PROJECT/result.json" > "$PROJECT/wave.vcd"請確認結束狀態為0。結果的結構描述為altifigence.rtl.operation-result.v1,operationId為altifigence.rtl.simulate.v1。其成品是一份altifigence.rtl.simulation-receipt.v1回條,內含preflight、事件步進追蹤、VCD波形、摘要與來源紀錄。對此請求,最終輸出為:
{"q":[false]}隨附的引擎會合成設計,並以其自有的二值事件步進模擬器執行。wave.vcd使用1ps時間刻度。
檢查並合成原始檔
將相同的模組儲存為專案檔案,然後輸出其電路圖並加以合成。原始檔路徑是相對於專案的路徑。
mkdir -p "$PROJECT/rtl"
jq -r '.request.sources[0].source' "$PROJECT/sim.json" > "$PROJECT/rtl/top.sv"
alti rtl schematic --project "$PROJECT" --top top rtl/top.sv > "$PROJECT/schematic.json"
jq -c '{schema, source}' "$PROJECT/schematic.json"請確認結束狀態為0。jq這一行會輸出:
{"schema":"alti-rtl-schematic.v1","source":"saved-files"}該文件還包含topModule、modules、instances、nets、connections、diagnostics與unsupported。其status為complete或partial;failed的文件會以結束狀態1結束。
alti rtl synth --project "$PROJECT" --top top rtl/top.sv > "$PROJECT/synth.json"
jq -c '{report: .report.schema, netlist: .netlist.schema, cells: .report.stats.cells_by_kind}' "$PROJECT/synth.json"請確認結束狀態為0。Synth會輸出邏輯網表及其合成報告。對此模組,jq這一行會輸出:
{"report":"rtl-synth-report-2","netlist":"logic-netlist-2","cells":{"dff_posedge_async_reset":1}}若synth因alti-rtl: synth requires at least one SystemVerilog file而停止,請在選項之後加入原始檔路徑,例如rtl/top.sv。
保留並重新開啟結果
alti rtl artifact store --project "$PROJECT" result.json > "$PROJECT/manifest.json"
ENTRY_ID="$(jq -r '.entryId' "$PROJECT/manifest.json")"
alti rtl artifact list --project "$PROJECT"
alti rtl artifact show --project "$PROJECT" "$ENTRY_ID" > "$PROJECT/reopened.json"Store會驗證完整的結果,並將其寫入專案的.altifigence/artifacts/rtl/之下。其altifigence.rtl.artifact-manifest.v1資訊清單包含entryId(已儲存結果的SHA-256)以及relativePath的results/<entryId>.json。List會輸出每份資訊清單;show會輸出已儲存的結果JSON。結果最大可達67108864位元組。
處理錯誤
若出現RTL simulation request must be the exact altifigence.rtl.simulate.v1 envelope,請讓檔案恰好包含鍵schema、version、operationId與request,其值如上所示。
若出現RTL simulation request must be a normalized project-relative path,請傳入相對於專案的路徑,例如sim.json,開頭不可有./或/。
引擎會在alti-rtl:之後輸出請求錯誤,並以結束狀態2結束。若出現RTL simulation resource limit exceeded for stimulus cycles: observed 5, maximum 4,請將limits.maxCycles提高到週期數,然後再次執行admit。
若出現RTL simulation resource limit exceeded for simulated time ps: observed 5000, maximum 4000,請將limits.maxTimePs提高到至少為週期數 × clock.periodPs。
若出現RTL artifact entry does not exist:後接一個ID,請從alti rtl artifact list複製一個entryId,然後再次執行show。
檢查與分析已儲存的原始檔
使用上一節已儲存的rtl/top.sv。檢查其診斷、檢查器涵蓋範圍與階層,然後讀取原生符號分析。請將執行選項放在編譯器子命令之後。
alti rtl compile check --runner local --project "$PROJECT" -- rtl/top.sv --format json
alti rtl compile coverage --runner local --project "$PROJECT" -- rtl/top.sv --format json
alti rtl compile hierarchy --runner local --project "$PROJECT" -- rtl/top.sv --top top --format json
alti rtl analysis --project "$PROJECT" rtl/top.sv > "$PROJECT/analysis.json"
jq -c '{schemaVersion}' "$PROJECT/analysis.json"{"schemaVersion":"sv-symbols.v2"}相容用的拼寫synthesize也會執行本機合成器。請在--之後傳入引擎引數:
alti rtl synthesize --runner local --project "$PROJECT" -- --top top rtl/top.sv > "$PROJECT/synth-compat.json"若出現RTL compiler execution options must follow the explicit subcommand,請依上方所示,將--runner local與--project放在check、coverage或hierarchy之後。
將組合邏輯網表映射至單元
儲存另一個組合邏輯範例及一個小型Liberty程式庫。合成其網表,然後將每個邏輯單元映射至功能等效的程式庫單元。
cat > "$PROJECT/rtl/map-example.sv" <<'SV'
module top(input logic a, input logic b, output logic y);
logic n;
assign n = a & b;
assign y = ~n;
endmodule
SV
cat > "$PROJECT/map-example.lib" <<'LIB'
library (neutral) {
cell (AND2) {
area : 2.0;
pin (A) { direction : input; }
pin (B) { direction : input; }
pin (Y) { direction : output; function : "A & B"; }
}
cell (INV) {
area : 1.0;
pin (A) { direction : input; }
pin (Y) { direction : output; function : "!A"; }
}
}
LIB
alti rtl synth --project "$PROJECT" --top top --netlist-only rtl/map-example.sv > "$PROJECT/map-netlist.json"
alti rtl map --project "$PROJECT" --netlist map-netlist.json --liberty map-example.lib > "$PROJECT/map-report.json"
jq -c '{schema, mapped_cell_count, total_area}' "$PROJECT/map-report.json"{"schema":"rtl-liberty-direct-map-report-0","mapped_cell_count":2,"total_area":"3.0"}若出現no direct Liberty cell covers generic kind後接單元種類,請提供具有相符布林函式與正值area的程式庫,然後再次執行map命令。
檢查目標選擇及其原始檔
讀取目標分析合約與就緒記錄,然後檢查原始檔套件。准入結果會記錄您的選擇與原始檔摘要。結構預先檢查會傳回診斷、涵蓋範圍與階層產出。
alti rtl target-analysis capabilities
alti rtl target-analysis readiness
jq '{schema:"rtl-source-bundle.v1",sources:[.request.sources[] | {path,text:.source}],roots:[.request.sources[].path],include_dirs:[],defines:[],tops:[.request.top]}' "$PROJECT/sim.json" > "$PROJECT/target-sources.json"
DEADLINE_MS="$(( $(date +%s) * 1000 + 60000 ))"
TARGET_ARGS=(--module top --top top --targets generic-asic --primary-target generic-asic
--tools schematic,evidence --report-detail standard --profile local-example
--cpu-slots 1 --memory-bytes 536870912 --max-wall-time-ms 5000
--deadline-unix-ms "$DEADLINE_MS")
alti rtl target-analysis admit "${TARGET_ARGS[@]}" < "$PROJECT/target-sources.json" > "$PROJECT/target-admission.json"
jq -c '{schema, structuralPreflightAvailable}' "$PROJECT/target-admission.json"
alti rtl target-analysis preflight "${TARGET_ARGS[@]}" < "$PROJECT/target-sources.json" > "$PROJECT/target-preflight.json"
jq -r '.schema' "$PROJECT/target-preflight.json"{"schema":"altifigence.rtl.target-analysis-direct-admission.v1","structuralPreflightAvailable":true}
altifigence.rtl.target-analysis-direct-result.v1local-example是此範例所記錄的設定檔選擇。請讓tops等於請求的--top。若出現target Analysis source bundle is invalid: source/root/include/define/top cardinality is invalid,請檢查sources與roots是否包含原始檔,且tops是否包含該唯一的頂層名稱。
執行四值模擬合約
以帶時間的四值請求重複使用sim.json中的原始碼。值為字串0、1、X與Z,由最低有效位元開始。此範例使用一個時脈、一個重設,以及帶時間的輸入排程。
jq '{schema:.schema,version:1,operationId:"altifigence.rtl.simulate.v2",request:{
top:.request.top,sources:.request.sources,
clocks:[{port:"clk",periodPs:1000,phasePs:500}],
resets:[{port:"rst",activeLevel:"active_high",changes:[
{timePs:0,valueLsb0:["1"]},{timePs:1000,valueLsb0:["0"]}]}],
inputSchedules:[{port:"d",changes:[
{timePs:0,valueLsb0:["0"]},{timePs:1000,valueLsb0:["1"]}]}],
initialRegisterValues:["0"],
limits:{maxCyclesPerClock:4,maxTimePs:4000,maxEvents:64}
}}' "$PROJECT/sim.json" > "$PROJECT/sim-v2.json"
alti rtl simulate-v2 admit --project "$PROJECT" sim-v2.json > "$PROJECT/v2-admission.json"
alti rtl simulate-v2 preflight --project "$PROJECT" sim-v2.json > "$PROJECT/v2-preflight.json"
alti rtl simulate-v2 run --project "$PROJECT" sim-v2.json > "$PROJECT/v2-result.json"
jq -r '.schema' "$PROJECT/v2-admission.json" "$PROJECT/v2-preflight.json"
jq -r '.artifact.payload.schema' "$PROJECT/v2-result.json"altifigence.rtl.simulation-admission.v2
altifigence.rtl.simulation-preflight.v2
altifigence.rtl.simulation-receipt.v2請確認每個步驟的結束狀態皆為0。准入會檢查帶時間的請求;預先檢查會準備其合成後的網表;run會產生追蹤、波形、摘要與來源紀錄。請使用偶數的periodPs,以及小於週期的phasePs。