------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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-2023, 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 README.md -- -- 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 Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Command_Line; use Ada.Command_Line; with AADL_Config; use AADL_Config; with unbounded_strings; use unbounded_strings; with Text_IO; use Text_IO; with Ada.Exceptions; use Ada.Exceptions; with translate; use translate; with processor_set; use processor_set; with text_io; use text_io; with ada.strings.unbounded; use ada.strings.unbounded; with unbounded_strings; use unbounded_strings; with Dependencies ; use Dependencies; with Task_Dependencies; use Task_Dependencies; with Task_Dependencies; use Task_Dependencies.Half_Dep_Set; with sets; with Tasks; use Tasks; with Task_Set; use Task_Set; with Message_Set ; use Message_Set ; with Messages; use Messages ; with Systems; use Systems; with Framework; use Framework; with Call_Framework; use Call_Framework; with Call_Framework_Interface; use Call_Framework_Interface; use Call_Framework_Interface.Framework_Response_Package; use Call_Framework_Interface.Framework_Request_Package; with Call_Scheduling_Framework; use Call_Scheduling_Framework; with Multiprocessor_Services; use Multiprocessor_Services; with Multiprocessor_Services_Interface; use Multiprocessor_Services_Interface; with Multiprocessor_Services_Interface; use Multiprocessor_Services_Interface.Scheduling_Result_Per_Processor_Package; with GNAT.Command_Line; with GNAT.OS_Lib; use GNAT.OS_Lib; with Version; use Version; with Parameters; use Parameters; use Parameters.User_Defined_Parameters_Table_Package; with Parameters.extended; use Parameters.extended; with noc_analysis; use noc_analysis; with noc_analysis.delays ; use noc_analysis.delays ; package body noc_flow_transformation is ----------------- -- subprograms -- ----------------- ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ ----- flow_to_task_SAF converts the flow model generated by ------ ----- the network to a task model ------ ----- For SAF NoC Router: ------ ----- 1 flow/link ==> 1 task ------ ----- 1 link ==> 1 processor ------ ------------------------------------------------------------------------------------ ----- PS: 1. Delete (NoC / dependencies / messages) ------ ----- 2. add new messages with new dependencies. ------ ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ procedure flow_to_task_SAF ( My_processors : in out Processors_set; My_tasks : in out Tasks_set ; My_messages : in out Messages_Set ; My_Dependencies : in out Tasks_Dependencies_Ptr ; A_link_mat : in links_mat ; Destination_tasks : in Tasks_set ; Source_tasks : in Tasks_set ; My_Address_Spaces : in Address_Spaces_set ; My_core_units : in core_units_Set ) is My_Iterator1 : Tasks_Iterator; My_Iterator2 : Messages_iterator; A_Message : Generic_Message_Ptr; i, var1, var2, var3 , var4, var5 : integer ; A_link : noc_Links ; A_link_table : Links_tab ; A_TaskNS : Generic_Task_Ptr; A_TaskND : Generic_Task_Ptr; A_message1, A_message2 : Generic_Message_Ptr; A_task1 : Generic_Task_Ptr; A_task2 : Generic_Task_Ptr; Output_Sys_SAF : system; begin Output_Sys_SAF.Tasks := My_tasks ; Output_Sys_SAF.Processors := My_processors ; Output_Sys_SAF.Address_Spaces := My_Address_Spaces ; Output_Sys_SAF.Core_units := My_core_units ; Output_Sys_SAF.messages := My_messages ; -------------------------------------- -------------------------------------- --- 1 Unidir link ==> 1 processor ---- -------------------------------------- -------------------------------------- put_line (" ") ; put_line (" display the output model " ) ; Add_core_unit(My_core_units => Output_Sys_SAF.Core_units, A_core_unit => a_core, Name => Suppress_Space (To_Unbounded_String ("Core_Link")), Is_Preemptive => preemptive, Quantum => 0, speed => 1.0, capacity => 1, period => 1, priority => 1, File_Name => empty_string, A_Scheduler => DAG_highest_level_first_estimated_times_protocol, --Rate_Monotonic_Protocol, -- ou fixed priority protocol automaton_name => empty_string, start_time => 0); -------------------------- --les liens horizontales-- -------------------------- for j in 0 .. (Y_max) loop var1 := (Y_max+1) * j ; for i in 0 .. (X_max-1) loop var2 := var1 ; var1 := var1 + 1 ; Add_Processor(My_processors => Output_Sys_SAF.Processors, Name => Suppress_Space (To_Unbounded_String("proc_link "& var2'Img & "To " & var1'Img )), a_Core => a_core ); Add_Processor(My_processors => Output_Sys_SAF.Processors, Name => Suppress_Space (To_Unbounded_String("proc_link "& var1'Img & "To " & var2'Img )), a_Core => a_core ); Add_Address_Space(My_Address_Spaces => Output_Sys_SAF.Address_Spaces, Name => Suppress_Space (To_Unbounded_String ("Address_Space_" & var2'Img & "To" & var1'Img )), Cpu_Name => Suppress_Space (To_Unbounded_String ("proc_link"& var2'Img & "To" & var1'Img )), Text_Memory_Size => 1024, Stack_Memory_Size => 1024, Data_Memory_Size => 1024, Heap_Memory_Size => 1024); Add_Address_Space(My_Address_Spaces => Output_Sys_SAF.Address_Spaces, Name => Suppress_Space (To_Unbounded_String ("Address_Space_" & var1'Img & "To" & var2'Img )), Cpu_Name => Suppress_Space (To_Unbounded_String ("proc_link"& var1'Img & "To" & var2'Img )), Text_Memory_Size => 1024, Stack_Memory_Size => 1024, Data_Memory_Size => 1024, Heap_Memory_Size => 1024); end loop ; end loop ; -------------------------- --les liens verticales-- -------------------------- for j in 0 .. (Y_max) loop var1 := j ; for i in 0 .. (X_max-1) loop var2 := var1 ; var1 := var1 + (X_max+1) ; Add_Processor(My_processors => Output_Sys_SAF.Processors, Name => Suppress_Space (To_Unbounded_String("proc_link "& var2'Img & "To " & var1'Img )), a_Core => a_core ); Add_Processor(My_processors => Output_Sys_SAF.Processors, Name => Suppress_Space (To_Unbounded_String("proc_link "& var1'Img & "To " & var2'Img )), a_Core => a_core ); Add_Address_Space ( My_Address_Spaces => Output_Sys_SAF.Address_Spaces, Name => Suppress_Space (To_Unbounded_String ("Address_Space_" & var2'Img & "To" & var1'Img )), Cpu_Name => Suppress_Space (To_Unbounded_String ("proc_link"& var2'Img & "To" & var1'Img )), Text_Memory_Size => 1024, Stack_Memory_Size => 1024, Data_Memory_Size => 1024, Heap_Memory_Size => 1024 ); Add_Address_Space ( My_Address_Spaces => Output_Sys_SAF.Address_Spaces, Name => Suppress_Space (To_Unbounded_String ("Address_Space_" & var1'Img & "To" & var2'Img )), Cpu_Name => Suppress_Space (To_Unbounded_String ("proc_link"& var1'Img & "To" & var2'Img )), Text_Memory_Size => 1024, Stack_Memory_Size => 1024, Data_Memory_Size => 1024, Heap_Memory_Size => 1024); end loop ; end loop ; ---------------------------------------------------------------------------- --- 1 flow ==> A task set -------------------------------------------------- --- (the number of tasks depends on the used links by the flow) ------------ ---------------------------------------------------------------------------- ----- exemple : Message i over the link j ==> task_flowij ------------------ ---------------------------------------------------------------------------- i := 1 ; reset_iterator (My_messages, My_Iterator2); reset_iterator (Destination_tasks, My_Iterator1); loop put_line(" ") ; put_line(" -- --- --- --- --- -- " ) ; current_element (My_messages , A_Message, My_Iterator2) ; current_element (Destination_tasks , A_TaskND, My_Iterator1) ; current_element (Source_tasks , A_TaskNS, My_Iterator1) ; A_link_table := A_link_mat(i) ; For j in 1 .. Integer(link_table_size(i)) loop A_link := A_link_table(j) ; --------------------------------------- ------converts flows to tasks---------- --------------------------------------- Add_Task (My_tasks => Output_Sys_SAF.Tasks, A_Task => a_task, Name => Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img&j'Img)), Cpu_Name => Suppress_Space (To_Unbounded_String("proc_link"& A_link.source'Img & "To" & A_link.destination'Img )), Address_Space_Name => Suppress_Space (To_Unbounded_String("Address_Space_"& A_link.source'Img & "To" & A_link.destination'Img )), Task_Type => Periodic_Type, Start_Time => 0, Capacity => One_Link_delay, --- le temps de transmission (Path delay) d'un seul flit/lien Period => A_TaskNS.Deadline, --A_TaskNS.Period, --- Periode de tâche source Deadline => A_TaskND.Deadline, --- deadline de tâche destination Jitter => 0, Blocking_Time => 0, Priority => 1, --- Priorité de la tâche source Criticality => 0, Policy => Sched_Fifo); put_line ("Added task name : "& To_String(A_task.name) ) ; --------------------------------------- ------Produce Messages between--------- --------task_flow---------------------- --------------------------------------- var3 := j; if var3 >1 then Add_Message(My_Messages => Output_Sys_SAF.messages, Name => Suppress_Space (To_Unbounded_String("Message_of_flow " & i'Img & ":" & var3'Img)), Size => 0, Period => 0, Deadline => 0, Jitter => 0, Param => No_User_Defined_Parameter, Response_Time => 0, Communication_Time => 0); end if ; -- put_line ("Added Message name : "& Suppress_Space (To_Unbounded_String("Message_of_flow " & i'Img & ":" & var3'Img)) ) ; --------------------------------------- ------Produce dependency between------- ------ task_flow ------- --------------------------------------- var3 := j ; if var3 >1 then var4 := var3 - 1 ; A_task1 := Search_Task (Output_Sys_SAF.Tasks, Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img&var4'Img))) ; A_task2 := Search_Task (Output_Sys_SAF.Tasks, Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img&var3'Img))); A_message2 := Search_Message (Output_Sys_SAF.Messages, Suppress_Space (To_Unbounded_String("Message_of_flow " & i'Img & ":" & var3'Img))); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_task1, A_Dep => A_message2, A_Type => FROM_TASK_TO_OBJECT, protocol_property => All_Messages); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_task2, A_Dep => A_message2, A_Type => FROM_OBJECT_TO_TASK, protocol_property => All_Messages); put_line ("from : "& To_String(A_task1.name) & " to " & To_String(A_task2.name) & " over " & To_String(A_message2.name) ) ; end if ; end loop ; --------------------------------------- ------Produce Messages between ------ ------ Source task and ------ ------ the first task_flow ------ --------------------------------------- Add_Message(My_Messages => Output_Sys_SAF.messages, Name => Suppress_Space (To_Unbounded_String("Message_of_flow" & i'Img & "from_source")), Size => 0, Period => 0, Deadline => 0, Jitter => 0, Param => No_User_Defined_Parameter, Response_Time => 0, Communication_Time => 0); --------------------------------------- ------Produce dependency between ------ ------ Source task and ------ ------ the first task_flow ------ --------------------------------------- A_message1 := Search_Message (Output_Sys_SAF.messages, Suppress_Space (To_Unbounded_String ("Message_of_flow" & i'Img & "from_source"))) ; A_task1 := Search_Task (Output_Sys_SAF.Tasks, Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img&"1"))) ; Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_TaskNS, A_Dep => A_message1, A_Type => FROM_TASK_TO_OBJECT, protocol_property => All_Messages); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_task1, A_Dep => A_message1, A_Type => FROM_OBJECT_TO_TASK, protocol_property => All_Messages); put_line ("from : "& To_String(A_TaskNS.name) & " to " & To_String(A_task1.name) & " over " & To_String(A_message1.name) ) ; --------------------------------------- ------Produce Messages between ------ ------ the last task_flow ------ ------ and the Destination task ------ --------------------------------------- Add_Message(My_Messages => Output_Sys_SAF.messages, Name => Suppress_Space (To_Unbounded_String("Message_of_flow" & i'Img & "To_Destination")), Size => 0, Period => 0, Deadline => 0, Jitter => 0, Param => No_User_Defined_Parameter, Response_Time => 0, Communication_Time => 0); --------------------------------------- ------Produce dependency between ------ ------ the last task_flow ------ ------ and the Destination task ------ --------------------------------------- A_message1 := Search_Message (Output_Sys_SAF.messages, Suppress_Space (To_Unbounded_String ("Message_of_flow" & i'Img & "To_Destination"))) ; var5 := Integer(link_table_size(i)) ; A_task2 := Search_Task (Output_Sys_SAF.Tasks, Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img&var5'Img))); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_Task2, A_Dep => A_message1, A_Type => FROM_TASK_TO_OBJECT, protocol_property => All_Messages); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_taskND, A_Dep => A_message1, A_Type => FROM_OBJECT_TO_TASK, protocol_property => All_Messages); put_line ("from : "& To_String(A_task2.name) & " to " & To_String(A_taskND.name) & " over " & To_String(A_message1.name) ) ; i := i +1 ; exit when is_last_element (My_messages, My_Iterator2 ); next_element (My_messages , My_Iterator2) ; next_element (Destination_tasks, My_Iterator1) ; end loop; Output_Sys_SAF.dependencies := My_Dependencies ; Put_Line ("------------------------"); Put_Line ("Write system to xml file"); Write_To_Xml_File (A_System => Output_Sys_SAF , File_Name => "framework_examples/transformation_algo_for_noc/output_Model.xmlv3"); Put_Line ("Finish write"); Put_Line ("------------------------"); end flow_to_task_SAF ; ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ ----- flow_to_task_WCCT converts the flow model generated by ------ ----- the network to a task model ------ ----- For SAF/Wormhole NoC Router: ------ ----- 1 flow ==> 1 task + 1 processor ------ ------------------------------------------------------------------------------------ ----- PS: 1. Delete (NoC / dependencies / messages) ------ ----- 2. add new messages with new dependencies. ------ ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ procedure flow_to_task_WCCT_SAF ( My_processors : in out Processors_set; My_tasks : in out Tasks_set ; My_messages : in out Messages_Set ; My_Dependencies : in out Tasks_Dependencies_Ptr ; A_link_mat : in links_mat ; Destination_tasks : in Tasks_set ; Source_tasks : in Tasks_set ; My_Address_Spaces : in Address_Spaces_set ; My_core_units : in core_units_Set; packet_size : in integer ; One_Link_transmission_time : in integer ) is My_Iterator1 : Tasks_Iterator; My_Iterator2 : Messages_iterator; A_Message : Generic_Message_Ptr; i, var5 : integer ; A_TaskNS : Generic_Task_Ptr; A_TaskND : Generic_Task_Ptr; A_message1 : Generic_Message_Ptr; A_task1 : Generic_Task_Ptr; A_task2 : Generic_Task_Ptr; Output_Sys_WCCT : system ; Path_delay : Integer_Table ; shared_links : Integer_Table ; communication_time : Integer_Table ; begin ------------------------------------------------------------------- ------- compute the Worst case communication time for each flow --- ------------------------------------------------------------------- Compute_Path_delay ( packet_size => packet_size , injection_time => 0 , Path_delay => Path_delay ) ; compute_Direct_Interference ( A_link_mat => A_link_mat , shared_links => shared_links ) ; Compute_Communication_Time_SAF ( My_messages => My_messages, Path_delay => Path_delay, shared_links => shared_links, communication_time => communication_time, One_Link_transmission_time => One_Link_transmission_time ) ; --------------------------------------------------------------------- --------------------------------------------------------------------- Output_Sys_WCCT.Tasks := My_tasks ; Output_Sys_WCCT.Processors := My_processors ; Output_Sys_WCCT.Address_Spaces := My_Address_Spaces ; Output_Sys_WCCT.Core_units := My_core_units ; Output_Sys_WCCT.messages := My_messages ; put_line (" ") ; put_line (" display the output model " ) ; Add_core_unit(My_core_units => Output_Sys_WCCT.Core_units, A_core_unit => a_core, Name => Suppress_Space (To_Unbounded_String ("Core_Link")), Is_Preemptive => preemptive, Quantum => 0, speed => 1.0, capacity => 1, period => 1, priority => 1, File_Name => empty_string, A_Scheduler => DAG_highest_level_first_estimated_times_protocol, --Rate_Monotonic_Protocol, -- ou fixed priority protocol automaton_name => empty_string, start_time => 0); ---------------------------------------------------------------------------- --- 1 flow ==> 1 task + 1 processor + adresse space ------------------------ ---------------------------------------------------------------------------- i := 1 ; reset_iterator (My_messages, My_Iterator2); reset_iterator (Destination_tasks, My_Iterator1); loop put_line(" ") ; put_line(" -- --- --- --- --- -- " ) ; current_element (My_messages , A_Message, My_Iterator2) ; current_element (Destination_tasks , A_TaskND, My_Iterator1) ; current_element (Source_tasks , A_TaskNS, My_Iterator1) ; -------------------------------------------- ----- add a new processor (proc_flow) ------ -------------------------------------------- Add_Processor(My_processors => Output_Sys_WCCT.Processors, Name => Suppress_Space (To_Unbounded_String("proc_flow "& i'Img)), a_Core => a_core ); --------------------------------------------------------- ----- add a new Address_Space (Address_Space_flow) ------ --------------------------------------------------------- Add_Address_Space ( My_Address_Spaces => Output_Sys_WCCT.Address_Spaces, Name => Suppress_Space (To_Unbounded_String ("Address_Space_flow" & i'Img )), Cpu_Name => Suppress_Space (To_Unbounded_String("proc_flow "& i'Img)), Text_Memory_Size => 1024, Stack_Memory_Size => 1024, Data_Memory_Size => 1024, Heap_Memory_Size => 1024 ); --------------------------------------- ----- add a new task (task_flow) ------ --------------------------------------- Add_Task (My_tasks => Output_Sys_WCCT.Tasks, A_Task => a_task, Name => Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img)), Cpu_Name => Suppress_Space (To_Unbounded_String("proc_flow "& i'Img)), Address_Space_Name => Suppress_Space (To_Unbounded_String ("Address_Space_flow" & i'Img )), Task_Type => Periodic_Type, Start_Time => 0, Capacity => communication_time(i), --- le pire temps de communication Period => A_TaskNS.Deadline, --- Periode de tâche source Deadline => A_TaskND.Deadline, --- deadline de tâche destination Jitter => 0, Blocking_Time => 0, Priority => 1, --- Priorité de la tâche source Criticality => 0, Policy => Sched_Fifo); put_line ("Added task name : "& To_String(A_task.name) ) ; --------------------------------------- ------Produce Messages between ------ ------ Source task and ------ ------ the task_flow ------ --------------------------------------- Add_Message(My_Messages => Output_Sys_WCCT.messages, Name => Suppress_Space (To_Unbounded_String("Message_of_flow" & i'Img & "from_source")), Size => 0, Period => 0, Deadline => 0, Jitter => 0, Param => No_User_Defined_Parameter, Response_Time => 0, Communication_Time => 0); --------------------------------------- ------Produce dependency between ------ ------ Source task and ------ ------ the task_flow ------ --------------------------------------- A_message1 := Search_Message (Output_Sys_WCCT.messages, Suppress_Space (To_Unbounded_String ("Message_of_flow" & i'Img & "from_source"))) ; A_task1 := Search_Task (Output_Sys_WCCT.Tasks, Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img))) ; put_line ("test" ) ; Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_TaskNS, A_Dep => A_message1, A_Type => FROM_TASK_TO_OBJECT, protocol_property => All_Messages); put_line ("test1" ) ; Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_task1, A_Dep => A_message1, A_Type => FROM_OBJECT_TO_TASK, protocol_property => All_Messages); put_line ("test2" ) ; put_line ("from : "& To_String(A_TaskNS.name) & " to " & To_String(A_task1.name) & " over " & To_String(A_message1.name) ) ; --------------------------------------- ------Produce Messages between ------ ------ the task_flow ------ ------ and the Destination task ------ --------------------------------------- Add_Message(My_Messages => Output_Sys_WCCT.messages, Name => Suppress_Space (To_Unbounded_String("Message_of_flow" & i'Img & "To_Destination")), Size => 0, Period => 0, Deadline => 0, Jitter => 0, Param => No_User_Defined_Parameter, Response_Time => 0, Communication_Time => 0); --------------------------------------- ------Produce dependency between ------ ------ the task_flow ------ ------ and the Destination task ------ --------------------------------------- A_message1 := Search_Message (Output_Sys_WCCT.messages, Suppress_Space (To_Unbounded_String ("Message_of_flow" & i'Img & "To_Destination"))) ; var5 := Integer(link_table_size(i)) ; A_task2 := Search_Task (Output_Sys_WCCT.Tasks, Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img))); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_Task2, A_Dep => A_message1, A_Type => FROM_TASK_TO_OBJECT, protocol_property => All_Messages); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_taskND, A_Dep => A_message1, A_Type => FROM_OBJECT_TO_TASK, protocol_property => All_Messages); put_line ("from : "& To_String(A_task2.name) & " to " & To_String(A_taskND.name) & " over " & To_String(A_message1.name) ) ; i := i +1 ; exit when is_last_element (My_messages, My_Iterator2 ); next_element (My_messages , My_Iterator2) ; next_element (Destination_tasks, My_Iterator1) ; end loop; Output_Sys_WCCT.dependencies := My_Dependencies ; Put_Line ("------------------------"); Put_Line ("Write system to xml file"); Write_To_Xml_File (A_System => Output_Sys_WCCT , File_Name => "framework_examples/transformation_algo_for_noc/output_Model.xmlv3"); Put_Line ("Finish write"); Put_Line ("------------------------"); end flow_to_task_WCCT_SAF ; ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ ----- flow_to_task_SAF converts the flow model generated by ------ ----- the network to a task model ------ ----- For SAF NoC Router: ------ ----- 1 flow/link ==> 1 task ------ ----- 1 link ==> 1 processor ------ ------------------------------------------------------------------------------------ ----- PS: 1. Delete (NoC / dependencies / messages) ------ ----- 2. add new messages with new dependencies. ------ ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ procedure flow_to_task_Wormhole ( My_processors : in out Processors_set; My_tasks : in out Tasks_set ; My_messages : in out Messages_Set ; My_Dependencies : in out Tasks_Dependencies_Ptr ; A_link_mat : in links_mat ; Destination_tasks : in Tasks_set ; Source_tasks : in Tasks_set ; My_Address_Spaces : in Address_Spaces_set ; My_core_units : in core_units_Set ; Packet_size : in integer ) is My_Iterator1 : Tasks_Iterator; My_Iterator2 : Messages_iterator; A_Message : Generic_Message_Ptr; i, var1, var2, var3 , var4, var5 : integer ; A_link : noc_Links ; A_link_table : Links_tab ; A_TaskNS : Generic_Task_Ptr; A_TaskND : Generic_Task_Ptr; A_message1, A_message2 : Generic_Message_Ptr; A_task1 : Generic_Task_Ptr; A_task2 : Generic_Task_Ptr; begin Sys.Tasks := My_tasks ; Sys.Processors := My_processors ; Sys.Address_Spaces := My_Address_Spaces ; Sys.Core_units := My_core_units ; Sys.messages := My_messages ; Sys.dependencies := My_Dependencies ; -------------------------------------- -------------------------------------- --- 1 Unidir link ==> 1 processor ---- -------------------------------------- -------------------------------------- put_line (" ") ; put_line (" display the output model " ) ; Add_core_unit(My_core_units => Sys.Core_units, A_core_unit => a_core, Name => Suppress_Space (To_Unbounded_String ("Core_Link")), Is_Preemptive => preemptive, Quantum => 0, speed => 1.0, capacity => 1, period => 1, priority => 1, File_Name => empty_string, A_Scheduler => DAG_highest_level_first_estimated_times_protocol, --Rate_Monotonic_Protocol, -- ou fixed priority protocol automaton_name => empty_string, start_time => 0); -------------------------- --les liens horizontales-- -------------------------- for j in 0 .. (Y_max) loop var1 := (Y_max+1) * j ; for i in 0 .. (X_max-1) loop var2 := var1 ; var1 := var1 + 1 ; Add_Processor(My_processors => Sys.Processors, Name => Suppress_Space (To_Unbounded_String("proc_link "& var2'Img & "To " & var1'Img )), a_Core => a_core ); Add_Processor(My_processors => Sys.Processors, Name => Suppress_Space (To_Unbounded_String("proc_link "& var1'Img & "To " & var2'Img )), a_Core => a_core ); --put_line ("proc_link "& var1'Img & "To " & var2'Img ) ; Add_Address_Space(My_Address_Spaces => Sys.Address_Spaces, Name => Suppress_Space (To_Unbounded_String ("Address_Space_" & var2'Img & "To" & var1'Img )), Cpu_Name => Suppress_Space (To_Unbounded_String ("proc_link"& var2'Img & "To" & var1'Img )), Text_Memory_Size => 1024, Stack_Memory_Size => 1024, Data_Memory_Size => 1024, Heap_Memory_Size => 1024); Add_Address_Space(My_Address_Spaces => Sys.Address_Spaces, Name => Suppress_Space (To_Unbounded_String ("Address_Space_" & var1'Img & "To" & var2'Img )), Cpu_Name => Suppress_Space (To_Unbounded_String ("proc_link"& var1'Img & "To" & var2'Img )), Text_Memory_Size => 1024, Stack_Memory_Size => 1024, Data_Memory_Size => 1024, Heap_Memory_Size => 1024); end loop ; end loop ; -------------------------- --les liens verticales-- -------------------------- for j in 0 .. (Y_max) loop var1 := j ; for i in 0 .. (X_max-1) loop var2 := var1 ; var1 := var1 + (X_max+1) ; Add_Processor(My_processors => Sys.Processors, Name => Suppress_Space (To_Unbounded_String("proc_link "& var2'Img & "To " & var1'Img )), a_Core => a_core ); Add_Processor(My_processors => Sys.Processors, Name => Suppress_Space (To_Unbounded_String("proc_link "& var1'Img & "To " & var2'Img )), a_Core => a_core ); --put_line ("proc_link "& var1'Img & "To " & var2'Img ) ; Add_Address_Space ( My_Address_Spaces => Sys.Address_Spaces, Name => Suppress_Space (To_Unbounded_String ("Address_Space_" & var2'Img & "To" & var1'Img )), Cpu_Name => Suppress_Space (To_Unbounded_String ("proc_link"& var2'Img & "To" & var1'Img )), Text_Memory_Size => 1024, Stack_Memory_Size => 1024, Data_Memory_Size => 1024, Heap_Memory_Size => 1024 ); Add_Address_Space ( My_Address_Spaces => Sys.Address_Spaces, Name => Suppress_Space (To_Unbounded_String ("Address_Space_" & var1'Img & "To" & var2'Img )), Cpu_Name => Suppress_Space (To_Unbounded_String ("proc_link"& var1'Img & "To" & var2'Img )), Text_Memory_Size => 1024, Stack_Memory_Size => 1024, Data_Memory_Size => 1024, Heap_Memory_Size => 1024); end loop ; end loop ; -- number of task_flow = packet_size * number of used links by the flow i := 1 ; reset_iterator (My_messages, My_Iterator2); reset_iterator (Destination_tasks, My_Iterator1); loop put_line(" ") ; put_line(" -- --- --- --- --- -- " ) ; current_element (My_messages , A_Message, My_Iterator2) ; current_element (Destination_tasks , A_TaskND, My_Iterator1) ; current_element (Source_tasks , A_TaskNS, My_Iterator1) ; A_link_table := A_link_mat(i) ; For j in 1 .. Integer(link_table_size(i)) loop A_link := A_link_table(j) ; --------------------------------------- ------converts flows to tasks---------- --------------------------------------- for flit in 1 .. Packet_size loop Add_Task (My_tasks => Sys.Tasks, A_Task => a_task, Name => Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img&j'Img&":"&flit'Img)), Cpu_Name => Suppress_Space (To_Unbounded_String("proc_link"& A_link.source'Img & "To" & A_link.destination'Img )), Address_Space_Name => Suppress_Space (To_Unbounded_String("Address_Space_"& A_link.source'Img & "To" & A_link.destination'Img )), Task_Type => Periodic_Type, Start_Time => 0, Capacity => One_Link_delay, --- le temps de transmission (Path delay) d'un seul flit/lien Period => A_TaskNS.Deadline, --- Periode de tâche source Deadline => A_TaskND.Deadline, --- deadline de tâche destination Jitter => 0, Blocking_Time => 0, Priority => 1, --- Priorité de la tâche source Criticality => 0, Policy => Sched_Fifo); put_line ("Added task name : "& To_String(A_task.name) ) ; --------------------------------------- ------Produce Messages between--------- --------task_flow---------------------- --------------------------------------- var3 := j; if var3 >1 then Add_Message(My_Messages => Sys.messages, Name => Suppress_Space (To_Unbounded_String("Message_of_flow_H " & i'Img & ":" & var3'Img & ":" & flit'Img )), Size => 0, Period => 0, Deadline => 0, Jitter => 0, Param => No_User_Defined_Parameter, Response_Time => 0, Communication_Time => 0); end if ; -- put_line ("Added Message name : "& Suppress_Space (To_Unbounded_String("Message_of_flow " & i'Img & ":" & var3'Img)) ) ; --------------------------------------- ------Produce dependency between------- ------ task_flow ------- --------------------------------------- var3 := j ; if var3 >1 then var4 := var3 - 1 ; A_task1 := Search_Task (Sys.Tasks, Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img&var4'Img&":"&flit'Img))) ; A_task2 := Search_Task (Sys.Tasks, Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img&var3'Img&":"&flit'Img))); A_message2 := Search_Message (Sys.Messages, Suppress_Space (To_Unbounded_String("Message_of_flow_H " & i'Img & ":" & var3'Img & ":" & flit'Img))); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_task1, A_Dep => A_message2, A_Type => FROM_TASK_TO_OBJECT, protocol_property => All_Messages); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_task2, A_Dep => A_message2, A_Type => FROM_OBJECT_TO_TASK, protocol_property => All_Messages); put_line ("from : "& To_String(A_task1.name) & " to " & To_String(A_task2.name) & " over " & To_String(A_message2.name) ) ; end if ; end loop ; end loop ; --------------------------------------- ------Produce Messages between ------ ------ Source task and ------ ------ the first task_flow ------ --------------------------------------- for flit in 1 .. Packet_size loop Add_Message(My_Messages => Sys.messages, Name => Suppress_Space (To_Unbounded_String("Message_of_flow" & i'Img & ":" & flit'Img & "from_source")), Size => 0, Period => 0, Deadline => 0, Jitter => 0, Param => No_User_Defined_Parameter, Response_Time => 0, Communication_Time => 0); --------------------------------------- ------Produce dependency between ------ ------ Source task and ------ ------ the first task_flow ------ --------------------------------------- A_message1 := Search_Message (Sys.messages, Suppress_Space (To_Unbounded_String ("Message_of_flow" & i'Img & ":" & flit'Img & "from_source"))) ; A_task1 := Search_Task (Sys.Tasks, Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img&"1"&":"&flit'Img))) ; Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_TaskNS, A_Dep => A_message1, A_Type => FROM_TASK_TO_OBJECT, protocol_property => All_Messages); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_task1, A_Dep => A_message1, A_Type => FROM_OBJECT_TO_TASK, protocol_property => All_Messages); put_line ("from : "& To_String(A_TaskNS.name) & " to " & To_String(A_task1.name) & " over " & To_String(A_message1.name) ) ; --------------------------------------- ------Produce Messages between ------ ------ the last task_flow ------ ------ and the Destination task ------ --------------------------------------- Add_Message(My_Messages => Sys.messages, Name => Suppress_Space (To_Unbounded_String("Message_of_flow" & i'Img & ":" & flit'Img & "To_Destination")), Size => 0, Period => 0, Deadline => 0, Jitter => 0, Param => No_User_Defined_Parameter, Response_Time => 0, Communication_Time => 0); --------------------------------------- ------Produce dependency between ------ ------ the last task_flow ------ ------ and the Destination task ------ --------------------------------------- A_message1 := Search_Message (Sys.messages, Suppress_Space (To_Unbounded_String ("Message_of_flow" & i'Img & ":" & flit'Img & "To_Destination"))) ; var5 := Integer(link_table_size(i)) ; A_task2 := Search_Task (Sys.Tasks, Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img&var5'Img & ":" & flit'Img))); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_Task2, A_Dep => A_message1, A_Type => FROM_TASK_TO_OBJECT, protocol_property => All_Messages); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_taskND, A_Dep => A_message1, A_Type => FROM_OBJECT_TO_TASK, protocol_property => All_Messages); put_line ("from : "& To_String(A_task2.name) & " to " & To_String(A_taskND.name) & " over " & To_String(A_message1.name) ) ; end loop ; i := i +1 ; exit when is_last_element (My_messages, My_Iterator2 ); next_element (My_messages , My_Iterator2) ; next_element (Destination_tasks, My_Iterator1) ; end loop; Put_Line ("------------------------"); Put_Line ("Write system to xml file"); Write_To_Xml_File (A_System => Sys , File_Name => "framework_examples/transformation_algo_for_noc/output_Model.xmlv3"); Put_Line ("Finish write"); Put_Line ("------------------------"); end flow_to_task_Wormhole ; ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ ----- flow_to_task_WCCT converts the flow model generated by ------ ----- the network to a task model ------ ----- For SAF/Wormhole NoC Router: ------ ----- 1 flow ==> 1 task + 1 processor ------ ------------------------------------------------------------------------------------ ----- PS: 1. Delete (NoC / dependencies / messages) ------ ----- 2. add new messages with new dependencies. ------ ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ procedure flow_to_task_WCCT_Wormhole ( My_processors : in out Processors_set; My_tasks : in out Tasks_set ; My_messages : in out Messages_Set ; My_Dependencies : in out Tasks_Dependencies_Ptr ; A_link_mat : in links_mat ; Destination_tasks : in Tasks_set ; Source_tasks : in Tasks_set ; My_Address_Spaces : in Address_Spaces_set ; My_core_units : in core_units_Set; packet_size : in integer ; One_Link_transmission_time : in integer ) is My_Iterator1 : Tasks_Iterator; My_Iterator2 : Messages_iterator; A_Message : Generic_Message_Ptr; i, var5 : integer ; A_TaskNS : Generic_Task_Ptr; A_TaskND : Generic_Task_Ptr; A_message1 : Generic_Message_Ptr; A_task1 : Generic_Task_Ptr; A_task2 : Generic_Task_Ptr; Output_Sys_WCCT : system ; Path_delay : Integer_Table ; shared_links : Integer_Table ; communication_time : Integer_Table ; begin ------------------------------------------------------------------- ------- compute the Worst case communication time for each flow --- ------------------------------------------------------------------- Compute_Path_delay ( packet_size => packet_size , injection_time => 0 , Path_delay => Path_delay ) ; compute_Direct_Interference ( A_link_mat => A_link_mat , shared_links => shared_links ) ; Compute_Communication_Time_Wormhole ( My_messages => My_messages, Path_delay => Path_delay, shared_links => shared_links, communication_time => communication_time, One_Link_transmission_time => One_Link_transmission_time , packet_size => packet_size ) ; --------------------------------------------------------------------- --------------------------------------------------------------------- Output_Sys_WCCT.Tasks := My_tasks ; Output_Sys_WCCT.Processors := My_processors ; Output_Sys_WCCT.Address_Spaces := My_Address_Spaces ; Output_Sys_WCCT.Core_units := My_core_units ; Output_Sys_WCCT.messages := My_messages ; put_line (" ") ; put_line (" display the output model " ) ; Add_core_unit(My_core_units => Output_Sys_WCCT.Core_units, A_core_unit => a_core, Name => Suppress_Space (To_Unbounded_String ("Core_Link")), Is_Preemptive => preemptive, Quantum => 0, speed => 1.0, capacity => 1, period => 1, priority => 1, File_Name => empty_string, A_Scheduler => DAG_highest_level_first_estimated_times_protocol, --Rate_Monotonic_Protocol, -- ou fixed priority protocol automaton_name => empty_string, start_time => 0); ---------------------------------------------------------------------------- --- 1 flow ==> 1 task + 1 processor + adresse space ------------------------ ---------------------------------------------------------------------------- i := 1 ; reset_iterator (My_messages, My_Iterator2); reset_iterator (Destination_tasks, My_Iterator1); loop put_line(" ") ; put_line(" -- --- --- --- --- -- " ) ; current_element (My_messages , A_Message, My_Iterator2) ; current_element (Destination_tasks , A_TaskND, My_Iterator1) ; current_element (Source_tasks , A_TaskNS, My_Iterator1) ; -------------------------------------------- ----- add a new processor (proc_flow) ------ -------------------------------------------- Add_Processor(My_processors => Output_Sys_WCCT.Processors, Name => Suppress_Space (To_Unbounded_String("proc_flow "& i'Img)), a_Core => a_core ); --------------------------------------------------------- ----- add a new Address_Space (Address_Space_flow) ------ --------------------------------------------------------- Add_Address_Space ( My_Address_Spaces => Output_Sys_WCCT.Address_Spaces, Name => Suppress_Space (To_Unbounded_String ("Address_Space_flow" & i'Img )), Cpu_Name => Suppress_Space (To_Unbounded_String("proc_flow "& i'Img)), Text_Memory_Size => 1024, Stack_Memory_Size => 1024, Data_Memory_Size => 1024, Heap_Memory_Size => 1024 ); --------------------------------------- ----- add a new task (task_flow) ------ --------------------------------------- Add_Task (My_tasks => Output_Sys_WCCT.Tasks, A_Task => a_task, Name => Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img)), Cpu_Name => Suppress_Space (To_Unbounded_String("proc_flow "& i'Img)), Address_Space_Name => Suppress_Space (To_Unbounded_String ("Address_Space_flow" & i'Img )), Task_Type => Periodic_Type, Start_Time => 0, Capacity => communication_time(i), --- le pire temps de communication Period => A_TaskNS.Deadline, --- Periode de tâche source Deadline => A_TaskND.Deadline, --- deadline de tâche destination Jitter => 0, Blocking_Time => 0, Priority => 1, --- Priorité de la tâche source Criticality => 0, Policy => Sched_Fifo); put_line ("Added task name : "& To_String(A_task.name) ) ; --------------------------------------- ------Produce Messages between ------ ------ Source task and ------ ------ the task_flow ------ --------------------------------------- Add_Message(My_Messages => Output_Sys_WCCT.messages, Name => Suppress_Space (To_Unbounded_String("Message_of_flow" & i'Img & "from_source")), Size => 0, Period => 0, Deadline => 0, Jitter => 0, Param => No_User_Defined_Parameter, Response_Time => 0, Communication_Time => 0); --------------------------------------- ------Produce dependency between ------ ------ Source task and ------ ------ the task_flow ------ --------------------------------------- A_message1 := Search_Message (Output_Sys_WCCT.messages, Suppress_Space (To_Unbounded_String ("Message_of_flow" & i'Img & "from_source"))) ; A_task1 := Search_Task (Output_Sys_WCCT.Tasks, Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img))) ; Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_TaskNS, A_Dep => A_message1, A_Type => FROM_TASK_TO_OBJECT, protocol_property => All_Messages); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_task1, A_Dep => A_message1, A_Type => FROM_OBJECT_TO_TASK, protocol_property => All_Messages); put_line ("from : "& To_String(A_TaskNS.name) & " to " & To_String(A_task1.name) & " over " & To_String(A_message1.name) ) ; --------------------------------------- ------Produce Messages between ------ ------ the task_flow ------ ------ and the Destination task ------ --------------------------------------- Add_Message(My_Messages => Output_Sys_WCCT.messages, Name => Suppress_Space (To_Unbounded_String("Message_of_flow" & i'Img & "To_Destination")), Size => 0, Period => 0, Deadline => 0, Jitter => 0, Param => No_User_Defined_Parameter, Response_Time => 0, Communication_Time => 0); --------------------------------------- ------Produce dependency between ------ ------ the task_flow ------ ------ and the Destination task ------ --------------------------------------- A_message1 := Search_Message (Output_Sys_WCCT.messages, Suppress_Space (To_Unbounded_String ("Message_of_flow" & i'Img & "To_Destination"))) ; var5 := Integer(link_table_size(i)) ; A_task2 := Search_Task (Output_Sys_WCCT.Tasks, Suppress_Space (To_Unbounded_String ("Task_flow"&i'Img))); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_Task2, A_Dep => A_message1, A_Type => FROM_TASK_TO_OBJECT, protocol_property => All_Messages); Add_One_Task_Dependency_asynchronous_communication (My_Dependencies => My_Dependencies, A_Task => A_taskND, A_Dep => A_message1, A_Type => FROM_OBJECT_TO_TASK, protocol_property => All_Messages); put_line ("from : "& To_String(A_task2.name) & " to " & To_String(A_taskND.name) & " over " & To_String(A_message1.name) ) ; i := i +1 ; exit when is_last_element (My_messages, My_Iterator2 ); next_element (My_messages , My_Iterator2) ; next_element (Destination_tasks, My_Iterator1) ; end loop; Output_Sys_WCCT.dependencies := My_Dependencies ; Put_Line ("------------------------"); Put_Line ("Write system to xml file"); Write_To_Xml_File (A_System => Output_Sys_WCCT , File_Name => "framework_examples/transformation_algo_for_noc/output_Model.xmlv3"); Put_Line ("Finish write"); Put_Line ("------------------------"); end flow_to_task_WCCT_Wormhole ; end noc_flow_transformation;