------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with unbounded_strings; use unbounded_strings; with Ada.Exceptions; use Ada.Exceptions; with Translate; use Translate; with initialize_framework; use initialize_framework; with objects.extended; use objects.extended; package body Network_Set is procedure Check_network (My_networks : in Networks_Set; Name : in Unbounded_String; Network_architecture_Type : in Networks_architecture_Type; topology : in topology_type := mesh_topology; link_delay : in integer:=0; number_of_processor : in integer:=0; dimension : in integer:=0; Xdimension : in integer:=0; Ydimension : in integer:=0; number_of_virtual_channel : in integer:=0; Network_Delay : in Networks_Delay_Type := bounded_delay; switching_protocol : in switching_type := Wormwole; Routing_Protocol : in Routing_Type := XY; Processor_Positions : in Positions_Table := No_Position) is begin if Name = "" then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Network_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_network (Current_Language) & " " & Name & " : " & Lb_network_Name (Current_Language) & Lb_Colon & Lb_Invalid_Identifier (Current_Language))); end if; if (link_delay < 0) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_network (Current_Language) & " " & Name & " : link_delay " & Lb_Must_Be (Current_Language) & Lb_greater_or_equal_than(Current_Language) & "0")); end if; if (number_of_processor < 0) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_network (Current_Language) & " " & Name & " : number_of_processor " & Lb_Must_Be (Current_Language) & Lb_greater_or_equal_than(Current_Language) & "0")); end if; if (dimension < 0) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_network (Current_Language) & " " & Name & " : dimension " & Lb_Must_Be (Current_Language) & Lb_greater_or_equal_than(Current_Language) & "0")); end if; if (number_of_virtual_channel < 0) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_network (Current_Language) & " " & Name & " : number_of_virtual_channel " & Lb_Must_Be (Current_Language) & Lb_greater_or_equal_than(Current_Language) & "0")); end if; if (Xdimension < 0) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_network (Current_Language) & " " & Name & " : Xdimension " & Lb_Must_Be (Current_Language) & Lb_greater_or_equal_than(Current_Language) & "0")); end if; if (Ydimension < 0) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_network (Current_Language) & " " & Name & " : Ydimension " & Lb_Must_Be (Current_Language) & Lb_greater_or_equal_than(Current_Language) & "0")); end if; end Check_network; procedure Add_Network (My_Networks : in out Networks_Set; Name : in Unbounded_String; Network_architecture_Type : in Networks_architecture_Type; topology : in topology_type := mesh_topology; link_delay : in integer:=0; number_of_processor : in integer:=0; dimension : in integer:=0; Xdimension : in integer:=0; Ydimension : in integer:=0; number_of_virtual_channel : in integer:=0; Network_Delay : in Networks_Delay_Type := bounded_delay; switching_protocol : in switching_type := Wormwole; Routing_Protocol : in Routing_Type := XY; Processor_Positions : in Positions_Table := No_Position) is dummy : generic_network_ptr; begin add_network(my_networks, dummy, name, Network_architecture_Type, topology, link_delay, number_of_processor, dimension, Xdimension, Ydimension, number_of_virtual_channel, network_delay, switching_protocol, Routing_Protocol, Processor_Positions); end add_network; procedure Add_Network (My_Networks : in out Networks_Set; a_network : out generic_network_ptr; Name : in Unbounded_String; Network_architecture_Type : in Networks_architecture_Type; topology : in topology_type := mesh_topology; link_delay : in integer:=0; number_of_processor : in integer:=0; dimension : in integer:=0; Xdimension : in integer:=0; Ydimension : in integer:=0; number_of_virtual_channel : in integer:=0; Network_Delay : in Networks_Delay_Type := bounded_delay; switching_protocol : in switching_type := Wormwole; Routing_Protocol : in Routing_Type := XY; Processor_Positions : in Positions_Table := No_Position) is My_Iterator : iterator; New_NOC_Network : NOC_network_ptr; New_Bus_Network : Bus_network_ptr; New_Spacewire_Network : Spacewire_network_ptr; begin check_initialize; check_network(my_networks, name, Network_architecture_Type, topology, link_delay, number_of_processor, dimension, Xdimension, Ydimension, number_of_virtual_channel, network_delay, switching_protocol, Routing_Protocol, Processor_Positions); if (get_number_of_elements (My_Networks) > 0) then reset_iterator (My_Networks, My_Iterator); loop current_element (My_Networks, A_Network, My_Iterator); if (Name = A_Network.name) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_network (Current_Language) & " " & Name & " : " & Lb_network_Name (Current_Language) & Lb_Already_Defined (Current_Language))); end if; exit when is_last_element (My_Networks, My_Iterator); next_element (My_Networks, My_Iterator); end loop; end if; check_network(my_networks, name, Network_architecture_Type, topology, link_delay, number_of_processor, dimension, Xdimension, Ydimension, number_of_virtual_channel, network_delay, switching_protocol, Routing_Protocol, Processor_Positions); case network_architecture_Type is when Shared_Bus | Crossbar | Star | Point_To_Point_Link => New_Bus_Network:= new Bus_network; A_Network := Generic_Network_Ptr (New_Bus_Network); when NOC => New_NOC_Network:= new NOC_network; New_Noc_Network.Routing_Protocol:= Routing_Protocol; New_Noc_Network.link_delay:= link_delay; New_Noc_Network.switching_protocol:= switching_protocol; New_Noc_Network.dimension:= dimension; New_Noc_Network.topology:= topology; New_Noc_Network.number_of_processor:= number_of_processor; New_Noc_Network.number_of_virtual_channel:= number_of_virtual_channel; New_Noc_Network.Processor_Positions:= Processor_Positions; A_Network := Generic_Network_Ptr (New_NOC_Network); when Spacewire => New_spacewire_Network:= new spacewire_network; New_spacewire_Network.Xdimension:= Xdimension; New_spacewire_Network.Ydimension:= Ydimension; New_spacewire_Network.Routing_Protocol:= Routing_Protocol; New_spacewire_Network.number_of_processor:= number_of_processor; New_spacewire_Network.link_delay:= link_delay; New_spacewire_Network.Processor_Positions:= Processor_Positions; A_Network := Generic_Network_Ptr (New_spacewire_Network); end case; A_Network.name := Name; A_Network.network_architecture_type := Network_architecture_Type; A_Network.network_delay := Network_delay; add (My_Networks, A_Network); exception when Generic_Network_Set.full_set => Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Can_Not_Define_More_Networks (Current_Language))); end Add_Network; procedure Update_Network (My_Networks : in out Networks_Set; Name : in Unbounded_String; Network_Type : in Networks_architecture_Type) is A_Network : generic_Network_Ptr; begin A_Network := Search_Network (My_Networks, Name); delete (My_Networks, A_Network); Add_Network (My_Networks, Name, network_type); end Update_Network; function Search_Network (My_Networks : in Networks_Set; Name : in Unbounded_String) return generic_Network_Ptr is My_Iterator : iterator; A_Network : generic_Network_Ptr; Result : generic_Network_Ptr; Found : Boolean := False; begin if not is_empty (My_Networks) then reset_iterator (My_Networks, My_Iterator); loop current_element (My_Networks, A_Network, My_Iterator); if (A_Network.name = Name) then Found := True; Result := A_Network; end if; exit when is_last_element (My_Networks, My_Iterator); next_element (My_Networks, My_Iterator); end loop; end if; if not Found then Raise_Exception (network_not_found'Identity, to_string(lb_name(current_language) & " = " & name) ); end if; return Result; end Search_Network; function Export_Aadl_Implementations (My_Networks : in Networks_Set) return Unbounded_String is My_Iterator : iterator; A_Network : generic_Network_Ptr; Result : Unbounded_String := empty_string; begin if not is_empty (My_Networks) then reset_iterator (My_Networks, My_Iterator); loop current_element (My_Networks, A_Network, My_Iterator); exit when is_last_element (My_Networks, My_Iterator); Result := Result & To_Unbounded_String ("bus " & To_String (A_Network.name)); Result := Result & To_Unbounded_String ("end " & To_String (A_Network.name) & ";"); Result := Result & To_Unbounded_String ("bus implementation " & To_String (A_Network.name) & ".Impl"); Result := Result & To_Unbounded_String ("end " & To_String (A_Network.name) & ".Impl"); next_element (My_Networks, My_Iterator); end loop; end if; return Result; end Export_Aadl_Implementations; function Export_Aadl_Declarations (My_Networks : in Networks_Set; Number_Of_Ht : in Natural) return Unbounded_String is My_Iterator : iterator; A_Network : generic_Network_Ptr; Result : Unbounded_String := empty_string; begin if not is_empty (My_Networks) then reset_iterator (My_Networks, My_Iterator); loop current_element (My_Networks, A_Network, My_Iterator); exit when is_last_element (My_Networks, My_Iterator); for I in 1 .. Number_Of_Ht loop Result := Result & ASCII.HT; end loop; Result := Result & To_Unbounded_String ("instancied_" & To_String (A_Network.name) & " : bus " & To_String (A_Network.name) & ".Impl;"); next_element (My_Networks, My_Iterator); end loop; end if; return Result; end Export_Aadl_Declarations; end Network_Set;