Skip to content

Commit 84b5ec8

Browse files
authored
Merge pull request #4320 from YosysHQ/ywb_asserts
write_btor: Include `$assert` and `$assume` cells in -ywmap output
2 parents 9570b39 + 1a0b5d8 commit 84b5ec8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

backends/btor/btor.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ struct BtorWorker
9898
vector<ywmap_btor_sig> ywmap_states;
9999
dict<SigBit, int> ywmap_clock_bits;
100100
dict<SigBit, int> ywmap_clock_inputs;
101+
vector<Cell *> ywmap_asserts;
102+
vector<Cell *> ywmap_assumes;
101103

102104

103105
PrettyJson ywmap_json;
@@ -1280,6 +1282,8 @@ struct BtorWorker
12801282
btorf("%d or %d %d %d\n", nid_a_or_not_en, sid, nid_a, nid_not_en);
12811283
btorf("%d constraint %d\n", nid, nid_a_or_not_en);
12821284

1285+
if (ywmap_json.active()) ywmap_assumes.emplace_back(cell);
1286+
12831287
btorf_pop(log_id(cell));
12841288
}
12851289

@@ -1304,6 +1308,8 @@ struct BtorWorker
13041308
} else {
13051309
int nid = next_nid++;
13061310
btorf("%d bad %d%s\n", nid, nid_en_and_not_a, getinfo(cell, true));
1311+
1312+
if (ywmap_json.active()) ywmap_asserts.emplace_back(cell);
13071313
}
13081314
}
13091315

@@ -1461,6 +1467,7 @@ struct BtorWorker
14611467
log_assert(cursor == 0);
14621468
log_assert(GetSize(todo) == 1);
14631469
btorf("%d bad %d\n", nid, todo[cursor]);
1470+
// What do we do with ywmap_asserts when using single_bad?
14641471
}
14651472
}
14661473

@@ -1526,6 +1533,18 @@ struct BtorWorker
15261533
emit_ywmap_btor_sig(entry);
15271534
ywmap_json.end_array();
15281535

1536+
ywmap_json.name("asserts");
1537+
ywmap_json.begin_array();
1538+
for (Cell *cell : ywmap_asserts)
1539+
ywmap_json.value(witness_path(cell));
1540+
ywmap_json.end_array();
1541+
1542+
ywmap_json.name("assumes");
1543+
ywmap_json.begin_array();
1544+
for (Cell *cell : ywmap_assumes)
1545+
ywmap_json.value(witness_path(cell));
1546+
ywmap_json.end_array();
1547+
15291548
ywmap_json.end_object();
15301549
}
15311550
}

0 commit comments

Comments
 (0)