How to quickly learn scripting languages for ASIC design interviews?

In ASIC design and implementation flows, Tcl and Python are the 2 most widely used scripting languages:

  • A wide variety of EDA tools like Synopsys Design Compiler and PrimeTime, use Tcl based syntax
  • Design engineers often use Python to automate the top-level module connectivity, and CAD engineers often use Python to implement the CAD flow

Therefore, it is important to master these 2 scripting languages for ASIC design interview preparation. We recommend the following 2 books if you want to learn Tcl and Python thoroughly:

https://amzn.to/3UaTHw1

However, for the sake of ASIC design interview preparation, we do not need to go over all chapters. Instead, we only need to focus on the following aspects.

Syntax

First, we need to understand how to create and use variables. For scripting languages, variable declaration is generally not needed. This rule applies to Tcl and Python as well. Once a new variable name is encountered, Tcl and Python will create a new variable. To reference / use an existing variable, Tcl appends “$” before the variable name, while Python simply references the variable name.

Second, we should know the basic flow control for Tcl and Python, namely, if statements and for loops. For Tcl, refer to this page and this page; for Python, refer to this page and this page.

Next, it is important to handle files properly, as design engineers often need to import data from some other files and process it using scripts. For Tcl, refer to this page; for Python, refer to this page.

It is worth pointing out that Python 2 and Python 3 have some differences in syntax. As Python 2 has gradually been deprecated, one may use the automatic conversion tool introduced in this page, to convert the legacy Python 2 program to Python 3.

Basic Data Structure

For 1-D data structure, use Tcl list and Python lists. For 2-D data structure or matrix, use nested lists.
For Hash Map or Hash Table, use Tcl associative array and Python dictionary.

Procedures / Functions

Procedures / Functions are blocks of reusable and organized code that perform a single, related action. Tcl uses the term “Procedure”, while Python uses the term “Function”. For Tcl, refer to this page. For Python, refer to this page.

In addition, Python has defined quite a few built-in functions, for common operations like getting absolute values and getting variable types. We should leverage these built-in functions, such that we do not necessarily reinvent the wheels.

Regular Expression

A regular expression is a pattern that the regular expression engine attempts to match in input text, and it is super useful in text and data processing.

Tcl uses “regexp” to match a regular expression against a string, while Python uses “re”.
In terms of how to write regular expressions and specify a pattern, refer to this page for Tcl and refer to this page for Python.

There is an interesting online regular expression debug tool, that we encourage everyone to try. Refer to this link for more details.

Subscribe

Enter your email to get updates from us. You might need to check the spam folder for the confirmation email.

Leave a comment