Example #1
0
def test_L1_bits_connection():
    a = CaseConnectBitsConstToOutComp.DUT()
    a.elaborate()
    a.apply(StructuralRTLIRGenL1Pass(gen_connections(a)))
    connections = a.get_metadata(StructuralRTLIRGenL1Pass.connections)
    comp = sexp.CurComp(a, 's')
    assert connections == \
      [(sexp.ConstInstance(Bits32(0), 0), sexp.CurCompAttr(comp, 'out'))]
Example #2
0
def test_L1_const_index():
    a = CaseConnectConstToOutComp.DUT()
    a.elaborate()
    a.apply(StructuralRTLIRGenL1Pass(gen_connections(a)))
    connections = a.get_metadata(StructuralRTLIRGenL1Pass.connections)
    comp = sexp.CurComp(a, 's')
    # The expression structure is removed and only the constant value
    # is left in this node.
    assert connections == \
      [(sexp.ConstInstance(Bits32(a.const_[2]), 42), sexp.CurCompAttr(comp, 'out'))]
def test_L1_bits_connection():
    class A(dsl.Component):
        def construct(s):
            s.out = dsl.OutPort(Bits32)
            dsl.connect(s.out, Bits32(0))

    a = A()
    a.elaborate()
    a.apply(StructuralRTLIRGenL1Pass(*gen_connections(a)))
    ns = a._pass_structural_rtlir_gen
    comp = sexp.CurComp(a, 's')
    assert ns.connections == \
      [(sexp.ConstInstance(Bits32(0), 0), sexp.CurCompAttr(comp, 'out'))]
def test_L1_const_index():
    class A(dsl.Component):
        def construct(s):
            s.const = [42 for _ in range(5)]
            s.out = dsl.OutPort(Bits32)
            dsl.connect(s.const[2], s.out)

    a = A()
    a.elaborate()
    a.apply(StructuralRTLIRGenL1Pass(*gen_connections(a)))
    ns = a._pass_structural_rtlir_gen
    comp = sexp.CurComp(a, 's')
    # The expression structure is removed and only the constant value
    # is left in this node.
    assert ns.connections == \
      [(sexp.ConstInstance(a.const[2], 42), sexp.CurCompAttr(comp, 'out'))]