Add ctx->pack() API

Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
Clifford Wolf 2018-07-13 15:16:44 +02:00
parent 45462ef3a7
commit c05bea12e0
12 changed files with 14 additions and 75 deletions

View File

@ -730,6 +730,7 @@ struct Arch : BaseCtx
// -------------------------------------------------
bool pack();
bool place();
bool route();

View File

@ -43,7 +43,6 @@
#include "bitstream.h"
#include "design_utils.h"
#include "jsonparse.h"
#include "pack.h"
#include "timing.h"
USING_NEXTPNR_NAMESPACE
@ -147,7 +146,7 @@ int main(int argc, char *argv[])
if (!parse_json_file(f, filename, ctx.get()))
log_error("Loading design failed.\n");
if (!pack_design(ctx.get()) && !ctx->force)
if (!ctx->pack() && !ctx->force)
log_error("Packing design failed.\n");
if (vm.count("freq"))
ctx->target_freq = vm["freq"].as<double>() * 1e6;

View File

@ -17,7 +17,6 @@
*
*/
#include "pack.h"
#include <algorithm>
#include <iterator>
#include <unordered_set>
@ -84,8 +83,9 @@ void pack_io(Context *ctx)
}
// Main pack function
bool pack_design(Context *ctx)
bool Arch::pack()
{
Context *ctx = getCtx();
try {
log_break();
pack_io(ctx);

View File

@ -1,31 +0,0 @@
/*
* nextpnr -- Next Generation Place and Route
*
* Copyright (C) 2018 David Shah <david@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 PACK_H
#define PACK_H
#include "nextpnr.h"
NEXTPNR_NAMESPACE_BEGIN
bool pack_design(Context *ctx);
NEXTPNR_NAMESPACE_END
#endif // ROUTE_H

View File

@ -183,6 +183,7 @@ struct Arch : BaseCtx
float getDelayNS(delay_t v) const { return v; }
uint32_t getDelayChecksum(delay_t v) const { return 0; }
bool pack() { return true; }
bool place();
bool route();

View File

@ -27,7 +27,6 @@
#include "design_utils.h"
#include "jsonparse.h"
#include "log.h"
#include "pack.h"
#include "pcf.h"
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }

View File

@ -23,7 +23,6 @@
#include "design_utils.h"
#include "jsonparse.h"
#include "log.h"
#include "pack.h"
#include "pcf.h"
#include "timing.h"
@ -97,7 +96,7 @@ void Worker::pack()
{
Q_EMIT taskStarted();
try {
bool res = pack_design(ctx);
bool res = ctx->pack();
print_utilisation(ctx);
Q_EMIT pack_finished(res);
} catch (WorkerInterruptionRequested) {

View File

@ -672,6 +672,7 @@ struct Arch : BaseCtx
// -------------------------------------------------
bool pack();
bool place();
bool route();

View File

@ -58,7 +58,10 @@ void arch_wrap_python()
auto arch_cls = class_<Arch, Arch *, bases<BaseCtx>, boost::noncopyable>("Arch", init<ArchArgs>());
auto ctx_cls = class_<Context, Context *, bases<Arch>, boost::noncopyable>("Context", no_init)
.def("checksum", &Context::checksum);
.def("checksum", &Context::checksum)
.def("pack", &Context::pack)
.def("place", &Context::place)
.def("route", &Context::route);
fn_wrapper_1a<Context, decltype(&Context::getBelType), &Context::getBelType, conv_to_str<BelType>,
conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelType");

View File

@ -39,7 +39,6 @@
#include "jsonparse.h"
#include "log.h"
#include "nextpnr.h"
#include "pack.h"
#include "pcf.h"
#include "place_legaliser.h"
#include "timing.h"
@ -382,7 +381,7 @@ int main(int argc, char *argv[])
log_error("Loading PCF failed.\n");
}
if (!pack_design(ctx.get()) && !ctx->force)
if (!ctx->pack() && !ctx->force)
log_error("Packing design failed.\n");
assign_budget(ctx.get());
ctx->check();

View File

@ -18,7 +18,6 @@
*
*/
#include "pack.h"
#include <algorithm>
#include <iterator>
#include <unordered_set>
@ -577,8 +576,9 @@ static void pack_special(Context *ctx)
}
// Main pack function
bool pack_design(Context *ctx)
bool Arch::pack()
{
Context *ctx = getCtx();
try {
log_break();
pack_constants(ctx);

View File

@ -1,32 +0,0 @@
/*
* nextpnr -- Next Generation Place and Route
*
* Copyright (C) 2018 Clifford Wolf <clifford@symbioticeda.com>
* Copyright (C) 2018 David Shah <david@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 PACK_H
#define PACK_H
#include "nextpnr.h"
NEXTPNR_NAMESPACE_BEGIN
bool pack_design(Context *ctx);
NEXTPNR_NAMESPACE_END
#endif // ROUTE_H