source: ReferenceDesigns/w3_802.11/python/examples/chan_est_viewer/rx_data_from_hdf5.m

Last change on this file was 6320, checked in by chunter, 5 years ago

1.8.0 release wlan-exp

File size: 2.3 KB
Line 
1function rx_data = rx_data_from_hdf5(varargin)
2% Utility to extract OFDM Rx entries from HDF5 file
3% Two input arguments:
4%  rx_data = rx_data_from_hdf5(hdf5_file_name, hdf5_dataset_path)
5%   hdf5_file_name: Path (full or relative) of source HDF5 file (required)
6%   hdf5_dataset_path: HDF5 path for dataset containing OFDM Rx entries
7%     Defaults to '/RX_OFDM'
8%
9% The HDF5 file fed to this function should be generated by processing
10%  raw log data from the 802.11 Reference Design with the wlan_exp_log
11%  Python utilities. This utility expects numpy-processed log entries
12%  *not* raw log data. Refer to the 802.11 Reference Design user guide
13%  for more details on using the wlan_exp_log tools.
14
15if(nargin == 1)
16    hdf5_filename = varargin{1};
17    dataset_name = '/RX_OFDM';
18elseif(nargin == 2)
19    hdf5_filename = varargin{1};
20    dataset_name = varargin{2};
21else
22    error('rx_data_from_hdf5 requires 1 or 2 input arguments: hdf5_file_name and hdf5_dataset_path')
23end
24
25rx_entries = h5read(hdf5_filename, dataset_name);
26
27rx_t = double(rx_entries.timestamp);
28rx_fcs = double((bitand(rx_entries.flags,1) == 1));
29rx_h = double(rx_entries.chan_est);
30rx_pwr = double(rx_entries.power);
31
32% For MAX2829 RF interfaces 8-bit rx_gain_index value is:
33%  [  8]: 0
34%  [6:5]: RF gain index (0, 1, 2)
35%  [4:0]: BB gain index (0, 1, ..., 31)
36rx_gain_index = uint8(rx_entries.rx_gain_index);
37rx_g_bb = double(mod(rx_gain_index, 32));
38rx_g_rf = double(rx_gain_index/32);
39
40%Sanitze gain values
41rx_g_rf( rx_g_rf < 1 ) = 1;
42rx_g_rf( rx_g_rf > 3 ) = 3;
43rx_g_bb( rx_g_bb < 0 ) = 0;
44rx_g_bb( rx_g_bb > 31 ) = 31;
45
46%Convert chan ests from [I,Q] of Fix16_15 to complex doubles
47rx_h = rx_h ./2^15;
48rx_h = fftshift(squeeze(complex(rx_h(1,:,:), rx_h(2,:,:))));
49
50%RF Gain: 1=0dB, 2=15dB, 3=30dB
51rx_g_rf_db = ((rx_g_rf - 1) * 15);
52
53%BB Gain: 2dB per step, approx [0, 63]dB total
54rx_g_bb_db = (rx_g_bb * 2);
55
56%Compute linear gain adjustment
57rx_h_g_adj = 10.^(-(rx_g_rf_db + rx_g_bb_db)/10);
58
59rx_h_g_adj = repmat(rx_h_g_adj, 1, size(rx_h, 1)).';
60
61%Remove effect of Rx gains on each channel estimate
62rx_h = rx_h .* rx_h_g_adj;
63
64%Construct output struct
65rx_data.timestamp   = rx_t;
66rx_data.g_bb_db     = rx_g_bb_db;
67rx_data.g_rf_db     = rx_g_rf_db;
68rx_data.fcs_result  = rx_fcs;
69rx_data.pwr         = rx_pwr;
70rx_data.chan_ests   = rx_h.';
Note: See TracBrowser for help on using the repository browser.