bmv2
Designing your own switch target with bmv2
Public Types | Public Member Functions | List of all members
bm::RegisterArray Class Reference
Inheritance diagram for bm::RegisterArray:
Inheritance graph
[legend]

Public Types

using Notifier = std::function< void(size_t idx)>
 

Public Member Functions

Registeroperator[] (size_t idx)
 Access the register at position idx, asserts if bad idx. More...
 
const Registeroperator[] (size_t idx) const
 Access the register at position idx, asserts if bad idx. More...
 
Registerat (size_t idx)
 
const Registerat (size_t idx) const
 
iterator begin ()
 NC. More...
 
const_iterator begin () const
 NC. More...
 
iterator end ()
 NC. More...
 
const_iterator end () const
 NC. More...
 
size_t size () const
 
void register_notifier (Notifier notifier)
 
UniqueLock unique_lock () const
 
- Public Member Functions inherited from bm::NamedP4Object
const std::string & get_name () const
 Get the name of the P4 instance. More...
 
p4object_id_t get_id () const
 Get the compiler-provided id. More...
 
 NamedP4Object (const NamedP4Object &other)=delete
 Deleted copy constructor. More...
 
NamedP4Objectoperator= (const NamedP4Object &other)=delete
 Deleted copy assignment operator. More...
 
 NamedP4Object (NamedP4Object &&other)=default
 Default move constructor. More...
 
NamedP4Objectoperator= (NamedP4Object &&other)=default
 Default assignment operator. More...
 

Detailed Description

RegisterArray corresponds to the register standard P4 v1.02 object. A RegisterArray reference can be used as a P4 primitive parameter. For example:

class register_write
: public ActionPrimitive<RegisterArray &, const Data &, const Data &> {
void operator ()(RegisterArray &dst, const Data &idx, const Data &src) {
dst[idx.get_uint()].set(src);
}
};

Member Typedef Documentation

◆ Notifier

using bm::RegisterArray::Notifier = std::function<void(size_t idx)>

Used to notify listeners that a write occurred in the array at idx. You can register your own notifier function by calling register_notifier().

Member Function Documentation

◆ at() [1/2]

Register& bm::RegisterArray::at ( size_t  idx)
inline

Access the register at position idx, throws a std::out_of_range exception if idx is invalid

◆ at() [2/2]

const Register& bm::RegisterArray::at ( size_t  idx) const
inline

Access the register at position idx, throws a std::out_of_range exception if idx is invalid

◆ begin() [1/2]

iterator bm::RegisterArray::begin ( )
inline

NC.

◆ begin() [2/2]

const_iterator bm::RegisterArray::begin ( ) const
inline

NC.

◆ end() [1/2]

iterator bm::RegisterArray::end ( )
inline

NC.

◆ end() [2/2]

const_iterator bm::RegisterArray::end ( ) const
inline

NC.

◆ operator[]() [1/2]

Register& bm::RegisterArray::operator[] ( size_t  idx)
inline

Access the register at position idx, asserts if bad idx.

◆ operator[]() [2/2]

const Register& bm::RegisterArray::operator[] ( size_t  idx) const
inline

Access the register at position idx, asserts if bad idx.

◆ register_notifier()

void bm::RegisterArray::register_notifier ( Notifier  notifier)

Register your own notifier function. Every time a write operation is performed on the register array, your notifier will be called, with the index at which the write happened as an argument. This method is not thread-safe. Please request the lock using unique_lock() if needed.

◆ size()

size_t bm::RegisterArray::size ( ) const
inline

Return the size of the RegisterArray (i.e. number of registers it includes)

◆ unique_lock()

UniqueLock bm::RegisterArray::unique_lock ( ) const
inline

Request exclusive access to this register array. This method needs to be called when the target needs to read or write a register. Note that it is never necessary to call this method in a primitive action, since when an action is executed, it is guaranteed exclusive access to all the register arrays it reads or writes.


The documentation for this class was generated from the following file: