A plurality of p wells and a plurality of n wells are formed in a p-type
semiconductor substrate having a memory portion and a
peripheral circuit portion. Next, a
resist pattern is formed on the
semiconductor substrate. The
resist pattern has apertures which, as viewed from the direction normal to the plane of the
semiconductor substrate, approximately coincide with the p wells, wherein the area of aperture openings on the top side of the
resist pattern is different from the area of aperture openings on the bottom side of the resist pattern. By using the resist pattern as a
mask, p-type ions are injected in a shape approximately the same as that of the aperture opening on the top side or bottom side, whichever has the smaller area. Thereafter, by using the same resist pattern as a
mask, n-type ions having enough energy to pass through resist of a predetermined thickness are injected into the p-type semiconductor substrate through areas, located adjacent the apertures in the resist pattern, in which the effective thickness of the resist is small, thereby forming deep n wells so as to cover the p well regions.