From f15dbc0484adf95c245ac86fb9aa7ea37ccce71b Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 23 Jan 2018 17:13:19 -0800 Subject: rfnoc: Check noc_shell compat number at runtime --- host/include/uhd/rfnoc/block_ctrl_base.hpp | 6 ++++++ host/include/uhd/rfnoc/constants.hpp | 6 ++++-- host/lib/rfnoc/block_ctrl_base.cpp | 26 +++++++++++++++++++------- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/host/include/uhd/rfnoc/block_ctrl_base.hpp b/host/include/uhd/rfnoc/block_ctrl_base.hpp index b36f7f77f..382dd1177 100644 --- a/host/include/uhd/rfnoc/block_ctrl_base.hpp +++ b/host/include/uhd/rfnoc/block_ctrl_base.hpp @@ -405,6 +405,12 @@ private: //! The base address of this block (the address of block port 0) uint32_t _base_address; + //! 64-bit NoC ID of this block + uint64_t _noc_id; + + //! noc_shell compat number, as one 64-bit number [major,minor] + uint64_t _compat_num; + //! The (unique) block ID. block_id_t _block_id; diff --git a/host/include/uhd/rfnoc/constants.hpp b/host/include/uhd/rfnoc/constants.hpp index 988a69246..2ddb197d8 100644 --- a/host/include/uhd/rfnoc/constants.hpp +++ b/host/include/uhd/rfnoc/constants.hpp @@ -24,6 +24,8 @@ static const std::string XML_PATH_ENV = "UHD_RFNOC_DIR"; //! If the block name can't be automatically detected, this name is used static const std::string DEFAULT_BLOCK_NAME = "Block"; static const uint64_t DEFAULT_NOC_ID = 0xFFFFFFFFFFFFFFFF; +static const size_t NOC_SHELL_COMPAT_MAJOR = 1; +static const size_t NOC_SHELL_COMPAT_MINOR = 0; static const size_t MAX_PACKET_SIZE = 8000; // bytes static const size_t DEFAULT_PACKET_SIZE = 1456; // bytes @@ -68,8 +70,8 @@ enum settingsbus_reg_t { SR_READBACK_REG_FIFOSIZE = 2, // fifo size SR_READBACK_REG_MTU = 3, SR_READBACK_REG_BLOCKPORT_SIDS = 4, - SR_READBACK_REG_USER = 5 - /* 6 currently unused */ + SR_READBACK_REG_USER = 5, + SR_READBACK_COMPAT = 6 }; // AXI stream configuration bus (output master bus of axi wrapper) registers diff --git a/host/lib/rfnoc/block_ctrl_base.cpp b/host/lib/rfnoc/block_ctrl_base.cpp index 9996d3b9b..551aa60a4 100644 --- a/host/lib/rfnoc/block_ctrl_base.cpp +++ b/host/lib/rfnoc/block_ctrl_base.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -27,8 +28,8 @@ using std::string; * Helpers **********************************************************************/ //! Convert register to a peek/poke compatible address -inline uint32_t _sr_to_addr(uint32_t reg) { return reg * 4; }; -inline uint32_t _sr_to_addr64(uint32_t reg) { return reg * 8; }; // for peek64 +inline uint32_t _sr_to_addr(const uint32_t reg) { return reg * 4; }; +inline uint32_t _sr_to_addr64(const uint32_t reg) { return reg * 8; }; // for peek64 /*********************************************************************** * Structors @@ -37,14 +38,15 @@ block_ctrl_base::block_ctrl_base( const make_args_t &make_args ) : _tree(make_args.tree), _ctrl_ifaces(make_args.ctrl_ifaces), - _base_address(make_args.base_address & 0xFFF0) + _base_address(make_args.base_address & 0xFFF0), + _noc_id(sr_read64(SR_READBACK_REG_ID)), + _compat_num(sr_read64(SR_READBACK_COMPAT)) { UHD_BLOCK_LOG() << "block_ctrl_base()" ; /*** Identify this block (NoC-ID, block-ID, and block definition) *******/ // Read NoC-ID (name is passed in through make_args): - uint64_t noc_id = sr_read64(SR_READBACK_REG_ID); - _block_def = blockdef::make_from_noc_id(noc_id); + _block_def = blockdef::make_from_noc_id(_noc_id); if (_block_def) UHD_BLOCK_LOG() << "Found valid blockdef" ; if (not _block_def) _block_def = blockdef::make_from_noc_id(DEFAULT_NOC_ID); @@ -56,12 +58,22 @@ block_ctrl_base::block_ctrl_base( _block_id++; } UHD_BLOCK_LOG() - << "NOC ID: " << str(boost::format("0x%016X ") % noc_id) + << "NOC ID: " << str(boost::format("0x%016X ") % _noc_id) << "Block ID: " << _block_id ; + /*** Check compat number ************************************************/ + assert_fpga_compat( + NOC_SHELL_COMPAT_MAJOR, + NOC_SHELL_COMPAT_MINOR, + _compat_num, + "noc_shell", + "RFNoC", + false /* fail_on_minor_behind */ + ); + /*** Initialize property tree *******************************************/ _root_path = "xbar/" + _block_id.get_local(); - _tree->create(_root_path / "noc_id").set(noc_id); + _tree->create(_root_path / "noc_id").set(_noc_id); /*** Reset block state *******************************************/ clear(); -- cgit v1.2.3