Commit 423d69b0 authored by lukashov's avatar lukashov

fixing matlab mex functions for 64bit


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5890 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 7f450fd6
......@@ -167,72 +167,7 @@ int lte_segmentation(unsigned char *input_buffer,
return(0);
}
// uint8_t eNB_id,uint8_t harq_pid, uint8_t UE_id,
int16_t estimate_ue_tx_power(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs){
/// The payload + CRC size in bits, "B"
uint32_t B;
/// Number of code segments
uint32_t C;
/// Number of "small" code segments
uint32_t Cminus;
/// Number of "large" code segments
uint32_t Cplus;
/// Number of bits in "small" code segments (<6144)
uint32_t Kminus;
/// Number of bits in "large" code segments (<6144)
uint32_t Kplus;
/// Total number of bits across all segments
uint32_t sumKr;
/// Number of "Filler" bits
uint32_t F;
// num resource elements
uint32_t num_re=0.0;
// num symbols
uint32_t num_symb=0.0;
/// effective spectral efficiency of the PUSCH
uint32_t MPR_x100=0;
/// beta_offset
uint16_t beta_offset_pusch_x8=8;
/// delta mcs
float delta_mcs=0.0;
/// bandwidth factor
float bw_factor=0.0;
B= tbs+24;
lte_segmentation(NULL,
NULL,
B,
&C,
&Cplus,
&Cminus,
&Kplus,
&Kminus,
&F);
sumKr = Cminus*Kminus + Cplus*Kplus;
num_symb = 12-(ncp<<1)-(use_srs==0?0:1);
num_re = num_symb * nb_rb * 12;
if (num_re == 0)
return(0);
MPR_x100 = 100*sumKr/num_re;
if (control_only == 1 )
beta_offset_pusch_x8=8; // fixme
//(beta_offset_pusch_x8=phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->control_only == 1) ? phy_vars_ue->ulsch_ue[eNB_id]->beta_offset_cqi_times8:8;
// if deltamcs_enabledm
delta_mcs = ((hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch_x8)>>3))/100.0);
bw_factor = (hundred_times_log10_NPRB[nb_rb-1]/100.0);
#ifdef DEBUG_SEGMENTATION
printf("estimated ue tx power %d (num_re %d, sumKr %d, mpr_x100 %d, delta_mcs %f, bw_factor %f)\n",
(int16_t)ceil(delta_mcs + bw_factor), num_re, sumKr, MPR_x100, delta_mcs, bw_factor);
#endif
return (int16_t)ceil(delta_mcs + bw_factor);
}
#ifdef MAIN
main() {
......
......@@ -182,3 +182,69 @@ int8_t get_PHR(uint8_t Mod_id, uint8_t CC_id,uint8_t eNB_index){
return PHY_vars_UE_g[Mod_id][CC_id]->ulsch_ue[eNB_index]->PHR;
}
// uint8_t eNB_id,uint8_t harq_pid, uint8_t UE_id,
int16_t estimate_ue_tx_power(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs){
/// The payload + CRC size in bits, "B"
uint32_t B;
/// Number of code segments
uint32_t C;
/// Number of "small" code segments
uint32_t Cminus;
/// Number of "large" code segments
uint32_t Cplus;
/// Number of bits in "small" code segments (<6144)
uint32_t Kminus;
/// Number of bits in "large" code segments (<6144)
uint32_t Kplus;
/// Total number of bits across all segments
uint32_t sumKr;
/// Number of "Filler" bits
uint32_t F;
// num resource elements
uint32_t num_re=0.0;
// num symbols
uint32_t num_symb=0.0;
/// effective spectral efficiency of the PUSCH
uint32_t MPR_x100=0;
/// beta_offset
uint16_t beta_offset_pusch_x8=8;
/// delta mcs
float delta_mcs=0.0;
/// bandwidth factor
float bw_factor=0.0;
B= tbs+24;
lte_segmentation(NULL,
NULL,
B,
&C,
&Cplus,
&Cminus,
&Kplus,
&Kminus,
&F);
sumKr = Cminus*Kminus + Cplus*Kplus;
num_symb = 12-(ncp<<1)-(use_srs==0?0:1);
num_re = num_symb * nb_rb * 12;
if (num_re == 0)
return(0);
MPR_x100 = 100*sumKr/num_re;
if (control_only == 1 )
beta_offset_pusch_x8=8; // fixme
//(beta_offset_pusch_x8=phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->control_only == 1) ? phy_vars_ue->ulsch_ue[eNB_id]->beta_offset_cqi_times8:8;
// if deltamcs_enabledm
delta_mcs = ((hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch_x8)>>3))/100.0);
bw_factor = (hundred_times_log10_NPRB[nb_rb-1]/100.0);
#ifdef DEBUG_SEGMENTATION
printf("estimated ue tx power %d (num_re %d, sumKr %d, mpr_x100 %d, delta_mcs %f, bw_factor %f)\n",
(int16_t)ceil(delta_mcs + bw_factor), num_re, sumKr, MPR_x100, delta_mcs, bw_factor);
#endif
return (int16_t)ceil(delta_mcs + bw_factor);
}
......@@ -102,7 +102,6 @@ endif
include $(COMMON_UTILS_DIR)/Makefile.inc
include $(TOP_DIR)/PHY/Makefile.inc
SCHED_OBJS = $(TOP_DIR)/SCHED/phy_procedures_lte_common.o #$(TOP_DIR)/SCHED/phy_procedures_lte_eNb.o $(TOP_DIR)/SCHED/phy_procedures_lte_ue.o
include $(TOP_DIR)/SCHED/Makefile.inc
include $(TOP_DIR)/SIMULATION/Makefile.inc
include $(OPENAIR2_DIR)/LAYER2/Makefile.inc
......@@ -198,5 +197,8 @@ showflags :
@echo $(CFLAGS)
@echo $(LFLAGS)
showobj:
@echo $(SCHED_OBJS)
run: syncsim
rtai-load --verbose
include $(OPENAIR1_DIR)/SIMULATION/LTE_PHY/Makefile
#include $(OPENAIR1_DIR)/SIMULATION/LTE_PHY/Makefile
CFLAGS += -DMEX
CFLAGS += -I/opt/MATLAB/extern/include/
SSE3PROC = $(shell echo `grep ssse3 /proc/cpuinfo`)
SSE4PROC = $(shell echo `grep sse4 /proc/cpuinfo`)
CPUFLAGS = -mmmx -msse -msse2 -mssse3 -msse4.1
#CPUFLAGS += $(shell if [ -z $(SSE3PROC) ]; then echo "" ; else echo "-mssse3"; fi)
#CPUFLAGS += $(shell if [ -z $(SSE4PROC) ]; then echo "" ; else echo "-msse4"; fi)
COMMON_UTILS_DIR = $(OPENAIR_HOME)/common/utils
TOP_DIR = $(OPENAIR1_DIR)
OPENAIR1_TOP = $(OPENAIR1_DIR)
OPENAIR2_TOP = $(OPENAIR2_DIR)
OPENAIR3 = $(OPENAIR3_DIR)
CFLAGS = -g -ggdb -Wno-strict-aliasing -rdynamic -DMAX_NUM_CCs=1 -Wall -DPHYSIM -DNODE_RG -DUSER_MODE -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 -DPHY_CONTEXT=1 $(CPUFLAGS) -DMALLOC_CHECK_=1 -DENABLE_VCD_FIFO # -Wno-packed-bitfield-compat
CFLAGS += -DOPENAIR_LTE -DNO_RRM -DOPENAIR1 #-DPHY_ABSTRACTION #-DOPENAIR2
CFLAGS += -I/usr/include/X11 -I/usr/X11R6/include
include $(COMMON_UTILS_DIR)/Makefile.inc
include $(TOP_DIR)/PHY/Makefile.inc
include $(TOP_DIR)/SCHED/Makefile.inc
SCHED_OBJS = $(TOP_DIR)/SCHED/phy_procedures_lte_common.o #$(TOP_DIR)/SCHED/phy_procedures_lte_eNb.o $(TOP_DIR)/SCHED/phy_procedures_lte_ue.o
include $(TOP_DIR)/SIMULATION/Makefile.inc
include $(OPENAIR2_DIR)/LAYER2/Makefile.inc
include $(OPENAIR2_DIR)/UTIL/Makefile.inc
include $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc
ASN1_MSG_INC = $(OPENAIR2_DIR)/RRC/LITE/MESSAGES
CFLAGS += $(L2_incl) -I$(ASN1_MSG_INC) -I$(TOP_DIR) -I$(OPENAIR2_DIR) -I$(OPENAIR3) $(UTIL_incl) $(UTILS_incl)
CFLAGS += -DMEX -fPIC -g
CFLAGS += -I/opt/MATLAB/R2014a/extern/include/
# Set mex extension, can be determined with mexext function in Matlab
MEXEXT = mexglx
# Just compile all the PHY objects
OBJ = $(PHY_OBJS) $(TOP_DIR)/SIMULATION/TOOLS/taus.o $(LOG_DIR)/log.o $(LOG_DIR)/vcd_signal_dumper.o
OBJ = $(PHY_OBJS) $(TOP_DIR)/SIMULATION/TOOLS/taus.o $(LOG_DIR)/log.o $(LOG_DIR)/vcd_signal_dumper.o
# List of all mex-files to compile
MEX_FILES += ./PHY/LTE_TRANSPORT/mexfiles/get_tbs.$(MEXEXT)
......@@ -48,10 +80,15 @@ $(MEX_FILES) : %.$(MEXEXT) : %.c
mex : $(MEX_FILES)
cleanlibs :
rm $(LIBDIR)/lib$(LIBNAME).*
rm -f $(LIBDIR)/lib$(LIBNAME).*
cleanmex :
rm -f $(MEX_FILES)
clean:
rm -f $(OBJ)
cleanall: clean cleanlibs cleanmex
show :
echo $(CFLAGS)
echo $(ASN1_MSG_INC)
......@@ -12,7 +12,7 @@
*
===============================================================================*/
//#define DEBUG_DLSCH_DECODING
#define DEBUG_DLSCH_DECODING
void mexFunction( int mlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[]
......@@ -34,7 +34,7 @@ void mexFunction( int mlhs, mxArray *plhs[],
LTE_DL_FRAME_PARMS *frame_parms;
PHY_VARS_UE *phy_vars_ue;
extern int *pi2tab16[188],*pi5tab16[188],*pi4tab16[188],*pi6tab16[188];
unsigned int *ptr_td;
unsigned long *ptr_td; //hack for 64bit
int *tmp[1];
/* Allocate input */
......@@ -107,7 +107,7 @@ void mexFunction( int mlhs, mxArray *plhs[],
mod_order = get_Qm(dlsch->harq_processes[harq_pid]->mcs);
dlsch->harq_processes[harq_pid]->G = get_G(frame_parms,dlsch->harq_processes[harq_pid]->nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,num_pdcch_symbols,0,subframe);
dlsch->harq_processes[harq_pid]->G = get_G(frame_parms,dlsch->harq_processes[harq_pid]->nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,dlsch->harq_processes[harq_pid]->Nl,num_pdcch_symbols,0,subframe);
#ifdef DEBUG_DLSCH_DECODING
mexPrintf("TBS %d\n",dlsch->harq_processes[harq_pid]->TBS);
......
......@@ -12,7 +12,7 @@
*
===============================================================================*/
//#define DEBUG_DLSCH_DECODING_INIT
#define DEBUG_DLSCH_DECODING_INIT
void mexFunction( int mlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[]
......@@ -20,7 +20,7 @@ void mexFunction( int mlhs, mxArray *plhs[],
{
extern int *pi2tab16[188],*pi5tab16[188],*pi4tab16[188],*pi6tab16[188];
int i;
unsigned int *ptr;
unsigned long *ptr; //hack for 64bit
int **tmp[1];
// Init CRC tables
......@@ -28,7 +28,7 @@ void mexFunction( int mlhs, mxArray *plhs[],
init_td16();
// assign output
plhs[0] = mxCreateNumericMatrix(4,1, mxUINT32_CLASS, mxREAL);
plhs[0] = mxCreateNumericMatrix(4,1, mxUINT64_CLASS, mxREAL);
ptr = (unsigned int*) mxGetData(plhs[0]);
tmp[0] = &pi2tab16[0];
......
......@@ -171,7 +171,7 @@ void mexFunction( int nlhs, mxArray *plhs[],
}
mod_order = get_Qm(dlsch->harq_processes[harq_pid]->mcs);
G = get_G(frame_parms,dlsch->nb_rb,dlsch->rb_alloc,mod_order,num_pdcch_symbols,0,subframe);
G = get_G(frame_parms,dlsch->nb_rb,dlsch->rb_alloc,mod_order,dlsch->harq_processes[harq_pid]->Nl,num_pdcch_symbols,0,subframe);
#ifdef DEBUG_DLSCH_ENCODING
mexPrintf("dlsch->current_harq_pid = %d\n", dlsch->current_harq_pid);
......
......@@ -29,6 +29,7 @@
#include "mex.h"
#include "../../SIMULATION/TOOLS/defs.h"
#include "../../PHY/types.h"
#include "../../PHY/TOOLS/defs.h"
#include "../../PHY/defs.h"
#include "../../PHY/vars.h"
#include "../../MAC_INTERFACE/vars.h"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment