aboutsummaryrefslogtreecommitdiffstats
path: root/fpga_interchange/cost_map.h
diff options
context:
space:
mode:
authorKeith Rothman <537074+litghost@users.noreply.github.com>2021-03-22 17:46:00 -0700
committerKeith Rothman <537074+litghost@users.noreply.github.com>2021-03-23 08:16:50 -0700
commit8d1eb0a1950816d4dcaae40fb230acff0d1afeef (patch)
tree4c0fac8969789f144c2296e4a3208565a57597f7 /fpga_interchange/cost_map.h
parent9ef412c2cc623ef84d8fb866734f3892fc6f127c (diff)
downloadnextpnr-8d1eb0a1950816d4dcaae40fb230acff0d1afeef.tar.gz
nextpnr-8d1eb0a1950816d4dcaae40fb230acff0d1afeef.tar.bz2
nextpnr-8d1eb0a1950816d4dcaae40fb230acff0d1afeef.zip
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>
Diffstat (limited to 'fpga_interchange/cost_map.h')
-rw-r--r--fpga_interchange/cost_map.h68
1 files changed, 68 insertions, 0 deletions
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 <boost/multi_array.hpp>
+#include <mutex>
+
+#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<std::pair<int32_t, int32_t>, 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<delay_t, 2> data;
+ std::pair<int32_t, int32_t> offset;
+ delay_t penalty;
+ };
+
+ std::mutex cost_map_mutex_;
+ HashTables::HashMap<TypeWirePair, CostMapEntry> cost_map_;
+
+ void fill_holes(const Context *ctx, const TypeWirePair &wire_pair, boost::multi_array<delay_t, 2> &matrix,
+ delay_t delay_penality);
+
+ std::pair<delay_t, int> get_nearby_cost_entry(const boost::multi_array<delay_t, 2> &matrix, int cx, int cy,
+ const ArcBounds &bounds);
+ delay_t get_penalty(const boost::multi_array<delay_t, 2> &matrix) const;
+};
+
+NEXTPNR_NAMESPACE_END
+
+#endif /* COST_MAP_H */