예제 #1
0
def _(left, right):
    check_connect_dir(left, right)

    # TODO: Accurate Error Message
    assert left.hcl_type.size == right.hcl_type.size

    for i in range(left.hcl_type.size):
        op_apply('<<=')(left[i], right[i])

    return left
예제 #2
0
def _(left, right):
    msg = 'connect(): connecting SInt to UInt, an auto-conversion will occur'
    logging.warning(msg)

    if left.hcl_type.width < right.hcl_type.width:
        logging.warning(
            'connect(): connecting {} to {} will truncate the bits'.format(
                right.hcl_type, left.hcl_type))
        return op_apply('<<=')(left, right[left.hcl_type.width - 1:0])

    return op_apply('<<=')(left, right.to_uint())
예제 #3
0
 def _(self, item):
     start = item.start if item.start is not None else 0
     if item.step is None:
         if item.stop is not None:
             return op_apply('[i:j]')(self, start, item.stop)
         if item.stop is None:
             return op_apply('[i:]')(self, start)
     if item.stop is not None:
         return op_apply('[i:j:k]')(self, start, item.stop, item.step)
     if item.stop is None:
         return op_apply('[i::k]')(self, start, item.step)
예제 #4
0
def _(left, right):
    check_connect_dir(left, right)

    if left.hcl_type.width < right.hcl_type.width:
        logging.warning(
            'connect(): connecting {} to {} will truncate the bits'.format(
                right.hcl_type, left.hcl_type))
        right = right[left.hcl_type.width - 1:0].to_sint()

    if left.hcl_type.width > right.hcl_type.width:
        right = op_apply('extend')(right, left.hcl_type.width)

    assert left.hcl_type.width == right.hcl_type.width
    StatementTrapper.track(Connect(left, right))
    return left
예제 #5
0
def _(left, right):
    check_connect_dir(left, right)

    # TODO: Accurate Error Message
    dir_and_types = right.hcl_type.fields
    keys = dir_and_types.keys()
    assert keys == left.hcl_type.fields.keys()

    for k in keys:
        lf = op_apply('.')(left, k)
        rt = op_apply('.')(right, k)
        if dir_and_types[k]['dir'] == Dir.SRC:
            op_apply('<<=')(lf, rt)
        else:
            op_apply('<<=')(rt, lf)

    return left
예제 #6
0
 def to_bool(self):
     return op_apply('to_bool')(self)
예제 #7
0
 def to_sint(self):
     return op_apply('to_sint')(self)
예제 #8
0
 def _(self, item):
     return op_apply('[i]')(self, item)
예제 #9
0
 def __getattr__(self, item):
     return op_apply('.')(self, item)
예제 #10
0
 def __xor__(self, other):
     return op_apply('^')(self, other)
예제 #11
0
 def __or__(self, other):
     return op_apply('|')(self, other)
예제 #12
0
 def __and__(self, other):
     return op_apply('&')(self, other)
예제 #13
0
 def __add__(self, other):
     return op_apply('+')(self, other)
예제 #14
0
 def __ilshift__(self, other):
     return op_apply('<<=')(self, other)