Mô phỏng RTL đã lưu và giữ kết quả

Lưu một yêu cầu mô phỏng RTL có giới hạn, admit và preflight yêu cầu đó, chạy nó, rồi lưu, liệt kê và mở lại kết quả trong dự án.

Dùng Altifigence CLI 0.1.9 trên Linux để mô phỏng SystemVerilog đã lưu bằng engine RTL đi kèm. Mỗi lệnh mô phỏng admit, preflight và run đọc một tệp yêu cầu bên trong dự án và in JSON. Để đọc hợp đồng mô phỏng bốn trạng thái đa xung nhịp, chạy alti rtl simulate-v2 capabilities.

Lưu yêu cầu mô phỏng

Tạo thư mục dự án và lưu yêu cầu này vào đó với tên sim.json. Dùng đúng bốn khóa cấp cao nhất này. Yêu cầu chứa mã nguồn SystemVerilog, cổng và chu kỳ xung nhịp, reset tùy chọn, các giá trị ban đầu của thanh ghi và một vector đầu vào cho mỗi chu kỳ.

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
    }
  }
}

Cung cấp mọi đầu vào cấp cao nhất trừ xung nhịp và reset trong từng chu kỳ, bit có trọng số thấp nhất trước. Engine điều khiển xung nhịp và kích hoạt reset trong assertCycles chu kỳ đầu tiên. Giữ clock.periodPs từ 2 đến 1000000000. Đặt limits.maxCycles từ số chu kỳ đến tối đa 32768, và limits.maxTimePs từ số chu kỳ × periodPs đến tối đa 1000000000000. Tệp yêu cầu có thể lớn tới 272629760 byte.

Kiểm tra yêu cầu trước khi chạy

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"

Xác nhận trạng thái thoát của từng lệnh là 0. Admit kiểm tra hình dạng và giới hạn của yêu cầu rồi trả về altifigence.rtl.simulation-admission.v1 với admitted là true; với yêu cầu này, nó báo cycleCount 4, transitionStepCount 8 và simulatedTimePs 4000. Preflight còn tổng hợp mã nguồn thành netlist logic và trả về altifigence.rtl.simulation-preflight.v1 cùng các cổng đầu vào, cổng đầu ra và thanh ghi. Dòng jq in ra:

["q"]

Admit và preflight là các bước kiểm tra trước. Mô phỏng chỉ chạy với run.

Chạy mô phỏng

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"

Xác nhận trạng thái thoát là 0. Kết quả có lược đồ altifigence.rtl.operation-result.v1 và operationId altifigence.rtl.simulate.v1. Sản phẩm đầu ra của nó là biên nhận altifigence.rtl.simulation-receipt.v1 gồm preflight, trace event-step, dạng sóng VCD, bản tóm tắt và nguồn gốc. Với yêu cầu này, đầu ra cuối cùng là:

{"q":[false]}

Engine đi kèm tổng hợp thiết kế và chạy nó bằng trình mô phỏng event-step hai trạng thái của riêng nó. wave.vcd dùng timescale 1ps.

Kiểm tra và tổng hợp tệp nguồn

Lưu cùng mô-đun đó thành một tệp dự án, rồi xuất sơ đồ của nó và tổng hợp nó. Đường dẫn tệp nguồn tương đối so với dự án.

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"

Xác nhận trạng thái thoát là 0. Dòng jq in ra:

{"schema":"alti-rtl-schematic.v1","source":"saved-files"}

Tài liệu cũng chứa topModule, modules, instances, nets, connections, diagnostics và unsupported. status của nó là complete hoặc partial; tài liệu failed thoát với trạng thái 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"

Xác nhận trạng thái thoát là 0. Synth in ra netlist logic và báo cáo tổng hợp của nó. Với mô-đun này, dòng jq in ra:

{"report":"rtl-synth-report-2","netlist":"logic-netlist-2","cells":{"dff_posedge_async_reset":1}}

Nếu synth dừng với alti-rtl: synth requires at least one SystemVerilog file, hãy thêm đường dẫn tệp nguồn, chẳng hạn rtl/top.sv, sau các tùy chọn.

Lưu và mở lại kết quả

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 xác thực toàn bộ kết quả và ghi vào .altifigence/artifacts/rtl/ trong dự án. Manifest altifigence.rtl.artifact-manifest.v1 của nó chứa entryId (SHA-256 của kết quả đã lưu) và relativePath results/<entryId>.json. List in mọi manifest; show in JSON kết quả đã lưu. Một kết quả có thể lớn tới 67108864 byte.

Xử lý lỗi

Với RTL simulation request must be the exact altifigence.rtl.simulate.v1 envelope, hãy để tệp có đúng các khóa schema, version, operationId và request với các giá trị như đã nêu ở trên.

Với RTL simulation request must be a normalized project-relative path, hãy truyền đường dẫn tương đối so với dự án, chẳng hạn sim.json, không có ./ hoặc / ở đầu.

Engine in lỗi yêu cầu sau alti-rtl: và thoát với trạng thái 2. Với RTL simulation resource limit exceeded for stimulus cycles: observed 5, maximum 4, hãy tăng limits.maxCycles lên bằng số chu kỳ rồi chạy lại admit.

Với RTL simulation resource limit exceeded for simulated time ps: observed 5000, maximum 4000, hãy tăng limits.maxTimePs lên ít nhất bằng số chu kỳ × clock.periodPs.

Với RTL artifact entry does not exist: theo sau là một id, hãy sao chép một entryId từ alti rtl artifact list rồi chạy lại show.

Kiểm tra và phân tích các tệp nguồn đã lưu

Dùng tệp rtl/top.sv đã lưu từ phần trước. Kiểm tra các chẩn đoán của nó, xem phạm vi bao phủ của bộ kiểm tra và hệ thống phân cấp, rồi đọc phân tích symbol gốc. Đặt các tùy chọn thực thi sau lệnh con của trình biên dịch.

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"}

Cách viết tương thích synthesize cũng chạy trình tổng hợp cục bộ. Truyền các đối số engine của nó sau --:

alti rtl synthesize --runner local --project "$PROJECT" -- --top top rtl/top.sv > "$PROJECT/synth-compat.json"

Với RTL compiler execution options must follow the explicit subcommand, hãy đặt --runner local và --project sau check, coverage hoặc hierarchy, như minh họa ở trên.

Ánh xạ netlist tổ hợp sang các cell

Lưu một ví dụ tổ hợp riêng và một thư viện Liberty nhỏ. Tổng hợp netlist của nó, rồi ánh xạ mỗi cell logic sang một cell thư viện tương đương về hàm.

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"}

Với no direct Liberty cell covers generic kind theo sau là một loại cell, hãy cung cấp thư viện có hàm Boolean phù hợp và area dương, rồi chạy lại lệnh ánh xạ.

Kiểm tra lựa chọn mục tiêu và các tệp nguồn của nó

Đọc hợp đồng phân tích mục tiêu và bản ghi sẵn sàng, rồi kiểm tra một gói tệp nguồn. Admission ghi lại các lựa chọn của bạn và mã băm tệp nguồn. Preflight cấu trúc trả về các chẩn đoán, phạm vi bao phủ và sản phẩm phân cấp.

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.v1

local-example là lựa chọn hồ sơ được ghi lại trong ví dụ này. Giữ tops bằng --top đã yêu cầu. Với target Analysis source bundle is invalid: source/root/include/define/top cardinality is invalid, hãy kiểm tra rằng sources và roots chứa tệp nguồn và tops chứa đúng tên top đó.

Chạy hợp đồng mô phỏng bốn trạng thái

Dùng lại mã nguồn trong sim.json với một yêu cầu bốn trạng thái có định thời. Các giá trị là chuỗi 0, 1, X và Z, bit có trọng số thấp nhất trước. Ví dụ này dùng một xung nhịp, một reset và một lịch đầu vào có định thời.

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

Xác nhận trạng thái thoát là 0 ở mỗi bước. Admission kiểm tra yêu cầu có định thời; preflight chuẩn bị netlist đã tổng hợp của nó; run tạo trace, dạng sóng, bản tóm tắt và nguồn gốc. Dùng periodPs là số chẵn và phasePs nhỏ hơn chu kỳ.

Các lệnh engine của CLI