Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ jobs:
run: |
util/clang_tidy.py

- name: Tool schema validation
run: |
util/tool_schema_validate.py

verilator-test:
runs-on: ["self-hosted", "nixos", "X64"]
needs: lint-check
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ scratch/

# SD card image file
sd.img

# JSON schema
tool_schema.json
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ dependencies = [
"dvsim>=1.33",
"svgwrite>=1.4.3",
"pyelftools>=0.32",
# Tool schema validation.
"jsonschema>=4.26.0",
"types-jsonschema>=4.26.0",
]

[tool.setuptools]
Expand Down
34 changes: 34 additions & 0 deletions tool_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"name": "FuseSoC",
"vendor": "olofk",
"version": "2.4.3",
"source-url": "https://github.com/olofk/fusesoc",
"doc-url": "https://fusesoc.readthedocs.io/en/stable/index.html",
"comment": "FuseSoC is a build system for digital hardware."
},
{
"name": "Jasper",
"vendor": "Cadence",
"version": "2025.09p002",
"comment": "Formal verification."
},
{
"name": "Verilator",
"vendor": "Veripool",
"version": "v5.040",
"comment": "Open source simulation tool."
},
{
"name": "Vivado",
"vendor": "Xilinx",
"version": "v2021.1",
"comment": "Used to build bitstreams for Genesys 2."
},
{
"name": "Xcelium",
"vendor": "Cadence",
"version": "24.03-s007",
"comment": "Provides xrun for simulations and is used to run our full UVM verification environment."
}
]
40 changes: 40 additions & 0 deletions util/tool_schema_validate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python
# Copyright lowRISC contributors (COSMIC project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

import jsonschema

try:
import json
import pathlib
import urllib.error
import urllib.request

url_string = ('https://raw.githubusercontent.com/'
'marnovandermaas/tool-schema/refs/'
'heads/main/tool_schema.json')

with urllib.request.urlopen(url_string) as url:
schema = json.loads(url.read())

with pathlib.Path('tool_data.json').open() as valid_data_file:
tool_data = json.load(valid_data_file)
except FileNotFoundError as err:
print('Error: The tool data file was not found.')
raise SystemExit(1) from err
except json.JSONDecodeError as err:
print('Error: Failed to decode JSON from the file.')
raise SystemExit(2) from err
except urllib.error.URLError as err:
print('Failed to fetch tool schema.')
raise SystemExit(3) from err

try:
jsonschema.validate(instance=tool_data, schema=schema)
except jsonschema.ValidationError as err:
print('Tool data is invalid according to the schema.')
raise SystemExit(10) from err

# If we get here the tool data has successfully been validated.
raise SystemExit(0)
Loading