From 8d1eb0a1950816d4dcaae40fb230acff0d1afeef Mon Sep 17 00:00:00 2001 From: Keith Rothman <537074+litghost@users.noreply.github.com> Date: Mon, 22 Mar 2021 17:46:00 -0700 Subject: Initial lookahead for FPGA interchange. Currently the lookahead is disabled by default because of the time to compute and RAM usage. However it does appear to work reasonably well in testing. Further effort is required to lower RAM usage after initial computation, and explore trade-off for cheaper time to compute. Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com> --- fpga_interchange/cost_map.h | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 fpga_interchange/cost_map.h (limited to 'fpga_interchange/cost_map.h') diff --git a/fpga_interchange/cost_map.h b/fpga_interchange/cost_map.h new file mode 100644 index 00000000..e57a1027 --- /dev/null +++ b/fpga_interchange/cost_map.h @@ -0,0 +1,68 @@ +/* + * nextpnr -- Next Generation Place and Route + * + * Copyright (C) 2021 Symbiflow Authors + * + * + * 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 COST_MAP_H +#define COST_MAP_H + +#include +#include + +#include "hash_table.h" +#include "lookahead.capnp.h" +#include "nextpnr_namespaces.h" +#include "nextpnr_types.h" +#include "type_wire.h" + +NEXTPNR_NAMESPACE_BEGIN + +struct Context; + +class CostMap +{ + public: + delay_t get_delay(const Context *ctx, WireId src, WireId dst) const; + void set_cost_map(const Context *ctx, const TypeWirePair &wire_pair, + const HashTables::HashMap, delay_t> &delays); + + void from_reader(lookahead_storage::CostMap::Reader reader); + void to_builder(lookahead_storage::CostMap::Builder builder) const; + + private: + struct CostMapEntry + { + boost::multi_array data; + std::pair offset; + delay_t penalty; + }; + + std::mutex cost_map_mutex_; + HashTables::HashMap cost_map_; + + void fill_holes(const Context *ctx, const TypeWirePair &wire_pair, boost::multi_array &matrix, + delay_t delay_penality); + + std::pair get_nearby_cost_entry(const boost::multi_array &matrix, int cx, int cy, + const ArcBounds &bounds); + delay_t get_penalty(const boost::multi_array &matrix) const; +}; + +NEXTPNR_NAMESPACE_END + +#endif /* COST_MAP_H */ -- cgit v1.2.3