mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-04 02:10:24 +00:00
sdc: separate out
This commit is contained in:
parent
026e9148f8
commit
d64a51106d
5 changed files with 117 additions and 86 deletions
|
@ -372,7 +372,6 @@ void rewrite_filename(std::string &filename)
|
|||
|
||||
// defined in tclapi.cc
|
||||
extern int yosys_tcl_interp_init(Tcl_Interp *interp);
|
||||
extern int yosys_sdc_interp_init(Tcl_Interp *interp);
|
||||
|
||||
extern Tcl_Interp *yosys_get_tcl_interp()
|
||||
{
|
||||
|
@ -382,15 +381,8 @@ extern Tcl_Interp *yosys_get_tcl_interp()
|
|||
}
|
||||
return yosys_tcl_interp;
|
||||
}
|
||||
extern Tcl_Interp *yosys_get_sdc_interp()
|
||||
{
|
||||
if (yosys_sdc_interp == NULL) {
|
||||
yosys_sdc_interp = Tcl_CreateInterp();
|
||||
yosys_sdc_interp_init(yosys_sdc_interp);
|
||||
}
|
||||
return yosys_sdc_interp;
|
||||
}
|
||||
|
||||
// Also see SdcPass
|
||||
struct TclPass : public Pass {
|
||||
TclPass() : Pass("tcl", "execute a TCL script file") { }
|
||||
void help() override {
|
||||
|
@ -433,26 +425,7 @@ struct TclPass : public Pass {
|
|||
Tcl_Release(interp);
|
||||
}
|
||||
} TclPass;
|
||||
struct SdcPass : public Pass {
|
||||
SdcPass() : Pass("sdc", "sniff at some SDC") { }
|
||||
void execute(std::vector<std::string> args, RTLIL::Design *) override {
|
||||
if (args.size() < 2)
|
||||
log_cmd_error("Missing script file.\n");
|
||||
|
||||
std::vector<Tcl_Obj*> script_args;
|
||||
for (auto it = args.begin() + 2; it != args.end(); ++it)
|
||||
script_args.push_back(Tcl_NewStringObj((*it).c_str(), (*it).size()));
|
||||
|
||||
Tcl_Interp *interp = yosys_get_sdc_interp();
|
||||
Tcl_Preserve(interp);
|
||||
Tcl_ObjSetVar2(interp, Tcl_NewStringObj("argc", 4), NULL, Tcl_NewIntObj(script_args.size()), 0);
|
||||
Tcl_ObjSetVar2(interp, Tcl_NewStringObj("argv", 4), NULL, Tcl_NewListObj(script_args.size(), script_args.data()), 0);
|
||||
Tcl_ObjSetVar2(interp, Tcl_NewStringObj("argv0", 5), NULL, Tcl_NewStringObj(args[1].c_str(), args[1].size()), 0);
|
||||
if (Tcl_EvalFile(interp, args[1].c_str()) != TCL_OK)
|
||||
log_cmd_error("SDC interpreter returned an error: %s\n", Tcl_GetStringResult(interp));
|
||||
Tcl_Release(interp);
|
||||
}
|
||||
} SdcPass;
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(__CYGWIN__)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue