Skip to content

Commit a440cc1

Browse files
Sebastien Baillouamykyta3
authored andcommitted
Add Xcelium simulator option
1 parent 08c24d4 commit a440cc1

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

tests/lib/simulators/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
from .base import Simulator
55
from .questa import Questa
66
from .xilinx import XilinxXSIM
7+
from .xcelium import Xcelium
78
from .stub import StubSimulator
89

910
ALL_SIMULATORS: List[Simulator]
1011
ALL_SIMULATORS = [
1112
Questa,
1213
XilinxXSIM,
14+
Xcelium,
1315
StubSimulator,
1416
]
1517

tests/lib/simulators/xcelium.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
from typing import List
2+
import subprocess
3+
import os
4+
import shutil
5+
from .base import Simulator
6+
7+
class Xcelium(Simulator):
8+
"""
9+
Don't use the Xcelium simulator, it is unable to compile & run any testcases.
10+
11+
As observed in 25.03.006:
12+
- Using unpacked structs with more than 2 levels of nesting in clocking blocks is not
13+
supported.
14+
"""
15+
name = "xcelium"
16+
17+
@classmethod
18+
def is_installed(cls) -> bool:
19+
return (
20+
shutil.which("xrun") is not None
21+
)
22+
23+
def compile(self) -> None:
24+
# Compile and elaborate into a snapshot
25+
cmd = [
26+
"xrun",
27+
"-64bit",
28+
"-elaborate",
29+
"-sv",
30+
"-log build.log",
31+
"-timescale 10ps/1ps",
32+
"-ENABLE_DS_UNPS", # Allow ".*" DUT connection with unpacked structs
33+
"-nowarn LNDER6", # Suppress warning about the `line 2 "lib/tb_base.sv" 0 file location
34+
"-nowarn SPDUSD", # Suppress warning about unused include directory
35+
"-incdir %s" % os.path.join(os.path.dirname(__file__), "..")
36+
]
37+
38+
if self.gui_mode:
39+
cmd.append("-access +rwc")
40+
41+
# Add source files
42+
cmd.extend(self.tb_files)
43+
44+
# Run command!
45+
subprocess.run(cmd, check=True)
46+
47+
48+
def run(self, plusargs:List[str] = None) -> None:
49+
plusargs = plusargs or []
50+
51+
test_name = self.testcase.request.node.name
52+
53+
# Call xrun on the elaborated snapshot
54+
cmd = [
55+
"xrun",
56+
"-64bit",
57+
"-log %s.log" % test_name,
58+
"-r worklib.tb:sv"
59+
]
60+
61+
if self.gui_mode:
62+
cmd.append("-gui")
63+
cmd.append('-input "@database -open waves -into waves.shm -shm -default -event"')
64+
cmd.append('-input "@probe -create tb -depth all -tasks -functions -all -packed 4k \
65+
-unpacked 16k -memories -dynamic -variables -database waves"')
66+
else:
67+
cmd.extend([
68+
"-input", "@run",
69+
])
70+
71+
for plusarg in plusargs:
72+
cmd.append("+" + plusarg)
73+
subprocess.run(cmd, check=True)
74+
75+
self.assertSimLogPass("%s.log" % test_name)
76+
77+
78+
def assertSimLogPass(self, path: str):
79+
self.testcase.assertTrue(os.path.isfile(path))
80+
81+
with open(path, encoding="utf-8") as f:
82+
for line in f:
83+
if line.startswith("xmsim: *E"):
84+
self.testcase.fail(line)
85+
elif line.startswith("xmsim: *F"):
86+
self.testcase.fail(line)

0 commit comments

Comments
 (0)