Skip to content

Commit

Permalink
Add "run_options" to VCS (#28)
Browse files Browse the repository at this point in the history
* VCS: Support runtime options

Introduce `run_options` to pass options to the simulation when running
it. (`vcs_options` is passed to VCS when compiling the simulation).

* VCS: Rename test_vcs2 to test_no_tool_options

And put the test files into a separate directory
  • Loading branch information
imphil authored and olofk committed May 9, 2019
1 parent 710ee27 commit 64bf171
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 17 deletions.
3 changes: 2 additions & 1 deletion doc/edam/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ vcs
================ ===================== ===========
Field Name Type Description
================ ===================== ===========
vcs_options List of String Extra options for VCS
vcs_options List of String Compile time options passed to ``vcs``
run_options List of String Runtime options passed to the simulation
================ ===================== ===========

verilator
Expand Down
4 changes: 2 additions & 2 deletions edalize/templates/vcs/Makefile.j2
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
all: {{ name }}

{{ name }}: {{ name }}.scr
vcs -full64 -top {{ toplevel }} -f {{ name }}.scr -o $@ {% for option in tool_options %} {{ option }} {% endfor %}
vcs -full64 -top {{ toplevel }} -f {{ name }}.scr -o $@ {% for option in vcs_options %} {{ option }}{% endfor %}

run: {{ name }}
./{{ name }} -l vcs.log {% for plusarg in plusargs %} {{ plusarg }} {% endfor %}
./{{ name }} -l vcs.log {% for plusarg in plusargs %} {{ plusarg }} {% endfor %}{% for option in run_options %} {{ option }}{% endfor %}

clean:
$(RM) {{ name }}
27 changes: 25 additions & 2 deletions edalize/vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,32 @@

logger = logging.getLogger(__name__)


class Vcs(Edatool):

_description = """ Synopsys VCS Backend
VCS is one of the "Big 3" simulators.
Example snippet of a CAPI2 description file for VCS:
.. code:: yaml
vcs:
vcs_options:
# Compile-time options passed to the vcs command
- -debug_access+pp
- -debug_access+all
run_options:
# Run-time options passed to the simulation itself
- -licqueue
"""

tool_options = {
'lists' : {'vcs_options' : 'String'}
'lists' : {
'vcs_options' : 'String', # compile-time options (passed to VCS)
'run_options' : 'String', # runtime options (passed to simulation)
}
}

argtypes = ['plusarg', 'vlogdefine', 'vlogparam']
Expand All @@ -24,7 +46,8 @@ def configure_main(self):

template_vars = {
'name' : self.name,
'tool_options' : self.tool_options.get('vcs_options', []),
'vcs_options' : self.tool_options.get('vcs_options', []),
'run_options' : self.tool_options.get('run_options', []),
'toplevel' : self.toplevel,
'plusargs' : plusargs
}
Expand Down
44 changes: 32 additions & 12 deletions tests/test_vcs.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
import pytest

def test_vcs2():

def test_vcs_tool_options():
import os
import shutil
from edalize_common import compare_files, setup_backend, tests_dir

ref_dir = os.path.join(tests_dir, __name__, 'tool_options')
paramtypes = ['plusarg', 'vlogdefine', 'vlogparam']
name = 'test_vcs_tool_options_0'
tool = 'vcs'
tool_options = {
'vcs_options' : [ '-debug_access+pp', '-debug_access+all' ],
'run_options' : [ '-licqueue' ],
}

(backend, args, work_root) = setup_backend(paramtypes, name, tool, tool_options, use_vpi=False)
backend.configure(args)

compare_files(ref_dir, work_root, ['Makefile', name + '.scr' ])

backend.build()
compare_files(ref_dir, work_root, ['vcs.cmd'])

backend.run(args)

compare_files(ref_dir, work_root, ['run.cmd'])


def test_vcs_no_tool_options():
import os
import shutil
from edalize_common import compare_files, setup_backend, tests_dir

ref_dir = os.path.join(tests_dir, __name__)
ref_dir = os.path.join(tests_dir, __name__, 'no_tool_options')
paramtypes = ['plusarg', 'vlogdefine', 'vlogparam']
name = 'test_vcs_0'
tool = 'vcs'
tool_options = {}
# tool_options = {
# 'iverilog_options' : ['some', 'iverilog_options'],
# 'timescale' : '1ns/1ns',
# }

(backend, args, work_root) = setup_backend(paramtypes, name, tool, tool_options, use_vpi=False)
backend.configure(args)

compare_files(ref_dir, work_root, ['Makefile',
name+'.scr',
])
compare_files(ref_dir, work_root, ['Makefile', name + '.scr' ])

backend.build()
compare_files(ref_dir, work_root, ['vcs.cmd'])
Expand Down Expand Up @@ -50,9 +72,7 @@ def test_vcs_minimal():
backend = get_edatool(tool)(edam=edam, work_root=work_root)
backend.configure([])

compare_files(ref_dir, work_root, ['Makefile',
name+'.scr',
])
compare_files(ref_dir, work_root, ['Makefile', name + '.scr' ])

backend.build()
compare_files(ref_dir, work_root, ['vcs.cmd'])
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions tests/test_vcs/tool_options/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
all: test_vcs_tool_options_0

test_vcs_tool_options_0: test_vcs_tool_options_0.scr
vcs -full64 -top top_module -f test_vcs_tool_options_0.scr -o $@ -debug_access+pp -debug_access+all
run: test_vcs_tool_options_0
./test_vcs_tool_options_0 -l vcs.log +plusarg_bool=1 +plusarg_int=42 +plusarg_str=hello -licqueue
clean:
$(RM) test_vcs_tool_options_0
1 change: 1 addition & 0 deletions tests/test_vcs/tool_options/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-l vcs.log +plusarg_bool=1 +plusarg_int=42 +plusarg_str=hello -licqueue
10 changes: 10 additions & 0 deletions tests/test_vcs/tool_options/test_vcs_tool_options_0.scr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
+define+vlogdefine_bool=1
+define+vlogdefine_int=42
+define+vlogdefine_str=hello
+parameter+top_module.vlogparam_bool=1
+parameter+top_module.vlogparam_int=42
+parameter+top_module.vlogparam_str="hello"
+incdir+.
sv_file.sv
vlog_file.v
vlog05_file.v
1 change: 1 addition & 0 deletions tests/test_vcs/tool_options/vcs.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-full64 -top top_module -f test_vcs_tool_options_0.scr -o test_vcs_tool_options_0 -debug_access+pp -debug_access+all

0 comments on commit 64bf171

Please sign in to comment.