summaryrefslogtreecommitdiff
blob: 5466dbb8c01688541595671688f3df6f3e64d324 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import java.util.*;

public class VHDLProcess
{
   private static final Map<String, VHDLProcess> FROM_ID;

   static
   {
      FROM_ID = new HashMap<String, VHDLProcess>();
   }

   public static void add_element (final String id)
   {
      if (!FROM_ID.containsKey(id))
      {
         FROM_ID.put(id, new VHDLProcess(id));
      }
   }

   public static VHDLProcess get_from_id (final String id)
   {
      final VHDLProcess result;

      result = FROM_ID.get(id);

      if (result == null)
      {
         System.err.println
         (
            "[E] Element "
            + id
            + " is used like a process, but is not declared as such before that"
            + " use."
         );

         System.exit(-1);
      }

      return result;
   }

   public static VHDLProcess find (final String id)
   {
      return FROM_ID.get(id);
   }

/******************************************************************************/
   private final Collection<VHDLWaveform> accessed_wfm;
   private final Collection<VHDLProcess.Instance> instances;
   private final String id;
   private int instances_count;

   private VHDLArchitecture architecture;

   private VHDLProcess (final String id)
   {
      this.id = id;
      accessed_wfm = new ArrayList<VHDLWaveform>();
      instances = new ArrayList<VHDLProcess.Instance>();
      instances_count = 0;
      architecture = null;
   }

   public void add_accessed_wfm (final VHDLWaveform wfm)
   {
      if (!accessed_wfm.contains(wfm))
      {
         accessed_wfm.add(wfm);
      }
   }

   public void set_architecture (final VHDLArchitecture arch)
   {
      architecture = arch;
   }

   public static class Instance
   {
      private final String id;
      private final VHDLProcess parent;
      private final Map<VHDLWaveform.Instance, VHDLWaveform> iwfm_map;
      private final VHDLEntity visibility;

      private Instance
      (
         final String id,
         final VHDLProcess parent,
         final VHDLEntity visibility,
         final Map<VHDLWaveform.Instance, VHDLWaveform> iwfm_map
      )
      {
         this.id = id;
         this.parent = parent;
         this.visibility = visibility;
         this.iwfm_map = iwfm_map;
      }

      public VHDLProcess get_parent ()
      {
         return parent;
      }

      public VHDLProcess.Instance add_instance
      (
         final VHDLEntity visibility,
         final Map<VHDLWaveform.Instance, VHDLWaveform.Instance> convertion
      )
      {
         final VHDLProcess.Instance result;
         final Set<Map.Entry<VHDLWaveform.Instance, VHDLWaveform>> iwfm_set;
         final Map<VHDLWaveform.Instance, VHDLWaveform> new_iwfm_map;

         iwfm_set = iwfm_map.entrySet();

         new_iwfm_map = new HashMap<VHDLWaveform.Instance, VHDLWaveform>();

         for
         (
            final Map.Entry<VHDLWaveform.Instance, VHDLWaveform> me: iwfm_set
         )
         {
            new_iwfm_map.put
            (
               convertion.get(me.getKey()),
               me.getValue()
            );
         }

         result =
            new VHDLProcess.Instance
            (
               Instances.get_id_for(parent.instances_count),
               parent,
               visibility,
               new_iwfm_map
            );

         parent.instances_count += 1;

         return result;
      }
   }
}