示例#1
0
 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)
示例#2
0
    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)
示例#3
0
 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)
示例#4
0
    def _copyParamsAndInterfaces(self):
        # note that the parameters are not added to HdlModuleDef (VHDL entity, Verilog module header)
        # as it was already build
        for p in self._possible_variants[0]._params:
            myP = Param(p.get_value())
            self._registerParameter(p._name, myP)
            myP.set_value(p.get_value())

        ns = self._store_manager.name_scope
        for p in sorted(self._params, key=lambda x: x._name):
            hdl_val = p.get_hdl_value()
            v = HdlIdDef()
            v.origin = p
            v.name = p.hdl_name = ns.checked_name(p._name, p)
            v.type = hdl_val._dtype
            v.value = hdl_val
            self._ctx.ent.params.append(v)

        for intf in self.possible_variants[0]._interfaces:
            # clone interface
            myIntf = copy(intf)
            myIntf._dtype = copy(myIntf._dtype)
            # sub-interfaces are not instantiated yet
            # myIntf._direction = intf._direction
            myIntf._direction = INTF_DIRECTION.opposite(intf._direction)

            self._registerInterface(intf._name, myIntf)
            object.__setattr__(self, intf._name, myIntf)

        ei = self._ctx.interfaces
        for i in self._interfaces:
            self._loadInterface(i, True)
            assert i._isExtern
            i._signalsForInterface(self._ctx,
                                   ei,
                                   self._store_manager.name_scope,
                                   reverse_dir=True)