Contexts

Classes

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.

Structures

struct AtomContext : public Context

State relating to the atom-level netlist.

This should contain only data structures related to user specified netlist being implemented by VPR onto the target device.

This class provides two categories of getter functions that give mutable or immutable reference to the global state. If you need read-only access, use the normal getter functions and if you need write access to the context use the mutable functions.

Public Functions

inline const AtomNetlist &netlist() const

Immutable reference to the AtomNetlist.

inline AtomNetlist &mutable_netlist()

Mutable reference to the AtomNetlist.

inline const AtomLookup &lookup() const

Immutable reference to the AtomLookup.

inline AtomLookup &mutable_lookup()

Mutable reference to the AtomLookup.

inline const FlatPlacementInfo &flat_placement_info() const

Immutable reference to the FlatPlacementInfo.

inline FlatPlacementInfo &mutable_flat_placement_info()

Mutable reference to the FlatPlacementInfo.

struct ClusteringContext : public Context

State relating to clustering.

This should contain only data structures that describe the current clustering/packing, or related clusterer/packer algorithmic state.

Public Members

ClusteredNetlist clb_nlist

New netlist class derived from Netlist.

std::map<ClusterBlockId, std::map<int, ClusterNetId>> post_routing_clb_pin_nets

Database for nets of each clb block pin after routing stage.

  • post_routing_clb_pin_nets: mapping of pb_type pins to clustered net ids.

  • pre_routing_net_pin_mapping: a copy of mapping for current pb_route index to previous pb_route index Record the previous pin mapping for finding the correct pin index during timing analysis.

vtr::vector<ClusterBlockId, std::unordered_set<AtomBlockId>> atoms_lookup

A vector of unordered_sets of AtomBlockIds that are inside each clustered block [0 .. num_clustered_blocks-1] This is populated when the packing is loaded.

struct Context

A Context is collection of state relating to a particular part of VPR.

This is a base class who’s only purpose is to disable copying of contexts. This ensures that attempting to use a context by value (instead of by reference) will result in a compilation error.

No data or member functions should be defined in this class!

Subclassed by APPackContext, AtomContext, ClusteringContext, DeviceContext, FloorplanningContext, NocContext, PackingMultithreadingContext, PlacementContext, PlacerRuntimeContext, PlacerState, PlacerTimingContext, PowerContext, RoutingContext, ServerContext, TimingContext, VprContext

struct DeviceContext : public Context

State relating the device.

This should contain only data structures describing the targeted device.

Public Members

DeviceGrid grid

The device grid.

This represents the physical layout of the device. To get the physical tile at each location (layer_num, x, y) the helper functions in this data structure should be used.

bool has_multiple_equivalent_tiles

Boolean that indicates whether the architecture implements an N:M physical tiles to logical blocks mapping.

t_chan_width chan_width

chan_width is for x|y-directed channels; i.e. between rows

std::vector<t_rr_rc_data> rr_rc_data

Fly-weighted Resistance/Capacitance data for RR Nodes.

std::vector<std::vector<RRNodeId>> rr_non_config_node_sets

Sets of non-configurably connected nodes.

std::unordered_map<RRNodeId, int> rr_node_to_non_config_node_set

Reverse look-up from RR node to non-configurably connected node set (index into rr_non_config_node_sets)

std::vector<std::map<int, int>> switch_fanin_remap

switch_fanin_remap is only used for printing out switch fanin stats (the -switch_stats option)

array index: [0..(num_arch_switches-1)]; map key: num of all possible fanin of that type of switch on chip map value: remapped switch index (index in rr_switch_inf)

std::string loaded_rr_graph_filename

Name of rrgraph file read (if any). Used to determine if the specified rr-graph file is already loaded, so we can avoid redundant reading of the rr-graph.

std::string loaded_rr_edge_override_filename

Name of rrgraph edge override file read (if any). Used to determine if the specified rr-graph edge override file is already loaded, so we can avoid redundant reading of the rr-graph.

struct PlacementContext : public Context

State relating to placement.

This should contain only data structures that describe the current placement, or related placer algorithm state.

Public Functions

void init_placement_context(const t_placer_opts &placer_opts, const std::vector<t_direct_inf> &directs)

Initialize the variables stored within the placement context. This must be called before performing placement, but must be called after the clusters are loaded.

Parameters:
  • placer_opts – The options passed into the placer.

  • directs – A list of the direct connections in the architecture.

void clean_placement_context_post_place()

Clean variables from the placement context which are not used outside of placement.

There are some variables that are stored in the placement context and are only used in placement; while there are some that are used outside of placement. This method frees up the memory of the variables used only within placement.

inline void lock_loc_vars()

Makes blk_loc_registry_ inaccessible through the getter methods.

This method should be called at the beginning of the placement stage to guarantee that the placement stage code does not access block location variables stored in the global state.

inline void unlock_loc_vars()

Makes blk_loc_registry_ accessible through the getter methods.

This method should be called at the end of the placement stage to make the block location information accessible for subsequent stages.

Public Members

std::unique_ptr<PlaceMacros> place_macros

Collection of all the placement macros in the netlist. A placement macro is a set of clustered blocks that must be placed in a way that is compliant with relative locations specified by the macro. Macros are used during placement and are not modified after they are created. This is created at the start of placement.

t_compressed_block_grids compressed_block_grids

Compressed grid space for each block type.

Used to efficiently find logically ‘adjacent’ blocks of the same block type even though the may be physically far apart Indexed with logical block type index: [0…num_logical_block_types-1] -> logical block compressed grid

std::string placement_id

SHA256 digest of the .place file.

Used for unique identification and consistency checking

bool f_placer_debug = false

Use during placement to print extra debug information. It is set to true based on the number assigned to placer_debug_net or placer_debug_block parameters in the command line.

bool cube_bb = false

Set this variable to ture if the type of the bounding box used in placement is of the type cube. If it is false, it would mean that per-layer bounding box is used. For the 2D architecture, the cube bounding box would be used.

struct PowerContext : public Context

State relating to power analysis.

This should contain only data structures related to power analysis, or related power analysis algorithmic state.

Public Members

std::unordered_map<AtomNetId, t_net_power> atom_net_power

Atom net power info.

struct RoutingContext : public Context

State relating to routing.

This should contain only data structures that describe the current routing implementation, or related router algorithmic state.

Public Members

vtr::dynamic_bitset<RRNodeId> non_configurable_bitset

Information about whether a node is part of a non-configurable set.

(i.e. connected to others with non-configurable edges like metal shorts that can’t be disabled) Stored in a single bit per rr_node for efficiency bit value 0: node is not part of a non-configurable set bit value 1: node is part of a non-configurable set Initialized once when RoutingContext is initialized, static throughout invocation of router

t_net_routing_status net_status

Information about current routing status of each net.

vtr::vector<ParentNetId, t_bb> route_bb

Limits area within which each net must be routed.

std::string routing_id

SHA256 digest of the .route file.

Used for unique identification and consistency checking

vtr::Cache<std::tuple<e_router_lookahead, std::string, std::vector<t_segment_inf>>, RouterLookahead> cached_router_lookahead_

Cache of router lookahead object.

Cache key: (lookahead type, read lookahead (if any), segment definitions).

UserRouteConstraints constraints

User specified routing constraints.

bool is_flat

Is flat routing enabled?

struct TimingContext : public Context

State relating to timing.

This should contain only data structures related to timing analysis, or related timing analysis algorithmic state.

Public Members

std::shared_ptr<tatum::TimingGraph> graph

The current timing graph.

This represents the timing dependencies between pins of the atom netlist

std::shared_ptr<tatum::TimingConstraints> constraints

The current timing constraints, as loaded from an SDC file (or set by default).

These specify how timing analysis is performed (e.g. target clock periods)

struct ServerContext : public Context

State relating to server mode.

This should contain only data structures that relate to the vpr server state.

Public Members

server::GateIO gate_io

server::GateIO.

server::TaskResolver task_resolver

server::TaskResolver.

std::vector<tatum::TimingPath> crit_paths

Stores the critical path items.

This value is used when rendering the critical path by the selected index. Once calculated upon request, it provides the value for a specific critical path to be rendered upon user request.

std::map<std::size_t, std::set<std::size_t>> crit_path_element_indexes

Stores the selected critical path elements.

This value is used to render the selected critical path elements upon client request. The std::map key plays role of path index, where the element indexes are stored as std::set.

bool draw_crit_path_contour = false

Stores the flag indicating whether to draw the critical path contour.

If True, the entire path will be rendered with some level of transparency, regardless of the selection of path elements. However, selected path elements will be drawn in full color. This feature is helpful in visual debugging, to see how the separate path elements are mapped into the whole path.

std::shared_ptr<SetupHoldTimingInfo> timing_info

Reference to the SetupHoldTimingInfo calculated during the routing stage.

std::shared_ptr<PostClusterDelayCalculator> routing_delay_calc

Reference to the PostClusterDelayCalculator calculated during the routing stage.