コード例 #1
0
ファイル: rivierapro_interface.py プロジェクト: omberge/vunit
    def merge_coverage(self, file_name, args=None):
        """
        Merge coverage from all test cases,
        """

        # Teardown to ensure acdb file was written.
        self._persistent_shell.teardown()

        merge_command = "acdb merge"

        for coverage_file in self._coverage_files:
            if file_exists(coverage_file):
                merge_command += " -i {%s}" % coverage_file.replace('\\', '/')
            else:
                LOGGER.warning("Missing coverage file: %s", coverage_file)

        if args is not None:
            merge_command += " " + " ".join("{%s}" % arg for arg in args)

        merge_command += " -o {%s}" % file_name.replace('\\', '/')

        merge_script_name = join(self._output_path, "acdb_merge.tcl")
        with open(merge_script_name, "w") as fptr:
            fptr.write(merge_command + "\n")

        vcover_cmd = [join(self._prefix, 'vsim'), '-c', '-do',
                      'source %s; quit;' % merge_script_name.replace('\\', '/')]

        print("Merging coverage files into %s..." % file_name)
        vcover_merge_process = Process(vcover_cmd,
                                       env=self.get_env())
        vcover_merge_process.consume_output()
        print("Done merging coverage files")
コード例 #2
0
    def merge_coverage(self, file_name, args=None):
        """
        Merge coverage from all test cases,
        """

        merge_command = "onerror {quit -code 1}\n"
        merge_command += "acdb merge"

        for coverage_file in self._coverage_files:
            if file_exists(coverage_file):
                merge_command += " -i {%s}" % fix_path(coverage_file)
            else:
                LOGGER.warning("Missing coverage file: %s", coverage_file)

        if args is not None:
            merge_command += " " + " ".join("{%s}" % arg for arg in args)

        merge_command += " -o {%s}" % fix_path(file_name) + "\n"

        merge_script_name = join(self._output_path, "acdb_merge.tcl")
        with open(merge_script_name, "w") as fptr:
            fptr.write(merge_command + "\n")

        vcover_cmd = [
            join(self._prefix, 'vsimsa'), '-tcl',
            '%s' % fix_path(merge_script_name)
        ]

        print("Merging coverage files into %s..." % file_name)
        vcover_merge_process = Process(vcover_cmd, env=self.get_env())
        vcover_merge_process.consume_output()
        print("Done merging coverage files")
コード例 #3
0
    def post_process(self, output_path):
        """
        Merge coverage from all test cases,
        """

        if self._coverage is None:
            return

        # Teardown to ensure acdb file was written.
        del self._persistent_shell

        merged_coverage_file = join(output_path, "merged_coverage.acdb")
        merge_command = "acdb merge"

        for coverage_file in self._coverage_files:
            if file_exists(coverage_file):
                merge_command += " -i {%s}" % coverage_file.replace('\\', '/')
            else:
                LOGGER.warning("Missing coverage file: %s", coverage_file)

        merge_command += " -o {%s}" % merged_coverage_file.replace('\\', '/')

        vcover_cmd = [
            join(self._prefix, 'vsim'), '-c', '-do',
            '%s; quit;' % merge_command
        ]

        print("Merging coverage files into %s..." % merged_coverage_file)
        vcover_merge_process = Process(vcover_cmd, env=self.get_env())
        vcover_merge_process.consume_output()
        print("Done merging coverage files")
コード例 #4
0
ファイル: modelsim_interface.py プロジェクト: suoto/vunit
    def _create_vsim_process(self):
        """
        Create the vsim process
        """
        ident = threading.current_thread().ident

        with self._lock:
            try:
                vsim_process = self._vsim_processes[ident]
                if vsim_process.is_alive():
                    return vsim_process
            except KeyError:
                pass

            transcript_id = self._transcript_id
            self._transcript_id += 1
            vsim_process = Process([
                join(self._prefix, "vsim"), "-c", "-l",
                join(dirname(self._modelsim_ini),
                     "transcript%i" % transcript_id)])
            self._vsim_processes[ident] = vsim_process

        vsim_process.write("#VUNIT_RETURN\n")
        vsim_process.consume_output(silent_output_consumer)
        return vsim_process
コード例 #5
0
ファイル: modelsim_interface.py プロジェクト: VLSI-EDA/vunit
    def _create_vsim_process(self):
        """
        Create the vsim process
        """
        ident = threading.current_thread().ident

        with self._lock:
            try:
                vsim_process = self._vsim_processes[ident]
                if vsim_process.is_alive():
                    return vsim_process
            except KeyError:
                pass

            transcript_id = self._transcript_id
            self._transcript_id += 1
            vsim_process = Process([join(self._prefix, "vsim"), "-c",
                                    "-l", join(dirname(self._modelsim_ini), "transcript%i" % transcript_id)])
            self._vsim_processes[ident] = vsim_process

        vsim_process.write("#VUNIT_RETURN\n")

        try:
            consumer = SilentOutputConsumer()
            vsim_process.consume_output(consumer)
        except Process.NonZeroExitCode:
            # Print output if background vsim process startup failed
            LOGGER.error("Failed to start re-usable background vsim process")
            print(consumer.output)
            raise

        return vsim_process
コード例 #6
0
    def merge_coverage(self, file_name, args=None):
        """
        Merge coverage from all test cases,
        """

        if self._persistent_shell is not None:
            # Teardown to ensure acdb file was written.
            self._persistent_shell.teardown()

        merge_command = "acdb merge"

        for coverage_file in self._coverage_files:
            if file_exists(coverage_file):
                merge_command += " -i {%s}" % coverage_file.replace('\\', '/')
            else:
                LOGGER.warning("Missing coverage file: %s", coverage_file)

        if args is not None:
            merge_command += " " + " ".join("{%s}" % arg for arg in args)

        merge_command += " -o {%s}" % file_name.replace('\\', '/')

        merge_script_name = join(self._output_path, "acdb_merge.tcl")
        with open(merge_script_name, "w") as fptr:
            fptr.write(merge_command + "\n")

        vcover_cmd = [join(self._prefix, 'vsim'), '-c', '-do',
                      'source %s; quit;' % merge_script_name.replace('\\', '/')]

        print("Merging coverage files into %s..." % file_name)
        vcover_merge_process = Process(vcover_cmd,
                                       env=self.get_env())
        vcover_merge_process.consume_output()
        print("Done merging coverage files")
コード例 #7
0
    def merge_coverage(self, file_name, args=None):
        """
        Merge coverage from all test cases
        """
        if self._persistent_shell is not None:
            # Teardown to ensure ucdb file was written.
            self._persistent_shell.teardown()

        if args is None:
            args = []

        coverage_files = join(self._output_path, "coverage_files.txt")
        vcover_cmd = (
            [join(self._prefix, "vcover"), "merge", "-inputs"]
            + [coverage_files]
            + args
            + [file_name]
        )
        with open(coverage_files, "w") as fptr:
            for coverage_file in self._coverage_files:
                if file_exists(coverage_file):
                    fptr.write(str(coverage_file) + "\n")
                else:
                    LOGGER.warning("Missing coverage file: %s", coverage_file)

        print("Merging coverage files into %s..." % file_name)
        vcover_merge_process = Process(vcover_cmd, env=self.get_env())
        vcover_merge_process.consume_output()
        print("Done merging coverage files")
コード例 #8
0
    def post_process(self, output_path):
        """
        Merge coverage from all test cases,
        top hierarchy level is removed since it has different name in each test case
        """
        if self._coverage is None:
            return

        # Teardown to ensure ucdb file was written.
        del self._persistent_shell

        merged_coverage_file = join(output_path, "merged_coverage.ucdb")
        vcover_cmd = [
            join(self._prefix, 'vcover'), 'merge', '-strip', '1',
            merged_coverage_file
        ]

        for coverage_file in self._coverage_files:
            if file_exists(coverage_file):
                vcover_cmd.append(coverage_file)
            else:
                LOGGER.warning("Missing coverage file: %s", coverage_file)

        print("Merging coverage files into %s..." % merged_coverage_file)
        vcover_merge_process = Process(vcover_cmd, env=self.get_env())
        vcover_merge_process.consume_output()
        print("Done merging coverage files")
コード例 #9
0
ファイル: ghdl_interface.py プロジェクト: jcparrad/vunit
    def simulate(self,  # pylint: disable=too-many-arguments, too-many-locals
                 output_path, library_name, entity_name, architecture_name, config):
        """
        Simulate with entity as top level using generics
        """
        assert config.pli == []

        ghdl_output_path = join(output_path, self.name)
        data_file_name = join(ghdl_output_path, "wave.%s" % self._gtkwave)
        if not exists(ghdl_output_path):
            os.makedirs(ghdl_output_path)

        launch_gtkwave = self._gtkwave is not None and not config.elaborate_only

        status = True
        try:
            cmd = []
            cmd += ['--elab-run']
            cmd += ['--std=%s' % self._std_str()]
            cmd += ['--work=%s' % library_name]
            cmd += ['--workdir=%s' % self._libraries[library_name]]
            cmd += ['-P%s' % path for path in self._libraries.values()]

            if self._has_output_flag():
                cmd += ['-o', join(ghdl_output_path, "%s-%s" % (entity_name, architecture_name))]
            cmd += config.options.get("ghdl_flags", [])

            cmd += [entity_name, architecture_name]

            for name, value in config.generics.items():
                cmd += ['-g%s=%s' % (name, value)]

            cmd += ['--assert-level=%s' % ("warning" if config.fail_on_warning else "error")]

            if config.disable_ieee_warnings:
                cmd += ["--ieee-asserts=disable"]

            if config.elaborate_only:
                cmd += ["--no-run"]

            if launch_gtkwave:
                if exists(data_file_name):
                    os.remove(data_file_name)
                if self._gtkwave == "ghw":
                    cmd += ['--wave=%s' % data_file_name]
                elif self._gtkwave == "vcd":
                    cmd += ['--vcd=%s' % data_file_name]

            proc = Process(['ghdl'] + cmd)
            proc.consume_output()
        except Process.NonZeroExitCode:
            status = False

        if launch_gtkwave:
            cmd = ["gtkwave"] + shlex.split(self._gtkwave_args) + [data_file_name]
            stdout.write("%s\n" % " ".join(cmd))
            subprocess.call(cmd)

        return status
コード例 #10
0
ファイル: ghdl_interface.py プロジェクト: ferdepe/vunit
    def simulate(self,  # pylint: disable=too-many-arguments, too-many-locals
                 output_path, library_name, entity_name, architecture_name, config, elaborate_only):
        """
        Simulate with entity as top level using generics
        """
        assert config.pli == []

        ghdl_output_path = join(output_path, self.name)
        data_file_name = join(ghdl_output_path, "wave.%s" % self._gtkwave)
        if not exists(ghdl_output_path):
            os.makedirs(ghdl_output_path)

        launch_gtkwave = self._gtkwave is not None and not elaborate_only

        status = True
        try:
            cmd = []
            cmd += ['--elab-run']
            cmd += ['--std=%s' % self._std_str()]
            cmd += ['--work=%s' % library_name]
            cmd += ['--workdir=%s' % self._libraries[library_name]]
            cmd += ['-P%s' % path for path in self._libraries.values()]

            if self._has_output_flag():
                cmd += ['-o', join(ghdl_output_path, "%s-%s" % (entity_name, architecture_name))]
            cmd += config.options.get("ghdl.flags", [])

            cmd += [entity_name, architecture_name]

            for name, value in config.generics.items():
                cmd += ['-g%s=%s' % (name, value)]

            cmd += ['--assert-level=%s' % ("warning" if config.fail_on_warning else "error")]

            if config.disable_ieee_warnings:
                cmd += ["--ieee-asserts=disable"]

            if elaborate_only:
                cmd += ["--no-run"]

            if launch_gtkwave:
                if exists(data_file_name):
                    os.remove(data_file_name)
                if self._gtkwave == "ghw":
                    cmd += ['--wave=%s' % data_file_name]
                elif self._gtkwave == "vcd":
                    cmd += ['--vcd=%s' % data_file_name]

            proc = Process([join(self._prefix, 'ghdl')] + cmd)
            proc.consume_output()
        except Process.NonZeroExitCode:
            status = False

        if launch_gtkwave:
            cmd = ["gtkwave"] + shlex.split(self._gtkwave_args) + [data_file_name]
            stdout.write("%s\n" % " ".join(cmd))
            subprocess.call(cmd)

        return status
コード例 #11
0
 def compile_verilog_file(self, source_file_name, library_name):
     try:
         proc = Process(['vlog', '-sv', '-quiet', '-modelsimini', self._modelsim_ini,
                         '-work', library_name, source_file_name])
         proc.consume_output()
     except Process.NonZeroExitCode:
         return False
     return True
コード例 #12
0
 def compile_vhdl_file(self, source_file_name, library_name, vhdl_standard):
     try:
         proc = Process(['vcom', '-quiet', '-modelsimini', self._modelsim_ini,
                         '-' + vhdl_standard, '-work', library_name, source_file_name])
         proc.consume_output()
     except Process.NonZeroExitCode:
         return False
     return True
コード例 #13
0
ファイル: ghdl_interface.py プロジェクト: Aaron-Hartwig/vunit
    def simulate(
            self,  # pylint: disable=too-many-locals
            output_path,
            test_suite_name,
            config,
            elaborate_only):
        """
        Simulate with entity as top level using generics
        """

        script_path = join(output_path, self.name)

        if not exists(script_path):
            os.makedirs(script_path)

        ghdl_e = elaborate_only and config.sim_options.get(
            "ghdl.elab_e", False)

        cmd = self._get_command(config, script_path, ghdl_e)

        if elaborate_only and not ghdl_e:
            cmd += ["--no-run"]

        if self._gtkwave_fmt is not None and not ghdl_e:
            data_file_name = join(script_path, "wave.%s" % self._gtkwave_fmt)

            if exists(data_file_name):
                os.remove(data_file_name)

            if self._gtkwave_fmt == "ghw":
                cmd += ['--wave=%s' % data_file_name]
            elif self._gtkwave_fmt == "vcd":
                cmd += ['--vcd=%s' % data_file_name]

        else:
            data_file_name = None

        status = True
        try:
            proc = Process(cmd)
            proc.consume_output()
        except Process.NonZeroExitCode:
            status = False

        if self._gui and not elaborate_only:
            cmd = ["gtkwave"] + shlex.split(
                self._gtkwave_args) + [data_file_name]

            init_file = config.sim_options.get(
                self.name + ".gtkwave_script.gui", None)
            if init_file is not None:
                cmd += ["--script", "\"{}\"".format(abspath(init_file))]

            stdout.write("%s\n" % " ".join(cmd))
            subprocess.call(cmd)

        return status
コード例 #14
0
ファイル: test_ostools.py プロジェクト: zberkes/vunit
    def test_parses_stderr(self):
        python_script = self.make_file("run_err.py", r"""
from sys import stderr
stderr.write("error\n")
""")
        process = Process([sys.executable, python_script])
        output = []
        process.consume_output(output.append)
        self.assertEqual(output, ["error"])
コード例 #15
0
def simulate(self,
             output_path,
             test_suite_name,
             config,
             elaborate_only,
             env=None):
    """
    Simulate with entity as top level using generics
    """

    if env is None:
        env = os.environ.copy()

    script_path = str(Path(output_path) / self.name)

    if not Path(script_path).exists():
        os.makedirs(script_path)

    ghdl_e = elaborate_only and config.sim_options.get("ghdl.elab_e", False)

    if self._gtkwave_fmt is not None:
        data_file_name = str(
            Path(script_path) / ("wave.%s" % self._gtkwave_fmt))
        if Path(data_file_name).exists():
            remove(data_file_name)
    else:
        data_file_name = None

    cmd = self._get_command(config, script_path, elaborate_only, ghdl_e,
                            data_file_name)

    status = True
    if config.sim_options.get("enable_coverage", False):
        # Set environment variable to put the coverage output in the test_output folder
        coverage_dir = str(Path(output_path) / "coverage")
        env["GCOV_PREFIX"] = coverage_dir
        self._coverage_test_dirs.add(coverage_dir)

    try:
        proc = Process(cmd, env=env)
        proc.consume_output()
    except Process.NonZeroExitCode:
        status = False

    if self._gui and not elaborate_only:
        cmd = ["gtkwave"] + shlex.split(self._gtkwave_args) + [data_file_name]

        init_file = config.sim_options.get(self.name + ".gtkwave_script.gui",
                                           None)
        if init_file is not None:
            cmd += ["--script", "{}".format(str(Path(init_file).resolve()))]

        stdout.write("%s\n" % " ".join(cmd))
        subprocess.call(cmd)

    return status
コード例 #16
0
ファイル: test_ostools.py プロジェクト: tomasnilefrost/vunit
    def test_parses_stderr(self):
        python_script = self.make_file("run_err.py", r"""
from sys import stderr
stderr.write("error\n")
""")
        process = Process(["python", python_script])
        output = []
        process.consume_output(lambda line: output.append(line))
        self.assertEqual(output, ["error"])
        self.assertEqual(process.output, "error\n")
コード例 #17
0
 def compile_vhdl_file(self, source_file_name, library_name, vhdl_standard):
     try:
         proc = Process([
             'vcom', '-quiet', '-modelsimini', self._modelsim_ini,
             '-' + vhdl_standard, '-work', library_name, source_file_name
         ])
         proc.consume_output()
     except Process.NonZeroExitCode:
         return False
     return True
コード例 #18
0
 def compile_verilog_file(self, source_file_name, library_name):
     try:
         proc = Process([
             'vlog', '-sv', '-quiet', '-modelsimini', self._modelsim_ini,
             '-work', library_name, source_file_name
         ])
         proc.consume_output()
     except Process.NonZeroExitCode:
         return False
     return True
コード例 #19
0
    def create_library(self, library_name, path):

        if not file_exists(dirname(path)):
            os.makedirs(dirname(path))

        if not file_exists(path):
            proc = Process(['vlib', '-unix', path])
            proc.consume_output(callback=None)

        try:
            proc = Process(['vmap', '-modelsimini', self._modelsim_ini, library_name])
            proc.consume_output(callback=None)
        except Process.NonZeroExitCode:
            pass

        match = self._vmap_pattern.search(proc.output)
        if match:
            do_vmap = not file_exists(match.group('dir'))
        else:
            do_vmap = False

        if 'No mapping for library' in proc.output:
            do_vmap = True

        if do_vmap:
            proc = Process(['vmap','-modelsimini', self._modelsim_ini, library_name, path])
            proc.consume_output(callback=None)
コード例 #20
0
def run_command(command):
    """
    Run a command
    """
    try:
        proc = Process(command)
        proc.consume_output()
        return True
    except Process.NonZeroExitCode:
        pass
    return False
コード例 #21
0
ファイル: test_ostools.py プロジェクト: zberkes/vunit
    def test_run_basic_subprocess(self):
        python_script = self.make_file("run_basic.py", r"""
from sys import stdout
stdout.write("foo\n")
stdout.write("bar\n")
""")

        output = []
        process = Process([sys.executable, python_script])
        process.consume_output(output.append)
        self.assertEqual(output, ["foo", "bar"])
コード例 #22
0
    def _create_vsim_process(self):
        """
        Create the vsim process
        """

        self._vsim_process = Process([
            "vsim", "-c", "-l",
            join(dirname(self._modelsim_ini), "transcript")
        ])
        self._vsim_process.write("#VUNIT_RETURN\n")
        self._vsim_process.consume_output(OutputConsumer(silent=True))
コード例 #23
0
 def compile_vhdl_file(self, source_file_name, library_name, vhdl_standard):
     """
     Compiles a vhdl file into a specific library using a specfic vhdl_standard
     """
     try:
         proc = Process([join(self._prefix, 'vcom'), '-dbg', '-quiet', '-j', dirname(self._library_cfg),
                         '-' + vhdl_standard, '-work', library_name, source_file_name])
         proc.consume_output()
     except Process.NonZeroExitCode:
         return False
     return True
コード例 #24
0
ファイル: simulator_interface.py プロジェクト: wzab/vunit
def run_command(command, cwd=None, env=None):
    """
    Run a command
    """
    try:
        proc = Process(command, cwd=cwd, env=env)
        proc.consume_output()
        return True
    except Process.NonZeroExitCode:
        pass
    return False
コード例 #25
0
ファイル: activehdl_interface.py プロジェクト: barri/vunit
    def supports_vhdl_package_generics(cls):
        """
        Returns True when this simulator supports VHDL package generics
        """
        proc = Process([join(cls.find_prefix(), 'vcom'), '-version'], env=cls.get_env())
        consumer = VersionConsumer()
        proc.consume_output(consumer)
        if consumer.major is not None:
            return consumer.minor >= 1 if consumer.major == 10 else consumer.major > 10

        return False
コード例 #26
0
ファイル: simulator_interface.py プロジェクト: zberkes/vunit
def run_command(command):
    """
    Run a command
    """
    try:
        proc = Process(command)
        proc.consume_output()
        return True
    except Process.NonZeroExitCode:
        pass
    return False
コード例 #27
0
    def supports_vhdl_package_generics(cls):
        """
        Returns True when this simulator supports VHDL package generics
        """
        proc = Process([join(cls.find_prefix(), 'vcom'), '-version'], env=cls.get_env())
        consumer = VersionConsumer()
        proc.consume_output(consumer)
        if consumer.major is not None:
            return consumer.minor >= 1 if consumer.major == 10 else consumer.major > 10

        return False
コード例 #28
0
ファイル: simulator_interface.py プロジェクト: barri/vunit
def run_command(command, cwd=None, env=None):
    """
    Run a command
    """
    try:
        proc = Process(command, cwd=cwd, env=env)
        proc.consume_output()
        return True
    except Process.NonZeroExitCode:
        pass
    return False
コード例 #29
0
ファイル: test_ostools.py プロジェクト: tomasnilefrost/vunit
    def test_parses_stderr(self):
        python_script = self.make_file(
            "run_err.py", r"""
from sys import stderr
stderr.write("error\n")
""")
        process = Process(["python", python_script])
        output = []
        process.consume_output(lambda line: output.append(line))
        self.assertEqual(output, ["error"])
        self.assertEqual(process.output, "error\n")
コード例 #30
0
    def get_osvvm_coverage_api(cls):
        """
        Returns simulator name when OSVVM coverage API is supported, None otherwise.
        """
        proc = Process([join(cls.find_prefix(), 'vcom'), '-version'])
        consumer = VersionConsumer()
        proc.consume_output(consumer)
        if consumer.year is not None:
            if (consumer.year == 2016 and consumer.month >= 10) or (consumer.year > 2016):
                return cls.name

        return None
コード例 #31
0
ファイル: test_ostools.py プロジェクト: tomasnilefrost/vunit
    def test_run_basic_subprocess(self):
        python_script = self.make_file("run_basic.py", r"""
from sys import stdout
stdout.write("foo\n")
stdout.write("bar\n")
""")

        output = []
        process = Process(["python", python_script])
        process.consume_output(lambda line: output.append(line))
        self.assertEqual(output, ["foo", "bar"])
        self.assertEqual(process.output, "foo\nbar\n")
コード例 #32
0
ファイル: rivierapro_interface.py プロジェクト: omberge/vunit
    def get_osvvm_coverage_api(cls):
        """
        Returns simulator name when OSVVM coverage API is supported, None otherwise.
        """
        proc = Process([join(cls.find_prefix(), 'vcom'), '-version'],
                       env=cls.get_env())
        consumer = VersionConsumer()
        proc.consume_output(consumer)
        if consumer.year is not None:
            if (consumer.year == 2016 and consumer.month >= 10) or (consumer.year > 2016):
                return cls.name

        return None
コード例 #33
0
ファイル: test_ostools.py プロジェクト: tomasnilefrost/vunit
    def test_run_basic_subprocess(self):
        python_script = self.make_file(
            "run_basic.py", r"""
from sys import stdout
stdout.write("foo\n")
stdout.write("bar\n")
""")

        output = []
        process = Process(["python", python_script])
        process.consume_output(lambda line: output.append(line))
        self.assertEqual(output, ["foo", "bar"])
        self.assertEqual(process.output, "foo\nbar\n")
コード例 #34
0
ファイル: test_ostools.py プロジェクト: zberkes/vunit
    def test_output_is_parallel(self):
        python_script = self.make_file("run_timeout.py", r"""
from time import sleep
from sys import stdout
stdout.write("message\n")
stdout.flush()
sleep(1000)
""")

        process = Process([sys.executable, python_script])
        message = process.next_line()
        process.terminate()
        self.assertEqual(message, "message")
コード例 #35
0
    def create_library(self, library_name, path, mapped_libraries=None):
        """
        Create and map a library_name to path
        """
        mapped_libraries = mapped_libraries if mapped_libraries is not None else {}

        if not file_exists(dirname(abspath(path))):
            os.makedirs(dirname(abspath(path)))

        if not file_exists(path):
            proc = Process(
                [join(self._prefix, "vlib"), library_name, path],
                cwd=dirname(self._library_cfg),
                env=self.get_env(),
            )
            proc.consume_output(callback=None)

        if library_name in mapped_libraries and mapped_libraries[
                library_name] == path:
            return

        proc = Process(
            [join(self._prefix, "vmap"), library_name, path],
            cwd=dirname(self._library_cfg),
            env=self.get_env(),
        )
        proc.consume_output(callback=None)
コード例 #36
0
    def _run_batch_file(self, batch_file_name, gui=False):
        """
        Run a test bench in batch by invoking a new vsim process from the command line
        """

        try:
            args = [join(self._prefix, "vsim"), "-gui" if gui else "-c",
                    "-l", join(dirname(batch_file_name), "transcript"),
                    '-do', "source \"%s\"" % fix_path(batch_file_name)]

            proc = Process(args, cwd=dirname(self._sim_cfg_file_name))
            proc.consume_output()
        except Process.NonZeroExitCode:
            return False
        return True
コード例 #37
0
ファイル: vsim_simulator_mixin.py プロジェクト: vmfox/vunit
    def _run_batch_file(self, batch_file_name, gui=False):
        """
        Run a test bench in batch by invoking a new vsim process from the command line
        """

        try:
            args = [join(self._prefix, "vsim"), "-gui" if gui else "-c",
                    "-l", join(dirname(batch_file_name), "transcript"),
                    '-do', "source \"%s\"" % fix_path(batch_file_name)]

            proc = Process(args, cwd=dirname(self._sim_cfg_file_name))
            proc.consume_output()
        except Process.NonZeroExitCode:
            return False
        return True
コード例 #38
0
 def compile_verilog_file(self, source_file_name, library_name, include_dirs):
     """
     Compiles a verilog file into a specific library
     """
     args = [join(self._prefix, 'vlog'), '-quiet', '-sv2k12', '-lc', self._library_cfg,
             '-work', library_name, source_file_name]
     for library in self._libraries.values():
         args += ["-l", library.name]
     for include_dir in include_dirs:
         args += ["+incdir+%s" % include_dir]
     try:
         proc = Process(args)
         proc.consume_output()
     except Process.NonZeroExitCode:
         return False
     return True
コード例 #39
0
ファイル: ghdl_interface.py プロジェクト: varunnagpaal/vunit
 def compile_vhdl_file(self, source_file_name, library_name, library_path, vhdl_standard):
     """
     Compile a vhdl file
     """
     try:
         cmd = ['ghdl', '-a', '--workdir=%s' % library_path,
                '--work=%s' % library_name,
                '--std=%s' % self._std_str()]
         for library_name, library_path in self._libraries.items():
             cmd += ["-P%s" % library_path]
         cmd += [source_file_name]
         proc = Process(cmd)
         proc.consume_output()
     except Process.NonZeroExitCode:
         return False
     return True
コード例 #40
0
    def _run_batch_file(self, batch_file_name, gui=False):
        try:
            args = ['vsim', '-quiet',
                    "-l", join(dirname(batch_file_name), "transcript"),
                    '-do', "do %s" % fix_path(batch_file_name)]
            
            if gui:
                args.append('-gui')
            else:
                args.append('-c')

            proc = Process(args)
            proc.consume_output()
        except Process.NonZeroExitCode:
            return False
        return True
コード例 #41
0
ファイル: rivierapro_interface.py プロジェクト: omberge/vunit
    def _get_mapped_libraries(self, library_cfg_file):
        """
        Get mapped libraries by running vlist on the working directory
        """
        lines = []
        proc = Process([join(self._prefix, 'vlist')], cwd=dirname(library_cfg_file))
        proc.consume_output(callback=lines.append)

        libraries = {}
        for line in lines:
            match = self._library_re.match(line)
            if match is None:
                continue
            key = match.group(1)
            value = match.group(2)
            libraries[key] = abspath(join(dirname(library_cfg_file), dirname(value)))
        return libraries
コード例 #42
0
    def _get_mapped_libraries(self, library_cfg_file):
        """
        Get mapped libraries by running vlist on the working directory
        """
        lines = []
        proc = Process([join(self._prefix, 'vlist')], cwd=dirname(library_cfg_file))
        proc.consume_output(callback=lines.append)

        libraries = {}
        for line in lines:
            match = self._library_re.match(line)
            if match is None:
                continue
            key = match.group(1)
            value = match.group(2)
            libraries[key] = abspath(join(dirname(library_cfg_file), dirname(value)))
        return libraries
コード例 #43
0
    def simulate(
            self,  # pylint: disable=too-many-locals
            output_path,
            test_suite_name,
            config,
            elaborate_only):
        """
        Simulate with entity as top level using generics
        """
        if not exists(output_path):
            os.makedirs(output_path)

        cmd = self._get_sim_command(config, output_path)

        if elaborate_only:
            cmd += ["--no-run"]

        if self._gtkwave_fmt is not None:
            data_file_name = join(output_path, "wave.%s" % self._gtkwave_fmt)

            if exists(data_file_name):
                os.remove(data_file_name)

            if self._gtkwave_fmt == "ghw":
                cmd += ['--wave=%s' % data_file_name]
            elif self._gtkwave_fmt == "vcd":
                cmd += ['--vcd=%s' % data_file_name]

        else:
            data_file_name = None

        status = True
        try:
            proc = Process(cmd)
            proc.consume_output()
        except Process.NonZeroExitCode:
            status = False

        if self._gui and not elaborate_only:
            cmd = ["gtkwave"] + shlex.split(
                self._gtkwave_args) + [data_file_name]
            stdout.write("%s\n" % " ".join(cmd))
            subprocess.call(cmd)

        return status
コード例 #44
0
ファイル: ghdl_interface.py プロジェクト: barri/vunit
    def simulate(self,  # pylint: disable=too-many-locals
                 output_path,
                 test_suite_name,
                 config, elaborate_only):
        """
        Simulate with entity as top level using generics
        """

        script_path = join(output_path, self.name)

        if not exists(script_path):
            os.makedirs(script_path)

        cmd = self._get_sim_command(config, script_path)

        if elaborate_only:
            cmd += ["--no-run"]

        if self._gtkwave_fmt is not None:
            data_file_name = join(script_path, "wave.%s" % self._gtkwave_fmt)

            if exists(data_file_name):
                os.remove(data_file_name)

            if self._gtkwave_fmt == "ghw":
                cmd += ['--wave=%s' % data_file_name]
            elif self._gtkwave_fmt == "vcd":
                cmd += ['--vcd=%s' % data_file_name]

        else:
            data_file_name = None

        status = True
        try:
            proc = Process(cmd)
            proc.consume_output()
        except Process.NonZeroExitCode:
            status = False

        if self._gui and not elaborate_only:
            cmd = ["gtkwave"] + shlex.split(self._gtkwave_args) + [data_file_name]
            stdout.write("%s\n" % " ".join(cmd))
            subprocess.call(cmd)

        return status
コード例 #45
0
 def create_process(ident):
     return Process([
         join(prefix, "vsim"), "-c", "-l",
         join(dirname(sim_cfg_file_name), "transcript%i" % ident),
         "-do",
         abspath(join(dirname(__file__), "tcl_read_eval_loop.tcl"))
     ],
                    cwd=dirname(sim_cfg_file_name),
                    env=env)
コード例 #46
0
    def _run_batch_file(self, batch_file_name, gui=False):
        try:
            args = [
                'vsim', '-quiet', "-l",
                join(dirname(batch_file_name), "transcript"), '-do',
                "do %s" % fix_path(batch_file_name)
            ]

            if gui:
                args.append('-gui')
            else:
                args.append('-c')

            proc = Process(args)
            proc.consume_output()
        except Process.NonZeroExitCode:
            return False
        return True
コード例 #47
0
    def _create_vsim_process(self):
        """
        Create the vsim process
        """

        self._vsim_process = Process(["vsim", "-c",
                                      "-l", join(dirname(self._modelsim_ini), "transcript")])
        self._vsim_process.write("#VUNIT_RETURN\n")
        self._vsim_process.consume_output(OutputConsumer(silent=True))
コード例 #48
0
    def compile_vhdl_file(self, source_file_name, library_name, vhdl_standard):
        """
        Compiles a vhdl file into a specific library using a specfic vhdl_standard
        """
        try:
            if self._coverage is None:
                coverage_args = []
            else:
                coverage_args = ["+cover=" + to_coverage_args(self._coverage)]

            proc = Process([join(self._prefix, 'vcom'), '-quiet', '-modelsimini', self._modelsim_ini] +
                           coverage_args +
                           ['-' + vhdl_standard, '-work', library_name, source_file_name])

            proc.consume_output()
        except Process.NonZeroExitCode:
            return False
        return True
コード例 #49
0
    def _run_batch_file(self, batch_file_name, gui, cwd):
        """
        Run a test bench in batch by invoking a new vsim process from the command line
        """

        todo = "@do -tcl \"\"%s\"\"" % fix_path(batch_file_name)
        if not gui:
            todo = "@onerror {quit -code 1};" + todo

        try:
            args = [join(self._prefix, "vsim"), "-gui" if gui else "-c",
                    "-l", join(dirname(batch_file_name), "transcript"),
                    '-do', todo]

            proc = Process(args, cwd=cwd)
            proc.consume_output()
        except Process.NonZeroExitCode:
            return False
        return True
コード例 #50
0
    def _run_batch_file(self, batch_file_name, gui, cwd):
        """
        Run a test bench in batch by invoking a new vsim process from the command line
        """

        todo = "@do -tcl \"\"%s\"\"" % fix_path(batch_file_name)
        if not gui:
            todo = "@onerror {quit -code 1};" + todo

        try:
            args = [join(self._prefix, "vsim"), "-gui" if gui else "-c",
                    "-l", join(dirname(batch_file_name), "transcript"),
                    '-do', todo]

            proc = Process(args, cwd=cwd, env=self.get_env())
            proc.consume_output()
        except Process.NonZeroExitCode:
            return False
        return True
コード例 #51
0
ファイル: modelsim_interface.py プロジェクト: cmarqu/vunit
    def create_library(self, library_name, path, mapped_libraries=None):
        """
        Create and map a library_name to path
        """
        mapped_libraries = mapped_libraries if mapped_libraries is not None else {}

        if not file_exists(dirname(abspath(path))):
            os.makedirs(dirname(abspath(path)))

        if not file_exists(path):
            proc = Process([join(self._prefix, 'vlib'), '-unix', path])
            proc.consume_output(callback=None)

        if library_name in mapped_libraries and mapped_libraries[library_name] == path:
            return

        cfg = parse_modelsimini(self._modelsim_ini)
        cfg.set("Library", library_name, path)
        write_modelsimini(cfg, self._modelsim_ini)
コード例 #52
0
ファイル: modelsim_interface.py プロジェクト: suoto/vunit
    def _run_batch_file(self, batch_file_name, gui=False):
        """
        Run a test bench in batch by invoking a new vsim process from the command line
        """

        try:
            args = [join(self._prefix, 'vsim'), '-quiet',
                    "-l", join(dirname(batch_file_name), "transcript"),
                    '-do', "do %s" % fix_path(batch_file_name)]

            if gui:
                args.append('-gui')
            else:
                args.append('-c')

            proc = Process(args)
            proc.consume_output()
        except Process.NonZeroExitCode:
            return False
        return True
コード例 #53
0
    def create_library(self, library_name, path, mapped_libraries=None):
        """
        Create and map a library_name to path
        """
        mapped_libraries = mapped_libraries if mapped_libraries is not None else {}

        if not file_exists(dirname(abspath(path))):
            os.makedirs(dirname(abspath(path)))

        if not file_exists(path):
            proc = Process([join(self._prefix, 'vlib'), '-unix', path],
                           env=self.get_env())
            proc.consume_output(callback=None)

        if library_name in mapped_libraries and mapped_libraries[library_name] == path:
            return

        cfg = parse_modelsimini(self._sim_cfg_file_name)
        cfg.set("Library", library_name, path)
        write_modelsimini(cfg, self._sim_cfg_file_name)
コード例 #54
0
ファイル: test_ostools.py プロジェクト: zberkes/vunit
    def test_run_error_subprocess(self):
        python_script = self.make_file("run_err.py", r"""
from sys import stdout
stdout.write("error\n")
exit(1)
""")
        process = Process([sys.executable, python_script])
        output = []
        self.assertRaises(Process.NonZeroExitCode,
                          process.consume_output, output.append)
        self.assertEqual(output, ["error"])
コード例 #55
0
    def _run_batch_file(self, batch_file_name, gui):
        """
        Run a test bench in batch by invoking a new vsim process from the command line
        """

        try:
            args = [
                join(self._prefix, "vsim"),
                "-gui" if gui else "-c",
                "-l",
                join(dirname(batch_file_name), "transcript"),
                "-do",
                'source "%s"' % fix_path(batch_file_name),
            ]

            os.environ["VSIMSALIBRARYCFG"] = dirname(self._library_cfg)
            proc = Process(args, cwd=dirname(self._library_cfg))
            proc.consume_output()
        except Process.NonZeroExitCode:
            return False
        return True
コード例 #56
0
    def create_library(self, library_name, path, mapped_libraries=None):
        """
        Create and map a library_name to path
        """
        mapped_libraries = mapped_libraries if mapped_libraries is not None else {}

        if not file_exists(dirname(path)):
            os.makedirs(dirname(path))

        if not file_exists(path):
            proc = Process([join(self._prefix, 'vlib'), '-unix', path])
            proc.consume_output(callback=None)

        if library_name in mapped_libraries and mapped_libraries[library_name] == path:
            return

        cfg = RawConfigParser()
        cfg.read(self._modelsim_ini)
        cfg.set("Library", library_name, path)
        with open(self._modelsim_ini, "w") as optr:
            cfg.write(optr)
コード例 #57
0
ファイル: modelsim_interface.py プロジェクト: mbeziouch/vunit
    def _create_vsim_process(self):
        """
        Create the vsim process
        """
        ident = threading.current_thread().ident

        with self._lock:
            try:
                vsim_process = self._vsim_processes[ident]
                if vsim_process.is_alive():
                    return vsim_process
            except KeyError:
                pass

            transcript_id = self._transcript_id
            self._transcript_id += 1
            vsim_process = Process([
                join(self._prefix, "vsim"), "-c", "-l",
                join(dirname(self._modelsim_ini),
                     "transcript%i" % transcript_id)
            ])
            self._vsim_processes[ident] = vsim_process

        vsim_process.write("#VUNIT_RETURN\n")
        vsim_process.consume_output(silent_output_consumer)
        return vsim_process