diff --git a/.gitmodules b/.gitmodules index 016d0c0..d1448a0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,5 +3,5 @@ url = https://git.vlab.cse.kyutech.ac.jp/stefan/kyupy.git branch = devel [submodule "circuits/picorv32"] - path = circuits/picorv32 + path = picorv32 url = git@github.com:s-holst/picorv32.git diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..e4fba21 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/circuits/picorv32 b/circuits/picorv32 deleted file mode 160000 index d438ffd..0000000 --- a/circuits/picorv32 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d438ffd49054288dc6d025e0a0ad2ae3cc1cfe1f diff --git a/kyupy b/kyupy index f0b55ee..c4aecbd 160000 --- a/kyupy +++ b/kyupy @@ -1 +1 @@ -Subproject commit f0b55eed271941db16687dbc625a18ef2e96f25d +Subproject commit c4aecbd6c94e86a18a3a7faab14789e84af61280 diff --git a/main.py b/main.py new file mode 100755 index 0000000..05247de --- /dev/null +++ b/main.py @@ -0,0 +1,24 @@ +#!/usr/bin/env -S uv run + +from pathlib import Path +from kyupy import verilog +from kyupy.techlib import SKY130 + +def path_for(circuit: str): + import subprocess + return Path(subprocess.check_output( + ["nix", "build", "--print-out-paths", "--no-link", + f"github:s-holst/benchmark-circuits#{circuit}" ], + text=True, + ).strip()) + +def verilog_nl_path_for(circuit: str): + return next(path_for(circuit).glob("*/nl/*.nl.v")) + +def main(): + c = verilog.load(verilog_nl_path_for("picorv32-sky130"), tlib=SKY130) + c.resolve_tlib_cells(SKY130) + for kind, count in sorted(c.stats.items()): print(f'{kind:10s} {count}') + +if __name__ == "__main__": + main() diff --git a/picorv32 b/picorv32 new file mode 160000 index 0000000..cf92946 --- /dev/null +++ b/picorv32 @@ -0,0 +1 @@ +Subproject commit cf92946d63004dc398df307ef44adce5505f65e2 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..17a8ce4 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,16 @@ +[project] +name = "infield" +version = "0.1.0" +description = "Add your description here" +requires-python = ">=3.12,<3.14" +dependencies = [ + "kyupy", +] + +[tool.uv.workspace] +members = [ + "kyupy", +] + +[tool.uv.sources] +kyupy = { workspace = true, editable = true } diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..ea5be98 --- /dev/null +++ b/shell.nix @@ -0,0 +1,38 @@ +# +# This file defines a development shell containing: +# - hardware synthesis and simulation tools +# - riscv32 cross-compiling toolchain +# +# Enable this shell by calling 'nix-shell' in the same directory as this file. +# + +let + nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/release-25.11"; + pkgs = (import nixpkgs {}).pkgsCross.riscv32-embedded; +in + +# callPackage is needed due to https://github.com/NixOS/nixpkgs/pull/126844 +pkgs.pkgsStatic.callPackage ({ pkgs }: pkgs.mkShell { + + # these tools run on the build platform, but are configured to target the host platform + nativeBuildInputs = with pkgs; [ pkg-config file ]; + + # libraries needed for the host platform + buildInputs = with pkgs; [ zlib ]; + + # tools running on build platform and target the build platform + depsBuildBuild = with pkgs; [ + python3 + gcc + yosys + sby + nextpnr + arachne-pnr + icestorm + z3 + boolector + yices + iverilog + verilator + ]; +}) {} \ No newline at end of file