Games / Command flash cards / TCL for physical design / Tool objects and collections

Tool objects and collections

Each card shows a command to explain. A missed card returns later in the round and starts the schedule over. A card answered correctly moves up the schedule and next appears after 1, 3, 7, then 21 days. Keys 1 to 4 choose an option, h shows a hint, and Enter moves on. A hint keeps the card where it is on the schedule. An ordering card is answered by clicking its items in order, and one wrong click ends it. Time values are in nanoseconds. Progress is stored in this browser.

SourceTCL (Tool Command Language) is the scripting language every place-and-route and timing tool embeds, so the same skills carry between them. These cards follow the official Tcl manual pages, and each answer links to the page for that command. The examples are in the style the OpenROAD-flow-scripts scripts use, since that is Tcl written for a real flow. Reference: the Tcl manual (Tcl on GitHub).
All 4 cards in this section, with answers
  • set regs [get_cells *_reg*] llength $regs sizeof_collection $regs
    A collection is not a list, so counting it needs the tool's own command.

    Hint: Ask what the second line counts, in a tool that returns objects.

    Commercial timers and place-and-route tools hand back a collection, which is a handle to a set of objects rather than a string. Counting it with a list command gives one, or nonsense. The open tools return ordinary Tcl lists, which is why a script moved between them needs care here. Tcl reference

  • foreach_in_collection c [get_cells *] { puts [get_object_name $c] }
    The tool's own loop over a collection, and the way to get an object's name.

    Hint: Two commands here are not Tcl's. Ask what each replaces.

    The loop variable holds an object, not a string, so printing it directly gives an internal identifier. Where the open tools let foreach work over a list of objects, the commercial ones need this form, and it is the commonest thing to change when a script crosses between them. Tcl reference

  • set ep [lindex $endpoints 0] report_slack $ep report_slack "dpath/a_reg[9]/D"
    Passing the object avoids the brackets in the name being substituted.

    Hint: Look at what the quoted name contains.

    Inside quotes the brackets are still a command substitution, so the name has to be braced or escaped. Keeping objects in variables and passing them straight through sidesteps the whole problem, which matters because bus bits and generated names are full of special characters. Tcl reference

  • redirect -variable txt { report_timing } with_output_to_variable txt { report_checks }
    Capture a report's text into a variable instead of printing it.

    Hint: Both do the same job, under different names.

    A report command prints and returns nothing, so parsing its output means capturing it first. The first spelling is the commercial one and the second is OpenSTA's. Both take the command as a script, so it must be braced, not built as a string. Tcl reference