### Start the Python Server Source: https://unihd-cag.github.io/skillbridge/_sources/usage/server.rst.txt Examples of starting the server with various keyword arguments to configure logging, server ID, timeouts, and interpreter paths. ```lisp ; only change the log level to "INFO" pyStartServer ?logLevel "INFO" ; only change the server id to "foo" pyStartServer ?id "foo" ; change both server id and log level pyStartServer ?id "foo" ?logLevel "INFO" ; same as above, the order does not matter pyStartServer ?logLevel "INFO" ?id "foo" ; this tells the server to wait at most 10.5 seconds ; before sending a timeout error pyStartServer ?timeout 10.5 ; use a custom interpreter path pyStartServer ?python "python3.6" ``` -------------------------------- ### Install SkillBridge from Source Source: https://unihd-cag.github.io/skillbridge/_sources/usage/installation.rst.txt Follow these steps to clone the repository, navigate to the directory, and install SkillBridge in editable mode. ```sh git clone *this repo* ``` ```sh cd skillbridge ``` ```sh pip install -e . ``` -------------------------------- ### Install Skillbridge from Source Source: https://unihd-cag.github.io/skillbridge/usage/installation.html Follow these steps to clone the repository and install Skillbridge in editable mode for development. ```bash git clone _this repo_ cd skillbridge pip install -e . ``` -------------------------------- ### Start the Skillbridge Server in Virtuoso Source: https://unihd-cag.github.io/skillbridge/_sources/usage/quickstart.rst.txt Load the IPC script and start the server within the Virtuoso Skill console. ```lisp load("PATH-TO-SKILL-IPC-SCRIPT") pyStartServer ``` -------------------------------- ### Start the Skillbridge Server Source: https://unihd-cag.github.io/skillbridge/usage/quickstart.html Commands to load the IPC script and start the server within the Virtuoso Skill console. ```skill load("PATH-TO-SKILL-IPC-SCRIPT") pyStartServer ``` ```shell skillbridge path ``` -------------------------------- ### Start Virtuoso Instance 1 (Default ID) Source: https://unihd-cag.github.io/skillbridge/_sources/examples/multiple-instances.rst.txt Use this to start the Virtuoso server with its default identifier. Ensure the IPC server path is correctly set. ```lisp ; This starts the server with the default id load("PATH-TO-IPC-SERVER") pyStartServer ``` -------------------------------- ### Start Virtuoso Instance 2 (Custom ID) Source: https://unihd-cag.github.io/skillbridge/_sources/examples/multiple-instances.rst.txt Starts a Virtuoso server with a custom identifier. This allows for multiple independent server instances. ```lisp ; This starts the server with a custom id load("PATH-TO-IPC-SERVER") pyStartServer "some-id" ``` -------------------------------- ### pyStartServer Source: https://unihd-cag.github.io/skillbridge/_sources/usage/server.rst.txt Starts the Python server process with configurable parameters for logging, concurrency, and timeouts. ```APIDOC ## pyStartServer ### Description Starts the python server. If you are only running a single instance of Virtuoso you can use the default id. For more instances, each server needs its own id. ### Parameters - **id** (string) - Optional - Server identifier, default is "default". - **logLevel** (string) - Optional - Log level (DEBUG, INFO, WARNING, ERROR, FATAL), default is "INFO". - **singleMode** (boolean) - Optional - Disables simultaneous connections if set to true. - **timeout** (number) - Optional - Seconds to wait for Skill code to finish, nil means wait forever. - **python** (string) - Optional - Path to the python interpreter, default is "python". - **forceTcp** (boolean) - Optional - Enables server-side use of TCP sockets in UNIX systems. ``` -------------------------------- ### Install Skillbridge via PyPI Source: https://unihd-cag.github.io/skillbridge/usage/installation.html Use this command to install the latest stable version of Skillbridge from the Python Package Index. ```bash pip install skillbridge ``` -------------------------------- ### Generate Completion Stubs Source: https://unihd-cag.github.io/skillbridge/_sources/usage/quickstart.rst.txt Create static completion stubs for IDE support after starting the server. ```sh skillbridge generate ``` -------------------------------- ### Install SkillBridge via PyPI Source: https://unihd-cag.github.io/skillbridge/_sources/usage/installation.rst.txt Use this command to install the SkillBridge package using pip from the Python Package Index. ```sh pip install skillbridge ``` -------------------------------- ### Start Virtuoso Server with Default ID Source: https://unihd-cag.github.io/skillbridge/examples/multiple-instances.html Use this command to start a Virtuoso server with its default identifier. Ensure the 'PATH-TO-IPC-SERVER' is correctly set. ```virtuoso ; This starts the server with the default id load("PATH-TO-IPC-SERVER") pyStartServer ``` -------------------------------- ### Start Python Server Source: https://unihd-cag.github.io/skillbridge/usage/server.html Starts the Python server process. Allows configuration of server ID, log level, single connection mode, timeout, Python interpreter path, and TCP socket usage. ```APIDOC ## pyStartServer ### Description Starts the python server. Allows configuration of server ID, log level, single connection mode, timeout, Python interpreter path, and TCP socket usage. ### Method Skill Console Command ### Endpoint N/A ### Parameters #### Keyword Parameters - **_id** (string) - Optional - A unique identifier for the server instance. Defaults to "default". - **logLevel** (string) - Optional - Sets the logging verbosity. Options: "DEBUG", "INFO", "WARNING", "ERROR", "FATAL". Defaults to "INFO". - **singleMode** (boolean) - Optional - Disables simultaneous connections to the server. Defaults to nil (multiple connections allowed). - **timeout** (number) - Optional - Maximum time in seconds the server waits for Skill code to finish. Defaults to nil (wait forever). - **python** (string) - Optional - Path to the Python interpreter. Defaults to "python". Requires python>=3.6. - **_forceTcp** (boolean) - Optional - Enables server-side TCP sockets on UNIX systems. Defaults to nil. ### Request Example ```skill pyStartServer ?id "foo" ?logLevel "INFO" pyStartServer ?timeout 10.5 pyStartServer ?python "python3.6" ``` ### Response #### Success Response (200) Server started successfully. #### Response Example (No specific response example provided, indicates successful execution) ``` -------------------------------- ### Skill Script IPC Answer Examples Source: https://unihd-cag.github.io/skillbridge/_sources/reference/protocol.rst.txt Examples of status and result strings returned by the skill script to the python server. ```lisp "success 1\n" ``` ```lisp "success (1 2 3)\n" ``` ```lisp "success db:0x1234\n" ``` ```lisp "failure error ...\n" ``` -------------------------------- ### Skill Script IPC Question Examples Source: https://unihd-cag.github.io/skillbridge/_sources/reference/protocol.rst.txt Examples of executable skill code sent as questions from the python server to the skill script. ```lisp "1 + 2\n" ``` ```lisp "geGetEditCellView()\n" ``` ```lisp "__py_cell = geGetEditCellView()\n" ``` -------------------------------- ### Start Virtuoso Server with Custom ID Source: https://unihd-cag.github.io/skillbridge/examples/multiple-instances.html Initiate a Virtuoso server with a specific custom identifier. Replace 'some-id' with your desired ID. Ensure 'PATH-TO-IPC-SERVER' is correctly specified. ```virtuoso ; This starts the server with a custom id load("PATH-TO-IPC-SERVER") pyStartServer "some-id" ``` -------------------------------- ### Verify SkillBridge Installation Source: https://unihd-cag.github.io/skillbridge/_sources/usage/installation.rst.txt Run this command in your terminal after installation to check if the SkillBridge CLI tool is accessible and to view its help message. ```sh skillbridge ``` -------------------------------- ### Open Workspace and Get Edit Cell View Source: https://unihd-cag.github.io/skillbridge/_sources/examples/basic.rst.txt Opens the Skillbridge workspace and retrieves the currently open edit cell view. Useful for initial setup and accessing the active design. ```python from skillbridge import Workspace ws = Workspace.open() cell_view = ws.ge.get_edit_cell_view() print(dir(cell_view)) print(cell_view.b_box) cell_view = ws.db.open_cell_view("lib", "cell_name", "view_name") ``` -------------------------------- ### Socket Protocol Encoding Examples Source: https://unihd-cag.github.io/skillbridge/_sources/reference/protocol.rst.txt Examples of encoding messages for the socket protocol, where the message length is prefixed as a 10-digit string. ```python >>> encode("1 + 2") b'00000000051 + 2' ``` ```python >>> encode("__py_cell = geGetEditCellView()") b'0000000031__py_cell = geGetEditCellView()' ``` -------------------------------- ### Calculate Instance Statistics and Plot Pie Charts Source: https://unihd-cag.github.io/skillbridge/_sources/examples/inst-statistics.rst.txt Use this Python script within a Skillbridge environment to analyze instance data from a layout view. It calculates the count and total area for each instance type and generates two pie charts for visualization. Ensure Matplotlib is installed. ```python from skillbridge import Workspace from collections import Counter from matplotlib.pyplot import pie,figure,title # Workspace.fix_completion() #use this function for correct tab completion in jupyter-notebook ws = Workspace.open() cv = ws.ge.get_edit_cell_view() def bbox_to_area(b_box): return (b_box[1][0]- b_box[0][0]) * (b_box[1][1] - b_box[0][1]) # Get a tuple of instance cellname and area insts = [(inst.cell_name,bbox_to_area(inst.b_box)) for inst in cv.instances] # Get a dictionary of cell_name and occurences counts = Counter(name for name, _ in insts) # create dictionary of cell_name and area areas = {} for name,area in insts: areas.setdefault(name,0) areas[name] += area # plot the pie chart f = figure(figsize=(12, 12)) sub1 = f.add_subplot(121) sub1.set_title("Number of instances") pie(counts.values(), labels = counts.keys()) sub2.set_title("Accumulated Area of each Cell") pie(areas.values(), labels = areas.keys()) ``` -------------------------------- ### SKILL Table Dictionary-like Access Source: https://unihd-cag.github.io/skillbridge/examples/tables_vectors.html Demonstrates using a SKILL table `t` as a Python dictionary, showing item assignment and retrieval using string keys, integer keys, and Symbol keys. Includes examples of accessing missing keys and converting the table to a Python dictionary. ```python >>> t['x'] = 1 >>> t[2] = 3 >>> t[Symbol('x')] = 4 >>> t['x'] 1 >>> t[2] 3 >>> t[Symbol('x')] 4 >>> t['missing'] Traceback (most recent call last): ... KeyError: 'missing' >>> t.get('missing') None >>> dict(t) {'x': 1, 2: 3, Symbol('x'): 4} ``` -------------------------------- ### Create and Access SKILL Tables Source: https://unihd-cag.github.io/skillbridge/_sources/examples/tables_vectors.rst.txt Demonstrates creating new tables, accessing existing ones, and using default values. ```python t = ws.make_table('MyTable') # translates to makeTable("MyTable") ``` ```python t = ws.__.existing_table ``` ```python t = ws.make_table('MyDefaultTable', None) # translates to makeTable("MyDefaultTable" nil) ``` -------------------------------- ### Initialize Direct Mode Connection Source: https://unihd-cag.github.io/skillbridge/_sources/usage/quickstart.rst.txt Open a workspace without an intermediate server, suitable for direct execution from Virtuoso. ```python from skillbridge import Workspace ws = Workspace.open(direct=True) print("cell view:", ws.ge.get_edit_cell_view()) ``` -------------------------------- ### Call Functions with Keyword Arguments Source: https://unihd-cag.github.io/skillbridge/examples/basic.html Demonstrates mapping Skill key parameters to Python keyword arguments and using the keys helper. ```python >>> ws.le.compute_area_density leComputeAreaDensity( w_windowId l_lppSpec [ ?depth x_depth ] [ ?region l_region ] ) ``` ```python >>> ws.le.compute_area_density(window, llp_spec, depth=some_value, region=some_value) [...] ``` ```python >>> from skillbridge import keys >>> ws._.some_function([keys(x=1, y=1), keys(x=2, y=2]) [...] ``` ```python >>> from skillbridge import Key >>> Key('xyz') Key(xyz) ``` -------------------------------- ### Initialize Workspace and Access Cell View Source: https://unihd-cag.github.io/skillbridge/examples/basic.html Demonstrates opening a workspace and retrieving the current edit cell view. ```python from skillbridge import Workspace ws = Workspace.open() cell_view = ws.ge.get_edit_cell_view() print(dir(cell_view)) print(cell_view.b_box) cell_view = ws.db.open_cell_view("lib", "cell_name", "view_name") ``` ```python cell_view = ws.ge.get_edit_cell_view() ``` -------------------------------- ### Load Skill File Directly Source: https://unihd-cag.github.io/skillbridge/_sources/examples/custom_functions.rst.txt Use the `ws['load']` method to directly load a Skill file into the Virtuoso instance. This requires importing the `Workspace` class and creating an instance. ```python from skillbrige import Workspace ws = Workspace() ws['load']('exmapleFile.il') ``` -------------------------------- ### Create and Manage SKILL Vectors Source: https://unihd-cag.github.io/skillbridge/_sources/examples/tables_vectors.rst.txt Covers vector initialization and the behavior differences between vectors with and without default values. ```python v = ws.make_vector(10) # translates to makeVector(10) ``` ```python v = ws.make_vector(5, 0) # translates to makeVector(5 0) ``` -------------------------------- ### Calling Global SKILL Functions (schCreateWire) Source: https://unihd-cag.github.io/skillbridge/_sources/examples/basic.rst.txt Illustrates calling another global SKILL function, 'schCreateWire', via the Skillbridge workspace. This shows how functions are accessed under their respective prefixes. ```python ws.sch.create_wire(...) ``` -------------------------------- ### Connect to the Skillbridge Server Source: https://unihd-cag.github.io/skillbridge/_sources/usage/quickstart.rst.txt Initialize a workspace connection to the running server. ```python from skillbridge import Workspace ws = Workspace.open() ``` -------------------------------- ### LazyList.foreach usage patterns Source: https://unihd-cag.github.io/skillbridge/examples/lazy_lists.html Demonstrates different ways to use foreach with remote functions, including passing arguments. ```python shapes.foreach(ws.db.delete_object) ``` ```python shapes.foreach(ws.example.move_object, LazyList.arg, [10, 10]) ``` ```python shapes.foreach(ws.example.move_object.lazy(LazyList.arg, [10, 10])) # notice the `lazy` attribute ``` -------------------------------- ### Load the Skill IPC Script Source: https://unihd-cag.github.io/skillbridge/_sources/usage/server.rst.txt Initializes the server script by loading the required Skill file. ```lisp load("PATH-TO-SKILL-IPC-SCRIPT") ``` -------------------------------- ### Creating SKILL Key Symbols Directly Source: https://unihd-cag.github.io/skillbridge/_sources/examples/basic.rst.txt Shows how to directly create SKILL key symbols using the `Key` class, which is the Python equivalent of SKILL's '?key' syntax. ```python from skillbridge import Key Key('xyz') ``` -------------------------------- ### Listing available properties Source: https://unihd-cag.github.io/skillbridge/_sources/reference/remote-object.rst.txt The dir() method lists all available Skill properties, which also enables tab completion in interactive environments like Jupyter. ```python >>> dir(cell) ['DBUPerUU', 'any_inst_count', 'area_boundaries', 'assoc_text_displays', ...] ``` ```python >>> cell. # Shows a dropdown menu containing ['DBUPerUU', 'any_inst_count', ...] ``` ```python >>> cell? # Shows a window containing ['DBUPerUU', 'any_inst_count', ...] ``` -------------------------------- ### Open Default Python Workspace Source: https://unihd-cag.github.io/skillbridge/examples/multiple-instances.html Connect to the default Virtuoso server instance from a Python client. This assumes the server is running with its default ID. ```python ws = Workspace.open() ``` -------------------------------- ### Initialize Skillbridge Workspace Source: https://unihd-cag.github.io/skillbridge/_sources/examples/tables_vectors.rst.txt Establishes a connection to the SKILL workspace required for subsequent operations. ```python from skillbridge import Workspace, Symbol ws = Workspace.open() ``` -------------------------------- ### Assign SKILL variables using var Source: https://unihd-cag.github.io/skillbridge/_sources/examples/globals.rst.txt Shows how to assign SKILL objects to global variables using the .var() method. ```python from skillbridge import Workspace ws = Workspace.open() my_globals = ws.globals('my_globals') # important: use `var` here my_globals.shapes << ws.ge.get_sel_set.var() # length is calculated on SKILL side print(ws['length'](my_globals.shapes)) ``` -------------------------------- ### Calling Global SKILL Functions (dbOpenCellView) Source: https://unihd-cag.github.io/skillbridge/_sources/examples/basic.rst.txt Demonstrates calling a global SKILL function, specifically 'dbOpenCellView', through the Skillbridge workspace object. Functions are grouped by their SKILL prefix (e.g., 'db'). ```python ws.db.open_cell_view("lib", "cell_name", "view_name") # dbOpenCellView ``` -------------------------------- ### Register Function with Type Annotations and Keyword Arguments Source: https://unihd-cag.github.io/skillbridge/examples/custom_functions.html Demonstrates registering a function with required, optional, and keyword arguments, including type annotations. The docstring explains the function's purpose. ```python from typing import Optional @ws.register def myFunction(required, optional: Optional, keyword="someName") -> "someReturnValue": """ A nice doc string, that explains the function """ ``` -------------------------------- ### Generate IDE Completion Stubs Source: https://unihd-cag.github.io/skillbridge/usage/quickstart.html Generates static completion stubs for IDE support. Requires the mypy package. ```shell skillbridge generate ``` ```shell pip install mypy ``` -------------------------------- ### Analyze and Visualize Layout Instances Source: https://unihd-cag.github.io/skillbridge/examples/inst-statistics.html Requires an active Virtuoso cell view. Uses matplotlib to generate pie charts for instance counts and total area per cell. ```python from skillbridge import Workspace from collections import Counter from matplotlib.pyplot import pie,figure,title # Workspace.fix_completion() #use this function for correct tab completion in jupyter-notebook ws = Workspace.open() cv = ws.ge.get_edit_cell_view() def bbox_to_area(b_box): return (b_box[1][0]- b_box[0][0]) * (b_box[1][1] - b_box[0][1]) # Get a tuple of instance cellname and area insts = [(inst.cell_name,bbox_to_area(inst.b_box)) for inst in cv.instances] # Get a dictionary of cell_name and occurences counts = Counter(name for name, _ in insts) # create dictionary of cell_name and area areas = {} for name,area in insts: areas.setdefault(name,0) areas[name] += area # plot the pie chart f = figure(figsize=(12, 12)) sub1 = f.add_subplot(121) sub1.set_title("Number of instances") pie(counts.values(), labels = counts.keys()) sub2.set_title("Accumulated Area of each Cell") pie(areas.values(), labels = areas.keys()) ``` -------------------------------- ### Initial State of SKILL Vector Source: https://unihd-cag.github.io/skillbridge/examples/tables_vectors.html Shows the initial state of a SKILL vector created with `make_vector(10)`. Accessing any index results in an `IndexError`, and converting the vector to a list produces an empty list, indicating that slots must be explicitly filled. ```python >>> len(v) 10 >>> v[0] Traceback (most recent call last): ... IndexError: 0 >>> list(v) [] ``` -------------------------------- ### Calling SKILL Functions with Keyword Arguments Source: https://unihd-cag.github.io/skillbridge/_sources/examples/basic.rst.txt Demonstrates calling SKILL functions that have optional named parameters. These are translated into Python keyword arguments. Use keyword arguments only when the SKILL function has named parameters. ```python ws.le.compute_area_density(window, llp_spec, depth=some_value, region=some_value) ``` -------------------------------- ### Calling SKILL Functions with Lists of Key Arguments Source: https://unihd-cag.github.io/skillbridge/_sources/examples/basic.rst.txt Illustrates how to pass lists of key-value pairs to SKILL functions using the `keys` helper function. This is for functions that accept multiple key arguments, often structured as lists of lists in SKILL. ```python from skillbridge import keys ws._.some_function([keys(x=1, y=1), keys(x=2, y=2)]) ``` -------------------------------- ### Connect Python Client 1 Source: https://unihd-cag.github.io/skillbridge/_sources/examples/multiple-instances.rst.txt Connects a Python client to the default Virtuoso server instance. No specific ID is required. ```python ws = Workspace.open() ``` -------------------------------- ### Connect Python Client 2 (Custom ID) Source: https://unihd-cag.github.io/skillbridge/_sources/examples/multiple-instances.rst.txt Connects a Python client to a specific Virtuoso server instance using a custom ID. Ensure the ID matches the server's custom ID. ```python ws = Workspace.open('some-id') ``` -------------------------------- ### Populating SKILL Vector Slots Source: https://unihd-cag.github.io/skillbridge/examples/tables_vectors.html Demonstrates how to fill the slots of a SKILL vector. Assigning values to indices like `v[0] = 1` makes those elements accessible and appear when the vector is converted to a list. ```python >>> v[0] = 1 >>> v[2] = 3 >>> list(v) [1] >>> v[1] = 2 >>> list(v) [1, 2, 3] ``` -------------------------------- ### Create a SKILL Vector Source: https://unihd-cag.github.io/skillbridge/examples/tables_vectors.html Creates a SKILL vector with a fixed length of 10. Initially, accessing elements will raise an `IndexError` and converting to a list yields an empty list. ```python v = ws.make_vector(10) # translates to makeVector(10) ``` -------------------------------- ### Call Global Skill Functions Source: https://unihd-cag.github.io/skillbridge/examples/basic.html Illustrates calling Skill functions grouped by their prefix within the workspace. ```python >>> ws.db.open_cell_view("lib", "cell_name", "view_name") # dbOpenCellView ``` ```python >>> ws.sch.create_wire(...) # schCreateWire [] ``` -------------------------------- ### Naive list iteration in Python Source: https://unihd-cag.github.io/skillbridge/_sources/examples/lazy_lists.rst.txt This approach triggers a SKILL command for every attribute access and function call within the loop. ```python cv = ws.ge.get_edit_cell_view() for shape in cv.shapes: if shape.layer == 'M1': ws.db.delete_object(shape) ``` -------------------------------- ### Call Remote Methods Source: https://unihd-cag.github.io/skillbridge/examples/basic.html Shows how to invoke functions that accept a remote object as the first argument as methods. ```python >>> ws.db.full_path dbFullPath( d_cellView ) ``` ```python >>> cell_view.db_full_path() # not the '_' instead of '.' # same output as ws.db.full_path(cell_view) ``` -------------------------------- ### Access and manipulate global variables Source: https://unihd-cag.github.io/skillbridge/_sources/examples/globals.rst.txt Demonstrates basic assignment and retrieval of global variables between Python and SKILL. ```python from skillbridge import Workspace ws = Workspace.open() my_globals = ws.globals('my_globals') # assign a value from python my_globals.x << 2 my_globals.y << 3 # read variable on python side print(my_globals.x() + my_globals.y()) # use variable on SKILL side print(ws['plus'](my_globals.x, my_globals.y)) ``` -------------------------------- ### Create SKILL Table with Default Value Source: https://unihd-cag.github.io/skillbridge/examples/tables_vectors.html Creates a new SKILL table named 'MyDefaultTable' with a default value of `None`. This means accessing a non-existent key will return `None`. ```python t = ws.make_table('MyDefaultTable', None) ``` -------------------------------- ### Calling SKILL Functions as Methods Source: https://unihd-cag.github.io/skillbridge/_sources/examples/basic.rst.txt Demonstrates how SKILL functions that take a remote object as their first argument can be called as methods directly on that object in Python. The method name includes the SKILL function's prefix to avoid collisions. ```python cell_view.db_full_path() ``` -------------------------------- ### Open Python Workspace with Custom ID Source: https://unihd-cag.github.io/skillbridge/examples/multiple-instances.html Establish a connection to a Virtuoso server instance using a custom identifier. This is necessary when multiple Virtuoso servers are running. ```python ws = Workspace.open('some-id') ``` -------------------------------- ### Create a New SKILL Table Source: https://unihd-cag.github.io/skillbridge/examples/tables_vectors.html Creates a new SKILL table named 'MyTable'. This is equivalent to calling `makeTable("MyTable")` in SKILL. ```python t = ws.make_table('MyTable') ``` -------------------------------- ### Inspecting Available Properties of a Cell View Source: https://unihd-cag.github.io/skillbridge/_sources/examples/basic.rst.txt Lists all available properties for a given cell view object. This is analogous to the SKILL 'cellView->?' command or using tab completion in IPython. ```python dir(cell_view) ``` -------------------------------- ### Load Skill File Directly Source: https://unihd-cag.github.io/skillbridge/examples/custom_functions.html Use the Workspace object to directly call the 'load' function in Skillbridge, typically used for loading Skill files. ```python from skillbrige import Workspace ws = Workspace() ws['load']('exmapleFile.il') ``` -------------------------------- ### Register Function with Argument Types Source: https://unihd-cag.github.io/skillbridge/_sources/examples/custom_functions.rst.txt Demonstrates registering a function with required, optional, and keyword arguments. The `Optional` type annotation is used for optional arguments, and default values define keyword arguments. A return type annotation and docstring are mandatory. ```python from typing import Optional @ws.register def myFunction(required, optional: Optional, keyword="someName") -> "someReturnValue": """ A nice doc string, that explains the function """ ``` -------------------------------- ### Inspect and Read Cell View Properties Source: https://unihd-cag.github.io/skillbridge/examples/basic.html Shows how to list available properties and read specific values from a cell view object. ```python >>> dir(cell_view) ['DBUPerUU', 'any_inst_count', 'area_boundaries', 'assoc_text_displays', 'b_box', ...] ``` ```python >>> print(cell_view.b_box) [[0, 10], [0, 10]] ``` ```python >>> cell_view.bBox [[0, 10], [0, 10]] >>> cell_view.b_box [[0, 10], [0, 10]] ``` -------------------------------- ### Show Server Log Source: https://unihd-cag.github.io/skillbridge/usage/server.html Displays the logging output from the Python server. Allows specifying the number of lines to show. ```APIDOC ## pyShowLog ### Description Shows the logging output from the python server. The `numberOfLines` parameter controls how many of the last lines will be printed. ### Method Skill Console Command ### Endpoint N/A ### Parameters #### Path Parameters - **numberOfLines** (integer) - Optional - The number of last lines to display. Defaults to 10. ### Request Example ```skill pyShowLog pyShowLog 20 ``` ### Response #### Success Response (200) Logging output from the Python server. #### Response Example ``` INFO: Server started successfully. WARNING: Potential performance impact with DEBUG log level. ``` ``` -------------------------------- ### Simple foreach usage Source: https://unihd-cag.github.io/skillbridge/_sources/examples/lazy_lists.rst.txt Applies a function to every item in the list without additional arguments. ```python shapes.foreach(ws.db.delete_object) ``` -------------------------------- ### RemoteObject Comparison Source: https://unihd-cag.github.io/skillbridge/reference/remote-object.html Methods for comparing two RemoteObject instances based on their underlying Skill identifiers. ```APIDOC ## RemoteObject Comparison ### Description Compares two RemoteObject instances to determine equality or inequality based on their Skill identifiers. ### Methods - **__eq__(other)**: Returns True if the Skill identifiers of both objects are equal. - **__ne__(other)**: Returns True if the Skill identifiers of both objects are not equal. ### Usage Example ```python cell = ws.ge.get_edit_cell_view() another = ws.ge.get_edit_cell_view() # Equality check assert cell == another ``` ``` -------------------------------- ### Create Horizontal and Vertical Paths Source: https://unihd-cag.github.io/skillbridge/examples/create_path.html Creates horizontal and vertical paths on Metal2 drawing layer. Requires opening a workspace and a cell view. ```python from skillbridge import Workspace ws = Workspace.open() cv = ws.db.open_cell_view_by_type("LIB", "Cell", "layout", "maskLayout", "a") for n in range(40): ws.rod.create_path(cv_id=cv, layer=["Metal2", "drawing"], width=0.08, pts=[[0.125 * n, 0], [0.125 * n, 5]]) ws.rod.create_path(cv_id=cv, layer=["Metal2", "drawing"], width=0.08, pts=[[0, 0.125 * n], [5, 0.125 * n]]) # Redraw the layout window ws.hi.redraw() ``` -------------------------------- ### pyKillServer Source: https://unihd-cag.github.io/skillbridge/_sources/usage/server.rst.txt Terminates the running Python subprocess. ```APIDOC ## pyKillServer ### Description This terminates the python subprocess and kills the server. Active connections will result in a BrokenPipe exception. ``` -------------------------------- ### Perform mapcar operations with multiple lists Source: https://unihd-cag.github.io/skillbridge/_sources/examples/globals.rst.txt Demonstrates mapping over multiple lists using loop_var_i and loop_var_j. ```python from skillbridge import Workspace, loop_var_i, loop_var_j ws = Workspace.open() my_globals = ws.globals('my_globals') my_globals.x << [1, 2, 3] my_globals.y << [1, 2, 4] my_globals.z << my_globals.x.map(loop_var_i + loop_var_j, j=my_globals.y) print(my_globals.z()) # [2, 4, 7] ``` -------------------------------- ### Retrieve Skillbridge Path Source: https://unihd-cag.github.io/skillbridge/_sources/usage/quickstart.rst.txt Use the command line to find the path to the Skill IPC script. ```sh skillbridge path ``` -------------------------------- ### Comparing RemoteObjects Source: https://unihd-cag.github.io/skillbridge/_sources/reference/remote-object.rst.txt Equality is determined by comparing the underlying Skill identifiers. ```python cell = ws.ge.get_edit_cell_view() # dbobject:0xHHHHHHH another = ws.ge.get_edit_cell_view() # dbobject:0xHHHHHH assert cell == another ``` -------------------------------- ### Use Table Attribute Access Source: https://unihd-cag.github.io/skillbridge/_sources/examples/tables_vectors.rst.txt Shows how attribute access serves as an alias for item access using Symbol keys. ```python t = ws.make_table('Table') t.snake_case = 10 print(t[Symbol('snakeCase')]) # prints 10 t[Symbol('snakeCase')] = 20 print(t.snake_case) # prints 20 ``` -------------------------------- ### Execute Python Scripts from Virtuoso Source: https://unihd-cag.github.io/skillbridge/_sources/usage/quickstart.rst.txt Run Python scripts directly from the CIW with optional arguments or custom executables. ```lisp pyRunScript "pathToScript.py" ``` ```lisp pyRunScript "pathToScript.py" ?python "python3.9" ``` ```lisp pyRunScript "pathToScript.py" ?args list("first" "second" "third") ``` -------------------------------- ### Anti-pattern for LazyList iteration Source: https://unihd-cag.github.io/skillbridge/_sources/examples/lazy_lists.rst.txt Avoid C-style index-based loops, as they result in quadratic time complexity due to repeated remote access. ```python for i in range(len(shapes)): print(shapes[i]) # very slow ``` -------------------------------- ### SKILL Vector with Default Value Behavior Source: https://unihd-cag.github.io/skillbridge/examples/tables_vectors.html Illustrates the behavior of a SKILL vector initialized with a default value. Converting to a list shows all elements initialized to the default (0). Accessing `v[0]` returns the default value, and assigning a new value updates the list. ```python >>> list(v) [0, 0, 0, 0, 0] >>> v[0] 0 >>> v[0] = 10 >>> list(v) [10, 0, 0, 0, 0] ``` -------------------------------- ### Run Scripts from CIW Source: https://unihd-cag.github.io/skillbridge/usage/quickstart.html Commands to execute Python scripts from the Virtuoso CIW, including options for custom executables, arguments, and blocking execution. ```skill pyRunScript "pathToScript.py" ``` ```skill pyRunScript "pathToScript.py" ?python "python3.9" ``` ```skill pyRunScript "pathToScript.py" ?args list("first" "second" "third") ``` ```skill pyRunScript "pathToScript.py" ?block t ``` -------------------------------- ### Show Server Logs Source: https://unihd-cag.github.io/skillbridge/_sources/usage/server.rst.txt Displays the most recent lines from the Python server log for debugging purposes. ```lisp ; show the last 10 lines of the log file pyShowLog ; show the last 20 lines of the log file pyShowLog 20 ``` -------------------------------- ### Accessing Global Variables Source: https://unihd-cag.github.io/skillbridge/_sources/examples/basic.rst.txt Shows how to access global SKILL variables through the Skillbridge workspace object using the '__' prefix, such as accessing standard output. ```python ws.__.stdout ``` -------------------------------- ### Create SKILL Vector with Default Value Source: https://unihd-cag.github.io/skillbridge/examples/tables_vectors.html Creates a SKILL vector of length 5, initialized with a default value of 0 for all elements. This allows direct access to elements and provides a default value for any unassigned slots. ```python v = ws.make_vector(5, 0) # translates to makeVector(5 0) ``` -------------------------------- ### pyReloadScript Source: https://unihd-cag.github.io/skillbridge/_sources/usage/server.rst.txt Restarts the server by killing the process and reloading the script. ```APIDOC ## pyReloadScript ### Description This calls pyKillServer and reloads the python_server.il Skill script. ``` -------------------------------- ### Remote Objects - RemoteObject Source: https://unihd-cag.github.io/skillbridge/reference/index.html Documentation for the `RemoteObject` class and its methods, used for interacting with remote objects. ```APIDOC ## Remote Objects - `RemoteObject` ### Description The `RemoteObject` class provides an interface for interacting with objects that reside in a different process or system. It allows for attribute access and modification as if the object were local. ### Methods - **`RemoteObject.__getattr__()`**: Retrieves an attribute from the remote object. - **`RemoteObject.__setattr__()`**: Sets an attribute on the remote object. - **`RemoteObject.__dir__()`**: Returns a list of attributes for the remote object. - **`RemoteObject.__eq__()`**: Compares the remote object for equality with another object. - **`RemoteObject.__ne__()`**: Compares the remote object for inequality with another object. ``` -------------------------------- ### Reading the Bounding Box Property Source: https://unihd-cag.github.io/skillbridge/_sources/examples/basic.rst.txt Reads and prints the bounding box property of a cell view. Demonstrates accessing properties using dot notation, which maps to SKILL's arrow notation (e.g., cellView->bBox). ```python print(cell_view.b_box) ``` -------------------------------- ### Compare Remote Objects for Inequality Source: https://unihd-cag.github.io/skillbridge/reference/remote-object.html Compare two RemoteObject instances for inequality. This is the logical opposite of the equality comparison. ```python # Python-Skill Bridge ### Navigation Contents: * Usage * Examples * Reference * Communication Protocol * Remote Objects ### Related Topics * Documentation overview * Reference * Previous: Communication Protocol ``` -------------------------------- ### Call a Defined Skill Function Directly Source: https://unihd-cag.github.io/skillbridge/examples/custom_functions.html Call a pre-defined Skill function directly using the Workspace object. This requires the function to be already defined in your Virtuoso instance. ```python from skillbrige import Workspace ws = Workspace() ws['myFunction_def'](...) ``` -------------------------------- ### Simulate Direct Mode via Pipe Source: https://unihd-cag.github.io/skillbridge/usage/quickstart.html Simulates the non-TTY stdin condition required for direct mode. ```shell echo 1234 | python file.py ``` -------------------------------- ### Register Function with Prefix Method Source: https://unihd-cag.github.io/skillbridge/_sources/examples/custom_functions.rst.txt Use the `@ws.register` decorator to register a Python function. Ensure a return type annotation and a docstring are provided. The function name can be in camelCase or snake_case. ```python @ws.register def dbCheck(d_cellview) -> None: """ A docstring """ ``` -------------------------------- ### Communication Protocol - Full Roundtrip Source: https://unihd-cag.github.io/skillbridge/reference/index.html Explains the concept of a full roundtrip in the context of SkillBridge communication protocols. ```APIDOC ## Communication Protocol - A Full Roundtrip ### Description This section elaborates on what constitutes a 'Full Roundtrip' in the context of SkillBridge's communication protocols. It likely describes the complete sequence of operations from sending a request to receiving a final response. ``` -------------------------------- ### Server Management API Source: https://unihd-cag.github.io/skillbridge/usage/index.html Functions to manage the lifecycle and status of the Python-Skill Bridge server. ```APIDOC ## pyStartServer() ### Description Starts the Python-Skill Bridge server instance. ## pyKillServer() ### Description Terminates the currently running Python-Skill Bridge server instance. ## pyReloadScript() ### Description Reloads the script configuration or environment without restarting the entire server process. ## pyShowLog() ### Description Displays the current server logs for debugging and monitoring purposes. ``` -------------------------------- ### Handling boolean properties Source: https://unihd-cag.github.io/skillbridge/_sources/reference/remote-object.rst.txt New boolean properties created on the Skill side may return string representations instead of native Python booleans. ```python >>> cell.new_bool_property = True >>> cell.new_bool_property "TRUE" # instead of t ``` ```python >>> cell.new_bool_property = False >>> cell.new_bool_property "FALSE" # instead of nil ``` -------------------------------- ### pyShowLog Source: https://unihd-cag.github.io/skillbridge/_sources/usage/server.rst.txt Displays the recent log output from the Python server for debugging purposes. ```APIDOC ## pyShowLog ### Description Used for debugging. This shows the logging output from the python server. ### Parameters - **numberOfLines** (integer) - Optional - Number of lines to print from the end of the log, default is 10. ``` -------------------------------- ### Check and Save Schematic Cell Views in a Library Source: https://unihd-cag.github.io/skillbridge/_sources/examples/lib_save.rst.txt Iterates through a specified list of libraries to check and save all schematic cell views. Requires an active skillbridge Workspace connection. ```python from skillbridge import Workspace ws = Workspace.open() libs = ws.dd.get_lib_list() lib_names = [lib.name for lib in libs] # create whitelist lib_list = ["LIB0", "LIB1", "LIB2"] for lib_name in lib_names: if lib_name in lib_list: lib = ws.dd.get_obj(lib_name) for cell in lib.cells: # only if schematic view exists if "schematic" in [cell_type.name for cell_type in cell.views]: print("Saved " + cell.name + " !") cv = ws.db.open_cell_view_by_type(lib.name, cell.name, "schematic", "", "a") ws.db.check(cv) ws.db.save(cv) ``` -------------------------------- ### Invoke Virtuoso function objects Source: https://unihd-cag.github.io/skillbridge/examples/funcall.html Call funobj objects directly using Python syntax, which maps to funcall in SKILL. ```python from skillbridge import Workspace ws = Workspace.open() fun = ... # obtain a funobj fun # fun() # SKILL equivalent: funcall(fun) fun(1, 2, 3) # SKILL equivalent: funcall(fun 1 2 3) fun(x=1, y=2, z=3) # SKILL equivalent: funcall(fun ?x 1 ?y 2 ?z 3) ``` -------------------------------- ### Advanced foreach with arguments Source: https://unihd-cag.github.io/skillbridge/_sources/examples/lazy_lists.rst.txt Passes a constant argument alongside the list element to the remote function. ```python shapes.foreach(ws.example.move_object, LazyList.arg, [10, 10]) ``` ```python shapes.foreach(ws.example.move_object.lazy(LazyList.arg, [10, 10])) # notice the `lazy` attribute ``` -------------------------------- ### Register Function with Prefix Method Source: https://unihd-cag.github.io/skillbridge/examples/custom_functions.html Use the `@ws.register` decorator to register a Python function with a prefix. Ensure a return type annotation and a docstring are provided. The function name can be in snake_case. ```python @ws.register def dbCheck(d_cellview) -> None: """ A docstring """ ``` -------------------------------- ### Efficient filtering with LazyList Source: https://unihd-cag.github.io/skillbridge/_sources/examples/lazy_lists.rst.txt Combine multiple filter criteria into a single call to avoid redundant SKILL command overhead. ```python shapes.filter(layer='M1', purpose='...') # better shapes.filter(layer='M1').filter(purpose='...') # worse ``` -------------------------------- ### Access an Existing SKILL Table Source: https://unihd-cag.github.io/skillbridge/examples/tables_vectors.html Accesses an existing SKILL table, typically one that is globally available in the SKILL environment. The variable `t` will then behave like a Python dictionary. ```python t = ws.__.existing_table ``` -------------------------------- ### SKILL Table Default Value Evaluation Warning Source: https://unihd-cag.github.io/skillbridge/examples/tables_vectors.html Illustrates that the default value for a SKILL table is evaluated on the SKILL side. Passing an empty list `[]` results in `None` on the SKILL side, which is then returned when accessing a missing key. ```python >>> ws.make_table('nil', [])['missing'] # translates to makeTable("nil" nil) None ``` -------------------------------- ### RemoteObject Class Source: https://unihd-cag.github.io/skillbridge/_sources/reference/remote-object.rst.txt Represents any object in Skill that is not a basic type (int, float, str, bool, list, nil). ```APIDOC ## RemoteObject Class ### Description Instances of `RemoteObject` represent any object in Skill that is neither of the following types: `int`, `float`, `str`, `bool`, `list`, `nil`. ### Methods #### `__getattr__` Skill properties can be accessed like normal Python attributes, provided the property exists on the Skill object. ```python cell = ws.ge.get_edit_cell_view() # [[0, 10], [0, 10]] cell.cell_view # ``` Properties of Skill objects can again be `RemoteObject` instances. #### `__setattr__` It is also possible to change the Skill properties using normal Python attribute access. If the property does not exist on the Skill side, it will be created. ```python cell.x = 123 cell.x # 123 ``` **Note:** Changes to lists are not synchronized with the Skill side at the moment. ```python cell.data = [1, 2, 3] cell.data.append(4) cell.data # [1, 2, 3] # To work around this, you must manually assign the list back to the object data = cell.data data.append(4) cell.data = data cell.data # [1, 2, 3, 4] ``` **Warning:** Creating new boolean properties on the Skill side shows strange behavior. ```python cell.new_bool_property = True cell.new_bool_property # "TRUE" # instead of True cell.new_bool_property = False cell.new_bool_property # "FALSE" # instead of nil ``` #### `__dir__` All available Skill properties can be listed using this method. It looks up the properties inside Skill using the expression `__var -> ?` and returns the property names as a list. ```python dir(cell) # ['DBUPerUU', 'any_inst_count', 'area_boundaries', 'assoc_text_displays', ...] ``` Inside Jupyter/IPython, this method is used to provide tab completion. ```python cell. # Shows a dropdown menu containing ['DBUPerUU', 'any_inst_count', ...] cell? # Shows a window containing ['DBUPerUU', 'any_inst_count', ...] ``` #### `__eq__` Compares two `RemoteObject` instances and returns whether they are considered equal. They are considered equal if their Skill identifiers are equal. ```python cell = ws.ge.get_edit_cell_view() # dbobject:0xHHHHHHH another = ws.ge.get_edit_cell_view() # dbobject:0xHHHHHH assert cell == another ``` #### `__ne__` Compares two `RemoteObject` instances and returns whether they are considered unequal. This is the opposite of the `__eq__` method. ``` -------------------------------- ### Access Missing Key in Table with Default Value Source: https://unihd-cag.github.io/skillbridge/examples/tables_vectors.html Retrieves a missing key from a SKILL table that was initialized with a default value. The output is `None` as expected. ```python >>> t['missing'] None ``` -------------------------------- ### SkillBridge RemoteObject Methods Source: https://unihd-cag.github.io/skillbridge/genindex.html This section details the methods available for the RemoteObject class, used for interacting with remote objects. ```APIDOC ## RemoteObject Methods ### Description Methods for the `RemoteObject` class in `skillbridge.client.objects`. ### Methods - **__dir__()**: Returns a list of attributes for the object. - **__eq__(other)**: Checks for equality with another object. - **__getattr__(name)**: Gets an attribute from the object. - **__ne__(other)**: Checks for inequality with another object. - **__setattr__(name, value)**: Sets an attribute on the object. ``` -------------------------------- ### Set Skillbridge Log Directory in CIW Source: https://unihd-cag.github.io/skillbridge/_sources/usage/logging.rst.txt Use this command within the CIW to set the SKILLBRIDGE_LOG_DIRECTORY environment variable before loading the server script. Ensure the path does not include a trailing slash. ```lisp setShellEnvVar("SKILLBRIDGE_LOG_DIRECTORY" "some/valid/path/here") load(...) ``` -------------------------------- ### Passing Quoted Symbols to SKILL Functions Source: https://unihd-cag.github.io/skillbridge/_sources/examples/basic.rst.txt Shows how to pass quoted symbols, like 'someSymbol' in SKILL, to Python functions using the Symbol wrapper class. This is necessary for functions expecting symbolic arguments. ```python from skillbridge import Symbol ws.ns.some_function(Symbol('someSymbol')) ``` -------------------------------- ### Access Global Variables Source: https://unihd-cag.github.io/skillbridge/examples/basic.html Access global Skill variables using the double underscore prefix. ```python >>> ws.__.stdout ``` -------------------------------- ### Block Execution until Script Completion Source: https://unihd-cag.github.io/skillbridge/_sources/usage/quickstart.rst.txt Force the Skill process to wait for the Python script to finish execution. ```lisp pyRunScript "pathToScript.py" ?block t ``` -------------------------------- ### Accessing Skill properties as attributes Source: https://unihd-cag.github.io/skillbridge/_sources/reference/remote-object.rst.txt Skill properties are accessed using standard Python attribute syntax. Properties may return further RemoteObject instances. ```python >>> cell = ws.ge.get_edit_cell_view() [[0, 10], [0, 10]] ``` ```python >>> cell.cell_view ``` -------------------------------- ### Use higher-order functions with global variables Source: https://unihd-cag.github.io/skillbridge/_sources/examples/globals.rst.txt Utilizes map, filter, and for_each operations on global variables using loop_var. ```python from skillbridge import Workspace, loop_var ws = Workspace.open() my_globals = ws.globals('my_globals') my_globals.shapes << ws.ge.get_sel_set.var() # get the boxes my_globals.boxes << my_globals.shapes.map(loop_var.b_box) # filter rectangles my_globals.rects << my_globals.shapes.filter(loop_var.obj_type == 'rect') # delete all shapes my_globals.shapes.for_each(ws.db.delete_object.var(loop_var)) ``` -------------------------------- ### Modifying Skill properties Source: https://unihd-cag.github.io/skillbridge/_sources/reference/remote-object.rst.txt Properties can be set via attribute assignment. Note that list modifications are not automatically synchronized and require manual reassignment. ```python >>> cell.x = 123 >>> cell.x 123 ``` ```python >>> cell.data = [1, 2, 3] >>> cell.data.append(4) >>> cell.data [1, 2, 3] ``` ```python >>> data = cell.data >>> data.append(4) >>> cell.data = data >>> cell.data [1, 2, 3, 4] ``` -------------------------------- ### Handle List Modifications Source: https://unihd-cag.github.io/skillbridge/reference/remote-object.html Directly appending to lists synchronized with Skill is not supported. Manually reassign the list to the object after modification to synchronize changes. ```python >>> cell.data = [1, 2, 3] >>> cell.data.append(4) >>> cell.data [1, 2, 3] ``` ```python >>> data = cell.data >>> data.append(4) >>> cell.data = data >>> cell.data [1, 2, 3, 4] ```