Converted all unsigned data types to uint32_t

master
ismagom 11 years ago
parent 67fb600193
commit 5181b771fd

@ -47,7 +47,7 @@ lte_cell_t cell = {
CPNORM // cyclic prefix CPNORM // cyclic prefix
}; };
uint8_t cfi=1; uint32_t cfi=1;
int nof_frames = -1; int nof_frames = -1;
char *uhd_args = ""; char *uhd_args = "";

@ -70,6 +70,8 @@ int sf_n_samples;
lte_cell_t cell; lte_cell_t cell;
uint32_t cell_id_file = 1;
int cell_id_initated = 0, mib_initiated = 0; int cell_id_initated = 0, mib_initiated = 0;
int frame_number; int frame_number;
@ -98,8 +100,9 @@ sync_frame_t sframe;
#define DOWNSAMPLE_FACTOR(x, y) lte_symbol_sz(x) / lte_symbol_sz(y) #define DOWNSAMPLE_FACTOR(x, y) lte_symbol_sz(x) / lte_symbol_sz(y)
void usage(char *prog) { void usage(char *prog) {
printf("Usage: %s [iagfndvtpb]\n", prog); printf("Usage: %s [icagfndvtpb]\n", prog);
printf("\t-i input_file [Default use USRP]\n"); printf("\t-i input_file [Default use USRP]\n");
printf("\t-c cell_id if reading from file [Default %d]\n", cell_id_file);
#ifndef DISABLE_UHD #ifndef DISABLE_UHD
printf("\t-a UHD args [Default %s]\n", uhd_args); printf("\t-a UHD args [Default %s]\n", uhd_args);
printf("\t-g UHD RX gain [Default %.2f dB]\n", uhd_gain); printf("\t-g UHD RX gain [Default %.2f dB]\n", uhd_gain);
@ -121,11 +124,14 @@ void usage(char *prog) {
void parse_args(int argc, char **argv) { void parse_args(int argc, char **argv) {
int opt; int opt;
while ((opt = getopt(argc, argv, "iagfndvtpb")) != -1) { while ((opt = getopt(argc, argv, "icagfndvtpb")) != -1) {
switch (opt) { switch (opt) {
case 'i': case 'i':
input_file_name = argv[optind]; input_file_name = argv[optind];
break; break;
case 'c':
cell_id_file = atoi(argv[optind]);
break;
case 'a': case 'a':
uhd_args = argv[optind]; uhd_args = argv[optind];
break; break;
@ -367,7 +373,7 @@ int cell_id_init(int nof_prb, int cell_id) {
lte_cell_t cell; lte_cell_t cell;
cell.id = cell_id; cell.id = cell_id;
cell.nof_prb = 6; cell.nof_prb = nof_prb;
cell.nof_ports = 2; cell.nof_ports = 2;
cell.cp = CPNORM; cell.cp = CPNORM;
@ -390,7 +396,7 @@ int cell_id_init(int nof_prb, int cell_id) {
char data[10000]; char data[10000];
int rx_run(cf_t *input, int sf_idx) { int rx_run(cf_t *input, int sf_idx) {
uint8_t cfi, cfi_distance; uint32_t cfi, cfi_distance;
int i, nof_dcis; int i, nof_dcis;
cf_t *input_decim; cf_t *input_decim;
ra_pdsch_t ra_dl; ra_pdsch_t ra_dl;
@ -497,7 +503,7 @@ int mib_decoder_run(cf_t *input, pbch_mib_t *mib) {
return pbch_decode(&pbch, fft_buffer, ce, mib); return pbch_decode(&pbch, fft_buffer, ce, mib);
} }
int run_receiver(cf_t *input, int cell_id, int sf_idx) { int run_receiver(cf_t *input, uint32_t cell_id, uint32_t sf_idx) {
pbch_mib_t mib; pbch_mib_t mib;
if (!cell_id_initated) { if (!cell_id_initated) {
@ -603,6 +609,10 @@ void read_io(cf_t *buffer, int nsamples) {
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
int ret;
uint32_t sf_idx;
uint32_t cell_id;
cf_t *in_ptr;
#ifdef DISABLE_UHD #ifdef DISABLE_UHD
if (argc < 3) { if (argc < 3) {
@ -640,7 +650,16 @@ int main(int argc, char **argv) {
read_io(input_buffer, sf_n_samples); read_io(input_buffer, sf_n_samples);
switch(sync_frame_push(&sframe, input_buffer, sf_buffer)) { if (input_file_name) {
ret = 1;
sf_idx = 0;
cell_id = cell_id_file;
in_ptr = input_buffer;
} else {
ret = sync_frame_push(&sframe, input_buffer, sf_buffer);
in_ptr = sf_buffer;
}
switch(ret ) {
case 0: case 0:
/* not yet synched */ /* not yet synched */
break; break;
@ -651,14 +670,18 @@ int main(int argc, char **argv) {
frame_number++; frame_number++;
} }
if (!input_file_name) {
sf_idx = sync_frame_sfidx(&sframe);
cell_id = sync_frame_cell_id(&sframe);
}
/* synch'd and tracking */ /* synch'd and tracking */
if (run_receiver(sf_buffer, sync_frame_cell_id(&sframe), sync_frame_sfidx(&sframe))) { if (run_receiver(in_ptr, cell_id, sf_idx)) {
exit(-1); exit(-1);
} }
if (!(frame_cnt % 10)) { if (!(frame_cnt % 10)) {
printf( printf("SFN: %4d, CFO: %+.4f KHz, SFO: %+.4f Khz, TimeOffset: %4d, Errors: %4d/%4d, BLER: %.1e\r",
"SFN: %4d, CFO: %+.4f KHz, SFO: %+.4f Khz, TimeOffset: %4d, Errors: %4d/%4d, BLER: %.1e\r",
frame_number, sframe.cur_cfo * 15, sframe.timeoffset / 5, sframe.peak_idx, frame_number, sframe.cur_cfo * 15, sframe.timeoffset / 5, sframe.peak_idx,
pkt_errors, pkts_total, pkt_errors, pkts_total,
(float) pkt_errors / pkts_total); (float) pkt_errors / pkts_total);

@ -56,9 +56,9 @@ typedef void (*interpolate_fnc_t) (cf_t *input,
/* Low-level API */ /* Low-level API */
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
uint8_t nof_ports; uint32_t nof_ports;
uint16_t nof_re; uint32_t nof_re;
uint8_t nof_symbols; uint32_t nof_symbols;
refsignal_t refsignal[MAX_PORTS][NSLOTS_X_FRAME]; refsignal_t refsignal[MAX_PORTS][NSLOTS_X_FRAME];
interpolate_fnc_t interp; interpolate_fnc_t interp;
@ -66,26 +66,26 @@ typedef struct LIBLTE_API {
LIBLTE_API int chest_init(chest_t *q, LIBLTE_API int chest_init(chest_t *q,
chest_interp_t interp, chest_interp_t interp,
uint16_t nof_re, uint32_t nof_re,
uint8_t nof_symbols, uint32_t nof_symbols,
uint8_t nof_ports); uint32_t nof_ports);
LIBLTE_API void chest_free(chest_t *q); LIBLTE_API void chest_free(chest_t *q);
LIBLTE_API int chest_set_nof_ports(chest_t *q, LIBLTE_API int chest_set_nof_ports(chest_t *q,
uint8_t nof_ports); uint32_t nof_ports);
LIBLTE_API int chest_init_LTEDL(chest_t *q, LIBLTE_API int chest_init_LTEDL(chest_t *q,
chest_interp_t interp, chest_interp_t interp,
lte_cell_t cell); lte_cell_t cell);
LIBLTE_API int chest_ref_LTEDL_slot_port(chest_t *q, LIBLTE_API int chest_ref_LTEDL_slot_port(chest_t *q,
uint8_t nslot, uint32_t nslot,
uint8_t port_id, uint32_t port_id,
lte_cell_t cell); lte_cell_t cell);
LIBLTE_API int chest_ref_LTEDL_slot(chest_t *q, LIBLTE_API int chest_ref_LTEDL_slot(chest_t *q,
uint8_t nslot, uint32_t nslot,
lte_cell_t cell); lte_cell_t cell);
LIBLTE_API int chest_ref_LTEDL(chest_t *q, LIBLTE_API int chest_ref_LTEDL(chest_t *q,
@ -93,56 +93,56 @@ LIBLTE_API int chest_ref_LTEDL(chest_t *q,
LIBLTE_API int chest_ce_ref(chest_t *q, LIBLTE_API int chest_ce_ref(chest_t *q,
cf_t *input, cf_t *input,
uint8_t nslot, uint32_t nslot,
uint8_t port_id, uint32_t port_id,
uint16_t nref); uint32_t nref);
LIBLTE_API int chest_ce_slot_port(chest_t *q, LIBLTE_API int chest_ce_slot_port(chest_t *q,
cf_t *input, cf_t *input,
cf_t *ce, cf_t *ce,
uint8_t nslot, uint32_t nslot,
uint8_t port_id); uint32_t port_id);
LIBLTE_API int chest_ce_sf_port(chest_t *q, LIBLTE_API int chest_ce_sf_port(chest_t *q,
cf_t *input, cf_t *input,
cf_t *ce, cf_t *ce,
uint8_t sf_idx, uint32_t sf_idx,
uint8_t port_id); uint32_t port_id);
LIBLTE_API int chest_ce_slot(chest_t *q, LIBLTE_API int chest_ce_slot(chest_t *q,
cf_t *input, cf_t *input,
cf_t *ce[MAX_PORTS], cf_t *ce[MAX_PORTS],
uint8_t nslot); uint32_t nslot);
LIBLTE_API int chest_ce_sf(chest_t *q, LIBLTE_API int chest_ce_sf(chest_t *q,
cf_t *input, cf_t *input,
cf_t *ce[MAX_PORTS], cf_t *ce[MAX_PORTS],
uint8_t sf_idx); uint32_t sf_idx);
LIBLTE_API void chest_fprint(chest_t *q, LIBLTE_API void chest_fprint(chest_t *q,
FILE *stream, FILE *stream,
uint8_t nslot, uint32_t nslot,
uint8_t port_id); uint32_t port_id);
LIBLTE_API void chest_ref_fprint(chest_t *q, LIBLTE_API void chest_ref_fprint(chest_t *q,
FILE *stream, FILE *stream,
uint8_t nslot, uint32_t nslot,
uint8_t port_id); uint32_t port_id);
LIBLTE_API void chest_recvsig_fprint(chest_t *q, LIBLTE_API void chest_recvsig_fprint(chest_t *q,
FILE *stream, FILE *stream,
uint8_t nslot, uint32_t nslot,
uint8_t port_id); uint32_t port_id);
LIBLTE_API void chest_ce_fprint(chest_t *q, LIBLTE_API void chest_ce_fprint(chest_t *q,
FILE *stream, FILE *stream,
uint8_t nslot, uint32_t nslot,
uint8_t port_id); uint32_t port_id);
LIBLTE_API int chest_ref_symbols(chest_t *q, LIBLTE_API int chest_ref_symbols(chest_t *q,
uint8_t port_id, uint32_t port_id,
uint8_t nslot, uint32_t nslot,
uint8_t l[2]); uint32_t l[2]);
/* High-level API */ /* High-level API */

@ -43,25 +43,25 @@
typedef _Complex float cf_t; typedef _Complex float cf_t;
typedef struct LIBLTE_API{ typedef struct LIBLTE_API{
uint8_t time_idx; uint32_t time_idx;
uint16_t freq_idx; uint32_t freq_idx;
cf_t simbol; cf_t simbol;
cf_t recv_simbol; cf_t recv_simbol;
}ref_t; }ref_t;
typedef struct LIBLTE_API{ typedef struct LIBLTE_API{
uint16_t nof_refs; // number of reference signals uint32_t nof_refs; // number of reference signals
uint8_t *symbols_ref; // symbols with at least one reference uint32_t *symbols_ref; // symbols with at least one reference
uint8_t nsymbols; // number of symbols with at least one reference uint32_t nsymbols; // number of symbols with at least one reference
uint8_t voffset; // offset of the first reference in the freq domain uint32_t voffset; // offset of the first reference in the freq domain
uint16_t nof_prb; uint32_t nof_prb;
ref_t *refs; ref_t *refs;
cf_t *ch_est; cf_t *ch_est;
} refsignal_t; } refsignal_t;
LIBLTE_API int refsignal_init_LTEDL(refsignal_t *q, LIBLTE_API int refsignal_init_LTEDL(refsignal_t *q,
uint8_t port_id, uint32_t port_id,
uint8_t nslot, uint32_t nslot,
lte_cell_t cell); lte_cell_t cell);
LIBLTE_API void refsignal_free(refsignal_t *q); LIBLTE_API void refsignal_free(refsignal_t *q);

@ -107,9 +107,9 @@ typedef enum {CPNORM, CPEXT} lte_cp_t;
#define NOF_TC_CB_SIZES 188 #define NOF_TC_CB_SIZES 188
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
uint8_t nof_prb; uint32_t nof_prb;
uint8_t nof_ports; uint32_t nof_ports;
uint16_t id; uint32_t id;
lte_cp_t cp; lte_cp_t cp;
}lte_cell_t; }lte_cell_t;

@ -46,26 +46,26 @@ LIBLTE_API int sequence_LTEPRS(sequence_t *q,
LIBLTE_API int sequence_pbch(sequence_t *seq, LIBLTE_API int sequence_pbch(sequence_t *seq,
lte_cp_t cp, lte_cp_t cp,
uint16_t cell_id); uint32_t cell_id);
LIBLTE_API int sequence_pcfich(sequence_t *seq, LIBLTE_API int sequence_pcfich(sequence_t *seq,
uint8_t nslot, uint32_t nslot,
uint16_t cell_id); uint32_t cell_id);
LIBLTE_API int sequence_phich(sequence_t *seq, LIBLTE_API int sequence_phich(sequence_t *seq,
uint8_t nslot, uint32_t nslot,
uint16_t cell_id); uint32_t cell_id);
LIBLTE_API int sequence_pdcch(sequence_t *seq, LIBLTE_API int sequence_pdcch(sequence_t *seq,
uint8_t nslot, uint32_t nslot,
uint16_t cell_id, uint32_t cell_id,
uint32_t len); uint32_t len);
LIBLTE_API int sequence_pdsch(sequence_t *seq, LIBLTE_API int sequence_pdsch(sequence_t *seq,
unsigned short rnti, unsigned short rnti,
int q, int q,
uint8_t nslot, uint32_t nslot,
uint16_t cell_id, uint32_t cell_id,
uint32_t len); uint32_t len);
#endif #endif

@ -62,9 +62,9 @@ typedef enum {
} dci_spec_t; } dci_spec_t;
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
uint8_t nof_bits; uint32_t nof_bits;
uint8_t L; // Aggregation level uint32_t L; // Aggregation level
uint8_t ncce; // Position of first CCE of the dci uint32_t ncce; // Position of first CCE of the dci
uint16_t rnti; uint16_t rnti;
} dci_candidate_t; } dci_candidate_t;
@ -75,20 +75,20 @@ typedef struct LIBLTE_API {
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
dci_msg_t *msg; dci_msg_t *msg;
uint8_t nof_dcis; uint32_t nof_dcis;
uint8_t max_dcis; uint32_t max_dcis;
} dci_t; } dci_t;
LIBLTE_API int dci_init(dci_t *q, LIBLTE_API int dci_init(dci_t *q,
uint8_t max_dci); uint32_t max_dci);
LIBLTE_API void dci_free(dci_t *q); LIBLTE_API void dci_free(dci_t *q);
LIBLTE_API char* dci_format_string(dci_format_t format); LIBLTE_API char* dci_format_string(dci_format_t format);
LIBLTE_API int dci_msg_candidate_set(dci_msg_t *msg, LIBLTE_API int dci_msg_candidate_set(dci_msg_t *msg,
uint8_t L, uint32_t L,
uint8_t nCCE, uint32_t nCCE,
uint16_t rnti); uint16_t rnti);
LIBLTE_API void dci_candidate_fprint(FILE *f, LIBLTE_API void dci_candidate_fprint(FILE *f,
@ -96,7 +96,7 @@ LIBLTE_API void dci_candidate_fprint(FILE *f,
LIBLTE_API int dci_msg_get_type(dci_msg_t *msg, LIBLTE_API int dci_msg_get_type(dci_msg_t *msg,
dci_msg_type_t *type, dci_msg_type_t *type,
uint8_t nof_prb, uint32_t nof_prb,
uint16_t crnti); uint16_t crnti);
LIBLTE_API void dci_msg_type_fprint(FILE *f, LIBLTE_API void dci_msg_type_fprint(FILE *f,
@ -105,25 +105,25 @@ LIBLTE_API void dci_msg_type_fprint(FILE *f,
// For dci_msg_type_t = PUSCH_SCHED // For dci_msg_type_t = PUSCH_SCHED
LIBLTE_API int dci_msg_pack_pusch(ra_pusch_t *data, LIBLTE_API int dci_msg_pack_pusch(ra_pusch_t *data,
dci_msg_t *msg, dci_msg_t *msg,
uint8_t nof_prb); uint32_t nof_prb);
LIBLTE_API int dci_msg_unpack_pusch(dci_msg_t *msg, LIBLTE_API int dci_msg_unpack_pusch(dci_msg_t *msg,
ra_pusch_t *data, ra_pusch_t *data,
uint8_t nof_prb); uint32_t nof_prb);
// For dci_msg_type_t = PDSCH_SCHED // For dci_msg_type_t = PDSCH_SCHED
LIBLTE_API int dci_msg_pack_pdsch(ra_pdsch_t *data, LIBLTE_API int dci_msg_pack_pdsch(ra_pdsch_t *data,
dci_msg_t *msg, dci_msg_t *msg,
dci_format_t format, dci_format_t format,
uint8_t nof_prb, uint32_t nof_prb,
bool crc_is_crnti); bool crc_is_crnti);
LIBLTE_API int dci_msg_unpack_pdsch(dci_msg_t *msg, LIBLTE_API int dci_msg_unpack_pdsch(dci_msg_t *msg,
ra_pdsch_t *data, ra_pdsch_t *data,
uint8_t nof_prb, uint32_t nof_prb,
bool crc_is_crnti); bool crc_is_crnti);
LIBLTE_API uint8_t dci_format_sizeof(dci_format_t format, LIBLTE_API uint32_t dci_format_sizeof(dci_format_t format,
uint8_t nof_prb); uint32_t nof_prb);
#endif // DCI_ #endif // DCI_

@ -47,8 +47,8 @@
typedef _Complex float cf_t; typedef _Complex float cf_t;
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
uint8_t nof_ports; uint32_t nof_ports;
uint8_t nof_prb; uint32_t nof_prb;
uint32_t sfn; uint32_t sfn;
phich_length_t phich_length; phich_length_t phich_length;
phich_resources_t phich_resources; phich_resources_t phich_resources;
@ -58,7 +58,7 @@ typedef struct LIBLTE_API {
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
lte_cell_t cell; lte_cell_t cell;
uint8_t nof_symbols; uint32_t nof_symbols;
/* buffers */ /* buffers */
cf_t *ce[MAX_PORTS]; cf_t *ce[MAX_PORTS];
@ -72,7 +72,7 @@ typedef struct LIBLTE_API {
char *data; char *data;
char *data_enc; char *data_enc;
uint8_t frame_idx; uint32_t frame_idx;
/* tx & rx objects */ /* tx & rx objects */
modem_table_t mod; modem_table_t mod;

@ -76,13 +76,13 @@ LIBLTE_API void pcfich_free(pcfich_t *q);
LIBLTE_API int pcfich_decode(pcfich_t *q, LIBLTE_API int pcfich_decode(pcfich_t *q,
cf_t *sf_symbols, cf_t *sf_symbols,
cf_t *ce[MAX_PORTS], cf_t *ce[MAX_PORTS],
uint8_t subframe, uint32_t subframe,
uint8_t *cfi, uint32_t *cfi,
uint8_t *distance); uint32_t *distance);
LIBLTE_API int pcfich_encode(pcfich_t *q, LIBLTE_API int pcfich_encode(pcfich_t *q,
uint8_t cfi, uint32_t cfi,
cf_t *sf_symbols[MAX_PORTS], cf_t *sf_symbols[MAX_PORTS],
uint8_t subframe); uint32_t subframe);
#endif #endif

@ -56,18 +56,18 @@ typedef enum LIBLTE_API {
* DCI messages as defined in Section 7.1 of 36.213 * DCI messages as defined in Section 7.1 of 36.213
*/ */
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
uint8_t nof_candidates; uint32_t nof_candidates;
dci_candidate_t candidates[NSUBFRAMES_X_FRAME][MAX_CANDIDATES]; dci_candidate_t candidates[NSUBFRAMES_X_FRAME][MAX_CANDIDATES];
} pdcch_search_t; } pdcch_search_t;
/* PDCCH object */ /* PDCCH object */
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
lte_cell_t cell; lte_cell_t cell;
uint16_t nof_bits; uint32_t nof_bits;
uint16_t nof_symbols; uint32_t nof_symbols;
uint16_t nof_regs; uint32_t nof_regs;
uint16_t nof_cce; uint32_t nof_cce;
uint16_t max_bits; uint32_t max_bits;
pdcch_search_t search_mode[PDCCH_NOF_SEARCH_MODES]; pdcch_search_t search_mode[PDCCH_NOF_SEARCH_MODES];
pdcch_search_mode_t current_search_mode; pdcch_search_mode_t current_search_mode;
@ -101,8 +101,8 @@ LIBLTE_API void pdcch_free(pdcch_t *q);
LIBLTE_API int pdcch_encode(pdcch_t *q, LIBLTE_API int pdcch_encode(pdcch_t *q,
dci_t *dci, dci_t *dci,
cf_t *slot_symbols[MAX_PORTS], cf_t *slot_symbols[MAX_PORTS],
uint8_t nsubframe, uint32_t nsubframe,
uint8_t cfi); uint32_t cfi);
/* Decoding functions */ /* Decoding functions */
@ -115,18 +115,18 @@ LIBLTE_API int pdcch_decode(pdcch_t *q,
cf_t *slot_symbols, cf_t *slot_symbols,
cf_t *ce[MAX_PORTS], cf_t *ce[MAX_PORTS],
dci_t *dci, dci_t *dci,
uint8_t nsubframe, uint32_t nsubframe,
uint8_t cfi); uint32_t cfi);
LIBLTE_API int pdcch_extract_llr(pdcch_t *q, LIBLTE_API int pdcch_extract_llr(pdcch_t *q,
cf_t *slot_symbols, cf_t *slot_symbols,
cf_t *ce[MAX_PORTS], cf_t *ce[MAX_PORTS],
float *llr, float *llr,
uint8_t nsubframe, uint32_t nsubframe,
uint8_t cfi); uint32_t cfi);
LIBLTE_API int pdcch_init_search_si(pdcch_t *q, LIBLTE_API int pdcch_init_search_si(pdcch_t *q,
uint8_t cfi); uint32_t cfi);
LIBLTE_API void pdcch_set_search_si(pdcch_t *q); LIBLTE_API void pdcch_set_search_si(pdcch_t *q);
@ -136,18 +136,18 @@ LIBLTE_API int pdcch_decode_si(pdcch_t *q,
LIBLTE_API int pdcch_init_search_ue(pdcch_t *q, LIBLTE_API int pdcch_init_search_ue(pdcch_t *q,
uint16_t c_rnti, uint16_t c_rnti,
uint8_t cfi); uint32_t cfi);
LIBLTE_API void pdcch_set_search_ue(pdcch_t *q); LIBLTE_API void pdcch_set_search_ue(pdcch_t *q);
LIBLTE_API int pdcch_decode_ue(pdcch_t *q, LIBLTE_API int pdcch_decode_ue(pdcch_t *q,
float *llr, float *llr,
dci_t *dci, dci_t *dci,
uint8_t nsubframe); uint32_t nsubframe);
LIBLTE_API int pdcch_init_search_ra(pdcch_t *q, LIBLTE_API int pdcch_init_search_ra(pdcch_t *q,
uint16_t ra_rnti, uint16_t ra_rnti,
uint8_t cfi); uint32_t cfi);
LIBLTE_API void pdcch_set_search_ra(pdcch_t *q); LIBLTE_API void pdcch_set_search_ra(pdcch_t *q);

@ -51,7 +51,7 @@ typedef _Complex float cf_t;
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
lte_cell_t cell; lte_cell_t cell;
uint16_t max_symbols; uint32_t max_symbols;
uint16_t rnti; uint16_t rnti;
/* buffers */ /* buffers */
@ -85,7 +85,7 @@ LIBLTE_API void pdsch_free(pdsch_t *q);
LIBLTE_API int pdsch_encode(pdsch_t *q, LIBLTE_API int pdsch_encode(pdsch_t *q,
char *data, char *data,
cf_t *sf_symbols[MAX_PORTS], cf_t *sf_symbols[MAX_PORTS],
uint8_t nsubframe, uint32_t nsubframe,
ra_mcs_t mcs, ra_mcs_t mcs,
ra_prb_t *prb_alloc); ra_prb_t *prb_alloc);
@ -93,7 +93,7 @@ LIBLTE_API int pdsch_decode(pdsch_t *q,
cf_t *sf_symbols, cf_t *sf_symbols,
cf_t *ce[MAX_PORTS], cf_t *ce[MAX_PORTS],
char *data, char *data,
uint8_t nsubframe, uint32_t nsubframe,
ra_mcs_t mcs, ra_mcs_t mcs,
ra_prb_t *prb_alloc); ra_prb_t *prb_alloc);
@ -101,6 +101,6 @@ LIBLTE_API int pdsch_get(pdsch_t *q,
cf_t *sf_symbols, cf_t *sf_symbols,
cf_t *pdsch_symbols, cf_t *pdsch_symbols,
ra_prb_t *prb_alloc, ra_prb_t *prb_alloc,
uint8_t subframe); uint32_t subframe);
#endif #endif

@ -87,22 +87,22 @@ LIBLTE_API void phich_free(phich_t *q);
LIBLTE_API int phich_decode(phich_t *q, LIBLTE_API int phich_decode(phich_t *q,
cf_t *slot_symbols, cf_t *slot_symbols,
cf_t *ce[MAX_PORTS], cf_t *ce[MAX_PORTS],
uint8_t ngroup, uint32_t ngroup,
uint8_t nseq, uint32_t nseq,
uint8_t nsubframe, uint32_t nsubframe,
char *ack, char *ack,
uint8_t *distance); uint32_t *distance);
LIBLTE_API int phich_encode(phich_t *q, LIBLTE_API int phich_encode(phich_t *q,
char ack, char ack,
uint8_t ngroup, uint32_t ngroup,
uint8_t nseq, uint32_t nseq,
uint8_t nsubframe, uint32_t nsubframe,
cf_t *slot_symbols[MAX_PORTS]); cf_t *slot_symbols[MAX_PORTS]);
LIBLTE_API void phich_reset(phich_t *q, LIBLTE_API void phich_reset(phich_t *q,
cf_t *slot_symbols[MAX_PORTS]); cf_t *slot_symbols[MAX_PORTS]);
LIBLTE_API uint8_t phich_ngroups(phich_t *q); LIBLTE_API uint32_t phich_ngroups(phich_t *q);
#endif // PHICH_ #endif // PHICH_

@ -44,8 +44,8 @@ typedef enum LIBLTE_API {
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
ra_mod_t mod; // By default, mod = MOD_NULL and the mcs_idx value is taken by the packing functions ra_mod_t mod; // By default, mod = MOD_NULL and the mcs_idx value is taken by the packing functions
// otherwise mod + tbs values are used to generate the mcs_idx automatically. // otherwise mod + tbs values are used to generate the mcs_idx automatically.
uint8_t tbs_idx; uint32_t tbs_idx;
uint8_t mcs_idx; uint32_t mcs_idx;
uint32_t tbs;// If tbs<=0, the tbs_idx value is taken by the packing functions to generate the DCI uint32_t tbs;// If tbs<=0, the tbs_idx value is taken by the packing functions to generate the DCI
// message. Otherwise the tbs_idx corresponding to the lower nearest TBS is taken. // message. Otherwise the tbs_idx corresponding to the lower nearest TBS is taken.
} ra_mcs_t; } ra_mcs_t;
@ -60,13 +60,13 @@ typedef struct LIBLTE_API {
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
uint32_t vrb_bitmask; uint32_t vrb_bitmask;
uint8_t rbg_subset;bool shift; uint32_t rbg_subset;bool shift;
} ra_type1_t; } ra_type1_t;
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
uint16_t riv; // if L_crb==0, DCI message packer will take this value directly uint32_t riv; // if L_crb==0, DCI message packer will take this value directly
uint8_t L_crb; uint32_t L_crb;
uint8_t RB_start; uint32_t RB_start;
enum { enum {
nprb1a_2 = 0, nprb1a_3 = 1 nprb1a_2 = 0, nprb1a_3 = 1
} n_prb1a; } n_prb1a;
@ -87,8 +87,8 @@ typedef struct LIBLTE_API {
ra_type2_t type2_alloc; ra_type2_t type2_alloc;
}; };
ra_mcs_t mcs; ra_mcs_t mcs;
uint8_t harq_process; uint32_t harq_process;
uint8_t rv_idx; uint32_t rv_idx;
bool ndi; bool ndi;
} ra_pdsch_t; } ra_pdsch_t;
@ -106,7 +106,7 @@ typedef struct LIBLTE_API {
ra_type2_t type2_alloc; ra_type2_t type2_alloc;
ra_mcs_t mcs; ra_mcs_t mcs;
uint8_t rv_idx; // If set to non-zero, a retransmission is requested with the same modulation uint32_t rv_idx; // If set to non-zero, a retransmission is requested with the same modulation
// than before (Format0 message, see also 8.6.1 in 36.2313). // than before (Format0 message, see also 8.6.1 in 36.2313).
bool ndi; bool ndi;
bool cqi_request; bool cqi_request;
@ -114,14 +114,14 @@ typedef struct LIBLTE_API {
} ra_pusch_t; } ra_pusch_t;
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
uint8_t prb_idx[MAX_PRB]; uint32_t prb_idx[MAX_PRB];
uint8_t nof_prb; uint32_t nof_prb;
} ra_prb_slot_t; } ra_prb_slot_t;
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
ra_prb_slot_t slot[2]; ra_prb_slot_t slot[2];
uint8_t lstart; uint32_t lstart;
uint16_t re_sf[NSUBFRAMES_X_FRAME]; uint32_t re_sf[NSUBFRAMES_X_FRAME];
} ra_prb_t; } ra_prb_t;
LIBLTE_API void ra_prb_fprint(FILE *f, LIBLTE_API void ra_prb_fprint(FILE *f,
@ -129,87 +129,87 @@ LIBLTE_API void ra_prb_fprint(FILE *f,
LIBLTE_API int ra_prb_get_dl(ra_prb_t *prb, LIBLTE_API int ra_prb_get_dl(ra_prb_t *prb,
ra_pdsch_t *ra, ra_pdsch_t *ra,
uint8_t nof_prb); uint32_t nof_prb);
LIBLTE_API int ra_prb_get_ul(ra_prb_slot_t *prb, LIBLTE_API int ra_prb_get_ul(ra_prb_slot_t *prb,
ra_pusch_t *ra, ra_pusch_t *ra,
uint8_t nof_prb); uint32_t nof_prb);
LIBLTE_API void ra_prb_get_re_dl(ra_prb_t *prb_dist, LIBLTE_API void ra_prb_get_re_dl(ra_prb_t *prb_dist,
uint8_t nof_prb, uint32_t nof_prb,
uint8_t nof_ports, uint32_t nof_ports,
uint8_t nof_ctrl_symbols, uint32_t nof_ctrl_symbols,
lte_cp_t cp); lte_cp_t cp);
LIBLTE_API uint16_t ra_nprb_dl(ra_pdsch_t *ra, LIBLTE_API uint32_t ra_nprb_dl(ra_pdsch_t *ra,
uint8_t nof_prb); uint32_t nof_prb);
LIBLTE_API uint16_t ra_nprb_ul(ra_pusch_t *ra, LIBLTE_API uint32_t ra_nprb_ul(ra_pusch_t *ra,
uint8_t nof_prb); uint32_t nof_prb);
LIBLTE_API uint8_t ra_mcs_to_table_idx(ra_mcs_t *mcs); LIBLTE_API uint32_t ra_mcs_to_table_idx(ra_mcs_t *mcs);
LIBLTE_API int ra_mcs_from_idx_dl(uint8_t idx, LIBLTE_API int ra_mcs_from_idx_dl(uint32_t idx,
ra_mcs_t *mcs); ra_mcs_t *mcs);
LIBLTE_API int ra_mcs_from_idx_ul(uint8_t idx, LIBLTE_API int ra_mcs_from_idx_ul(uint32_t idx,
ra_mcs_t *mcs); ra_mcs_t *mcs);
LIBLTE_API int ra_tbs_from_idx_format1c(uint8_t tbs_idx); LIBLTE_API int ra_tbs_from_idx_format1c(uint32_t tbs_idx);
LIBLTE_API int ra_tbs_to_table_idx_format1c(uint32_t tbs); LIBLTE_API int ra_tbs_to_table_idx_format1c(uint32_t tbs);
LIBLTE_API int ra_tbs_from_idx(uint8_t tbs_idx, LIBLTE_API int ra_tbs_from_idx(uint32_t tbs_idx,
uint8_t n_prb); uint32_t n_prb);
LIBLTE_API int ra_tbs_to_table_idx(uint32_t tbs, LIBLTE_API int ra_tbs_to_table_idx(uint32_t tbs,
uint8_t n_prb); uint32_t n_prb);
LIBLTE_API uint8_t ra_mcs_to_table_idx(ra_mcs_t *mcs); LIBLTE_API uint32_t ra_mcs_to_table_idx(ra_mcs_t *mcs);
LIBLTE_API int ra_mcs_from_idx_dl(uint8_t idx, LIBLTE_API int ra_mcs_from_idx_dl(uint32_t idx,
ra_mcs_t *mcs); ra_mcs_t *mcs);
LIBLTE_API int ra_mcs_from_idx_ul(uint8_t idx, LIBLTE_API int ra_mcs_from_idx_ul(uint32_t idx,
ra_mcs_t *mcs); ra_mcs_t *mcs);
LIBLTE_API char *ra_mod_string(ra_mod_t mod); LIBLTE_API char *ra_mod_string(ra_mod_t mod);
LIBLTE_API uint8_t ra_type0_P(uint8_t nof_prb); LIBLTE_API uint32_t ra_type0_P(uint32_t nof_prb);
LIBLTE_API uint16_t ra_type2_to_riv(uint8_t L_crb, LIBLTE_API uint32_t ra_type2_to_riv(uint32_t L_crb,
uint8_t RB_start, uint32_t RB_start,
uint8_t nof_prb); uint32_t nof_prb);
LIBLTE_API void ra_type2_from_riv(uint16_t riv, LIBLTE_API void ra_type2_from_riv(uint32_t riv,
uint8_t *L_crb, uint32_t *L_crb,
uint8_t *RB_start, uint32_t *RB_start,
uint8_t nof_prb, uint32_t nof_prb,
uint8_t nof_vrb); uint32_t nof_vrb);
LIBLTE_API uint8_t ra_type2_n_vrb_dl(uint8_t nof_prb, LIBLTE_API uint32_t ra_type2_n_vrb_dl(uint32_t nof_prb,
bool ngap_is_1); bool ngap_is_1);
LIBLTE_API uint8_t ra_type2_n_rb_step(uint8_t nof_prb); LIBLTE_API uint32_t ra_type2_n_rb_step(uint32_t nof_prb);
LIBLTE_API uint8_t ra_type2_ngap(uint8_t nof_prb, LIBLTE_API uint32_t ra_type2_ngap(uint32_t nof_prb,
bool ngap_is_1); bool ngap_is_1);
LIBLTE_API uint8_t ra_type1_N_rb(uint8_t nof_prb); LIBLTE_API uint32_t ra_type1_N_rb(uint32_t nof_prb);
LIBLTE_API void ra_pdsch_set_mcs_index(ra_pdsch_t *ra, LIBLTE_API void ra_pdsch_set_mcs_index(ra_pdsch_t *ra,
uint8_t mcs_idx); uint32_t mcs_idx);
LIBLTE_API void ra_pdsch_set_mcs(ra_pdsch_t *ra, LIBLTE_API void ra_pdsch_set_mcs(ra_pdsch_t *ra,
ra_mod_t mod, ra_mod_t mod,
uint8_t tbs_idx); uint32_t tbs_idx);
LIBLTE_API void ra_pdsch_fprint(FILE *f, LIBLTE_API void ra_pdsch_fprint(FILE *f,
ra_pdsch_t *ra, ra_pdsch_t *ra,
uint8_t nof_prb); uint32_t nof_prb);
LIBLTE_API void ra_pusch_fprint(FILE *f, LIBLTE_API void ra_pusch_fprint(FILE *f,
ra_pusch_t *ra, ra_pusch_t *ra,
uint8_t nof_prb); uint32_t nof_prb);
#endif /* RB_ALLOC_H_ */ #endif /* RB_ALLOC_H_ */

@ -45,23 +45,23 @@
typedef _Complex float cf_t; typedef _Complex float cf_t;
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
uint16_t k[4]; uint32_t k[4];
uint16_t k0; uint32_t k0;
uint8_t l; uint32_t l;
bool assigned; bool assigned;
}regs_reg_t; }regs_reg_t;
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
uint16_t nof_regs; uint32_t nof_regs;
regs_reg_t **regs; regs_reg_t **regs;
}regs_ch_t; }regs_ch_t;
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
lte_cell_t cell; lte_cell_t cell;
uint8_t max_ctrl_symbols; uint32_t max_ctrl_symbols;
uint8_t cfi; uint32_t cfi;
bool cfi_initiated; bool cfi_initiated;
uint8_t ngroups_phich; uint32_t ngroups_phich;
phich_resources_t phich_res; phich_resources_t phich_res;
phich_length_t phich_len; phich_length_t phich_len;
@ -71,7 +71,7 @@ typedef struct LIBLTE_API {
regs_ch_t pdcch[3]; /* PDCCH indexing, permutation and interleaving is computed for regs_ch_t pdcch[3]; /* PDCCH indexing, permutation and interleaving is computed for
the three possible CFI value */ the three possible CFI value */
uint16_t nof_regs; uint32_t nof_regs;
regs_reg_t *regs; regs_reg_t *regs;
}regs_t; }regs_t;
@ -82,10 +82,10 @@ LIBLTE_API int regs_init(regs_t *h,
LIBLTE_API void regs_free(regs_t *h); LIBLTE_API void regs_free(regs_t *h);
LIBLTE_API int regs_set_cfi(regs_t *h, LIBLTE_API int regs_set_cfi(regs_t *h,
uint8_t nof_ctrl_symbols); uint32_t nof_ctrl_symbols);
LIBLTE_API uint16_t regs_pcfich_nregs(regs_t *h); LIBLTE_API uint32_t regs_pcfich_nregs(regs_t *h);
LIBLTE_API int regs_pcfich_put(regs_t *h, LIBLTE_API int regs_pcfich_put(regs_t *h,
cf_t pcfich_symbols[REGS_PCFICH_NSYM], cf_t pcfich_symbols[REGS_PCFICH_NSYM],
cf_t *slot_symbols); cf_t *slot_symbols);
@ -94,22 +94,22 @@ LIBLTE_API int regs_pcfich_get(regs_t *h,
cf_t *slot_symbols, cf_t *slot_symbols,
cf_t pcfich_symbols[REGS_PCFICH_NSYM]); cf_t pcfich_symbols[REGS_PCFICH_NSYM]);
LIBLTE_API uint16_t regs_phich_nregs(regs_t *h); LIBLTE_API uint32_t regs_phich_nregs(regs_t *h);
LIBLTE_API int regs_phich_add(regs_t *h, LIBLTE_API int regs_phich_add(regs_t *h,
cf_t phich_symbols[REGS_PHICH_NSYM], cf_t phich_symbols[REGS_PHICH_NSYM],
uint8_t ngroup, uint32_t ngroup,
cf_t *slot_symbols); cf_t *slot_symbols);
LIBLTE_API int regs_phich_get(regs_t *h, LIBLTE_API int regs_phich_get(regs_t *h,
cf_t *slot_symbols, cf_t *slot_symbols,
cf_t phich_symbols[REGS_PHICH_NSYM], cf_t phich_symbols[REGS_PHICH_NSYM],
uint8_t ngroup); uint32_t ngroup);
LIBLTE_API uint8_t regs_phich_ngroups(regs_t *h); LIBLTE_API uint32_t regs_phich_ngroups(regs_t *h);
LIBLTE_API int regs_phich_reset(regs_t *h, LIBLTE_API int regs_phich_reset(regs_t *h,
cf_t *slot_symbols); cf_t *slot_symbols);
LIBLTE_API int regs_pdcch_nregs(regs_t *h, uint8_t cfi); LIBLTE_API int regs_pdcch_nregs(regs_t *h, uint32_t cfi);
LIBLTE_API int regs_pdcch_put(regs_t *h, LIBLTE_API int regs_pdcch_put(regs_t *h,
cf_t *pdcch_symbols, cf_t *pdcch_symbols,
cf_t *slot_symbols); cf_t *slot_symbols);

@ -55,36 +55,38 @@ enum sync_frame_state { SF_FIND, SF_TRACK };
typedef struct LIBLTE_API { typedef struct LIBLTE_API {
sync_t s; sync_t s;
enum sync_frame_state state; enum sync_frame_state state;
int downsampling; uint32_t downsampling;
resample_arb_t resample; resample_arb_t resample;
unsigned long frame_cnt; unsigned long frame_cnt;
bool fb_wp; bool fb_wp;
int frame_size; uint32_t frame_size;
cf_t *input_buffer; cf_t *input_buffer;
cf_t *input_downsampled; cf_t *input_downsampled;
cfo_t cfocorr; cfo_t cfocorr;
float cur_cfo; float cur_cfo;
int peak_idx; uint32_t peak_idx;
int cell_id; uint32_t cell_id;
float timeoffset; float timeoffset;
int last_found; uint32_t last_found;
int sf_idx; uint32_t sf_idx;
}sync_frame_t; }sync_frame_t;
/* Initializes the automatic tracker, setting the downsampling ratio for the input signal. /* Initializes the automatic tracker, setting the downsampling ratio for the input signal.
* upsampled is the ratio of the provided signal sampling frequency to 1.92 Mhz. E.g. if input is sampled at 3.84 Mhz, * downsampling is the ratio of the provided signal sampling frequency to 1.92 Mhz. E.g. if input is sampled at 3.84 Mhz,
* upsampled should be 2. * downsampling should be 2.
*/ */
LIBLTE_API int sync_frame_init(sync_frame_t *q, int upsampled); LIBLTE_API int sync_frame_init(sync_frame_t *q,
uint32_t downsampling);
LIBLTE_API void sync_frame_free(sync_frame_t *q); LIBLTE_API void sync_frame_free(sync_frame_t *q);
LIBLTE_API void sync_frame_set_threshold(sync_frame_t *q, float threshold); LIBLTE_API void sync_frame_set_threshold(sync_frame_t *q,
float threshold);
LIBLTE_API int sync_frame_cell_id(sync_frame_t *q); LIBLTE_API uint32_t sync_frame_cell_id(sync_frame_t *q);
LIBLTE_API int sync_frame_sfidx(sync_frame_t *q); LIBLTE_API uint32_t sync_frame_sfidx(sync_frame_t *q);
/* Automatically time/freq synchronizes the input signal. Returns 1 if the signal is synched and locked, /* Automatically time/freq synchronizes the input signal. Returns 1 if the signal is synched and locked,
* and fills the output buffer with the time and frequency aligned version of the signal. * and fills the output buffer with the time and frequency aligned version of the signal.
@ -95,7 +97,9 @@ LIBLTE_API int sync_frame_sfidx(sync_frame_t *q);
* *
* The buffer input must have subframe_size samples (used in sync_init) * The buffer input must have subframe_size samples (used in sync_init)
*/ */
LIBLTE_API int sync_frame_push(sync_frame_t *q, cf_t *input, cf_t *output); LIBLTE_API int sync_frame_push(sync_frame_t *q,
cf_t *input,
cf_t *output);
/* Resets the automatic tracker */ /* Resets the automatic tracker */
LIBLTE_API void sync_frame_reset(sync_frame_t *q); LIBLTE_API void sync_frame_reset(sync_frame_t *q);

@ -38,7 +38,7 @@ LIBLTE_API uint32_t bit_unpack(char **bits, int nof_bits);
LIBLTE_API void bit_pack(uint32_t value, char **bits, int nof_bits); LIBLTE_API void bit_pack(uint32_t value, char **bits, int nof_bits);
LIBLTE_API void bit_fprint(FILE *stream, char *bits, int nof_bits); LIBLTE_API void bit_fprint(FILE *stream, char *bits, int nof_bits);
LIBLTE_API unsigned int bit_diff(char *x, char *y, int nbits); LIBLTE_API unsigned int bit_diff(char *x, char *y, int nbits);
LIBLTE_API uint8_t bit_count(uint32_t n); LIBLTE_API uint32_t bit_count(uint32_t n);
#endif // BIT_ #endif // BIT_

@ -39,7 +39,7 @@
#define SLOT_SZ(q) (q->nof_symbols * q->symbol_sz) #define SLOT_SZ(q) (q->nof_symbols * q->symbol_sz)
#define SF_SZ(q) (2 * SLOT_SZ(q)) #define SF_SZ(q) (2 * SLOT_SZ(q))
void chest_fprint(chest_t *q, FILE *stream, uint8_t nslot, uint8_t port_id) { void chest_fprint(chest_t *q, FILE *stream, uint32_t nslot, uint32_t port_id) {
chest_ref_fprint(q, stream, nslot, port_id); chest_ref_fprint(q, stream, nslot, port_id);
chest_recvsig_fprint(q, stream, nslot, port_id); chest_recvsig_fprint(q, stream, nslot, port_id);
chest_ce_fprint(q, stream, nslot, port_id); chest_ce_fprint(q, stream, nslot, port_id);
@ -48,7 +48,7 @@ void chest_fprint(chest_t *q, FILE *stream, uint8_t nslot, uint8_t port_id) {
/* Sets the number of ports to estimate. nof_ports must be smaler than nof_ports /* Sets the number of ports to estimate. nof_ports must be smaler than nof_ports
* used during the call to chest_init(). * used during the call to chest_init().
*/ */
int chest_set_nof_ports(chest_t *q, uint8_t nof_ports) { int chest_set_nof_ports(chest_t *q, uint32_t nof_ports) {
if (nof_ports < q->nof_ports) { if (nof_ports < q->nof_ports) {
q->nof_ports = nof_ports; q->nof_ports = nof_ports;
return LIBLTE_SUCCESS; return LIBLTE_SUCCESS;
@ -57,7 +57,7 @@ int chest_set_nof_ports(chest_t *q, uint8_t nof_ports) {
} }
} }
void chest_ref_fprint(chest_t *q, FILE *stream, uint8_t nslot, uint8_t port_id) { void chest_ref_fprint(chest_t *q, FILE *stream, uint32_t nslot, uint32_t port_id) {
int i; int i;
fprintf(stream, "refs%d=[",port_id); fprintf(stream, "refs%d=[",port_id);
for (i=0;i<q->refsignal[port_id][nslot].nof_refs;i++) { for (i=0;i<q->refsignal[port_id][nslot].nof_refs;i++) {
@ -67,7 +67,7 @@ void chest_ref_fprint(chest_t *q, FILE *stream, uint8_t nslot, uint8_t port_id)
fprintf(stream, "];\n"); fprintf(stream, "];\n");
} }
void chest_recvsig_fprint(chest_t *q, FILE *stream, uint8_t nslot, uint8_t port_id) { void chest_recvsig_fprint(chest_t *q, FILE *stream, uint32_t nslot, uint32_t port_id) {
int i; int i;
fprintf(stream, "recvsig%d=[",port_id); fprintf(stream, "recvsig%d=[",port_id);
for (i=0;i<q->refsignal[port_id][nslot].nof_refs;i++) { for (i=0;i<q->refsignal[port_id][nslot].nof_refs;i++) {
@ -77,7 +77,7 @@ void chest_recvsig_fprint(chest_t *q, FILE *stream, uint8_t nslot, uint8_t port_
fprintf(stream, "];\n"); fprintf(stream, "];\n");
} }
void chest_ce_fprint(chest_t *q, FILE *stream, uint8_t nslot, uint8_t port_id) { void chest_ce_fprint(chest_t *q, FILE *stream, uint32_t nslot, uint32_t port_id) {
int i; int i;
fprintf(stream, "mag%d=[",port_id); fprintf(stream, "mag%d=[",port_id);
for (i=0;i<q->refsignal[port_id][nslot].nof_refs;i++) { for (i=0;i<q->refsignal[port_id][nslot].nof_refs;i++) {
@ -91,7 +91,7 @@ void chest_ce_fprint(chest_t *q, FILE *stream, uint8_t nslot, uint8_t port_id) {
fprintf(stream, "];\n"); fprintf(stream, "];\n");
} }
int chest_ce_ref(chest_t *q, cf_t *input, uint8_t nslot, uint8_t port_id, uint16_t nref) { int chest_ce_ref(chest_t *q, cf_t *input, uint32_t nslot, uint32_t port_id, uint32_t nref) {
int fidx, tidx; int fidx, tidx;
cf_t known_ref, channel_ref; cf_t known_ref, channel_ref;
int ret = LIBLTE_ERROR_INVALID_INPUTS; int ret = LIBLTE_ERROR_INVALID_INPUTS;
@ -128,7 +128,7 @@ int chest_ce_ref(chest_t *q, cf_t *input, uint8_t nslot, uint8_t port_id, uint16
/* Computes channel estimates for each reference in a slot and port. /* Computes channel estimates for each reference in a slot and port.
* Saves the nof_prb * 12 * nof_symbols channel estimates in the array ce * Saves the nof_prb * 12 * nof_symbols channel estimates in the array ce
*/ */
int chest_ce_slot_port(chest_t *q, cf_t *input, cf_t *ce, uint8_t nslot, uint8_t port_id) { int chest_ce_slot_port(chest_t *q, cf_t *input, cf_t *ce, uint32_t nslot, uint32_t port_id) {
int i, j; int i, j;
cf_t x[2], y[MAX_NSYMB]; cf_t x[2], y[MAX_NSYMB];
@ -183,7 +183,7 @@ int chest_ce_slot_port(chest_t *q, cf_t *input, cf_t *ce, uint8_t nslot, uint8_t
/* Computes channel estimates for each reference in a subframe and port id. /* Computes channel estimates for each reference in a subframe and port id.
*/ */
int chest_ce_sf_port(chest_t *q, cf_t *input, cf_t *ce, uint8_t sf_idx, uint8_t port_id) { int chest_ce_sf_port(chest_t *q, cf_t *input, cf_t *ce, uint32_t sf_idx, uint32_t port_id) {
int n, slotsz, ret; int n, slotsz, ret;
slotsz = q->nof_symbols*q->nof_re; slotsz = q->nof_symbols*q->nof_re;
for (n=0;n<2;n++) { for (n=0;n<2;n++) {
@ -197,7 +197,7 @@ int chest_ce_sf_port(chest_t *q, cf_t *input, cf_t *ce, uint8_t sf_idx, uint8_t
/* Computes channel estimates for each reference in a slot for all ports. /* Computes channel estimates for each reference in a slot for all ports.
*/ */
int chest_ce_slot(chest_t *q, cf_t *input, cf_t **ce, uint8_t nslot) { int chest_ce_slot(chest_t *q, cf_t *input, cf_t **ce, uint32_t nslot) {
int p, ret; int p, ret;
for (p=0;p<q->nof_ports;p++) { for (p=0;p<q->nof_ports;p++) {
ret = chest_ce_slot_port(q, input, ce[p], nslot, p); ret = chest_ce_slot_port(q, input, ce[p], nslot, p);
@ -210,7 +210,7 @@ int chest_ce_slot(chest_t *q, cf_t *input, cf_t **ce, uint8_t nslot) {
/* Computes channel estimates for each reference in a subframe for all ports. /* Computes channel estimates for each reference in a subframe for all ports.
*/ */
int chest_ce_sf(chest_t *q, cf_t *input, cf_t *ce[MAX_PORTS], uint8_t sf_idx) { int chest_ce_sf(chest_t *q, cf_t *input, cf_t *ce[MAX_PORTS], uint32_t sf_idx) {
int p, n, slotsz, ret; int p, n, slotsz, ret;
slotsz = q->nof_symbols*q->nof_re; slotsz = q->nof_symbols*q->nof_re;
for (p=0;p<q->nof_ports;p++) { for (p=0;p<q->nof_ports;p++) {
@ -224,7 +224,7 @@ int chest_ce_sf(chest_t *q, cf_t *input, cf_t *ce[MAX_PORTS], uint8_t sf_idx) {
return LIBLTE_SUCCESS; return LIBLTE_SUCCESS;
} }
int chest_init(chest_t *q, chest_interp_t interp, uint16_t nof_re, uint8_t nof_symbols, uint8_t nof_ports) { int chest_init(chest_t *q, chest_interp_t interp, uint32_t nof_re, uint32_t nof_symbols, uint32_t nof_ports) {
int ret = LIBLTE_ERROR_INVALID_INPUTS; int ret = LIBLTE_ERROR_INVALID_INPUTS;
if (q != NULL && if (q != NULL &&
@ -259,7 +259,7 @@ int chest_init_LTEDL(chest_t *q, chest_interp_t interp, lte_cell_t cell) {
} }
} }
int chest_ref_LTEDL_slot_port(chest_t *q, uint8_t nslot, uint8_t port_id, lte_cell_t cell) { int chest_ref_LTEDL_slot_port(chest_t *q, uint32_t nslot, uint32_t port_id, lte_cell_t cell) {
int ret = LIBLTE_ERROR_INVALID_INPUTS; int ret = LIBLTE_ERROR_INVALID_INPUTS;
if (q != NULL && if (q != NULL &&
@ -271,7 +271,7 @@ int chest_ref_LTEDL_slot_port(chest_t *q, uint8_t nslot, uint8_t port_id, lte_ce
return ret; return ret;
} }
int chest_ref_LTEDL_slot(chest_t *q, uint8_t nslot, lte_cell_t cell) { int chest_ref_LTEDL_slot(chest_t *q, uint32_t nslot, lte_cell_t cell) {
int p, ret; int p, ret;
for (p=0;p<q->nof_ports;p++) { for (p=0;p<q->nof_ports;p++) {
ret = chest_ref_LTEDL_slot_port(q, nslot, p, cell); ret = chest_ref_LTEDL_slot_port(q, nslot, p, cell);
@ -306,13 +306,13 @@ void chest_free(chest_t *q) {
/* Fills l[2] with the symbols in the slot nslot that contain references. /* Fills l[2] with the symbols in the slot nslot that contain references.
* returns the number of symbols with references (in the slot) * returns the number of symbols with references (in the slot)
*/ */
int chest_ref_symbols(chest_t *q, uint8_t port_id, uint8_t nslot, uint8_t l[2]) { int chest_ref_symbols(chest_t *q, uint32_t port_id, uint32_t nslot, uint32_t l[2]) {
if (q != NULL && if (q != NULL &&
port_id < MAX_PORTS && port_id < MAX_PORTS &&
nslot < NSLOTS_X_FRAME) nslot < NSLOTS_X_FRAME)
{ {
memcpy(l, q->refsignal[port_id][nslot].symbols_ref, sizeof(uint8_t) * q->refsignal[port_id][nslot].nsymbols); memcpy(l, q->refsignal[port_id][nslot].symbols_ref, sizeof(uint32_t) * q->refsignal[port_id][nslot].nsymbols);
return q->refsignal[port_id][nslot].nsymbols; return q->refsignal[port_id][nslot].nsymbols;
} else { } else {
return LIBLTE_ERROR_INVALID_INPUTS; return LIBLTE_ERROR_INVALID_INPUTS;

@ -40,7 +40,7 @@
#define idx(x, y) (l*nof_refs_x_symbol+i) #define idx(x, y) (l*nof_refs_x_symbol+i)
int refsignal_v(uint8_t port_id, uint8_t ns, uint8_t symbol_id) { int refsignal_v(uint32_t port_id, uint32_t ns, uint32_t symbol_id) {
int v=-1; int v=-1;
switch(port_id) { switch(port_id) {
case 0: case 0:
@ -67,13 +67,13 @@ int refsignal_v(uint8_t port_id, uint8_t ns, uint8_t symbol_id) {
return v; return v;
} }
int refsignal_k(int m, int v, uint16_t cell_id) { int refsignal_k(int m, int v, uint32_t cell_id) {
return 6*m+((v+(cell_id%6))%6); return 6*m+((v+(cell_id%6))%6);
} }
int refsignal_put(refsignal_t *q, cf_t *slot_symbols) { int refsignal_put(refsignal_t *q, cf_t *slot_symbols) {
int i; int i;
uint16_t fidx, tidx; uint32_t fidx, tidx;
if (q != NULL && if (q != NULL &&
slot_symbols != NULL) slot_symbols != NULL)
{ {
@ -91,18 +91,18 @@ int refsignal_put(refsignal_t *q, cf_t *slot_symbols) {
/** Initializes refsignal_t object according to 3GPP 36.211 6.10.1 /** Initializes refsignal_t object according to 3GPP 36.211 6.10.1
* *
*/ */
int refsignal_init_LTEDL(refsignal_t *q, uint8_t port_id, uint8_t nslot, int refsignal_init_LTEDL(refsignal_t *q, uint32_t port_id, uint32_t nslot,
lte_cell_t cell) { lte_cell_t cell) {
uint32_t c_init; uint32_t c_init;
uint8_t ns, l, lp[2]; uint32_t ns, l, lp[2];
int N_cp; int N_cp;
int i; int i;
int ret = LIBLTE_ERROR_INVALID_INPUTS; int ret = LIBLTE_ERROR_INVALID_INPUTS;
sequence_t seq; sequence_t seq;
int v; int v;
int mp; int mp;
uint8_t nof_refs_x_symbol, nof_ref_symbols; uint32_t nof_refs_x_symbol, nof_ref_symbols;
if (q != NULL && if (q != NULL &&
port_id < MAX_PORTS && port_id < MAX_PORTS &&
@ -134,13 +134,13 @@ int refsignal_init_LTEDL(refsignal_t *q, uint8_t port_id, uint8_t nslot,
q->voffset = cell.id%6; q->voffset = cell.id%6;
q->nof_prb = cell.nof_prb; q->nof_prb = cell.nof_prb;
q->symbols_ref = malloc(sizeof(uint8_t) * nof_ref_symbols); q->symbols_ref = malloc(sizeof(uint32_t) * nof_ref_symbols);
if (!q->symbols_ref) { if (!q->symbols_ref) {
perror("malloc"); perror("malloc");
goto free_and_exit; goto free_and_exit;
} }
memcpy(q->symbols_ref, lp, sizeof(uint8_t) * nof_ref_symbols); memcpy(q->symbols_ref, lp, sizeof(uint32_t) * nof_ref_symbols);
q->refs = vec_malloc(q->nof_refs * sizeof(ref_t)); q->refs = vec_malloc(q->nof_refs * sizeof(ref_t));
if (!q->refs) { if (!q->refs) {

@ -40,7 +40,7 @@
#include "liblte/phy/utils/vector.h" #include "liblte/phy/utils/vector.h"
#include "liblte/phy/utils/debug.h" #include "liblte/phy/utils/debug.h"
int dci_init(dci_t *q, uint8_t max_dcis) { int dci_init(dci_t *q, uint32_t max_dcis) {
q->msg = calloc(sizeof(dci_msg_t), max_dcis); q->msg = calloc(sizeof(dci_msg_t), max_dcis);
if (!q->msg) { if (!q->msg) {
perror("malloc"); perror("malloc");
@ -62,7 +62,7 @@ void dci_candidate_fprint(FILE *f, dci_candidate_t *q) {
q->nof_bits); q->nof_bits);
} }
int dci_msg_candidate_set(dci_msg_t *msg, uint8_t L, uint8_t nCCE, uint16_t rnti) { int dci_msg_candidate_set(dci_msg_t *msg, uint32_t L, uint32_t nCCE, uint16_t rnti) {
if (L >= 0 && L <= 3) { if (L >= 0 && L <= 3) {
msg->location.L = L; msg->location.L = L;
} else { } else {
@ -79,13 +79,13 @@ int dci_msg_candidate_set(dci_msg_t *msg, uint8_t L, uint8_t nCCE, uint16_t rnti
return LIBLTE_SUCCESS; return LIBLTE_SUCCESS;
} }
uint8_t riv_nbits(uint8_t nof_prb) { uint32_t riv_nbits(uint32_t nof_prb) {
return (uint8_t) ceilf(log2f((float) nof_prb * ((float) nof_prb + 1) / 2)); return (uint32_t) ceilf(log2f((float) nof_prb * ((float) nof_prb + 1) / 2));
} }
const uint8_t ambiguous_sizes[10] = { 12, 14, 16, 20, 24, 26, 32, 40, 44, 56 }; const uint32_t ambiguous_sizes[10] = { 12, 14, 16, 20, 24, 26, 32, 40, 44, 56 };
bool is_ambiguous_size(uint8_t size) { bool is_ambiguous_size(uint32_t size) {
int i; int i;
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
if (size == ambiguous_sizes[i]) { if (size == ambiguous_sizes[i]) {
@ -98,12 +98,12 @@ bool is_ambiguous_size(uint8_t size) {
/********************************** /**********************************
* PAYLOAD sizeof functions * PAYLOAD sizeof functions
* ********************************/ * ********************************/
uint8_t dci_format0_sizeof_(uint8_t nof_prb) { uint32_t dci_format0_sizeof_(uint32_t nof_prb) {
return 1 + 1 + riv_nbits(nof_prb) + 5 + 1 + 2 + 3 + 1; return 1 + 1 + riv_nbits(nof_prb) + 5 + 1 + 2 + 3 + 1;
} }
uint8_t dci_format1A_sizeof(uint8_t nof_prb) { uint32_t dci_format1A_sizeof(uint32_t nof_prb) {
uint8_t n; uint32_t n;
n = 1 + 1 + riv_nbits(nof_prb) + 5 + 3 + 1 + 2 + 2; n = 1 + 1 + riv_nbits(nof_prb) + 5 + 3 + 1 + 2 + 2;
while (n < dci_format0_sizeof_(nof_prb)) { while (n < dci_format0_sizeof_(nof_prb)) {
n++; n++;
@ -114,17 +114,17 @@ uint8_t dci_format1A_sizeof(uint8_t nof_prb) {
return n; return n;
} }
uint8_t dci_format0_sizeof(uint8_t nof_prb) { uint32_t dci_format0_sizeof(uint32_t nof_prb) {
uint8_t n = dci_format0_sizeof_(nof_prb); uint32_t n = dci_format0_sizeof_(nof_prb);
while (n < dci_format1A_sizeof(nof_prb)) { while (n < dci_format1A_sizeof(nof_prb)) {
n++; n++;
} }
return n; return n;
} }
uint8_t dci_format1_sizeof(uint8_t nof_prb) { uint32_t dci_format1_sizeof(uint32_t nof_prb) {
uint8_t n = (uint8_t) ceilf((float) nof_prb / ra_type0_P(nof_prb)) + 5 + 3 + 1 + 2 uint32_t n = (uint32_t) ceilf((float) nof_prb / ra_type0_P(nof_prb)) + 5 + 3 + 1 + 2
+ 2; + 2;
if (nof_prb > 10) { if (nof_prb > 10) {
n++; n++;
@ -136,17 +136,17 @@ uint8_t dci_format1_sizeof(uint8_t nof_prb) {
return n; return n;
} }
uint8_t dci_format1C_sizeof(uint8_t nof_prb) { uint32_t dci_format1C_sizeof(uint32_t nof_prb) {
uint8_t n_vrb_dl_gap1 = ra_type2_n_vrb_dl(nof_prb, true); uint32_t n_vrb_dl_gap1 = ra_type2_n_vrb_dl(nof_prb, true);
uint8_t n_step = ra_type2_n_rb_step(nof_prb); uint32_t n_step = ra_type2_n_rb_step(nof_prb);
uint8_t n = riv_nbits((uint8_t) n_vrb_dl_gap1 / n_step) + 5; uint32_t n = riv_nbits((uint32_t) n_vrb_dl_gap1 / n_step) + 5;
if (nof_prb >= 50) { if (nof_prb >= 50) {
n++; n++;
} }
return n; return n;
} }
uint8_t dci_format_sizeof(dci_format_t format, uint8_t nof_prb) { uint32_t dci_format_sizeof(dci_format_t format, uint32_t nof_prb) {
switch (format) { switch (format) {
case Format0: case Format0:
return dci_format0_sizeof(nof_prb); return dci_format0_sizeof(nof_prb);
@ -170,11 +170,11 @@ uint8_t dci_format_sizeof(dci_format_t format, uint8_t nof_prb) {
* *
* TODO: TPC and cyclic shift for DM RS not implemented * TODO: TPC and cyclic shift for DM RS not implemented
*/ */
int dci_format0_pack(ra_pusch_t *data, dci_msg_t *msg, uint8_t nof_prb) { int dci_format0_pack(ra_pusch_t *data, dci_msg_t *msg, uint32_t nof_prb) {
/* pack bits */ /* pack bits */
char *y = msg->data; char *y = msg->data;
uint8_t n_ul_hop; uint32_t n_ul_hop;
*y++ = 0; // format differentiation *y++ = 0; // format differentiation
if (data->freq_hop_fl == hop_disabled) { // frequency hopping if (data->freq_hop_fl == hop_disabled) { // frequency hopping
@ -193,7 +193,7 @@ int dci_format0_pack(ra_pusch_t *data, dci_msg_t *msg, uint8_t nof_prb) {
} }
/* pack RIV according to 8.1 of 36.213 */ /* pack RIV according to 8.1 of 36.213 */
uint16_t riv; uint32_t riv;
if (data->type2_alloc.L_crb) { if (data->type2_alloc.L_crb) {
riv = ra_type2_to_riv(data->type2_alloc.L_crb, data->type2_alloc.RB_start, riv = ra_type2_to_riv(data->type2_alloc.L_crb, data->type2_alloc.RB_start,
nof_prb); nof_prb);
@ -203,7 +203,7 @@ int dci_format0_pack(ra_pusch_t *data, dci_msg_t *msg, uint8_t nof_prb) {
bit_pack((uint32_t) riv, &y, riv_nbits(nof_prb) - n_ul_hop); bit_pack((uint32_t) riv, &y, riv_nbits(nof_prb) - n_ul_hop);
/* pack MCS according to 8.6.1 of 36.213 */ /* pack MCS according to 8.6.1 of 36.213 */
uint8_t mcs; uint32_t mcs;
if (data->cqi_request) { if (data->cqi_request) {
mcs = 29; mcs = 29;
} else { } else {
@ -241,7 +241,7 @@ int dci_format0_pack(ra_pusch_t *data, dci_msg_t *msg, uint8_t nof_prb) {
*y++ = data->cqi_request; *y++ = data->cqi_request;
// Padding with zeros // Padding with zeros
uint8_t n = dci_format0_sizeof(nof_prb); uint32_t n = dci_format0_sizeof(nof_prb);
while (y - msg->data < n) { while (y - msg->data < n) {
*y++ = 0; *y++ = 0;
} }
@ -253,11 +253,11 @@ int dci_format0_pack(ra_pusch_t *data, dci_msg_t *msg, uint8_t nof_prb) {
* *
* TODO: TPC and cyclic shift for DM RS not implemented * TODO: TPC and cyclic shift for DM RS not implemented
*/ */
int dci_format0_unpack(dci_msg_t *msg, ra_pusch_t *data, uint8_t nof_prb) { int dci_format0_unpack(dci_msg_t *msg, ra_pusch_t *data, uint32_t nof_prb) {
/* pack bits */ /* pack bits */
char *y = msg->data; char *y = msg->data;
uint8_t n_ul_hop; uint32_t n_ul_hop;
/* Make sure it's a Format0 message */ /* Make sure it's a Format0 message */
if (msg->location.nof_bits != dci_format_sizeof(Format0, nof_prb)) { if (msg->location.nof_bits != dci_format_sizeof(Format0, nof_prb)) {
@ -283,14 +283,14 @@ int dci_format0_unpack(dci_msg_t *msg, ra_pusch_t *data, uint8_t nof_prb) {
} }
} }
/* unpack RIV according to 8.1 of 36.213 */ /* unpack RIV according to 8.1 of 36.213 */
uint16_t riv = bit_unpack(&y, riv_nbits(nof_prb) - n_ul_hop); uint32_t riv = bit_unpack(&y, riv_nbits(nof_prb) - n_ul_hop);
ra_type2_from_riv(riv, &data->type2_alloc.L_crb, &data->type2_alloc.RB_start, ra_type2_from_riv(riv, &data->type2_alloc.L_crb, &data->type2_alloc.RB_start,
nof_prb, nof_prb); nof_prb, nof_prb);
bit_pack((uint32_t) riv, &y, riv_nbits(nof_prb) - n_ul_hop); bit_pack((uint32_t) riv, &y, riv_nbits(nof_prb) - n_ul_hop);
data->type2_alloc.riv = riv; data->type2_alloc.riv = riv;
/* unpack MCS according to 8.6 of 36.213 */ /* unpack MCS according to 8.6 of 36.213 */
uint8_t mcs = bit_unpack(&y, 5); uint32_t mcs = bit_unpack(&y, 5);
data->ndi = *y++ ? true : false; data->ndi = *y++ ? true : false;
@ -326,7 +326,7 @@ int dci_format0_unpack(dci_msg_t *msg, ra_pusch_t *data, uint8_t nof_prb) {
* TODO: TPC commands * TODO: TPC commands
*/ */
int dci_format1_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb) { int dci_format1_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb) {
/* pack bits */ /* pack bits */
char *y = msg->data; char *y = msg->data;
@ -336,8 +336,8 @@ int dci_format1_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb) {
} }
/* Resource allocation: type0 or type 1 */ /* Resource allocation: type0 or type 1 */
uint8_t P = ra_type0_P(nof_prb); uint32_t P = ra_type0_P(nof_prb);
uint8_t alloc_size = (uint8_t) ceilf((float) nof_prb / P); uint32_t alloc_size = (uint32_t) ceilf((float) nof_prb / P);
switch (data->alloc_type) { switch (data->alloc_type) {
case alloc_type0: case alloc_type0:
bit_pack((uint32_t) data->type0_alloc.rbg_bitmask, &y, alloc_size); bit_pack((uint32_t) data->type0_alloc.rbg_bitmask, &y, alloc_size);
@ -355,7 +355,7 @@ int dci_format1_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb) {
} }
/* pack MCS according to 7.1.7 of 36.213 */ /* pack MCS according to 7.1.7 of 36.213 */
uint8_t mcs; uint32_t mcs;
if (data->mcs.mod == MOD_NULL) { if (data->mcs.mod == MOD_NULL) {
mcs = data->mcs.mcs_idx; mcs = data->mcs.mcs_idx;
} else { } else {
@ -381,7 +381,7 @@ int dci_format1_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb) {
*y++ = 0; *y++ = 0;
// Padding with zeros // Padding with zeros
uint8_t n = dci_format1_sizeof(nof_prb); uint32_t n = dci_format1_sizeof(nof_prb);
while (y - msg->data < n) { while (y - msg->data < n) {
*y++ = 0; *y++ = 0;
} }
@ -390,7 +390,7 @@ int dci_format1_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb) {
return LIBLTE_SUCCESS; return LIBLTE_SUCCESS;
} }
int dci_format1_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint8_t nof_prb) { int dci_format1_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint32_t nof_prb) {
/* pack bits */ /* pack bits */
char *y = msg->data; char *y = msg->data;
@ -408,8 +408,8 @@ int dci_format1_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint8_t nof_prb) {
} }
/* Resource allocation: type0 or type 1 */ /* Resource allocation: type0 or type 1 */
uint8_t P = ra_type0_P(nof_prb); uint32_t P = ra_type0_P(nof_prb);
uint8_t alloc_size = (uint8_t) ceilf((float) nof_prb / P); uint32_t alloc_size = (uint32_t) ceilf((float) nof_prb / P);
switch (data->alloc_type) { switch (data->alloc_type) {
case alloc_type0: case alloc_type0:
data->type0_alloc.rbg_bitmask = bit_unpack(&y, alloc_size); data->type0_alloc.rbg_bitmask = bit_unpack(&y, alloc_size);
@ -426,7 +426,7 @@ int dci_format1_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint8_t nof_prb) {
} }
/* unpack MCS according to 7.1.7 of 36.213 */ /* unpack MCS according to 7.1.7 of 36.213 */
uint8_t mcs = bit_unpack(&y, 5); uint32_t mcs = bit_unpack(&y, 5);
data->mcs.mcs_idx = mcs; data->mcs.mcs_idx = mcs;
if (ra_mcs_from_idx_dl(mcs, &data->mcs)) { if (ra_mcs_from_idx_dl(mcs, &data->mcs)) {
fprintf(stderr, "Error getting MCS\n"); fprintf(stderr, "Error getting MCS\n");
@ -457,7 +457,7 @@ int dci_format1_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint8_t nof_prb) {
* *
* TODO: RA procedure initiated by PDCCH, TPC commands * TODO: RA procedure initiated by PDCCH, TPC commands
*/ */
int dci_format1As_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb, int dci_format1As_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb,
bool crc_is_crnti) { bool crc_is_crnti) {
/* pack bits */ /* pack bits */
@ -479,7 +479,7 @@ int dci_format1As_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb,
return LIBLTE_ERROR; return LIBLTE_ERROR;
} }
} else { } else {
uint8_t n_vrb_dl; uint32_t n_vrb_dl;
if (crc_is_crnti && nof_prb > 50) { if (crc_is_crnti && nof_prb > 50) {
n_vrb_dl = 16; n_vrb_dl = 16;
} else { } else {
@ -493,14 +493,14 @@ int dci_format1As_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb,
} }
} }
/* pack RIV according to 7.1.6.3 of 36.213 */ /* pack RIV according to 7.1.6.3 of 36.213 */
uint16_t riv; uint32_t riv;
if (data->type2_alloc.L_crb) { if (data->type2_alloc.L_crb) {
riv = ra_type2_to_riv(data->type2_alloc.L_crb, data->type2_alloc.RB_start, riv = ra_type2_to_riv(data->type2_alloc.L_crb, data->type2_alloc.RB_start,
nof_prb); nof_prb);
} else { } else {
riv = data->type2_alloc.riv; riv = data->type2_alloc.riv;
} }
uint8_t nb_gap = 0; uint32_t nb_gap = 0;
if (crc_is_crnti && data->type2_alloc.mode == t2_dist && nof_prb >= 50) { if (crc_is_crnti && data->type2_alloc.mode == t2_dist && nof_prb >= 50) {
nb_gap = 1; nb_gap = 1;
*y++ = data->type2_alloc.n_gap; *y++ = data->type2_alloc.n_gap;
@ -508,13 +508,13 @@ int dci_format1As_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb,
bit_pack((uint32_t) riv, &y, riv_nbits(nof_prb) - nb_gap); bit_pack((uint32_t) riv, &y, riv_nbits(nof_prb) - nb_gap);
// in format1A, MCS = TBS according to 7.1.7.2 of 36.213 // in format1A, MCS = TBS according to 7.1.7.2 of 36.213
uint8_t mcs; uint32_t mcs;
if (data->mcs.mod == MOD_NULL) { if (data->mcs.mod == MOD_NULL) {
mcs = data->mcs.mcs_idx; mcs = data->mcs.mcs_idx;
} else { } else {
if (data->mcs.tbs) { if (data->mcs.tbs) {
// In format 1A, n_prb_1a is 2 or 3 if crc is not scrambled with C-RNTI // In format 1A, n_prb_1a is 2 or 3 if crc is not scrambled with C-RNTI
uint8_t n_prb; uint32_t n_prb;
if (!crc_is_crnti) { if (!crc_is_crnti) {
n_prb = ra_nprb_dl(data, nof_prb); n_prb = ra_nprb_dl(data, nof_prb);
} else { } else {
@ -547,7 +547,7 @@ int dci_format1As_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb,
} }
// Padding with zeros // Padding with zeros
uint8_t n = dci_format1A_sizeof(nof_prb); uint32_t n = dci_format1A_sizeof(nof_prb);
while (y - msg->data < n) { while (y - msg->data < n) {
*y++ = 0; *y++ = 0;
} }
@ -559,7 +559,7 @@ int dci_format1As_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb,
/* Unpacks DCI format 1A for compact scheduling of PDSCH words according to 36.212 5.3.3.1.3 /* Unpacks DCI format 1A for compact scheduling of PDSCH words according to 36.212 5.3.3.1.3
* *
*/ */
int dci_format1As_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint8_t nof_prb, int dci_format1As_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint32_t nof_prb,
bool crc_is_crnti) { bool crc_is_crnti) {
/* pack bits */ /* pack bits */
@ -583,18 +583,18 @@ int dci_format1As_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint8_t nof_prb,
data->type2_alloc.n_gap = t2_ng1; data->type2_alloc.n_gap = t2_ng1;
/* unpack RIV according to 7.1.6.3 of 36.213 */ /* unpack RIV according to 7.1.6.3 of 36.213 */
uint8_t nb_gap = 0; uint32_t nb_gap = 0;
if (crc_is_crnti && data->type2_alloc.mode == t2_dist && nof_prb >= 50) { if (crc_is_crnti && data->type2_alloc.mode == t2_dist && nof_prb >= 50) {
nb_gap = 1; nb_gap = 1;
data->type2_alloc.n_gap = *y++; data->type2_alloc.n_gap = *y++;
} }
uint8_t nof_vrb; uint32_t nof_vrb;
if (data->type2_alloc.mode == t2_loc) { if (data->type2_alloc.mode == t2_loc) {
nof_vrb = nof_prb; nof_vrb = nof_prb;
} else { } else {
nof_vrb = ra_type2_n_vrb_dl(nof_prb, data->type2_alloc.n_gap == t2_ng1); nof_vrb = ra_type2_n_vrb_dl(nof_prb, data->type2_alloc.n_gap == t2_ng1);
} }
uint16_t riv = bit_unpack(&y, riv_nbits(nof_prb) - nb_gap); uint32_t riv = bit_unpack(&y, riv_nbits(nof_prb) - nb_gap);
ra_type2_from_riv(riv, &data->type2_alloc.L_crb, &data->type2_alloc.RB_start, ra_type2_from_riv(riv, &data->type2_alloc.L_crb, &data->type2_alloc.RB_start,
nof_prb, nof_vrb); nof_prb, nof_vrb);
data->type2_alloc.riv = riv; data->type2_alloc.riv = riv;
@ -623,7 +623,7 @@ int dci_format1As_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint8_t nof_prb,
} }
data->mcs.tbs_idx = data->mcs.mcs_idx; data->mcs.tbs_idx = data->mcs.mcs_idx;
uint8_t n_prb; uint32_t n_prb;
if (crc_is_crnti) { if (crc_is_crnti) {
n_prb = ra_nprb_dl(data, nof_prb); n_prb = ra_nprb_dl(data, nof_prb);
} else { } else {
@ -638,7 +638,7 @@ int dci_format1As_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint8_t nof_prb,
/* Format 1C for compact scheduling of PDSCH words /* Format 1C for compact scheduling of PDSCH words
* *
*/ */
int dci_format1Cs_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb) { int dci_format1Cs_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb) {
/* pack bits */ /* pack bits */
char *y = msg->data; char *y = msg->data;
@ -652,12 +652,12 @@ int dci_format1Cs_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb) {
if (nof_prb >= 50) { if (nof_prb >= 50) {
*y++ = data->type2_alloc.n_gap; *y++ = data->type2_alloc.n_gap;
} }
uint8_t n_step = ra_type2_n_rb_step(nof_prb); uint32_t n_step = ra_type2_n_rb_step(nof_prb);
uint8_t n_vrb_dl = ra_type2_n_vrb_dl(nof_prb, data->type2_alloc.n_gap == t2_ng1); uint32_t n_vrb_dl = ra_type2_n_vrb_dl(nof_prb, data->type2_alloc.n_gap == t2_ng1);
if (data->type2_alloc.L_crb > ((uint8_t) n_vrb_dl / n_step) * n_step) { if (data->type2_alloc.L_crb > ((uint32_t) n_vrb_dl / n_step) * n_step) {
fprintf(stderr, "L_CRB=%d can not exceed N_vrb_dl=%d for distributed type2\n", fprintf(stderr, "L_CRB=%d can not exceed N_vrb_dl=%d for distributed type2\n",
data->type2_alloc.L_crb, ((uint8_t) n_vrb_dl / n_step) * n_step); data->type2_alloc.L_crb, ((uint32_t) n_vrb_dl / n_step) * n_step);
return LIBLTE_ERROR; return LIBLTE_ERROR;
} }
if (data->type2_alloc.L_crb % n_step) { if (data->type2_alloc.L_crb % n_step) {
@ -668,11 +668,11 @@ int dci_format1Cs_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb) {
fprintf(stderr, "RB_start must be multiple of n_step\n"); fprintf(stderr, "RB_start must be multiple of n_step\n");
return LIBLTE_ERROR; return LIBLTE_ERROR;
} }
uint8_t L_p = data->type2_alloc.L_crb / n_step; uint32_t L_p = data->type2_alloc.L_crb / n_step;
uint8_t RB_p = data->type2_alloc.RB_start / n_step; uint32_t RB_p = data->type2_alloc.RB_start / n_step;
uint8_t n_vrb_p = (int) n_vrb_dl / n_step; uint32_t n_vrb_p = (int) n_vrb_dl / n_step;
uint16_t riv; uint32_t riv;
if (data->type2_alloc.L_crb) { if (data->type2_alloc.L_crb) {
riv = ra_type2_to_riv(L_p, RB_p, n_vrb_p); riv = ra_type2_to_riv(L_p, RB_p, n_vrb_p);
} else { } else {
@ -681,7 +681,7 @@ int dci_format1Cs_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb) {
bit_pack((uint32_t) riv, &y, riv_nbits((int) n_vrb_dl / n_step)); bit_pack((uint32_t) riv, &y, riv_nbits((int) n_vrb_dl / n_step));
// in format1C, MCS = TBS according to 7.1.7.2 of 36.213 // in format1C, MCS = TBS according to 7.1.7.2 of 36.213
uint8_t mcs; uint32_t mcs;
if (data->mcs.mod == MOD_NULL) { if (data->mcs.mod == MOD_NULL) {
mcs = data->mcs.mcs_idx; mcs = data->mcs.mcs_idx;
} else { } else {
@ -697,8 +697,8 @@ int dci_format1Cs_pack(ra_pdsch_t *data, dci_msg_t *msg, uint8_t nof_prb) {
return LIBLTE_SUCCESS; return LIBLTE_SUCCESS;
} }
int dci_format1Cs_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint8_t nof_prb) { int dci_format1Cs_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint32_t nof_prb) {
uint8_t L_p, RB_p; uint32_t L_p, RB_p;
/* pack bits */ /* pack bits */
char *y = msg->data; char *y = msg->data;
@ -712,11 +712,11 @@ int dci_format1Cs_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint8_t nof_prb) {
if (nof_prb >= 50) { if (nof_prb >= 50) {
data->type2_alloc.n_gap = *y++; data->type2_alloc.n_gap = *y++;
} }
uint8_t n_step = ra_type2_n_rb_step(nof_prb); uint32_t n_step = ra_type2_n_rb_step(nof_prb);
uint8_t n_vrb_dl = ra_type2_n_vrb_dl(nof_prb, data->type2_alloc.n_gap == t2_ng1); uint32_t n_vrb_dl = ra_type2_n_vrb_dl(nof_prb, data->type2_alloc.n_gap == t2_ng1);
uint16_t riv = bit_unpack(&y, riv_nbits((int) n_vrb_dl / n_step)); uint32_t riv = bit_unpack(&y, riv_nbits((int) n_vrb_dl / n_step));
uint8_t n_vrb_p = (uint8_t) n_vrb_dl / n_step; uint32_t n_vrb_p = (uint32_t) n_vrb_dl / n_step;
ra_type2_from_riv(riv, &L_p, &RB_p, n_vrb_p, n_vrb_p); ra_type2_from_riv(riv, &L_p, &RB_p, n_vrb_p, n_vrb_p);
data->type2_alloc.L_crb = L_p * n_step; data->type2_alloc.L_crb = L_p * n_step;
@ -734,7 +734,7 @@ int dci_format1Cs_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint8_t nof_prb) {
} }
int dci_msg_pack_pdsch(ra_pdsch_t *data, dci_msg_t *msg, dci_format_t format, int dci_msg_pack_pdsch(ra_pdsch_t *data, dci_msg_t *msg, dci_format_t format,
uint8_t nof_prb, bool crc_is_crnti) { uint32_t nof_prb, bool crc_is_crnti) {
switch (format) { switch (format) {
case Format1: case Format1:
return dci_format1_pack(data, msg, nof_prb); return dci_format1_pack(data, msg, nof_prb);
@ -749,7 +749,7 @@ int dci_msg_pack_pdsch(ra_pdsch_t *data, dci_msg_t *msg, dci_format_t format,
} }
} }
int dci_msg_unpack_pdsch(dci_msg_t *msg, ra_pdsch_t *data, uint8_t nof_prb, int dci_msg_unpack_pdsch(dci_msg_t *msg, ra_pdsch_t *data, uint32_t nof_prb,
bool crc_is_crnti) { bool crc_is_crnti) {
if (msg->location.nof_bits == dci_format_sizeof(Format1, nof_prb)) { if (msg->location.nof_bits == dci_format_sizeof(Format1, nof_prb)) {
return dci_format1_unpack(msg, data, nof_prb); return dci_format1_unpack(msg, data, nof_prb);
@ -762,11 +762,11 @@ int dci_msg_unpack_pdsch(dci_msg_t *msg, ra_pdsch_t *data, uint8_t nof_prb,
} }
} }
int dci_msg_pack_pusch(ra_pusch_t *data, dci_msg_t *msg, uint8_t nof_prb) { int dci_msg_pack_pusch(ra_pusch_t *data, dci_msg_t *msg, uint32_t nof_prb) {
return dci_format0_pack(data, msg, nof_prb); return dci_format0_pack(data, msg, nof_prb);
} }
int dci_msg_unpack_pusch(dci_msg_t *msg, ra_pusch_t *data, uint8_t nof_prb) { int dci_msg_unpack_pusch(dci_msg_t *msg, ra_pusch_t *data, uint32_t nof_prb) {
return dci_format0_unpack(msg, data, nof_prb); return dci_format0_unpack(msg, data, nof_prb);
} }
@ -806,7 +806,7 @@ void dci_msg_type_fprint(FILE *f, dci_msg_type_t type) {
} }
} }
int dci_msg_get_type(dci_msg_t *msg, dci_msg_type_t *type, uint8_t nof_prb, int dci_msg_get_type(dci_msg_t *msg, dci_msg_type_t *type, uint32_t nof_prb,
uint16_t crnti) { uint16_t crnti) {
if (msg->location.nof_bits == dci_format_sizeof(Format0, nof_prb) if (msg->location.nof_bits == dci_format_sizeof(Format0, nof_prb)
&& !msg->data[0]) { && !msg->data[0]) {

@ -372,15 +372,15 @@ void crc_set_mask(char *data, int nof_ports) {
* *
* Returns 0 if the data is correct, -1 otherwise * Returns 0 if the data is correct, -1 otherwise
*/ */
uint32_t pbch_crc_check(pbch_t *q, char *bits, uint8_t nof_ports) { uint32_t pbch_crc_check(pbch_t *q, char *bits, uint32_t nof_ports) {
char data[40]; char data[40];
memcpy(data, bits, 40 * sizeof(char)); memcpy(data, bits, 40 * sizeof(char));
crc_set_mask(data, nof_ports); crc_set_mask(data, nof_ports);
return crc_checksum(&q->crc, data, 40); return crc_checksum(&q->crc, data, 40);
} }
int pbch_decode_frame(pbch_t *q, pbch_mib_t *mib, uint8_t src, uint8_t dst, uint8_t n, int pbch_decode_frame(pbch_t *q, pbch_mib_t *mib, uint32_t src, uint32_t dst, uint32_t n,
uint16_t nof_bits, uint8_t nof_ports) { uint32_t nof_bits, uint32_t nof_ports) {
int j; int j;
memcpy(&q->temp[dst * nof_bits], &q->pbch_llr[src * nof_bits], memcpy(&q->temp[dst * nof_bits], &q->pbch_llr[src * nof_bits],
@ -440,9 +440,9 @@ int pbch_decode_frame(pbch_t *q, pbch_mib_t *mib, uint8_t src, uint8_t dst, uint
* Returns 1 if successfully decoded MIB, 0 if not and -1 on error * Returns 1 if successfully decoded MIB, 0 if not and -1 on error
*/ */
int pbch_decode(pbch_t *q, cf_t *sf_symbols, cf_t *ce[MAX_PORTS], pbch_mib_t *mib) { int pbch_decode(pbch_t *q, cf_t *sf_symbols, cf_t *ce[MAX_PORTS], pbch_mib_t *mib) {
uint8_t src, dst, nb; uint32_t src, dst, nb;
uint8_t nant_[3] = { 1, 2, 4 }; uint32_t nant_[3] = { 1, 2, 4 };
uint8_t na, nant; uint32_t na, nant;
cf_t *slot1_symbols; cf_t *slot1_symbols;
int i; int i;
int nof_bits; int nof_bits;

@ -105,7 +105,7 @@ void pcfich_free(pcfich_t *q) {
/** Finds the CFI with minimum distance with the vector of received 32 bits. /** Finds the CFI with minimum distance with the vector of received 32 bits.
* Saves the CFI value in the cfi pointer and returns the distance. * Saves the CFI value in the cfi pointer and returns the distance.
*/ */
int pcfich_cfi_decode(char bits[PCFICH_CFI_LEN], uint8_t *cfi) { int pcfich_cfi_decode(char bits[PCFICH_CFI_LEN], uint32_t *cfi) {
int i, j; int i, j;
int distance, index = -1; int distance, index = -1;
int min = 32; int min = 32;
@ -144,7 +144,7 @@ int pcfich_cfi_encode(int cfi, char bits[PCFICH_CFI_LEN]) {
* Returns 1 if successfully decoded the CFI, 0 if not and -1 on error * Returns 1 if successfully decoded the CFI, 0 if not and -1 on error
*/ */
int pcfich_decode(pcfich_t *q, cf_t *slot_symbols, cf_t *ce[MAX_PORTS], int pcfich_decode(pcfich_t *q, cf_t *slot_symbols, cf_t *ce[MAX_PORTS],
uint8_t nsubframe, uint8_t *cfi, uint8_t *distance) { uint32_t nsubframe, uint32_t *cfi, uint32_t *distance) {
int dist; int dist;
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
@ -216,8 +216,8 @@ int pcfich_decode(pcfich_t *q, cf_t *slot_symbols, cf_t *ce[MAX_PORTS],
/** Encodes CFI and maps symbols to the slot /** Encodes CFI and maps symbols to the slot
*/ */
int pcfich_encode(pcfich_t *q, uint8_t cfi, cf_t *slot_symbols[MAX_PORTS], int pcfich_encode(pcfich_t *q, uint32_t cfi, cf_t *slot_symbols[MAX_PORTS],
uint8_t subframe) { uint32_t subframe) {
int i; int i;
if (q != NULL && if (q != NULL &&

@ -54,12 +54,12 @@ const dci_format_t ue_formats[NOF_UE_FORMATS] = { Format0, Format1 }; // 1A has
#define MIN(a,b) ((a>b)?b:a) #define MIN(a,b) ((a>b)?b:a)
void set_cfi(pdcch_t *q, uint8_t cfi); void set_cfi(pdcch_t *q, uint32_t cfi);
/** /**
* 36.213 9.1 * 36.213 9.1
*/ */
int gen_common_search(dci_candidate_t *c, uint16_t nof_cce, uint16_t nof_bits, int gen_common_search(dci_candidate_t *c, uint32_t nof_cce, uint32_t nof_bits,
uint16_t rnti) { uint16_t rnti) {
int i, l, L, k; int i, l, L, k;
k = 0; k = 0;
@ -81,8 +81,8 @@ int gen_common_search(dci_candidate_t *c, uint16_t nof_cce, uint16_t nof_bits,
/** /**
* 36.213 9.1 * 36.213 9.1
*/ */
int gen_ue_search(dci_candidate_t *c, uint16_t nof_cce, uint8_t nof_bits, int gen_ue_search(dci_candidate_t *c, uint32_t nof_cce, uint32_t nof_bits,
uint16_t rnti, uint8_t subframe) { uint16_t rnti, uint32_t subframe) {
int i, l, L, k, m; int i, l, L, k, m;
unsigned int Yk; unsigned int Yk;
const int S[4] = { 6, 12, 8, 16 }; const int S[4] = { 6, 12, 8, 16 };
@ -124,9 +124,9 @@ int gen_ue_search(dci_candidate_t *c, uint16_t nof_cce, uint8_t nof_bits,
* user-specific search space. Currently supported transmission Mode 1: * user-specific search space. Currently supported transmission Mode 1:
* DCI Format 1A and 1 + PUSCH scheduling format 0 * DCI Format 1A and 1 + PUSCH scheduling format 0
*/ */
int pdcch_init_search_ue(pdcch_t *q, uint16_t c_rnti, uint8_t cfi) { int pdcch_init_search_ue(pdcch_t *q, uint16_t c_rnti, uint32_t cfi) {
int k, i, r; int k, i, r;
uint8_t n; uint32_t n;
set_cfi(q, cfi); set_cfi(q, cfi);
@ -181,7 +181,7 @@ int pdcch_init_common(pdcch_t *q, pdcch_search_t *s, uint16_t rnti) {
/** 36.213 v9.3 Table 7.1-1: System Information DCI messages /** 36.213 v9.3 Table 7.1-1: System Information DCI messages
* Expect DCI formats 1C and 1A in the common search space * Expect DCI formats 1C and 1A in the common search space
*/ */
int pdcch_init_search_si(pdcch_t *q, uint8_t cfi) { int pdcch_init_search_si(pdcch_t *q, uint32_t cfi) {
set_cfi(q, cfi); set_cfi(q, cfi);
int r = pdcch_init_common(q, &q->search_mode[SEARCH_SI], SIRNTI); int r = pdcch_init_common(q, &q->search_mode[SEARCH_SI], SIRNTI);
if (r >= 0) { if (r >= 0) {
@ -193,7 +193,7 @@ int pdcch_init_search_si(pdcch_t *q, uint8_t cfi) {
/** 36.213 v9.3 Table 7.1-3 /** 36.213 v9.3 Table 7.1-3
* Expect DCI formats 1C and 1A in the common search space * Expect DCI formats 1C and 1A in the common search space
*/ */
int pdcch_init_search_ra(pdcch_t *q, uint16_t ra_rnti, uint8_t cfi) { int pdcch_init_search_ra(pdcch_t *q, uint16_t ra_rnti, uint32_t cfi) {
set_cfi(q, cfi); set_cfi(q, cfi);
int r = pdcch_init_common(q, &q->search_mode[SEARCH_RA], ra_rnti); int r = pdcch_init_common(q, &q->search_mode[SEARCH_RA], ra_rnti);
if (r >= 0) { if (r >= 0) {
@ -212,7 +212,7 @@ void pdcch_set_search_ra(pdcch_t *q) {
q->current_search_mode = SEARCH_RA; q->current_search_mode = SEARCH_RA;
} }
void set_cfi(pdcch_t *q, uint8_t cfi) { void set_cfi(pdcch_t *q, uint32_t cfi) {
if (cfi > 0 && cfi < 4) { if (cfi > 0 && cfi < 4) {
q->nof_regs = (regs_pdcch_nregs(q->regs, cfi) / 9) * 9; q->nof_regs = (regs_pdcch_nregs(q->regs, cfi) / 9) * 9;
q->nof_cce = q->nof_regs / 9; q->nof_cce = q->nof_regs / 9;
@ -343,7 +343,7 @@ void pdcch_free(pdcch_t *q) {
* *
* TODO: UE transmit antenna selection CRC mask * TODO: UE transmit antenna selection CRC mask
*/ */
int dci_decode(pdcch_t *q, float *e, char *data, uint16_t E, uint16_t nof_bits, uint16_t *crc) { int dci_decode(pdcch_t *q, float *e, char *data, uint32_t E, uint32_t nof_bits, uint16_t *crc) {
float tmp[3 * (DCI_MAX_BITS + 16)]; float tmp[3 * (DCI_MAX_BITS + 16)];
uint16_t p_bits, crc_res; uint16_t p_bits, crc_res;
@ -406,7 +406,7 @@ int pdcch_decode_candidate(pdcch_t *q, float *llr, dci_candidate_t *c,
} }
int pdcch_extract_llr(pdcch_t *q, cf_t *slot_symbols, cf_t *ce[MAX_PORTS], int pdcch_extract_llr(pdcch_t *q, cf_t *slot_symbols, cf_t *ce[MAX_PORTS],
float *llr, uint8_t nsubframe, uint8_t cfi) { float *llr, uint32_t nsubframe, uint32_t cfi) {
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
int i; int i;
@ -480,7 +480,7 @@ int pdcch_extract_llr(pdcch_t *q, cf_t *slot_symbols, cf_t *ce[MAX_PORTS],
} }
} }
int pdcch_decode_current_mode(pdcch_t *q, float *llr, dci_t *dci, uint8_t subframe) { int pdcch_decode_current_mode(pdcch_t *q, float *llr, dci_t *dci, uint32_t subframe) {
int k, i; int k, i;
int ret; int ret;
@ -513,7 +513,7 @@ int pdcch_decode_ra(pdcch_t *q, float *llr, dci_t *dci) {
pdcch_set_search_ra(q); pdcch_set_search_ra(q);
return pdcch_decode_current_mode(q, llr, dci, 0); return pdcch_decode_current_mode(q, llr, dci, 0);
} }
int pdcch_decode_ue(pdcch_t *q, float *llr, dci_t *dci, uint8_t nsubframe) { int pdcch_decode_ue(pdcch_t *q, float *llr, dci_t *dci, uint32_t nsubframe) {
pdcch_set_search_ue(q); pdcch_set_search_ue(q);
return pdcch_decode_current_mode(q, llr, dci, nsubframe); return pdcch_decode_current_mode(q, llr, dci, nsubframe);
} }
@ -525,7 +525,7 @@ int pdcch_decode_ue(pdcch_t *q, float *llr, dci_t *dci, uint8_t nsubframe) {
* Returns number of messages stored in dci * Returns number of messages stored in dci
*/ */
int pdcch_decode(pdcch_t *q, cf_t *slot_symbols, cf_t *ce[MAX_PORTS], int pdcch_decode(pdcch_t *q, cf_t *slot_symbols, cf_t *ce[MAX_PORTS],
dci_t *dci, uint8_t subframe, uint8_t cfi) { dci_t *dci, uint32_t subframe, uint32_t cfi) {
if (q != NULL && if (q != NULL &&
dci != NULL && dci != NULL &&
@ -564,7 +564,7 @@ void crc_set_mask_rnti(char *crc, uint16_t rnti) {
/** 36.212 5.3.3.2 to 5.3.3.4 /** 36.212 5.3.3.2 to 5.3.3.4
* TODO: UE transmit antenna selection CRC mask * TODO: UE transmit antenna selection CRC mask
*/ */
int dci_encode(pdcch_t *q, char *data, char *e, uint16_t nof_bits, uint16_t E, int dci_encode(pdcch_t *q, char *data, char *e, uint32_t nof_bits, uint32_t E,
uint16_t rnti) { uint16_t rnti) {
convcoder_t encoder; convcoder_t encoder;
char tmp[3 * (DCI_MAX_BITS + 16)]; char tmp[3 * (DCI_MAX_BITS + 16)];
@ -603,7 +603,7 @@ int dci_encode(pdcch_t *q, char *data, char *e, uint16_t nof_bits, uint16_t E,
/** Converts the set of DCI messages to symbols mapped to the slot ready for transmission /** Converts the set of DCI messages to symbols mapped to the slot ready for transmission
*/ */
int pdcch_encode(pdcch_t *q, dci_t *dci, cf_t *slot_symbols[MAX_PORTS], int pdcch_encode(pdcch_t *q, dci_t *dci, cf_t *slot_symbols[MAX_PORTS],
uint8_t nsubframe, uint8_t cfi) { uint32_t nsubframe, uint32_t cfi) {
int i; int i;
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
cf_t *x[MAX_LAYERS]; cf_t *x[MAX_LAYERS];

@ -60,11 +60,11 @@ struct cb_segm {
}; };
int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_prb_t *prb_alloc, int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_prb_t *prb_alloc,
uint8_t nsubframe, bool put) { uint32_t nsubframe, bool put) {
uint8_t s, n, l, lp, lstart, lend, nof_refs; uint32_t s, n, l, lp, lstart, lend, nof_refs;
bool is_pbch, is_sss; bool is_pbch, is_sss;
cf_t *in_ptr = input, *out_ptr = output; cf_t *in_ptr = input, *out_ptr = output;
uint8_t offset; uint32_t offset;
INFO("%s %d RE from %d PRB\n", put ? "Putting" : "Getting", INFO("%s %d RE from %d PRB\n", put ? "Putting" : "Getting",
prb_alloc->re_sf[nsubframe], prb_alloc->slot[0].nof_prb); prb_alloc->re_sf[nsubframe], prb_alloc->slot[0].nof_prb);
@ -161,7 +161,7 @@ int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_prb_t *prb_alloc,
* 36.211 10.3 section 6.3.5 * 36.211 10.3 section 6.3.5
*/ */
int pdsch_put(pdsch_t *q, cf_t *pdsch_symbols, cf_t *sf_symbols, int pdsch_put(pdsch_t *q, cf_t *pdsch_symbols, cf_t *sf_symbols,
ra_prb_t *prb_alloc, uint8_t subframe) { ra_prb_t *prb_alloc, uint32_t subframe) {
return pdsch_cp(q, pdsch_symbols, sf_symbols, prb_alloc, subframe, true); return pdsch_cp(q, pdsch_symbols, sf_symbols, prb_alloc, subframe, true);
} }
@ -173,7 +173,7 @@ int pdsch_put(pdsch_t *q, cf_t *pdsch_symbols, cf_t *sf_symbols,
* 36.211 10.3 section 6.3.5 * 36.211 10.3 section 6.3.5
*/ */
int pdsch_get(pdsch_t *q, cf_t *sf_symbols, cf_t *pdsch_symbols, int pdsch_get(pdsch_t *q, cf_t *sf_symbols, cf_t *pdsch_symbols,
ra_prb_t *prb_alloc, uint8_t subframe) { ra_prb_t *prb_alloc, uint32_t subframe) {
return pdsch_cp(q, sf_symbols, pdsch_symbols, prb_alloc, subframe, false); return pdsch_cp(q, sf_symbols, pdsch_symbols, prb_alloc, subframe, false);
} }
@ -364,7 +364,7 @@ void codeblock_segmentation(struct cb_segm *s, int tbs) {
/* Decode a transport block according to 36.212 5.3.2 /* Decode a transport block according to 36.212 5.3.2
* *
*/ */
int pdsch_decode_tb(pdsch_t *q, char *data, uint16_t tbs, uint16_t nb_e, uint8_t rv_idx) { int pdsch_decode_tb(pdsch_t *q, char *data, uint32_t tbs, uint32_t nb_e, uint32_t rv_idx) {
char parity[24]; char parity[24];
char *p_parity = parity; char *p_parity = parity;
uint32_t par_rx, par_tx; uint32_t par_rx, par_tx;
@ -464,7 +464,7 @@ int pdsch_decode_tb(pdsch_t *q, char *data, uint16_t tbs, uint16_t nb_e, uint8_t
/** Decodes the PDSCH from the received symbols /** Decodes the PDSCH from the received symbols
*/ */
int pdsch_decode(pdsch_t *q, cf_t *sf_symbols, cf_t *ce[MAX_PORTS], char *data, int pdsch_decode(pdsch_t *q, cf_t *sf_symbols, cf_t *ce[MAX_PORTS], char *data,
uint8_t subframe, ra_mcs_t mcs, ra_prb_t *prb_alloc) { uint32_t subframe, ra_mcs_t mcs, ra_prb_t *prb_alloc) {
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
int i, n; int i, n;
@ -548,7 +548,7 @@ int pdsch_decode(pdsch_t *q, cf_t *sf_symbols, cf_t *ce[MAX_PORTS], char *data,
/* Encode a transport block according to 36.212 5.3.2 /* Encode a transport block according to 36.212 5.3.2
* *
*/ */
int pdsch_encode_tb(pdsch_t *q, char *data, uint16_t tbs, uint16_t nb_e, uint8_t rv_idx) { int pdsch_encode_tb(pdsch_t *q, char *data, uint32_t tbs, uint32_t nb_e, uint32_t rv_idx) {
char parity[24]; char parity[24];
char *p_parity = parity; char *p_parity = parity;
unsigned int par; unsigned int par;
@ -656,9 +656,9 @@ int pdsch_encode_tb(pdsch_t *q, char *data, uint16_t tbs, uint16_t nb_e, uint8_t
/** Converts the PDSCH data bits to symbols mapped to the slot ready for transmission /** Converts the PDSCH data bits to symbols mapped to the slot ready for transmission
*/ */
int pdsch_encode(pdsch_t *q, char *data, cf_t *sf_symbols[MAX_PORTS], int pdsch_encode(pdsch_t *q, char *data, cf_t *sf_symbols[MAX_PORTS],
uint8_t subframe, ra_mcs_t mcs, ra_prb_t *prb_alloc) { uint32_t subframe, ra_mcs_t mcs, ra_prb_t *prb_alloc) {
int i; int i;
uint16_t nof_symbols, nof_bits, nof_bits_e; uint32_t nof_symbols, nof_bits, nof_bits_e;
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
cf_t *x[MAX_LAYERS]; cf_t *x[MAX_LAYERS];

@ -50,7 +50,7 @@ const cf_t w_ext[PHICH_EXT_NSEQUENCES][2] = { { 1, 1 }, { 1, -1 }, { I, I }, {
I, -I } }; I, -I } };
uint8_t phich_ngroups(phich_t *q) { uint32_t phich_ngroups(phich_t *q) {
return regs_phich_ngroups(q->regs); return regs_phich_ngroups(q->regs);
} }
@ -107,7 +107,7 @@ void phich_free(phich_t *q) {
/* Decodes ACK /* Decodes ACK
* *
*/ */
char phich_ack_decode(char bits[PHICH_NBITS], uint8_t *distance) { char phich_ack_decode(char bits[PHICH_NBITS], uint32_t *distance) {
int i, n; int i, n;
n = 0; n = 0;
@ -140,7 +140,7 @@ void phich_ack_encode(char ack, char bits[PHICH_NBITS]) {
* Returns 1 if successfully decoded the CFI, 0 if not and -1 on error * Returns 1 if successfully decoded the CFI, 0 if not and -1 on error
*/ */
int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[MAX_PORTS], int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[MAX_PORTS],
uint8_t ngroup, uint8_t nseq, uint8_t subframe, char *ack, uint8_t *distance) { uint32_t ngroup, uint32_t nseq, uint32_t subframe, char *ack, uint32_t *distance) {
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
int i, j; int i, j;
@ -270,7 +270,7 @@ int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[MAX_PORTS],
/** Encodes ACK/NACK bits, modulates and inserts into resource. /** Encodes ACK/NACK bits, modulates and inserts into resource.
* The parameter ack is an array of phich_ngroups() pointers to buffers of nof_sequences chars * The parameter ack is an array of phich_ngroups() pointers to buffers of nof_sequences chars
*/ */
int phich_encode(phich_t *q, char ack, uint8_t ngroup, uint8_t nseq, uint8_t subframe, int phich_encode(phich_t *q, char ack, uint32_t ngroup, uint32_t nseq, uint32_t subframe,
cf_t *slot_symbols[MAX_PORTS]) { cf_t *slot_symbols[MAX_PORTS]) {
int i; int i;

@ -41,10 +41,10 @@
#define min(a,b) (a<b?a:b) #define min(a,b) (a<b?a:b)
/* Returns the number of RE in a PRB in a slot and subframe */ /* Returns the number of RE in a PRB in a slot and subframe */
uint16_t ra_re_x_prb(uint8_t subframe, uint8_t slot, uint8_t prb_idx, uint8_t nof_prb, uint32_t ra_re_x_prb(uint32_t subframe, uint32_t slot, uint32_t prb_idx, uint32_t nof_prb,
uint8_t nof_ports, uint8_t nof_ctrl_symbols, lte_cp_t cp) { uint32_t nof_ports, uint32_t nof_ctrl_symbols, lte_cp_t cp) {
uint16_t re; uint32_t re;
bool skip_refs = false; bool skip_refs = false;
if (slot == 0) { if (slot == 0) {
@ -109,9 +109,9 @@ uint16_t ra_re_x_prb(uint8_t subframe, uint8_t slot, uint8_t prb_idx, uint8_t no
} }
/* Computes the number of RE for each PRB in the prb_dist structure */ /* Computes the number of RE for each PRB in the prb_dist structure */
void ra_prb_get_re_dl(ra_prb_t *prb_dist, uint8_t nof_prb, uint8_t nof_ports, void ra_prb_get_re_dl(ra_prb_t *prb_dist, uint32_t nof_prb, uint32_t nof_ports,
uint8_t nof_ctrl_symbols, lte_cp_t cp) { uint32_t nof_ctrl_symbols, lte_cp_t cp) {
uint8_t i, j, s; uint32_t i, j, s;
/* Set start symbol according to Section 7.1.6.4 in 36.213 */ /* Set start symbol according to Section 7.1.6.4 in 36.213 */
prb_dist->lstart = nof_ctrl_symbols; prb_dist->lstart = nof_ctrl_symbols;
@ -139,7 +139,7 @@ void ra_prb_fprint(FILE *f, ra_prb_slot_t *prb) {
} }
/** Compute PRB allocation for Downlink as defined in 8.1 of 36.213 */ /** Compute PRB allocation for Downlink as defined in 8.1 of 36.213 */
int ra_prb_get_ul(ra_prb_slot_t *prb, ra_pusch_t *ra, uint8_t nof_prb) { int ra_prb_get_ul(ra_prb_slot_t *prb, ra_pusch_t *ra, uint32_t nof_prb) {
int i; int i;
if (ra->type2_alloc.mode != t2_loc) { if (ra->type2_alloc.mode != t2_loc) {
fprintf(stderr, "Uplink only accepts type2 localized scheduling\n"); fprintf(stderr, "Uplink only accepts type2 localized scheduling\n");
@ -153,11 +153,11 @@ int ra_prb_get_ul(ra_prb_slot_t *prb, ra_pusch_t *ra, uint8_t nof_prb) {
} }
/** Compute PRB allocation for Downlink as defined in 7.1.6 of 36.213 */ /** Compute PRB allocation for Downlink as defined in 7.1.6 of 36.213 */
int ra_prb_get_dl(ra_prb_t *prb_dist, ra_pdsch_t *ra, uint8_t nof_prb) { int ra_prb_get_dl(ra_prb_t *prb_dist, ra_pdsch_t *ra, uint32_t nof_prb) {
int i, j; int i, j;
uint32_t bitmask; uint32_t bitmask;
uint8_t P = ra_type0_P(nof_prb); uint32_t P = ra_type0_P(nof_prb);
uint8_t n_rb_rbg_subset, n_rb_type1; uint32_t n_rb_rbg_subset, n_rb_type1;
bzero(prb_dist, sizeof(ra_prb_t)); bzero(prb_dist, sizeof(ra_prb_t));
switch (ra->alloc_type) { switch (ra->alloc_type) {
@ -267,26 +267,26 @@ int ra_prb_get_dl(ra_prb_t *prb_dist, ra_pdsch_t *ra, uint8_t nof_prb) {
} }
/* Returns the number of allocated PRB for Uplink */ /* Returns the number of allocated PRB for Uplink */
uint16_t ra_nprb_ul(ra_pusch_t *ra, uint8_t nof_prb) { uint32_t ra_nprb_ul(ra_pusch_t *ra, uint32_t nof_prb) {
return ra->type2_alloc.L_crb; return ra->type2_alloc.L_crb;
} }
/* Returns the number of allocated PRB for Downlink */ /* Returns the number of allocated PRB for Downlink */
uint16_t ra_nprb_dl(ra_pdsch_t *ra, uint8_t nof_prb) { uint32_t ra_nprb_dl(ra_pdsch_t *ra, uint32_t nof_prb) {
uint8_t nprb; uint32_t nprb;
uint8_t nof_rbg, P; uint32_t nof_rbg, P;
switch (ra->alloc_type) { switch (ra->alloc_type) {
case alloc_type0: case alloc_type0:
// Get the number of allocated RBG except the last RBG // Get the number of allocated RBG except the last RBG
nof_rbg = bit_count(ra->type0_alloc.rbg_bitmask & 0xFFFFFFFE); nof_rbg = bit_count(ra->type0_alloc.rbg_bitmask & 0xFFFFFFFE);
P = ra_type0_P(nof_prb); P = ra_type0_P(nof_prb);
if (nof_rbg > (uint8_t) ceilf((float) nof_prb / P)) { if (nof_rbg > (uint32_t) ceilf((float) nof_prb / P)) {
nof_rbg = (uint8_t) ceilf((float) nof_prb / P) - 1; nof_rbg = (uint32_t) ceilf((float) nof_prb / P) - 1;
} }
nprb = nof_rbg * P; nprb = nof_rbg * P;
// last RBG may have smaller size. Add if set // last RBG may have smaller size. Add if set
uint8_t P_last = (nof_prb % P); uint32_t P_last = (nof_prb % P);
if (!P_last) if (!P_last)
P_last = P; P_last = P;
nprb += P_last * (ra->type0_alloc.rbg_bitmask & 1); nprb += P_last * (ra->type0_alloc.rbg_bitmask & 1);
@ -309,7 +309,7 @@ uint16_t ra_nprb_dl(ra_pdsch_t *ra, uint8_t nof_prb) {
} }
/* RBG size for type0 scheduling as in table 7.1.6.1-1 of 36.213 */ /* RBG size for type0 scheduling as in table 7.1.6.1-1 of 36.213 */
uint8_t ra_type0_P(uint8_t nof_prb) { uint32_t ra_type0_P(uint32_t nof_prb) {
if (nof_prb <= 10) { if (nof_prb <= 10) {
return 1; return 1;
} else if (nof_prb <= 26) { } else if (nof_prb <= 26) {
@ -322,14 +322,14 @@ uint8_t ra_type0_P(uint8_t nof_prb) {
} }
/* Returns N_rb_type1 according to section 7.1.6.2 */ /* Returns N_rb_type1 according to section 7.1.6.2 */
uint8_t ra_type1_N_rb(uint8_t nof_prb) { uint32_t ra_type1_N_rb(uint32_t nof_prb) {
uint8_t P = ra_type0_P(nof_prb); uint32_t P = ra_type0_P(nof_prb);
return (uint8_t) ceilf((float) nof_prb / P) - (uint8_t) ceilf(log2f((float) P)) - 1; return (uint32_t) ceilf((float) nof_prb / P) - (uint32_t) ceilf(log2f((float) P)) - 1;
} }
/* Convert Type2 scheduling L_crb and RB_start to RIV value */ /* Convert Type2 scheduling L_crb and RB_start to RIV value */
uint16_t ra_type2_to_riv(uint8_t L_crb, uint8_t RB_start, uint8_t nof_prb) { uint32_t ra_type2_to_riv(uint32_t L_crb, uint32_t RB_start, uint32_t nof_prb) {
uint16_t riv; uint32_t riv;
if (L_crb <= nof_prb / 2) { if (L_crb <= nof_prb / 2) {
riv = nof_prb * (L_crb - 1) + RB_start; riv = nof_prb * (L_crb - 1) + RB_start;
} else { } else {
@ -339,10 +339,10 @@ uint16_t ra_type2_to_riv(uint8_t L_crb, uint8_t RB_start, uint8_t nof_prb) {
} }
/* Convert Type2 scheduling RIV value to L_crb and RB_start values */ /* Convert Type2 scheduling RIV value to L_crb and RB_start values */
void ra_type2_from_riv(uint16_t riv, uint8_t *L_crb, uint8_t *RB_start, void ra_type2_from_riv(uint32_t riv, uint32_t *L_crb, uint32_t *RB_start,
uint8_t nof_prb, uint8_t nof_vrb) { uint32_t nof_prb, uint32_t nof_vrb) {
*L_crb = (uint8_t) (riv / nof_prb) + 1; *L_crb = (uint32_t) (riv / nof_prb) + 1;
*RB_start = (uint8_t) (riv % nof_prb); *RB_start = (uint32_t) (riv % nof_prb);
if (*L_crb > nof_vrb - *RB_start) { if (*L_crb > nof_vrb - *RB_start) {
*L_crb = nof_prb - (int) (riv / nof_prb) + 1; *L_crb = nof_prb - (int) (riv / nof_prb) + 1;
*RB_start = nof_prb - riv % nof_prb - 1; *RB_start = nof_prb - riv % nof_prb - 1;
@ -350,7 +350,7 @@ void ra_type2_from_riv(uint16_t riv, uint8_t *L_crb, uint8_t *RB_start,
} }
/* Table 6.2.3.2-1 in 36.211 */ /* Table 6.2.3.2-1 in 36.211 */
uint8_t ra_type2_ngap(uint8_t nof_prb, bool ngap_is_1) { uint32_t ra_type2_ngap(uint32_t nof_prb, bool ngap_is_1) {
if (nof_prb <= 10) { if (nof_prb <= 10) {
return nof_prb / 2; return nof_prb / 2;
} else if (nof_prb == 11) { } else if (nof_prb == 11) {
@ -373,7 +373,7 @@ uint8_t ra_type2_ngap(uint8_t nof_prb, bool ngap_is_1) {
} }
/* Table 7.1.6.3-1 in 36.213 */ /* Table 7.1.6.3-1 in 36.213 */
uint8_t ra_type2_n_rb_step(uint8_t nof_prb) { uint32_t ra_type2_n_rb_step(uint32_t nof_prb) {
if (nof_prb < 50) { if (nof_prb < 50) {
return 2; return 2;
} else { } else {
@ -382,17 +382,17 @@ uint8_t ra_type2_n_rb_step(uint8_t nof_prb) {
} }
/* as defined in 6.2.3.2 of 36.211 */ /* as defined in 6.2.3.2 of 36.211 */
uint8_t ra_type2_n_vrb_dl(uint8_t nof_prb, bool ngap_is_1) { uint32_t ra_type2_n_vrb_dl(uint32_t nof_prb, bool ngap_is_1) {
uint8_t ngap = ra_type2_ngap(nof_prb, ngap_is_1); uint32_t ngap = ra_type2_ngap(nof_prb, ngap_is_1);
if (ngap_is_1) { if (ngap_is_1) {
return 2 * (ngap < (nof_prb - ngap) ? ngap : nof_prb - ngap); return 2 * (ngap < (nof_prb - ngap) ? ngap : nof_prb - ngap);
} else { } else {
return ((uint8_t) nof_prb / ngap) * 2 * ngap; return ((uint32_t) nof_prb / ngap) * 2 * ngap;
} }
} }
/* Converts ra_mcs_t structure to MCS index for both Uplink and Downlink */ /* Converts ra_mcs_t structure to MCS index for both Uplink and Downlink */
uint8_t ra_mcs_to_table_idx(ra_mcs_t *mcs) { uint32_t ra_mcs_to_table_idx(ra_mcs_t *mcs) {
switch (mcs->mod) { switch (mcs->mod) {
case QPSK: case QPSK:
return mcs->tbs_idx; return mcs->tbs_idx;
@ -406,7 +406,7 @@ uint8_t ra_mcs_to_table_idx(ra_mcs_t *mcs) {
} }
/* Converts MCS index to ra_mcs_t structure for Downlink as defined inTable 7.1.7.1-1 on 36.213 */ /* Converts MCS index to ra_mcs_t structure for Downlink as defined inTable 7.1.7.1-1 on 36.213 */
int ra_mcs_from_idx_dl(uint8_t idx, ra_mcs_t *mcs) { int ra_mcs_from_idx_dl(uint32_t idx, ra_mcs_t *mcs) {
if (idx < 10) { if (idx < 10) {
mcs->mod = QPSK; mcs->mod = QPSK;
mcs->tbs_idx = idx; mcs->tbs_idx = idx;
@ -434,7 +434,7 @@ int ra_mcs_from_idx_dl(uint8_t idx, ra_mcs_t *mcs) {
} }
/* Converts MCS index to ra_mcs_t structure for Uplink as defined in Table 8.6.1-1 on 36.213 */ /* Converts MCS index to ra_mcs_t structure for Uplink as defined in Table 8.6.1-1 on 36.213 */
int ra_mcs_from_idx_ul(uint8_t idx, ra_mcs_t *mcs) { int ra_mcs_from_idx_ul(uint32_t idx, ra_mcs_t *mcs) {
if (idx < 11) { if (idx < 11) {
mcs->mod = QPSK; mcs->mod = QPSK;
mcs->tbs_idx = idx; mcs->tbs_idx = idx;
@ -453,7 +453,7 @@ int ra_mcs_from_idx_ul(uint8_t idx, ra_mcs_t *mcs) {
} }
/* Downlink Transport Block size for Format 1C as defined in 7.1.7.2.2-1 on 36.213 */ /* Downlink Transport Block size for Format 1C as defined in 7.1.7.2.2-1 on 36.213 */
int ra_tbs_from_idx_format1c(uint8_t tbs_idx) { int ra_tbs_from_idx_format1c(uint32_t tbs_idx) {
if (tbs_idx < 32) { if (tbs_idx < 32) {
return tbs_format1c_table[tbs_idx]; return tbs_format1c_table[tbs_idx];
} else { } else {
@ -478,7 +478,7 @@ int ra_tbs_to_table_idx_format1c(uint32_t tbs) {
} }
/* Downlink Transport Block size determination as defined in 7.1.7.2 on 36.213 */ /* Downlink Transport Block size determination as defined in 7.1.7.2 on 36.213 */
int ra_tbs_from_idx(uint8_t tbs_idx, uint8_t n_prb) { int ra_tbs_from_idx(uint32_t tbs_idx, uint32_t n_prb) {
if (tbs_idx < 27 && n_prb > 0 && n_prb <= MAX_PRB) { if (tbs_idx < 27 && n_prb > 0 && n_prb <= MAX_PRB) {
return tbs_table[tbs_idx][n_prb - 1]; return tbs_table[tbs_idx][n_prb - 1];
} else { } else {
@ -489,7 +489,7 @@ int ra_tbs_from_idx(uint8_t tbs_idx, uint8_t n_prb) {
/* Returns lowest nearest index of TBS value in table 7.1.7.2 on 36.213 /* Returns lowest nearest index of TBS value in table 7.1.7.2 on 36.213
* or -1 if the TBS value is not within the valid TBS values * or -1 if the TBS value is not within the valid TBS values
*/ */
int ra_tbs_to_table_idx(uint32_t tbs, uint8_t n_prb) { int ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb) {
int idx; int idx;
if (n_prb > 0 && n_prb <= MAX_PRB) { if (n_prb > 0 && n_prb <= MAX_PRB) {
return LIBLTE_ERROR; return LIBLTE_ERROR;
@ -518,7 +518,7 @@ char *ra_mod_string(ra_mod_t mod) {
} }
} }
void ra_pusch_fprint(FILE *f, ra_pusch_t *ra, uint8_t nof_prb) { void ra_pusch_fprint(FILE *f, ra_pusch_t *ra, uint32_t nof_prb) {
fprintf(f, "Frequency Hopping:\t"); fprintf(f, "Frequency Hopping:\t");
if (ra->freq_hop_fl == hop_disabled) { if (ra->freq_hop_fl == hop_disabled) {
fprintf(f, "No"); fprintf(f, "No");
@ -541,17 +541,17 @@ char *ra_type_string(ra_type_t alloc_type) {
} }
} }
void ra_pdsch_set_mcs_index(ra_pdsch_t *ra, uint8_t mcs_idx) { void ra_pdsch_set_mcs_index(ra_pdsch_t *ra, uint32_t mcs_idx) {
ra->mcs.mod = MOD_NULL; ra->mcs.mod = MOD_NULL;
ra->mcs.mcs_idx = mcs_idx; ra->mcs.mcs_idx = mcs_idx;
} }
void ra_pdsch_set_mcs(ra_pdsch_t *ra, ra_mod_t mod, uint8_t tbs_idx) { void ra_pdsch_set_mcs(ra_pdsch_t *ra, ra_mod_t mod, uint32_t tbs_idx) {
ra->mcs.mod = mod; ra->mcs.mod = mod;
ra->mcs.tbs_idx = tbs_idx; ra->mcs.tbs_idx = tbs_idx;
ra->mcs.tbs = 0; ra->mcs.tbs = 0;
} }
void ra_pdsch_fprint(FILE *f, ra_pdsch_t *ra, uint8_t nof_prb) { void ra_pdsch_fprint(FILE *f, ra_pdsch_t *ra, uint32_t nof_prb) {
fprintf(f, " - Resource Allocation Type:\t\t%s\n", fprintf(f, " - Resource Allocation Type:\t\t%s\n",
ra_type_string(ra->alloc_type)); ra_type_string(ra->alloc_type));
switch (ra->alloc_type) { switch (ra->alloc_type) {

@ -34,23 +34,23 @@
#include "liblte/phy/phch/regs.h" #include "liblte/phy/phch/regs.h"
#include "liblte/phy/utils/debug.h" #include "liblte/phy/utils/debug.h"
regs_reg_t *regs_find_reg(regs_t *h, uint16_t k, uint8_t l); regs_reg_t *regs_find_reg(regs_t *h, uint32_t k, uint32_t l);
int regs_put_reg(regs_reg_t *reg, int regs_put_reg(regs_reg_t *reg,
cf_t *reg_data, cf_t *reg_data,
cf_t *slot_symbols, cf_t *slot_symbols,
uint8_t nof_prb); uint32_t nof_prb);
int regs_add_reg(regs_reg_t *reg, int regs_add_reg(regs_reg_t *reg,
cf_t *reg_data, cf_t *reg_data,
cf_t *slot_symbols, cf_t *slot_symbols,
uint8_t nof_prb); uint32_t nof_prb);
int regs_get_reg(regs_reg_t *reg, int regs_get_reg(regs_reg_t *reg,
cf_t *slot_symbols, cf_t *slot_symbols,
cf_t *reg_data, cf_t *reg_data,
uint8_t nof_prb); uint32_t nof_prb);
int regs_reset_reg(regs_reg_t *reg, cf_t *slot_symbols, uint8_t nof_prb); int regs_reset_reg(regs_reg_t *reg, cf_t *slot_symbols, uint32_t nof_prb);
/*************************************************************** /***************************************************************
@ -151,7 +151,7 @@ clean_and_exit:
return ret; return ret;
} }
int regs_pdcch_nregs(regs_t *h, uint8_t cfi) { int regs_pdcch_nregs(regs_t *h, uint32_t cfi) {
if (cfi < 1 || cfi > 3) { if (cfi < 1 || cfi > 3) {
fprintf(stderr, "Invalid CFI=%d\n", cfi); fprintf(stderr, "Invalid CFI=%d\n", cfi);
return LIBLTE_ERROR; return LIBLTE_ERROR;
@ -320,9 +320,9 @@ void regs_phich_free(regs_t *h) {
} }
} }
u_int16_t regs_phich_nregs(regs_t *h) { uint32_t regs_phich_nregs(regs_t *h) {
int i; int i;
u_int16_t n; uint32_t n;
n=0; n=0;
for (i=0;i<h->ngroups_phich;i++) { for (i=0;i<h->ngroups_phich;i++) {
n += h->phich[i].nof_regs; n += h->phich[i].nof_regs;
@ -331,7 +331,7 @@ u_int16_t regs_phich_nregs(regs_t *h) {
} }
u_int8_t regs_phich_ngroups(regs_t *h) { uint32_t regs_phich_ngroups(regs_t *h) {
return h->ngroups_phich; return h->ngroups_phich;
} }
@ -342,7 +342,7 @@ u_int8_t regs_phich_ngroups(regs_t *h) {
* *
* Returns the number of written symbols, or -1 on error * Returns the number of written symbols, or -1 on error
*/ */
int regs_phich_add(regs_t *h, cf_t phich_symbols[REGS_PHICH_NSYM], u_int8_t ngroup, cf_t *slot_symbols) { int regs_phich_add(regs_t *h, cf_t phich_symbols[REGS_PHICH_NSYM], uint32_t ngroup, cf_t *slot_symbols) {
int i; int i;
if (ngroup >= h->ngroups_phich) { if (ngroup >= h->ngroups_phich) {
fprintf(stderr, "Error invalid ngroup %d\n", ngroup); fprintf(stderr, "Error invalid ngroup %d\n", ngroup);
@ -365,7 +365,7 @@ int regs_phich_add(regs_t *h, cf_t phich_symbols[REGS_PHICH_NSYM], u_int8_t ngro
*/ */
int regs_phich_reset(regs_t *h, cf_t *slot_symbols) { int regs_phich_reset(regs_t *h, cf_t *slot_symbols) {
int i; int i;
u_int8_t ngroup, ng; uint32_t ngroup, ng;
for (ngroup = 0;ngroup < h->ngroups_phich;CP_ISEXT(h->cell.cp)?ngroup+=2:ngroup++) { for (ngroup = 0;ngroup < h->ngroups_phich;CP_ISEXT(h->cell.cp)?ngroup+=2:ngroup++) {
if (CP_ISEXT(h->cell.cp)) { if (CP_ISEXT(h->cell.cp)) {
ng = ngroup/2; ng = ngroup/2;
@ -385,7 +385,7 @@ int regs_phich_reset(regs_t *h, cf_t *slot_symbols) {
* *
* Returns the number of written symbols, or -1 on error * Returns the number of written symbols, or -1 on error
*/ */
int regs_phich_get(regs_t *h, cf_t *slot_symbols, cf_t phich_symbols[REGS_PHICH_NSYM], u_int8_t ngroup) { int regs_phich_get(regs_t *h, cf_t *slot_symbols, cf_t phich_symbols[REGS_PHICH_NSYM], uint32_t ngroup) {
int i; int i;
if (ngroup >= h->ngroups_phich) { if (ngroup >= h->ngroups_phich) {
fprintf(stderr, "Error invalid ngroup %d\n", ngroup); fprintf(stderr, "Error invalid ngroup %d\n", ngroup);
@ -422,7 +422,7 @@ int regs_phich_get(regs_t *h, cf_t *slot_symbols, cf_t phich_symbols[REGS_PHICH_
*/ */
int regs_pcfich_init(regs_t *h) { int regs_pcfich_init(regs_t *h) {
int i; int i;
uint16_t k_hat, k; uint32_t k_hat, k;
regs_ch_t *ch = &h->pcfich; regs_ch_t *ch = &h->pcfich;
ch->regs = malloc(sizeof(regs_reg_t*) * REGS_PCFICH_NREGS); ch->regs = malloc(sizeof(regs_reg_t*) * REGS_PCFICH_NREGS);
@ -463,7 +463,7 @@ void regs_pcfich_free(regs_t *h) {
} }
} }
uint16_t regs_pcfich_nregs(regs_t *h) { uint32_t regs_pcfich_nregs(regs_t *h) {
return h->pcfich.nof_regs; return h->pcfich.nof_regs;
} }
@ -515,7 +515,7 @@ int regs_pcfich_get(regs_t *h, cf_t *slot_symbols, cf_t ch_data[REGS_PCFICH_NSYM
* *
***************************************************************/ ***************************************************************/
regs_reg_t *regs_find_reg(regs_t *h, uint16_t k, uint8_t l) { regs_reg_t *regs_find_reg(regs_t *h, uint32_t k, uint32_t l) {
int i; int i;
for (i=0;i<h->nof_regs;i++) { for (i=0;i<h->nof_regs;i++) {
if (h->regs[i].l == l && h->regs[i].k0 == k) { if (h->regs[i].l == l && h->regs[i].k0 == k) {
@ -529,7 +529,7 @@ regs_reg_t *regs_find_reg(regs_t *h, uint16_t k, uint8_t l) {
* Returns the number of REGs in a PRB * Returns the number of REGs in a PRB
* 36.211 Section 6.2.4 * 36.211 Section 6.2.4
*/ */
int regs_num_x_symbol(uint8_t symbol, uint8_t nof_port, lte_cp_t cp) { int regs_num_x_symbol(uint32_t symbol, uint32_t nof_port, lte_cp_t cp) {
switch (symbol) { switch (symbol) {
case 0: case 0:
@ -562,7 +562,7 @@ int regs_num_x_symbol(uint8_t symbol, uint8_t nof_port, lte_cp_t cp) {
* Initializes the indices of a REG * Initializes the indices of a REG
* 36.211 Section 6.2.4 * 36.211 Section 6.2.4
*/ */
int regs_reg_init(regs_reg_t *reg, uint8_t symbol, uint16_t nreg, uint16_t k0, uint8_t maxreg, uint8_t vo) { int regs_reg_init(regs_reg_t *reg, uint32_t symbol, uint32_t nreg, uint32_t k0, uint32_t maxreg, uint32_t vo) {
int i, j, z; int i, j, z;
reg->l = symbol; reg->l = symbol;
@ -619,7 +619,7 @@ void regs_free(regs_t *h) {
/** Sets the CFI value for this subframe (CFI must be in the range 1..3). /** Sets the CFI value for this subframe (CFI must be in the range 1..3).
*/ */
int regs_set_cfi(regs_t *h, uint8_t cfi) { int regs_set_cfi(regs_t *h, uint32_t cfi) {
if (cfi > 0 && cfi <= 3) { if (cfi > 0 && cfi <= 3) {
if (h->phich_len == PHICH_EXT && if (h->phich_len == PHICH_EXT &&
((h->cell.nof_prb < 10 && cfi < 2) || (h->cell.nof_prb >= 10 && cfi < 3))) { ((h->cell.nof_prb < 10 && cfi < 2) || (h->cell.nof_prb >= 10 && cfi < 3))) {
@ -644,8 +644,8 @@ int regs_set_cfi(regs_t *h, uint8_t cfi) {
int regs_init(regs_t *h, phich_resources_t phich_res, phich_length_t phich_len, lte_cell_t cell) { int regs_init(regs_t *h, phich_resources_t phich_res, phich_length_t phich_len, lte_cell_t cell) {
int ret = LIBLTE_ERROR_INVALID_INPUTS; int ret = LIBLTE_ERROR_INVALID_INPUTS;
int i, k; int i, k;
uint16_t j[4], jmax, prb; uint32_t j[4], jmax, prb;
uint8_t n[4], vo; uint32_t n[4], vo;
int max_ctrl_symbols; int max_ctrl_symbols;
if (h != NULL && if (h != NULL &&
@ -732,7 +732,7 @@ clean_and_exit:
/** /**
* Puts one REG data (4 symbols) in the slot symbols array * Puts one REG data (4 symbols) in the slot symbols array
*/ */
int regs_put_reg(regs_reg_t *reg, cf_t *reg_data, cf_t *slot_symbols, uint8_t nof_prb) { int regs_put_reg(regs_reg_t *reg, cf_t *reg_data, cf_t *slot_symbols, uint32_t nof_prb) {
int i; int i;
for (i = 0; i < REGS_RE_X_REG; i++) { for (i = 0; i < REGS_RE_X_REG; i++) {
slot_symbols[REG_IDX(reg, i, nof_prb)] = reg_data[i]; slot_symbols[REG_IDX(reg, i, nof_prb)] = reg_data[i];
@ -744,7 +744,7 @@ int regs_put_reg(regs_reg_t *reg, cf_t *reg_data, cf_t *slot_symbols, uint8_t no
* Adds one REG data (4 symbols) in the slot symbols array * Adds one REG data (4 symbols) in the slot symbols array
* Used by PHICH * Used by PHICH
*/ */
int regs_add_reg(regs_reg_t *reg, cf_t *reg_data, cf_t *slot_symbols, uint8_t nof_prb) { int regs_add_reg(regs_reg_t *reg, cf_t *reg_data, cf_t *slot_symbols, uint32_t nof_prb) {
int i; int i;
for (i = 0; i < REGS_RE_X_REG; i++) { for (i = 0; i < REGS_RE_X_REG; i++) {
slot_symbols[REG_IDX(reg, i, nof_prb)] += reg_data[i]; slot_symbols[REG_IDX(reg, i, nof_prb)] += reg_data[i];
@ -756,7 +756,7 @@ int regs_add_reg(regs_reg_t *reg, cf_t *reg_data, cf_t *slot_symbols, uint8_t no
/** /**
* Reset REG data (4 symbols) in the slot symbols array * Reset REG data (4 symbols) in the slot symbols array
*/ */
int regs_reset_reg(regs_reg_t *reg, cf_t *slot_symbols, uint8_t nof_prb) { int regs_reset_reg(regs_reg_t *reg, cf_t *slot_symbols, uint32_t nof_prb) {
int i; int i;
for (i = 0; i < REGS_RE_X_REG; i++) { for (i = 0; i < REGS_RE_X_REG; i++) {
slot_symbols[REG_IDX(reg, i, nof_prb)] = 0; slot_symbols[REG_IDX(reg, i, nof_prb)] = 0;
@ -767,7 +767,7 @@ int regs_reset_reg(regs_reg_t *reg, cf_t *slot_symbols, uint8_t nof_prb) {
/** /**
* Gets one REG data (4 symbols) from the slot symbols array * Gets one REG data (4 symbols) from the slot symbols array
*/ */
int regs_get_reg(regs_reg_t *reg, cf_t *slot_symbols, cf_t *reg_data, uint8_t nof_prb) { int regs_get_reg(regs_reg_t *reg, cf_t *slot_symbols, cf_t *reg_data, uint32_t nof_prb) {
int i; int i;
for (i = 0; i < REGS_RE_X_REG; i++) { for (i = 0; i < REGS_RE_X_REG; i++) {
reg_data[i] = slot_symbols[REG_IDX(reg, i, nof_prb)]; reg_data[i] = slot_symbols[REG_IDX(reg, i, nof_prb)];

@ -33,7 +33,7 @@
/** /**
* 36.211 6.6.1 * 36.211 6.6.1
*/ */
int sequence_pbch(sequence_t *seq, lte_cp_t cp, uint16_t cell_id) { int sequence_pbch(sequence_t *seq, lte_cp_t cp, uint32_t cell_id) {
bzero(seq, sizeof(sequence_t)); bzero(seq, sizeof(sequence_t));
return sequence_LTEPRS(seq, CP_ISNORM(cp)?1920:1728, cell_id); return sequence_LTEPRS(seq, CP_ISNORM(cp)?1920:1728, cell_id);
} }
@ -41,7 +41,7 @@ int sequence_pbch(sequence_t *seq, lte_cp_t cp, uint16_t cell_id) {
/** /**
* 36.211 6.7.1 * 36.211 6.7.1
*/ */
int sequence_pcfich(sequence_t *seq, uint8_t nslot, uint16_t cell_id) { int sequence_pcfich(sequence_t *seq, uint32_t nslot, uint32_t cell_id) {
bzero(seq, sizeof(sequence_t)); bzero(seq, sizeof(sequence_t));
return sequence_LTEPRS(seq, 32, (nslot/2+1) * (2*cell_id + 1) * 512 + cell_id); return sequence_LTEPRS(seq, 32, (nslot/2+1) * (2*cell_id + 1) * 512 + cell_id);
} }
@ -50,7 +50,7 @@ int sequence_pcfich(sequence_t *seq, uint8_t nslot, uint16_t cell_id) {
/** /**
* 36.211 6.9.1 * 36.211 6.9.1
*/ */
int sequence_phich(sequence_t *seq, uint8_t nslot, uint16_t cell_id) { int sequence_phich(sequence_t *seq, uint32_t nslot, uint32_t cell_id) {
bzero(seq, sizeof(sequence_t)); bzero(seq, sizeof(sequence_t));
return sequence_LTEPRS(seq, 12, (nslot/2+1) * (2*cell_id + 1) * 512 + cell_id); return sequence_LTEPRS(seq, 12, (nslot/2+1) * (2*cell_id + 1) * 512 + cell_id);
} }
@ -58,7 +58,7 @@ int sequence_phich(sequence_t *seq, uint8_t nslot, uint16_t cell_id) {
/** /**
* 36.211 6.8.2 * 36.211 6.8.2
*/ */
int sequence_pdcch(sequence_t *seq, uint8_t nslot, uint16_t cell_id, uint32_t len) { int sequence_pdcch(sequence_t *seq, uint32_t nslot, uint32_t cell_id, uint32_t len) {
bzero(seq, sizeof(sequence_t)); bzero(seq, sizeof(sequence_t));
return sequence_LTEPRS(seq, len, (nslot/2) * 512 + cell_id); return sequence_LTEPRS(seq, len, (nslot/2) * 512 + cell_id);
} }
@ -66,7 +66,7 @@ int sequence_pdcch(sequence_t *seq, uint8_t nslot, uint16_t cell_id, uint32_t le
/** /**
* 36.211 6.3.1 * 36.211 6.3.1
*/ */
int sequence_pdsch(sequence_t *seq, unsigned short rnti, int q, uint8_t nslot, uint16_t cell_id, uint32_t len) { int sequence_pdsch(sequence_t *seq, unsigned short rnti, int q, uint32_t nslot, uint32_t cell_id, uint32_t len) {
bzero(seq, sizeof(sequence_t)); bzero(seq, sizeof(sequence_t));
return sequence_LTEPRS(seq, len, (rnti<<14) + (q<<13) + ((nslot/2)<<9) + cell_id); return sequence_LTEPRS(seq, len, (rnti<<14) + (q<<13) + ((nslot/2)<<9) + cell_id);
} }

@ -188,7 +188,7 @@ void base_free() {
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
uint8_t cfi, distance; uint32_t cfi, distance;
int i, n; int i, n;
if (argc < 3) { if (argc < 3) {

@ -80,7 +80,7 @@ int main(int argc, char **argv) {
cf_t *ce[MAX_PORTS]; cf_t *ce[MAX_PORTS];
int nof_re; int nof_re;
cf_t *slot_symbols[MAX_PORTS]; cf_t *slot_symbols[MAX_PORTS];
uint8_t cfi, cfi_rx, nsf, distance; uint32_t cfi, cfi_rx, nsf, distance;
int cid, max_cid; int cid, max_cid;
parse_args(argc,argv); parse_args(argc,argv);

@ -44,7 +44,7 @@ lte_cell_t cell = {
CPNORM // cyclic prefix CPNORM // cyclic prefix
}; };
uint8_t cfi = 2; uint32_t cfi = 2;
int flen; int flen;
uint16_t rnti = SIRNTI; uint16_t rnti = SIRNTI;
int max_frames = 10; int max_frames = 10;

@ -40,7 +40,7 @@ lte_cell_t cell = {
CPNORM // cyclic prefix CPNORM // cyclic prefix
}; };
uint8_t cfi = 1; uint32_t cfi = 1;
void usage(char *prog) { void usage(char *prog) {
printf("Usage: %s [cell.cpv]\n", prog); printf("Usage: %s [cell.cpv]\n", prog);

@ -45,7 +45,7 @@ lte_cell_t cell = {
int flen; int flen;
uint8_t cfi = 2; uint32_t cfi = 2;
uint16_t rnti = SIRNTI; uint16_t rnti = SIRNTI;
int max_frames = 10; int max_frames = 10;

@ -80,7 +80,7 @@ int main(int argc, char **argv) {
pdsch_init(&pdsch, 0, cell); pdsch_init(&pdsch, 0, cell);
memset(prb_alloc.re_sf, 0, sizeof(uint16_t) * 10); memset(prb_alloc.re_sf, 0, sizeof(uint32_t) * 10);
prb_alloc.slot[0].nof_prb = test_re_prb[i]; prb_alloc.slot[0].nof_prb = test_re_prb[i];
prb_alloc.slot[1].nof_prb = test_re_prb[i]; prb_alloc.slot[1].nof_prb = test_re_prb[i];
ra_prb_get_re_dl(&prb_alloc, test_re_prb[i], test_re_ports[i], test_re_csymb[i], test_re_cp[i]); ra_prb_get_re_dl(&prb_alloc, test_re_prb[i], test_re_ports[i], test_re_csymb[i], test_re_cp[i]);

@ -41,9 +41,9 @@ lte_cell_t cell = {
CPNORM // cyclic prefix CPNORM // cyclic prefix
}; };
uint8_t cfi = 1; uint32_t cfi = 1;
uint16_t tbs = -1; uint32_t tbs = -1;
uint8_t subframe = 1; uint32_t subframe = 1;
ra_mod_t modulation = BPSK; ra_mod_t modulation = BPSK;
void usage(char *prog) { void usage(char *prog) {

@ -213,9 +213,9 @@ void base_free() {
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
uint8_t distance; uint32_t distance;
int i, n; int i, n;
uint8_t ngroup, nseq, max_nseq; uint32_t ngroup, nseq, max_nseq;
char ack_rx; char ack_rx;
if (argc < 3) { if (argc < 3) {

@ -106,9 +106,9 @@ int main(int argc, char **argv) {
int nof_re; int nof_re;
cf_t *slot_symbols[MAX_PORTS]; cf_t *slot_symbols[MAX_PORTS];
char ack[50][PHICH_NORM_NSEQUENCES], ack_rx; char ack[50][PHICH_NORM_NSEQUENCES], ack_rx;
uint8_t nsf, distance; uint32_t nsf, distance;
int cid, max_cid; int cid, max_cid;
uint8_t ngroup, nseq, max_nseq; uint32_t ngroup, nseq, max_nseq;
parse_args(argc,argv); parse_args(argc,argv);

@ -35,7 +35,7 @@
#include "liblte/phy/sync/sync_frame.h" #include "liblte/phy/sync/sync_frame.h"
int sync_frame_init(sync_frame_t *q, int downsampling) { int sync_frame_init(sync_frame_t *q, uint32_t downsampling) {
int ret = -1; int ret = -1;
bzero(q, sizeof(sync_frame_t)); bzero(q, sizeof(sync_frame_t));
@ -87,7 +87,7 @@ void sync_frame_free(sync_frame_t *q) {
} }
void sync_frame_run(sync_frame_t *q, cf_t *input) { void sync_frame_run(sync_frame_t *q, cf_t *input) {
int track_idx; uint32_t track_idx;
switch (q->state) { switch (q->state) {
@ -152,7 +152,7 @@ void sync_frame_run(sync_frame_t *q, cf_t *input) {
} }
} else { } else {
/* if sync not found, adjust time offset with the averaged value */ /* if sync not found, adjust time offset with the averaged value */
q->peak_idx = (q->peak_idx + (int) q->timeoffset) % SYNC_SF_LEN; q->peak_idx = (q->peak_idx + (uint32_t) q->timeoffset) % SYNC_SF_LEN;
/* if we missed too many PSS go back to FIND */ /* if we missed too many PSS go back to FIND */
if (q->frame_cnt - q->last_found > TRACK_MAX_LOST) { if (q->frame_cnt - q->last_found > TRACK_MAX_LOST) {
@ -169,11 +169,11 @@ void sync_frame_set_threshold(sync_frame_t *q, float threshold) {
sync_set_threshold(&q->s, threshold); sync_set_threshold(&q->s, threshold);
} }
int sync_frame_cell_id(sync_frame_t *q) { uint32_t sync_frame_cell_id(sync_frame_t *q) {
return q->cell_id; return q->cell_id;
} }
int sync_frame_sfidx(sync_frame_t *q) { uint32_t sync_frame_sfidx(sync_frame_t *q) {
return q->sf_idx; return q->sf_idx;
} }
@ -182,7 +182,7 @@ int sync_frame_push(sync_frame_t *q, cf_t *input, cf_t *output) {
int retval = 0; int retval = 0;
int frame_start; int frame_start;
cf_t *input_ds; cf_t *input_ds;
int sf_len; uint32_t sf_len;
if (q->downsampling == 1) { if (q->downsampling == 1) {
input_ds = input; input_ds = input;

@ -75,7 +75,7 @@ unsigned int bit_diff(char *x, char *y, int nbits) {
} }
// Counts the number of ones in a word. K&R book exercise 2.9 // Counts the number of ones in a word. K&R book exercise 2.9
uint8_t bit_count(uint32_t n) { uint32_t bit_count(uint32_t n) {
int c; int c;
for (c = 0; n; c++) for (c = 0; n; c++)
n &= n - 1; n &= n - 1;

Loading…
Cancel
Save