mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.9 KiB
C
66 lines
1.9 KiB
C
4 years ago
|
/**
|
||
8 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
8 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
8 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
8 years ago
|
*
|
||
|
*/
|
||
|
|
||
|
/******************************************************************************
|
||
|
* File: tti_synch.h
|
||
|
* Description: Interface used for PHY-MAC synchronization
|
||
|
* (producer-consumer model). The consumer waits while its
|
||
|
* counter is lower than the producer counter.
|
||
|
* The PHY is the consumer. The MAC is the producer.
|
||
|
* Reference:
|
||
|
*****************************************************************************/
|
||
|
|
||
4 years ago
|
#ifndef SRSRAN_TTI_SYNC_H
|
||
|
#define SRSRAN_TTI_SYNC_H
|
||
8 years ago
|
|
||
|
#include <stdint.h>
|
||
|
|
||
4 years ago
|
namespace srsran {
|
||
5 years ago
|
|
||
8 years ago
|
class tti_sync
|
||
|
{
|
||
5 years ago
|
public:
|
||
|
tti_sync(uint32_t modulus_)
|
||
|
{
|
||
|
modulus = modulus_;
|
||
|
increment = 1;
|
||
|
init_counters(0);
|
||
|
}
|
||
|
virtual void increase() = 0;
|
||
|
virtual void increase(uint32_t cnt) = 0;
|
||
|
virtual void resync() = 0;
|
||
|
virtual uint32_t wait() = 0;
|
||
|
virtual void set_producer_cntr(uint32_t) = 0;
|
||
|
uint32_t get_producer_cntr() { return producer_cntr; }
|
||
|
uint32_t get_consumer_cntr() { return consumer_cntr; }
|
||
|
void set_increment(uint32_t increment_) { increment = increment_; }
|
||
|
|
||
|
protected:
|
||
|
void increase_producer() { producer_cntr = (producer_cntr + increment) % modulus; }
|
||
|
void increase_producer(uint32_t cnt) { producer_cntr = cnt % modulus; }
|
||
|
void increase_consumer() { consumer_cntr = (consumer_cntr + increment) % modulus; }
|
||
|
bool wait_condition() { return producer_cntr == consumer_cntr; }
|
||
|
void init_counters(uint32_t val)
|
||
|
{
|
||
|
consumer_cntr = val;
|
||
|
producer_cntr = val;
|
||
|
}
|
||
|
uint32_t increment;
|
||
|
uint32_t modulus;
|
||
|
uint32_t producer_cntr;
|
||
|
uint32_t consumer_cntr;
|
||
5 years ago
|
};
|
||
8 years ago
|
|
||
4 years ago
|
} // namespace srsran
|
||
8 years ago
|
|
||
4 years ago
|
#endif // SRSRAN_TTI_SYNC_H
|