Coverage for pyEDAA/IPXACT/Component.py: 29%
223 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-17 01:13 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-17 01:13 +0000
1# ==================================================================================================================== #
2# _____ ____ _ _ ___ ______ __ _ ____ _____ #
3# _ __ _ _| ____| _ \ / \ / \ |_ _| _ \ \/ / / \ / ___|_ _| #
4# | '_ \| | | | _| | | | |/ _ \ / _ \ | || |_) \ / / _ \| | | | #
5# | |_) | |_| | |___| |_| / ___ \ / ___ \ _ | || __// \ / ___ \ |___ | | #
6# | .__/ \__, |_____|____/_/ \_\/_/ \_(_)___|_| /_/\_\/_/ \_\____| |_| #
7# |_| |___/ #
8# ==================================================================================================================== #
9# Authors: #
10# Patrick Lehmann #
11# #
12# License: #
13# ==================================================================================================================== #
14# Copyright 2017-2024 Patrick Lehmann - Bötzingen, Germany #
15# Copyright 2016-2016 Patrick Lehmann - Dresden, Germany #
16# #
17# Licensed under the Apache License, Version 2.0 (the "License"); #
18# you may not use this file except in compliance with the License. #
19# You may obtain a copy of the License at #
20# #
21# http://www.apache.org/licenses/LICENSE-2.0 #
22# #
23# Unless required by applicable law or agreed to in writing, software #
24# distributed under the License is distributed on an "AS IS" BASIS, #
25# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
26# See the License for the specific language governing permissions and #
27# limitations under the License. #
28# #
29# SPDX-License-Identifier: Apache-2.0 #
30# ==================================================================================================================== #
31#
32from textwrap import dedent
34from pyTooling.Decorators import export
36from pyEDAA.IPXACT import RootElement, __DEFAULT_SCHEMA__
39@export
40class Component(RootElement):
41 """Represents an IP-XACT components."""
43 def __init__(self, vlnv, description):
44 super().__init__(vlnv)
46 self._description = description
47 self._busInterfaces = []
48 self._indirectInterfaces = []
49 self._channels = []
50 self._remapStates = []
51 self._addressSpaces = []
52 self._memoryMaps = []
53 self._model = None
54 self._componentGenerators = []
55 self._choices = []
56 self._fileSets = []
57 self._whiteboxElements = []
58 self._cpus = []
59 self._otherClockDrivers = []
60 self._resetTypes = []
61 self._parameters = []
62 self._assertions = []
64 def Settem(self, item):
65 if isinstance(item, Model): self._model = item
66 else:
67 raise ValueError()
69 def AddItem(self, item) -> None:
70 if isinstance(item, BusInterface): self._busInterfaces.append(item)
71 elif isinstance(item, IndirectInterface): self._indirectInterfaces.append(item)
72 elif isinstance(item, Channel): self._channels.append(item)
73 elif isinstance(item, RemapState): self._remapStates.append(item)
74 elif isinstance(item, AddressSpace): self._addressSpaces.append(item)
75 elif isinstance(item, MemoryMap): self._memoryMaps.append(item)
76 elif isinstance(item, ComponentGenerator): self._componentGenerators.append(item)
77 elif isinstance(item, Choice): self._choices.append(item)
78 elif isinstance(item, FileSet): self._fileSets.append(item)
79 elif isinstance(item, WhiteboxElement): self._whiteboxElements.append(item)
80 elif isinstance(item, Cpu): self._cpus.append(item)
81 elif isinstance(item, OtherClockDriver): self._otherClockDrivers.append(item)
82 elif isinstance(item, ResetType): self._resetTypes.append(item)
83 elif isinstance(item, Parameter): self._parameters.append(item)
84 elif isinstance(item, Assertion): self._assertions.append(item)
85 else:
86 raise ValueError()
88 def ToXml(self) -> str:
89 """Converts the object's data into XML format."""
91 buffer = dedent("""\
92 <?xml version="1.0" encoding="UTF-8"?>
93 <{xmlns}:component
94 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
95 xmlns:{xmlns}="{schemaUri}"
96 xsi:schemaLocation="{schemaUri} {schemaUrl}">
97 {versionedIdentifier}
98 <{xmlns}:description>{description}</{xmlns}:description>
99 """).format(
100 xmlns=__DEFAULT_SCHEMA__.NamespacePrefix,
101 schemaUri=__DEFAULT_SCHEMA__.SchemaUri,
102 schemaUrl=__DEFAULT_SCHEMA__.SchemaUrl,
103 versionedIdentifier=self._vlnv.ToXml(isVersionedIdentifier=True),
104 description=self._description
105 )
107 if self._busInterfaces:
108 buffer += "\t<{xmlns}:busInterfaces>\n"
109 for busInterface in self._busInterfaces:
110 buffer += busInterface.ToXml(2)
111 buffer += "\t</{xmlns}:busInterfaces>\n"
113 if self._indirectInterfaces:
114 buffer += "\t<{xmlns}:indirectInterfaces>\n"
115 for indirectInterface in self._indirectInterfaces:
116 buffer += indirectInterface.ToXml(2)
117 buffer += "\t</{xmlns}:indirectInterfaces>\n"
119 if self._channels:
120 buffer += "\t<{xmlns}:channels>\n"
121 for channel in self._channels:
122 buffer += channel.ToXml(2)
123 buffer += "\t</{xmlns}:channels>\n"
125 if self._remapStates:
126 buffer += "\t<{xmlns}:remapStates>\n"
127 for remapState in self._remapStates:
128 buffer += remapState.ToXml(2)
129 buffer += "\t</{xmlns}:remapStates>\n"
131 if self._addressSpaces:
132 buffer += "\t<{xmlns}:addressSpaces>\n"
133 for addressSpace in self._addressSpaces:
134 buffer += addressSpace.ToXml(2)
135 buffer += "\t</{xmlns}:addressSpaces>\n"
137 if self._memoryMaps:
138 buffer += "\t<{xmlns}:memoryMaps>\n"
139 for memoryMap in self._memoryMaps:
140 buffer += memoryMap.ToXml(2)
141 buffer += "\t</{xmlns}:memoryMaps>\n"
143 if self._model:
144 buffer += "\t<{xmlns}:model>\n"
145 buffer += self._model.ToXml(2)
146 buffer += "\t</{xmlns}:model>\n"
148 if self._componentGenerators:
149 buffer += "\t<{xmlns}:componentGenerators>\n"
150 for componentGenerator in self._componentGenerators:
151 buffer += componentGenerator.ToXml(2)
152 buffer += "\t</{xmlns}:componentGenerators>\n"
154 if self._choices:
155 buffer += "\t<{xmlns}:choices>\n"
156 for choice in self._choices:
157 buffer += choice.ToXml(2)
158 buffer += "\t</{xmlns}:choices>\n"
160 if self._fileSets:
161 buffer += "\t<{xmlns}:fileSets>\n"
162 for fileSet in self._fileSets:
163 buffer += fileSet.ToXml(2)
164 buffer += "\t</{xmlns}:fileSets>\n"
166 if self._whiteboxElements:
167 buffer += "\t<{xmlns}:whiteboxElements>\n"
168 for whiteboxElement in self._whiteboxElements:
169 buffer += whiteboxElement.ToXml(2)
170 buffer += "\t</{xmlns}:whiteboxElements>\n"
172 if self._cpus:
173 buffer += "\t<{xmlns}:cpus>\n"
174 for cpu in self._cpus:
175 buffer += cpu.ToXml(2)
176 buffer += "\t</{xmlns}:cpus>\n"
178 if self._otherClockDrivers:
179 buffer += "\t<{xmlns}:otherClockDrivers>\n"
180 for otherClockDriver in self._otherClockDrivers:
181 buffer += otherClockDriver.ToXml(2)
182 buffer += "\t</{xmlns}:otherClockDrivers>\n"
184 if self._resetTypes:
185 buffer += "\t<{xmlns}:resetTypes>\n"
186 for resetType in self._resetTypes:
187 buffer += resetType.ToXml(2)
188 buffer += "\t</{xmlns}:resetTypes>\n"
190 if self._parameters:
191 buffer += "\t<{xmlns}:parameters>\n"
192 for parameter in self._parameters:
193 buffer += parameter.ToXml(2)
194 buffer += "\t</{xmlns}:parameters>\n"
196 if self._assertions:
197 buffer += "\t<{xmlns}:assertions>\n"
198 for assertion in self._assertions:
199 buffer += assertion.ToXml(2)
200 buffer += "\t</{xmlns}:assertions>\n"
202 buffer += dedent("""\
203 </{xmlns}:component>
204 """)
206 return buffer.format(xmlns=__DEFAULT_SCHEMA__.NamespacePrefix)
209@export
210class BusInterface:
211 """Represents an IP-XACT bus interface."""
213 def __init__(self) -> None:
214 pass
216 def ToXml(self, indent=0):
217 """Converts the object's data into XML format."""
219 return ""
222@export
223class IndirectInterface:
224 """Represents an IP-XACT indirect interface."""
226 def __init__(self) -> None:
227 pass
229 def ToXml(self, indent=0):
230 """Converts the object's data into XML format."""
232 return ""
235@export
236class Channel:
237 """Represents an IP-XACT channel."""
239 def __init__(self) -> None:
240 pass
242 def ToXml(self, indent=0):
243 """Converts the object's data into XML format."""
245 return ""
248@export
249class RemapState:
250 """Represents an IP-XACT remap state."""
252 def __init__(self) -> None:
253 pass
255 def ToXml(self, indent=0):
256 """Converts the object's data into XML format."""
258 return ""
261@export
262class AddressSpace:
263 """Represents an IP-XACT address space."""
265 def __init__(self) -> None:
266 pass
268 def ToXml(self, indent=0):
269 """Converts the object's data into XML format."""
271 return ""
274@export
275class MemoryMap:
276 """Represents an IP-XACT memory map."""
278 def __init__(self) -> None:
279 pass
281 def ToXml(self, indent=0):
282 """Converts the object's data into XML format."""
284 return ""
287@export
288class Model:
289 """Represents an IP-XACT model."""
291 def __init__(self) -> None:
292 pass
294 def ToXml(self, indent=0):
295 """Converts the object's data into XML format."""
297 return ""
300@export
301class ComponentGenerator:
302 """Represents an IP-XACT component generator."""
304 def __init__(self) -> None:
305 pass
307 def ToXml(self, indent=0):
308 """Converts the object's data into XML format."""
310 return ""
313@export
314class Choice:
315 """Represents an IP-XACT choice."""
317 def __init__(self) -> None:
318 pass
320 def ToXml(self, indent=0):
321 """Converts the object's data into XML format."""
323 return ""
326@export
327class FileSet:
328 """Represents an IP-XACT fileset."""
330 def __init__(self) -> None:
331 pass
333 def ToXml(self, indent=0):
334 """Converts the object's data into XML format."""
336 return ""
339@export
340class WhiteboxElement:
341 """Represents an IP-XACT whitebos element."""
343 def __init__(self) -> None:
344 pass
346 def ToXml(self, indent=0):
347 """Converts the object's data into XML format."""
349 return ""
352@export
353class Cpu:
354 """Represents an IP-XACT cpu."""
356 def __init__(self) -> None:
357 pass
359 def ToXml(self, indent=0):
360 """Converts the object's data into XML format."""
362 return ""
365@export
366class OtherClockDriver:
367 """Represents an IP-XACT *other* clock driver."""
369 def __init__(self) -> None:
370 pass
372 def ToXml(self, indent=0):
373 """Converts the object's data into XML format."""
375 return ""
378@export
379class ResetType:
380 """Represents an IP-XACT reset type."""
382 def __init__(self) -> None:
383 pass
385 def ToXml(self, indent=0):
386 """Converts the object's data into XML format."""
388 return ""
391@export
392class Parameter:
393 """Represents an IP-XACT parameter."""
395 def __init__(self) -> None:
396 pass
398 def ToXml(self, indent=0):
399 """Converts the object's data into XML format."""
401 return ""
404@export
405class Assertion:
406 """Represents an IP-XACT assertion."""
408 def __init__(self) -> None:
409 pass
411 def ToXml(self, indent=0):
412 """Converts the object's data into XML format."""
414 return ""