仿真已保存的RTL并保存结果
保存有界RTL仿真请求,对其进行准入检查和预检,运行后在项目中存储、列出并重新打开结果。
在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检查请求的结构和限制,返回altifigence.rtl.simulation-admission.v1,其中admitted为true;对于此请求,它报告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回执,包含预检结果、事件步进跟踪、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。
对于后面跟着ID的RTL artifact entry does not exist:,请从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。