Optical implementation of bipolar codes