2018-07-05 19:32:13 +08:00
|
|
|
/*
|
|
|
|
* nextpnr -- Next Generation Place and Route
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Clifford Wolf <clifford@symbioticeda.com>
|
2018-07-06 20:02:37 +08:00
|
|
|
* Copyright (C) 2018 David Shah <david@symbioticeda.com>
|
2018-07-05 19:32:13 +08:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NEXTPNR_H
|
|
|
|
#error Include "arch.h" via "nextpnr.h" only.
|
|
|
|
#endif
|
|
|
|
|
2018-08-02 20:51:05 +08:00
|
|
|
#include <set>
|
2018-07-06 20:02:37 +08:00
|
|
|
#include <sstream>
|
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/**** Everything in this section must be kept in sync with chipdb.py ****/
|
|
|
|
|
|
|
|
template <typename T> struct RelPtr
|
|
|
|
{
|
|
|
|
int32_t offset;
|
|
|
|
|
|
|
|
// void set(const T *ptr) {
|
|
|
|
// offset = reinterpret_cast<const char*>(ptr) -
|
|
|
|
// reinterpret_cast<const char*>(this);
|
|
|
|
// }
|
|
|
|
|
|
|
|
const T *get() const { return reinterpret_cast<const T *>(reinterpret_cast<const char *>(this) + offset); }
|
|
|
|
|
|
|
|
const T &operator[](size_t index) const { return get()[index]; }
|
|
|
|
|
|
|
|
const T &operator*() const { return *(get()); }
|
|
|
|
|
|
|
|
const T *operator->() const { return get(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct BelWirePOD {
|
2018-07-06 18:15:07 +08:00
|
|
|
LocationPOD rel_wire_loc;
|
2018-07-06 02:59:11 +08:00
|
|
|
int32_t wire_index;
|
2018-08-09 01:08:43 +08:00
|
|
|
int32_t port;
|
2018-07-22 23:07:38 +08:00
|
|
|
int32_t type;
|
2018-07-06 02:59:11 +08:00
|
|
|
});
|
2018-07-05 19:32:13 +08:00
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct BelInfoPOD {
|
2018-07-06 02:59:11 +08:00
|
|
|
RelPtr<char> name;
|
2018-08-09 01:08:43 +08:00
|
|
|
int32_t type;
|
2018-07-23 16:32:42 +08:00
|
|
|
int32_t z;
|
2018-07-06 02:59:11 +08:00
|
|
|
int32_t num_bel_wires;
|
|
|
|
RelPtr<BelWirePOD> bel_wires;
|
|
|
|
});
|
2018-07-05 19:32:13 +08:00
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct BelPortPOD {
|
2018-07-06 18:15:07 +08:00
|
|
|
LocationPOD rel_bel_loc;
|
2018-07-06 02:59:11 +08:00
|
|
|
int32_t bel_index;
|
2018-08-09 01:08:43 +08:00
|
|
|
int32_t port;
|
2018-07-06 02:59:11 +08:00
|
|
|
});
|
2018-07-05 19:32:13 +08:00
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct PipInfoPOD {
|
2018-07-06 18:15:07 +08:00
|
|
|
LocationPOD rel_src_loc, rel_dst_loc;
|
2018-07-06 02:59:11 +08:00
|
|
|
int32_t src_idx, dst_idx;
|
|
|
|
int32_t delay;
|
|
|
|
int16_t tile_type;
|
|
|
|
int8_t pip_type;
|
|
|
|
int8_t padding_0;
|
|
|
|
});
|
2018-07-05 19:32:13 +08:00
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct PipLocatorPOD {
|
2018-07-06 18:15:07 +08:00
|
|
|
LocationPOD rel_loc;
|
2018-07-05 19:32:13 +08:00
|
|
|
int32_t index;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct WireInfoPOD {
|
2018-07-06 02:59:11 +08:00
|
|
|
RelPtr<char> name;
|
|
|
|
int32_t num_uphill, num_downhill;
|
|
|
|
RelPtr<PipLocatorPOD> pips_uphill, pips_downhill;
|
2018-07-05 19:32:13 +08:00
|
|
|
|
2018-07-22 23:07:38 +08:00
|
|
|
int32_t num_bel_pins;
|
|
|
|
RelPtr<BelPortPOD> bel_pins;
|
2018-07-06 02:59:11 +08:00
|
|
|
});
|
2018-07-05 19:32:13 +08:00
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct LocationTypePOD {
|
2018-07-06 02:59:11 +08:00
|
|
|
int32_t num_bels, num_wires, num_pips;
|
|
|
|
RelPtr<BelInfoPOD> bel_data;
|
|
|
|
RelPtr<WireInfoPOD> wire_data;
|
|
|
|
RelPtr<PipInfoPOD> pip_data;
|
2018-07-05 19:32:13 +08:00
|
|
|
});
|
|
|
|
|
2018-07-18 21:34:22 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct PIOInfoPOD {
|
2018-07-25 23:42:32 +08:00
|
|
|
LocationPOD abs_loc;
|
2018-07-18 21:34:22 +08:00
|
|
|
int32_t bel_index;
|
|
|
|
RelPtr<char> function_name;
|
|
|
|
int16_t bank;
|
|
|
|
int16_t padding;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct PackagePinPOD {
|
|
|
|
RelPtr<char> name;
|
2018-07-25 23:42:32 +08:00
|
|
|
LocationPOD abs_loc;
|
2018-07-18 21:34:22 +08:00
|
|
|
int32_t bel_index;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct PackageInfoPOD {
|
|
|
|
RelPtr<char> name;
|
|
|
|
int32_t num_pins;
|
|
|
|
RelPtr<PackagePinPOD> pin_data;
|
|
|
|
});
|
|
|
|
|
2018-08-01 21:23:27 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct TileNamePOD {
|
|
|
|
RelPtr<char> name;
|
|
|
|
int16_t type_idx;
|
|
|
|
int16_t padding;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct TileInfoPOD {
|
|
|
|
int32_t num_tiles;
|
|
|
|
RelPtr<TileNamePOD> tile_names;
|
|
|
|
});
|
|
|
|
|
2018-07-26 01:44:50 +08:00
|
|
|
enum TapDirection : int8_t
|
|
|
|
{
|
|
|
|
TAP_DIR_LEFT = 0,
|
|
|
|
TAP_DIR_RIGHT = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
enum GlobalQuadrant : int8_t
|
|
|
|
{
|
|
|
|
QUAD_UL = 0,
|
|
|
|
QUAD_UR = 1,
|
|
|
|
QUAD_LL = 2,
|
|
|
|
QUAD_LR = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct GlobalInfoPOD {
|
|
|
|
int16_t tap_col;
|
|
|
|
TapDirection tap_dir;
|
|
|
|
GlobalQuadrant quad;
|
2018-08-07 21:12:55 +08:00
|
|
|
int16_t spine_row;
|
|
|
|
int16_t spine_col;
|
2018-07-26 01:44:50 +08:00
|
|
|
});
|
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct ChipInfoPOD {
|
2018-07-06 02:59:11 +08:00
|
|
|
int32_t width, height;
|
2018-07-06 18:15:07 +08:00
|
|
|
int32_t num_tiles;
|
2018-07-06 02:59:11 +08:00
|
|
|
int32_t num_location_types;
|
2018-07-18 21:34:22 +08:00
|
|
|
int32_t num_packages, num_pios;
|
2018-07-06 02:59:11 +08:00
|
|
|
RelPtr<LocationTypePOD> locations;
|
|
|
|
RelPtr<int32_t> location_type;
|
2018-07-26 01:44:50 +08:00
|
|
|
RelPtr<GlobalInfoPOD> location_glbinfo;
|
2018-07-09 00:25:53 +08:00
|
|
|
RelPtr<RelPtr<char>> tiletype_names;
|
2018-07-18 21:34:22 +08:00
|
|
|
RelPtr<PackageInfoPOD> package_info;
|
|
|
|
RelPtr<PIOInfoPOD> pio_info;
|
2018-08-01 21:23:27 +08:00
|
|
|
RelPtr<TileInfoPOD> tile_info;
|
2018-07-06 02:59:11 +08:00
|
|
|
});
|
2018-07-05 19:32:13 +08:00
|
|
|
|
|
|
|
#if defined(_MSC_VER)
|
2018-07-06 18:15:07 +08:00
|
|
|
extern const char *chipdb_blob_25k;
|
|
|
|
extern const char *chipdb_blob_45k;
|
|
|
|
extern const char *chipdb_blob_85k;
|
2018-07-05 19:32:13 +08:00
|
|
|
#else
|
2018-07-06 18:15:07 +08:00
|
|
|
extern const char chipdb_blob_25k[];
|
|
|
|
extern const char chipdb_blob_45k[];
|
|
|
|
extern const char chipdb_blob_85k[];
|
2018-07-05 19:32:13 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/************************ End of chipdb section. ************************/
|
|
|
|
|
|
|
|
struct BelIterator
|
|
|
|
{
|
2018-07-06 02:59:11 +08:00
|
|
|
const ChipInfoPOD *chip;
|
|
|
|
int cursor_index;
|
|
|
|
int cursor_tile;
|
2018-07-05 19:32:13 +08:00
|
|
|
|
|
|
|
BelIterator operator++()
|
|
|
|
{
|
2018-07-06 02:59:11 +08:00
|
|
|
cursor_index++;
|
2018-07-06 18:15:07 +08:00
|
|
|
while (cursor_tile < chip->num_tiles &&
|
|
|
|
cursor_index >= chip->locations[chip->location_type[cursor_tile]].num_bels) {
|
2018-07-06 02:59:11 +08:00
|
|
|
cursor_index = 0;
|
|
|
|
cursor_tile++;
|
|
|
|
}
|
2018-07-05 19:32:13 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
BelIterator operator++(int)
|
|
|
|
{
|
|
|
|
BelIterator prior(*this);
|
2018-07-06 18:15:07 +08:00
|
|
|
++(*this);
|
2018-07-05 19:32:13 +08:00
|
|
|
return prior;
|
|
|
|
}
|
|
|
|
|
2018-07-06 02:59:11 +08:00
|
|
|
bool operator!=(const BelIterator &other) const
|
|
|
|
{
|
|
|
|
return cursor_index != other.cursor_index || cursor_tile != other.cursor_tile;
|
|
|
|
}
|
2018-07-05 19:32:13 +08:00
|
|
|
|
2018-07-06 02:59:11 +08:00
|
|
|
bool operator==(const BelIterator &other) const
|
|
|
|
{
|
|
|
|
return cursor_index == other.cursor_index && cursor_tile == other.cursor_tile;
|
|
|
|
}
|
2018-07-05 19:32:13 +08:00
|
|
|
|
|
|
|
BelId operator*() const
|
|
|
|
{
|
|
|
|
BelId ret;
|
2018-07-06 02:59:11 +08:00
|
|
|
ret.location.x = cursor_tile % chip->width;
|
|
|
|
ret.location.y = cursor_tile / chip->width;
|
|
|
|
ret.index = cursor_index;
|
2018-07-05 19:32:13 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BelRange
|
|
|
|
{
|
|
|
|
BelIterator b, e;
|
|
|
|
BelIterator begin() const { return b; }
|
|
|
|
BelIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct BelPinIterator
|
|
|
|
{
|
|
|
|
const BelPortPOD *ptr = nullptr;
|
2018-07-06 18:15:07 +08:00
|
|
|
Location wire_loc;
|
2018-07-05 19:32:13 +08:00
|
|
|
void operator++() { ptr++; }
|
|
|
|
bool operator!=(const BelPinIterator &other) const { return ptr != other.ptr; }
|
|
|
|
|
|
|
|
BelPin operator*() const
|
|
|
|
{
|
|
|
|
BelPin ret;
|
|
|
|
ret.bel.index = ptr->bel_index;
|
2018-07-06 02:59:11 +08:00
|
|
|
ret.bel.location = wire_loc + ptr->rel_bel_loc;
|
2018-08-09 01:08:43 +08:00
|
|
|
ret.pin.index = ptr->port;
|
2018-07-05 19:32:13 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BelPinRange
|
|
|
|
{
|
|
|
|
BelPinIterator b, e;
|
|
|
|
BelPinIterator begin() const { return b; }
|
|
|
|
BelPinIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct WireIterator
|
|
|
|
{
|
2018-07-06 02:59:11 +08:00
|
|
|
const ChipInfoPOD *chip;
|
|
|
|
int cursor_index;
|
|
|
|
int cursor_tile;
|
2018-07-05 19:32:13 +08:00
|
|
|
|
2018-07-06 02:59:11 +08:00
|
|
|
WireIterator operator++()
|
|
|
|
{
|
|
|
|
cursor_index++;
|
2018-07-06 18:15:07 +08:00
|
|
|
while (cursor_tile < chip->num_tiles &&
|
|
|
|
cursor_index >= chip->locations[chip->location_type[cursor_tile]].num_wires) {
|
2018-07-06 02:59:11 +08:00
|
|
|
cursor_index = 0;
|
|
|
|
cursor_tile++;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
WireIterator operator++(int)
|
|
|
|
{
|
|
|
|
WireIterator prior(*this);
|
2018-07-06 18:15:07 +08:00
|
|
|
++(*this);
|
2018-07-06 02:59:11 +08:00
|
|
|
return prior;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const WireIterator &other) const
|
|
|
|
{
|
|
|
|
return cursor_index != other.cursor_index || cursor_tile != other.cursor_tile;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const WireIterator &other) const
|
|
|
|
{
|
|
|
|
return cursor_index == other.cursor_index && cursor_tile == other.cursor_tile;
|
|
|
|
}
|
2018-07-05 19:32:13 +08:00
|
|
|
|
|
|
|
WireId operator*() const
|
|
|
|
{
|
|
|
|
WireId ret;
|
2018-07-06 02:59:11 +08:00
|
|
|
ret.location.x = cursor_tile % chip->width;
|
|
|
|
ret.location.y = cursor_tile / chip->width;
|
|
|
|
ret.index = cursor_index;
|
2018-07-05 19:32:13 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WireRange
|
|
|
|
{
|
|
|
|
WireIterator b, e;
|
|
|
|
WireIterator begin() const { return b; }
|
|
|
|
WireIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct AllPipIterator
|
|
|
|
{
|
2018-07-06 02:59:11 +08:00
|
|
|
const ChipInfoPOD *chip;
|
|
|
|
int cursor_index;
|
|
|
|
int cursor_tile;
|
2018-07-05 19:32:13 +08:00
|
|
|
|
2018-07-06 02:59:11 +08:00
|
|
|
AllPipIterator operator++()
|
|
|
|
{
|
|
|
|
cursor_index++;
|
2018-07-06 18:15:07 +08:00
|
|
|
while (cursor_tile < chip->num_tiles &&
|
|
|
|
cursor_index >= chip->locations[chip->location_type[cursor_tile]].num_pips) {
|
2018-07-06 02:59:11 +08:00
|
|
|
cursor_index = 0;
|
|
|
|
cursor_tile++;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
AllPipIterator operator++(int)
|
|
|
|
{
|
2018-07-06 18:15:07 +08:00
|
|
|
AllPipIterator prior(*this);
|
|
|
|
++(*this);
|
2018-07-06 02:59:11 +08:00
|
|
|
return prior;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const AllPipIterator &other) const
|
|
|
|
{
|
|
|
|
return cursor_index != other.cursor_index || cursor_tile != other.cursor_tile;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const AllPipIterator &other) const
|
|
|
|
{
|
|
|
|
return cursor_index == other.cursor_index && cursor_tile == other.cursor_tile;
|
|
|
|
}
|
2018-07-05 19:32:13 +08:00
|
|
|
|
|
|
|
PipId operator*() const
|
|
|
|
{
|
|
|
|
PipId ret;
|
2018-07-06 02:59:11 +08:00
|
|
|
ret.location.x = cursor_tile % chip->width;
|
|
|
|
ret.location.y = cursor_tile / chip->width;
|
|
|
|
ret.index = cursor_index;
|
2018-07-05 19:32:13 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AllPipRange
|
|
|
|
{
|
|
|
|
AllPipIterator b, e;
|
|
|
|
AllPipIterator begin() const { return b; }
|
|
|
|
AllPipIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct PipIterator
|
|
|
|
{
|
2018-07-06 02:59:11 +08:00
|
|
|
|
|
|
|
const PipLocatorPOD *cursor = nullptr;
|
|
|
|
Location wire_loc;
|
2018-07-05 19:32:13 +08:00
|
|
|
|
|
|
|
void operator++() { cursor++; }
|
|
|
|
bool operator!=(const PipIterator &other) const { return cursor != other.cursor; }
|
|
|
|
|
|
|
|
PipId operator*() const
|
|
|
|
{
|
|
|
|
PipId ret;
|
2018-07-06 02:59:11 +08:00
|
|
|
ret.index = cursor->index;
|
2018-07-06 18:15:07 +08:00
|
|
|
ret.location = wire_loc + cursor->rel_loc;
|
2018-07-05 19:32:13 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PipRange
|
|
|
|
{
|
|
|
|
PipIterator b, e;
|
|
|
|
PipIterator begin() const { return b; }
|
|
|
|
PipIterator end() const { return e; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ArchArgs
|
|
|
|
{
|
2018-08-04 17:48:29 +08:00
|
|
|
enum ArchArgsTypes
|
2018-07-05 19:32:13 +08:00
|
|
|
{
|
|
|
|
NONE,
|
2018-07-06 02:59:11 +08:00
|
|
|
LFE5U_25F,
|
|
|
|
LFE5U_45F,
|
|
|
|
LFE5U_85F,
|
2018-10-16 21:37:24 +08:00
|
|
|
LFE5UM_25F,
|
|
|
|
LFE5UM_45F,
|
|
|
|
LFE5UM_85F,
|
|
|
|
LFE5UM5G_25F,
|
|
|
|
LFE5UM5G_45F,
|
|
|
|
LFE5UM5G_85F,
|
2018-07-05 19:32:13 +08:00
|
|
|
} type = NONE;
|
|
|
|
std::string package;
|
2018-07-06 02:59:11 +08:00
|
|
|
int speed = 6;
|
2018-07-05 19:32:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Arch : BaseCtx
|
|
|
|
{
|
2018-07-15 01:50:29 +08:00
|
|
|
const ChipInfoPOD *chip_info;
|
2018-07-18 22:01:53 +08:00
|
|
|
const PackageInfoPOD *package_info;
|
2018-07-15 01:50:29 +08:00
|
|
|
|
2018-07-06 20:02:37 +08:00
|
|
|
mutable std::unordered_map<IdString, BelId> bel_by_name;
|
|
|
|
mutable std::unordered_map<IdString, WireId> wire_by_name;
|
|
|
|
mutable std::unordered_map<IdString, PipId> pip_by_name;
|
2018-07-05 19:32:13 +08:00
|
|
|
|
2018-08-19 02:04:32 +08:00
|
|
|
std::vector<CellInfo *> bel_to_cell;
|
2018-08-05 22:32:12 +08:00
|
|
|
std::unordered_map<WireId, NetInfo *> wire_to_net;
|
|
|
|
std::unordered_map<PipId, NetInfo *> pip_to_net;
|
2018-07-05 19:32:13 +08:00
|
|
|
|
|
|
|
ArchArgs args;
|
|
|
|
Arch(ArchArgs args);
|
|
|
|
|
2018-07-31 23:01:38 +08:00
|
|
|
std::string getChipName() const;
|
2018-07-05 19:32:13 +08:00
|
|
|
|
2018-07-06 02:59:11 +08:00
|
|
|
IdString archId() const { return id("ecp5"); }
|
2018-08-07 01:32:17 +08:00
|
|
|
ArchArgs archArgs() const { return args; }
|
2018-07-05 19:32:13 +08:00
|
|
|
IdString archArgsToId(ArchArgs args) const;
|
|
|
|
|
2018-07-23 19:02:37 +08:00
|
|
|
// -------------------------------------------------
|
2018-07-05 19:32:13 +08:00
|
|
|
|
2018-07-23 19:02:37 +08:00
|
|
|
int getGridDimX() const { return chip_info->width; };
|
|
|
|
int getGridDimY() const { return chip_info->height; };
|
2018-08-09 16:39:40 +08:00
|
|
|
int getTileBelDimZ(int, int) const { return 4; };
|
|
|
|
int getTilePipDimZ(int, int) const { return 1; };
|
2018-07-23 19:02:57 +08:00
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
// -------------------------------------------------
|
|
|
|
|
2018-07-15 01:50:23 +08:00
|
|
|
BelId getBelByName(IdString name) const;
|
|
|
|
|
2018-07-06 18:15:07 +08:00
|
|
|
template <typename Id> const LocationTypePOD *locInfo(Id &id) const
|
|
|
|
{
|
|
|
|
return &(chip_info->locations[chip_info->location_type[id.location.y * chip_info->width + id.location.x]]);
|
|
|
|
}
|
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
IdString getBelName(BelId bel) const
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2018-07-06 20:02:37 +08:00
|
|
|
std::stringstream name;
|
|
|
|
name << "X" << bel.location.x << "/Y" << bel.location.y << "/" << locInfo(bel)->bel_data[bel.index].name.get();
|
|
|
|
return id(name.str());
|
2018-07-05 19:32:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t getBelChecksum(BelId bel) const { return bel.index; }
|
|
|
|
|
2018-08-19 02:04:32 +08:00
|
|
|
const int max_loc_bels = 20;
|
|
|
|
int getBelFlatIndex(BelId bel) const
|
|
|
|
{
|
|
|
|
return (bel.location.y * chip_info->width + bel.location.x) * max_loc_bels + bel.index;
|
|
|
|
}
|
|
|
|
|
2018-08-05 22:32:12 +08:00
|
|
|
void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength)
|
2018-07-15 01:50:18 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2018-08-19 02:04:32 +08:00
|
|
|
int idx = getBelFlatIndex(bel);
|
|
|
|
NPNR_ASSERT(bel_to_cell.at(idx) == nullptr);
|
|
|
|
bel_to_cell[idx] = cell;
|
2018-08-05 22:32:12 +08:00
|
|
|
cell->bel = bel;
|
|
|
|
cell->belStrength = strength;
|
2018-08-03 18:00:07 +08:00
|
|
|
refreshUiBel(bel);
|
2018-07-15 01:50:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void unbindBel(BelId bel)
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2018-08-19 02:04:32 +08:00
|
|
|
int idx = getBelFlatIndex(bel);
|
|
|
|
NPNR_ASSERT(bel_to_cell.at(idx) != nullptr);
|
|
|
|
bel_to_cell[idx]->bel = BelId();
|
|
|
|
bel_to_cell[idx]->belStrength = STRENGTH_NONE;
|
|
|
|
bel_to_cell[idx] = nullptr;
|
2018-08-03 18:00:07 +08:00
|
|
|
refreshUiBel(bel);
|
2018-07-15 01:50:18 +08:00
|
|
|
}
|
|
|
|
|
2018-07-23 16:53:07 +08:00
|
|
|
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;
|
|
|
|
|
2018-11-01 00:22:34 +08:00
|
|
|
bool getBelGlobalBuf(BelId bel) const { return getBelType(bel) == id_DCCA; }
|
2018-07-23 16:53:07 +08:00
|
|
|
|
2018-07-15 01:50:23 +08:00
|
|
|
bool checkBelAvail(BelId bel) const
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2018-08-19 02:04:32 +08:00
|
|
|
return bel_to_cell[getBelFlatIndex(bel)] == nullptr;
|
2018-07-15 01:50:23 +08:00
|
|
|
}
|
|
|
|
|
2018-08-05 22:32:12 +08:00
|
|
|
CellInfo *getBoundBelCell(BelId bel) const
|
2018-07-15 01:50:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2018-08-19 02:04:32 +08:00
|
|
|
return bel_to_cell[getBelFlatIndex(bel)];
|
2018-07-15 01:50:23 +08:00
|
|
|
}
|
|
|
|
|
2018-08-05 22:32:12 +08:00
|
|
|
CellInfo *getConflictingBelCell(BelId bel) const
|
2018-07-15 01:50:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2018-08-19 02:04:32 +08:00
|
|
|
return bel_to_cell[getBelFlatIndex(bel)];
|
2018-07-15 01:50:23 +08:00
|
|
|
}
|
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
BelRange getBels() const
|
|
|
|
{
|
|
|
|
BelRange range;
|
2018-07-06 18:15:07 +08:00
|
|
|
range.b.cursor_tile = 0;
|
|
|
|
range.b.cursor_index = -1;
|
|
|
|
range.b.chip = chip_info;
|
|
|
|
++range.b; //-1 and then ++ deals with the case of no Bels in the first tile
|
|
|
|
range.e.cursor_tile = chip_info->width * chip_info->height;
|
|
|
|
range.e.cursor_index = 0;
|
|
|
|
range.e.chip = chip_info;
|
2018-07-05 19:32:13 +08:00
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
2018-08-09 01:08:43 +08:00
|
|
|
IdString getBelType(BelId bel) const
|
2018-07-05 19:32:13 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2018-08-09 01:08:43 +08:00
|
|
|
IdString id;
|
|
|
|
id.index = locInfo(bel)->bel_data[bel.index].type;
|
|
|
|
return id;
|
2018-07-05 19:32:13 +08:00
|
|
|
}
|
|
|
|
|
2018-08-14 23:16:14 +08:00
|
|
|
std::vector<std::pair<IdString, std::string>> getBelAttrs(BelId) const
|
|
|
|
{
|
|
|
|
std::vector<std::pair<IdString, std::string>> ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-08-09 01:08:43 +08:00
|
|
|
WireId getBelPinWire(BelId bel, IdString pin) const;
|
2018-07-15 01:50:23 +08:00
|
|
|
|
2018-07-22 23:07:38 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-08-09 01:08:43 +08:00
|
|
|
std::vector<IdString> getBelPins(BelId bel) const;
|
2018-07-22 23:07:38 +08:00
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
// -------------------------------------------------
|
|
|
|
|
2018-07-15 01:50:23 +08:00
|
|
|
WireId getWireByName(IdString name) const;
|
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
IdString getWireName(WireId wire) const
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-07-06 20:02:37 +08:00
|
|
|
|
|
|
|
std::stringstream name;
|
|
|
|
name << "X" << wire.location.x << "/Y" << wire.location.y << "/"
|
|
|
|
<< locInfo(wire)->wire_data[wire.index].name.get();
|
|
|
|
return id(name.str());
|
2018-07-05 19:32:13 +08:00
|
|
|
}
|
|
|
|
|
2018-07-26 22:38:11 +08:00
|
|
|
IdString getWireType(WireId wire) const { return IdString(); }
|
|
|
|
|
2018-08-14 23:16:14 +08:00
|
|
|
std::vector<std::pair<IdString, std::string>> getWireAttrs(WireId) const
|
|
|
|
{
|
|
|
|
std::vector<std::pair<IdString, std::string>> ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
uint32_t getWireChecksum(WireId wire) const { return wire.index; }
|
|
|
|
|
2018-08-05 22:32:12 +08:00
|
|
|
void bindWire(WireId wire, NetInfo *net, PlaceStrength strength)
|
2018-07-15 01:50:18 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-08-05 22:32:12 +08:00
|
|
|
NPNR_ASSERT(wire_to_net[wire] == nullptr);
|
2018-07-15 01:50:18 +08:00
|
|
|
wire_to_net[wire] = net;
|
2018-08-05 22:32:12 +08:00
|
|
|
net->wires[wire].pip = PipId();
|
|
|
|
net->wires[wire].strength = strength;
|
2018-07-15 01:50:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void unbindWire(WireId wire)
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-08-05 22:32:12 +08:00
|
|
|
NPNR_ASSERT(wire_to_net[wire] != nullptr);
|
2018-07-15 01:50:18 +08:00
|
|
|
|
2018-08-05 22:32:12 +08:00
|
|
|
auto &net_wires = wire_to_net[wire]->wires;
|
2018-07-15 01:50:18 +08:00
|
|
|
auto it = net_wires.find(wire);
|
|
|
|
NPNR_ASSERT(it != net_wires.end());
|
|
|
|
|
|
|
|
auto pip = it->second.pip;
|
|
|
|
if (pip != PipId()) {
|
2018-08-05 22:32:12 +08:00
|
|
|
pip_to_net[pip] = nullptr;
|
2018-07-15 01:50:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
net_wires.erase(it);
|
2018-08-05 22:32:12 +08:00
|
|
|
wire_to_net[wire] = nullptr;
|
2018-07-15 01:50:18 +08:00
|
|
|
}
|
|
|
|
|
2018-07-15 01:50:23 +08:00
|
|
|
bool checkWireAvail(WireId wire) const
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-08-05 22:32:12 +08:00
|
|
|
return wire_to_net.find(wire) == wire_to_net.end() || wire_to_net.at(wire) == nullptr;
|
2018-07-15 01:50:23 +08:00
|
|
|
}
|
|
|
|
|
2018-08-05 22:32:12 +08:00
|
|
|
NetInfo *getBoundWireNet(WireId wire) const
|
2018-07-15 01:50:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
|
|
|
if (wire_to_net.find(wire) == wire_to_net.end())
|
2018-08-05 22:32:12 +08:00
|
|
|
return nullptr;
|
2018-07-15 01:50:23 +08:00
|
|
|
else
|
|
|
|
return wire_to_net.at(wire);
|
|
|
|
}
|
|
|
|
|
2018-08-05 22:32:12 +08:00
|
|
|
NetInfo *getConflictingWireNet(WireId wire) const
|
2018-07-15 01:50:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
|
|
|
if (wire_to_net.find(wire) == wire_to_net.end())
|
2018-08-05 22:32:12 +08:00
|
|
|
return nullptr;
|
2018-07-15 01:50:23 +08:00
|
|
|
else
|
|
|
|
return wire_to_net.at(wire);
|
|
|
|
}
|
|
|
|
|
2018-07-21 19:38:44 +08:00
|
|
|
DelayInfo getWireDelay(WireId wire) const
|
|
|
|
{
|
|
|
|
DelayInfo delay;
|
2018-07-22 23:07:38 +08:00
|
|
|
delay.delay = 0;
|
2018-07-21 19:38:44 +08:00
|
|
|
return delay;
|
|
|
|
}
|
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
WireRange getWires() const
|
|
|
|
{
|
|
|
|
WireRange range;
|
2018-07-06 18:15:07 +08:00
|
|
|
range.b.cursor_tile = 0;
|
|
|
|
range.b.cursor_index = -1;
|
|
|
|
range.b.chip = chip_info;
|
|
|
|
++range.b; //-1 and then ++ deals with the case of no wries in the first tile
|
|
|
|
range.e.cursor_tile = chip_info->width * chip_info->height;
|
|
|
|
range.e.cursor_index = 0;
|
|
|
|
range.e.chip = chip_info;
|
2018-07-05 19:32:13 +08:00
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
2018-07-26 19:05:15 +08:00
|
|
|
IdString getWireBasename(WireId wire) const { return id(locInfo(wire)->wire_data[wire.index].name.get()); }
|
|
|
|
|
|
|
|
WireId getWireByLocAndBasename(Location loc, std::string basename) const
|
|
|
|
{
|
|
|
|
WireId wireId;
|
|
|
|
wireId.location = loc;
|
|
|
|
for (int i = 0; i < locInfo(wireId)->num_wires; i++) {
|
|
|
|
if (locInfo(wireId)->wire_data[i].name.get() == basename) {
|
|
|
|
wireId.index = i;
|
|
|
|
return wireId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return WireId();
|
|
|
|
}
|
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
// -------------------------------------------------
|
|
|
|
|
2018-07-15 01:50:23 +08:00
|
|
|
PipId getPipByName(IdString name) const;
|
2018-07-05 19:32:13 +08:00
|
|
|
IdString getPipName(PipId pip) const;
|
|
|
|
|
2018-07-26 22:38:11 +08:00
|
|
|
IdString getPipType(PipId pip) const { return IdString(); }
|
|
|
|
|
2018-08-14 23:16:14 +08:00
|
|
|
std::vector<std::pair<IdString, std::string>> getPipAttrs(PipId) const
|
|
|
|
{
|
|
|
|
std::vector<std::pair<IdString, std::string>> ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
uint32_t getPipChecksum(PipId pip) const { return pip.index; }
|
|
|
|
|
2018-08-05 22:32:12 +08:00
|
|
|
void bindPip(PipId pip, NetInfo *net, PlaceStrength strength)
|
2018-07-15 01:50:18 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
2018-08-05 22:32:12 +08:00
|
|
|
NPNR_ASSERT(pip_to_net[pip] == nullptr);
|
2018-07-15 01:50:18 +08:00
|
|
|
|
|
|
|
pip_to_net[pip] = net;
|
|
|
|
|
|
|
|
WireId dst;
|
|
|
|
dst.index = locInfo(pip)->pip_data[pip.index].dst_idx;
|
|
|
|
dst.location = pip.location + locInfo(pip)->pip_data[pip.index].rel_dst_loc;
|
2018-08-05 22:32:12 +08:00
|
|
|
NPNR_ASSERT(wire_to_net[dst] == nullptr);
|
2018-07-15 01:50:18 +08:00
|
|
|
wire_to_net[dst] = net;
|
2018-08-05 22:32:12 +08:00
|
|
|
net->wires[dst].pip = pip;
|
|
|
|
net->wires[dst].strength = strength;
|
2018-07-15 01:50:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void unbindPip(PipId pip)
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
2018-08-05 22:32:12 +08:00
|
|
|
NPNR_ASSERT(pip_to_net[pip] != nullptr);
|
2018-07-15 01:50:18 +08:00
|
|
|
|
|
|
|
WireId dst;
|
|
|
|
dst.index = locInfo(pip)->pip_data[pip.index].dst_idx;
|
|
|
|
dst.location = pip.location + locInfo(pip)->pip_data[pip.index].rel_dst_loc;
|
2018-08-05 22:32:12 +08:00
|
|
|
NPNR_ASSERT(wire_to_net[dst] != nullptr);
|
|
|
|
wire_to_net[dst] = nullptr;
|
|
|
|
pip_to_net[pip]->wires.erase(dst);
|
2018-07-15 01:50:18 +08:00
|
|
|
|
2018-08-05 22:32:12 +08:00
|
|
|
pip_to_net[pip] = nullptr;
|
2018-07-15 01:50:18 +08:00
|
|
|
}
|
|
|
|
|
2018-07-15 01:50:23 +08:00
|
|
|
bool checkPipAvail(PipId pip) const
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
2018-08-05 22:32:12 +08:00
|
|
|
return pip_to_net.find(pip) == pip_to_net.end() || pip_to_net.at(pip) == nullptr;
|
2018-07-15 01:50:23 +08:00
|
|
|
}
|
|
|
|
|
2018-08-05 22:32:12 +08:00
|
|
|
NetInfo *getBoundPipNet(PipId pip) const
|
2018-07-15 01:50:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
|
|
|
if (pip_to_net.find(pip) == pip_to_net.end())
|
2018-08-05 22:32:12 +08:00
|
|
|
return nullptr;
|
2018-07-15 01:50:23 +08:00
|
|
|
else
|
|
|
|
return pip_to_net.at(pip);
|
|
|
|
}
|
|
|
|
|
2018-08-05 22:32:12 +08:00
|
|
|
NetInfo *getConflictingPipNet(PipId pip) const
|
2018-07-15 01:50:23 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
|
|
|
if (pip_to_net.find(pip) == pip_to_net.end())
|
2018-08-05 22:32:12 +08:00
|
|
|
return nullptr;
|
2018-07-15 01:50:23 +08:00
|
|
|
else
|
|
|
|
return pip_to_net.at(pip);
|
|
|
|
}
|
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
AllPipRange getPips() const
|
|
|
|
{
|
|
|
|
AllPipRange range;
|
2018-07-06 18:15:07 +08:00
|
|
|
range.b.cursor_tile = 0;
|
|
|
|
range.b.cursor_index = -1;
|
|
|
|
range.b.chip = chip_info;
|
|
|
|
++range.b; //-1 and then ++ deals with the case of no wries in the first tile
|
|
|
|
range.e.cursor_tile = chip_info->width * chip_info->height;
|
|
|
|
range.e.cursor_index = 0;
|
|
|
|
range.e.chip = chip_info;
|
2018-07-05 19:32:13 +08:00
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
|
|
|
WireId getPipSrcWire(PipId pip) const
|
|
|
|
{
|
|
|
|
WireId wire;
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
2018-07-06 18:15:07 +08:00
|
|
|
wire.index = locInfo(pip)->pip_data[pip.index].src_idx;
|
|
|
|
wire.location = pip.location + locInfo(pip)->pip_data[pip.index].rel_src_loc;
|
2018-07-05 19:32:13 +08:00
|
|
|
return wire;
|
|
|
|
}
|
|
|
|
|
|
|
|
WireId getPipDstWire(PipId pip) const
|
|
|
|
{
|
|
|
|
WireId wire;
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
2018-07-06 18:15:07 +08:00
|
|
|
wire.index = locInfo(pip)->pip_data[pip.index].dst_idx;
|
|
|
|
wire.location = pip.location + locInfo(pip)->pip_data[pip.index].rel_dst_loc;
|
2018-07-05 19:32:13 +08:00
|
|
|
return wire;
|
|
|
|
}
|
|
|
|
|
|
|
|
DelayInfo getPipDelay(PipId pip) const
|
|
|
|
{
|
|
|
|
DelayInfo delay;
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
2018-08-19 21:29:16 +08:00
|
|
|
delay.delay = locInfo(pip)->pip_data[pip.index].delay;
|
2018-07-05 19:32:13 +08:00
|
|
|
return delay;
|
|
|
|
}
|
|
|
|
|
|
|
|
PipRange getPipsDownhill(WireId wire) const
|
|
|
|
{
|
|
|
|
PipRange range;
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-07-06 18:15:07 +08:00
|
|
|
range.b.cursor = locInfo(wire)->wire_data[wire.index].pips_downhill.get();
|
2018-07-08 19:29:13 +08:00
|
|
|
range.b.wire_loc = wire.location;
|
2018-07-06 18:15:07 +08:00
|
|
|
range.e.cursor = range.b.cursor + locInfo(wire)->wire_data[wire.index].num_downhill;
|
2018-07-08 19:29:13 +08:00
|
|
|
range.e.wire_loc = wire.location;
|
2018-07-05 19:32:13 +08:00
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
|
|
|
PipRange getPipsUphill(WireId wire) const
|
|
|
|
{
|
|
|
|
PipRange range;
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-07-06 18:15:07 +08:00
|
|
|
range.b.cursor = locInfo(wire)->wire_data[wire.index].pips_uphill.get();
|
2018-07-08 19:29:13 +08:00
|
|
|
range.b.wire_loc = wire.location;
|
2018-07-06 18:15:07 +08:00
|
|
|
range.e.cursor = range.b.cursor + locInfo(wire)->wire_data[wire.index].num_uphill;
|
2018-07-08 19:29:13 +08:00
|
|
|
range.e.wire_loc = wire.location;
|
2018-07-05 19:32:13 +08:00
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
|
|
|
PipRange getWireAliases(WireId wire) const
|
|
|
|
{
|
|
|
|
PipRange range;
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
|
|
|
range.b.cursor = nullptr;
|
|
|
|
range.e.cursor = nullptr;
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
2018-08-01 21:30:28 +08:00
|
|
|
std::string getPipTilename(PipId pip) const
|
|
|
|
{
|
|
|
|
auto &tileloc = chip_info->tile_info[pip.location.y * chip_info->width + pip.location.x];
|
|
|
|
for (int i = 0; i < tileloc.num_tiles; i++) {
|
|
|
|
if (tileloc.tile_names[i].type_idx == locInfo(pip)->pip_data[pip.index].tile_type)
|
|
|
|
return tileloc.tile_names[i].name.get();
|
|
|
|
}
|
|
|
|
NPNR_ASSERT_FALSE("failed to find Pip tile");
|
|
|
|
}
|
|
|
|
|
2018-07-09 00:25:53 +08:00
|
|
|
std::string getPipTiletype(PipId pip) const
|
|
|
|
{
|
|
|
|
return chip_info->tiletype_names[locInfo(pip)->pip_data[pip.index].tile_type].get();
|
|
|
|
}
|
|
|
|
|
2018-08-09 16:39:40 +08:00
|
|
|
Loc getPipLocation(PipId pip) const
|
|
|
|
{
|
|
|
|
Loc loc;
|
|
|
|
loc.x = pip.location.x;
|
|
|
|
loc.y = pip.location.y;
|
|
|
|
loc.z = 0;
|
|
|
|
return loc;
|
|
|
|
}
|
|
|
|
|
2018-07-27 00:48:07 +08:00
|
|
|
int8_t getPipClass(PipId pip) const { return locInfo(pip)->pip_data[pip.index].pip_type; }
|
2018-07-09 18:02:31 +08:00
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
BelId getPackagePinBel(const std::string &pin) const;
|
|
|
|
std::string getBelPackagePin(BelId bel) const;
|
2018-07-24 01:15:59 +08:00
|
|
|
int getPioBelBank(BelId bel) const;
|
|
|
|
// For getting GCLK, PLL, Vref, etc, pins
|
|
|
|
std::string getPioFunctionName(BelId bel) const;
|
|
|
|
BelId getPioByFunctionName(const std::string &name) const;
|
2018-07-05 19:32:13 +08:00
|
|
|
|
2018-08-09 01:08:43 +08:00
|
|
|
PortType getBelPinType(BelId bel, IdString pin) const;
|
2018-07-22 23:07:38 +08:00
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
// -------------------------------------------------
|
|
|
|
|
2018-07-12 23:22:29 +08:00
|
|
|
GroupId getGroupByName(IdString name) const { return GroupId(); }
|
|
|
|
IdString getGroupName(GroupId group) const { return IdString(); }
|
|
|
|
std::vector<GroupId> getGroups() const { return std::vector<GroupId>(); }
|
|
|
|
std::vector<BelId> getGroupBels(GroupId group) const { return std::vector<BelId>(); }
|
|
|
|
std::vector<WireId> getGroupWires(GroupId group) const { return std::vector<WireId>(); }
|
|
|
|
std::vector<PipId> getGroupPips(GroupId group) const { return std::vector<PipId>(); }
|
|
|
|
std::vector<GroupId> getGroupGroups(GroupId group) const { return std::vector<GroupId>(); }
|
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
|
2018-07-05 19:32:13 +08:00
|
|
|
delay_t estimateDelay(WireId src, WireId dst) const;
|
2018-07-31 10:19:30 +08:00
|
|
|
delay_t predictDelay(const NetInfo *net_info, const PortRef &sink) const;
|
2018-07-05 19:32:13 +08:00
|
|
|
delay_t getDelayEpsilon() const { return 20; }
|
|
|
|
delay_t getRipupDelayPenalty() const { return 200; }
|
|
|
|
float getDelayNS(delay_t v) const { return v * 0.001; }
|
|
|
|
uint32_t getDelayChecksum(delay_t v) const { return v; }
|
2018-08-06 13:33:14 +08:00
|
|
|
bool getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t &budget) const;
|
2018-07-05 19:32:13 +08:00
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
|
2018-07-13 21:16:44 +08:00
|
|
|
bool pack();
|
2018-07-12 00:15:08 +08:00
|
|
|
bool place();
|
2018-07-12 00:04:09 +08:00
|
|
|
bool route();
|
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
|
2018-07-15 01:50:23 +08:00
|
|
|
std::vector<GraphicElement> getDecalGraphics(DecalId decal) const;
|
|
|
|
|
2018-07-11 20:27:15 +08:00
|
|
|
DecalXY getBelDecal(BelId bel) const;
|
|
|
|
DecalXY getWireDecal(WireId wire) const;
|
|
|
|
DecalXY getPipDecal(PipId pip) const;
|
2018-07-12 23:22:29 +08:00
|
|
|
DecalXY getGroupDecal(GroupId group) const;
|
2018-07-05 19:32:13 +08:00
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
|
|
|
|
// Get the delay through a cell from one port to another, returning false
|
|
|
|
// if no path exists
|
2018-07-30 22:59:30 +08:00
|
|
|
bool getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, DelayInfo &delay) const;
|
2018-08-08 20:37:59 +08:00
|
|
|
// Get the port class, also setting clockPort if applicable
|
|
|
|
TimingPortClass getPortTimingClass(const CellInfo *cell, IdString port, IdString &clockPort) const;
|
2018-07-05 19:32:13 +08:00
|
|
|
// Return true if a port is a net
|
|
|
|
bool isGlobalNet(const NetInfo *net) const;
|
2018-07-15 01:50:23 +08:00
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
// Placement validity checks
|
|
|
|
bool isValidBelForCell(CellInfo *cell, BelId bel) const;
|
|
|
|
bool isBelLocationValid(BelId bel) const;
|
2018-07-17 22:18:06 +08:00
|
|
|
|
|
|
|
// Helper function for above
|
|
|
|
bool slicesCompatible(const std::vector<const CellInfo *> &cells) const;
|
|
|
|
|
2018-08-19 01:14:18 +08:00
|
|
|
void assignArchInfo();
|
|
|
|
|
2018-08-01 21:58:38 +08:00
|
|
|
std::vector<std::pair<std::string, std::string>> getTilesAtLocation(int row, int col);
|
|
|
|
std::string getTileByTypeAndLocation(int row, int col, std::string type) const
|
|
|
|
{
|
|
|
|
auto &tileloc = chip_info->tile_info[row * chip_info->width + col];
|
|
|
|
for (int i = 0; i < tileloc.num_tiles; i++) {
|
|
|
|
if (chip_info->tiletype_names[tileloc.tile_names[i].type_idx].get() == type)
|
|
|
|
return tileloc.tile_names[i].name.get();
|
|
|
|
}
|
|
|
|
NPNR_ASSERT_FALSE_STR("no tile at (" + std::to_string(col) + ", " + std::to_string(row) + ") with type " +
|
|
|
|
type);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getTileByTypeAndLocation(int row, int col, const std::set<std::string> &type) const
|
|
|
|
{
|
|
|
|
auto &tileloc = chip_info->tile_info[row * chip_info->width + col];
|
|
|
|
for (int i = 0; i < tileloc.num_tiles; i++) {
|
|
|
|
if (type.count(chip_info->tiletype_names[tileloc.tile_names[i].type_idx].get()))
|
|
|
|
return tileloc.tile_names[i].name.get();
|
|
|
|
}
|
|
|
|
NPNR_ASSERT_FALSE_STR("no tile at (" + std::to_string(col) + ", " + std::to_string(row) + ") with type in set");
|
|
|
|
}
|
2018-07-26 19:05:15 +08:00
|
|
|
|
|
|
|
GlobalInfoPOD globalInfoAtLoc(Location loc);
|
|
|
|
|
2018-10-31 18:48:54 +08:00
|
|
|
// Apply LPF constraints to the context
|
|
|
|
bool applyLPF(std::string filename, std::istream &in);
|
|
|
|
|
2018-07-26 19:05:15 +08:00
|
|
|
IdString id_trellis_slice;
|
|
|
|
IdString id_clk, id_lsr;
|
|
|
|
IdString id_clkmux, id_lsrmux;
|
|
|
|
IdString id_srmode, id_mode;
|
2018-07-05 19:32:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_END
|