Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/interface/tcl/tcl_ista/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
add_library(tcl_ista
${HOME_INTERFACE}/tcl/tcl_ista/src/tcl_init_sta.cpp
${HOME_INTERFACE}/tcl/tcl_ista/src/tcl_run_sta.cpp
${HOME_INTERFACE}/tcl/tcl_ista/src/tcl_remove_wire_load_model.cpp
${HOME_INTERFACE}/tcl/tcl_ista/src/tcl_update_timing.cpp
${HOME_INTERFACE}/tcl/tcl_ista/src/tcl_write_sdf.cpp
${HOME_INTERFACE}/tcl/tcl_ista/src/tcl_report_timing.cpp
${HOME_INTERFACE}/tcl/tcl_ista/src/tcl_create_clock.cpp
${HOME_INTERFACE}/tcl/tcl_ista/src/tcl_set_propagated_clock.cpp
${HOME_INTERFACE}/tcl/tcl_ista/src/tcl_get_clocks.cpp
${HOME_INTERFACE}/tcl/tcl_ista/src/tcl_get_ports.cpp
${HOME_INTERFACE}/tcl/tcl_ista/src/tcl_extract_lib.cpp
${HOME_INTERFACE}/tcl/tcl_ista/src/tcl_destroy_sta.cpp
)
Expand Down
48 changes: 48 additions & 0 deletions src/interface/tcl/tcl_ista/include/tcl_ista_util.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ***************************************************************************************
// Copyright (c) 2023-2025 Peng Cheng Laboratory
// Copyright (c) 2023-2025 Institute of Computing Technology, Chinese Academy of Sciences
// Copyright (c) 2023-2025 Beijing Institute of Open Source Chip
//
// iEDA is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
// http://license.coscl.org.cn/MulanPSL2
//
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
//
// See the Mulan PSL v2 for more details.
// ***************************************************************************************
#pragma once

#include "tcl_util.h"

namespace {

void setResult(const std::string& result)
{
Tcl_Interp* _interp{tcl::ScriptEngine::getOrCreateInstance()->get_interp()};
auto* buffer = new char[result.size() + 1];
std::strcpy(buffer, result.c_str());
Tcl_SetResult(_interp, buffer, [](auto* buffer) {
delete[] buffer;
});
}

void setResult(const std::vector<std::string>& result)
{
Tcl_Obj* list_obj{Tcl_NewListObj(0, nullptr)};
Tcl_Interp* _interp{tcl::ScriptEngine::getOrCreateInstance()->get_interp()};
for (const std::string& value : result) {
Tcl_ListObjAppendElement(_interp, list_obj, Tcl_NewStringObj(value.c_str(), static_cast<int>(value.size())));
}
Tcl_SetObjResult(_interp, list_obj);
}

void setTclError(const std::string& message)
{
setResult(message);
}

} // namespace
8 changes: 8 additions & 0 deletions src/interface/tcl/tcl_ista/include/tcl_register_ista.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ int registerCmdSTA()
// sta
registerTclCmd(TclInitSTA, "init_sta");
registerTclCmd(TclRunSTA, "run_sta");
registerTclCmd(TclRemoveWireLoadModel, "remove_wire_load_model");
registerTclCmd(TclUpdateTiming, "update_timing");
registerTclCmd(TclWriteSDF, "write_sdf");
registerTclCmd(TclReportTiming, "report_timing");
registerTclCmd(TclCreateClock, "create_clock");
registerTclCmd(TclSetPropagatedClock, "set_propagated_clock");
registerTclCmd(TclGetPorts, "get_ports");
registerTclCmd(TclGetClocks, "get_clocks");
registerTclCmd(TclExtractLib, "extract_lib");
registerTclCmd(TclDestroySTA, "destroy_sta");
return EXIT_SUCCESS;
Expand Down
88 changes: 84 additions & 4 deletions src/interface/tcl/tcl_ista/include/tcl_sta.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TclInitSTA : public TclCmd
explicit TclInitSTA(const char* cmd_name);
~TclInitSTA() override = default;

unsigned check() override { return 1; };
unsigned check() override { return 1; }

unsigned exec() override;

Expand All @@ -42,21 +42,101 @@ class TclRunSTA : public TclCmd
explicit TclRunSTA(const char* cmd_name);
~TclRunSTA() override = default;

unsigned check() override { return 1; };
unsigned check() override { return 1; }

unsigned exec() override;

private:
std::vector<std::pair<std::string, ValueType>> _config_list;
};

class TclRemoveWireLoadModel : public TclCmd
{
public:
explicit TclRemoveWireLoadModel(const char* cmd_name);
~TclRemoveWireLoadModel() override = default;

unsigned check() override { return 1; }
unsigned exec() override;
};

class TclUpdateTiming : public TclCmd
{
public:
explicit TclUpdateTiming(const char* cmd_name);
~TclUpdateTiming() override = default;

unsigned check() override { return 1; }
unsigned exec() override;
};

class TclWriteSDF : public TclCmd
{
public:
explicit TclWriteSDF(const char* cmd_name);
~TclWriteSDF() override = default;

unsigned check() override { return 1; }
unsigned exec() override;
};

class TclReportTiming : public TclCmd
{
public:
explicit TclReportTiming(const char* cmd_name);
~TclReportTiming() override = default;

unsigned check() override { return 1; }
unsigned exec() override;
};

class TclCreateClock : public TclCmd
{
public:
explicit TclCreateClock(const char* cmd_name);
~TclCreateClock() override = default;

unsigned check() override { return 1; }
unsigned exec() override;
};

class TclSetPropagatedClock : public TclCmd
{
public:
explicit TclSetPropagatedClock(const char* cmd_name);
~TclSetPropagatedClock() override = default;

unsigned check() override { return 1; }
unsigned exec() override;
};

class TclGetPorts : public TclCmd
{
public:
explicit TclGetPorts(const char* cmd_name);
~TclGetPorts() override = default;

unsigned check() override { return 1; }
unsigned exec() override;
};

class TclGetClocks : public TclCmd
{
public:
explicit TclGetClocks(const char* cmd_name);
~TclGetClocks() override = default;

unsigned check() override { return 1; }
unsigned exec() override;
};

class TclExtractLib : public TclCmd
{
public:
explicit TclExtractLib(const char* cmd_name);
~TclExtractLib() override = default;

unsigned check() override { return 1; };
unsigned check() override { return 1; }

unsigned exec() override;

Expand All @@ -70,7 +150,7 @@ class TclDestroySTA : public TclCmd
explicit TclDestroySTA(const char* cmd_name);
~TclDestroySTA() override = default;

unsigned check() override { return 1; };
unsigned check() override { return 1; }

unsigned exec() override;

Expand Down
63 changes: 63 additions & 0 deletions src/interface/tcl/tcl_ista/src/tcl_create_clock.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// ***************************************************************************************
// Copyright (c) 2023-2025 Peng Cheng Laboratory
// Copyright (c) 2023-2025 Institute of Computing Technology, Chinese Academy of Sciences
// Copyright (c) 2023-2025 Beijing Institute of Open Source Chip
//
// iEDA is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
// http://license.coscl.org.cn/MulanPSL2
//
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
//
// See the Mulan PSL v2 for more details.
// ***************************************************************************************
#include "STAInterface.hpp"
#include "tcl_ista_util.hpp"
#include "tcl_sta.h"

namespace tcl {

TclCreateClock::TclCreateClock(const char* cmd_name) : TclCmd(cmd_name)
{
addOption(new TclStringOption("-name", 0));
addOption(new TclDoubleOption("-period", 0));
addOption(new TclDoubleListOption("-waveform", 0));
addOption(new TclStringListOption("objects", 1));
}

unsigned TclCreateClock::exec()
{
TclOption* name_option = getOptionOrArg("-name");
TclOption* period_option = getOptionOrArg("-period");
TclOption* waveform_option = getOptionOrArg("-waveform");
TclOption* object_option = getOptionOrArg("objects");
if (!name_option->is_set_val() || !period_option->is_set_val() || !object_option->is_set_val()) {
setTclError("create_clock requires -name, -period, and a port collection");
return 0;
}

const double period = period_option->getDoubleVal();
double rise_edge = 0.0;
double fall_edge = period / 2.0;
if (waveform_option->is_set_val()) {
const std::vector<double> waveform = waveform_option->getDoubleList();
if (waveform.size() != 2) {
setTclError("create_clock -waveform must contain exactly two values");
return 0;
}
rise_edge = waveform[0];
fall_edge = waveform[1];
}

if (std::string error_message;
!STAI.createClock(name_option->getStringVal(), period, rise_edge, fall_edge, object_option->getStringList(), error_message)) {
setTclError(error_message);
return 0;
}
return 1;
}

} // namespace tcl
44 changes: 44 additions & 0 deletions src/interface/tcl/tcl_ista/src/tcl_get_clocks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ***************************************************************************************
// Copyright (c) 2023-2025 Peng Cheng Laboratory
// Copyright (c) 2023-2025 Institute of Computing Technology, Chinese Academy of Sciences
// Copyright (c) 2023-2025 Beijing Institute of Open Source Chip
//
// iEDA is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
// http://license.coscl.org.cn/MulanPSL2
//
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
//
// See the Mulan PSL v2 for more details.
// ***************************************************************************************
#include "STAInterface.hpp"
#include "tcl_ista_util.hpp"
#include "tcl_sta.h"

namespace tcl {

TclGetClocks::TclGetClocks(const char* cmd_name) : TclCmd(cmd_name)
{
addOption(new TclStringListOption("clocks", 1));
}

unsigned TclGetClocks::exec()
{
TclOption* clock_option = getOptionOrArg("clocks");
if (!clock_option->is_set_val()) {
setTclError("get_clocks requires a clock list");
return 0;
}
std::vector<std::string> resolved_clock_list;
if (std::string error_message; !STAI.getClocks(clock_option->getStringList(), resolved_clock_list, error_message)) {
setTclError(error_message);
return 0;
}
setResult(resolved_clock_list);
return 1;
}

} // namespace tcl
44 changes: 44 additions & 0 deletions src/interface/tcl/tcl_ista/src/tcl_get_ports.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ***************************************************************************************
// Copyright (c) 2023-2025 Peng Cheng Laboratory
// Copyright (c) 2023-2025 Institute of Computing Technology, Chinese Academy of Sciences
// Copyright (c) 2023-2025 Beijing Institute of Open Source Chip
//
// iEDA is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
// http://license.coscl.org.cn/MulanPSL2
//
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
//
// See the Mulan PSL v2 for more details.
// ***************************************************************************************
#include "STAInterface.hpp"
#include "tcl_ista_util.hpp"
#include "tcl_sta.h"

namespace tcl {

TclGetPorts::TclGetPorts(const char* cmd_name) : TclCmd(cmd_name)
{
addOption(new TclStringListOption("ports", 1));
}

unsigned TclGetPorts::exec()
{
TclOption* port_option = getOptionOrArg("ports");
if (!port_option->is_set_val()) {
setTclError("get_ports requires a port list");
return 0;
}
std::vector<std::string> resolved_port_list;
if (std::string error_message; !STAI.getPorts(port_option->getStringList(), resolved_port_list, error_message)) {
setTclError(error_message);
return 0;
}
setResult(resolved_port_list);
return 1;
}

} // namespace tcl
31 changes: 31 additions & 0 deletions src/interface/tcl/tcl_ista/src/tcl_remove_wire_load_model.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// ***************************************************************************************
// Copyright (c) 2023-2025 Peng Cheng Laboratory
// Copyright (c) 2023-2025 Institute of Computing Technology, Chinese Academy of Sciences
// Copyright (c) 2023-2025 Beijing Institute of Open Source Chip
//
// iEDA is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
// http://license.coscl.org.cn/MulanPSL2
//
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
//
// See the Mulan PSL v2 for more details.
// ***************************************************************************************
#include "tcl_sta.h"

namespace tcl {

TclRemoveWireLoadModel::TclRemoveWireLoadModel(const char* cmd_name) : TclCmd(cmd_name)
{
}

unsigned TclRemoveWireLoadModel::exec()
{
// Wire-load models are not modeled by iSTA yet.
return check();
}

} // namespace tcl
Loading
Loading