1 | warning off; |
---|
2 | |
---|
3 | fixScopes; |
---|
4 | |
---|
5 | %Int filter options |
---|
6 | txfilt_firpm = firpm(31, [0 .75*.25 1.25*.25 1], [1 1 0 0], [1 .2]); |
---|
7 | txfilt_firpm = 0.95*txfilt_firpm./(max(txfilt_firpm)); |
---|
8 | txfilt_intfilt = [0 intfilt(4,4,.8)]; |
---|
9 | |
---|
10 | set(0, 'DefaultLineLineWidth', 1.5); |
---|
11 | |
---|
12 | %Compile-time maximum values; used to set precision of control logic values |
---|
13 | max_OFDM_symbols = 511;%2047; |
---|
14 | max_num_subcarriers = 64; |
---|
15 | max_CP_length = 16; |
---|
16 | max_num_baseRateSymbols = 31; |
---|
17 | max_num_trainingSymbols = 15; |
---|
18 | max_numBytes = 16384; |
---|
19 | |
---|
20 | %Hard-coded OFDM parameters for now; these might be dynamic some day |
---|
21 | numSubcarriers = 64; |
---|
22 | CPLength = 16; |
---|
23 | |
---|
24 | %Set the transceiver mode - SISO and Alamouti must not both be 1! |
---|
25 | tx_SISO_Mode = 0; |
---|
26 | tx_Alamouti_Mode = 1; |
---|
27 | |
---|
28 | %Cyclic Redundancy Check parameters |
---|
29 | CRCPolynomial32 = hex2dec('04c11db7'); %CRC-32 |
---|
30 | CRCPolynomial16 = hex2dec('1021'); %CRC-CCIT |
---|
31 | CRC_Table32 = CRC_table_gen(CRCPolynomial32, 32); |
---|
32 | CRC_Table16 = CRC_table_gen(CRCPolynomial16, 16); |
---|
33 | |
---|
34 | %Define the preamble which is pre-pended to each packet |
---|
35 | %These long and short symbols are borrowed from the 802.11a PHY standard |
---|
36 | shortSymbol_freq = [0 0 0 0 0 0 0 0 1+i 0 0 0 -1+i 0 0 0 -1-i 0 0 0 1-i 0 0 0 -1-i 0 0 0 1-i 0 0 0 0 0 0 0 1-i 0 0 0 -1-i 0 0 0 1-i 0 0 0 -1-i 0 0 0 -1+i 0 0 0 1+i 0 0 0 0 0 0 0].'; |
---|
37 | shortSymbol_time = ifft(fftshift(shortSymbol_freq)); |
---|
38 | shortSymbol_time = shortSymbol_time(1:16).'; |
---|
39 | |
---|
40 | longSymbol_freq_bot = [0 0 0 0 0 0 1 1 -1 -1 1 1 -1 1 -1 1 1 1 1 1 1 -1 -1 1 1 -1 1 -1 1 1 1 1]'; |
---|
41 | longSymbol_freq_top = [1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 -1 1 1 1 1 0 0 0 0 0]'; |
---|
42 | longSymbol_freq = [longSymbol_freq_bot ; 0 ; longSymbol_freq_top]; |
---|
43 | longSymbol_time = ifft(fftshift(longSymbol_freq)).'; |
---|
44 | |
---|
45 | %Concatenate 10 short symbols together |
---|
46 | %shortsyms_10 = linspace(0,0.4-2^-13,160); |
---|
47 | shortsyms_10 = repmat(shortSymbol_time,1,10); |
---|
48 | |
---|
49 | %Concatenate and cyclicly extend two long symbols |
---|
50 | %longsyms_2 = [longSymbol_time(33:64) repmat(longSymbol_time,1,2)]; |
---|
51 | %longSymbol_time = linspace(-1/6, 1/6, 64); |
---|
52 | %longsyms_2 = [repmat(longSymbol_time,1,2) longSymbol_time(1:32)];%complex(linspace(-1,0.98,160), linspace(0.98,-1,160));% |
---|
53 | %longsyms_2 = [longSymbol_time(33:64) repmat(longSymbol_time,1,2)];%complex(linspace(-1,0.98,160), linspace(0.98,-1,160));% |
---|
54 | longsyms_2 = [longSymbol_time(49:64) repmat(longSymbol_time,1,2) longSymbol_time(1:16)]; |
---|
55 | %longsyms_2 = linspace(0.6,1-2^-13,160);%0.5*ones(1,160);% |
---|
56 | |
---|
57 | %Scale the resulting time-domain preamble to fit [-1,1] |
---|
58 | preamble_scale = 6; |
---|
59 | preamble = preamble_scale*[shortsyms_10 longsyms_2]; |
---|
60 | preamble_I = real(preamble); |
---|
61 | preamble_Q = imag(preamble); |
---|
62 | |
---|
63 | %The preamble stored in memory is slightly different- it contains cyclic extensions of each half (STS/LTS) |
---|
64 | % to make addressing easier for two antennas sending cyclicaly shifted preambles |
---|
65 | %The preamble consists of 320 actual samples: [10xSTS] [2.5xLTS] |
---|
66 | % Each half is padded with 8 samples before/after when stored in memory |
---|
67 | preamble_ext = preamble_scale*[... |
---|
68 | shortSymbol_time(end-7:end) repmat(shortSymbol_time,1,10) shortSymbol_time(1:8) ... |
---|
69 | longSymbol_time(41:48) longSymbol_time(49:64) repmat(longSymbol_time,1,2) longSymbol_time(1:16) longSymbol_time(17:24)]; |
---|
70 | |
---|
71 | preamble_I_ROM = round(2^13*real(preamble_ext)); |
---|
72 | ii = find(preamble_I_ROM < 0); |
---|
73 | preamble_I_ROM(ii) = 2^16 + preamble_I_ROM(ii); |
---|
74 | |
---|
75 | preamble_Q_ROM = round(2^13*imag(preamble_ext)); |
---|
76 | ii = find(preamble_Q_ROM < 0); |
---|
77 | preamble_Q_ROM(ii) = 2^16 + preamble_Q_ROM(ii); |
---|
78 | |
---|
79 | preamble_ROM = preamble_I_ROM + preamble_Q_ROM*2^16; |
---|
80 | |
---|
81 | %Configure the pilot tone registers |
---|
82 | %pilot_indicies = 7 + ( (64-7) * 2^8) + (21 * 2^16) + ( (64-21) * 2^24); |
---|
83 | pilot_indicies = 7 + ( (64-21) * 2^8) + ( (64-7) * 2^16) + (21 * 2^24); |
---|
84 | |
---|
85 | %Values from hardware (~.7, like QPSK, to avoid saturation) |
---|
86 | pilotValues = hex2dec('A57D') + (2^16 * hex2dec('5A82')); |
---|
87 | |
---|
88 | %Actual BPSK (+/- 1) |
---|
89 | %pilotValues = hex2dec('8000') + (2^16 * hex2dec('7FFF')); |
---|
90 | |
---|
91 | %Training sequence, borrowed from 802.11a |
---|
92 | |
---|
93 | %12 empty (DC + 11 HF) |
---|
94 | %train = [0 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 1 1 -1 1 1 1 1 1 -1 -1 1 1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 1 -1 1 1 1 -1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 1 1 1 -1 -1 -1 -1 -1 -1]; |
---|
95 | |
---|
96 | %10 empty (DC + 9 HF) |
---|
97 | train = [0 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 1 1 -1 1 1 1 1 1 -1 -1 1 1 -1 -1 1 0 0 0 0 0 0 0 0 0 -1 1 -1 1 1 1 -1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 1 1 1 -1 -1 -1 -1 -1 -1]; |
---|
98 | |
---|
99 | %Match the training sequence to the pilot tone signs |
---|
100 | train(8) = 1; |
---|
101 | train(22) = -1; |
---|
102 | train(44) = 1; |
---|
103 | train(58) = 1; |
---|
104 | |
---|
105 | %train=zeros(1,length(train)); |
---|
106 | |
---|
107 | %MIMO training; use the same sequence for both antennas |
---|
108 | train = [train train]; |
---|
109 | |
---|
110 | %Maximum number of bytes per packet |
---|
111 | %RAM_init_size = 4096; |
---|
112 | BER_RAM_init_size = 2048; %only support BER tests up to 2048 bytes/packet |
---|
113 | RAM_init_size = max_numBytes; |
---|
114 | |
---|
115 | %Standard 48-active subcarriers |
---|
116 | subcarrier_masks = ones(1,numSubcarriers); |
---|
117 | subcarrier_masks(1)=0; %DC tone at Xk=0 |
---|
118 | subcarrier_masks(8)=0; %pilot tone at Xk=7 |
---|
119 | subcarrier_masks(22)=0; %pilot tone at Xk=21 |
---|
120 | subcarrier_masks(44)=0; %pilot tone at Xk=43 |
---|
121 | subcarrier_masks(58)=0; %pilot tone at Xk=57 |
---|
122 | subcarrier_masks([28:32])=0; %zeros at higher frequencies |
---|
123 | subcarrier_masks([33:38])=0; %zeros at higher frequencies |
---|
124 | |
---|
125 | subcarrier_masks = ones(1,numSubcarriers); |
---|
126 | subcarrier_masks(1)=0; %DC tone at Xk=0 |
---|
127 | subcarrier_masks(2)=0; %DC tone at Xk=0 |
---|
128 | subcarrier_masks(63)=0; %DC tone at Xk=0 |
---|
129 | subcarrier_masks(8)=0; %pilot tone at Xk=7 |
---|
130 | subcarrier_masks(22)=0; %pilot tone at Xk=21 |
---|
131 | subcarrier_masks(44)=0; %pilot tone at Xk=43 |
---|
132 | subcarrier_masks(58)=0; %pilot tone at Xk=57 |
---|
133 | subcarrier_masks([29:32])=0; %zeros at higher frequencies |
---|
134 | subcarrier_masks([33:37])=0; %zeros at higher frequencies |
---|
135 | |
---|
136 | %Choose the modulation schemes to use for the base-rate and full-rate symbols |
---|
137 | %Valid values are [0,2,4,6,8], meaning 0, QPSK, 16/64/256 QAM symbols per subcarrier |
---|
138 | %QPSK/QPSK |
---|
139 | mod_baseRate = 2; |
---|
140 | modMask_antA = 2; |
---|
141 | modMask_antB = 2; %AntB is ignored in SISO mode, so it's safe to leave this field non-zero all the time |
---|
142 | |
---|
143 | %BPSK/16-QAM |
---|
144 | %mod_baseRate = 1; |
---|
145 | %modMask_antA = 4; |
---|
146 | %modMask_antB = 4; %AntB is ignored in SISO mode, so it's safe to leave this field non-zero all the time |
---|
147 | |
---|
148 | modulation_antA = modMask_antA*subcarrier_masks; |
---|
149 | modulation_antB = modMask_antB*subcarrier_masks; |
---|
150 | |
---|
151 | modulation_antA = 15*subcarrier_masks; |
---|
152 | modulation_antB = 15*subcarrier_masks; |
---|
153 | |
---|
154 | modulation_baseRate = mod_baseRate*subcarrier_masks; |
---|
155 | |
---|
156 | %Final vector must be: [AntennaA AntennaB BaseRate] |
---|
157 | %AntA = AntB = BaseRate = 48 non-zero subcarriers -> 12 bytes/OFDM symbol with QPSK |
---|
158 | subcarrier_QAM_Values = [modulation_antA modulation_antB modulation_baseRate]; |
---|
159 | numBytes_BaseRateOFDMSymbol = sum(modulation_baseRate)/8; |
---|
160 | |
---|
161 | numBytes_AFullRateOFDMSymbol = sum(bitand(modMask_antA,modulation_antA))/8; |
---|
162 | numBytes_BFullRateOFDMSymbol = sum(bitand(modMask_antB,modulation_antB))/8; |
---|
163 | |
---|
164 | %numBytes_FullRateOFDMSymbol = sum(modulation_antA)/8; |
---|
165 | numBytes_FullRateOFDMSymbol = numBytes_AFullRateOFDMSymbol; |
---|
166 | if(tx_SISO_Mode == 1) |
---|
167 | numBytes_FullRateOFDMSymbol = numBytes_AFullRateOFDMSymbol; |
---|
168 | else |
---|
169 | numBytes_FullRateOFDMSymbol = (numBytes_AFullRateOFDMSymbol + numBytes_BFullRateOFDMSymbol)/2; |
---|
170 | end |
---|
171 | |
---|
172 | %Example of how modulation data gets formatted as bytes in the packet's header; useed for simulation |
---|
173 | subcarrier_QAM_Values_bytes = reshape([modulation_antA modulation_antB], 2, numSubcarriers); |
---|
174 | subcarrier_QAM_Values_bytes = sum(subcarrier_QAM_Values_bytes .* [ones(1,64).*2^4; ones(1,64)]); |
---|
175 | |
---|
176 | %Setup the packet length for simulation |
---|
177 | numHeaderBytes = 24; |
---|
178 | numTrainingSymbols = 2; |
---|
179 | numBaseRateSymbols = ceil(numHeaderBytes / numBytes_BaseRateOFDMSymbol); |
---|
180 | |
---|
181 | %Setup the packet contents |
---|
182 | rand('state',1); %Get the same packet each time for BER testing |
---|
183 | |
---|
184 | %Calculate the number of bytes in the packet, based on the number of OFDM symbols specified above |
---|
185 | % In hardware, the user code will provide this value per-packet |
---|
186 | pkt_numPayloadBytes = (1412);%X OFDM symbols worth of payload, plus header and checksum |
---|
187 | |
---|
188 | %Calculate the number of full rate OFDM symbols |
---|
189 | % This number is actually the number of FFT frames which are calculated |
---|
190 | % In SISO mode, it is double the number of actual OFDM symbols transmitted |
---|
191 | % As a result, this value must be even, in any mode |
---|
192 | if(tx_SISO_Mode == 1 || tx_Alamouti_Mode == 1) |
---|
193 | numFullRateSymbols = 2*ceil((4+pkt_numPayloadBytes)/numBytes_FullRateOFDMSymbol);%124; |
---|
194 | else |
---|
195 | numFullRateSymbols = ceil((4+pkt_numPayloadBytes)/numBytes_FullRateOFDMSymbol);%124; |
---|
196 | end |
---|
197 | numFullRateSymbols = numFullRateSymbols + mod(numFullRateSymbols, 2); |
---|
198 | |
---|
199 | %Define the indicies (zero-indexed, like C) of some important bytes in the header |
---|
200 | byteIndex_numPayloadBytes = [3 2]; |
---|
201 | byteIndex_simpleDynModMasks = 0; |
---|
202 | |
---|
203 | %Total number of bytes to process (header + payload + 32-bit payload checksum) |
---|
204 | if(pkt_numPayloadBytes > 0) |
---|
205 | pkt_totalBytes = numHeaderBytes + pkt_numPayloadBytes + 4; |
---|
206 | else |
---|
207 | pkt_totalBytes = numHeaderBytes; |
---|
208 | end |
---|
209 | |
---|
210 | %Construct the packet header |
---|
211 | % The PHY only cares about 3 bytess (length_lsb, length_msb and modMasks) |
---|
212 | % In hardware, the MAC will use the rest of the header for MAC-ish stuff |
---|
213 | packetHeader = [... |
---|
214 | (modMask_antA + modMask_antB*2^4) ... %byte 0 mod masks |
---|
215 | 3 ... %byte 1 code rate |
---|
216 | floor((pkt_totalBytes/256))... %byte 2 pkt size |
---|
217 | mod(pkt_totalBytes,256)... %byte 3 pkt size |
---|
218 | 3 ... %src addr msb |
---|
219 | 1 ... %src addr lsb |
---|
220 | 2 ... %dst addr msb |
---|
221 | 0 ... %dst addr lsb |
---|
222 | 0 ... %relay addr msb |
---|
223 | 0 ... %relay addr lsb |
---|
224 | 2 ... %byte 10 pkt type |
---|
225 | zeros(1,13) ... |
---|
226 | ]; |
---|
227 | |
---|
228 | %Assemble the rest of the packet, using some filler bytes for the full-rate payload |
---|
229 | %packet = [packetHeader 1:(pkt_numPayloadBytes)]; |
---|
230 | packet = [packetHeader zeros(1,pkt_numPayloadBytes)]; |
---|
231 | |
---|
232 | %Make sure each element is really just one byte |
---|
233 | packet = mod(packet,256); |
---|
234 | |
---|
235 | %Add the 32-bit checksum to the end of the payload (sim-only) |
---|
236 | % In hardware, the checksum automatically over-writes the last four bytes of the payload |
---|
237 | packet = [packet calcCRC32(packet)]; |
---|
238 | |
---|
239 | %Zero-pad the vector to fill a multiple of 8 bytes |
---|
240 | packet = [packet zeros(1,8-mod(length(packet),8))]; |
---|
241 | |
---|
242 | %Endian-flip at 64-bit boundaries to mimic the PLB packet buffer interface in hardware |
---|
243 | % [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...] becomes [8 7 6 5 4 3 2 1 16 15 14 13 12 11 10 9 ...] |
---|
244 | packet = reshape(flipud(reshape(packet,8,length(packet)/8)),1,length(packet)); |
---|
245 | |
---|
246 | %This value allows the simulated transmitter to start new packets |
---|
247 | % leaving a few hundred cycles of idle time between each packet |
---|
248 | simOnly_numSamples = length(preamble)+( (numSubcarriers+CPLength)*(numTrainingSymbols + numBaseRateSymbols + numFullRateSymbols/2) ); |
---|
249 | simOnly_simLength = 1000 + 2 * (4 * (simOnly_numSamples + 500)); |
---|
250 | |
---|
251 | %Default value for the Tx symbol counts register |
---|
252 | txReg_symbolCounts = (2^8 *numBaseRateSymbols ) + numTrainingSymbols; |
---|
253 | |
---|
254 | %Parameters to initialize the packet buffers |
---|
255 | % The default packet is loaded at configuration, allowing real-time BER tests |
---|
256 | % This packet will be overwritten in hardware when user-code loads packets |
---|
257 | packet_length = length(packet)-1; |
---|
258 | RAM_init_values = [packet, zeros(1,RAM_init_size-1-packet_length)]; |
---|
259 | |
---|
260 | BER_RAM_init_values = RAM_init_values(1:BER_RAM_init_size); |
---|
261 | BER_RAM_init_values = reshape(flipud(reshape(BER_RAM_init_values, 8, BER_RAM_init_size/8)), 1, BER_RAM_init_size); |
---|
262 | |
---|
263 | %LPF coefficients for the interpolation/decimation filters |
---|
264 | lpf_h = [1.296923e-003 1.408510e-003 1.257711e-003 3.226648e-005 -2.519384e-003 -6.198394e-003 -1.022530e-002 -1.333438e-002 -1.410672e-002 -1.149196e-002 -5.345330e-003 3.224983e-003 1.190534e-002 1.770326e-002 1.787723e-002 1.101327e-002 -2.108767e-003 -1.821814e-002 -3.204219e-002 -3.756010e-002 -2.972681e-002 -6.174810e-003 3.165421e-002 7.836874e-002 1.256233e-001 1.640445e-001 1.855768e-001 1.855768e-001 1.640445e-001 1.256233e-001 7.836874e-002 3.165421e-002 -6.174810e-003 -2.972681e-002 -3.756010e-002 -3.204219e-002 -1.821814e-002 -2.108767e-003 1.101327e-002 1.787723e-002 1.770326e-002 1.190534e-002 3.224983e-003 -5.345330e-003 -1.149196e-002 -1.410672e-002 -1.333438e-002 -1.022530e-002 -6.198394e-003 -2.519384e-003 3.226648e-005 1.257711e-003 1.408510e-003 1.296923e-003]; |
---|
265 | lpf_h = firpm(53,[0 .18 .21 1],[1 1 0 0]); |
---|
266 | %B = RCOSFIR(R, N_T, RATE, T) |
---|
267 | lpf_h_tx = rcosfir(.25, 5, 5, 1, 'sqrt'); |
---|
268 | %lpf_h_rx = firpm(53,[0 .5 .55 1],[1 1 0 0]); |
---|
269 | lpf_h_rx = rcosfir(.25, 5, 5, 1, 'sqrt'); |
---|
270 | |
---|
271 | %LSFR parameters, used for random payload mode |
---|
272 | txLSFR_numBits = 13; |
---|
273 | txLSFR_polynomials = {'21' '35' '0B' '1D' '35' '0B' '3D' '2B'}; |
---|
274 | txLSFR_initValues = {'3F' '1B' '03' '35' '17' '0A' '74' '39'}; |
---|
275 | |
---|
276 | %Precision for the constants which store the modulation values |
---|
277 | modConstellation_prec = 8; |
---|
278 | modConstellation_bp = 7; |
---|
279 | |
---|
280 | %Defintion of the various constellations |
---|
281 | %Gray coded bit-symbol mappings |
---|
282 | %Borrowed from the IEEE 802.16 specification |
---|
283 | % IEEE Std 802.16-2004 Tables 153-155 (pg. 329) |
---|
284 | |
---|
285 | %QPSK constellation |
---|
286 | %2 bits per symbol, 1 bit per I/Q |
---|
287 | % I = MSB, Q = LSB |
---|
288 | %modConstellation_qpsk = [1 -1]; |
---|
289 | modConstellation_qpsk = [1 -1]./sqrt(2); |
---|
290 | %modConstellation_qpsk = (1-2^-modConstellation_bp).*modConstellation_qpsk./(max(abs(modConstellation_qpsk))); |
---|
291 | |
---|
292 | %16-QAM constellation |
---|
293 | %4 bits per symbol, 2 bits per I/Q |
---|
294 | % I = 2MSB, Q = 2LSB |
---|
295 | modConstellation_qam16 = .75*[1 3 -1 -3]./3; |
---|
296 | %modConstellation_qam16 = [1 3 -1 -3]; |
---|
297 | %modConstellation_qam16 = [1 3 -1 -3]./sqrt(10); |
---|
298 | %modConstellation_qam16 = (1-2^-modConstellation_bp).*modConstellation_qam16./(max(abs(modConstellation_qam16))); |
---|
299 | |
---|
300 | %FIXME: 64/256QAM constellations exceed +/-1, which won't fit in the current data types! |
---|
301 | %64-QAM constellation |
---|
302 | %6 bits per symbol, 3 bits per I/Q |
---|
303 | % I = 3MSB, Q = 3LSB |
---|
304 | modConstellation_qam64 = 0.875*[3 1 5 7 -3 -1 -5 -7]./7; |
---|
305 | %modConstellation_qam64 = [3 1 5 7 -3 -1 -5 -7]; |
---|
306 | %modConstellation_qam64 = [3 1 5 7 -3 -1 -5 -7]./(7*3/sqrt(10));%sqrt(42); |
---|
307 | %modConstellation_qam64 = (1-2^-modConstellation_bp).*modConstellation_qam64./(max(abs(modConstellation_qam64))); |
---|
308 | |
---|
309 | %256-QAM constellation |
---|
310 | %8 bits per symbol, 4 bits per I/Q |
---|
311 | % I = 4MSB, Q = 4LSB |
---|
312 | modConstellation_qam256 = 0.9375*[3 1 5 7 11 9 13 15 -3 -1 -5 -7 -11 -9 -13 -15]./15; |
---|
313 | %modConstellation_qam256 = [3 1 5 7 11 9 13 15 -3 -1 -5 -7 -11 -9 -13 -15]; |
---|
314 | %1/(modnorm(qammod(0:255,256),'avpow',1))^2 |
---|
315 | %modConstellation_qam256 = [3 1 5 7 11 9 13 15 -3 -1 -5 -7 -11 -9 -13 -15]./sqrt(170); |
---|
316 | %modConstellation_qam256 = (1-2^-modConstellation_bp).*modConstellation_qam256./(max(abs(modConstellation_qam256))); |
---|
317 | |
---|
318 | antB_preambleShift = 3; |
---|
319 | |
---|
320 | %Fill in the TxControlBits register; each bit has a different purpose |
---|
321 | %0x1: 1 SISO Mode |
---|
322 | %0x2: 2 Alamouti Mode |
---|
323 | %0x4: 4 Disable AntB preamble |
---|
324 | %0x8: 8 Enable Pilot Scrambling (2^3) |
---|
325 | %0xF0: Preamble shift |
---|
326 | %0x100: 256 Random payload |
---|
327 | %0x200: 512 Swap Tx antennas |
---|
328 | %0x400: 1024 Start Tx using software write |
---|
329 | %0x800: 2048 Enable ExtTxEn port |
---|
330 | %0x1000: Always use preSpin (instead of requring auto responder) |
---|
331 | %0x2000: Capture random payloads |
---|
332 | %0x4000: Enable AutoTwoTx |
---|
333 | %0x8000: Enable TxRunning_d0 output |
---|
334 | %0x10000: Enable TxRunning_d1 output |
---|
335 | %0x20000: Tx int filt sel (0=intfilt, 1=firpm) |
---|
336 | %0x3F0_0000: Tx post IFFT cyclic shift (0 = use only cyclic prefix) |
---|
337 | tx_controlBits = (antB_preambleShift * 2^4) + (2^1 * tx_Alamouti_Mode) + ... |
---|
338 | (2^0 * tx_SISO_Mode) + 4*0 + 8*1 + 0*256 + 512*0 + 1024*0 + ... |
---|
339 | 0*hex2dec('1000') + 0*hex2dec('2000') + 0*hex2dec('4000') + ... |
---|
340 | 1*hex2dec('8000') + 1*hex2dec('10000') + hex2dec('20000') + ... |
---|
341 | 16*hex2dec('100000'); |
---|
342 | |
---|
343 | %0x0000_00FF: External TxEn delay |
---|
344 | %0x0000_0F00: Extra Tx/rx-Tx delay |
---|
345 | %0x000F_F000: TxRunning_d output delay |
---|
346 | tx_delays = (50*2^0) + (0*2^8) + (30*2^12); |
---|
347 | |
---|
348 | %tx_scaling = (2480) + (9792 * 2^16); |
---|
349 | %tx_scaling = (4365) + (14267 * 2^16); |
---|
350 | tx_scaling = (3072) + (12288 * 2^16); |
---|
351 | |
---|
352 | %12-bit value: bits[5:0]=TxFFTScaling, bits[11:6]=RxFFTScaling |
---|
353 | %TxRx_FFTScaling = bin2dec('010111') + (bin2dec('000101') * 2^6); |
---|
354 | % TxRx_FFTScaling = ... |
---|
355 | % (3 * 2^0) + ... %Tx stage3 |
---|
356 | % (1 * 2^2) + ... %Tx stage2 |
---|
357 | % (1 * 2^4) + ... %Tx stage1 |
---|
358 | % (1 * 2^6) + ... %Rx stage3 |
---|
359 | % (1 * 2^8) + ... %Rx stage2 |
---|
360 | % (0 * 2^10); %Rx stage1 |
---|
361 | |
---|
362 | TxRx_FFTScaling = ... |
---|
363 | (3 * 2^0) + ... %Tx stage3 |
---|
364 | (2 * 2^2) + ... %Tx stage2 |
---|
365 | (1 * 2^4) + ... %Tx stage1 |
---|
366 | (1 * 2^6) + ... %Rx stage3 |
---|
367 | (1 * 2^8) + ... %Rx stage2 |
---|
368 | (0 * 2^10); %Rx stage1 |
---|
369 | |
---|
370 | %DataScrambling_Seq = zeros(1,32); |
---|
371 | TxDataScrambling_Seq = [40 198 78 63 82 173 102 245 48 111 172 115 147 230 216 93 72 65 62 2 205 242 122 90 128 83 105 97 73 10 5 252]; |
---|
372 | RxDataScrambling_Seq = [40 198 78 63 82 173 102 245 48 111 172 115 147 230 216 93 72 65 62 2 205 242 122 90 128 83 105 97 73 10 5 252]; |
---|
373 | |
---|
374 | |
---|
375 | %AutoReply params |
---|
376 | ActionID_Disabled = 0; |
---|
377 | ActionID_SetFlagA = 62; |
---|
378 | ActionID_SetFlagB = 61; |
---|
379 | ActionID_AFTransmit = 31; |
---|
380 | |
---|
381 | PHY_AUTORESPONSE_MATCH_LENGTH_OFFSET = 5; |
---|
382 | PHY_AUTORESPONSE_MATCH_VALUE_OFFSET = 8; |
---|
383 | |
---|
384 | PHY_AUTORESPONSE_REQ_MATCH0 = hex2dec('001'); |
---|
385 | PHY_AUTORESPONSE_REQ_MATCH1 = hex2dec('002'); |
---|
386 | PHY_AUTORESPONSE_REQ_MATCH2 = hex2dec('004'); |
---|
387 | PHY_AUTORESPONSE_REQ_MATCH3 = hex2dec('008'); |
---|
388 | PHY_AUTORESPONSE_REQ_MATCH4 = hex2dec('010'); |
---|
389 | PHY_AUTORESPONSE_REQ_MATCH5 = hex2dec('020'); |
---|
390 | PHY_AUTORESPONSE_REQ_MATCH6 = hex2dec('040'); |
---|
391 | PHY_AUTORESPONSE_REQ_MATCH7 = hex2dec('080'); |
---|
392 | |
---|
393 | PHY_AUTORESPONSE_REQ_GOODHDR = hex2dec('800'); |
---|
394 | PHY_AUTORESPONSE_REQ_BADPKT = hex2dec('1000'); |
---|
395 | PHY_AUTORESPONSE_REQ_GOODPKT = hex2dec('2000'); |
---|
396 | PHY_AUTORESPONSE_REQ_FLAGA = hex2dec('4000'); |
---|
397 | PHY_AUTORESPONSE_REQ_FLAGB = hex2dec('8000'); |
---|
398 | |
---|
399 | PHY_AUTORESPONSE_ACT_HDRTRANS_EN = hex2dec('10000'); |
---|
400 | PHY_AUTORESPONSE_ACT_PRECFO_EN = hex2dec('20000'); |
---|
401 | PHY_AUTORESPONSE_ACT_ID_OFFSET = 18; |
---|
402 | PHY_AUTORESPONSE_ACT_PARAM_OFFSET = 24; |
---|
403 | |
---|
404 | %14=goodPkt, 18:24=actionID |
---|
405 | %Action0_Config = (PHY_AUTORESPONSE_REQ_MATCH0 + PHY_AUTORESPONSE_REQ_MATCH1 + PHY_AUTORESPONSE_REQ_GOODHDR + PHY_AUTORESPONSE_REQ_GOODPKT) + (2 * 2^PHY_AUTORESPONSE_ACT_ID_OFFSET) + (100 * 2^PHY_AUTORESPONSE_ACT_PARAM_OFFSET); |
---|
406 | %Action0_Config = 31*2^18 + 100*2^24; %AF testing |
---|
407 | %Action0_Config = 2^14 + ActionID_SetFlagA*2^18 + 100*2^24; %Flag A testing |
---|
408 | Action0_Config = 0; %Disabled |
---|
409 | %Match0_Config = 0;%Disabled |
---|
410 | Match0_Config = 0;%10 + (1 * 2^6) + (packetHeader(11) * 2^8); |
---|
411 | |
---|
412 | |
---|
413 | %Testing: Config for Node 0: |
---|
414 | Action0_Config = 0* 31*2^18 + 0*2^24 + PHY_AUTORESPONSE_REQ_GOODHDR + PHY_AUTORESPONSE_REQ_GOODPKT + PHY_AUTORESPONSE_REQ_FLAGA;%AF |
---|
415 | Action1_Config = 0* 62*2^18 + PHY_AUTORESPONSE_REQ_GOODHDR + PHY_AUTORESPONSE_REQ_GOODPKT;%Set FlagA |
---|
416 | Action2_Config = 0;%hex2dec('41005'); |
---|
417 | Action3_Config = 0; |
---|
418 | Action4_Config = 0; |
---|
419 | Action5_Config = 0; |
---|
420 | |
---|
421 | Match0_Config = 0;%hex2dec('246'); %Addressed to 0x0200 |
---|
422 | Match1_Config = 0;%hex2dec('12A'); %pktType 1 (DATA) |
---|
423 | Match2_Config = 0;%hex2dec('22A'); %pktType 2 (NACK) |
---|
424 | Match3_Config = 0; |
---|
425 | Match4_Config = 0; |
---|
426 | Match5_Config = 0; |
---|
427 | Match6_Config = 0; |
---|
428 | Match7_Config = 0; |
---|
429 | |
---|
430 | %Testing: Config for Node 1: |
---|
431 | %Action0_Config = hex2dec('0'); |
---|
432 | %Action1_Config = hex2dec('e5003'); %MATCH0|MATCH1|GOODPKT -> Send from 3 |
---|
433 | %Action2_Config = hex2dec('41005'); %MATCH0|MATCH2|? -> Send from 1 |
---|
434 | %Action3_Config = 0; |
---|
435 | %Action4_Config = 0; |
---|
436 | %Action5_Config = 0; |
---|
437 | |
---|
438 | %Match0_Config = hex2dec('10346'); %Addressed to 0x0301 |
---|
439 | %Match1_Config = hex2dec('12A'); %pktType 1 (DATA) |
---|
440 | %Match2_Config = hex2dec('22A'); %pktType 2 (NACK) |
---|
441 | %Match3_Config = 0; |
---|
442 | %Match4_Config = 0; |
---|
443 | %Match5_Config = 0; |
---|
444 | |
---|
445 | |
---|