OEIL
definition_optical.h
1 /*********************************************************************************
2  *
3  * File name: defination_optical.h
4  * Version: 3.0
5  * Software:
6  * Authors: Zhehui Wang, Jiang Xu
7  * Website: http://www.ece.ust.hk/~eexu/
8  * The copyright information of this program can be found in the file COPYRIGHT.
9  *
10  *********************************************************************************/
11 #ifndef DEFINITION_OPTICAL_H
12 #define DEFINITION_OPTICAL_H
13 
14 #include <math.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 
18 #include <iostream>
19 
20 /*file pointer to the files*/
21 FILE* parameter_flie_optical;
22 FILE* configuration_file_optical;
23 FILE* output_file_optical;
24 
25 /*The following is for the transmitter*/
26 double laser_slope_efficiency; // the slope efficiency of laser unit:W/A
27 double laser_threshold_current; // the threshold current of laser unit:mA
28 double laser_extinction_ratio; // the extinction ratio of laser unit:N/A
29 double laser_area; // area size of laser unit:um^2
30 double laser_voltage; // supply voltage of laser unit:V
31 double driver_voltage; // supply voltage of the driver unit:V
32 
33 /*The following is for the waveguide*/
34 double optical_pin_loss; // the coupling effciecny of each optical pin unit/N/A
35 double optical_pin_height; // the height of optical pin
36 double optical_pin_width; // the width of optical pin
37 double propagation_loss; // the propagation loss of the waveguide unit:cm^-1
38 double wg_refractive_index; // the group refractive index of waveguide unit:N/A
39 double wg_pitch; // the pitch of waveguide
40 
41 /*The following is for the receiver*/
42 double signal_to_noise_ratio; // signal to noise ratio unit:N/A
43 double tia_noise_density; // noise density of transimpedance amplifer unit:pA/sqrt(Hz)
44 double tia_transimpendance; // transimpendance of the transimpendance amplifer unit:kOhm
45 double la_voltage_threshold; // threshold voltage of the limiting amplifer unit:mV
46 double pd_responsity; // responsity of the photodetector unit: A/W
47 double pd_capacitance; // the capacitance of the photodetector unit: fF
48 
49 /*The following is for the micro-resonator*/
50 double mr_radius_range; // the radius of the micro-resonator, the real length is close to the range unit:um
51 double mr_attenuation; // the round trip attenuation of of the ring unit:N/A
52 double mr_power_split_k; // the power split ratio that can be transmitted into the ring unit:N/A
53 double mr_refractive_index; // the refractive index of the mr unit:N/A
54 double mr_tuning_power; // the tunning power consumption of one mr unit:mW
55 double mr_static_power; // the static power consumption of one mr unit:mW
56 double mr_dynamic_power; // the dynamic power consumption of one mr unit:mW/Gbps
57 /*The following are not inputed from "parameter.txt", they are calculated by the other parameters*/
58 double mr_radius_real; // the real radius of micro-resonator unit:um
59 double delta_wavelength; // the spacing between two nearby wavelengths unit:nm
60 double mr_power_split_r; // the power split ratio that can be transmitted into the waveguide unit:N/A
61 double mr_area; // the area of a single micro-resonator unit:um^2
62 
63 /*The following is for serdes*/
64 double serdes_cur_optical; // The unit current in SerDes circuit unit in optical interconnect unit:mA/Gbps
65 double serdes_area_optical; // The unit area in SerDes circuit unit in optical interconnect unit:um^2/Gbps
66 
67 /*The following is for nonlinear loss model */
68 // #waveguide-nonlinear-loss-model#
69 double carrier_lifetime;
70 double TPA_coefficient;
71 double FCA_coefficient;
72 
73 /*The following is for configurations*/
74 double data_rate_optical; // The data rate of signals in optical interconnects, which is double the working frequency unit:N/A
75 double length_optical; // the length of the optical interconnect unit:cm
76 int serdes_ratio_optical; // the parallel-to-serial ratio of SerDes in optical interconnect unit:N/A
77 int number_of_wavelengths; // number of wavelenght in WDM optical interconnects unit:N/A
78 double laser_wavelength; // the central wavelength of the laser unit: N/A
79 int is_direct_modulation; // 1 for direct modulation and 0 for not modulation using MRs unit:N/A
80 // [nonlinear loss model]
81 int is_nonlinear_model_enabled; // Set to 1 if nonlinear loss is taken into account. 0 otherwise.
82 double effective_mode_area; // The effective mode area for single mode transmission in on-chip waveguide unit: cm^-2
83 double laser2modular_distance; // Distance between laser source and the modular array unit: cm
84 double modular2coupler_distance; // Distance between the modular array and the coupler for coupling power out of the chip unit: cm
85 double coupler2receiver_distance; // Distance between the coupler on a second chip and the receivers on that chip unit: cm
86 
87 /*The following is for calculated results*/
88 double sensitivity_oma; // the sensitivity of optical receiver unit:mW
89 double crosstalk_coefficient_optical; // the ratio of noise power to signal power unit:N/A
90 double total_attenuation_optical; // the total attenuation on the entire optical interconenct unit: N/A
91 double energy_consumption_optical; // the energy consumed by interconect per bit unit:pJ/bit
92 double area_density_optical; // the area bandwidth density of optical interconnect unit:Gbps/mm^2
93 double linear_density_optical; // the linear bandwidth density of optical interconnect unit:Gbps/mm
94 double area_optical; // the area of optical interconnect unit:mm^2
95 double latency_value_optical; // the signal latency of optical interconnect unit:ns
96 
97 /*this is to read the paramters from the file parameter_optical.txt*/
98 void read_parameter_optical() {
99  printf("Optical:\n");
100  char name[150];
101  char unit[20];
102  if ((parameter_flie_optical = fopen("../config/parameter_optical.txt", "r")) == NULL) {
103  printf("Cannot open file parameter_optical.txt\n");
104  }
105  // /*skip the text file head.*/
106  // for (int i = 0; i < 37; i++) {
107  // fscanf(parameter_flie_optical, "%s\n", name);
108  // }
109  /*skip the text file head.*/
110  for (int i = 0; i < 10; i++) {
111  char* line;
112  size_t len = 0;
113  getline(&line, &len, configuration_file_optical);
114  }
115  /*parameters for transmitter*/
116  fscanf(parameter_flie_optical, "%s\n", name);
117  printf("%s\n", name);
118  fscanf(parameter_flie_optical, "%lf %s %s\n", &laser_slope_efficiency, name, unit);
119  printf("%s\t%f\t%s\n", name, laser_slope_efficiency, unit);
120  fscanf(parameter_flie_optical, "%lf %s %s\n", &laser_threshold_current, name, unit);
121  printf("%s\t%f\t%s\n", name, laser_threshold_current, unit);
122  fscanf(parameter_flie_optical, "%lf %s %s\n", &laser_extinction_ratio, name, unit);
123  printf("%s\t%f\t%s\n", name, laser_extinction_ratio, unit);
124  fscanf(parameter_flie_optical, "%lf %s %s\n", &laser_area, name, unit);
125  printf("%s\t\t%f\t%s\n", name, laser_area, unit);
126  fscanf(parameter_flie_optical, "%lf %s %s\n", &laser_voltage, name, unit);
127  printf("%s\t\t%f\t%s\n", name, laser_voltage, unit);
128  fscanf(parameter_flie_optical, "%lf %s %s\n", &driver_voltage, name, unit);
129  printf("%s\t\t%f\t%s\n", name, driver_voltage, unit);
130 
131  /*parameters for waveguide*/
132  fscanf(parameter_flie_optical, "%s\n", name);
133  printf("%s\n", name);
134  fscanf(parameter_flie_optical, "%lf %s %s\n", &optical_pin_loss, name, unit);
135  printf("%s\t%f\t%s\n", name, optical_pin_loss, unit);
136  fscanf(parameter_flie_optical, "%lf %s %s\n", &optical_pin_height, name, unit);
137  printf("%s\t%f\t%s\n", name, optical_pin_height, unit);
138  fscanf(parameter_flie_optical, "%lf %s %s\n", &optical_pin_width, name, unit);
139  printf("%s\t%f\t%s\n", name, optical_pin_width, unit);
140  fscanf(parameter_flie_optical, "%lf %s %s\n", &propagation_loss, name, unit);
141  printf("%s\t%f\t%s\n", name, propagation_loss, unit);
142  fscanf(parameter_flie_optical, "%lf %s %s\n", &wg_refractive_index, name, unit);
143  printf("%s\t%f\t%s\n", name, wg_refractive_index, unit);
144  fscanf(parameter_flie_optical, "%lf %s %s\n", &wg_pitch, name, unit);
145  printf("%s\t\t%f\t%s\n", name, wg_pitch, unit);
146 
147  /*parameters for receiver*/
148  fscanf(parameter_flie_optical, "%s\n", name);
149  printf("%s\n", name);
150  fscanf(parameter_flie_optical, "%lf %s %s\n", &signal_to_noise_ratio, name, unit);
151  printf("%s\t%f\t%s\n", name, signal_to_noise_ratio, unit);
152  fscanf(parameter_flie_optical, "%lf %s %s\n", &tia_noise_density, name, unit);
153  printf("%s\t%f\t%s\n", name, tia_noise_density, unit);
154  fscanf(parameter_flie_optical, "%lf %s %s\n", &tia_transimpendance, name, unit);
155  printf("%s\t%f\t%s\n", name, tia_transimpendance, unit);
156  fscanf(parameter_flie_optical, "%lf %s %s\n", &la_voltage_threshold, name, unit);
157  printf("%s\t%f\t%s\n", name, la_voltage_threshold, unit);
158  fscanf(parameter_flie_optical, "%lf %s %s\n", &pd_responsity, name, unit);
159  printf("%s\t\t%f\t%s\n", name, pd_responsity, unit);
160  fscanf(parameter_flie_optical, "%lf %s %s\n", &pd_capacitance, name, unit);
161  printf("%s\t\t%f\t%s\n", name, pd_capacitance, unit);
162 
163  /*parameters for micro-resonator*/
164  fscanf(parameter_flie_optical, "%s\n", name);
165  printf("%s\n", name);
166  fscanf(parameter_flie_optical, "%lf %s %s\n", &mr_radius_range, name, unit);
167  printf("%s\t\t%f\t%s\n", name, mr_radius_range, unit);
168  fscanf(parameter_flie_optical, "%lf %s %s\n", &mr_attenuation, name, unit);
169  printf("%s\t\t%f\t%s\n", name, mr_attenuation, unit);
170  fscanf(parameter_flie_optical, "%lf %s %s\n", &mr_power_split_k, name, unit);
171  printf("%s\t%f\t%s\n", name, mr_power_split_k, unit);
172  fscanf(parameter_flie_optical, "%lf %s %s\n", &mr_refractive_index, name, unit);
173  printf("%s\t%f\t%s\n", name, mr_refractive_index, unit);
174  fscanf(parameter_flie_optical, "%lf %s %s\n", &mr_tuning_power, name, unit);
175  printf("%s\t\t%f\t%s\n", name, mr_tuning_power, unit);
176  fscanf(parameter_flie_optical, "%lf %s %s\n", &mr_static_power, name, unit);
177  printf("%s\t\t%f\t%s\n", name, mr_static_power, unit);
178  fscanf(parameter_flie_optical, "%lf %s %s\n", &mr_dynamic_power, name, unit);
179  printf("%s\t%f\t%s\n", name, mr_dynamic_power, unit);
180  fscanf(parameter_flie_optical, "%lf %s %s\n", &mr_area, name, unit);
181  printf("%s\t\t\t%f\t%s\n", name, mr_area, unit);
182 
183  /*parameters for serdes*/
184  fscanf(parameter_flie_optical, "%s\n", name);
185  printf("%s\n", name);
186  fscanf(parameter_flie_optical, "%lf %s %s\n", &serdes_cur_optical, name, unit);
187  printf("%s\t%f\t%s\n", name, serdes_cur_optical, unit);
188  fscanf(parameter_flie_optical, "%lf %s %s\n", &serdes_area_optical, name, unit);
189  printf("%s\t%f\t%s\n", name, serdes_area_optical, unit);
190 
191  // #waveguide-nonlinear-loss-model#
192  // 4e-9 carrier_lifetime s
193  // 8e-10 TPA_coefficient cm/W
194  // 1.45e-17 FCA_coefficient cm^2
195  fscanf(parameter_flie_optical, "%s\n", name);
196  printf("%s\n", name);
197  fscanf(parameter_flie_optical, "%lf %s %s\n", &carrier_lifetime, name, unit);
198  std::cout << name << "\t" << carrier_lifetime << "\t\t" << unit << std::endl;
199  fscanf(parameter_flie_optical, "%lf %s %s\n", &TPA_coefficient, name, unit);
200  std::cout << name << "\t\t" << TPA_coefficient << "\t\t" << unit << std::endl;
201  fscanf(parameter_flie_optical, "%lf %s %s\n", &FCA_coefficient, name, unit);
202  std::cout << name << "\t\t" << FCA_coefficient << "\t" << unit << std::endl;
203 
204  printf("\n\n");
205  fclose(parameter_flie_optical);
206 }
207 
208 /*this is to read the confiuration from the file configuration_optical.txt*/
209 void read_configuration_optical() {
210  printf("Optical:\n");
211  char name[150];
212  char unit[120];
213  if ((configuration_file_optical = fopen("../config/configuration_optical.txt", "r")) == NULL) {
214  printf("Cannot open file configuration_optical.txt\n");
215  }
216  // for (int i = 0; i < 10; i++) {
217  // std::cout << "Here is the " << i << "th time we enter this loop." << std::endl;
218  // printf("%dth time reading config.\n", i);
219  // fscanf(configuration_file_optical, "%s\n", name);
220  // printf("What???? %s Are ya kidding?\n", name);
221  // }
222  /*skip the text file head.*/
223  for (int i = 0; i < 10; i++) {
224  char* line;
225  size_t len = 0;
226  getline(&line, &len, configuration_file_optical);
227  }
228  /*data for configuration*/
229  fscanf(configuration_file_optical, "%lf\t%s\t%s\n", &data_rate_optical, name, unit);
230  printf("%s\t\t%lf\t%s\n", name, data_rate_optical, unit);
231  fscanf(configuration_file_optical, "%lf %s %s\n", &length_optical, name, unit);
232  printf("%s\t\t\t%lf\t%s\n", name, length_optical, unit);
233  fscanf(configuration_file_optical, "%d %s %s\n", &serdes_ratio_optical, name, unit);
234  printf("%s\t\t%d\t\t%s\n", name, serdes_ratio_optical, unit);
235  fscanf(configuration_file_optical, "%d %s %s\n", &number_of_wavelengths, name, unit);
236  printf("%s\t\t%d\t\t%s\n", name, number_of_wavelengths, unit);
237  fscanf(configuration_file_optical, "%lf %s %s\n", &laser_wavelength, name, unit);
238  printf("%s\t\t%lf\t%s\n", name, laser_wavelength, unit);
239  fscanf(configuration_file_optical, "%d %s %s\n", &is_direct_modulation, name, unit);
240  std::cout << name << "\t\t" << std::boolalpha << (bool)is_direct_modulation << "\t\t" << unit << std::endl;
241  // printf("%s\t\t%d\t\t%s\n", name, is_direct_modulation, unit);
242 
243  // Nonlinear loss model
244  // 0 is_nonlinear_model_enabled N/A
245  // 1e-8 effective_mode_area cm^-2
246  // 0.5 laser2modular_distance cm
247  // 0.5 modular2coupler_distance cm
248  // 0.5 coupler2receiver_distance cm
249  fscanf(configuration_file_optical, "%d %s %s\n", &is_nonlinear_model_enabled, name, unit);
250  std::cout << name << "\t" << std::boolalpha << (bool)is_nonlinear_model_enabled << "\t\t" << unit << std::endl;
251  // printf("%s\t%d\t\t%s\n", name, is_nonlinear_model_enabled, unit);
252  fscanf(configuration_file_optical, "%lf %s %s\n", &effective_mode_area, name, unit);
253  printf("%s\t\t%lf\t%s\n", name, effective_mode_area * 1e8, "um^2");
254  fscanf(configuration_file_optical, "%lf %s %s\n", &laser2modular_distance, name, unit);
255  printf("%s\t\t%lf\t%s\n", name, laser2modular_distance, unit);
256  fscanf(configuration_file_optical, "%lf %s %s\n", &modular2coupler_distance, name, unit);
257  printf("%s\t%lf\t%s\n", name, modular2coupler_distance, unit);
258  fscanf(configuration_file_optical, "%lf %s %s\n", &coupler2receiver_distance, name, unit);
259  printf("%s\t%lf\t%s\n", name, coupler2receiver_distance, unit);
260  printf("\n");
261  fclose(configuration_file_optical);
262 }
263 
264 /*this is to write the calculated results to the file output.txt*/
265 void write_result_optical() {
266  printf("Optical:\n");
267  if ((output_file_optical = fopen("output_optical.txt", "w")) == NULL) {
268  printf("Cannot open file output_optical.txt\n");
269  }
270  /*writing heads*/
271  fprintf(output_file_optical, "/*********************************************************************************");
272  fprintf(output_file_optical, "\n *");
273  fprintf(output_file_optical, "\n * File name: output_optical.txt");
274  fprintf(output_file_optical, "\n * Version: 3.0");
275  fprintf(output_file_optical, "\n * Software: OEIL");
276  fprintf(output_file_optical, "\n * Authors: Zhehui Wang, Jiang Xu ");
277  fprintf(output_file_optical, "\n * Website: http://www.ece.ust.hk/~eexu/");
278  fprintf(output_file_optical, "\n * The copyright information of this program can be found in the file COPYRIGHT.");
279  fprintf(output_file_optical, "\n *");
280  fprintf(output_file_optical, "\n *********************************************************************************/");
281  fprintf(output_file_optical, "\n");
282 
283  /*output data written on file*/
284  printf("sensitivity_oma\t\t%lf\tmW\n", sensitivity_oma);
285  fprintf(output_file_optical, "sensitivity_oma\t\t%lf\tmW\n", sensitivity_oma);
286  printf("crosstalk_coefficient\t%lf\tN/A\n", crosstalk_coefficient_optical);
287  fprintf(output_file_optical, "crosstalk_coefficient\t%lf\tN/A\n", crosstalk_coefficient_optical);
288  printf("total_attenuation\t%lf\tN/A\n", total_attenuation_optical);
289  fprintf(output_file_optical, "total_attenuation\t%lf\tN/A\n", total_attenuation_optical);
290  printf("\t\t\t%lf\tdB\n", -10 * log10(total_attenuation_optical));
291  fprintf(output_file_optical, "\t\t\t%lf\tdB\n", -10 * log10(total_attenuation_optical));
292  printf("energy_consumption\t%lf\tpJ/bit\n", energy_consumption_optical);
293  fprintf(output_file_optical, "energy_consumption\t%lf\tpJ/bit\n", energy_consumption_optical);
294  printf("area_density\t\t%lf\tGbps/mm^2\n", area_density_optical);
295  fprintf(output_file_optical, "area_density\t\t%lf\tGbps/mm^2\n", area_density_optical);
296  printf("linear_density\t\t%lf\tGbps/mm\n", linear_density_optical);
297  fprintf(output_file_optical, "linear_density\t\t%lf\tGbps/mm\n", linear_density_optical);
298  printf("area\t\t\t%lf\tmm^2\n", area_optical);
299  fprintf(output_file_optical, "area\t\t\t%lf\tmm^2\n", area_optical);
300  printf("latency\t\t\t%lf\tns\n", latency_value_optical);
301  fprintf(output_file_optical, "latency\t\t\t%lf\tns\n", latency_value_optical);
302  printf("\n");
303 
304  fclose(output_file_optical);
305 }
306 
307 #endif