clangformat
Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
parent
d00fdc8f7a
commit
2afb1f632e
@ -185,7 +185,8 @@ template <typename R> struct BaseArch : ArchAPI<R>
|
||||
return empty_if_possible<typename R::BelAttrsRangeT>();
|
||||
}
|
||||
|
||||
virtual typename R::CellBelPinRangeT getBelPinsForCellPin(const CellInfo * /*cell_info*/, IdString pin) const override
|
||||
virtual typename R::CellBelPinRangeT getBelPinsForCellPin(const CellInfo * /*cell_info*/,
|
||||
IdString pin) const override
|
||||
{
|
||||
return return_if_match<std::array<IdString, 1>, typename R::CellBelPinRangeT>({pin});
|
||||
}
|
||||
@ -314,7 +315,8 @@ template <typename R> struct BaseArch : ArchAPI<R>
|
||||
};
|
||||
|
||||
// Delay methods
|
||||
virtual bool getArcDelayOverride(const NetInfo * /*net_info*/, const PortRef &/*sink*/, DelayQuad &/*delay*/) const override
|
||||
virtual bool getArcDelayOverride(const NetInfo * /*net_info*/, const PortRef & /*sink*/,
|
||||
DelayQuad & /*delay*/) const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -330,15 +332,18 @@ template <typename R> struct BaseArch : ArchAPI<R>
|
||||
virtual DecalXY getGroupDecal(GroupId /*group*/) const override { return DecalXY(); }
|
||||
|
||||
// Cell timing methods
|
||||
virtual bool getCellDelay(const CellInfo * /*cell*/, IdString /*fromPort*/, IdString /*toPort*/, DelayQuad &/*delay*/) const override
|
||||
virtual bool getCellDelay(const CellInfo * /*cell*/, IdString /*fromPort*/, IdString /*toPort*/,
|
||||
DelayQuad & /*delay*/) const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual TimingPortClass getPortTimingClass(const CellInfo * /*cell*/, IdString /*port*/, int &/*clockInfoCount*/) const override
|
||||
virtual TimingPortClass getPortTimingClass(const CellInfo * /*cell*/, IdString /*port*/,
|
||||
int & /*clockInfoCount*/) const override
|
||||
{
|
||||
return TMG_IGNORE;
|
||||
}
|
||||
virtual TimingClockingInfo getPortClockingInfo(const CellInfo * /*cell*/, IdString /*port*/, int /*index*/) const override
|
||||
virtual TimingClockingInfo getPortClockingInfo(const CellInfo * /*cell*/, IdString /*port*/,
|
||||
int /*index*/) const override
|
||||
{
|
||||
NPNR_ASSERT_FALSE("unreachable");
|
||||
}
|
||||
|
@ -105,7 +105,9 @@ struct DelayQuad
|
||||
DelayQuad(delay_t min_delay, delay_t max_delay) : rise(min_delay, max_delay), fall(min_delay, max_delay) {}
|
||||
DelayQuad(DelayPair rise, DelayPair fall) : rise(rise), fall(fall) {}
|
||||
DelayQuad(delay_t min_rise, delay_t max_rise, delay_t min_fall, delay_t max_fall)
|
||||
: rise(min_rise, max_rise), fall(min_fall, max_fall) { }
|
||||
: rise(min_rise, max_rise), fall(min_fall, max_fall)
|
||||
{
|
||||
}
|
||||
|
||||
delay_t minRiseDelay() const { return rise.minDelay(); }
|
||||
delay_t maxRiseDelay() const { return rise.maxDelay(); }
|
||||
@ -209,8 +211,14 @@ struct RegionPlug : PseudoCell
|
||||
|
||||
// TODO: partial reconfiguration region timing
|
||||
bool getDelay(IdString /*fromPort*/, IdString /*toPort*/, DelayQuad & /*delay*/) const override { return false; }
|
||||
TimingPortClass getPortTimingClass(IdString /*port*/, int &/*clockInfoCount*/) const override { return TMG_IGNORE; }
|
||||
TimingClockingInfo getPortClockingInfo(IdString /*port*/, int /*index*/) const override { return TimingClockingInfo{}; }
|
||||
TimingPortClass getPortTimingClass(IdString /*port*/, int & /*clockInfoCount*/) const override
|
||||
{
|
||||
return TMG_IGNORE;
|
||||
}
|
||||
TimingClockingInfo getPortClockingInfo(IdString /*port*/, int /*index*/) const override
|
||||
{
|
||||
return TimingClockingInfo{};
|
||||
}
|
||||
|
||||
dict<IdString, WireId> port_wires;
|
||||
Loc loc;
|
||||
|
150
rust/rust.cc
150
rust/rust.cc
@ -24,40 +24,41 @@
|
||||
namespace {
|
||||
USING_NEXTPNR_NAMESPACE;
|
||||
|
||||
template<typename T> static inline uint64_t wrap(const T &thing) noexcept {
|
||||
template <typename T> static inline uint64_t wrap(const T &thing) noexcept
|
||||
{
|
||||
static_assert(sizeof(T) <= 8, "T is too big for FFI");
|
||||
uint64_t b = 0;
|
||||
memcpy(&b, &thing, sizeof(T));
|
||||
return b;
|
||||
}
|
||||
|
||||
template<typename T> static inline T unwrap(const std::array<uint8_t, 8> &value) noexcept {
|
||||
template <typename T> static inline T unwrap(const std::array<uint8_t, 8> &value) noexcept
|
||||
{
|
||||
static_assert(sizeof(T) <= 8, "T is too big for FFI");
|
||||
T result{};
|
||||
memcpy(&result, value.data(), sizeof(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T> static inline T unwrap(const uint64_t value) noexcept {
|
||||
template <typename T> static inline T unwrap(const uint64_t value) noexcept
|
||||
{
|
||||
std::array<uint8_t, 8> data{};
|
||||
static_assert(sizeof(value) >= data.size(), "uint64_t is not an appropriate size");
|
||||
memcpy(data.data(), &value, data.size());
|
||||
return unwrap<T>(data);
|
||||
}
|
||||
|
||||
static inline BelId unwrap_bel(const uint64_t bel) noexcept
|
||||
{ return unwrap<BelId>(bel); }
|
||||
static inline BelId unwrap_bel(const uint64_t bel) noexcept { return unwrap<BelId>(bel); }
|
||||
|
||||
static inline PipId unwrap_pip(const uint64_t pip) noexcept
|
||||
{ return unwrap<PipId>(pip); }
|
||||
static inline PipId unwrap_pip(const uint64_t pip) noexcept { return unwrap<PipId>(pip); }
|
||||
|
||||
static inline WireId unwrap_wire(const uint64_t wire) noexcept
|
||||
{ return unwrap<WireId>(wire); }
|
||||
}
|
||||
static inline WireId unwrap_wire(const uint64_t wire) noexcept { return unwrap<WireId>(wire); }
|
||||
} // namespace
|
||||
|
||||
using DownhillIter = decltype(Context(ArchArgs()).getPipsDownhill(WireId()).begin());
|
||||
|
||||
struct DownhillIterWrapper {
|
||||
struct DownhillIterWrapper
|
||||
{
|
||||
DownhillIter current;
|
||||
DownhillIter end;
|
||||
|
||||
@ -65,7 +66,8 @@ struct DownhillIterWrapper {
|
||||
};
|
||||
using UphillIter = decltype(Context(ArchArgs()).getPipsUphill(WireId()).begin());
|
||||
|
||||
struct UphillIterWrapper {
|
||||
struct UphillIterWrapper
|
||||
{
|
||||
UphillIter current;
|
||||
UphillIter end;
|
||||
|
||||
@ -84,28 +86,54 @@ extern "C" {
|
||||
|
||||
int npnr_context_get_grid_dim_x(const Context *ctx) { return ctx->getGridDimX(); }
|
||||
int npnr_context_get_grid_dim_y(const Context *ctx) { return ctx->getGridDimY(); }
|
||||
void npnr_context_bind_bel(Context *ctx, uint64_t bel, CellInfo* cell, PlaceStrength strength) { return ctx->bindBel(unwrap_bel(bel), cell, strength); }
|
||||
void npnr_context_bind_bel(Context *ctx, uint64_t bel, CellInfo *cell, PlaceStrength strength)
|
||||
{
|
||||
return ctx->bindBel(unwrap_bel(bel), cell, strength);
|
||||
}
|
||||
void npnr_context_unbind_bel(Context *ctx, uint64_t bel) { return ctx->unbindBel(unwrap_bel(bel)); }
|
||||
bool npnr_context_check_bel_avail(Context *ctx, uint64_t bel) { return ctx->checkBelAvail(unwrap_bel(bel)); }
|
||||
void npnr_context_bind_wire(Context *ctx, uint64_t wire, NetInfo* net, PlaceStrength strength) { ctx->bindWire(unwrap_wire(wire), net, strength); }
|
||||
void npnr_context_bind_wire(Context *ctx, uint64_t wire, NetInfo *net, PlaceStrength strength)
|
||||
{
|
||||
ctx->bindWire(unwrap_wire(wire), net, strength);
|
||||
}
|
||||
void npnr_context_unbind_wire(Context *ctx, uint64_t wire) { ctx->unbindWire(unwrap_wire(wire)); }
|
||||
void npnr_context_bind_pip(Context *ctx, uint64_t pip, NetInfo* net, PlaceStrength strength) { ctx->bindPip(unwrap_pip(pip), net, strength); }
|
||||
void npnr_context_bind_pip(Context *ctx, uint64_t pip, NetInfo *net, PlaceStrength strength)
|
||||
{
|
||||
ctx->bindPip(unwrap_pip(pip), net, strength);
|
||||
}
|
||||
void npnr_context_unbind_pip(Context *ctx, uint64_t pip) { ctx->unbindPip(unwrap_pip(pip)); }
|
||||
uint64_t npnr_context_get_pip_src_wire(const Context *ctx, uint64_t pip) { return wrap(ctx->getPipSrcWire(unwrap_pip(pip))); }
|
||||
uint64_t npnr_context_get_pip_dst_wire(const Context *ctx, uint64_t pip) { return wrap(ctx->getPipDstWire(unwrap_pip(pip))); }
|
||||
float npnr_context_estimate_delay(const Context *ctx, uint64_t src, uint64_t dst) { return ctx->getDelayNS(ctx->estimateDelay(unwrap_wire(src), unwrap_wire(dst))); }
|
||||
float npnr_context_get_pip_delay(const Context *ctx, uint64_t pip) { return ctx->getDelayNS(ctx->getPipDelay(unwrap_pip(pip)).maxDelay()); }
|
||||
float npnr_context_get_wire_delay(const Context *ctx, uint64_t wire) { return ctx->getDelayNS(ctx->getWireDelay(unwrap_wire(wire)).maxDelay()); }
|
||||
uint64_t npnr_context_get_pip_src_wire(const Context *ctx, uint64_t pip)
|
||||
{
|
||||
return wrap(ctx->getPipSrcWire(unwrap_pip(pip)));
|
||||
}
|
||||
uint64_t npnr_context_get_pip_dst_wire(const Context *ctx, uint64_t pip)
|
||||
{
|
||||
return wrap(ctx->getPipDstWire(unwrap_pip(pip)));
|
||||
}
|
||||
float npnr_context_estimate_delay(const Context *ctx, uint64_t src, uint64_t dst)
|
||||
{
|
||||
return ctx->getDelayNS(ctx->estimateDelay(unwrap_wire(src), unwrap_wire(dst)));
|
||||
}
|
||||
float npnr_context_get_pip_delay(const Context *ctx, uint64_t pip)
|
||||
{
|
||||
return ctx->getDelayNS(ctx->getPipDelay(unwrap_pip(pip)).maxDelay());
|
||||
}
|
||||
float npnr_context_get_wire_delay(const Context *ctx, uint64_t wire)
|
||||
{
|
||||
return ctx->getDelayNS(ctx->getWireDelay(unwrap_wire(wire)).maxDelay());
|
||||
}
|
||||
float npnr_context_delay_epsilon(const Context *ctx) { return ctx->getDelayNS(ctx->getDelayEpsilon()); }
|
||||
Loc npnr_context_get_pip_location(const Context *ctx, uint64_t pip) { return ctx->getPipLocation(unwrap_pip(pip)); }
|
||||
bool npnr_context_check_pip_avail_for_net(const Context *ctx, uint64_t pip, NetInfo *net) { return ctx->checkPipAvailForNet(unwrap_pip(pip), net); }
|
||||
bool npnr_context_check_pip_avail_for_net(const Context *ctx, uint64_t pip, NetInfo *net)
|
||||
{
|
||||
return ctx->checkPipAvailForNet(unwrap_pip(pip), net);
|
||||
}
|
||||
|
||||
uint64_t npnr_context_get_pips_leak(const Context *const ctx, uint64_t **const pips) {
|
||||
uint64_t npnr_context_get_pips_leak(const Context *const ctx, uint64_t **const pips)
|
||||
{
|
||||
const auto ctx_pips{ctx->getPips()};
|
||||
const auto size{
|
||||
std::accumulate(ctx_pips.begin(), ctx_pips.end(), /*initial value*/ size_t{},
|
||||
[](size_t value, const auto &/*pip*/) { return value + 1U; }
|
||||
)};
|
||||
const auto size{std::accumulate(ctx_pips.begin(), ctx_pips.end(), /*initial value*/ size_t{},
|
||||
[](size_t value, const auto & /*pip*/) { return value + 1U; })};
|
||||
*pips = new uint64_t[size];
|
||||
auto idx = 0;
|
||||
for (const auto &pip : ctx_pips) {
|
||||
@ -116,12 +144,11 @@ extern "C" {
|
||||
return size;
|
||||
}
|
||||
|
||||
uint64_t npnr_context_get_wires_leak(const Context *const ctx, uint64_t **const wires) {
|
||||
uint64_t npnr_context_get_wires_leak(const Context *const ctx, uint64_t **const wires)
|
||||
{
|
||||
const auto ctx_wires{ctx->getWires()};
|
||||
const auto size{
|
||||
std::accumulate(ctx_wires.begin(), ctx_wires.end(), /*initial value*/ size_t{},
|
||||
[](size_t value, const auto &/*wire*/) { return value + 1U; }
|
||||
)};
|
||||
const auto size{std::accumulate(ctx_wires.begin(), ctx_wires.end(), /*initial value*/ size_t{},
|
||||
[](size_t value, const auto & /*wire*/) { return value + 1U; })};
|
||||
*wires = new uint64_t[size];
|
||||
auto idx = 0;
|
||||
for (const auto &wire : ctx_wires) {
|
||||
@ -140,10 +167,17 @@ extern "C" {
|
||||
const char *npnr_context_name_of_wire(const Context *ctx, uint64_t wire) { return ctx->nameOfWire(unwrap_wire(wire)); }
|
||||
bool npnr_context_verbose(const Context *ctx) { return ctx->verbose; }
|
||||
|
||||
uint64_t npnr_context_get_netinfo_source_wire(const Context *ctx, const NetInfo *net) { return wrap(ctx->getNetinfoSourceWire(net)); }
|
||||
uint64_t npnr_context_get_netinfo_sink_wire(const Context *ctx, const NetInfo *net, const PortRef *sink, uint32_t n) { return wrap(ctx->getNetinfoSinkWire(net, *sink, n)); }
|
||||
uint64_t npnr_context_get_netinfo_source_wire(const Context *ctx, const NetInfo *net)
|
||||
{
|
||||
return wrap(ctx->getNetinfoSourceWire(net));
|
||||
}
|
||||
uint64_t npnr_context_get_netinfo_sink_wire(const Context *ctx, const NetInfo *net, const PortRef *sink, uint32_t n)
|
||||
{
|
||||
return wrap(ctx->getNetinfoSinkWire(net, *sink, n));
|
||||
}
|
||||
|
||||
uint32_t npnr_context_nets_leak(const Context *ctx, int **names, NetInfo ***nets) {
|
||||
uint32_t npnr_context_nets_leak(const Context *ctx, int **names, NetInfo ***nets)
|
||||
{
|
||||
auto size = ctx->nets.size();
|
||||
*names = new int[size];
|
||||
*nets = new NetInfo *[size];
|
||||
@ -157,31 +191,31 @@ extern "C" {
|
||||
return size;
|
||||
}
|
||||
|
||||
DownhillIterWrapper *npnr_context_get_pips_downhill(Context *ctx, uint64_t wire_id) {
|
||||
DownhillIterWrapper *npnr_context_get_pips_downhill(Context *ctx, uint64_t wire_id)
|
||||
{
|
||||
auto wire = unwrap_wire(wire_id);
|
||||
auto range = ctx->getPipsDownhill(wire);
|
||||
return new DownhillIterWrapper(range.begin(), range.end());
|
||||
}
|
||||
void npnr_delete_downhill_iter(DownhillIterWrapper *iter) {
|
||||
delete iter;
|
||||
}
|
||||
UphillIterWrapper *npnr_context_get_pips_uphill(Context *ctx, uint64_t wire_id) {
|
||||
void npnr_delete_downhill_iter(DownhillIterWrapper *iter) { delete iter; }
|
||||
UphillIterWrapper *npnr_context_get_pips_uphill(Context *ctx, uint64_t wire_id)
|
||||
{
|
||||
auto wire = unwrap_wire(wire_id);
|
||||
auto range = ctx->getPipsUphill(wire);
|
||||
return new UphillIterWrapper(range.begin(), range.end());
|
||||
}
|
||||
void npnr_delete_uphill_iter(UphillIterWrapper *iter) {
|
||||
delete iter;
|
||||
}
|
||||
void npnr_delete_uphill_iter(UphillIterWrapper *iter) { delete iter; }
|
||||
|
||||
PortRef* npnr_netinfo_driver(NetInfo *net) {
|
||||
PortRef *npnr_netinfo_driver(NetInfo *net)
|
||||
{
|
||||
if (net == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return &net->driver;
|
||||
}
|
||||
|
||||
uint32_t npnr_netinfo_users_leak(NetInfo *net, PortRef ***users) {
|
||||
uint32_t npnr_netinfo_users_leak(NetInfo *net, PortRef ***users)
|
||||
{
|
||||
auto size = net->users.entries();
|
||||
*users = new PortRef *[size];
|
||||
auto idx = 0;
|
||||
@ -205,32 +239,18 @@ extern "C" {
|
||||
CellInfo *npnr_portref_cell(const PortRef *port) { return port->cell; }
|
||||
Loc npnr_cellinfo_get_location(const CellInfo *info) { return info->getLocation(); }
|
||||
|
||||
void npnr_inc_downhill_iter(DownhillIterWrapper *iter) {
|
||||
++iter->current;
|
||||
}
|
||||
uint64_t npnr_deref_downhill_iter(DownhillIterWrapper *iter) {
|
||||
return wrap(*iter->current);
|
||||
}
|
||||
bool npnr_is_downhill_iter_done(DownhillIterWrapper *iter) {
|
||||
return !(iter->current != iter->end);
|
||||
}
|
||||
void npnr_inc_uphill_iter(UphillIterWrapper *iter) {
|
||||
++iter->current;
|
||||
}
|
||||
uint64_t npnr_deref_uphill_iter(UphillIterWrapper *iter) {
|
||||
return wrap(*iter->current);
|
||||
}
|
||||
bool npnr_is_uphill_iter_done(UphillIterWrapper *iter) {
|
||||
return !(iter->current != iter->end);
|
||||
}
|
||||
void npnr_inc_downhill_iter(DownhillIterWrapper *iter) { ++iter->current; }
|
||||
uint64_t npnr_deref_downhill_iter(DownhillIterWrapper *iter) { return wrap(*iter->current); }
|
||||
bool npnr_is_downhill_iter_done(DownhillIterWrapper *iter) { return !(iter->current != iter->end); }
|
||||
void npnr_inc_uphill_iter(UphillIterWrapper *iter) { ++iter->current; }
|
||||
uint64_t npnr_deref_uphill_iter(UphillIterWrapper *iter) { return wrap(*iter->current); }
|
||||
bool npnr_is_uphill_iter_done(UphillIterWrapper *iter) { return !(iter->current != iter->end); }
|
||||
|
||||
void rust_example_printnets(Context *ctx);
|
||||
}
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
void example_printnets(Context *ctx) {
|
||||
rust_example_printnets(ctx);
|
||||
}
|
||||
void example_printnets(Context *ctx) { rust_example_printnets(ctx); }
|
||||
|
||||
NEXTPNR_NAMESPACE_END
|
||||
|
Loading…
Reference in New Issue
Block a user