From 058deb777e72458fa018e21eaf0322ca75b86fd7 Mon Sep 17 00:00:00 2001 From: eddiehung Date: Tue, 28 Apr 2015 08:55:26 +0100 Subject: [PATCH 1/7] blifwriter: write out .names for true/false/undef type == '-' --- backends/blif/blif.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backends/blif/blif.cc b/backends/blif/blif.cc index 6422d9f01..bbc0614e4 100644 --- a/backends/blif/blif.cc +++ b/backends/blif/blif.cc @@ -145,18 +145,24 @@ struct BlifDumper if (config->false_type != "-") f << stringf(".%s %s %s=$false\n", subckt_or_gate(config->false_type), config->false_type.c_str(), config->false_out.c_str()); + else + f << stringf(".names %s\n", config->false_out.c_str()); } else f << stringf(".names $false\n"); if (!config->true_type.empty()) { if (config->true_type != "-") f << stringf(".%s %s %s=$true\n", subckt_or_gate(config->true_type), config->true_type.c_str(), config->true_out.c_str()); + else + f << stringf(".names %s\n1\n", config->true_out.c_str()); } else f << stringf(".names $true\n1\n"); if (!config->undef_type.empty()) { if (config->undef_type != "-") f << stringf(".%s %s %s=$undef\n", subckt_or_gate(config->undef_type), config->undef_type.c_str(), config->undef_out.c_str()); + else + f << stringf(".names %s\n", config->undef_out.c_str()); } else f << stringf(".names $undef\n"); } From 872e13321c4c39997d3b14408224ef1c2fcc0821 Mon Sep 17 00:00:00 2001 From: eddiehung Date: Tue, 28 Apr 2015 08:56:00 +0100 Subject: [PATCH 2/7] For vtr, escape angle brackets as well --- backends/blif/blif.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backends/blif/blif.cc b/backends/blif/blif.cc index bbc0614e4..4a5121977 100644 --- a/backends/blif/blif.cc +++ b/backends/blif/blif.cc @@ -66,7 +66,7 @@ struct BlifDumper { std::string str = RTLIL::unescape_id(id); for (size_t i = 0; i < str.size(); i++) - if (str[i] == '#' || str[i] == '=') + if (str[i] == '#' || str[i] == '=' || str[i] == '<' || str[i] == '>') str[i] = '?'; cstr_buf.push_back(str); return cstr_buf.back().c_str(); From 079c1205fec6d194114b3d031d78a23cb8e0e7f9 Mon Sep 17 00:00:00 2001 From: eddiehung Date: Sun, 3 May 2015 10:37:20 +0100 Subject: [PATCH 3/7] Escape '<' and '>' some more --- backends/blif/blif.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backends/blif/blif.cc b/backends/blif/blif.cc index 4a5121977..3a4618a90 100644 --- a/backends/blif/blif.cc +++ b/backends/blif/blif.cc @@ -82,7 +82,7 @@ struct BlifDumper std::string str = RTLIL::unescape_id(sig.wire->name); for (size_t i = 0; i < str.size(); i++) - if (str[i] == '#' || str[i] == '=') + if (str[i] == '#' || str[i] == '=' || str[i] == '<' || str[i] == '>') str[i] = '?'; if (sig.wire->width != 1) From 7c623182393aa2e8445336a99f0cfd4bc7c7e88f Mon Sep 17 00:00:00 2001 From: eddiehung Date: Sun, 3 May 2015 12:53:09 +0100 Subject: [PATCH 4/7] Fix for all zero mask --- Makefile | 6 +++++- backends/blif/blif.cc | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f1188da2e..d41bec187 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -CONFIG := clang +CONFIG := icc # CONFIG := gcc # CONFIG := gcc-4.6 # CONFIG := emcc @@ -109,6 +109,10 @@ ABCMKARGS += ARCHFLAGS="-DSIZEOF_VOID_P=4 -DSIZEOF_LONG=4 -DSIZEOF_INT=4 -DWIN32 ABCMKARGS += LIBS="lib/x86/pthreadVC2.lib -s" READLINE=0 CC="$(CXX)" CXX="$(CXX)" EXE = .exe +else ifeq ($(CONFIG),icc) +CXX = icpc +CXXFLAGS += -std=gnu++0x -Os + else ifneq ($(CONFIG),none) $(error Invalid CONFIG setting '$(CONFIG)'. Valid values: clang, gcc, gcc-4.6, emcc, none) endif diff --git a/backends/blif/blif.cc b/backends/blif/blif.cc index 3a4618a90..2734ca321 100644 --- a/backends/blif/blif.cc +++ b/backends/blif/blif.cc @@ -234,13 +234,24 @@ struct BlifDumper f << stringf(" %s", cstr(output)); f << stringf("\n"); RTLIL::SigSpec mask = cell->parameters.at("\\LUT"); + bool one = false; for (int i = 0; i < (1 << width); i++) if (mask[i] == RTLIL::S1) { for (int j = width-1; j >= 0; j--) { f << ((i>>j)&1 ? '1' : '0'); } f << " 1\n"; + one = true; } + /* For some reason, sometimes we get LUTs with + * an all zero mask, which won't give any + * .names entries, so write one entry with + * all don't cares */ + if (!one) { + for (int j = width-1; j >= 0; j--) + f << '-'; + f << " 0\n"; + } continue; } From 6bda61292513cbe7ffd69b4e3462b849757d2337 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 8 Jul 2016 11:35:15 +0200 Subject: [PATCH 5/7] Undo eddiehung-vtr Makefile changes --- Makefile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Makefile b/Makefile index fee099a02..7ed68ef42 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -CONFIG := icc +CONFIG := clang # CONFIG := gcc # CONFIG := gcc-4.8 # CONFIG := emcc @@ -172,10 +172,6 @@ ABCMKARGS += ARCHFLAGS="-DSIZEOF_VOID_P=4 -DSIZEOF_LONG=4 -DSIZEOF_INT=4 -DWIN32 ABCMKARGS += LIBS="lib/x86/pthreadVC2.lib -s" ABC_USE_NO_READLINE=1 CC="$(CXX)" CXX="$(CXX)" EXE = .exe -else ifeq ($(CONFIG),icc) -CXX = icpc -CXXFLAGS += -std=gnu++0x -Os - else ifneq ($(CONFIG),none) $(error Invalid CONFIG setting '$(CONFIG)'. Valid values: clang, gcc, gcc-4.8, emcc, none) endif From 72149aba2e8fece72450a81142a44d123154fd12 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 8 Jul 2016 11:41:26 +0200 Subject: [PATCH 6/7] In BLIF, a .names without entries already always outputs 0 --- backends/blif/blif.cc | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/backends/blif/blif.cc b/backends/blif/blif.cc index 93953049a..d5787c23a 100644 --- a/backends/blif/blif.cc +++ b/backends/blif/blif.cc @@ -351,24 +351,13 @@ struct BlifDumper f << stringf(" %s", cstr(output)); f << stringf("\n"); RTLIL::SigSpec mask = cell->parameters.at("\\LUT"); - bool one = false; for (int i = 0; i < (1 << width); i++) if (mask[i] == RTLIL::S1) { for (int j = width-1; j >= 0; j--) { f << ((i>>j)&1 ? '1' : '0'); } f << " 1\n"; - one = true; } - /* For some reason, sometimes we get LUTs with - * an all zero mask, which won't give any - * .names entries, so write one entry with - * all don't cares */ - if (!one) { - for (int j = width-1; j >= 0; j--) - f << '-'; - f << " 0\n"; - } continue; } From 27b5347a871d209ec4cba094e1203cc896c9c4b3 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 8 Jul 2016 11:49:55 +0200 Subject: [PATCH 7/7] Restored blif "-true - .." behavior, use "-true + .." for eddiehung-vtr behavior --- backends/blif/blif.cc | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/backends/blif/blif.cc b/backends/blif/blif.cc index d5787c23a..6a379e67f 100644 --- a/backends/blif/blif.cc +++ b/backends/blif/blif.cc @@ -104,9 +104,9 @@ struct BlifDumper cstr_bits_seen.insert(sig); if (sig.wire == NULL) { - if (sig == RTLIL::State::S0) return config->false_type == "-" ? config->false_out.c_str() : "$false"; - if (sig == RTLIL::State::S1) return config->true_type == "-" ? config->true_out.c_str() : "$true"; - return config->undef_type == "-" ? config->undef_out.c_str() : "$undef"; + if (sig == RTLIL::State::S0) return config->false_type == "-" || config->false_type == "+" ? config->false_out.c_str() : "$false"; + if (sig == RTLIL::State::S1) return config->true_type == "-" || config->true_type == "+" ? config->true_out.c_str() : "$true"; + return config->undef_type == "-" || config->undef_type == "+" ? config->undef_out.c_str() : "$undef"; } std::string str = RTLIL::unescape_id(sig.wire->name); @@ -204,27 +204,27 @@ struct BlifDumper if (!config->impltf_mode) { if (!config->false_type.empty()) { - if (config->false_type != "-") + if (config->false_type == "+") + f << stringf(".names %s\n", config->false_out.c_str()); + else if (config->false_type != "-") f << stringf(".%s %s %s=$false\n", subckt_or_gate(config->false_type), config->false_type.c_str(), config->false_out.c_str()); - else - f << stringf(".names %s\n", config->false_out.c_str()); } else f << stringf(".names $false\n"); if (!config->true_type.empty()) { - if (config->true_type != "-") + if (config->true_type == "+") + f << stringf(".names %s\n1\n", config->true_out.c_str()); + else if (config->true_type != "-") f << stringf(".%s %s %s=$true\n", subckt_or_gate(config->true_type), config->true_type.c_str(), config->true_out.c_str()); - else - f << stringf(".names %s\n1\n", config->true_out.c_str()); } else f << stringf(".names $true\n1\n"); if (!config->undef_type.empty()) { - if (config->undef_type != "-") + if (config->undef_type == "+") + f << stringf(".names %s\n", config->undef_out.c_str()); + else if (config->undef_type != "-") f << stringf(".%s %s %s=$undef\n", subckt_or_gate(config->undef_type), config->undef_type.c_str(), config->undef_out.c_str()); - else - f << stringf(".names %s\n", config->undef_out.c_str()); } else f << stringf(".names $undef\n"); } @@ -462,7 +462,9 @@ struct BlifBackend : public Backend { log(" use the specified cell types to drive nets that are constant 1, 0, or\n"); log(" undefined. when '-' is used as , then specifies\n"); log(" the wire name to be used for the constant signal and no cell driving\n"); - log(" that wire is generated.\n"); + log(" that wire is generated. when '+' is used as , then \n"); + log(" specifies the wire name to be used for the constant signal and a .names\n"); + log(" statement is generated to drive the wire.\n"); log("\n"); log(" -noalias\n"); log(" if a net name is aliasing another net name, then by default a net\n");