source: ResearchApps/PHY/MIMO_OFDM/SG10/ofdm_rx_supermimo_init.m

Last change on this file was 1717, checked in by murphpo, 12 years ago

creating SG10 subdirectory to separate Sysgen 10 model (for v1 kits); the files in MIMO_OFDM will be Sysgen 13+ from now on

File size: 8.7 KB
Line 
1%Make sure the Tx init has already been loaded
2ofdm_tx_supermimo_init;
3
4%Do not use 16! Breaks Alamouti Rx timing
5%Symbol_Timing_Offset = 15; %Use for no cyclic shift offset w/ antB preamble enabled, countLoad=229
6
7%Symbol_Timing_Offset = 12; %Use for no cyclic shift offset w/ SISO, antB channel disabled, countLoad=229
8Symbol_Timing_Offset = 10;
9
10PktDet_Delay = 58+32 + ... %UFix7_0 packet detect delay
11    Symbol_Timing_Offset*2^7 + ... %UFix6_0 FFT window offset
12    0*2^16 + ... %UFix5_0 CFO calc delay, in samples
13    (117* 2^24); %UFix8_8 threshold
14%    (round(0.15 * 2^8)* 2^24); %UFix8_8 threshold
15
16pktByteNums =   numHeaderBytes + ...
17                byteIndex_numPayloadBytes(1)*2^8 + ...
18                byteIndex_numPayloadBytes(2)*2^16 + ...
19                byteIndex_simpleDynModMasks * 2^24;
20
21rx_SISO_Mode = tx_SISO_Mode;
22
23pktTiming_controlCounter_bits = 16;
24
25%Structure of packet following detection
26%Short symbols
27pktTiming_ss_num = 6;
28pktTiming_ss_length = length(shortSymbol_time);
29%Long symbols
30pktTiming_ls_num = 2;
31pktTiming_ls_length = length(longSymbol_time);
32%Long symbol cyclic prefix
33pktTiming_lscp_length = 32;
34
35pktTiming_count_ssStart = 0;
36pktTiming_count_lscpStart = (pktTiming_count_ssStart + pktTiming_ss_num*pktTiming_ss_length);
37pktTiming_count_lsStart = (pktTiming_count_lscpStart + pktTiming_lscp_length);
38pktTiming_count_payloadStart = pktTiming_count_lsStart + pktTiming_ls_num*pktTiming_ls_length;
39
40%Packet detection threshold
41pkt_crossCorr_thresh = 0.7;
42pkt_energy_thresh = 0;
43
44rxReg_pktDetCorr = ...
45    2^00 * (floor(0.7*128)) + ...   %min correlation/power ratio (UFix8_7)
46    2^08 * (300) + ...              %min power
47    0;
48
49%In alamouti mode, the Rx syncs to the earlier preamble
50%LongCorrCounterLoad = 229;
51%LongCorrCounterLoad = 232;
52LongCorrCounterLoad = 253-8;%234;
53
54Rx_PktDet_LongCorrThresholds = 8000;
55
56Rx_PktDet_LongCorr_Params = LongCorrCounterLoad + 0*2^8 + 0*2^16 + 255*2^24;
57
58%Interrupt control register has 8 bits:
59%0: Rx Pkt Interrupts Reset
60%1: Rx Header Interrupts Reset
61%2: Tx Done Interrupt Reset
62%3: Rx Good Pkt Interrupt Enable
63%4: Rx Bad Pkt Interrupt Enable
64%5: Rx Good Header Interrupt Enable
65%6: Rx Bad Header Interrupt Enable
66%7: Tx Done Interrupt Enable
67reg_InterruptControl = ...
68    0 + ...  %3 bits [RxPkt, RxHeader, TxDone] interrupt resets
69    0*15 * 2^3 + ... %4 bits[LSB:MSB]=[goodPkt, badPkt, goodHdr, badHdr] interrupt enables
70    0 * 2^7; %1 bit for TxDone enable
71
72%32-bit register holds both pkt buffer offsets (16LSB+8) and interrupt control (8LSB)
73reg_Interrupt_PktBuf_Control = ...
74    reg_InterruptControl + ...
75    1 * 2^16 + ... %6 bits for Tx pkt buff offset
76    0 * 2^24; %6 bits for Rx pkt buff offset
77
78minPilotChanMag = (0.01 * 2^12); %UFix12_12
79reg_PilotCalcParams = (4 * 2^16) + (minPilotChanMag);
80
81regRx_preCFOoptions = ...
82    0 * 2^0 + ... %Use coarse CFO estimate
83    1 * 2^1 + ... %Use pilot CFO estimate
84    0;
85
86regRx_pilotCalcCorrection = round(1.00115 * 2^31);
87regRx_coarseCalcCorrection = round((1.3e-3 - 1.2982e-3)*2^32);
88%Initialization values for the long correlator
89% The correlator only stores the signs of the values in a long trainin symbol
90% This code and the correlator block were designed by Dr. Chris Dick
91
92%Fix2_0 version of longSym
93longCorr_coef_nbits = 3;
94longCorr_coef_bp = 0;
95LTS = fliplr(longSymbol_time./max(abs(longSymbol_time)));
96
97%longCorr_coef_i = [-1*sign(real(fliplr(LTS))) 0];
98%longCorr_coef_q = [sign(imag(fliplr(LTS))) 0];
99
100longCorr_coef_i = [-4*real(LTS) 0];
101longCorr_coef_q = [4*imag(LTS) 0];
102ii = find(longCorr_coef_i < -3.5);
103longCorr_coef_i(ii) = -3;
104ii = find(longCorr_coef_q < -3.5);
105longCorr_coef_q(ii) = -3;
106
107%Shift the correlation pattern by 16 to allow the calculation
108% to finish in time to decide the beginning of the payload
109%L = [longSymbol_time(50:64) longSymbol_time(1:49)];
110L = [longSymbol_time];
111
112ccr = -1*sign(real(fliplr(L)));
113ccr = [ccr 0];
114ii = find(ccr==0);
115ccr(ii)=1;
116
117cci = 1*sign(fliplr(imag(L)));
118cci = [cci 0];
119ii=find(cci==0);
120cci(ii)=1;
121
122ii = find(ccr==-1);
123hr = zeros(1,length(ccr));
124hr(ii) = 1;
125
126ii = find(cci==-1);
127hi = zeros(1,length(cci));
128hi(ii) = 1;
129
130long_cor_acc_n_bits = 6;
131%long_cor_acc_n_bits = 4;
132Tr1 = 1/4;
133
134%Demodulator input precision
135symbol_unmap_bp= 15;
136symbol_unmap_nb= 16;
137
138RxReg_FixedPktLen = 0;%2^32 + 512;
139
140%Popluate the RxControlBits register
141% Each bit has a different function
142%0x1:   1: Reset BER
143%0x2:   2: Require long correlation for pkt detection
144%0x4:   4: Enable dynamic packet lengths
145%0x8:   8: Big sub-pkt buffer mode (16KB max pkt size)
146%0x10:  16: Enable SISO mode
147%0x20:  32: Require 2 long correlations for pkt detection
148%0x40:  64: Require short correlation or ext pkt detection
149%0x80:  128: Record channel estimates
150%0x100: 256: Record channel estimate magnitudes
151%0x200: 512: bypass CFO correction
152%0x400: 1024: Enable coarse CFO estimation
153%0x800: 2048: CFO debug output selection
154%0x1000:4096: Compensate for RF gain in RSSI input
155%0x4000:16384: Bypass division during EQ
156%0x8000:32768: Disable Rx PHY on Tx (not useful for simulation!)
157%0x1_0000:65536: Enable simple dynamic modulation
158%0x2_0000:131072: Enable switching diversity
159%0x4_0000:262144: Use antenna B in SISO mode
160%0x8_0000:524288: Enable Rx reset on bad header CRC
161%0x10_0000: 1048576: Enable Rx Alamouti mode
162%0x20_0000: 2097152: Enable flexBER mode
163%0x40_0000: 4194304: Ignore headers for BER
164%0x80_0000: 8388608: Per-packet BER reset
165%0x100_0000: 16777216: Force-enable radio RxEn
166%0x200_0000: 33554432: SaveAF waveform
167%0x400_0000: Reset autoResponse flagA
168%0x800_0000: Reset autoResponse flagB
169%0x2000_0000: 536870912: Enable channel magnitude masking (only useful in Alamouti mode)
170%0x8000_0000: 2147483648: Global Rx reset
171
172rx_controlBits = 1 * 2 ... %Long correlation
173         + 1 * 4 ... %Dyn pkt lengths
174         + 0 * 8 ... %1=big sub-pkt buffers
175         + 1 * 16 * rx_SISO_Mode ...
176         + 1 * 32 ... %2 long correlations
177         + 1 * 64 ... %short correlation
178         + 1 * 128 ... %record channel estimates
179         + 1 * 256 ... %record channel estimate mags
180         + 1 * 512 ... %bypass CFO%%%%%%%%%%%%
181         + 1 * 1024 ... %1=Enable coarse CFO estimation
182         + 1 * 4096 ... %Compensate for RFgain in RSSI input
183         + 0 * 16384 ... %1=Bypass EQ division
184         + 0 * 32768 ... %0=Don't disable Rx during Tx
185         + 1 * 65536 ... %1=Use simple dynamic modulation
186         + 0 * 131072 ... %1=Use switching diversity in SISO mode
187         + 0 * 262144 ... %1=force AntB in SISO mode
188         + 1 * 524288 ... %1=Reset Rx on bad header
189         + 1 * 1048576 * tx_Alamouti_Mode ...
190         + 0 * 2097152 ... %1=flex BER mode
191         + 1 * 33554432 ... %1=Save AF waveform
192         + 0 * 4194304 ... %1=ignore headers (and header-only packets) for BER calculation
193         + 0 * 8388608 ... %1=Per-packet BER reset
194         + 0 * 16777216 ... %Don't force RxEn in simulation (used in hardware though)
195         + 1 * 536870912 * tx_Alamouti_Mode ... %Enables chan mag checking/masking
196         + 0 * 2147483648; %Global Rx reset
197     
198     
199%Min chan est magnitudes (Two UFix16_15 values, re-interpreted as UFix16_0)
200regRx_chanEst_minMag = ((0.5)*2^15) + ((0.5 * 2^15)*2^16);
201
202%Pkt detector control register
203pktDet_controlBits = 0 * 2^0 ... %Pkt det master reset
204    + 0 * 2^1 ... %Ignore all pktDet events
205    + 0 * 2^2 ... %Clock divider for RSSI ADC
206    + 1 * 2^3 ... %Enable the CSMA IDLEFORDIFS output
207    + 1 * 2^4 ... %Pkt det mode (1=antA OR antB, 0=antA AND antB)
208    + 1 * 2^5 ... %Accept pkt det events on antA
209    + 1 * 2^6 ... %Accept pkt det events on antB
210    + 0 * 2^7 ... %Enable the external pkt det input
211    + 1 * 2^8 ... %Enable the RSSI/energy-threshold detector
212    + 1 * 2^9 ... %Enable the auto-correlation detector
213    + 0;
214
215%Post-equalization scaling
216%This value is used to scale the equalizer's output before demodulation
217%This is used to correct for any fixed gain/attenuation the full system has
218% The value shouldn't be channel or modulation dependent
219% It does depend on the number of training symbols (1/training)
220if(tx_SISO_Mode)
221    rxScaling = 2;
222else
223    rxScaling = 1;
224end
225
226%AF scaling; UFix18_12
227reg_AF_Tx_Scaling = 2944;%2 * 2^12;
228
229reg_AF_Tx_Blanking = (320+80) + ( (320+80+79)*2^16);
230
231% This scaling value resides in a UFix_32_0 register
232%  The value is split into two 16 bit values, then
233%   each is re-interpreted as a UFix_16_11
234rx_postEq_scaling = round(rxScaling*2^11) * (1 + 2^16);
235%mod((rxScaling*2^11),2^16) + (2^16 * mod((rxScaling*2^11),2^16));
236
237%Load Chipscope capture data
238AntA_ADC_I = 0;AntA_ADC_Q = 0; csInterp = 1; t_start = 1; t_stop = 1;%2260;
239%xlLoadChipScopeData('cs_capts\v15_19_1_badPkt_v0.prn'); csInterp = 1; t_start = 392;
240
241rxAntI.time = [];
242rxAntQ.time = [];
243rxAntI.signals.values = AntA_ADC_I(t_start:csInterp:end);
244rxAntQ.signals.values = AntA_ADC_Q(t_start:csInterp:end);
245if(length(AntA_ADC_I) > 1)
246    simOnly_simLength = 1000 + 4*(length(AntA_ADC_I) - t_start);
247end
248
Note: See TracBrowser for help on using the repository browser.