Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bitread: Don't overwrite last frame #1335

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/include/prjxray/xilinx/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ Configuration<ArchType>::InitWithPackets(const typename ArchType::Part& part,
typename ArchType::FrameAddress current_frame_address = 0;

Configuration<ArchType>::FrameMap frames;
bool configuration_data_end = false;
for (auto packet : packets) {
if (packet.opcode() !=
ConfigurationPacket<
Expand Down Expand Up @@ -305,6 +306,8 @@ Configuration<ArchType>::InitWithPackets(const typename ArchType::Part& part,
frame_address_register;
start_new_write = false;
}
if (configuration_data_end)
break;

// Number of words in configuration frames
// depend on tje architecture. Writes to this
Expand All @@ -319,8 +322,10 @@ Configuration<ArchType>::InitWithPackets(const typename ArchType::Part& part,
auto next_address =
part.GetNextFrameAddress(
current_frame_address);
if (!next_address)
if (!next_address) {
configuration_data_end = true;
break;
}

// Bitstreams appear to have 2 frames of
// padding between rows.
Expand Down
Binary file added lib/test_data/configuration_test_type_1.bit
Binary file not shown.
20 changes: 20 additions & 0 deletions lib/xilinx/tests/xc7series/configuration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,23 @@ TEST(ConfigurationTest, CheckForPaddingFrames) {
EXPECT_EQ(frame.second, frames.getFrames().at(frame.first));
}
}

TEST(ConfigurationTest, CheckLastFrameOverwrite) {
auto part = xc7series::Part::FromFile("configuration_test.yaml");
ASSERT_TRUE(part);
auto normal_bitstream = prjxray::MemoryMappedFile::InitWithFile(
"configuration_test_type_1.bit");
ASSERT_TRUE(normal_bitstream);

auto normal_reader = BitstreamReader<Series7>::InitWithBytes(
normal_bitstream->as_bytes());
ASSERT_TRUE(normal_reader);

auto normal_configuration =
Configuration<Series7>::InitWithPackets(*part, *normal_reader);
ASSERT_TRUE(normal_configuration);

auto& frames = normal_configuration->frames();
auto& last_frame = *frames.rbegin();
EXPECT_EQ(last_frame.second.at(4), 0x8000);
}