VPR Context¶
-
class
VprContext: public Context¶ This object encapsulates VPR’s state.
There is typically a single instance which is accessed via the global variable g_vpr_ctx (see globals.h/.cpp).
It is divided up into separate sub-contexts of logically related data structures.
Each sub-context can be accessed via member functions which return a reference to the sub-context:
The default the member function (e.g. device()) return an const (immutable) reference providing read-only access to the context. This should be the preferred form, as the compiler will detect unintentional state changes.
The ‘mutable’ member function (e.g. mutable_device()) will return a non-const (mutable) reference allowing modification of the context. This should only be used on an as-needed basis.
Typical usage in VPR would be to call the appropriate accessor to get a reference to the context of interest, and then operate on it.
For example if we were performing an action which required access to the current placement, we would do:
void my_analysis_algorithm() { //Get read-only access to the placement auto& place_ctx = g_vpr_ctx.placement(); //Do something that depends on (but does not change) //the current placement... }
If we needed to modify the placement (e.g. we were implementing another placement algorithm) we would do:
void my_placement_algorithm() { //Get read-write access to the placement auto& place_ctx = g_vpr_ctx.mutable_placement(); //Do something that modifies the placement //... }
- Note
The returned contexts are not copyable, so they must be taken by reference.
Public Functions
-
const AtomContext &
atom() const¶
-
AtomContext &
mutable_atom()¶
-
const DeviceContext &
device() const¶
-
DeviceContext &
mutable_device()¶
-
const TimingContext &
timing() const¶
-
TimingContext &
mutable_timing()¶
-
const PowerContext &
power() const¶
-
PowerContext &
mutable_power()¶
-
const ClusteringContext &
clustering() const¶
-
ClusteringContext &
mutable_clustering()¶
-
const PlacementContext &
placement() const¶
-
PlacementContext &
mutable_placement()¶
-
const RoutingContext &
routing() const¶
-
RoutingContext &
mutable_routing()¶