From 630cebd0fb0a0d9e63d45de7d07c4274e465f1b5 Mon Sep 17 00:00:00 2001 From: Tomasz Michalak Date: Tue, 8 Oct 2019 10:33:37 +0200 Subject: [PATCH] Remove unused class Signed-off-by: Tomasz Michalak --- lib/CMakeLists.txt | 2 - .../prjxray/xilinx/configuration_packetizer.h | 72 -------- lib/xilinx/configuration_packetizer.cc | 162 ------------------ .../configuration_packetizer_test.cc | 119 ------------- 4 files changed, 355 deletions(-) delete mode 100644 lib/include/prjxray/xilinx/configuration_packetizer.h delete mode 100644 lib/xilinx/configuration_packetizer.cc delete mode 100644 lib/xilinx/tests/xc7series/configuration_packetizer_test.cc diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 41eca2b5..9aee7afd 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -4,7 +4,6 @@ add_library(libprjxray segbits_file_reader.cc xilinx/bitstream_writer.cc xilinx/configuration_packet.cc - xilinx/configuration_packetizer.cc xilinx/configuration_register.cc xilinx/frames.cc xilinx/configuration.cc @@ -52,7 +51,6 @@ if (PRJXRAY_BUILD_TESTING) xilinx/tests/xc7series/configuration_column_test.cc xilinx/tests/xc7series/configuration_test.cc xilinx/tests/xc7series/configuration_packet_test.cc - xilinx/tests/xc7series/configuration_packetizer_test.cc xilinx/tests/xc7series/crc_test.cc xilinx/tests/xc7series/ecc_test.cc xilinx/tests/xc7series/frame_address_test.cc diff --git a/lib/include/prjxray/xilinx/configuration_packetizer.h b/lib/include/prjxray/xilinx/configuration_packetizer.h deleted file mode 100644 index 5ca7ed9e..00000000 --- a/lib/include/prjxray/xilinx/configuration_packetizer.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef PRJXRAY_LIB_XILINX_CONFIGURATION_PACKETIZER_H_ -#define PRJXRAY_LIB_XILINX_CONFIGURATION_PACKETIZER_H_ - -#include -#include -#include - -namespace prjxray { -namespace xilinx { - -template -class ConfigurationPacketizer { - public: - class iterator - : std::iterator< - std::input_iterator_tag, - ConfigurationPacket> { - public: - iterator( - const typename ArchType::Part* part, - typename Configuration::FrameMap::const_iterator - begin, - typename Configuration::FrameMap::const_iterator - end); - - iterator& operator++(); - - bool operator==(const iterator& other) const; - bool operator!=(const iterator& other) const; - - const ConfigurationPacket& - operator*() const; - const ConfigurationPacket* - operator->() const; - - private: - friend class ConfigurationPacketizer; - - enum class State { - Start, - FrameAddressWritten, - FrameDataWritten, - ZeroPadWritten, - Finished, - }; - - const typename ArchType::Part* part_; - State state_; - typename Configuration::FrameMap::const_iterator - frame_cur_; - typename Configuration::FrameMap::const_iterator - frame_end_; - absl::optional frame_address_; - absl::optional< - ConfigurationPacket> - packet_; - int zero_pad_packets_to_write_; - }; - - ConfigurationPacketizer(const Configuration& config); - - iterator begin() const; - iterator end() const; - - private: - const Configuration& config_; -}; - -} // namespace xilinx -} // namespace prjxray - -#endif // PRJXRAY_LIB_XILINX_CONFIGURATION_PACKETIZER_H_ diff --git a/lib/xilinx/configuration_packetizer.cc b/lib/xilinx/configuration_packetizer.cc deleted file mode 100644 index e25b3d3b..00000000 --- a/lib/xilinx/configuration_packetizer.cc +++ /dev/null @@ -1,162 +0,0 @@ -#include -#include -#include - -namespace prjxray { -namespace xilinx { - -template -ConfigurationPacketizer::ConfigurationPacketizer( - const Configuration& config) - : config_(config) {} - -template -typename ConfigurationPacketizer::iterator -ConfigurationPacketizer::begin() const { - return iterator(&config_.part(), config_.frames().begin(), - config_.frames().end()); -} - -template -typename ConfigurationPacketizer::iterator -ConfigurationPacketizer::end() const { - return iterator(&config_.part(), config_.frames().end(), - config_.frames().end()); -} - -template -ConfigurationPacketizer::iterator::iterator( - const typename ArchType::Part* part, - typename Configuration::FrameMap::const_iterator begin, - typename Configuration::FrameMap::const_iterator end) - : part_(part), - state_(begin != end ? State::Start : State::Finished), - frame_cur_(begin), - frame_end_(end) { - this->operator++(); -} - -template -const ConfigurationPacket& - ConfigurationPacketizer::iterator::operator*() const { - return *packet_; -} - -template -const ConfigurationPacket* - ConfigurationPacketizer::iterator::operator->() const { - return &(*packet_); -} - -template -bool ConfigurationPacketizer::iterator::operator==( - const ConfigurationPacketizer::iterator& other) const { - return state_ == other.state_ && frame_cur_ == other.frame_cur_; -} - -template -bool ConfigurationPacketizer::iterator::operator!=( - const ConfigurationPacketizer::iterator& other) const { - return !(*this == other); -} - -template <> -typename ConfigurationPacketizer::iterator& - ConfigurationPacketizer::iterator::operator++() { - using ArchType = Series7; - // Frames are accessed via an indirect addressing scheme using the FAR - // and FDRI registers. Writes begin with writing the target frame - // address to FAR and then the frame data is written to FDRI. The - // following state machine primarily follows that flow: - // Start -> FrameAddressWritten -> FrameDataWritten -> Start.... - // When the last frame within a row is written, 2 full frames (202 - // words) of zero padding need to be written after the frame data. - switch (state_) { - case State::FrameDataWritten: { - // If this is the last address in this row (i.e. the - // next valid address known by the part is in a - // different row, half, or bus type), start a zero fill. - // Otherwise, increment the frame iterator and fall - // through to Start. - auto& this_address = frame_cur_->first; - auto next_address = - part_->GetNextFrameAddress(frame_cur_->first); - if (next_address && - (next_address->block_type() != - this_address.block_type() || - next_address->is_bottom_half_rows() != - this_address.is_bottom_half_rows() || - next_address->row() != this_address.row())) { - zero_pad_packets_to_write_ = 202; - // Type 0 frames aren't documented in UG470. In - // practice, they are used to zero pad in the - // bitstream. - packet_ = ConfigurationPacket< - typename ArchType::ConfRegType>( - 0, - ConfigurationPacket< - typename ArchType::ConfRegType>:: - Opcode::NOP, - ArchType::ConfRegType::CRC, {}); - state_ = State::ZeroPadWritten; - break; - } - - ++frame_cur_; - } - case State::Start: - if (frame_cur_ == frame_end_) { - state_ = State::Finished; - frame_address_.reset(); - packet_.reset(); - return *this; - } - - frame_address_ = frame_cur_->first; - packet_ = ConfigurationPacket< - typename ArchType::ConfRegType>( - 1, - ConfigurationPacket< - typename ArchType::ConfRegType>::Opcode::Write, - ArchType::ConfRegType::FAR, - absl::Span(&frame_address_.value(), 1)); - state_ = State::FrameAddressWritten; - break; - case State::FrameAddressWritten: - packet_ = ConfigurationPacket< - typename ArchType::ConfRegType>( - 1, - ConfigurationPacket< - typename ArchType::ConfRegType>::Opcode::Write, - ArchType::ConfRegType::FDRI, frame_cur_->second); - state_ = State::FrameDataWritten; - break; - case State::ZeroPadWritten: - if (--zero_pad_packets_to_write_ == 1) { - ++frame_cur_; - state_ = State::Start; - } - break; - case State::Finished: - break; - } - - return *this; -} - -template ConfigurationPacketizer::ConfigurationPacketizer( - const Configuration& config); -template ConfigurationPacketizer::iterator -ConfigurationPacketizer::begin() const; -template ConfigurationPacketizer::iterator -ConfigurationPacketizer::end() const; -template const ConfigurationPacket& - ConfigurationPacketizer::iterator::operator*() const; -template const ConfigurationPacket* - ConfigurationPacketizer::iterator::operator->() const; -template bool ConfigurationPacketizer::iterator::operator==( - const ConfigurationPacketizer::iterator& other) const; -template bool ConfigurationPacketizer::iterator::operator!=( - const ConfigurationPacketizer::iterator& other) const; -} // namespace xilinx -} // namespace prjxray diff --git a/lib/xilinx/tests/xc7series/configuration_packetizer_test.cc b/lib/xilinx/tests/xc7series/configuration_packetizer_test.cc deleted file mode 100644 index 48cbb440..00000000 --- a/lib/xilinx/tests/xc7series/configuration_packetizer_test.cc +++ /dev/null @@ -1,119 +0,0 @@ -#include -#include - -#include - -#include -#include - -using namespace prjxray::xilinx; - -TEST(ConfigurationPacketizerTest, EmptyConfigGeneratesNoPackets) { - auto part = xc7series::Part::FromFile("configuration_test.yaml"); - ASSERT_TRUE(part); - - std::map> frames; - Configuration config(*part, &frames); - ConfigurationPacketizer packetizer(config); - - EXPECT_EQ(packetizer.begin(), packetizer.end()); -} - -TEST(ConfigurationPacketizerTest, ConfigWithFramesGeneratesPackets) { - auto part = xc7series::Part::FromFile("configuration_test.yaml"); - ASSERT_TRUE(part); - - std::map> frames; - frames[0] = std::vector(101, 0xAA); - frames[1] = std::vector(101, 0xBB); - - Configuration config(*part, &frames); - - EXPECT_EQ(config.frames().at(0), frames[0]); - EXPECT_EQ(config.frames().at(1), frames[1]); - - ConfigurationPacketizer packetizer(config); - - auto packet = packetizer.begin(); - ASSERT_NE(packet, packetizer.end()); - - // Write 0x0 to FAR - EXPECT_EQ(packet->header_type(), static_cast(1)); - EXPECT_EQ(packet->opcode(), - ConfigurationPacket::Opcode::Write); - EXPECT_EQ(packet->address(), Series7::ConfRegType::FAR); - EXPECT_EQ(packet->data(), std::vector{0}); - - ++packet; - ASSERT_NE(packet, packetizer.end()); - EXPECT_EQ(packet->header_type(), static_cast(1)); - EXPECT_EQ(packet->opcode(), - ConfigurationPacket::Opcode::Write); - EXPECT_EQ(packet->address(), Series7::ConfRegType::FDRI); - EXPECT_EQ(packet->data(), frames[0]); - - ++packet; - ASSERT_NE(packet, packetizer.end()); - EXPECT_EQ(packet->header_type(), static_cast(1)); - EXPECT_EQ(packet->opcode(), - ConfigurationPacket::Opcode::Write); - EXPECT_EQ(packet->address(), Series7::ConfRegType::FAR); - EXPECT_EQ(packet->data(), std::vector{1}); - - ++packet; - ASSERT_NE(packet, packetizer.end()); - EXPECT_EQ(packet->header_type(), static_cast(1)); - EXPECT_EQ(packet->opcode(), - ConfigurationPacket::Opcode::Write); - EXPECT_EQ(packet->address(), Series7::ConfRegType::FDRI); - EXPECT_EQ(packet->data(), frames[1]); - - ++packet; - EXPECT_EQ(packet, packetizer.end()); -} - -TEST(ConfigurationPacketizerTest, ConfigWithFrameAtEndOfRowGeneratesZerofill) { - auto part = xc7series::Part::FromFile("configuration_test.yaml"); - ASSERT_TRUE(part); - - xc7series::FrameAddress last_frame_in_first_row( - xc7series::BlockType::CLB_IO_CLK, false, 0, 43, 41); - - std::map> frames; - frames[last_frame_in_first_row] = std::vector(101, 0xAA); - - Configuration config(*part, &frames); - ConfigurationPacketizer packetizer(config); - - auto packet = packetizer.begin(); - ASSERT_NE(packet, packetizer.end()); - - EXPECT_EQ(packet->header_type(), static_cast(1)); - EXPECT_EQ(packet->opcode(), - ConfigurationPacket::Opcode::Write); - EXPECT_EQ(packet->address(), Series7::ConfRegType::FAR); - EXPECT_EQ(packet->data(), - std::vector{last_frame_in_first_row}); - - ++packet; - ASSERT_NE(packet, packetizer.end()); - EXPECT_EQ(packet->header_type(), static_cast(1)); - EXPECT_EQ(packet->opcode(), - ConfigurationPacket::Opcode::Write); - EXPECT_EQ(packet->address(), Series7::ConfRegType::FDRI); - EXPECT_EQ(packet->data(), frames[last_frame_in_first_row]); - - for (int ii = 0; ii < 202; ++ii) { - ++packet; - ASSERT_NE(packet, packetizer.end()); - EXPECT_EQ(packet->header_type(), static_cast(0)); - EXPECT_EQ( - packet->opcode(), - ConfigurationPacket::Opcode::NOP); - EXPECT_EQ(packet->address(), Series7::ConfRegType::CRC); - EXPECT_EQ(packet->data(), std::vector()); - } - - ++packet; - EXPECT_EQ(packet, packetizer.end()); -}