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
|
#pragma once
#include "specs.h"
#include <systemc.h>
#include <spx_module.h>
#include <optical_output_port.h>
#include <optical_signal.h>
/** An electrically-controllable phase shifter. */
class PhaseShifterBase : public spx_module {
public:
// Member variables
/** The phaseshift applied to the pulse, in rad. */
double m_phaseshift_rad = 0;
/** The attenuation of the device in dB. */
double m_attenuation_dB;
/** The responsivity of the phase-shifter in rad/V. */
double m_sensitivity = 1;
/** Constructor for PhaseShifter
*
* @param name name of the module
* */
PhaseShifterBase(sc_module_name name, double attenuation_dB = 0)
: spx_module(name)
, m_phaseshift_rad(0)
, m_attenuation_dB(attenuation_dB)
{}
};
class PhaseShifterUni : public PhaseShifterBase {
public:
// Ports
/** The electrical input port. */
spx::ea_port_in_type p_vin;
/** The optical input port. */
spx::oa_port_in_type p_in;
/** The optical output port. */
spx::oa_port_out_type p_out;
// Timed ports writers
/** Timed writer to the output port.
*
* @sa DelayedWriter
* */
OpticalOutputPort m_out_writer;
/** Memory of the current input value for all wavelengths. */
std::map<uint32_t,OpticalSignal::field_type> m_memory_in;
// Processes
/** Main process of the module.
*
* It copies the input to the output, after attenuation and delay.
* Will use the current m_phaseshift_rad at that moment.
*
* **SystemC type:** thread
*
* **Sensitivity list:** p_in
* */
void on_port_in_changed();
/** Auxiliary process of the module.
*
* Updates @param m_phaseshift_rad and creates a new event
* using the current optical input, sending it to the output
* after zero time.
*
* **SystemC type:** thread
*
* **Sensitivity list:** v_in
* */
void on_port_vin_changed();
/** Constructor for PhaseShifter
*
* @param name name of the module
* */
PhaseShifterUni(sc_module_name name, double attenuation_dB = 0)
: PhaseShifterBase(name, attenuation_dB)
, m_out_writer("out_delayed_writer", p_out)
{
SC_HAS_PROCESS(PhaseShifterUni);
SC_THREAD(on_port_in_changed);
sensitive << p_in;
SC_THREAD(on_port_vin_changed);
sensitive << p_vin;
}
};
typedef PhaseShifterUni PhaseShifter;
class PhaseShifterBi : public PhaseShifterBase {
public:
// Ports
/** The electrical input port. */
spx::ea_port_in_type p_vin;
/** The optical input ports. */
spx::oa_port_in_type p0_in;
spx::oa_port_in_type p1_in;
/** The optical output ports. */
spx::oa_port_out_type p0_out;
spx::oa_port_out_type p1_out;
// Timed ports writers
/** Timed writer to the output port.
*
* @sa DelayedWriter
* */
OpticalOutputPort m_p0_writer;
OpticalOutputPort m_p1_writer;
/** Memory of the current input value for all wavelengths. */
std::map<uint32_t,OpticalSignal::field_type> m_memory_p0;
std::map<uint32_t,OpticalSignal::field_type> m_memory_p1;
// Processes
/** Main process of the module.
*
* It copies the input to the output, after attenuation and delay.
* Will use the current m_phaseshift_rad at that moment.
*
* **SystemC type:** thread
*
* **Sensitivity list:** p0_in
* */
void on_p0_in_changed();
void on_p1_in_changed();
/** Auxiliary process of the module.
*
* Updates @param m_phaseshift_rad and creates a new event
* using the current optical input, sending it to the output
* after zero time.
*
* **SystemC type:** thread
*
* **Sensitivity list:** v_in
* */
void on_port_vin_changed();
/** Constructor for PhaseShifter
*
* @param name name of the module
* */
PhaseShifterBi(sc_module_name name, double attenuation_dB = 0)
: PhaseShifterBase(name, attenuation_dB)
, m_p0_writer("p0_out_delayed_writer", p0_out)
, m_p1_writer("p1_out_delayed_writer", p1_out)
{
SC_HAS_PROCESS(PhaseShifterBi);
SC_THREAD(on_p0_in_changed);
sensitive << p0_in;
SC_THREAD(on_p1_in_changed);
sensitive << p1_in;
SC_THREAD(on_port_vin_changed);
sensitive << p_vin;
}
};
|