diff options
-rw-r--r-- | bba/main.cc | 29 | ||||
-rw-r--r-- | ice40/pcf.cc | 5 |
2 files changed, 22 insertions, 12 deletions
diff --git a/bba/main.cc b/bba/main.cc index 263cf39e..d3c81445 100644 --- a/bba/main.cc +++ b/bba/main.cc @@ -77,10 +77,11 @@ int main(int argc, char **argv) namespace po = boost::program_options; po::positional_options_description pos; po::options_description options("Allowed options"); - options.add_options()("v", "verbose output"); - options.add_options()("d", "debug output"); - options.add_options()("b", "big endian"); - options.add_options()("c", "write c strings"); + options.add_options()("help,h", "verbose output"); + options.add_options()("verbose,v", "verbose output"); + options.add_options()("debug,d", "debug output"); + options.add_options()("be,b", "big endian"); + options.add_options()("c,c", "write c strings"); options.add_options()("files", po::value<std::vector<std::string>>(), "file parameters"); pos.add("files", -1); @@ -95,11 +96,15 @@ int main(int argc, char **argv) std::cout << e.what() << "\n"; return 1; } - if (vm.count("v")) + if (vm.count("help")) { + std::cout << options; + return 0; + } + if (vm.count("verbose")) verbose = true; - if (vm.count("d")) + if (vm.count("debug")) debug = true; - if (vm.count("b")) + if (vm.count("be")) bigEndian = true; if (vm.count("c")) writeC = true; @@ -181,10 +186,12 @@ int main(int argc, char **argv) if (cmd == "str") { const char *value = skipWhitespace(strtok(nullptr, "\r\n")); - char terminator[2] = {*value, 0}; - assert(terminator[0] != 0); - value = strtok((char *)value + 1, terminator); - const char *comment = skipWhitespace(strtok(nullptr, "\r\n")); + assert(*value != 0); + char *end = strchr((char *)value + 1, *value); + assert(end != nullptr); + *end = 0; + value += 1; + const char *comment = skipWhitespace(strtok(end+1, "\r\n")); std::string label = std::string("str:") + value; Stream &s = streams.at(streamStack.back()); if (labelIndex.count(label) == 0) { diff --git a/ice40/pcf.cc b/ice40/pcf.cc index a8273dd6..15132800 100644 --- a/ice40/pcf.cc +++ b/ice40/pcf.cc @@ -77,8 +77,11 @@ bool apply_pcf(Context *ctx, std::string filename, std::istream &in) } args_end++; } - if (args_end >= words.size() - 1) + if (args_end > words.size() - 2) log_error("expected PCF syntax 'set_io cell pin' (on line %d)\n", lineno); + else if (args_end < words.size() - 2 && !nowarn) + log_warning("Ignoring trailing PCF settings (on line %d)\n", lineno); + std::string cell = words.at(args_end); std::string pin = words.at(args_end + 1); auto fnd_cell = ctx->cells.find(ctx->id(cell)); |