In DesignWorks Professional for Windows

Version 5 introduces a package of new customization technologies that allow users and OEMs to add a wide variety of functions to the package without using any external tools. The new JavaScript engine, built into the package, allows you to use a standard scripting language to do everything from automating a few commonly used editing steps to adding major new features.

What is JavaScript and Why Use It In DesignWorks?

JavaScript is a standard language widely used for creating interactive applications on the World Wide Web. The language is a scripting language based on Java, which is itself based on C++, so the general format and syntax will be familiar to anyone who has used any of those languages. As a scripting language, JavaScript has much more flexibility than an application programming language. This allows quick development of scripts for a wide variety of small to medium-sized applications.

As implemented in DesignWorks, JavaScript gives access to essentially every program data element and function, as well as access to the web-development facilities such as HTML, links, controls and images. This combination is extremely powerful, allowing quick user development of significant new functionality such as:

  • simple or extensive data display and entry boxes (“property sheets”) to allow users to view and display design data using the full power of HTML, including links to outside resources on the web
  • import and export of any type of design data using the power of a general-purpose programming language
  • new menu commands and functions, such as searching for and updating attribute values, saving and backing up files, creating symbols based on given parameters, organizing and updating libraries, etc.
  • linking design data to local or remote databases or web services
  • creating and connecting circuit and design elements using script facilities

Where are JavaScripts Used?

In DesignWorks, JavaScript code can be used in two different environments:

  • JavaScript can be stored in a standalone text file (with the file extension DWJ) and can be run on command by the user. Scripts can be run by either directly opening the script file and selecting the Run command, or they can be executed in response to custom menu items or started as a result of specific user actions, such as double-clicking on a device on the diagram. When used in this mode, JavaScript has access to all the objects and methods implemented by DesignWorks, but, since it is not running within Internet Explorer, it does not have access to the typical web objects, such as documents and controls.
  • JavaScript can also be used to add functionality to HTML pages that are displayed within DesignWorks. When used in this mode, JavaScript is running inside an instance of Internet Explorer, so it has access to the full range of objects designed for creating web pages, such as HTML structural elements and controls. In addition, scripts can access the objects implemented in DesignWorks.Script ExampleHere is a simple example of automating an editing change to apply a width change to a group of selected signals.
    sigs = currentCircuit.signals(1);   // Get selected signals
    for (i = 0; i < sigs.length; i++) sigs[i].width = 5;  // Apply width change

    You can see that two simple lines of code is all it takes to add a useful new function to the package. If this script was to be used often, you could attach it to a custom menu command so that a simple mouse selection will apply your new function.

    The package includes a number of sample scripts to help you get started, including:

    • ChanChange Library Attributes – runs through a library and updates attribute values in each symbol
    • Create Circuit – creates a circuit by placing elements from a library and wiring them together under script control
    • Create Page Index – creates a text block on the schematic with an index of all the pages in the design
    • Create Symbol – generates the graphics and attributes for a symbol under script control
    • Design Backup – creates a dated backup copy of the current design
    • Design Report – displays a custom panel with design summary information
    • Device Properties – displays an HTML dialog prompting for device data
    • Generate Hierarchical Design Netlist – Generates a netlist with hierarchy blocks written to separate files
    • Generate Segmented Design Netlist – Generates a netlist from a design that has each hierarchy block stored in a separate circuit file.
    • Library Report – generates a text report of information on symbols in a library
    • Open Device Document – locates and opens a documentation file associated with the selected device
    • Remove Custom Menus – updates the program initialization file to remove the sample custom menusThe scope of these examples gives you some idea of the functions that can be added.

Custom Display PanelsDWW_scripting_image_1

  • The Custom Panel is a panel that can be opened in a separate window, usually in the tabbed status area at the bottom of the DesignWorks main window, although it can be moved by the user. Once displayed, the window stays up until closed by the user and can remain up while the user edits a design or performs any other functions. Because all other program operations are enabled while a panel is displayed, some care must be taken in scripting these pages as design data can change and disappear during the life of the display.
  • HTML Dialogs are display boxes that may contain a single simple page or can have multiple tabbed pages. An HTML dialog is “modal”, that is once it is displayed, all other program functions are locked out until the user clicks OK or Cancel. These boxes are intended to be used to allow display and entry of design dataBoth these types of windows are implemented the same way, that is, an instance of Internet Explorer is launched and displayed in the window and then navigated to the given HTML file. Any desired JavaScript (or other scripting language supported by Internet Explorer) code can be embedded in the page or referred to in an external file.
Email
Print