Added read_blif command
authorClifford Wolf <clifford@clifford.at>
Sun, 17 May 2015 13:25:03 +0000 (15:25 +0200)
committerClifford Wolf <clifford@clifford.at>
Sun, 17 May 2015 13:25:03 +0000 (15:25 +0200)
frontends/blif/blifparse.cc
kernel/yosys.cc

index fb71cee166695dbe91211291c64d7680f1bb1aa8..cc06dfbd3d553c932963e1d7bdd5ed93d99c23fc 100644 (file)
@@ -133,7 +133,7 @@ void parse_blif(RTLIL::Design *design, std::istream &f, std::string dff_name)
                                continue;
                        }
 
-                       if (!strcmp(cmd, ".gate"))
+                       if (!strcmp(cmd, ".gate") || !strcmp(cmd, ".subckt"))
                        {
                                char *p = strtok(NULL, " \t\r\n");
                                if (p == NULL)
@@ -268,5 +268,35 @@ error:
        log_error("Syntax error in line %d!\n", line_count);
 }
 
+struct BlifFrontend : public Frontend {
+       BlifFrontend() : Frontend("blif", "read BLIF file") { }
+       virtual void help()
+       {
+               //   |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
+               log("\n");
+               log("    read_blif [filename]\n");
+               log("\n");
+               log("Load modules from a BLIF file into the current design.\n");
+               log("\n");
+       }
+       virtual void execute(std::istream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design)
+       {
+               log_header("Executing BLIF frontend.\n");
+
+               size_t argidx;
+               for (argidx = 1; argidx < args.size(); argidx++) {
+                       std::string arg = args[argidx];
+                       // if (arg == "-lib") {
+                       //      flag_lib = true;
+                       //      continue;
+                       // }
+                       break;
+               }
+               extra_args(f, filename, args, argidx);
+
+               parse_blif(design, *f, "\\DFF");
+       }
+} BlifFrontend;
+
 YOSYS_NAMESPACE_END
 
index 1d6e7113b289fe6f388e562e5222d9fd3ae154d2..d66f33b1ec15dbea773d85d4110b01cd68c78b8c 100644 (file)
@@ -746,6 +746,8 @@ void run_frontend(std::string filename, std::string command, std::string *backen
                        command = "verilog";
                else if (filename.size() > 2 && filename.substr(filename.size()-3) == ".sv")
                        command = "verilog -sv";
+               else if (filename.size() > 4 && filename.substr(filename.size()-5) == ".blif")
+                       command = "blif";
                else if (filename.size() > 3 && filename.substr(filename.size()-3) == ".il")
                        command = "ilang";
                else if (filename.size() > 3 && filename.substr(filename.size()-3) == ".ys")