-
Notifications
You must be signed in to change notification settings - Fork 2
/
LUT_PRBS.m
78 lines (53 loc) · 9.39 KB
/
LUT_PRBS.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
function pattern = LUT_PRBS(N, samples_per_bit, num_repeats)
% Generates a PRBS signal of length 2^N-1. Since we have not succeeeded in
% getting the same results as matlab, we will just cheat and copy the
% sequences.
% Inputs
% ------
% N --> Order of the PRBS (L = 2^N-1)
% samples_per_bit --> Number of samples per each bit
% num_repeats --> Number of times the PRBS pattern is repeated
% Outputs
% -------
% pattern --> The pattern, of total length
% (2^N-1)*samples_per_bit*num_repeats. The signa toggles between 1 and -1.
% ************ Select the correct seed *************
switch N
case 2
output_pattern = [0 0 1];
case 3
output_pattern = [0 0 0 1 0 1 1];
case 4
output_pattern = [0 0 0 0 1 0 1 0 0 1 1 0 1 1 1];
case 5
output_pattern = [0 0 0 0 0 1 1 0 0 1 0 1 1 0 1 1 1 1 0 1 0 1 0 0 0 1 0 0 1 1 1];
case 6
output_pattern = [0 0 0 0 0 0 1 0 1 0 1 0 0 1 1 0 0 1 0 0 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 1 1 0 1 0 0 0 0 1 1 0 1 0 1 1 1 0 0 1 1 1 1 0 1 1 1 1 1];
case 7
output_pattern = [0 0 0 0 0 0 0 1 0 1 0 1 0 1 1 0 0 1 1 0 0 0 1 0 0 ...
0 1 0 1 1 0 1 0 0 1 1 1 0 0 1 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 1 ...
0 1 1 0 1 1 1 0 0 0 1 1 1 1 0 1 0 0 0 0 0 1 1 0 1 0 1 0 0 0 1 1 ...
0 0 1 0 1 1 1 0 1 1 0 0 0 0 1 1 1 0 1 0 1 1 1 1 0 0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0 1 0 0 1 0 1 0 1 0 1 1 0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 1 1 0 1 0 1 1 1 1 0 0 0 1 1 1 0 1 1 0 0 1 0 0 1 0 1 0 0 0 0 1 0 0 1 1 1 0 1 1 0 1 0 0 0 1 0 1 0 0 1 1 0 1 0 1 1 1 0 0 0 0 1 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 0 0 0 0 0 1 1 0 0 0 1 1 1 1 0 0 0 0 1 0 0 1 1 0 0 1 1 0 1 0 0 0 0 0 0 0 0 1 1 0 1 1 1 1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 0 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 1 0 1 0 1 1 1 0 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 0 1 1 1 1 1 0 1 1 0 1 0 1 1 1 0 1 0 0 1 1 1 0 1 0 1 1 0 0 0 1 0 1 1 1 0 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 0 1 1 0 0 1 1];
end
% ******** Sample the pattern based on the bit stream ********************
output_pattern = (output_pattern - 0.5)*2;
% Now we have the outptut bit pattern for a single PRBS.
% Construct the output signal.
patt = [];
for i = 1:length(output_pattern)
patt = [patt, output_pattern(i)*ones(1,samples_per_bit)];
end
pattern = [];
for i = 1:num_repeats
pattern = [pattern, patt];
end
end