Exemple #1
0
def _(bd, item):
    # TODO: Accurate Error Message
    assert item in bd.hcl_type.fields
    if isinstance(bd, BundleHolder):
        return bd.assoc_value[item]

    # build connect side
    sd = bd.conn_side
    f = bd.hcl_type.fields[item]
    dr, tpe = f["dir"], f["hcl_type"]
    new_sd = build_new_sd(sd, dr)

    return ExprHolder(tpe, new_sd, FieldAccess(bd, item))
Exemple #2
0
def _(sint, size):
    return ExprHolder(SIntT(size), ConnSide.RT, Extend(sint))
Exemple #3
0
def _(lf, rt):
    w = max(lf.hcl_type.width, rt.hcl_type.width)
    t = UIntT(w)
    return ExprHolder(t, ConnSide.RT, And(lf, rt))
Exemple #4
0
def _(uint):
    t = SIntT(uint.hcl_type.width)
    return ExprHolder(t, ConnSide.RT, ToSInt(uint))
Exemple #5
0
def _(sint):
    t = UIntT(sint.hcl_type.width)
    return ExprHolder(t, ConnSide.RT, ToUInt(sint))
Exemple #6
0
def _(vec, i: int):
    # TODO: Accurate Error Message
    assert i < vec.hcl_type.size
    if isinstance(vec, VecHolder):
        return vec.assoc_value[i]
    return ExprHolder(vec.hcl_type.inner_type, vec.conn_side, VecIndex(vec, i))
Exemple #7
0
def _(sint, high: int, low: int):
    check_bit_width(sint, high, low)
    t = UIntT(high - low + 1)
    return ExprHolder(t, ConnSide.RT, Bits(sint, high, low))