Skip to content

step_static_attributes_interface Class Reference

Bill Moore edited this page Sep 20, 2024 · 5 revisions

step_static_attributes_interface

Name Description
Class step_static_attributes_interface Interface for the step's static attributes object.
get_keyword() Gets the static step keyword.
get_expression() Gets the static step definition expression.
get_regexp() Gets the static step definition regular expression.
get_step_obj() Gets the UVM object wrapper for the step definition class.
get_step_obj_name() Gets the object type name for the step definition class.
print_attributes() Prints the values of the static attributes object.

Class step_static_attributes_interface

interface class step_static_attributes_interface;

Interface for the step's static attributes object.

At time 0, the simulator collects static attributes from the user's step definition class into an attributes object. The attributes object implements the methods in this step_static_attributes_interface interface class. The step definition can use its get_step_static_attributes() function to retrieve its attributes object and call these methods. However, several of these methods are more conveniently accessed through the step definition's own step_definition_interface methods. The default step_definition_interface implementation delegates to the respective methods here in the static step attributes object.

The static attributes are in contrast to the run-time step attributes, which are accessed through a different interface.

get_keyword()

pure virtual function step_keyword_t get_keyword();

Gets the static step keyword.

Retrieves the Gherkin keyword from the user's step definition class. It is a static property of the class, and is determined by the user's choice of macro: `Given, `When(), or `Then(). This keyword is an enum of type bathtub_pkg::step_keyword_t, not a string. Possible values are Given, When, or Then.

get_expression()

pure virtual function string get_expression();

Gets the static step definition expression.

Retrieves the step definition expression from the user's step definition class. It is a static property of the class, and is the argument to the `Given, `When(), and `Then() macros. The expression could be a POSIX regular expression surrounded by slashes ("/"), or a SystemVerilog format specification with escape sequences like %d and %s. Taking the regular expression or format specification into account, the expression matches the run-time step text.

In this example, the expression is "this expression matches %s" and it is a SystemVerilog format specification.

class user_step_definition extends uvm_pkg::uvm_sequence implements bathtub_pkg::step_definition_interface;
	`When("this expression matches %s")

In this example, the expression is "/^this expression matches .*$/" and it is a POSIX regular expression.

class user_step_definition extends uvm_pkg::uvm_sequence implements bathtub_pkg::step_definition_interface;
	`When("/^this expression matches .*$/")

get_regexp()

pure virtual function string get_regexp();

Gets the static step definition regular expression.

Retrieves the step definition regular expression from the user's step definition class. It is a static property of the class, and is derived from the step definition expression argument to the `Given, `When(), and `Then() macros. If the expression is a POSIX regular expression surrounded by slashes ("/"), then the regular expression from get_regexp() is identical to the expression from get_expression(). If the expression is a SystemVerilog format specification with escape sequences like %d and %s, then the regular expression is the expression translated into a POSIX regular expression pattern. The regular expression matches the run-time step text. Note that the regular expression is stored in the UVM resource database as the "scope" lookup string for the step definition class.

In this example, the expression is, "the user types the single character %c", and get_regexp() returns the translated POSIX regular expression, "/^the user types the single character (.)$/". Note that the SystemVerilog escape sequence %c has been translated into a grouped regular expression (.).

class user_step_definition extends uvm_pkg::uvm_sequence implements bathtub_pkg::step_definition_interface;
	`When("the user types the single character %c")

get_step_obj()

pure virtual function uvm_object_wrapper get_step_obj();

Gets the UVM object wrapper for the step definition class.

As typical UVM objects, by default user step definition classes have UVM object wrappers which are registered with the UVM factory. This function returns a reference to that object wrapper. A user step definition would not typically need to retrieve its own object wrapper this way. This function is primarily for completeness and debug.

get_step_obj_name()

pure virtual function string get_step_obj_name();

Gets the object type name for the step definition class.

This function returns the type name of the user's step definition class, as returned by the class' UVM object wrapper. A user step definition would not typically need to retrieve its own class name this way. This function is primarily for completeness and debug.

print_attributes()

pure virtual function void print_attributes(uvm_verbosity verbosity);

Prints the values of the static attributes object.

Prints the values of the static attributes object with the given verbosity. Prints with the default UVM report object, not Bathtub's dedicated report object.