GHDL.py
Summary
- Lines:
31 of 47 covered (66.0%)
- Excluded lines:
9
- Branches:
0 of 2 taken (0.0%), 0 lines partially
- Coverage:
63.3%
- Directory:
- Missed lines:
49-54, 59, 64, 69, 72-74, 77, 89, 92, 95, 107
Source
pyEDAA/ToolSetup/OpenSource/GHDL.pycoveredpartialuncoveredexcludednot executable
1# ==================================================================================================================== #
2# _____ ____ _ _ _____ _ ____ _ #
3# _ __ _ _| ____| _ \ / \ / \ |_ _|__ ___ | / ___| ___| |_ _ _ _ __ #
4# | '_ \| | | | _| | | | |/ _ \ / _ \ | |/ _ \ / _ \| \___ \ / _ \ __| | | | '_ \ #
5# | |_) | |_| | |___| |_| / ___ \ / ___ \ _| | (_) | (_) | |___) | __/ |_| |_| | |_) | #
6# | .__/ \__, |_____|____/_/ \_\/_/ \_(_)_|\___/ \___/|_|____/ \___|\__|\__,_| .__/ #
7# |_| |___/ |_| #
8# ==================================================================================================================== #
9# Authors: #
10# Patrick Lehmann #
11# #
12# License: #
13# ==================================================================================================================== #
14# Copyright 2021-2026 Electronic Design Automation Abstraction (EDA²) #
15# #
16# Licensed under the Apache License, Version 2.0 (the "License"); #
17# you may not use this file except in compliance with the License. #
18# You may obtain a copy of the License at #
19# #
20# http://www.apache.org/licenses/LICENSE-2.0 #
21# #
22# Unless required by applicable law or agreed to in writing, software #
23# distributed under the License is distributed on an "AS IS" BASIS, #
24# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
25# See the License for the specific language governing permissions and #
26# limitations under the License. #
27# #
28# SPDX-License-Identifier: Apache-2.0 #
29# ==================================================================================================================== #
30#
31from typing import cast
32
33from pyTooling.Decorators import export
34from pyTooling.Configuration.YAML import Dictionary
35from pyTooling.CLIAbstraction import Executable
36from .. import Tool, ToolInstance
37from ..Interface import HDLSimulator
38from pyEDAA.CLITool.GHDL import GHDL as CLI_GHDL
39
40
41@export
42class GHDLInstance(ToolInstance, HDLSimulator):
43 _platform: str
44 _runtime: str
45 _backend: str
46 _ghdl: CLI_GHDL
47
48 def __init__(self, config: Dictionary, parent: 'GHDL') -> None:
49 super().__init__(config, parent)
50
51 self._ghdl = None
52 self._platform = config["Platform"]
53 self._runtime = config["Runtime"]
54 self._backend = config["Backend"]
55
56 @property
57 def Platform(self) -> str:
58 """Platform GHDL runs on: ``win64``, ``lin64``."""
59 return self._platform
60
61 @property
62 def Runtime(self) -> str:
63 """Runtime used to run GHDL: ``mingw64``, ``ucrt64``, ``lin64``."""
64 return self._runtime
65
66 @property
67 def Backend(self) -> str:
68 """GHDL's backend: ``mcode``, ``llvm`` or ``gcc``."""
69 return self._backend
70
71 def _CreateGHDLCLIInstance(self) -> CLI_GHDL:
72 if self._ghdl is None:
73 self._ghdl = CLI_GHDL(binaryDirectoryPath=self.BinaryDirectory)
74 return self._ghdl
75
76 def GetGHDL(self) -> CLI_GHDL:
77 return self._CreateGHDLCLIInstance()
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 return self._CreateGHDLCLIInstance().GetGHDLAsAnalyzer()
90
91 def GetEloborator(self) -> Executable:
92 return self._CreateGHDLCLIInstance().GetGHDLAsElaborator()
93
94 def GetSimulator(self) -> Executable:
95 return self._CreateGHDLCLIInstance().GetGHDLAsSimulator()
96
97
98@export
99class GHDL(Tool, HDLSimulator):
100 _vendorKey = "OpenSource" #: Key of the parent node (vendor) in the configuration structure.
101 _key = "GHDL" #: Key used in the configuration structure.
102
103 _instanceClass = GHDLInstance
104
105 @property
106 def Default(self) -> GHDLInstance:
107 return cast(GHDLInstance, super().Default)
108
109 # def GetLibraryCreator(self) -> Executable:
110 # raise NotImplementedError(f"")
111 #
112 # def GetLibraryMapper(self) -> Executable:
113 # raise NotImplementedError(f"")
114 #
115 # def GetLibraryDeleter(self) -> Executable:
116 # raise NotImplementedError(f"")
117
118 def GetVHDLAnalyzer(self) -> Executable:
119 raise NotImplementedError("")
120
121 def GetEloborator(self) -> Executable:
122 raise NotImplementedError("")
123
124 def GetSimulator(self) -> Executable:
125 raise NotImplementedError("")