Coverage for tsfpga/vivado/simlib.py: 88%
16 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 20:52 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 20:52 +0000
1# --------------------------------------------------------------------------------------------------
2# Copyright (c) Lukas Vik. All rights reserved.
3#
4# This file is part of the tsfpga project, a project platform for modern FPGA development.
5# https://tsfpga.com
6# https://github.com/tsfpga/tsfpga
7# --------------------------------------------------------------------------------------------------
9# Standard libraries
10from pathlib import Path
11from typing import TYPE_CHECKING, Optional
13# Third party libraries
14from vunit.ui import VUnit
16# Local folder libraries
17from .simlib_commercial import VivadoSimlibCommercial
18from .simlib_ghdl import VivadoSimlibGhdl
20if TYPE_CHECKING:
21 # Local folder libraries
22 from .simlib_common import VivadoSimlibCommon
25class VivadoSimlib:
26 """
27 Factory class for getting a Vivado simlib API.
28 """
30 @staticmethod
31 def init(
32 output_path: Path, vunit_proj: VUnit, vivado_path: Optional[Path] = None
33 ) -> "VivadoSimlibCommon":
34 """
35 Get a Vivado simlib API suitable for your current simulator. Uses VUnit mechanism
36 for detecting the simulator currently in use.
38 Will return a :class:`.VivadoSimlibCommon` subclass object.
40 Arguments:
41 output_path: The compiled simlib will be placed here.
42 vunit_proj: The VUnit project that is used to run simulation.
43 vivado_path: Path to Vivado executable. If left out, the default
44 from system ``PATH`` will be used.
45 """
46 simulator_interface = vunit_proj._simulator_class # pylint: disable=protected-access
48 if simulator_interface is None:
49 raise RuntimeError("VUnit found no simulator. Can not proceed.")
51 if simulator_interface.name == "ghdl":
52 return VivadoSimlibGhdl(
53 vivado_path=vivado_path,
54 output_path=output_path,
55 vunit_proj=vunit_proj,
56 simulator_interface=simulator_interface,
57 )
59 return VivadoSimlibCommercial(
60 vivado_path=vivado_path,
61 output_path=output_path,
62 vunit_proj=vunit_proj,
63 simulator_interface=simulator_interface,
64 )