Support binary files for backends, fixes #1407
authorMiodrag Milanovic <mmicko@gmail.com>
Sat, 28 Sep 2019 07:28:51 +0000 (09:28 +0200)
committerMiodrag Milanovic <mmicko@gmail.com>
Sat, 28 Sep 2019 07:36:18 +0000 (09:36 +0200)
backends/aiger/xaiger.cc
kernel/register.cc
kernel/register.h

index fa6ba0aca4f28b3c25ca93202b9426022c906768..87ba0aedf80540ea70b6bbf301fb0a3b752c94f2 100644 (file)
@@ -856,7 +856,7 @@ struct XAigerBackend : public Backend {
                        }
                        break;
                }
-               extra_args(f, filename, args, argidx);
+               extra_args(f, filename, args, argidx, !ascii_mode);
 
                Module *top_module = design->top_module();
 
index 8131fa279ca5565582fe8a0b2a0b1950dadef367..3033ee710a75e7e0fea768a37df60c84bf3a2fa4 100644 (file)
@@ -612,7 +612,7 @@ void Backend::execute(std::vector<std::string> args, RTLIL::Design *design)
                delete f;
 }
 
-void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<std::string> args, size_t argidx)
+void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<std::string> args, size_t argidx, bool bin_output)
 {
        bool called_with_fp = f != NULL;
 
@@ -647,7 +647,7 @@ void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<st
 #endif
                } else {
                        std::ofstream *ff = new std::ofstream;
-                       ff->open(filename.c_str(), std::ofstream::trunc);
+                       ff->open(filename.c_str(), bin_output ? (std::ofstream::trunc | std::ofstream::binary) : std::ofstream::trunc);
                        yosys_output_files.insert(filename);
                        if (ff->fail()) {
                                delete ff;
index c740298233d26f30109245397c3214f7134aad14..be836013f9c74b9ac879ecf5a784dcc79ab085f5 100644 (file)
@@ -109,7 +109,7 @@ struct Backend : Pass
        void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE YS_FINAL;
        virtual void execute(std::ostream *&f, std::string filename,  std::vector<std::string> args, RTLIL::Design *design) = 0;
 
-       void extra_args(std::ostream *&f, std::string &filename, std::vector<std::string> args, size_t argidx);
+       void extra_args(std::ostream *&f, std::string &filename, std::vector<std::string> args, size_t argidx, bool bin_output = false);
 
        static void backend_call(RTLIL::Design *design, std::ostream *f, std::string filename, std::string command);
        static void backend_call(RTLIL::Design *design, std::ostream *f, std::string filename, std::vector<std::string> args);