1 Introduction

Photonic crystals with a variable refractive index could be utilized to regulate and direct light output if the periodic pattern is replicated in two dimensions, the two-dimensional photonic crystal structure (Yablonovitch 1987; John 1987; Yablonovitch et al. 1991; Sibilia et al. 2008). Due to the significant resemblance between the Schrödinger equation in solid-state physics as well as the Helmholtz equation in the setting of the electric field, photonic crystal formations could be referred to as dual semiconductor crystals (Quimby 2006). For instance, in the Schrödinger equation, the electric potential is analogous to the refractive index in the Helmholtz equation (Baba 2008; Saha and Sen 2020). As a result, photonic crystals have a nearly identical functionality against photons as semiconductor crystals perform against electrons (Baba 2008; Saha and Sen 2020). All-optical photonic crystal devices are expanding and evolving (Mohammadi et al. 2019, 2022; He et al. 2020; Serajmohammadi et al. 2019; Rajasekar et al. 2019; Mohammadi and Seifouri 2019; Moradi et al. 2021; Foroughifar et al. 2021; Cheshmberah et al. 2021). Encoders and decoders are integral components of optical signal processing systems, all-optical networks, as well as all optimal processors, contributing tremendously to their effectiveness (Xavier et al. 2016; Younis et al. 2014; D'souza and Mathew 2016). The study of photonic crystal digital devices, such as logic gates (Mohebzadeh-Bahabady and Olyaee 2018; He et al. 2019; Ge et al. 2020; Veisi et al. 2021) and analog-to-digital converters (Mehdizadeh et al. 2017; Geng and Zhao 2020), is becoming a substantial area of research for the scientific world. Lately, considerable research on the design of encoders has been undertaken (Lee et al. 2009; Hassangholizadeh-Kashtiban et al. 2015; Moniem 2016; Seif-Dargahi 2018; Parandin 2019; Monisha et al. 2019; Naghizade and Saghaei 2020; Rajasekar et al. 2020, 2021; Mohebzadeh-Bahabady and Olyaee 2020; Fallahi et al. 2021; Hamedi et al. 2021). For an encoder with a 598 μm2 footprint, Hassangholizadeh et al. have suggested a Kerr effect-based structure; however, there is no information regarding their suggested structure's time response or contrast ratio (Hassangholizadeh-Kashtiban et al. 2015).

Seif-Dargahi generated a two-dimensional photonic crystal structure for an encoder and examined it at a wavelength of 1,555 μm, and displayed a contrast ratio of 9.2 dB and time response of 1.8 ps, respectively (Seif-Dargahi 2018). The designed structure's downside was its extraordinarily huge size. Monisha et al. also created a mechanism for an encoder with an 8 dB contrast ratio; however, there is no information about the structure's time response or footprint (Monisha et al. 2019). Rajasekar et al. developed an innovative Barium Titanate rods-based structure in the airbed for a ~ 174 μm encoder with a contrast ratio of 7.11 dB (Rajasekar et al. 2020). Mohebzadeh and Olyaee have presented a novel all-optical encoder with a contrast ratio of 9.51 dB depending on silicon dielectric rods in air (Mohebzadeh-Bahabady and Olyaee 2020). Fallahi et al. utilized scattering rods and nano-resonators to create an optimized and asymmetric encoder with a contrast ratio of 7.8 dB regardless of relatively low reaction time (Fallahi et al. 2021). The interference mechanism was employed in the light diffusion in the encoder structure, and silicon rods were utilized in the airbed to construct a symmetric encoder. Recently, Rajasekar et al. devised a high-speed encoder relying on BaTiO3 in the air having a time delay of ~ 375 s, a bit rate of 2.66 Tb, as well as a contrast ratio of 10.4 dB (Rajasekar et al. 2021). Furthermore, because of its high efficacy, BaTiO3 is typically employed in nonlinear modes; however, in this study, only the linear function of the material was regarded for the encoder (Quimby 2006).

A PhCRR-based encoder was suggested in this research, and its efficiency was assessed utilizing the FDTD numerical solution technique, yielding a footprint of 108 μm2, a delay time of ~ 530 fs, and a bit rate of 1.88 Tb/s. The suggested encoder structure has the distinct benefit of distinguishing logic 0 from logic one due to its outstanding contrast ratio. In the linear model, the contrast ratio of the suggested encoder nanostructure is approximately 16.4 dB, which is the highest contrast ratio among other systems described.

2 AOE nanostructure design

2.1 Binary encoder 2 N to N

Encoders are employed in a variety of systems for encryption. 2 N bits are converted to N bits via an N-bit encoder in the output. For instance, whether an encoder has three bits, eight input modes, and three output modes must be regarded. Encoders can be categorized into two classes: Priority encoders and Binary encoders (Mano 2002; Brown 2010; Holdsworth and Woods 2002). Binary encoder is mentioned in the paper (Mano 2002; Brown 2010; Holdsworth and Woods 2002). In the priority encoder, if another input is on, encryption will be performed based on the priority of the inputs. A 4 × 2 binary encoder that is the number of bits required to encode two bits, would be used in this work by having four input modes as well as two output modes. If the input values are "1000," the coded output value is "00," if the input values are equivalent to "0100," the coded output value is "01," and if the input values are comparable to "0010," the output values are "10." In the other scenario, where the input value is equal to "0001," the output values are identical to "11," and therefore, the information is presented as encoded in the binary encoder output. The encoder is shown in Fig. 1.

Fig. 1
figure 1

Encoder scheme

2.2 Calculation of photonic band gaps and AOE nanostructure optimization

A 21 × 19 two-dimensional photonic crystal structure containing Si rods in air with triangular lattice is used to design the AOE. Figure 2 shows the first Brillouin zone for the proposed nanostructure next to the TM band structure. As shown in Fig. 2, the proposed structure has two band gaps for TM mode. We used the first band gap of the structure to design the proposed AOE. The range of the first band gap includes frequencies from a/λ = 0.269 to a/λ = 0.430. The encoder is designed with four waveguides for the input light sources, a PhCRR, and two waveguides for measuring the light output power. The lattice constant of the nanostructure is 556 nm, the radius of the Si rods after optimizing the structure is equal to 117 nm. The wavelength range in the first band gap is between 1293 and 2066 nm.

Fig. 2
figure 2

TM band structure and the first Brillouin zone

The optimum central wavelength of 1.55 μm is obtained for the nanostructure that the suggested nanostructure is appropriate for usage in the third telecommunication window and the radius of the PhCRR core rods after AOE optimization is 113 nm. Of course, in designing the structure, it has been taken into account that if the radius of ± 1 nm of each of the rods is changed, the AOE performance will not decrease much. The proposed encoder structure is shown in Fig. 3.

Fig. 3
figure 3

The proposed AOE

The aim of designing an optimum structure for an all-optical encoder is to accomplish an ultra-compact structure, which in addition to reducing the size of the structure, escalating the effectiveness of the structure and escalating the bit rate is also significant. To optimize the radius of the AOE core rods, we examined the outputs of the structure while the fourth input is on. As can be seen in Fig. 4, in the radii of 112 nm to 114 nm, the output values will be optimal in the fourth case. If the core rod radius is shorter than the current state, the resonator will provide a weaker transmission rate performance. Also if the core rod radius is longer than the current state, the resonator will provide a weaker transmission rate performance. In this case, the optimal radius of the core rod for us will be where the two outputs have the highest amount of transmission. The reason for choosing a radius of 113 nm is the ± 1 nm tolerance of the radius of these rods, which may occur in the fabrication for the radius of the rods. The radius of the AOE core rods from 90 to 125 nm will not disturb the performance of the encoder, but if the radius of these rods exceeds 125 nm, the structure will intensify and the encoder performance will be disturbed.

Fig. 4
figure 4

AOE core rod radius optimization

The rods radius of the AOE for both outputs of the structure is given in Fig. 5 as the highest value of state zero and the lowest value of state one. The output for radii of 116 nm to 118 nm in the ON state will be about 0.35. Also, the output for radii of 117 to 118 nm in the off state will be equal to about 0.007. Based on this, a radius of 117 nm has been selected for Si rods. The optimal mode selection is when there is the largest difference between zero and one mode. In this case, the AOE performance will be the most optimal mode possible. Figure 5 shows these values for radii of 115 nm to 125 nm in ON and OFF mode.

Fig. 5
figure 5

AOE rod radius optimization

3 Numerical analysis of the proposed AOE nanostructure

The nanostructure of the encoder will be simulated and numerically analyzed. The FDTD approach was employed in the numerical analysis of the suggested encoder nanostructure. The normalized Maxwell equations are presented in Eqs. (1)–(3) for FDTD numerical analysis (Veisi et al. 2022; Houle and Sullivan 2020):

$$\frac{{\partial \tilde{D}}}{\partial t} = \frac{1}{{\sqrt {\varepsilon_{0} \mu_{0} } }} \nabla \times H$$
(1)
$$\tilde{D}\left( \omega \right) = \varepsilon_{r}^{*} \left( \omega \right) \cdot \tilde{E}\left( \omega \right)$$
(2)
$$\frac{\partial H}{{\partial t}} = - \frac{1}{{\sqrt {\varepsilon_{0} \mu_{0} } }} \nabla \times \tilde{E}$$
(3)

The utilization of TM mode in Ez, Hx, and Hz nanostructure is considered for the preceding equations. By substituting Ez, Hx, and Hz into the preceding equation, we obtain (Veisi et al. 2022; Houle and Sullivan 2020):

$$\frac{{\partial D_{z} }}{\partial t} = \frac{1}{{\sqrt {\varepsilon_{0} \mu_{0} } }}\left( { \frac{{\partial H_{y} }}{\partial t} - \frac{{\partial H_{x} }}{\partial t}} \right)$$
(4)
$$D_{z} \left( \omega \right) = \varepsilon_{r}^{*} \left( \omega \right) \cdot E_{z} \left( \omega \right)$$
(5)
$$\frac{{\partial H_{x} }}{\partial t} = - \frac{1}{{\sqrt {\varepsilon_{0} \mu_{0} } }} \frac{{\partial E_{z} }}{\partial y}$$
(6)
$$\frac{{\partial H_{y} }}{\partial t} = \frac{1}{{\sqrt {\varepsilon_{0} \mu_{0} } }} \frac{{\partial E_{z} }}{\partial x}$$
(7)

where, ε0 and μ0 are the permittivity of free space and the permeability of free space, respectively. The perfectly matched layers (PML) is one of the most adaptable and successful attracting ABCs in boundary conditions. The return value of the wave is determined from the equation as it propagates from medium A (ηA) to medium B (ηB) (Veisi et al. 2022; Houle and Sullivan 2020):

$${\Gamma } = \frac{{\eta_{A} - \eta_{B} }}{{\eta_{A} + \eta_{B} }}$$
(8)

The impedances of media A and B are determined from the underlying equation. The best ideal scenario in Eq. (8) is for media A's impedance to be near media B's. This means that the return wave will be close to Zero. The impedance of the media is obtained from Veisi et al. (2022):

$$\eta = \sqrt {\frac{\mu }{\varepsilon }}$$
(9)

where, ε and μ are the permittivity and the permeability, respectively. These values are obtained from:

$$\varepsilon = \varepsilon_{0} \times \varepsilon_{r}$$
(10)
$$\mu = \mu_{0} \times \mu_{r}$$
(11)

In this research, the meshing approach is as follows: Δy and Δx are the minimal size values for meshing in the y and x directions, respectively, equal to λ /16. In this situation, Δt values will be determined utilizing Eq. (12):

$${\Delta }t < \frac{1}{{c\sqrt {\left( {\frac{1}{{{\Delta }x}}} \right)^{2} - \left( {\frac{1}{{{\Delta }y}}} \right)^{2} } }}$$
(12)

3.1 Case1

In the first case, which we will examine for encoder, the light source will be ON. The final value of two outputs one and two in this case is less than 0.0001 the amount of input light power. In this case, the two outputs are equal to logic zero and will encode “1000” to “00”. The field distribution and time response diagram in this case is shown in Fig. 6.

Fig. 6
figure 6

a Case 1 in which input port input1 is On, and another inputs are Off. The outputs become Off (< 0.0001 W/μm2). b Response time of case 1

3.2 Case2

In the second case, which was analyzed, the input light source 2 is on and the other light sources are off. The field distribution diagram and frequency response of this case are shown in Fig. 7. The value of the first output is equal to 0.008 of the input light power and the value of the second output is equal to 0.35 of the input light power. The second output in this case will be equal to the logical ON and the first output will be in the OFF mode. The amount of time delay in this case is about 238 femtoseconds.

Fig. 7
figure 7

a Case 2 in which input port input2 is On, and another inputs are Off. The output1 becomes Off (0.008 W/μm2), and the output2 becomes Off (0.35 W/μm2). b Response time of case 2

3.3 Case3

In the third case, due to the relative symmetry in the proposed encoder structure, the conditions will be inverse of the second case. In this case, the third input will be on. The value of the first output in this case will be equal to 0.35 of the input light power and equal to one logic. The value of the second output in this case will be equal to 0.008 of the input light power and equal to zero logic. The amount of time delay in this case will be the same as in the second case. The encrypted value in this case will be equal to “10”. The field distribution diagram and frequency response of this case are shown in Fig. 8.

Fig. 8
figure 8

a Case 2 in which input port input3 is On, and another inputs are Off. The output1 becomes On (0.35 W/μm2), and the output2 becomes Off (0.008 W/μm2). b Response time of case 3

3.4 Case 4

In the fourth case, the fourth input light source will be on. In this case, the two proposed encoder outputs must be equal to one logic. As can be seen in Fig. 9, in the fourth case the two outputs are equal and in the on position. In this case, the time delay is about 530 femtoseconds. The bit rate will be 1.88 Tb/s. The normalized output value for the two output ports will be 0.58 W/μm2, as shown in Fig. 9 and the encrypted value will be equal to “11”. Detailed analysis will follow in the following sections.

Fig. 9
figure 9

a Case 4 in which input port input4 is On, and another inputs are Off. The outputs become ON (less than 0.58 W/μm2). b Response time of case 4

3.5 Nonlinear case

All the analyzes examined in the previous section were in linear mode. The structure exhibited at low power intensities does not rely on the power intensity, but in the nonlinear state, with enhancing the intensity of input power, unwanted conditions might happen for the structure, which were studied by inspecting the structure in the nonlinear state. In this section, we want to analyze all of the above by applying a nonlinear Kerr effect. In the nonlinear case, the refractive index will be obtained from the following equation (Veisi et al. 2021).

$$n = n_{0} + n_{2} I$$
(13)

where, I is the intensity, n2 is the nonlinear refractive index and n0 is the free space refractive index and depends on the wavelength (Veisi et al. 2021). The nonlinear refractive index of silicon is equal to 1.5 × 10–17 m2/W and the amount of light intensity in this case is equal to 100 W/μm2 (Veisi et al. 2021). The values obtained in the four cases examined are given in Table 1.

Table 1 Nonlinear case values

4 Discussion and compare of the all-optical 4 × 2 encoder performance

4.1 Evaluation based on contrast ratio

The contrast ratio is presented in this section to assess the suggested encoder's performance. The contrast ratio is the differential in values between the ON as well as OFF states of output, and The high contrast ratio demonstrates the encoder's appropriate functioning. Equation specifies the contrast ratio (CR) (Veisi et al. 2021):

$$CR \left( {dB} \right) = 10{\text{log}}\frac{{Output\left( i \right)_{ON} }}{{Output\left( i \right)_{OFF} }}$$
(14)

The values obtained for the linear mode and the CR are given in Table 2.

Table 2 The proposed AOE performance

4.2 Evaluate the performance of the proposed all-optical 4 × 2 encoder

In the previous section, the output values for the structure were analyzed and evaluated. In this section, we will review and analyze the proposed AOE in comparison with other proposed all-optical encoders. The contrast ratio will be 16.4 dB in the linear mode and 10.12 dB in the nonlinear mode. As you can see in Table 3, the performance of the proposed nanostructure compared to other structures presented will be very good and optimal in both linear and nonlinear modes.

Table 3 Compare the proposed all-optical 4 × 2 encoder with similar works

5 Conclusion

This research discusses the design, simulation, and evaluation of an ultra-compact as well as ultra-fast encoder nanostructure. The encoder suggested here is optimized for rod radius, core rod radius, and wavelength of the input light source. The PWE approach was utilized for designing the suggested encoder, and the FDTD method was employed to get numerical outcomes and simulate the recommended nanostructure. The suggested ultra-compact nanostructure footprint is approximately 108 μm2, with a nanostructure delay time of roughly 530 fs. Another aspect discussed in this study is the encoder's superior contrast ratio in comparison to other encoders. The suggested encoder's high bit rate seems to be another distinguishing characteristic. The bit rate is obtained 1.88 Tb/s. The suggested encoder may be employed in all-optical integrated circuits with distinct properties.