1 Introduction

A crystal is a periodic arrangement of atoms, ions or molecules. The arrangement in which these atoms, ions or molecules are to be repeated in space forms a lattice. Like semiconductor, photonic crystal exhibits a certain gap known as photonic band gap (PBG), which prevents a certain range of wavelength. Using this photonic bandgap, we can design and construct optical devices using photonic crystals. The basis on the arrangement of elements in the crystal lattice, photonic crystals are classified into one dimensional (1D), two dimensional (2D), and three dimensional (3D) photonic crystals. In one dimensional photonic crystal, the periodicity exhibits in one direction only so the band gap, index state, and bound states all restricted in one direction only. So this one-dimensional photonic crystal finds fewer applications.

In two dimensional photonic crystals, the periodicity varies in two directions, it and remains idle in the third direction. The three-dimensional photonic crystals, periodicity is heterogeneous in all the three directions. The photonic band gaps in 2D crystals also have a plane of periodicity also due to the complications in integration and fabrication of the three-dimensional crystals, two-dimensional photonic crystals find more application in the field of photonics (Joannopoulos et al. 2008; Skorobogatiy and Yang 2008; Kotiyal et al. 2012). The lattice may be either square lattice or hexagonal lattice but hexagonal lattice has an advantage of its geometry, which provides smaller angles for the bending of light. In turn, this provides fewer scattering of light that leads to lessening the losses while transmission. The de-multiplexer for two wavelengths of 1.31 μm and 1.55 μm using a hexagonal lattice of the 2D photonic crystal structure is designed and 70% of transmission is achieved (Amoh et al. 2012). By using hexagonal lattice, dual-nano ring resonator is designed to obtain two-port channel drop filter (Hsiao and Lee 2013). With the help of hexagonal lattice photonic crystal, 1 × 2 optical wavelength division de-multiplexer with 90% of transmission is achieved at wavelengths of 1350 nm and 1530 nm (Kumar and Sabnani 2014).

In literature, the encoder has been realized using logic gates. Optical AND & OR gate are designed using a combination of ring cavities and y-shaped line defect photonic crystals in which contrast ratio of more than 5 dB and transmission power more than 0.5 is accomplished (Younis et al. 2014). Various gates like OR, AND, NOT and XOR gates are designed using square ring resonators excluding non-linear materials by which XOR and NOT gates achieves a high contrast ratio of 35 dB. Similarly, by using T-branch combiner 4.77 dB of contrast ratio is achieved (D’souza and Mathew 2016; Fasihi 2016). In (Mohebbi et al. 2015), optical XOR, XNOR, NAND and NOT gates are designed using L-shaped waveguide in the square lattice by which the contrast ratio of 20 dB is achieved. By using ring resonator with non-linear Kerr effect, optical logic gates like NAND and NOR is designed to be resonating at a wavelength of 1550 nm. Similarly, these gates are designed without using nonlinear materials in square lattice photonic crystal ring resonator (Alipour-Banaeia et al. 2014; Bao et al. 2014).

An Optical 4 × 2 reversible encoder has been designed using non-linear Kerr effect with two elliptical ring resonator and seven vertical waveguides resonating at the wavelength of 1555 nm (Hassangholizadeh Kashtibana et al. 2015). Optical encoder with the employment of self-collimation effect with the combination of beam splitters and mirrors is designed to achieve a response time of 1.4 ps (Alipour-Banaei et al. 2016). Another 4 × 2 optical encoder is designed using a combination of a line defect, Y-branch and coupling waveguides in a triangular lattice with cylindrical silicon rods (Lee et al. 2009). In literature, very few works have been carried out in the design of optical encoder. However, these works do not consider the effect of the contrast ratio, which demands the high power output for logic 1 and very low output for logic 0. Hence, in this paper, the 4 × 2 optical reversible encoder is designed with high contrast ratio so as to realize an encoder that best suit for the design of photonic logic devices.

The rest of the paper is structured as follows: Following this introduction and related works in the design of photonic devices, a detailed analysis of the proposed structure is given in Sect. 2. The simulation and discussion of the proposed design are carried out in Sect. 3. Finally, Sect. 4 draws the conclusion.

2 Proposed structure

The proposed 4 × 2 optical reversible encoder consists of four input waveguide, four output waveguide, and hexagonal shaped resonators as shown in Fig. 1. The basic parameters, namely, ε(dielectric constant), a(lattice constant) and n(refractive index) must be chosen appropriately to get the desired bandgap structure. The proposed structure is structured to resonate at the wavelength of 1550 nm by means of the dielectric constant equals to 11.56, with a refractive index of 3.47. In addition, The lattice constant is 650 nm and radius is 247.5 nm. In calculating the bandgap structure, plane wave expansion (PWE) method is used, which is considered to be one of the best solutions to calculate the Maxwell equation in the frequency domain. The bandgap structure of this proposed structure is given in Fig. 2. The range of this structure varies from 0.321 < a/λ < 0.464. Due to the PBG domination in TE mode, all simulations have been done in TE mode.

Fig. 1
figure 1

Structure of waveguide-based 4 × 2 reversible optical encoder

Fig. 2
figure 2

Band gap structure for the proposed design (TE mode)

In Fig. 1, when the input is transmitted from the left side, the O1 and O2 acts as an output and O0 and O3 act as squander output. Since it is a reversible structure it consists set of four inputs I1, I2, I3, and I4 and set of four outputs O1, O2, O3, and O4. So when transmitting from the left side, only O1 and O2 should be considered and O0 and O3 should be ignored. Similarly, when the input is transmitted from the left side, the I1 and I2 acts as an output and I0 and I3 act as squander output. So when transmitting from the left side, only I1and I2 should be considered and I0 and I3 should be ignored. The truth table for the reversible encoder is given in Table 1. The bandgap of the proposed structure is given in Fig. 2. The bandgap structure is in the range of 0.321 < a/λ < 0.464. In this structure, we had introduced a hexagonal shaped structure in between the waveguides for efficient performance and improved contrast ratio. The bandgap structure is in the range of 0.321 < a/λ < 0.464. In the band structure, since wavelength should be in the range of 1416 < λ < 2083, we have obtained band gap in the range from 0.321 < a/λ < 0.464, which is necessary to obtain the desired output. Therefore, a line defect has been created so that the photons with these wavelength within the bandgap can be propagated in a certain path.

Table 1 Truth of a 4 × 2 reversible optical encoder

3 Kerr effect

A defect has to be added to the structure of waveguide, in order to create a cavity mode in the bandgap region of a PC. To exhibits strong Kerr effect, the defected material has to be doped later. The refractive index can be modified using electro-optic, thermo-optic or optical Kerr effect. Kerr effect can be used in all optical applications apart from the other effect which is mentioned above. The material which possesses Kerr effect, the refractive index can be linearly changed using the optical pump signal as follows:

$${\text{n }} = {\text{ n}}_{0} + {\text{ n}}_{2} {\text{I}}$$
(1)

where n0 is the refractive index of the linear regime, I is the optical field intensity and n2 is the nonlinear Kerr coefficient. The nonlinear Kerr effect value is equal to n2 = 2.7 × 10−9m2/w.

4 FDTD method

The FDTD method imitates the electromagnetic wave by a volumetric sampling of unknown fields. In photonic band structure materials where the dielectric constant is periodically modulated, the electric and magnetic fields of the electromagnetic waves, E (r) and H(r), through the structure can be described by band index n and a wave vector k in irreducible Brillouin zone due to Bloch’s theorem:

$$\vec{E}_{n,k} \left( {\vec{r}} \right) = u_{n,k} \left( {\vec{r}} \right)exp\left( {i\overrightarrow {k.} \vec{r}} \right), u_{n,k} \left( {\vec{r} + \vec{R}} \right) = u_{n,k} \left( {\vec{r}} \right)$$
(2)
$$\vec{H}_{n,k} \left( {\vec{r}} \right) = v_{n,k} \left( {\vec{r}} \right)exp\left( {i\overrightarrow {k.} \vec{r}} \right), v_{n,k} \left( {\vec{r} + \vec{R}} \right) = v_{n,k} \left( {\vec{r}} \right)$$
(3)

where \(\vec{R}\) is the lattice constant, \(u_{n,k} \left( {\vec{r}} \right)\) and \(v_{n,k} \left( {\vec{r}} \right)\) are the periodic functions related to Bloch waves.

5 Simulation results and discussion

For a given input of 1000, the signal enters through the port I0 and it does not couple at any resonator due to the arrangement of the structures. Thus, the output generates a low power signal as 00. Alternatively, for the input of 0100, the signal enters the input port I1, and the signal couples through the resonator in the port O1, which generates an output of 01. If input 0010 is given, then signal couples with resonator through I2, then the signal travels through the output port O2, hence the output generates as 10. Similarly, if the input 0001 is given, then the signal enters through port I3, signal couples through both sides of waveguides and reaches output which generates high in both O1 and O2. The transmission diagram for the input 1000,0100,0010, and 0001 is shown in Fig. 3a–d, respectively, and the obtained logical output values are given in Table 1. The transmission diagram for 4 × 2 reversible encoder for input of 1000 and 0100 is shown in Fig. 3a, b, respectively. As displayed in Fig. 3a, for input given in port I0, the signal does not a couple in any of the ports and hence a very low output signal is generated in port O1 and O2. Alternatively, from Fig. 3b, for input given in port I1, the signal gets coupled through the third hexagonal structure to generate a high signal in output port O1 and low signal in port O2.

Fig. 3
figure 3

Transmission diagram for input a 1000 and b 0100

The transmission diagram for a 4 × 2 encoder for input of 0010 and 0001 is shown in Fig. 4a, b, respectively. In Fig. 4a, when the input 0010 is given, the signal couples through first hexagonal resonator and generates a high signal at the port O2 and low signal at port O1. In Fig. 4b, when the input 0001 is given, the signal couples with both the resonator generating a high signal on both the ports O2 and O1. Similarly when considering the input transmitting reverse side, if input 1000 is given, then the signal enters through the port O0, the signal will not couple with any resonator, the output generates low power signal as 00. If the input 0100 is given, then the signal enters the input port O1, so the signal couples through the resonator in the port I1, so the output generates as 01. If input 0010 is given, then signal couples with a resonator in I2, then the signal travels through output port O2, hence the output generates as 10. Similarly, if the input 0001 is given, then the signal enters through port I3, signal couples through both sides of waveguides and reaches output which generates high in both O1 and O2.

Fig. 4
figure 4

Transmission diagram for input a 0010 and b 0001

The transmission diagram for 4 × 2 reversible encoder for input of 1000 and 0100 transmitting from reverse side is shown in Fig. 5a, b, respectively. In Fig. 5a, for input given in port O0, the signal does not couple in any of the ports and hence very low output signal is generated in port I1 and I2. Alternatively, from Fig. 5b, for input 0100 is given, then the signal enters port O1 gets coupled through the third hexagonal structure to generate a high signal in output port I1 and low signal in port I2. The transmission diagram for 4 × 2 reversible encoder for input of 0010 and 0001 transmitting from reverse side is shown in Fig. 6a, b, respectively. In Fig. 6a, when the input 0010 is given, the signal couples through first hexagonal resonator and generates a high signal at the port I2 and a low signal at port I1. In Fig. 6b, when the input 0001 is given, the signal enters through O3 and then couples with both the resonator generating a high signal on both the ports I2 and I1.

Fig. 5
figure 5

Transmission diagram for reversible input a 1000 and b 0100

Fig. 6
figure 6

Transmission diagram for reversible input a 0010 and b 0001

The input–output characteristics for input 1000 and 0100 are shown in Fig. 7a, b respectively. The logical output obtained at port O1 is 0.045 and at port, O2 is 0.05 for input 1000. For input 0100, the value obtained at O1 is 0.97 and at O2 is 0.048. The input–output characteristics for input 0010 and 0001 are shown in Fig. 8a, b, respectively. The logical output obtained at port O1 is 0.99 and at port, O2 is 0.073 for input 1000. For input 0100, the value obtained at O1 is 0.46 and at O2 is 0.36. The input–output characteristics for input 1000, 0100, 0010 and 0001 is shown in Figs. 9a, b, 10a, b, respectively.

Fig. 7
figure 7

Observation analysis for input a 1000 and b 0100

Fig. 8
figure 8

Observation analysis for input a 0010 and b 0001

Fig. 9
figure 9

Observation analysis for reversible input a 1000 and b 0100

Fig. 10
figure 10

Observation analysis for reversible input a 0010 and b 0001

5.1 Analysis of wavelength deviations due to varying crystal lattice and rod radius

The reason for the choice of radius and position of the rods is analyzed in this section. At times, even misplacing of a single lattice also lead to the variation in the results. As shown in Fig. 11, the red color circle indicates that defects are introduced in the crystal lattice. Introducing of defects will have an effect on getting the desired output. Here the desired results are not obtained due to the improper placement of crystals in the design. Similarly, in Fig. 12, some lattice were missing in the waveguide I0 and O0 shown in the circle, this leads to imperfection while transmitting the input 1000 to get desired logical output 00.

Fig. 11
figure 11

Structure of waveguide-based 4 × 2 reversible optical encoder with defects introduced by removing the rods

Fig. 12
figure 12

Structure of Waveguide-based 4 × 2 Reversible Optical Encoder with defects introduced in the waveguide

As shown in Fig. 13, the removing some of the rods in hexagon and some of the rods in waveguide does not provide the required wavelength (1550 nm) with high power as compared to the defect in the proposed structure. The choice of the radius of the rods in the proposed structure and its observation analysis is displayed in Figs. 14 and 15, respectively. As shown in Fig. 15, the radius is equal to 0.2475 um which perform better than the rods in the range between 0.15 and 0.35 um. The performance of the proposed structure in terms of its contrast ratio is shown in Table 2. In Table 2, when input 1000 transmitted from the front side, the value of O1 corresponds to 0.05 and 0.045 is obtained at O2. As both the states correspond to logic 0, a difference of 10% is obtained between these states and the contrast ratio is 0.45 dB. For input 0100, the value of O1 is 0.97and O2 is 0.048. As contrast ratio 13 dB of these two states is high, a difference of 95% is obtained between these states. For input 0010, the value of O1 is 0.073 and O2 is 0.99. As contrast ratio 11.5 dB is obtained between these two states is high, a difference of 92.6% is obtained between these states. For input 0001, the value of O1 corresponds to 0.46 and 0.36 is obtained at O2. As both the states correspond to logic 1, a difference of 21.7% is obtained between these states and contrast ratio as 1.06 dB.

Fig. 13
figure 13

Observation analysis of wavelength deviation for various defects

Fig. 14
figure 14

Structure of waveguide-based 4 × 2 reversible optical encoder with defects

Fig. 15
figure 15

Observation analysis showing deviations for varying radius of the rods

Table 2 Logical output values and the obtained output using the proposed design

When input 1000 transmitted from the reverse side, the value of I1 corresponds to 0.059 and 0.05 is obtained at I2. As both the states correspond to logic 0, a difference of 15.25% is obtained between these states and the contrast ratio is 0.7 dB. For input 0100, the value of I1 is 0.97 and I2 is 0.07 and the contrast ratio of 11.3 dB is obtained between these two states is high, a difference of 92.7% is obtained between these states. For input 0010, the value of I1 is 0.07and I2 is 0.99and the contrast ratio of 11.5 dB is obtained between these two states is high, a difference of 92.9% is obtained between these states. For input 0001, the value of I1 corresponds to 0.3 and 0.36 is obtained at I2. As both the states correspond to logic 1, a difference of 16.6% is obtained between these states and contrast ratio as 0.79 dB.

6 Conclusion

In this paper, the design and simulation of 4 × 2 reversible optical encoder are realized using a multi-hexagonal shaped structure based on waveguide transmission using photonic crystal resonator. It is also observed that the contrast ratio for output states of 01 and 10 is found to be 13 dB and 11.5 dB respectively. When the input of 0100 or 0010 is given, output logic states of 01 and 10 is obtained with a high contrast ratio and similarly for the input 1000 or 0001 is given, output logic states of 00 and 11 with low contrast ratio 0.45 dB and 1.06 dB is achieved, which ultimately demonstrates the working of 4 × 2 encoder.