Skip to content

This is a method for communicating between a Python script and a Tcl-based utility through a socket

Notifications You must be signed in to change notification settings

enics-labs/tclpy

Repository files navigation

TCLPY Description

TCLPY a method of controlling EDA tools with a TCL-based user interface from a remote Python session.

Motivation:

TCL is apparently the standard user interface scripting language for EDA tools for decades. Meanwhile Python has been developed and emerged as a leading generic interactive scripting and data management utility.

Concept:

TCLPY provides the capability for a remote python program to iteratively issue commands to TCL-based multiple utilities, capture response and data that comes out of the tool into a data structure, then manipulate and issue further commands accordingly. As an example the Python program can issue a request provided as a TCL command for Cadence Innovus to dump a timing report, then the Python session parse the report, analyze it, and issue smart ECO commands accordingly.

Implementation:

The TCLPY utility is based on a messaging socket infrastructure over TCP/IP which is essentially acting as a mailbox, The transferred messages are basically tokens or elements that the other side can fetch and interpret. You can send a message from one side and send a response from the other side, messages may be blocking and non blocking, however the most simple communication method is to perform a full handshake per message.

Demo

TCLPY informal presentation and demo recording can be found at https://youtu.be/41oU5Tcz4SQ?si=iRyTgsqR1ITTWsYQ

Reference "Hello World" Example:

This git repository includes a basic reference example and getting started instructions, where the Python session is requesting the EDA tool side running Innovus and telling it what is the date on its side. This simple example, once established, can be easily extended for any type of remote management of a set of multiple tool up to a complete RTL to GDS flow.

Cloning TCLPY reference example

git clone git@gitlab.local:udik/tclpy.git
cd tclpy
  • Note that this example is adapted for the EnICS network setup. You will need to slightly modify it to work in your environment

Open two terminals on same work server

Open the first terminal (the "Python terminal")

xterm & # will open a terminal on a worker server

Open the second terminal (the "TCL terminal") from the xterm you just opened (to ensure that both are on the same server)

# go to the opened terminal
xterm & # will open another terminal on same worker server

SCRIPT EXAMPLE

Open a socket on the "Python terminal"

# At the python terminal (better be first)
python  tclpy_script_example.py  # see example remote access code

Run your EDA tool on the "Tcl terminal"

# At the tcl terminal (innovus tool as an example)
innovus -no_gui -file tclpy_client.tcl 
# The Innovus session prompt is fully remotely controlled

INTERACTIVE EXAMPLE

At the "Python terminal" (better be first)

python 
# at the python prompt
import socket_master_server as sms
sock = sms.set_server_socket(port=5555,host='')  # port 5555 on localhost

At the "Tcl terminal" (innovus tool as an example)

innovus -stylus -no_gui -file tclpy_client.tcl 

Now the innovus session is remotely controlled from the python session from within the Python terminal.

Example of Issuing a request from the python session

print "Requesting remote tcl to execute command: date"
msg_to_socket = "date"
rsp_msg = sms.req_msg(sock,msg_to_socket)
print "Remote tcl response is: %s" % rsp_msg

About

This is a method for communicating between a Python script and a Tcl-based utility through a socket

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published