more cleanup, start scope vizualisation rework
This commit is contained in:
@@ -34,6 +34,9 @@
|
||||
#include <common/utils/LOG/log.h>
|
||||
#include <common/config/config_userapi.h>
|
||||
#include <openair1/SIMULATION/TOOLS/sim.h>
|
||||
#include <common/utils/telnetsrv/telnetsrv.h>
|
||||
#include <common/utils/load_module_shlib.h>
|
||||
#include <targets/ARCH/rfsimulator/rfsimulator.h>
|
||||
|
||||
/*
|
||||
Legacy study:
|
||||
@@ -99,8 +102,8 @@ void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_si
|
||||
} //l
|
||||
}
|
||||
|
||||
out_ptr->r += round(rx_tmp.x*pathLossLinear + noise_per_sample*gaussdouble(0.0,1.0));
|
||||
out_ptr->i += round(rx_tmp.y*pathLossLinear + noise_per_sample*gaussdouble(0.0,1.0));
|
||||
out_ptr->r += round(rx_tmp.x*pathLossLinear + noise_per_sample*gaussZiggurat(0.0,1.0));
|
||||
out_ptr->i += round(rx_tmp.y*pathLossLinear + noise_per_sample*gaussZiggurat(0.0,1.0));
|
||||
out_ptr++;
|
||||
}
|
||||
|
||||
@@ -112,3 +115,4 @@ void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_si
|
||||
channelDesc->path_loss_dB,
|
||||
10*log10(noise_per_sample));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -50,6 +50,7 @@
|
||||
#include "openair1/PHY/defs_UE.h"
|
||||
#define CHANNELMOD_DYNAMICLOAD
|
||||
#include <openair1/SIMULATION/TOOLS/sim.h>
|
||||
#include <targets/ARCH/rfsimulator/rfsimulator.h>
|
||||
|
||||
#define PORT 4043 //default TCP port for this simulator
|
||||
#define CirSize 307200 // 100ms is enough
|
||||
@@ -146,6 +147,12 @@ void allocCirBuf(rfsimulator_state_t *bridge, int sock) {
|
||||
// the value channel_model->path_loss_dB seems only a storage place (new_channel_desc_scm() only copy the passed value)
|
||||
// Legacy changes directlty the variable channel_model->path_loss_dB place to place
|
||||
// while calling new_channel_desc_scm() with path losses = 0
|
||||
static bool init_done=false;
|
||||
if (!init_done) {
|
||||
randominit(0);
|
||||
tableNor(0);
|
||||
init_done=true;
|
||||
}
|
||||
ptr->channel_model=new_channel_desc_scm(bridge->tx_num_channels,bridge->rx_num_channels,
|
||||
bridge->channelmod,
|
||||
bridge->sample_rate,
|
||||
@@ -368,7 +375,6 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp
|
||||
if (t->lastWroteTS > timestamp+nsamps)
|
||||
LOG_E(HW,"Not supported to send Tx out of order (same in USRP) %lu, %lu\n",
|
||||
t->lastWroteTS, timestamp);
|
||||
|
||||
t->lastWroteTS=timestamp+nsamps;
|
||||
|
||||
if (!alreadyLocked)
|
||||
@@ -470,18 +476,20 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
|
||||
b->trashingPacket=true;
|
||||
} else if ( b->lastReceivedTS < b->th.timestamp) {
|
||||
int nbAnt= b->th.nbAnt;
|
||||
|
||||
for (uint64_t index=b->lastReceivedTS; index < b->th.timestamp; index++ ) {
|
||||
for (int a=0; a < nbAnt; a++) {
|
||||
b->circularBuf[(index*nbAnt+a)%CirSize].r = 0;
|
||||
b->circularBuf[(index*nbAnt+a)%CirSize].i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( b->th.timestamp-b->lastReceivedTS < CirSize ) {
|
||||
for (uint64_t index=b->lastReceivedTS; index < b->th.timestamp; index++ ) {
|
||||
for (int a=0; a < nbAnt; a++) {
|
||||
b->circularBuf[(index*nbAnt+a)%CirSize].r = 0;
|
||||
b->circularBuf[(index*nbAnt+a)%CirSize].i = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
memset(b->circularBuf, 0, sampleToByte(CirSize,1));
|
||||
}
|
||||
if (b->lastReceivedTS != 0 && b->th.timestamp-b->lastReceivedTS > 50 )
|
||||
LOG_W(HW,"UEsock: %d gap of: %ld in reception\n", fd, b->th.timestamp-b->lastReceivedTS );
|
||||
|
||||
b->lastReceivedTS=b->th.timestamp;
|
||||
|
||||
} else if ( b->lastReceivedTS > b->th.timestamp && b->th.size == 1 ) {
|
||||
LOG_W(HW,"Received Rx/Tx synchro out of order\n");
|
||||
b->trashingPacket=true;
|
||||
@@ -640,10 +648,11 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
|
||||
);
|
||||
else { // no channel modeling
|
||||
sample_t *out=(sample_t *)samplesVoid[a];
|
||||
|
||||
const int64_t base=t->nextTimestamp*nbAnt+a;
|
||||
for ( int i=0; i < nsamps; i++ ) {
|
||||
out[i].r+=ptr->circularBuf[((t->nextTimestamp+i)*nbAnt+a)%CirSize].r;
|
||||
out[i].i+=ptr->circularBuf[((t->nextTimestamp+i)*nbAnt+a)%CirSize].i;
|
||||
const int idx=(i*nbAnt+base)%CirSize;
|
||||
out[i].r+=ptr->circularBuf[idx].r;
|
||||
out[i].i+=ptr->circularBuf[idx].i;
|
||||
}
|
||||
} // end of no channel modeling
|
||||
} // end for a...
|
||||
|
||||
Reference in New Issue
Block a user