コード例 #1
0
    def array1d_t_to_vhdl(to_hdl: ToHdlAstVhdl2008, declaration=False):
        if not isinstance(to_hdl, ToHdlAstVhdl2008):
            raise NotImplementedError()

        if declaration:
            raise ValueError(
                "_as_hdl_requires_def specifies that this should not be required"
            )
        # "mem(0 to %d)(%d downto 0)" % (t.size, t.element_t.bit_length() - 1)
        _int = to_hdl.as_hdl_int
        size = HdlOp(HdlOpType.TO, [_int(0), _int(int(array1d_t.size))])
        e_width = hdl_downto(_int(array1d_t.element_t.bit_length() - 1),
                             _int(0))
        return hdl_index(hdl_index(HdlValueId("mem"), size), e_width)
コード例 #2
0
 def as_hdl_HdlType_array(self, typ: HArray, declaration=False):
     if declaration:
         raise NotImplementedError()
     else:
         _int = self.as_hdl_int
         size = HdlOp(HdlOpType.DOWNTO, [_int(0), _int(int(typ.size) - 1)])
         return hdl_index(self.as_hdl_HdlType(typ.element_t), size)
コード例 #3
0
 def as_hdl_Assignment(self, a: Assignment):
     dst, dst_indexes, src = self._as_hdl_Assignment_auto_conversions(a)
     dst = self.as_hdl(dst)
     if dst_indexes:
         for i in dst_indexes:
             dst = hdl_index(dst, i)
     a = HdlStmAssign(src, dst)
     return a
コード例 #4
0
ファイル: type.py プロジェクト: KwameSwift/Django-API
 def as_hdl_HdlType_array(self, typ: HArray, declaration=False):
     if declaration:
         return super(ToHdlAstSystemC_type,
                      self).as_hdl_HdlType_array(self,
                                                 typ,
                                                 declaration=declaration)
     else:
         _int = self.as_hdl_int
         size = _int(int(typ.size))
         return hdl_index(self.as_hdl_HdlType(typ.element_t), size)
コード例 #5
0
ファイル: to_hdl_ast.py プロジェクト: arnabd88/hwt
    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)
コード例 #6
0
 def as_hdl_HdlType_array(self, typ: HArray, declaration=False):
     if declaration:
         v = HdlIdDef()
         name = getattr(typ, "name", None)
         if name is None:
             name = "arr_t_"
         v.name = self.name_scope.checked_name(name, typ)
         v.type = HdlTypeType
         v.origin = typ
         size = hdl_downto(self.as_hdl_int(int(typ.size) - 1),
                           self.as_hdl_int(0))
         if self.does_type_requires_extra_def(typ.element_t, ()):
             raise NotImplementedError(typ.element_t)
         e_t = self.as_hdl_HdlType(typ.element_t, declaration=False)
         v.value = hdl_index(e_t, size)
         return v
     else:
         return super(ToHdlAstVhdl2008_types,
                      self).as_hdl_HdlType_array(typ, declaration)
コード例 #7
0
 def as_hdl_HdlType_array(self, typ: HArray, declaration=False):
     assert not declaration, "declaration should not be required"
     t = self.as_hdl_HdlType(typ.element_t, declaration=declaration)
     return hdl_index(t, HdlValueInt(int(typ.size), None, None))