Skip to content

Commit

Permalink
Add method to know how many ports are bound (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
furuame authored Nov 9, 2023
1 parent 0d6f518 commit 050a860
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sparta/sparta/ports/Port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ namespace sparta
return (bound_ports_.empty() == false);
}

/**
* \brief How many ports are bound to this port?
* \return The number of bound ports
*/
size_t getNumBoundPorts() const {
return bound_ports_.size();
}

/**
* \brief The direction of the port
* \return In or out
Expand Down
5 changes: 5 additions & 0 deletions sparta/test/Port/Port_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ int main ()
signal_out.bind(signal_in);
delay1_out_non_continuing.bind(delay1_in_non_continuing);

EXPECT_EQUAL(delay0_out.getNumBoundPorts(), 1);
EXPECT_EQUAL(delay0_in.getNumBoundPorts(), 1);
EXPECT_EQUAL(signal_out.getNumBoundPorts(), 1);
EXPECT_EQUAL(signal_in.getNumBoundPorts(), 1);

// Try some binding rules
sparta::SignalInPort signal_bind_in(&ps, "signal_bind_in");
sparta::SignalOutPort signal_bind_out(&ps, "signal_bind_out");
Expand Down

0 comments on commit 050a860

Please sign in to comment.