def as_hdl_HdlPortItem(self, o: HdlPortItem): var = HdlIdDef() var.direction = HWT_TO_HDLCONVEROTR_DIRECTION[o.direction] s = o.getInternSig() var.name = s.name var.origin = o var.type = o._dtype return self.as_hdl_HdlModuleDef_variable(var, (), None, None, None, None)
def as_hdl_HdlType_enum(self, typ: HEnum, declaration=False): ns = self.name_scope if declaration: e = HdlEnumDef() e.origin = typ e.name = ns.checked_name(typ.name, typ) e.values = [(ns.checked_name(n, getattr(typ, n)), None) for n in typ._allValues] dec = HdlIdDef() dec.type = HdlTypeType dec.value = e dec.name = e.name return dec else: name = ns.get_object_name(typ) return HdlValueId(name, obj=None)
def as_hdl_HdlType_array(self, typ: HArray, declaration=False): ns = self.name_scope if declaration: dec = HdlIdDef() dec.type = HdlTypeType if self.does_type_requires_extra_def(typ.element_t, ()): # problem there is that we do not have a list of already defined types # so we can not just declare an element type raise NotImplementedError(typ.element_t) dec.value = hdl_index(self.as_hdl_HdlType(typ.element_t, declaration=False), self.as_hdl_int(int(typ.size))) name = getattr(typ, "name", "arr_t_") dec.name = ns.checked_name(name, typ) return dec else: name = ns.get_object_name(typ) return HdlValueId(name, obj=typ)