Skip to content

Commit

Permalink
check: Assert edges data is not out-of-bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
povik committed Feb 12, 2024
1 parent 28fe02f commit 54c12bd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions passes/cmds/check.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,12 @@ struct CheckPass : public Pass {

void add_edge(RTLIL::Cell *cell, RTLIL::IdString from_port, int from_bit,
RTLIL::IdString to_port, int to_bit, int) override {
SigBit from = sigmap(cell->getPort(from_port))[from_bit];
SigBit to = sigmap(cell->getPort(to_port))[to_bit];
SigSpec from_portsig = cell->getPort(from_port);
SigSpec to_portsig = cell->getPort(to_port);
log_assert(from_bit >= 0 && from_bit < from_portsig.size());
log_assert(to_bit >= 0 && to_bit < to_portsig.size());
SigBit from = sigmap(from_portsig[from_bit]);
SigBit to = sigmap(to_portsig[to_bit]);

if (from.wire && to.wire)
topo.edge(std::make_pair(from.wire->name, from.offset), std::make_pair(to.wire->name, to.offset));
Expand Down

0 comments on commit 54c12bd

Please sign in to comment.