Coverage for tsfpga/vivado/simlib.py: 93%

14 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-07 11:31 +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# -------------------------------------------------------------------------------------------------- 

8 

9# Standard libraries 

10from pathlib import Path 

11from typing import TYPE_CHECKING, Optional 

12 

13# Third party libraries 

14from vunit.ui import VUnit 

15 

16# Local folder libraries 

17from .simlib_commercial import VivadoSimlibCommercial 

18from .simlib_ghdl import VivadoSimlibGhdl 

19 

20if TYPE_CHECKING: 

21 # Local folder libraries 

22 from .simlib_common import VivadoSimlibCommon 

23 

24 

25class VivadoSimlib: 

26 """ 

27 Factory class for getting a Vivado simlib API. 

28 """ 

29 

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. 

37 

38 Will return a :class:`.VivadoSimlibCommon` subclass object. 

39 

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 

47 

48 if simulator_interface.name == "ghdl": 

49 return VivadoSimlibGhdl( 

50 vivado_path=vivado_path, 

51 output_path=output_path, 

52 vunit_proj=vunit_proj, 

53 simulator_interface=simulator_interface, 

54 ) 

55 

56 return VivadoSimlibCommercial( 

57 vivado_path=vivado_path, 

58 output_path=output_path, 

59 vunit_proj=vunit_proj, 

60 simulator_interface=simulator_interface, 

61 )