예제 #1
0
def test_component_double_star_args_ungroup(do_test):
    class A(Component):
        def construct(s, foo, bar):
            assert foo == Bits4(0)
            assert bar == Bits16(42)

    kwargs = {'foo': Bits4(0), 'bar': Bits16(42)}
    a = A(**kwargs)
    a._ref_name = 'A__foo_0__bar_002a'
    a._ref_src = \
  """\
component {}
(
port_decls:
interface_decls:
);
const_decls:
freevars:
wire_decls:
component_decls:
tmpvars:
upblk_srcs:
connections:

endcomponent
""".format( a._ref_name )
    do_test(a)
예제 #2
0
def test_component_mixed_kw_args(do_test):
    class A(Component):
        def construct(s, foo, bar, woo=Bits32(0)):
            pass

    a = A(Bits4(0), bar=Bits16(42))
    a._ref_name = 'A__foo_0__bar_002a__woo_00000000'
    a._ref_src = \
  """\
component {}
(
port_decls:
interface_decls:
);
const_decls:
freevars:
wire_decls:
component_decls:
tmpvars:
upblk_srcs:
connections:

endcomponent
""".format( a._ref_name )
    do_test(a)
예제 #3
0
def test_component_kw_args(do_test):
    class A(Component):
        def construct(s, foo, bar):
            assert foo == Bits4(0)
            assert bar == Bits16(42)

    a = A(foo=Bits4(0), bar=Bits16(42))
    a._ref_name = 'A__foo_0__bar_002a'
    a._ref_src = \
  """\
component {}
(
port_decls:
interface_decls:
);
const_decls:
freevars:
wire_decls:
component_decls:
tmpvars:
upblk_srcs:
connections:

endcomponent
""".format( a._ref_name )
    do_test(a)
예제 #4
0
        def construct(s):
            s.foo = Bits32(0)
            s.bar = Bits4(0)
            s.out = OutPort(Bits32)

            @s.update
            def upblk():
                s.out = s.foo
                s.out = Bits32(s.bar)
예제 #5
0
def test_component_star_args(do_test):
    class A(Component):
        def construct(s, *args):
            assert args[0] == Bits4(0)
            assert args[1] == Bits16(42)

    args = [Bits4(0), Bits16(42)]
    a = A(*args)
    with expected_failure(RTLIRConversionError, "varargs are not allowed"):
        do_test(a)
예제 #6
0
def test_component_double_star_args(do_test):
    class A(Component):
        def construct(s, **kwargs):
            assert kwargs['foo'] == Bits4(0)
            assert kwargs['bar'] == Bits16(42)

    kwargs = {'foo': Bits4(0), 'bar': Bits16(42)}
    a = A(**kwargs)
    with expected_failure(RTLIRConversionError,
                          "keyword args are not allowed"):
        do_test(a)
예제 #7
0
 def upblk():
     for s.in_ in range(4):
         s.out = Bits4(1)
예제 #8
0
 def upblk():
     for i in range(4):
         s.out = Bits4(1)
     else:
         s.out = Bits4(1)
예제 #9
0
 def upblk():
     s.out = u + Bits4(1)
예제 #10
0
 def __init__( s, foo=42 ):
   s.foo = [ Bits4( 42 ) for _ in range(4) ]
예제 #11
0
 def up_wr_y():
     s.y @= Bits4(0xf)
예제 #12
0
 def up_wr_As():
     s.A[0:4] @= Bits4(0xf)
예제 #13
0
 def upblk():
     for i in range():
         s.out = Bits4(1)
예제 #14
0
 def upblk():
     for i in s.in_:
         s.out = Bits4(1)
예제 #15
0
 def upblk():
     s.foo = 42
     s.bar = Bits4(0)
예제 #16
0
 def construct(s, *args):
     assert args[0] == Bits4(0)
     assert args[1] == Bits16(42)
예제 #17
0
 def construct(s, **kwargs):
     assert kwargs['foo'] == Bits4(0)
     assert kwargs['bar'] == Bits16(42)
예제 #18
0
 def upblk():
     for i in foo():
         s.out = Bits4(1)
예제 #19
0
 def construct(s, foo, bar):
     assert foo == Bits4(0)
     assert bar == Bits16(42)
예제 #20
0
 def upblk():
     for i in range(0, 4, 1, 1):
         s.out = Bits4(1)
예제 #21
0
 def tv_out(m, tv):
     assert m.out == Bits4(tv[1])