Template Class stack_t#

Nested Relationships#

Nested Types#

Class Documentation#

template<class params>
class stack_t#

The stack class (YP: \(\mu_{s}\))

Public Types

typedef arith_env_t<params> arith_t#

The arithmetical environment used by the arbitrary length integer library.

typedef arith_t::bn_t bn_t#

The arbitrary length integer type.

typedef cgbn_mem_t<params::BITS> evm_word_t#

The arbitrary length integer type used for the storage. It is defined as the EVM word type.

typedef arith_env_t<params>::bn_wide_t bn_wide_t#

The arbitrary length integer type with double the size of the EVM word type.

Public Functions

inline __host__ __device__ __forceinline__ stack_t (arith_t arith, stack_data_t *content)

The constructor of the stack given the arithmetical environment and the stack data structure.

Parameters
  • arith[in] The arithmetical environment

  • content[in] The stack data structure

inline __host__ __device__ __forceinline__ stack_t (arith_t arith)

The constructor of the stack given the arithmetical environment.

Parameters

arith[in] The arithmetical environment

inline __host__ __device__ __forceinline__ ~stack_t ()

The destructor of the stack.

inline __host__ __device__ __forceinline__ uint32_t size ()

Get the size of the stack.

Returns

The size of the stack

inline __host__ __device__ __forceinline__ evm_word_t * top ()

Get the top of the stack.

Returns

The top of the stack pointer

inline __host__ __device__ __forceinline__ void push (const bn_t &value, uint32_t &error_code)

Push a value on the stack.

Parameters
  • value[in] The value to be pushed on the stack

  • error_code[out] The error code

inline __host__ __device__ __forceinline__ void pop (bn_t &y, uint32_t &error_code)

Pop a value from the stack.

Parameters
  • y[out] The value popped from the stack

  • error_code[out] The error code

inline __host__ __device__ __forceinline__ void pushx (uint8_t x, uint32_t &error_code, uint8_t *src_byte_data, uint8_t src_byte_size)

Push a value on the stack given by a byte array. If the size of the byte array is smaller than x, the value is padded with zeros for the least significant bytes.

Parameters
  • x[in] The number of bytes to be pushed on the stack

  • error_code[out] The error code

  • src_byte_data[in] The byte array

  • src_byte_size[in] The size of the byte array

inline __host__ __device__ __forceinline__ evm_word_t * get_index (uint32_t index, uint32_t &error_code)

Get the pointer to the stack element at a given index from the top.

Parameters
  • index[in] The index from the top of the stack

  • error_code[out] The error code

Returns

The pointer to the stack element

inline __host__ __device__ __forceinline__ void dupx (uint8_t x, uint32_t &error_code)

Duplicate the stack element at a given index from the top, and push it on the stack.

Parameters
  • index[in] The index from the top of the stack

  • error_code[out] The error code

inline __host__ __device__ __forceinline__ void swapx (uint32_t index, uint32_t &error_code)

Swap the stack element at a given index from the top with the top element.

Parameters
  • index[in] The index from the top of the stack

  • error_code[out] The error code

inline __host__ __device__ __forceinline__ void to_stack_data_t (stack_data_t &dst)

Copy the stack to a stack data structure.

Parameters

dst[out] The stack data structure

inline __host__ __device__ void print (bool full=false)

Print the stack.

Parameters

full[in] If false, prints only active stack elements, otherwise prints the entire stack

inline __host__ cJSON * json (bool full=false)

Generate a JSON object from the stack.

Parameters

full[in] If false, prints only active stack elements, otherwise prints the entire stack

Public Members

stack_data_t *_content#

The conent of the stack

arith_t _arith#

The arithmetical environment

Public Static Functions

static inline __host__ __device__ __forceinline__ void print_stack_data_t (arith_t &arith, stack_data_t &stack_data)

Print the stack data structure.

Parameters
  • arith[in] The arithmetical environment

  • stack_data[in] The stack data structure

static inline __host__ cJSON * json_from_stack_data_t (arith_t &arith, stack_data_t &stack_data)

Generate a JSON object from a stack data structure.

Parameters
  • arith[in] The arithmetical environment

  • stack_data[in] The stack data structure

Returns

The JSON object

static inline __host__ stack_data_t * get_cpu_instances (uint32_t count)

Generate the cpu data structures for the stack.

Parameters

count[in] The number of instances

Returns

The cpu data structures

static inline __host__ void free_cpu_instances (stack_data_t *cpu_instances, uint32_t count)

Free the cpu data structures for the stack.

Parameters
  • cpu_instances[in] The cpu data structures

  • count[in] The number of instances

static inline __host__ stack_data_t * get_gpu_instances_from_cpu_instances (stack_data_t *cpu_instances, uint32_t count)

Generate the gpu data structures for the stack.

Parameters
  • cpu_instances[in] The cpu data structures

  • count[in] The number of instances

Returns

The gpu data structures

static inline __host__ void free_gpu_instances (stack_data_t *gpu_instances, uint32_t count)

Free the gpu data structures for the stack.

Parameters
  • gpu_instances[in] The gpu data structures

  • count[in] The number of instances

static inline __host__ stack_data_t * get_cpu_instances_from_gpu_instances (stack_data_t *gpu_instances, uint32_t count)

Generate the cpu data structures for the stack from the gpu data structures.

Parameters
  • gpu_instances[in] The gpu data structures

  • count[in] The number of instances

Returns

The cpu data structures

Public Static Attributes

static const uint32_t STACK_SIZE = params::STACK_SIZE#

The size of the stack.

struct stack_data_t#

The stack data structure.

Public Members

evm_word_t *stack_base#

The stack YP: (YP: \(\mu_{s}\))

uint32_t stack_offset#

The stack offset (YP: \(|\mu_{s}|\))