OpticalModel.h revision 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 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 165