Skip to content

Commit

Permalink
Merge pull request verilog-to-routing#2623 from verilog-to-routing/3d…
Browse files Browse the repository at this point in the history
…_constraints

3D Placement Constraints
  • Loading branch information
vaughnbetz committed Jul 8, 2024
2 parents cb55d66 + 224c8ac commit f37ec16
Show file tree
Hide file tree
Showing 49 changed files with 238,469 additions and 1,978 deletions.
36 changes: 33 additions & 3 deletions doc/src/vpr/placement_constraints.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ A Placement Constraints File Example
<add_atom name_pattern="n4917"/>
<add_atom name_pattern="n6010"/>
</partition>
<partition name="Part2">
<add_region x_low="3" y_low="3" x_high="85" y_high="85"/> <!-- When the layer is not explicitly specified, layer 0 is assumed. -->
<add_region x_low="8" y_low="5" x_high="142" y_high="29 layer_low="0" layer_high="1"/> <!-- In 3D architectures, the region can span across multiple layers. -->
<add_region x_low="6" y_low="55" x_high="50" y_high="129 layer_low="2" layer_high="2"/> <!-- If the region only covers a non-zero layer, both layer_low and layer_high must be set the same value. -->
<add_atom name_pattern="n135"/>
<add_atom name_pattern="n7016"/>
</partition>
</partition_list>
</vpr_constraints>
Expand Down Expand Up @@ -75,7 +83,10 @@ The ``name_pattern`` can be the exact name of the atom from the input atom netli
Region
^^^^^^

An ``<add_region>`` tag is used to add a region to the partition. A ``region`` is a rectangular area on the chip. A partition can contain any number of independent regions - the regions within one partition must not overlap with each other (in order to ease processing when loading in the file). An ``<add_region>`` tag has the following attributes.
An ``<add_region>`` tag is used to add a region to the partition. A ``region`` is a rectangular area or cubic volume
on the chip. A partition can contain any number of independent regions - the regions within one partition **must not**
overlap with each other (in order to ease processing when loading in the file).
An ``<add_region>`` tag has the following attributes.

:req_param x_low:
The x value of the lower left point of the rectangle.
Expand All @@ -90,11 +101,30 @@ An ``<add_region>`` tag is used to add a region to the partition. A ``region`` i
The y value of the upper right point of the rectangle.

:opt_param subtile:
Each x, y location on the grid may contain multiple locations known as subtiles. This paramter is an optional value specifying the subtile location that the atom(s) of the partition shall be constrained to.
Each x, y location on the grid may contain multiple locations known as subtiles. This parameter is an optional value specifying the subtile location that the atom(s) of the partition shall be constrained to.

:opt_param layer_low:
The lowest layer number that the region covers. The default value is 0.

:opt_param layer_high:
The highest layer number that the region covers. The default value is 0.

The optional ``subtile`` attribute is commonly used when constraining an atom to a specific location on the chip (e.g. an exact I/O location). It is legal to use with larger regions, but uncommon.

If a user would like to specify an area on the chip with an unusual shape (e.g. L-shaped or T-shaped), they can simply add multiple ``<add_region>`` tags to cover the area specified.
In 2D architectures, ``layer_low`` and ``layer_high`` can be safely ignored as their default value is 0.
In 3D architectures, a region can span across multiple layers or be assigned to a specific layer.
For assigning a region to a specific non-zero layer, the user should set both ``layer_low`` and ``layer_high`` to the
desired layer number. If a layer range is to be covered by the region, the user set ``layer_low`` and ``layer_high`` to
different values.

If a user would like to specify an area on the chip with an unusual shape (e.g. L-shaped or T-shaped),
they can simply add multiple ``<add_region>`` tags to cover the area specified.

It is strongly recommended that different partitions do not overlap. The packing algorithm compares the number clustered
blocks and the number of physical blocks in a region to decide pack atoms inside a partition more aggressively when
there are not enough resources in a partition. Overlapping partitions causes some physical blocks to be counted in more
than one partition.




Expand Down
12 changes: 6 additions & 6 deletions libs/libarchfpga/src/echo_arch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ void PrintArchInfo(FILE* Echo, const t_arch* arch) {
}

fprintf(Echo, "\tInput Connect Block Switch Name Within a Same Die: %s\n", arch->ipin_cblock_switch_name[ipin_cblock_switch_index_within_die].c_str());

//if there is more than one layer available, print the connection block switch name that is used for connection between two dice
for(const auto& layout : arch->grid_layouts){
for (const auto& layout : arch->grid_layouts) {
int num_layers = (int)layout.layers.size();
if(num_layers > 1){
if (num_layers > 1) {
fprintf(Echo, "\tInput Connect Block Switch Name Between Two Dice: %s\n", arch->ipin_cblock_switch_name[ipin_cblock_switch_index_between_dice].c_str());
}
}
Expand Down Expand Up @@ -295,11 +295,11 @@ void PrintArchInfo(FILE* Echo, const t_arch* arch) {
fprintf(Echo, "\t\t\t\ttype unidir mux_name for within die connections: %s\n",
arch->Switches[seg.arch_wire_switch].name.c_str());
//if there is more than one layer available, print the segment switch name that is used for connection between two dice
for(const auto& layout : arch->grid_layouts){
for (const auto& layout : arch->grid_layouts) {
int num_layers = (int)layout.layers.size();
if(num_layers > 1){
if (num_layers > 1) {
fprintf(Echo, "\t\t\t\ttype unidir mux_name for between two dice connections: %s\n",
arch->Switches[seg.arch_opin_between_dice_switch].name.c_str());
arch->Switches[seg.arch_opin_between_dice_switch].name.c_str());
}
}
} else { //Should be bidir
Expand Down
23 changes: 21 additions & 2 deletions libs/libvtrutil/src/vtr_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

/**
* @file
* @brief This file include differents different geometry classes
* @brief This file includes different geometry classes
*/

namespace vtr {
Expand Down Expand Up @@ -92,11 +92,18 @@ class Point {
///@brief Swap x and y values
void swap();

/// @brief += operator
Point<T>& operator+= (const Point<T>& rhs);

/// @brief += operator
Point<T>& operator-= (const Point<T>& rhs);

private:
T x_;
T y_;
};


/**
* @brief A 2D rectangle
*
Expand Down Expand Up @@ -144,6 +151,12 @@ class Rect {
///@brief Return the top right point
Point<T> top_right() const;

/**
* @brief Return the bottom left and top right coordinates
* @return [xmin, ymin, xmax, ymax]
*/
std::tuple<T, T, T, T> coordinates() const;

///@brief Return the rectangle width
T width() const;

Expand Down Expand Up @@ -190,6 +203,12 @@ class Rect {
///@brief set ymax to a point
void set_ymax(T ymax_val);

/// @brief += operator
Rect<T>& operator+= (const Point<T>& rhs);

/// @brief -= operator
Rect<T>& operator-= (const Point<T>& rhs);

///@brief Equivalent to `*this = bounding_box(*this, other)`
Rect<T>& expand_bounding_box(const Rect<T>& other);

Expand Down Expand Up @@ -302,7 +321,7 @@ class RectUnion {
friend bool operator!= <>(const RectUnion<T>& lhs, const RectUnion<T>& rhs);

private:
// Note that a union of rectanges may have holes and may not be contiguous
// Note that a union of rectangles may have holes and may not be contiguous
std::vector<Rect<T>> rects_;
};

Expand Down
33 changes: 33 additions & 0 deletions libs/libvtrutil/src/vtr_geometry.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ void Point<T>::swap() {
std::swap(x_, y_);
}

template<class T>
Point<T>& Point<T>::operator+=(const Point<T>& rhs) {
x_ += rhs.x_;
y_ += rhs.y_;
return *this;
}

template<class T>
Point<T>& Point<T>::operator-=(const Point<T>& rhs) {
x_ -= rhs.x_;
y_ -= rhs.y_;
return *this;
}

/*
* Rect
*/
Expand Down Expand Up @@ -120,6 +134,11 @@ Point<T> Rect<T>::top_right() const {
return top_right_;
}

template<class T>
std::tuple<T, T, T, T> Rect<T>::coordinates() const {
return {xmin(), ymin(), xmax(), ymax()};
}

template<class T>
T Rect<T>::width() const {
return xmax() - xmin();
Expand Down Expand Up @@ -224,6 +243,20 @@ void Rect<T>::set_ymax(T ymax_val) {
top_right_.set_y(ymax_val);
}

template<class T>
Rect<T>& Rect<T>::operator+=(const Point<T>& rhs) {
bottom_left_ += rhs;
top_right_ += rhs;
return *this;
}

template<class T>
Rect<T>& Rect<T>::operator-=(const Point<T>& rhs) {
bottom_left_ -= rhs;
top_right_ -= rhs;
return *this;
}

template<class T>
Rect<T>& Rect<T>::expand_bounding_box(const Rect<T>& other) {
*this = bounding_box(*this, other);
Expand Down
Loading

0 comments on commit f37ec16

Please sign in to comment.