From c7fd3fbb68351a09575eb66e5db8de06d6ab1984 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Tue, 4 Aug 2015 20:05:37 +0200 Subject: [PATCH] Added $assert support to SMV back-end --- backends/smv/smv.cc | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/backends/smv/smv.cc b/backends/smv/smv.cc index f4e8ff724..03959a4f7 100644 --- a/backends/smv/smv.cc +++ b/backends/smv/smv.cc @@ -42,7 +42,7 @@ struct SmvWorker pool partial_assignment_wires; dict> partial_assignment_bits; - vector assignments; + vector assignments, invarspecs; const char *cid() { @@ -227,6 +227,16 @@ struct SmvWorker { // FIXME: $slice, $concat, $mem + if (cell->type.in("$assert")) + { + SigSpec sig_a = cell->getPort("\\A"); + SigSpec sig_en = cell->getPort("\\EN"); + + invarspecs.push_back(stringf("!bool(%s) | bool(%s);", rvalue(sig_en), rvalue(sig_a))); + + continue; + } + if (cell->type.in("$shl", "$shr", "$sshl", "$sshr", "$shift", "$shiftx")) { SigSpec sig_a = cell->getPort("\\A"); @@ -634,9 +644,16 @@ struct SmvWorker assignments.push_back(stringf("%s := %s;", cid(wire->name), expr.c_str())); } - f << stringf(" ASSIGN\n"); - for (const string &line : assignments) - f << stringf(" %s\n", line.c_str()); + if (!assignments.empty()) { + f << stringf(" ASSIGN\n"); + for (const string &line : assignments) + f << stringf(" %s\n", line.c_str()); + } + + if (!invarspecs.empty()) { + for (const string &line : invarspecs) + f << stringf(" INVARSPEC %s\n", line.c_str()); + } } }; -- 2.30.2