Merge pull request #42 from YosysHQ/floorplan

Add basic data structures for floorplanning
This commit is contained in:
David Shah 2018-08-09 10:49:11 +02:00 committed by GitHub
commit ed602baa06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 86 additions and 20 deletions

View File

@ -75,7 +75,7 @@ void archcheck_locs(const Context *ctx)
log_assert(0 <= loc.z); log_assert(0 <= loc.z);
log_assert(loc.x < ctx->getGridDimX()); log_assert(loc.x < ctx->getGridDimX());
log_assert(loc.y < ctx->getGridDimY()); log_assert(loc.y < ctx->getGridDimY());
log_assert(loc.z < ctx->getTileDimZ(loc.x, loc.y)); log_assert(loc.z < ctx->getTileBelDimZ(loc.x, loc.y));
BelId bel2 = ctx->getBelByLocation(loc); BelId bel2 = ctx->getBelByLocation(loc);
dbg(" ... %s\n", ctx->getBelName(bel2).c_str(ctx)); dbg(" ... %s\n", ctx->getBelName(bel2).c_str(ctx));
@ -88,7 +88,7 @@ void archcheck_locs(const Context *ctx)
dbg("> %d %d\n", x, y); dbg("> %d %d\n", x, y);
std::unordered_set<int> usedz; std::unordered_set<int> usedz;
for (int z = 0; z < ctx->getTileDimZ(x, y); z++) { for (int z = 0; z < ctx->getTileBelDimZ(x, y); z++) {
BelId bel = ctx->getBelByLocation(Loc(x, y, z)); BelId bel = ctx->getBelByLocation(Loc(x, y, z));
if (bel == BelId()) if (bel == BelId())
continue; continue;

View File

@ -216,6 +216,19 @@ struct BelPin
struct CellInfo; struct CellInfo;
struct Region
{
IdString name;
bool constr_bels = false;
bool constr_wires = false;
bool constr_pips = false;
std::unordered_set<BelId> bels;
std::unordered_set<WireId> wires;
std::unordered_set<Loc> piplocs;
};
enum PlaceStrength enum PlaceStrength
{ {
STRENGTH_NONE = 0, STRENGTH_NONE = 0,
@ -250,6 +263,8 @@ struct NetInfo : ArchNetInfo
// wire -> uphill_pip // wire -> uphill_pip
std::unordered_map<WireId, PipMap> wires; std::unordered_map<WireId, PipMap> wires;
Region *region = nullptr;
}; };
enum PortType enum PortType
@ -289,6 +304,8 @@ struct CellInfo : ArchCellInfo
int constr_z = UNCONSTR; // this.z - parent.z int constr_z = UNCONSTR; // this.z - parent.z
bool constr_abs_z = false; // parent.z := 0 bool constr_abs_z = false; // parent.z := 0
// parent.[xyz] := 0 when (constr_parent == nullptr) // parent.[xyz] := 0 when (constr_parent == nullptr)
Region *region = nullptr;
}; };
enum TimingPortClass enum TimingPortClass
@ -391,6 +408,9 @@ struct BaseCtx
std::unordered_map<IdString, std::unique_ptr<NetInfo>> nets; std::unordered_map<IdString, std::unique_ptr<NetInfo>> nets;
std::unordered_map<IdString, std::unique_ptr<CellInfo>> cells; std::unordered_map<IdString, std::unique_ptr<CellInfo>> cells;
// Floorplanning regions
std::unordered_map<IdString, std::unique_ptr<Region>> region;
BaseCtx() BaseCtx()
{ {
idstring_str_to_idx = new std::unordered_map<std::string, int>; idstring_str_to_idx = new std::unordered_map<std::string, int>;

View File

@ -251,7 +251,7 @@ class ConstraintLegaliseWorker
ySearch = IncreasingDiameterSearch(loc.y + child->constr_y); ySearch = IncreasingDiameterSearch(loc.y + child->constr_y);
} }
if (child->constr_z == child->UNCONSTR) { if (child->constr_z == child->UNCONSTR) {
zSearch = IncreasingDiameterSearch(loc.z, 0, ctx->getTileDimZ(loc.x, loc.y)); zSearch = IncreasingDiameterSearch(loc.z, 0, ctx->getTileBelDimZ(loc.x, loc.y));
} else { } else {
if (child->constr_abs_z) { if (child->constr_abs_z) {
zSearch = IncreasingDiameterSearch(child->constr_z); zSearch = IncreasingDiameterSearch(child->constr_z);
@ -329,7 +329,7 @@ class ConstraintLegaliseWorker
yRootSearch = IncreasingDiameterSearch(cell->constr_y); yRootSearch = IncreasingDiameterSearch(cell->constr_y);
if (cell->constr_z == cell->UNCONSTR) if (cell->constr_z == cell->UNCONSTR)
zRootSearch = IncreasingDiameterSearch(currentLoc.z, 0, ctx->getTileDimZ(currentLoc.x, currentLoc.y)); zRootSearch = IncreasingDiameterSearch(currentLoc.z, 0, ctx->getTileBelDimZ(currentLoc.x, currentLoc.y));
else else
zRootSearch = IncreasingDiameterSearch(cell->constr_z); zRootSearch = IncreasingDiameterSearch(cell->constr_z);
while (!xRootSearch.done()) { while (!xRootSearch.done()) {

View File

@ -74,15 +74,19 @@ Return a string representation of the ArchArgs that was used to construct this o
### int getGridDimX() const ### int getGridDimX() const
Get grid X dimension. All bels must have Y coordinates in the range `0 .. getGridDimX()-1` (inclusive). Get grid X dimension. All bels and pips must have Y coordinates in the range `0 .. getGridDimX()-1` (inclusive).
### int getGridDimY() const ### int getGridDimY() const
Get grid Y dimension. All bels must have Y coordinates in the range `0 .. getGridDimY()-1` (inclusive). Get grid Y dimension. All bels and pips must have Y coordinates in the range `0 .. getGridDimY()-1` (inclusive).
### int getTileDimZ(int x, int y) const ### int getTileBelDimZ(int x, int y) const
Get Z dimension for the specified tile. All bels with the specified X and Y coordinates must have a Z coordinate in the range `0 .. getTileDimZ(X,Y)-1` (inclusive). Get Z dimension for the specified tile for bels. All bels with at specified X and Y coordinates must have a Z coordinate in the range `0 .. getTileDimZ(X,Y)-1` (inclusive).
### int getTilePipDimZ(int x, int y) const
Get Z dimension for the specified tile for pips. All pips with at specified X and Y coordinates must have a Z coordinate in the range `0 .. getTileDimZ(X,Y)-1` (inclusive).
Bel Methods Bel Methods
----------- -----------
@ -97,7 +101,7 @@ Get the name for a bel. (Bel names must be unique.)
### Loc getBelLocation(BelId bel) const ### Loc getBelLocation(BelId bel) const
Get the X/Y/Z location of a given bel. Get the X/Y/Z location of a given bel. Each bel must have a unique X/Y/Z location.
### BelId getBelByLocation(Loc loc) const ### BelId getBelByLocation(Loc loc) const
@ -238,6 +242,11 @@ Get the name for a pip. (Pip names must be unique.)
Get the type of a pip. Pip types are purely informal and Get the type of a pip. Pip types are purely informal and
implementations may simply return `IdString()`. implementations may simply return `IdString()`.
### Loc getPipLocation(PipId pip) const
Get the X/Y/Z location of a given pip. Pip locations do not need to be unique, and in most cases they aren't. So
for pips a X/Y/Z location refers to a group of pips, not an individual pip.
### uint32\_t getPipChecksum(PipId pip) const ### uint32\_t getPipChecksum(PipId pip) const
Return a (preferably unique) number that represents this pip. This is used in design state checksum calculations. Return a (preferably unique) number that represents this pip. This is used in design state checksum calculations.

View File

@ -421,7 +421,8 @@ struct Arch : BaseCtx
int getGridDimX() const { return chip_info->width; }; int getGridDimX() const { return chip_info->width; };
int getGridDimY() const { return chip_info->height; }; int getGridDimY() const { return chip_info->height; };
int getTileDimZ(int, int) const { return 4; }; int getTileBelDimZ(int, int) const { return 4; };
int getTilePipDimZ(int, int) const { return 1; };
// ------------------------------------------------- // -------------------------------------------------
@ -774,6 +775,15 @@ struct Arch : BaseCtx
return chip_info->tiletype_names[locInfo(pip)->pip_data[pip.index].tile_type].get(); return chip_info->tiletype_names[locInfo(pip)->pip_data[pip.index].tile_type].get();
} }
Loc getPipLocation(PipId pip) const
{
Loc loc;
loc.x = pip.location.x;
loc.y = pip.location.y;
loc.z = 0;
return loc;
}
int8_t getPipClass(PipId pip) const { return locInfo(pip)->pip_data[pip.index].pip_type; } int8_t getPipClass(PipId pip) const { return locInfo(pip)->pip_data[pip.index].pip_type; }
BelId getPackagePinBel(const std::string &pin) const; BelId getPackagePinBel(const std::string &pin) const;

View File

@ -36,7 +36,7 @@ void Arch::addWire(IdString name, IdString type, int x, int y)
wire_ids.push_back(name); wire_ids.push_back(name);
} }
void Arch::addPip(IdString name, IdString type, IdString srcWire, IdString dstWire, DelayInfo delay) void Arch::addPip(IdString name, IdString type, IdString srcWire, IdString dstWire, DelayInfo delay, Loc loc)
{ {
NPNR_ASSERT(pips.count(name) == 0); NPNR_ASSERT(pips.count(name) == 0);
PipInfo &pi = pips[name]; PipInfo &pi = pips[name];
@ -45,10 +45,21 @@ void Arch::addPip(IdString name, IdString type, IdString srcWire, IdString dstWi
pi.srcWire = srcWire; pi.srcWire = srcWire;
pi.dstWire = dstWire; pi.dstWire = dstWire;
pi.delay = delay; pi.delay = delay;
pi.loc = loc;
wires.at(srcWire).downhill.push_back(name); wires.at(srcWire).downhill.push_back(name);
wires.at(dstWire).uphill.push_back(name); wires.at(dstWire).uphill.push_back(name);
pip_ids.push_back(name); pip_ids.push_back(name);
if (int(tilePipDimZ.size()) <= loc.x)
tilePipDimZ.resize(loc.x + 1);
if (int(tilePipDimZ[loc.x].size()) <= loc.y)
tilePipDimZ[loc.x].resize(loc.y + 1);
gridDimX = std::max(gridDimX, loc.x + 1);
gridDimY = std::max(gridDimY, loc.x + 1);
tilePipDimZ[loc.x][loc.y] = std::max(tilePipDimZ[loc.x][loc.y], loc.z + 1);
} }
void Arch::addAlias(IdString name, IdString type, IdString srcWire, IdString dstWire, DelayInfo delay) void Arch::addAlias(IdString name, IdString type, IdString srcWire, IdString dstWire, DelayInfo delay)
@ -88,15 +99,15 @@ void Arch::addBel(IdString name, IdString type, Loc loc, bool gb)
bels_by_tile[loc.x][loc.y].push_back(name); bels_by_tile[loc.x][loc.y].push_back(name);
if (int(tileDimZ.size()) <= loc.x) if (int(tileBelDimZ.size()) <= loc.x)
tileDimZ.resize(loc.x + 1); tileBelDimZ.resize(loc.x + 1);
if (int(tileDimZ[loc.x].size()) <= loc.y) if (int(tileBelDimZ[loc.x].size()) <= loc.y)
tileDimZ[loc.x].resize(loc.y + 1); tileBelDimZ[loc.x].resize(loc.y + 1);
gridDimX = std::max(gridDimX, loc.x + 1); gridDimX = std::max(gridDimX, loc.x + 1);
gridDimY = std::max(gridDimY, loc.x + 1); gridDimY = std::max(gridDimY, loc.x + 1);
tileDimZ[loc.x][loc.y] = std::max(tileDimZ[loc.x][loc.y], loc.z + 1); tileBelDimZ[loc.x][loc.y] = std::max(tileBelDimZ[loc.x][loc.y], loc.z + 1);
} }
void Arch::addBelInput(IdString bel, IdString name, IdString wire) void Arch::addBelInput(IdString bel, IdString name, IdString wire)
@ -352,6 +363,8 @@ NetInfo *Arch::getConflictingPipNet(PipId pip) const { return pips.at(pip).bound
const std::vector<PipId> &Arch::getPips() const { return pip_ids; } const std::vector<PipId> &Arch::getPips() const { return pip_ids; }
Loc Arch::getPipLocation(PipId pip) const { return pips.at(pip).loc; }
WireId Arch::getPipSrcWire(PipId pip) const { return pips.at(pip).srcWire; } WireId Arch::getPipSrcWire(PipId pip) const { return pips.at(pip).srcWire; }
WireId Arch::getPipDstWire(PipId pip) const { return pips.at(pip).dstWire; } WireId Arch::getPipDstWire(PipId pip) const { return pips.at(pip).dstWire; }

View File

@ -36,6 +36,7 @@ struct PipInfo
WireId srcWire, dstWire; WireId srcWire, dstWire;
DelayInfo delay; DelayInfo delay;
DecalXY decalxy; DecalXY decalxy;
Loc loc;
}; };
struct WireInfo struct WireInfo
@ -94,12 +95,13 @@ struct Arch : BaseCtx
std::unordered_map<DecalId, std::vector<GraphicElement>> decal_graphics; std::unordered_map<DecalId, std::vector<GraphicElement>> decal_graphics;
int gridDimX, gridDimY; int gridDimX, gridDimY;
std::vector<std::vector<int>> tileDimZ; std::vector<std::vector<int>> tileBelDimZ;
std::vector<std::vector<int>> tilePipDimZ;
float grid_distance_to_delay; float grid_distance_to_delay;
void addWire(IdString name, IdString type, int x, int y); void addWire(IdString name, IdString type, int x, int y);
void addPip(IdString name, IdString type, IdString srcWire, IdString dstWire, DelayInfo delay); void addPip(IdString name, IdString type, IdString srcWire, IdString dstWire, DelayInfo delay, Loc loc);
void addAlias(IdString name, IdString type, IdString srcWire, IdString dstWire, DelayInfo delay); void addAlias(IdString name, IdString type, IdString srcWire, IdString dstWire, DelayInfo delay);
void addBel(IdString name, IdString type, Loc loc, bool gb); void addBel(IdString name, IdString type, Loc loc, bool gb);
@ -132,7 +134,8 @@ struct Arch : BaseCtx
int getGridDimX() const { return gridDimX; } int getGridDimX() const { return gridDimX; }
int getGridDimY() const { return gridDimY; } int getGridDimY() const { return gridDimY; }
int getTileDimZ(int x, int y) const { return tileDimZ[x][y]; } int getTileBelDimZ(int x, int y) const { return tileBelDimZ[x][y]; }
int getTilePipDimZ(int x, int y) const { return tilePipDimZ[x][y]; }
BelId getBelByName(IdString name) const; BelId getBelByName(IdString name) const;
IdString getBelName(BelId bel) const; IdString getBelName(BelId bel) const;
@ -175,6 +178,7 @@ struct Arch : BaseCtx
NetInfo *getBoundPipNet(PipId pip) const; NetInfo *getBoundPipNet(PipId pip) const;
NetInfo *getConflictingPipNet(PipId pip) const; NetInfo *getConflictingPipNet(PipId pip) const;
const std::vector<PipId> &getPips() const; const std::vector<PipId> &getPips() const;
Loc getPipLocation(PipId pip) const;
WireId getPipSrcWire(PipId pip) const; WireId getPipSrcWire(PipId pip) const;
WireId getPipDstWire(PipId pip) const; WireId getPipDstWire(PipId pip) const;
DelayInfo getPipDelay(PipId pip) const; DelayInfo getPipDelay(PipId pip) const;

View File

@ -418,7 +418,8 @@ struct Arch : BaseCtx
int getGridDimX() const { return 34; } int getGridDimX() const { return 34; }
int getGridDimY() const { return 34; } int getGridDimY() const { return 34; }
int getTileDimZ(int, int) const { return 8; } int getTileBelDimZ(int, int) const { return 8; }
int getTilePipDimZ(int, int) const { return 1; }
// ------------------------------------------------- // -------------------------------------------------
@ -680,6 +681,15 @@ struct Arch : BaseCtx
return range; return range;
} }
Loc getPipLocation(PipId pip) const
{
Loc loc;
loc.x = chip_info->pip_data[pip.index].x;
loc.y = chip_info->pip_data[pip.index].y;
loc.z = 0;
return loc;
}
IdString getPipName(PipId pip) const; IdString getPipName(PipId pip) const;
IdString getPipType(PipId pip) const { return IdString(); } IdString getPipType(PipId pip) const { return IdString(); }