Skip to content

UVM SystemC Randomization LRM

Thilo Voertler edited this page Oct 26, 2021 · 2 revisions

UVM SystemC Randomization LRM

Introduction and Motivation

Objects and Hierarchy

Base class for hierarchy (crv_object)

Randomizable objects (crv_sequence_item)

Randomizable variables (crv_variable)

Hard Constratins (crv_constraint)

deactivate (constraint management functions)

Soft Constraints (crv_soft_constraint)

Vectors of randomizable objects (crv_vector)

Arrays of randomizable objects (crv_array)

Constraint Operators

Crave constraints support the following operators

Boolean Operators

within

for_each

if_then

bitslice

Distributions

range

weighted_range

functions

onehot

Datatypes and Enums

Supported Datatypes

Requirements for adding custom Datatypes

Enum support (Better Enums)

Global Functions

Setting seeds

Class Definition

The followoing lists required classes required for a minimal crave API

crv_object

Base class for all CRAVE objects

Public Member Functions

crv_object ()

Empty Constructor.


crave::crv_object::crv_object (const crv_object &  other)

Copy constructor.


~crv_object ()

Destructor.


virtual std::string obj_kind () const

Return the type of the object as a string. The type is most likely the name of the class the object is made from.

Returns:

  • Type of the object as a string.

virtual bool randomize ()

Randomizes the variables in this object.

The variables must be of type crv_variable in order to be randomized. While randomizing, all constraints that are part of the object will be used to get a solution. These constraints may produce contradicts and cannot be solved. In that case, this method returns false.

Returns:

  • true if a solution is found, false otherwise.

std::string name () const

Get the name of the object.

Returns:

  • Name of the object as a string.

std::string fullname () const

Get the fullname of the object.

Returns:

  • Fullname of the object as a string.

void print_object_hierarchy (int level=0) const

Outputs the object hierarchy (i.e. children and their children, etc.) to std::cout.

Static Public Member Functions

static crv_object * root ()

Get the root object of the hierarchy

Returns:

  • Pointer to the root element of the object hierarchy, nullptr if no element exists

static crv_object * find (std::string)

Find the object with a given name.

Returns:

  • Pointer to the element with name, nullptr if no element exists

static unsigned count ()

Get the numer of objects in the hierarchy,

Returns:

  • Number of elements in the obect hierarchy

crv_object_name

Class for names of CRAVE objects.

This class is a type safe class to wrap the name of an object in CRAVE.

Public Member Functions

crv_object_name (const char *)

Constructor using a char array.

Parameters:

  • ca character array to create the name from.

crv_object_name (const std::string &s)

Constructor using a string.

Parameters:

  • s string to create the name from.

crv_object_name (const crv_object_name &)=default

Copy constructor.


 ~crv_object_name ()

Destructor.


std::string operator() ()

Operator() to get the name as a string

Returns

  • wrapped name as a string

crv_variable_base_

Non template base class for crv_variable. Dervied from crave_object

Public Member Functions

virtual Constant constant_expr ()=0

Get an instance of Constant, which captures the current value of this variable.

Returns:

  • a Constant

virtual expression bound_expr ()=0

Get an expression, which bounds the symbolic value to be equal to another symbolic value.

Returns:

-bound expression


virtual unsigned id ()=0

get id

Returns:

  • id

std::string obj_kind () const override final

Return the type of the object as a string.

Returns

  • crv_variable as a string.

crv_variable_base

Non template base class for crv_variable. Dervied from crave_object

Public Member Functions