Using Renaming Rules with CadEnhance Tools
The CadEnhance Tools support Renaming Rules for many of the opearations performed on Text Strings
PartBuilder uses Rename Rules to rename Pins, strip PinNumbers from within PinNames, and remove leading zeros from PinNumbers or PinNames extracted from PinReports
CE_HDL uses Rename rules to alter the Signal Names added to wires based on the PinName of the component
FPGA_PIN_PLANNER uses rename rules when migrate signal names or pin names between designs
NET_BOM can use rename rules to rename REF_DES or NET_NAMES from an old design to match the REF_DES or NET_NAME in the new design if the user knows that a bunch of names have been replaced in the next revision of a design.
SIG_RENAME_RULE SYNTAX
A SIG_RENAME_RULE using Match/Replace or Join can be entered as follows
- MATCH_STRING:REPLACE_STRING
- checks all strings to see if they contain the MATCH_STRING... if it does, the occurrence of the MATCH_STRING will be replaced with the REPLACE_STRING
- !JOIN_,MATCH_STRING,JOIN_STRING
- checks all strings to see if they contain the MATCH_STRING if they do the current pin name is appended with the JOIN_STRING preceeded by the character after the !JOIN which in this case and most cases will be the '_'
The SIG_RENAME_RULE can also be a REPLACEMENT_DIRECTIVE. The CadEnhance tools support several REPLACEMENT_DIRECTIVES
!STRIP_LEADING_ZEROS
- Remove leading zeros in any pin_name OR pin_number in the pin database.
- This is very useful for BSDL files which sometimes use leading zeros in their pinnames and pinnumbers
- dq00 will be changed to dq0, dq09 will be changed to dq9
- pin A01 will be change to A1
- Remove leading zeros in any pin_name OR pin_number in the pin database.
!STRIP_LEADING_ZEROS_FROM_END
- This is for a case like intel signals 1p05_001
- we do not want to strip the p05 because it means something special... but we do want to strip the 001 down to 1
!FIX_ACTIVE_LOW (Added in release v22.1.1)
- This is very valuable in the CE_HDL tool where pinNames that start with '-' or end with '*' can be fixed
- -RESET or RESET* will be changed to RESET_N
- Bussed Names like: -DQ7 or DQ7* will be changed to DQ_N7 (to keeping the digit at the end so busses are properly maintained
The MATCH_STRING in the SIG_RENAME_RULES are sorted by length before they are applied. Only the longest match for a pin_name is applied.
This enables the user to target more specific matches like the following (without worrying about the order the SIG_REPLACE_RULES are entered in)
VSS:GND
AVSS:ANALOG_GND
In this case a pin named AVSS_25 would be changed to ANALOG_GROUND_25
VSS_25 would be changed to GND_25
a pinNamed BVSS_25 would be changed to BGND_25 because it only matches the VSS PIN_MATCH
USEFUL RENAMING MATCH STRINGS
PartBuilder accepts regular expressions on the left side of the colon in the WAS:IS rename rule. This allows the user precise control over which pins get renamed as shown in the following table.
RENAME_RULE | Notes | examples pin names |
---|---|---|
CK:CK_P | this will replace any pin name that CONTAINS CK with CK_P... If a pin named CKE in the exists pinList, it would be renamed to CK_PE which you might not want CK0 would be renamed CK_P0 which you may or may not want | CK→CK_P ALT_CK → ALK_CK_P You might want: CK0 → CK_P0 (maybe what you want) You probabaly don't want: CKE->CK_PE CKP → CK_PP CK# →CK_P# |
CK$:CK_P | The '$' changes the above rule so that partBuilder will rename any pin name that ENDS_WITH CK with CK_P... A pin named CKE in the pinList, would not be renamed by this rule, since it ends with an 'E' A pin named CK0 would also not be renamed. | CK→CK_P ALT_CK->ALT_CK_P CKE→CKE (no change) CK0 → CK0 (no change) CKP → CKP (no change) CK# → CK# (no change) |
CK(\d+)$:CK_$1_P | This is a regular expression match where the '(\d+)' tells the replace function to capture any number of consecutive digits into the $1 variable which can be used on the other side of the colon as part of the replacement. \d+ means any number of digits... Note that the parenthesis around the \d+ are what tells the function to capture the digits. (this is called back matching) The replace function will not be looking to find any parenthesis in the string. What this rule says is replace any pinName that ENDS_WITH (because of the '$') CK followed by any number of digits with CK_(the_captured_digits)_P so CK0 would be replaced with CK_0_P, CK25 would be replaced with CK_25_P and CK25# would not be replaced because the pinName does not end in a digit. | CK→CK (no change (no digit at end) ALT_CK→ALT_CK (no change) CKE→CKE (no change) CK0 → CK_0_P CK25 → CK_25_P CK25# → CK25# (no change) CKP → CKP (no change) |
CK#:CK_N | Will replace any pinname containing CK# with CK_N | CK#→CK_N CK25# →CK25# (no change) ALT_CK# → ALT_CK_N CKE# → CKE_N |
^-(\S+):$1_N | will replace any set of pin_names that start with a '-' to that pin_name_n uses backmatching... the regular expression captures all characters after the '-' and stores them in $1 then we replace with $1_N | '-pce_rx0' → pce_rx0_n '-low_sig' → low_sig_n |
_WF: | a blank string after the colon ':' instructs the rename function to remove the match from the string. | 'dq0_wf' → dq0 'sda_wf_low'->sda_low |
Using Renaming Rules with Math Operations
In v21.12.1 The CadEnhance tools added support to include Math operations using matching numbers in the Renaming Rule specs.
This is a very valuable addtion for the CE_HDL tool when you want to rename groups of pins in a large bus to a smaller bus
The Math operation is surrounded by exclamation points and includes a back reference from the match regexp
Supported Simple Math operators
The math is accomplished using perl builtin math, so proper order of operation is maintained.
'+' addition
'-' subtraction
'*' multiply
'/' divide
note that the user should be careful not to specify a divide operation with a 0 as the divisor
Simple Increment Math Replace:
CB(\d+):DQ!$1+64!
here the match has one set of parenthesis so the digits after CB string will be captured in $1
The math operation says to add 64 to $1
results:
CB0 →CB64,
$1=0
math op = $1+64 =64
CB1 →CB65...
$1=1
math op=$1+64 =65
Math using 2 or more back matches
C(\d+)_D(\d+):DQ!($1+1)*64+$2!
Here the match has 2 sets of parenthesis so the digits after the 'CB' string will be captured in $1, and the digits after the '_D' string will be captured in $2
The math operation calculates $1+1*64 + $2
sample results:
C0_D1 -> DQ65
$1 is 0, $2 is 1 {DQ'(0+1)*64+1'} ,
C1_D1 -> DQ127 {DQ'(1+1)*64+1'}
$1 is 1, $2 is 1
Math using more than 1 operation
#C(\d+)_D(\d+)_(\d+):C!$1*2!_D!$3*20+$2!
Here the match as 3 sets of parenthisis, so the digits after the 'C' string will be captured in $1, the digits after '_D' will be captured in $2 and the digits after the last '_' will be captured in $3
The replacement uses 2 math operations to build the replace string
the first is $1*$2
the second is $3*20+$2
sample results
C1_D5_2 → C5_D45
$1=1,$2=5,$3=2
math op 1 $1*$2=1*5=5
math op 2 $3*20+$2 =2*20+5 =45
More Advanced Math operators
Because the tools are using perl to run the math functions, any valid perl math statement can be used between the 2 !perl_math_expr!'
you can try something more exotic expressions:
C!int(4/$2)+$3**2!
use the integer of (4/$2) and then add $3 raised to the power of 2(squared)
- We will not attempt to document all the possiblities, rather we provide some links to websites where things have already been explained
- Obviously if you are willing to try, you can create some very powerful rules
- You can try these at your own risk and know that support staff will be happy to help you acheive your desired replacement rules
- If there is an error in a math expression, you will be warned and the resulting value substituted for that operation will be 'MATH_ERR'
RR_REPLACE_CHAR_LIST
The RR_REPLACE_CHAR_LIST is a kind of REPLACEMENT_DIRECTIVE but it is provided separately from the SIG_RENAME_RULES entry or File.
It's purpose is to provide a list of restricted characters for the symbol_tool, and have all those characters replaced with a valid character the RR_REPLACE_CHAR_SUB
the list defaults to ()\/ so any and the RR_REPLACE_CHAR_SUB defaults to the _
Any occurrence of the restricted characters in the pin_names will be substituted to the RR_REPLACE_CHAR_SUB
This substitution occurs after all the SIG_RENAME_RULES have been applied.
# rename rule1 VSS:GND #rename rule 2 !JOIN_,GPIO28,(INT5_N) #rename rule 3 !JOIN_,GPIO27,(INT4_N) #rename rule 4 GPIO26:INT_3_N
effect of rename rule1: Any occurrence of 'VSS' in a PinName will be replaced with GND VSS_1->GND_1 AVSS_25_SPECIAL=>GND_25_SPECIAL effect of rename rule2: pin GPIO28 will be JOINED with _INT5_N to create GPIO28_INT5_N effect of rename rule3: (!JOIN_) pin GPIO27 will be JOINED with _INT4_N to create GPIO27_INT4_N effect of rename rule 4 any occurrence of GPIO26 in a pin name will be replaced with INT_3_N