Fixed bug in resource allocation for 50 PRB

master
ismagom 9 years ago
parent 5e3f577e97
commit 6581c9b0e2

@ -1,16 +1,14 @@
clear
enbConfig=struct('NCellID',1,'CyclicPrefix','Normal','CellRefP',1);
pdschConfig=struct('Modulation','QPSK','RV',0,'TxScheme','Port0');
pdschConfig=struct('Modulation','64QAM','RV',0,'TxScheme','Port0');
addpath('/home/ismael/work/srsLTE/build/srslte/lib/phch/test')
addpath('../../build/srslte/lib/phch/test')
TBs=40:8:800;
e_bits=1000;
TBs=19848;
e_bits=38460;
error=zeros(size(TBs));
for i=1:length(TBs)
trblkin=randi(2,TBs(i),1)-1;
%trblkin=ones(104,1);
%trblkin=[1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, ];
%trblkin=[1, 0];
[mat, info]=lteDLSCH(enbConfig,pdschConfig,e_bits,trblkin);
lib=srslte_dlsch_encode(enbConfig,pdschConfig,e_bits,trblkin);

@ -6,15 +6,15 @@
recordedSignal=[];
Npackets = 1;
SNR_values = linspace(15,20,4);
Npackets = 8;
SNR_values = linspace(10.5,13,4);
%% Choose RMC
[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.4',[1;0;0;1]);
[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.6',[1;0;0;1]);
waveform = sum(waveform,2);
if ~isempty(recordedSignal)
rmccFgOut = struct('NCellID',1,'CellRefP',1,'CFI',1,'NDLRB',15,'SamplingRate',3.84e6,'Nfft',256,'DuplexMode','FDD','CyclicPrefix','Normal');
rmccFgOut = struct('NCellID',1,'CellRefP',1,'CFI',1,'NDLRB',50,'SamplingRate',3.84e6,'Nfft',256,'DuplexMode','FDD','CyclicPrefix','Normal');
rmccFgOut.PDSCH.RNTI = 1234;
rmccFgOut.PDSCH.PRBSet = repmat(transpose(0:rmccFgOut.NDLRB-1),1,2);
rmccFgOut.PDSCH.TxScheme = 'Port0';
@ -79,7 +79,6 @@ for snr_idx=1:length(SNR_values)
frame_rx = lteOFDMDemodulate(rmccFgOut, rxWaveform);
for sf_idx=0:Nsf
subframe_waveform = rxWaveform(sf_idx*flen+1:(sf_idx+1)*flen);
subframe_rx=frame_rx(:,sf_idx*14+1:(sf_idx+1)*14);
rmccFgOut.NSubframe=sf_idx;
rmccFgOut.TotSubframes=1;
@ -87,7 +86,7 @@ for snr_idx=1:length(SNR_values)
% Perform channel estimation
[hest, nest] = lteDLChannelEstimate(rmccFgOut, cec, subframe_rx);
[cws,symbols,pdschSymbols,hestCH,indices] = ltePDSCHDecode2(rmccFgOut,rmccFgOut.PDSCH,subframe_rx,hest,nest);
[cws,symbols] = ltePDSCHDecode(rmccFgOut,rmccFgOut.PDSCH,subframe_rx,hest,nest);
[trblkout,blkcrc,dstate] = lteDLSCHDecode(rmccFgOut,rmccFgOut.PDSCH, ...
rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1),cws);
@ -98,7 +97,7 @@ for snr_idx=1:length(SNR_values)
if (rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1) > 0)
[dec2, data, pdschRx, pdschSymbols2, deb] = srslte_pdsch(rmccFgOut, rmccFgOut.PDSCH, ...
rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1), ...
subframe_waveform);
subframe_rx);
else
dec2 = 1;
end

@ -596,7 +596,7 @@ int main(int argc, char **argv) {
/* Configure pdsch_cfg parameters */
srslte_ra_dl_grant_t grant;
srslte_ra_dl_dci_to_grant(&ra_dl, cell.nof_prb, true, &grant);
if (srslte_pdsch_cfg(&pdsch_cfg, cell, &grant, cfi, sf_idx, UE_CRNTI, 0)) {
if (srslte_pdsch_cfg(&pdsch_cfg, cell, &grant, cfi, sf_idx, 0)) {
fprintf(stderr, "Error configuring PDSCH\n");
exit(-1);
}

@ -87,7 +87,6 @@ SRSLTE_API int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg,
srslte_ra_dl_grant_t *grant,
uint32_t cfi,
uint32_t sf_idx,
uint16_t rnti,
uint32_t rvidx);
SRSLTE_API int srslte_pdsch_encode(srslte_pdsch_t *q,

@ -45,7 +45,7 @@ typedef struct SRSLTE_API {
srslte_ra_dl_grant_t grant;
srslte_ra_nbits_t nbits;
uint32_t rv;
uint32_t sf_idx;
uint32_t sf_idx;
} srslte_pdsch_cfg_t;
#endif

@ -101,7 +101,6 @@ SRSLTE_API int srslte_ue_dl_cfg_grant(srslte_ue_dl_t *q,
srslte_ra_dl_grant_t *grant,
uint32_t cfi,
uint32_t sf_idx,
uint16_t rnti,
uint32_t rvidx);
SRSLTE_API int srslte_ue_dl_find_ul_dci(srslte_ue_dl_t *q,

@ -33,7 +33,7 @@
#include "srslte/utils/bit.h"
#include "srslte/modem/demod_soft.h"
#define SCALE_DEMOD16QAM
//#define SCALE_DEMOD16QAM
void demod_bpsk_lte(const cf_t *symbols, float *llr, int nsymbols) {

@ -98,7 +98,7 @@ int srslte_pdsch_cp(srslte_pdsch_t *q, cf_t *input, cf_t *output, srslte_ra_dl_g
// Skip PSS/SSS signals
if (s == 0 && (nsubframe == 0 || nsubframe == 5)) {
if (n >= q->cell.nof_prb / 2 - 3
&& n <= q->cell.nof_prb / 2 + 3) {
&& n < q->cell.nof_prb / 2 + 3 + (q->cell.nof_prb%2)) {
lend = SRSLTE_CP_NSYMB(q->cell.cp) - 2;
is_sss = true;
}
@ -106,7 +106,7 @@ int srslte_pdsch_cp(srslte_pdsch_t *q, cf_t *input, cf_t *output, srslte_ra_dl_g
// Skip PBCH
if (s == 1 && nsubframe == 0) {
if (n >= q->cell.nof_prb / 2 - 3
&& n <= q->cell.nof_prb / 2 + 3) {
&& n < q->cell.nof_prb / 2 + 3 + (q->cell.nof_prb%2)) {
lstart = 4;
is_pbch = true;
}
@ -302,7 +302,7 @@ void srslte_pdsch_free(srslte_pdsch_t *q) {
/* Configures the structure srslte_pdsch_cfg_t from the DL DCI allocation dci_msg.
* If dci_msg is NULL, the grant is assumed to be already stored in cfg->grant
*/
int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg, srslte_cell_t cell, srslte_ra_dl_grant_t *grant, uint32_t cfi, uint32_t sf_idx, uint16_t rnti, uint32_t rvidx)
int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg, srslte_cell_t cell, srslte_ra_dl_grant_t *grant, uint32_t cfi, uint32_t sf_idx, uint32_t rvidx)
{
if (cfg && grant) {
@ -314,8 +314,8 @@ int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg, srslte_cell_t cell, srslte_ra_dl_g
}
srslte_ra_dl_grant_to_nbits(&cfg->grant, cfi, cell, sf_idx, &cfg->nbits);
cfg->sf_idx = sf_idx;
cfg->rv = rvidx;
cfg->rv = rvidx;
return SRSLTE_SUCCESS;
}

@ -55,7 +55,7 @@ uint32_t ra_re_x_prb(uint32_t subframe, uint32_t slot, uint32_t prb_idx, uint32_
/* if it's the prb in the middle, there are less RE due to PBCH and PSS/SSS */
if ((subframe == 0 || subframe == 5)
&& (prb_idx >= nof_prb / 2 - 3 && prb_idx <= nof_prb / 2 + 3)) {
&& (prb_idx >= nof_prb / 2 - 3 && prb_idx < nof_prb / 2 + 3 + (nof_prb%2))) {
if (subframe == 0) {
if (slot == 0) {
re = (SRSLTE_CP_NSYMB(cp) - nof_ctrl_symbols - 2) * SRSLTE_NRE;
@ -104,7 +104,6 @@ uint32_t ra_re_x_prb(uint32_t subframe, uint32_t slot, uint32_t prb_idx, uint32_
break;
}
}
return re;
}

@ -93,10 +93,10 @@ BuildMex(MEXNAME pdcch SOURCES pdcch_test_mex.c LIBRARIES srslte srslte_mex)
ADD_EXECUTABLE(pdsch_test pdsch_test.c)
TARGET_LINK_LIBRARIES(pdsch_test srslte)
ADD_TEST(pdsch_test_bpsk pdsch_test -l 504 -m 1 -n 50 -r 2)
ADD_TEST(pdsch_test_qpsk pdsch_test -l 2216 -m 2 -n 50 -r 1)
ADD_TEST(pdsch_test_qam16 pdsch_test -l 18336 -m 4 -n 100)
ADD_TEST(pdsch_test_qam64 pdsch_test -l 75376 -m 6 -n 100 -r 0)
ADD_TEST(pdsch_test_bpsk pdsch_test -m 0 -n 50 -r 2)
ADD_TEST(pdsch_test_qpsk pdsch_test -m 10 -n 50 -r 1)
ADD_TEST(pdsch_test_qam16 pdsch_test -m 20 -n 100)
ADD_TEST(pdsch_test_qam64 pdsch_test -m 28 -n 100 -r 0)
BuildMex(MEXNAME pdsch SOURCES pdsch_test_mex.c LIBRARIES srslte srslte_mex)
BuildMex(MEXNAME dlsch_encode SOURCES dlsch_encode_test_mex.c LIBRARIES srslte srslte_mex)

@ -45,18 +45,21 @@ srslte_cell_t cell = {
};
uint32_t cfi = 2;
uint32_t tbs = 0;
uint32_t mcs = 0;
uint32_t subframe = 1;
srslte_mod_t modulation = SRSLTE_MOD_BPSK;
uint32_t rv_idx = 0;
uint16_t rnti = 1234;
char *input_file = NULL;
void usage(char *prog) {
printf("Usage: %s [Lcpsrnfvmt] -l TBS \n", prog);
printf("\t-m modulation (1: BPSK, 2: QPSK, 3: QAM16, 4: QAM64) [Default BPSK]\n");
printf("Usage: %s [fmcsrRFpnv] \n", prog);
printf("\t-f read signal from file [Default generate it with pdsch_encode()]\n");
printf("\t-m MCS [Default %d]\n", mcs);
printf("\t-c cell id [Default %d]\n", cell.id);
printf("\t-s subframe [Default %d]\n", subframe);
printf("\t-r rv_idx [Default %d]\n", rv_idx);
printf("\t-f cfi [Default %d]\n", cfi);
printf("\t-R rnti [Default %d]\n", rnti);
printf("\t-F cfi [Default %d]\n", cfi);
printf("\t-p cell.nof_ports [Default %d]\n", cell.nof_ports);
printf("\t-n cell.nof_prb [Default %d]\n", cell.nof_prb);
printf("\t-v [set srslte_verbose to debug, default none]\n");
@ -64,27 +67,13 @@ void usage(char *prog) {
void parse_args(int argc, char **argv) {
int opt;
while ((opt = getopt(argc, argv, "lcpnfvmtsr")) != -1) {
while ((opt = getopt(argc, argv, "fmcsrRFpnv")) != -1) {
switch(opt) {
case 'f':
input_file = argv[optind];
break;
case 'm':
switch(atoi(argv[optind])) {
case 1:
modulation = SRSLTE_MOD_BPSK;
break;
case 2:
modulation = SRSLTE_MOD_QPSK;
break;
case 4:
modulation = SRSLTE_MOD_16QAM;
break;
case 6:
modulation = SRSLTE_MOD_64QAM;
break;
default:
fprintf(stderr, "Invalid modulation %d. Possible values: "
"(1: BPSK, 2: QPSK, 3: QAM16, 4: QAM64)\n", atoi(argv[optind]));
break;
}
mcs = atoi(argv[optind]);
break;
case 's':
subframe = atoi(argv[optind]);
@ -92,8 +81,11 @@ void parse_args(int argc, char **argv) {
case 'r':
rv_idx = atoi(argv[optind]);
break;
case 'l':
tbs = atoi(argv[optind]);
case 'R':
rnti = atoi(argv[optind]);
break;
case 'F':
cfi = atoi(argv[optind]);
break;
case 'p':
cell.nof_ports = atoi(argv[optind]);
@ -112,10 +104,6 @@ void parse_args(int argc, char **argv) {
exit(-1);
}
}
if (tbs == 0) {
usage(argv[0]);
exit(-1);
}
}
int main(int argc, char **argv) {
@ -140,18 +128,19 @@ int main(int argc, char **argv) {
bzero(&softbuffer_rx, sizeof(srslte_softbuffer_rx_t));
bzero(&softbuffer_tx, sizeof(srslte_softbuffer_tx_t));
srslte_ra_dl_dci_t dci;
bzero(&dci, sizeof(srslte_ra_dl_dci_t));
dci.mcs_idx = mcs;
dci.rv_idx = rv_idx;
dci.type0_alloc.rbg_bitmask = 0xffffffff;
srslte_ra_dl_grant_t grant;
grant.mcs.tbs = tbs;
grant.mcs.mod = modulation;
grant.Qm = srslte_mod_bits_x_symbol(grant.mcs.mod);
grant.nof_prb = cell.nof_prb; // Allocate all PRB
for (i=0;i<grant.nof_prb;i++) {
grant.prb_idx[0][i] = true;
if (srslte_ra_dl_dci_to_grant(&dci, cell.nof_prb, true, &grant)) {
fprintf(stderr, "Error computing resource allocation\n");
return ret;
}
memcpy(&grant.prb_idx[1], &grant.prb_idx[0], SRSLTE_MAX_PRB * sizeof(bool));
/* Configure PDSCH */
if (srslte_pdsch_cfg(&pdsch_cfg, cell, &grant, cfi, subframe, 1234, 0)) {
if (srslte_pdsch_cfg(&pdsch_cfg, cell, &grant, cfi, subframe, 0)) {
fprintf(stderr, "Error configuring PDSCH\n");
exit(-1);
}
@ -173,7 +162,7 @@ int main(int argc, char **argv) {
}
}
data = malloc(sizeof(uint8_t) * tbs/8);
data = malloc(sizeof(uint8_t) * grant.mcs.tbs/8);
if (!data) {
perror("malloc");
goto quit;
@ -184,7 +173,7 @@ int main(int argc, char **argv) {
goto quit;
}
srslte_pdsch_set_rnti(&pdsch, 1234);
srslte_pdsch_set_rnti(&pdsch, rnti);
if (srslte_softbuffer_tx_init(&softbuffer_tx, cell.nof_prb)) {
fprintf(stderr, "Error initiating TX soft buffer\n");
@ -196,6 +185,17 @@ int main(int argc, char **argv) {
goto quit;
}
if (input_file) {
srslte_filesource_t fsrc;
if (srslte_filesource_init(&fsrc, input_file, SRSLTE_COMPLEX_FLOAT_BIN)) {
fprintf(stderr, "Error opening file %s\n", input_file);
exit(-1);
}
srslte_filesource_read(&fsrc, slot_symbols[0], SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp));
srslte_filesource_free(&fsrc);
}
if (SRSLTE_VERBOSE_ISNONE()) {
printf("Decoding TBS: %d\r",grant.mcs.tbs);
}
@ -207,11 +207,13 @@ int main(int argc, char **argv) {
pdsch_cfg.rv = rv;
if (srslte_pdsch_encode(&pdsch, &pdsch_cfg, &softbuffer_tx, data, slot_symbols)) {
fprintf(stderr, "Error encoding PDSCH\n");
goto quit;
if (!input_file) {
if (srslte_pdsch_encode(&pdsch, &pdsch_cfg, &softbuffer_tx, data, slot_symbols)) {
fprintf(stderr, "Error encoding PDSCH\n");
goto quit;
}
}
/* combine outputs */
for (i=0;i<cell.nof_ports;i++) {
for (j=0;j<SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp);j++) {

@ -53,8 +53,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
srslte_cell_t cell;
srslte_pdsch_t pdsch;
srslte_chest_dl_t chest;
srslte_ofdm_t fft;
cf_t *input_fft, *input_signal;
cf_t *input_fft;
int nof_re;
srslte_pdsch_cfg_t cfg;
srslte_softbuffer_rx_t softbuffer;
@ -103,10 +102,6 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
return;
}
if (srslte_ofdm_rx_init(&fft, cell.cp, cell.nof_prb)) {
mexErrMsgTxt("Error initializing FFT\n");
return;
}
nof_re = 2 * SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE;
@ -166,25 +161,22 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
/* Configure rest of pdsch_cfg parameters */
grant.Qm = srslte_mod_bits_x_symbol(grant.mcs.mod);
if (srslte_pdsch_cfg(&cfg, cell, &grant, cfi, cfg.sf_idx, (uint16_t) (rnti32 & 0xffff), cfg.rv)) {
if (srslte_pdsch_cfg(&cfg, cell, &grant, cfi, cfg.sf_idx, cfg.rv)) {
fprintf(stderr, "Error configuring PDSCH\n");
exit(-1);
}
/** Allocate input buffers */
if (mexutils_read_cf(INPUT, &input_signal) < 0) {
if (mexutils_read_cf(INPUT, &input_fft) < 0) {
mexErrMsgTxt("Error reading input signal\n");
return;
}
input_fft = srslte_vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
cf_t *ce[SRSLTE_MAX_PORTS];
for (i=0;i<cell.nof_ports;i++) {
ce[i] = srslte_vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
}
srslte_ofdm_rx_sf(&fft, input_signal, input_fft);
if (nrhs > NOF_INPUTS) {
cf_t *cearray = NULL;
nof_re = mexutils_read_cf(prhs[NOF_INPUTS], &cearray);
@ -236,14 +228,12 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
}
srslte_chest_dl_free(&chest);
srslte_ofdm_rx_free(&fft);
srslte_pdsch_free(&pdsch);
for (i=0;i<cell.nof_ports;i++) {
free(ce[i]);
}
free(data);
free(input_signal);
free(input_fft);
return;

@ -204,9 +204,9 @@ int srslte_ue_dl_decode_fft_estimate(srslte_ue_dl_t *q, cf_t *input, uint32_t sf
}
}
int srslte_ue_dl_cfg_grant(srslte_ue_dl_t *q, srslte_ra_dl_grant_t *grant, uint32_t cfi, uint32_t sf_idx, uint16_t rnti, uint32_t rvidx)
int srslte_ue_dl_cfg_grant(srslte_ue_dl_t *q, srslte_ra_dl_grant_t *grant, uint32_t cfi, uint32_t sf_idx, uint32_t rvidx)
{
return srslte_pdsch_cfg(&q->pdsch_cfg, q->cell, grant, cfi, sf_idx, rnti, rvidx);
return srslte_pdsch_cfg(&q->pdsch_cfg, q->cell, grant, cfi, sf_idx, rvidx);
}
int srslte_ue_dl_decode_rnti_rv_packet(srslte_ue_dl_t *q, srslte_ra_dl_grant_t *grant, uint8_t *data,
@ -217,7 +217,7 @@ int srslte_ue_dl_decode_rnti_rv_packet(srslte_ue_dl_t *q, srslte_ra_dl_grant_t *
q->nof_detected++;
/* Setup PDSCH configuration for this CFI, SFIDX and RVIDX */
if (srslte_ue_dl_cfg_grant(q, grant, cfi, sf_idx, rnti, rvidx)) {
if (srslte_ue_dl_cfg_grant(q, grant, cfi, sf_idx, rvidx)) {
return SRSLTE_ERROR;
}

Loading…
Cancel
Save