~ruther/vhdl-vunit-template

6bdd527bbcc83d4f1e36a52260355b0810f5fe3d — Rutherther 5 months ago
Initial commit
8 files changed, 296 insertions(+), 0 deletions(-)

A .envrc
A .gitignore
A flake.lock
A flake.nix
A poetry.lock
A pyproject.toml
A run.py
A vhdl_ls.toml
A  => .envrc +1 -0
@@ 1,1 @@
use flake

A  => .gitignore +20 -0
@@ 1,20 @@
.DS_Store
.idea
*.log
tmp/

work/
out/
sim/
.direnv/

__pycache__/
vunit_out/

synth_1/
utils_1/
impl_1/

stopwatch.runs/
stopwatch.hw/
stopwatch.cache/

A  => flake.lock +155 -0
@@ 1,155 @@
{
  "nodes": {
    "flake-utils": {
      "inputs": {
        "systems": "systems"
      },
      "locked": {
        "lastModified": 1726560853,
        "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "nix-github-actions": {
      "inputs": {
        "nixpkgs": [
          "poetry2nix",
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1720066371,
        "narHash": "sha256-uPlLYH2S0ACj0IcgaK9Lsf4spmJoGejR9DotXiXSBZQ=",
        "owner": "nix-community",
        "repo": "nix-github-actions",
        "rev": "622f829f5fe69310a866c8a6cd07e747c44ef820",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "repo": "nix-github-actions",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1728279793,
        "narHash": "sha256-W3D5YpNrUVTFPVU4jiEiboaaUDShaiH5fRl9aJLqUnU=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "f85a2d005e83542784a755ca8da112f4f65c4aa4",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixpkgs-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs_2": {
      "locked": {
        "lastModified": 1728228884,
        "narHash": "sha256-E9JaDKGi21oUypH0P9881lbkhi6USNJ6XL2tFzU5uuE=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "ff0da78cfd41aa1784910ce1fea89119822013ce",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-unstable-small",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "poetry2nix": {
      "inputs": {
        "flake-utils": "flake-utils",
        "nix-github-actions": "nix-github-actions",
        "nixpkgs": "nixpkgs_2",
        "systems": "systems_2",
        "treefmt-nix": "treefmt-nix"
      },
      "locked": {
        "lastModified": 1728266256,
        "narHash": "sha256-RefXB9kqYch6uGT+mo6m3KTbNerfbDYz+EqkLb6YBbs=",
        "owner": "nix-community",
        "repo": "poetry2nix",
        "rev": "8e965fd42c0da4357c53d987bc62b54a954424da",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "repo": "poetry2nix",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "nixpkgs": "nixpkgs",
        "poetry2nix": "poetry2nix"
      }
    },
    "systems": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "owner": "nix-systems",
        "repo": "default",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "github"
      },
      "original": {
        "owner": "nix-systems",
        "repo": "default",
        "type": "github"
      }
    },
    "systems_2": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "owner": "nix-systems",
        "repo": "default",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "github"
      },
      "original": {
        "id": "systems",
        "type": "indirect"
      }
    },
    "treefmt-nix": {
      "inputs": {
        "nixpkgs": [
          "poetry2nix",
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1727984844,
        "narHash": "sha256-xpRqITAoD8rHlXQafYZOLvUXCF6cnZkPfoq67ThN0Hc=",
        "owner": "numtide",
        "repo": "treefmt-nix",
        "rev": "4446c7a6fc0775df028c5a3f6727945ba8400e64",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "treefmt-nix",
        "type": "github"
      }
    }
  },
  "root": "root",
  "version": 7
}

A  => flake.nix +49 -0
@@ 1,49 @@
{
  description = "NSV stopwatch";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    poetry2nix.url = "github:nix-community/poetry2nix";
  };

  outputs = { self, poetry2nix, nixpkgs }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
      inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryPackages defaultPoetryOverrides;
      poetryEnv = mkPoetryPackages {
        projectDir = ./.;
        python = pkgs.python311;
        overrides = defaultPoetryOverrides.extend
          (self: super: {
            vunit-hdl = super.vunit-hdl.overridePythonAttrs(
              attrs: {
                buildInputs = (attrs.buildInputs or []) ++ [ super.setuptools ];
              }
            );
          });
      };
      vhdl-toolchain = pkgs.symlinkJoin {
        name = "vhdl-toolchain";
        meta.mainProgram = "nvc";
        paths = [
          pkgs.ghdl
          pkgs.nvc
          poetryEnv.python
          poetryEnv.poetryPackages
        ];
      };
    in {
      packages.${system}.default = vhdl-toolchain;

      devShells.${system}.default = pkgs.mkShell {
        nativeBuildInputs = [
          vhdl-toolchain
          pkgs.vhdl-ls
          pkgs.gtkwave
        ];

        VUNIT_SIMULATOR = "nvc";
      };
    };
}

A  => poetry.lock +30 -0
@@ 1,30 @@
# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.

[[package]]
name = "colorama"
version = "0.4.6"
description = "Cross-platform colored terminal text."
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
files = [
    {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},
    {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
]

[[package]]
name = "vunit-hdl"
version = "4.7.0"
description = "VUnit is an open source unit testing framework for VHDL/SystemVerilog."
optional = false
python-versions = ">=3.6"
files = [
    {file = "vunit_hdl-4.7.0.tar.gz", hash = "sha256:a25fb991babd2ea851966e0dbdc5f4d8f649ab3e650e3012983b29fd5d18f22d"},
]

[package.dependencies]
colorama = "*"

[metadata]
lock-version = "2.0"
python-versions = "^3.11"
content-hash = "972ad9ede03323707207a688c81bc344c7c1fa90da26153adfaa77f5c4bf89fa"

A  => pyproject.toml +15 -0
@@ 1,15 @@
[tool.poetry]
name = "stopwatch"
version = "0.0.1"
description = "Project for NSV course, simple stopwatch"
authors = ["Frantisek Bohacek <bohacfr2@fel.cvut.cz>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
vunit-hdl = "^4.7.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

A  => run.py +16 -0
@@ 1,16 @@
#!/usr/bin/env python3

from vunit import VUnit
from pathlib import Path

vu = VUnit.from_argv(compile_builtins = False)

vu.add_vhdl_builtins()

testbench_lib = vu.add_library('PROJECT_tb')
testbench_lib.add_source_files(Path(__file__).parent / 'testbench/**/*.vhd')

stopwatch_lib = vu.add_library('PROJECT')
stopwatch_lib.add_source_files(Path(__file__).parent / 'src/**/*.vhd')

vu.main()

A  => vhdl_ls.toml +10 -0
@@ 1,10 @@
[libraries]
PROJECT.files = [
  'src/*.vhd',
  'src/**/*.vhd'
]

PROJECT_tb.files = [
  'testbench/*.vhd',
  'testbench/**/*.vhd'
]

Do not follow this link