From 30e2f0e1e8cfdb24abe6c3a8013691497c706975 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sat, 21 Jul 2018 21:40:06 +0200 Subject: Add Loc constructors Signed-off-by: Clifford Wolf --- generic/arch.cc | 15 +++++---------- generic/arch.h | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'generic') diff --git a/generic/arch.cc b/generic/arch.cc index b7ec847e..447aaa35 100644 --- a/generic/arch.cc +++ b/generic/arch.cc @@ -62,28 +62,23 @@ void Arch::addAlias(IdString name, IdString srcWire, IdString dstWire, DelayInfo pip_ids.push_back(name); } -void Arch::addBel(IdString name, IdString type, int x, int y, int z, bool gb) +void Arch::addBel(IdString name, IdString type, Loc loc, bool gb) { - Loc loc; - loc.x = x; - loc.y = y; - loc.z = z; - NPNR_ASSERT(bels.count(name) == 0); NPNR_ASSERT(bel_by_loc.count(loc) == 0); BelInfo &bi = bels[name]; bi.name = name; bi.type = type; - bi.x = x; - bi.y = y; - bi.z = z; + bi.x = loc.x; + bi.y = loc.y; + bi.z = loc.z; bi.gb = gb; bel_ids.push_back(name); bel_ids_by_type[type].push_back(name); bel_by_loc[loc] = name; - bels_by_tile[x][y].push_back(name); + bels_by_tile[loc.x][loc.y].push_back(name); } void Arch::addBelInput(IdString bel, IdString name, IdString wire) diff --git a/generic/arch.h b/generic/arch.h index e1516569..f4ca4383 100644 --- a/generic/arch.h +++ b/generic/arch.h @@ -97,7 +97,7 @@ struct Arch : BaseCtx void addPip(IdString name, IdString srcWire, IdString dstWire, DelayInfo delay); void addAlias(IdString name, IdString srcWire, IdString dstWire, DelayInfo delay); - void addBel(IdString name, IdString type, int x, int y, int z, bool gb); + void addBel(IdString name, IdString type, Loc loc, bool gb); void addBelInput(IdString bel, IdString name, IdString wire); void addBelOutput(IdString bel, IdString name, IdString wire); void addBelInout(IdString bel, IdString name, IdString wire); -- cgit v1.2.3 From 62b66e02085371c456dee95dc08d2cd41351c91f Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sun, 22 Jul 2018 10:59:21 +0200 Subject: Rename getWireBelPin to getBelPinWire Signed-off-by: Clifford Wolf --- generic/arch.cc | 2 +- generic/arch.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'generic') diff --git a/generic/arch.cc b/generic/arch.cc index 447aaa35..1a8b1a67 100644 --- a/generic/arch.cc +++ b/generic/arch.cc @@ -215,7 +215,7 @@ const std::vector &Arch::getBelsByType(BelType type) const BelType Arch::getBelType(BelId bel) const { return bels.at(bel).type; } -WireId Arch::getWireBelPin(BelId bel, PortPin pin) const { return bels.at(bel).pins.at(pin).wire; } +WireId Arch::getBelPinWire(BelId bel, PortPin pin) const { return bels.at(bel).pins.at(pin).wire; } BelPin Arch::getBelPinUphill(WireId wire) const { return wires.at(wire).uphill_bel_pin; } diff --git a/generic/arch.h b/generic/arch.h index f4ca4383..7bcb965f 100644 --- a/generic/arch.h +++ b/generic/arch.h @@ -145,7 +145,7 @@ struct Arch : BaseCtx const std::vector &getBels() const; const std::vector &getBelsByType(BelType type) const; BelType getBelType(BelId bel) const; - WireId getWireBelPin(BelId bel, PortPin pin) const; + WireId getBelPinWire(BelId bel, PortPin pin) const; BelPin getBelPinUphill(WireId wire) const; const std::vector &getBelPinsDownhill(WireId wire) const; -- cgit v1.2.3 From bfa83b3bfd8020298b672d467dbd6c1c6c067c21 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sun, 22 Jul 2018 11:12:28 +0200 Subject: Add Arch::getBelPinType() and Arch::getWireBelPins() in generic arch Signed-off-by: Clifford Wolf --- generic/arch.cc | 7 +++++++ generic/arch.h | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'generic') diff --git a/generic/arch.cc b/generic/arch.cc index 1a8b1a67..8c7a7670 100644 --- a/generic/arch.cc +++ b/generic/arch.cc @@ -90,6 +90,7 @@ void Arch::addBelInput(IdString bel, IdString name, IdString wire) pi.type = PORT_IN; wires.at(wire).downhill_bel_pins.push_back(BelPin{bel, name}); + wires.at(wire).bel_pins.push_back(BelPin{bel, name}); } void Arch::addBelOutput(IdString bel, IdString name, IdString wire) @@ -101,6 +102,7 @@ void Arch::addBelOutput(IdString bel, IdString name, IdString wire) pi.type = PORT_OUT; wires.at(wire).uphill_bel_pin = BelPin{bel, name}; + wires.at(wire).bel_pins.push_back(BelPin{bel, name}); } void Arch::addBelInout(IdString bel, IdString name, IdString wire) @@ -112,6 +114,7 @@ void Arch::addBelInout(IdString bel, IdString name, IdString wire) pi.type = PORT_INOUT; wires.at(wire).downhill_bel_pins.push_back(BelPin{bel, name}); + wires.at(wire).bel_pins.push_back(BelPin{bel, name}); } void Arch::addGroupBel(IdString group, IdString bel) { groups[group].bels.push_back(bel); } @@ -217,6 +220,8 @@ BelType Arch::getBelType(BelId bel) const { return bels.at(bel).type; } WireId Arch::getBelPinWire(BelId bel, PortPin pin) const { return bels.at(bel).pins.at(pin).wire; } +PortType Arch::getBelPinType(BelId bel, PortPin pin) const { return bels.at(bel).pins.at(pin).type; } + BelPin Arch::getBelPinUphill(WireId wire) const { return wires.at(wire).uphill_bel_pin; } const std::vector &Arch::getBelPinsDownhill(WireId wire) const { return wires.at(wire).downhill_bel_pins; } @@ -267,6 +272,8 @@ IdString Arch::getBoundWireNet(WireId wire) const { return wires.at(wire).bound_ IdString Arch::getConflictingWireNet(WireId wire) const { return wires.at(wire).bound_net; } +const std::vector &Arch::getWireBelPins(WireId wire) const { return wires.at(wire).bel_pins; } + const std::vector &Arch::getWires() const { return wire_ids; } // --------------------------------------------------------------- diff --git a/generic/arch.h b/generic/arch.h index 7bcb965f..2a74b1ae 100644 --- a/generic/arch.h +++ b/generic/arch.h @@ -43,6 +43,7 @@ struct WireInfo std::vector downhill, uphill, aliases; BelPin uphill_bel_pin; std::vector downhill_bel_pins; + std::vector bel_pins; DecalXY decalxy; int x, y; }; @@ -146,8 +147,9 @@ struct Arch : BaseCtx const std::vector &getBelsByType(BelType type) const; BelType getBelType(BelId bel) const; WireId getBelPinWire(BelId bel, PortPin pin) const; - BelPin getBelPinUphill(WireId wire) const; - const std::vector &getBelPinsDownhill(WireId wire) const; + PortType getBelPinType(BelId bel, PortPin pin) const; + BelPin getBelPinUphill(WireId wire) const NPNR_DEPRECATED; + const std::vector &getBelPinsDownhill(WireId wire) const NPNR_DEPRECATED; WireId getWireByName(IdString name) const; IdString getWireName(WireId wire) const; @@ -159,6 +161,7 @@ struct Arch : BaseCtx IdString getConflictingWireNet(WireId wire) const; DelayInfo getWireDelay(WireId wire) const { return DelayInfo(); } const std::vector &getWires() const; + const std::vector &getWireBelPins(WireId wire) const; PipId getPipByName(IdString name) const; IdString getPipName(PipId pip) const; -- cgit v1.2.3 From e13fc7edabb449d21ad6473bab23d5c1b2cf3761 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sun, 22 Jul 2018 12:08:52 +0200 Subject: Add Arch::getBelPins() to generic and iCE40 archs Signed-off-by: Clifford Wolf --- generic/arch.cc | 7 +++++++ generic/arch.h | 1 + 2 files changed, 8 insertions(+) (limited to 'generic') diff --git a/generic/arch.cc b/generic/arch.cc index 8c7a7670..0f2f5fe3 100644 --- a/generic/arch.cc +++ b/generic/arch.cc @@ -226,6 +226,13 @@ BelPin Arch::getBelPinUphill(WireId wire) const { return wires.at(wire).uphill_b const std::vector &Arch::getBelPinsDownhill(WireId wire) const { return wires.at(wire).downhill_bel_pins; } +std::vector Arch::getBelPins(BelId bel) const +{ + std::vector ret; + for (auto &it : bels.at(bel).pins) + ret.push_back(it.first); +} + // --------------------------------------------------------------- WireId Arch::getWireByName(IdString name) const diff --git a/generic/arch.h b/generic/arch.h index 2a74b1ae..e650906d 100644 --- a/generic/arch.h +++ b/generic/arch.h @@ -150,6 +150,7 @@ struct Arch : BaseCtx PortType getBelPinType(BelId bel, PortPin pin) const; BelPin getBelPinUphill(WireId wire) const NPNR_DEPRECATED; const std::vector &getBelPinsDownhill(WireId wire) const NPNR_DEPRECATED; + std::vector getBelPins(BelId bel) const; WireId getWireByName(IdString name) const; IdString getWireName(WireId wire) const; -- cgit v1.2.3 From b9c413a5aa06a325de5c55e254441aee58143676 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 22 Jul 2018 19:58:17 +0200 Subject: Move to new API and remove deprecated --- generic/arch.cc | 4 ---- generic/arch.h | 2 -- 2 files changed, 6 deletions(-) (limited to 'generic') diff --git a/generic/arch.cc b/generic/arch.cc index 0f2f5fe3..6f2bd5df 100644 --- a/generic/arch.cc +++ b/generic/arch.cc @@ -222,10 +222,6 @@ WireId Arch::getBelPinWire(BelId bel, PortPin pin) const { return bels.at(bel).p PortType Arch::getBelPinType(BelId bel, PortPin pin) const { return bels.at(bel).pins.at(pin).type; } -BelPin Arch::getBelPinUphill(WireId wire) const { return wires.at(wire).uphill_bel_pin; } - -const std::vector &Arch::getBelPinsDownhill(WireId wire) const { return wires.at(wire).downhill_bel_pins; } - std::vector Arch::getBelPins(BelId bel) const { std::vector ret; diff --git a/generic/arch.h b/generic/arch.h index e650906d..a77dca68 100644 --- a/generic/arch.h +++ b/generic/arch.h @@ -148,8 +148,6 @@ struct Arch : BaseCtx BelType getBelType(BelId bel) const; WireId getBelPinWire(BelId bel, PortPin pin) const; PortType getBelPinType(BelId bel, PortPin pin) const; - BelPin getBelPinUphill(WireId wire) const NPNR_DEPRECATED; - const std::vector &getBelPinsDownhill(WireId wire) const NPNR_DEPRECATED; std::vector getBelPins(BelId bel) const; WireId getWireByName(IdString name) const; -- cgit v1.2.3 From 27c523682601e7b504c924a00bec98743fd3477c Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Mon, 23 Jul 2018 12:19:54 +0200 Subject: Add getGridDimX(), getGridDimY(), getTileDimZ() API Signed-off-by: Clifford Wolf --- generic/arch.cc | 17 +++++++++++++++++ generic/arch.h | 9 ++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'generic') 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; -- cgit v1.2.3 From 90fe002a36a9b90cd6d003d34398242a5d5affb6 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Mon, 23 Jul 2018 13:16:27 +0200 Subject: Remove getBelsByType() API Signed-off-by: Clifford Wolf --- generic/arch.cc | 10 ---------- generic/arch.h | 2 -- 2 files changed, 12 deletions(-) (limited to 'generic') diff --git a/generic/arch.cc b/generic/arch.cc index 4fc07613..0fff2e4c 100644 --- a/generic/arch.cc +++ b/generic/arch.cc @@ -75,8 +75,6 @@ void Arch::addBel(IdString name, IdString type, Loc loc, bool gb) bi.gb = gb; bel_ids.push_back(name); - bel_ids_by_type[type].push_back(name); - bel_by_loc[loc] = name; if (bels_by_tile.size() <= loc.x) @@ -225,14 +223,6 @@ IdString Arch::getConflictingBelCell(BelId bel) const { return bels.at(bel).boun const std::vector &Arch::getBels() const { return bel_ids; } -const std::vector &Arch::getBelsByType(BelType type) const -{ - static std::vector empty_list; - if (bel_ids_by_type.count(type)) - return bel_ids_by_type.at(type); - return empty_list; -} - BelType Arch::getBelType(BelId bel) const { return bels.at(bel).type; } WireId Arch::getBelPinWire(BelId bel, PortPin pin) const { return bels.at(bel).pins.at(pin).wire; } diff --git a/generic/arch.h b/generic/arch.h index 5f0df988..61e6b033 100644 --- a/generic/arch.h +++ b/generic/arch.h @@ -84,7 +84,6 @@ struct Arch : BaseCtx std::unordered_map groups; std::vector bel_ids, wire_ids, pip_ids; - std::unordered_map> bel_ids_by_type; std::unordered_map bel_by_loc; std::vector>> bels_by_tile; @@ -151,7 +150,6 @@ struct Arch : BaseCtx IdString getBoundBelCell(BelId bel) const; IdString getConflictingBelCell(BelId bel) const; const std::vector &getBels() const; - const std::vector &getBelsByType(BelType type) const; BelType getBelType(BelId bel) const; WireId getBelPinWire(BelId bel, PortPin pin) const; PortType getBelPinType(BelId bel, PortPin pin) const; -- cgit v1.2.3