⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grt-avhpi.adb

📁 vhdl集成电路设计软件.需要用gcc-4.0.2版本编译.
💻 ADB
📖 第 1 页 / 共 2 页
字号:
         when VhpiPackInsts =>            declare               Blk : Ghdl_Rtin_Block_Acc;            begin               Blk := To_Ghdl_Rtin_Block_Acc (Iterator.Ctxt.Block);               if Iterator.It_Cur >= Blk.Nbr_Child then                  Error := AvhpiErrorIteratorEnd;                  return;               end if;               Res := (Kind => VhpiPackInstK,                       Ctxt => (Base => Null_Address,                                Block => Blk.Children (Iterator.It_Cur)));               Iterator.It_Cur := Iterator.It_Cur + 1;               Error := AvhpiErrorOk;            end;         when VhpiInternalRegions =>            Vhpi_Scan_Internal_Regions (Iterator, Res, Error);         when VhpiDecls =>            Vhpi_Scan_Decls (Iterator, Res, Error);         when others =>            Res := Null_Handle;            Error := AvhpiErrorNotImplemented;      end case;   end Vhpi_Scan;   function Avhpi_Get_Base_Name (Obj : VhpiHandleT) return Ghdl_C_String   is   begin      case Obj.Kind is         when VhpiEnumTypeDeclK =>            return To_Ghdl_Rtin_Type_Enum_Acc (Obj.Atype).Name;         when VhpiPackInstK           | VhpiArchBodyK           | VhpiEntityDeclK           | VhpiProcessStmtK           | VhpiBlockStmtK           | VhpiIfGenerateK           | VhpiForGenerateK =>            return To_Ghdl_Rtin_Block_Acc (Obj.Ctxt.Block).Name;         when VhpiRootInstK =>            declare               Blk : Ghdl_Rtin_Block_Acc;            begin               Blk := To_Ghdl_Rtin_Block_Acc (Obj.Ctxt.Block);               Blk := To_Ghdl_Rtin_Block_Acc (Blk.Parent);               return Blk.Name;            end;         when VhpiCompInstStmtK =>            return Obj.Inst.Name;         when VhpiSigDeclK           | VhpiPortDeclK           | VhpiGenericDeclK =>            return Obj.Obj.Name;         when VhpiSubtypeDeclK =>            return To_Ghdl_Rtin_Subtype_Scalar_Acc (Obj.Atype).Name;         when others =>            return null;      end case;   end Avhpi_Get_Base_Name;   procedure Vhpi_Get_Str (Property : VhpiStrPropertyT;                           Obj : VhpiHandleT;                           Res : out String;                           Len : out Natural)   is      subtype R_Type is String (1 .. Res'Length);      R : R_Type renames Res;      procedure Add (C : Character) is      begin         Len := Len + 1;         if Len <= R_Type'Last then            R (Len) := C;         end if;      end Add;      procedure Add (Str : String) is      begin         for I in Str'Range loop            Add (Str (I));         end loop;      end Add;      procedure Add (Str : Ghdl_C_String) is      begin         for I in Str'Range loop            exit when Str (I) = NUL;            Add (Str (I));         end loop;      end Add;   begin      Len := 0;      case Property is         when VhpiNameP =>            case Obj.Kind is               when VhpiEnumTypeDeclK =>                  Add (To_Ghdl_Rtin_Type_Enum_Acc (Obj.Atype).Name);               when VhpiPackInstK                 | VhpiArchBodyK                 | VhpiEntityDeclK                 | VhpiProcessStmtK                 | VhpiBlockStmtK                 | VhpiIfGenerateK =>                  Add (To_Ghdl_Rtin_Block_Acc (Obj.Ctxt.Block).Name);               when VhpiRootInstK =>                  declare                     Blk : Ghdl_Rtin_Block_Acc;                  begin                     Blk := To_Ghdl_Rtin_Block_Acc (Obj.Ctxt.Block);                     Blk := To_Ghdl_Rtin_Block_Acc (Blk.Parent);                     Add (Blk.Name);                  end;               when VhpiCompInstStmtK =>                  Add (Obj.Inst.Name);               when VhpiSigDeclK                 | VhpiPortDeclK                 | VhpiGenericDeclK =>                  Add (Obj.Obj.Name);               when VhpiSubtypeDeclK =>                  Add (To_Ghdl_Rtin_Subtype_Scalar_Acc (Obj.Atype).Name);               when VhpiForGenerateK =>                  declare                     Blk : Ghdl_Rtin_Block_Acc;                     Iter : Ghdl_Rtin_Object_Acc;                     Iter_Type : Ghdl_Rti_Access;                     Vptr : Ghdl_Value_Ptr;                     Buf : String (1 .. 12);                     Buf_Len : Natural;                  begin                     Blk := To_Ghdl_Rtin_Block_Acc (Obj.Ctxt.Block);                     Iter := To_Ghdl_Rtin_Object_Acc (Blk.Children (0));                     Vptr := To_Ghdl_Value_Ptr                       (Loc_To_Addr (Iter.Common.Depth, Iter.Loc, Obj.Ctxt));                     Add (Blk.Name);                     Add ('(');                     Iter_Type := Iter.Obj_Type;                     if Iter_Type.Kind = Ghdl_Rtik_Subtype_Scalar then                        Iter_Type := To_Ghdl_Rtin_Subtype_Scalar_Acc                          (Iter_Type).Basetype;                     end if;                     case Iter_Type.Kind is                        when Ghdl_Rtik_Type_I32 =>                           To_String (Buf, Buf_Len, Vptr.I32);                           Add (Buf (Buf_Len .. Buf'Last));--                         when Ghdl_Rtik_Type_E8 =>--                            Disp_Enum_Value--                              (Stream, Rti, Ghdl_Index_Type (Vptr.E8));--                         when Ghdl_Rtik_Type_B2 =>--                            Disp_Enum_Value--                              (Stream, Rti,--                               Ghdl_Index_Type (Ghdl_B2'Pos (Vptr.B2)));                        when others =>                           Add ('?');                     end case;                     --Disp_Value (stdout, Iter.Obj_Type, Ctxt, Addr, False);                     Add (')');                  end;               when others =>                  null;            end case;         when VhpiCompNameP =>            case Obj.Kind is               when VhpiCompInstStmtK =>                  declare                     Comp : Ghdl_Rtin_Component_Acc;                  begin                     Comp := To_Ghdl_Rtin_Component_Acc (Obj.Obj.Obj_Type);                     if Comp.Common.Kind = Ghdl_Rtik_Component then                        Add (Comp.Name);                     end if;                  end;               when others =>                  null;            end case;         when VhpiLibLogicalNameP =>            case Obj.Kind is               when VhpiPackInstK                 | VhpiArchBodyK                 | VhpiEntityDeclK =>                  declare                     Blk : Ghdl_Rtin_Block_Acc;                     Lib : Ghdl_Rtin_Type_Scalar_Acc;                  begin                     Blk := To_Ghdl_Rtin_Block_Acc (Obj.Ctxt.Block);                     if Blk.Common.Kind = Ghdl_Rtik_Package_Body then                        Blk := To_Ghdl_Rtin_Block_Acc (Blk.Parent);                     end if;                     Lib := To_Ghdl_Rtin_Type_Scalar_Acc (Blk.Parent);                     if Lib.Common.Kind /= Ghdl_Rtik_Library then                        Internal_Error ("VhpiLibLogicalNameP");                     end if;                     Add (Lib.Name);                  end;               when others =>                  null;            end case;         when VhpiFullNameP =>            declare               Rstr : Rstring;               Nctxt : Rti_Context;            begin               if Obj.Kind = VhpiCompInstStmtK then                  Get_Instance_Context (Obj.Inst, Obj.Ctxt, Nctxt);                  Get_Path_Name (Rstr, Nctxt, ':', False);               else                  Get_Path_Name (Rstr, Obj.Ctxt, ':', False);               end if;               Copy (Rstr, R, Len);               Free (Rstr);               case Obj.Kind is                  when VhpiCompInstStmtK =>                     null;                  when VhpiPortDeclK                    | VhpiSigDeclK =>                     Add (':');                     Add (Obj.Obj.Name);                  when others =>                     null;               end case;            end;         when others =>            null;      end case;   end Vhpi_Get_Str;   procedure Vhpi_Handle (Rel : VhpiOneToOneT;                          Ref : VhpiHandleT;                          Res : out VhpiHandleT;                          Error : out AvhpiErrorT)   is   begin      --  Default error.      Error := AvhpiErrorNotImplemented;      case Rel is         when VhpiDesignUnit =>            case Ref.Kind is               when VhpiRootInstK =>                  case Ref.Ctxt.Block.Kind is                     when Ghdl_Rtik_Architecture =>                        Res := (Kind => VhpiArchBodyK,                                Ctxt => Ref.Ctxt);                        Error := AvhpiErrorOk;                        return;                     when others =>                        return;                  end case;               when others =>                  return;            end case;         when VhpiPrimaryUnit =>            case Ref.Kind is               when VhpiArchBodyK =>                  declare                     Rti : Ghdl_Rti_Access;                     Ent : Ghdl_Rtin_Block_Acc;                  begin                     Rti := To_Ghdl_Rtin_Block_Acc (Ref.Ctxt.Block).Parent;                     Ent := To_Ghdl_Rtin_Block_Acc (Rti);                     Res := (Kind => VhpiEntityDeclK,                             Ctxt => (Base => Ref.Ctxt.Base + Ent.Loc.Off,                                      Block => Rti));                     Error := AvhpiErrorOk;                  end;               when others =>                  return;            end case;         when VhpiIterScheme =>            case Ref.Kind is               when VhpiForGenerateK =>                  declare                     Blk : Ghdl_Rtin_Block_Acc;                     Iter : Ghdl_Rtin_Object_Acc;                  begin                     Blk := To_Ghdl_Rtin_Block_Acc (Ref.Ctxt.Block);                     Iter := To_Ghdl_Rtin_Object_Acc (Blk.Children (0));                     Res := (Kind => VhpiConstDeclK,                             Ctxt => Ref.Ctxt,                             Obj => Iter);                     Error := AvhpiErrorOk;                  end;               when others =>                  return;            end case;         when VhpiSubtype =>            case Ref.Kind is               when VhpiPortDeclK                 | VhpiSigDeclK                 | VhpiGenericDeclK                 | VhpiConstDeclK =>                  Res := (Kind => VhpiSubtypeIndicK,                          Ctxt => Ref.Ctxt,                          Atype => Ref.Obj.Obj_Type);                  Error := AvhpiErrorOk;               when others =>                  return;            end case;         when VhpiTypeMark =>            case Ref.Kind is               when VhpiSubtypeIndicK =>                  --  FIXME: if the subtype is anonymous, return the base type.                  Rti_To_Handle (Ref.Atype, Ref.Ctxt, Res);                  if Res.Kind /= VhpiUndefined then                     Error := AvhpiErrorOk;                  end if;                  return;               when others =>                  return;            end case;         when others =>            Res := Null_Handle;            Error := AvhpiErrorNotImplemented;      end case;   end Vhpi_Handle;   function Vhpi_Get_EntityClass (Obj : VhpiHandleT)                                 return VhpiEntityClassT   is   begin      case Obj.Kind is         when VhpiArchBodyK =>            return VhpiArchitectureEC;         when others =>            return VhpiErrorEC;      end case;   end Vhpi_Get_EntityClass;   function Vhpi_Get_Kind (Obj : VhpiHandleT) return VhpiClassKindT is   begin      return Obj.Kind;   end Vhpi_Get_Kind;   function Vhpi_Get_Mode (Obj : VhpiHandleT) return VhpiModeP is   begin      case Obj.Kind is         when VhpiPortDeclK =>            case Obj.Obj.Common.Mode and Ghdl_Rti_Signal_Mode_Mask is               when Ghdl_Rti_Signal_Mode_In =>                  return VhpiInMode;               when Ghdl_Rti_Signal_Mode_Out =>                  return VhpiOutMode;               when Ghdl_Rti_Signal_Mode_Inout =>                  return VhpiInoutMode;               when Ghdl_Rti_Signal_Mode_Buffer =>                  return VhpiBufferMode;               when Ghdl_Rti_Signal_Mode_Linkage =>                  return VhpiLinkageMode;               when others =>                  return VhpiErrorMode;            end case;         when others =>            return VhpiErrorMode;      end case;   end Vhpi_Get_Mode;   function Avhpi_Get_Rti (Obj : VhpiHandleT) return Ghdl_Rti_Access is   begin      case Obj.Kind is         when VhpiSubtypeIndicK           | VhpiEnumTypeDeclK =>            return Obj.Atype;         when VhpiSigDeclK           | VhpiPortDeclK =>            return To_Ghdl_Rti_Access (Obj.Obj);         when others =>            return null;      end case;   end Avhpi_Get_Rti;   function Avhpi_Get_Address (Obj : VhpiHandleT) return Address is   begin      case Obj.Kind is         when VhpiPortDeclK           | VhpiSigDeclK           | VhpiGenericDeclK           | VhpiConstDeclK =>            return Loc_To_Addr (Obj.Ctxt.Block.Depth,                                Obj.Obj.Loc,                                Obj.Ctxt);         when others =>            return Null_Address;      end case;   end Avhpi_Get_Address;   function Avhpi_Get_Context (Obj : VhpiHandleT) return Rti_Context is   begin      return Obj.Ctxt;   end Avhpi_Get_Context;   function Vhpi_Compare_Handles (Hdl1, Hdl2 : VhpiHandleT)                                 return Boolean   is   begin      if Hdl1.Kind /= Hdl2.Kind then         return False;      end if;      case Hdl1.Kind is         when VhpiSubtypeIndicK           | VhpiSubtypeDeclK           | VhpiArrayTypeDeclK =>            return Hdl1.Atype = Hdl2.Atype;         when others =>            -- FIXME: todo            Internal_Error ("vhpi_compare_handles");      end case;   end Vhpi_Compare_Handles;   function Vhpi_Put_Value (Obj : VhpiHandleT; Val : Ghdl_I64)                           return AvhpiErrorT   is      Vptr : Ghdl_Value_Ptr;      Atype : Ghdl_Rti_Access;   begin      case Obj.Kind is         when VhpiIndexedNameK =>            Vptr := To_Ghdl_Value_Ptr (Obj.N_Addr);            Atype := Obj.N_Type;         when others =>            return AvhpiErrorNotImplemented;      end case;      case Get_Base_Type (Atype).Kind is         when Ghdl_Rtik_Type_P64 =>            null;         when others =>            return AvhpiErrorHandle;      end case;      Vptr.I64 := Val;      return AvhpiErrorOk;   end Vhpi_Put_Value;end Grt.Avhpi;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -