2018-06-30 02:36:34 +08:00
|
|
|
/*
|
|
|
|
* nextpnr -- Next Generation Place and Route
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Clifford Wolf <clifford@symbioticeda.com>
|
|
|
|
*
|
|
|
|
* 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 "archdefs.h" via "nextpnr.h" only.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
typedef int delay_t;
|
|
|
|
|
|
|
|
struct DelayInfo
|
|
|
|
{
|
|
|
|
delay_t delay = 0;
|
|
|
|
|
2018-07-21 19:52:59 +08:00
|
|
|
delay_t minRaiseDelay() const { return delay; }
|
|
|
|
delay_t maxRaiseDelay() const { return delay; }
|
|
|
|
|
|
|
|
delay_t minFallDelay() const { return delay; }
|
|
|
|
delay_t maxFallDelay() const { return delay; }
|
|
|
|
|
|
|
|
delay_t minDelay() const { return delay; }
|
|
|
|
delay_t maxDelay() const { return delay; }
|
2018-06-30 02:36:34 +08:00
|
|
|
|
|
|
|
DelayInfo operator+(const DelayInfo &other) const
|
|
|
|
{
|
|
|
|
DelayInfo ret;
|
|
|
|
ret.delay = this->delay + other.delay;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2019-12-27 18:32:23 +08:00
|
|
|
// https://bugreports.qt.io/browse/QTBUG-80789
|
|
|
|
|
|
|
|
#ifndef Q_MOC_RUN
|
2018-08-08 23:01:18 +08:00
|
|
|
enum ConstIds
|
2018-06-30 02:36:34 +08:00
|
|
|
{
|
2018-08-08 23:01:18 +08:00
|
|
|
ID_NONE
|
|
|
|
#define X(t) , ID_##t
|
|
|
|
#include "constids.inc"
|
|
|
|
#undef X
|
2018-06-30 02:36:34 +08:00
|
|
|
};
|
|
|
|
|
2018-08-08 23:01:18 +08:00
|
|
|
#define X(t) static constexpr auto id_##t = IdString(ID_##t);
|
|
|
|
#include "constids.inc"
|
2018-06-30 02:36:34 +08:00
|
|
|
#undef X
|
2019-12-27 18:32:23 +08:00
|
|
|
#endif
|
2018-06-30 02:36:34 +08:00
|
|
|
|
|
|
|
struct BelId
|
|
|
|
{
|
|
|
|
int32_t index = -1;
|
|
|
|
|
|
|
|
bool operator==(const BelId &other) const { return index == other.index; }
|
|
|
|
bool operator!=(const BelId &other) const { return index != other.index; }
|
2018-11-13 12:03:46 +08:00
|
|
|
bool operator<(const BelId &other) const { return index < other.index; }
|
2018-06-30 02:36:34 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct WireId
|
|
|
|
{
|
|
|
|
int32_t index = -1;
|
|
|
|
|
|
|
|
bool operator==(const WireId &other) const { return index == other.index; }
|
|
|
|
bool operator!=(const WireId &other) const { return index != other.index; }
|
2018-11-13 12:03:46 +08:00
|
|
|
bool operator<(const WireId &other) const { return index < other.index; }
|
2018-06-30 02:36:34 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PipId
|
|
|
|
{
|
|
|
|
int32_t index = -1;
|
|
|
|
|
|
|
|
bool operator==(const PipId &other) const { return index == other.index; }
|
|
|
|
bool operator!=(const PipId &other) const { return index != other.index; }
|
2018-11-13 12:03:46 +08:00
|
|
|
bool operator<(const PipId &other) const { return index < other.index; }
|
2018-06-30 02:36:34 +08:00
|
|
|
};
|
|
|
|
|
2018-07-12 23:22:29 +08:00
|
|
|
struct GroupId
|
|
|
|
{
|
2018-07-13 04:04:13 +08:00
|
|
|
enum : int8_t
|
|
|
|
{
|
2018-07-12 23:22:29 +08:00
|
|
|
TYPE_NONE,
|
|
|
|
TYPE_FRAME,
|
|
|
|
TYPE_MAIN_SW,
|
|
|
|
TYPE_LOCAL_SW,
|
|
|
|
TYPE_LC0_SW,
|
|
|
|
TYPE_LC1_SW,
|
|
|
|
TYPE_LC2_SW,
|
|
|
|
TYPE_LC3_SW,
|
|
|
|
TYPE_LC4_SW,
|
|
|
|
TYPE_LC5_SW,
|
|
|
|
TYPE_LC6_SW,
|
|
|
|
TYPE_LC7_SW
|
|
|
|
} type = TYPE_NONE;
|
|
|
|
int8_t x = 0, y = 0;
|
|
|
|
|
|
|
|
bool operator==(const GroupId &other) const { return (type == other.type) && (x == other.x) && (y == other.y); }
|
|
|
|
bool operator!=(const GroupId &other) const { return (type != other.type) || (x != other.x) || (y == other.y); }
|
|
|
|
};
|
|
|
|
|
2018-07-11 20:03:23 +08:00
|
|
|
struct DecalId
|
|
|
|
{
|
2018-07-13 04:04:13 +08:00
|
|
|
enum : int8_t
|
|
|
|
{
|
2018-07-12 23:22:29 +08:00
|
|
|
TYPE_NONE,
|
|
|
|
TYPE_BEL,
|
|
|
|
TYPE_WIRE,
|
|
|
|
TYPE_PIP,
|
|
|
|
TYPE_GROUP
|
|
|
|
} type = TYPE_NONE;
|
|
|
|
int32_t index = -1;
|
2018-07-13 20:29:03 +08:00
|
|
|
bool active = false;
|
2018-07-12 23:22:29 +08:00
|
|
|
|
|
|
|
bool operator==(const DecalId &other) const { return (type == other.type) && (index == other.index); }
|
|
|
|
bool operator!=(const DecalId &other) const { return (type != other.type) || (index != other.index); }
|
2018-07-11 20:03:23 +08:00
|
|
|
};
|
|
|
|
|
2018-07-18 18:12:05 +08:00
|
|
|
struct ArchNetInfo
|
|
|
|
{
|
|
|
|
bool is_global = false;
|
2018-07-20 17:36:32 +08:00
|
|
|
bool is_reset = false, is_enable = false;
|
2018-07-18 18:12:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct NetInfo;
|
|
|
|
|
|
|
|
struct ArchCellInfo
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2018-08-03 23:37:59 +08:00
|
|
|
bool dffEnable;
|
|
|
|
bool carryEnable;
|
|
|
|
bool negClk;
|
2018-07-18 18:12:05 +08:00
|
|
|
int inputCount;
|
|
|
|
const NetInfo *clk, *cen, *sr;
|
|
|
|
} lcInfo;
|
2018-09-24 22:14:28 +08:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool lvds;
|
2018-11-17 20:04:14 +08:00
|
|
|
bool global;
|
2019-01-08 01:18:40 +08:00
|
|
|
bool negtrig;
|
|
|
|
int pintype;
|
2018-09-24 22:14:28 +08:00
|
|
|
// TODO: clk packing checks...
|
|
|
|
} ioInfo;
|
2018-11-19 08:57:47 +08:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool forPadIn;
|
|
|
|
} gbInfo;
|
2019-06-10 17:30:01 +08:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool ledCurConnected;
|
|
|
|
} ledInfo;
|
2018-07-18 18:12:05 +08:00
|
|
|
};
|
|
|
|
};
|
2018-07-18 02:04:49 +08:00
|
|
|
|
2021-01-30 06:55:10 +08:00
|
|
|
struct BelBucketId {
|
2021-01-29 11:24:00 +08:00
|
|
|
IdString name;
|
|
|
|
|
2021-01-30 06:55:10 +08:00
|
|
|
bool operator==(const BelBucketId &other) const { return (name == other.name); }
|
|
|
|
bool operator!=(const BelBucketId &other) const { return (name != other.name); }
|
|
|
|
bool operator<(const BelBucketId &other) const
|
2021-01-29 11:24:00 +08:00
|
|
|
{
|
|
|
|
return name < other.name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-06-30 02:36:34 +08:00
|
|
|
NEXTPNR_NAMESPACE_END
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX BelId>
|
|
|
|
{
|
|
|
|
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX BelId &bel) const noexcept { return hash<int>()(bel.index); }
|
|
|
|
};
|
|
|
|
|
|
|
|
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX WireId>
|
|
|
|
{
|
|
|
|
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX WireId &wire) const noexcept
|
|
|
|
{
|
|
|
|
return hash<int>()(wire.index);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX PipId>
|
|
|
|
{
|
|
|
|
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX PipId &pip) const noexcept { return hash<int>()(pip.index); }
|
|
|
|
};
|
|
|
|
|
2018-07-12 23:22:29 +08:00
|
|
|
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX GroupId>
|
|
|
|
{
|
2018-07-13 04:04:13 +08:00
|
|
|
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX GroupId &group) const noexcept
|
|
|
|
{
|
2018-07-12 23:22:29 +08:00
|
|
|
std::size_t seed = 0;
|
|
|
|
boost::hash_combine(seed, hash<int>()(group.type));
|
|
|
|
boost::hash_combine(seed, hash<int>()(group.x));
|
|
|
|
boost::hash_combine(seed, hash<int>()(group.y));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-07-11 20:03:23 +08:00
|
|
|
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX DecalId>
|
|
|
|
{
|
2018-07-13 04:04:13 +08:00
|
|
|
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX DecalId &decal) const noexcept
|
|
|
|
{
|
2018-07-11 20:03:23 +08:00
|
|
|
std::size_t seed = 0;
|
|
|
|
boost::hash_combine(seed, hash<int>()(decal.type));
|
2018-07-12 23:22:29 +08:00
|
|
|
boost::hash_combine(seed, hash<int>()(decal.index));
|
2018-07-11 20:03:23 +08:00
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
};
|
2021-01-29 11:24:00 +08:00
|
|
|
|
2021-01-30 06:55:10 +08:00
|
|
|
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX BelBucketId>
|
2021-01-29 11:24:00 +08:00
|
|
|
{
|
2021-01-30 06:55:10 +08:00
|
|
|
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX BelBucketId &bucket) const noexcept
|
2021-01-29 11:24:00 +08:00
|
|
|
{
|
|
|
|
std::size_t seed = 0;
|
2021-01-30 06:55:10 +08:00
|
|
|
boost::hash_combine(seed, hash<NEXTPNR_NAMESPACE_PREFIX IdString>()(bucket.name));
|
2021-01-29 11:24:00 +08:00
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-06-30 02:36:34 +08:00
|
|
|
} // namespace std
|