------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real-time scheduling analysis tool. -- This program provides services to automatically check schedulability and -- other performance criteria of real-time architecture models. -- -- Copyright (C) 2002-2020, Frank Singhoff, Alain Plantec, Jerome Legrand, -- Hai Nam Tran, Stephane Rubini -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285, Université de Bretagne Occidentale -- -- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008. -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- The full list of contributors and sponsors can be found in AUTHORS.txt and SPONSORS.txt -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- Contact : cheddar@listes.univ-brest.fr -- ------------------------------------------------------------------------------ -- Last update : -- $Rev$ -- $Date$ -- $Author: $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Ada.Exceptions; use Ada.Exceptions; with Translate; use Translate; with Objects; use Objects; with Objects.extended; use Objects.extended; with unbounded_strings; use unbounded_strings; with initialize_framework; use initialize_framework; with Debug; use Debug; package body Memory_Set is procedure Check_Memory (My_memories : in memories_Set; Name : in Unbounded_String; A_Memory_Record : in Memory_Record) is begin if (Name = "") then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Memory_Name (Current_Language) & Lb_Mandatory (Current_Language))); end if; if not Is_A_Valid_Identifier (Name) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Memory (Current_Language) & " " & Name & " : " & Lb_Buffer_Name (Current_Language) & Lb_Colon & Lb_Invalid_Identifier (Current_Language))); end if; end Check_Memory; procedure Add_Memory (My_memories : in out memories_Set; Name : in Unbounded_String; A_Memory_Record : in Memory_Record) is Dummy : Generic_Memory_Ptr; begin Add_Memory (My_Memories, Dummy, Name, A_Memory_Record); end Add_Memory; procedure Add_Memory (My_memories : in out memories_Set; A_Memory : in out Generic_Memory_Ptr; Name : in Unbounded_String; A_Memory_Record : in Memory_Record) is My_Iterator : iterator; A_DRAM_Memory : DRAM_Memory_Ptr; A_Kalray_Memory : Kalray_Memory_Ptr; begin Check_Initialize; Check_Memory (My_Memories, Name, A_Memory_Record); if (get_number_of_elements (My_Memories) > 0) then reset_iterator (My_Memories, My_Iterator); loop current_element (My_Memories, A_Memory, My_Iterator); if (Name = A_Memory.name) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Memory (Current_Language) & " " & Name & " : " & Lb_Memory_Name (Current_Language) & Lb_Already_Defined (Current_Language))); end if; exit when is_last_element (My_Memories, My_Iterator); next_element (My_Memories, My_Iterator); end loop; end if; if (A_Memory_Record.memory_category = Generic_Memory_Type) then A_Memory := new Generic_Memory; elsif (A_Memory_Record.memory_category = DRAM_Type) then A_DRAM_Memory := new DRAM_Memory; A_DRAM_Memory.memory_category := DRAM_Type; A_DRAM_Memory.shared_access_latency := A_Memory_Record.shared_access_latency; A_DRAM_Memory.private_access_latency := A_Memory_Record.private_access_latency; A_DRAM_Memory.l_act_inter := A_Memory_Record.l_act_inter; A_DRAM_Memory.l_rw_inter := A_Memory_Record.l_rw_inter; A_DRAM_Memory.l_pre_inter := A_Memory_Record.l_pre_inter; A_DRAM_Memory.l_conf := A_Memory_Record.l_conf; A_DRAM_Memory.n_reorder := A_Memory_Record.n_reorder; A_DRAM_Memory.l_conhit := A_Memory_Record.l_conhit; A_Memory := Generic_Memory_Ptr(A_DRAM_Memory); elsif (A_Memory_Record.memory_category = Kalray_Type) then A_Kalray_Memory := new Kalray_Memory; A_Kalray_Memory.nb_bank := A_Memory_Record.nb_bank; A_Kalray_Memory.partition_mode := A_Memory_Record.partition_mode; A_Memory := Generic_Memory_Ptr(A_Kalray_Memory); end if; A_Memory.name := Name; A_Memory.access_latency := A_Memory_Record.access_latency; A_Memory.memory_category := A_Memory_Record.memory_category; add (My_Memories, A_Memory); exception when full_set => Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Can_Not_Define_More_Memories (Current_Language))); end Add_Memory; function Search_Memory (My_Memories : in Memories_Set; Name : in Unbounded_String) return Generic_Memory_Ptr is My_Iterator : iterator; A_Memory : Generic_Memory_Ptr; Result : Generic_Memory_Ptr; Found : Boolean := False; begin if not is_empty(My_Memories) then reset_iterator (My_Memories, My_Iterator); loop current_element (My_Memories, A_Memory, My_Iterator); if (A_Memory.name = Name) then Found := True; Result := A_Memory; end if; exit when is_last_element (My_Memories, My_Iterator); next_element (My_Memories, My_Iterator); end loop; end if; if not Found then Raise_Exception (Memory_Not_Found'Identity, To_String (Lb_Memory_Name (Current_Language) & "=" & Name)); end if; return Result; end Search_Memory; function Search_memory_by_id (My_memories : in memories_Set; id : in Unbounded_String) return generic_memory_Ptr is My_Iterator : memories_Iterator; A_memory : generic_memory_Ptr; Result : generic_memory_Ptr; Found : Boolean := False; begin if not is_empty(My_memories) then reset_iterator (My_memories, My_Iterator); loop current_element (My_memories, A_memory, My_Iterator); if (A_memory.cheddar_private_id = id) then Found := True; Result := A_memory; end if; exit when is_last_element (My_memories, My_Iterator); next_element (My_memories, My_Iterator); end loop; end if; if not Found then Raise_Exception (memory_Not_Found'Identity, To_String (lb_memory_id (Current_Language) & "=" & id)); end if; return Result; end Search_memory_by_id; end Memory_Set;