From bd9338da4ae8472d21c11bf27b80503e4872f7b1 Mon Sep 17 00:00:00 2001 From: Rick Altherr Date: Fri, 8 Dec 2017 19:34:32 -0800 Subject: [PATCH] Tool to decode xc7series frame addresses Signed-off-by: Rick Altherr Signed-off-by: Tim 'mithro' Ansell --- tools/CMakeLists.txt | 3 +++ tools/frame_address_decoder.cc | 43 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 tools/frame_address_decoder.cc diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index b5bcafd8..68290a6c 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -6,3 +6,6 @@ target_link_libraries(segmatch libprjxray gflags absl::strings) add_executable(bittool bittool.cc) target_link_libraries(bittool libprjxray gflags absl::strings absl::span) + +add_executable(frame_address_decoder frame_address_decoder.cc) +target_link_libraries(frame_address_decoder libprjxray) diff --git a/tools/frame_address_decoder.cc b/tools/frame_address_decoder.cc new file mode 100644 index 00000000..60410521 --- /dev/null +++ b/tools/frame_address_decoder.cc @@ -0,0 +1,43 @@ +#include +#include +#include + +#include + +namespace xc7series = prjxray::xilinx::xc7series; + +int main(int argc, char *argv[]) { + std::istream * input_stream = &std::cin; + if (argc > 1) { + auto file_stream = std::ifstream(argv[1]); + if (file_stream) { + input_stream = &file_stream; + } + } + + for (uint32_t frame_address_raw; + (*input_stream) >> std::hex >> frame_address_raw; + ) { + xc7series::ConfigurationFrameAddress frame_address(frame_address_raw); + std::cout << "[" + << std::hex << std::showbase << std::setw(10) + << frame_address_raw + << "] " + << (frame_address.is_bottom_half_rows() ? + "BOTTOM" : "TOP") + << " Row=" + << std::setw(2) << std::dec + << static_cast(frame_address.row_address()) + << " Column=" + << std::setw(2) << std::dec + << frame_address.column_address() + << " Minor=" + << std::setw(2) << std::dec + << static_cast(frame_address.minor_address()) + << " Type=" + << frame_address.block_type() + << std::endl; + } + + return 0; +}