Automating sawtooth tuning for differential pairs

By Alex Diaz |  No Comments  |  Posted: March 1, 2009
Topics/Categories: PCB - Layout & Routing  |  Tags: ,  | Organizations:

Length matching within a differential pair can be one of the more tedious tasks facing a PCB designer. This article describes how a team at communications and consumer electronics semiconductor company Broadcom overcame this by using the automation options available within their design tools. While the article describes automation tailored to a specific task, the authors present it here as an example of what can be done more generally. The workflow they developed is described, followed by detailed description of the code that underpinned the automation process.

PCB designers at Broadcom were tasked with accomplishing length matching within a differential pair. The task involves applying serpentine or sawtooth routing to a trace. Doing this manually is tedious and time-consuming, whereas automation cuts the time and effort involved significantly. The automation layer in Mentor Graphics’ Expedition product provides all the tools needed to complete this job.

The paper demonstrates how the script form editor and automation object model were used to create an interface for applying a sawtooth route on an existing trace to achieve proper length matching for differential pairs.

Tuning requirements

All signal traces in the MAC section have controlled impedance and need to be routed with a specific trace width. They must follow 3-W minimum spacing from other traces and differential pairs on the same layer.

  • 95? +/- 10% for the PCIe differential pairs (17 pairs total).
  • 100? +/- 10% for the XAUI differential pairs (two sets of 16 pairs each).

The two traces within each PCIe differential pair must be length-matched so that the long trace is no more than 5mils longer than the short trace. The two traces within each XAUI differential pair must be length-matched so that the long trace is no more than 5mils longer than the short trace.

Figure 1 shows how to achieve the 5mil-length matching within a differential pair. Apply this serpentine at the end of the trace run where the mismatch occurs for the PCIe and for the XAUI differential pairs.

To achieve the above sawtooth serpentine, we had two options:

Option one

Create an AutoCad DXF file of a small two-bump sawtooth pattern following the requirements shown in Figure 1. Import this DXF file into Expedition as a drawn line object onto a temporary user layer where it will be copied-and-pasted until the desired length is met. Then select all the segments and convert them into a continuous poly line. Change this drawn poly line type from a ‘Draw Object’ to a ‘Trace’, changing the ‘Layer’ and ‘Net’ properties at the same time. Move the trace to the desired location and finish routing the differential pair.

Option two

Select the longest line in the differential pair net and ‘fix’ or ‘lock’ it down. Manually create a small segment on the shortest net of the differential pair and pull this segment away from the longest differential pair net. Adjust this small segment to meet the sawtooth requirement shown in Figure 1.

Continue creating and adjusting these small segments until the desired length is met.

Either option demands a lot of time and effort. For one particular design, we chose option two because it best suited the board’s routing density. The initial routing pass of 49 differential pairs took almost 32 hours to match. By replacing this with sawtooth tuning automation, we cut the time required to route and match all 49 pairs to five hours.

Sawtooth tuning automation

The tuning form that we developed modifies the route of an existing trace to have sawtooth bumps according to user-defined parameters. It was designed using Expedition’s Script Form Editor. Figure 2 shows the form that is presented to the user.

Differential pair section

In this section, the user must first select a differential pair net to work with using the ‘ComboBox’ control. On selection, the pair is highlighted in the Expedition workspace. Just under the ComboBox control is a checkbox labeled ‘Fit window when selected’. If this is checked, the program will fit the Expedition workspace area to the differential pair traces that are highlighted.

Once selected, the information for the net is automatically gathered through the Constraint Editor System (CES) and presented to the user in the form. This information is the two electrical net names for the differential pair, the length for each electrical net, the length difference between them, and the differential pair tolerance constraint value. Next to each electrical net name is a ‘Highlight’ button. If clicked, then all that net’s features are highlighted in the Expedition workspace.

Line width and spacing information for the differential pair needs to be manually entered in this section of the form. The spacing value is shown as variable ‘S’ in Figure 1. The ‘OK’ button is then clicked to enable the ‘Sawtooth’ and ‘Routing’ sections of the form.

Sawtooth section

This is where the user describes the parameters for the sawtooth bump that will be added to the trace. The parameters are spacing, length, quantity and type. The spacing parameter is the distance between the edge of the opposing trace segment and the edge of the ‘bumped’ sawtooth segment. It is shown in Figure 1 as variable S1. This value is automatically filled out to be just less than double the spacing value from the differential pair section.

The length parameter defines how long the ‘bumped’ sawtooth segment is to run after the angle. This is shown as variable >3w in Figure 1 (i.e., greater than three times the width of the trace).

The quantity (‘Qty’) parameter states how many sawtooth segments the user wants to add. This can be an integer number entered in to the EditBox control or the user can click on a ‘Maximum’ CheckBox control to keep adding them until the length matching is within tolerance or there is no more room on the trace, whichever comes first.

The type parameter is a RadioButton control and the value can only be positive or negative. This determines which way to ‘bump’ the trace with the sawtooth segment. ‘Positive’ will bump above horizontal and angled traces and bump to the right of vertical traces. ‘Negative’ will bump below horizontal and angled traces and bump to the left of vertical traces.

Routing section

In this section, the user fills in two parameters, ‘Start With’ and ‘Direction’.

‘Start With’ determines whether to start with the bump right away (‘Sawtooth’) or continue on the same path with a segment that is the length of the sawtooth and then apply the bump (‘Segment’).

The direction can be either right or left for horizontal and angled lines, and either up or down for vertical lines. This will determine the start/end-point of the working trace where the sawtooth segments begin to be added.

‘Apply’ button

This is at the bottom of the form and executes the sawtooth route modification on the selected trace in the Expedition document. It is not enabled unless the current selection in the Expedition workspace is a one-segment trace that belongs to the working differential pair that the user has selected in the form.


This section considers key programming techniques used in this program that the Automation Layer in the CES and Expedition provide. The language used for this program and in the examples to follow is VBScript.

Populating the ComboBox

Upon program start up, the ComboBox control in the Differential Pair section of the form is populated. In order to do this, the program will access the CES Application object. The code is shown in Figure 3 (p.47).

The key object needed here is a CES ‘Design’ object. This will let us access the ‘DiffPairs’ collection in order to check the Pair Tolerance constraint value as well as the actual difference in length between the lengths of the differential pair nets. Lines 1 through 8 do the steps necessary to retrieve the ‘Design’ object—first by getting the ‘Application’ object, then the CES object, and finally the ‘Design’ object itself on line 8.

Beginning on line 10, a ‘For Each’ loop is then used to traverse the ‘objDesign.DiffPairs’ collection. Within this loop on line 11, the variable ‘objDiffPairRow’ is being set as a spreadsheet object, which is retrieved from the ‘ENET’ page in CES using the differential pair name as the argument for the ‘FindObject’ method. Using this object allows us to retrieve the constraint values we want through the ‘ConstraintEx’ property.

Line 13 gets the maximum pair tolerance and assigns the value to the variable ‘dpTol’, and line 15 gets the actual difference in length assigning it to the variable ‘dpAct’. From there, we can do the math on line 17 to see if this differential pair is in violation. If it is in violation, then the differential pair name is added to the ‘ComboBox’ control on line 19 using the ‘AddString’ method.

Selecting the differential pair

When the user selects a differential pair from the ‘ComboBox’ control, the electrical net names and lengths are then presented in the form automatically. Figure 4 shows the code. Along with the CES’ ‘Application’ object, we also use Expedition’s ‘Application’ and ‘Document’ object. ‘Document’ allows us to interact with the working PCB design. The object is being set as the variable ‘ExpDoc’ on line 11 and is derived from the ‘Application.ActiveDocument’ property. This will be used to highlight the net’s features and zoom to their extents in the Expedition Workspace.

Lines 10 through 14 accomplish retrieving the Document object; first by retrieving the ‘Application’ object on line 11 and then the ‘Document’ object on line 14. Line 17 sets a variable named ‘DiffPairName’ to be the differential pair name that has been selected in the ComboBox control. This is accomplished using the ‘ComboBox.TextValue’ attribute. With this differential pair name we can now get the ‘DiffPair’ object on line 24 from the ‘objDesign.GetDiffPair’ method.

Now that we have a ‘DiffPair’ object, we can loop through the child electrical nets within the ‘DiffPair’. Line 28 starts the appropriate ‘For Each’ loop, where the name of each electrical net is being placed in the appropriate ‘EditBox’ control on line 35. The length of the electrical net is then retrieved from the CES spreadsheet on line 38 and placed in the appropriate length ‘EditBox’ control on line 40. Next the features for the electrical nets are highlighted in a nested ‘For Each’ loop starting on line 43. It loops through the child physical nets within the electrical net. First, the physical ‘Net’ object is retrieved from the Expedition Document object on line 45, and it is then highlighted on line 47.

After the electrical net information is filled out, we then must populate the length difference and pair tolerance ‘EditBox’ controls. This is done on lines 52 through 60. First, by retrieving the constraint values on line 55 and 57 from the CES, and then by setting the text properties for the controls on lines 59 and 60.

We can now enable the ‘Update’ and ‘OK’ buttons within the differential pair section. This is done on line 63 and 64 using their respective ‘Enable’ properties and setting them to 1.

There is a check to see if the ‘Fit window when selected’ checkbox is checked or not on line 68 and, if it is, then the extents of the Expedition Workspace are set to the highlighted features on line 69.

Enabling the ‘Apply’ button

This button will not be enabled unless the current selection in the Expedition Workspace is a single trace that belongs to the working differential pair that the user has selected in the form. To check for this, the program uses the ‘OnSelectionChange’ event in the ‘Document’ object. Figure 5 shows the code.

First we must bind the document object event to our event handler function. This is done on line 7. The ‘AttachEvents’ method takes two parameters, the object reference and the event function prefix. We are specifying ‘docEvents’ as the function prefix that the automation layer will look for when an event occurs in the ‘Document’ object. The event handler function we define is ‘docEvents_OnSelectionChange’ on line 9. This event passes one argument, the ‘SelectionType’. Whenever a selection change occurs in the ‘Document’, this function will then execute. For our purposes, we want to verify that the selection is a single trace and is part of the differential pair currently selected in the form.

Line 14 gets the collection of ‘Traces’ selected in the ‘Document’. Line 16 verifies that there is only one trace selected. Line 26 gets the physical net name of the selected trace. We then get the ‘DiffPair’ object from the CES on line 27 based on what is currently selected in the form’s ComboBox control. From there, we can traverse the child electrical and physical nets to verify that the selected physical net is part of the ‘DiffPair’. If it is, then the ‘enable’ variable is set to 1 on line 32 and will enable the ‘Apply’ button on line 37.

Applying the sawtooth modification

When the ‘Apply’ button is pressed, the program will then modify the selected trace to have the sawtooth bumps according to the parameters from the form. Figure 6 (p.49) shows the code.

First, information is gathered from the selected trace to be modified. This is done on lines 1 through 17. We need to know the layer the trace is on, the width of the trace, and finally we need to retrieve the ‘Net’ object that the trace belongs to. This information is necessary in order to execute the ‘PutTrace’ method for the sawtooth bump later down the line. The original trace is then deleted on line 21 using the ‘Trace.Delete’ method. The next step is to retrieve all the parameter values from the form’s controls. This is done on lines 23 through 53.

Using all the parameters, we can now calculate where to start the sawtooth bumps and set a points array to use in the ‘Document.PutTrace’ method. This method is performed within a ‘Do While’ loop and will only execute if there is enough room left to add a sawtooth or a user-defined number of sawtooth segments has been reached. Lines 59 through 62 demonstrate setting a points array to be used and line 65 executes the ‘Document.PutTrace’ method.


This paper has demonstrated the power of the script form editor and the automation layer that Expedition and the CES have available. This problem is only one of many out there that can be solved using automation. We hope this paper will increase your interest in and knowledge of automation. If your PCB design group finds itself repeating time-consuming tasks, consider automation as the solution.

16215 Alton Parkway
CA 92618

T: +1 949 926 5000

Comments are closed.


Synopsys Cadence Design Systems Siemens EDA
View All Sponsors