|
| 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