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
|
#pragma once
#include <systemc.h>
#include <spx_module.h>
#include <optical_output_port.h>
#include <optical_signal.h>
/* A waveguide crossing that accounts for */
/* loss and interchannel crosstalk */
/* */
/* (2)p_in2 */
/* | */
/* (1)p_in1----+---->p_out1(3) */
/* | */
/* v */
/* p_out2(4) */
/* */
/* ---------------------------------------*/
class CrossingBase : public spx_module {
public:
// Member variables
double m_attenuation_power_dB;
double m_crosstalk_power_dB;
// Constructor with crosstalk
// Attenuation relates to out1/in1 when there's nothing in in2
// Crosstalk relates to out2/in1 when there's nothing in in1
CrossingBase(sc_module_name name,
double attenuation_power_dB = 0,
double crosstalk_power_dB = NAN)
: spx_module(name)
, m_attenuation_power_dB(attenuation_power_dB)
, m_crosstalk_power_dB(crosstalk_power_dB)
{
}
};
class CrossingUni : public CrossingBase {
public:
// Ports
spx::oa_port_in_type p_in1;
spx::oa_port_in_type p_in2;
spx::oa_port_out_type p_out1;
spx::oa_port_out_type p_out2;
// Timed ports writers
OpticalOutputPort m_out1_writer;
OpticalOutputPort m_out2_writer;
// Processes
void on_input_changed();
// Constructor with crosstalk
// Attenuation relates to out1/in1 when there's nothing in in2
// Crosstalk relates to out2/in1 when there's nothing in in1
CrossingUni(sc_module_name name,
double attenuation_power_dB = 0,
double crosstalk_power_dB = NAN)
: CrossingBase(name, attenuation_power_dB, crosstalk_power_dB)
, m_out1_writer("out1_delayed_writer", p_out1)
, m_out2_writer("out2_delayed_writer", p_out2)
{
SC_HAS_PROCESS(CrossingUni);
SC_THREAD(on_input_changed);
sensitive << p_in1 << p_in2;
}
};
typedef CrossingUni Crossing;
class CrossingBi : public CrossingBase {
public:
// Ports
spx::oa_port_in_type p0_in;
spx::oa_port_in_type p1_in;
spx::oa_port_in_type p2_in;
spx::oa_port_in_type p3_in;
spx::oa_port_out_type p0_out;
spx::oa_port_out_type p1_out;
spx::oa_port_out_type p2_out;
spx::oa_port_out_type p3_out;
// Timed ports writers
OpticalOutputPort m_p0_out_writer;
OpticalOutputPort m_p1_out_writer;
OpticalOutputPort m_p2_out_writer;
OpticalOutputPort m_p3_out_writer;
// Processes
void on_input_changed();
// Constructor with crosstalk
// Attenuation relates to out1/in1 when there's nothing in in2
// Crosstalk relates to out2/in1 when there's nothing in in1
CrossingBi(sc_module_name name,
double attenuation_power_dB = 0,
double crosstalk_power_dB = NAN)
: CrossingBase(name, attenuation_power_dB, crosstalk_power_dB)
, m_p0_out_writer("p0_out_delayed_writer", p0_out)
, m_p1_out_writer("p1_out_delayed_writer", p1_out)
, m_p2_out_writer("p2_out_delayed_writer", p2_out)
, m_p3_out_writer("p3_out_delayed_writer", p3_out)
{
SC_HAS_PROCESS(CrossingBi);
SC_THREAD(on_input_changed);
sensitive << p0_in << p1_in << p2_in << p3_in;
}
};
|