コード例 #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)