Since the importance of address code of OCDMA passive optical network (PON) diversity and lacking of general coding method until now, in this paper, we present a general coding method of (F, K, λ a , λ c ) optical orthogonal code (OOC) based on block design. Through the discussion of block, difference sets and cyclic permutation of perfect distance (CPPD), cyclic permutation of imperfect distance (CPID) is defined and applied to realize the coding method. Simulations results demonstrated that it is possible to construct (F, K, λ a , λ c ) OOCs with arbitrary code length, code weight, auto-correlation constraints and co-correlation constraints based on the same general coding method.