# CDMA generating the sequence for gold codes

Is this the correct way to generate a set of Gold codes:

Take a preferred pair of M sequence polynomials and load each one of them into a separate LFSR. The serial bit streams that are generated from this process are combined using an exclusive or gate; the result is a gold code bit stream.

This is modulated with a data bit stream using an EX OR gate before further modulation or transmission.

Using the same preferred pair of polynomials to generate another gold code as above. However, this time using a different seed value. For example:

Code length of 64 gives a family size of 6. Does a family size of 6 mean that I have to generate 6 codes to divide 6 users in a channel using the method I described above with a different seed every time?

Could somebody correct the above and help me understand this process?

Also are there any tables available for the preferred pairs of polynomials Vs family size?

• For more than you probably want to know, I refer you to the paper D.V. Sarwate and M.B. Pursley, "Cross-correlation properties of pseudorandom and related sequences," Proc. IEEE, vol.68, pp.593-619, May 1980. It includes a detailed discussion of the Gold sequences as well as the small sets and large sets of Kasami sequences. Jun 30, 2021 at 19:47

Once you have a preferred pair of M sequence polynomials, you can generate up to $$2^N-1$$ unique and almost orthogonal Gold Code sequences by simply shifting one of the codes prior to the XOR combining. Each shift provides an independent sequence, and since for a LFSR of order $$N$$ we have $$2^N-1$$ possible shifts within the sequence before it repeats, we will get $$2^N-1$$ unique codes. Additionally as if often done in Gold Code generators, if you XOR (GF2 add) two delayed copies of the same generator, the result will be a delayed copy of the same generator! Thus we can create an efficient generator that can give us a family of codes by XORing two different delayed taps from one generator prior to XORing with the second generator - which is effectively choosing a different delay before XORing resulting in an independent code! See this classical implementation of a GPS C/A Code Generator where such a structure is commonly used:

What may be interesting is that when you XOR (GF2 add) two LFSR sequences, it generates the same sequence as a generator polynomial as the convolution of the two sequences (which is not maximum length since it is clearly not irreducible since we created it by a product of the polynomials, as given by the convolution of their coefficients). For instance, I have created GPS Gold Code generators from a single universal LFSR as an alternate to the above dual LFSR structure byusing the convolution of those two polynomials (resulting in a length 20 polynomial). The resulting sequence is still cyclical within $$2^{10}-1$$ chips, but if you seed it with a portion of the sequence for any given GPS Satellite, then it will generate the Gold Code for that satellite, now being within that cyclical group. A 20th length LFSR if maximum length (using an irreducible generator polynomial) would generate $$2^{20}-1$$ sequences before repeating. In this case because it was not maximum length there are $$2^{10}-1$$ subgroups that can each generate a $$2^{10}-1$$ sequence. We select or force which subgroup we are in simply by seeding the generator to be any 20 bit sequence within that group, thus suggesting that all 20 bit sequences would be unique to any of the $$2^{10}-1$$ groups.

Is this the correct way to generate a set of Gold codes:

Take a preferred pair of M sequence polynomials and load each one of them into a separate LFSR. The serial bit streams that are generated from this process are combined using an exclusive or gate; the result is a gold code bit stream.

Sort of. One does not "load" a preferred pair of m-sequences into separate LFSRs; the coefficients of the m-sequence specify the feedback connections of the LFSR. What is loaded into each LFSR is the seed which determines which Gold sequence (sometimes called a Gold code) is generated. Gold sequences are periodic and to avoid getting the same Gold sequence but with a different starting point (a strict no-no for asynchronous CDMA) when using assigning different seeds for different users, it is best to assign the same (nonzero) seed for one LFSR to all users, and to assign different (nonzero) seeds for the other LFSR to different users.

Code length of 64 gives a family size of 6. Does a family size of 6 mean that I have to generate 6 codes to divide 6 users in a channel using the method I described above with a different seed every time?

Er, no, Gold sequences have periods (or lengths) of the form $$2^n-1$$ and so you likely meant $$63$$, not $$64$$. There are $$65$$ Gold sequences (not $$6$$ as you think) of period $$63$$ consisting $$63$$ sequences generated by nonzero seeds in each LFSR, and the two m-sequences which are generated when one LFSR is loaded with a zero seed and other has a nonzero seed. Each of these $$65$$ sequences of length or period has $$63$$ different cyclic shifts giving a total of $$65\times 63 = (2^6+1)\times (2^6-1) = 2^{12}-1$$ "different" nonzero outputs that might be observed. As Dan Boschen's answer (after replacing $$10$$ with $$6$$ mutatis mutandis) points out, Gold sequences of period $$63$$ can be generated with a $$12$$-bit LFSR whose feedback taps correspond to the product of the two preferred polynomials, and the $$2^{12}-1$$ "different outputs" of this $$12$$-bit LFSR can be grouped into sets of $$63$$ cyclically-equivalent Gold codes.

For more than you probably want to know, I refer you to the paper D.V. Sarwate and M.B. Pursley, "Cross-correlation properties of pseudorandom and related sequences," Proc. IEEE, vol.68, pp.593-619, May 1980. It includes a detailed discussion of the Gold sequences as well as the small sets and large sets of Kasami sequences.