Commit 5f7c30fb authored by Rakesh's avatar Rakesh Committed by Raymond Knopp

fix for get_slot_from_timestamp

parent 2cac29b5
...@@ -623,6 +623,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) { ...@@ -623,6 +623,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
unsigned int rxs; unsigned int rxs;
int i; int i;
uint32_t samples_per_slot = fp->get_samples_per_slot(*slot,fp); uint32_t samples_per_slot = fp->get_samples_per_slot(*slot,fp);
uint32_t samples_per_slot_prev ;
openair0_timestamp ts,old_ts; openair0_timestamp ts,old_ts;
AssertFatal(*slot<fp->slots_per_frame && *slot>=0, "slot %d is illegal (%d)\n",*slot,fp->slots_per_frame); AssertFatal(*slot<fp->slots_per_frame && *slot>=0, "slot %d is illegal (%d)\n",*slot,fp->slots_per_frame);
...@@ -658,16 +659,16 @@ void rx_rf(RU_t *ru,int *frame,int *slot) { ...@@ -658,16 +659,16 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
ru->ts_offset = proc->timestamp_rx; ru->ts_offset = proc->timestamp_rx;
proc->timestamp_rx = 0; proc->timestamp_rx = 0;
} else { } else {
if (proc->timestamp_rx - old_ts != fp->get_samples_per_slot((*slot-1)%fp->slots_per_frame,fp)) { samples_per_slot_prev = fp->get_samples_per_slot((*slot-1)%fp->slots_per_frame,fp);
LOG_D(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - samples_per_slot,ru->ts_offset); if (proc->timestamp_rx - old_ts != samples_per_slot_prev) {
ru->ts_offset += (proc->timestamp_rx - old_ts - samples_per_slot); LOG_D(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - samples_per_slot_prev,ru->ts_offset);
ru->ts_offset += (proc->timestamp_rx - old_ts - samples_per_slot_prev);
proc->timestamp_rx = ts-ru->ts_offset; proc->timestamp_rx = ts-ru->ts_offset;
} }
} }
proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023; proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023;
uint32_t idx_sf = proc->timestamp_rx / fp->samples_per_subframe; proc->tti_rx = fp->get_slot_from_timestamp(proc->timestamp_rx,fp);
proc->tti_rx = (idx_sf * fp->slots_per_subframe + (int)round((float)(proc->timestamp_rx % fp->samples_per_subframe) / fp->samples_per_slot0))%(fp->slots_per_frame);
// synchronize first reception to frame 0 subframe 0 // synchronize first reception to frame 0 subframe 0
LOG_D(PHY,"RU %d/%d TS %llu (off %d), frame %d, slot %d.%d / %d\n", LOG_D(PHY,"RU %d/%d TS %llu (off %d), frame %d, slot %d.%d / %d\n",
ru->idx, ru->idx,
...@@ -688,7 +689,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) { ...@@ -688,7 +689,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
} }
if (proc->frame_rx != *frame) { if (proc->frame_rx != *frame) {
LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",(long long unsigned int)proc->timestamp_rx,proc->frame_rx,*frame); LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d, proc->tti_rx %d, slot %d)\n",(long long unsigned int)proc->timestamp_rx,proc->frame_rx,*frame,proc->tti_rx,*slot);
exit_fun("Exiting"); exit_fun("Exiting");
} }
} else { } else {
......
...@@ -233,6 +233,20 @@ uint32_t get_samples_per_slot(int slot, NR_DL_FRAME_PARMS* fp) ...@@ -233,6 +233,20 @@ uint32_t get_samples_per_slot(int slot, NR_DL_FRAME_PARMS* fp)
return samp_count; return samp_count;
} }
uint32_t get_slot_from_timestamp(openair0_timestamp timestamp_rx, NR_DL_FRAME_PARMS* fp)
{
uint32_t slot_idx = 0;
int samples_till_the_slot = 0;
timestamp_rx = timestamp_rx%fp->samples_per_frame;
while (timestamp_rx > samples_till_the_slot) {
samples_till_the_slot += fp->get_samples_per_slot(slot_idx,fp);
slot_idx++;
}
return slot_idx;
}
uint32_t get_samples_slot_timestamp(int slot, NR_DL_FRAME_PARMS* fp, uint8_t sl_ahead) uint32_t get_samples_slot_timestamp(int slot, NR_DL_FRAME_PARMS* fp, uint8_t sl_ahead)
{ {
uint32_t samp_count = 0; uint32_t samp_count = 0;
...@@ -289,6 +303,7 @@ int nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg, ...@@ -289,6 +303,7 @@ int nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg,
(fp->nb_prefix_samples + fp->ofdm_symbol_size) * (fp->symbols_per_slot * fp->slots_per_subframe - 2); (fp->nb_prefix_samples + fp->ofdm_symbol_size) * (fp->symbols_per_slot * fp->slots_per_subframe - 2);
fp->get_samples_per_slot = &get_samples_per_slot; fp->get_samples_per_slot = &get_samples_per_slot;
fp->get_samples_slot_timestamp = &get_samples_slot_timestamp; fp->get_samples_slot_timestamp = &get_samples_slot_timestamp;
fp->get_slot_from_timestamp = &get_slot_from_timestamp;
fp->samples_per_frame = 10 * fp->samples_per_subframe; fp->samples_per_frame = 10 * fp->samples_per_subframe;
fp->freq_range = (fp->dl_CarrierFreq < 6e9)? nr_FR1 : nr_FR2; fp->freq_range = (fp->dl_CarrierFreq < 6e9)? nr_FR1 : nr_FR2;
......
...@@ -414,7 +414,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, ...@@ -414,7 +414,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
uci_pdu->harq->harq_confidence_level = (no_conf) ? 1 : 0; uci_pdu->harq->harq_confidence_level = (no_conf) ? 1 : 0;
uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(1); uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(1);
uci_pdu->harq->harq_list[0].harq_value = index&0x01; uci_pdu->harq->harq_list[0].harq_value = index&0x01;
LOG_I(PHY, "HARQ value %d with confidence level (0 is good, 1 is bad) %d\n", LOG_D(PHY, "HARQ value %d with confidence level (0 is good, 1 is bad) %d\n",
uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level); uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level);
if (pucch_pdu->sr_flag == 1) { if (pucch_pdu->sr_flag == 1) {
uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr));
...@@ -429,7 +429,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, ...@@ -429,7 +429,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(2); uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(2);
uci_pdu->harq->harq_list[1].harq_value = index&0x01; uci_pdu->harq->harq_list[1].harq_value = index&0x01;
uci_pdu->harq->harq_list[0].harq_value = (index>>1)&0x01; uci_pdu->harq->harq_list[0].harq_value = (index>>1)&0x01;
LOG_I(PHY, "HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d\n", LOG_D(PHY, "HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d\n",
uci_pdu->harq->harq_list[1].harq_value,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level); uci_pdu->harq->harq_list[1].harq_value,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level);
if (pucch_pdu->sr_flag == 1) { if (pucch_pdu->sr_flag == 1) {
uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr));
......
...@@ -233,6 +233,7 @@ typedef struct { ...@@ -233,6 +233,7 @@ typedef struct {
typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS;
typedef uint32_t (*get_samples_per_slot_t)(int slot, NR_DL_FRAME_PARMS* fp); typedef uint32_t (*get_samples_per_slot_t)(int slot, NR_DL_FRAME_PARMS* fp);
typedef uint32_t (*get_slot_from_timestamp_t)(openair0_timestamp timestamp_rx, NR_DL_FRAME_PARMS* fp);
typedef uint32_t (*get_samples_slot_timestamp_t)(int slot, NR_DL_FRAME_PARMS* fp, uint8_t sl_ahead); typedef uint32_t (*get_samples_slot_timestamp_t)(int slot, NR_DL_FRAME_PARMS* fp, uint8_t sl_ahead);
...@@ -289,6 +290,8 @@ struct NR_DL_FRAME_PARMS { ...@@ -289,6 +290,8 @@ struct NR_DL_FRAME_PARMS {
uint32_t samples_per_subframe; uint32_t samples_per_subframe;
/// Number of samples in current slot /// Number of samples in current slot
get_samples_per_slot_t get_samples_per_slot; get_samples_per_slot_t get_samples_per_slot;
/// slot calculation from timestamp
get_slot_from_timestamp_t get_slot_from_timestamp;
/// Number of samples before slot /// Number of samples before slot
get_samples_slot_timestamp_t get_samples_slot_timestamp; get_samples_slot_timestamp_t get_samples_slot_timestamp;
/// Number of samples in 0th and center slot of a subframe /// Number of samples in 0th and center slot of a subframe
......
...@@ -693,10 +693,10 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp ...@@ -693,10 +693,10 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
*ptimestamp = s->rx_timestamp; *ptimestamp = s->rx_timestamp;
// push GPIO bits 7-9 from flags_msb // push GPIO bits 7-9 from flags_msb
s->usrp->set_command_time(uhd::time_spec_t::from_ticks((s->rx_timestamp+(2*nsamps)),s->sample_rate)); /*s->usrp->set_command_time(uhd::time_spec_t::from_ticks((s->rx_timestamp+(2*nsamps)),s->sample_rate));
s->usrp->set_gpio_attr("FP0", "OUT", gpio789<<7, 0x380); s->usrp->set_gpio_attr("FP0", "OUT", gpio789<<7, 0x380);
s->usrp->clear_command_time(); s->usrp->clear_command_time();
gpio789 = (gpio789+1)&7; gpio789 = (gpio789+1)&7;*/
if (device->recplay_state != NULL) { // record mode if (device->recplay_state != NULL) { // record mode
// Copy subframes to memory (later dump on a file) // Copy subframes to memory (later dump on a file)
......
...@@ -239,6 +239,8 @@ RUs = ( ...@@ -239,6 +239,8 @@ RUs = (
eNB_instances = [0]; eNB_instances = [0];
sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2"; sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2";
if_freq = 5300000000L; if_freq = 5300000000L;
#time_source = "external";
clock_source = "external";
} }
); );
......
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