85 return sel.q_1_nz || (sel.q_m_nz && sel.gate_selector != 3) || sel.gate_selector == 3;
89 [](
const Selectors& sel) {
return sel.q_2_nz || (sel.q_m_nz && sel.gate_selector != 3); } },
93 {
Wire::W_4, [](
const Selectors& sel) {
return sel.q_4_nz || sel.gate_selector == 3; } },
96 [](
const Selectors& sel) {
return sel.gate_selector == 2 || sel.gate_selector == 3; } },
141namespace nnf_helpers {
154inline const GatePattern
170 [](
const Selectors& sel) {
return sel.q_m_nz || (sel.q_2_nz && sel.q_4_nz); } },
172 [](
const Selectors& sel) {
return sel.q_m_nz || (sel.q_2_nz && sel.q_4_nz); } },
188namespace memory_helpers {
208inline const GatePattern
343template <
typename Block,
typename GateSelectorColumn>
347 .
gate_selector =
static_cast<int64_t
>(
static_cast<uint64_t
>(gate_selector_column[gate_index])),
348 .q_m_nz = !block.q_m()[gate_index].is_zero(),
349 .q_1_nz = !block.q_1()[gate_index].is_zero(),
350 .q_2_nz = !block.q_2()[gate_index].is_zero(),
351 .q_3_nz = !block.q_3()[gate_index].is_zero(),
352 .q_4_nz = !block.q_4()[gate_index].is_zero(),
353 .q_c_nz = !block.q_c()[gate_index].is_zero(),
357template <
typename Block> uint32_t
get_wire(Block& block,
size_t gate_index,
Wire wire)
361 return block.w_l()[gate_index];
363 return block.w_r()[gate_index];
365 return block.w_o()[gate_index];
367 return block.w_4()[gate_index];
369 return block.w_l()[gate_index + 1];
371 return block.w_r()[gate_index + 1];
373 return block.w_o()[gate_index + 1];
375 return block.w_4()[gate_index + 1];
385template <
typename Block>
391 std::vector<uint32_t> result;
392 for (
const auto& wire_spec : pattern.
wires) {
394 if (
is_shifted(wire_spec.wire) && gate_index + 1 >= block.size()) {
397 if (wire_spec.condition(selectors)) {
398 result.push_back(
get_wire(block, gate_index, wire_spec.wire));
bool is_timestamp_check(const Selectors &sel)
bool is_rom_consistency(const Selectors &sel)
bool is_ram_consistency(const Selectors &sel)
bool is_limb_accum_2(const Selectors &sel)
bool is_product_3(const Selectors &sel)
uint32_t get_wire(Block &block, size_t gate_index, Wire wire)
const GatePattern POSEIDON2_EXTERNAL
const GatePattern POSEIDON2_INTERNAL
std::function< bool(const Selectors &)> Predicate
const GatePattern DATABUS
const GatePattern NON_NATIVE_FIELD
const GatePattern ELLIPTIC
const GatePattern DELTA_RANGE
Selectors read_selectors(Block &block, size_t gate_index, const GateSelectorColumn &gate_selector_column)
const GatePattern ARITHMETIC
std::vector< uint32_t > extract_wires(Block &block, size_t gate_index, const GatePattern &pattern, const Selectors &selectors)
bool is_shifted(Wire wire)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Pattern defining which wires are constrained by a gate type.
std::vector< WireSpec > wires
Selector values read from a gate.