diff --git a/generic/arch.cc b/generic/arch.cc index 6f2bd5df..4fc07613 100644 --- a/generic/arch.cc +++ b/generic/arch.cc @@ -78,7 +78,24 @@ void Arch::addBel(IdString name, IdString type, Loc loc, bool gb) bel_ids_by_type[type].push_back(name); bel_by_loc[loc] = name; + + if (bels_by_tile.size() <= loc.x) + bels_by_tile.resize(loc.x + 1); + + if (bels_by_tile[loc.x].size() <= loc.y) + bels_by_tile[loc.x].resize(loc.y + 1); + bels_by_tile[loc.x][loc.y].push_back(name); + + if (tileDimZ.size() <= loc.x) + tileDimZ.resize(loc.x + 1); + + if (tileDimZ[loc.x].size() <= loc.y) + tileDimZ[loc.x].resize(loc.y + 1); + + gridDimX = std::max(gridDimX, 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); } void Arch::addBelInput(IdString bel, IdString name, IdString wire) diff --git a/generic/arch.h b/generic/arch.h index a77dca68..5f0df988 100644 --- a/generic/arch.h +++ b/generic/arch.h @@ -87,11 +87,14 @@ struct Arch : BaseCtx std::unordered_map> bel_ids_by_type; std::unordered_map bel_by_loc; - std::unordered_map>> bels_by_tile; + std::vector>> bels_by_tile; std::unordered_map> decal_graphics; DecalXY frame_decalxy; + int gridDimX, gridDimY; + std::vector> tileDimZ; + float grid_distance_to_delay; void addWire(IdString name, int x, int y); @@ -131,6 +134,10 @@ struct Arch : BaseCtx BelType belTypeFromId(IdString id) const { return id; } PortPin portPinFromId(IdString id) const { return id; } + int getGridDimX() const { return gridDimX; } + int getGridDimY() const { return gridDimY; } + int getTileDimZ(int x, int y) const { return tileDimZ[x][y]; } + BelId getBelByName(IdString name) const; IdString getBelName(BelId bel) const; Loc getBelLocation(BelId bel) const; diff --git a/ice40/arch.h b/ice40/arch.h index 3ae6ce65..cd699a0c 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -377,6 +377,12 @@ struct Arch : BaseCtx // ------------------------------------------------- + int getGridDimX() const { return 34; } + int getGridDimY() const { return 34; } + int getTileDimZ(int, int) const { return 8; } + + // ------------------------------------------------- + BelId getBelByName(IdString name) const; IdString getBelName(BelId bel) const