add tile direct data structure
This commit is contained in:
parent
59c13550e0
commit
7e86cf1079
|
@ -0,0 +1,102 @@
|
|||
/******************************************************************************
|
||||
* Memember functions for data structure TileDirect
|
||||
******************************************************************************/
|
||||
#include "vtr_assert.h"
|
||||
|
||||
#include "tile_direct.h"
|
||||
|
||||
/* begin namespace openfpga */
|
||||
namespace openfpga {
|
||||
|
||||
/**************************************************
|
||||
* Public Accessors
|
||||
*************************************************/
|
||||
TileDirect::tile_direct_range TileDirect::directs() const {
|
||||
return vtr::make_range(direct_ids_.begin(), direct_ids_.end());
|
||||
}
|
||||
|
||||
t_physical_tile_type_ptr TileDirect::from_tile(const TileDirectId& direct_id) const {
|
||||
/* Validate the direct_id */
|
||||
VTR_ASSERT(valid_direct_id(direct_id));
|
||||
return from_tiles_[direct_id];
|
||||
}
|
||||
|
||||
vtr::Point<size_t> TileDirect::from_tile_coordinate(const TileDirectId& direct_id) const {
|
||||
/* Validate the direct_id */
|
||||
VTR_ASSERT(valid_direct_id(direct_id));
|
||||
return from_tile_coords_[direct_id];
|
||||
}
|
||||
|
||||
size_t TileDirect::from_tile_pin(const TileDirectId& direct_id) const {
|
||||
/* Validate the direct_id */
|
||||
VTR_ASSERT(valid_direct_id(direct_id));
|
||||
return from_tile_pins_[direct_id];
|
||||
}
|
||||
|
||||
e_side TileDirect::from_tile_side(const TileDirectId& direct_id) const {
|
||||
/* Validate the direct_id */
|
||||
VTR_ASSERT(valid_direct_id(direct_id));
|
||||
return from_tile_sides_[direct_id];
|
||||
}
|
||||
|
||||
t_physical_tile_type_ptr TileDirect::to_tile(const TileDirectId& direct_id) const {
|
||||
/* Validate the direct_id */
|
||||
VTR_ASSERT(valid_direct_id(direct_id));
|
||||
return to_tiles_[direct_id];
|
||||
}
|
||||
|
||||
vtr::Point<size_t> TileDirect::to_tile_coordinate(const TileDirectId& direct_id) const {
|
||||
/* Validate the direct_id */
|
||||
VTR_ASSERT(valid_direct_id(direct_id));
|
||||
return to_tile_coords_[direct_id];
|
||||
}
|
||||
|
||||
size_t TileDirect::to_tile_pin(const TileDirectId& direct_id) const {
|
||||
/* Validate the direct_id */
|
||||
VTR_ASSERT(valid_direct_id(direct_id));
|
||||
return to_tile_pins_[direct_id];
|
||||
}
|
||||
|
||||
e_side TileDirect::to_tile_side(const TileDirectId& direct_id) const {
|
||||
/* Validate the direct_id */
|
||||
VTR_ASSERT(valid_direct_id(direct_id));
|
||||
return to_tile_sides_[direct_id];
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Private Mutators
|
||||
******************************************************************************/
|
||||
TileDirectId TileDirect::add_direct(t_physical_tile_type_ptr from_tile,
|
||||
const vtr::Point<size_t>& from_tile_coord,
|
||||
const e_side& from_tile_side,
|
||||
const size_t& from_tile_pin,
|
||||
t_physical_tile_type_ptr to_tile,
|
||||
const vtr::Point<size_t>& to_tile_coord,
|
||||
const e_side& to_tile_side,
|
||||
const size_t& to_tile_pin) {
|
||||
/* Create an new id */
|
||||
TileDirectId direct = TileDirectId(direct_ids_.size());
|
||||
direct_ids_.push_back(direct);
|
||||
|
||||
/* Allocate other attributes */
|
||||
from_tiles_.push_back(from_tile);
|
||||
from_tile_coords_.push_back(from_tile_coord);
|
||||
from_tile_sides_.push_back(from_tile_side);
|
||||
from_tile_pins_.push_back(from_tile_pin);
|
||||
|
||||
to_tiles_.push_back(to_tile);
|
||||
to_tile_coords_.push_back(to_tile_coord);
|
||||
to_tile_sides_.push_back(to_tile_side);
|
||||
to_tile_pins_.push_back(to_tile_pin);
|
||||
|
||||
return direct;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Private validators/invalidators
|
||||
******************************************************************************/
|
||||
bool TileDirect::valid_direct_id(const TileDirectId& direct_id) const {
|
||||
return ( size_t(direct_id) < direct_ids_.size() ) && ( direct_id == direct_ids_[direct_id] );
|
||||
}
|
||||
|
||||
} /* end namespace openfpga */
|
|
@ -0,0 +1,78 @@
|
|||
#ifndef TILE_DIRECT_H
|
||||
#define TILE_DIRECT_H
|
||||
|
||||
/********************************************************************
|
||||
* Include header files required by the data structure definition
|
||||
*******************************************************************/
|
||||
/* Headers from vtrutil library */
|
||||
#include "vtr_geometry.h"
|
||||
#include "vtr_vector.h"
|
||||
|
||||
/* Headers from readarch library */
|
||||
#include "physical_types.h"
|
||||
|
||||
#include "tile_direct_fwd.h"
|
||||
|
||||
/* Begin namespace openfpga */
|
||||
namespace openfpga {
|
||||
|
||||
/********************************************************************
|
||||
* TileDirect object aims to be a database to store all the information
|
||||
* about direct connection between tiles
|
||||
* - starting tile and end tile for each point-to-point direct connection
|
||||
* - circuit model to implement each direct connection
|
||||
*
|
||||
* TileDirect is compiled from ArchDirect for a specific FPGA fabric.
|
||||
*******************************************************************/
|
||||
class TileDirect {
|
||||
public: /* Types and ranges */
|
||||
typedef vtr::vector<TileDirectId, TileDirectId>::const_iterator tile_direct_iterator;
|
||||
typedef vtr::Range<tile_direct_iterator> tile_direct_range;
|
||||
public: /* Public aggregators */
|
||||
tile_direct_range directs() const;
|
||||
t_physical_tile_type_ptr from_tile(const TileDirectId& direct_id) const;
|
||||
vtr::Point<size_t> from_tile_coordinate(const TileDirectId& direct_id) const;
|
||||
e_side from_tile_side(const TileDirectId& direct_id) const;
|
||||
size_t from_tile_pin(const TileDirectId& direct_id) const;
|
||||
t_physical_tile_type_ptr to_tile(const TileDirectId& direct_id) const;
|
||||
vtr::Point<size_t> to_tile_coordinate(const TileDirectId& direct_id) const;
|
||||
e_side to_tile_side(const TileDirectId& direct_id) const;
|
||||
size_t to_tile_pin(const TileDirectId& direct_id) const;
|
||||
public: /* Public mutators */
|
||||
TileDirectId add_direct(t_physical_tile_type_ptr from_tile,
|
||||
const vtr::Point<size_t>& from_tile_coord,
|
||||
const e_side& from_tile_side,
|
||||
const size_t& from_tile_pin,
|
||||
t_physical_tile_type_ptr to_tile,
|
||||
const vtr::Point<size_t>& to_tile_coord,
|
||||
const e_side& to_tile_side,
|
||||
const size_t& to_tile_pin);
|
||||
public: /* Public validators/invalidators */
|
||||
bool valid_direct_id(const TileDirectId& direct_id) const;
|
||||
private: /* Internal Data */
|
||||
vtr::vector<TileDirectId, TileDirectId> direct_ids_;
|
||||
|
||||
/* Detailed information about the starting tile
|
||||
* - tile type description
|
||||
* - tile coordinate
|
||||
* - tile pin id
|
||||
*/
|
||||
vtr::vector<TileDirectId, t_physical_tile_type_ptr> from_tiles_;
|
||||
vtr::vector<TileDirectId, vtr::Point<size_t>> from_tile_coords_;
|
||||
vtr::vector<TileDirectId, e_side> from_tile_sides_;
|
||||
vtr::vector<TileDirectId, size_t> from_tile_pins_;
|
||||
|
||||
/* Detailed information about the ending tile
|
||||
* - tile type description
|
||||
* - tile coordinate
|
||||
* - tile pin id
|
||||
*/
|
||||
vtr::vector<TileDirectId, t_physical_tile_type_ptr> to_tiles_;
|
||||
vtr::vector<TileDirectId, vtr::Point<size_t>> to_tile_coords_;
|
||||
vtr::vector<TileDirectId, e_side> to_tile_sides_;
|
||||
vtr::vector<TileDirectId, size_t> to_tile_pins_;
|
||||
};
|
||||
|
||||
} /* End namespace openfpga*/
|
||||
|
||||
#endif
|
|
@ -0,0 +1,23 @@
|
|||
/**************************************************
|
||||
* This file includes only declarations for
|
||||
* the data structures for TileDirect
|
||||
* Please refer to tile_direct.h for more details
|
||||
*************************************************/
|
||||
#ifndef TILE_DIRECT_FWD_H
|
||||
#define TILE_DIRECT_FWD_H
|
||||
|
||||
#include "vtr_strong_id.h"
|
||||
|
||||
/* begin namespace openfpga */
|
||||
namespace openfpga {
|
||||
|
||||
/* Strong Ids for ModuleManager */
|
||||
struct tile_direct_id_tag;
|
||||
|
||||
typedef vtr::StrongId<tile_direct_id_tag> TileDirectId;
|
||||
|
||||
class TileDirect;
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue