Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::stdlib::ram_table< Builder > Class Template Reference

#include <ram_table.hpp>

Public Member Functions

 ram_table ()
 
 ram_table (Builder *builder, const std::vector< field_pt > &table_entries)
 Construct a new RAM table, i.e., dynamic memory with a fixed length.
 
 ram_table (const std::vector< field_pt > &table_entries)
 Construct a new RAM table, i.e., dynamic memory with a fixed length.
 
 ram_table (const ram_table &other)
 
 ram_table (ram_table &&other)
 
void initialize_table () const
 internal method, is used to call Builder methods that will generate RAM table.
 
ram_tableoperator= (const ram_table &other)
 
ram_tableoperator= (ram_table &&other)
 
field_pt read (const field_pt &index) const
 Read a field element from the RAM table at an index value.
 
void write (const field_pt &index, const field_pt &value)
 Write a field element from the RAM table at an index value.
 
size_t size () const
 
Builderget_context () const
 
bool check_indices_initialized () const
 

Private Types

typedef field_t< Builderfield_pt
 

Private Attributes

std::vector< field_ptraw_entries
 
std::vector< OriginTag_tags
 
std::vector< bool > index_initialized
 
size_t length = 0
 
size_t ram_id = 0
 
bool ram_table_generated_in_builder = false
 
bool all_entries_written_to_with_constant_index = false
 
Buildercontext = nullptr
 

Detailed Description

template<IsUltraOrMegaBuilder Builder>
class bb::stdlib::ram_table< Builder >

Definition at line 16 of file ram_table.hpp.

Member Typedef Documentation

◆ field_pt

Definition at line 18 of file ram_table.hpp.

Constructor & Destructor Documentation

◆ ram_table() [1/5]

template<IsUltraOrMegaBuilder Builder>
bb::stdlib::ram_table< Builder >::ram_table ( )
inline

Definition at line 21 of file ram_table.hpp.

◆ ram_table() [2/5]

template<IsUltraOrMegaBuilder Builder>
bb::stdlib::ram_table< Builder >::ram_table ( Builder builder,
const std::vector< field_pt > &  table_entries 
)

Construct a new RAM table, i.e., dynamic memory with a fixed length.

This constructor is used in DSL, where we need to initialize a table with a builder to prevent the case in which a read operation happens before the context has been set.

Definition at line 24 of file ram_table.cpp.

◆ ram_table() [3/5]

template<IsUltraOrMegaBuilder Builder>
bb::stdlib::ram_table< Builder >::ram_table ( const std::vector< field_pt > &  table_entries)

Construct a new RAM table, i.e., dynamic memory with a fixed length.

This constructor is used internally in barretenberg to construct tables without the need to specify the builder. It is especially useful when methods create new rom tables operating on in-circuit values which a priori we don't know whether they are constant or witnesses.

Definition at line 49 of file ram_table.cpp.

◆ ram_table() [4/5]

template<IsUltraOrMegaBuilder Builder>
bb::stdlib::ram_table< Builder >::ram_table ( const ram_table< Builder > &  other)
default

◆ ram_table() [5/5]

template<IsUltraOrMegaBuilder Builder>
bb::stdlib::ram_table< Builder >::ram_table ( ram_table< Builder > &&  other)
default

Member Function Documentation

◆ check_indices_initialized()

template<IsUltraOrMegaBuilder Builder>
bool bb::stdlib::ram_table< Builder >::check_indices_initialized ( ) const
inline

Definition at line 40 of file ram_table.hpp.

◆ get_context()

template<IsUltraOrMegaBuilder Builder>
Builder * bb::stdlib::ram_table< Builder >::get_context ( ) const
inline

Definition at line 38 of file ram_table.hpp.

◆ initialize_table()

template<IsUltraOrMegaBuilder Builder>
void bb::stdlib::ram_table< Builder >::initialize_table ( ) const

internal method, is used to call Builder methods that will generate RAM table.

initialize the table once we perform a read. This ensures we always have a pointer to a Builder. (if both the table entries and the index are constant, we don't need a builder as we can directly extract the desired value fram raw_entries)

Template Parameters
Builder

Definition at line 83 of file ram_table.cpp.

◆ operator=() [1/2]

template<IsUltraOrMegaBuilder Builder>
ram_table< Builder > & bb::stdlib::ram_table< Builder >::operator= ( const ram_table< Builder > &  other)
default

◆ operator=() [2/2]

template<IsUltraOrMegaBuilder Builder>
ram_table< Builder > & bb::stdlib::ram_table< Builder >::operator= ( ram_table< Builder > &&  other)
default

◆ read()

template<IsUltraOrMegaBuilder Builder>
field_t< Builder > bb::stdlib::ram_table< Builder >::read ( const field_pt index) const

Read a field element from the RAM table at an index value.

Template Parameters
Builder
Parameters
index
Returns
field_t<Builder>

Definition at line 131 of file ram_table.cpp.

◆ size()

template<IsUltraOrMegaBuilder Builder>
size_t bb::stdlib::ram_table< Builder >::size ( ) const
inline

Definition at line 36 of file ram_table.hpp.

◆ write()

template<IsUltraOrMegaBuilder Builder>
void bb::stdlib::ram_table< Builder >::write ( const field_pt index,
const field_pt value 
)

Write a field element from the RAM table at an index value.

Template Parameters
Builder
Parameters
index
value
Note
This is used to write an already-existing RAM entry and also to initialize a not-yet-written RAM entry.

Definition at line 180 of file ram_table.cpp.

Member Data Documentation

◆ _tags

template<IsUltraOrMegaBuilder Builder>
std::vector<OriginTag> bb::stdlib::ram_table< Builder >::_tags
mutableprivate

Definition at line 59 of file ram_table.hpp.

◆ all_entries_written_to_with_constant_index

template<IsUltraOrMegaBuilder Builder>
bool bb::stdlib::ram_table< Builder >::all_entries_written_to_with_constant_index = false
mutableprivate

Definition at line 64 of file ram_table.hpp.

◆ context

template<IsUltraOrMegaBuilder Builder>
Builder* bb::stdlib::ram_table< Builder >::context = nullptr
mutableprivate

Definition at line 65 of file ram_table.hpp.

◆ index_initialized

template<IsUltraOrMegaBuilder Builder>
std::vector<bool> bb::stdlib::ram_table< Builder >::index_initialized
mutableprivate

Definition at line 60 of file ram_table.hpp.

◆ length

template<IsUltraOrMegaBuilder Builder>
size_t bb::stdlib::ram_table< Builder >::length = 0
private

Definition at line 61 of file ram_table.hpp.

◆ ram_id

template<IsUltraOrMegaBuilder Builder>
size_t bb::stdlib::ram_table< Builder >::ram_id = 0
mutableprivate

Definition at line 62 of file ram_table.hpp.

◆ ram_table_generated_in_builder

template<IsUltraOrMegaBuilder Builder>
bool bb::stdlib::ram_table< Builder >::ram_table_generated_in_builder = false
mutableprivate

Definition at line 63 of file ram_table.hpp.

◆ raw_entries

template<IsUltraOrMegaBuilder Builder>
std::vector<field_pt> bb::stdlib::ram_table< Builder >::raw_entries
private

Definition at line 57 of file ram_table.hpp.


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