ext: add the source code for DSENT
[gem5.git] / ext / dsent / model / OpticalModel.h
1 #ifndef __DSENT_MODEL_OPTICALMODEL_H__
2 #define __DSENT_MODEL_OPTICALMODEL_H__
3
4 #include "util/CommonType.h"
5 #include "model/ElectricalModel.h"
6
7 namespace DSENT
8 {
9 class PortInfo;
10 class EventInfo;
11 class OpticalWaveguide;
12 class OpticalLaser;
13 class OpticalFilter;
14 class OpticalModulator;
15 class OpticalDetector;
16 class OpticalReceiver;
17 class OpticalTransmitter;
18
19 // A Wavelength group consisting of start and end wavelength indices
20 // Assuming it is the same as a net index so I can use the PortInfo class
21 typedef NetIndex WavelengthGroup;
22
23 // Helper function for making waveguide groups
24 inline WavelengthGroup makeWavelengthGroup(int start_index_, int end_index_)
25 {
26 ASSERT(end_index_ >= start_index_, (String) "[Error] Invalid wavelength group range " +
27 "[" + (String) start_index_ + ":" + (String) end_index_ + "]");
28
29 return WavelengthGroup(start_index_, end_index_);
30 }
31
32 // Helper function for making wavelength groups
33 inline WavelengthGroup makeWavelengthGroup(int index_)
34 {
35 return makeWavelengthGroup(index_, index_);
36 }
37
38 // OpticalModel specifies optical connectivity to other optical models as well
39 class OpticalModel : public ElectricalModel
40 {
41
42 public:
43 OpticalModel(const String& instance_name_, const TechModel* tech_model_);
44 virtual ~OpticalModel();
45
46 public:
47 //-----------------------------------------------------------------
48 // Connectivity specification
49 //-----------------------------------------------------------------
50
51 /*
52
53 // Waveguide multiplier
54 void setWaveguideMultiplier(unsigned int waveguide_multiplier_);
55 unsigned int getWaveguideMultiplier();
56
57 */
58 // Input Ports
59 void createOpticalInputPort(const String& name_, const WavelengthGroup& wavelengths_);
60 const Map<PortInfo*>* getOpticalInputs() const;
61 PortInfo* getOpticalInputPort(const String& name_);
62 const PortInfo* getOpticalInputPort(const String& name_) const;
63
64 // Output Ports
65 void createOpticalOutputPort(const String& name_, const WavelengthGroup& wavelengths_);
66 const Map<PortInfo*>* getOpticalOutputs() const;
67 PortInfo* getOpticalOutputPort(const String& name_);
68 const PortInfo* getOpticalOutputPort(const String& name_) const;
69
70 // Optical Waveguides
71 void createWaveguide(const String& name_, const WavelengthGroup& wavelengths_);
72 const Map<OpticalWaveguide*>* getWaveguides() const;
73 OpticalWaveguide* getWaveguide(const String& name_);
74
75 // Assign a waveguide to be downstream from another waveguide
76 void opticalAssign(const String& downstream_waveguide_name_, const String& upstream_waveguide_name_);
77
78 // Connect a port (input or output) to some waveguide
79 void opticalPortConnect(OpticalModel* connect_model_, const String& connect_port_name_, const String& connect_waveguide_name_);
80 //-----------------------------------------------------------------
81
82 //-----------------------------------------------------------------
83 // Optical Graph Model Components
84 //-----------------------------------------------------------------
85 // Optical Laser Sources
86
87 void createLaser(const String& name_, const WavelengthGroup& wavelengths_);
88 const Map<OpticalLaser*>* getLasers() const;
89 OpticalLaser* getLaser(const String& name_);
90 // Optical Laser Sources
91 void createFilter(const String& name_, const WavelengthGroup& wavelengths_, bool drop_all_, const WavelengthGroup& drop_wavelengths_);
92 const Map<OpticalFilter*>* getFilters() const;
93 OpticalFilter* getFilter(const String& name_);
94 // Optical Modulators
95 void createModulator(const String& name_, const WavelengthGroup& wavelengths_, bool opt_loss_, OpticalTransmitter* transmitter_);
96 const Map<OpticalModulator*>* getModulators() const;
97 OpticalModulator* getModulator(const String& name_);
98 // Optical Detectors
99 void createDetector(const String& name_, const WavelengthGroup& wavelengths_, OpticalReceiver* receiver_);
100 const Map<OpticalDetector*>* getDetectors() const;
101 OpticalDetector* getDetector(const String& name_);
102
103 //-----------------------------------------------------------------
104
105 protected:
106 // In an OpticalModel, the complete optical port-to-port connectivity
107 // of all sub-instances must be specified. Addition/Removal optical
108 // ports or port-related nets cannot happen after this step
109 //virtual void constructModel() = 0;
110 // In an OpticalModel, updateModel MUST finish all necessary
111 // calculations such that loss and wavelength power can be calculated
112 //virtual void updateModel() = 0;
113 // In an OpticalModel, evaluateModel should calculate all wavelength
114 // power, updating power and energy events as necessary
115 //virtual void evaluateModel() = 0;
116
117 private:
118 // Private copy constructor. Use clone to perform copy operation.
119 OpticalModel(const OpticalModel& model_);
120
121 private:
122 // Map of all input ports
123 Map<PortInfo*>* m_optical_input_ports_;
124 // Map of all output ports
125 Map<PortInfo*>* m_optical_output_ports_;
126
127 // Optical graph model elements
128 // Map of all waveguides
129 Map<OpticalWaveguide*>* m_waveguides_;
130 // Map of all laser source elements
131 Map<OpticalLaser*>* m_lasers_;
132 // Map of all filter elements
133 Map<OpticalFilter*>* m_filters_;
134 // Map of all modulator elements
135 Map<OpticalModulator*>* m_modulators_;
136 // Map of all photodetector elements
137 Map<OpticalDetector*>* m_detectors_;
138
139 }; // class OpticalModel
140 } // namespace DSENT
141
142 #endif // __DSENT_MODEL_OPTICALMODEL_H__
143