There is provided an apparatus for performing, by optical code division multiplex
access, at least one of encoding and decoding of wavelength-division-multiplexed
light. The apparatus includes: an optical input/output section 203 for handling
input/output of the wavelength-division-multiplexed light; and N fiber gratings
(where N is an integer equal to or greater than two) 101 to 103,
which are in a series connection to the optical input/output section 203.
Each of the N fiber gratings has a sampled grating structure having an alternating
array of first regions (11 to 14; 21 to 24; and 31
to 34) which provide a refractive index modulation with a relatively large
amplitude and second regions (201) which provide a refractive index modulation
with a relatively small amplitude, the first and second regions being disposed
with a constant period P. Each sampled grating structure defines a plurality of
reflection wavelength bands which are replicated with a period that is equal to
the interval (T) between the central wavelengths of wavelength bands contained
in the wavelength-division-multiplexed light. The central values of the respective
reflection wavelength bands differ from one fiber grating to another at least during operation.