Debian Codegraph @

src/cocotb_tools/sim_versions.py

raw symbols SCIP
1 # Copyright cocotb contributors
2 # Licensed under the Revised BSD License, see LICENSE for details.
3 # SPDX-License-Identifier: BSD-3-Clause
4
5 # type: ignore # distutils is untyped, so there's little reason to check this file
6
7 """
8 Classes to compare simulation versions.
9
10 These are for cocotb-internal use only.
11
12 .. warning::
13 These classes silently allow comparing versions of different simulators.
14 """
15
16 from cocotb_tools._vendor.distutils_version import LooseVersion
17
18
19 class ActivehdlVersion(LooseVersion):
20 """Version numbering class for Aldec Active-HDL.
21
22 NOTE: unsupported versions exist, e.g.
23 ActivehdlVersion("10.5a.12.6914") > ActivehdlVersion("10.5.216.6767")
24 """
25
26
27 class CvcVersion(LooseVersion):
28 """Version numbering class for Tachyon DA CVC.
29
30 Example:
31 >>> CvcVersion(
32 ... "OSS_CVC_7.00b-x86_64-rhel6x of 07/07/14 (Linux-elf)"
33 ... ) > CvcVersion("OSS_CVC_7.00a-x86_64-rhel6x of 07/07/14 (Linux-elf)")
34 True
35 """
36
37
38 class GhdlVersion(LooseVersion):
39 """Version numbering class for GHDL."""
40
41
42 class IcarusVersion(LooseVersion):
43 """Version numbering class for Icarus Verilog.
44
45 Example:
46 >>> IcarusVersion("11.0 (devel)") > IcarusVersion("10.3 (stable)")
47 True
48 >>> IcarusVersion("10.3 (stable)") <= IcarusVersion("10.3 (stable)")
49 True
50 """
51
52
53 class ModelsimVersion(LooseVersion):
54 """Version numbering class for Mentor ModelSim."""
55
56
57 class QuestaVersion(LooseVersion):
58 """Version numbering class for Mentor Questa.
59
60 Example:
61 >>> QuestaVersion("10.7c 2018.08") > QuestaVersion("10.7b 2018.06")
62 True
63 >>> QuestaVersion("2020.1 2020.01") > QuestaVersion("10.7c 2018.08")
64 True
65 >>> QuestaVersion("2020.1 2020.01") == QuestaVersion("2020.1")
66 True
67 >>> QuestaVersion("2023.1_2 2023.03") > QuestaVersion("2023.1_1")
68 True
69 """
70
71 def parse(self, vstring):
72 # A Questa version string, as returned by the simulator, consists of two
73 # space-separated parts. The first part is the actual version number,
74 # the second part seems to be the year and month of the initial release.
75 # We only need the first part, which is also used in public
76 # communication by Siemens.
77 try:
78 first_component = vstring.split(" ", 1)[0]
79 except IndexError:
80 first_component = vstring
81
82 super().parse(first_component)
83
84
85 class RivieraVersion(LooseVersion):
86 """Version numbering class for Aldec Riviera-PRO.
87
88 Example:
89 >>> RivieraVersion("2019.10.138.7537") == RivieraVersion("2019.10.138.7537")
90 True
91 """
92
93
94 class VcsVersion(LooseVersion):
95 """Version numbering class for Synopsys VCS.
96
97 Example:
98 >>> VcsVersion("Q-2020.03-1_Full64") > VcsVersion("K-2015.09_Full64")
99 True
100 """
101
102
103 class VerilatorVersion(LooseVersion):
104 """Version numbering class for Verilator.
105
106 Example:
107 >>> VerilatorVersion("4.032 2020-04-04") > VerilatorVersion("4.031 devel")
108 True
109 """
110
111
112 class XceliumVersion(LooseVersion):
113 """Version numbering class for Cadence Xcelium.
114
115 Example:
116 >>> XceliumVersion("20.06-g183") > XceliumVersion("20.03-s002")
117 True
118 >>> XceliumVersion("20.07-e501") > XceliumVersion("20.06-g183")
119 True
120 """
121
122
123 class IusVersion(XceliumVersion): # inherit everything from Xcelium
124 """Version numbering class for Cadence IUS.
125
126 Example:
127 >>> IusVersion("15.20-s050") > IusVersion("15.20-s049")
128 True
129 """
130
131
132 class NvcVersion(LooseVersion):
133 """Version numbering class for NVC."""
134
135 @classmethod
136 def from_commandline(cls, cmdline):
137 firstline = cmdline.split("\n")[0]
138 sim, version, *version_extra = firstline.strip().split(" ")
139 assert sim == "nvc"
140 return cls(version)