1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
#include "specs.h"
#include <phaseshifter.h>
using namespace std;
void PhaseShifterUni::on_port_in_changed()
{
auto transmission_field = pow(10.0, - m_attenuation_dB / 20);
m_memory_in[0] = 0; // initializing for nan wavelength
if (specsGlobalConfig.verbose_component_initialization)
{
cout << name() << ":" << endl;
cout << "transmission_power = " << pow(transmission_field,2) << " W/W" << endl;
cout << "sensitivity = " << m_sensitivity << " rad/V" << endl;
cout << "initial phase delay = " << m_phaseshift_rad << " rad @1.55)" << endl;
cout << (dynamic_cast<spx::oa_signal_type *>(p_in.get_interface()))->name();
cout << " --> ";
cout << (dynamic_cast<spx::oa_signal_type *>(p_out.get_interface()))->name();
cout << endl << "\t^" << endl;
cout << "\t|" << endl << "\t";
cout << (dynamic_cast<spx::ea_signal_type *>(p_vin.get_interface()))->name();
cout << endl;
cout << endl;
}
while (true) {
// Wait for a new input signal
wait();
// Read the input signal and apply attenuation
OpticalSignal s = p_in->read();
// Store field value in memory
m_memory_in[s.m_wavelength_id] = s.m_field;
// Get new ID for output event
s.getNewId();
// Apply transmission and phase-shift
s *= polar(transmission_field, m_sensitivity * p_vin->read());
// Write to ouput port after zero delay
m_out_writer.delayedWrite(s, SC_ZERO_TIME);
}
}
void PhaseShifterUni::on_port_vin_changed()
{
auto transmission_field = pow(10.0, - m_attenuation_dB / 20);
uint32_t cur_wavelength_id = 0;
OpticalSignal::field_type cur_field = (complex<double>)0;
while (true)
{
wait();
// Read the new phase-delay
m_phaseshift_rad = m_sensitivity * p_vin->read();
// writes the signals of all wavelengths with the new phase shift
for(auto id_field : m_memory_in)
{
cur_wavelength_id = id_field.first;
cur_field = id_field.second;
auto s = OpticalSignal(cur_field, cur_wavelength_id);
// Get a new ID for the signal
s.getNewId();
// Apply transmission and phase-shift
s *= polar(transmission_field, m_phaseshift_rad);
// Write to ouput port after zero delay
m_out_writer.delayedWrite(s, SC_ZERO_TIME);
}
}
}
void PhaseShifterBi::on_p0_in_changed()
{
auto transmission_field = pow(10.0, - m_attenuation_dB / 20);
m_memory_p0[0] = 0; // initializing for nan wavelength
if (specsGlobalConfig.verbose_component_initialization)
{
cout << name() << ":" << endl;
cout << "transmission_power = " << pow(transmission_field,2) << " W/W" << endl;
cout << "sensitivity = " << m_sensitivity << " rad/V" << endl;
cout << "initial phase delay = " << m_phaseshift_rad << " rad @1.55)" << endl;
cout << (dynamic_cast<spx::oa_signal_type *>(p0_in.get_interface()))->name();
cout << " --> ";
cout << (dynamic_cast<spx::oa_signal_type *>(p1_out.get_interface()))->name();
cout << endl;
cout << (dynamic_cast<spx::oa_signal_type *>(p0_out.get_interface()))->name();
cout << " <-- ";
cout << (dynamic_cast<spx::oa_signal_type *>(p1_in.get_interface()))->name();
cout << endl << "\t^" << endl;
cout << "\t|" << endl << "\t";
cout << (dynamic_cast<spx::ea_signal_type *>(p_vin.get_interface()))->name();
cout << endl;
cout << endl;
}
while (true) {
// Wait for a new input signal
wait();
// Read the input signal and apply attenuation
OpticalSignal s = p0_in->read();
// Store field value in memory
m_memory_p0[s.m_wavelength_id] = s.m_field;
// Get new ID for output event
s.getNewId();
// Apply transmission and phase-shift
s *= polar(transmission_field, m_sensitivity * p_vin->read());
// Write to ouput port after zero delay
m_p1_writer.delayedWrite(s, SC_ZERO_TIME);
}
}
void PhaseShifterBi::on_p1_in_changed()
{
auto transmission_field = pow(10.0, - m_attenuation_dB / 20);
m_memory_p1[0] = 0; // initializing for nan wavelength
while (true) {
// Wait for a new input signal
wait();
// Read the input signal and apply attenuation
OpticalSignal s = p1_in->read();
// Store field value in memory
m_memory_p1[s.m_wavelength_id] = s.m_field;
// Get new ID for output event
s.getNewId();
// Apply transmission and phase-shift
s *= polar(transmission_field, m_sensitivity * p_vin->read());
// Write to ouput port after zero delay
m_p0_writer.delayedWrite(s, SC_ZERO_TIME);
}
}
void PhaseShifterBi::on_port_vin_changed()
{
auto transmission_field = pow(10.0, - m_attenuation_dB / 20);
uint32_t cur_wavelength_id = 0;
OpticalSignal::field_type cur_field = (complex<double>)0;
while (true)
{
wait();
// Read the new phase-delay
m_phaseshift_rad = m_sensitivity * p_vin->read();
// writes the signals of all wavelengths with the new phase shift
for(auto id_field : m_memory_p0)
{
cur_wavelength_id = id_field.first;
cur_field = id_field.second;
auto s = OpticalSignal(cur_field, cur_wavelength_id);
// Get a new ID for the signal
s.getNewId();
// Apply transmission and phase-shift
s *= polar(transmission_field, m_phaseshift_rad);
// Write to ouput port after zero delay
m_p1_writer.delayedWrite(s, SC_ZERO_TIME);
}
for(auto id_field : m_memory_p1)
{
cur_wavelength_id = id_field.first;
cur_field = id_field.second;
auto s = OpticalSignal(cur_field, cur_wavelength_id);
// Get a new ID for the signal
s.getNewId();
// Apply transmission and phase-shift
s *= polar(transmission_field, m_phaseshift_rad);
// Write to ouput port after zero delay
m_p0_writer.delayedWrite(s, SC_ZERO_TIME);
}
}
}
|