Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
alu_event.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstdint>
4
5
#include "
barretenberg/vm2/common/memory_types.hpp
"
6
7
namespace
bb::avm2::simulation
{
8
9
enum class
AluOperation
: uint8_t {
10
ADD
,
11
SUB
,
12
MUL
,
13
DIV
,
14
FDIV
,
15
EQ
,
16
LT
,
17
LTE
,
18
NOT
,
19
SHL
,
20
SHR
,
21
TRUNCATE
,
22
};
23
24
// Explanations on default values:
25
// Circuit values of execution.register[X], execution.mem_tag_reg[X] corresponding to the output c are all set to 0 when
26
// an error is thrown. In order to have a correct lookup from Execution into ALU, we therefore need to set the default
27
// values to 0. Note also that the default value for b allows to deduplicate events when only member `a` is being set
28
// (e.g. NOT with error). Otherwise, the key would not be deterministic.
29
// For a, the default constructor ensures that the value is not unitialized, but we always explicitly set it during
30
// event emission.
31
struct
AluEvent
{
32
AluOperation
operation
=
static_cast<
AluOperation
>
(0);
33
MemoryValue
a
;
34
MemoryValue
b
=
MemoryValue::from_tag
(
static_cast<
ValueTag
>
(0), 0);
35
MemoryValue
c
=
MemoryValue::from_tag
(
static_cast<
ValueTag
>
(0), 0);
36
37
bool
error
=
false
;
38
// To be used with deduplicating event emitters.
39
using
Key
=
std::tuple<AluOperation, MemoryValue, MemoryValue>
;
40
Key
get_key
()
const
{
return
{
operation
,
a
,
b
}; }
41
42
bool
operator==
(
const
AluEvent
& other)
const
=
default
;
43
};
44
45
}
// namespace bb::avm2::simulation
bb::avm2::TaggedValue
Definition
tagged_value.hpp:70
bb::avm2::TaggedValue::from_tag
static TaggedValue from_tag(ValueTag tag, FF value)
Definition
tagged_value.cpp:227
memory_types.hpp
bb::avm2::simulation
Definition
address_derivation_event.hpp:6
bb::avm2::simulation::AluOperation
AluOperation
Definition
alu_event.hpp:9
bb::avm2::simulation::AluOperation::TRUNCATE
@ TRUNCATE
bb::avm2::ValueTag
ValueTag
Definition
tagged_value.hpp:36
bb::avm2::ExecutionOpCode::SHR
@ SHR
bb::avm2::ExecutionOpCode::NOT
@ NOT
bb::avm2::ExecutionOpCode::SUB
@ SUB
bb::avm2::ExecutionOpCode::DIV
@ DIV
bb::avm2::ExecutionOpCode::MUL
@ MUL
bb::avm2::ExecutionOpCode::EQ
@ EQ
bb::avm2::ExecutionOpCode::ADD
@ ADD
bb::avm2::ExecutionOpCode::SHL
@ SHL
bb::avm2::ExecutionOpCode::FDIV
@ FDIV
bb::avm2::ExecutionOpCode::LT
@ LT
bb::avm2::ExecutionOpCode::LTE
@ LTE
std::get
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition
tuple.hpp:13
bb::avm2::simulation::AluEvent
Definition
alu_event.hpp:31
bb::avm2::simulation::AluEvent::Key
std::tuple< AluOperation, MemoryValue, MemoryValue > Key
Definition
alu_event.hpp:39
bb::avm2::simulation::AluEvent::operation
AluOperation operation
Definition
alu_event.hpp:32
bb::avm2::simulation::AluEvent::b
MemoryValue b
Definition
alu_event.hpp:34
bb::avm2::simulation::AluEvent::operator==
bool operator==(const AluEvent &other) const =default
bb::avm2::simulation::AluEvent::a
MemoryValue a
Definition
alu_event.hpp:33
bb::avm2::simulation::AluEvent::error
bool error
Definition
alu_event.hpp:37
bb::avm2::simulation::AluEvent::get_key
Key get_key() const
Definition
alu_event.hpp:40
bb::avm2::simulation::AluEvent::c
MemoryValue c
Definition
alu_event.hpp:35
src
barretenberg
vm2
simulation
events
alu_event.hpp
Generated by
1.9.8