diff --git a/src/Compiler/Compiler.cpp b/src/Compiler/Compiler.cpp index f5ff05ccd..9b812fe5a 100644 --- a/src/Compiler/Compiler.cpp +++ b/src/Compiler/Compiler.cpp @@ -418,7 +418,7 @@ bool Compiler::RegisterCommands(TclInterpreter* interp, bool batchMode) { const char* argv[]) -> int { Compiler* compiler = (Compiler*)clientData; std::string name = compiler->ProjManager()->projectName(); - Tcl_AppendResult(interp, strdup(name.c_str()), nullptr); + Tcl_SetResult(interp, (char*)name.c_str(), TCL_VOLATILE); return TCL_OK; }; interp->registerCmd("get_design_name", get_design_name, this, nullptr); @@ -427,11 +427,65 @@ bool Compiler::RegisterCommands(TclInterpreter* interp, bool batchMode) { const char* argv[]) -> int { Compiler* compiler = (Compiler*)clientData; std::string name = compiler->ProjManager()->DesignTopModule(); - Tcl_AppendResult(interp, strdup(name.c_str()), nullptr); + Tcl_SetResult(interp, (char*)name.c_str(), TCL_VOLATILE); return TCL_OK; }; interp->registerCmd("get_top_module", get_top_module, this, nullptr); + auto get_bin_path = [](void* clientData, Tcl_Interp* interp, int argc, + const char* argv[]) -> int { + Compiler* compiler = (Compiler*)clientData; + std::string name = compiler->GetBinPath().string(); + Tcl_SetResult(interp, (char*)name.c_str(), TCL_VOLATILE); + return TCL_OK; + }; + interp->registerCmd("get_bin_path", get_bin_path, this, nullptr); + + auto get_data_path = [](void* clientData, Tcl_Interp* interp, int argc, + const char* argv[]) -> int { + Compiler* compiler = (Compiler*)clientData; + std::string name = compiler->GetDataPath().string(); + Tcl_SetResult(interp, (char*)name.c_str(), TCL_VOLATILE); + return TCL_OK; + }; + interp->registerCmd("get_data_path", get_data_path, this, nullptr); + + auto get_python3_path = [](void* clientData, Tcl_Interp* interp, int argc, + const char* argv[]) -> int { + Compiler* compiler = (Compiler*)clientData; + std::filesystem::path python3Path = compiler->GetDataPath() / ".." / + "envs" / "python3.8" / "bin" / + "python3"; + std::string name = python3Path.string(); + Tcl_SetResult(interp, (char*)name.c_str(), TCL_VOLATILE); + return TCL_OK; + }; + interp->registerCmd("get_python3_path", get_python3_path, this, nullptr); + + auto message = [](void* clientData, Tcl_Interp* interp, int argc, + const char* argv[]) -> int { + Compiler* compiler = (Compiler*)clientData; + std::string text; + for (int i = 1; i < argc; i++) { + text += std::string(argv[i]) + " "; + } + compiler->Message(text); + return TCL_OK; + }; + interp->registerCmd("message", message, this, nullptr); + + auto error_message = [](void* clientData, Tcl_Interp* interp, int argc, + const char* argv[]) -> int { + Compiler* compiler = (Compiler*)clientData; + std::string text; + for (int i = 1; i < argc; i++) { + text += std::string(argv[i]) + " "; + } + compiler->ErrorMessage(text); + return TCL_ERROR; + }; + interp->registerCmd("error_message", error_message, this, nullptr); + auto get_top_simulation_module = [](void* clientData, Tcl_Interp* interp, int argc, const char* argv[]) -> int { Compiler* compiler = (Compiler*)clientData; diff --git a/src/Simulation/Simulator.cpp b/src/Simulation/Simulator.cpp index 92e6c51ed..70bc6f9e4 100644 --- a/src/Simulation/Simulator.cpp +++ b/src/Simulation/Simulator.cpp @@ -253,55 +253,9 @@ bool Simulator::RegisterCommands(TclInterpreter* interp) { }; interp->registerCmd("simulation_options", simulation_options, this, 0); - auto auto_testbench = [](void* clientData, Tcl_Interp* interp, int argc, - const char* argv[]) -> int { - Simulator* simulator = (Simulator*)clientData; - float clock_period = 5.0; - for (int i = 1; i < argc; i++) { - std::string arg = argv[i]; - if (arg == "-clock_period") { - i++; - arg = argv[i]; - clock_period = std::atof(arg.c_str()); - } - } - int result = simulator->GenerateAutoTestbench(clock_period); - if (result != 0) { - return TCL_ERROR; - } - return TCL_OK; - }; - interp->registerCmd("auto_testbench", auto_testbench, this, 0); - return ok; } -int Simulator::GenerateAutoTestbench(float clock_period) { - Message("##################################################"); - Message("Generating automatic RTL vs gate-level testbench "); - Message("##################################################"); - std::filesystem::path python3Path = m_compiler->GetDataPath() / ".." / - "envs" / "python3.8" / "bin" / "python3"; - std::filesystem::path scriptPath = - m_compiler->GetDataPath() / "python3" / "tb_generator.py"; - const auto& path = std::filesystem::current_path(); - std::string workingDir = - std::filesystem::path(path / ProjManager()->projectName()).string(); - std::string command = std::string(python3Path.string()) + " " + - std::string(scriptPath.string()) + " " + - ProjManager()->projectName() + " " + - std::string(path.string()) + " " + std::to_string(100) + - " " + std::to_string(clock_period); - FileUtils::WriteToFile(CommandLogFile("comp"), command); - int status = m_compiler->ExecuteAndMonitorSystemCommand( - command, "auto-testbench.log", false, workingDir); - if (status == 0) - Message("Testbench is generated."); - else - ErrorMessage("Testbench generation failed"); - return status; -} - bool Simulator::Clean(SimulationType action) { Message("Cleaning simulation results for " + ProjManager()->projectName()); auto base = m_compiler->FilePath(Compiler::ToCompilerAction(action)); diff --git a/src/Simulation/Simulator.h b/src/Simulation/Simulator.h index 717645052..dac15d1db 100644 --- a/src/Simulation/Simulator.h +++ b/src/Simulation/Simulator.h @@ -115,8 +115,6 @@ class Simulator { void UserSimulationType(SimulationType simulation, SimulatorType simulator); SimulatorType UserSimulationType(SimulationType simulation, bool& ok) const; - int GenerateAutoTestbench(float clock_period); - bool IsTimedSimulation() { return m_timed_simulation; } void SetTimedSimulation(bool timed) { m_timed_simulation = timed; }