from pathlib import Path

from cocotb_tools.runner import get_runner


ROOT = Path(__file__).resolve().parent
BUILD_DIR = ROOT / "sim_build" / "verilator"


def main() -> None:
    runner = get_runner("verilator")
    runner.build(
        sources=[ROOT / "rtl" / "counter.sv"],
        hdl_toplevel="counter",
        build_dir=BUILD_DIR,
        always=True,
        waves=True,
    )
    runner.test(
        hdl_toplevel="counter",
        test_module="test_counter",
        build_dir=BUILD_DIR,
        test_dir=ROOT,
        waves=True,
    )


if __name__ == "__main__":
    main()
