Edge AI Add-on API 2.2.0
Loading...
Searching...
No Matches
nrf_axon_platform_simulator.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7
8#pragma once
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14#include <stdint.h>
15#include <stdio.h>
17
18typedef struct {
19 uint64_t overflow_cnt;
20 uint64_t underflow_cnt;
21 uint64_t total_ops_cnt;
23
28
29#define MAX_FUNCTIONS_LOG 100
30typedef struct {
32 uint16_t functionCount;
34
35extern volatile bool axon_simulator_ints_enabled;
36
37
38extern uint64_t nn_o_cycles;
39extern uint64_t dsp_o_cycles;
40
60
61/*
62 * starts the simulator and returns the "base address" of axon .
63 */
65
66#if __unix || (__APPLE__ && __MACH__)
67int fopen_s(FILE** f, const char* name, const char* mode);
68int fprintf_s(FILE * stream,const char * format, ...);
69int fscanf_s(FILE * stream,const char * format, ...);
70size_t fread_s(void * buffer_ptr, size_t buffer_size, size_t size, size_t n, FILE * stream);
71char *strcpy_s(char* dest, size_t size, char const* src);
72#endif
73
74/*
75 * register write to axon nn primitive.
76 * returns:
77 * 0 if normal register written.
78 * 1 if an "action" register was written (meanning the command buffer needs to be serviced)
79 * or a negative error code (invalid address or read-only register)
80 */
84
88
91
94
96
98
99/*
100* processes a pending axon_dsp action request.
101* returns 1 if any interrupts are pending upon completion, 0 if not.
102*/
104 int *check_cfg_err,
105 uint64_t *o_cycles,
106 int *o_wdog_cmd,
107 int *o_wdog_finish);
108
110 int *check_cfg_err,
111 uint64_t *o_cycles,
112 int *o_wdog_cmd,
113 int *o_wdog_finish);
114
115/*
116 * initializes register values to hardware defaults.
117 * returns point to base address of register space.
118 */
121
122// create a register buffer for axons to target when writing to each other
123typedef uint32_t AXONS_SIMULATOR_FAKE_REGISTERS[0x400];
125
127 FILE * src_file,
128 int8_t *test_vector_buffer,
129 uint32_t buffer_length);
131 FILE * src_file,
132 int16_t *test_vector_buffer,
133 uint32_t buffer_length);
134extern void axon_platform_printf(const char* fmt, ...);
135
136void axon_simulator_log_function_saturation(const char* funcName);
140
142 char *input_file_path,
143 char *output_file_path,
144 char *input_file_ext,
145 char *output_file_head_str,
146 uint32_t buffer_size,
147 int (*callback_function)(char *input_file_name, char *output_file_name,
148 int8_t *input_vector, uint32_t buffer_size));
149
150#ifdef __cplusplus
151}
152#endif
uint32_t NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE
Definition nrf_axon_driver.h:76
int axon_dsp_simulator_process_action_request(int *check_cfg_err, uint64_t *o_cycles, int *o_wdog_cmd, int *o_wdog_finish)
NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE axon_dsp_simulator_read_reg(volatile NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE *addr)
void axon_simulator_clear_saturation_cnt()
bool axon_nn_simualtor_int_pending_prim()
void axon_nn_simulator_write_reg(volatile NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE *addr, NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE value)
int axon_nn_simulator_process_action_request(int *check_cfg_err, uint64_t *o_cycles, int *o_wdog_cmd, int *o_wdog_finish)
int axon_nn_simulator_write_reg_prim(volatile NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE *addr, NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE value)
void axon_simulator_read_saturation_cnt(AxonCoreSatCntLogSt *)
AXONS_SIMULATOR_FAKE_REGISTERS axons_simulator_fake_registers
NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE axon_nn_simulator_read_reg_prim(volatile NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE *addr)
#define MAX_FUNCTIONS_LOG
Definition nrf_axon_platform_simulator.h:29
NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE axon_nn_simulator_read_reg(volatile NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE *addr)
void exit_simulator()
void * axon_nn_initialize_registers()
int axon_simulator_get_failure_code(void)
void * axon_dsp_initialize_registers()
uint32_t axon_platform_get_ticks()
void axon_dsp_simulator_write_reg(volatile NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE *addr, NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE value)
int read_in_test_vector_int8(FILE *src_file, int8_t *test_vector_buffer, uint32_t buffer_length)
int nrf_axon_simulator_run_test_files(char *input_file_path, char *output_file_path, char *input_file_ext, char *output_file_head_str, uint32_t buffer_size, int(*callback_function)(char *input_file_name, char *output_file_name, int8_t *input_vector, uint32_t buffer_size))
uint64_t nn_o_cycles
uint32_t AXONS_SIMULATOR_FAKE_REGISTERS[0x400]
Definition nrf_axon_platform_simulator.h:123
int read_in_test_vector_int16(FILE *src_file, int16_t *test_vector_buffer, uint32_t buffer_length)
volatile bool axon_simulator_ints_enabled
void axon_platform_printf(const char *fmt,...)
void nrf_axon_simulator_perfmodel_init()
void nrf_axon_simulator_perfmodel_enable()
uint64_t nrf_axon_simulator_perfmodel_get_cycles()
void axon_simulator_log_function_saturation(const char *funcName)
void nrf_axon_simulator_perfmodel_disable()
void host_wait_for_interrupt()
NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE axon_dsp_simulator_read_reg_prim(volatile NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE *addr)
uint64_t dsp_o_cycles
bool axon_dsp_simualtor_int_pending_prim()
void axon_simulator_print_saturation_statistics()
int axon_dsp_simulator_write_reg_prim(volatile NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE *addr, NRF_AXON_PLATFORM_BITWIDTH_UNSIGNED_TYPE value)
void * start_simulator()
bool nrf_axon_simulator_perfmodel_is_enabled()
uint64_t total_ops_cnt
Definition nrf_axon_platform_simulator.h:21
uint64_t overflow_cnt
Definition nrf_axon_platform_simulator.h:19
uint64_t underflow_cnt
Definition nrf_axon_platform_simulator.h:20
Definition nrf_axon_platform_simulator.h:18
char * name
Definition nrf_axon_platform_simulator.h:25
AxonCoreSatCntLogSt cnts
Definition nrf_axon_platform_simulator.h:26
Definition nrf_axon_platform_simulator.h:24
uint16_t functionCount
Definition nrf_axon_platform_simulator.h:32
Definition nrf_axon_platform_simulator.h:30