aboutsummaryrefslogtreecommitdiffstats
path: root/common/place.cc
diff options
context:
space:
mode:
authorZipCPU <dgisselq@ieee.org>2018-06-07 09:38:14 -0400
committerZipCPU <dgisselq@ieee.org>2018-06-07 09:38:14 -0400
commitf32b9622d5c61610f6027f6544ab9683cd57282b (patch)
treedf3bb9add472148dcf4d4556eafae5431bb0f66c /common/place.cc
parent0dbfa4662f74b89c5f3f8c4fa5ebbef6a89d532b (diff)
downloadnextpnr-f32b9622d5c61610f6027f6544ab9683cd57282b.tar.gz
nextpnr-f32b9622d5c61610f6027f6544ab9683cd57282b.tar.bz2
nextpnr-f32b9622d5c61610f6027f6544ab9683cd57282b.zip
Initial (random) placer capability
This commit also includes changes to jsonparse to allow it to 1) recognize ports with no connection, and set their net pointers to NULL 2) recognize designs with a ports node rather than a ports_direction The rule checker has also been modified to accommodate possible NULL netlists The ice40 chip now also has iterator operations ++bi and bi++.
Diffstat (limited to 'common/place.cc')
-rw-r--r--common/place.cc82
1 files changed, 82 insertions, 0 deletions
diff --git a/common/place.cc b/common/place.cc
new file mode 100644
index 00000000..d3348820
--- /dev/null
+++ b/common/place.cc
@@ -0,0 +1,82 @@
+/*
+ * nextpnr -- Next Generation Place and Route
+ *
+ * Copyright (C) 2018 Clifford Wolf <clifford@clifford.at>
+ *
+ * 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.
+ *
+ */
+
+#include <iostream>
+#include <ostream>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <vector>
+#include <list>
+#include <map>
+#include <set>
+
+#include "log.h"
+#include "design.h"
+
+namespace Placer {
+};
+
+void place_design(Design *design) {
+ std::set<IdString> types_used;
+ std::set<IdString>::iterator not_found, element;
+ std::set<BelType> used_bels;
+
+ for(auto cell_entry : design->cells) {
+ CellInfo *cell = cell_entry.second;
+ BelType bel_type;
+
+ element = types_used.find(cell->type);
+ if (element != types_used.end()) {
+ continue;
+ }
+
+ bel_type = belTypeFromId(cell->type);
+ if (bel_type == TYPE_NIL) {
+ log_error("No Bel of type \'%s\' defined for "
+ "this chip\n", cell->type.c_str());
+ }
+ types_used.insert(cell->type);
+ std::cout << cell->type << std::endl;
+ }
+
+ for(auto bel_type_name : types_used) {
+ BelRange blist = design->chip.getBels();
+ BelType bel_type = belTypeFromId(bel_type_name);
+ BelIterator bi = blist.begin();
+
+ for(auto cell_entry : design->cells) {
+ CellInfo *cell = cell_entry.second;
+
+ // Only place one type of Bel at a time
+ if (cell->type.compare(bel_type_name)!=0)
+ continue;
+
+ while((bi != blist.end())
+ &&(design->chip.getBelType(*bi) != bel_type))
+ bi++;
+ if (bi == blist.end())
+ log_error("Too many \'%s\' used in design\n",
+ cell->type.c_str());
+ cell->bel = *bi++;
+ }
+ }
+}
+