Commit 20021542 authored by Maxime Perrotin's avatar Maxime Perrotin

Simulink demo now builds fine using lated DMT

parent f5de4e09
......@@ -9,6 +9,7 @@ with System.Assertions,
Ada.Directories,
Ada.Strings.Equal_Case_Insensitive,
Ada.Containers,
Ada.Characters.Handling, -- Contains "To_Lower"
GNAT.Command_Line,
Errors,
Locations,
......@@ -26,6 +27,7 @@ use Ada.Text_IO,
Ada.Exceptions,
Ada.Directories,
Ada.Containers,
Ada.Characters.Handling,
Locations,
Ocarina.Namet,
Ocarina;
......@@ -341,9 +343,9 @@ package body TASTE.AADL_Parser is
Dist : constant Remote_Entity :=
RI.Remote_Interfaces.First_Element;
Remote_Thread_Name : constant Unbounded_String :=
Dist.Function_Name & "_" & Dist.Interface_Name;
To_Lower (To_String (Dist.Function_Name))
& "_" & Dist.Interface_Name;
Port_Name : constant Unbounded_String := RI.Name;
-- Remote_Thread_Name & "_" & Dist.Interface_Name;
New_P : constant Thread_Port :=
(Name => Port_Name,
Remote_Thread => Remote_Thread_Name,
......@@ -464,7 +466,8 @@ package body TASTE.AADL_Parser is
if PI.RCM = Cyclic_Operation or PI.RCM = Sporadic_Operation then
declare
Thread : constant AADL_Thread :=
(Name => F.Name & "_" & PI.Name,
(Name => To_Lower (To_String (F.Name))
& "_" & PI.Name,
RCM => US (PI.RCM'Img),
Need_Mutex => (F.Provided.Length > 1),
Entry_Port_Name => PI.Name,
......
......@@ -14,8 +14,6 @@ package body TASTE.Model_Transformations is
return Function_Maps.Map
is
New_Functions : Function_Maps.Map;
-- Count_Active_PI : Natural := 0;
-- Count_Passive_PI : Natural := 0;
begin
-- Look for GUIs and add a Poll PI (if there is at least one RI)
if F.Required.Length > 0 and F.Language = "gui" then
......@@ -26,95 +24,12 @@ package body TASTE.Model_Transformations is
Period_Or_MIAT => 10,
others => <>));
end if;
-- Count the number of Active (Cyclic, Sporadic, Protected) and Passive
-- provided interfaces of a function ; this is needed for some model
-- transformations.
-- for PI of F.Provided loop
-- if PI.RCM = Unprotected_Operation then
-- Count_Passive_PI := Count_Passive_PI + 1;
-- else
-- Count_Active_PI := Count_Active_PI + 1;
-- end if;
-- end loop;
-- When a function contains several active interfaces, create a new
-- separate function for each of them; this is needed to keep the
-- system analyzable by having a 1-to-1 mapping between a function and
-- a thread.
-- for PI of F.Provided loop
-- if (PI.RCM = Cyclic_Operation or PI.RCM = Sporadic_Operation)
-- and then Count_Passive_PI + Count_Active_PI > 1
-- then
-- declare
-- New_F : Taste_Terminal_Function :=
-- (Name => F.Name & "_" & PI.Name,
-- Language => US ("blackbox_device"),
-- Context => F.Name,
-- Required => F.Required, -- Inherit from RIs
-- others => <>);
-- New_F_PI : Taste_Interface := PI;
-- New_F_RI : Taste_Interface := PI;
-- begin
-- New_F_PI.Parent_Function := New_F.Name;
--
-- -- Set the name of the RI of the newly created function
-- -- (avoid keeping the same name as the PI)
-- New_F_RI.Name := (if PI.RCM = Cyclic_Operation
-- then "CYC_" & PI.Name
-- else "SPO_" & PI.Name);
--
-- -- Connect the new function's RI to the PI of the old function
-- New_F_RI.Remote_Interfaces.Clear;
-- New_F_RI.Remote_Interfaces.Append
-- (Remote_Entity'(Function_Name => F.Name,
-- Interface_Name => PI.Name));
-- -- The Remote interface of the new PI are inherited from PI
--
-- -- NOTE: The remote interfaces of the callers of the PI will be
-- -- updated after the creation of all new functions, at model
-- -- level.
--
-- -- Change the nature of the PI that triggered a new function
-- -- (Unprotected if the function only contained one active PI,
-- -- and possibly any number of other unprotected PIs)
-- PI.RCM := (if Count_Active_PI > 1
-- then Protected_Operation
-- else Unprotected_Operation);
--
-- -- Replace the remotes of the PI with the new function
-- -- (They were copied to the PI of the new function)
-- PI.Remote_Interfaces.Clear;
-- PI.Remote_Interfaces.Append
-- (Remote_Entity'(Function_Name => New_F.Name,
-- Interface_Name => New_F_RI.Name));
--
-- -- Add the PI and RI to the new function
-- New_F.Provided.Insert (Key => To_String (PI.Name),
-- New_Item => New_F_PI);
-- New_F.Required.Insert (Key => To_String (New_F_RI.Name),
-- New_Item => New_F_RI);
--
-- -- Make sure the parent function of all RIs is set
-- for RI of New_F.Required loop
-- RI.Parent_Function := New_F.Name;
-- end loop;
--
-- -- Add to the list of newly created functions
-- New_Functions.Insert (Key => To_String (New_F.Name),
-- New_Item => New_F);
-- end;
-- end if;
-- end loop;
return New_Functions;
end Process_Function;
function Transform (Model : TASTE_Model) return TASTE_Model is
Result : TASTE_Model := Model;
New_Functions : Function_Maps.Map;
-- Functions : Function_Maps.Map
-- renames Result.Interface_View.Flat_Functions;
begin
-- Processing of user-defined functions (may return a list of new
-- functions that will be added to the model)
......@@ -128,77 +43,6 @@ package body TASTE.Model_Transformations is
end loop;
end;
end loop;
-- Update the PI/RI connections of the existing functions:
-- For each PI and RI of newly-created function, look for all remote
-- functions, and find the corresponding PI or RI
-- Then replace the old remote function with the new one
-- for F of New_Functions loop
-- for PI of F.Provided loop
-- for Remote of PI.Remote_Interfaces loop
-- declare
-- Remote_Function : constant Function_Maps.Cursor :=
-- Functions.Find (To_String (Remote.Function_Name));
-- Corresponding_RI : constant Interfaces_Maps.Cursor :=
-- Functions (Remote_Function).Required.Find
-- (To_String (Remote.Interface_Name));
-- begin
-- for RI_Remote of Functions (Remote_Function).Required
-- (Corresponding_RI).Remote_Interfaces
-- loop
-- if RI_Remote.Function_Name = F.Context then
-- RI_Remote.Function_Name := F.Name;
-- end if;
-- end loop;
-- end;
-- end loop;
-- end loop;
--
-- for RI of F.Required loop
-- for Remote of RI.Remote_Interfaces loop
-- declare
-- Remote_Function : constant Function_Maps.Cursor :=
-- Functions.Find (To_String (Remote.Function_Name));
-- Corresponding_PI : constant Interfaces_Maps.Cursor :=
-- Functions (Remote_Function).Provided.Find
-- (To_String (Remote.Interface_Name));
-- begin
-- for PI_Remote of Functions (Remote_Function).Provided
-- (Corresponding_PI).Remote_Interfaces
-- loop
-- if PI_Remote.Function_Name = F.Context then
-- PI_Remote.Function_Name := F.Name;
-- end if;
-- end loop;
-- end;
-- end loop;
--
-- end loop;
--
-- -- Add the function to the deployment view
-- for Node of Result.Deployment_View.Nodes loop
-- for Partition of Node.Partitions loop
-- if Partition.Bound_Functions.Contains (To_String (F.Context))
-- then
-- begin
-- Partition.Bound_Functions.Insert (To_String (F.Name));
-- exception
-- when Constraint_Error =>
-- -- Insert error, value already exists in the set
-- Put_Error ("Vertical Transformation Error: generated "
-- & "name conflicts with user function "
-- & To_String (F.Name));
-- end;
-- end if;
-- end loop;
-- end loop;
--
-- -- Finally, add all newly-created functions to the new model
-- Result.Interface_View.Flat_Functions.Insert
-- (Key => To_String (F.Name),
-- New_Item => F);
-- end loop;
return Result;
end Transform;
end TASTE.Model_Transformations;
......@@ -31,9 +31,9 @@ void pro_@_Parent_Function_@_@_Name_@
extern process_package__taste_protected_object @_LOWER:Parent_Function_@_protected;
__po_hi_protected_lock (@_LOWER:Parent_Function_@_protected.protected_id);
@@IF@@ @_Param_Names'Length_@ = 0 @@-- zero param
@_Parent_Function_@_@_Name_@();
@_LOWER:Parent_Function_@_@_Name_@();
@@ELSE@@
@_Parent_Function_@_@_Name_@
@_LOWER:Parent_Function_@_@_Name_@
@@INLINE( \()(,\n )(\);\n)@@
@@TABLE@@
@@IF@@ @_Param_Directions_@ = "PARAM_IN"
......
......@@ -60,12 +60,12 @@ size_IN_buf_@_LOWER:Param_Names_@;
@@END_TABLE@@
// calling threads: @_Calling_Threads_@ partition: @_Partition_Name_@
@@ELSIF@@ @_Kind_@ = UNPROTECTED_OPERATION
// Unprotected call
// Unprotected call (call function defined in vm_if or SIMULINK.Simulink.c function)
@@TABLE@@
@@IF@@ @_No_Param_@
@_Remote_Function_Names_@_@_Remote_Interface_Names_@();
@_LOWER:Remote_Function_Names_@_@_Remote_Interface_Names_@();
@@ELSE@@
@_Remote_Function_Names_@_@_Remote_Interface_Names_@
@_LOWER:Remote_Function_Names_@_@_Remote_Interface_Names_@
@@INLINE( \()(,\n )(\);\n)@@
@@TABLE@@
@@IF@@ @_Param_Directions_@ = "PARAM_IN"
......
......@@ -12,7 +12,7 @@
@@-- @_Param_Directions_@ : |_ Corresponding direction
@@-- @_Param_Encodings_@ : |_ Corresponding encoding (Default, Native, UPER, ACN)
@@IF@@ @_EXIST:Param_Names_@
void @_Parent_Function_@_@_Name_@
void @_LOWER:Parent_Function_@_@_Name_@
@@INLINE( \()(,\n )(\)\n)@@
@@TABLE@@
@@IF@@ @_Param_Directions_@ = "PARAM_IN"
......@@ -78,10 +78,9 @@ void @_Parent_Function_@_@_Name_@
@@END_TABLE@@
}
@@ELSE@@ @@-- parameterless functions
void @_Parent_Function_@_@_Name_@()
void @_LOWER:Parent_Function_@_@_Name_@()
{
// Directly call user code, no parameters to pass
// This could be done directly from the concurrency glue...
extern void @_LOWER:Parent_Function_@_PI_@_Name_@(void);
@_LOWER:Parent_Function_@_PI_@_Name_@();
// puts ("@_LOWER:Parent_Function_@_@_LOWER:Name_@ called");
......
......@@ -13,7 +13,7 @@
@@-- @_Param_Encodings_@ : |_ Corresponding encoding (Default, Native, UPER, ACN)
@@IF@@ @_Direction_@ = "PI"
@@IF@@ @_EXIST:Param_Names_@
void @_Parent_Function_@_@_Name_@
void @_LOWER:Parent_Function_@_@_Name_@
@@INLINE( \()(,\n )(\);\n)@@
@@TABLE@@
@@IF@@ @_Param_Directions_@ = "PARAM_IN"
......@@ -24,6 +24,6 @@ void *OUT_@_LOWER:Param_Names_@, size_t *OUT_@_LOWER:Param_Names_@_len
@@END_TABLE@@
@@END_INLINE@@
@@ELSE@@
void @_Parent_Function_@_@_Name_@(void);
void @_LOWER:Parent_Function_@_@_Name_@(void);
@@END_IF@@
@@END_IF@@
Markdown is supported
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