OpticalModel.h (10447:a465576671d4) OpticalModel.h (10448:bc1a3b7ab5ef)
1/* Copyright (c) 2012 Massachusetts Institute of Technology
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 * THE SOFTWARE.
20 */
21
1#ifndef __DSENT_MODEL_OPTICALMODEL_H__
2#define __DSENT_MODEL_OPTICALMODEL_H__
3
4#include "util/CommonType.h"
5#include "model/ElectricalModel.h"
6
7namespace 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
22#ifndef __DSENT_MODEL_OPTICALMODEL_H__
23#define __DSENT_MODEL_OPTICALMODEL_H__
24
25#include "util/CommonType.h"
26#include "model/ElectricalModel.h"
27
28namespace DSENT
29{
30 class PortInfo;
31 class EventInfo;
32 class OpticalWaveguide;
33 class OpticalLaser;
34 class OpticalFilter;
35 class OpticalModulator;
36 class OpticalDetector;
37 class OpticalReceiver;
38 class OpticalTransmitter;
39
40 // A Wavelength group consisting of start and end wavelength indices
41 // Assuming it is the same as a net index so I can use the PortInfo class
42 typedef NetIndex WavelengthGroup;
43
44 // Helper function for making waveguide groups
45 inline WavelengthGroup makeWavelengthGroup(int start_index_, int end_index_)
46 {
47 ASSERT(end_index_ >= start_index_, (String) "[Error] Invalid wavelength group range " +
48 "[" + (String) start_index_ + ":" + (String) end_index_ + "]");
49
50 return WavelengthGroup(start_index_, end_index_);
51 }
52
53 // Helper function for making wavelength groups
54 inline WavelengthGroup makeWavelengthGroup(int index_)
55 {
56 return makeWavelengthGroup(index_, index_);
57 }
58
59 // OpticalModel specifies optical connectivity to other optical models as well
60 class OpticalModel : public ElectricalModel
61 {
62
63 public:
64 OpticalModel(const String& instance_name_, const TechModel* tech_model_);
65 virtual ~OpticalModel();
66
67 public:
68 //-----------------------------------------------------------------
69 // Connectivity specification
70 //-----------------------------------------------------------------
71
72 /*
73
74 // Waveguide multiplier
75 void setWaveguideMultiplier(unsigned int waveguide_multiplier_);
76 unsigned int getWaveguideMultiplier();
77
78 */
79 // Input Ports
80 void createOpticalInputPort(const String& name_, const WavelengthGroup& wavelengths_);
81 const Map<PortInfo*>* getOpticalInputs() const;
82 PortInfo* getOpticalInputPort(const String& name_);
83 const PortInfo* getOpticalInputPort(const String& name_) const;
84
85 // Output Ports
86 void createOpticalOutputPort(const String& name_, const WavelengthGroup& wavelengths_);
87 const Map<PortInfo*>* getOpticalOutputs() const;
88 PortInfo* getOpticalOutputPort(const String& name_);
89 const PortInfo* getOpticalOutputPort(const String& name_) const;
90
91 // Optical Waveguides
92 void createWaveguide(const String& name_, const WavelengthGroup& wavelengths_);
93 const Map<OpticalWaveguide*>* getWaveguides() const;
94 OpticalWaveguide* getWaveguide(const String& name_);
95
96 // Assign a waveguide to be downstream from another waveguide
97 void opticalAssign(const String& downstream_waveguide_name_, const String& upstream_waveguide_name_);
98
99 // Connect a port (input or output) to some waveguide
100 void opticalPortConnect(OpticalModel* connect_model_, const String& connect_port_name_, const String& connect_waveguide_name_);
101 //-----------------------------------------------------------------
102
103 //-----------------------------------------------------------------
104 // Optical Graph Model Components
105 //-----------------------------------------------------------------
106 // Optical Laser Sources
107
108 void createLaser(const String& name_, const WavelengthGroup& wavelengths_);
109 const Map<OpticalLaser*>* getLasers() const;
110 OpticalLaser* getLaser(const String& name_);
111 // Optical Laser Sources
112 void createFilter(const String& name_, const WavelengthGroup& wavelengths_, bool drop_all_, const WavelengthGroup& drop_wavelengths_);
113 const Map<OpticalFilter*>* getFilters() const;
114 OpticalFilter* getFilter(const String& name_);
115 // Optical Modulators
116 void createModulator(const String& name_, const WavelengthGroup& wavelengths_, bool opt_loss_, OpticalTransmitter* transmitter_);
117 const Map<OpticalModulator*>* getModulators() const;
118 OpticalModulator* getModulator(const String& name_);
119 // Optical Detectors
120 void createDetector(const String& name_, const WavelengthGroup& wavelengths_, OpticalReceiver* receiver_);
121 const Map<OpticalDetector*>* getDetectors() const;
122 OpticalDetector* getDetector(const String& name_);
123
124 //-----------------------------------------------------------------
125
126 protected:
127 // In an OpticalModel, the complete optical port-to-port connectivity
128 // of all sub-instances must be specified. Addition/Removal optical
129 // ports or port-related nets cannot happen after this step
130 //virtual void constructModel() = 0;
131 // In an OpticalModel, updateModel MUST finish all necessary
132 // calculations such that loss and wavelength power can be calculated
133 //virtual void updateModel() = 0;
134 // In an OpticalModel, evaluateModel should calculate all wavelength
135 // power, updating power and energy events as necessary
136 //virtual void evaluateModel() = 0;
137
138 private:
139 // Private copy constructor. Use clone to perform copy operation.
140 OpticalModel(const OpticalModel& model_);
141
142 private:
143 // Map of all input ports
144 Map<PortInfo*>* m_optical_input_ports_;
145 // Map of all output ports
146 Map<PortInfo*>* m_optical_output_ports_;
147
148 // Optical graph model elements
149 // Map of all waveguides
150 Map<OpticalWaveguide*>* m_waveguides_;
151 // Map of all laser source elements
152 Map<OpticalLaser*>* m_lasers_;
153 // Map of all filter elements
154 Map<OpticalFilter*>* m_filters_;
155 // Map of all modulator elements
156 Map<OpticalModulator*>* m_modulators_;
157 // Map of all photodetector elements
158 Map<OpticalDetector*>* m_detectors_;
159
160 }; // class OpticalModel
161} // namespace DSENT
162
163#endif // __DSENT_MODEL_OPTICALMODEL_H__
164