How to use edalize - 10 common examples

To help you get started, we’ve selected a few edalize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github olofk / edalize / tests / test_edam.py View on Github external
def test_empty_edam():
    import tempfile
    from edalize import get_edatool

    (h, edam_file) = tempfile.mkstemp()

    with pytest.raises(TypeError):
        backend = get_edatool('icarus')(edam=None)
github olofk / fusesoc / tests / edalize / edalize_common.py View on Github external
def setup_backend_minimal(name, tool, files):
    os.environ['PATH'] = os.path.join(tests_dir, 'mock_commands')+':'+os.environ['PATH']

    work_root = tempfile.mkdtemp(prefix=tool+'_')

    eda_api = {'name'         : name,
               'files'        : files,
               'toplevel'     : 'top_module',
    }
    return (get_edatool(tool)(eda_api=eda_api,
                              work_root=work_root), work_root)
github olofk / edalize / tests / test_edam.py View on Github external
def test_edam_files():
    from edalize import get_edatool
    files = [{'name' : 'plain_file'},
             {'name' : 'subdir/plain_include_file',
              'is_include_file' : True},
             {'name' : 'file_with_args',
              'file_type' : 'verilogSource',
              'logical_name' : 'libx'},
             {'name' : 'include_file_with_args',
              'is_include_file' : True,
              'file_type' : 'verilogSource',
              'logical_name' : 'libx'}]
    edam = {'files' : files,
               'name' : 'test_edam_files'}

    backend = get_edatool('icarus')(edam=edam)
    (parsed_files, incdirs) = backend._get_fileset_files()

    assert len(parsed_files) == 2
    assert parsed_files[0].name         == 'plain_file'
    assert parsed_files[0].file_type    == ''
    assert parsed_files[0].logical_name == ''
    assert parsed_files[1].name         == 'file_with_args'
    assert parsed_files[1].file_type    == 'verilogSource'
    assert parsed_files[1].logical_name == 'libx'

    assert incdirs == ['subdir', '.']
github olofk / fusesoc / tests / edalize / test_verilator.py View on Github external
def test_verilator_run():
    import os.path
    import tempfile
    import yaml
    from edalize import get_edatool
    ref_dir_cc = os.path.join(ref_dir, 'cc')

    work_root    = tempfile.mkdtemp()
    eda_api_file = os.path.join(ref_dir_cc, core_name)+ '.eda.yml'
    backend = get_edatool(tool)(eda_api=yaml.load(open(eda_api_file)), work_root=work_root)
    dummy_exe = 'V'+backend.tool_options['top_module']
    shutil.copy(os.path.join(ref_dir, dummy_exe),
                os.path.join(work_root, dummy_exe))

    backend.run(params)

    compare_files(ref_dir, work_root, ['run.cmd'])
github olofk / fusesoc / tests / edalize / test_icarus.py View on Github external
import tempfile

    from edalize import get_edatool

    from edalize_common import compare_files, tests_dir

    ref_dir      = os.path.join(tests_dir, __name__, 'minimal')
    os.environ['PATH'] = os.path.join(tests_dir, 'mock_commands')+':'+os.environ['PATH']
    tool = 'icarus'
    name = 'test_'+tool+'_minimal_0'
    work_root = tempfile.mkdtemp(prefix=tool+'_')

    eda_api = {'name'         : name,
               'toplevel' : 'top'}

    backend = get_edatool(tool)(eda_api=eda_api, work_root=work_root)
    backend.configure([])

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

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

    backend.run([])

    compare_files(ref_dir, work_root, ['vvp.cmd'])
github olofk / fusesoc / tests / edalize / test_eda_api.py View on Github external
import tempfile
    from edalize import get_edatool

    tests_dir = os.path.dirname(__file__)
    ref_dir   = os.path.join(tests_dir, __name__)

    script = 'exit_1_script'
    hooks = {'pre_build' : [
        {'cmd' : ['sh', os.path.join(ref_dir, script)],
         'name' : script}]}

    work_root = tempfile.mkdtemp(prefix='eda_api_hooks_')
    eda_api = {'hooks' : hooks,
               'name' : script}

    backend = get_edatool('icarus')(eda_api=eda_api,
                                    work_root=work_root)
    with pytest.raises(RuntimeError):
        backend.build()
github olofk / edalize / tests / test_vunit.py View on Github external
ref_dir = os.path.join(tests_dir, __name__, 'minimal')
    tool = 'vunit'
    name = 'test_' + tool + '_minimal_0'
    work_root = str(tmpdir)

    files = [{'name' : os.path.join(ref_dir, 'vunit_runner_test.py'),
              'file_type' : 'pythonSource-3.7'},
             {'name' : os.path.join(ref_dir, 'tb_minimal.vhd'),
              'file_type' : 'vhdlSource-2008',
              'logical_name' : 'libx'}]

    edam = {'name'     : name,
            'files'    : files,
            'toplevel' : 'top'}

    backend = get_edatool(tool)(edam=edam, work_root=work_root)

    original_impl = subprocess.check_call

    def subprocess_intercept(args, **kwargs):
        if len(args) > 1 and args[1].endswith('run.py'):
            import sys
            with patch.object(sys, 'argv', args):
                spec = importlib.util.spec_from_file_location("__main__", args[1])
                runner_script = importlib.util.module_from_spec(spec)

                spec.loader.exec_module(runner_script)
        else:
            original_impl(args, **kwargs)

    with mock.patch('subprocess.check_call', new=subprocess_intercept):
        backend.configure()
github olofk / edalize / tests / test_icarus.py View on Github external
import os

    from edalize import get_edatool

    from edalize_common import compare_files, tests_dir

    ref_dir      = os.path.join(tests_dir, __name__, 'minimal')
    os.environ['PATH'] = os.path.join(tests_dir, 'mock_commands')+':'+os.environ['PATH']
    tool = 'icarus'
    name = 'test_'+tool+'_minimal_0'
    work_root = str(tmpdir)

    edam = {'name'         : name,
               'toplevel' : 'top'}

    backend = get_edatool(tool)(edam=edam, work_root=work_root)
    backend.configure()

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

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

    backend.run()

    compare_files(ref_dir, work_root, ['vvp.cmd'])
github olofk / fusesoc / fusesoc / main.py View on Github external
logger.error(e.msg)
            exit(1)
        except RuntimeError as e:
            logger.error("Setup failed : {}".format(str(e)))
            exit(1)
        edalizer.to_yaml(eda_api_file)

    #Frontend/backend separation

    try:
        if do_configure:
            edam = edalizer.edalize
        else:
            import yaml
            edam = yaml.safe_load(open(eda_api_file))
        backend = get_edatool(tool)(edam=edam,
                                    work_root=work_root)

    except ImportError:
        logger.error('Backend "{}" not found'.format(tool))
        exit(1)
    except RuntimeError as e:
        logger.error(str(e))
        exit(1)
    except FileNotFoundError as e:
        logger.error('Could not find EDA API file "{}"'.format(e.filename))
        exit(1)

    if do_configure:
        try:
            backend.configure(backendargs)
            print('')
github olofk / edalize / edalize / vunit.py View on Github external
import os
import sys
import logging
from collections import OrderedDict
from edalize.edatool import Edatool

logger = logging.getLogger(__name__)


class Vunit(Edatool):
    argtypes = ["cmdlinearg"]
    testrunner_template = "run.py.j2"
    testrunner = "run.py"

    @classmethod
    def get_doc(cls, api_ver):
        if api_ver == 0:
            return {
                "description": "VUnit testing framework",
                "members": [
                    {
                        "name": "vunit_runner",
                        "type": "String",
                        "desc": 'Name of the Python file exporting a "VUnitRunner" class that is used to configure and execute test',
                    }
                ],

edalize

Library for interfacing EDA tools such as simulators, linters or synthesis tools, using a common interface

BSD-2-Clause
Latest version published 6 months ago

Package Health Score

69 / 100
Full package analysis

Similar packages