P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelRegisterValue Class Reference

#include <test_spec.h>

Inheritance diagram for P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelRegisterValue:
[legend]

Public Member Functions

 Bmv2V1ModelRegisterValue (const IR::Expression *initialValue)
 
 DECLARE_TYPEINFO (Bmv2V1ModelRegisterValue, IndexMap)
 
const Bmv2V1ModelRegisterValueevaluate (const Model &model, bool doComplete) const override
 
cstring getObjectName () const override
 
- Public Member Functions inherited from P4::P4Tools::P4Testgen::Bmv2::IndexMap
 IndexMap (const IR::Expression *initialValue)
 
 DECLARE_TYPEINFO (IndexMap, TestObject)
 
const IR::Constant * getEvaluatedInitialValue () const
 
const IR::Expression * getInitialValue () const
 
const IR::Expression * getValueAtIndex (const IR::Expression *index) const
 
std::map< big_int, std::pair< int, const IR::Constant * > > unravelMap () const
 Return the "writes" to this index map as a.
 
void writeToIndex (const IR::Expression *index, const IR::Expression *value)
 Write.
 
- Public Member Functions inherited from P4::P4Tools::P4Testgen::TestObject
 TestObject (const TestObject &)=default
 
 TestObject (TestObject &&)=default
 
 DECLARE_TYPEINFO (TestObject)
 
TestObjectoperator= (const TestObject &)=default
 
TestObjectoperator= (TestObject &&)=default
 
- Public Member Functions inherited from P4::ICastable
template<typename T >
T & as ()
 Tries to convert the class to type T. A BUG occurs if the cast fails.
 
template<typename T >
const T & as () const
 Tries to convert the class to type T. A BUG occurs if the cast fails.
 
template<typename T >
T * checkedTo ()
 Performs a checked cast. A BUG occurs if the cast fails.
 
template<typename T >
const T * checkedTo () const
 Performs a checked cast. A BUG occurs if the cast fails.
 
- Public Member Functions inherited from P4::RTTI::Base
template<typename T >
bool is () const noexcept
 
virtual bool isA (TypeId typeId) const noexcept=0
 
template<typename T >
const T * to () const noexcept
 Same as to, but returns const pointer to T.
 
template<typename T >
T * to () noexcept
 
virtual TypeId typeId () const noexcept=0
 

Additional Inherited Members

- Protected Member Functions inherited from P4::RTTI::Base
virtual const void * toImpl (TypeId typeId) const noexcept=0
 
- Protected Attributes inherited from P4::P4Tools::P4Testgen::Bmv2::IndexMap
std::vector< IndexExpressionindexConditions
 Each element is an API name paired with a match rule.
 
const IR::Expression * initialValue
 A new IndexMap always requires an initial value. This can be a constant or taint.
 

Detailed Description

This object tracks the list of writes that have been performed to a particular register. The registerConditionList represents the pair of the index that was written, and the value that was written to this index. When reading from a register, we can furl this list starting from the first index into a set of nested Mux expressions (e.g., "readIndex == savedIndex ? savedValue : defaultValue", where defaultValue may be another Mux expression). If the read index matches with the index that was saved in this tuple, we return the value, otherwise we unroll the nested MUX expressions. This implicitly handles overwrites too, as the latest writes to a particular index appear the earliest in this unraveling phase..

Member Function Documentation

◆ evaluate()

const Bmv2V1ModelRegisterValue * P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelRegisterValue::evaluate ( const Model & model,
bool doComplete ) const
nodiscardoverridevirtual
Returns
a version of the test object where all expressions are resolved and symbolic variables are substituted according to the mapping present in the
Parameters
model.

Implements P4::P4Tools::P4Testgen::TestObject.

◆ getObjectName()

cstring P4::P4Tools::P4Testgen::Bmv2::Bmv2V1ModelRegisterValue::getObjectName ( ) const
nodiscardoverridevirtual
Returns
the string name of this particular test object.

Implements P4::P4Tools::P4Testgen::TestObject.