forked from gnuradio/gnuradio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrfnoc_block.cc
62 lines (53 loc) · 2.04 KB
/
rfnoc_block.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* -*- c++ -*- */
/*
* Copyright 2020 Free Software Foundation, Inc.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gnuradio/uhd/rfnoc_block.h>
namespace gr {
namespace uhd {
/******************************************************************************
* Factory and Structors
*****************************************************************************/
::uhd::rfnoc::noc_block_base::sptr
rfnoc_block::make_block_ref(rfnoc_graph::sptr graph,
const ::uhd::device_addr_t& block_args,
const std::string& block_name,
const int device_select,
const int block_select,
const size_t max_ref_count)
{
const std::string block_id =
graph->get_block_id(block_name, device_select, block_select);
if (block_id.empty()) {
throw std::runtime_error("Cannot find block!");
}
return graph->get_block_ref(block_id, max_ref_count);
}
rfnoc_block::rfnoc_block(::uhd::rfnoc::noc_block_base::sptr block_ref)
: gr::block(
std::string("RFNoC::") + block_ref->get_unique_id(),
gr::io_signature::make(0, 0, 0), // All RFNoC blocks don't stream into GNU Radio
gr::io_signature::make(0, 0, 0)),
d_block_ref(block_ref)
{
}
/******************************************************************************
* GNU Radio API
*****************************************************************************/
std::string rfnoc_block::get_unique_id() const { return d_block_ref->get_unique_id(); }
int rfnoc_block::general_work(int /*noutput_items*/,
gr_vector_int& /*ninput_items*/,
gr_vector_const_void_star& /*input_items*/,
gr_vector_void_star& /*output_items*/)
{
// We should never land here
throw std::runtime_error("Unexpected call to general_work() in an RFNoC block!");
return 0;
}
} /* namespace uhd */
} /* namespace gr */