2018-05-26 20:27:21 +08:00
|
|
|
/*
|
|
|
|
* nextpnr -- Next Generation Place and Route
|
|
|
|
*
|
2018-06-22 22:19:17 +08:00
|
|
|
* Copyright (C) 2018 Clifford Wolf <clifford@symbioticeda.com>
|
2018-05-26 20:27:21 +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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-06-12 02:12:57 +08:00
|
|
|
#ifndef NEXTPNR_H
|
2018-06-18 20:12:39 +08:00
|
|
|
#error Include "arch.h" via "nextpnr.h" only.
|
2018-06-12 02:12:57 +08:00
|
|
|
#endif
|
|
|
|
|
2018-06-12 20:24:59 +08:00
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
2018-06-17 19:32:38 +08:00
|
|
|
/**** Everything in this section must be kept in sync with chipdb.py ****/
|
|
|
|
|
2018-06-17 22:14:27 +08:00
|
|
|
template <typename T> struct RelPtr
|
|
|
|
{
|
2018-06-17 19:32:38 +08:00
|
|
|
int32_t offset;
|
2018-06-16 21:23:04 +08:00
|
|
|
|
2018-06-17 19:32:38 +08:00
|
|
|
// void set(const T *ptr) {
|
2018-06-17 22:14:27 +08:00
|
|
|
// offset = reinterpret_cast<const char*>(ptr) -
|
|
|
|
// reinterpret_cast<const char*>(this);
|
2018-06-17 19:32:38 +08:00
|
|
|
// }
|
|
|
|
|
2018-06-23 21:28:09 +08:00
|
|
|
const T *get() const { return reinterpret_cast<const T *>(reinterpret_cast<const char *>(this) + offset); }
|
2018-06-16 21:23:04 +08:00
|
|
|
|
2018-06-17 22:14:27 +08:00
|
|
|
const T &operator[](size_t index) const { return get()[index]; }
|
2018-06-16 21:23:04 +08:00
|
|
|
|
2018-06-17 22:14:27 +08:00
|
|
|
const T &operator*() const { return *(get()); }
|
2018-06-16 23:53:09 +08:00
|
|
|
|
2018-06-17 22:14:27 +08:00
|
|
|
const T *operator->() const { return get(); }
|
2018-06-16 21:23:04 +08:00
|
|
|
};
|
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct BelWirePOD {
|
2018-08-08 23:01:18 +08:00
|
|
|
int32_t port;
|
2018-07-22 17:56:51 +08:00
|
|
|
int32_t type;
|
2018-07-31 17:55:25 +08:00
|
|
|
int32_t wire_index;
|
2018-07-03 14:52:19 +08:00
|
|
|
});
|
2018-06-10 00:19:20 +08:00
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct BelInfoPOD {
|
2018-06-16 21:23:04 +08:00
|
|
|
RelPtr<char> name;
|
2018-08-08 23:01:18 +08:00
|
|
|
int32_t type;
|
2018-06-16 21:23:04 +08:00
|
|
|
int32_t num_bel_wires;
|
|
|
|
RelPtr<BelWirePOD> bel_wires;
|
2018-06-07 18:56:49 +08:00
|
|
|
int8_t x, y, z;
|
2018-06-17 19:32:38 +08:00
|
|
|
int8_t padding_0;
|
2018-07-03 14:52:19 +08:00
|
|
|
});
|
2018-05-26 20:56:30 +08:00
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct BelPortPOD {
|
2018-06-07 18:56:49 +08:00
|
|
|
int32_t bel_index;
|
2018-08-08 23:01:18 +08:00
|
|
|
int32_t port;
|
2018-07-03 14:52:19 +08:00
|
|
|
});
|
2018-05-26 20:56:30 +08:00
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct PipInfoPOD {
|
2018-08-03 23:37:59 +08:00
|
|
|
enum PipFlags : uint32_t
|
|
|
|
{
|
|
|
|
FLAG_NONE = 0,
|
|
|
|
FLAG_ROUTETHRU = 1,
|
|
|
|
FLAG_NOCARRY = 2
|
|
|
|
};
|
|
|
|
|
2018-07-16 03:41:34 +08:00
|
|
|
// RelPtr<char> name;
|
2018-06-07 18:56:49 +08:00
|
|
|
int32_t src, dst;
|
2018-07-30 22:21:03 +08:00
|
|
|
int32_t fast_delay;
|
|
|
|
int32_t slow_delay;
|
2018-06-07 18:56:49 +08:00
|
|
|
int8_t x, y;
|
2018-07-16 02:29:32 +08:00
|
|
|
int16_t src_seg, dst_seg;
|
2018-06-10 16:54:41 +08:00
|
|
|
int16_t switch_mask;
|
|
|
|
int32_t switch_index;
|
2018-08-03 23:37:59 +08:00
|
|
|
PipFlags flags;
|
2018-07-03 14:52:19 +08:00
|
|
|
});
|
2018-06-06 21:13:41 +08:00
|
|
|
|
2018-07-13 03:05:09 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct WireSegmentPOD {
|
|
|
|
int8_t x, y;
|
|
|
|
int16_t index;
|
|
|
|
});
|
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct WireInfoPOD {
|
2018-08-04 03:11:12 +08:00
|
|
|
enum WireType : int8_t
|
|
|
|
{
|
2018-08-05 20:18:34 +08:00
|
|
|
WIRE_TYPE_NONE = 0,
|
|
|
|
WIRE_TYPE_GLB2LOCAL = 1,
|
|
|
|
WIRE_TYPE_GLB_NETWK = 2,
|
|
|
|
WIRE_TYPE_LOCAL = 3,
|
|
|
|
WIRE_TYPE_LUTFF_IN = 4,
|
2018-08-04 03:11:12 +08:00
|
|
|
WIRE_TYPE_LUTFF_IN_LUT = 5,
|
2018-08-05 20:18:34 +08:00
|
|
|
WIRE_TYPE_LUTFF_LOUT = 6,
|
|
|
|
WIRE_TYPE_LUTFF_OUT = 7,
|
|
|
|
WIRE_TYPE_LUTFF_COUT = 8,
|
2018-08-04 03:11:12 +08:00
|
|
|
WIRE_TYPE_LUTFF_GLOBAL = 9,
|
|
|
|
WIRE_TYPE_CARRY_IN_MUX = 10,
|
2018-08-05 20:18:34 +08:00
|
|
|
WIRE_TYPE_SP4_V = 11,
|
|
|
|
WIRE_TYPE_SP4_H = 12,
|
|
|
|
WIRE_TYPE_SP12_V = 13,
|
|
|
|
WIRE_TYPE_SP12_H = 14
|
2018-08-04 03:11:12 +08:00
|
|
|
};
|
|
|
|
|
2018-06-17 20:30:26 +08:00
|
|
|
RelPtr<char> name;
|
2018-06-16 21:23:04 +08:00
|
|
|
int32_t num_uphill, num_downhill;
|
2018-06-17 20:30:26 +08:00
|
|
|
RelPtr<int32_t> pips_uphill, pips_downhill;
|
2018-05-26 20:56:30 +08:00
|
|
|
|
2018-07-22 17:56:51 +08:00
|
|
|
int32_t num_bel_pins;
|
|
|
|
RelPtr<BelPortPOD> bel_pins;
|
|
|
|
|
2018-07-13 03:05:09 +08:00
|
|
|
int32_t num_segments;
|
|
|
|
RelPtr<WireSegmentPOD> segments;
|
|
|
|
|
2018-07-30 22:21:03 +08:00
|
|
|
int32_t fast_delay;
|
|
|
|
int32_t slow_delay;
|
|
|
|
|
2018-08-05 01:50:49 +08:00
|
|
|
int8_t x, y, z;
|
2018-06-20 18:50:38 +08:00
|
|
|
WireType type;
|
2018-07-03 14:52:19 +08:00
|
|
|
});
|
2018-05-26 20:56:30 +08:00
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct PackagePinPOD {
|
2018-06-17 00:42:29 +08:00
|
|
|
RelPtr<char> name;
|
2018-06-13 17:40:28 +08:00
|
|
|
int32_t bel_index;
|
2018-07-03 14:52:19 +08:00
|
|
|
});
|
2018-06-13 17:40:28 +08:00
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct PackageInfoPOD {
|
2018-06-17 21:53:17 +08:00
|
|
|
RelPtr<char> name;
|
|
|
|
int32_t num_pins;
|
|
|
|
RelPtr<PackagePinPOD> pins;
|
2018-07-03 14:52:19 +08:00
|
|
|
});
|
2018-06-13 17:40:28 +08:00
|
|
|
|
2018-06-17 21:46:39 +08:00
|
|
|
enum TileType : uint32_t
|
2018-06-10 16:54:41 +08:00
|
|
|
{
|
2018-06-10 17:14:50 +08:00
|
|
|
TILE_NONE = 0,
|
|
|
|
TILE_LOGIC = 1,
|
|
|
|
TILE_IO = 2,
|
|
|
|
TILE_RAMB = 3,
|
|
|
|
TILE_RAMT = 4,
|
2018-06-22 22:40:22 +08:00
|
|
|
TILE_DSP0 = 5,
|
|
|
|
TILE_DSP1 = 6,
|
|
|
|
TILE_DSP2 = 7,
|
|
|
|
TILE_DSP3 = 8,
|
|
|
|
TILE_IPCON = 9
|
2018-06-10 16:54:41 +08:00
|
|
|
};
|
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct ConfigBitPOD { int8_t row, col; });
|
2018-06-10 16:54:41 +08:00
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct ConfigEntryPOD {
|
2018-06-17 01:25:37 +08:00
|
|
|
RelPtr<char> name;
|
|
|
|
int32_t num_bits;
|
|
|
|
RelPtr<ConfigBitPOD> bits;
|
2018-07-03 14:52:19 +08:00
|
|
|
});
|
2018-06-10 16:54:41 +08:00
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct TileInfoPOD {
|
2018-06-10 17:14:50 +08:00
|
|
|
int8_t cols, rows;
|
2018-06-17 21:15:49 +08:00
|
|
|
int16_t num_config_entries;
|
|
|
|
RelPtr<ConfigEntryPOD> entries;
|
2018-07-03 14:52:19 +08:00
|
|
|
});
|
2018-06-10 16:54:41 +08:00
|
|
|
|
|
|
|
static const int max_switch_bits = 5;
|
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct SwitchInfoPOD {
|
2018-06-17 21:05:17 +08:00
|
|
|
int32_t num_bits;
|
2018-08-02 22:28:47 +08:00
|
|
|
int32_t bel;
|
2018-06-10 16:54:41 +08:00
|
|
|
int8_t x, y;
|
|
|
|
ConfigBitPOD cbits[max_switch_bits];
|
2018-07-03 14:52:19 +08:00
|
|
|
});
|
2018-06-10 16:54:41 +08:00
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct IerenInfoPOD {
|
2018-06-10 19:24:48 +08:00
|
|
|
int8_t iox, ioy, ioz;
|
|
|
|
int8_t ierx, iery, ierz;
|
2018-07-03 14:52:19 +08:00
|
|
|
});
|
2018-06-10 19:24:48 +08:00
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct BitstreamInfoPOD {
|
2018-06-17 21:39:19 +08:00
|
|
|
int32_t num_switches, num_ierens;
|
|
|
|
RelPtr<TileInfoPOD> tiles_nonrouting;
|
|
|
|
RelPtr<SwitchInfoPOD> switches;
|
|
|
|
RelPtr<IerenInfoPOD> ierens;
|
2018-07-03 14:52:19 +08:00
|
|
|
});
|
2018-06-10 16:54:41 +08:00
|
|
|
|
2018-07-19 17:14:43 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct BelConfigEntryPOD {
|
|
|
|
RelPtr<char> entry_name;
|
|
|
|
RelPtr<char> cbit_name;
|
|
|
|
int8_t x, y;
|
|
|
|
int16_t padding;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Stores mapping between bel parameters and config bits,
|
|
|
|
// for extra cells where this mapping is non-trivial
|
|
|
|
NPNR_PACKED_STRUCT(struct BelConfigPOD {
|
|
|
|
int32_t bel_index;
|
|
|
|
int32_t num_entries;
|
|
|
|
RelPtr<BelConfigEntryPOD> entries;
|
|
|
|
});
|
|
|
|
|
2018-08-02 21:20:43 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct CellPathDelayPOD {
|
2018-08-08 23:01:18 +08:00
|
|
|
int32_t from_port;
|
|
|
|
int32_t to_port;
|
2018-08-02 21:20:43 +08:00
|
|
|
int32_t fast_delay;
|
|
|
|
int32_t slow_delay;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct CellTimingPOD {
|
2018-08-02 22:02:43 +08:00
|
|
|
int32_t type;
|
2018-08-02 21:20:43 +08:00
|
|
|
int32_t num_paths;
|
|
|
|
RelPtr<CellPathDelayPOD> path_delays;
|
|
|
|
});
|
|
|
|
|
2018-11-16 07:04:55 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct GlobalNetworkInfoPOD {
|
|
|
|
uint8_t gb_x;
|
|
|
|
uint8_t gb_y;
|
|
|
|
|
|
|
|
uint8_t pi_gb_x;
|
|
|
|
uint8_t pi_gb_y;
|
|
|
|
uint8_t pi_gb_pio;
|
|
|
|
|
|
|
|
uint8_t pi_eb_bank;
|
|
|
|
uint16_t pi_eb_x;
|
|
|
|
uint16_t pi_eb_y;
|
|
|
|
|
|
|
|
uint16_t pad;
|
|
|
|
});
|
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct ChipInfoPOD {
|
2018-06-17 22:12:52 +08:00
|
|
|
int32_t width, height;
|
|
|
|
int32_t num_bels, num_wires, num_pips;
|
2018-07-19 17:14:43 +08:00
|
|
|
int32_t num_switches, num_belcfgs, num_packages;
|
2018-11-16 07:04:55 +08:00
|
|
|
int32_t num_timing_cells, num_global_networks;
|
2018-06-17 22:12:52 +08:00
|
|
|
RelPtr<BelInfoPOD> bel_data;
|
|
|
|
RelPtr<WireInfoPOD> wire_data;
|
|
|
|
RelPtr<PipInfoPOD> pip_data;
|
|
|
|
RelPtr<TileType> tile_grid;
|
|
|
|
RelPtr<BitstreamInfoPOD> bits_info;
|
2018-07-19 17:14:43 +08:00
|
|
|
RelPtr<BelConfigPOD> bel_config;
|
2018-06-17 22:12:52 +08:00
|
|
|
RelPtr<PackageInfoPOD> packages_data;
|
2018-08-02 21:20:43 +08:00
|
|
|
RelPtr<CellTimingPOD> cell_timing;
|
2018-11-16 07:04:55 +08:00
|
|
|
RelPtr<GlobalNetworkInfoPOD> global_network_info;
|
2018-08-18 20:14:27 +08:00
|
|
|
RelPtr<RelPtr<char>> tile_wire_names;
|
2018-07-03 14:52:19 +08:00
|
|
|
});
|
2018-05-26 20:56:30 +08:00
|
|
|
|
2018-07-04 18:06:03 +08:00
|
|
|
#if defined(_MSC_VER)
|
2018-07-04 18:15:23 +08:00
|
|
|
extern const char *chipdb_blob_384;
|
|
|
|
extern const char *chipdb_blob_1k;
|
|
|
|
extern const char *chipdb_blob_5k;
|
|
|
|
extern const char *chipdb_blob_8k;
|
2018-07-04 18:06:03 +08:00
|
|
|
#else
|
2018-06-18 00:15:41 +08:00
|
|
|
extern const char chipdb_blob_384[];
|
|
|
|
extern const char chipdb_blob_1k[];
|
|
|
|
extern const char chipdb_blob_5k[];
|
|
|
|
extern const char chipdb_blob_8k[];
|
2018-07-04 18:06:03 +08:00
|
|
|
#endif
|
2018-05-26 20:56:30 +08:00
|
|
|
|
2018-06-17 19:32:38 +08:00
|
|
|
/************************ End of chipdb section. ************************/
|
|
|
|
|
2018-06-02 18:57:19 +08:00
|
|
|
struct BelIterator
|
2018-05-26 20:27:21 +08:00
|
|
|
{
|
2018-06-07 18:56:49 +08:00
|
|
|
int cursor;
|
|
|
|
|
2018-06-08 03:38:24 +08:00
|
|
|
BelIterator operator++()
|
|
|
|
{
|
|
|
|
cursor++;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
BelIterator operator++(int)
|
|
|
|
{
|
|
|
|
BelIterator prior(*this);
|
|
|
|
cursor++;
|
|
|
|
return prior;
|
|
|
|
}
|
2018-06-07 21:38:14 +08:00
|
|
|
|
2018-06-23 21:28:09 +08:00
|
|
|
bool operator!=(const BelIterator &other) const { return cursor != other.cursor; }
|
2018-06-07 18:56:49 +08:00
|
|
|
|
2018-06-23 21:28:09 +08:00
|
|
|
bool operator==(const BelIterator &other) const { return cursor == other.cursor; }
|
2018-06-07 21:38:14 +08:00
|
|
|
|
2018-06-07 18:56:49 +08:00
|
|
|
BelId operator*() const
|
|
|
|
{
|
|
|
|
BelId ret;
|
|
|
|
ret.index = cursor;
|
|
|
|
return ret;
|
|
|
|
}
|
2018-05-26 20:27:21 +08:00
|
|
|
};
|
|
|
|
|
2018-06-02 18:57:19 +08:00
|
|
|
struct BelRange
|
2018-05-26 20:27:21 +08:00
|
|
|
{
|
2018-06-07 18:56:49 +08:00
|
|
|
BelIterator b, e;
|
|
|
|
BelIterator begin() const { return b; }
|
|
|
|
BelIterator end() const { return e; }
|
2018-05-26 20:27:21 +08:00
|
|
|
};
|
|
|
|
|
2018-05-26 20:56:30 +08:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2018-06-06 21:13:41 +08:00
|
|
|
struct BelPinIterator
|
2018-05-26 20:27:21 +08:00
|
|
|
{
|
2018-06-17 20:30:26 +08:00
|
|
|
const BelPortPOD *ptr = nullptr;
|
2018-06-07 18:56:49 +08:00
|
|
|
|
|
|
|
void operator++() { ptr++; }
|
2018-06-23 21:28:09 +08:00
|
|
|
bool operator!=(const BelPinIterator &other) const { return ptr != other.ptr; }
|
2018-06-07 18:56:49 +08:00
|
|
|
|
|
|
|
BelPin operator*() const
|
|
|
|
{
|
|
|
|
BelPin ret;
|
|
|
|
ret.bel.index = ptr->bel_index;
|
|
|
|
ret.pin = ptr->port;
|
|
|
|
return ret;
|
|
|
|
}
|
2018-06-06 21:13:41 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct BelPinRange
|
|
|
|
{
|
2018-06-07 18:56:49 +08:00
|
|
|
BelPinIterator b, e;
|
|
|
|
BelPinIterator begin() const { return b; }
|
|
|
|
BelPinIterator end() const { return e; }
|
2018-06-06 21:13:41 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct WireIterator
|
|
|
|
{
|
2018-06-07 18:56:49 +08:00
|
|
|
int cursor = -1;
|
|
|
|
|
|
|
|
void operator++() { cursor++; }
|
2018-06-23 21:28:09 +08:00
|
|
|
bool operator!=(const WireIterator &other) const { return cursor != other.cursor; }
|
2018-06-07 18:56:49 +08:00
|
|
|
|
|
|
|
WireId operator*() const
|
|
|
|
{
|
|
|
|
WireId ret;
|
|
|
|
ret.index = cursor;
|
|
|
|
return ret;
|
|
|
|
}
|
2018-05-26 20:27:21 +08:00
|
|
|
};
|
|
|
|
|
2018-06-06 21:13:41 +08:00
|
|
|
struct WireRange
|
2018-05-26 20:27:21 +08:00
|
|
|
{
|
2018-06-07 18:56:49 +08:00
|
|
|
WireIterator b, e;
|
|
|
|
WireIterator begin() const { return b; }
|
|
|
|
WireIterator end() const { return e; }
|
2018-05-26 20:27:21 +08:00
|
|
|
};
|
|
|
|
|
2018-05-26 20:56:30 +08:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2018-06-06 21:13:41 +08:00
|
|
|
struct AllPipIterator
|
2018-05-26 20:27:21 +08:00
|
|
|
{
|
2018-06-07 18:56:49 +08:00
|
|
|
int cursor = -1;
|
|
|
|
|
|
|
|
void operator++() { cursor++; }
|
2018-06-23 21:28:09 +08:00
|
|
|
bool operator!=(const AllPipIterator &other) const { return cursor != other.cursor; }
|
2018-06-07 18:56:49 +08:00
|
|
|
|
|
|
|
PipId operator*() const
|
|
|
|
{
|
|
|
|
PipId ret;
|
|
|
|
ret.index = cursor;
|
|
|
|
return ret;
|
|
|
|
}
|
2018-05-26 20:27:21 +08:00
|
|
|
};
|
|
|
|
|
2018-06-06 21:13:41 +08:00
|
|
|
struct AllPipRange
|
2018-05-26 20:27:21 +08:00
|
|
|
{
|
2018-06-07 18:56:49 +08:00
|
|
|
AllPipIterator b, e;
|
|
|
|
AllPipIterator begin() const { return b; }
|
|
|
|
AllPipIterator end() const { return e; }
|
2018-05-26 20:27:21 +08:00
|
|
|
};
|
|
|
|
|
2018-05-26 20:56:30 +08:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2018-06-06 21:13:41 +08:00
|
|
|
struct PipIterator
|
2018-05-26 20:27:21 +08:00
|
|
|
{
|
2018-06-17 20:30:26 +08:00
|
|
|
const int *cursor = nullptr;
|
2018-06-07 18:56:49 +08:00
|
|
|
|
|
|
|
void operator++() { cursor++; }
|
2018-06-23 21:28:09 +08:00
|
|
|
bool operator!=(const PipIterator &other) const { return cursor != other.cursor; }
|
2018-06-07 18:56:49 +08:00
|
|
|
|
|
|
|
PipId operator*() const
|
|
|
|
{
|
|
|
|
PipId ret;
|
|
|
|
ret.index = *cursor;
|
|
|
|
return ret;
|
|
|
|
}
|
2018-05-26 20:27:21 +08:00
|
|
|
};
|
|
|
|
|
2018-06-06 21:13:41 +08:00
|
|
|
struct PipRange
|
2018-05-26 20:27:21 +08:00
|
|
|
{
|
2018-06-07 18:56:49 +08:00
|
|
|
PipIterator b, e;
|
|
|
|
PipIterator begin() const { return b; }
|
|
|
|
PipIterator end() const { return e; }
|
2018-05-26 20:27:21 +08:00
|
|
|
};
|
|
|
|
|
2018-06-18 19:35:25 +08:00
|
|
|
struct ArchArgs
|
2018-05-26 20:27:21 +08:00
|
|
|
{
|
2018-07-07 19:23:45 +08:00
|
|
|
enum ArchArgsTypes
|
2018-06-07 18:56:49 +08:00
|
|
|
{
|
|
|
|
NONE,
|
|
|
|
LP384,
|
|
|
|
LP1K,
|
|
|
|
LP8K,
|
|
|
|
HX1K,
|
|
|
|
HX8K,
|
|
|
|
UP5K
|
|
|
|
} type = NONE;
|
2018-06-13 17:40:28 +08:00
|
|
|
std::string package;
|
2018-05-26 20:27:21 +08:00
|
|
|
};
|
|
|
|
|
2018-07-15 02:01:33 +08:00
|
|
|
struct Arch : BaseCtx
|
2018-05-26 20:27:21 +08:00
|
|
|
{
|
2018-07-30 22:21:03 +08:00
|
|
|
bool fast_part;
|
2018-06-17 22:12:52 +08:00
|
|
|
const ChipInfoPOD *chip_info;
|
|
|
|
const PackageInfoPOD *package_info;
|
2018-05-26 20:27:21 +08:00
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
mutable std::unordered_map<IdString, int> bel_by_name;
|
|
|
|
mutable std::unordered_map<IdString, int> wire_by_name;
|
|
|
|
mutable std::unordered_map<IdString, int> pip_by_name;
|
2018-07-20 23:33:57 +08:00
|
|
|
mutable std::unordered_map<Loc, int> bel_by_loc;
|
2018-07-15 01:52:56 +08:00
|
|
|
|
2018-08-03 23:37:59 +08:00
|
|
|
std::vector<bool> bel_carry;
|
2018-08-07 08:35:23 +08:00
|
|
|
std::vector<CellInfo *> bel_to_cell;
|
|
|
|
std::vector<NetInfo *> wire_to_net;
|
|
|
|
std::vector<NetInfo *> pip_to_net;
|
2018-11-11 18:34:38 +08:00
|
|
|
std::vector<WireId> switches_locked;
|
2018-07-15 02:01:33 +08:00
|
|
|
|
2018-06-18 19:35:25 +08:00
|
|
|
ArchArgs args;
|
|
|
|
Arch(ArchArgs args);
|
2018-05-26 20:27:21 +08:00
|
|
|
|
2018-07-31 23:01:38 +08:00
|
|
|
std::string getChipName() const;
|
2018-06-11 00:25:23 +08:00
|
|
|
|
2018-06-24 20:38:45 +08:00
|
|
|
IdString archId() const { return id("ice40"); }
|
2018-08-07 01:32:17 +08:00
|
|
|
ArchArgs archArgs() const { return args; }
|
2018-06-24 20:38:45 +08:00
|
|
|
IdString archArgsToId(ArchArgs args) const;
|
|
|
|
|
2018-06-18 19:35:25 +08:00
|
|
|
// -------------------------------------------------
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-10-18 00:35:43 +08:00
|
|
|
int getGridDimX() const { return chip_info->width; }
|
|
|
|
int getGridDimY() const { return chip_info->height; }
|
2018-08-08 16:27:08 +08:00
|
|
|
int getTileBelDimZ(int, int) const { return 8; }
|
|
|
|
int getTilePipDimZ(int, int) const { return 1; }
|
2018-07-23 18:19:54 +08:00
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
|
2018-07-15 01:50:15 +08:00
|
|
|
BelId getBelByName(IdString name) const;
|
2018-05-26 20:27:21 +08:00
|
|
|
|
2018-06-07 18:56:49 +08:00
|
|
|
IdString getBelName(BelId bel) const
|
|
|
|
{
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(bel != BelId());
|
2018-06-18 21:53:18 +08:00
|
|
|
return id(chip_info->bel_data[bel.index].name.get());
|
2018-06-07 18:56:49 +08:00
|
|
|
}
|
2018-05-26 20:27:21 +08:00
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
uint32_t getBelChecksum(BelId bel) const { return bel.index; }
|
|
|
|
|
2018-08-05 21:25:42 +08:00
|
|
|
void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength)
|
2018-07-15 01:50:34 +08:00
|
|
|
{
|
2018-07-15 01:52:56 +08:00
|
|
|
NPNR_ASSERT(bel != BelId());
|
2018-08-05 21:25:42 +08:00
|
|
|
NPNR_ASSERT(bel_to_cell[bel.index] == nullptr);
|
2018-08-03 23:37:59 +08:00
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
bel_to_cell[bel.index] = cell;
|
2018-08-08 23:17:16 +08:00
|
|
|
bel_carry[bel.index] = (cell->type == id_ICESTORM_LC && cell->lcInfo.carryEnable);
|
2018-08-05 21:25:42 +08:00
|
|
|
cell->bel = bel;
|
|
|
|
cell->belStrength = strength;
|
2018-07-18 02:16:26 +08:00
|
|
|
refreshUiBel(bel);
|
2018-07-15 01:52:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void unbindBel(BelId bel)
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2018-08-05 21:25:42 +08:00
|
|
|
NPNR_ASSERT(bel_to_cell[bel.index] != nullptr);
|
|
|
|
bel_to_cell[bel.index]->bel = BelId();
|
|
|
|
bel_to_cell[bel.index]->belStrength = STRENGTH_NONE;
|
|
|
|
bel_to_cell[bel.index] = nullptr;
|
2018-08-03 23:37:59 +08:00
|
|
|
bel_carry[bel.index] = false;
|
2018-07-18 02:16:26 +08:00
|
|
|
refreshUiBel(bel);
|
2018-07-15 01:52:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool checkBelAvail(BelId bel) const
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
2018-08-05 21:25:42 +08:00
|
|
|
return bel_to_cell[bel.index] == nullptr;
|
2018-07-15 01:52:56 +08:00
|
|
|
}
|
|
|
|
|
2018-08-05 21:25:42 +08:00
|
|
|
CellInfo *getBoundBelCell(BelId bel) const
|
2018-07-15 01:52:56 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
|
|
|
return bel_to_cell[bel.index];
|
|
|
|
}
|
|
|
|
|
2018-08-05 21:25:42 +08:00
|
|
|
CellInfo *getConflictingBelCell(BelId bel) const
|
2018-07-15 01:52:56 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
|
|
|
return bel_to_cell[bel.index];
|
2018-07-15 01:50:34 +08:00
|
|
|
}
|
2018-05-26 22:08:20 +08:00
|
|
|
|
2018-06-07 18:56:49 +08:00
|
|
|
BelRange getBels() const
|
|
|
|
{
|
|
|
|
BelRange range;
|
|
|
|
range.b.cursor = 0;
|
2018-06-17 22:12:52 +08:00
|
|
|
range.e.cursor = chip_info->num_bels;
|
2018-06-07 18:56:49 +08:00
|
|
|
return range;
|
|
|
|
}
|
2018-05-26 22:08:20 +08:00
|
|
|
|
2018-07-17 23:03:44 +08:00
|
|
|
Loc getBelLocation(BelId bel) const
|
|
|
|
{
|
2018-11-14 04:51:46 +08:00
|
|
|
NPNR_ASSERT(bel != BelId());
|
2018-07-17 23:03:44 +08:00
|
|
|
Loc loc;
|
|
|
|
loc.x = chip_info->bel_data[bel.index].x;
|
|
|
|
loc.y = chip_info->bel_data[bel.index].y;
|
|
|
|
loc.z = chip_info->bel_data[bel.index].z;
|
|
|
|
return loc;
|
|
|
|
}
|
|
|
|
|
2018-07-21 00:09:22 +08:00
|
|
|
BelId getBelByLocation(Loc loc) const;
|
2018-07-20 23:33:57 +08:00
|
|
|
BelRange getBelsByTile(int x, int y) const;
|
2018-07-17 23:03:44 +08:00
|
|
|
|
2018-08-08 23:01:18 +08:00
|
|
|
bool getBelGlobalBuf(BelId bel) const { return chip_info->bel_data[bel.index].type == ID_SB_GB; }
|
2018-07-17 23:03:44 +08:00
|
|
|
|
2018-08-08 23:01:18 +08:00
|
|
|
IdString getBelType(BelId bel) const
|
2018-06-07 18:56:49 +08:00
|
|
|
{
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(bel != BelId());
|
2018-08-08 23:01:18 +08:00
|
|
|
return IdString(chip_info->bel_data[bel.index].type);
|
2018-06-07 18:56:49 +08:00
|
|
|
}
|
|
|
|
|
2018-08-18 20:14:27 +08:00
|
|
|
std::vector<std::pair<IdString, std::string>> getBelAttrs(BelId bel) const;
|
2018-08-14 23:16:14 +08:00
|
|
|
|
2018-08-08 23:01:18 +08:00
|
|
|
WireId getBelPinWire(BelId bel, IdString pin) const;
|
|
|
|
PortType getBelPinType(BelId bel, IdString pin) const;
|
|
|
|
std::vector<IdString> getBelPins(BelId bel) const;
|
2018-07-22 18:08:52 +08:00
|
|
|
|
2018-11-17 17:18:17 +08:00
|
|
|
bool isBelLocked(BelId bel) const;
|
|
|
|
|
2018-06-07 18:56:49 +08:00
|
|
|
// -------------------------------------------------
|
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
WireId getWireByName(IdString name) const;
|
|
|
|
|
2018-06-07 18:56:49 +08:00
|
|
|
IdString getWireName(WireId wire) const
|
|
|
|
{
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-06-18 21:53:18 +08:00
|
|
|
return id(chip_info->wire_data[wire.index].name.get());
|
2018-06-07 18:56:49 +08:00
|
|
|
}
|
|
|
|
|
2018-08-04 03:11:12 +08:00
|
|
|
IdString getWireType(WireId wire) const;
|
2018-08-18 20:14:27 +08:00
|
|
|
std::vector<std::pair<IdString, std::string>> getWireAttrs(WireId wire) const;
|
2018-08-14 23:16:14 +08:00
|
|
|
|
2018-06-22 01:36:20 +08:00
|
|
|
uint32_t getWireChecksum(WireId wire) const { return wire.index; }
|
2018-06-21 21:47:41 +08:00
|
|
|
|
2018-08-05 21:25:42 +08:00
|
|
|
void bindWire(WireId wire, NetInfo *net, PlaceStrength strength)
|
2018-07-15 01:52:56 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-08-05 21:25:42 +08:00
|
|
|
NPNR_ASSERT(wire_to_net[wire.index] == nullptr);
|
2018-07-15 01:52:56 +08:00
|
|
|
wire_to_net[wire.index] = net;
|
2018-08-05 21:25:42 +08:00
|
|
|
net->wires[wire].pip = PipId();
|
|
|
|
net->wires[wire].strength = strength;
|
2018-07-18 02:16:26 +08:00
|
|
|
refreshUiWire(wire);
|
2018-07-15 01:52:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void unbindWire(WireId wire)
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-08-05 21:25:42 +08:00
|
|
|
NPNR_ASSERT(wire_to_net[wire.index] != nullptr);
|
2018-07-15 01:52:56 +08:00
|
|
|
|
2018-08-05 21:25:42 +08:00
|
|
|
auto &net_wires = wire_to_net[wire.index]->wires;
|
2018-07-15 01:52:56 +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 21:25:42 +08:00
|
|
|
pip_to_net[pip.index] = nullptr;
|
2018-11-11 18:34:38 +08:00
|
|
|
switches_locked[chip_info->pip_data[pip.index].switch_index] = WireId();
|
2018-07-15 01:52:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
net_wires.erase(it);
|
2018-08-05 21:25:42 +08:00
|
|
|
wire_to_net[wire.index] = nullptr;
|
2018-07-18 02:16:26 +08:00
|
|
|
refreshUiWire(wire);
|
2018-07-15 01:52:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool checkWireAvail(WireId wire) const
|
|
|
|
{
|
2018-07-15 01:53:08 +08:00
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-08-05 21:25:42 +08:00
|
|
|
return wire_to_net[wire.index] == nullptr;
|
2018-07-15 01:52:56 +08:00
|
|
|
}
|
|
|
|
|
2018-08-05 21:25:42 +08:00
|
|
|
NetInfo *getBoundWireNet(WireId wire) const
|
2018-07-15 01:52:56 +08:00
|
|
|
{
|
2018-07-15 01:53:08 +08:00
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-07-15 01:52:56 +08:00
|
|
|
return wire_to_net[wire.index];
|
|
|
|
}
|
|
|
|
|
2018-11-12 02:48:15 +08:00
|
|
|
WireId getConflictingWireWire(WireId wire) const { return wire; }
|
2018-11-12 00:28:41 +08:00
|
|
|
|
2018-08-05 21:25:42 +08:00
|
|
|
NetInfo *getConflictingWireNet(WireId wire) const
|
2018-07-15 01:52:56 +08:00
|
|
|
{
|
2018-07-15 01:53:08 +08:00
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-07-15 01:52:56 +08:00
|
|
|
return wire_to_net[wire.index];
|
|
|
|
}
|
|
|
|
|
2018-07-21 19:38:44 +08:00
|
|
|
DelayInfo getWireDelay(WireId wire) const
|
|
|
|
{
|
|
|
|
DelayInfo delay;
|
2018-07-30 22:21:03 +08:00
|
|
|
NPNR_ASSERT(wire != WireId());
|
|
|
|
if (fast_part)
|
2018-08-01 10:59:27 +08:00
|
|
|
delay.delay = chip_info->wire_data[wire.index].fast_delay;
|
2018-07-30 22:21:03 +08:00
|
|
|
else
|
2018-08-01 10:59:27 +08:00
|
|
|
delay.delay = chip_info->wire_data[wire.index].slow_delay;
|
2018-07-21 19:38:44 +08:00
|
|
|
return delay;
|
|
|
|
}
|
|
|
|
|
2018-07-22 17:56:51 +08:00
|
|
|
BelPinRange getWireBelPins(WireId wire) const
|
|
|
|
{
|
|
|
|
BelPinRange range;
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
|
|
|
range.b.ptr = chip_info->wire_data[wire.index].bel_pins.get();
|
|
|
|
range.e.ptr = range.b.ptr + chip_info->wire_data[wire.index].num_bel_pins;
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
WireRange getWires() const
|
|
|
|
{
|
|
|
|
WireRange range;
|
|
|
|
range.b.cursor = 0;
|
|
|
|
range.e.cursor = chip_info->num_wires;
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
|
|
|
|
PipId getPipByName(IdString name) const;
|
|
|
|
|
2018-08-05 21:25:42 +08:00
|
|
|
void bindPip(PipId pip, NetInfo *net, PlaceStrength strength)
|
2018-07-15 01:52:56 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
2018-08-05 21:25:42 +08:00
|
|
|
NPNR_ASSERT(pip_to_net[pip.index] == nullptr);
|
2018-11-11 18:34:38 +08:00
|
|
|
NPNR_ASSERT(switches_locked[chip_info->pip_data[pip.index].switch_index] == WireId());
|
2018-07-15 01:52:56 +08:00
|
|
|
|
|
|
|
WireId dst;
|
|
|
|
dst.index = chip_info->pip_data[pip.index].dst;
|
2018-08-05 21:25:42 +08:00
|
|
|
NPNR_ASSERT(wire_to_net[dst.index] == nullptr);
|
2018-11-11 18:34:38 +08:00
|
|
|
|
|
|
|
pip_to_net[pip.index] = net;
|
|
|
|
switches_locked[chip_info->pip_data[pip.index].switch_index] = dst;
|
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
wire_to_net[dst.index] = net;
|
2018-08-05 21:25:42 +08:00
|
|
|
net->wires[dst].pip = pip;
|
|
|
|
net->wires[dst].strength = strength;
|
2018-07-18 02:16:26 +08:00
|
|
|
refreshUiPip(pip);
|
|
|
|
refreshUiWire(dst);
|
2018-07-15 01:52:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void unbindPip(PipId pip)
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
2018-08-05 21:25:42 +08:00
|
|
|
NPNR_ASSERT(pip_to_net[pip.index] != nullptr);
|
2018-11-11 18:34:38 +08:00
|
|
|
NPNR_ASSERT(switches_locked[chip_info->pip_data[pip.index].switch_index] != WireId());
|
2018-07-15 01:52:56 +08:00
|
|
|
|
|
|
|
WireId dst;
|
|
|
|
dst.index = chip_info->pip_data[pip.index].dst;
|
2018-08-05 21:25:42 +08:00
|
|
|
NPNR_ASSERT(wire_to_net[dst.index] != nullptr);
|
|
|
|
wire_to_net[dst.index] = nullptr;
|
|
|
|
pip_to_net[pip.index]->wires.erase(dst);
|
2018-07-15 01:52:56 +08:00
|
|
|
|
2018-08-05 21:25:42 +08:00
|
|
|
pip_to_net[pip.index] = nullptr;
|
2018-11-11 18:34:38 +08:00
|
|
|
switches_locked[chip_info->pip_data[pip.index].switch_index] = WireId();
|
2018-07-18 02:16:26 +08:00
|
|
|
refreshUiPip(pip);
|
|
|
|
refreshUiWire(dst);
|
2018-07-15 01:52:56 +08:00
|
|
|
}
|
|
|
|
|
2018-11-12 00:28:41 +08:00
|
|
|
bool ice40_pip_hard_unavail(PipId pip) const
|
2018-07-15 01:52:56 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
2018-08-03 23:37:59 +08:00
|
|
|
auto &pi = chip_info->pip_data[pip.index];
|
|
|
|
auto &si = chip_info->bits_info->switches[pi.switch_index];
|
2018-08-02 22:28:47 +08:00
|
|
|
|
2018-08-03 23:37:59 +08:00
|
|
|
if (pi.flags & PipInfoPOD::FLAG_ROUTETHRU) {
|
|
|
|
NPNR_ASSERT(si.bel >= 0);
|
2018-08-05 21:25:42 +08:00
|
|
|
if (bel_to_cell[si.bel] != nullptr)
|
2018-11-12 00:28:41 +08:00
|
|
|
return true;
|
2018-08-03 23:37:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pi.flags & PipInfoPOD::FLAG_NOCARRY) {
|
|
|
|
NPNR_ASSERT(si.bel >= 0);
|
|
|
|
if (bel_carry[si.bel])
|
2018-11-12 00:28:41 +08:00
|
|
|
return true;
|
2018-08-03 23:37:59 +08:00
|
|
|
}
|
2018-08-02 22:28:47 +08:00
|
|
|
|
2018-11-12 00:28:41 +08:00
|
|
|
return false;
|
2018-07-15 01:52:56 +08:00
|
|
|
}
|
|
|
|
|
2018-11-12 00:28:41 +08:00
|
|
|
bool checkPipAvail(PipId pip) const
|
2018-07-15 01:52:56 +08:00
|
|
|
{
|
2018-11-12 00:28:41 +08:00
|
|
|
if (ice40_pip_hard_unavail(pip))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto &pi = chip_info->pip_data[pip.index];
|
|
|
|
return switches_locked[pi.switch_index] == WireId();
|
2018-07-15 01:52:56 +08:00
|
|
|
}
|
|
|
|
|
2018-08-05 21:25:42 +08:00
|
|
|
NetInfo *getBoundPipNet(PipId pip) const
|
2018-07-15 01:52:56 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(pip != PipId());
|
|
|
|
return pip_to_net[pip.index];
|
|
|
|
}
|
|
|
|
|
2018-11-11 18:34:38 +08:00
|
|
|
WireId getConflictingPipWire(PipId pip) const
|
2018-07-15 01:52:56 +08:00
|
|
|
{
|
2018-11-12 00:28:41 +08:00
|
|
|
if (ice40_pip_hard_unavail(pip))
|
|
|
|
return WireId();
|
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
return switches_locked[chip_info->pip_data[pip.index].switch_index];
|
|
|
|
}
|
|
|
|
|
2018-11-12 00:28:41 +08:00
|
|
|
NetInfo *getConflictingPipNet(PipId pip) const
|
|
|
|
{
|
|
|
|
if (ice40_pip_hard_unavail(pip))
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
WireId wire = switches_locked[chip_info->pip_data[pip.index].switch_index];
|
|
|
|
return wire == WireId() ? nullptr : wire_to_net[wire.index];
|
|
|
|
}
|
|
|
|
|
2018-06-07 18:56:49 +08:00
|
|
|
AllPipRange getPips() const
|
|
|
|
{
|
|
|
|
AllPipRange range;
|
|
|
|
range.b.cursor = 0;
|
2018-06-17 22:12:52 +08:00
|
|
|
range.e.cursor = chip_info->num_pips;
|
2018-06-07 18:56:49 +08:00
|
|
|
return range;
|
|
|
|
}
|
2018-07-18 18:12:05 +08:00
|
|
|
|
2018-08-08 16:27:08 +08:00
|
|
|
Loc getPipLocation(PipId pip) const
|
|
|
|
{
|
|
|
|
Loc loc;
|
|
|
|
loc.x = chip_info->pip_data[pip.index].x;
|
|
|
|
loc.y = chip_info->pip_data[pip.index].y;
|
|
|
|
loc.z = 0;
|
|
|
|
return loc;
|
|
|
|
}
|
|
|
|
|
2018-07-14 02:10:20 +08:00
|
|
|
IdString getPipName(PipId pip) const;
|
|
|
|
|
2018-08-18 20:14:27 +08:00
|
|
|
IdString getPipType(PipId pip) const;
|
|
|
|
std::vector<std::pair<IdString, std::string>> getPipAttrs(PipId pip) const;
|
2018-08-14 23:16:14 +08:00
|
|
|
|
2018-07-14 02:10:20 +08:00
|
|
|
uint32_t getPipChecksum(PipId pip) const { return pip.index; }
|
2018-06-07 18:56:49 +08:00
|
|
|
|
|
|
|
WireId getPipSrcWire(PipId pip) const
|
|
|
|
{
|
|
|
|
WireId wire;
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(pip != PipId());
|
2018-06-17 22:12:52 +08:00
|
|
|
wire.index = chip_info->pip_data[pip.index].src;
|
2018-06-07 18:56:49 +08:00
|
|
|
return wire;
|
|
|
|
}
|
|
|
|
|
|
|
|
WireId getPipDstWire(PipId pip) const
|
|
|
|
{
|
|
|
|
WireId wire;
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(pip != PipId());
|
2018-06-17 22:12:52 +08:00
|
|
|
wire.index = chip_info->pip_data[pip.index].dst;
|
2018-06-07 18:56:49 +08:00
|
|
|
return wire;
|
|
|
|
}
|
|
|
|
|
|
|
|
DelayInfo getPipDelay(PipId pip) const
|
|
|
|
{
|
|
|
|
DelayInfo delay;
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(pip != PipId());
|
2018-07-30 22:21:03 +08:00
|
|
|
if (fast_part)
|
|
|
|
delay.delay = chip_info->pip_data[pip.index].fast_delay;
|
|
|
|
else
|
|
|
|
delay.delay = chip_info->pip_data[pip.index].slow_delay;
|
2018-06-07 18:56:49 +08:00
|
|
|
return delay;
|
|
|
|
}
|
|
|
|
|
|
|
|
PipRange getPipsDownhill(WireId wire) const
|
|
|
|
{
|
|
|
|
PipRange range;
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-06-17 22:12:52 +08:00
|
|
|
range.b.cursor = chip_info->wire_data[wire.index].pips_downhill.get();
|
2018-06-23 21:28:09 +08:00
|
|
|
range.e.cursor = range.b.cursor + chip_info->wire_data[wire.index].num_downhill;
|
2018-06-07 18:56:49 +08:00
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
|
|
|
PipRange getPipsUphill(WireId wire) const
|
|
|
|
{
|
|
|
|
PipRange range;
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-06-17 22:12:52 +08:00
|
|
|
range.b.cursor = chip_info->wire_data[wire.index].pips_uphill.get();
|
2018-06-23 21:28:09 +08:00
|
|
|
range.e.cursor = range.b.cursor + chip_info->wire_data[wire.index].num_uphill;
|
2018-06-07 18:56:49 +08:00
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
|
|
|
PipRange getWireAliases(WireId wire) const
|
|
|
|
{
|
|
|
|
PipRange range;
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-06-07 18:56:49 +08:00
|
|
|
range.b.cursor = nullptr;
|
|
|
|
range.e.cursor = nullptr;
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
2018-06-13 18:30:15 +08:00
|
|
|
BelId getPackagePinBel(const std::string &pin) const;
|
2018-06-16 03:29:02 +08:00
|
|
|
std::string getBelPackagePin(BelId bel) const;
|
2018-06-13 18:30:15 +08:00
|
|
|
|
2018-06-07 18:56:49 +08:00
|
|
|
// -------------------------------------------------
|
|
|
|
|
2018-07-12 23:22:29 +08:00
|
|
|
GroupId getGroupByName(IdString name) const;
|
|
|
|
IdString getGroupName(GroupId group) const;
|
|
|
|
std::vector<GroupId> getGroups() const;
|
|
|
|
std::vector<BelId> getGroupBels(GroupId group) const;
|
|
|
|
std::vector<WireId> getGroupWires(GroupId group) const;
|
|
|
|
std::vector<PipId> getGroupPips(GroupId group) const;
|
|
|
|
std::vector<GroupId> getGroupGroups(GroupId group) const;
|
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
|
2018-06-16 21:23:04 +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-06-21 20:08:45 +08:00
|
|
|
delay_t getDelayEpsilon() const { return 20; }
|
|
|
|
delay_t getRipupDelayPenalty() const { return 200; }
|
2018-06-20 18:50:38 +08:00
|
|
|
float getDelayNS(delay_t v) const { return v * 0.001; }
|
2018-11-04 22:03:33 +08:00
|
|
|
DelayInfo getDelayFromNS(float ns) const
|
|
|
|
{
|
|
|
|
DelayInfo del;
|
|
|
|
del.delay = delay_t(ns * 1000);
|
|
|
|
return del;
|
|
|
|
}
|
2018-06-21 21:47:41 +08:00
|
|
|
uint32_t getDelayChecksum(delay_t v) const { return v; }
|
2018-08-06 13:31:59 +08:00
|
|
|
bool getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t &budget) const;
|
2018-06-13 18:37:23 +08:00
|
|
|
|
|
|
|
// -------------------------------------------------
|
2018-06-12 01:46:03 +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:50 +08:00
|
|
|
std::vector<GraphicElement> getDecalGraphics(DecalId decal) const;
|
|
|
|
|
2018-07-11 20:03:23 +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-06-13 18:48:58 +08:00
|
|
|
|
2018-06-20 17:44:28 +08:00
|
|
|
// -------------------------------------------------
|
|
|
|
|
2018-06-20 18:21:56 +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-11-02 21:35:59 +08:00
|
|
|
// Get the port class, also setting clockInfoCount to the number of TimingClockingInfos associated with a port
|
|
|
|
TimingPortClass getPortTimingClass(const CellInfo *cell, IdString port, int &clockInfoCount) const;
|
|
|
|
// Get the TimingClockingInfo of a port
|
|
|
|
TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const;
|
2018-06-23 18:09:01 +08:00
|
|
|
// Return true if a port is a net
|
|
|
|
bool isGlobalNet(const NetInfo *net) const;
|
|
|
|
|
2018-06-25 17:43:59 +08:00
|
|
|
// -------------------------------------------------
|
|
|
|
|
2018-08-07 08:35:23 +08:00
|
|
|
// Perform placement validity checks, returning false on failure (all
|
|
|
|
// implemented in arch_place.cc)
|
2018-07-15 01:50:29 +08:00
|
|
|
|
2018-06-25 17:43:59 +08:00
|
|
|
// Whether or not a given cell can be placed at a given Bel
|
|
|
|
// This is not intended for Bel type checks, but finer-grained constraints
|
|
|
|
// such as conflicting set/reset signals, etc
|
|
|
|
bool isValidBelForCell(CellInfo *cell, BelId bel) const;
|
2018-07-15 01:50:29 +08:00
|
|
|
|
2018-06-25 17:43:59 +08:00
|
|
|
// Return true whether all Bels at a given location are valid
|
|
|
|
bool isBelLocationValid(BelId bel) const;
|
2018-07-15 01:50:29 +08:00
|
|
|
|
2018-06-25 17:43:59 +08:00
|
|
|
// Helper function for above
|
2018-09-30 22:13:18 +08:00
|
|
|
bool logicCellsCompatible(const CellInfo **it, const size_t size) const;
|
2018-06-25 17:43:59 +08:00
|
|
|
|
2018-07-18 18:21:02 +08:00
|
|
|
// -------------------------------------------------
|
2018-08-07 08:35:23 +08:00
|
|
|
// Assign architecure-specific arguments to nets and cells, which must be
|
|
|
|
// called between packing or further
|
2018-07-18 18:21:02 +08:00
|
|
|
// netlist modifications, and validity checks
|
2018-07-18 20:34:32 +08:00
|
|
|
void assignArchInfo();
|
|
|
|
void assignCellInfo(CellInfo *cell);
|
2018-07-18 18:21:02 +08:00
|
|
|
|
2018-07-25 18:32:21 +08:00
|
|
|
// -------------------------------------------------
|
2018-08-08 23:01:18 +08:00
|
|
|
BelPin getIOBSharingPLLPin(BelId pll, IdString pll_pin) const
|
2018-07-25 18:32:21 +08:00
|
|
|
{
|
|
|
|
auto wire = getBelPinWire(pll, pll_pin);
|
|
|
|
for (auto src_bel : getWireBelPins(wire)) {
|
2018-08-08 23:01:18 +08:00
|
|
|
if (getBelType(src_bel.bel) == id_SB_IO && src_bel.pin == id_D_IN_0) {
|
2018-07-25 18:32:21 +08:00
|
|
|
return src_bel;
|
|
|
|
}
|
|
|
|
}
|
2018-07-25 18:57:10 +08:00
|
|
|
NPNR_ASSERT_FALSE("Expected PLL pin to share an output with an SB_IO D_IN_{0,1}");
|
2018-07-25 18:32:21 +08:00
|
|
|
}
|
2018-05-26 20:27:21 +08:00
|
|
|
};
|
|
|
|
|
2018-08-04 19:41:42 +08:00
|
|
|
void ice40DelayFuzzerMain(Context *ctx);
|
|
|
|
|
2018-06-12 20:24:59 +08:00
|
|
|
NEXTPNR_NAMESPACE_END
|