Coverage for pyVHDLModel/IEEE.py: 100%

152 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2024-12-20 22:13 +0000

1# ==================================================================================================================== # 

2# __ ___ _ ____ _ __ __ _ _ # 

3# _ __ _ \ \ / / | | | _ \| | | \/ | ___ __| | ___| | # 

4# | '_ \| | | \ \ / /| |_| | | | | | | |\/| |/ _ \ / _` |/ _ \ | # 

5# | |_) | |_| |\ V / | _ | |_| | |___| | | | (_) | (_| | __/ | # 

6# | .__/ \__, | \_/ |_| |_|____/|_____|_| |_|\___/ \__,_|\___|_| # 

7# |_| |___/ # 

8# ==================================================================================================================== # 

9# Authors: # 

10# Patrick Lehmann # 

11# # 

12# License: # 

13# ==================================================================================================================== # 

14# Copyright 2017-2024 Patrick Lehmann - Boetzingen, Germany # 

15# Copyright 2016-2017 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# 

32"""This module contains library and package declarations for VHDL library ``IEEE``.""" 

33from pyTooling.Decorators import export 

34 

35from pyVHDLModel.Expression import EnumerationLiteral 

36from pyVHDLModel.Name import SimpleName 

37from pyVHDLModel.Predefined import PredefinedLibrary, PredefinedPackage, PredefinedPackageBody 

38from pyVHDLModel.Symbol import SimpleSubtypeSymbol 

39from pyVHDLModel.Type import EnumeratedType, ArrayType, Subtype 

40 

41 

42@export 

43class Ieee(PredefinedLibrary): 

44 """ 

45 Predefined VHDL library ``ieee``. 

46 

47 The following predefined packages are in this library: 

48 

49 * Math 

50 

51 * :class:`~pyVHDLModel.IEEE.Math_Real` 

52 * :class:`~pyVHDLModel.IEEE.Math_Complex` 

53 

54 * Std_logic 

55 

56 * :class:`~pyVHDLModel.IEEE.Std_Logic_1164` 

57 * :class:`~pyVHDLModel.IEEE.Std_Logic_TextIO` 

58 * :class:`~pyVHDLModel.IEEE.Std_Logic_Misc` 

59 

60 * Numeric 

61 

62 * :class:`~pyVHDLModel.IEEE.Numeric_Bit` 

63 * :class:`~pyVHDLModel.IEEE.Numeric_Bit_Unsigned` 

64 * :class:`~pyVHDLModel.IEEE.Numeric_Std` 

65 * :class:`~pyVHDLModel.IEEE.Numeric_Std_Unsigned` 

66 

67 * Fixed/floating point 

68 

69 * :class:`~pyVHDLModel.IEEE.Fixed_Float_Types` 

70 * :class:`~pyVHDLModel.IEEE.Fixed_Generic_Pkg` 

71 * :class:`~pyVHDLModel.IEEE.Fixed_Pkg` 

72 * :class:`~pyVHDLModel.IEEE.Float_Generic_Pkg` 

73 * :class:`~pyVHDLModel.IEEE.Float_Pkg` 

74 

75 .. seealso:: 

76 

77 Other predefined libraries: 

78 * Library :class:`~pyVHDLModel.STD.Std` 

79 """ 

80 

81 def __init__(self) -> None: 

82 super().__init__(PACKAGES) 

83 

84 def LoadSynopsysPackages(self) -> None: 

85 self.AddPackages(PACKAGES_SYNOPSYS) 

86 

87 

88 

89@export 

90class Math_Real(PredefinedPackage): 

91 """ 

92 Predefined package ``ieee.math_real``. 

93 """ 

94 

95 

96@export 

97class Math_Real_Body(PredefinedPackageBody): 

98 """ 

99 Predefined package body of package ``ieee.math_real``. 

100 """ 

101 

102 

103@export 

104class Math_Complex(PredefinedPackage): 

105 """ 

106 Predefined package ``ieee.math_complex``. 

107 """ 

108 

109 def __init__(self) -> None: 

110 super().__init__() 

111 

112 self._AddPackageClause(("work.math_real.all",)) 

113 

114 

115@export 

116class Math_Complex_Body(PredefinedPackageBody): 

117 """ 

118 Predefined package body of package ``ieee.math_complex``. 

119 """ 

120 

121 def __init__(self) -> None: 

122 super().__init__() 

123 

124 self._AddPackageClause(("work.math_real.all",)) 

125 

126 

127@export 

128class Std_logic_1164(PredefinedPackage): 

129 """ 

130 Predefined package ``ieee.std_logic_1164``. 

131 

132 Predefined types: 

133 

134 * ``std_ulogic``, ``std_ulogic_vector`` 

135 * ``std_logic``, ``std_logic_vector`` 

136 """ 

137 

138 def __init__(self) -> None: 

139 super().__init__() 

140 

141 self._AddPackageClause(("STD.TEXTIO.all", )) 

142 

143 stdULogic = EnumeratedType("std_ulogic", ( 

144 EnumerationLiteral("U"), 

145 EnumerationLiteral("X"), 

146 EnumerationLiteral("0"), 

147 EnumerationLiteral("1"), 

148 EnumerationLiteral("Z"), 

149 EnumerationLiteral("W"), 

150 EnumerationLiteral("L"), 

151 EnumerationLiteral("H"), 

152 EnumerationLiteral("-"), 

153 ), None) 

154 self._types[stdULogic._normalizedIdentifier] = stdULogic 

155 self._declaredItems.append(stdULogic) 

156 

157 stdULogicVector = ArrayType("std_ulogic_vector", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("std_ulogic")), None) 

158 self._types[stdULogicVector._normalizedIdentifier] = stdULogicVector 

159 self._declaredItems.append(stdULogicVector) 

160 

161 stdLogic = Subtype("std_logic", SimpleSubtypeSymbol(SimpleName("std_ulogic")), None) 

162 stdLogic._baseType = stdULogic 

163 self._subtypes[stdLogic._normalizedIdentifier] = stdLogic 

164 self._declaredItems.append(stdLogic) 

165 

166 stdLogicVector = Subtype("std_logic_vector", SimpleSubtypeSymbol(SimpleName("std_ulogic_vector")), None) 

167 stdLogicVector._baseType = stdULogicVector 

168 self._subtypes[stdLogicVector._normalizedIdentifier] = stdLogicVector 

169 self._declaredItems.append(stdLogicVector) 

170 

171 

172@export 

173class Std_logic_1164_Body(PredefinedPackageBody): 

174 """ 

175 Predefined package body of package ``ieee.std_logic_1164``. 

176 """ 

177 

178 

179@export 

180class std_logic_textio(PredefinedPackage): 

181 """ 

182 Predefined package ``ieee.std_logic_textio``. 

183 """ 

184 

185 def __init__(self) -> None: 

186 super().__init__() 

187 

188 self._AddPackageClause(("STD.TEXTIO.all", )) 

189 self._AddLibraryClause(("IEEE", )) 

190 self._AddPackageClause(("IEEE.std_logic_1164.all", )) 

191 

192 

193@export 

194class Std_logic_misc(PredefinedPackage): 

195 """ 

196 Predefined package ``ieee.std_logic_misc``. 

197 """ 

198 

199 def __init__(self) -> None: 

200 super().__init__() 

201 

202 self._AddLibraryClause(("IEEE", )) 

203 self._AddPackageClause(("IEEE.std_logic_1164.all", )) 

204 

205 

206@export 

207class Std_logic_misc_Body(PredefinedPackageBody): 

208 """ 

209 Predefined package body of package ``ieee.std_logic_misc``. 

210 """ 

211 

212 

213@export 

214class Numeric_Bit(PredefinedPackage): 

215 """ 

216 Predefined package ``ieee.numeric_bit``. 

217 """ 

218 

219 def __init__(self) -> None: 

220 super().__init__() 

221 

222 self._AddPackageClause(("STD.TEXTIO.all", )) 

223 

224 

225@export 

226class Numeric_Bit_Body(PredefinedPackageBody): 

227 """ 

228 Predefined package body of package ``ieee.numeric_bit``. 

229 """ 

230 

231 

232@export 

233class Numeric_Bit_Unsigned(PredefinedPackage): 

234 """ 

235 Predefined package ``ieee.numeric_bit_unsigned``. 

236 """ 

237 

238 

239@export 

240class Numeric_Bit_Unsigned_Body(PredefinedPackageBody): 

241 """ 

242 Predefined package body of package ``ieee.numeric_bit_unsigned``. 

243 """ 

244 

245 def __init__(self) -> None: 

246 super().__init__() 

247 

248 self._AddLibraryClause(("IEEE", )) 

249 self._AddPackageClause(("IEEE.numeric_bit.all", )) 

250 

251 

252@export 

253class Numeric_Std(PredefinedPackage): 

254 """ 

255 Predefined package ``ieee.numeric_std``. 

256 

257 Predefined types: 

258 

259 * ``unresolved_unsigned``, ``unsigned`` 

260 * ``unresolved_signed``, ``signed`` 

261 """ 

262 

263 def __init__(self) -> None: 

264 super().__init__() 

265 

266 self._AddPackageClause(("STD.TEXTIO.all", )) 

267 self._AddLibraryClause(("IEEE", )) 

268 self._AddPackageClause(("IEEE.std_logic_1164.all", )) 

269 

270 unresolvedUnsigned = ArrayType("unresolved_unsigned", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("std_ulogic")), None) 

271 self._types[unresolvedUnsigned._normalizedIdentifier] = unresolvedUnsigned 

272 self._declaredItems.append(unresolvedUnsigned) 

273 

274 unsigned = Subtype("unsigned", SimpleSubtypeSymbol(SimpleName("unresolved_unsigned")), None) 

275 unsigned._baseType = unresolvedUnsigned 

276 self._subtypes[unsigned._normalizedIdentifier] = unsigned 

277 self._declaredItems.append(unsigned) 

278 

279 unresolvedSigned = ArrayType("unresolved_signed", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("std_ulogic")), None) 

280 self._types[unresolvedSigned._normalizedIdentifier] = unresolvedSigned 

281 self._declaredItems.append(unresolvedSigned) 

282 

283 signed = Subtype("signed", SimpleSubtypeSymbol(SimpleName("unresolved_signed")), None) 

284 signed._baseType = unresolvedSigned 

285 self._subtypes[signed._normalizedIdentifier] = signed 

286 self._declaredItems.append(signed) 

287 

288 

289@export 

290class Numeric_Std_Body(PredefinedPackageBody): 

291 """ 

292 Predefined package body of package ``ieee.numeric_std``. 

293 """ 

294 

295 

296@export 

297class Numeric_Std_Unsigned(PredefinedPackage): 

298 """ 

299 Predefined package ``ieee.numeric_std_unsigned``. 

300 """ 

301 

302 def __init__(self) -> None: 

303 super().__init__() 

304 

305 self._AddLibraryClause(("IEEE", )) 

306 self._AddPackageClause(("IEEE.std_logic_1164.all", )) 

307 

308 

309@export 

310class Numeric_Std_Unsigned_Body(PredefinedPackageBody): 

311 """ 

312 Predefined package body of package ``ieee.numeric_std_unsigned``. 

313 """ 

314 

315 def __init__(self) -> None: 

316 super().__init__() 

317 

318 self._AddLibraryClause(("IEEE", )) 

319 self._AddPackageClause(("IEEE.numeric_std.all", )) 

320 

321 

322@export 

323class Fixed_Float_Types(PredefinedPackage): 

324 """ 

325 Predefined package ``ieee.fixed_float_types``. 

326 """ 

327 

328 

329@export 

330class Fixed_Generic_Pkg(PredefinedPackage): 

331 """ 

332 Predefined package ``ieee.fixed_generic_pkg``. 

333 """ 

334 

335 def __init__(self) -> None: 

336 super().__init__() 

337 

338 self._AddPackageClause(("STD.TEXTIO.all", )) 

339 self._AddLibraryClause(("IEEE", )) 

340 self._AddPackageClause(("IEEE.STD_LOGIC_1164.all", )) 

341 self._AddPackageClause(("IEEE.NUMERIC_STD.all", )) 

342 self._AddPackageClause(("IEEE.fixed_float_types.all", )) 

343 

344 

345@export 

346class Fixed_Generic_Pkg_Body(PredefinedPackageBody): 

347 """ 

348 Predefined package body of package ``ieee.fixed_generic_pkg``. 

349 """ 

350 

351 def __init__(self) -> None: 

352 super().__init__() 

353 

354 self._AddLibraryClause(("IEEE", )) 

355 self._AddPackageClause(("IEEE.MATH_REAL.all", )) 

356 

357 

358@export 

359class Fixed_Pkg(PredefinedPackage): 

360 """ 

361 Predefined package ``ieee.fixed_pkg``. 

362 """ 

363 def __init__(self) -> None: 

364 super().__init__() 

365 

366 self._AddLibraryClause(("IEEE", )) 

367 

368 

369@export 

370class Float_Generic_Pkg(PredefinedPackage): 

371 """ 

372 Predefined package ``ieee.float_generic_pkg``. 

373 """ 

374 

375 def __init__(self) -> None: 

376 super().__init__() 

377 

378 self._AddPackageClause(("STD.TEXTIO.all", )) 

379 self._AddLibraryClause(("IEEE", )) 

380 self._AddPackageClause(("IEEE.STD_LOGIC_1164.all", )) 

381 self._AddPackageClause(("IEEE.NUMERIC_STD.all", )) 

382 self._AddPackageClause(("IEEE.fixed_float_types.all", )) 

383 

384 

385@export 

386class Float_Generic_Pkg_Body(PredefinedPackageBody): 

387 """ 

388 Predefined package body of package ``ieee.float_generic_pkg``. 

389 """ 

390 

391 

392@export 

393class Float_Pkg(PredefinedPackage): 

394 """ 

395 Predefined package ``ieee.float_pkg``. 

396 """ 

397 

398 def __init__(self) -> None: 

399 super().__init__() 

400 

401 self._AddLibraryClause(("IEEE", )) 

402 

403 

404PACKAGES = ( 

405 (Math_Real, Math_Real_Body), 

406 (Math_Complex, Math_Complex_Body), 

407 (Std_logic_1164, Std_logic_1164_Body), 

408 (std_logic_textio, None), 

409 (Numeric_Bit, Numeric_Bit_Body), 

410 (Numeric_Bit_Unsigned, Numeric_Bit_Unsigned_Body), 

411 (Numeric_Std, Numeric_Std_Body), 

412 (Numeric_Std_Unsigned, Numeric_Std_Unsigned_Body), 

413 (Fixed_Float_Types, None), 

414 (Fixed_Generic_Pkg, Fixed_Generic_Pkg_Body), 

415 (Fixed_Pkg, None), 

416 (Float_Generic_Pkg, Float_Generic_Pkg_Body), 

417 (Float_Pkg, None), 

418) 

419 

420PACKAGES_SYNOPSYS = ( 

421 (Std_logic_misc, Std_logic_misc_Body), 

422)