1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237 | ------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- 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 CNRS 6285, Universite 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: 4589 $
-- $Date: 2023-09-29 16:02:19 +0200 (ven., 29 sept. 2023) $
-- $Author: nam $
------------------------------------------------------------------------------
------------------------------------------------------------------------------
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Directories; use Ada.Directories;
with Ada.Text_IO; use Ada.Text_IO;
with Systems; use Systems;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Framework_Config; use Framework_Config;
with Buffer_Test_Case_Generator; use Buffer_Test_Case_Generator;
with unbounded_strings; use unbounded_strings;
with buffer_scheduling_simulation_test; use buffer_scheduling_simulation_test;
with Task_Set; use Task_Set;
with initialize_framework; use initialize_framework;
with buffer_event_table_analyzer; use buffer_event_table_analyzer;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with GNAT.Command_Line;
with Ada.IO_Exceptions;
with Buffers.Extended; use Buffers.Extended;
with Integer_Arrays; use Integer_Arrays;
with Multiprocessor_Services_Interface; use Multiprocessor_Services_Interface;
procedure buffer_sched
is
----------------------------------------------
--Configuration for the scheduling simulator--
default_Period : Integer := 1000000;
----------------------------------------------
H : Integer := 0;
--Time_And_Date : TIME;
input_file_path : Unbounded_String := empty_string;
event_table_name : Unbounded_String := empty_string;
log_directory : Unbounded_String := empty_string;
sched_duration : Integer := 0;
sched : Scheduling_Table_Ptr;
sys : System;
Project_File_Dir_List : unbounded_string_list;
export_data : Boolean := False;
max_offset : Integer := 0;
----------------------------------------------
exp_dir : STRING := "xml/";
----------------------------------------------
test_mode : Character := 'A';
----------------------------------------------
--testAF : Amplitude_Function_Ptr;
test_data_size : Integer := 0;
begin
loop
case GNAT.Command_Line.Getopt ("t: f: e: d: x: l: n") is
when ASCII.NUL =>
exit;
when 't' =>
Put_Line("Test mode: " & GNAT.Command_Line.Parameter);
test_mode := GNAT.Command_Line.Parameter(1);
when 'f' =>
Put_Line("File: " & GNAT.Command_Line.Parameter);
input_file_path := To_Unbounded_String(GNAT.Command_Line.Parameter);
when 'e' =>
Put_Line("Event table: " & GNAT.Command_Line.Parameter);
event_table_name := To_Unbounded_String(GNAT.Command_Line.Parameter);
when 'd' =>
Put_Line("Sched duration: " & GNAT.Command_Line.Parameter);
sched_duration := Integer'Value(GNAT.Command_Line.Parameter);
when 'x' =>
Put_Line("Export Data: " & GNAT.Command_Line.Parameter);
if (Integer'Value(GNAT.Command_Line.Parameter) = 1) then
export_data := True;
else
export_data := False;
end if;
when 'l' =>
Put_Line("Log Directory: " & GNAT.Command_Line.Parameter);
log_directory := To_Unbounded_String(GNAT.Command_Line.Parameter);
when 'n' =>
Put_Line("No debug");
Cheddar_Debug := No_Debug;
when others =>
OS_Exit(0);
end case;
end loop;
if(test_mode = 'F') then
if(input_file_path = empty_string) then
Put_Line("- Please specify system file name with -f FILENAME");
GNAT.OS_Lib.OS_Exit (0);
end if;
Set_Initialize;
Initialize (sys);
sys.Read_From_Xml_File(Dir_List => Project_File_Dir_List,
File_Name => input_file_path);
begin
if(sched_duration = 0) then
sched_duration := get_max_offset(sys.Tasks) + get_max_start_time(sys.Tasks) + Compute_Hyperperiod(sys.Tasks);
end if;
exception
when Constraint_Error =>
sched_duration := Integer'Last;
end;
-- Run the simulation and export data
Put_Line("- Simulation Period:" & sched_duration'Img);
sched := scheduling_simulation_with_buffer(sched_duration,sys,To_Unbounded_String(To_String(input_file_path) & ".ev.xml"),export_data);
Put_Line("- Simulation complete !");
if (export_data) then
Put_Line("- Exported Event Table to: " & To_String(input_file_path) & ".ev.xml");
end if;
-- Analyze the event table
Put_Line("- Analyze_Buffer_Event_Table");
Put_Line(To_String(input_file_path));
Analyze_Buffer_Event_Table(Sys => sys,
Sched => sched,
Sched_Duration => sched_duration,
File_Name => To_Unbounded_String(Ada.Directories.Simple_Name(Name => To_String(input_file_path))),
Log_Directory => log_directory);
elsif(test_mode = 'I') then
analyze_buffer_event_table(Input_System => input_file_path,
Input_Event_Table => event_table_name,
Sched_Duration => sched_duration,
Log_Directory => log_directory);
elsif(test_mode = '1') then
Set_Directory(exp_dir);
Case_Study_01;
sys.Read_From_Xml_File(Dir_List => Project_File_Dir_List,
File_Name => To_Unbounded_String("Buffer_Sched_Case_Study_01.xmlv3"));
sched := scheduling_simulation_with_buffer(40,
sys,
To_Unbounded_String("Buffer_Sched_Case_Study_01_Event_Table.xml"),TRUE);
elsif(test_mode = '2') then
Set_Directory(exp_dir);
Case_Study_02_Buffer_Initial_Data;
sys.Read_From_Xml_File(Dir_List => Project_File_Dir_List,
File_Name => To_Unbounded_String("Buffer_Sched_Case_Study_02_Buffer_Initial_Data.xmlv3"));
sched := scheduling_simulation_with_buffer(40,
sys,
To_Unbounded_String("Buffer_Sched_Case_Study_02_Buffer_Initial_Data_Event_Table.xml"),TRUE);
elsif(test_mode = '3') then
Set_Directory(exp_dir);
Case_Study_03_Buffer_Underflow;
sys.Read_From_Xml_File(Dir_List => Project_File_Dir_List,
File_Name => To_Unbounded_String("Buffer_Sched_Case_Study_03_Buffer_Underflow.xmlv3"));
sched := scheduling_simulation_with_buffer(40,
sys,
To_Unbounded_String("Buffer_Sched_Case_Study_03_Buffer_Underflow_Event_Table.xml"),TRUE);
elsif(test_mode = '4') then
Set_Directory(exp_dir);
Case_Study_04_Buffer_Overflow;
sys.Read_From_Xml_File(Dir_List => Project_File_Dir_List,
File_Name => To_Unbounded_String("Buffer_Sched_Case_Study_04_Buffer_Overflow.xmlv3"));
sched := scheduling_simulation_with_buffer(40,
sys,
To_Unbounded_String("Buffer_Sched_Case_Study_04_Buffer_Overflow_Event_Table.xml"),TRUE);
elsif(test_mode = '5') then
Set_Directory(exp_dir);
Case_Study_05_Discrete_Cosine_Transform;
sys.Read_From_Xml_File(Dir_List => Project_File_Dir_List,
File_Name => To_Unbounded_String("Buffer_Sched_Case_Study_05_Discrete_Cosine_Transform.xmlv3"));
sched := scheduling_simulation_with_buffer(142848,
sys,
To_Unbounded_String("Buffer_Sched_Case_Study_05_Discrete_Cosine_Transform_Event_Table.xml"),TRUE);
elsif(test_mode = '6') then
Set_Directory(exp_dir);
Case_Study_06_Multi_Processor;
sys.Read_From_Xml_File(Dir_List => Project_File_Dir_List,
File_Name => To_Unbounded_String("Buffer_Sched_Case_Study_06_Multi_Processor.xmlv3"));
sched := scheduling_simulation_with_buffer(40,
sys,
To_Unbounded_String("Buffer_Sched_Case_Study_06_Multi_Processor_Event_Table.xml"),TRUE);
elsif(test_mode = '7') then
Set_Directory(exp_dir);
Case_Study_07_USCDF;
elsif(test_mode = '8') then
for i in 1..10 loop
test_data_size := Get_Data_Size(Amplitude_Function_Str => "5_4(1_2)",
Activation_Number => i);
end loop;
end if;
end buffer_sched;
|