sim, kvm: make KvmVM a System parameter
[gem5.git] / ext / dsent / model / optical / RingFilter.cc
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 #include "model/optical/RingFilter.h"
23
24 #include "model/optical_graph/OpticalWaveguide.h"
25 #include "model/optical_graph/OpticalFilter.h"
26
27 namespace DSENT
28 {
29 RingFilter::RingFilter(const String& instance_name_, const TechModel* tech_model_)
30 : OpticalModel(instance_name_, tech_model_)
31 {
32 initParameters();
33 initProperties();
34 }
35
36 RingFilter::~RingFilter()
37 {}
38
39 void RingFilter::initParameters()
40 {
41 addParameterName("InStart");
42 addParameterName("InEnd");
43 addParameterName("DropStart");
44 addParameterName("DropEnd");
45 addParameterName("DropAll", "TRUE");
46 return;
47 }
48
49 void RingFilter::initProperties()
50 {
51 return;
52 }
53
54 void RingFilter::constructModel()
55 {
56 //TODO: Add tuning energy/ndd-power costs?
57
58 // Create Area result
59 Result* area_result = new AtomicResult("Photonic");
60 addAreaResult(area_result);
61
62 // Get parameters
63 WavelengthGroup in_wavelengths = makeWavelengthGroup(getParameter("InStart"), getParameter("InEnd"));
64 WavelengthGroup drop_wavelengths = makeWavelengthGroup(getParameter("DropStart"), getParameter("DropEnd"));
65 bool drop_all = getParameter("DropAll");
66
67 // Create optical ports
68 createOpticalInputPort( "In", in_wavelengths);
69 createOpticalOutputPort( "Drop", drop_wavelengths);
70 createOpticalOutputPort( "Out", in_wavelengths);
71 // Create the filter
72 createFilter( "RingFilter", in_wavelengths, drop_all, drop_wavelengths);
73 OpticalFilter* ring_filter = getFilter("RingFilter");
74 // Connect the filter
75 getWaveguide("In")->addDownstreamNode(ring_filter);
76 ring_filter->addDownstreamNode(getWaveguide("Out"));
77 ring_filter->setDropPort(getWaveguide("Drop"));
78 }
79
80 void RingFilter::updateModel()
81 {
82 //TODO: Get numbers from tech model;
83 double ring_area = 200e-12;
84 double thru_loss = 1e-4;
85 double drop_loss = 1.0;
86 // Get parameters
87 WavelengthGroup drop_wavelengths = makeWavelengthGroup(getParameter("DropStart"), getParameter("DropEnd"));
88 int number_wavelengths = drop_wavelengths.second - drop_wavelengths.first + 1;
89 // Update losses
90 OpticalFilter* ring_filter = getFilter("RingFilter");
91 ring_filter->setLoss(thru_loss * number_wavelengths);
92 ring_filter->setDropLoss(drop_loss + thru_loss * number_wavelengths);
93 // Update area
94 getAreaResult("Photonic")->setValue(ring_area * (number_wavelengths));
95 }
96
97 } // namespace DSENT
98