mirror of https://github.com/openXC7/prjxray.git
lib: xc7series: wrapper for ranges of config frame addresses
Includes conversion to/from YAML. Signed-off-by: Rick Altherr <kc8apf@kc8apf.net> Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
This commit is contained in:
parent
92509c5043
commit
4f6046d177
|
|
@ -5,6 +5,7 @@ add_library(libprjxray
|
||||||
xilinx/xc7series/bitstream_reader.cc
|
xilinx/xc7series/bitstream_reader.cc
|
||||||
xilinx/xc7series/block_type.cc
|
xilinx/xc7series/block_type.cc
|
||||||
xilinx/xc7series/configuration_frame_address.cc
|
xilinx/xc7series/configuration_frame_address.cc
|
||||||
|
xilinx/xc7series/configuration_frame_range.cc
|
||||||
xilinx/xc7series/configuration_packet.cc
|
xilinx/xc7series/configuration_packet.cc
|
||||||
xilinx/xc7series/configuration_register.cc
|
xilinx/xc7series/configuration_register.cc
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
#ifndef PRJXRAY_LIB_XILINX_XC7SERIES_CONFIGURATION_FRAME_RANGE_H_
|
||||||
|
#define PRJXRAY_LIB_XILINX_XC7SERIES_CONFIGURATION_FRAME_RANGE_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include <prjxray/xilinx/xc7series/configuration_frame_address.h>
|
||||||
|
#include <yaml-cpp/yaml.h>
|
||||||
|
|
||||||
|
namespace prjxray {
|
||||||
|
namespace xilinx {
|
||||||
|
namespace xc7series {
|
||||||
|
|
||||||
|
class ConfigurationFrameRange {
|
||||||
|
public:
|
||||||
|
ConfigurationFrameRange() : begin_(0), end_(0) {}
|
||||||
|
|
||||||
|
ConfigurationFrameRange(ConfigurationFrameAddress begin,
|
||||||
|
ConfigurationFrameAddress end)
|
||||||
|
: begin_(begin), end_(end) {};
|
||||||
|
|
||||||
|
ConfigurationFrameAddress begin() const { return begin_; }
|
||||||
|
ConfigurationFrameAddress end() const { return end_; }
|
||||||
|
|
||||||
|
size_t size() const { return end_ - begin_; }
|
||||||
|
bool empty() const { return size() == 0; }
|
||||||
|
|
||||||
|
bool Contains(ConfigurationFrameAddress address) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ConfigurationFrameAddress begin_;
|
||||||
|
ConfigurationFrameAddress end_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace xc7series
|
||||||
|
} // namespace xilinx
|
||||||
|
} // namespace prjxray
|
||||||
|
|
||||||
|
namespace YAML {
|
||||||
|
template<>
|
||||||
|
struct convert<prjxray::xilinx::xc7series::ConfigurationFrameRange> {
|
||||||
|
static Node encode(
|
||||||
|
const prjxray::xilinx::xc7series::ConfigurationFrameRange &rhs);
|
||||||
|
static bool decode(
|
||||||
|
const Node& node,
|
||||||
|
prjxray::xilinx::xc7series::ConfigurationFrameRange &lhs);
|
||||||
|
};
|
||||||
|
} // namespace YAML
|
||||||
|
#endif // PRJXRAY_LIB_XILINX_XC7SERIES_CONFIGURATION_FRAME_RANGE_H_
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
#include <prjxray/xilinx/xc7series/configuration_frame_range.h>
|
||||||
|
|
||||||
|
namespace prjxray {
|
||||||
|
namespace xilinx {
|
||||||
|
namespace xc7series {
|
||||||
|
|
||||||
|
bool ConfigurationFrameRange::Contains(
|
||||||
|
ConfigurationFrameAddress address) const {
|
||||||
|
return address >= begin_ && address < end_;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace xc7series
|
||||||
|
} // namespace xilinx
|
||||||
|
} // namespace prjxray
|
||||||
|
|
||||||
|
namespace xc7series = prjxray::xilinx::xc7series;
|
||||||
|
|
||||||
|
namespace YAML {
|
||||||
|
|
||||||
|
Node convert<xc7series::ConfigurationFrameRange>::encode(
|
||||||
|
const xc7series::ConfigurationFrameRange &rhs) {
|
||||||
|
Node node;
|
||||||
|
node.SetTag("xilinx/xc7series/configuration_frame_range");
|
||||||
|
node["begin"] = rhs.begin();
|
||||||
|
node["end"] = rhs.end();
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool convert<xc7series::ConfigurationFrameRange>::decode(
|
||||||
|
const Node &node,
|
||||||
|
xc7series::ConfigurationFrameRange &lhs) {
|
||||||
|
if (node.Tag() != "xilinx/xc7series/configuration_frame_range" ||
|
||||||
|
!node["begin"] ||
|
||||||
|
!node["end"]) return false;
|
||||||
|
|
||||||
|
lhs = xc7series::ConfigurationFrameRange(
|
||||||
|
node["begin"].as<xc7series::ConfigurationFrameAddress>(),
|
||||||
|
node["end"].as<xc7series::ConfigurationFrameAddress>());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace YAML;
|
||||||
Loading…
Reference in New Issue