diff --git a/lib/include/prjxray/xilinx/bitstream_reader.h b/lib/include/prjxray/xilinx/bitstream_reader.h index 4cf98c23..61e807f1 100644 --- a/lib/include/prjxray/xilinx/bitstream_reader.h +++ b/lib/include/prjxray/xilinx/bitstream_reader.h @@ -72,16 +72,16 @@ class BitstreamReader { std::vector words_; }; -template <> +template template -absl::optional> -BitstreamReader::InitWithBytes(T bitstream) { +absl::optional> +BitstreamReader::InitWithBytes(T bitstream) { // If this is really a Xilinx bitstream, there will be a sync // word somewhere toward the beginning. auto sync_pos = std::search(bitstream.begin(), bitstream.end(), kSyncWord.begin(), kSyncWord.end()); if (sync_pos == bitstream.end()) { - return absl::optional>(); + return absl::optional>(); } sync_pos += kSyncWord.size(); @@ -91,63 +91,12 @@ BitstreamReader::InitWithBytes(T bitstream) { bitstream_span.subspan(sync_pos - bitstream.begin()); // Convert the bytes into 32-bit, big-endian words. - auto big_endian_reader = make_big_endian_span(config_packets); + auto big_endian_reader = + make_big_endian_span(config_packets); std::vector words{big_endian_reader.begin(), big_endian_reader.end()}; - return BitstreamReader(std::move(words)); -} - -template <> -template -absl::optional> -BitstreamReader::InitWithBytes(T bitstream) { - // If this is really a Xilinx bitstream, there will be a sync - // word somewhere toward the beginning. - auto sync_pos = std::search(bitstream.begin(), bitstream.end(), - kSyncWord.begin(), kSyncWord.end()); - if (sync_pos == bitstream.end()) { - return absl::optional>(); - } - sync_pos += kSyncWord.size(); - - // Wrap the provided container in a span that strips off the preamble. - absl::Span bitstream_span(bitstream); - auto config_packets = - bitstream_span.subspan(sync_pos - bitstream.begin()); - - // Convert the bytes into 32-bit, big-endian words. - auto big_endian_reader = make_big_endian_span(config_packets); - std::vector words{big_endian_reader.begin(), - big_endian_reader.end()}; - - return BitstreamReader(std::move(words)); -} - -template <> -template -absl::optional> -BitstreamReader::InitWithBytes(T bitstream) { - // If this is really a Xilinx bitstream, there will be a sync - // word somewhere toward the beginning. - auto sync_pos = std::search(bitstream.begin(), bitstream.end(), - kSyncWord.begin(), kSyncWord.end()); - if (sync_pos == bitstream.end()) { - return absl::optional>(); - } - sync_pos += kSyncWord.size(); - - // Wrap the provided container in a span that strips off the preamble. - absl::Span bitstream_span(bitstream); - auto config_packets = - bitstream_span.subspan(sync_pos - bitstream.begin()); - - // Convert the bytes into 32-bit, big-endian words. - auto big_endian_reader = make_big_endian_span(config_packets); - std::vector words{big_endian_reader.begin(), - big_endian_reader.end()}; - - return BitstreamReader(std::move(words)); + return BitstreamReader(std::move(words)); } // Sync word as specified in UG470 page 81