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 --- ecp5/arch.cc | 2 +- ecp5/arch.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'ecp5') diff --git a/ecp5/arch.cc b/ecp5/arch.cc index 1510a27f..f6ee0711 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -206,7 +206,7 @@ BelRange Arch::getBelsAtSameTile(BelId bel) const return br; } -WireId Arch::getWireBelPin(BelId bel, PortPin pin) const +WireId Arch::getBelPinWire(BelId bel, PortPin pin) const { WireId ret; diff --git a/ecp5/arch.h b/ecp5/arch.h index bf36ef2f..234773e3 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -484,7 +484,7 @@ struct Arch : BaseCtx return locInfo(bel)->bel_data[bel.index].type; } - WireId getWireBelPin(BelId bel, PortPin pin) const; + WireId getBelPinWire(BelId bel, PortPin pin) const; BelPin getBelPinUphill(WireId wire) const { -- cgit v1.2.3 From 38431bd420ff2dcbaa9581571e6d0302dcfe2379 Mon Sep 17 00:00:00 2001 From: David Shah Date: Sun, 22 Jul 2018 16:55:10 +0200 Subject: ecp5: Fix regression following router update Signed-off-by: David Shah --- ecp5/arch.cc | 2 +- ecp5/arch.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'ecp5') diff --git a/ecp5/arch.cc b/ecp5/arch.cc index f6ee0711..c7896ca6 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -325,7 +325,7 @@ void Arch::estimatePosition(BelId bel, int &x, int &y, bool &gb) const delay_t Arch::estimateDelay(WireId src, WireId dst) const { - return abs(src.location.x - dst.location.x) + abs(src.location.y - dst.location.y); + return 200 * (abs(src.location.x - dst.location.x) + abs(src.location.y - dst.location.y)); } // ----------------------------------------------------------------------- diff --git a/ecp5/arch.h b/ecp5/arch.h index 234773e3..13b2c3b8 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -694,7 +694,7 @@ struct Arch : BaseCtx { DelayInfo delay; NPNR_ASSERT(pip != PipId()); - delay.delay = locInfo(pip)->pip_data[pip.index].delay; + delay.delay = locInfo(pip)->pip_data[pip.index].delay * 100; return delay; } -- cgit v1.2.3 From 987fdc1b29d9cb7478df49c72f68ce5f3f9f740c Mon Sep 17 00:00:00 2001 From: David Shah Date: Sun, 22 Jul 2018 17:07:38 +0200 Subject: ecp5: Adding new Bel pin API Signed-off-by: David Shah --- ecp5/arch.cc | 30 ++++++++++++++++++++++++++++++ ecp5/arch.h | 24 ++++++++++++++++++++++-- ecp5/trellis_import.py | 12 +++++++++++- 3 files changed, 63 insertions(+), 3 deletions(-) (limited to 'ecp5') diff --git a/ecp5/arch.cc b/ecp5/arch.cc index c7896ca6..90950492 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -224,6 +224,20 @@ WireId Arch::getBelPinWire(BelId bel, PortPin pin) const return ret; } +PortType Arch::getBelPinType(BelId bel, PortPin pin) const +{ + NPNR_ASSERT(bel != BelId()); + + int num_bel_wires = locInfo(bel)->bel_data[bel.index].num_bel_wires; + const BelWirePOD *bel_wires = locInfo(bel)->bel_data[bel.index].bel_wires.get(); + + for (int i = 0; i < num_bel_wires; i++) + if (bel_wires[i].port == pin) + return PortType(bel_wires[i].type); + + return PORT_INOUT; +} + // ----------------------------------------------------------------------- WireId Arch::getWireByName(IdString name) const @@ -314,6 +328,22 @@ std::string Arch::getBelPackagePin(BelId bel) const } return ""; } + +std::vector Arch::getBelPins(BelId bel) const + +{ + std::vector ret; + NPNR_ASSERT(bel != BelId()); + + int num_bel_wires = locInfo(bel)->bel_data[bel.index].num_bel_wires; + const BelWirePOD *bel_wires = locInfo(bel)->bel_data[bel.index].bel_wires.get(); + + for (int i = 0; i < num_bel_wires; i++) + ret.push_back(bel_wires[i].port); + + return ret; +} + // ----------------------------------------------------------------------- void Arch::estimatePosition(BelId bel, int &x, int &y, bool &gb) const diff --git a/ecp5/arch.h b/ecp5/arch.h index 13b2c3b8..b6aec856 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -50,6 +50,7 @@ NPNR_PACKED_STRUCT(struct BelWirePOD { LocationPOD rel_wire_loc; int32_t wire_index; PortPin port; + int32_t type; }); NPNR_PACKED_STRUCT(struct BelInfoPOD { @@ -87,6 +88,9 @@ NPNR_PACKED_STRUCT(struct WireInfoPOD { int32_t num_bels_downhill; BelPortPOD bel_uphill; RelPtr bels_downhill; + + int32_t num_bel_pins; + RelPtr bel_pins; }); NPNR_PACKED_STRUCT(struct LocationTypePOD { @@ -486,7 +490,7 @@ struct Arch : BaseCtx WireId getBelPinWire(BelId bel, PortPin pin) const; - BelPin getBelPinUphill(WireId wire) const + BelPin getBelPinUphill(WireId wire) const NPNR_DEPRECATED { BelPin ret; NPNR_ASSERT(wire != WireId()); @@ -500,7 +504,7 @@ struct Arch : BaseCtx return ret; } - BelPinRange getBelPinsDownhill(WireId wire) const + BelPinRange getBelPinsDownhill(WireId wire) const NPNR_DEPRECATED { BelPinRange range; NPNR_ASSERT(wire != WireId()); @@ -511,6 +515,19 @@ struct Arch : BaseCtx return range; } + BelPinRange getWireBelPins(WireId wire) const + { + BelPinRange range; + NPNR_ASSERT(wire != WireId()); + range.b.ptr = locInfo(wire)->wire_data[wire.index].bel_pins.get(); + range.b.wire_loc = wire.location; + range.e.ptr = range.b.ptr + locInfo(wire)->wire_data[wire.index].num_bel_pins; + range.e.wire_loc = wire.location; + return range; + } + + std::vector getBelPins(BelId bel) const; + // ------------------------------------------------- WireId getWireByName(IdString name) const; @@ -581,6 +598,7 @@ struct Arch : BaseCtx DelayInfo getWireDelay(WireId wire) const { DelayInfo delay; + delay.delay = 0; return delay; } @@ -739,6 +757,8 @@ struct Arch : BaseCtx BelId getPackagePinBel(const std::string &pin) const; std::string getBelPackagePin(BelId bel) const; + PortType getBelPinType(BelId bel, PortPin pin) const; + // ------------------------------------------------- GroupId getGroupByName(IdString name) const { return GroupId(); } diff --git a/ecp5/trellis_import.py b/ecp5/trellis_import.py index af5386e7..b0cbdd90 100755 --- a/ecp5/trellis_import.py +++ b/ecp5/trellis_import.py @@ -407,6 +407,12 @@ def write_database(dev_name, ddrg, endianness): write_loc(db.bel.rel, "rel_bel_loc") bba.u32(db.bel.id, "bel_index") bba.u32(portpins[ddrg.to_str(db.pin)], "port") + if len(wire.belPins) > 0: + bba.l("loc%d_wire%d_belpins" % (idx, wire_idx), "BelPortPOD") + for bp in wire.belPins: + write_loc(bp.bel.rel, "rel_bel_loc") + bba.u32(bp.bel.id, "bel_index") + bba.u32(portpins[ddrg.to_str(bp.pin)], "port") bba.l("loc%d_wires" % idx, "WireInfoPOD") for wire_idx in range(len(loctype.wires)): wire = loctype.wires[wire_idx] @@ -424,14 +430,18 @@ def write_database(dev_name, ddrg, endianness): bba.u32(0xFFFFFFFF, "bel_uphill.bel_index") bba.u32(0, "bel_uphill.port") bba.r("loc%d_wire%d_downbels" % (idx, wire_idx) if len(wire.belsDownhill) > 0 else None, "bels_downhill") + bba.u32(len(wire.belPins), "num_bel_pins") + bba.r("loc%d_wire%d_belpins" % (idx, wire_idx) if len(wire.belPins) > 0 else None, "bel_pins") + if len(loctype.bels) > 0: for bel_idx in range(len(loctype.bels)): bel = loctype.bels[bel_idx] - bba.l("loc%d_bel%d_wires" % (idx, bel_idx), "BelPortPOD") + bba.l("loc%d_bel%d_wires" % (idx, bel_idx), "BelWirePOD") for pin in bel.wires: write_loc(pin.wire.rel, "rel_wire_loc") bba.u32(pin.wire.id, "wire_index") bba.u32(portpins[ddrg.to_str(pin.pin)], "port") + bba.u32(int(pin.dir), "dir") bba.l("loc%d_bels" % idx, "BelInfoPOD") for bel_idx in range(len(loctype.bels)): bel = loctype.bels[bel_idx] -- 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 --- ecp5/arch.h | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'ecp5') diff --git a/ecp5/arch.h b/ecp5/arch.h index b6aec856..cce9f09d 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -490,31 +490,6 @@ struct Arch : BaseCtx WireId getBelPinWire(BelId bel, PortPin pin) const; - BelPin getBelPinUphill(WireId wire) const NPNR_DEPRECATED - { - BelPin ret; - NPNR_ASSERT(wire != WireId()); - - if (locInfo(wire)->wire_data[wire.index].bel_uphill.bel_index >= 0) { - ret.bel.index = locInfo(wire)->wire_data[wire.index].bel_uphill.bel_index; - ret.bel.location = wire.location + locInfo(wire)->wire_data[wire.index].bel_uphill.rel_bel_loc; - ret.pin = locInfo(wire)->wire_data[wire.index].bel_uphill.port; - } - - return ret; - } - - BelPinRange getBelPinsDownhill(WireId wire) const NPNR_DEPRECATED - { - BelPinRange range; - NPNR_ASSERT(wire != WireId()); - range.b.ptr = locInfo(wire)->wire_data[wire.index].bels_downhill.get(); - range.b.wire_loc = wire.location; - range.e.ptr = range.b.ptr + locInfo(wire)->wire_data[wire.index].num_bels_downhill; - range.e.wire_loc = wire.location; - return range; - } - BelPinRange getWireBelPins(WireId wire) const { BelPinRange range; -- cgit v1.2.3 From d0ed23d673013b4fc44f5e938bc74103d1268c13 Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 23 Jul 2018 10:32:42 +0200 Subject: ecp5: Remove obsolete db entries, add Bel z-position Signed-off-by: David Shah --- ecp5/arch.h | 5 +---- ecp5/trellis_import.py | 16 +--------------- 2 files changed, 2 insertions(+), 19 deletions(-) (limited to 'ecp5') diff --git a/ecp5/arch.h b/ecp5/arch.h index cce9f09d..9d99da8c 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -56,6 +56,7 @@ NPNR_PACKED_STRUCT(struct BelWirePOD { NPNR_PACKED_STRUCT(struct BelInfoPOD { RelPtr name; BelType type; + int32_t z; int32_t num_bel_wires; RelPtr bel_wires; }); @@ -85,10 +86,6 @@ NPNR_PACKED_STRUCT(struct WireInfoPOD { int32_t num_uphill, num_downhill; RelPtr pips_uphill, pips_downhill; - int32_t num_bels_downhill; - BelPortPOD bel_uphill; - RelPtr bels_downhill; - int32_t num_bel_pins; RelPtr bel_pins; }); diff --git a/ecp5/trellis_import.py b/ecp5/trellis_import.py index b0cbdd90..b5cd53f1 100755 --- a/ecp5/trellis_import.py +++ b/ecp5/trellis_import.py @@ -401,12 +401,6 @@ def write_database(dev_name, ddrg, endianness): for up in wire.arcsUphill: write_loc(up.rel, "rel_loc") bba.u32(up.id, "index") - if len(wire.belsDownhill) > 0: - bba.l("loc%d_wire%d_downbels" % (idx, wire_idx), "BelPortPOD") - for db in wire.belsDownhill: - write_loc(db.bel.rel, "rel_bel_loc") - bba.u32(db.bel.id, "bel_index") - bba.u32(portpins[ddrg.to_str(db.pin)], "port") if len(wire.belPins) > 0: bba.l("loc%d_wire%d_belpins" % (idx, wire_idx), "BelPortPOD") for bp in wire.belPins: @@ -421,15 +415,6 @@ def write_database(dev_name, ddrg, endianness): bba.u32(len(wire.arcsDownhill), "num_downhill") bba.r("loc%d_wire%d_uppips" % (idx, wire_idx) if len(wire.arcsUphill) > 0 else None, "pips_uphill") bba.r("loc%d_wire%d_downpips" % (idx, wire_idx) if len(wire.arcsDownhill) > 0 else None, "pips_downhill") - bba.u32(len(wire.belsDownhill), "num_bels_downhill") - write_loc(wire.belUphill.bel.rel, "uphill_bel_loc") - if wire.belUphill.pin != -1: - bba.u32(wire.belUphill.bel.id, "uphill_bel_idx") - bba.u32(portpins[ddrg.to_str(wire.belUphill.pin)], "uphill_bel_pin") - else: - bba.u32(0xFFFFFFFF, "bel_uphill.bel_index") - bba.u32(0, "bel_uphill.port") - bba.r("loc%d_wire%d_downbels" % (idx, wire_idx) if len(wire.belsDownhill) > 0 else None, "bels_downhill") bba.u32(len(wire.belPins), "num_bel_pins") bba.r("loc%d_wire%d_belpins" % (idx, wire_idx) if len(wire.belPins) > 0 else None, "bel_pins") @@ -447,6 +432,7 @@ def write_database(dev_name, ddrg, endianness): bel = loctype.bels[bel_idx] bba.s(ddrg.to_str(bel.name), "name") bba.u32(bel_types[ddrg.to_str(bel.type)], "type") + bba.u32(bel.z, "z") bba.u32(len(bel.wires), "num_bel_wires") bba.r("loc%d_bel%d_wires" % (idx, bel_idx), "bel_wires") -- cgit v1.2.3 From 54d1b8adcee3d1a89bf86b87be281e683d1cea93 Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 23 Jul 2018 10:53:07 +0200 Subject: ecp5: Implement new Grid APIs Signed-off-by: David Shah --- ecp5/arch.cc | 36 ++++++++++++++++++++++++++++++++++++ ecp5/arch.h | 14 ++++++++++++++ 2 files changed, 50 insertions(+) (limited to 'ecp5') diff --git a/ecp5/arch.cc b/ecp5/arch.cc index 90950492..a817651e 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -344,6 +344,42 @@ std::vector Arch::getBelPins(BelId bel) const return ret; } +BelId Arch::getBelByLocation(Loc loc) const { + if (loc.x >= chip_info->width || loc.y >= chip_info->height) + return BelId(); + const LocationTypePOD &locI = chip_info->locations[chip_info->location_type[loc.y * chip_info->width + loc.x]]; + for (int i = 0; i < locI.num_bels; i++) { + if (locI.bel_data[i].z == loc.z) { + BelId bi; + bi.location.x = loc.x; + bi.location.y = loc.y; + bi.index = i; + return bi; + } + } + return BelId(); +} + +BelRange Arch::getBelsByTile(int x, int y) const { + BelRange br; + + int num_bels = 0; + + if (x < chip_info->width && y < chip_info->height) { + const LocationTypePOD &locI = chip_info->locations[chip_info->location_type[y * chip_info->width + x]]; + num_bels = locI.num_bels; + } + + br.b.cursor_tile = y * chip_info->width + x; + br.e.cursor_tile = y * chip_info->width + x; + br.b.cursor_index = 0; + br.e.cursor_index = num_bels - 1; + br.b.chip = chip_info; + br.e.chip = chip_info; + ++br.e; + return br; +} + // ----------------------------------------------------------------------- void Arch::estimatePosition(BelId bel, int &x, int &y, bool &gb) const diff --git a/ecp5/arch.h b/ecp5/arch.h index 9d99da8c..92240719 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -426,6 +426,20 @@ struct Arch : BaseCtx bel_to_cell[bel] = IdString(); } + Loc getBelLocation(BelId bel) const + { + Loc loc; + loc.x = bel.location.x; + loc.y = bel.location.y; + loc.z = locInfo(bel)->bel_data[bel.index].z; + return loc; + } + + BelId getBelByLocation(Loc loc) const; + BelRange getBelsByTile(int x, int y) const; + + bool getBelGlobalBuf(BelId bel) const { return false; } + bool checkBelAvail(BelId bel) const { NPNR_ASSERT(bel != BelId()); -- cgit v1.2.3 From 38962d0f02720799d797326cc3d5ce906f853359 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Mon, 23 Jul 2018 12:45:31 +0200 Subject: clangformat Signed-off-by: Clifford Wolf --- ecp5/arch.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ecp5') diff --git a/ecp5/arch.cc b/ecp5/arch.cc index a817651e..7ac56378 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -344,7 +344,8 @@ std::vector Arch::getBelPins(BelId bel) const return ret; } -BelId Arch::getBelByLocation(Loc loc) const { +BelId Arch::getBelByLocation(Loc loc) const +{ if (loc.x >= chip_info->width || loc.y >= chip_info->height) return BelId(); const LocationTypePOD &locI = chip_info->locations[chip_info->location_type[loc.y * chip_info->width + loc.x]]; @@ -360,7 +361,8 @@ BelId Arch::getBelByLocation(Loc loc) const { return BelId(); } -BelRange Arch::getBelsByTile(int x, int y) const { +BelRange Arch::getBelsByTile(int x, int y) const +{ BelRange br; int num_bels = 0; -- cgit v1.2.3 From a3864c2936dbb47af431e5c1b3dfa08f10666936 Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 23 Jul 2018 13:02:37 +0200 Subject: ecp5: Add Add getGridDimX(), getGridDimY(), getTileDimZ() Signed-off-by: David Shah --- ecp5/arch.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ecp5') diff --git a/ecp5/arch.h b/ecp5/arch.h index 92240719..f53817fd 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -388,7 +388,12 @@ struct Arch : BaseCtx IdString portPinToId(PortPin type) const; PortPin portPinFromId(IdString id) const; + // ------------------------------------------------- + int getGridDimX() const { return chip_info->width; }; + int getGridDimY() const { return chip_info->height; }; + int getTileDimZ(int,int) const { return 4; }; + // ------------------------------------------------- BelId getBelByName(IdString name) const; -- cgit v1.2.3 From bfa1137fe03a62bf4bcef1d039d520116cc5a13a Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 23 Jul 2018 13:02:57 +0200 Subject: clangformat Signed-off-by: David Shah --- ecp5/arch.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ecp5') diff --git a/ecp5/arch.h b/ecp5/arch.h index f53817fd..aada2079 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -392,8 +392,8 @@ struct Arch : BaseCtx int getGridDimX() const { return chip_info->width; }; int getGridDimY() const { return chip_info->height; }; - int getTileDimZ(int,int) const { return 4; }; - + int getTileDimZ(int, int) const { return 4; }; + // ------------------------------------------------- BelId getBelByName(IdString name) 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 --- ecp5/arch.h | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'ecp5') diff --git a/ecp5/arch.h b/ecp5/arch.h index aada2079..b3ef5195 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -482,20 +482,6 @@ struct Arch : BaseCtx return range; } - BelRange getBelsByType(BelType type) const - { - BelRange range; -// FIXME -#if 0 - if (type == "TYPE_A") { - range.b.cursor = bels_type_a_begin; - range.e.cursor = bels_type_a_end; - } - ... -#endif - return range; - } - BelRange getBelsAtSameTile(BelId bel) const; BelType getBelType(BelId bel) const -- cgit v1.2.3