UHD: Improved RFNOC

master
Xavier Arteaga 4 years ago committed by Xavier Arteaga
parent 38d9545e99
commit dcf05f7a53

@ -69,7 +69,7 @@ private:
const uhd::fs_path TREE_RX_SENSORS = "/mboards/0/dboards/A/rx_frontends/0/sensors"; const uhd::fs_path TREE_RX_SENSORS = "/mboards/0/dboards/A/rx_frontends/0/sensors";
const std::string TX_ANTENNA_PORT = "TX/RX"; const std::string TX_ANTENNA_PORT = "TX/RX";
const std::string RX_ANTENNA_PORT = "RX2"; const std::string RX_ANTENNA_PORT = "RX2";
const size_t spp = 246; const size_t spp = 1920 / 8;
// Primary parameters // Primary parameters
double master_clock_rate = 184.32e6; double master_clock_rate = 184.32e6;
@ -78,7 +78,6 @@ private:
size_t nof_channels = 1; ///< Number of Channels per Radio size_t nof_channels = 1; ///< Number of Channels per Radio
std::vector<double> rx_freq_hz; std::vector<double> rx_freq_hz;
std::vector<double> tx_freq_hz; std::vector<double> tx_freq_hz;
size_t nof_samples_per_packet = spp * 4 + 2 * sizeof(uint64_t);
size_t dma_fifo_depth = 8192UL * 4096UL; size_t dma_fifo_depth = 8192UL * 4096UL;
// Radio control // Radio control
@ -181,8 +180,11 @@ private:
radio_ctrl[i]->set_tx_antenna(TX_ANTENNA_PORT, 0); radio_ctrl[i]->set_tx_antenna(TX_ANTENNA_PORT, 0);
radio_ctrl[i]->enable_rx_timestamps(true, 0); radio_ctrl[i]->enable_rx_timestamps(true, 0);
if (spp) {
radio_ctrl[i]->set_arg("spp", spp); radio_ctrl[i]->set_arg("spp", spp);
} }
}
// Sleep for some time // Sleep for some time
std::this_thread::sleep_for(SETUP_TIME_MS); std::this_thread::sleep_for(SETUP_TIME_MS);
@ -274,6 +276,12 @@ private:
uhd_error connect() uhd_error connect()
{ {
size_t nof_samples_per_packet = 0;
if (spp != 0) {
nof_samples_per_packet = spp * 4 + 2 * sizeof(uint64_t);
}
UHD_SAFE_C_SAVE_ERROR(this, UHD_SAFE_C_SAVE_ERROR(this,
// Get Tx and Rx Graph // Get Tx and Rx Graph
@ -437,7 +445,8 @@ public:
this, uhd::stream_args_t stream_args("fc32", "sc16"); this, uhd::stream_args_t stream_args("fc32", "sc16");
stream_args.channels.resize(nof_radios * nof_channels); stream_args.channels.resize(nof_radios * nof_channels);
stream_args.args["spp"] = std::to_string(spp);
if (spp != 0) { stream_args.args["spp"] = std::to_string(spp); }
// Populate stream arguments with RF-NOC blocks interfaces // Populate stream arguments with RF-NOC blocks interfaces
size_t channel_count = 0; size_t channel_count = 0;
@ -461,7 +470,7 @@ public:
this, uhd::stream_args_t stream_args("fc32", "sc16"); this, uhd::stream_args_t stream_args("fc32", "sc16");
stream_args.channels.resize(nof_radios * nof_channels); stream_args.channels.resize(nof_radios * nof_channels);
stream_args.args["spp"] = std::to_string(spp); if (spp != 0) { stream_args.args["spp"] = std::to_string(spp); }
// Populate stream arguments with RF-NOC blocks interfaces // Populate stream arguments with RF-NOC blocks interfaces
size_t channel_count = 0; size_t channel_count = 0;
@ -546,10 +555,9 @@ public:
tx_freq_hz[ch] = target_freq; tx_freq_hz[ch] = target_freq;
actual_freq = tx_freq_hz[ch]; actual_freq = tx_freq_hz[ch];
UHD_SAFE_C_SAVE_ERROR(this, Debug("Tuning Tx " << ch << " to " << actual_freq / 1e6 << " MHz...");
size_t i = ch / nof_channels;
// For each radio...
for (size_t i = 0; i < nof_radios; i++) {
// Calculate center frequency from average // Calculate center frequency from average
double center_freq_hz = 0.0; double center_freq_hz = 0.0;
for (size_t j = 0; j < nof_channels; j++) { for (size_t j = 0; j < nof_channels; j++) {
@ -560,6 +568,9 @@ public:
} }
center_freq_hz /= nof_channels; center_freq_hz /= nof_channels;
UHD_SAFE_C_SAVE_ERROR(
this,
// Set Radio Tx freq // Set Radio Tx freq
UHD_LOG_DEBUG(radio_id[i], "Setting TX Freq: " << center_freq_hz / 1e6 << " MHz..."); UHD_LOG_DEBUG(radio_id[i], "Setting TX Freq: " << center_freq_hz / 1e6 << " MHz...");
radio_ctrl[i]->set_tx_frequency(center_freq_hz, 0); radio_ctrl[i]->set_tx_frequency(center_freq_hz, 0);
@ -571,7 +582,6 @@ public:
double freq_hz = tx_freq_hz[nof_channels * i + j] - center_freq_hz; double freq_hz = tx_freq_hz[nof_channels * i + j] - center_freq_hz;
UHD_LOG_DEBUG(duc_id[i], "Setting " << j << " freq: " << freq_hz / 1e6 << " MHz ..."); UHD_LOG_DEBUG(duc_id[i], "Setting " << j << " freq: " << freq_hz / 1e6 << " MHz ...");
duc_ctrl[i]->set_arg("freq", std::to_string(freq_hz), j); duc_ctrl[i]->set_arg("freq", std::to_string(freq_hz), j);
}
}) })
} }
uhd_error set_rx_freq(uint32_t ch, double target_freq, double& actual_freq) override uhd_error set_rx_freq(uint32_t ch, double target_freq, double& actual_freq) override
@ -596,7 +606,9 @@ public:
rx_freq_hz[ch] = target_freq; rx_freq_hz[ch] = target_freq;
actual_freq = rx_freq_hz[ch]; actual_freq = rx_freq_hz[ch];
UHD_SAFE_C_SAVE_ERROR(this, for (size_t i = 0; i < nof_radios; i++) { Debug("Tuning Rx " << ch << " to " << actual_freq / 1e6 << " MHz...");
size_t i = ch / nof_channels;
// Calculate center frequency from average // Calculate center frequency from average
double center_freq_hz = 0.0; double center_freq_hz = 0.0;
for (size_t j = 0; j < nof_channels; j++) { for (size_t j = 0; j < nof_channels; j++) {
@ -607,6 +619,9 @@ public:
} }
center_freq_hz /= nof_channels; center_freq_hz /= nof_channels;
UHD_SAFE_C_SAVE_ERROR(
this,
// Set Radio Tx freq // Set Radio Tx freq
UHD_LOG_DEBUG(radio_id[i], "Setting RX Freq: " << center_freq_hz / 1e6 << " MHz..."); UHD_LOG_DEBUG(radio_id[i], "Setting RX Freq: " << center_freq_hz / 1e6 << " MHz...");
radio_ctrl[i]->set_rx_frequency(center_freq_hz, 0); radio_ctrl[i]->set_rx_frequency(center_freq_hz, 0);
@ -618,7 +633,6 @@ public:
double freq_hz = center_freq_hz - rx_freq_hz[nof_channels * i + j]; double freq_hz = center_freq_hz - rx_freq_hz[nof_channels * i + j];
UHD_LOG_DEBUG(ddc_id[i], "Setting " << j << " freq: " << freq_hz / 1e6 << " MHz ..."); UHD_LOG_DEBUG(ddc_id[i], "Setting " << j << " freq: " << freq_hz / 1e6 << " MHz ...");
ddc_ctrl[i]->set_arg("freq", freq_hz, j); ddc_ctrl[i]->set_arg("freq", freq_hz, j);
}
}) })
} }
}; };

@ -119,7 +119,7 @@ public:
virtual uhd_error get_rx_sensor(const std::string& sensor_name, uhd::sensor_value_t& sensor_value) = 0; virtual uhd_error get_rx_sensor(const std::string& sensor_name, uhd::sensor_value_t& sensor_value) = 0;
virtual uhd_error set_time_unknown_pps(const uhd::time_spec_t& timespec) = 0; virtual uhd_error set_time_unknown_pps(const uhd::time_spec_t& timespec) = 0;
virtual uhd_error get_time_now(uhd::time_spec_t& timespec) = 0; virtual uhd_error get_time_now(uhd::time_spec_t& timespec) = 0;
virtual uhd_error start_rx_stream(double delay) uhd_error start_rx_stream(double delay)
{ {
uhd::time_spec_t time_spec; uhd::time_spec_t time_spec;
uhd_error err = get_time_now(time_spec); uhd_error err = get_time_now(time_spec);
@ -134,7 +134,7 @@ public:
rx_stream->issue_stream_cmd(stream_cmd);) rx_stream->issue_stream_cmd(stream_cmd);)
} }
virtual uhd_error stop_rx_stream() uhd_error stop_rx_stream()
{ {
UHD_SAFE_C_SAVE_ERROR(this, uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); UHD_SAFE_C_SAVE_ERROR(this, uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
rx_stream->issue_stream_cmd(stream_cmd);) rx_stream->issue_stream_cmd(stream_cmd);)
@ -155,7 +155,7 @@ public:
virtual uhd_error get_tx_gain(double& gain) = 0; virtual uhd_error get_tx_gain(double& gain) = 0;
virtual uhd_error set_tx_freq(uint32_t ch, double target_freq, double& actual_freq) = 0; virtual uhd_error set_tx_freq(uint32_t ch, double target_freq, double& actual_freq) = 0;
virtual uhd_error set_rx_freq(uint32_t ch, double target_freq, double& actual_freq) = 0; virtual uhd_error set_rx_freq(uint32_t ch, double target_freq, double& actual_freq) = 0;
virtual uhd_error receive(void** buffs, uhd_error receive(void** buffs,
const size_t nsamps_per_buff, const size_t nsamps_per_buff,
uhd::rx_metadata_t& metadata, uhd::rx_metadata_t& metadata,
const double timeout, const double timeout,
@ -169,7 +169,7 @@ public:
{ {
UHD_SAFE_C_SAVE_ERROR(this, valid = tx_stream->recv_async_msg(async_metadata, timeout);) UHD_SAFE_C_SAVE_ERROR(this, valid = tx_stream->recv_async_msg(async_metadata, timeout);)
} }
virtual uhd_error send(void** buffs, uhd_error send(void** buffs,
const size_t nsamps_per_buff, const size_t nsamps_per_buff,
const uhd::tx_metadata_t& metadata, const uhd::tx_metadata_t& metadata,
const double timeout, const double timeout,

Loading…
Cancel
Save