Generate Hadamard code from orthogonal set of codes
Sequence Generators sublibrary of Comm Sources
The Hadamard Code Generator block generates a Hadamard code from a Hadamard matrix, whose rows form an orthogonal set of codes. Orthogonal codes can be used for spreading in communication systems in which the receiver is perfectly synchronized with the transmitter. In these systems, the despreading operation is ideal, as the codes are decorrelated completely.
The Hadamard codes are the individual rows of a Hadamard matrix. Hadamard matrices are square matrices whose entries are +1 or -1, and whose rows and columns are mutually orthogonal. If N is a nonnegative power of 2, the N-by-N Hadamard matrix, denoted HN, is defined recursively as follows.
The N-by-N Hadamard matrix has the property that
HNHNT = NIN
where IN is the N-by-N identity matrix.
The Hadamard Code Generator block outputs a row of HN. The output is bipolar. You specify the length of the code, N, by the Code length parameter. The Code length must be a power of 2. You specify the index of the row of the Hadamard matrix, which is an integer in the range [0, 1, ... , N-1], by the Code index parameter.
A positive integer that is a power of two specifying the length of the Hadamard code.
An integer between 0 and N-1, where N is the Code length, specifying a row of the Hadamard matrix.
The time between each sample of the output signal. Specify as a nonnegative real scalar.
The number of samples in one column of the output signal. Specify as a positive integer scalar.
Note: The time between output updates is equal to the product of Samples per frame and Sample time. For example, if Sample time and Samples per frame equal one, the block outputs a sample every second. If Samples per frame is increased to 10, then a 10-by-1 vector is output every 10 seconds. This ensures that the equivalent output rate is not dependent on the Samples per frame parameter.
The output type of the block can be specified as an
By default, the block sets this to
Select the simulation mode.
On the first model run, simulate and generate code. If the structure of the block does not change, subsequent model runs do not regenerate the code.
If the simulation mode is
System objects corresponding to the blocks accept a maximum of nine
Simulate model without generating code. This option results in faster start times but can slow subsequent simulation performance.
This example model compares a single-user system vs. a two-user data transmission system with the two data streams being independently spread by different orthogonal codes.
The model uses random binary data which is BPSK modulated (real), spread by Hadamard codes of length 64 and then transmitted over an AWGN channel. The receiver consists of a despreader followed by a BPSK demodulator. Open the model here: hadamard_block_example1.
modelname = 'hadamard_block_example1'; open_system(modelname); sim(modelname);
For the same data and channel settings, the model calculates the performance for one- and two-user transmissions.
Note that for the individual users, the error rates are exactly the same in both cases. This shows that perfect despreading is possible due to the ideal cross-correlation properties of the Hadamard codes.
To experiment with this model further, specify a different Code length or Code index for the individual users to examine the variations in relative performance.
This example model considers a single-user system in which the signal is transmitted over multiple paths. This is similar to a mobile channel environment where the signals are received over multiple paths, each of which have different amplitudes and delays. To take advantage of the multipath transmission, the receiver employs diversity reception which combines the independent paths coherently.
Note, to keep the system simple, no shadowing effects are considered and the receiver has a priori knowledge of the number of paths and their respective delays. Open the model here: hadamard_block_example2.
modelname = 'hadamard_block_example2'; open_system(modelname); sim(modelname);
For the data transmission with the same spreading code that was used in the first example, we now see deterioration in performance when compared with that example (compare the 180 errors with 81 in the previous case). This can be attributed to the non-ideal auto-correlation values of the orthogonal spreading codes chosen, which prevents perfect resolution of the individual paths. Consequently, we don't see the merits of diversity combining.
To experiment with this model further, try selecting other path delays to see how the performance varies for the same code. Also try different codes with the same delays.