diff --git a/CMakeLists.txt b/CMakeLists.txt index 36fa8c80..58cc3d13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,9 +208,11 @@ set(DIFF_FILE ${PATCH_DIR}/libpugiutil_fix/DIFF/pugixml_util_cpp.diff) apply_patch(${DIFF_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/OpenFPGA/vtr-verilog-to-routing/libs/libpugiutil/src "pugixml_util.cpp") # copy RS additions and patch CMakefiles -message(STATUS "NOTE: COPYING OpenFPGA CMakefile..") +message(STATUS "NOTE: COPYING/PATCHING OpenFPGA CMakefiles..") #set(DIFF_FILE ${PATCH_DIR}/CMAKE_fix/OpenFPGA_CMake.diff) #apply_patch(${DIFF_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/OpenFPGA "OpenFPGA CMakefile") +set(DIFF_FILE ${PATCH_DIR}/CMAKE_fix/PATCHED_OpenFPGA/libs_cmakefile.diff) +apply_patch(${DIFF_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/OpenFPGA/libs "OpenFPGA/libs CMakefile") # temporarily swithed to copying because of "partial patch" issue in Raptor build. file(COPY diff --git a/include/CMAKE_fix/PATCHED_OpenFPGA/libs_cmakefile.diff b/include/CMAKE_fix/PATCHED_OpenFPGA/libs_cmakefile.diff new file mode 100644 index 00000000..3e5d8583 --- /dev/null +++ b/include/CMAKE_fix/PATCHED_OpenFPGA/libs_cmakefile.diff @@ -0,0 +1,10 @@ +diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt +index de555d3af..0abd99c90 100644 +--- a/libs/CMakeLists.txt ++++ b/libs/CMakeLists.txt +@@ -10,4 +10,4 @@ add_subdirectory(libpcf) + add_subdirectory(libbusgroup) + add_subdirectory(libnamemanager) + add_subdirectory(libtileconfig) +-add_subdirectory(libopenfpgacapnproto) ++#add_subdirectory(libopenfpgacapnproto) # replaced by generated src diff --git a/include/openfpga/annotation/unique_blocks_uxsdcxx.capnp b/include/openfpga/annotation/unique_blocks_uxsdcxx.capnp new file mode 100644 index 00000000..2f2c722f --- /dev/null +++ b/include/openfpga/annotation/unique_blocks_uxsdcxx.capnp @@ -0,0 +1,34 @@ +# This file is generated by uxsdcap 0.1.0. +# https://github.com/duck2/uxsdcxx +# Modify only if your build process doesn't involve regenerating this file. +# +# Cmdline: uxsdcxx/uxsdcap.py /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen/unique_blocks.xsd unique_blocks_capnproto_generate/unique_blocks_uxsdcxx.h unique_blocks_capnproto_generate/unique_blocks_uxsdcxx_capnp.h unique_blocks_capnproto_generate/unique_blocks_uxsdcxx_interface.h /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen +# Input file: /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen/unique_blocks.xsd +# md5sum of input file: 1db9d740309076fa51f61413bae1e072 + +@0xacc1f04555994b8c; +using Cxx = import "/capnp/c++.capnp"; +$Cxx.namespace("ucap"); + +enum Type { + uxsdInvalid @0; + cbx @1; + cby @2; + sb @3; +} + +struct Instance { + x @0 :UInt32; + y @1 :UInt32; +} + +struct Block { + type @0 :Type; + x @1 :UInt32; + y @2 :UInt32; + instances @3 :List(Instance); +} + +struct UniqueBlocks { + blocks @0 :List(Block); +} diff --git a/include/openfpga/annotation/unique_blocks_uxsdcxx.capnp.c++ b/include/openfpga/annotation/unique_blocks_uxsdcxx.capnp.c++ new file mode 100644 index 00000000..43fbf281 --- /dev/null +++ b/include/openfpga/annotation/unique_blocks_uxsdcxx.capnp.c++ @@ -0,0 +1,313 @@ +// Generated by Cap'n Proto compiler, DO NOT EDIT +// source: unique_blocks_uxsdcxx.capnp + +#include "unique_blocks_uxsdcxx.capnp.h" + +namespace capnp { +namespace schemas { +static const ::capnp::_::AlignedData<36> b_c16da73cfbff13c7 = { + { 0, 0, 0, 0, 5, 0, 6, 0, + 199, 19, 255, 251, 60, 167, 109, 193, + 32, 0, 0, 0, 2, 0, 0, 0, + 140, 75, 153, 85, 69, 240, 193, 172, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 42, 1, 0, 0, + 37, 0, 0, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 33, 0, 0, 0, 103, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 103, 101, 110, 47, 117, 110, 105, 113, + 117, 101, 95, 98, 108, 111, 99, 107, + 115, 95, 117, 120, 115, 100, 99, 120, + 120, 46, 99, 97, 112, 110, 112, 58, + 84, 121, 112, 101, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 1, 0, + 16, 0, 0, 0, 1, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 41, 0, 0, 0, 98, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, + 37, 0, 0, 0, 34, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, 0, 0, + 29, 0, 0, 0, 34, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 26, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 117, 120, 115, 100, 73, 110, 118, 97, + 108, 105, 100, 0, 0, 0, 0, 0, + 99, 98, 120, 0, 0, 0, 0, 0, + 99, 98, 121, 0, 0, 0, 0, 0, + 115, 98, 0, 0, 0, 0, 0, 0, } +}; +::capnp::word const* const bp_c16da73cfbff13c7 = b_c16da73cfbff13c7.words; +#if !CAPNP_LITE +static const uint16_t m_c16da73cfbff13c7[] = {1, 2, 3, 0}; +const ::capnp::_::RawSchema s_c16da73cfbff13c7 = { + 0xc16da73cfbff13c7, b_c16da73cfbff13c7.words, 36, nullptr, m_c16da73cfbff13c7, + 0, 4, nullptr, nullptr, nullptr, { &s_c16da73cfbff13c7, nullptr, nullptr, 0, 0, nullptr }, false +}; +#endif // !CAPNP_LITE +CAPNP_DEFINE_ENUM(Type_c16da73cfbff13c7, c16da73cfbff13c7); +static const ::capnp::_::AlignedData<50> b_cc86674979cf0fd6 = { + { 0, 0, 0, 0, 5, 0, 6, 0, + 214, 15, 207, 121, 73, 103, 134, 204, + 32, 0, 0, 0, 1, 0, 1, 0, + 140, 75, 153, 85, 69, 240, 193, 172, + 0, 0, 7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 74, 1, 0, 0, + 41, 0, 0, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 37, 0, 0, 0, 119, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 103, 101, 110, 47, 117, 110, 105, 113, + 117, 101, 95, 98, 108, 111, 99, 107, + 115, 95, 117, 120, 115, 100, 99, 120, + 120, 46, 99, 97, 112, 110, 112, 58, + 73, 110, 115, 116, 97, 110, 99, 101, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 1, 0, + 8, 0, 0, 0, 3, 0, 4, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 41, 0, 0, 0, 18, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 36, 0, 0, 0, 3, 0, 1, 0, + 48, 0, 0, 0, 2, 0, 1, 0, + 1, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 45, 0, 0, 0, 18, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 40, 0, 0, 0, 3, 0, 1, 0, + 52, 0, 0, 0, 2, 0, 1, 0, + 120, 0, 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 121, 0, 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, } +}; +::capnp::word const* const bp_cc86674979cf0fd6 = b_cc86674979cf0fd6.words; +#if !CAPNP_LITE +static const uint16_t m_cc86674979cf0fd6[] = {0, 1}; +static const uint16_t i_cc86674979cf0fd6[] = {0, 1}; +const ::capnp::_::RawSchema s_cc86674979cf0fd6 = { + 0xcc86674979cf0fd6, b_cc86674979cf0fd6.words, 50, nullptr, m_cc86674979cf0fd6, + 0, 2, i_cc86674979cf0fd6, nullptr, nullptr, { &s_cc86674979cf0fd6, nullptr, nullptr, 0, 0, nullptr }, false +}; +#endif // !CAPNP_LITE +static const ::capnp::_::AlignedData<84> b_e65125b552e5bccc = { + { 0, 0, 0, 0, 5, 0, 6, 0, + 204, 188, 229, 82, 181, 37, 81, 230, + 32, 0, 0, 0, 1, 0, 2, 0, + 140, 75, 153, 85, 69, 240, 193, 172, + 1, 0, 7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 50, 1, 0, 0, + 37, 0, 0, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 33, 0, 0, 0, 231, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 103, 101, 110, 47, 117, 110, 105, 113, + 117, 101, 95, 98, 108, 111, 99, 107, + 115, 95, 117, 120, 115, 100, 99, 120, + 120, 46, 99, 97, 112, 110, 112, 58, + 66, 108, 111, 99, 107, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 1, 0, + 16, 0, 0, 0, 3, 0, 4, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 97, 0, 0, 0, 42, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 92, 0, 0, 0, 3, 0, 1, 0, + 104, 0, 0, 0, 2, 0, 1, 0, + 1, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 101, 0, 0, 0, 18, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 96, 0, 0, 0, 3, 0, 1, 0, + 108, 0, 0, 0, 2, 0, 1, 0, + 2, 0, 0, 0, 2, 0, 0, 0, + 0, 0, 1, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 105, 0, 0, 0, 18, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 100, 0, 0, 0, 3, 0, 1, 0, + 112, 0, 0, 0, 2, 0, 1, 0, + 3, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 109, 0, 0, 0, 82, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 108, 0, 0, 0, 3, 0, 1, 0, + 136, 0, 0, 0, 2, 0, 1, 0, + 116, 121, 112, 101, 0, 0, 0, 0, + 15, 0, 0, 0, 0, 0, 0, 0, + 199, 19, 255, 251, 60, 167, 109, 193, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 120, 0, 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 121, 0, 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 105, 110, 115, 116, 97, 110, 99, 101, + 115, 0, 0, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, 1, 0, + 16, 0, 0, 0, 0, 0, 0, 0, + 214, 15, 207, 121, 73, 103, 134, 204, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, } +}; +::capnp::word const* const bp_e65125b552e5bccc = b_e65125b552e5bccc.words; +#if !CAPNP_LITE +static const ::capnp::_::RawSchema* const d_e65125b552e5bccc[] = { + &s_c16da73cfbff13c7, + &s_cc86674979cf0fd6, +}; +static const uint16_t m_e65125b552e5bccc[] = {3, 0, 1, 2}; +static const uint16_t i_e65125b552e5bccc[] = {0, 1, 2, 3}; +const ::capnp::_::RawSchema s_e65125b552e5bccc = { + 0xe65125b552e5bccc, b_e65125b552e5bccc.words, 84, d_e65125b552e5bccc, m_e65125b552e5bccc, + 2, 4, i_e65125b552e5bccc, nullptr, nullptr, { &s_e65125b552e5bccc, nullptr, nullptr, 0, 0, nullptr }, false +}; +#endif // !CAPNP_LITE +static const ::capnp::_::AlignedData<39> b_f6ad8a85615a2b06 = { + { 0, 0, 0, 0, 5, 0, 6, 0, + 6, 43, 90, 97, 133, 138, 173, 246, + 32, 0, 0, 0, 1, 0, 0, 0, + 140, 75, 153, 85, 69, 240, 193, 172, + 1, 0, 7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 106, 1, 0, 0, + 41, 0, 0, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 37, 0, 0, 0, 63, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 103, 101, 110, 47, 117, 110, 105, 113, + 117, 101, 95, 98, 108, 111, 99, 107, + 115, 95, 117, 120, 115, 100, 99, 120, + 120, 46, 99, 97, 112, 110, 112, 58, + 85, 110, 105, 113, 117, 101, 66, 108, + 111, 99, 107, 115, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 1, 0, + 4, 0, 0, 0, 3, 0, 4, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 13, 0, 0, 0, 58, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 3, 0, 1, 0, + 36, 0, 0, 0, 2, 0, 1, 0, + 98, 108, 111, 99, 107, 115, 0, 0, + 14, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, 1, 0, + 16, 0, 0, 0, 0, 0, 0, 0, + 204, 188, 229, 82, 181, 37, 81, 230, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, } +}; +::capnp::word const* const bp_f6ad8a85615a2b06 = b_f6ad8a85615a2b06.words; +#if !CAPNP_LITE +static const ::capnp::_::RawSchema* const d_f6ad8a85615a2b06[] = { + &s_e65125b552e5bccc, +}; +static const uint16_t m_f6ad8a85615a2b06[] = {0}; +static const uint16_t i_f6ad8a85615a2b06[] = {0}; +const ::capnp::_::RawSchema s_f6ad8a85615a2b06 = { + 0xf6ad8a85615a2b06, b_f6ad8a85615a2b06.words, 39, d_f6ad8a85615a2b06, m_f6ad8a85615a2b06, + 1, 1, i_f6ad8a85615a2b06, nullptr, nullptr, { &s_f6ad8a85615a2b06, nullptr, nullptr, 0, 0, nullptr }, false +}; +#endif // !CAPNP_LITE +} // namespace schemas +} // namespace capnp + +// ======================================================================================= + +namespace ucap { + +// Instance +#if CAPNP_NEED_REDUNDANT_CONSTEXPR_DECL +constexpr uint16_t Instance::_capnpPrivate::dataWordSize; +constexpr uint16_t Instance::_capnpPrivate::pointerCount; +#endif // !CAPNP_NEED_REDUNDANT_CONSTEXPR_DECL +#if !CAPNP_LITE +#if CAPNP_NEED_REDUNDANT_CONSTEXPR_DECL +constexpr ::capnp::Kind Instance::_capnpPrivate::kind; +constexpr ::capnp::_::RawSchema const* Instance::_capnpPrivate::schema; +#endif // !CAPNP_NEED_REDUNDANT_CONSTEXPR_DECL +#endif // !CAPNP_LITE + +// Block +#if CAPNP_NEED_REDUNDANT_CONSTEXPR_DECL +constexpr uint16_t Block::_capnpPrivate::dataWordSize; +constexpr uint16_t Block::_capnpPrivate::pointerCount; +#endif // !CAPNP_NEED_REDUNDANT_CONSTEXPR_DECL +#if !CAPNP_LITE +#if CAPNP_NEED_REDUNDANT_CONSTEXPR_DECL +constexpr ::capnp::Kind Block::_capnpPrivate::kind; +constexpr ::capnp::_::RawSchema const* Block::_capnpPrivate::schema; +#endif // !CAPNP_NEED_REDUNDANT_CONSTEXPR_DECL +#endif // !CAPNP_LITE + +// UniqueBlocks +#if CAPNP_NEED_REDUNDANT_CONSTEXPR_DECL +constexpr uint16_t UniqueBlocks::_capnpPrivate::dataWordSize; +constexpr uint16_t UniqueBlocks::_capnpPrivate::pointerCount; +#endif // !CAPNP_NEED_REDUNDANT_CONSTEXPR_DECL +#if !CAPNP_LITE +#if CAPNP_NEED_REDUNDANT_CONSTEXPR_DECL +constexpr ::capnp::Kind UniqueBlocks::_capnpPrivate::kind; +constexpr ::capnp::_::RawSchema const* UniqueBlocks::_capnpPrivate::schema; +#endif // !CAPNP_NEED_REDUNDANT_CONSTEXPR_DECL +#endif // !CAPNP_LITE + + +} // namespace + diff --git a/include/openfpga/annotation/unique_blocks_uxsdcxx.capnp.h b/include/openfpga/annotation/unique_blocks_uxsdcxx.capnp.h new file mode 100644 index 00000000..324f35e6 --- /dev/null +++ b/include/openfpga/annotation/unique_blocks_uxsdcxx.capnp.h @@ -0,0 +1,488 @@ +// Generated by Cap'n Proto compiler, DO NOT EDIT +// source: unique_blocks_uxsdcxx.capnp + +#pragma once + +#include +#include + +#ifndef CAPNP_VERSION +#error "CAPNP_VERSION is not defined, is capnp/generated-header-support.h missing?" +#elif CAPNP_VERSION != 1000002 +#error "Version mismatch between generated code and library headers. You must use the same version of the Cap'n Proto compiler and library." +#endif + + +CAPNP_BEGIN_HEADER + +namespace capnp { +namespace schemas { + +CAPNP_DECLARE_SCHEMA(c16da73cfbff13c7); +enum class Type_c16da73cfbff13c7: uint16_t { + UXSD_INVALID, + CBX, + CBY, + SB, +}; +CAPNP_DECLARE_ENUM(Type, c16da73cfbff13c7); +CAPNP_DECLARE_SCHEMA(cc86674979cf0fd6); +CAPNP_DECLARE_SCHEMA(e65125b552e5bccc); +CAPNP_DECLARE_SCHEMA(f6ad8a85615a2b06); + +} // namespace schemas +} // namespace capnp + +namespace ucap { + +typedef ::capnp::schemas::Type_c16da73cfbff13c7 Type; + +struct Instance { + Instance() = delete; + + class Reader; + class Builder; + class Pipeline; + + struct _capnpPrivate { + CAPNP_DECLARE_STRUCT_HEADER(cc86674979cf0fd6, 1, 0) + #if !CAPNP_LITE + static constexpr ::capnp::_::RawBrandedSchema const* brand() { return &schema->defaultBrand; } + #endif // !CAPNP_LITE + }; +}; + +struct Block { + Block() = delete; + + class Reader; + class Builder; + class Pipeline; + + struct _capnpPrivate { + CAPNP_DECLARE_STRUCT_HEADER(e65125b552e5bccc, 2, 1) + #if !CAPNP_LITE + static constexpr ::capnp::_::RawBrandedSchema const* brand() { return &schema->defaultBrand; } + #endif // !CAPNP_LITE + }; +}; + +struct UniqueBlocks { + UniqueBlocks() = delete; + + class Reader; + class Builder; + class Pipeline; + + struct _capnpPrivate { + CAPNP_DECLARE_STRUCT_HEADER(f6ad8a85615a2b06, 0, 1) + #if !CAPNP_LITE + static constexpr ::capnp::_::RawBrandedSchema const* brand() { return &schema->defaultBrand; } + #endif // !CAPNP_LITE + }; +}; + +// ======================================================================================= + +class Instance::Reader { +public: + typedef Instance Reads; + + Reader() = default; + inline explicit Reader(::capnp::_::StructReader base): _reader(base) {} + + inline ::capnp::MessageSize totalSize() const { + return _reader.totalSize().asPublic(); + } + +#if !CAPNP_LITE + inline ::kj::StringTree toString() const { + return ::capnp::_::structString(_reader, *_capnpPrivate::brand()); + } +#endif // !CAPNP_LITE + + inline ::uint32_t getX() const; + + inline ::uint32_t getY() const; + +private: + ::capnp::_::StructReader _reader; + template + friend struct ::capnp::ToDynamic_; + template + friend struct ::capnp::_::PointerHelpers; + template + friend struct ::capnp::List; + friend class ::capnp::MessageBuilder; + friend class ::capnp::Orphanage; +}; + +class Instance::Builder { +public: + typedef Instance Builds; + + Builder() = delete; // Deleted to discourage incorrect usage. + // You can explicitly initialize to nullptr instead. + inline Builder(decltype(nullptr)) {} + inline explicit Builder(::capnp::_::StructBuilder base): _builder(base) {} + inline operator Reader() const { return Reader(_builder.asReader()); } + inline Reader asReader() const { return *this; } + + inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); } +#if !CAPNP_LITE + inline ::kj::StringTree toString() const { return asReader().toString(); } +#endif // !CAPNP_LITE + + inline ::uint32_t getX(); + inline void setX( ::uint32_t value); + + inline ::uint32_t getY(); + inline void setY( ::uint32_t value); + +private: + ::capnp::_::StructBuilder _builder; + template + friend struct ::capnp::ToDynamic_; + friend class ::capnp::Orphanage; + template + friend struct ::capnp::_::PointerHelpers; +}; + +#if !CAPNP_LITE +class Instance::Pipeline { +public: + typedef Instance Pipelines; + + inline Pipeline(decltype(nullptr)): _typeless(nullptr) {} + inline explicit Pipeline(::capnp::AnyPointer::Pipeline&& typeless) + : _typeless(kj::mv(typeless)) {} + +private: + ::capnp::AnyPointer::Pipeline _typeless; + friend class ::capnp::PipelineHook; + template + friend struct ::capnp::ToDynamic_; +}; +#endif // !CAPNP_LITE + +class Block::Reader { +public: + typedef Block Reads; + + Reader() = default; + inline explicit Reader(::capnp::_::StructReader base): _reader(base) {} + + inline ::capnp::MessageSize totalSize() const { + return _reader.totalSize().asPublic(); + } + +#if !CAPNP_LITE + inline ::kj::StringTree toString() const { + return ::capnp::_::structString(_reader, *_capnpPrivate::brand()); + } +#endif // !CAPNP_LITE + + inline ::ucap::Type getType() const; + + inline ::uint32_t getX() const; + + inline ::uint32_t getY() const; + + inline bool hasInstances() const; + inline ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>::Reader getInstances() const; + +private: + ::capnp::_::StructReader _reader; + template + friend struct ::capnp::ToDynamic_; + template + friend struct ::capnp::_::PointerHelpers; + template + friend struct ::capnp::List; + friend class ::capnp::MessageBuilder; + friend class ::capnp::Orphanage; +}; + +class Block::Builder { +public: + typedef Block Builds; + + Builder() = delete; // Deleted to discourage incorrect usage. + // You can explicitly initialize to nullptr instead. + inline Builder(decltype(nullptr)) {} + inline explicit Builder(::capnp::_::StructBuilder base): _builder(base) {} + inline operator Reader() const { return Reader(_builder.asReader()); } + inline Reader asReader() const { return *this; } + + inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); } +#if !CAPNP_LITE + inline ::kj::StringTree toString() const { return asReader().toString(); } +#endif // !CAPNP_LITE + + inline ::ucap::Type getType(); + inline void setType( ::ucap::Type value); + + inline ::uint32_t getX(); + inline void setX( ::uint32_t value); + + inline ::uint32_t getY(); + inline void setY( ::uint32_t value); + + inline bool hasInstances(); + inline ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>::Builder getInstances(); + inline void setInstances( ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>::Reader value); + inline ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>::Builder initInstances(unsigned int size); + inline void adoptInstances(::capnp::Orphan< ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>>&& value); + inline ::capnp::Orphan< ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>> disownInstances(); + +private: + ::capnp::_::StructBuilder _builder; + template + friend struct ::capnp::ToDynamic_; + friend class ::capnp::Orphanage; + template + friend struct ::capnp::_::PointerHelpers; +}; + +#if !CAPNP_LITE +class Block::Pipeline { +public: + typedef Block Pipelines; + + inline Pipeline(decltype(nullptr)): _typeless(nullptr) {} + inline explicit Pipeline(::capnp::AnyPointer::Pipeline&& typeless) + : _typeless(kj::mv(typeless)) {} + +private: + ::capnp::AnyPointer::Pipeline _typeless; + friend class ::capnp::PipelineHook; + template + friend struct ::capnp::ToDynamic_; +}; +#endif // !CAPNP_LITE + +class UniqueBlocks::Reader { +public: + typedef UniqueBlocks Reads; + + Reader() = default; + inline explicit Reader(::capnp::_::StructReader base): _reader(base) {} + + inline ::capnp::MessageSize totalSize() const { + return _reader.totalSize().asPublic(); + } + +#if !CAPNP_LITE + inline ::kj::StringTree toString() const { + return ::capnp::_::structString(_reader, *_capnpPrivate::brand()); + } +#endif // !CAPNP_LITE + + inline bool hasBlocks() const; + inline ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>::Reader getBlocks() const; + +private: + ::capnp::_::StructReader _reader; + template + friend struct ::capnp::ToDynamic_; + template + friend struct ::capnp::_::PointerHelpers; + template + friend struct ::capnp::List; + friend class ::capnp::MessageBuilder; + friend class ::capnp::Orphanage; +}; + +class UniqueBlocks::Builder { +public: + typedef UniqueBlocks Builds; + + Builder() = delete; // Deleted to discourage incorrect usage. + // You can explicitly initialize to nullptr instead. + inline Builder(decltype(nullptr)) {} + inline explicit Builder(::capnp::_::StructBuilder base): _builder(base) {} + inline operator Reader() const { return Reader(_builder.asReader()); } + inline Reader asReader() const { return *this; } + + inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); } +#if !CAPNP_LITE + inline ::kj::StringTree toString() const { return asReader().toString(); } +#endif // !CAPNP_LITE + + inline bool hasBlocks(); + inline ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>::Builder getBlocks(); + inline void setBlocks( ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>::Reader value); + inline ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>::Builder initBlocks(unsigned int size); + inline void adoptBlocks(::capnp::Orphan< ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>>&& value); + inline ::capnp::Orphan< ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>> disownBlocks(); + +private: + ::capnp::_::StructBuilder _builder; + template + friend struct ::capnp::ToDynamic_; + friend class ::capnp::Orphanage; + template + friend struct ::capnp::_::PointerHelpers; +}; + +#if !CAPNP_LITE +class UniqueBlocks::Pipeline { +public: + typedef UniqueBlocks Pipelines; + + inline Pipeline(decltype(nullptr)): _typeless(nullptr) {} + inline explicit Pipeline(::capnp::AnyPointer::Pipeline&& typeless) + : _typeless(kj::mv(typeless)) {} + +private: + ::capnp::AnyPointer::Pipeline _typeless; + friend class ::capnp::PipelineHook; + template + friend struct ::capnp::ToDynamic_; +}; +#endif // !CAPNP_LITE + +// ======================================================================================= + +inline ::uint32_t Instance::Reader::getX() const { + return _reader.getDataField< ::uint32_t>( + ::capnp::bounded<0>() * ::capnp::ELEMENTS); +} + +inline ::uint32_t Instance::Builder::getX() { + return _builder.getDataField< ::uint32_t>( + ::capnp::bounded<0>() * ::capnp::ELEMENTS); +} +inline void Instance::Builder::setX( ::uint32_t value) { + _builder.setDataField< ::uint32_t>( + ::capnp::bounded<0>() * ::capnp::ELEMENTS, value); +} + +inline ::uint32_t Instance::Reader::getY() const { + return _reader.getDataField< ::uint32_t>( + ::capnp::bounded<1>() * ::capnp::ELEMENTS); +} + +inline ::uint32_t Instance::Builder::getY() { + return _builder.getDataField< ::uint32_t>( + ::capnp::bounded<1>() * ::capnp::ELEMENTS); +} +inline void Instance::Builder::setY( ::uint32_t value) { + _builder.setDataField< ::uint32_t>( + ::capnp::bounded<1>() * ::capnp::ELEMENTS, value); +} + +inline ::ucap::Type Block::Reader::getType() const { + return _reader.getDataField< ::ucap::Type>( + ::capnp::bounded<0>() * ::capnp::ELEMENTS); +} + +inline ::ucap::Type Block::Builder::getType() { + return _builder.getDataField< ::ucap::Type>( + ::capnp::bounded<0>() * ::capnp::ELEMENTS); +} +inline void Block::Builder::setType( ::ucap::Type value) { + _builder.setDataField< ::ucap::Type>( + ::capnp::bounded<0>() * ::capnp::ELEMENTS, value); +} + +inline ::uint32_t Block::Reader::getX() const { + return _reader.getDataField< ::uint32_t>( + ::capnp::bounded<1>() * ::capnp::ELEMENTS); +} + +inline ::uint32_t Block::Builder::getX() { + return _builder.getDataField< ::uint32_t>( + ::capnp::bounded<1>() * ::capnp::ELEMENTS); +} +inline void Block::Builder::setX( ::uint32_t value) { + _builder.setDataField< ::uint32_t>( + ::capnp::bounded<1>() * ::capnp::ELEMENTS, value); +} + +inline ::uint32_t Block::Reader::getY() const { + return _reader.getDataField< ::uint32_t>( + ::capnp::bounded<2>() * ::capnp::ELEMENTS); +} + +inline ::uint32_t Block::Builder::getY() { + return _builder.getDataField< ::uint32_t>( + ::capnp::bounded<2>() * ::capnp::ELEMENTS); +} +inline void Block::Builder::setY( ::uint32_t value) { + _builder.setDataField< ::uint32_t>( + ::capnp::bounded<2>() * ::capnp::ELEMENTS, value); +} + +inline bool Block::Reader::hasInstances() const { + return !_reader.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS).isNull(); +} +inline bool Block::Builder::hasInstances() { + return !_builder.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS).isNull(); +} +inline ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>::Reader Block::Reader::getInstances() const { + return ::capnp::_::PointerHelpers< ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>>::get(_reader.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS)); +} +inline ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>::Builder Block::Builder::getInstances() { + return ::capnp::_::PointerHelpers< ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>>::get(_builder.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS)); +} +inline void Block::Builder::setInstances( ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>::Reader value) { + ::capnp::_::PointerHelpers< ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>>::set(_builder.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS), value); +} +inline ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>::Builder Block::Builder::initInstances(unsigned int size) { + return ::capnp::_::PointerHelpers< ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>>::init(_builder.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS), size); +} +inline void Block::Builder::adoptInstances( + ::capnp::Orphan< ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>>&& value) { + ::capnp::_::PointerHelpers< ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>>::adopt(_builder.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS), kj::mv(value)); +} +inline ::capnp::Orphan< ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>> Block::Builder::disownInstances() { + return ::capnp::_::PointerHelpers< ::capnp::List< ::ucap::Instance, ::capnp::Kind::STRUCT>>::disown(_builder.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS)); +} + +inline bool UniqueBlocks::Reader::hasBlocks() const { + return !_reader.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS).isNull(); +} +inline bool UniqueBlocks::Builder::hasBlocks() { + return !_builder.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS).isNull(); +} +inline ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>::Reader UniqueBlocks::Reader::getBlocks() const { + return ::capnp::_::PointerHelpers< ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>>::get(_reader.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS)); +} +inline ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>::Builder UniqueBlocks::Builder::getBlocks() { + return ::capnp::_::PointerHelpers< ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>>::get(_builder.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS)); +} +inline void UniqueBlocks::Builder::setBlocks( ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>::Reader value) { + ::capnp::_::PointerHelpers< ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>>::set(_builder.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS), value); +} +inline ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>::Builder UniqueBlocks::Builder::initBlocks(unsigned int size) { + return ::capnp::_::PointerHelpers< ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>>::init(_builder.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS), size); +} +inline void UniqueBlocks::Builder::adoptBlocks( + ::capnp::Orphan< ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>>&& value) { + ::capnp::_::PointerHelpers< ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>>::adopt(_builder.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS), kj::mv(value)); +} +inline ::capnp::Orphan< ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>> UniqueBlocks::Builder::disownBlocks() { + return ::capnp::_::PointerHelpers< ::capnp::List< ::ucap::Block, ::capnp::Kind::STRUCT>>::disown(_builder.getPointerField( + ::capnp::bounded<0>() * ::capnp::POINTERS)); +} + +} // namespace + +CAPNP_END_HEADER + diff --git a/include/openfpga/annotation/unique_blocks_uxsdcxx.cpp b/include/openfpga/annotation/unique_blocks_uxsdcxx.cpp new file mode 100644 index 00000000..79d86860 --- /dev/null +++ b/include/openfpga/annotation/unique_blocks_uxsdcxx.cpp @@ -0,0 +1,16 @@ +/* + * This file is generated by uxsdcxx 0.1.0. + * https://github.com/duck2/uxsdcxx + * Modify only if your build process doesn't involve regenerating this file. + * + * Cmdline: uxsdcxx/uxsdcxx.py /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen/unique_blocks.xsd + * Input file: /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen/unique_blocks.xsd + * md5sum of input file: 1db9d740309076fa51f61413bae1e072 + */ +#include "unique_blocks_uxsdcxx.h" + +/* All uxsdcxx functions and structs live in this namespace. */ +namespace uxsd { + + +} /* namespace uxsd */ diff --git a/include/openfpga/annotation/unique_blocks_uxsdcxx.h b/include/openfpga/annotation/unique_blocks_uxsdcxx.h new file mode 100644 index 00000000..b89b7423 --- /dev/null +++ b/include/openfpga/annotation/unique_blocks_uxsdcxx.h @@ -0,0 +1,578 @@ +#pragma once +/* + * This file is generated by uxsdcxx 0.1.0. + * https://github.com/duck2/uxsdcxx + * Modify only if your build process doesn't involve regenerating this file. + * + * Cmdline: uxsdcxx/uxsdcxx.py /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen/unique_blocks.xsd + * Input file: /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen/unique_blocks.xsd + * md5sum of input file: 1db9d740309076fa51f61413bae1e072 + */ + +#include + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "pugixml.hpp" + +#include "unique_blocks_uxsdcxx_interface.h" +/* All uxsdcxx functions and structs live in this namespace. */ +namespace uxsd { + +/** + * Internal function for getting line and column number from file based on + * byte offset. + */ +inline void get_line_number(const char *filename, std::ptrdiff_t offset, int * line, int * col); + +[[noreturn]] inline void noreturn_report(const std::function * report_error, const char *msg) { + (*report_error)(msg); + throw std::runtime_error("Unreachable!"); +} + +/* Declarations for internal load functions for the complex types. */ +template +inline void load_instance(const pugi::xml_node &root, T &out, Context &context, const std::function *report_error, ptrdiff_t *offset_debug); +inline void load_instance_required_attributes(const pugi::xml_node &root, unsigned int * x, unsigned int * y, const std::function * report_error); +template +inline void load_block(const pugi::xml_node &root, T &out, Context &context, const std::function *report_error, ptrdiff_t *offset_debug); +inline void load_block_required_attributes(const pugi::xml_node &root, enum_type * type, unsigned int * x, unsigned int * y, const std::function * report_error); +template +inline void load_unique_blocks(const pugi::xml_node &root, T &out, Context &context, const std::function *report_error, ptrdiff_t *offset_debug); + +/* Declarations for internal write functions for the complex types. */ +template +inline void write_block(T &in, std::ostream &os, const void *data, void *iter); +template +inline void write_unique_blocks(T &in, std::ostream &os, const void *data, void *iter); + +/* Load function for the root element. */ +template +inline void load_unique_blocks_xml(T &out, Context &context, const char * filename, std::istream &is){ + pugi::xml_document doc; + pugi::xml_parse_result result = doc.load(is); + if(!result) { + int line, col; + get_line_number(filename, result.offset, &line, &col); + std::stringstream msg; + msg << "Unable to load XML file '" << filename << "', "; + msg << result.description() << " (line: " << line; + msg << " col: " << col << ")"; out.error_encountered(filename, line, msg.str().c_str()); + } + ptrdiff_t offset_debug = 0; + std::function report_error = [filename, &out, &offset_debug](const char * message) { + int line, col; + get_line_number(filename, offset_debug, &line, &col); + out.error_encountered(filename, line, message); + // If error_encountered didn't throw, throw now to unwind. + throw std::runtime_error(message); + }; + out.start_load(&report_error); + + for(pugi::xml_node node= doc.first_child(); node; node = node.next_sibling()){ + if(std::strcmp(node.name(), "unique_blocks") == 0){ + /* If errno is set up to this point, it messes with strtol errno checking. */ + errno = 0; + load_unique_blocks(node, out, context, &report_error, &offset_debug); + } else { + offset_debug = node.offset_debug(); + report_error(("Invalid root-level element " + std::string(node.name())).c_str()); + } + } + out.finish_load(); +} + +/* Write function for the root element. */ +template +inline void write_unique_blocks_xml(T &in, Context &context, std::ostream &os){ + in.start_write(); + os << "\n"; + write_unique_blocks(in, os, context); + os << "\n"; + in.finish_write(); +} + + +typedef const uint32_t __attribute__((aligned(1))) triehash_uu32; +typedef const uint64_t __attribute__((aligned(1))) triehash_uu64; +static_assert(alignof(triehash_uu32) == 1, "Unaligned 32-bit access not found."); +static_assert(alignof(triehash_uu64) == 1, "Unaligned 64-bit access not found."); +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define onechar(c, s, l) (((uint64_t)(c)) << (s)) +#else +#define onechar(c, s, l) (((uint64_t)(c)) << (l-8-s)) +#endif + +/* Tokens for attribute and node names. */ + +enum class atok_t_instance {X, Y}; +constexpr const char *atok_lookup_t_instance[] = {"x", "y"}; + +enum class gtok_t_block {INSTANCE}; +constexpr const char *gtok_lookup_t_block[] = {"instance"}; +enum class atok_t_block {TYPE, X, Y}; +constexpr const char *atok_lookup_t_block[] = {"type", "x", "y"}; + +enum class gtok_t_unique_blocks {BLOCK}; +constexpr const char *gtok_lookup_t_unique_blocks[] = {"block"}; + +/* Internal lexers. These convert the PugiXML node names to input tokens. */ +inline atok_t_instance lex_attr_t_instance(const char *in, const std::function * report_error){ + unsigned int len = strlen(in); + switch(len){ + case 1: + switch(in[0]){ + case onechar('x', 0, 8): + return atok_t_instance::X; + break; + case onechar('y', 0, 8): + return atok_t_instance::Y; + break; + default: break; + } + break; + default: break; + } + noreturn_report(report_error, ("Found unrecognized attribute " + std::string(in) + " of .").c_str()); +} + +inline gtok_t_block lex_node_t_block(const char *in, const std::function *report_error){ + unsigned int len = strlen(in); + switch(len){ + case 8: + switch(*((triehash_uu64*)&in[0])){ + case onechar('i', 0, 64) | onechar('n', 8, 64) | onechar('s', 16, 64) | onechar('t', 24, 64) | onechar('a', 32, 64) | onechar('n', 40, 64) | onechar('c', 48, 64) | onechar('e', 56, 64): + return gtok_t_block::INSTANCE; + break; + default: break; + } + break; + default: break; + } + noreturn_report(report_error, ("Found unrecognized child " + std::string(in) + " of .").c_str()); +} +inline atok_t_block lex_attr_t_block(const char *in, const std::function * report_error){ + unsigned int len = strlen(in); + switch(len){ + case 1: + switch(in[0]){ + case onechar('x', 0, 8): + return atok_t_block::X; + break; + case onechar('y', 0, 8): + return atok_t_block::Y; + break; + default: break; + } + break; + case 4: + switch(*((triehash_uu32*)&in[0])){ + case onechar('t', 0, 32) | onechar('y', 8, 32) | onechar('p', 16, 32) | onechar('e', 24, 32): + return atok_t_block::TYPE; + break; + default: break; + } + break; + default: break; + } + noreturn_report(report_error, ("Found unrecognized attribute " + std::string(in) + " of .").c_str()); +} + +inline gtok_t_unique_blocks lex_node_t_unique_blocks(const char *in, const std::function *report_error){ + unsigned int len = strlen(in); + switch(len){ + case 5: + switch(*((triehash_uu32*)&in[0])){ + case onechar('b', 0, 32) | onechar('l', 8, 32) | onechar('o', 16, 32) | onechar('c', 24, 32): + switch(in[4]){ + case onechar('k', 0, 8): + return gtok_t_unique_blocks::BLOCK; + break; + default: break; + } + break; + default: break; + } + break; + default: break; + } + noreturn_report(report_error, ("Found unrecognized child " + std::string(in) + " of .").c_str()); +} + +/** + * Internal error function for xs:choice and xs:sequence validators. + */ +[[noreturn]] inline void dfa_error(const char *wrong, const int *states, const char * const *lookup, int len, const std::function * report_error); + +/** + * Internal error function for attribute validators. + */ +template +[[noreturn]] inline void attr_error(std::bitset astate, const char * const *lookup, const std::function * report_error); + + +/* Lookup tables for enums. */ +constexpr const char *lookup_type[] = {"UXSD_INVALID", "cbx", "cby", "sb"}; + +/* Lexers(string->token functions) for enums. */ +inline enum_type lex_enum_type(const char *in, bool throw_on_invalid, const std::function * report_error){ + unsigned int len = strlen(in); + switch(len){ + case 2: + switch(in[0]){ + case onechar('s', 0, 8): + switch(in[1]){ + case onechar('b', 0, 8): + return enum_type::SB; + break; + default: break; + } + break; + default: break; + } + break; + case 3: + switch(in[0]){ + case onechar('c', 0, 8): + switch(in[1]){ + case onechar('b', 0, 8): + switch(in[2]){ + case onechar('x', 0, 8): + return enum_type::CBX; + break; + case onechar('y', 0, 8): + return enum_type::CBY; + break; + default: break; + } + break; + default: break; + } + break; + default: break; + } + break; + default: break; + } + if(throw_on_invalid) + noreturn_report(report_error, ("Found unrecognized enum value " + std::string(in) + " of enum_type.").c_str()); + return enum_type::UXSD_INVALID; +} + + +/* Internal loading functions, which validate and load a PugiXML DOM tree into memory. */ +inline unsigned int load_unsigned_int(const char *in, const std::function * report_error){ + unsigned int out; + out = std::strtoul(in, NULL, 10); + if(errno != 0) + noreturn_report(report_error, ("Invalid value `" + std::string(in) + "` when loading into a unsigned int.").c_str()); + return out; +} +inline void load_instance_required_attributes(const pugi::xml_node &root, unsigned int * x, unsigned int * y, const std::function * report_error){ + std::bitset<2> astate = 0; + for(pugi::xml_attribute attr = root.first_attribute(); attr; attr = attr.next_attribute()){ + atok_t_instance in = lex_attr_t_instance(attr.name(), report_error); + if(astate[(int)in] == 0) astate[(int)in] = 1; + else noreturn_report(report_error, ("Duplicate attribute " + std::string(attr.name()) + " in .").c_str()); + switch(in){ + case atok_t_instance::X: + *x = load_unsigned_int(attr.value(), report_error); + break; + case atok_t_instance::Y: + *y = load_unsigned_int(attr.value(), report_error); + break; + default: break; /* Not possible. */ + } + } + std::bitset<2> test_astate = astate | std::bitset<2>(0b00); + if(!test_astate.all()) attr_error(test_astate, atok_lookup_t_instance, report_error); +} + +inline void load_block_required_attributes(const pugi::xml_node &root, enum_type * type, unsigned int * x, unsigned int * y, const std::function * report_error){ + std::bitset<3> astate = 0; + for(pugi::xml_attribute attr = root.first_attribute(); attr; attr = attr.next_attribute()){ + atok_t_block in = lex_attr_t_block(attr.name(), report_error); + if(astate[(int)in] == 0) astate[(int)in] = 1; + else noreturn_report(report_error, ("Duplicate attribute " + std::string(attr.name()) + " in .").c_str()); + switch(in){ + case atok_t_block::TYPE: + *type = lex_enum_type(attr.value(), true, report_error); + break; + case atok_t_block::X: + *x = load_unsigned_int(attr.value(), report_error); + break; + case atok_t_block::Y: + *y = load_unsigned_int(attr.value(), report_error); + break; + default: break; /* Not possible. */ + } + } + std::bitset<3> test_astate = astate | std::bitset<3>(0b000); + if(!test_astate.all()) attr_error(test_astate, atok_lookup_t_block, report_error); +} +template +inline void load_instance(const pugi::xml_node &root, T &out, Context &context, const std::function *report_error, ptrdiff_t *offset_debug){ + (void)root; + (void)out; + (void)context; + (void)report_error; + // Update current file offset in case an error is encountered. + *offset_debug = root.offset_debug(); + + + if(root.first_child().type() == pugi::node_element) + noreturn_report(report_error, "Unexpected child element in ."); + +} + +constexpr int NUM_T_BLOCK_STATES = 1; +constexpr const int NUM_T_BLOCK_INPUTS = 1; +constexpr int gstate_t_block[NUM_T_BLOCK_STATES][NUM_T_BLOCK_INPUTS] = { + {0}, +}; +template +inline void load_block(const pugi::xml_node &root, T &out, Context &context, const std::function *report_error, ptrdiff_t *offset_debug){ + (void)root; + (void)out; + (void)context; + (void)report_error; + // Update current file offset in case an error is encountered. + *offset_debug = root.offset_debug(); + + + // Preallocate arrays by counting child nodes (if any) + size_t instance_count = 0; + { + int next, state=0; + for(pugi::xml_node node = root.first_child(); node; node = node.next_sibling()) { + *offset_debug = node.offset_debug(); + gtok_t_block in = lex_node_t_block(node.name(), report_error); + next = gstate_t_block[state][(int)in]; + if(next == -1) + dfa_error(gtok_lookup_t_block[(int)in], gstate_t_block[state], gtok_lookup_t_block, 1, report_error); + state = next; + switch(in) { + case gtok_t_block::INSTANCE: + instance_count += 1; + break; + default: break; /* Not possible. */ + } + } + + out.preallocate_block_instance(context, instance_count); + } + int next, state=0; + for(pugi::xml_node node = root.first_child(); node; node = node.next_sibling()){ + *offset_debug = node.offset_debug(); + gtok_t_block in = lex_node_t_block(node.name(), report_error); + next = gstate_t_block[state][(int)in]; + if(next == -1) + dfa_error(gtok_lookup_t_block[(int)in], gstate_t_block[state], gtok_lookup_t_block, 1, report_error); + state = next; + switch(in){ + case gtok_t_block::INSTANCE: + { + unsigned int instance_x; + memset(&instance_x, 0, sizeof(instance_x)); + unsigned int instance_y; + memset(&instance_y, 0, sizeof(instance_y)); + load_instance_required_attributes(node, &instance_x, &instance_y, report_error); + auto child_context = out.add_block_instance(context, instance_x, instance_y); + load_instance(node, out, child_context, report_error, offset_debug); + out.finish_block_instance(child_context); + } + break; + default: break; /* Not possible. */ + } + } + if(state != 0) dfa_error("end of input", gstate_t_block[state], gtok_lookup_t_block, 1, report_error); + +} + +constexpr int NUM_T_UNIQUE_BLOCKS_STATES = 2; +constexpr const int NUM_T_UNIQUE_BLOCKS_INPUTS = 1; +constexpr int gstate_t_unique_blocks[NUM_T_UNIQUE_BLOCKS_STATES][NUM_T_UNIQUE_BLOCKS_INPUTS] = { + {0}, + {0}, +}; +template +inline void load_unique_blocks(const pugi::xml_node &root, T &out, Context &context, const std::function *report_error, ptrdiff_t *offset_debug){ + (void)root; + (void)out; + (void)context; + (void)report_error; + // Update current file offset in case an error is encountered. + *offset_debug = root.offset_debug(); + + if(root.first_attribute()) + noreturn_report(report_error, "Unexpected attribute in ."); + + // Preallocate arrays by counting child nodes (if any) + size_t block_count = 0; + { + int next, state=1; + for(pugi::xml_node node = root.first_child(); node; node = node.next_sibling()) { + *offset_debug = node.offset_debug(); + gtok_t_unique_blocks in = lex_node_t_unique_blocks(node.name(), report_error); + next = gstate_t_unique_blocks[state][(int)in]; + if(next == -1) + dfa_error(gtok_lookup_t_unique_blocks[(int)in], gstate_t_unique_blocks[state], gtok_lookup_t_unique_blocks, 1, report_error); + state = next; + switch(in) { + case gtok_t_unique_blocks::BLOCK: + block_count += 1; + break; + default: break; /* Not possible. */ + } + } + + out.preallocate_unique_blocks_block(context, block_count); + } + int next, state=1; + for(pugi::xml_node node = root.first_child(); node; node = node.next_sibling()){ + *offset_debug = node.offset_debug(); + gtok_t_unique_blocks in = lex_node_t_unique_blocks(node.name(), report_error); + next = gstate_t_unique_blocks[state][(int)in]; + if(next == -1) + dfa_error(gtok_lookup_t_unique_blocks[(int)in], gstate_t_unique_blocks[state], gtok_lookup_t_unique_blocks, 1, report_error); + state = next; + switch(in){ + case gtok_t_unique_blocks::BLOCK: + { + enum_type block_type; + memset(&block_type, 0, sizeof(block_type)); + unsigned int block_x; + memset(&block_x, 0, sizeof(block_x)); + unsigned int block_y; + memset(&block_y, 0, sizeof(block_y)); + load_block_required_attributes(node, &block_type, &block_x, &block_y, report_error); + auto child_context = out.add_unique_blocks_block(context, block_type, block_x, block_y); + load_block(node, out, child_context, report_error, offset_debug); + out.finish_unique_blocks_block(child_context); + } + break; + default: break; /* Not possible. */ + } + } + if(state != 0) dfa_error("end of input", gstate_t_unique_blocks[state], gtok_lookup_t_unique_blocks, 1, report_error); + +} + + +/* Internal writing functions, which uxsdcxx uses to write out a class. */ +template +inline void write_block(T &in, std::ostream &os, Context &context){ + (void)in; + (void)os; + (void)context; + { + for(size_t i=0, n=in.num_block_instance(context); i\n"; + } + } +} + +template +inline void write_unique_blocks(T &in, std::ostream &os, Context &context){ + (void)in; + (void)os; + (void)context; + { + for(size_t i=0, n=in.num_unique_blocks_block(context); i"; + write_block(in, os, child_context); + os << "\n"; + } + } +} + +inline void dfa_error(const char *wrong, const int *states, const char * const *lookup, int len, const std::function * report_error){ + std::vector expected; + for(int i=0; i +inline void attr_error(std::bitset astate, const char * const *lookup, const std::function * report_error){ + std::vector missing; + for(unsigned int i=0; i f(fopen(filename, "rb"), fclose); + + if (!f) { + throw std::runtime_error(std::string("Failed to open file") + filename); + } + + int current_line = 1; + std::ptrdiff_t offset = 0; + std::ptrdiff_t last_line_offset = 0; + std::ptrdiff_t current_line_offset = 0; + + char buffer[1024]; + std::size_t size; + + while ((size = fread(buffer, 1, sizeof(buffer), f.get())) > 0) { + for (std::size_t i = 0; i < size; ++i) { + if (buffer[i] == '\n') { + current_line += 1; + last_line_offset = current_line_offset; + current_line_offset = offset + i; + + if(target_offset < current_line_offset) { + if(target_offset < last_line_offset) { + throw std::runtime_error("Assertion violation"); + } + + *line = current_line - 1; + *col = target_offset - last_line_offset; + return; + } + } + } + + offset += size; + } + + *line = current_line; + *col = target_offset - current_line_offset; +} + + +} /* namespace uxsd */ diff --git a/include/openfpga/annotation/unique_blocks_uxsdcxx_capnp.h b/include/openfpga/annotation/unique_blocks_uxsdcxx_capnp.h new file mode 100644 index 00000000..5c22a686 --- /dev/null +++ b/include/openfpga/annotation/unique_blocks_uxsdcxx_capnp.h @@ -0,0 +1,200 @@ +#pragma once +/* + * This file is generated by uxsdcxx 0.1.0. + * https://github.com/duck2/uxsdcxx + * Modify only if your build process doesn't involve regenerating this file. + * + * Cmdline: uxsdcxx/uxsdcap.py /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen/unique_blocks.xsd unique_blocks_capnproto_generate/unique_blocks_uxsdcxx.h unique_blocks_capnproto_generate/unique_blocks_uxsdcxx_capnp.h unique_blocks_capnproto_generate/unique_blocks_uxsdcxx_interface.h /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen + * Input file: /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen/unique_blocks.xsd + * md5sum of input file: 1db9d740309076fa51f61413bae1e072 + */ + +#include + +#include +#include +#include +#include +#include +#include "capnp/serialize.h" +#include "unique_blocks_uxsdcxx.capnp.h" +#include "unique_blocks_uxsdcxx_interface.h" + +/* All uxsdcxx functions and structs live in this namespace. */ +namespace uxsd { +/* Declarations for internal load functions for the complex types. */ +template +void load_instance_capnp_type(const ucap::Instance::Reader &root, T &out, Context &context, const std::function * report_error, std::vector> * stack); +template +void load_block_capnp_type(const ucap::Block::Reader &root, T &out, Context &context, const std::function * report_error, std::vector> * stack); +template +void load_unique_blocks_capnp_type(const ucap::UniqueBlocks::Reader &root, T &out, Context &context, const std::function * report_error, std::vector> * stack); + +/* Declarations for internal write functions for the complex types. */ +template +inline void write_block_capnp_type(T &in, ucap::Block::Builder &root, Context &context); +template +inline void write_unique_blocks_capnp_type(T &in, ucap::UniqueBlocks::Builder &root, Context &context); + +/* Enum conversions from uxsd to ucap */ +inline enum_type conv_enum_type(ucap::Type e, const std::function * report_error) { + switch(e) { + case ucap::Type::UXSD_INVALID: + return enum_type::UXSD_INVALID; + case ucap::Type::CBX: + return enum_type::CBX; + case ucap::Type::CBY: + return enum_type::CBY; + case ucap::Type::SB: + return enum_type::SB; + default: + (*report_error)("Unknown enum_type"); + throw std::runtime_error("Unreachable!"); + } +} + +inline ucap::Type conv_to_enum_type(enum_type e) { + switch(e) { + case enum_type::UXSD_INVALID: + return ucap::Type::UXSD_INVALID; + case enum_type::CBX: + return ucap::Type::CBX; + case enum_type::CBY: + return ucap::Type::CBY; + case enum_type::SB: + return ucap::Type::SB; + default: + throw std::runtime_error("Unknown enum_type"); + } +} + + +/* Load function for the root element. */ +template +inline void load_unique_blocks_capnp(T &out, kj::ArrayPtr data, Context &context, const char * filename){ + /* Remove traversal limits. */ + ::capnp::ReaderOptions opts = ::capnp::ReaderOptions(); + opts.traversalLimitInWords = std::numeric_limits::max(); + ::capnp::FlatArrayMessageReader reader(data, opts); + auto root = reader.getRoot(); + std::vector> stack; + stack.reserve(20); + stack.push_back(std::make_pair("root", 0)); + + std::function report_error = [filename, &out, &stack](const char *message){ + std::stringstream msg; + msg << message << std::endl; + msg << "Error occured at "; + for(size_t i = 0; i < stack.size(); ++i) { + msg << stack[i].first << "[" << stack[i].second << "]"; + if(i+1 < stack.size()) { + msg << " . "; + } + } + out.error_encountered(filename, -1, msg.str().c_str()); + }; + out.start_load(&report_error); + load_unique_blocks_capnp_type(root, out, context, &report_error, &stack); + out.finish_load(); +} + +/* Write function for the root element. */ +template +inline void write_unique_blocks_capnp(T &in, Context &context, ucap::UniqueBlocks::Builder &root) { + in.start_write(); + write_unique_blocks_capnp_type(in, root, context); + in.finish_write(); +} + + +/* Internal loading functions, which validate and load a PugiXML DOM tree into memory. */ +template +inline void load_instance_capnp_type(const ucap::Instance::Reader &root, T &out, Context &context, const std::function * report_error, std::vector> * stack){ + (void)root; + (void)out; + (void)context; + (void)report_error; + (void)stack; + +} + +template +inline void load_block_capnp_type(const ucap::Block::Reader &root, T &out, Context &context, const std::function * report_error, std::vector> * stack){ + (void)root; + (void)out; + (void)context; + (void)report_error; + (void)stack; + + stack->push_back(std::make_pair("getInstance", 0)); + { + auto data = root.getInstances(); + out.preallocate_block_instance(context, data.size()); + for(const auto & el : data) { + auto child_context = out.add_block_instance(context, el.getX(), el.getY()); + load_instance_capnp_type(el, out, child_context, report_error, stack); + out.finish_block_instance(child_context); + stack->back().second += 1; + } + } + stack->pop_back(); +} + +template +inline void load_unique_blocks_capnp_type(const ucap::UniqueBlocks::Reader &root, T &out, Context &context, const std::function * report_error, std::vector> * stack){ + (void)root; + (void)out; + (void)context; + (void)report_error; + (void)stack; + + stack->push_back(std::make_pair("getBlock", 0)); + { + auto data = root.getBlocks(); + out.preallocate_unique_blocks_block(context, data.size()); + for(const auto & el : data) { + auto child_context = out.add_unique_blocks_block(context, conv_enum_type(el.getType(), report_error), el.getX(), el.getY()); + load_block_capnp_type(el, out, child_context, report_error, stack); + out.finish_unique_blocks_block(child_context); + stack->back().second += 1; + } + } + stack->pop_back(); +} + + +/* Internal writing functions, which uxsdcxx uses to write out a class. */ +template +inline void write_block_capnp_type(T &in, ucap::Block::Builder &root, Context &context) { + (void)in; + (void)root; + + size_t num_block_instances = in.num_block_instance(context); + auto block_instances = root.initInstances(num_block_instances); + for(size_t i = 0; i < num_block_instances; i++) { + auto block_instance = block_instances[i]; + auto child_context = in.get_block_instance(i, context); + block_instance.setX(in.get_instance_x(child_context)); + block_instance.setY(in.get_instance_y(child_context)); + } +} + +template +inline void write_unique_blocks_capnp_type(T &in, ucap::UniqueBlocks::Builder &root, Context &context) { + (void)in; + (void)root; + + size_t num_unique_blocks_blocks = in.num_unique_blocks_block(context); + auto unique_blocks_blocks = root.initBlocks(num_unique_blocks_blocks); + for(size_t i = 0; i < num_unique_blocks_blocks; i++) { + auto unique_blocks_block = unique_blocks_blocks[i]; + auto child_context = in.get_unique_blocks_block(i, context); + unique_blocks_block.setType(conv_to_enum_type(in.get_block_type(child_context))); + unique_blocks_block.setX(in.get_block_x(child_context)); + unique_blocks_block.setY(in.get_block_y(child_context)); + write_block_capnp_type(in, unique_blocks_block, child_context); + } +} + + +} /* namespace uxsd */ diff --git a/include/openfpga/annotation/unique_blocks_uxsdcxx_capnp_impl.h b/include/openfpga/annotation/unique_blocks_uxsdcxx_capnp_impl.h new file mode 100644 index 00000000..6e80f140 --- /dev/null +++ b/include/openfpga/annotation/unique_blocks_uxsdcxx_capnp_impl.h @@ -0,0 +1,156 @@ +#pragma once +/* + * This file is generated by uxsdcxx 0.1.0. + * https://github.com/duck2/uxsdcxx + * Modify only if your build process doesn't involve regenerating this file. + * + * Cmdline: uxsdcxx/uxsdcap.py /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen/unique_blocks.xsd unique_blocks_capnproto_generate/unique_blocks_uxsdcxx.h unique_blocks_capnproto_generate/unique_blocks_uxsdcxx_capnp.h unique_blocks_capnproto_generate/unique_blocks_uxsdcxx_interface.h /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen + * Input file: /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen/unique_blocks.xsd + * md5sum of input file: 1db9d740309076fa51f61413bae1e072 + */ + +#include + +#include +#include +#include "capnp/serialize.h" +#include "unique_blocks_uxsdcxx.capnp.h" +#include "unique_blocks_uxsdcxx_interface.h" + +/* All uxsdcxx functions and structs live in this namespace. */ +namespace uxsd { + + +/* Enum conversions from uxsd to ucap */ +inline enum_type conv_enum_type(ucap::Type e, const std::function * report_error) { + switch(e) { + case ucap::Type::UXSD_INVALID: + return enum_type::UXSD_INVALID; + case ucap::Type::CBX: + return enum_type::CBX; + case ucap::Type::CBY: + return enum_type::CBY; + case ucap::Type::SB: + return enum_type::SB; + default: + (*report_error)("Unknown enum_type"); + throw std::runtime_error("Unreachable!"); + } +} + +inline ucap::Type conv_to_enum_type(enum_type e) { + switch(e) { + case enum_type::UXSD_INVALID: + return ucap::Type::UXSD_INVALID; + case enum_type::CBX: + return ucap::Type::CBX; + case enum_type::CBY: + return ucap::Type::CBY; + case enum_type::SB: + return ucap::Type::SB; + default: + throw std::runtime_error("Unknown enum_type"); + } +} +struct CapnpUniqueBlocksContextTypes : public DefaultUniqueBlocksContextTypes { + using InstanceReadContext = ucap::Instance::Reader; + using BlockReadContext = ucap::Block::Reader; + using UniqueBlocksReadContext = ucap::UniqueBlocks::Reader; + using InstanceWriteContext = ucap::Instance::Builder; + using BlockWriteContext = ucap::Block::Builder; + using UniqueBlocksWriteContext = ucap::UniqueBlocks::Builder; +}; + +class CapnpUniqueBlocks : public UniqueBlocksBase { + public: + CapnpUniqueBlocks() {} + + void start_load(const std::function *report_error_in) override { + report_error = report_error_in; + } + void finish_load() override {} + void start_write() override {} + void finish_write() override {} + void error_encountered(const char * file, int line, const char *message) override { + std::stringstream msg; msg << message << " occured at file: " << file << " line: " << line; + throw std::runtime_error(msg.str()); + } + inline unsigned int get_instance_x(ucap::Instance::Reader &reader) override { + return reader.getX(); + } + + inline unsigned int get_instance_y(ucap::Instance::Reader &reader) override { + return reader.getY(); + } + inline enum_type get_block_type(ucap::Block::Reader &reader) override { + return conv_enum_type(reader.getType(), report_error); + } + + inline unsigned int get_block_x(ucap::Block::Reader &reader) override { + return reader.getX(); + } + + inline unsigned int get_block_y(ucap::Block::Reader &reader) override { + return reader.getY(); + } + + inline ucap::Instance::Builder add_block_instance(ucap::Block::Builder &builder, unsigned int x, unsigned int y) override { + auto instance = capnp::Orphanage::getForMessageContaining(builder).newOrphan(); + instances_.emplace_back(std::move(instance)); + auto child_builder = instances_.back().get(); + child_builder.setX(x); + child_builder.setY(y); + return child_builder; + } + + inline void preallocate_block_instance(ucap::Block::Builder&, size_t size) override { + instances_.reserve(size); + } + + inline void finish_block_instance(ucap::Instance::Builder &builder) override { + } + + inline size_t num_block_instance(ucap::Block::Reader &reader) override { + return reader.getInstances().size(); + } + + inline ucap::Instance::Reader get_block_instance(int n, ucap::Block::Reader &reader) override { + return reader.getInstances()[n]; + } + inline ucap::Block::Builder add_unique_blocks_block(ucap::UniqueBlocks::Builder &builder, enum_type type, unsigned int x, unsigned int y) override { + auto block = capnp::Orphanage::getForMessageContaining(builder).newOrphan(); + blocks_.emplace_back(std::move(block)); + auto child_builder = blocks_.back().get(); + child_builder.setType(conv_to_enum_type(type)); + child_builder.setX(x); + child_builder.setY(y); + return child_builder; + } + + inline void preallocate_unique_blocks_block(ucap::UniqueBlocks::Builder&, size_t size) override { + blocks_.reserve(size); + } + + inline void finish_unique_blocks_block(ucap::Block::Builder &builder) override { + auto instance = builder.initInstances(instances_.size()); + for(size_t i = 0; i < instances_.size(); ++i) { + instance.adoptWithCaveats(i, std::move(instances_[i])); + } + instances_.clear(); + } + + inline size_t num_unique_blocks_block(ucap::UniqueBlocks::Reader &reader) override { + return reader.getBlocks().size(); + } + + inline ucap::Block::Reader get_unique_blocks_block(int n, ucap::UniqueBlocks::Reader &reader) override { + return reader.getBlocks()[n]; + } +private: + const std::function *report_error; + std::vector> instances_; + std::vector> blocks_; +}; + + +} /* namespace uxsd */ diff --git a/include/openfpga/annotation/unique_blocks_uxsdcxx_interface.h b/include/openfpga/annotation/unique_blocks_uxsdcxx_interface.h new file mode 100644 index 00000000..1bd018d6 --- /dev/null +++ b/include/openfpga/annotation/unique_blocks_uxsdcxx_interface.h @@ -0,0 +1,87 @@ +#pragma once +/* + * This file is generated by uxsdcxx 0.1.0. + * https://github.com/duck2/uxsdcxx + * Modify only if your build process doesn't involve regenerating this file. + * + * Cmdline: uxsdcxx/uxsdcxx.py /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen/unique_blocks.xsd + * Input file: /home/serge/bes/13oct/Backend/OpenFPGA/libs/libopenfpgacapnproto/gen/unique_blocks.xsd + * md5sum of input file: 1db9d740309076fa51f61413bae1e072 + */ + +#include + + +/* All uxsdcxx functions and structs live in this namespace. */ + +#include +#include + +namespace uxsd { + +/* Enum tokens generated from XSD enumerations. */ + +enum class enum_type {UXSD_INVALID = 0, CBX, CBY, SB}; + +/* Base class for the schema. */ +struct DefaultUniqueBlocksContextTypes { +using InstanceReadContext = void *; + using BlockReadContext = void *; + using UniqueBlocksReadContext = void *; +using InstanceWriteContext = void *; + using BlockWriteContext = void *; + using UniqueBlocksWriteContext = void *; +}; + +template +class UniqueBlocksBase { +public: + virtual ~UniqueBlocksBase() {} + virtual void start_load(const std::function *report_error) = 0; + virtual void finish_load() = 0; + virtual void start_write() = 0; + virtual void finish_write() = 0; + virtual void error_encountered(const char * file, int line, const char *message) = 0; + /** Generated for complex type "instance": + * + * + * + * + */ + virtual inline unsigned int get_instance_x(typename ContextTypes::InstanceReadContext &ctx) = 0; + virtual inline unsigned int get_instance_y(typename ContextTypes::InstanceReadContext &ctx) = 0; + + /** Generated for complex type "block": + * + * + * + * + * + * + * + * + */ + virtual inline enum_type get_block_type(typename ContextTypes::BlockReadContext &ctx) = 0; + virtual inline unsigned int get_block_x(typename ContextTypes::BlockReadContext &ctx) = 0; + virtual inline unsigned int get_block_y(typename ContextTypes::BlockReadContext &ctx) = 0; + virtual inline void preallocate_block_instance(typename ContextTypes::BlockWriteContext &ctx, size_t size) = 0; + virtual inline typename ContextTypes::InstanceWriteContext add_block_instance(typename ContextTypes::BlockWriteContext &ctx, unsigned int x, unsigned int y) = 0; + virtual inline void finish_block_instance(typename ContextTypes::InstanceWriteContext &ctx) = 0; + virtual inline size_t num_block_instance(typename ContextTypes::BlockReadContext &ctx) = 0; + virtual inline typename ContextTypes::InstanceReadContext get_block_instance(int n, typename ContextTypes::BlockReadContext &ctx) = 0; + + /** Generated for complex type "unique_blocks": + * + * + * + * + * + */ + virtual inline void preallocate_unique_blocks_block(typename ContextTypes::UniqueBlocksWriteContext &ctx, size_t size) = 0; + virtual inline typename ContextTypes::BlockWriteContext add_unique_blocks_block(typename ContextTypes::UniqueBlocksWriteContext &ctx, enum_type type, unsigned int x, unsigned int y) = 0; + virtual inline void finish_unique_blocks_block(typename ContextTypes::BlockWriteContext &ctx) = 0; + virtual inline size_t num_unique_blocks_block(typename ContextTypes::UniqueBlocksReadContext &ctx) = 0; + virtual inline typename ContextTypes::BlockReadContext get_unique_blocks_block(int n, typename ContextTypes::UniqueBlocksReadContext &ctx) = 0; +}; + +} /* namespace uxsd */