summaryrefslogtreecommitdiff
blob: 5597529575dd1dff3977177c070c85561869f1af (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 VHDLArchitecture
{
   private static final Map<String, VHDLArchitecture> FROM_ID;

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

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

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

      result = FROM_ID.get(id);

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

         System.exit(-1);
      }

      return result;
   }

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

/******************************************************************************/
   private final Collection<VHDLProcess> processes;
   private final Collection<VHDLComponent> components;
   private final Collection<VHDLWaveform> waveforms;
   private final String id;

   private VHDLEntity entity;

   private VHDLArchitecture (final String id)
   {
      this.id = id;

      processes = new ArrayList<VHDLProcess>();
      components = new ArrayList<VHDLComponent>();
      waveforms = new ArrayList<VHDLWaveform>();
   }

   public VHDLEntity get_entity ()
   {
      return entity;
   }

   public void set_entity (final VHDLEntity e)
   {
      entity = e;
   }

   public void add_process (final VHDLProcess ps)
   {
      if (!processes.contains(ps))
      {
         processes.add(ps);
      }
   }

   public void add_component (final VHDLComponent cmp)
   {
      if (!components.contains(cmp))
      {
         components.add(cmp);
      }
   }

   public Collection<VHDLComponent> get_components ()
   {
      return components;
   }

   public void add_waveform (final VHDLWaveform wfm)
   {
      if (!waveforms.contains(wfm))
      {
         waveforms.add(wfm);
      }
   }

   public void add_instance_to
   (
      final Collection<VHDLProcess.Instance> process_instances,
      final Collection<VHDLWaveform.Instance> waveform_instances,
      final Map<VHDLWaveform, VHDLWaveform.Instance> local_conversion
   )
   {
      for (final VHDLWaveform wfm: waveforms)
      {
         final VHDLWaveform.Instance i_wfm;

         i_wfm = wfm.add_instance(entity);

         waveform_instances.add(i_wfm);

         local_conversion.put(wfm, i_wfm);
      }

      for (final VHDLProcess ps: processes)
      {
         process_instances.add
         (
            ps.generate_base_instance
            (
               entity,
               waveform_instances
            )
         );
      }

      for (final VHDLComponent cmp: components)
      {
         cmp.add_instance_content_to
         (
            process_instances,
            waveform_instances,
            local_conversion
         );
      }
   }
}