mirror of https://github.com/openXC7/prjxray.git
lib: xc7series: verify bitstream variants parse to same configurations
Normal, debug, and per-frame CRC bitstreams differ in the commands used to write the frame data but should generate equivalent configurations. Note that this currently fails as something is wrong with normal bitstream parsing. Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
This commit is contained in:
parent
0d2c33bf0f
commit
6ba411294e
|
|
@ -62,7 +62,8 @@ if (PRJXRAY_BUILD_TESTING)
|
|||
target_link_libraries(xilinx_xc7series_configuration_test
|
||||
libprjxray gtest_main absl::span)
|
||||
add_test(NAME xilinx_xc7series_configuration_test
|
||||
COMMAND xilinx_xc7series_configuration_test)
|
||||
COMMAND xilinx_xc7series_configuration_test
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test_data)
|
||||
|
||||
add_executable(xilinx_xc7series_configuration_packet_test
|
||||
xilinx/xc7series/configuration_packet_test.cc)
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <absl/types/span.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <prjxray/memory_mapped_file.h>
|
||||
#include <prjxray/xilinx/xc7series/configuration_packet.h>
|
||||
#include <prjxray/xilinx/xc7series/configuration_register.h>
|
||||
#include <prjxray/xilinx/xc7series/part.h>
|
||||
|
|
@ -106,6 +107,106 @@ TEST(ConfigurationTest, ConstructFromPacketsWithAutoincrement) {
|
|||
absl::Span<uint32_t> frame_span(frame);
|
||||
EXPECT_EQ(test_config->part().idcode(), static_cast<uint32_t>(0x1234));
|
||||
EXPECT_EQ(test_config->frames().size(), static_cast<size_t>(2));
|
||||
EXPECT_EQ(test_config->frames().at(0x456F), frame_span.subspan(0, 101));
|
||||
EXPECT_EQ(test_config->frames().at(0x4580), frame_span.subspan(101));
|
||||
EXPECT_EQ(test_config->frames().at(0x456F), std::vector<uint32_t>(101, 0xAA));
|
||||
EXPECT_EQ(test_config->frames().at(0x4580), std::vector<uint32_t>(101, 0xBB));
|
||||
}
|
||||
|
||||
TEST(ConfigurationTest, DebugAndPerFrameCrcBitstreamsProduceEqualConfigurations) {
|
||||
auto part = xc7series::Part::FromFile("configuration_test.yaml");
|
||||
ASSERT_TRUE(part);
|
||||
|
||||
auto debug_bitstream = prjxray::MemoryMappedFile::InitWithFile(
|
||||
"configuration_test.debug.bit");
|
||||
ASSERT_TRUE(debug_bitstream);
|
||||
|
||||
auto debug_reader = xc7series::BitstreamReader::InitWithBytes(
|
||||
debug_bitstream->as_bytes());
|
||||
ASSERT_TRUE(debug_reader);
|
||||
|
||||
auto debug_configuration = xc7series::Configuration::InitWithPackets(
|
||||
*part, *debug_reader);
|
||||
ASSERT_TRUE(debug_configuration);
|
||||
|
||||
auto perframecrc_bitstream = prjxray::MemoryMappedFile::InitWithFile(
|
||||
"configuration_test.perframecrc.bit");
|
||||
ASSERT_TRUE(perframecrc_bitstream);
|
||||
|
||||
auto perframecrc_reader = xc7series::BitstreamReader::InitWithBytes(
|
||||
perframecrc_bitstream->as_bytes());
|
||||
ASSERT_TRUE(perframecrc_reader);
|
||||
|
||||
auto perframecrc_configuration = xc7series::Configuration::InitWithPackets(
|
||||
*part, *perframecrc_reader);
|
||||
ASSERT_TRUE(perframecrc_configuration);
|
||||
|
||||
for (auto debug_frame : debug_configuration->frames()) {
|
||||
auto perframecrc_frame = perframecrc_configuration->frames().find(debug_frame.first);
|
||||
if (perframecrc_frame == perframecrc_configuration->frames().end()) {
|
||||
ADD_FAILURE() << debug_frame.first << ": missing in perframecrc bitstream";
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int ii = 0; ii < 101; ++ii) {
|
||||
EXPECT_EQ(perframecrc_frame->second[ii], debug_frame.second[ii])
|
||||
<< debug_frame.first << ": word " << ii;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto perframecrc_frame : perframecrc_configuration->frames()) {
|
||||
auto debug_frame = debug_configuration->frames().find(perframecrc_frame.first);
|
||||
if (debug_frame == debug_configuration->frames().end()) {
|
||||
ADD_FAILURE() << perframecrc_frame.first
|
||||
<< ": unexpectedly present in perframecrc bitstream";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ConfigurationTest, DebugAndNormalBitstreamsProduceEqualConfigurations) {
|
||||
auto part = xc7series::Part::FromFile("configuration_test.yaml");
|
||||
ASSERT_TRUE(part);
|
||||
|
||||
auto debug_bitstream = prjxray::MemoryMappedFile::InitWithFile(
|
||||
"configuration_test.debug.bit");
|
||||
ASSERT_TRUE(debug_bitstream);
|
||||
|
||||
auto debug_reader = xc7series::BitstreamReader::InitWithBytes(
|
||||
debug_bitstream->as_bytes());
|
||||
ASSERT_TRUE(debug_reader);
|
||||
|
||||
auto debug_configuration = xc7series::Configuration::InitWithPackets(
|
||||
*part, *debug_reader);
|
||||
ASSERT_TRUE(debug_configuration);
|
||||
|
||||
auto normal_bitstream = prjxray::MemoryMappedFile::InitWithFile(
|
||||
"configuration_test.bit");
|
||||
ASSERT_TRUE(normal_bitstream);
|
||||
|
||||
auto normal_reader = xc7series::BitstreamReader::InitWithBytes(
|
||||
normal_bitstream->as_bytes());
|
||||
ASSERT_TRUE(normal_reader);
|
||||
|
||||
auto normal_configuration = xc7series::Configuration::InitWithPackets(
|
||||
*part, *normal_reader);
|
||||
ASSERT_TRUE(normal_configuration);
|
||||
|
||||
for (auto debug_frame : debug_configuration->frames()) {
|
||||
auto normal_frame = normal_configuration->frames().find(debug_frame.first);
|
||||
if (normal_frame == normal_configuration->frames().end()) {
|
||||
ADD_FAILURE() << debug_frame.first << ": missing in normal bitstream";
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int ii = 0; ii < 101; ++ii) {
|
||||
EXPECT_EQ(normal_frame->second[ii], debug_frame.second[ii])
|
||||
<< debug_frame.first << ": word " << ii;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto normal_frame : normal_configuration->frames()) {
|
||||
auto debug_frame = debug_configuration->frames().find(normal_frame.first);
|
||||
if (debug_frame == debug_configuration->frames().end()) {
|
||||
ADD_FAILURE() << normal_frame.first
|
||||
<< ": unexpectedly present in normal bitstream";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue