From fc0acd0ad119de5a606355cd8d9da2548338e579 Mon Sep 17 00:00:00 2001 From: Charlotte Date: Wed, 28 Jun 2023 11:51:26 +1000 Subject: [PATCH] cxxrtl: restrict -print-output to cout, cerr --- backends/cxxrtl/cxxrtl_backend.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backends/cxxrtl/cxxrtl_backend.cc b/backends/cxxrtl/cxxrtl_backend.cc index 2c9dc4121..8f06dda66 100644 --- a/backends/cxxrtl/cxxrtl_backend.cc +++ b/backends/cxxrtl/cxxrtl_backend.cc @@ -3265,7 +3265,8 @@ struct CxxrtlBackend : public Backend { log("\n"); log(" -print-output \n"); log(" $print cells in the generated code direct their output to .\n"); - log(" if not specified, \"std::cout\" is used.\n"); + log(" must be one of \"std::cout\", \"std::cerr\". if not specified,\n"); + log(" \"std::cout\" is used.\n"); log("\n"); log(" -nohierarchy\n"); log(" use design hierarchy as-is. in most designs, a top module should be\n"); @@ -3407,6 +3408,10 @@ struct CxxrtlBackend : public Backend { } if (args[argidx] == "-print-output" && argidx+1 < args.size()) { worker.print_output = args[++argidx]; + if (!(worker.print_output == "std::cout" || worker.print_output == "std::cerr")) { + log_cmd_error("Invalid output stream \"%s\".\n", worker.print_output.c_str()); + worker.print_output = "std::cout"; + } continue; } break;