Skip to content

Created draft of new constraints class header file #1535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions vpr/src/base/partition.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef PARTITION_H
#define PARTITION_H

#include "vtr_strong_id.h"
#include "region.h"

/**
* This class stores the data for each constraint partition -
* partition name, the atoms that are in the partition,
* and the regions that the partition can be placed in.
*/

//Type tag for PartitionId
struct partition_id_tag;

//A unique identifier for a partition
typedef vtr::StrongId<partition_id_tag> PartitionId;

class Partition {
public: //accessors
private:
PartitionId id;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment this too - unique id for this partition

std::string name;
std::vector<AtomBlockId> atomBlocks; //atoms that belong to this partition
std::vector<Region> regions; //regions that this partition can be placed in
};
#endif /* PARTITION_H */
15 changes: 15 additions & 0 deletions vpr/src/base/partition_regions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef PARTITION_REGIONS_H
#define PARTITION_REGIONS_H

/**
* Vectors of type PartitionRegions are used to return information on the intersection of regions
* (ex. between a cluster and an atom).
*/

class PartitionRegions {
public: //accessors
private:
std::vector<Region> partition_regions;
};

#endif /* PARTITION_REGIONS_H */
25 changes: 25 additions & 0 deletions vpr/src/base/region.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef REGION_H
#define REGION_H

#include "vtr_strong_id.h"
#include "globals.h"

/**
* This class stores the data for each constraint region - the region bounds and the subtile bounds.
*/

//Type tag for RegionId
struct region_id_tag;

//A unique identifier for a region
typedef vtr::StrongId<region_id_tag> RegionId;

class Region {
public: //accessors
private:
//may need to include zmin, zmax for future use in 3D FPGA designs
vtr::Rect<int> region_bounds; //xmin, xmax, ymin, ymax
int subTilemin, subTilemax;
};

#endif /* REGION_H */
52 changes: 52 additions & 0 deletions vpr/src/base/vpr_constraints.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#ifndef VPR_CONSTRAINTS_H
#define VPR_CONSTRAINTS_H

#include "vtr_vector.h"
#include "vpr_utils.h"
#include "partition.h"
#include "partition_regions.h"

/**
* @file
* @brief This file defines the VprConstraints class used to store and read out data related to user-specified
* block and region constraints for the packing and placement stages.
*
* Overview
* ========
* This class contains functions that read in and store information from a constraints XML file.
* The XML file provides a partition list, with the names/ids of the partitions, and each atom in the partition.
* It also provides placement constraints, where it is specified which regions the partitions should go in.
* In the constraints file, a placement constraint can also be created for a specific primitive. A partition would be automatically
* created for the primitive when a placement constraint was specified for it.
*
*/

class VprConstraints {
public:
/**
* Returns the intersection of two PartitionRegions vectors that are passed to it.
* Can be used by atom_cluster_intersection.
*/
PartitionRegions do_regions_intersect(PartitionRegions part_regions_old, PartitionRegions part_regions_new);

/**
* Takes Atom Id and PartitonRegions vector and returns the intersection of the atom's partition regions
* and the net PartitionRegions of the cluster (if any exists)
* Used by clusterer during packing.
*/
PartitionRegions atom_cluster_intersection(const AtomBlockId id, PartitionRegions part_regions);

private:
/**
* Store constraints information of each constrained atom.
* Store ID of the partition the atom belongs to/invalid entry if it doesn't belong to any partition.
*/
std::unordered_map<AtomBlockId, PartitionId> constrained_atoms;

/**
* Store partitions in a vector
*/
std::vector<Partition> partitions;
};

#endif /* VPR_CONSTRAINTS_H */