Refactor Configuration::createType2ConfigurationPacketData template method

Signed-off-by: Tomasz Michalak <tmichalak@antmicro.com>
This commit is contained in:
Tomasz Michalak 2019-10-17 22:12:20 +02:00
parent d91b0a5006
commit 170169b01c
2 changed files with 29 additions and 74 deletions

View File

@ -65,6 +65,35 @@ class Configuration {
FrameMap frames_;
};
template <typename ArchType>
typename Configuration<ArchType>::PacketData
Configuration<ArchType>::createType2ConfigurationPacketData(
const typename Frames<ArchType>::Frames2Data& frames,
absl::optional<typename ArchType::Part>& part) {
PacketData packet_data;
// Certain configuration frames blocks are separated by Zero Frames,
// i.e. frames with words with all zeroes. For Series-7, US and US+
// there zero frames separator consists of two frames.
static const int kZeroFramesSeparatorWords =
ArchType::words_per_frame * 2;
for (auto& frame : frames) {
std::copy(frame.second.begin(), frame.second.end(),
std::back_inserter(packet_data));
auto next_address = part->GetNextFrameAddress(frame.first);
if (next_address &&
(next_address->block_type() != frame.first.block_type() ||
next_address->is_bottom_half_rows() !=
frame.first.is_bottom_half_rows() ||
next_address->row() != frame.first.row())) {
packet_data.insert(packet_data.end(),
kZeroFramesSeparatorWords, 0);
}
}
packet_data.insert(packet_data.end(), kZeroFramesSeparatorWords, 0);
return packet_data;
}
template <typename ArchType>
template <typename Collection>
absl::optional<Configuration<ArchType>>

View File

@ -18,80 +18,6 @@
namespace prjxray {
namespace xilinx {
template <>
Configuration<Series7>::PacketData
Configuration<Series7>::createType2ConfigurationPacketData(
const Frames<Series7>::Frames2Data& frames,
absl::optional<Series7::Part>& part) {
PacketData packet_data;
for (auto& frame : frames) {
std::copy(frame.second.begin(), frame.second.end(),
std::back_inserter(packet_data));
auto next_address = part->GetNextFrameAddress(frame.first);
if (next_address &&
(next_address->block_type() != frame.first.block_type() ||
next_address->is_bottom_half_rows() !=
frame.first.is_bottom_half_rows() ||
next_address->row() != frame.first.row())) {
packet_data.insert(packet_data.end(), 202, 0);
}
}
packet_data.insert(packet_data.end(), 202, 0);
return packet_data;
}
template <>
Configuration<UltraScale>::PacketData
Configuration<UltraScale>::createType2ConfigurationPacketData(
const Frames<UltraScale>::Frames2Data& frames,
absl::optional<UltraScale::Part>& part) {
PacketData packet_data;
for (auto& frame : frames) {
std::copy(frame.second.begin(), frame.second.end(),
std::back_inserter(packet_data));
auto next_address = part->GetNextFrameAddress(frame.first);
if (next_address &&
(next_address->block_type() != frame.first.block_type() ||
next_address->is_bottom_half_rows() !=
frame.first.is_bottom_half_rows() ||
next_address->row() != frame.first.row())) {
packet_data.insert(packet_data.end(),
UltraScale::words_per_frame * 2, 0);
}
}
packet_data.insert(packet_data.end(), UltraScale::words_per_frame * 2,
0);
return packet_data;
}
template <>
Configuration<UltraScalePlus>::PacketData
Configuration<UltraScalePlus>::createType2ConfigurationPacketData(
const Frames<UltraScalePlus>::Frames2Data& frames,
absl::optional<UltraScalePlus::Part>& part) {
PacketData packet_data;
for (auto& frame : frames) {
std::copy(frame.second.begin(), frame.second.end(),
std::back_inserter(packet_data));
auto next_address = part->GetNextFrameAddress(frame.first);
if (next_address &&
(next_address->block_type() != frame.first.block_type() ||
next_address->is_bottom_half_rows() !=
frame.first.is_bottom_half_rows() ||
next_address->row() != frame.first.row())) {
packet_data.insert(packet_data.end(),
UltraScalePlus::words_per_frame * 2,
0);
}
}
packet_data.insert(packet_data.end(),
UltraScalePlus::words_per_frame * 2, 0);
return packet_data;
}
template <>
void Configuration<Series7>::createConfigurationPackage(
Series7::ConfigurationPackage& out_packets,