1 /* Copyright (c) 2012 Massachusetts Institute of Technology
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:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
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
22 #include "model/optical/OpticalTestModel.h"
23 #include "model/optical_graph/OpticalGraph.h"
24 #include "model/optical_graph/OpticalWaveguide.h"
25 #include "model/optical/RingModulator.h"
26 #include "model/optical/RingFilter.h"
27 #include "model/optical/RingDetector.h"
28 #include "model/optical/LaserSource.h"
32 OpticalTestModel::OpticalTestModel(const String
& instance_name_
, const TechModel
* tech_model_
)
33 : OpticalModel(instance_name_
, tech_model_
)
39 OpticalTestModel::~OpticalTestModel()
42 void OpticalTestModel::initParameters()
47 void OpticalTestModel::initProperties()
52 void OpticalTestModel::constructModel()
54 unsigned int wavelengths
= 64;
55 unsigned int number_readers
= 1;
57 createWaveguide("LaserToMod", makeWavelengthGroup(0, wavelengths
-1));
60 LaserSource
* laser
= new LaserSource("Laser", getTechModel());
61 laser
->setParameter("OutStart", 0);
62 laser
->setParameter("OutEnd", wavelengths
-1);
66 RingModulator
* modulator
= new RingModulator("Modulator", getTechModel());
67 modulator
->setParameter("InStart", 0);
68 modulator
->setParameter("InEnd", wavelengths
-1);
69 modulator
->setParameter("ModStart", 0);
70 modulator
->setParameter("ModEnd", wavelengths
-1);
71 modulator
->construct();
73 for (unsigned int i
= 0; i
<= number_readers
; ++i
)
75 String n
= (String
) i
;
76 createWaveguide("WaveguideDet-" + n
, makeWavelengthGroup(0, wavelengths
-1));
79 // Create a SWMR Configuration
80 for (unsigned int i
= 0; i
< number_readers
; ++i
)
82 String n
= (String
) i
;
84 // Create resonant ring detector
85 RingDetector
* detector
= new RingDetector("Detector-" + n
, getTechModel());
86 detector
->setParameter("InStart", 0);
87 detector
->setParameter("InEnd", wavelengths
-1);
88 detector
->setParameter("DetStart", 0);
89 detector
->setParameter("DetEnd", wavelengths
-1);
90 detector
->setParameter("DropAll", "FALSE");
91 detector
->setParameter("SenseAmp", "TRUE");
92 detector
->construct();
94 opticalPortConnect(detector
, "In", "WaveguideDet-" + n
);
95 opticalPortConnect(detector
, "Out", "WaveguideDet-" + (String
) (i
+ 1));
97 addSubInstances(detector
, 1.0);
100 opticalPortConnect(laser
, "Out", "LaserToMod");
101 opticalPortConnect(modulator
, "In", "LaserToMod");
102 opticalPortConnect(modulator
, "Out", "WaveguideDet-0");
104 addSubInstances(laser
, 1.0);
105 addSubInstances(modulator
, 1.0);
108 void OpticalTestModel::updateModel()
110 double data_rate
= 8e9
;
111 double extinction_ratio
= 5;
112 double insertion_loss
= 3;
114 Model
* laser
= getSubInstance("Laser");
117 getWaveguide("LaserToMod")->setLoss(10);
119 Model
* modulator
= getSubInstance("Modulator");
120 modulator
->setProperty("ExtinctionRatio", extinction_ratio
);
121 modulator
->setProperty("InsertionLoss", insertion_loss
);
122 modulator
->setProperty("DataRate", data_rate
);
123 modulator
->setProperty("P(In)", 0.5);
124 modulator
->setProperty("Act(In)", 1.0);
127 unsigned int number_readers
= 1;
128 for (unsigned int i
= 0; i
< number_readers
; ++i
)
130 Model
* detector
= getSubInstance("Detector-" + (String
) i
);
131 detector
->setProperty("ExtinctionRatio", extinction_ratio
);
132 detector
->setProperty("DataRate", data_rate
);
133 detector
->setProperty("P(In)", 0.5);
134 detector
->setProperty("Act(In)", 1.0);