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() {
}
If we needed to modify the placement (e.g. we were implementing another placement algorithm) we would do:
void my_placement_algorithm() {
}
- Note
- The returned contexts are not copyable, so they must be taken by reference.