An encoder according to the present invention is an encoder for encoding
an optical wavelength-multiplexed signal compliant with optical CDMA into
a code having a code pattern, including: L optical fibers 36 and 42
(where L is an integer equal to or greater than two) each having a
plurality of gratings 37 to 47; and a circulator 52 for coupling the
plurality of optical fibers 36 and 42. The code pattern contains time
bins t1 to t3. A plurality of wavelengths .lamda.1, .lamda.4 and .lamda.5
are assigned to the time bin t1. If a sum of an optical path difference
in each optical fiber from the grating which reflects the optical signal
of the wavelength .lamda.1 to the grating which reflects the optical
signal of the wavelength .lamda.4 is calculated for all of the optical
fibers 36 and 42, the sum equals zero.