blob: b66a63b0c81e5455b24c4e90fa7e4dcf5f73c2cb (
plain)
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
|
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.io.FileWriter;
public class Main
{
private static Parameters PARAMETERS;
public static void main (final String... args)
{
final FileWriter output;
PARAMETERS = new Parameters(args);
if (!PARAMETERS.are_valid())
{
return;
}
try
{
ModelFile.load_file(PARAMETERS.get_model_file());
}
catch (final Exception e)
{
System.err.println
(
"[E] Could not load model file \""
+ PARAMETERS.get_model_file()
+ "\":"
);
e.printStackTrace();
return;
}
create_instances();
OutputFile.close_all();
}
private static void create_instances ()
{
final Collection<VHDLEntity> futur_candidates;
final Deque<VHDLEntity> candidates;
final Collection<VHDLEntity> processed_candidates;
boolean is_stuck;
futur_candidates = new ArrayList<VHDLEntity>();
candidates = new ArrayDeque<VHDLEntity>();
processed_candidates = new ArrayList<VHDLEntity>();
futur_candidates.addAll(VHDLEntity.get_all());
while (!futur_candidates.isEmpty())
{
is_stuck = true;
candidates.addAll(futur_candidates);
futur_candidates.clear();
while (!candidates.isEmpty())
{
final VHDLEntity e;
boolean is_ready;
e = candidates.pop();
is_ready = true;
for (final VHDLComponent cmp: e.get_architecture().get_components())
{
if (!processed_candidates.contains(cmp.get_destination()))
{
is_ready = false;
break;
}
}
if (is_ready)
{
is_stuck = false;
e.generate_instance();
e.write_predicates();
processed_candidates.add(e);
}
else
{
futur_candidates.add(e);
}
}
if (is_stuck)
{
System.err.println("[F] Unable to create all the instances...");
System.err.println
(
"[E] The following entites might form a circular dependency:"
);
for (final VHDLEntity e: futur_candidates)
{
System.err.println("[E] Entity " + e.get_id());
}
System.exit(-1);
}
}
}
public static Parameters get_parameters ()
{
return PARAMETERS;
}
}
|