summaryrefslogtreecommitdiff
blob: 0a61a249ad977b11d8b68d654847fd17b60f34bc (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
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 void add_waveform (final VHDLWaveform wfm)
   {
      if (!waveforms.contains(wfm))
      {
         waveforms.add(wfm);
      }
   }
}