mirror of https://github.com/openXC7/prjxray.git
bittool: command to dump all frame addresses used in a bitstream
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net> Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
This commit is contained in:
parent
7345f2630a
commit
d799da0ad5
|
|
@ -40,9 +40,67 @@ int ListConfigPackets(int argc, char *argv[]) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int DumpDebugbitstreamFrameAddresses(int argc, char *argv[]) {
|
||||
if (argc < 1) {
|
||||
std::cerr << "ERROR: no input specified" << std::endl;
|
||||
std::cerr << "Usage: " << argv[0]
|
||||
<< "dump_debugbitstream_frame_addresses <bit_file>"
|
||||
<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto in_file_name = argv[0];
|
||||
auto in_file = prjxray::MemoryMappedFile::InitWithFile(in_file_name);
|
||||
if (!in_file) {
|
||||
std::cerr << "Unable to open bit file: " << in_file_name
|
||||
<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto in_bytes = absl::Span<uint8_t>(
|
||||
static_cast<uint8_t*>(in_file->data()),
|
||||
in_file->size());
|
||||
auto reader = xc7series::BitstreamReader::InitWithBytes(in_bytes);
|
||||
if (!reader) {
|
||||
std::cerr << "Input doesn't look like a bitstream"
|
||||
<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool found_one_lout = false;
|
||||
for (auto packet : *reader) {
|
||||
if ((packet.opcode() !=
|
||||
xc7series::ConfigurationPacket::Opcode::Write) ||
|
||||
(packet.address() !=
|
||||
xc7series::ConfigurationRegister::LOUT)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (packet.data().size() != 1) {
|
||||
std::cerr << "Write to FAR with word_count != 1"
|
||||
<< std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
found_one_lout = true;
|
||||
std::cout << std::dec << packet.data()[0] << std::endl;
|
||||
}
|
||||
|
||||
if (!found_one_lout) {
|
||||
std::cerr << "No LOUT writes found. Was "
|
||||
<< "BITSTREAM.GENERAL.DEBUGBITSTREAM set to YES?"
|
||||
<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
Action actions[] = {
|
||||
{ "list_config_packets", ListConfigPackets },
|
||||
{ "dump_debugbitstream_frame_addresses",
|
||||
DumpDebugbitstreamFrameAddresses },
|
||||
};
|
||||
|
||||
gflags::SetUsageMessage(
|
||||
|
|
|
|||
Loading…
Reference in New Issue