USRP Hardware Driver and USRP Manual  Version: 4.6.0.0
UHD and USRP Manual
blockdef.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2014-2015 Ettus Research LLC
3 // Copyright 2018 Ettus Research, a National Instruments Company
4 //
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 
8 #pragma once
9 
10 #include <uhd/config.hpp>
12 #include <stdint.h>
13 #include <memory>
14 #include <set>
15 #include <vector>
16 
17 namespace uhd { namespace rfnoc {
18 
21 class UHD_API blockdef : public std::enable_shared_from_this<blockdef>
22 {
23 public:
24  typedef std::shared_ptr<blockdef> sptr;
25 
27  //
28  // This is not the same as a uhd::rfnoc::stream_sig_t. This is used
29  // to describe which ports are defined in a block definition, and
30  // to describe what kind of connection is allowed for this port.
31  //
32  // All the keys listed in PORT_ARGS will be available in this class.
33  class port_t : public uhd::dict<std::string, std::string>
34  {
35  public:
37  static const device_addr_t PORT_ARGS;
38 
39  port_t();
40 
42  bool is_variable(const std::string& key) const;
44  bool is_keyword(const std::string& key) const;
46  // keywords are not resolved.
47  bool is_valid() const;
49  std::string to_string() const;
50  };
51  typedef std::vector<port_t> ports_t;
52 
54  class arg_t : public uhd::dict<std::string, std::string>
55  {
56  public:
58  static const device_addr_t ARG_ARGS;
59  static const std::set<std::string> VALID_TYPES;
60 
61  arg_t();
62 
64  bool is_valid() const;
66  std::string to_string() const;
67  };
68  typedef std::vector<arg_t> args_t;
69 
71 
78  static sptr make_from_noc_id(uint64_t noc_id);
79 
81  virtual bool is_block() const = 0;
82 
84  virtual bool is_component() const = 0;
85 
87  virtual std::string get_key() const = 0;
88 
90  virtual std::string get_name() const = 0;
91 
93  virtual uint64_t noc_id() const = 0;
94 
95  virtual ports_t get_input_ports() = 0;
96  virtual ports_t get_output_ports() = 0;
97 
99  virtual std::vector<size_t> get_all_port_numbers() = 0;
100 
102  //
103  // \throws uhd::runtime_error if args are invalid.
104  virtual args_t get_args() = 0;
105 
107  virtual registers_t get_settings_registers() = 0;
108 
110  virtual registers_t get_readback_registers() = 0;
111 };
112 
113 }} /* namespace uhd::rfnoc */
Definition: blockdef.hpp:21
uhd::dict< std::string, size_t > registers_t
Definition: blockdef.hpp:70
Definition: dict.hpp:21
static const std::set< std::string > VALID_TYPES
Definition: blockdef.hpp:59
std::vector< arg_t > args_t
Definition: blockdef.hpp:68
Definition: build_info.hpp:12
#define UHD_API
Definition: config.h:87
Describes port options for a block definition.
Definition: blockdef.hpp:33
static const device_addr_t PORT_ARGS
A list of args a port can have.
Definition: blockdef.hpp:37
static const device_addr_t ARG_ARGS
A list of args an argument can have.
Definition: blockdef.hpp:58
Describes arguments in a block definition.
Definition: blockdef.hpp:54
std::shared_ptr< blockdef > sptr
Definition: blockdef.hpp:24
std::vector< port_t > ports_t
Definition: blockdef.hpp:51
Definition: device_addr.hpp:37