Adding archdefs and bba PODs
Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
parent
1afa494e69
commit
54e0ef9cf7
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
|||||||
/nextpnr-generic*
|
/nextpnr-generic*
|
||||||
/nextpnr-ice40*
|
/nextpnr-ice40*
|
||||||
/nextpnr-ecp5*
|
/nextpnr-ecp5*
|
||||||
|
/nextpnr-nexus*
|
||||||
cmake-build-*/
|
cmake-build-*/
|
||||||
Makefile
|
Makefile
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
|
@ -66,7 +66,7 @@ endif()
|
|||||||
set(PROGRAM_PREFIX "" CACHE STRING "Name prefix for executables")
|
set(PROGRAM_PREFIX "" CACHE STRING "Name prefix for executables")
|
||||||
|
|
||||||
# List of families to build
|
# List of families to build
|
||||||
set(FAMILIES generic ice40 ecp5)
|
set(FAMILIES generic ice40 ecp5 nexus)
|
||||||
|
|
||||||
set(ARCH "" CACHE STRING "Architecture family for nextpnr build")
|
set(ARCH "" CACHE STRING "Architecture family for nextpnr build")
|
||||||
set_property(CACHE ARCH PROPERTY STRINGS ${FAMILIES})
|
set_property(CACHE ARCH PROPERTY STRINGS ${FAMILIES})
|
||||||
|
172
nexus/arch.h
Normal file
172
nexus/arch.h
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
/*
|
||||||
|
* nextpnr -- Next Generation Place and Route
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 David Shah <dave@ds0.me>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
#include <boost/iostreams/device/mapped_file.hpp>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
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) + int64_t(offset) * 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
const T &operator[](size_t index) const { return get()[index]; }
|
||||||
|
|
||||||
|
const T &operator*() const { return *(get()); }
|
||||||
|
|
||||||
|
const T *operator->() const { return get(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Fully deduplicated database
|
||||||
|
|
||||||
|
There are two key data structures in the database:
|
||||||
|
|
||||||
|
Locations (aka tile but not called this to avoid confusion
|
||||||
|
with Lattice terminology), are a (x, y) location.
|
||||||
|
|
||||||
|
Local wires; pips and bels are all stored once per variety of location
|
||||||
|
(called a location type) with a separate grid containing the location type
|
||||||
|
at a (x, y) coordinate.
|
||||||
|
|
||||||
|
Each location also has _neighbours_, other locations with interconnected
|
||||||
|
wires. The set of neighbours for a location are called a _neighbourhood_.
|
||||||
|
|
||||||
|
Each variety of _neighbourhood_ for a location type is also stored once,
|
||||||
|
using relative coordinates.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
NPNR_PACKED_STRUCT(struct BelWirePOD {
|
||||||
|
uint32_t port;
|
||||||
|
uint16_t type;
|
||||||
|
uint16_t wire_index; // wire index in tile
|
||||||
|
});
|
||||||
|
|
||||||
|
NPNR_PACKED_STRUCT(struct BelInfoPOD {
|
||||||
|
int32_t name; // bel name in tile IdString
|
||||||
|
int32_t type; // bel type IdString
|
||||||
|
int16_t rel_x, rel_y; // bel location relative to parent
|
||||||
|
RelPtr<BelWirePOD> ports; // ports, sorted by name IdString
|
||||||
|
int32_t num_ports; // number of ports
|
||||||
|
});
|
||||||
|
|
||||||
|
NPNR_PACKED_STRUCT(struct BelPinPOD {
|
||||||
|
uint32_t bel; // bel index in tile
|
||||||
|
int32_t pin; // bel pin name IdString
|
||||||
|
});
|
||||||
|
|
||||||
|
enum TileWireFlags : uint32_t {
|
||||||
|
WIRE_PRIMARY = 0x80000000,
|
||||||
|
}
|
||||||
|
|
||||||
|
NPNR_PACKED_STRUCT(struct LocWireInfoPOD {
|
||||||
|
int32_t name; // wire name in tile IdString
|
||||||
|
uint32_t flags;
|
||||||
|
int32_t num_uphill, num_downhill, num_bpins;
|
||||||
|
// Note this pip lists exclude neighbourhood pips
|
||||||
|
RelPtr<int32_t> pips_uh, pips_dh; // list of uphill/downhill pip indices in tile
|
||||||
|
RelPtr<BelPinPOD> bel_pins;
|
||||||
|
});
|
||||||
|
|
||||||
|
NPNR_PACKED_STRUCT(struct PipInfoPOD {
|
||||||
|
uint16_t from_wire, to_wire;
|
||||||
|
int32_t tile_type;
|
||||||
|
});
|
||||||
|
|
||||||
|
enum RelLocFlags
|
||||||
|
{
|
||||||
|
REL_GLOBAL = 0x80,
|
||||||
|
REL_BRANCH = 0x40,
|
||||||
|
REL_SPINE = 0x20,
|
||||||
|
REL_HROW = 0x10
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ArcFlags
|
||||||
|
{
|
||||||
|
LOGICAL_TO_PRIMARY = 0x80,
|
||||||
|
PHYSICAL_DOWNHILL = 0x08,
|
||||||
|
};
|
||||||
|
|
||||||
|
NPNR_PACKED_STRUCT(struct RelWireInfoPOD {
|
||||||
|
int16_t rel_x, rel_y;
|
||||||
|
uint16_t wire_index;
|
||||||
|
uint8_t loc_flags;
|
||||||
|
uint8_t arc_flags;
|
||||||
|
});
|
||||||
|
|
||||||
|
NPNR_PACKED_STRUCT(struct WireNeighboursInfoPOD {
|
||||||
|
uint16_t num_uphill, num_downhill;
|
||||||
|
RelPtr<RelWireInfoPOD> wires_uh, wires_dh;
|
||||||
|
});
|
||||||
|
|
||||||
|
NPNR_PACKED_STRUCT(struct LocNeighourhoodPOD { RelPtr<WireNeighboursInfoPOD> wire_neighbours; });
|
||||||
|
|
||||||
|
NPNR_PACKED_STRUCT(struct LocTypePOD {
|
||||||
|
uint32_t num_bels, num_wires, num_pips, num_nhtypes;
|
||||||
|
RelPtr<BelInfoPOD> bels;
|
||||||
|
RelPtr<LocWireInfoPOD> wires;
|
||||||
|
RelPtr<PipInfoPOD> pips;
|
||||||
|
RelPtr<LocNeighourhoodPOD> neighbourhoods;
|
||||||
|
});
|
||||||
|
|
||||||
|
// A physical (bitstream) tile; of which there may be more than
|
||||||
|
// one in a logical tile (XY grid location).
|
||||||
|
// Tile name is reconstructed {prefix}R{row}C{col}:{tiletype}
|
||||||
|
NPNR_PACKED_STRUCT(struct PhysicalTileInfoPOD {
|
||||||
|
int32_t prefix; // tile name prefix IdString
|
||||||
|
int32_t tiletype; // tile type IdString
|
||||||
|
});
|
||||||
|
|
||||||
|
NPNR_PACKED_STRUCT(struct GridLocationPOD {
|
||||||
|
uint32_t loc_type;
|
||||||
|
uint16_t neighbourhood_type;
|
||||||
|
uint16_t num_phys_tiles;
|
||||||
|
RelPtr<PhysicalTileInfoPOD> phys_tiles;
|
||||||
|
});
|
||||||
|
|
||||||
|
NPNR_PACKED_STRUCT(struct ChipInfoPOD {
|
||||||
|
RelPtr<char> device_name;
|
||||||
|
uint16_t width;
|
||||||
|
uint16_t height;
|
||||||
|
RelPtr<GridLocationPOD> grid;
|
||||||
|
});
|
||||||
|
|
||||||
|
NPNR_PACKED_STRUCT(struct DatabasePOD {
|
||||||
|
uint32_t num_chips;
|
||||||
|
RelPtr<ChipInfoPOD> chips;
|
||||||
|
});
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_END
|
215
nexus/archdefs.h
Normal file
215
nexus/archdefs.h
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
/*
|
||||||
|
* nextpnr -- Next Generation Place and Route
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 David Shah <dave@ds0.me>
|
||||||
|
*
|
||||||
|
* 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 min_delay = 0, max_delay = 0;
|
||||||
|
|
||||||
|
delay_t minRaiseDelay() const { return min_delay; }
|
||||||
|
delay_t maxRaiseDelay() const { return max_delay; }
|
||||||
|
|
||||||
|
delay_t minFallDelay() const { return min_delay; }
|
||||||
|
delay_t maxFallDelay() const { return max_delay; }
|
||||||
|
|
||||||
|
delay_t minDelay() const { return min_delay; }
|
||||||
|
delay_t maxDelay() const { return max_delay; }
|
||||||
|
|
||||||
|
DelayInfo operator+(const DelayInfo &other) const
|
||||||
|
{
|
||||||
|
DelayInfo ret;
|
||||||
|
ret.min_delay = this->min_delay + other.min_delay;
|
||||||
|
ret.max_delay = this->max_delay + other.max_delay;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ConstIds
|
||||||
|
{
|
||||||
|
ID_NONE
|
||||||
|
#define X(t) , ID_##t
|
||||||
|
#include "constids.inc"
|
||||||
|
#undef X
|
||||||
|
};
|
||||||
|
|
||||||
|
#define X(t) static constexpr auto id_##t = IdString(ID_##t);
|
||||||
|
#include "constids.inc"
|
||||||
|
#undef X
|
||||||
|
|
||||||
|
struct BelId
|
||||||
|
{
|
||||||
|
int32_t tile = -1;
|
||||||
|
// PIP index in tile
|
||||||
|
int32_t index = -1;
|
||||||
|
|
||||||
|
bool operator==(const BelId &other) const { return tile == other.tile && index == other.index; }
|
||||||
|
bool operator!=(const BelId &other) const { return tile != other.tile || index != other.index; }
|
||||||
|
bool operator<(const BelId &other) const
|
||||||
|
{
|
||||||
|
return tile < other.tile || (tile == other.tile && index < other.index);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WireId
|
||||||
|
{
|
||||||
|
int32_t tile = -1;
|
||||||
|
// Node wires: tile == -1; index = node index in chipdb
|
||||||
|
// Tile wires: tile != -1; index = wire index in tile
|
||||||
|
int32_t index = -1;
|
||||||
|
|
||||||
|
bool operator==(const WireId &other) const { return tile == other.tile && index == other.index; }
|
||||||
|
bool operator!=(const WireId &other) const { return tile != other.tile || index != other.index; }
|
||||||
|
bool operator<(const WireId &other) const
|
||||||
|
{
|
||||||
|
return tile < other.tile || (tile == other.tile && index < other.index);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PipId
|
||||||
|
{
|
||||||
|
int32_t tile = -1;
|
||||||
|
// PIP index in tile
|
||||||
|
int32_t index = -1;
|
||||||
|
|
||||||
|
bool operator==(const PipId &other) const { return tile == other.tile && index == other.index; }
|
||||||
|
bool operator!=(const PipId &other) const { return tile != other.tile || index != other.index; }
|
||||||
|
bool operator<(const PipId &other) const
|
||||||
|
{
|
||||||
|
return tile < other.tile || (tile == other.tile && index < other.index);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GroupId
|
||||||
|
{
|
||||||
|
enum : int8_t
|
||||||
|
{
|
||||||
|
TYPE_NONE,
|
||||||
|
} 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); }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DecalId
|
||||||
|
{
|
||||||
|
enum : int8_t
|
||||||
|
{
|
||||||
|
TYPE_NONE,
|
||||||
|
TYPE_BEL,
|
||||||
|
TYPE_WIRE,
|
||||||
|
TYPE_PIP,
|
||||||
|
TYPE_GROUP
|
||||||
|
} type = TYPE_NONE;
|
||||||
|
int32_t index = -1;
|
||||||
|
bool active = false;
|
||||||
|
|
||||||
|
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); }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ArchNetInfo
|
||||||
|
{
|
||||||
|
bool is_global = false;
|
||||||
|
bool is_clock, is_reset = false, is_enable = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ArchCellInfo
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
bool is_memory, is_carry;
|
||||||
|
int input_count;
|
||||||
|
} lutInfo;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
bool is_clkinv, is_lsrinv, is_ceinv, is_async, gsr;
|
||||||
|
NetInfo *clk, *lsr, *ce, *d;
|
||||||
|
} ffInfo;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX BelId>
|
||||||
|
{
|
||||||
|
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX BelId &bel) const noexcept
|
||||||
|
{
|
||||||
|
std::size_t seed = 0;
|
||||||
|
boost::hash_combine(seed, hash<int>()(bel.tile));
|
||||||
|
boost::hash_combine(seed, hash<int>()(bel.index));
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX WireId>
|
||||||
|
{
|
||||||
|
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX WireId &wire) const noexcept
|
||||||
|
{
|
||||||
|
std::size_t seed = 0;
|
||||||
|
boost::hash_combine(seed, hash<int>()(wire.tile));
|
||||||
|
boost::hash_combine(seed, hash<int>()(wire.index));
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX PipId>
|
||||||
|
{
|
||||||
|
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX PipId &pip) const noexcept
|
||||||
|
{
|
||||||
|
std::size_t seed = 0;
|
||||||
|
boost::hash_combine(seed, hash<int>()(pip.tile));
|
||||||
|
boost::hash_combine(seed, hash<int>()(pip.index));
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX GroupId>
|
||||||
|
{
|
||||||
|
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX GroupId &group) const noexcept
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX DecalId>
|
||||||
|
{
|
||||||
|
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX DecalId &decal) const noexcept
|
||||||
|
{
|
||||||
|
std::size_t seed = 0;
|
||||||
|
boost::hash_combine(seed, hash<int>()(decal.type));
|
||||||
|
boost::hash_combine(seed, hash<int>()(decal.index));
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace std
|
0
nexus/constids.inc
Normal file
0
nexus/constids.inc
Normal file
0
nexus/family.cmake
Normal file
0
nexus/family.cmake
Normal file
Loading…
Reference in New Issue
Block a user