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.
208 lines
7.4 KiB
C
208 lines
7.4 KiB
C
4 years ago
|
/**
|
||
5 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
5 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
5 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.
|
||
5 years ago
|
*
|
||
|
*/
|
||
|
|
||
|
/******************************************************************************
|
||
|
* File: radio_interfaces.h
|
||
|
* Description: Common interface for eNB/UE for PHY and radio
|
||
|
*****************************************************************************/
|
||
|
|
||
4 years ago
|
#ifndef SRSRAN_RADIO_INTERFACES_H
|
||
|
#define SRSRAN_RADIO_INTERFACES_H
|
||
5 years ago
|
|
||
4 years ago
|
#include "srsran/phy/common/phy_common.h"
|
||
|
#include "srsran/phy/common/timestamp.h"
|
||
|
#include "srsran/phy/rf/rf.h"
|
||
|
#include "srsran/phy/utils/vector.h"
|
||
5 years ago
|
#include <array>
|
||
|
|
||
4 years ago
|
namespace srsran {
|
||
5 years ago
|
|
||
|
/**
|
||
|
* Class used to pass buffers for all channels and antennas to the radio
|
||
|
*
|
||
|
* The class provides an abstraction to map carriers and antennas to the underlying
|
||
|
* RF channels. It provides getters and setters to access the raw pointers where the signal
|
||
|
* is stored.
|
||
|
*
|
||
|
* It can automatically allocate and deallocate memory for the buffers if
|
||
|
* a non-zero number of subframes is passed to the constructor.
|
||
|
*
|
||
|
*/
|
||
|
class rf_buffer_interface
|
||
|
{
|
||
|
public:
|
||
5 years ago
|
virtual cf_t* get(const uint32_t& channel_idx) const = 0;
|
||
|
virtual void set(const uint32_t& channel_idx, cf_t* ptr) = 0;
|
||
|
virtual cf_t* get(const uint32_t& cc_idx, const uint32_t& port_idx, const uint32_t& nof_antennas) const = 0;
|
||
|
virtual void set(const uint32_t& cc_idx, const uint32_t& port_idx, const uint32_t& nof_antennas, cf_t* ptr) = 0;
|
||
|
virtual void** to_void() = 0;
|
||
|
virtual cf_t** to_cf_t() = 0;
|
||
|
virtual uint32_t size() = 0;
|
||
5 years ago
|
virtual void set_nof_samples(uint32_t n) = 0;
|
||
|
virtual uint32_t get_nof_samples() const = 0;
|
||
5 years ago
|
};
|
||
|
|
||
5 years ago
|
/**
|
||
|
* Class used to pass RF devices timestamps to the radio instance
|
||
|
*
|
||
|
* The class provides an abstraction to store a number of timestamps underlying RF devices.
|
||
|
*/
|
||
|
class rf_timestamp_interface
|
||
|
{
|
||
|
public:
|
||
4 years ago
|
virtual const srsran_timestamp_t& get(uint32_t idx) const = 0;
|
||
|
virtual srsran_timestamp_t* get_ptr(uint32_t idx) = 0;
|
||
5 years ago
|
virtual void add(double secs) = 0;
|
||
|
virtual void sub(double secs) = 0;
|
||
|
|
||
|
void copy(const rf_timestamp_interface& other)
|
||
|
{
|
||
|
// Nothing to copy
|
||
|
if (this == &other) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// Copy timestamps
|
||
4 years ago
|
for (uint32_t i = 0; i < SRSRAN_MAX_CHANNELS; i++) {
|
||
5 years ago
|
*this->get_ptr(i) = other.get(i);
|
||
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
srsran_timestamp_t& operator[](uint32_t idx) { return *this->get_ptr(idx); }
|
||
5 years ago
|
};
|
||
|
|
||
5 years ago
|
/**
|
||
|
* Radio interface for the PHY.
|
||
|
*
|
||
|
* The main functionality is to allow TX and RX of samples to the radio.
|
||
|
* It also provides functions to change the radio settings such as carrier frequency,
|
||
|
* sampling rate, gains, etc.
|
||
|
*
|
||
|
* The radio interface supports multiple carriers and multiple antennas per carrier. This interface presents an
|
||
|
* abstract access to carries and ports to the PHY, regardless of the mapping to RF channels in the underlying radio.
|
||
4 years ago
|
* number of carriers <= SRSRAN_MAX_CARRIERS
|
||
|
* number of ports <= SRSRAN_MAX_PORTS
|
||
5 years ago
|
*
|
||
|
* Changing the tx/rx frequency is done on a carrier level and the underlying implementation
|
||
|
* will set it for all ports when necessary.
|
||
|
*
|
||
|
* Samples are passed and received to/from the radio using rf_buffer_t object
|
||
|
* @see rf_buffer_t
|
||
|
* @see radio
|
||
|
*/
|
||
|
class radio_interface_phy
|
||
|
{
|
||
|
public:
|
||
|
/**
|
||
|
* Indicates the end of a burst in the current TX stream. Usually called after a call to tx() if
|
||
|
* no more samples are needed to be transmitted.
|
||
|
*/
|
||
|
virtual void tx_end() = 0;
|
||
|
/**
|
||
|
* Indicates the radio to transmit on all antennas and carriers synchronously the samples contained in
|
||
|
* the buffer object.
|
||
|
*
|
||
|
* @param buffer Is the object that contains the pointers to all RF channels
|
||
|
* @param tx_time Time to transmit all signals
|
||
5 years ago
|
* @return it returns true if the transmission was successful, otherwise it returns false
|
||
5 years ago
|
*/
|
||
5 years ago
|
virtual bool tx(rf_buffer_interface& buffer, const rf_timestamp_interface& tx_time) = 0;
|
||
5 years ago
|
|
||
|
/**
|
||
|
* Indicates the radio to receive from all antennas and carriers synchronously and store the samples
|
||
|
* in the buffer object
|
||
|
*
|
||
|
* @param buffer Is the object where the samples will be stored
|
||
|
* @param tx_time Time at which the samples were received. Note the time is the same for all carriers
|
||
|
* @return
|
||
|
*/
|
||
5 years ago
|
virtual bool rx_now(rf_buffer_interface& buffer, rf_timestamp_interface& rxd_time) = 0;
|
||
5 years ago
|
|
||
|
/**
|
||
|
* Sets the TX frequency for all antennas in the provided carrier index
|
||
|
* @param carrier_idx Index of the carrier to change the frequency
|
||
|
* @param freq Frequency to set to in Hz
|
||
|
*/
|
||
|
virtual void set_tx_freq(const uint32_t& carrier_idx, const double& freq) = 0;
|
||
|
|
||
|
/**
|
||
|
* Sets the RX frequency for all antennas in the provided carrier index
|
||
|
* @param carrier_idx Index of the carrier to change the frequency
|
||
|
* @param freq Frequency to set to in Hz
|
||
|
*/
|
||
|
virtual void set_rx_freq(const uint32_t& carrier_idx, const double& freq) = 0;
|
||
|
|
||
5 years ago
|
/**
|
||
|
* Releases any mapping between frequency and carrier done when calling set_tx_freq() or set_rx_freq()
|
||
|
* @param carrier_idx Index of the carrier to release the mapping
|
||
|
*/
|
||
|
virtual void release_freq(const uint32_t& carrier_idx) = 0;
|
||
|
|
||
5 years ago
|
/**
|
||
|
* Sets the transmit gain for all carriers and antennas
|
||
|
* @param gain Gain in dB
|
||
|
*/
|
||
|
virtual void set_tx_gain(const float& gain) = 0;
|
||
|
|
||
|
/**
|
||
|
* Sets the receive gain for all carriers and antennas in a background
|
||
|
* @param gain Gain in dB
|
||
|
*/
|
||
|
virtual void set_rx_gain_th(const float& gain) = 0;
|
||
|
|
||
|
/**
|
||
|
* Sets the receive gain for all carriers and antennas
|
||
|
* @param gain Gain in dB
|
||
|
*/
|
||
|
virtual void set_rx_gain(const float& gain) = 0;
|
||
|
|
||
|
/**
|
||
|
* Sets the sampling rate of the D/A converter simultaneously for all carriers and antennas
|
||
|
* @param srate Sampling rate in Hz
|
||
|
*/
|
||
|
virtual void set_tx_srate(const double& srate) = 0;
|
||
|
|
||
|
/**
|
||
|
* Sets the sampling rate of the A/D converter simultaneously for all carriers and antennas
|
||
|
* @param srate Sampling rate in Hz
|
||
|
*/
|
||
|
virtual void set_rx_srate(const double& srate) = 0;
|
||
|
|
||
5 years ago
|
/**
|
||
|
* Sets relative offset between receiver channels. It does not guarantee that the offset is corrected by the radio
|
||
|
* implementation.
|
||
|
* @param ch logical channel index
|
||
|
* @param offset_samples Offset in samples, it can be negative
|
||
|
*/
|
||
|
virtual void set_channel_rx_offset(uint32_t ch, int32_t offset_samples) = 0;
|
||
|
|
||
5 years ago
|
// getter
|
||
|
virtual double get_freq_offset() = 0;
|
||
|
virtual float get_rx_gain() = 0;
|
||
|
virtual bool is_continuous_tx() = 0;
|
||
|
virtual bool get_is_start_of_burst() = 0;
|
||
|
virtual bool is_init() = 0;
|
||
|
virtual void reset() = 0;
|
||
4 years ago
|
virtual srsran_rf_info_t* get_info() = 0;
|
||
5 years ago
|
};
|
||
|
|
||
|
class phy_interface_radio
|
||
|
{
|
||
|
public:
|
||
|
virtual void radio_overflow() = 0;
|
||
|
virtual void radio_failure() = 0;
|
||
|
};
|
||
|
|
||
4 years ago
|
} // namespace srsran
|
||
5 years ago
|
|
||
4 years ago
|
#endif // SRSRAN_RADIO_INTERFACES_H
|