aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--backends/verilog/verilog_backend.cc22
-rw-r--r--frontends/aiger/Makefile.inc3
-rw-r--r--frontends/aiger/aigerparse.cc408
-rw-r--r--frontends/aiger/aigerparse.h50
-rw-r--r--frontends/blif/blifparse.cc2
-rw-r--r--passes/techmap/abc.cc2
-rw-r--r--techlibs/common/simcells.v111
-rw-r--r--techlibs/common/simlib.v18
-rw-r--r--tests/aiger/and.aag5
-rw-r--r--tests/aiger/and.aig3
-rw-r--r--tests/aiger/buffer.aag3
-rw-r--r--tests/aiger/buffer.aig2
-rw-r--r--tests/aiger/cnt1.aag3
-rw-r--r--tests/aiger/cnt1.aig3
-rw-r--r--tests/aiger/cnt1e.aag8
-rw-r--r--tests/aiger/cnt1e.aig4
-rw-r--r--tests/aiger/empty.aag1
-rw-r--r--tests/aiger/empty.aig1
-rw-r--r--tests/aiger/false.aag2
-rw-r--r--tests/aiger/false.aig2
-rw-r--r--tests/aiger/halfadder.aag14
-rw-r--r--tests/aiger/halfadder.aig9
-rw-r--r--tests/aiger/inverter.aag3
-rw-r--r--tests/aiger/inverter.aig2
-rw-r--r--tests/aiger/notcnt1.aag4
-rw-r--r--tests/aiger/notcnt1.aig4
-rw-r--r--tests/aiger/notcnt1e.aag8
-rw-r--r--tests/aiger/notcnt1e.aig4
-rw-r--r--tests/aiger/or.aag5
-rw-r--r--tests/aiger/or.aig3
-rwxr-xr-xtests/aiger/run-test.sh24
-rw-r--r--tests/aiger/toggle-re.aag14
-rw-r--r--tests/aiger/toggle-re.aig8
-rw-r--r--tests/aiger/toggle.aag4
-rw-r--r--tests/aiger/toggle.aig4
-rw-r--r--tests/aiger/true.aag2
-rw-r--r--tests/aiger/true.aig2
-rw-r--r--tests/simple/dff_init.v42
-rwxr-xr-xtests/simple_defparam/run-test.sh21
-rwxr-xr-xtests/tools/autotest.sh23
40 files changed, 800 insertions, 53 deletions
diff --git a/backends/verilog/verilog_backend.cc b/backends/verilog/verilog_backend.cc
index 60668f1f0..4b5a13941 100644
--- a/backends/verilog/verilog_backend.cc
+++ b/backends/verilog/verilog_backend.cc
@@ -293,7 +293,7 @@ void dump_const(std::ostream &f, const RTLIL::Const &data, int width = -1, int o
}
}
-void dump_reg_init(std::ostream &f, SigSpec sig)
+void dump_reg_init(std::ostream &f, SigSpec sig, bool write_equals = true)
{
Const initval;
bool gotinit = false;
@@ -308,7 +308,7 @@ void dump_reg_init(std::ostream &f, SigSpec sig)
}
if (gotinit) {
- f << " = ";
+ if (write_equals) f << " = ";
dump_const(f, initval);
}
}
@@ -1250,7 +1250,14 @@ void dump_cell(std::ostream &f, std::string indent, RTLIL::Cell *cell)
dump_attributes(f, indent, cell->attributes);
f << stringf("%s" "%s", indent.c_str(), id(cell->type, false).c_str());
- if (!defparam && cell->parameters.size() > 0) {
+ std::string init;
+ if (reg_ct.count(cell->type) && cell->hasPort("\\Q")) {
+ std::stringstream ss;
+ dump_reg_init(ss, cell->getPort("\\Q"), false /* write_equals */);
+ init = ss.str();
+ }
+
+ if (!defparam && (cell->parameters.size() > 0 || !init.empty())) {
f << stringf(" #(");
for (auto it = cell->parameters.begin(); it != cell->parameters.end(); ++it) {
if (it != cell->parameters.begin())
@@ -1260,6 +1267,11 @@ void dump_cell(std::ostream &f, std::string indent, RTLIL::Cell *cell)
dump_const(f, it->second, -1, 0, false, is_signed);
f << stringf(")");
}
+ if (!init.empty()) {
+ if (!cell->parameters.empty())
+ f << stringf(",");
+ f << stringf("\n%s .INIT(%s)", indent.c_str(), init.c_str());
+ }
f << stringf("\n%s" ")", indent.c_str());
}
@@ -1301,13 +1313,15 @@ void dump_cell(std::ostream &f, std::string indent, RTLIL::Cell *cell)
}
f << stringf("\n%s" ");\n", indent.c_str());
- if (defparam && cell->parameters.size() > 0) {
+ if (defparam && (cell->parameters.size() > 0 || !init.empty())) {
for (auto it = cell->parameters.begin(); it != cell->parameters.end(); ++it) {
f << stringf("%sdefparam %s.%s = ", indent.c_str(), cell_name.c_str(), id(it->first).c_str());
bool is_signed = (it->second.flags & RTLIL::CONST_FLAG_SIGNED) != 0;
dump_const(f, it->second, -1, 0, false, is_signed);
f << stringf(";\n");
}
+ if (!init.empty())
+ f << stringf("%sdefparam %s.INIT = %s;\n", indent.c_str(), cell_name.c_str(), init.c_str());
}
}
diff --git a/frontends/aiger/Makefile.inc b/frontends/aiger/Makefile.inc
new file mode 100644
index 000000000..bc1112452
--- /dev/null
+++ b/frontends/aiger/Makefile.inc
@@ -0,0 +1,3 @@
+
+OBJS += frontends/aiger/aigerparse.o
+
diff --git a/frontends/aiger/aigerparse.cc b/frontends/aiger/aigerparse.cc
new file mode 100644
index 000000000..7df28fe87
--- /dev/null
+++ b/frontends/aiger/aigerparse.cc
@@ -0,0 +1,408 @@
+/*
+ * yosys -- Yosys Open SYnthesis Suite
+ *
+ * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
+ * Eddie Hung <eddie@fpgeh.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.
+ *
+ */
+
+// [[CITE]] The AIGER And-Inverter Graph (AIG) Format Version 20071012
+// Armin Biere. The AIGER And-Inverter Graph (AIG) Format Version 20071012. Technical Report 07/1, October 2011, FMV Reports Series, Institute for Formal Models and Verification, Johannes Kepler University, Altenbergerstr. 69, 4040 Linz, Austria.
+// http://fmv.jku.at/papers/Biere-FMV-TR-07-1.pdf
+
+#include "kernel/yosys.h"
+#include "kernel/sigtools.h"
+#include "aigerparse.h"
+
+YOSYS_NAMESPACE_BEGIN
+
+#define log_debug log
+
+AigerReader::AigerReader(RTLIL::Design *design, std::istream &f, RTLIL::IdString module_name, RTLIL::IdString clk_name)
+ : design(design), f(f), clk_name(clk_name)
+{
+ module = new RTLIL::Module;
+ module->name = module_name;
+ if (design->module(module->name))
+ log_error("Duplicate definition of module %s!\n", log_id(module->name));
+}
+
+void AigerReader::parse_aiger()
+{
+ std::string header;
+ f >> header;
+ if (header != "aag" && header != "aig")
+ log_error("Unsupported AIGER file!\n");
+
+ // Parse rest of header
+ if (!(f >> M >> I >> L >> O >> A))
+ log_error("Invalid AIGER header\n");
+
+ // Optional values
+ B = C = J = F = 0;
+ for (auto &i : std::array<std::reference_wrapper<unsigned>,4>{B, C, J, F}) {
+ if (f.peek() != ' ') break;
+ if (!(f >> i))
+ log_error("Invalid AIGER header\n");
+ }
+
+ std::string line;
+ std::getline(f, line); // Ignore up to start of next line, as standard
+ // says anything that follows could be used for
+ // optional sections
+
+ log_debug("M=%u I=%u L=%u O=%u A=%u B=%u C=%u J=%u F=%u\n", M, I, L, O, A, B, C, J, F);
+
+ line_count = 1;
+
+ if (header == "aag")
+ parse_aiger_ascii();
+ else if (header == "aig")
+ parse_aiger_binary();
+ else
+ log_abort();
+
+ // Parse footer (symbol table, comments, etc.)
+ unsigned l1;
+ std::string s;
+ for (int c = f.peek(); c != EOF; c = f.peek(), ++line_count) {
+ if (c == 'i' || c == 'l' || c == 'o') {
+ f.ignore(1);
+ if (!(f >> l1 >> s))
+ log_error("Line %u cannot be interpreted as a symbol entry!\n", line_count);
+
+ if ((c == 'i' && l1 > inputs.size()) || (c == 'l' && l1 > latches.size()) || (c == 'o' && l1 > outputs.size()))
+ log_error("Line %u has invalid symbol position!\n", line_count);
+
+ RTLIL::Wire* wire;
+ if (c == 'i') wire = inputs[l1];
+ else if (c == 'l') wire = latches[l1];
+ else if (c == 'o') wire = outputs[l1];
+ else log_abort();
+
+ module->rename(wire, stringf("\\%s", s.c_str()));
+ }
+ else if (c == 'b' || c == 'j' || c == 'f') {
+ // TODO
+ }
+ else if (c == 'c') {
+ f.ignore(1);
+ if (f.peek() == '\n')
+ break;
+ // Else constraint (TODO)
+ }
+ else
+ log_error("Line %u: cannot interpret first character '%c'!\n", line_count, c);
+ std::getline(f, line); // Ignore up to start of next line
+ }
+
+ module->fixup_ports();
+ design->add(module);
+}
+
+static RTLIL::Wire* createWireIfNotExists(RTLIL::Module *module, unsigned literal)
+{
+ const unsigned variable = literal >> 1;
+ const bool invert = literal & 1;
+ RTLIL::IdString wire_name(stringf("\\n%d%s", variable, invert ? "_inv" : "")); // FIXME: is "_inv" the right suffix?
+ RTLIL::Wire *wire = module->wire(wire_name);
+ if (wire) return wire;
+ log_debug("Creating %s\n", wire_name.c_str());
+ wire = module->addWire(wire_name);
+ if (!invert) return wire;
+ RTLIL::IdString wire_inv_name(stringf("\\n%d", variable));
+ RTLIL::Wire *wire_inv = module->wire(wire_inv_name);
+ if (wire_inv) {
+ if (module->cell(wire_inv_name)) return wire;
+ }
+ else {
+ log_debug("Creating %s\n", wire_inv_name.c_str());
+ wire_inv = module->addWire(wire_inv_name);
+ }
+
+ log_debug("Creating %s = ~%s\n", wire_name.c_str(), wire_inv_name.c_str());
+ module->addNotGate(stringf("\\n%d_not", variable), wire_inv, wire); // FIXME: is "_not" the right suffix?
+
+ return wire;
+}
+
+void AigerReader::parse_aiger_ascii()
+{
+ std::string line;
+ std::stringstream ss;
+
+ unsigned l1, l2, l3;
+
+ // Parse inputs
+ for (unsigned i = 0; i < I; ++i, ++line_count) {
+ if (!(f >> l1))
+ log_error("Line %u cannot be interpreted as an input!\n", line_count);
+ log_debug("%d is an input\n", l1);
+ log_assert(!(l1 & 1)); // TODO: Inputs can't be inverted?
+ RTLIL::Wire *wire = createWireIfNotExists(module, l1);
+ wire->port_input = true;
+ inputs.push_back(wire);
+ }
+
+ // Parse latches
+ RTLIL::Wire *clk_wire = nullptr;
+ if (L > 0) {
+ clk_wire = module->wire(clk_name);
+ log_assert(!clk_wire);
+ log_debug("Creating %s\n", clk_name.c_str());
+ clk_wire = module->addWire(clk_name);
+ clk_wire->port_input = true;
+ }
+ for (unsigned i = 0; i < L; ++i, ++line_count) {
+ if (!(f >> l1 >> l2))
+ log_error("Line %u cannot be interpreted as a latch!\n", line_count);
+ log_debug("%d %d is a latch\n", l1, l2);
+ log_assert(!(l1 & 1)); // TODO: Latch outputs can't be inverted?
+ RTLIL::Wire *q_wire = createWireIfNotExists(module, l1);
+ RTLIL::Wire *d_wire = createWireIfNotExists(module, l2);
+
+ module->addDffGate(NEW_ID, clk_wire, d_wire, q_wire);
+
+ // Reset logic is optional in AIGER 1.9
+ if (f.peek() == ' ') {
+ if (!(f >> l3))
+ log_error("Line %u cannot be interpreted as a latch!\n", line_count);
+
+ if (l3 == 0 || l3 == 1)
+ q_wire->attributes["\\init"] = RTLIL::Const(l3);
+ else if (l3 == l1) {
+ //q_wire->attributes["\\init"] = RTLIL::Const(RTLIL::State::Sx);
+ }
+ else
+ log_error("Line %u has invalid reset literal for latch!\n", line_count);
+ }
+ else {
+ // AIGER latches are assumed to be initialized to zero
+ q_wire->attributes["\\init"] = RTLIL::Const(0);
+ }
+ latches.push_back(q_wire);
+ }
+
+ // Parse outputs
+ for (unsigned i = 0; i < O; ++i, ++line_count) {
+ if (!(f >> l1))
+ log_error("Line %u cannot be interpreted as an output!\n", line_count);
+
+ log_debug("%d is an output\n", l1);
+ RTLIL::Wire *wire = createWireIfNotExists(module, l1);
+ wire->port_output = true;
+ outputs.push_back(wire);
+ }
+ std::getline(f, line); // Ignore up to start of next line
+
+ // TODO: Parse bad state properties
+ for (unsigned i = 0; i < B; ++i, ++line_count)
+ std::getline(f, line); // Ignore up to start of next line
+
+ // TODO: Parse invariant constraints
+ for (unsigned i = 0; i < C; ++i, ++line_count)
+ std::getline(f, line); // Ignore up to start of next line
+
+ // TODO: Parse justice properties
+ for (unsigned i = 0; i < J; ++i, ++line_count)
+ std::getline(f, line); // Ignore up to start of next line
+
+ // TODO: Parse fairness constraints
+ for (unsigned i = 0; i < F; ++i, ++line_count)
+ std::getline(f, line); // Ignore up to start of next line
+
+ // Parse AND
+ for (unsigned i = 0; i < A; ++i) {
+ if (!(f >> l1 >> l2 >> l3))
+ log_error("Line %u cannot be interpreted as an AND!\n", line_count);
+
+ log_debug("%d %d %d is an AND\n", l1, l2, l3);
+ log_assert(!(l1 & 1)); // TODO: Output of ANDs can't be inverted?
+ RTLIL::Wire *o_wire = createWireIfNotExists(module, l1);
+ RTLIL::Wire *i1_wire = createWireIfNotExists(module, l2);
+ RTLIL::Wire *i2_wire = createWireIfNotExists(module, l3);
+ module->addAndGate(NEW_ID, i1_wire, i2_wire, o_wire);
+ }
+}
+
+static unsigned parse_next_delta_literal(std::istream &f, unsigned ref)
+{
+ unsigned x = 0, i = 0;
+ unsigned char ch;
+ while ((ch = f.get()) & 0x80)
+ x |= (ch & 0x7f) << (7 * i++);
+ return ref - (x | (ch << (7 * i)));
+}
+
+void AigerReader::parse_aiger_binary()
+{
+ unsigned l1, l2, l3;
+ std::string line;
+
+ // Parse inputs
+ for (unsigned i = 1; i <= I; ++i) {
+ RTLIL::Wire *wire = createWireIfNotExists(module, i << 1);
+ wire->port_input = true;
+ inputs.push_back(wire);
+ }
+
+ // Parse latches
+ RTLIL::Wire *clk_wire = nullptr;
+ if (L > 0) {
+ clk_wire = module->wire(clk_name);
+ log_assert(!clk_wire);
+ log_debug("Creating %s\n", clk_name.c_str());
+ clk_wire = module->addWire(clk_name);
+ clk_wire->port_input = true;
+ }
+ l1 = (I+1) * 2;
+ for (unsigned i = 0; i < L; ++i, ++line_count, l1 += 2) {
+ if (!(f >> l2))
+ log_error("Line %u cannot be interpreted as a latch!\n", line_count);
+ log_debug("%d %d is a latch\n", l1, l2);
+ RTLIL::Wire *q_wire = createWireIfNotExists(module, l1);
+ RTLIL::Wire *d_wire = createWireIfNotExists(module, l2);
+
+ module->addDff(NEW_ID, clk_wire, d_wire, q_wire);
+
+ // Reset logic is optional in AIGER 1.9
+ if (f.peek() == ' ') {
+ if (!(f >> l3))
+ log_error("Line %u cannot be interpreted as a latch!\n", line_count);
+
+ if (l3 == 0 || l3 == 1)
+ q_wire->attributes["\\init"] = RTLIL::Const(l3);
+ else if (l3 == l1) {
+ //q_wire->attributes["\\init"] = RTLIL::Const(RTLIL::State::Sx);
+ }
+ else
+ log_error("Line %u has invalid reset literal for latch!\n", line_count);
+ }
+ else {
+ // AIGER latches are assumed to be initialized to zero
+ q_wire->attributes["\\init"] = RTLIL::Const(0);
+ }
+ latches.push_back(q_wire);
+ }
+
+ // Parse outputs
+ for (unsigned i = 0; i < O; ++i, ++line_count) {
+ if (!(f >> l1))
+ log_error("Line %u cannot be interpreted as an output!\n", line_count);
+
+ log_debug("%d is an output\n", l1);
+ RTLIL::Wire *wire = createWireIfNotExists(module, l1);
+ wire->port_output = true;
+ outputs.push_back(wire);
+ }
+ std::getline(f, line); // Ignore up to start of next line
+
+ // TODO: Parse bad state properties
+ for (unsigned i = 0; i < B; ++i, ++line_count)
+ std::getline(f, line); // Ignore up to start of next line
+
+ // TODO: Parse invariant constraints
+ for (unsigned i = 0; i < C; ++i, ++line_count)
+ std::getline(f, line); // Ignore up to start of next line
+
+ // TODO: Parse justice properties
+ for (unsigned i = 0; i < J; ++i, ++line_count)
+ std::getline(f, line); // Ignore up to start of next line
+
+ // TODO: Parse fairness constraints
+ for (unsigned i = 0; i < F; ++i, ++line_count)
+ std::getline(f, line); // Ignore up to start of next line
+
+ // Parse AND
+ l1 = (I+L+1) << 1;
+ for (unsigned i = 0; i < A; ++i, ++line_count, l1 += 2) {
+ l2 = parse_next_delta_literal(f, l1);
+ l3 = parse_next_delta_literal(f, l2);
+
+ log_debug("%d %d %d is an AND\n", l1, l2, l3);
+ log_assert(!(l1 & 1)); // TODO: Output of ANDs can't be inverted?
+ RTLIL::Wire *o_wire = createWireIfNotExists(module, l1);
+ RTLIL::Wire *i1_wire = createWireIfNotExists(module, l2);
+ RTLIL::Wire *i2_wire = createWireIfNotExists(module, l3);
+
+ RTLIL::Cell *and_cell = module->addCell(NEW_ID, "$_AND_");
+ and_cell->setPort("\\A", i1_wire);
+ and_cell->setPort("\\B", i2_wire);
+ and_cell->setPort("\\Y", o_wire);
+ }
+ std::getline(f, line); // Ignore up to start of next line
+
+}
+
+struct AigerFrontend : public Frontend {
+ AigerFrontend() : Frontend("aiger", "read AIGER file") { }
+ void help() YS_OVERRIDE
+ {
+ // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
+ log("\n");
+ log(" read_aiger [options] [filename]\n");
+ log("\n");
+ log("Load module from an AIGER file into the current design.\n");
+ log("\n");
+ log(" -module_name <module_name>\n");
+ log(" Name of module to be created (default: <filename>)"
+#ifdef _WIN32
+ "top" // FIXME
+#else
+ "<filename>"
+#endif
+ ")\n");
+ log("\n");
+ log(" -clk_name <wire_name>\n");
+ log(" AIGER latches to be transformed into posedge DFFs clocked by wire of");
+ log(" this name (default: clk)\n");
+ log("\n");
+ }
+ void execute(std::istream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE
+ {
+ log_header(design, "Executing AIGER frontend.\n");
+
+ RTLIL::IdString clk_name = "\\clk";
+ RTLIL::IdString module_name;
+
+ size_t argidx;
+ for (argidx = 1; argidx < args.size(); argidx++) {
+ std::string arg = args[argidx];
+ if (arg == "-module_name" && argidx+1 < args.size()) {
+ module_name = RTLIL::escape_id(args[++argidx]);
+ continue;
+ }
+ if (arg == "-clk_name" && argidx+1 < args.size()) {
+ clk_name = RTLIL::escape_id(args[++argidx]);
+ continue;
+ }
+ break;
+ }
+ extra_args(f, filename, args, argidx);
+
+ if (module_name.empty()) {
+#ifdef _WIN32
+ module_name = "top"; // FIXME: basename equivalent on Win32?
+#else
+ module_name = RTLIL::escape_id(basename(filename.c_str()));
+#endif
+ }
+
+ AigerReader reader(design, *f, module_name, clk_name);
+ reader.parse_aiger();
+ }
+} AigerFrontend;
+
+YOSYS_NAMESPACE_END
diff --git a/frontends/aiger/aigerparse.h b/frontends/aiger/aigerparse.h
new file mode 100644
index 000000000..39a77bd93
--- /dev/null
+++ b/frontends/aiger/aigerparse.h
@@ -0,0 +1,50 @@
+/*
+ * yosys -- Yosys Open SYnthesis Suite
+ *
+ * Copyright (C) 2012 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.
+ *
+ */
+
+#ifndef ABC_AIGERPARSE
+#define ABC_AIGERPARSE
+
+#include "kernel/yosys.h"
+
+YOSYS_NAMESPACE_BEGIN
+
+struct AigerReader
+{
+ RTLIL::Design *design;
+ std::istream &f;
+ RTLIL::IdString clk_name;
+ RTLIL::Module *module;
+
+ unsigned M, I, L, O, A;
+ unsigned B, C, J, F; // Optional in AIGER 1.9
+ unsigned line_count;
+
+ std::vector<RTLIL::Wire*> inputs;
+ std::vector<RTLIL::Wire*> latches;
+ std::vector<RTLIL::Wire*> outputs;
+
+ AigerReader(RTLIL::Design *design, std::istream &f, RTLIL::IdString module_name, RTLIL::IdString clk_name);
+ void parse_aiger();
+ void parse_aiger_ascii();
+ void parse_aiger_binary();
+};
+
+YOSYS_NAMESPACE_END
+
+#endif
diff --git a/frontends/blif/blifparse.cc b/frontends/blif/blifparse.cc
index 9116b257f..a6a07863f 100644
--- a/frontends/blif/blifparse.cc
+++ b/frontends/blif/blifparse.cc
@@ -584,7 +584,7 @@ struct BlifFrontend : public Frontend {
{
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
log("\n");
- log(" read_blif [filename]\n");
+ log(" read_blif [options] [filename]\n");
log("\n");
log("Load modules from a BLIF file into the current design.\n");
log("\n");
diff --git a/passes/techmap/abc.cc b/passes/techmap/abc.cc
index d2d15a4a9..b215b1ea4 100644
--- a/passes/techmap/abc.cc
+++ b/passes/techmap/abc.cc
@@ -52,6 +52,8 @@
#include <cerrno>
#include <sstream>
#include <climits>
+#include <array>
+#include <functional>
#ifndef _WIN32
# include <unistd.h>
diff --git a/techlibs/common/simcells.v b/techlibs/common/simcells.v
index 289673e82..b9957bd5e 100644
--- a/techlibs/common/simcells.v
+++ b/techlibs/common/simcells.v
@@ -451,8 +451,9 @@ endmodule
//- 1 1 | y
//-
module \$_SR_NN_ (S, R, Q);
+parameter INIT = 1'bx;
input S, R;
-output reg Q;
+output reg Q = INIT;
always @(negedge S, negedge R) begin
if (R == 0)
Q <= 0;
@@ -475,8 +476,9 @@ endmodule
//- 1 0 | y
//-
module \$_SR_NP_ (S, R, Q);
+parameter INIT = 1'bx;
input S, R;
-output reg Q;
+output reg Q = INIT;
always @(negedge S, posedge R) begin
if (R == 1)
Q <= 0;
@@ -499,8 +501,9 @@ endmodule
//- 0 1 | y
//-
module \$_SR_PN_ (S, R, Q);
+parameter INIT = 1'bx;
input S, R;
-output reg Q;
+output reg Q = INIT;
always @(posedge S, negedge R) begin
if (R == 0)
Q <= 0;
@@ -523,8 +526,9 @@ endmodule
//- 0 0 | y
//-
module \$_SR_PP_ (S, R, Q);
+parameter INIT = 1'bx;
input S, R;
-output reg Q;
+output reg Q = INIT;
always @(posedge S, posedge R) begin
if (R == 1)
Q <= 0;
@@ -542,8 +546,9 @@ endmodule
//- type is usually only used in netlists for formal verification.)
//-
module \$_FF_ (D, Q);
+parameter INIT = 1'bx;
input D;
-output reg Q;
+output reg Q = INIT;
always @($global_clock) begin
Q <= D;
end
@@ -562,8 +567,9 @@ endmodule
//- - - | q
//-
module \$_DFF_N_ (D, C, Q);
+parameter INIT = 1'bx;
input D, C;
-output reg Q;
+output reg Q = INIT;
always @(negedge C) begin
Q <= D;
end
@@ -581,8 +587,9 @@ endmodule
//- - - | q
//-
module \$_DFF_P_ (D, C, Q);
+parameter INIT = 1'bx;
input D, C;
-output reg Q;
+output reg Q = INIT;
always @(posedge C) begin
Q <= D;
end
@@ -600,8 +607,9 @@ endmodule
//- - - - | q
//-
module \$_DFFE_NN_ (D, C, E, Q);
+parameter INIT = 1'bx;
input D, C, E;
-output reg Q;
+output reg Q = INIT;
always @(negedge C) begin
if (!E) Q <= D;
end
@@ -619,8 +627,9 @@ endmodule
//- - - - | q
//-
module \$_DFFE_NP_ (D, C, E, Q);
+parameter INIT = 1'bx;
input D, C, E;
-output reg Q;
+output reg Q = INIT;
always @(negedge C) begin
if (E) Q <= D;
end
@@ -638,8 +647,9 @@ endmodule
//- - - - | q
//-
module \$_DFFE_PN_ (D, C, E, Q);
+parameter INIT = 1'bx;
input D, C, E;
-output reg Q;
+output reg Q = INIT;
always @(posedge C) begin
if (!E) Q <= D;
end
@@ -657,8 +667,9 @@ endmodule
//- - - - | q
//-
module \$_DFFE_PP_ (D, C, E, Q);
+parameter INIT = 1'bx;
input D, C, E;
-output reg Q;
+output reg Q = INIT;
always @(posedge C) begin
if (E) Q <= D;
end
@@ -677,8 +688,9 @@ endmodule
//- - - - | q
//-
module \$_DFF_NN0_ (D, C, R, Q);
+parameter INIT = 1'bx;
input D, C, R;
-output reg Q;
+output reg Q = INIT;
always @(negedge C or negedge R) begin
if (R == 0)
Q <= 0;
@@ -700,8 +712,9 @@ endmodule
//- - - - | q
//-
module \$_DFF_NN1_ (D, C, R, Q);
+parameter INIT = 1'bx;
input D, C, R;
-output reg Q;
+output reg Q = INIT;
always @(negedge C or negedge R) begin
if (R == 0)
Q <= 1;
@@ -723,8 +736,9 @@ endmodule
//- - - - | q
//-
module \$_DFF_NP0_ (D, C, R, Q);
+parameter INIT = 1'bx;
input D, C, R;
-output reg Q;
+output reg Q = INIT;
always @(negedge C or posedge R) begin
if (R == 1)
Q <= 0;
@@ -746,8 +760,9 @@ endmodule
//- - - - | q
//-
module \$_DFF_NP1_ (D, C, R, Q);
+parameter INIT = 1'bx;
input D, C, R;
-output reg Q;
+output reg Q = INIT;
always @(negedge C or posedge R) begin
if (R == 1)
Q <= 1;
@@ -769,8 +784,9 @@ endmodule
//- - - - | q
//-
module \$_DFF_PN0_ (D, C, R, Q);
+parameter INIT = 1'bx;
input D, C, R;
-output reg Q;
+output reg Q = INIT;
always @(posedge C or negedge R) begin
if (R == 0)
Q <= 0;
@@ -792,8 +808,9 @@ endmodule
//- - - - | q
//-
module \$_DFF_PN1_ (D, C, R, Q);
+parameter INIT = 1'bx;
input D, C, R;
-output reg Q;
+output reg Q = INIT;
always @(posedge C or negedge R) begin
if (R == 0)
Q <= 1;
@@ -815,8 +832,9 @@ endmodule
//- - - - | q
//-
module \$_DFF_PP0_ (D, C, R, Q);
+parameter INIT = 1'bx;
input D, C, R;
-output reg Q;
+output reg Q = INIT;
always @(posedge C or posedge R) begin
if (R == 1)
Q <= 0;
@@ -838,8 +856,9 @@ endmodule
//- - - - | q
//-
module \$_DFF_PP1_ (D, C, R, Q);
+parameter INIT = 1'bx;
input D, C, R;
-output reg Q;
+output reg Q = INIT;
always @(posedge C or posedge R) begin
if (R == 1)
Q <= 1;
@@ -862,8 +881,9 @@ endmodule
//- - - - - | q
//-
module \$_DFFSR_NNN_ (C, S, R, D, Q);
+parameter INIT = 1'bx;
input C, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @(negedge C, negedge S, negedge R) begin
if (R == 0)
Q <= 0;
@@ -889,8 +909,9 @@ endmodule
//- - - - - | q
//-
module \$_DFFSR_NNP_ (C, S, R, D, Q);
+parameter INIT = 1'bx;
input C, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @(negedge C, negedge S, posedge R) begin
if (R == 1)
Q <= 0;
@@ -916,8 +937,9 @@ endmodule
//- - - - - | q
//-
module \$_DFFSR_NPN_ (C, S, R, D, Q);
+parameter INIT = 1'bx;
input C, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @(negedge C, posedge S, negedge R) begin
if (R == 0)
Q <= 0;
@@ -942,8 +964,9 @@ endmodule
//- - - - - | q
//-
module \$_DFFSR_NPP_ (C, S, R, D, Q);
+parameter INIT = 1'bx;
input C, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @(negedge C, posedge S, posedge R) begin
if (R == 1)
Q <= 0;
@@ -968,8 +991,9 @@ endmodule
//- - - - - | q
//-
module \$_DFFSR_PNN_ (C, S, R, D, Q);
+parameter INIT = 1'bx;
input C, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @(posedge C, negedge S, negedge R) begin
if (R == 0)
Q <= 0;
@@ -995,8 +1019,9 @@ endmodule
//- - - - - | q
//-
module \$_DFFSR_PNP_ (C, S, R, D, Q);
+parameter INIT = 1'bx;
input C, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @(posedge C, negedge S, posedge R) begin
if (R == 1)
Q <= 0;
@@ -1022,8 +1047,9 @@ endmodule
//- - - - - | q
//-
module \$_DFFSR_PPN_ (C, S, R, D, Q);
+parameter INIT = 1'bx;
input C, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @(posedge C, posedge S, negedge R) begin
if (R == 0)
Q <= 0;
@@ -1048,8 +1074,9 @@ endmodule
//- - - - - | q
//-
module \$_DFFSR_PPP_ (C, S, R, D, Q);
+parameter INIT = 1'bx;
input C, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @(posedge C, posedge S, posedge R) begin
if (R == 1)
Q <= 0;
@@ -1072,8 +1099,9 @@ endmodule
//- - - | q
//-
module \$_DLATCH_N_ (E, D, Q);
+parameter INIT = 1'bx;
input E, D;
-output reg Q;
+output reg Q = INIT;
always @* begin
if (E == 0)
Q <= D;
@@ -1092,8 +1120,9 @@ endmodule
//- - - | q
//-
module \$_DLATCH_P_ (E, D, Q);
+parameter INIT = 1'bx;
input E, D;
-output reg Q;
+output reg Q = INIT;
always @* begin
if (E == 1)
Q <= D;
@@ -1114,8 +1143,9 @@ endmodule
//- - - - - | q
//-
module \$_DLATCHSR_NNN_ (E, S, R, D, Q);
+parameter INIT = 1'bx;
input E, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @* begin
if (R == 0)
Q <= 0;
@@ -1141,8 +1171,9 @@ endmodule
//- - - - - | q
//-
module \$_DLATCHSR_NNP_ (E, S, R, D, Q);
+parameter INIT = 1'bx;
input E, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @* begin
if (R == 1)
Q <= 0;
@@ -1168,8 +1199,9 @@ endmodule
//- - - - - | q
//-
module \$_DLATCHSR_NPN_ (E, S, R, D, Q);
+parameter INIT = 1'bx;
input E, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @* begin
if (R == 0)
Q <= 0;
@@ -1194,8 +1226,9 @@ endmodule
//- - - - - | q
//-
module \$_DLATCHSR_NPP_ (E, S, R, D, Q);
+parameter INIT = 1'bx;
input E, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @* begin
if (R == 1)
Q <= 0;
@@ -1220,8 +1253,9 @@ endmodule
//- - - - - | q
//-
module \$_DLATCHSR_PNN_ (E, S, R, D, Q);
+parameter INIT = 1'bx;
input E, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @* begin
if (R == 0)
Q <= 0;
@@ -1247,8 +1281,9 @@ endmodule
//- - - - - | q
//-
module \$_DLATCHSR_PNP_ (E, S, R, D, Q);
+parameter INIT = 1'bx;
input E, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @* begin
if (R == 1)
Q <= 0;
@@ -1274,8 +1309,9 @@ endmodule
//- - - - - | q
//-
module \$_DLATCHSR_PPN_ (E, S, R, D, Q);
+parameter INIT = 1'bx;
input E, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @* begin
if (R == 0)
Q <= 0;
@@ -1300,8 +1336,9 @@ endmodule
//- - - - - | q
//-
module \$_DLATCHSR_PPP_ (E, S, R, D, Q);
+parameter INIT = 1'bx;
input E, S, R, D;
-output reg Q;
+output reg Q = INIT;
always @* begin
if (R == 1)
Q <= 0;
diff --git a/techlibs/common/simlib.v b/techlibs/common/simlib.v
index 8e43fe058..a1e0c1575 100644
--- a/techlibs/common/simlib.v
+++ b/techlibs/common/simlib.v
@@ -1464,10 +1464,11 @@ module \$dff (CLK, D, Q);
parameter WIDTH = 0;
parameter CLK_POLARITY = 1'b1;
+parameter INIT = {WIDTH > 0 ? WIDTH : 1{1'bx}};
input CLK;
input [WIDTH-1:0] D;
-output reg [WIDTH-1:0] Q;
+output reg [WIDTH-1:0] Q = INIT;
wire pos_clk = CLK == CLK_POLARITY;
always @(posedge pos_clk) begin
@@ -1483,10 +1484,11 @@ module \$dffe (CLK, EN, D, Q);
parameter WIDTH = 0;
parameter CLK_POLARITY = 1'b1;
parameter EN_POLARITY = 1'b1;
+parameter INIT = {WIDTH > 0 ? WIDTH : 1{1'bx}};
input CLK, EN;
input [WIDTH-1:0] D;
-output reg [WIDTH-1:0] Q;
+output reg [WIDTH-1:0] Q = INIT;
wire pos_clk = CLK == CLK_POLARITY;
always @(posedge pos_clk) begin
@@ -1504,10 +1506,11 @@ parameter WIDTH = 0;
parameter CLK_POLARITY = 1'b1;
parameter SET_POLARITY = 1'b1;
parameter CLR_POLARITY = 1'b1;
+parameter INIT = {WIDTH > 0 ? WIDTH : 1{1'bx}};
input CLK;
input [WIDTH-1:0] SET, CLR, D;
-output reg [WIDTH-1:0] Q;
+output reg [WIDTH-1:0] Q = INIT;
wire pos_clk = CLK == CLK_POLARITY;
wire [WIDTH-1:0] pos_set = SET_POLARITY ? SET : ~SET;
@@ -1537,10 +1540,11 @@ parameter WIDTH = 0;
parameter CLK_POLARITY = 1'b1;
parameter ARST_POLARITY = 1'b1;
parameter ARST_VALUE = 0;
+parameter INIT = {WIDTH > 0 ? WIDTH : 1{1'bx}};
input CLK, ARST;
input [WIDTH-1:0] D;
-output reg [WIDTH-1:0] Q;
+output reg [WIDTH-1:0] Q = INIT;
wire pos_clk = CLK == CLK_POLARITY;
wire pos_arst = ARST == ARST_POLARITY;
@@ -1559,10 +1563,11 @@ module \$dlatch (EN, D, Q);
parameter WIDTH = 0;
parameter EN_POLARITY = 1'b1;
+parameter INIT = {WIDTH > 0 ? WIDTH : 1{1'bx}};
input EN;
input [WIDTH-1:0] D;
-output reg [WIDTH-1:0] Q;
+output reg [WIDTH-1:0] Q = INIT;
always @* begin
if (EN == EN_POLARITY)
@@ -1580,10 +1585,11 @@ parameter WIDTH = 0;
parameter EN_POLARITY = 1'b1;
parameter SET_POLARITY = 1'b1;
parameter CLR_POLARITY = 1'b1;
+parameter INIT = {WIDTH > 0 ? WIDTH : 1{1'bx}};
input EN;
input [WIDTH-1:0] SET, CLR, D;
-output reg [WIDTH-1:0] Q;
+output reg [WIDTH-1:0] Q = INIT;
wire pos_en = EN == EN_POLARITY;
wire [WIDTH-1:0] pos_set = SET_POLARITY ? SET : ~SET;
diff --git a/tests/aiger/and.aag b/tests/aiger/and.aag
new file mode 100644
index 000000000..d1ef2c5a5
--- /dev/null
+++ b/tests/aiger/and.aag
@@ -0,0 +1,5 @@
+aag 3 2 0 1 1
+2
+4
+6
+6 2 4
diff --git a/tests/aiger/and.aig b/tests/aiger/and.aig
new file mode 100644
index 000000000..da0fa0719
--- /dev/null
+++ b/tests/aiger/and.aig
@@ -0,0 +1,3 @@
+aig 3 2 0 1 1
+6
+ \ No newline at end of file
diff --git a/tests/aiger/buffer.aag b/tests/aiger/buffer.aag
new file mode 100644
index 000000000..94a6fb1ed
--- /dev/null
+++ b/tests/aiger/buffer.aag
@@ -0,0 +1,3 @@
+aag 1 1 0 1 0
+2
+2
diff --git a/tests/aiger/buffer.aig b/tests/aiger/buffer.aig
new file mode 100644
index 000000000..0c715fdeb
--- /dev/null
+++ b/tests/aiger/buffer.aig
@@ -0,0 +1,2 @@
+aig 1 1 0 1 0
+2
diff --git a/tests/aiger/cnt1.aag b/tests/aiger/cnt1.aag
new file mode 100644
index 000000000..ce4f28fcb
--- /dev/null
+++ b/tests/aiger/cnt1.aag
@@ -0,0 +1,3 @@
+aag 1 0 1 0 0 1
+2 3
+2
diff --git a/tests/aiger/cnt1.aig b/tests/aiger/cnt1.aig
new file mode 100644
index 000000000..8d0ba13b1
--- /dev/null
+++ b/tests/aiger/cnt1.aig
@@ -0,0 +1,3 @@
+aig 1 0 1 0 0 1
+3
+2
diff --git a/tests/aiger/cnt1e.aag b/tests/aiger/cnt1e.aag
new file mode 100644
index 000000000..6db3f0ffd
--- /dev/null
+++ b/tests/aiger/cnt1e.aag
@@ -0,0 +1,8 @@
+aag 5 1 1 0 3 1
+2
+4 10
+4
+6 5 3
+8 4 2
+10 9 7
+b0 AIGER_NEVER
diff --git a/tests/aiger/cnt1e.aig b/tests/aiger/cnt1e.aig
new file mode 100644
index 000000000..d8d159f11
--- /dev/null
+++ b/tests/aiger/cnt1e.aig
@@ -0,0 +1,4 @@
+aig 5 1 1 0 3 1
+10
+4
+b0 AIGER_NEVER
diff --git a/tests/aiger/empty.aag b/tests/aiger/empty.aag
new file mode 100644
index 000000000..40c0f00cb
--- /dev/null
+++ b/tests/aiger/empty.aag
@@ -0,0 +1 @@
+aag 0 0 0 0 0
diff --git a/tests/aiger/empty.aig b/tests/aiger/empty.aig
new file mode 100644
index 000000000..a28373cd3
--- /dev/null
+++ b/tests/aiger/empty.aig
@@ -0,0 +1 @@
+aig 0 0 0 0 0
diff --git a/tests/aiger/false.aag b/tests/aiger/false.aag
new file mode 100644
index 000000000..421e64a91
--- /dev/null
+++ b/tests/aiger/false.aag
@@ -0,0 +1,2 @@
+aag 0 0 0 1 0
+0
diff --git a/tests/aiger/false.aig b/tests/aiger/false.aig
new file mode 100644
index 000000000..ad7d039fa
--- /dev/null
+++ b/tests/aiger/false.aig
@@ -0,0 +1,2 @@
+aig 0 0 0 1 0
+0
diff --git a/tests/aiger/halfadder.aag b/tests/aiger/halfadder.aag
new file mode 100644
index 000000000..5bf54d38d
--- /dev/null
+++ b/tests/aiger/halfadder.aag
@@ -0,0 +1,14 @@
+aag 7 2 0 2 3
+2
+4
+6
+12
+6 13 15
+12 2 4
+14 3 5
+i0 x
+i1 y
+o0 s
+o1 c
+c
+half adder
diff --git a/tests/aiger/halfadder.aig b/tests/aiger/halfadder.aig
new file mode 100644
index 000000000..83727ee63
--- /dev/null
+++ b/tests/aiger/halfadder.aig
@@ -0,0 +1,9 @@
+aig 5 2 0 2 3
+10
+6
+i0 x
+i1 y
+o0 s
+o1 c
+c
+half adder
diff --git a/tests/aiger/inverter.aag b/tests/aiger/inverter.aag
new file mode 100644
index 000000000..ff7c28542
--- /dev/null
+++ b/tests/aiger/inverter.aag
@@ -0,0 +1,3 @@
+aag 1 1 0 1 0
+2
+3
diff --git a/tests/aiger/inverter.aig b/tests/aiger/inverter.aig
new file mode 100644
index 000000000..525d82392
--- /dev/null
+++ b/tests/aiger/inverter.aig
@@ -0,0 +1,2 @@
+aig 1 1 0 1 0
+3
diff --git a/tests/aiger/notcnt1.aag b/tests/aiger/notcnt1.aag
new file mode 100644
index 000000000..e92815f23
--- /dev/null
+++ b/tests/aiger/notcnt1.aag
@@ -0,0 +1,4 @@
+aag 1 0 1 0 0 1
+2 3
+3
+b0 AIGER_NEVER
diff --git a/tests/aiger/notcnt1.aig b/tests/aiger/notcnt1.aig
new file mode 100644
index 000000000..f8a667f1f
--- /dev/null
+++ b/tests/aiger/notcnt1.aig
@@ -0,0 +1,4 @@
+aig 1 0 1 0 0 1
+3
+3
+b0 AIGER_NEVER
diff --git a/tests/aiger/notcnt1e.aag b/tests/aiger/notcnt1e.aag
new file mode 100644
index 000000000..141c864f7
--- /dev/null
+++ b/tests/aiger/notcnt1e.aag
@@ -0,0 +1,8 @@
+aag 5 1 1 0 3 1
+2
+4 10
+5
+6 5 3
+8 4 2
+10 9 7
+b0 AIGER_NEVER
diff --git a/tests/aiger/notcnt1e.aig b/tests/aiger/notcnt1e.aig
new file mode 100644
index 000000000..7c85a7290
--- /dev/null
+++ b/tests/aiger/notcnt1e.aig
@@ -0,0 +1,4 @@
+aig 5 1 1 0 3 1
+10
+5
+b0 AIGER_NEVER
diff --git a/tests/aiger/or.aag b/tests/aiger/or.aag
new file mode 100644
index 000000000..f780e339f
--- /dev/null
+++ b/tests/aiger/or.aag
@@ -0,0 +1,5 @@
+aag 3 2 0 1 1
+2
+4
+7
+6 3 5
diff --git a/tests/aiger/or.aig b/tests/aiger/or.aig
new file mode 100644
index 000000000..75c9e4480
--- /dev/null
+++ b/tests/aiger/or.aig
@@ -0,0 +1,3 @@
+aig 3 2 0 1 1
+7
+ \ No newline at end of file
diff --git a/tests/aiger/run-test.sh b/tests/aiger/run-test.sh
new file mode 100755
index 000000000..e0a34f023
--- /dev/null
+++ b/tests/aiger/run-test.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+OPTIND=1
+seed="" # default to no seed specified
+while getopts "S:" opt
+do
+ case "$opt" in
+ S) arg="${OPTARG#"${OPTARG%%[![:space:]]*}"}" # remove leading space
+ seed="SEED=$arg" ;;
+ esac
+done
+shift "$((OPTIND-1))"
+
+# check for Icarus Verilog
+if ! which iverilog > /dev/null ; then
+ echo "$0: Error: Icarus Verilog 'iverilog' not found."
+ exit 1
+fi
+
+echo "===== AAG ======"
+${MAKE:-make} -f ../tools/autotest.mk $seed *.aag EXTRA_FLAGS="-f aiger"
+
+echo "===== AIG ======"
+exec ${MAKE:-make} -f ../tools/autotest.mk $seed *.aig EXTRA_FLAGS="-f aiger"
diff --git a/tests/aiger/toggle-re.aag b/tests/aiger/toggle-re.aag
new file mode 100644
index 000000000..b662bb386
--- /dev/null
+++ b/tests/aiger/toggle-re.aag
@@ -0,0 +1,14 @@
+aag 7 2 1 2 4
+2
+4
+6 8
+6
+7
+8 4 10
+10 13 15
+12 2 6
+14 3 7
+i0 enable
+i1 reset
+o0 Q
+o1 !Q
diff --git a/tests/aiger/toggle-re.aig b/tests/aiger/toggle-re.aig
new file mode 100644
index 000000000..9d6730f21
--- /dev/null
+++ b/tests/aiger/toggle-re.aig
@@ -0,0 +1,8 @@
+aig 7 2 1 2 4
+14
+6
+7
+i0 enable
+i1 reset
+o0 Q
+o1 !Q
diff --git a/tests/aiger/toggle.aag b/tests/aiger/toggle.aag
new file mode 100644
index 000000000..09651012d
--- /dev/null
+++ b/tests/aiger/toggle.aag
@@ -0,0 +1,4 @@
+aag 1 0 1 2 0
+2 3
+2
+3
diff --git a/tests/aiger/toggle.aig b/tests/aiger/toggle.aig
new file mode 100644
index 000000000..b69e21aaf
--- /dev/null
+++ b/tests/aiger/toggle.aig
@@ -0,0 +1,4 @@
+aig 1 0 1 2 0
+3
+2
+3
diff --git a/tests/aiger/true.aag b/tests/aiger/true.aag
new file mode 100644
index 000000000..366893648
--- /dev/null
+++ b/tests/aiger/true.aag
@@ -0,0 +1,2 @@
+aag 0 0 0 1 0
+1
diff --git a/tests/aiger/true.aig b/tests/aiger/true.aig
new file mode 100644
index 000000000..10086f389
--- /dev/null
+++ b/tests/aiger/true.aig
@@ -0,0 +1,2 @@
+aig 0 0 0 1 0
+1
diff --git a/tests/simple/dff_init.v b/tests/simple/dff_init.v
new file mode 100644
index 000000000..be947042e
--- /dev/null
+++ b/tests/simple/dff_init.v
@@ -0,0 +1,42 @@
+module dff0_test(n1, n1_inv, clk);
+ input clk;
+ output n1;
+ reg n1 = 32'd0;
+ output n1_inv;
+ always @(posedge clk)
+ n1 <= n1_inv;
+ assign n1_inv = ~n1;
+endmodule
+
+module dff1_test(n1, n1_inv, clk);
+ input clk;
+ (* init = 32'd1 *)
+ output n1;
+ reg n1 = 32'd1;
+ output n1_inv;
+ always @(posedge clk)
+ n1 <= n1_inv;
+ assign n1_inv = ~n1;
+endmodule
+
+module dff0a_test(n1, n1_inv, clk);
+ input clk;
+ (* init = 32'd0 *) // Must be consistent with reg initialiser below
+ output n1;
+ reg n1 = 32'd0;
+ output n1_inv;
+ always @(posedge clk)
+ n1 <= n1_inv;
+ assign n1_inv = ~n1;
+endmodule
+
+module dff1a_test(n1, n1_inv, clk);
+ input clk;
+ (* init = 32'd1 *) // Must be consistent with reg initialiser below
+ output n1;
+ reg n1 = 32'd1;
+ output n1_inv;
+ always @(posedge clk)
+ n1 <= n1_inv;
+ assign n1_inv = ~n1;
+endmodule
diff --git a/tests/simple_defparam/run-test.sh b/tests/simple_defparam/run-test.sh
new file mode 100755
index 000000000..137e15076
--- /dev/null
+++ b/tests/simple_defparam/run-test.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+OPTIND=1
+seed="" # default to no seed specified
+while getopts "S:" opt
+do
+ case "$opt" in
+ S) arg="${OPTARG#"${OPTARG%%[![:space:]]*}"}" # remove leading space
+ seed="SEED=$arg" ;;
+ esac
+done
+shift "$((OPTIND-1))"
+
+# check for Icarus Verilog
+if ! which iverilog > /dev/null ; then
+ echo "$0: Error: Icarus Verilog 'iverilog' not found."
+ exit 1
+fi
+
+cp ../simple/*.v .
+exec ${MAKE:-make} -f ../tools/autotest.mk $seed *.v EXTRA_FLAGS="-B \"-defparam\""
diff --git a/tests/tools/autotest.sh b/tests/tools/autotest.sh
index 218edf931..2722cba19 100755
--- a/tests/tools/autotest.sh
+++ b/tests/tools/autotest.sh
@@ -28,7 +28,7 @@ if [ ! -f $toolsdir/cmp_tbdata -o $toolsdir/cmp_tbdata.c -nt $toolsdir/cmp_tbdat
( set -ex; ${CC:-gcc} -Wall -o $toolsdir/cmp_tbdata $toolsdir/cmp_tbdata.c; ) || exit 1
fi
-while getopts xmGl:wkjvref:s:p:n:S:I:-: opt; do
+while getopts xmGl:wkjvref:s:p:n:S:I:B:-: opt; do
case "$opt" in
x)
use_xsim=true ;;
@@ -65,6 +65,8 @@ while getopts xmGl:wkjvref:s:p:n:S:I:-: opt; do
include_opts="$include_opts -I $OPTARG"
xinclude_opts="$xinclude_opts -i $OPTARG"
minclude_opts="$minclude_opts +incdir+$OPTARG" ;;
+ B)
+ backend_opts="$backend_opts $OPTARG" ;;
-)
case "${OPTARG}" in
xfirrtl)
@@ -82,7 +84,7 @@ while getopts xmGl:wkjvref:s:p:n:S:I:-: opt; do
;;
esac;;
*)
- echo "Usage: $0 [-x|-m] [-G] [-w] [-k] [-j] [-v] [-r] [-e] [-l libs] [-f frontend] [-s script] [-p cmdstring] [-n iters] [-S seed] [-I incdir] [--xfirrtl FIRRTL test exclude file] [--firrtl2verilog command to generate verilog from firrtl] verilog-files\n" >&2
+ echo "Usage: $0 [-x|-m] [-G] [-w] [-k] [-j] [-v] [-r] [-e] [-l libs] [-f frontend] [-s script] [-p cmdstring] [-n iters] [-S seed] [-I incdir] [-B backend_opt] [--xfirrtl FIRRTL test exclude file] [--firrtl2verilog command to generate verilog from firrtl] verilog-files\n" >&2
exit 1
esac
done
@@ -108,8 +110,9 @@ shift $((OPTIND - 1))
for fn
do
- bn=${fn%.v}
- if [ "$bn" == "$fn" ]; then
+ bn=${fn%.*}
+ ext=${fn##*.}
+ if [[ "$ext" != "v" ]] && [[ "$ext" != "aag" ]] && [[ "$ext" != "aig" ]]; then
echo "Invalid argument: $fn" >&2
exit 1
fi
@@ -131,9 +134,18 @@ do
fn=$(basename $fn)
bn=$(basename $bn)
+<<<<<<< HEAD
+ if [[ "$ext" == "v" ]]; then
+ egrep -v '^\s*`timescale' ../$fn > ${bn}_ref.${ext}
+ else
+ "$toolsdir"/../../yosys -f "$frontend $include_opts" -b "verilog" -o ${bn}_ref.v ../${fn}
+ frontend="verilog"
+ fi
+=======
rm -f ${bn}_ref.fir
egrep -v '^\s*`timescale' ../$fn > ${bn}_ref.v
+>>>>>>> e45f62b0c56717a23099425f078d1e56212aa632
if [ ! -f ../${bn}_tb.v ]; then
"$toolsdir"/../../yosys -f "$frontend $include_opts" -b "test_autotb $autotb_opts" -o ${bn}_tb.v ${bn}_ref.v
@@ -141,7 +153,8 @@ do
cp ../${bn}_tb.v ${bn}_tb.v
fi
if $genvcd; then sed -i 's,// \$dump,$dump,g' ${bn}_tb.v; fi
- compile_and_run ${bn}_tb_ref ${bn}_out_ref ${bn}_tb.v ${bn}_ref.v $libs
+ compile_and_run ${bn}_tb_ref ${bn}_out_ref ${bn}_tb.v ${bn}_ref.v $libs \
+ "$toolsdir"/../../techlibs/common/simlib.v
if $genvcd; then mv testbench.vcd ${bn}_ref.vcd; fi
test_count=0