ThisIsABitStructWithSuperLongName,
)
from ..behavioral.test.YosysBehavioralTranslatorL2_test import test_yosys_behavioral_L2
from ..behavioral.test.YosysBehavioralTranslatorL3_test import test_yosys_behavioral_L3
from ..structural.test.YosysStructuralTranslatorL2_test import test_yosys_structural_L2
from ..YosysTranslator import YosysTranslator


def run_test(case, m):
    m.elaborate()
    tr = YosysTranslator(m)
    tr.translate(m)
    check_eq(tr.hierarchy.src, case.REF_SRC)

@pytest.mark.parametrize(
    'case', get_parameter('case', test_yosys_behavioral_L2) + \
          get_parameter('case', test_yosys_behavioral_L3) + \
          get_parameter('case', test_yosys_structural_L2)
)
def test_yosys_L2(case):
    run_test(case, case.DUT())


def test_long_component_name():
    args = [ThisIsABitStructWithSuperLongName] * 7
    run_test(CaseConnectPassThroughLongNameComp,
             CaseConnectPassThroughLongNameComp.DUT(*args))


@pytest.mark.xfail(
    run=False,
#=========================================================================
# RTLIRTranslator_L3_cases_test.py
#=========================================================================
# Author : Peitian Pan
# Date   : May 23, 2019
"""Test the RTLIR translator."""

import pytest

from pymtl3.passes.rtlir.util.test_utility import get_parameter

from ..behavioral.test.BehavioralTranslatorL3_test import test_generic_behavioral_L3
from ..structural.test.StructuralTranslatorL3_test import test_generic_structural_L3
from .TestRTLIRTranslator import TestRTLIRTranslator


def run_test(case, m):
    if not m._dsl.constructed:
        m.elaborate()
    tr = TestRTLIRTranslator(m)
    tr.translate(m)
    src = tr.hierarchy.src
    assert src == case.REF_SRC

@pytest.mark.parametrize(
    'case', get_parameter('case', test_generic_behavioral_L3) + \
          get_parameter('case', test_generic_structural_L3)
)
def test_generic_L3(case):
    run_test(case, case.DUT())
Esempio n. 3
0
    ThisIsABitStructWithSuperLongName,
)
from ..behavioral.test.VBehavioralTranslatorL2_test import test_verilog_behavioral_L2
from ..behavioral.test.VBehavioralTranslatorL3_test import test_verilog_behavioral_L3
from ..structural.test.VStructuralTranslatorL2_test import test_verilog_structural_L2
from ..VTranslator import VTranslator


def run_test( case, m ):
  m.elaborate()
  tr = VTranslator( m )
  tr.translate( m )
  check_eq( tr.hierarchy.src, case.REF_SRC )

@pytest.mark.parametrize(
  'case', get_parameter('case', test_verilog_behavioral_L2) + \
          get_parameter('case', test_verilog_behavioral_L3) + \
          get_parameter('case', test_verilog_structural_L2)
)
def test_verilog_L2( case ):
  run_test( case, case.DUT() )

def test_long_component_name():
  args = [ThisIsABitStructWithSuperLongName]*7
  run_test( CaseConnectPassThroughLongNameComp, CaseConnectPassThroughLongNameComp.DUT(*args) )

def test_type_name_as_field_name():
  with expected_failure( VerilogStructuralTranslationError, 'same name as BitStruct type' ):
    run_test( CaseTypeNameAsFieldNameComp, CaseTypeNameAsFieldNameComp.DUT() )

@pytest.mark.xfail(run=False, reason="TODO: resolving BitStructs according to name AND fields")
#=========================================================================
# RTLIRTranslator_L5_cases_test.py
#=========================================================================
# Author : Peitian Pan
# Date   : May 23, 2019
"""Test the RTLIR translator."""

import pytest

from pymtl3.passes.rtlir.util.test_utility import get_parameter

from ..behavioral.test.BehavioralTranslatorL5_test import test_generic_behavioral_L5
from .TestRTLIRTranslator import TestRTLIRTranslator


def run_test(case, m):
    if not m._dsl.constructed:
        m.elaborate()
    tr = TestRTLIRTranslator(m)
    tr.translate(m)
    src = tr.hierarchy.src
    assert src == case.REF_SRC


@pytest.mark.parametrize('case',
                         get_parameter('case', test_generic_behavioral_L5))
def test_generic_L5(case):
    run_test(case, case.DUT())