Visualizer Biometric Search for Range of Values

2024-11-06T17:00:46.000-0500
Debug

Summary

Biometric Search is commonly used to search single values on Visualizer Waveform. This article demonstrates a way to search a range of values using regular expressions.


Details

Biometric search highlights selected values in Visualizer waveform. Using limited regular expressions, we can search, not only single values, but a range of values. Furthermore, we can search for a group of values that are not necessarily consecutive. For instance, a group of even numbers, or a group of 3-character strings. A reminder, biometric search can apply on one or more selected signals.

 

Motivation

 

On biometric search list we can add multiple values explicitly. However, trying to search a large range of values can be repetitive or often impractical. For instance, if we would like to highlight any decimal number that is smaller than 100 without regular expressions, we would need to add the numbers 0 to 99 explicitly.

 

Supported Regex starting 2024.3 version:

 

Regex

Description

Example

^

Starting position in a string

^a matches strings that start with "a"

$

Ending position in a string

a$ matches strings that end with "a"

.

Matches any single character

a.c matches "abc", "a@c", "a7c", etc

?

Matches the proceeding element 0 or 1 occurrences

ab?c matches only "ac" or "abc"

+

Matches the proceeding element 1 or more occurrences

ab+c matches "abc", "abbc", "abbbc", and so on, but not "ac"

*

Matches the proceeding element 0, 1, or more occurrences

ab*c matches "ac", "abc", "abbbc", etc

|

The choice operator

abc|def matches "abc" or "def"

{m,n}

Matches the preceding element at least m and not more than n times

a{3,5} matches only "aaa", "aaaa", and "aaaaa".

[  ]

Matches a single character that is contained within the brackets:

 

 

[abc] matches either 'a', 'b', or 'c'

[0-9] matches any digit from 0 to 9

[a-z] matches any single lowercase characters

[A-Z] matches any single uppercase characters

[^ ]

Matches a single character that is not contained within the brackets

[^abc] matches any character other than "a", "b", or "c"

 

 

Note: Biometric search is a string search, not a value search. Therefore, 0xC and 12 are not the same. Changing the signal radix will affect the behavior of the biometric search.

     

    Example 1: a range of single-digit decimal numbers

     

    Range

    Suitable Regex

    Greater than or equal to 5

    [5-9] or [56789]

    Less than 3

    [0-2] or [012]

    0 to 6

    [0-6] or [0123456]

     

    Example 2: search decimal numbers from 12 to 21 will be split into 2 rules

     

    1[2-9]            //match 12 to 19

    2[0-1]            //match 20 to 21

     

    Example 3: search hex numbers from 35 to f2 will be split into 3 rules

     

    3[5-9a-f]         //match 35 to 3f

    [4-9a-e][0-9a-f]  //match 40 to ef

    f[0-2]            //match f0 to f2

     

     

     

    Additions:

    Starting from version 2024.3, the wave search window has the following additions:

    1. Match Case – To match case sensitive strings.

    2. Match Whole Word – To be used with Regex option. This option prevents the regular expression from matching a sub string. Without it, the search phrase ".1" for instance, will match any strings that has the substring <any character> and 1:
      91, 4210, b'100010, 0xd0a1, UP1
      But when enabled, it will match only 2-character strings. This could be also achieved with anchors: ^.1$

     

    Example 4:  search binary numbers, using 'Match Whole Word' option

     

    Note: Versions 2024.2 and earlier are limited in regex, and do not fully support the standard TCL regex syntax. For those versions, matching a whole word and case-sensitivity are not supported, and the wildcards "*" and "?" are used differently.

    *  matches any string

    ?  matches any single character.

    With those versions, it is possible to select a range of values, as described in the first 3 examples above but the syntax used in this example depends on using 'Match Whole Word' option which is supported only starting release 2024.3.

     

    Group

    Suitable Regex

    Match 2 digits even numbers

    .0

    Multiple digits odd numbers

    .*1

    Match b'100 to b'111

    1..

    Match b'000, b'001, b'100, b'101

    .0.

     

     

    Biometric Search Steps

    1. From the Wave window menu open Tools -> Biometric search, or use keyboard shortcut: ALT + B
    2. Click Add and insert a desired string
    3. Include Regular Expression if needed
    4. Include Match Whole Word if needed
    5. Modify the color to your taste
    6. Click OK

    Alternatively, this can be performed by Questa TCL command:

    wave bio set {<regex>} <color>

     

    To view existing biometric search list, wave bio list command will print the associated TCL commands for coloring values.

    For instance, to view the list of example 3:

     

    visualizer 2> wave bio list

    # wave bio set {3[5-9a-f]} Green

    # wave bio set {[4-9a-f][0-9a-f]} Green

    # wave bio set {f[0-2]} Green

    KB Article ID# KB000155262_EN_US

    Contents

    SummaryDetails

    Associated Components

    Visualizer Debug