Ejemplo n.º 1
0
 def isAvailable():
     try:
         runShellCommand(["vcom", "-version"])
         runShellCommand(["vlog", "-version"])
         return True
     except OSError:
         return False
Ejemplo n.º 2
0
 def isAvailable():
     try:
         temp_dir = tempfile.mkdtemp()
         runShellCommand(["xvhdl", "--nolog", "--version"], cwd=temp_dir)
         return True
     except OSError:
         return False
     finally:
         shutil.rmtree(temp_dir)
Ejemplo n.º 3
0
    def _mapLibrary(self, library):
        # type: (Identifier) -> None
        """
        Adds a library to an existing ModelSim init file
        """
        runShellCommand(["vlib", p.join(self._work_folder, library.name)])

        runShellCommand([
            "vmap",
            "-modelsimini",
            self._modelsim_ini.name,
            library.name,
            p.join(self._work_folder, library.name),
        ])
Ejemplo n.º 4
0
 def deleteLibrary(self, library):
     "Deletes a library from ModelSim init file"
     if not p.exists(p.join(self._work_folder, library)):
         self._logger.warning("Library %s doesn't exists", library)
         return None
     return runShellCommand([
         "vdel", "-modelsimini", self._modelsim_ini, "-lib", library, "-all"
     ])
Ejemplo n.º 5
0
 def _checkEnvironment(self):
     stdout = runShellCommand(["ghdl", "--version"])
     self._version = re.findall(r"(?<=GHDL)\s+([^\s]+)\s+", stdout[0])[0]
     self._logger.info(
         "GHDL version string: '%s'. " "Version number is '%s'",
         stdout[:-1],
         self._version,
     )
Ejemplo n.º 6
0
 def _checkEnvironment(self):
     stdout = runShellCommand(["vcom", "-version"])
     self._version = re.findall(r"(?<=vcom)\s+([\w\.]+)\s+(?=Compiler)",
                                stdout[0])[0]
     self._logger.debug(
         "vcom version string: '%s'. "
         "Version number is '%s'",
         stdout,
         self._version,
     )
Ejemplo n.º 7
0
 def _checkEnvironment(self):
     stdout = runShellCommand(["xvhdl", "--nolog", "--version"],
                              cwd=self._work_folder)
     self._version = re.findall(r"^Vivado Simulator\s+([\d\.]+)",
                                stdout[0])[0]
     self._logger.info(
         "xvhdl version string: '%s'. "
         "Version number is '%s'",
         stdout[:-1],
         self._version,
     )
Ejemplo n.º 8
0
    def _buildSource(self, path, library, flags=None):
        # type: (Path, Identifier, Optional[BuildFlags]) -> Iterable[str]
        self._importSource(path, library, flags)

        stdout = []  # type: List[str]
        for cmd in (
            self._analyzeSource(path, library, flags),
            self._checkSyntax(path, library, flags),
        ):
            stdout += runShellCommand(cmd)

        return stdout
Ejemplo n.º 9
0
    def _createIniFile(self):
        # type: (...) -> Any
        """
        Adds a library to a non-existent ModelSim init file
        """
        if not p.exists(self._work_folder):  # pragma: no cover
            os.makedirs(self._work_folder)

        self._logger.debug("Creating modelsim.ini at '%s'", self._modelsim_ini)

        modelsim_env = os.environ.get("MODELSIM")
        if modelsim_env is not None:  # pragma: no cover
            self._logger.info(
                "MODELSIM environment variable set to %s, using "
                "this path as default modelsim.ini",
                modelsim_env,
            )
            # Copy the modelsim.ini as indicated by the MODELSIM environment
            # variable
            copyfile(modelsim_env, self._modelsim_ini.abspath)
        else:
            runShellCommand(["vmap", "-c"], cwd=self._work_folder)
Ejemplo n.º 10
0
 def _buildSource(self, path, library, flags=None):
     # type: (Path, Identifier, Optional[BuildFlags]) -> Iterable[str]
     cmd = [
         "xvhdl",
         "--nolog",
         "--verbose",
         "0",
         "--initfile",
         self._xvhdlini,
         "--work",
         library.name,
     ]
     cmd += [str(x) for x in (flags or [])]
     cmd += [path.name]
     return runShellCommand(cmd, cwd=self._work_folder)
Ejemplo n.º 11
0
    def _buildVhdl(self, path, library, flags=None):
        # type: (Path, Identifier, Optional[BuildFlags]) -> Iterable[str]
        "Builds a VHDL file"
        assert isinstance(library, Identifier)
        cmd = [
            "vcom",
            "-modelsimini",
            self._modelsim_ini.name,
            "-quiet",
            "-work",
            p.join(self._work_folder, library.name),
        ]
        if flags:  # pragma: no cover
            cmd += flags
        cmd += [path.name]

        return runShellCommand(cmd)
Ejemplo n.º 12
0
    def _buildVerilog(self, path, library, flags=None):
        # type: (Path, Identifier, Optional[BuildFlags]) -> Iterable[str]
        "Builds a Verilog/SystemVerilog file"
        cmd = [
            "vlog",
            "-modelsimini",
            self._modelsim_ini.name,
            "-quiet",
            "-work",
            p.join(self._work_folder, library.name),
        ]

        if FileType.fromPath(path) == FileType.systemverilog:
            cmd += ["-sv"]
        if flags:  # pragma: no cover
            cmd += flags

        cmd += self._getExtraFlags(path)
        cmd += [path.name]

        return runShellCommand(cmd)
Ejemplo n.º 13
0
    def _parseBuiltinLibraries(self):
        # type: (...) -> Any
        """
        Discovers libraries that exist regardless before we do anything
        """
        for line in runShellCommand(["ghdl", "--dispconfig"]):
            library_path_match = self._scan_library_paths.search(line)
            if library_path_match:
                library_path = library_path_match.groupdict()["library_path"]
                self._logger.debug("library path is %s", library_path)

                # Up to v0.36 ghdl kept libraries at
                #   <library_path>/<vhdl starndard>/<name>
                # but his has been changed to
                #   <library_path>/<name>/<vhdl starndard>
                libraries_paths = glob(
                    p.join(library_path, "v93", "*")
                    if self._version < "0.36"
                    else p.join(library_path, "*")
                )

                for path in filter(p.isdir, libraries_paths):
                    name = path.split(p.sep)[-1]
                    yield Identifier(name.strip(), case_sensitive=False)
Ejemplo n.º 14
0
 def _parseBuiltinLibraries(self):
     # type: (...) -> Any
     "Discovers libraries that exist regardless before we do anything"
     for line in runShellCommand(["vmap"]):
         for match in self._BuilderLibraryScanner.finditer(line):
             yield Identifier(match.groupdict()["library_name"], False)
Ejemplo n.º 15
0
 def isAvailable():
     try:
         runShellCommand(["ghdl", "--version"])
         return True
     except OSError:
         return False