P4C
The P4 Compiler
Loading...
Searching...
No Matches
ActionData::RandomNumber Class Reference

#include <action_format.h>

Inheritance diagram for ActionData::RandomNumber:
[legend]

Public Member Functions

 RandomNumber (cstring rand, cstring act, le_bitrange range)
 
bool can_merge (const Parameter *ad) const override
 
void dbprint (std::ostream &out) const override
 
bool equiv_value (const Parameter *ad, bool check_cond=true) const override
 
bool from_p4_program () const override
 
const Parameterget_extended_param (uint32_t extension, const Parameter *ad) const override
 
bool is_next_bit_of_param (const Parameter *ad, bool same_alias) const override
 
bool is_subset_of (const Parameter *ad) const override
 
const Parametermerge (const Parameter *ad) const override
 
cstring name () const override
 
bool only_one_overlap_solution () const override
 
const Parameteroverlap (const Parameter *ad, bool only_one_overlap_solution, le_bitrange *my_overlap, le_bitrange *ad_overlap) const override
 
bool rand_nums_overlap_into (const RandomNumber *rn) const
 
int size () const override
 
const Parametersplit (int lo, int hi) const override
 
- Public Member Functions inherited from ActionData::Parameter
bool can_overlap_ranges (le_bitrange my_range, le_bitrange ad_range, le_bitrange &overlap, le_bitrange *my_overlap, le_bitrange *ad_overlap) const
 
cstring cond_name () const
 
bool equiv_cond (const Parameter *p) const
 
template<typename T >
bool is () const
 
bool is_cond_type (ModConditionally_t type) const
 
void set_cond (const Parameter *p)
 
void set_cond (ModConditionally_t ct, cstring n)
 
template<typename T >
const T * to () const
 
- Public Member Functions inherited from P4::IHasDbPrint
void print () const
 

Additional Inherited Members

- Protected Attributes inherited from ActionData::Parameter
cstring _cond_name
 
ModConditionally_t _cond_type = NONE
 

Detailed Description

Represents an output from the Random Number Generator. Up to 32 bits possible per logical table, as this is the size of the immediate bits maximum position.

Because all Random Numbers across all actions can possibly be merged, a set of random numbers (in the initial case a single entry) represent all of the data at those particular bits. Because the bits are always random, there is not lo-hi, only size.

Member Function Documentation

◆ can_merge()

bool ActionData::RandomNumber::can_merge ( const Parameter * ad) const
overridevirtual

Reimplemented from ActionData::Parameter.

◆ dbprint()

void ActionData::RandomNumber::dbprint ( std::ostream & out) const
inlineoverridevirtual

Implements ActionData::Parameter.

◆ equiv_value()

bool ActionData::RandomNumber::equiv_value ( const Parameter * ad,
bool check_cond = true ) const
overridevirtual

Implements ActionData::Parameter.

◆ from_p4_program()

bool ActionData::RandomNumber::from_p4_program ( ) const
inlineoverridevirtual

Implements ActionData::Parameter.

◆ get_extended_param()

const Parameter * ActionData::RandomNumber::get_extended_param ( uint32_t extension,
const Parameter * ad ) const
overridevirtual

Implements ActionData::Parameter.

◆ is_next_bit_of_param()

bool ActionData::RandomNumber::is_next_bit_of_param ( const Parameter * ad,
bool same_alias ) const
overridevirtual

Implements ActionData::Parameter.

◆ is_subset_of()

bool ActionData::RandomNumber::is_subset_of ( const Parameter * ad) const
overridevirtual

Reimplemented from ActionData::Parameter.

◆ merge()

const Parameter * ActionData::RandomNumber::merge ( const Parameter * ad) const
overridevirtual

Reimplemented from ActionData::Parameter.

◆ name()

cstring ActionData::RandomNumber::name ( ) const
inlineoverridevirtual

Implements ActionData::Parameter.

◆ only_one_overlap_solution()

bool ActionData::RandomNumber::only_one_overlap_solution ( ) const
inlineoverridevirtual

Implements ActionData::Parameter.

◆ overlap()

const Parameter * ActionData::RandomNumber::overlap ( const Parameter * ad,
bool only_one_overlap_solution,
le_bitrange * my_overlap,
le_bitrange * ad_overlap ) const
overridevirtual

Each action in a table is mutually exclusive, thus random externs that are used in different actions can share the same bits in the immediate, as these bits will be mutually exclusive. Random externs used in the same actions can not overlap, in order to guarantee that each random bit is unique.

Previously checked before this pass is run, a random extern can only be used once per action, as the infrastucture cannot tell what bits are supposed to be shared, vs. what bits will be different.

Bits that are not headed directly to an ALU operation can be overlaid:

action a1() { f1 = random1.get(); f2 = random2.get(); }

where f1 and f2 are two 4 bit fields in different 8 bit containers. In this case, because the random numbers output byte by byte, each random number impact is actually 8 bits. But because each of these operands only use 4 bits, each random number can overlap with each other.

Because these bits can always overlap, just return the max size position

Implements ActionData::Parameter.

◆ rand_nums_overlap_into()

bool ActionData::RandomNumber::rand_nums_overlap_into ( const RandomNumber * rn) const
See also
RandomNumber::overlap

Returns true if the set of randoms don't have any overlapping actions, or are padding within that action

◆ size()

int ActionData::RandomNumber::size ( ) const
overridevirtual

Implements ActionData::Parameter.

◆ split()

const Parameter * ActionData::RandomNumber::split ( int lo,
int hi ) const
overridevirtual

Implements ActionData::Parameter.