(N/A) $p-n$ junction is formed by joining a $p$-type semiconductor and an $n$-type semiconductor. When an acceptor impurity (like $Al$) is added to one region of a $Si$ wafer,it becomes a $p$-type semiconductor,and when a donor impurity (like $As$) is added to another region,it becomes an $n$-type semiconductor.
Two important processes occur during the formation of a $p-n$ junction: diffusion and drift.
Due to the concentration gradient of charge carriers,holes diffuse from the $p$-side to the $n$-side $(p \rightarrow n)$,and electrons diffuse from the $n$-side to the $p$-side $(n \rightarrow p)$. This motion constitutes a diffusion current.
As electrons diffuse from $n \rightarrow p$,they leave behind ionized donor atoms (positive charges) on the $n$-side. Similarly,as holes diffuse from $p \rightarrow n$,they leave behind ionized acceptor atoms (negative charges) on the $p$-side. These ionized charges are immobile.
The region around the junction that becomes depleted of mobile charge carriers is called the depletion region or depletion layer. Its thickness is typically of the order of $0.5 \mu m$.
Due to the positive space-charge on the $n$-side and negative space-charge on the $p$-side,an electric field is established directed from the $n$-side to the $p$-side. This electric field opposes further diffusion and causes drift of charge carriers. The potential difference developed across the junction due to this electric field is known as the barrier potential $(V_0)$.