Skip to content

Commit

Permalink
Made modelsim_interface use explicit installation prefix.
Browse files Browse the repository at this point in the history
  • Loading branch information
kraigher committed Sep 11, 2015
1 parent 2345135 commit 9a78e4e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions vunit/modelsim_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def __init__(self, modelsim_ini="modelsim.ini", persistent=False, gui_mode=None)
self._vsim_processes = {}
self._lock = threading.Lock()
self._transcript_id = 0
self._prefix = dirname(find_executable('vsim'))

self._persistent = persistent
self._gui_mode = gui_mode
Expand All @@ -110,7 +111,7 @@ def _create_vsim_process(self):

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

Expand All @@ -128,7 +129,8 @@ def _create_modelsim_ini(self):
try:
env = os.environ.copy()
del env["MODELSIM"]
output = subprocess.check_output(['vmap', '-c'], cwd=cwd, stderr=subprocess.PIPE, env=env)
output = subprocess.check_output([join(self._prefix, 'vmap'), '-c'],
cwd=cwd, stderr=subprocess.PIPE, env=env)
except subprocess.CalledProcessError as exc:
LOGGER.error("Failed to create %s by running 'vmap -c' in %s exit code was %i",
self._modelsim_ini, cwd, exc.returncode)
Expand Down Expand Up @@ -165,7 +167,7 @@ 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(['vcom', '-quiet', '-modelsimini', self._modelsim_ini,
proc = Process([join(self._prefix, 'vcom'), '-quiet', '-modelsimini', self._modelsim_ini,
'-' + vhdl_standard, '-work', library_name, source_file_name])
proc.consume_output()
except Process.NonZeroExitCode:
Expand All @@ -177,7 +179,7 @@ def compile_verilog_file(self, source_file_name, library_name):
Compiles a verilog file into a specific library
"""
try:
proc = Process(['vlog', '-sv', '-quiet', '-modelsimini', self._modelsim_ini,
proc = Process([join(self._prefix, 'vlog'), '-sv', '-quiet', '-modelsimini', self._modelsim_ini,
'-work', library_name, source_file_name])
proc.consume_output()
except Process.NonZeroExitCode:
Expand All @@ -194,13 +196,13 @@ def create_library(self, library_name, path, mapped_libraries=None):
os.makedirs(dirname(path))

if not file_exists(path):
proc = Process(['vlib', '-unix', 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

proc = Process(['vmap', '-modelsimini', self._modelsim_ini, library_name, path])
proc = Process([join(self._prefix, 'vmap'), '-modelsimini', self._modelsim_ini, library_name, path])
proc.consume_output(callback=None)

def _get_mapped_libraries(self):
Expand Down Expand Up @@ -411,14 +413,13 @@ def _create_gui_run_script(common_file_name):
""" % fix_path(common_file_name)
return tcl

@staticmethod
def _run_batch_file(batch_file_name, gui=False):
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 = ['vsim', '-quiet',
args = [join(self._prefix, 'vsim'), '-quiet',
"-l", join(dirname(batch_file_name), "transcript"),
'-do', "do %s" % fix_path(batch_file_name)]

Expand Down

0 comments on commit 9a78e4e

Please sign in to comment.