2019-06-12 23:48:00 -05:00
|
|
|
/**********************************************************
|
|
|
|
* MIT License
|
|
|
|
*
|
|
|
|
* Copyright (c) 2018 LNIS - The University of Utah
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Filename: gsb_graph.h
|
|
|
|
* Created by: Xifan Tang
|
|
|
|
* Change history:
|
|
|
|
* +-------------------------------------+
|
|
|
|
* | Date | Author | Notes
|
|
|
|
* +-------------------------------------+
|
|
|
|
* | 2019/06/12 | Xifan Tang | Created
|
|
|
|
* +-------------------------------------+
|
|
|
|
***********************************************************************/
|
|
|
|
/************************************************************************
|
|
|
|
* This file constains a class to model the connection of a
|
|
|
|
* General Switch Block (GSB), which is a unified block of Connection Blocks
|
|
|
|
* and Switch Blocks.
|
|
|
|
* This block contains
|
|
|
|
* 1. A switch block
|
|
|
|
* 2. A X-direction Connection block locates at the left side of the switch block
|
|
|
|
* 2. A Y-direction Connection block locates at the top side of the switch block
|
|
|
|
*
|
|
|
|
* +---------------------------------+
|
2019-06-17 23:10:30 -05:00
|
|
|
* IPIN_NODES | Y-direction CB | IPIN_NODES
|
2019-06-12 23:48:00 -05:00
|
|
|
* | [x][y + 1] |
|
|
|
|
* +---------------------------------+
|
|
|
|
*
|
2019-06-17 23:10:30 -05:00
|
|
|
* IPIN_NODES TOP SIDE
|
2019-06-12 23:48:00 -05:00
|
|
|
* +-------------+ +---------------------------------+
|
|
|
|
* | | | OPIN_NODE CHAN_NODES OPIN_NODES |
|
|
|
|
* | | | |
|
|
|
|
* | | | OPIN_NODES OPIN_NODES |
|
|
|
|
* | X-direction | | |
|
|
|
|
* | CB | LEFT SIDE | Switch Block | RIGHT SIDE
|
|
|
|
* | [x][y] | | [x][y] |
|
|
|
|
* | | | |
|
|
|
|
* | | | CHAN_NODES CHAN_NODES |
|
|
|
|
* | | | |
|
|
|
|
* | | | OPIN_NODES OPIN_NODES |
|
|
|
|
* | | | |
|
|
|
|
* | | | OPIN_NODE CHAN_NODES OPIN_NODES |
|
|
|
|
* +-------------+ +---------------------------------+
|
2019-06-17 23:10:30 -05:00
|
|
|
* IPIN_NODES BOTTOM SIDE
|
2019-06-12 23:48:00 -05:00
|
|
|
*
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
/* IMPORTANT:
|
|
|
|
* The following preprocessing flags are added to
|
|
|
|
* avoid compilation error when this headers are included in more than 1 times
|
|
|
|
*/
|
|
|
|
#ifndef GSB_GRAPH_H
|
|
|
|
#define GSB_GRAPH_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Notes in include header files in a head file
|
|
|
|
* Only include the neccessary header files
|
|
|
|
* that is required by the data types in the function/class declarations!
|
|
|
|
*/
|
|
|
|
/* Header files should be included in a sequence */
|
|
|
|
/* Standard header files required go first */
|
|
|
|
#include <vector>
|
|
|
|
|
2019-06-13 15:42:39 -05:00
|
|
|
/* External library header files */
|
|
|
|
#include "vtr_vector.h"
|
|
|
|
#include "vtr_range.h"
|
|
|
|
|
2019-06-12 23:48:00 -05:00
|
|
|
#include "device_coordinator.h"
|
|
|
|
#include "vpr_types.h"
|
2019-06-13 15:42:39 -05:00
|
|
|
#include "rr_graph_fwd.h"
|
|
|
|
|
|
|
|
/* Define open nodes */
|
|
|
|
#define OPEN_NODE_ID RRNodeId(-1)
|
|
|
|
#define OPEN_EDGE_ID RREdgeId(-1)
|
2019-06-17 23:10:30 -05:00
|
|
|
#define OPEN_SEGMENT_ID RRSegmentId(-1)
|
2019-06-12 23:48:00 -05:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* This data structure focuses on modeling the internal pin-to-pin connections.
|
|
|
|
* It is basically a collection of nodes and edges.
|
|
|
|
* To make the data structure general, the nodes and edges are not linked to any another data
|
|
|
|
* structures.
|
|
|
|
*
|
2019-06-13 15:42:39 -05:00
|
|
|
* node_ids_: a collection of nodes (basically ids) modelling routing tracks
|
|
|
|
* which locate at each side of the GSB <0..num_nodes_per_side-1>
|
2019-06-12 23:48:00 -05:00
|
|
|
*
|
2019-06-13 15:42:39 -05:00
|
|
|
* node_directions_: Indicate if this node is an input or an output of the GSB
|
|
|
|
* <0..num_nodes_per_side-1>
|
2019-06-12 23:48:00 -05:00
|
|
|
*
|
2019-06-13 15:42:39 -05:00
|
|
|
* node_types_: specify the types of the node, CHANX|CHANY|IPIN|OPIN
|
2019-06-12 23:48:00 -05:00
|
|
|
*
|
2019-06-13 15:42:39 -05:00
|
|
|
* node_sides_: specify the sides of the node on a GSB, TOP|RIGHT|BOTTOM|LEFT
|
2019-06-12 23:48:00 -05:00
|
|
|
*
|
2019-06-13 15:42:39 -05:00
|
|
|
* node_grid_sides_: specify the side of the node on which side of a GRID
|
2019-06-12 23:48:00 -05:00
|
|
|
* for CHANX and CHANY, it is an invalid value
|
2019-06-13 15:42:39 -05:00
|
|
|
* <0..num_nodes_per_side-1>
|
|
|
|
*
|
|
|
|
* node_in_edges_: indcies of input edges of a node
|
|
|
|
* <0..num_nodes><0..num_input_edgess-1>
|
2019-06-12 23:48:00 -05:00
|
|
|
*
|
2019-06-13 15:42:39 -05:00
|
|
|
* node_out_edges_: indcies of output edges of a node
|
|
|
|
* <0..num_nodes><0..num_output_edges-1>
|
|
|
|
*
|
|
|
|
* edge_ids_: a collection of indices of edges, <0..num_edges-1>, which connects the nodes
|
2019-06-12 23:48:00 -05:00
|
|
|
*
|
2019-06-13 15:42:39 -05:00
|
|
|
* edge_src_nodes_: indcies of input nodes of an edge (driving nodes for each edge)
|
|
|
|
* <0..num_input_nodes-1>
|
2019-06-12 23:48:00 -05:00
|
|
|
*
|
2019-06-13 15:42:39 -05:00
|
|
|
* edge_sink_nodes_: indices of output nodes of an edge (fan-out nodes for each edge)
|
|
|
|
* <0..num_output_nodes-1>
|
2019-06-12 23:48:00 -05:00
|
|
|
*
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
class GSBGraph {
|
2019-06-13 15:42:39 -05:00
|
|
|
public: /* Types */
|
|
|
|
typedef vtr::vector<RRNodeId, RRNodeId>::const_iterator node_iterator;
|
|
|
|
typedef vtr::vector<RREdgeId, RREdgeId>::const_iterator edge_iterator;
|
|
|
|
typedef vtr::Range<node_iterator> node_range;
|
|
|
|
typedef vtr::Range<edge_iterator> edge_range;
|
2019-06-12 23:48:00 -05:00
|
|
|
public: /* Constructors */
|
|
|
|
GSBGraph(const GSBGraph&); /* A constructor to duplicate */
|
|
|
|
GSBGraph();
|
2019-06-13 15:42:39 -05:00
|
|
|
public: /* Accessors */
|
|
|
|
/* Aggregates */
|
|
|
|
node_range nodes() const;
|
|
|
|
edge_range edges() const;
|
2019-06-17 23:10:30 -05:00
|
|
|
public: /* Coordinator generation */
|
|
|
|
public: /* Accessors */
|
|
|
|
public: /* Mutators */
|
2019-06-12 23:48:00 -05:00
|
|
|
private: /* Internal Data */
|
|
|
|
/* Coordinator of this GSB */
|
|
|
|
DeviceCoordinator coordinator_;
|
|
|
|
|
|
|
|
/* nodes on each side */
|
2019-06-13 15:42:39 -05:00
|
|
|
vtr::vector<RRNodeId, RRNodeId> node_ids_;
|
|
|
|
vtr::vector<RRNodeId, t_rr_type> node_types_;
|
|
|
|
vtr::vector<RRNodeId, enum e_side> node_sides_;
|
|
|
|
vtr::vector<RRNodeId, enum e_direction> node_directions_;
|
|
|
|
vtr::vector<RRNodeId, enum e_side> node_grid_sides_;
|
2019-06-17 23:10:30 -05:00
|
|
|
vtr::vector<RRNodeId, RRSegmentId> node_segment_ids_;
|
2019-06-13 15:42:39 -05:00
|
|
|
|
|
|
|
vtr::vector<RRNodeId, std::vector<RREdgeId>> node_in_edges;
|
|
|
|
vtr::vector<RRNodeId, std::vector<RREdgeId>> node_out_edges;
|
|
|
|
|
2019-06-12 23:48:00 -05:00
|
|
|
/* edges */
|
2019-06-13 15:42:39 -05:00
|
|
|
vtr::vector<RREdgeId, RREdgeId> edge_ids_;
|
|
|
|
vtr::vector<RREdgeId, RREdgeId> edge_src_nodes_; /* each element is a node_id */
|
|
|
|
vtr::vector<RREdgeId, RREdgeId> edge_sink_nodes_; /* each element is a node_id */
|
2019-06-17 23:10:30 -05:00
|
|
|
|
|
|
|
/* fast look-up [node_side][node_type][node_id] */
|
|
|
|
typedef std::vector< std::vector< std::vector<RRNodeId> > > NodeLookup;
|
|
|
|
mutable NodeLookup node_lookup_;
|
2019-06-12 23:48:00 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|