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