fix build_oai and CUDA latency

parent b64b6e85
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
#---------------------------------------------------------------------
# Python for CI of OAI-eNB + COTS-UE
#
# Required Python Version
# Python 3.x
#
# Required Python Package
# pexpect
#---------------------------------------------------------------------
#to use logging.info()
import logging
#to create a SSH object locally in the methods
import sshconnection
#to update the HTML object
import html
from multiprocessing import SimpleQueue
#for log folder maintenance
import os
class PhySim:
def __init__(self):
self.buildargs = ""
self.runargs = ""
self.eNBIpAddr = ""
self.eNBUserName = ""
self.eNBPassWord = ""
self.eNBSourceCodePath = ""
self.ranRepository = ""
self.ranBranch = ""
self.ranCommitID= ""
self.ranAllowMerge= ""
self.ranTargetBranch= ""
self.exitStatus=0
self.forced_workspace_cleanup=False
#private attributes
self.__workSpacePath=''
self.__buildLogFile='compile_phy_sim.log'
self.__runLogFile=''
self.__runResults=[]
self.__runLogPath='phy_sim_logs'
#-----------------
#PRIVATE Methods
#-----------------
def __CheckResults_PhySim(self,HTML,CONST,testcase_id):
mySSH = sshconnection.SSHConnection()
mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord)
#retrieve run log file and store it locally$
mySSH.copyin(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord, self.__workSpacePath+self.__runLogFile, '.')
mySSH.close()
#parse results looking for Encoding and Decoding mean values
self.__runResults=[]
with open(self.__runLogFile) as f:
for line in f:
if 'mean' in line:
self.__runResults.append(line)
#the values are appended for each mean value (2), so we take these 2 values from the list
info=self.__runResults[0]+self.__runResults[1]
#once parsed move the local logfile to its folder for tidiness
os.system('mv '+self.__runLogFile+' '+ self.__runLogPath+'/.')
#updating the HTML with results
html_cell = '<pre style="background-color:white">' + info + '</pre>'
html_queue=SimpleQueue()
html_queue.put(html_cell)
HTML.CreateHtmlTestRowQueue(self.runargs, 'OK', 1, html_queue)
return HTML
def __CheckBuild_PhySim(self, HTML, CONST):
self.__workSpacePath=self.eNBSourceCodePath+'/cmake_targets/'
mySSH = sshconnection.SSHConnection()
mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord)
#retrieve compile log file and store it locally
mySSH.copyin(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord, self.__workSpacePath+self.__buildLogFile, '.')
#delete older run log file
mySSH.command('rm ' + self.__workSpacePath+self.__runLogFile, '\$', 5)
mySSH.close()
#check build result from local compile log file
buildStatus=False
with open(self.__buildLogFile) as f:
#nr_prachsim is the last compile step
if 'nr_prachsim compiled' in f.read():
buildStatus=True
#update HTML based on build status
if buildStatus:
HTML.CreateHtmlTestRow(self.buildargs, 'OK', CONST.ALL_PROCESSES_OK, 'LDPC')
self.exitStatus=0
else:
logging.error('\u001B[1m Building Physical Simulators Failed\u001B[0m')
HTML.CreateHtmlTestRow(self.buildargs, 'KO', CONST.ALL_PROCESSES_OK, 'LDPC')
HTML.CreateHtmlTabFooter(False)
#exitStatus=1 will do a sys.exit in main
self.exitStatus=1
return HTML
#-----------------$
#PUBLIC Methods$
#-----------------$
def Build_PhySim(self,htmlObj,constObj):
mySSH = sshconnection.SSHConnection()
mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord)
#create working dir
mySSH.command('mkdir -p ' + self.eNBSourceCodePath, '\$', 5)
mySSH.command('cd ' + self.eNBSourceCodePath, '\$', 5)
if not self.ranRepository.lower().endswith('.git'):
self.ranRepository+='.git'
#git clone
mySSH.command('if [ ! -e .git ]; then stdbuf -o0 git clone ' + self.ranRepository + ' .; else stdbuf -o0 git fetch --prune; fi', '\$', 600)
#git config
mySSH.command('git config user.email "jenkins@openairinterface.org"', '\$', 5)
mySSH.command('git config user.name "OAI Jenkins"', '\$', 5)
#git clean depending on self.forced_workspace_cleanup captured in xml
if self.forced_workspace_cleanup==True:
logging.info('Cleaning workspace ...')
mySSH.command('echo ' + self.eNBPassWord + ' | sudo -S git clean -x -d -ff', '\$', 30)
else:
logging.info('Workspace cleaning was disabled')
# if the commit ID is provided, use it to point to it
if self.ranCommitID != '':
mySSH.command('git checkout -f ' + self.ranCommitID, '\$', 5)
# if the branch is not develop, then it is a merge request and we need to do
# the potential merge. Note that merge conflicts should have already been checked earlier
if (self.ranAllowMerge):
if self.ranTargetBranch == '':
if (self.ranBranch != 'develop') and (self.ranBranch != 'origin/develop'):
mySSH.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5)
else:
logging.info('Merging with the target branch: ' + self.ranTargetBranch)
mySSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5)
#build
mySSH.command('source oaienv', '\$', 5)
mySSH.command('cd cmake_targets', '\$', 5)
mySSH.command('mkdir -p log', '\$', 5)
mySSH.command('chmod 777 log', '\$', 5)
mySSH.command('stdbuf -o0 ./build_oai ' + self.buildargs + ' 2>&1 | stdbuf -o0 tee ' + self.__buildLogFile, 'Bypassing the Tests|build have failed', 1500)
mySSH.close()
#check build status and update HTML object
lHTML = html.HTMLManagement()
lHTML=self.__CheckBuild_PhySim(htmlObj,constObj)
return lHTML
def Run_PhySim(self,htmlObj,constObj,testcase_id):
#create run logs folder locally
os.system('mkdir -p ./'+self.__runLogPath)
#log file is tc_<testcase_id>.log remotely
self.__runLogFile='physim_'+str(testcase_id)+'.log'
#open a session for test run
mySSH = sshconnection.SSHConnection()
mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord)
mySSH.command('cd '+self.__workSpacePath,'\$',5)
#run and redirect the results to a log file
mySSH.command(self.__workSpacePath+'phy_simulators/build/ldpctest ' + self.runargs + ' >> '+self.__runLogFile, '\$', 30)
mySSH.close()
#return updated HTML to main
lHTML = html.HTMLManagement()
lHTML=self.__CheckResults_PhySim(htmlObj,constObj,testcase_id)
return lHTML
<!--
Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The OpenAirInterface Software Alliance licenses this file to You under
the OAI Public License, Version 1.1 (the "License"); you may not use this file
except in compliance with the License.
You may obtain a copy of the License at
http://www.openairinterface.org/?page_id=698
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
For more information about the OpenAirInterface (OAI) Software Alliance:
contact@openairinterface.org
-->
<testCaseList>
<htmlTabRef>run-oai-gnb-nr-ue-tx-write-thread</htmlTabRef>
<htmlTabName>Run-gNB-and-NR-UE-TX-Write-Thread</htmlTabName>
<htmlTabIcon>tasks</htmlTabIcon>
<repeatCount>2</repeatCount>
<TestCaseRequestedList>
090103 000001 090104 000002 090108 090109
</TestCaseRequestedList>
<TestCaseExclusionList></TestCaseExclusionList>
<testCase id="090103">
<class>Initialize_eNB</class>
<desc>Initialize gNB USRP (Tx-Write-Threading enabled)</desc>
<Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf --phy-test --usrp-tx-thread-config 1</Initialize_eNB_args>
<air_interface>NR</air_interface>
</testCase>
<testCase id="000001">
<class>IdleSleep</class>
<desc>Sleep</desc>
<idle_sleep_time_in_sec>5</idle_sleep_time_in_sec>
</testCase>
<testCase id="000002">
<class>IdleSleep</class>
<desc>Waiting for NR UE to synchronize w/ gNB</desc>
<idle_sleep_time_in_sec>180</idle_sleep_time_in_sec>
</testCase>
<testCase id="090104">
<class>Initialize_OAI_UE</class>
<desc>Initialize NR UE USRP</desc>
<Initialize_OAI_UE_args>--phy-test --usrp-args "addr=192.168.30.2,second_addr=192.168.50.2,clock_source=external,time_source=external" --threadoffset 16 --rrc_config_path .</Initialize_OAI_UE_args>
<air_interface>NR</air_interface>
</testCase>
<testCase id="090108">
<class>Terminate_OAI_UE</class>
<desc>Terminate NR UE</desc>
<air_interface>NR</air_interface>
</testCase>
<testCase id="090109">
<class>Terminate_eNB</class>
<desc>Terminate gNB</desc>
<air_interface>NR</air_interface>
</testCase>
</testCaseList>
<!--
Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The OpenAirInterface Software Alliance licenses this file to You under
the OAI Public License, Version 1.1 (the "License"); you may not use this file
except in compliance with the License.
You may obtain a copy of the License at
http://www.openairinterface.org/?page_id=698
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
For more information about the OpenAirInterface (OAI) Software Alliance:
contact@openairinterface.org
030105 040301 040502 040606 040601 040603 040608 040605 040646 040641 040643 040648 040645 040401 040201 030201
-->
<testCaseList>
<htmlTabRef>test-ldpc-gpu</htmlTabRef>
<htmlTabName>Test-ldpc-GPU</htmlTabName>
<htmlTabIcon>tasks</htmlTabIcon>
<repeatCount>1</repeatCount>
<TestCaseRequestedList>000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 000011 000012 000013 000014 000015 000016 000017 000018 000019 000020 000021</TestCaseRequestedList>
<TestCaseExclusionList></TestCaseExclusionList>
<testCase id="000001">
<class>Build_PhySim</class>
<desc>Build for physical simulator</desc>
<physim_build_args>--phy_simulators --ninja</physim_build_args>
<forced_workspace_cleanup>FALSE</forced_workspace_cleanup>
</testCase>
<testCase id="000002">
<class>Run_PhySim</class>
<desc>Run LDPC Test with CPU</desc>
<physim_run_args>-l 3872 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000003">
<class>Run_PhySim</class>
<desc>Run LDPC Test with GPU</desc>
<physim_run_args>-l 3872 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000004">
<class>Run_PhySim</class>
<desc>Run LDPC Test with CPU</desc>
<physim_run_args>-l 4224 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000005">
<class>Run_PhySim</class>
<desc>Run LDPC Test with GPU</desc>
<physim_run_args>-l 4224 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000006">
<class>Run_PhySim</class>
<desc>Run LDPC Test with CPU</desc>
<physim_run_args>-l 4576 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000007">
<class>Run_PhySim</class>
<desc>Run LDPC Test with GPU</desc>
<physim_run_args>-l 4576 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000008">
<class>Run_PhySim</class>
<desc>Run LDPC Test with CPU</desc>
<physim_run_args>-l 4928 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000009">
<class>Run_PhySim</class>
<desc>Run LDPC Test with GPU</desc>
<physim_run_args>-l 4928 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000010">
<class>Run_PhySim</class>
<desc>Run LDPC Test with CPU</desc>
<physim_run_args>-l 5280 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000011">
<class>Run_PhySim</class>
<desc>Run LDPC Test with GPU</desc>
<physim_run_args>-l 5280 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000012">
<class>Run_PhySim</class>
<desc>Run LDPC Test with CPU</desc>
<physim_run_args>-l 5632 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000013">
<class>Run_PhySim</class>
<desc>Run LDPC Test with GPU</desc>
<physim_run_args>-l 5632 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000014">
<class>Run_PhySim</class>
<desc>Run LDPC Test with CPU</desc>
<physim_run_args>-l 6336 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000015">
<class>Run_PhySim</class>
<desc>Run LDPC Test with GPU</desc>
<physim_run_args>-l 6336 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000016">
<class>Run_PhySim</class>
<desc>Run LDPC Test with CPU</desc>
<physim_run_args>-l 7040 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000017">
<class>Run_PhySim</class>
<desc>Run LDPC Test with GPU</desc>
<physim_run_args>-l 7040 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000018">
<class>Run_PhySim</class>
<desc>Run LDPC Test with CPU</desc>
<physim_run_args>-l 7744 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000019">
<class>Run_PhySim</class>
<desc>Run LDPC Test with GPU</desc>
<physim_run_args>-l 7744 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000020">
<class>Run_PhySim</class>
<desc>Run LDPC Test with CPU</desc>
<physim_run_args>-l 8448 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000021">
<class>Run_PhySim</class>
<desc>Run LDPC Test with GPU</desc>
<physim_run_args>-l 8448 -s10 -n100 -G 1</physim_run_args>
</testCase>
</testCaseList>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file PHY/NR_TRANSPORT/nr_dci_tools_common.c
* \brief
* \author
* \date 2018
* \version 0.1
* \company Eurecom
* \email:
* \note
* \warning
*/
#include "nr_dci.h"
//#define DEBUG_FILL_DCI
#include "nr_dlsch.h"
void get_coreset_rballoc(uint8_t *FreqDomainResource,int *n_rb,int *rb_offset) {
uint8_t count=0, start=0, start_set=0;
uint64_t bitmap = (((uint64_t)FreqDomainResource[0])<<37)|
(((uint64_t)FreqDomainResource[1])<<29)|
(((uint64_t)FreqDomainResource[2])<<21)|
(((uint64_t)FreqDomainResource[3])<<13)|
(((uint64_t)FreqDomainResource[4])<<5)|
(((uint64_t)FreqDomainResource[5])>>3);
for (int i=0; i<45; i++)
if ((bitmap>>(44-i))&1) {
count++;
if (!start_set) {
start = i;
start_set = 1;
}
}
*rb_offset = 6*start;
*n_rb = 6*count;
}
This diff is collapsed.
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*!
* \file slicing.h
* \brief General slice definition and helper parameters
* \author Robert Schmidt
* \date 2020
* \email robert.schmidt@eurecom.fr
*/
#ifndef __SLICING_H__
#define __SLICING_H__
#include "openair2/LAYER2/MAC/mac.h"
typedef struct slice_s {
/// Arbitrary ID
slice_id_t id;
/// Arbitrary label
char *label;
union {
default_sched_dl_algo_t dl_algo;
default_sched_ul_algo_t ul_algo;
};
/// A specific algorithm's implementation parameters
void *algo_data;
/// Internal data that might be kept alongside a slice's params
void *int_data;
// list of users in this slice
UE_list_t UEs;
} slice_t;
typedef struct slice_info_s {
uint8_t num;
slice_t **s;
uint8_t UE_assoc_slice[MAX_MOBILES_PER_ENB];
} slice_info_t;
int slicing_get_UE_slice_idx(slice_info_t *si, int UE_id);
#define STATIC_SLICING 10
/* only four static slices for UL, DL resp. (not enough DCIs) */
#define MAX_STATIC_SLICES 4
typedef struct {
uint16_t posLow;
uint16_t posHigh;
} static_slice_param_t;
pp_impl_param_t static_dl_init(module_id_t mod_id, int CC_id);
pp_impl_param_t static_ul_init(module_id_t mod_id, int CC_id);
#endif /* __SLICING_H__ */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*!
* \file slicing_internal.h
* \brief Internal slice helper functions
* \author Robert Schmidt
* \date 2020
* \email robert.schmidt@eurecom.fr
*/
#ifndef __SLICING_INTERNAL_H__
#define __SLICING_INTERNAL_H__
#include "slicing.h"
void slicing_add_UE(slice_info_t *si, int UE_id);
void _remove_UE(slice_t **s, uint8_t *assoc, int UE_id);
void slicing_remove_UE(slice_info_t *si, int UE_id);
void _move_UE(slice_t **s, uint8_t *assoc, int UE_id, int to);
void slicing_move_UE(slice_info_t *si, int UE_id, int idx);
slice_t *_add_slice(uint8_t *n, slice_t **s);
slice_t *_remove_slice(uint8_t *n, slice_t **s, uint8_t *assoc, int idx);
#endif /* __SLICING_INTERNAL_H__ */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file mac.h
* \brief MAC data structures, constant, and function prototype
* \author Navid Nikaein and Raymond Knopp, WIE-TAI CHEN
* \date Dec. 2019
* \version 0.1
* \company Eurecom
* \email raymond.knopp@eurecom.fr
*/
#ifndef __LAYER2_NR_MAC_COMMON_H__
#define __LAYER2_NR_MAC_COMMON_H__
#include "NR_PDSCH-Config.h"
#include "NR_CellGroupConfig.h"
#include "nr_mac.h"
typedef enum {
NR_DL_DCI_FORMAT_1_0 = 0,
NR_DL_DCI_FORMAT_1_1,
NR_DL_DCI_FORMAT_2_0,
NR_DL_DCI_FORMAT_2_1,
NR_DL_DCI_FORMAT_2_2,
NR_DL_DCI_FORMAT_2_3,
NR_UL_DCI_FORMAT_0_0,
NR_UL_DCI_FORMAT_0_1
} nr_dci_format_t;
typedef enum {
NR_RNTI_new = 0,
NR_RNTI_C,
NR_RNTI_RA,
NR_RNTI_P,
NR_RNTI_CS,
NR_RNTI_TC,
NR_RNTI_SP_CSI,
NR_RNTI_SI,
NR_RNTI_SFI,
NR_RNTI_INT,
NR_RNTI_TPC_PUSCH,
NR_RNTI_TPC_PUCCH,
NR_RNTI_TPC_SRS
} nr_rnti_type_t;
uint16_t config_bandwidth(int mu, int nb_rb, int nr_band);
void get_band(uint64_t downlink_frequency, uint16_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type);
uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn);
uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint8_t scs_index, uint32_t bw);
int16_t fill_dmrs_mask(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols);
int is_nr_DL_slot(NR_ServingCellConfigCommon_t *scc,slot_t slotP);
int is_nr_UL_slot(NR_ServingCellConfigCommon_t *scc,slot_t slotP);
uint16_t nr_dci_size(NR_ServingCellConfigCommon_t *scc,
NR_CellGroupConfig_t *secondaryCellGroup,
dci_pdu_rel15_t *dci_pdu,
nr_dci_format_t format,
nr_rnti_type_t rnti_type,
uint16_t N_RB,
int bwp_id);
void find_monitoring_periodicity_offset_common(NR_SearchSpace_t *ss,
uint16_t *slot_period,
uint16_t *offset);
int get_nr_prach_info_from_index(uint8_t index,
int frame,
int slot,
uint32_t pointa,
uint8_t mu,
uint8_t unpaired,
uint16_t *format,
uint8_t *start_symbol,
uint8_t *N_t_slot,
uint8_t *N_dur);
uint8_t compute_nr_root_seq(NR_RACH_ConfigCommon_t *rach_config,
uint8_t nb_preambles,
uint8_t unpaired);
int ul_ant_bits(NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig,long transformPrecoder);
int get_format0(uint8_t index, uint8_t unpaired);
uint16_t get_NCS(uint8_t index, uint16_t format, uint8_t restricted_set_config);
int get_num_dmrs(uint16_t dmrs_mask );
uint8_t get_l0_ul(uint8_t mapping_type, uint8_t dmrs_typeA_position);
int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmrs_AdditionalPosition_t additional_pos, pusch_maxLength_t pusch_maxLength);
uint8_t get_L_ptrs(uint8_t mcs1, uint8_t mcs2, uint8_t mcs3, uint8_t I_mcs, uint8_t mcs_table);
uint8_t get_K_ptrs(uint16_t nrb0, uint16_t nrb1, uint16_t N_RB);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nr_l1_helper.c
* \brief PHY helper functions for PRACH adapted to NR
* \author Guido Casati
* \date 2019
* \version 2.0
* \email guido.casati@iis.fraunhofer.de
* @ingroup _mac
*/
#include "PHY/defs_nr_common.h"
#include "mac_defs.h"
#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h"
#include "LAYER2/NR_MAC_UE/mac_proto.h"
/* TS 38.321 subclause 7.3 - return DELTA_PREAMBLE values in dB */
int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_format){
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
NR_ServingCellConfigCommon_t *scc = mac->scc;
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
NR_SubcarrierSpacing_t scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing;
int prach_sequence_length = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present - 1;
uint8_t prachConfigIndex, mu;
AssertFatal(CC_id == 0, "Transmission on secondary CCs is not supported yet\n");
// SCS configuration from msg1_SubcarrierSpacing and table 4.2-1 in TS 38.211
switch (scs){
case NR_SubcarrierSpacing_kHz15:
mu = 0;
break;
case NR_SubcarrierSpacing_kHz30:
mu = 1;
break;
case NR_SubcarrierSpacing_kHz60:
mu = 2;
break;
case NR_SubcarrierSpacing_kHz120:
mu = 3;
break;
case NR_SubcarrierSpacing_kHz240:
mu = 4;
break;
case NR_SubcarrierSpacing_spare3:
mu = 5;
break;
case NR_SubcarrierSpacing_spare2:
mu = 6;
break;
case NR_SubcarrierSpacing_spare1:
mu = 7;
break;
default:
AssertFatal(1 == 0,"Unknown msg1_SubcarrierSpacing %lu\n", scs);
}
// Preamble formats given by prach_ConfigurationIndex and tables 6.3.3.2-2 and 6.3.3.2-2 in TS 38.211
prachConfigIndex = nr_rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex;
if (prach_sequence_length == 0) {
AssertFatal(prach_format < 4, "Illegal PRACH format %d for sequence length 839\n", prach_format);
switch (prach_format) {
// long preamble formats
case 0:
case 3:
return 0;
case 1:
return -3;
case 2:
return -6;
}
} else {
switch (prach_format) { // short preamble formats
case 0:
case 3:
return 8 + 3*mu;
case 1:
case 4:
case 8:
return 5 + 3*mu;
case 2:
case 5:
return 3 + 3*mu;
case 6:
return 3*mu;
case 7:
return 5 + 3*mu;
default:
AssertFatal(1 == 0, "[UE %d] ue_procedures.c: FATAL, Illegal preambleFormat %d, prachConfigIndex %d\n", mod_id, prach_format, prachConfigIndex);
}
}
return 0;
}
/* TS 38.321 subclause 5.1.3 - RA preamble transmission - ra_PREAMBLE_RECEIVED_TARGET_POWER configuration */
int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t mod_id, uint8_t CC_id){
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
NR_ServingCellConfigCommon_t *scc = mac->scc;
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
int8_t receivedTargerPower, delta_preamble;
long preambleReceivedTargetPower;
AssertFatal(nr_rach_ConfigCommon != NULL, "[UE %d] CCid %d FATAL nr_rach_ConfigCommon is NULL !!!\n", mod_id, CC_id);
preambleReceivedTargetPower = nr_rach_ConfigCommon->rach_ConfigGeneric.preambleReceivedTargetPower;
delta_preamble = nr_get_DELTA_PREAMBLE(mod_id, CC_id, prach_resources->prach_format);
receivedTargerPower = preambleReceivedTargetPower + delta_preamble + (mac->RA_PREAMBLE_POWER_RAMPING_COUNTER - 1) * prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP;
return receivedTargerPower;
}
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file rar_tools_nrUE.c
* \brief RA tools for NR UE
* \author Guido Casati
* \date 2019
* \version 1.0
* @ingroup _mac
*/
/* Sim */
#include "SIMULATION/TOOLS/sim.h"
/* Utils */
#include "common/utils/LOG/log.h"
#include "OCG.h"
#include "OCG_extern.h"
#include "UTIL/OPT/opt.h"
/* Common */
#include "common/ran_context.h"
/* MAC */
#include "NR_MAC_UE/mac.h"
#include "NR_MAC_UE/mac_proto.h"
#include "NR_MAC_COMMON/nr_mac_extern.h"
#include <common/utils/nr/nr_common.h>
#define DEBUG_RAR
// table 7.2-1 TS 38.321
uint16_t table_7_2_1[16] = {
5, // row index 0
10, // row index 1
20, // row index 2
30, // row index 3
40, // row index 4
60, // row index 5
80, // row index 6
120, // row index 7
160, // row index 8
240, // row index 9
320, // row index 10
480, // row index 11
960, // row index 12
1920, // row index 13
};
/////////////////////////////////////
// Random Access Response PDU //
// TS 38.213 ch 8.2 //
// TS 38.321 ch 6.2.3 //
/////////////////////////////////////
//| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |// bit-wise
//| E | T | R A P I D |//
//| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |//
//| R | T A |//
//| T A | UL grant |//
//| UL grant |//
//| UL grant |//
//| UL grant |//
//| T C - R N T I |//
//| T C - R N T I |//
/////////////////////////////////////
// UL grant (27 bits) //
/////////////////////////////////////
//| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |// bit-wise
//|-------------------|FHF|F_alloc|//
//| Freq allocation |//
//| F_alloc |Time allocation|//
//| MCS | TPC |CSI|//
/////////////////////////////////////
// WIP todo:
// - apply UL grant freq alloc & time alloc as per 8.2 TS 38.213
// - apply tpc command, csi req, mcs
uint16_t nr_ue_process_rar(module_id_t mod_id,
int CC_id,
frame_t frameP,
uint8_t * dlsch_buffer,
rnti_t * t_crnti,
uint8_t preamble_index,
uint8_t * selected_rar_buffer){
NR_UE_MAC_INST_t *ue_mac = get_mac_inst(mod_id);
NR_RA_HEADER_RAPID *rarh = (NR_RA_HEADER_RAPID *) dlsch_buffer; // RAR subheader pointer
NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 1); // RAR subPDU pointer
uint8_t n_subPDUs = 0; // number of RAR payloads
uint8_t n_subheaders = 0; // number of MAC RAR subheaders
//uint8_t best_rx_rapid = -1; // the closest RAPID receive from all RARs
unsigned char freq_hopping, msg3_t_alloc, mcs, tpc_command, csi_req;
uint16_t ta_command = 0, msg3_f_alloc, bwp_size;
int f_alloc, mask;
AssertFatal(CC_id == 0, "RAR reception on secondary CCs is not supported yet\n");
while (1) {
n_subheaders++;
if (rarh->T == 1) {
n_subPDUs++;
LOG_D(MAC, "[UE %d][RAPROC] Got RAPID RAR subPDU\n", mod_id);
} else {
n_subPDUs++;
ue_mac->RA_backoff_indicator = table_7_2_1[((NR_RA_HEADER_BI *)rarh)->BI];
ue_mac->RA_BI_found = 1;
LOG_D(MAC, "[UE %d][RAPROC] Got BI RAR subPDU %d\n", mod_id, ue_mac->RA_backoff_indicator);
}
if (rarh->RAPID == preamble_index) {
LOG_D(PHY, "[UE %d][RAPROC] Found RAR with the intended RAPID %d\n", mod_id, rarh->RAPID);
rar = (NR_MAC_RAR *) (dlsch_buffer + n_subheaders + (n_subPDUs - 1) * sizeof(NR_MAC_RAR));
ue_mac->RA_RAPID_found = 1;
break;
}
if (rarh->E == 0) {
LOG_I(PHY, "No RAR found with the intended RAPID. \n");
break;
} else {
rarh += sizeof(NR_MAC_RAR) + 1;
}
};
LOG_D(MAC, "number of RAR subheader %d; number of RAR pyloads %d\n", n_subheaders, n_subPDUs);
// LOG_I(MAC, "[UE %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n",
// mod_id, frameP, *(uint8_t *) rarh, rar[0], rar[1], rar[2], rar[3], rar[4], rar[5], rarh->RAPID, preamble_index);
if (ue_mac->RA_RAPID_found) {
// TC-RNTI
*t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8);
ue_mac->t_crnti = *t_crnti;
ue_mac->rnti_type = NR_RNTI_TC;
// TA command
ta_command = rar->TA2 + (rar->TA1 << 5);
// CSI
csi_req = (unsigned char) (rar->UL_GRANT_4 & 0x01);
// TPC
tpc_command = (unsigned char) ((rar->UL_GRANT_4 >> 1) & 0x07);
switch (tpc_command){
case 0:
ue_mac->Msg3_TPC = -6;
break;
case 1:
ue_mac->Msg3_TPC = -4;
break;
case 2:
ue_mac->Msg3_TPC = -2;
break;
case 3:
ue_mac->Msg3_TPC = 0;
break;
case 4:
ue_mac->Msg3_TPC = 2;
break;
case 5:
ue_mac->Msg3_TPC = 4;
break;
case 6:
ue_mac->Msg3_TPC = 6;
break;
case 7:
ue_mac->Msg3_TPC = 8;
break;
}
//MCS
mcs = (unsigned char) (rar->UL_GRANT_4 >> 4);
// time and frequency alloc
bwp_size = NRRIV2BW(ue_mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275);
msg3_t_alloc = (unsigned char) (rar->UL_GRANT_3 & 0x07);
msg3_f_alloc = (uint16_t) ((rar->UL_GRANT_3 >> 4) | (rar->UL_GRANT_2 << 4) | ((rar->UL_GRANT_1 & 0x03) << 12));
if (bwp_size < 180)
mask = (1 << ((int) ceil(log2((bwp_size*(bwp_size+1))>>1)))) - 1;
else
mask = (1 << (28 - (int)(ceil(log2((bwp_size*(bwp_size+1))>>1))))) - 1;
f_alloc = msg3_f_alloc & mask;
// frequency hopping flag
freq_hopping = (unsigned char) (rar->UL_GRANT_1 >> 2);
} else {
ue_mac->t_crnti = 0;
ta_command = (0xffff);
}
// move the selected RAR to the front of the RA_PDSCH buffer
memcpy((void *) (selected_rar_buffer + 0), (void *) rarh, 1);
memcpy((void *) (selected_rar_buffer + 1), (void *) rar, sizeof(NR_MAC_RAR));
return ta_command;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file rrc_gNB_GTPV1U.c
* \brief rrc GTPV1U procedures for gNB
* \author Lionel GAUTHIER, Panos MATZAKOS
* \version 1.0
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr, panagiotis.matzakos@eurecom.fr
*/
# include "rrc_defs.h"
# include "rrc_extern.h"
# include "RRC/LTE/MESSAGES/asn1_msg.h"
# include "rrc_eNB_GTPV1U.h"
# include "rrc_eNB_UE_context.h"
# include "msc.h"
# include "openair2/RRC/NR/rrc_gNB_UE_context.h"
//# if defined(ENABLE_ITTI)
# include "asn1_conversions.h"
# include "intertask_interface.h"
//#endif
# include "common/ran_context.h"
extern RAN_CONTEXT_t RC;
int
rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(
const protocol_ctxt_t *const ctxt_pP,
const gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP,
uint8_t *inde_list
) {
rnti_t rnti;
int i;
struct rrc_gNB_ue_context_s *ue_context_p = NULL;
if (create_tunnel_resp_pP) {
LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" RX CREATE_TUNNEL_RESP num tunnels %u \n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
create_tunnel_resp_pP->num_tunnels);
rnti = create_tunnel_resp_pP->rnti;
ue_context_p = rrc_gNB_get_ue_context(
RC.nrrrc[ctxt_pP->module_id],
ctxt_pP->rnti);
for (i = 0; i < create_tunnel_resp_pP->num_tunnels; i++) {
ue_context_p->ue_context.gnb_gtp_teid[inde_list[i]] = create_tunnel_resp_pP->enb_S1u_teid[i];
ue_context_p->ue_context.gnb_gtp_addrs[inde_list[i]] = create_tunnel_resp_pP->enb_addr;
ue_context_p->ue_context.gnb_gtp_ebi[inde_list[i]] = create_tunnel_resp_pP->eps_bearer_id[i];
LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP tunnel (%u, %u) bearer UE context index %u, msg index %u, id %u, gtp addr len %d \n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
create_tunnel_resp_pP->enb_S1u_teid[i],
ue_context_p->ue_context.gnb_gtp_teid[inde_list[i]],
inde_list[i],
i,
create_tunnel_resp_pP->eps_bearer_id[i],
create_tunnel_resp_pP->enb_addr.length);
}
MSC_LOG_RX_MESSAGE(
MSC_RRC_ENB,
MSC_GTPU_ENB,
NULL,0,
MSC_AS_TIME_FMT" CREATE_TUNNEL_RESP RNTI %"PRIx16" ntuns %u ebid %u enb-s1u teid %u",
0,0,rnti,
create_tunnel_resp_pP->num_tunnels,
ue_context_p->ue_context.gnb_gtp_ebi[0],
ue_context_p->ue_context.gnb_gtp_teid[0]);
(void)rnti; /* avoid gcc warning "set but not used" */
return 0;
} else {
return -1;
}
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file rrc_gNB_GTPV1U.h
* \brief rrc GTPV1U procedures for gNB
* \author Lionel GAUTHIER, Panos MATZAKOS
* \version 1.0
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr, panagiotis.matzakos@eurecom.fr
*/
#ifndef RRC_GNB_GTPV1U_H_
#define RRC_GNB_GTPV1U_H_
int
rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(
const protocol_ctxt_t *const ctxt_pP,
const gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP,
uint8_t *inde_list
);
This diff is collapsed.
/* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file gtpv1u_gNB_task.h
* \brief
* \author Lionel Gauthier Panos Matzakos
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
*/
#ifndef GTPV1U_GNB_TASK_H_
#define GTPV1U_GNB_TASK_H_
int gtpv1u_gNB_init(void);
void *gtpv1u_gNB_task(void *args);
#endif /* GTPV1U_GNB_TASK_H_ */
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Author and copyright: Laurent Thomas, open-cells.com
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
#include <errno.h>
#include <common/utils/assertions.h>
#include <common/utils/LOG/log.h>
#include <common/config/config_userapi.h>
#include <openair1/SIMULATION/TOOLS/sim.h>
#include <targets/ARCH/rfsimulator/rfsimulator.h>
// Ziggurat
static double wn[128],fn[128];
static uint32_t iz,jz,jsr=123456789,kn[128];
static int32_t hz;
#define SHR3 (jz=jsr, jsr^=(jsr<<13),jsr^=(jsr>>17),jsr^=(jsr<<5),jz+jsr)
#define UNI (0.5+(signed) SHR3 * 0.2328306e-9)
double nfix(void) {
const double r = 3.442620;
static double x, y;
for (;;) {
x=hz * wn[iz];
if (iz==0) {
do {
x = - 0.2904764 * log (UNI);
y = - log (UNI);
} while (y+y < x*x);
return (hz>0)? r+x : -r-x;
}
if (fn[iz]+UNI*(fn[iz-1]-fn[iz])<exp(-0.5*x*x)) {
return x;
}
hz = SHR3;
iz = hz&127;
if (abs(hz) < kn[iz]) {
return ((hz)*wn[iz]);
}
}
}
/*!\Procedure to create tables for normal distribution kn,wn and fn. */
void tableNor(unsigned long seed) {
jsr=seed;
double dn = 3.442619855899;
int i;
const double m1 = 2147483648.0;
double q;
double tn = 3.442619855899;
const double vn = 9.91256303526217E-03;
q = vn/exp(-0.5*dn*dn);
kn[0] = ((dn/q)*m1);
kn[1] = 0;
wn[0] = ( q / m1 );
wn[127] = ( dn / m1 );
fn[0] = 1.0;
fn[127] = ( exp ( - 0.5 * dn * dn ) );
for ( i = 126; 1 <= i; i-- ) {
dn = sqrt (-2.0 * log ( vn/dn + exp(-0.5*dn*dn)));
kn[i+1] = ((dn / tn)*m1);
tn = dn;
fn[i] = (exp (-0.5*dn*dn));
wn[i] = (dn / m1);
}
return;
}
double gaussZiggurat(double mean, double variance) {
hz=SHR3;
iz=hz&127;
return abs(hz)<kn[iz]? hz*wn[iz] : nfix();
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Author and copyright: Laurent Thomas, open-cells.com
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef __RFSIMULATOR_H
#define __RFSIMULATOR_H
double gaussZiggurat(double mean, double variance);
void tableNor(unsigned long seed);
void rxAddInput( struct complex16 *input_sig,
struct complex16 *after_channel_sig,
int rxAnt,
channel_desc_t *channelDesc,
int nbSamples,
uint64_t TS,
uint32_t CirSize
);
#endif
This diff is collapsed.
This diff is collapsed.
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