[source]

Class uvm_spell_chkr

uvm_pkg::uvm_spell_chkr <T> + max : int unsigned + check(): bit

Inheritance Diagram of uvm_spell_chkr

class uvm_spell_chkr

Parameters

Name

Default value

Description

T

int

Variables

Name

Type

Description

max

int unsigned

Typedefs

Name

Actual Type

Description

tab_t

T

Functions

static function bit check ( tab_t strtab, string s ) [source]

check

primary interface to the spell checker. The function takes two arguments, a table of strings and a string to check. The table is organized as an associative array of type T. E.g.

T strtab[string]

It doesn't matter what T is since we are only concerned with the string keys. However, we need T in order to make argument types match.

First, we do the simple thing and see if the string already is in the string table by calling the exists() method. If it does exist then there is a match and we're done. If the string doesn't exist in the table then we invoke the spell checker algorithm to see if our string is a misspelled variation on a string that does exist in the table.

The main loop traverses the string table computing the levenshtein distance between each string and the string we are checking. The strings in the table with the minimum distance are considered possible alternatives. There may be more than one string in the table with a minimum distance. So all the alternatives are stored in a queue.

Note

This is not a particularly efficient algorithm. It requires

computing the levenshtein distance for every string in the string table. If that list were very large the run time could be long. For the resources application in UVM probably the size of the string table is not excessive and run times will be fast enough. If, on average, that proves to be an invalid assumption then we'll have to find ways to optimize this algorithm.

note

strtab should not be modified inside check()