More write_xaiger cleanup
authorEddie Hung <eddie@fpgeh.com>
Wed, 12 Jun 2019 17:00:57 +0000 (10:00 -0700)
committerEddie Hung <eddie@fpgeh.com>
Wed, 12 Jun 2019 17:00:57 +0000 (10:00 -0700)
backends/aiger/xaiger.cc
passes/techmap/abc9.cc

index fd0620cac4ea43752be3e6e7194b48d72dec263b..af9a30135069ab9ce447a6d7756f7fbfe6497170 100644 (file)
@@ -105,7 +105,7 @@ struct XAigerWriter
                return aig_map.at(bit);
        }
 
-       XAigerWriter(Module *module, bool zinit_mode, bool imode, bool omode, bool holes_mode=false) : module(module), zinit_mode(zinit_mode), sigmap(module)
+       XAigerWriter(Module *module, bool zinit_mode, bool holes_mode=false) : module(module), zinit_mode(zinit_mode), sigmap(module)
        {
                pool<SigBit> undriven_bits;
                pool<SigBit> unused_bits;
@@ -543,10 +543,6 @@ struct XAigerWriter
                                ff_aig_map[bit] = 2*aig_m;
                }
 
-               if (imode && input_bits.empty()) {
-                       aig_m++, aig_i++;
-               }
-
                //if (zinit_mode)
                //{
                //      for (auto it : ff_map) {
@@ -620,13 +616,9 @@ struct XAigerWriter
                        aig_outputs.push_back(ff_aig_map.at(bit));
                }
 
-               if (omode && output_bits.empty()) {
-                       aig_o++;
-                       aig_outputs.push_back(0);
-               }
        }
 
-       void write_aiger(std::ostream &f, bool ascii_mode, bool omode)
+       void write_aiger(std::ostream &f, bool ascii_mode)
        {
                int aig_obc = aig_o;
                int aig_obcj = aig_obc;
@@ -716,18 +708,15 @@ struct XAigerWriter
 #endif
                                h_buffer.write(reinterpret_cast<const char*>(&i32_be), sizeof(i32_be));
                        };
-                       int num_outputs = output_bits.size();
-                       if (omode && num_outputs == 0)
-                               num_outputs = 1;
                        write_h_buffer(1);
                        log_debug("ciNum = %zu\n", input_bits.size() + ff_bits.size() + ci_bits.size());
                        write_h_buffer(input_bits.size() + ff_bits.size() + ci_bits.size());
-                       log_debug("coNum = %zu\n", num_outputs + ff_bits.size() + co_bits.size());
-                       write_h_buffer(num_outputs + ff_bits.size()+ co_bits.size());
+                       log_debug("coNum = %zu\n", output_bits.size() + ff_bits.size() + co_bits.size());
+                       write_h_buffer(output_bits.size() + ff_bits.size()+ co_bits.size());
                        log_debug("piNum = %zu\n", input_bits.size() + ff_bits.size());
                        write_h_buffer(input_bits.size()+ ff_bits.size());
-                       log_debug("poNum = %zu\n", num_outputs + ff_bits.size());
-                       write_h_buffer(num_outputs + ff_bits.size());
+                       log_debug("poNum = %zu\n", output_bits.size() + ff_bits.size());
+                       write_h_buffer(output_bits.size() + ff_bits.size());
                        log_debug("boxNum = %zu\n", box_list.size());
                        write_h_buffer(box_list.size());
 
@@ -859,8 +848,8 @@ struct XAigerWriter
                                holes_module->design->selection_stack.pop_back();
 
                                std::stringstream a_buffer;
-                               XAigerWriter writer(holes_module, false /*zinit_mode*/, false /*imode*/, false /*omode*/, true /* holes_mode */);
-                               writer.write_aiger(a_buffer, false /*ascii_mode*/, false /* omode */);
+                               XAigerWriter writer(holes_module, false /*zinit_mode*/, true /* holes_mode */);
+                               writer.write_aiger(a_buffer, false /*ascii_mode*/);
 
                                f << "a";
                                std::string buffer_str = a_buffer.str();
@@ -879,7 +868,7 @@ struct XAigerWriter
                f << stringf("Generated by %s\n", yosys_version_str);
        }
 
-       void write_map(std::ostream &f, bool verbose_map, bool omode)
+       void write_map(std::ostream &f, bool verbose_map)
        {
                dict<int, string> input_lines;
                dict<int, string> init_lines;
@@ -952,8 +941,6 @@ struct XAigerWriter
                for (auto &it : output_lines)
                        f << it.second;
                log_assert(output_lines.size() == output_bits.size());
-               if (omode && output_bits.empty())
-                       f << "output " << output_lines.size() << " 0 __dummy_o__\n";
 
                latch_lines.sort();
                for (auto &it : latch_lines)
@@ -989,19 +976,12 @@ struct XAigerBackend : public Backend {
                log("    -vmap <filename>\n");
                log("        like -map, but more verbose\n");
                log("\n");
-               log("    -I, -O, -B\n");
-               log("        If the design contains no input/output/assert then create one\n");
-               log("        dummy input/output/bad_state pin to make the tools reading the\n");
-               log("        AIGER file happy.\n");
-               log("\n");
        }
        void execute(std::ostream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE
        {
                bool ascii_mode = false;
                bool zinit_mode = false;
                bool verbose_map = false;
-               bool imode = false;
-               bool omode = false;
                std::string map_filename;
 
                log_header(design, "Executing XAIGER backend.\n");
@@ -1026,14 +1006,6 @@ struct XAigerBackend : public Backend {
                                verbose_map = true;
                                continue;
                        }
-                       if (args[argidx] == "-I") {
-                               imode = true;
-                               continue;
-                       }
-                       if (args[argidx] == "-O") {
-                               omode = true;
-                               continue;
-                       }
                        break;
                }
                extra_args(f, filename, args, argidx);
@@ -1043,15 +1015,15 @@ struct XAigerBackend : public Backend {
                if (top_module == nullptr)
                        log_error("Can't find top module in current design!\n");
 
-               XAigerWriter writer(top_module, zinit_mode, imode, omode);
-               writer.write_aiger(*f, ascii_mode, omode);
+               XAigerWriter writer(top_module, zinit_mode);
+               writer.write_aiger(*f, ascii_mode);
 
                if (!map_filename.empty()) {
                        std::ofstream mapf;
                        mapf.open(map_filename.c_str(), std::ofstream::trunc);
                        if (mapf.fail())
                                log_error("Can't open file `%s' for writing: %s\n", map_filename.c_str(), strerror(errno));
-                       writer.write_map(mapf, verbose_map, omode);
+                       writer.write_map(mapf, verbose_map);
                }
        }
 } XAigerBackend;
index 47e87fa462b86f829dc2fc4cb886a8e32e16c5da..b0c6b6d7b4e31c51c71f677ec4f97436490201b9 100644 (file)
@@ -425,7 +425,7 @@ void abc9_module(RTLIL::Design *design, RTLIL::Module *current_module, std::stri
 
        handle_loops(design);
 
-       Pass::call(design, stringf("write_xaiger -O -map %s/input.sym %s/input.xaig; ", tempdir_name.c_str(), tempdir_name.c_str()));
+       Pass::call(design, stringf("write_xaiger -map %s/input.sym %s/input.xaig; ", tempdir_name.c_str(), tempdir_name.c_str()));
 
 #if 0
        std::string buffer = stringf("%s/%s", tempdir_name.c_str(), "input.xaig");