Skip to content

Commit

Permalink
Add debugging to segmatch
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Michalak <tmichalak@antmicro.com>
  • Loading branch information
tmichalak committed Dec 14, 2022
1 parent 7800bcb commit 5db9cc8
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions tools/segmatch.cc
Expand Up @@ -223,9 +223,9 @@ void read_input(std::istream& f, std::string filename) {
abort();
}

// printf("Number of segments: %d\n", int(segdata.size()));
// printf("Number of bits: %d\n", num_bits);
// printf("Number of tags: %d\n", num_tags);
printf("Number of segments: %d\n", int(segdata.size()));
printf("Number of bits: %d\n", num_bits);
printf("Number of tags: %d\n", num_tags);

for (auto& segdat : segdata) {
segdata_bits(segdat.second).resize(num_bits);
Expand Down Expand Up @@ -279,26 +279,48 @@ int main(int argc, char** argv) {

std::vector<std::string> out_lines;

for (int tag_idx = 0; tag_idx < num_tags; tag_idx++) {
int searched_tag = tag_ids.at("IOB18.IOB_Y0.SSTL135.IN");
for (int tag_idx = searched_tag; tag_idx <= searched_tag ; tag_idx++) {
bool_vec mask(num_bits, true);
int count1 = 0, count0 = 0;
std::cout << tag_ids_r.at(tag_idx) << ": " << tag_idx;

for (auto& segdat : segdata) {
std::cout << "Segment: " << segdat.first << std::endl;

auto& sd = segdat.second;
bool tag1 = segdata_tags1(sd).get(tag_idx);
bool tag0 = segdata_tags0(sd).get(tag_idx);

assert(!tag1 || !tag0);
for (int bit_idx = 0; bit_idx < num_bits; bit_idx++) {
if (tag1 && segdata_bits(sd).get(bit_idx)) {
std::cout << bit_ids_r.at(bit_idx) << std::endl;
}
}

if (tag1) {
count1++;
mask.apply_and(segdata_bits(sd));
std::cout << "Resulting mask(tag1): ";
for (int bit_idx = 0; bit_idx < num_bits; bit_idx++) {
if (tag1 && mask.get(bit_idx)) {
std::cout <<bit_ids_r.at(bit_idx) << " ";
}
}
std::cout << std::endl;
continue;
}

if (tag0) {
count0++;
mask.apply_andc(segdata_bits(sd));
std::cout << "Resulting mask(tag0): ";
for (int bit_idx = 0; bit_idx < num_bits; bit_idx++) {
if (tag1 && mask.get(bit_idx)) {
std::cout <<bit_ids_r.at(bit_idx) << " ";
}
}
std::cout << std::endl;
continue;
}
}
Expand Down

0 comments on commit 5db9cc8

Please sign in to comment.