Esempio n. 1
0
def test_trellis_minimal(make_edalize_test):
    tf = make_edalize_test('trellis',
                           param_types=[],
                           files=[],
                           ref_dir='minimal')

    run_trellis_test(tf)
Esempio n. 2
0
def test_gatemate_multiple_ccf(make_edalize_test):
    files = [
        {
            "name": "ccf_file.ccf",
            "file_type": "CCF"
        },
        {
            "name": "ccf_file2.ccf",
            "file_type": "CCF"
        },
    ]
    tool_options = {
        "device": "CCGM1A1",
    }
    tf = make_edalize_test(
        "gatemate",
        param_types=[],
        files=files,
        tool_options=tool_options,
    )

    with pytest.raises(RuntimeError) as e:
        tf.backend.configure()
    assert (
        "p_r only supports one ccf file. Found ccf_file.ccf and ccf_file2.ccf"
        in str(e.value))
Esempio n. 3
0
def test_ghdl_03(make_edalize_test):
    tf = make_edalize_test(
        "ghdl",
        ref_dir="test03",
        test_name="test_ghdl_03",
        param_types=["generic"],
        files=LOCAL_FILES,
        tool_options={
            "analyze_options": ["--std=08", "--ieee=synopsys"],
            "run_options": ["a", "few", "run_options"],
        },
    )

    for vhdl_file in ["vhdl_file.vhd", "vhdl_lfile", "vhdl2008_file"]:
        with open(os.path.join(tf.work_root, vhdl_file), "a"):
            os.utime(os.path.join(tf.work_root, vhdl_file), None)

    tf.backend.configure()

    tf.compare_files(["Makefile"])

    tf.backend.build()
    tf.compare_files(["analyze.cmd"])

    tf.backend.run()
    tf.compare_files(["elab-run.cmd"])
Esempio n. 4
0
def test_mistral_no_device(make_edalize_test):
    tf = make_edalize_test("mistral", param_types=[])

    with pytest.raises(RuntimeError) as e:
        tf.backend.configure()
    assert "Missing required option 'device' for nextpnr-mistral" in str(
        e.value)
Esempio n. 5
0
def test_xcelium(make_edalize_test):
    tool_options = {
        'xmvhdl_options' : ['various', 'xmvhdl_options'],
        'xmvlog_options' : ['some', 'xmvlog_options'],
        'xmsim_options' : ['a', 'few', 'xmsim_options'],
        'xrun_options' : ['plenty', 'of', 'xrun_options'],
    }

    #FIXME: Add VPI tests
    tf = make_edalize_test('xcelium', tool_options=tool_options)

    tf.backend.configure()
    tf.compare_files(['Makefile',
                      'edalize_build_rtl.f',
                      'edalize_main.f'])

    orig_env = os.environ.copy()
    try:
        os.environ['PATH'] = '{}:{}'.format(os.path.join(tests_dir, 'mock_commands/xcelium'),
                                            os.environ['PATH'])

        # For some strange reason, writing to os.environ['PATH'] doesn't update the environment. This
        # leads to test fails, but only when running multiple tests. When running this test by itself,
        # everything works fine without the 'putenv'.
        os.putenv('PATH', os.environ['PATH'])

        tf.backend.build()
        os.makedirs(os.path.join(tf.work_root, 'work'))

        tf.backend.run()
        tf.compare_files(['xrun.cmd'])
    finally:
        os.environ = orig_env
Esempio n. 6
0
def test_ghdl_04(make_edalize_test):
    tf = make_edalize_test(
        "ghdl",
        ref_dir="test04",
        param_types=["generic"],
        tool_options={
            "analyze_options": ["some", "analyze_options"],
            "run_options": ["a", "few", "run_options"],
        },
        toplevel="libx.vhdl_lfile",
    )

    for vhdl_file in ["vhdl_file.vhd", "vhdl_lfile", "vhdl2008_file"]:
        with open(os.path.join(tf.work_root, vhdl_file), "a"):
            os.utime(os.path.join(tf.work_root, vhdl_file), None)

    tf.backend.configure()

    tf.compare_files(["Makefile"])

    tf.backend.build()
    tf.compare_files(["analyze.cmd"])

    tf.backend.run()
    tf.compare_files(["elab-run.cmd"])
Esempio n. 7
0
def test_symbiflow_vtr(make_edalize_test):
    tool = "symbiflow"
    tool_options = {
        "part": "xc7a35tcsg324-1",
        "package": "csg324-1",
        "vendor": "xilinx",
        "pnr": "vtr",
        "vpr_options": "--fake_option 1000"
    }

    files = [
        {
            "name": "top.xdc",
            "file_type": "xdc"
        },
        {
            "name": "top.sdc",
            "file_type": "SDC"
        },
        {
            "name": "top.pcf",
            "file_type": "PCF"
        },
    ]
    tf = make_edalize_test("symbiflow",
                           test_name="test_symbiflow_vtr_0",
                           param_types=["vlogdefine", "vlogparam"],
                           tool_options=tool_options,
                           files=files,
                           ref_dir="vtr")

    run_symbiflow_test(tf)
Esempio n. 8
0
def test_symbiflow_nextpnr_xilinx(make_edalize_test):
    tool = "symbiflow"
    tool_options = {
        "arch": "xilinx",
        "part": "xc7a35tcsg324-1",
        "package": "csg324-1",
        "vendor": "xilinx",
        "pnr": "nextpnr",
        "nextpnr_options": "--fake_option 1000"
    }

    files = [
        {"name": "top.xdc", "file_type": "xdc"},
        {"name": "chipdb.bin", "file_type": "bba"},
    ]

    test_name = "test_symbiflow_nextpnr_xilinx_0"
    tf = make_edalize_test("symbiflow",
                           test_name=test_name,
                           param_types=["vlogdefine", "vlogparam"],
                           tool_options=tool_options,
                           files=files,
                           ref_dir=os.path.join("nextpnr", "xilinx"))

    config_files = [
        "edalize_yosys_procs.tcl",
        "edalize_yosys_template.tcl",
        "{}.mk".format(test_name),
        "{}-nextpnr.mk".format(test_name),
    ]

    run_symbiflow_test(tf, config_files)
Esempio n. 9
0
def test_xcelium(make_edalize_test):
    tool_options = {
        "xmvhdl_options": ["various", "xmvhdl_options"],
        "xmvlog_options": ["some", "xmvlog_options"],
        "xmsim_options": ["a", "few", "xmsim_options"],
        "xrun_options": ["plenty", "of", "xrun_options"],
    }

    # FIXME: Add VPI tests
    tf = make_edalize_test("xcelium", tool_options=tool_options)

    tf.backend.configure()
    tf.compare_files(["Makefile", "edalize_build_rtl.f", "edalize_main.f"])

    orig_env = os.environ.copy()
    try:
        os.environ["PATH"] = "{}:{}".format(
            os.path.join(tests_dir, "mock_commands/xcelium"), os.environ["PATH"]
        )

        # For some strange reason, writing to os.environ['PATH'] doesn't update the environment. This
        # leads to test fails, but only when running multiple tests. When running this test by itself,
        # everything works fine without the 'putenv'.
        os.putenv("PATH", os.environ["PATH"])

        tf.backend.build()
        os.makedirs(os.path.join(tf.work_root, "work"))

        tf.backend.run()
        tf.compare_files(["xrun.cmd"])
    finally:
        os.environ = orig_env
Esempio n. 10
0
def test_trellis_minimal(make_edalize_test):
    tf = make_edalize_test("trellis",
                           param_types=[],
                           files=[],
                           ref_dir="minimal")

    run_trellis_test(tf)
Esempio n. 11
0
def test_rivierapro(make_edalize_test):
    tool_options = {
        'vlog_options': ['some', 'vlog_options'],
        'vsim_options': ['a', 'few', 'vsim_options'],
    }

    # FIXME: Add VPI tests
    tf = make_edalize_test('rivierapro', tool_options=tool_options)
    tf.backend.configure()

    tf.compare_files(
        ['edalize_build_rtl.tcl', 'edalize_launch.tcl', 'edalize_main.tcl'])

    orig_env = os.environ.copy()
    try:
        os.environ['ALDEC_PATH'] = os.path.join(tests_dir, 'mock_commands')

        tf.backend.build()
        os.makedirs(os.path.join(tf.work_root, 'work'))

        tf.compare_files(['vsim.cmd'])

        tf.backend.run()

        assert filecmp.cmp(os.path.join(tf.ref_dir, 'vsim2.cmd'),
                           os.path.join(tf.work_root, 'vsim.cmd'),
                           shallow=False)
    finally:
        os.environ = orig_env
Esempio n. 12
0
def test_symbiyosys(make_edalize_test):
    tf = make_edalize_test(
        "symbiyosys",
        param_types=["vlogdefine", "vlogparam"],
        tool_options={
            "tasknames": ["task0", "task1"],
        },
    )

    # Copy our example configuration file to the work root. The name matches an
    # entry in edalize_common's FILES list. Note that we chose a name that
    # doesn't collide with test.sby (the file that the tool generates, in the
    # same directory).
    tf.copy_to_work_root("config.sby.j2")

    tf.backend.configure()

    # The configure step is supposed to interpolate the .sby file and dump
    # lists of RTL files and include directories. (These are needed if you want
    # to use sv2v as a fusesoc pre_build hook).
    tf.compare_files(["test.sby", "files.txt", "incdirs.txt"])

    # The 'build' step doesn't actually do anything, but we should run it to
    # check that nothing explodes.
    tf.backend.build()

    # The 'run' step runs sby. Our mock version dumps its command line
    # arguments to "sby.cmd".
    tf.backend.run()

    tf.compare_files(["sby.cmd"])
Esempio n. 13
0
def test_icestorm_no_pcf(make_edalize_test):
    tf = make_edalize_test('icestorm',
                           param_types=[],
                           files=[])

    tf.backend.configure()
    assert os.path.exists(os.path.join(tf.work_root, 'empty.pcf'))
Esempio n. 14
0
def test_rivierapro(make_edalize_test):
    tool_options = {
        "vlog_options": ["some", "vlog_options"],
        "vsim_options": ["a", "few", "vsim_options"],
    }

    # FIXME: Add VPI tests
    tf = make_edalize_test("rivierapro", tool_options=tool_options)
    tf.backend.configure()

    tf.compare_files(
        ["edalize_build_rtl.tcl", "edalize_launch.tcl", "edalize_main.tcl"])

    orig_env = os.environ.copy()
    try:
        os.environ["ALDEC_PATH"] = os.path.join(tests_dir, "mock_commands")

        tf.backend.build()
        os.makedirs(os.path.join(tf.work_root, "work"))

        tf.compare_files(["vsim.cmd"])

        tf.backend.run()

        assert filecmp.cmp(
            os.path.join(tf.ref_dir, "vsim2.cmd"),
            os.path.join(tf.work_root, "vsim.cmd"),
            shallow=False,
        )
    finally:
        os.environ = orig_env
Esempio n. 15
0
def test_xsim_mfc(make_edalize_test):
    tool_options = {
        "compilation_mode": "common",
        "xelab_options": ["some", "xelab_options"],
        "xsim_options": ["a", "few", "xsim_options"],
    }
    paramtypes = ["plusarg", "vlogdefine", "vlogparam", "generic"]

    tf = make_edalize_test("xsim",
                           tool_options=tool_options,
                           param_types=paramtypes)

    tf.backend.configure()
    tf.compare_files(["config.mk", "Makefile", tf.test_name + ".prj"],
                     ref_subdir="mfc")

    tf.backend.build()
    tf.compare_files(["xelab.cmd"])

    xsimkdir = os.path.join(tf.work_root, "xsim.dir", tf.test_name)
    os.makedirs(xsimkdir)
    with open(os.path.join(xsimkdir, "xsimk"), "w") as f:
        f.write("I am a compiled simulation kernel\n")
    tf.backend.run()

    tf.compare_files(["xsim.cmd"])
Esempio n. 16
0
def test_icestorm_minimal(make_edalize_test):
    files = [{'name': 'pcf_file.pcf', 'file_type': 'PCF'}]
    tf = make_edalize_test('icestorm',
                           param_types=[],
                           files=files,
                           ref_dir='minimal')

    run_icestorm_test(tf)
Esempio n. 17
0
def test_icestorm_minimal(make_edalize_test):
    files = [{"name": "pcf_file.pcf", "file_type": "PCF"}]
    tf = make_edalize_test("icestorm",
                           param_types=[],
                           files=files,
                           ref_dir="minimal")

    run_icestorm_test(tf)
Esempio n. 18
0
def test_icestorm(make_edalize_test):
    tool_options = {
        'yosys_synth_options': ['some', 'yosys_synth_options'],
        'arachne_pnr_options': ['a', 'few', 'arachne_pnr_options']
    }
    tf = make_edalize_test('icestorm',
                           param_types=['vlogdefine', 'vlogparam'],
                           tool_options=tool_options)

    run_icestorm_test(tf)
Esempio n. 19
0
def test_morty(make_edalize_test):
    tool_options = {'morty_options': ['--prefix', 'blub']}
    paramtypes = ['vlogdefine']

    tf = make_edalize_test('morty',
                           tool_options=tool_options,
                           param_types=paramtypes)

    tf.backend.build()
    tf.compare_files(['morty.cmd'])
Esempio n. 20
0
def test_trellis(make_edalize_test):
    tool_options = {
        "yosys_synth_options": ["some", "yosys_synth_options"],
        "nextpnr_options": ["a", "few", "nextpnr_options"],
    }
    tf = make_edalize_test("trellis",
                           param_types=["vlogdefine", "vlogparam"],
                           tool_options=tool_options)

    run_trellis_test(tf)
Esempio n. 21
0
def test_icestorm(make_edalize_test):
    tool_options = {
        "yosys_synth_options": ["some", "yosys_synth_options"],
        "arachne_pnr_options": ["a", "few", "arachne_pnr_options"],
    }
    tf = make_edalize_test("icestorm",
                           param_types=["vlogdefine", "vlogparam"],
                           tool_options=tool_options)

    run_icestorm_test(tf)
Esempio n. 22
0
def test_trellis(make_edalize_test):
    tool_options = {
        'yosys_synth_options': ['some', 'yosys_synth_options'],
        'nextpnr_options': ['a', 'few', 'nextpnr_options']
    }
    tf = make_edalize_test('trellis',
                           param_types=['vlogdefine', 'vlogparam'],
                           tool_options=tool_options)

    run_trellis_test(tf)
Esempio n. 23
0
def test_icestorm_multiple_pcf(make_edalize_test):
    files = [{'name': 'pcf_file.pcf', 'file_type': 'PCF'},
             {'name': 'pcf_file2.pcf', 'file_type': 'PCF'}]
    tf = make_edalize_test('icestorm',
                           param_types=[],
                           files=files)

    with pytest.raises(RuntimeError) as e:
        tf.backend.configure()
    assert "Icestorm backend supports only one PCF file. Found pcf_file.pcf, pcf_file2.pcf" in str(e.value)
Esempio n. 24
0
def test_trellis_multiple_pcf(make_edalize_test):
    files = [{'name': 'pcf_file.pcf', 'file_type': 'PCF'},
             {'name': 'pcf_file2.pcf', 'file_type': 'PCF'}]
    tf = make_edalize_test('trellis',
                           param_types=[],
                           files=files)

    with pytest.raises(RuntimeError) as e:
        tf.backend.configure()
    assert "Nextpnr only supports one PCF file. Found pcf_file.pcf and pcf_file2.pcf" in str(e.value)
Esempio n. 25
0
def test_vcs_tool_options(make_edalize_test):
    tool_options = {
        'vcs_options': ['-debug_access+pp', '-debug_access+all'],
        'run_options': ['-licqueue'],
    }
    tf = make_edalize_test('vcs',
                           test_name='test_vcs_tool_options_0',
                           ref_dir='tool_options',
                           tool_options=tool_options)
    run_vcs_test(tf)
Esempio n. 26
0
def test_verilator_lint_only(make_edalize_test):
    mode = 'lint-only'
    tf = make_edalize_test('verilator',
                           param_types=[],
                           tool_options={'mode': mode})

    tf.backend.configure()

    tf.compare_files(['Makefile'])
    tf.compare_files(['config.mk', tf.test_name + '.vc'], ref_subdir=mode)
Esempio n. 27
0
def test_morty(make_edalize_test):
    tool_options = {"morty_options": ["--prefix", "blub"]}
    paramtypes = ["vlogdefine"]

    tf = make_edalize_test("morty",
                           tool_options=tool_options,
                           param_types=paramtypes)

    tf.backend.build()
    tf.compare_files(["morty.cmd"])
Esempio n. 28
0
def test_veribleformat_default(make_edalize_test):
    """ Test the format mode of Verible """
    tf = make_edalize_test('veribleformat',
                           test_name='test_verible',
                           param_types=['vlogdefine', 'vlogparam'],
                           ref_dir='default')
    tf.backend.configure()
    tf.backend.build()
    tf.backend.run()
    tf.compare_files(['verible-verilog-format.cmd'])
Esempio n. 29
0
def test_verilator_lint_only(make_edalize_test):
    mode = "lint-only"
    tf = make_edalize_test("verilator",
                           param_types=[],
                           tool_options={"mode": mode})

    tf.backend.configure()

    tf.compare_files(["Makefile"])
    tf.compare_files(["config.mk", tf.test_name + ".vc"], ref_subdir=mode)
Esempio n. 30
0
def test_gatemate(make_edalize_test):
    tool_options = {
        "device": "CCGM1A1",
        "yosys_synth_options": ["some", "yosys_synth_options"],
        "p_r_options": ["some", "p_r_synth_options"],
    }
    tf = make_edalize_test("gatemate",
                           param_types=["vlogdefine", "vlogparam"],
                           tool_options=tool_options)

    run_gatemate_test(tf)