コード例 #1
0
def run_test():
    random.seed(0)
    # Initialize vunit with command line parameters.
    vu = config.setup_vunit()
    # Set up logging.
    config.setup_logging(vu.log_level)
    # Get filenames for test
    import os
    this_dir = os.path.dirname(os.path.realpath(__file__))
    filenames = [
        os.path.join(this_dir, 'complex_pkg.vhd'),
        os.path.join(this_dir, 'complex_mag2.vhd'),
    ]
    # Register the test with VUnit.
    test_output_directory = os.path.join(this_dir, 'generated')
    test_utils.register_test_with_vunit(
        vu=vu,
        directory=test_output_directory,
        filenames=filenames,
        top_entity='complex_mag2',
        all_generics=[{}],
        test_class=ComplexMag2Test,
        top_params={},
    )
    # Run the tests with VUnit
    vu.set_sim_option('disable_ieee_warnings', True)
    vu.main()
コード例 #2
0
def run_vunit(tests, cores_roots, test_output_directory):
    '''
    Setup vunit, register the tests, and run them.
    '''
    vu = config.setup_vunit()
    config.setup_logging(vu.log_level)
    for test in tests:
        register_coretest_with_vunit(vu, test, test_output_directory)
    vu.main()
コード例 #3
0
from slvcodec import entity, package, typs, config, symbolic_math

vhdl_dir = os.path.join(os.path.dirname(__file__), 'vhdl')


def test_dummy_width():
    # Parse and process entity
    entity_filename = os.path.join(vhdl_dir, 'dummy.vhd')
    parsed_entity = package.parsed_from_filename(entity_filename)
    processed_entity = entity.process_parsed_entity(parsed_entity)
    # Parse and process packages
    package_filenames = [os.path.join(vhdl_dir, 'vhdl_type_pkg.vhd')]
    packages = package.parse_process_and_resolve_packages(package_filenames)
    # Resolve the entity with the constants and types defined in the package.
    resolved_entity = processed_entity.resolve(packages=packages)
    # And get the ports from the resolved entity.
    o_data = resolved_entity.ports['o_data']
    i_dummy = resolved_entity.ports['i_dummy']
    # i_dummy width can be resolved without generics
    assert (i_dummy.typ.width.value() == 23)
    # o_data depends on the generic parameter size.
    length = 2
    w = typs.make_substitute_generics_function({'length':
                                                length})(o_data.typ.width)
    assert (w.value() == length * 6)


if __name__ == '__main__':
    config.setup_logging(logging.DEBUG)
    test_dummy_width()