Coverage for pyEDAA/ToolSetup/OpenSource/GHDL.py: 68%

51 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-17 00:56 +0000

1from typing import cast 

2 

3from pyTooling.Decorators import export 

4from pyTooling.Configuration.YAML import Dictionary 

5from pyTooling.CLIAbstraction import Executable 

6from .. import Tool, ToolInstance 

7from ..Interface import HDLSimulator 

8from pyEDAA.CLITool.GHDL import GHDL as CLI_GHDL 

9 

10 

11@export 

12class GHDLInstance(ToolInstance, HDLSimulator): 

13 _platform: str 

14 _runtime: str 

15 _backend: str 

16 _ghdl: CLI_GHDL 

17 

18 def __init__(self, config: Dictionary, parent: 'GHDL'): 

19 super().__init__(config, parent) 

20 

21 self._ghdl = None 

22 self._platform = config["Platform"] 

23 self._runtime = config["Runtime"] 

24 self._backend = config["Backend"] 

25 

26 @property 

27 def Platform(self) -> str: 

28 """Platform GHDL runs on: ``win32``, ``win64``, ``lin64``.""" 

29 return self._platform 

30 

31 @property 

32 def Runtime(self) -> str: 

33 """Runtime used to run GHDL: ``mingw32``, ``mingw64``, ``ucrt64``, ``gnatgpl32``, ``lin64``.""" 

34 return self._runtime 

35 

36 @property 

37 def Backend(self) -> str: 

38 """GHDL's backend (``mcode``, ``llvm`` or ``gcc``.""" 

39 return self._backend 

40 

41 def _CreateGHDLCLIInstance(self) -> CLI_GHDL: 

42 if self._ghdl is None: 

43 self._ghdl = CLI_GHDL(binaryDirectoryPath=self.BinaryDirectory) 

44 return self._ghdl 

45 

46 def GetGHDL(self) -> CLI_GHDL: 

47 return self._CreateGHDLCLIInstance() 

48 

49 # def GetLibraryCreator(self) -> Executable: 

50 # raise NotImplementedError(f"") 

51 # 

52 # def GetLibraryMapper(self) -> Executable: 

53 # raise NotImplementedError(f"") 

54 # 

55 # def GetLibraryDeleter(self) -> Executable: 

56 # raise NotImplementedError(f"") 

57 

58 def GetVHDLAnalyzer(self) -> Executable: 

59 return self._CreateGHDLCLIInstance().GetGHDLAsAnalyzer() 

60 

61 def GetEloborator(self) -> Executable: 

62 return self._CreateGHDLCLIInstance().GetGHDLAsElaborator() 

63 

64 def GetSimulator(self) -> Executable: 

65 return self._CreateGHDLCLIInstance().GetGHDLAsSimulator() 

66 

67 

68@export 

69class GHDL(Tool, HDLSimulator): 

70 _vendorKey = "OpenSource" #: Key of the parent node (vendor) in the configuration structure. 

71 _key = "GHDL" #: Key used in the configuration structure. 

72 

73 _instanceClass = GHDLInstance 

74 

75 @property 

76 def Default(self) -> GHDLInstance: 

77 return cast(GHDLInstance, super().Default) 

78 

79 # def GetLibraryCreator(self) -> Executable: 

80 # raise NotImplementedError(f"") 

81 # 

82 # def GetLibraryMapper(self) -> Executable: 

83 # raise NotImplementedError(f"") 

84 # 

85 # def GetLibraryDeleter(self) -> Executable: 

86 # raise NotImplementedError(f"") 

87 

88 def GetVHDLAnalyzer(self) -> Executable: 

89 raise NotImplementedError(f"") 

90 

91 def GetEloborator(self) -> Executable: 

92 raise NotImplementedError(f"") 

93 

94 def GetSimulator(self) -> Executable: 

95 raise NotImplementedError(f"")