-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimulation_Results_To_XML_File.java
285 lines (200 loc) · 6.36 KB
/
Simulation_Results_To_XML_File.java
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
package Router;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;
import Router.Final_parametre;
public class Simulation_Results_To_XML_File {
public Element Scenario;
public Element Simulation;
public Document document;
//public Element Cycle;
public Simulation_Results_To_XML_File()
{
this.Scenario = new Element("Scenario");
this.document = new Document(Scenario);
}
public void Create_XML_Simulation_Results()
{
}
public void Generate_XML_NoC_Generation()
{
Element NoC_Generation = new Element("NoC_Generation");
Element NoC_Size = new Element("NoC_Size");
NoC_Size.setText(""+Final_parametre.Noc_size);
Element NoC_Nbr_Buffer_Per_Port = new Element("NoC_Nbr_Buffer_Per_Port");
NoC_Nbr_Buffer_Per_Port.setText(""+ Final_parametre.Number_vcbuffer_per_Plink);
Element Buffer_size = new Element("Buffer_size");
Buffer_size.setText(""+ Final_parametre.Buffer_size);
this.Scenario.addContent(NoC_Generation);
NoC_Generation.addContent(NoC_Size);
NoC_Generation.addContent(NoC_Nbr_Buffer_Per_Port);
NoC_Generation.addContent(Buffer_size);
}
public void Genarate_XML_NoC_Configuration()
{
Element NoC_Configuration = new Element("NoC_Configuration");
Element Routing = new Element("Routing");
Routing.setText("XY");
Element Arbiter = new Element("Arbiter");
Arbiter.setText("Round robin");
Element Switching = new Element("Switching");
Switching.setText("Wormole");
Element Flow_Control = new Element("Flow_Control");
Flow_Control.setText("Credit Based");
Element Flit_Length = new Element("Flit_Length");
Flit_Length.setText("16");
this.Scenario.addContent(NoC_Configuration);
NoC_Configuration.addContent(Routing);
NoC_Configuration.addContent(Arbiter);
NoC_Configuration.addContent(Switching);
NoC_Configuration.addContent(Flow_Control);
NoC_Configuration.addContent(Flit_Length);
}
public void Genarate_XML_NoC_Execution_Time()
{
Element Execution_Time = new Element("Execution_Time");
Execution_Time.setText(""+ Run_Similation.Simulation_Life );
this.Scenario.addContent(Execution_Time);
}
public void Genarate_XML_Simulation ()
{
this.Simulation = new Element("Simulation");
this.Scenario.addContent(Simulation);
}
public Element Genarate_XML_Cycle( int Cycle_number)
{
Element Cycle= new Element("Cycle");
Cycle.setAttribute("Cycle", ""+Cycle_number);
this.Simulation.addContent(Cycle);
return Cycle;
}
public void Remove_XML_Cycle( Element Cycle)
{
this.Simulation.removeContent(Cycle);
}
public Element Genarate_XML_Router(Element Cycle, int Manager_ID )
{
Element Router= new Element("Router");
Router.setAttribute("Router", ""+Manager_ID);
Cycle.addContent(Router);
return Router;
}
public Element Genarate_XML_Arrival_Data(Element Router, ArrayList<Paquet> List_Arrival_paquet, int ID_Manager)
{
Element Arrival_Data= new Element("Arrival_Data");
for(int i=0;i<List_Arrival_paquet.size();i++)
{
if(List_Arrival_paquet.get(i).getFlit(0).Src== ID_Manager)
{
Element Router_Source= new Element("Router_Source");
Router_Source.addContent(""+ List_Arrival_paquet.get(i).getFlit(0).Src);
Arrival_Data.addContent(Router_Source);
Element Router_Destination= new Element("Router_Destination");
Router_Destination.addContent(""+ List_Arrival_paquet.get(i).getFlit(0).dest);
Arrival_Data.addContent(Router_Destination);
Element Buffer_Source= new Element("Buffer_Source");
Buffer_Source.addContent(""+ List_Arrival_paquet.get(i).vc);
Arrival_Data.addContent(Buffer_Source);
Element Flit_Number= new Element("Flit_Number");
Flit_Number.addContent(""+ List_Arrival_paquet.get(i).size());
Arrival_Data.addContent(Flit_Number);
}
}
Router.addContent(Arrival_Data);
return Arrival_Data;
}
public Element Genarate_XML_Port(Element Router, int Port_ID)
{
Element Port= new Element("Port");
if (Port_ID==0)
{
Port.setAttribute("Port", "Local");
}
else if (Port_ID==1)
{
Port.setAttribute("Port", "West");
}
else if (Port_ID==2)
{
Port.setAttribute("Port", "South");
}
else if (Port_ID==3)
{
Port.setAttribute("Port", "East");
}
else if (Port_ID==4)
{
Port.setAttribute("Port", "North");
}
Router.addContent(Port);
return Port;
}
public Element Genarate_XML_Output_Port(Element Port)
{
Element Output_Port= new Element("Output_Port");
Port.addContent(Output_Port);
return Output_Port;
}
public Element Genarate_XML_Input_Port(Element Port)
{
Element Input_Port= new Element("Input_Port");
Port.addContent(Input_Port);
return Input_Port;
}
public Element Genarate_XML_Buffer(Element Input_Port, int Buffer_ID, int Credit, int F_Type )
{
if (Credit==Final_parametre.Buffer_size)
{
return null;
}
else {
Element Buffer= new Element("Buffer");
Buffer.setAttribute("Buffer", ""+Buffer_ID);
Input_Port.addContent(Buffer);
Element Credit_Buffer= new Element("Credit_Buffer");
Credit_Buffer.setText(""+Credit);
Buffer.addContent(Credit_Buffer);
Element Flit_Type= new Element("Flit_Type");
if (F_Type ==1)
{
Flit_Type.setText("Header");
}
else
{
Flit_Type.setText("Data");
}
/**else
{
//Flit_Type.setText("null");
//Buffer.removeContent(Flit_Type);
Input_Port.removeContent(Buffer);
} **/
Buffer.addContent(Flit_Type);
return Buffer;
}
}
/**
* cette methose sert à:
* @author Meghabber
*@category : method
*
*/
public void Genarate_XML_save()
{
XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
try {
sortie.output(this.document, new FileOutputStream("simulation.xml"));
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
}