Skip to content

Commit

Permalink
auto_testbench Tcl command
Browse files Browse the repository at this point in the history
  • Loading branch information
alaindargelas committed Aug 23, 2024
1 parent b43ea13 commit df848c9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Simulation/Simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,44 @@ 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;
int result = simulator->GenerateAutoTestbench();
if (result != 0) {
return TCL_ERROR;
}
return TCL_OK;
};
interp->registerCmd("auto_testbench", auto_testbench, this, 0);

return ok;
}

int Simulator::GenerateAutoTestbench() {
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";
std::string workingDir =
std::filesystem::current_path() / ProjManager()->projectName();
std::string command = std::string(python3Path) + " " +
std::string(scriptPath) + " " +
ProjManager()->projectName() + " " +
std::string(std::filesystem::current_path());
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));
Expand Down
2 changes: 2 additions & 0 deletions src/Simulation/Simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class Simulator {
void UserSimulationType(SimulationType simulation, SimulatorType simulator);
SimulatorType UserSimulationType(SimulationType simulation, bool& ok) const;

int GenerateAutoTestbench();

protected:
virtual bool SimulateRTL(SimulatorType type);
virtual bool SimulateGate(SimulatorType type);
Expand Down

0 comments on commit df848c9

Please sign in to comment.