source: ReferenceDesigns/w3_802.11/sysgen/wlan_phy_tx_pmd/util/wlan_tx_interleave_rom_gen.m

Last change on this file was 5095, checked in by murphpo, 8 years ago

First commit of new Tx PHY.

Re-designed most of the Tx PHY pipeline

-Added 11n SISO support, implements MCS 0-7, long-GI only (still working on short-GI mode)
-Replaced interleaver-per-mod with unified bits-in, syms-out interleaver
-Replaced control logic with simpler generate-one-sym-at-a-time logic
-Replcaed packet buffer addressing logic with simpler packet section decode logic
-Moved all MAC I/O and radio_controller I/O to common subsystem for easier integration in XPS
-Adopted external sample clock enable; ad_bridge now decides sampling rate
-Unified configuration params for each OFDM symbol in one subsystem

-Added DFFs around output FIFO control signals, hoping to isolate apparent asynchronous assertions
-Qualified PHY_Start by samp_ce, for fixed phase relationship between sample clock and PHY-MAC control

File size: 5.8 KB
Line 
1function interleave_mapping_ROM = wlan_tx_interleave_rom_gen()
2
3% Define numbers of coded bits per OFDM symbol for each modulation rate
4NCBPS_11a_BPSK  = 48;
5NCBPS_11a_QPSK  = 96;
6NCBPS_11a_16QAM = 192;
7NCBPS_11a_64QAM = 288;
8
9NCBPS_11n_BPSK  = 52;
10NCBPS_11n_QPSK  = 104;
11NCBPS_11n_16QAM = 208;
12NCBPS_11n_64QAM = 312;
13
14% Calculate interleaving vectors for each modulation scheme for each PHY mode
15interleave_11a_BPSK  = calc_interleave_vec_11a(NCBPS_11a_BPSK,  1);
16interleave_11a_QPSK  = calc_interleave_vec_11a(NCBPS_11a_QPSK,  2);
17interleave_11a_16QAM = calc_interleave_vec_11a(NCBPS_11a_16QAM, 4);
18interleave_11a_64QAM = calc_interleave_vec_11a(NCBPS_11a_64QAM, 6);
19interleave_11n_BPSK  = calc_interleave_vec_11n(NCBPS_11n_BPSK,  1);
20interleave_11n_QPSK  = calc_interleave_vec_11n(NCBPS_11n_QPSK,  2);
21interleave_11n_16QAM = calc_interleave_vec_11n(NCBPS_11n_16QAM, 4);
22interleave_11n_64QAM = calc_interleave_vec_11n(NCBPS_11n_64QAM, 6);
23
24% The interleave_11x vectors define the 1:1 mapping of input bit index to
25%  output bit index. The spec places the first bit (output index 0) in the
26%  lowest (most negative) frequency subcarrier, subcarrier index -26 for 11a,
27%  -28 for 11n. The Tx PHY IFFT core requires inputs in natual order,
28%  starting at subcarrier 0 (DC), then +1, +2, etc. Thus the interleaving
29%  vectors must be rotated to align the bit indices with the IFFT
30%  subcarrier indices. This is effectivly an fftshift() operation.
31interleave_11a_BPSK  = mod(interleave_11a_BPSK  + (NCBPS_11a_BPSK/2),  NCBPS_11a_BPSK);
32interleave_11a_QPSK  = mod(interleave_11a_QPSK  + (NCBPS_11a_QPSK/2),  NCBPS_11a_QPSK);
33interleave_11a_16QAM = mod(interleave_11a_16QAM + (NCBPS_11a_16QAM/2), NCBPS_11a_16QAM);
34interleave_11a_64QAM = mod(interleave_11a_64QAM + (NCBPS_11a_64QAM/2), NCBPS_11a_64QAM);
35interleave_11n_BPSK  = mod(interleave_11n_BPSK  + (NCBPS_11n_BPSK/2),  NCBPS_11n_BPSK);
36interleave_11n_QPSK  = mod(interleave_11n_QPSK  + (NCBPS_11n_QPSK/2),  NCBPS_11n_QPSK);
37interleave_11n_16QAM = mod(interleave_11n_16QAM + (NCBPS_11n_16QAM/2), NCBPS_11n_16QAM);
38interleave_11n_64QAM = mod(interleave_11n_64QAM + (NCBPS_11n_64QAM/2), NCBPS_11n_64QAM);
39
40% The Tx PHY interleaver uses a single RAM to store all the bits for a
41% single OFDM symbol. The same RAM is used for all rates. The RAM stores
42% coded/punctured data bits for each subcarrier on 8-bit boundaries. By
43% allocating 1 byte per subcarrier the design can use an efficient BRAM
44% architecture with 2 parallel 1-bit writes (coded bits A/B) and serial
45% 8-bit reads (bits for 1 subcarrier). Even with the aspect ratio change
46% write and read operations require a single clock cycle.
47%
48% The vectors above define the interleaver mapping as bit indexes in:out.
49% The operations below convert these to mapping
50%  (bit index in) : (interleaver RAM address out) by increasing the
51% output index values to place each subcarrier's bits on an 8-bit boundary.
52%
53% floor(x / bits_per_sym) calculates the subcarrier index of each output bit index
54% mod(x, bits_per_sym) calculates the bit index within the subcarrier
55ramaddr_11a_BPSK  = mod(interleave_11a_BPSK, 1)  + (8 * floor(interleave_11a_BPSK  / 1));
56ramaddr_11a_QPSK  = mod(interleave_11a_QPSK, 2)  + (8 * floor(interleave_11a_QPSK  / 2));
57ramaddr_11a_16QAM = mod(interleave_11a_16QAM, 4) + (8 * floor(interleave_11a_16QAM / 4));
58ramaddr_11a_64QAM = mod(interleave_11a_64QAM, 6) + (8 * floor(interleave_11a_64QAM / 6));
59
60ramaddr_11n_BPSK  = mod(interleave_11n_BPSK, 1)  + (8 * floor(interleave_11n_BPSK  / 1));
61ramaddr_11n_QPSK  = mod(interleave_11n_QPSK, 2)  + (8 * floor(interleave_11n_QPSK  / 2));
62ramaddr_11n_16QAM = mod(interleave_11n_16QAM, 4) + (8 * floor(interleave_11n_16QAM / 4));
63ramaddr_11n_64QAM = mod(interleave_11n_64QAM, 6) + (8 * floor(interleave_11n_64QAM / 6));
64
65%Concatenate all the mapping vectors into a single vector, to be used as
66% the init value for the ROM which implements the mapping LUT. Each LUT entry
67% is used as a memory address. The Tx PHY logic constructs the RAM write address as:
68%  addr[8:0] = {phy_mode_11n[0] mod_sel[1:0] bit_ind[5:0]}
69% Each mod scheme occupies 512 entries (64 subcarriers * 8 RAM bits per subcarrier)
70interleave_mapping_ROM = [];
71interleave_mapping_ROM = [interleave_mapping_ROM   ramaddr_11a_BPSK    zeros(1, 512-length(ramaddr_11a_BPSK))];
72interleave_mapping_ROM = [interleave_mapping_ROM   ramaddr_11a_QPSK    zeros(1, 512-length(ramaddr_11a_QPSK))];
73interleave_mapping_ROM = [interleave_mapping_ROM   ramaddr_11a_16QAM   zeros(1, 512-length(ramaddr_11a_16QAM))];
74interleave_mapping_ROM = [interleave_mapping_ROM   ramaddr_11a_64QAM   zeros(1, 512-length(ramaddr_11a_64QAM))];
75interleave_mapping_ROM = [interleave_mapping_ROM   ramaddr_11n_BPSK    zeros(1, 512-length(ramaddr_11n_BPSK))];
76interleave_mapping_ROM = [interleave_mapping_ROM   ramaddr_11n_QPSK    zeros(1, 512-length(ramaddr_11n_QPSK))];
77interleave_mapping_ROM = [interleave_mapping_ROM   ramaddr_11n_16QAM   zeros(1, 512-length(ramaddr_11n_16QAM))];
78interleave_mapping_ROM = [interleave_mapping_ROM   ramaddr_11n_64QAM   zeros(1, 512-length(ramaddr_11n_64QAM))];
79
80%Helper functions to calculate the interleaving vectors
81% These are implementations of the interleaving functions in the 802.11 spec
82function intlv_vec = calc_interleave_vec_11a(cbps, bpsc)
83    N_CBPS = cbps;
84    N_BPSC = bpsc;
85    s = max(N_BPSC/2, 1);
86
87    k = 0:N_CBPS-1;
88    i = (N_CBPS/16) .* mod(k,16) + floor(k/16);
89    j = s * floor(i/s) + mod( (i + N_CBPS - floor(16*i/N_CBPS)), s);
90    intlv_vec = j;
91end
92
93function intlv_vec = calc_interleave_vec_11n(cbps, bpsc)
94    N_CBPS = cbps;
95    N_BPSC = bpsc;
96    s = max(N_BPSC/2, 1);
97
98    k = 0:N_CBPS-1;
99    i = (4 * N_BPSC) .* mod(k,13) + floor(k/13);
100    j = s * floor(i/s) + mod( (i + N_CBPS - floor(13*i/N_CBPS)), s);
101    intlv_vec = j;
102end
103
104end
Note: See TracBrowser for help on using the repository browser.