From 7e86cf107915b00cc3095aba31808e9e6c8b4706 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Fri, 14 Feb 2020 19:11:49 -0700 Subject: [PATCH] add tile direct data structure --- openfpga/src/tile_direct/tile_direct.cpp | 102 +++++++++++++++++++++ openfpga/src/tile_direct/tile_direct.h | 78 ++++++++++++++++ openfpga/src/tile_direct/tile_direct_fwd.h | 23 +++++ 3 files changed, 203 insertions(+) create mode 100644 openfpga/src/tile_direct/tile_direct.cpp create mode 100644 openfpga/src/tile_direct/tile_direct.h create mode 100644 openfpga/src/tile_direct/tile_direct_fwd.h diff --git a/openfpga/src/tile_direct/tile_direct.cpp b/openfpga/src/tile_direct/tile_direct.cpp new file mode 100644 index 000000000..0face1b7e --- /dev/null +++ b/openfpga/src/tile_direct/tile_direct.cpp @@ -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 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 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& 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& 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 */ diff --git a/openfpga/src/tile_direct/tile_direct.h b/openfpga/src/tile_direct/tile_direct.h new file mode 100644 index 000000000..562b559ca --- /dev/null +++ b/openfpga/src/tile_direct/tile_direct.h @@ -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::const_iterator tile_direct_iterator; + typedef vtr::Range 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 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 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& 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& 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 direct_ids_; + + /* Detailed information about the starting tile + * - tile type description + * - tile coordinate + * - tile pin id + */ + vtr::vector from_tiles_; + vtr::vector> from_tile_coords_; + vtr::vector from_tile_sides_; + vtr::vector from_tile_pins_; + + /* Detailed information about the ending tile + * - tile type description + * - tile coordinate + * - tile pin id + */ + vtr::vector to_tiles_; + vtr::vector> to_tile_coords_; + vtr::vector to_tile_sides_; + vtr::vector to_tile_pins_; +}; + +} /* End namespace openfpga*/ + +#endif diff --git a/openfpga/src/tile_direct/tile_direct_fwd.h b/openfpga/src/tile_direct/tile_direct_fwd.h new file mode 100644 index 000000000..c83a00ee9 --- /dev/null +++ b/openfpga/src/tile_direct/tile_direct_fwd.h @@ -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 TileDirectId; + +class TileDirect; + +} /* end namespace openfpga */ + +#endif