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))
def _(sint, size): return ExprHolder(SIntT(size), ConnSide.RT, Extend(sint))
def _(lf, rt): w = max(lf.hcl_type.width, rt.hcl_type.width) t = UIntT(w) return ExprHolder(t, ConnSide.RT, And(lf, rt))
def _(uint): t = SIntT(uint.hcl_type.width) return ExprHolder(t, ConnSide.RT, ToSInt(uint))
def _(sint): t = UIntT(sint.hcl_type.width) return ExprHolder(t, ConnSide.RT, ToUInt(sint))
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))
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))