mirror of
https://github.com/retroSoC/retroSoC.git
synced 2026-11-06 14:55:14 +00:00
- Introduced a comprehensive RTL coding style document at detailing naming conventions, module structure, formatting, and ownership boundaries. - Updated to reference the new coding style document and clarify the python3 /nfs/share/home/miaoyuchi/retroSoC/scripts/check_rtl_style.py --root /nfs/share/home/miaoyuchi/retroSoC \ --profile owned --changed-only --verible-verilog-lint verible-verilog-lint rtl-style-check: owned passed (0 baseline findings) process. - Refactored several RTL modules in to adhere to the new naming conventions for clock and reset signals. - Created to define profiles for owned, verification, and technology RTL sources, including suffixes and linting rules. - Developed to check for compliance with the ownership-aware RTL style rules, focusing on positional connections and legacy constructs. - Added tests in to validate the functionality of the RTL style checker. - Updated to document the new style checking script and its usage.
61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
SCRIPT = ROOT / "scripts/check_rtl_style.py"
|
|
|
|
|
|
def run_style(tmp_path: Path, source: str) -> subprocess.CompletedProcess[str]:
|
|
(tmp_path / "rtl/ip/test.sv").parent.mkdir(parents=True)
|
|
(tmp_path / "rtl/ip/test.sv").write_text(source, encoding="utf-8")
|
|
(tmp_path / "rtl/rtl_style_manifest.json").write_text(
|
|
json.dumps(
|
|
{
|
|
"schema_version": 1,
|
|
"profiles": {
|
|
"owned": {
|
|
"roots": ["rtl/ip"],
|
|
"suffixes": [".sv"],
|
|
"format": "verible",
|
|
"lint": "strict",
|
|
}
|
|
},
|
|
}
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
subprocess.run(["git", "init", "-q", str(tmp_path)], check=True)
|
|
subprocess.run(["git", "-C", str(tmp_path), "add", "."], check=True)
|
|
return subprocess.run(
|
|
[sys.executable, str(SCRIPT), "--root", str(tmp_path), "--profile", "owned"],
|
|
text=True,
|
|
capture_output=True,
|
|
check=False,
|
|
)
|
|
|
|
|
|
def test_owned_style_rejects_positional_connections(tmp_path: Path) -> None:
|
|
result = run_style(
|
|
tmp_path,
|
|
"module test(input logic clk_i, output logic data_o);\n"
|
|
" dffr #(1) u_reg (clk_i, 1'b1, 1'b0, data_o);\n"
|
|
"endmodule\n",
|
|
)
|
|
assert result.returncode == 1
|
|
assert "module-port" in result.stderr
|
|
|
|
|
|
def test_owned_style_allows_named_connections(tmp_path: Path) -> None:
|
|
result = run_style(
|
|
tmp_path,
|
|
"module test(input logic clk_i, output logic data_o);\n"
|
|
" dffr #(1) u_reg (.clk_i(clk_i), .rst_n_i(1'b1), .dat_i(1'b0), .dat_o(data_o));\n"
|
|
"endmodule\n",
|
|
)
|
|
assert result.returncode == 0, result.stderr
|