Commit 49d61433 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Improve templates for simulation

parent d6f6a381
...@@ -135,7 +135,7 @@ package body @_CAPITALIZE:Name_@_Events is ...@@ -135,7 +135,7 @@ package body @_CAPITALIZE:Name_@_Events is
(Kind => Output_Event_PRESENT); (Kind => Output_Event_PRESENT);
Limit_Reached : Boolean; Limit_Reached : Boolean;
begin begin
-- Put_Line ("Exhausing interface @_CAPITALIZE:List_Of_ASync_RIs_@"); -- Put_Line ("Exhausting interface @_CAPITALIZE:List_Of_ASync_RIs_@");
-- Create an event to store as an edge of the state graph -- Create an event to store as an edge of the state graph
Event.Output_Event.Source := asn1Scc@_CAPITALIZE:Name_@; Event.Output_Event.Source := asn1Scc@_CAPITALIZE:Name_@;
Event.Output_Event.Dest := asn1Scc@_CAPITALIZE:Async_RIs_Parent_@; Event.Output_Event.Dest := asn1Scc@_CAPITALIZE:Async_RIs_Parent_@;
......
...@@ -24,7 +24,7 @@ package body Simulator_Interface is ...@@ -24,7 +24,7 @@ package body Simulator_Interface is
(Kind => System_Startup_PRESENT, (Kind => System_Startup_PRESENT,
System_Startup => (null record)); System_Startup => (null record));
begin begin
Text_IO.Put_Line ("Simulation startup"); Text_IO.Put_Line ("[-] Simulator_Interface startup");
Full_State := Full_State_Init; Full_State := Full_State_Init;
...@@ -55,7 +55,7 @@ package body Simulator_Interface is ...@@ -55,7 +55,7 @@ package body Simulator_Interface is
Start_Time : constant Time := Clock; Start_Time : constant Time := Clock;
begin begin
if not Init then if not Init then
Put_Line ("Error: you must call Startup function first"); Put_Line ("[X] ERROR: you must call Startup function first");
return; return;
end if; end if;
...@@ -69,18 +69,18 @@ package body Simulator_Interface is ...@@ -69,18 +69,18 @@ package body Simulator_Interface is
end loop; end loop;
if ES.Properties.Length > 0 then if ES.Properties.Length > 0 then
Put_Line ("Generating MSC"); Put_Line ("[-] Generating MSC");
ES.Generate_MSC; ES.Generate_MSC;
end if; end if;
Put_Line ("Called" & ES.Count'Img & " interfaces"); Put_Line ("[-] Called" & ES.Count'Img & " interfaces");
Put_Line ("Visited" & ES.Grafset.Length'Img & " states"); Put_Line ("[-] Visited" & ES.Grafset.Length'Img & " states");
Put_Line ("Execution time:" & Duration'Image (Clock - Start_Time) & "s."); Put_Line ("[-] Execution time:" & Duration'Image (Clock - Start_Time) & "s.");
end Run_Exhaustive_Simulation; end Run_Exhaustive_Simulation;
procedure Process_Event (Event : asn1SccObservable_Event) is procedure Process_Event (Event : asn1SccObservable_Event) is
begin begin
Put(" *** Process_Event : "); Put("[-] Process_Event : ");
Print_Event (Event); Print_Event (Event);
User_State := Application_State (Full_state); User_State := Application_State (Full_state);
case Event.Kind is case Event.Kind is
...@@ -168,7 +168,7 @@ package body Simulator_Interface is ...@@ -168,7 +168,7 @@ package body Simulator_Interface is
-- for (3): -- for (3):
loop loop
-- Make sure all message queues are drained -- Make sure all message queues are drained
@@INLINE( exit when Stop_Condition or \(Simulator.Events.Length = 0 and )( and )(\);\n)@@ @@INLINE( exit when Stop_Condition or \(Simulator.Events.Length = 0 and )( and )(\);\n)@@
@@TABLE@@ @@TABLE@@
@@-- Timer Managers (Tick only) and Passive functions have no input queue. Queues are for sporadic. @@-- Timer Managers (Tick only) and Passive functions have no input queue. Queues are for sporadic.
@@IF@@ @_Block_Languages_@ /= GUI and @_Block_Languages_@ /= Timer_Manager and not @_Block_Is_Passive_@ @@IF@@ @_Block_Languages_@ /= GUI and @_Block_Languages_@ /= Timer_Manager and not @_Block_Is_Passive_@
...@@ -209,21 +209,21 @@ package body Simulator_Interface is ...@@ -209,21 +209,21 @@ package body Simulator_Interface is
-- Clear the queue of event in case stop conditions interrupted them -- Clear the queue of event in case stop conditions interrupted them
Simulator.Events.Length := 0; Simulator.Events.Length := 0;
Put_Line ("Number of states before Add_To_Graph: " & ES.Grafset.Length'Img); Put_Line ("[-] Number of states before Add_To_Graph: " & ES.Grafset.Length'Img);
-- for (5): -- for (5):
Unused_Hash := ES.Add_To_Graph (Event, Id, Stop_Condition); Unused_Hash := ES.Add_To_Graph (Event, Id, Stop_Condition);
Put_Line ("STATE AT THE END OF CALLBACK: " & State_As_String (Full_State)); Put_Line ("[-] STATE AT THE END OF CALLBACK: " & State_As_String (Full_State));
-- Put_Line ("hash: " & Unused_Hash'Img & " In Grafset: " & ES.Grafset.Contains (Key=>Unused_Hash)'Img); -- Put_Line ("hash: " & Unused_Hash'Img & " In Grafset: " & ES.Grafset.Contains (Key=>Unused_Hash)'Img);
-- Put_Line ("ES Queue Length : " & ES.Queue.Length'Img); -- Put_Line ("ES Queue Length : " & ES.Queue.Length'Img);
Put_Line("Stop Condition = " & Stop_Condition'img); Put_Line("[-] Stop Condition = " & Stop_Condition'img);
-- Put_Line ("ES.Visited.Contains(Hash)? " & ES.Visited.Contains(Unused_Hash)'Img); -- Put_Line ("ES.Visited.Contains(Hash)? " & ES.Visited.Contains(Unused_Hash)'Img);
-- Restore the full state (to get the observer in original state for the next iteration -- Restore the full state (to get the observer in original state for the next iteration
Full_State := ES.Backup_Ctxt; Full_State := ES.Backup_Ctxt;
-- Put_Line ("ES_Callback: " & System_State_Pkg.Image (Simulator.State)); -- Put_Line ("[-] ES_Callback: " & System_State_Pkg.Image (Simulator.State));
Put_Line ("Number of states after Add_To_Graph: " & ES.Grafset.Length'Img); Put_Line ("[-] Number of states after Add_To_Graph: " & ES.Grafset.Length'Img);
Limit_Reached := ES.Properties.Length >= 10; Limit_Reached := ES.Properties.Length >= 10;
end ES_Callback; end ES_Callback;
......
...@@ -22,7 +22,9 @@ package Simulator_Interface is ...@@ -22,7 +22,9 @@ package Simulator_Interface is
-- not visible here. This is an opaque type, but it is tagged, -- not visible here. This is an opaque type, but it is tagged,
-- and user provides function to read/write the application state -- and user provides function to read/write the application state
Full_State : State_With_Observers; Full_State : State_With_Observers;
User_State : aliased asn1SccSystem_State; -- State without observers -- State without observers, exported for python ctypes interfacing
User_State : aliased asn1SccSystem_State
with Export, Convention => C, Link_Name => "global_state";
procedure Simulation_Startup; procedure Simulation_Startup;
......
...@@ -16,7 +16,8 @@ package Simulator is ...@@ -16,7 +16,8 @@ package Simulator is
-- Exception raised by Pop_Event if the FIFO is empty -- Exception raised by Pop_Event if the FIFO is empty
Empty_Queue : exception; Empty_Queue : exception;
-- Event list (call of RI) -- Event list (call of RI). Export it to permit Python access with ctypes
Events : asn1SccEvents_Ty := asn1SccEvents_Ty_Init; Events : asn1SccEvents_Ty := asn1SccEvents_Ty_Init
with Export, Convention => C, Link_Name => "global_event_queue";
end Simulator; end Simulator;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment