From fefe0fc0430f4f173a25e674708aa0f4f0854b31 Mon Sep 17 00:00:00 2001 From: Ruben Undheim Date: Thu, 3 Nov 2016 23:18:00 +0100 Subject: Imported yosys 0.7 --- frontends/blif/blifparse.cc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'frontends/blif/blifparse.cc') diff --git a/frontends/blif/blifparse.cc b/frontends/blif/blifparse.cc index 3717a1e5..6d4d6087 100644 --- a/frontends/blif/blifparse.cc +++ b/frontends/blif/blifparse.cc @@ -23,6 +23,7 @@ YOSYS_NAMESPACE_BEGIN static bool read_next_line(char *&buffer, size_t &buffer_size, int &line_count, std::istream &f) { + string strbuf; int buffer_len = 0; buffer[0] = 0; @@ -42,8 +43,13 @@ static bool read_next_line(char *&buffer, size_t &buffer_size, int &line_count, if (buffer_len > 0 && buffer[buffer_len-1] == '\\') buffer[--buffer_len] = 0; line_count++; - if (!f.getline(buffer+buffer_len, buffer_size-buffer_len)) + if (!std::getline(f, strbuf)) return false; + while (buffer_size-buffer_len < strbuf.size()+1) { + buffer_size *= 2; + buffer = (char*)realloc(buffer, buffer_size); + } + strcpy(buffer+buffer_len, strbuf.c_str()); } else return true; } @@ -256,9 +262,13 @@ void parse_blif(RTLIL::Design *design, std::istream &f, std::string dff_name, bo cell = module->addDlatch(NEW_ID, blif_wire(clock), blif_wire(d), blif_wire(q), false); else { no_latch_clock: - cell = module->addCell(NEW_ID, dff_name); - cell->setPort("\\D", blif_wire(d)); - cell->setPort("\\Q", blif_wire(q)); + if (dff_name.empty()) { + cell = module->addFf(NEW_ID, blif_wire(d), blif_wire(q)); + } else { + cell = module->addCell(NEW_ID, dff_name); + cell->setPort("\\D", blif_wire(d)); + cell->setPort("\\Q", blif_wire(q)); + } } obj_attributes = &cell->attributes; @@ -477,7 +487,7 @@ struct BlifFrontend : public Frontend { } extra_args(f, filename, args, argidx); - parse_blif(design, *f, "\\DFF", true, sop_mode); + parse_blif(design, *f, "", true, sop_mode); } } BlifFrontend; -- cgit v1.2.3