diff --git a/Makefile b/Makefile index 5cf96bf10..da17c1fea 100644 --- a/Makefile +++ b/Makefile @@ -178,11 +178,19 @@ openocd.checkout: fi openocd.build: openocd.checkout - cd utils/openocd && ./bootstrap && ./configure --enable-jtag_dpi --prefix=$(INSTALL_DIR)/openocd && make && make install + cd utils/openocd && ./bootstrap && ./configure --enable-jtag_dpi --prefix=$(INSTALL_DIR)/openocd && $(MAKE) && $(MAKE) install openocd.clean: rm -rf $(INSTALL_DIR)/openocd tools/openocd +PROFILER_V2_DIR = $(GAP_SDK_HOME)/tools/profiler_v2 +PROFILER_V2_BUILD_DIR = $(GAP_SDK_HOME)/build/profiler_v2 + +profiler_v2: + cmake -S $(PROFILER_V2_DIR) -B $(PROFILER_V2_BUILD_DIR) + cmake --build $(PROFILER_V2_BUILD_DIR) + cmake --install $(PROFILER_V2_BUILD_DIR) --prefix $(INSTALL_DIR) + profiler: $(MAKE) -C tools/profiler all mkdir -p $(INSTALL_DIR)/bin diff --git a/configs/common.sh b/configs/common.sh index e3d675d5d..ce8f600f5 100644 --- a/configs/common.sh +++ b/configs/common.sh @@ -21,14 +21,14 @@ export NNTOOL_KERNELS_PATH=$NNTOOL_DIR/autotiler/kernels export NNTOOL_MATH_PATH=$NNTOOL_DIR/autotiler/math_funcs export NNTOOL_GENERATOR_PATH=$NNTOOL_DIR/autotiler/generators export PATH=$PATH:"$GAP_SDK_HOME" -export PATH=$PATH:"$NNTOOL_DIR" +export PATH="$NNTOOL_DIR":$PATH # OpenMP export OPENMP_DIR="$GAP_SDK_HOME/libs/openmp" # PulpOS 2 export PULPOS_HOME=$GAP_SDK_HOME/rtos/pulp/pulpos-2 -export PULPOS_MODULES="$GAP_SDK_HOME/rtos/pulp/pulpos-2_gap8 $GAP_SDK_HOME/rtos/pulp/pulpos-2_gap9 $GAP_SDK_HOME/rtos/pmsis/pmsis_bsp $OPENMP_DIR $GAP_SDK_HOME/rtos/sfu" +export PULPOS_MODULES="$GAP_SDK_HOME/rtos/pmsis/pmsis_implem $GAP_SDK_HOME/rtos/pulp/pulpos-2_gap8 $GAP_SDK_HOME/rtos/pulp/pulpos-2_gap9 $GAP_SDK_HOME/rtos/pmsis/pmsis_bsp $OPENMP_DIR $GAP_SDK_HOME/rtos/sfu" export PULPOS_GAP8_HOME=$GAP_SDK_HOME/rtos/pulp/pulpos-2_gap8 export PULPOS_GAP9_HOME=$GAP_SDK_HOME/rtos/pulp/pulpos-2_gap9 export GAP_PULPOS_ARCHI=$GAP_SDK_HOME/rtos/pulp/gap_archi @@ -47,6 +47,9 @@ export RUNTIME_PATH=$GAP_SDK_HOME/pulp-os # For FreeRTOS export FREERTOS_PATH=$GAP_SDK_HOME/rtos/freeRTOS +# For PMSIS +export PMSIS_HOME=$GAP_SDK_HOME/rtos/pmsis + export PATH="$INSTALL_DIR/bin":$PATH export LD_LIBRARY_PATH="$INSTALL_DIR/lib":$LD_LIBRARY_PATH export PYTHONPATH=$INSTALL_DIR/python:$PYTHONPATH @@ -62,7 +65,7 @@ export GVSOC_SRC_PATH=$GAP_SDK_HOME/gvsoc/gvsoc export GVSOC_GAP_SRC_PATH=$GAP_SDK_HOME/gvsoc/gvsoc_gap export GVSOC_SFU_PATH=$GAP_SDK_HOME/gvsoc/gvsoc_gap_sfu source $GAP_SDK_HOME/gvsoc/setup_gvsoc.sh -if [ -e "$GAP_SDK_HOME/configs/skip_udma_build" ]; then +if [ -d "$GAP_SDK_HOME/gvsoc/gvsoc_libs" ]; then export CONFIG_GVSOC_SKIP_UDMA_BUILD=1 fi export PYTHONPATH=$GAP_SDK_HOME/gvsoc/gvsoc_gap/models:$PYTHONPATH @@ -73,7 +76,8 @@ export PYTHONPATH=$GAP_SDK_HOME/gvsoc/gvsoc/engine/python:$PYTHONPATH export PATH="$GAP_SDK_HOME/utils/gaptest":$PATH # Audio framework -export PYTHONPATH=$GAP_SDK_HOME/tools/audio-framework/frontends/python_graph_generator:$GAP_SDK_HOME/tools/audio-framework/components:$PYTHONPATH +export GAP_AUDIO_FRAMEWORK_HOME=$GAP_SDK_HOME/tools/audio-framework +export PYTHONPATH=$GAP_AUDIO_FRAMEWORK_HOME/frontends/python_graph_generator:$GAP_AUDIO_FRAMEWORK_HOME/components:$PYTHONPATH # Autotiler diff --git a/configs/gapuino_v3.sh b/configs/gapuino_v3.sh index 2db43eac9..ff20523ca 100644 --- a/configs/gapuino_v3.sh +++ b/configs/gapuino_v3.sh @@ -23,4 +23,6 @@ export OPENOCD_CABLE=interface/ftdi/gapuino_ftdi.cfg export GAPY_TARGET=gapuino_v3 +export PLPTEST_DEFAULT_PROPERTIES="chip=gap8_v3 chip_family=gap8 board=gapuino_v3 duration=50 test_duration=50" + source $GAP_SDK_HOME/configs/common.sh diff --git a/configs/openocd.sh b/configs/openocd.sh index ff88497ee..61566bc8d 100644 --- a/configs/openocd.sh +++ b/configs/openocd.sh @@ -9,3 +9,7 @@ else fi export PATH=$GAP_SDK_HOME/install/workstation/openocd/bin:$PATH + +# Path to openocd scripts +export OPENOCD_SCRIPTS=$GAP_SDK_HOME/utils/openocd_tools + diff --git a/doc/conf.py b/doc/conf.py index f9bc1c7da..d672e4da7 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -35,6 +35,7 @@ def configure_doxyfile(file_in, file_out, replace_dict): "../rtos/pmsis/pmsis_api/include/pmsis/rtos/", "../rtos/pmsis/pmsis_api/include/pmsis/cluster/", "../rtos/pmsis/pmsis_api/include/pmsis/platforms/", + "../rtos/pmsis/pmsis_api/include/pmsis/", "../rtos/pmsis/pmsis_bsp/include/", "source/reference/builtins/headers/", ] @@ -86,6 +87,10 @@ def configure_doxyfile(file_in, file_out, replace_dict): html_theme = "sphinx_rtd_theme" html_logo = "_static/logo.png" +html_theme_options = { + 'navigation_depth' : -1, +} + # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". diff --git a/examples/autotiler/BilinearResize/Bilinear_Resize.c b/examples/autotiler/BilinearResize/Bilinear_Resize.c index a78ed9819..73ea1bce5 100644 --- a/examples/autotiler/BilinearResize/Bilinear_Resize.c +++ b/examples/autotiler/BilinearResize/Bilinear_Resize.c @@ -115,13 +115,12 @@ void run_Bilinear_Resize(void) cluster_call.ImageOut = ImageOut; /* Prepare task to be offload to Cluster. */ - struct pi_cluster_task task = {0}; - task.entry = (void *) cluster_main; - task.arg = &cluster_call; + struct pi_cluster_task task; + pi_cluster_task(&task, (void *) cluster_main, &cluster_call); task.stack_size = (uint32_t) STACK_SIZE; /* Execute the function "cluster_main" on the Core 0 of cluster. */ - pi_cluster_send_task_to_cl(&cluster_dev, &task); + pi_cluster_send_task(&cluster_dev, &task); pi_l1_free(&cluster_dev, Resize_L1_Memory, _Resize_L1_Memory_SIZE); diff --git a/examples/autotiler/Cifar10/Cifar10.c b/examples/autotiler/Cifar10/Cifar10.c index eb8f0d610..2ef2099a0 100644 --- a/examples/autotiler/Cifar10/Cifar10.c +++ b/examples/autotiler/Cifar10/Cifar10.c @@ -336,12 +336,10 @@ void test_cifar10(void) } struct pi_cluster_task *task = pmsis_l2_malloc(sizeof(struct pi_cluster_task)); - memset(task, 0, sizeof(struct pi_cluster_task)); - task->entry = RunCifar10; - task->arg = NULL; + pi_cluster_task(task, RunCifar10, NULL); // task->stack_size = 2048*2; - pi_cluster_send_task_to_cl(&cluster_dev, task); + pi_cluster_send_task(&cluster_dev, task); pmsis_l1_malloc_free(Cifar10_L1_Memory, _Cifar10_L1_Memory_SIZE); diff --git a/examples/autotiler/FFT2DModel/TestFFT2D.c b/examples/autotiler/FFT2DModel/TestFFT2D.c index daf496b89..f41f2d78d 100644 --- a/examples/autotiler/FFT2DModel/TestFFT2D.c +++ b/examples/autotiler/FFT2DModel/TestFFT2D.c @@ -103,12 +103,10 @@ void fft_2d(void) } struct pi_cluster_task *task = pmsis_l2_malloc(sizeof(struct pi_cluster_task)); - memset(task, 0, sizeof(struct pi_cluster_task)); - task->entry = (void *)Process; - task->arg = (void *) NULL; + pi_cluster_task(task, (void *)Process, (void *) NULL); task->stack_size = (uint32_t) STACK_SIZE; - pi_cluster_send_task_to_cl(&cluster_dev, task); + pi_cluster_send_task(&cluster_dev, task); // Close the cluster pi_cluster_close(&cluster_dev); diff --git a/examples/autotiler/FFTL1/FFTRunTest.c b/examples/autotiler/FFTL1/FFTRunTest.c index f72211d8c..340333255 100644 --- a/examples/autotiler/FFTL1/FFTRunTest.c +++ b/examples/autotiler/FFTL1/FFTRunTest.c @@ -4,6 +4,12 @@ #define pmsis_exit(a) exit(a) #endif +#ifndef SILENT + #define PRINTF printf +#else + #define PRINTF(...) ((void) 0) +#endif + #define __XSTR(__s) __STR(__s) #define __STR(__s) #__s #include @@ -21,7 +27,8 @@ #endif #define STACK_SIZE 2048 typedef void (*FFTFun_T )(void *Data, void *Twiddles, signed char *shift, unsigned int Nfft, unsigned int Inverse); - +PI_L2 int PERF_ARR[6][3][2]; +PI_L2 float MSE_ARR[6][2]; short int *InBuff_q16; float *InBuff_f32, *InBuff_f32R4, *OutBuff_f32; @@ -58,14 +65,14 @@ float MSE_f32(float* real, float* calc, int Size){ void CallFFT(int Nfft, int Type){ // FFT: reset buffers, run and check mse - int start, elapsed, elapsedFFT, Q; + int start, elapsed, elapsedFFT, Q = 0; FFT_InstallArg_T ArgIns; FFT_Arg_T FFTArg; AT_L2_EVENT DmaR_Evt1; - void (*FFTFun)(FFT_Arg_T*); - void (*SwapFun)(SwapSamples_Arg_T*); + void (*FFTFun)(FFT_Arg_T*) = 0; + void (*SwapFun)(SwapSamples_Arg_T*) = 0; char *FFTDataType = 0; - void *InBuff; + void *InBuff = 0; ArgIns.Nfft = Nfft; ArgIns.Radix = ((Nfft)==64 || (Nfft)==256 || (Nfft)==1024)?4:2; @@ -96,11 +103,11 @@ void CallFFT(int Nfft, int Type){ FFTDataType = "Q16"; switch (Nfft) { case 64: ArgIns.Twiddles = R4_Twiddles_fix_64; ArgIns.SwapLUT = R4_SwapTable_fix_64; Q = 10; break; - case 128: ArgIns.Twiddles = R2_Twiddles_fix_128; ArgIns.SwapLUT = R2_SwapTable_fix_128; Q = 8; break; - case 256: ArgIns.Twiddles = R4_Twiddles_fix_256; ArgIns.SwapLUT = R4_SwapTable_fix_256; Q = 8; break; - case 512: ArgIns.Twiddles = R2_Twiddles_fix_512; ArgIns.SwapLUT = R2_SwapTable_fix_512; Q = 6; break; - case 1024: ArgIns.Twiddles = R4_Twiddles_fix_1024; ArgIns.SwapLUT = R4_SwapTable_fix_1024; Q = 6; break; - case 2048: ArgIns.Twiddles = R2_Twiddles_fix_2048; ArgIns.SwapLUT = R2_SwapTable_fix_2048; Q = 4; break; + case 128: ArgIns.Twiddles = R2_Twiddles_fix_128; ArgIns.SwapLUT = R2_SwapTable_fix_128; Q = 7; break; + case 256: ArgIns.Twiddles = R4_Twiddles_fix_256; ArgIns.SwapLUT = R4_SwapTable_fix_256; Q = 6; break; + case 512: ArgIns.Twiddles = R2_Twiddles_fix_512; ArgIns.SwapLUT = R2_SwapTable_fix_512; Q = 5; break; + case 1024: ArgIns.Twiddles = R4_Twiddles_fix_1024; ArgIns.SwapLUT = R4_SwapTable_fix_1024; Q = 4; break; + case 2048: ArgIns.Twiddles = R2_Twiddles_fix_2048; ArgIns.SwapLUT = R2_SwapTable_fix_2048; Q = 3; break; } if (ArgIns.Radix == 2) FFTFun = &Radix2FFT_DIF_Par_Fix16; else FFTFun = &Radix4FFT_DIF_Par_Fix16; @@ -139,24 +146,32 @@ void CallFFT(int Nfft, int Type){ __CALL((*FFTFun), &FFTArg); AT_FORK(gap_ncore(), (void *) (*SwapFun), (void *) &SwapArg); __CALL((*SwapFun), &SwapArg); - elapsed = gap_cl_readhwtimer() - start; printf("| %4d | %3s %6s | %6d | %5d | %6d", Nfft, FFTDataType, ArgIns.Radix==2?"Radix2":"Radix4", elapsedFFT, elapsed, elapsed+elapsedFFT); + elapsed = gap_cl_readhwtimer() - start; + + PERF_ARR[Nfft/128][Type][0] = elapsedFFT; + PERF_ARR[Nfft/128][Type][1] = elapsed; + + + PRINTF("| %4d | %3s %6s | %6d | %5d | %6d", Nfft, FFTDataType, ArgIns.Radix==2?"Radix2":"Radix4", elapsedFFT, elapsed, elapsed+elapsedFFT); #if !defined(__EMUL__) && defined(PERF_ALL) - printf(" | %7d | %7d | %7d | %8d | %7d |", pi_perf_read(PI_PERF_INSTR), pi_perf_read(PI_PERF_ACTIVE_CYCLES), pi_perf_read(PI_PERF_TCDM_CONT), pi_perf_read(PI_PERF_LD_STALL), pi_perf_read(PI_PERF_IMISS)); + PRINTF(" | %7d | %7d | %7d | %8d | %7d |", pi_perf_read(PI_PERF_INSTR), pi_perf_read(PI_PERF_ACTIVE_CYCLES), pi_perf_read(PI_PERF_TCDM_CONT), pi_perf_read(PI_PERF_LD_STALL), pi_perf_read(PI_PERF_IMISS)); #else - printf(" | | | | | |"); + PRINTF(" | | | | | |"); #endif if (Type == 0) { - printf(" |\n"); - // printf("\nOutFFT%d_f32 = np.array([\n", Nfft); for(int i=0;i<(Nfft); i++) printf("%f%+fj, ", InBuff_f32[2*i], InBuff_f32[2*i+1]); printf("])\n"); + PRINTF(" |\n"); + // PRINTF("\nOutFFT%d_f32 = np.array([\n", Nfft); for(int i=0;i<(Nfft); i++) PRINTF("%f%+fj, ", InBuff_f32[2*i], InBuff_f32[2*i+1]); PRINTF("])\n"); } else if (Type == 1) { - // printf("\nOutFFT%d_q16 = np.array([\n", Nfft); for(int i=0;i<(Nfft); i++) printf("%d%+dj, ", ((short int*)InBuff_q16)[2*i], ((short int*)InBuff_q16)[2*i+1]); printf("])\n"); - printf(" %f |\n", MSE_16(InBuff_f32, (short int*) InBuff_q16, Nfft, Q)); + // PRINTF("\nOutFFT%d_q16 = np.array([\n", Nfft); for(int i=0;i<(Nfft); i++) PRINTF("%d%+dj, ", ((short int*)InBuff_q16)[2*i], ((short int*)InBuff_q16)[2*i+1]); PRINTF("])\n"); + MSE_ARR[Nfft/128][0] = MSE_16(InBuff_f32, (short int*) InBuff_q16, Nfft, Q); + PRINTF(" %f |\n", MSE_ARR[Nfft/128][0]); } else if (Type == 2) { #ifdef __gap9__ - // printf("\nOutFFT%d_f16 = np.array([\n", Nfft); for(int i=0;i<(Nfft); i++) printf("%f%+fj, ", ((f16*)OutBuff)[2*i], ((f16*)OutBuff)[2*i+1]); printf("])\n"); - printf(" %f |\n", MSE_f16(InBuff_f32, (f16 *) InBuff_f16, Nfft)); + // PRINTF("\nOutFFT%d_f16 = np.array([\n", Nfft); for(int i=0;i<(Nfft); i++) PRINTF("%f%+fj, ", ((f16*)OutBuff)[2*i], ((f16*)OutBuff)[2*i+1]); PRINTF("])\n"); + MSE_ARR[Nfft/128][1] = MSE_f16(InBuff_f32, (f16 *) InBuff_f16, Nfft); + PRINTF(" %f |\n", MSE_ARR[Nfft/128][1]); #else - printf("\n"); + PRINTF("\n"); #endif } } @@ -171,31 +186,31 @@ static void RunFFT() #endif gap_cl_resethwtimer(); int start, elapsed, timef32; - printf("Initializing inputs....\n"); + PRINTF("Initializing inputs....\n"); //InitData4 (InDataQ16, MAXDIM, 37, 15, 23, 73, 0.1, 0.5, 0.6, 0.8); //InitData4_float(InDataf32, MAXDIM, 37, 15, 23, 73, 0.1, 0.5, 0.6, 0.8); #ifdef __gap9__ for (int i=0; i 0.016) { + printf("Error: MSE too large for %d FFT Q16\n", FFTBins); + printf("Test FAILED\n"); + pmsis_exit(-1); + } + #ifdef __gap9__ + if (MSE_ARR[FFTBins/128][1] > 0.000048) { + printf("Error: MSE too large for %d FFT F16\n", FFTBins); + printf("Test FAILED\n"); + pmsis_exit(-1); + } + #endif + FFTBins *= 2; + } + + printf("Test PASSED\n"); pmsis_exit(0); } diff --git a/examples/autotiler/FFTL1/Makefile b/examples/autotiler/FFTL1/Makefile index 56a7a8a6a..f9886f037 100644 --- a/examples/autotiler/FFTL1/Makefile +++ b/examples/autotiler/FFTL1/Makefile @@ -1,7 +1,7 @@ # User Test #------------------------------------ -PMSIS_OS?=pulpos +#PMSIS_OS?=pulpos APP = test APP_SRCS += FFTRunTest.c $(AT_HOME)/DSP_Libraries/FFT_Library.c $(AT_HOME)/DSP_Libraries/LUT_Tables/TwiddlesDef.c $(AT_HOME)/DSP_Libraries/LUT_Tables/SwapTablesDef.c APP_INC += diff --git a/examples/autotiler/Fir/main.c b/examples/autotiler/Fir/main.c index 539e2351e..a4a954f5a 100644 --- a/examples/autotiler/Fir/main.c +++ b/examples/autotiler/Fir/main.c @@ -194,12 +194,10 @@ void test_fir() printf ("Call cluster\n"); struct pi_cluster_task *task = pmsis_l2_malloc(sizeof(struct pi_cluster_task)); - memset(task, 0, sizeof(struct pi_cluster_task)); - task->entry = cluster_main; - task->arg = (void *) NULL; + pi_cluster_task(task, cluster_main, NULL); task->stack_size = (uint32_t) STACK_SIZE; - pi_cluster_send_task_to_cl(&cluster_dev, task); + pi_cluster_send_task(&cluster_dev, task); pi_cluster_close(&cluster_dev); diff --git a/examples/autotiler/IRFFT2D/FFTRunTest.c b/examples/autotiler/IRFFT2D/FFTRunTest.c index 31d74298b..962158ada 100644 --- a/examples/autotiler/IRFFT2D/FFTRunTest.c +++ b/examples/autotiler/IRFFT2D/FFTRunTest.c @@ -102,11 +102,10 @@ void test_kickoff(void *arg) #ifdef __EMUL__ RunFFT(); #else - struct pi_cluster_task task = {0}; - task.entry = RunFFT; - task.arg = NULL; + struct pi_cluster_task task; + pi_cluster_task(&task, RunFFT, NULL); task.stack_size = (unsigned int) STACK_SIZE; - pi_cluster_send_task_to_cl(&cluster_dev, &task); + pi_cluster_send_task(&cluster_dev, &task); #endif diff --git a/examples/autotiler/IntegralImage/main.c b/examples/autotiler/IntegralImage/main.c index 0d60b867e..d21e7f874 100644 --- a/examples/autotiler/IntegralImage/main.c +++ b/examples/autotiler/IntegralImage/main.c @@ -126,7 +126,7 @@ void integral_image(int argc, char *argv[]) pi_cluster_task(task, (void (*)(void *))cluster_main, (void *) &ClusterCall); - pi_cluster_send_task_to_cl(&cluster_dev, task); + pi_cluster_send_task(&cluster_dev, task); //Enable Debug to print to stdout the result image if(DEBUG){ diff --git a/examples/autotiler/MatMult/MatMult.c b/examples/autotiler/MatMult/MatMult.c index 9bf9a7b8e..ad8e5c283 100644 --- a/examples/autotiler/MatMult/MatMult.c +++ b/examples/autotiler/MatMult/MatMult.c @@ -107,13 +107,12 @@ void run_MatMult(void) } /* Prepare cluster task and send it to cluster. */ - struct pi_cluster_task task = {0}; - task.entry = cluster_main; - task.arg = NULL; + struct pi_cluster_task task; + pi_cluster_task(&task, cluster_main, NULL); task.stack_size = (uint32_t) STACK_SIZE; /* Offloading Task to cluster. */ - pi_cluster_send_task_to_cl(&cluster_dev, &task); + pi_cluster_send_task(&cluster_dev, &task); pi_l1_free(&cluster_dev, L1_Memory, _L1_Memory_SIZE); diff --git a/examples/autotiler/MatrixAdd/MatAdd.c b/examples/autotiler/MatrixAdd/MatAdd.c index 1eba10268..7d30256b4 100644 --- a/examples/autotiler/MatrixAdd/MatAdd.c +++ b/examples/autotiler/MatrixAdd/MatAdd.c @@ -75,13 +75,12 @@ void run_MatAdd(void) printf("Allocated: %p, for %d bytes\n", L1_Memory, _L1_Memory_SIZE); /* Prepare task to be offload to Cluster. */ - struct pi_cluster_task task = {0}; - task.entry = cluster_main; - task.arg = NULL; + struct pi_cluster_task task; + pi_cluster_task(&task, cluster_main, NULL); task.stack_size = (uint32_t) STACK_SIZE; /* Offloading Task to cluster. */ - pi_cluster_send_task_to_cl(&cluster_dev, &task); + pi_cluster_send_task(&cluster_dev, &task); pi_l1_free(&cluster_dev, L1_Memory, _L1_Memory_SIZE); diff --git a/examples/autotiler/Mfcc/MfccRunTest.c b/examples/autotiler/Mfcc/MfccRunTest.c index a11a0d04c..1d483ec3a 100644 --- a/examples/autotiler/Mfcc/MfccRunTest.c +++ b/examples/autotiler/Mfcc/MfccRunTest.c @@ -131,11 +131,10 @@ void test_kickoff(void *arg) #ifdef __EMUL__ RunMFCC(); #else - struct pi_cluster_task task = {0}; - task.entry = RunMFCC; - task.arg = NULL; + struct pi_cluster_task task; + pi_cluster_task(&task, RunMFCC, NULL); task.stack_size = (unsigned int) STACK_SIZE; - pi_cluster_send_task_to_cl(&cluster_dev, &task); + pi_cluster_send_task(&cluster_dev, &task); #endif #ifdef PRINT_INOUT diff --git a/examples/autotiler/Mnist/GenMnist b/examples/autotiler/Mnist/GenMnist index 172bf3b0e..2a3bbf31d 100755 Binary files a/examples/autotiler/Mnist/GenMnist and b/examples/autotiler/Mnist/GenMnist differ diff --git a/examples/autotiler/Mnist/Mnist.c b/examples/autotiler/Mnist/Mnist.c index 2bb54af31..3ae9d57d3 100644 --- a/examples/autotiler/Mnist/Mnist.c +++ b/examples/autotiler/Mnist/Mnist.c @@ -234,12 +234,10 @@ void test_mnist(void) struct pi_cluster_task *task = pmsis_l2_malloc(sizeof(struct pi_cluster_task)); - memset(task, 0, sizeof(struct pi_cluster_task)); - task->entry = RunMnist; - task->arg = (void *) &rec_digit; + pi_cluster_task(task, RunMnist, (void *) &rec_digit); task->stack_size = (uint32_t) STACK_SIZE; - pi_cluster_send_task_to_cl(&cluster_dev, task); + pi_cluster_send_task(&cluster_dev, task); pmsis_l1_malloc_free(Mnist_L1_Memory, _Mnist_L1_Memory_SIZE); diff --git a/examples/autotiler/MnistGraph/Mnist.c b/examples/autotiler/MnistGraph/Mnist.c index ba6a43b76..644d71d64 100644 --- a/examples/autotiler/MnistGraph/Mnist.c +++ b/examples/autotiler/MnistGraph/Mnist.c @@ -187,7 +187,7 @@ void test_mnist(void) pi_cluster_task(task, (void (*)(void *))RunMnist, (void *) &rec_digit); printf("Calling Cluster\n"); - pi_cluster_send_task_to_cl(&cluster_dev, task); + pi_cluster_send_task(&cluster_dev, task); MnistCNN_Destruct(); pi_cluster_close(&cluster_dev); diff --git a/examples/libs/jpeg_encoder/Makefile b/examples/libs/jpeg_encoder/Makefile index d183dea4a..c2330a3aa 100644 --- a/examples/libs/jpeg_encoder/Makefile +++ b/examples/libs/jpeg_encoder/Makefile @@ -1,12 +1,30 @@ APP = jpeg_encoder APP_SRCS += test.c APP_INC += -#Uncomment to compute Jpeg on cluster -#APP_CFLAGS += -DRUN_ENCODER_ON_CLUSTER=1 -APP_CFLAGS += -O3 -g -w -APP_CFLAGS += -I$(TILER_EMU_INC) -I$(TILER_INC) $(CNN_LIB_INCLUDE) -## This define can be used to change JPEG Quality +COLOR_JPG?=0 +RUN_ON_CLUSTER?=1 + +ifeq ($(COLOR_JPG), 1) + APP_CFLAGS += -DCOLOR_JPG=1 + APP_CFLAGS += -DIMG_W=320 + APP_CFLAGS += -DIMG_H=240 + APP_CFLAGS += -DIMG_C=3 + APP_CFLAGS += -DIMAGE_FILE=$(CURDIR)/imgTest0.ppm +else + APP_CFLAGS += -DIMG_W=324 + APP_CFLAGS += -DIMG_H=244 + APP_CFLAGS += -DIMG_C=1 + APP_CFLAGS += -DIMAGE_FILE=$(CURDIR)/imgTest0.pgm +endif + + +ifeq ($(RUN_ON_CLUSTER), 1) + APP_CFLAGS += -DRUN_ENCODER_ON_CLUSTER=1 +endif + + +## These defines can be used to change JPEG Quality ## Here are listed to the possible values ## The default value (without defining any flag) is JPEG_Q_50 #APP_CFLAGS += -DJPEG_Q_0 @@ -17,16 +35,16 @@ APP_CFLAGS += -I$(TILER_EMU_INC) -I$(TILER_INC) $(CNN_LIB_INCLUDE) #APP_CFLAGS += -DJPEG_Q_95 -IMAGE1=imgTest0.pgm - # Include GAP_LIB/JPEG CONFIG_GAP_LIB_JPEG = 1 # Include GAP_LIB/IMGIO CONFIG_GAP_LIB_IMGIO = 1 +APP_CFLAGS += -O3 -g -w +APP_CFLAGS += -I$(TILER_EMU_INC) -I$(TILER_INC) $(CNN_LIB_INCLUDE) io=host -# export GAP_USE_OPENOCD=1 -#READFS_FILES += $(IMAGE1) +clean:: + rm -f imgTest0.jpg -include $(RULES_DIR)/pmsis_rules.mk +include $(RULES_DIR)/pmsis_rules.mk \ No newline at end of file diff --git a/examples/libs/jpeg_encoder/README b/examples/libs/jpeg_encoder/README deleted file mode 100644 index 2c6071bcf..000000000 --- a/examples/libs/jpeg_encoder/README +++ /dev/null @@ -1,4 +0,0 @@ -This is an example of JPEG encoding. -It reads the input PGM image from the flash, encodes it to JPEG, and saves it to the workstation using semi-hosting. -You can run this example with "make clean all run" or "make clean all run platform=gvsoc". -Once it has been run, the output JPEG image can be opened in the build folder with "xview BUILD/GAP8_V2/GCC_RISCV/imgTest0.jpg" (on gapuino v2). \ No newline at end of file diff --git a/examples/libs/jpeg_encoder/README.rst b/examples/libs/jpeg_encoder/README.rst new file mode 100644 index 000000000..119b1eb2d --- /dev/null +++ b/examples/libs/jpeg_encoder/README.rst @@ -0,0 +1,36 @@ +Jpeg Encoder +===== + +This is an example of JPEG encoding. +It reads the input PGM image from the flash, encodes it to JPEG, and saves it to the workstation using semi-hosting. + +You can run this example with "make clean all run" or "make clean all run platform=gvsoc". +Once it has been run, the output JPEG image can be opened in the build folder with + +.. code-block:: c + + xview imgTest0.jpg + +Versions +-------- + +You can choose to run the monchrome or the color example changing this flag ``COLOR_JPG?=1`` in the Makefile. + +You can run the encoder on the Gap Cluster or Fabric Controller. This flag ``RUN_ON_CLUSTER?=1`` in the makefile control the execution. + + +Jpeg Quality and Compression +-------- + +There are different level of jpeg compression available. The default value (without defining any flag in the Makefile) is JPEG_Q_50 which representes 50% compression. + +To change the Jpeg quality you can add one of these flags in the Makefile: + +.. code-block:: c + + APP_CFLAGS += -DJPEG_Q_0 + APP_CFLAGS += -DJPEG_Q_10 + APP_CFLAGS += -DJPEG_Q_20 + APP_CFLAGS += -DJPEG_Q_90 + APP_CFLAGS += -DJPEG_Q_90 + APP_CFLAGS += -DJPEG_Q_95 \ No newline at end of file diff --git a/examples/libs/jpeg_encoder/gaptest.yml b/examples/libs/jpeg_encoder/gaptest.yml new file mode 100644 index 000000000..e3ac8be09 --- /dev/null +++ b/examples/libs/jpeg_encoder/gaptest.yml @@ -0,0 +1,56 @@ +name: jpeg_encoder +boards: [] +platforms: + - board + - gvsoc +os: +# - freertos + - pulpos +chips: + - gap8 +# - gap9 +variants: + monochorme_cl: + name: standard + tags: + - integration + - release + duration: standard + os: + - pulpos + chips: + - gap8 + flags: COLOR_JPG=0 RUN_ON_CLUSTER=1 + color_cl: + name: standard + tags: + - integration + - release + duration: standard + os: + - pulpos + chips: + - gap8 + flags: COLOR_JPG=1 RUN_ON_CLUSTER=1 + monochorme_fc: + name: standard + tags: + - integration + - release + duration: standard + os: + - pulpos + chips: + - gap8 + flags: COLOR_JPG=0 RUN_ON_CLUSTER=0 + color_fc: + name: standard + tags: + - integration + - release + duration: standard + os: + - pulpos + chips: + - gap8 + flags: COLOR_JPG=1 RUN_ON_CLUSTER=0 \ No newline at end of file diff --git a/examples/libs/jpeg_encoder/imgTest0.ppm b/examples/libs/jpeg_encoder/imgTest0.ppm new file mode 100644 index 000000000..227e1f17f --- /dev/null +++ b/examples/libs/jpeg_encoder/imgTest0.ppm @@ -0,0 +1,4 @@ +P6 +320 240 +255 +!, ) - / -!,!,$+!.#+"/!+#,"/".#- -",#.%,$,#+#+$-!/#.'0(1/74==G@F?H AIAG>I>G=E:B:@?C>DDKKMGLLQMPPX![\gf$ik hn%en#dp&fp'jq'hv%jo%fh#ac"X[YTRTEI9?5:88486756566;HIXj't269999~71~042}3sz+ji)g\"_X bV!bW^V!h`!eg"lk#nj&qo%rv(ry.w~0u},is,Tb'8F!#,#%$' %          !!!  !!!!!      *!+ +"--".#.%- -#/%-!-#.#.",#,!.!,$-#,$,#- -&/$/%1)30:<@FHDNCODM DO>P@H;H:D>B;B:=6?<<=?>A@=?:@=?=>;=8B9><@>AD7;5<6;;;;<8:79:<;<FFV["m~-}9~5}3|3}5}1y.v/v~-u|,zy&vo#nf$j] f] a[!`Y"[X#[U_W!eb#qj#u{'|*}/}0y0u|.Ud*5E!&,#%(*!# !  ! "     ! !!   !!    ! "  ! #+$+!. +/"-#.#-!.%--!+#-#."- -!-#-$-"-#-#,#0$3)5-:;DDOLWK[ NZ$LYMT"IV$FPEPEHEG@C?D?A>A@CADEHIJOOPPJMJJNIVQVQ TSHL@F=<?@>AFI[\$jw.y4{4}103z0ly)jh'll"pq#ts(vq&sl$qg#ia d\_[ \Z!XWZZ!`[ ji#p|+z/~.x11q/\n+5E$$+#$$,# "  !  !!!!!! !"""! !!!!!!! !!+#.".#-,". -$- ,"+$.#- .!.!/-!-"0$+",$-%-'0(239;DFNM^"O_!P_"Q_#Rd$Q]"NV#JQ IQ GN DMCG@H@BCE=DBEDFCE@DBE?F=C=@=@?@=<;@?A?>=B;AABNLW\"lr)y0|0y.w/w0u},gn(d_"ec#qq%vx(vt#vr#ql!h`"h^!f] h\`]#X\!TY]k'l}*|/6{7v4z4_w33F$%+$&#(" !"!  !!"!!  !!!! !! """!! !"  ! !!!!! !"! !.$."."/#/-!/"-".$.#,",!/"/%.$/#-#1#-".#/&.(30;D>B=@9@=AC@F?G?H>DC:B=>=>;B@B>CAFCDEJOQZ^!qt(q,u+x+x/v0pu*ba$^U`Wef pq$qn(sr%nh$ed ic"ic!lf#de#a`"\`#gn%y2:6345_z14G#$."'&(#  %! ! !! "!!! !  ! !!!  !!" !#!! ! "! #%"!#!! " !/#0#/#-"- /!-#."."/#/!-"-$/".%. /"/#/%0&0(50<:FJVZe%Zn(_l)\o&Yo+Zg&Xi&Ta&S\ MT QV NS LVIRKOGKIKIJGLEOFLDLGIEGAE?E=A<@??;B=B?D<@@B=CAFCH?I>G@A9>;AACDGKJGHJMYVih$q+v-|,o,qy,jo+jf#aW%XU\R ^Y"f_!fd&nh#lj#nh!jf#pi#nn#hk%bc$fi'x.:?8|3|35\~17E#$-!($) "! !&" ""!! "!"! !! !  " # !!!"" !"" !  "!"""" !#!  ! #,!- /!.".".#-!,"0#/%.".!0"/","/!.%0#0%1*61:BBE@E>EAD?D?GCGADAC?D??ADEEIHKJNKO^\"go$s~.w~,s{0kw,kj&ib$_[_X WSTKUM_R`]"d_$dh#ie%np#yq%wv'us'ln"nr){3@~A|:}1-{2Yw03C &.$'$(#!  &$ !""!!"!"  "!!!! "!""  !#""""" ##!!! $!"!!#  !!  "  "/#."- /"."."-$0".%0#.%."/!0'/#-#0&2$/+3/:;HOX!Xk$fz)b(d~/a|-cy.^r,Zk(Sd&T`"R^#Q^!Ud$W`$V_#VZQV"RWOSNSMSNTLW!NT LO!JOGJEG@B@D@A?BDGBHCF CFDFDCCH@E?E@;B@C@GFJGO"MQMOW["el*p{,m{-lt+ik'd` a[ `Y!]SWO!RIOKTRXS!]V!f_$mm'x|'|'v~*rz&su(yv(z1{8y8v0},z-y,Xq.6A ).#*#)# "($  " ""#!!!"!!!"#!!" #!!#!#"!"  !#"""# !#! " $#!!"!"!!!" !."/ .#.$-".$1"- -$."/#1$,$."1#-$/$0*1-<$.&*'*$"" )" #"""$###$%$##$##$#!$$#"%%$#"$&$$%$$$#$%%#$#$$#&$%$$%#"$$$##%!"##/!-#/%1%0%.$0%1$/$2#/#/#0$1'4-88CGQ \i$f(i,k+j2o0k2h/j~-cv+bq'`m$ao'bp$Yi'S`#Tg#hy.s4n1i.bw,]n'`i$[b#\f$]i#ak'^r%[n&`k&`f"V\#SRKJKJMMSRTV VY"R\!QVQN NKIFBDE?BADBEFJIQR#U[&Y\&PV%KPFGEGCDDFNN!QQWZ"TX!XU XQSMMLJGMJTT"]e#m0w>{;|:v{/jq&gf"db$c^"`Z b\c`!ed#^b'[\'DO!5>!(1'(&) $  !'!!$%!#$#$#$"%#$$#$#$$$#$"$%&#$#%%%%#%%#%&##&&&&%$%$##$$%%%%$%$$%$"%$&/$/%2#/#/$0%1'0#.%1#/$0%0$4-94>DPXd"d{'n*p-p.m,l/_{1et+mx+my*iy'ap%gp%dn#\m'Wj&^o'g/u7r3n0dx*_s&\h#Zf&]f$[h ah$eo(fv'hu(`p&X`"UR!LNPMNLOTT\"Z]"\b$R[ PU NOLGHBDA?@BAADDHOS!NT#OZ#QT"MO GHFB@ABBEDJLPR RP!ST#URQKNHJFSJXW ae&jy.u6p8p3nt*lm)f_"cY!`W_Wd] ^^!a^ a\\\"ER"2A%(1&)#) $!  #+$ #!$&$""##"$#%$%&#%%##$%#&%&%$$%#%&#%%$&$#%#$%#$$$&'%%$%%&%&%$'%%%$"/$/$0#/!0$/#/#0#/'0%0"3&3)45A@LZc#cw)m0o-n-p1n1i,`q*\k'et&i~'m{)i{'dv,cw&as*ct&e|,i7u>m7k1dw)ak&Yf"Yf"Yd$Zd![g&_q)fx+kv-jt+be$TV RMNNSOWU Y] _h!^g"_["WWSV!PJKDF@C?BABEFHKMPTKT#NQHKDGAB=AB>@ABCGHFM KN RPROOHMIUJ YU `c'as,gw1iz5jv-kq'ih&c`#cY"^X!_X\Z _[!_Z%ca"ce(HW&5C"(2(,$)#!!#'&#$%&!%&&%$%##$$$%#&!$&'$%%$"$%%&&%%$&$$'%%&$$'&%&&&(&'%')'((')'*#$"$0$2#1"/%1#1#/#0$0#1$4&3*42=?IP`$`u)p/h+q0p0r0i0dt+Xj$Yg#_r%m-k+g*i}(gz'fw)ix)h-p4o9k4k|/hy)aj&[c#[c!Wb%Zd"Ye%Yo*dx)j0jz+`k&XY$WRTOWVVV!X^ ]d#]e(`c#\_!VT!LJJFFAD?D@CBCGFH JMFM GMFJFD?@>>;?<=:@?;<;;:=9=7;5<?@FIGHMLOO!PSMP!UV#VW&U^#[^$]_$[]#^Z"]Z bZ aa!fa hcii"jo&ir'G]'5B!(0&-") % # !$* )  "$%$&%&%&&&%%&&''&#%%&%%'$&((&'&''&(*(*(('()(())*)*)**+,)**-+-+- . - ."0"1#2&0&0&0'0(2&/(2%.(51<9IM\#dr(i+q+p,q-r1n*dw+_m'\e%W^#V_[j$fv%n.q)l~)m~*m+j~)i~)m-g|.jt*bn'`f%Y]#X^!X]"W`!Wc%Wk(`t's2s7t5iv,aa$XVYX!^]`Z ]d"dk"bi'`i$]e!\a%PTNKIBEDFBCBCCBECEFFCFAB?AA@;=<<=>;=:<09.73<;BHJLNHP ILQOMKPMQP WUUV!UV!ZP_X!^`!jh$ml'pm"ps&qw'sy-H[)4?"(2*-$)!$!%!!$-!* "$%&%&&&&$(''%'('&'&('&&)((())()***,+**++-*++,,-.-/ . ./. 3"1 $4'8+>!2C 5L#?T$Le*Qp+^}1g7pB?K$2%0!3'.%0&2$2%2%3'5198GK["^t)r,r)o2p/q1o/h.er*`m%ag#^b"T^!__$gs*n(q+l~(h{*n)l|'iz(i{,k|*gn$]m%[d$Y^ RYXZ"^`#`f%er(o/x9~@:>;;7:8>;;29+4,55<=AFIGHLIFFMELIMMKKPM LKPLXV"de'ko)my+kv'mv*r},jy.H])6A"+4'-#( % !%!&.'!%&'''&&'&%%')%'('*'&&'((()*(****,--*...!- 1/ 2"1#3%4#7*< /B 3G$:O$F\&Pn,Zz0l>>8>::9:5;;;6<2:,7*4034<@;==<6>:;:<8:8;5:394;17-4)2)2*5,367:>ABECFDAFHFDD CEGJOW[c(bn-^o0im)il(il&dm*DT(2C$(3&.&*%!# !$%.& ! #&'* ,- + * .."+ -"-#0#3%3 %4&7 (7!1; 0B$5H(&E&0!-*+>7?{ܠ۝ݚ֤ߝڡٜ]$0&4&2'4&3'4+91>@K Pc"jw+p1p-q1s4w6t5o1e}+ht(fv'is%fm&ep$`g!]e$`e"dj&hz*m)v-v+s*p+q)o~)gu(do(\]$WT!SSONRS[VY\!_h%du)n{,my*ix,lr)jt#go$eo#dm%bi&Xa"V`$^m*ew0cr+]h&X^$SV#ONFHCHGF?E?B8:7<5>575927492;16,7*3*3*1)3-619:=?BBDBCAD@@B@FELO X]&Wd*\d'^f*ef&]g)]a%@Q$5B#*0),&)!%"$!$$.!% !"""$#$!)#+$.%/$1'5,9 &<".?$2B%8J*>O,E[-Rf4\s9g>wDWfsՈ33,+) -LNܣ٧נc#3&2'2(6'4*60==HRY"`w*r/o.u-r2v5v5r4m+ky)fu(kt'hv$ju$hw%aq#bi%^g&ah"fu%k~%v+w.z)p(o&m{-r{+dq&Ye%VU SPQJPQYV ]`"bg#fn&hq&pw'lv(nx)jr$ip$jr#hr&gi%U_!Wa%fr*c{1ar*]`(V_"PYMP IHDGAC>C5;493879182847190818/1,5,1)2)1*317688>>@@@@@?B??CDIITS SZ$U]&[a&U]"\\%TZ%EP#4B!+3,0%* '!$'"$'0!) !#!#"$%'(")#-&0)2!,76@#9H$CT-J_0Yk4cx;rEQ_p}ܓꥤ˞ɝʤ֞Тўߢې3!61-, 0NR"~ޜޞܡc)2%4(3%3'8/<:FKW#^r)g0q.p.q2v4w4n2j/fw)fv,ls*mz)l%q~&ly'dv$dq'fo"`j"bl%hw't.z-w,p)o(p|(sz+ir(ce%XZ!UPRN!TTZX"[]#cf"ej$im$hu&lr&ms&kp#np%np$ip(^m'Ze$[i'du-hw.[i)Yd(T\&LU"HN EIBE BA@8<8:2;1<373939282748/71504*5,2'2'1*3)4.7297:=>>=?AB@AAGGJN PO!RU"OU#ST!SS KO"AJ3@#(4+/%+%#& %$&.!%  %)($.#-(5-9 1?$6F&AP)M[/Yk5jwBACAEFNJKKHL!KJLI ML ?I$0>"*2)/%*"'!$!'#$$-& !"!% =<JT(Yc3dr:wANZnՅޗ쪳̭Щߵڴۥ5 ;6 //1PQ#ݦq&4&4,5.:7CET#Wk)k-n1s/z4w4u1t3k1hz.dq([o&`l$du&o}+n-w-o,n)i{,js(`j$`g#bn$ny*w,~+x+u)q}+u{)m{)ei'\["WVZUZT"c_!^e!ei#io%ep%cl$bg"cd$\a"]b$bl#io$lo#go&fs(du-_l-Sb%V["OW"MT"EL>D;@9>8?:@3;3:49579:9<9=9=3<27282624-5'4*2)4)2*3)5*3,31989=>>?==>@B@DECEDEHD IFJFBI 5>",3*-%*!&! '%&). '    "#&&' ,#.&2.42;+?3! !\DqʶӸشٹ۾ש9!;2 / !/ 2RR#t&6&5,97B@SYj'e,t2u0x3w5{2w4t3dz,ds*Zh%Yg#[c$\l&d|*r1x0u,n+oz'kx(gq%dh%bl"n{'t-{.y.w+t*u+qu(im&`c#[Z#[X!][c^"ik!il'hl&io&ai!Zb%YX YY W\"aa$ho"hp'_o(ep'^q*Yf*S\#PY#KT"IN DG>@6?;;8A5=3<2747688=>BGEGICD@@7>6;2906+6(4)2*2,2)5+4(4-4179:;==?;<@@?A=?A?FCIDFEAK 5?#-4/.)- '!#"& '$/'  """"%(&$)$-&2,5/84A:G;O!@W"F]&Gc*Gk,Nq.Iu0Ju4Cr:=- !"[Zۿ8":21 "2 2PN!~'4,95E@P"Tf'j.u2t3w5y3x8t4h6h~,dr)_l&\d"[a"Tb$Wg'cx,s2~9t1t)m~(js&hp&cm#fn&nx&{00|-y+w+v)xw)mp&he&c_!\] a^"hg$ij"qq$kq'ek%de#[[!]V UV!\X^_%bk&fp%gl'_l&Yd'V^%PXNOHRFM?F?A7<7>9<6:393:3<9>DDNOUU"W\$V\$OU KO!DF>B5?5;*7.5*3*3,3*3.2,3+62:9><<8=>=?==<><@@B@DF@J 3@!+1,1%0 (#'%'%/!(   !  ##%!'")"*(.*2.63<;D9LBR#B[$Jc(Hh+Mm0Ip5Ju4Jx1Jy8O7L}4N8N8K5L3Q5N5Ev8@-!! &i]ݻ߮;!=70"1&3MQ!},92@ER"Ve%k.p4x2|6x4y9w;q4k-dv+al'Zf$Zc&Ua"Va"Zg%h{/~:9x2t,k{,pw$gt&hn$dq&rx&y.~2|-~.w+{*y*pv&hj%ec#db$dhkk$mo'mv$mr%hn&Z\#[VQQTQUV`["`f"em'`m&\e"W_"TX#ORMN!GNDKC@ED?I!4A"+1-0',!& $!'#'&/!&!         ! !!   $!("*$+%/+6097A=FAOHWHY%Gc+Li*Ko1Iq1Ky2N|8Mz4N~4M5L~9O}8K5R8M6K7Q8O5Q3J6M7O3P6Q6L4Bx2=-#! %i^ݻ߱;$?7$4"%4!$1!SO!/ABP!Ye%j*v2q4~5v6z5x9t5p.cy+`p(\e&Vb%Xc"\a%\i'[q(r1BA|6n.v|(kt(is(eq'iq&jz&u+/00y.x,x-t}*or%hi&ff&ii&ln(nt&o|(mw*jp&]^"VS!NOUS WQ"XYZc"ah'bg'\^$T[%QV"JQ"FN FI@E@B:A;=:>8<4=59496>GGSV$X[$X_$V]&Ya)^g*]h(^e+_a(Z_%Xa(XY#LN!AK =A7>28/7*6+6*518299::::;99=:>>B@DE>K"5F!&3+/(.!& $$(!%('2'  !! ! !  !""!!!#&%%!)")%/'0(2) %$$@<#2!"1#5OS#>K Pa#f,u2t7z6{6y8t7w7m3g~._q&`b%Yb#X] Vc"Wc#cl$l}-{6DC{8s/r*jy'ks&fn$hq&ju&p)x.{10/~1x,t)t{+kp&ik%jn$pq&sv%p~)p|*ll&a]"[V"TMQO TR YX _]"]e"]b$Y_#SZ"PS!IP!HLAH?F<<7=7<19789;;@GN OQPR#HP!JL!PR"P]&UY'WY"\_)gh)lo.lp-ci,^_'NW$JT$CJ!9C2<28.6.6.828;;8<88:=:;=@AE?K!3A$*4+0&*#% $!(#')$1 *"! "  !!    !    !"!! "#% %#("+'-(1,5 182?"=G$GQ)R\0Zh5ct?mFmW^Z#J@",/Ie.P{9R{3Oz3N3Px4M|4O}2M~4S~4R8S7N3P4P3P6S6O6Q8P8P3P8R7R4Q6K8R6O:U5T9Q7N6O8Q7L6O8K958>*%""&qc =!B:!4!#2$3!JR$O]%gz,q2w2z3x3|4|8>7;59454;7=0:074998:<<=9>=<CD>L$4C"-3,1(.#'!%&"(+'2 (!! !  !!"!    !!!!! "$% '"(%,*,*2.7!4;"6C%v6y-o*p}+mw(lt"mr&hl$gs(i|)s-022}1|-r,s~(y{'ox(rw$mx&qw)ry)fm'dh!]W!VRQOWPVXX\"\a$W_"OY!NT JOEJALAD!>A<@7=2<3<4=7<6=ACKM JNCL9B <@GI!UW$_`'\c#hc&ee'lm*km*fl*bl,^f+bf+en-ns1on/ih,\e(R['IO#@G;A7C6>9<;=<;<>DFBO"3D&06/2&,"(#$ '#',(0 ("     !"! "!  #" #$!"!"  $")&)%,(0+5495>!;C(JM*MU-\c2`n9k{BlQp]siqvtxx{{™ƚzǘ|ƞyƢʟ}ɠy̢{ͤ|вxϥ{Υg"OV !15Nj0O5P2T4N5P3M3Q8S5N5T3Q6Q7U5R7X3Q8T8V4T7P6W7S7N7Q5U6Q6S:U9Q9Q7S6N8Q:P;Q9Q6H< ?-#$ 'ti"?#A;"4"$3 "6MP$q1u0r2x4y7z9z9n6k.ft)dk&Ya$ZY"QV!TW"YU"VY#Z`$ci'i{*n0{8~7v4z/v,n(s{&nt%lm&dm%in&cr'p}(/6|0~/z+z)v,v)x)sy(vx'pz(s{(jp)gf#a["WW"TRTSSTV[#Y_"T^#UU!PRJM"GIAH=C9?7@9:4<2;696><@GJGM$HKBE9AhFnRl[qivyusvwvvpÝ|z|ƞǛzɚ|ś~ˠ~ɢͩͥ~Φ͡{ͪ~ХˬХ~ׯ|Ԩi#O^ !"07Or.P7P4X5R4M2U6T6O4R5U7S6P2T6S7U3T4U8U5S7W7V7V8T8U9P6W5U8V9W8S:S7V9Q9Q;V7O6IB;?8;9:3=6<79<>DGLN!JL!HI9E9??@JS#\c'ku.iz.lt-ip.dm+il+ek*ef']a'b`'ad(fe(gk*lm,st+zy2kx0nr0pq1ho+bh+\b'PU%II@CKICO%7B#/5.3(/!($(( *+)1!'!  "!#!$!'$'('(+/..0368;@?KF PL!^Y%ke,}n-}4=zG,V6&"25oIqyxpxvtzw“uœ}v{ʜ}Ý~ę}ġ~ʣ}̢{ɥ̡ỵ~ʫϧ~ʢϨϣЭ~ӥҧҧxΦ{լԫe!MZ!""55Qr4U;P5S3T7S4U5U7V7P6R6U:Q7V4U5V6X:T9T9[7V>+&$#(l%D&C:4$%3%6!NP%t5y4|3{2z6r5o-ex)lv)fo'cd!^`!YY!YYQSTY"U\!X`#_c!fs(p*v1v0y.}.w.z&r~)ov)mq(mo&fp$fk%do%w,}03}.},)y)y*t*ow)i~+o,v/y*lt(ab&^Z\S!RS!VSWW"TV"VY!OV"JRDLBJ @D>C:?:<5;4;3;9?GC INFQ IP>E:> 8>BCJL YZ#Zi)`i/]f,`g+gf+il+mp.tt-os,qq,in*pp*kp-js(ht1ko.hp/jo+su.mx1v~7o{2no1`^+VZ#PT"EV%7D$/605&.#)"('!(,'0 *#"!"$2.9<GG RM"]Z&lb)zt.7;CRYbhrvro}0aQ&#88nMzvtwuy™|šyƗwěÝxŚzĤƤ}ơvΧ{ţ˥ʤ|ˤ}ɡ̫ѪѨФЦΪЩЩѨӬت׫ұj NY#"$88Pt/T7R8S7Y5R6S4V6S8R5R8W;U8X5Z6Y7X5X7Z7T7V9U;S9V;Y:Q:X8W;X8V9Y;V:T=Q:=6<7=:<@BIKMM"GO$CJDGJ FPCN#GP#OV#XY$a^$ff*qs*sz1ox-v|2rz.sy1tt1sw4mq/mn+il-fe)en+lm.ny3r|1q2rz-pr*bi(CU'6B%-8/3-/ (%( ' ")/'3!( !  "6.vf-DS_`gllpomoqsstotu/_M#&%4:kTusyuv{zŞyǛ{ĞvŞ{Ƣ}¢~ɣzΩͤ͝}ѥΥЪ~ˡЭϣӪѪԮҪҪدԭޱհӫ֯k!MY#$"69Ty4S9P7T4R7V5V6T7V:U6S8V8U5Z5[:X:Z8Z7[8T;[9XJ>?/)'#*|r(H(D@#4%$4 $5#HN"|x2w5{4w8s0m,ny*mx)py)is'ko'ee&]`$[\"XX#]\!]^!^a$ae#ek#io#mw's*x+u,v,x+t(pz&ns'kl#ks%ho$kj#ox'}*0~0-}+{*{*l{*`r+eq*t09{6s},eo&cc&[[#XV#XURY SS NTIPFL BH?D;C9>:=7=2:7<=BCGEH!JN!CG!?D-'%'.t%D'GB#7%%2#'9"JO%{y4u7u5r/n+k}(l}*jy)p|+iw+gw'cm%\b&ba"c`$`_#_c!`f$ej#il#ho$lx&nv&r{+r+x(v-t+rv)lx'qu'oq&iq%ol#nt(x-/~.*)v.x.p{*gr(lw*{3;};t3lp)cf&Z\$WX"TSTTPT#NP!HP DKEB;A9@:@7<9<9==CDCJIIJAL >F ;D@D?D;D=B;B@DHLLPJO OOYU!VY#U\(XZ%Za,Zd*[c)lm*qw2{~3|3~5{~4w}1tv3rv0kj,jh'gl(pp0sv0cl.D\+7A$2608.3#(', )$)1'2*# #$?;9[bdhfhsmjllqptusrt-[N)"'=@zg}{›zǘ{ʟ~̝{Ơť˝~ʜ}˟ʤ̤}̣͠ӬҡШҩէԭרح֩٭ܯدڭްݩٱܮڱدh IR$!$6=Sz4V8X7R8X7W7Z9Y:Z9V9X8X9W:Z8W;Y7[=[=Y9Y>\<^;Z9Y?Y?Z<^9X:[=X;Y9WR>Y?Z;Y:K?">-''#)u'I*G>$6"'6!)7!LL'z8q7s5p.l~(my,r|(m})o*q})iy'lr$kg#da!ab%fe!gg$dk!gl%lo(kq#jq$lw(t{'v*z*{*x+py%oz(pv%ns%os'lr&mr&t(-~-*..x,s)sx+r+|3@|B;?CDIKIM"EK =G@@=C@F =E9@;ABDRPdb$df'[`(VX SX#UW#PU$EQ"HJ!FK#MO$XZ&ii,pt/r{4v3|7z5w3y5t}/tw1vt.sv/ll-`j)O^-6F'094:-1#+&+ ,#*/*2"(#"$"@;<_dhjjiqmtppnpqsruo/WN#("(>@{a}˜zƠ}Øɟ~Ś͡Ƞͣ˦~ˤˤȥͩѦӪ֧ҪӮک֫өըܬ׬گֳܱܱ۬ᧁ޳ܱܹe$FQ$##9=W{4V;V;W5Y4X9[2W6Y;S5V8X:[8X8Y8]:[;]:Z;]<[:Z:]9Y<\:[Z?[?^;[>L>$=/' '&.y&E(H?%9$#6!';"MN&yu6s2n+l{'n{+u~*s(r~(t*o}(m)mv'io%gg%dk$dm!el$jl&jq%mt%nu(ot)rt'v{(s*y,y,t*t(u}*t{'uz&qy*tv'pw'u~(x+,}+z.{--v,t}+r0}:@t;o4gp+cf%X_%UW#QU LS HQIO!ILDG>E9D8?9?6;=A>AIHJM!EL#AH =E@CBC=G>B9@BCNN[[#nl)lt-jo,gl)ad'a_$XZ"VR!HLHI!KJRO!a[&mf+vn-w}.q3q2x3|7545v}3kv-gn.J`26J%/;69*1$)'**%+1(2("#! %C>A_eemqormsmorrwtyuv.XI#)#)CEyazœ{Ş~Ȝŧ~ʢȤʢΡͧϦТΧҥϥӮӯէѦիӨշ԰٭ծඅܨްݰᶉ߲ڷ㸉ڶe!DN$!$;>Y}7Z">-'!*',z%J(GE&9#&5"%8$JL'q0n1h}+ky*m{*r}(s't~(w-s*o+p|-lv)mq'nq'pq%lr$ot&ow(rz'p}(qx&v|%s{(v)u(,u,q+w*x~({)y~(x}&ox)qz(s*w*t*w)z)z-u.v-|0}5w4s1k},go*_i(Z`$VW!MS!FNHQ!JL!EKBIABFJLLO!CL=DBA CGDF =F8C??HFYT$_`%`f)bk,bk-ch-kl,em+km)cg)[^&SV#UT QR#Z["c_'je)in*lo2pu/mz2rw0w{4<:5x}4ar/M]+;J(395<+2#)&,!+%,2'0 ) %"##%D?B^fnkgjqoulvvqxwwut-XI")#(CE!zi|Ś~ƤɢΨ̤ɩЬ̩ӧФӧ֮Ҩѫҫ٨ٳح٪ᯉܴ֯߬گ޺ۮٶڰ涌ޯ᱊䷈߷hDP$!%=@Y8Z_=Z:Z=Y+(*+-)H)HD"7&&7"*7%FO#zm.i{*ix)lz&p*q,q,q+x)t,s*u+u&uz(mv'ow(qy)ty)o~&u+t{*v|'v{+r~)q)w+z-v,x+v+{){,{)u){(x(s~)t)t,x|'{*|*}0-u,t3|/q|/hs'bi)_f&Z\"NW"HM DJAFEG@L!=E:E8=:A=@=@DHJL LN"HL!=F!EHGEH ?F9@@FLP"U[%T]&OW$KO!WW%]_%a]&`e&jh(hj+mi)kh'mj)ic'^^#^a&`e'bd+ge+]d+Yd)^d,il+ry3|;;|6cv2GZ+Y=`:^>[>_>^,'")(0'P+KE&7&%8#(:#KO${n~*gy*i{'lz(o}*s-s+r*u-w)v,u.q+s)w*s(q)v(z)z(x)y)x~,o}+p+s+x-{-x,y*~+)z+{-v'z|(t|)x}*s{)x)u,-y0w.s.r+r{,lu+fm'ag'\_%T["OR"IN@GACAJ">J=E?B=@:>=CFEKP!LQ FO!@E"@DIGKEL"AD>DHHLQ QU GS$?GAFNN"ZW"^["^Z'^a(ef*el'kq,oo,hp*ok.ei+fi)lh*bf(_a%YZ%YX"^]'ed&ss.vz4|6d{3GY+8H$1:49-5$-*0!+ #/2'4#)!###'IDC^hmpjnssusxuroyzvt,UD!)%+IG#zoʢʟӤϬϧլΨң֦Ԭ٦ܫٯԭٳݱڧ૎۳۱߭ᮇ్ಐᮍẎ洎休Ἅ汍䶎޻c BJ&"(AH[=a;]:[9a<]=^Y<`9_@\A_D^A^?KE"=+!( )+.*L+GE&7%#6"(8$HJ&{m|(pz*du&\u(bz*o-y2{0w+v+v,|,{+z.u/z+z+t+w*|)z-{-)v&w*u)z.y*v,v*y,z)+}*|+t*u|+nu)qx)oz'v}+u,|2x-s-r{)lv'kr(`i'de$Z]#SY#NS DLCH=F CI@G#>@8@8?:AEEMO!PU#KN"@L!;@=CBEFFBI"AG CDIH IQRS!OQ%EJ8A!HH![T d^%ac$`_'_]$g`(je*bj.fk*km)qk+op+vp)uv.st.no)sn*ek)_d(d`'hd)lp*rs1^l2GY':I&5<7<+2%+,/*%.2*2"( $#!##'LDG`jkooptsqvtquu}}||,RG$)%+JN!~rǣϩϢҧԧըЧԫѪխӧתܱڱ۳ٱ಍ᴍ޹ݰױݳ弎㱍߷㳎廎䶏㷐庌빎仌` ?K&$!&BF];];]<^9]<\:^:\;[8a:a;X;^;a7`:[>Z;]?`<`?\=]?a>^>_<]:\>a=^<_A^>]>aB[?^?[@[?LD%?(, *+/.M)JF(<&'7%$7$IP%wl}*fy*at)bj([q,m1:6}2}/u+t,s.u/v0v,y*u--v++/}-~+w+v)x*y~)t}*w*{)},}/z.z/|+q|)lr(mt(py&px+u+u,t*t}*qy*ow(hm(`g&\`$YX"MWIQ FJ!BGCJ@H!AIKMSKS"GM"?E">D AEBH@G=F =CDFON RR!NR$FJ!>C?ENMg["qp(yx.vo*qm(pj'rl)ig&de(bf(lf*om,ut-tr0ns1xy.{/~0yw/mq.kg+jj*pq*hp0FW(7D&5:5;/4!*-1!*"&/7)3"'$#!#)SEIcknrjqtutvvyyutt*SG#,%,KP$xΥΠԡЧөիթר֪بۮڸݯݰٮ೏޳޴Ḏⶑ᳏䯎㱒赏亏廐뽘㾏亏底뺕d#=I%$"&BG^9]=a9_:`8[8Z?_8_>a;a;a9]6[;^9_?]9\:d?b=_;]=`>^@^;^=c>`<`<_B_>[Ae;_Cb@`B]?R@&<.!)!+)/-M*IE&8&'7##:#FN'zm|*jv,Zp(\j(av*s3B=~6y0t+t-z+w/z-y-{-y.y/~,,|1}0{*|*|+s*w+t'w(|,{(z-|,{-~,o|*jr)pv(mt&rx)u{'sx)ny+mw*nx(lq'gj&ag$_]"RX"OS!KN"GNCH!AD@G:A :C;?I?D DHBDDG=E;BADGM!LR QT$NP ?H!>ECEYU!om(~z/322zy1or,up1mj'je(pi(nj&lm*hn+pj'qt*yx.z4z3y}4xx/zv0vx.fs3FW+:D!8=7<.7$,-0'&&-5'3#)"%"$%$)TLNdjiuquvtxxyvx|{|zx-LD#*%+LR#yΧҪեѫة׮ԩԭկ׬ڭٯٰ۰೏ߴᵔݷṔ綋㱗㶐ී뿘躎칕䴔”︔뼒` @D%%#'FK\<]=^9`;\9b=c7]:_b>_@a=`B]Z>`@a=^>^B^?^Ba?aBNB%?. +#+,/+O*LM&8$&7#'8#GL&{jw)fx'at)`p'ez*}5E>8z3~-x.t*y*v-u-q+r*r.}2.1,|,y+{,t)v'v}(y,{+{+v,~+y,}*t+pw'gp'lw&uy'pz'qx(jt&hs(kq(cm)_g$ac&[\#PZ!LN NO BGDG >F=B!=?;?8@>EGNKR IN!GJ AG DHIJ GI=F =D?GII IR#OQ#JO!?I"@DEFPLi`%zx.25:5y2xv1pt,sr,wo*wt(qo+qo,qm-nn+li(jk(ul,px2yx2ux1x~/z|/ex4HW(7L'7>:A.8#+',!)$$-8)3"*$ #!#''PKJimoqrzuxsy|uxyu*KA#+&,NP%~СѧҪԧ֭ܯڤثׯ߮߱ڬ޳䵐㴐එ۵Ⱄ湓軜䵕洔帙귔黔軔Đ겐Ò_">F%%"'JLX:_;a;^;`:`;^:a9`:`>b<^<`9\@_9a9^;b=b;b<^Aa<`@`<\>b@b@c?cAa?a>^?_?c@^@Z@_>LC$=,,"*,3 /Q)NG&8%#6$(:%NN&yeu$bs+eq&dx+p.~9GB}8|0u.p~*r}*v+t)m(my,hv+m+162|/~.|(x+x)x(x+z-y/}*x*y*v+}-|/ux&rr$up$wx(qx(ot(mp(gp&il(hn$ad&Yc$ZY#QU!NPGJFK?D8@?@;A>@EDJK NS!KT"IL!DK EJGMMO!FK=D\9[9]9b;^9`b=a>_B`Ac@e@d@`9_DaA`Bf>c?^D`Bd=aEdBMB#=-"+"*,2-P*KE'8''6"(9EN&y`n(`t*ds'iy*p2}=B@};y2l,oy-jx+o{*r)kz'dv*bp(i15;5.+*{-{*z)y+~*.,w,z+-},/x+s|(wz&v'v)v}(ou&ko$ip(ek'`i$[e%VX#UT!KQGNEIAB!=D@@;@ACKLIN!LQ#FO$BI BG!KNQU MP!EJ#>C?AEK MN!HO!@H =D ?GGDTRf^#qq(x,05>@5512453}12w~1}w+xv,{w-{p,pr/on)so,rs/\k/K[*:J)8=:@06$.'/ )#'05-3#* '&$&(\O!Phmrsu{xwuww|t~}|)H<$,&,SX(ϧبիիׯܴݮگܪ߳ഏߵ䶏沓渘㳓䱘꺗긙漘緒￙龛œ:뾓ē“đd%=> '&")IN!`;\:_9d:^9_a@d;`;b=c=d=d9b:`@`@`>f>c@e?bB_>b?^@f@_>d@df@c_<`=c:c;bc=e;e>c:c>i?_=aAa=f:g@g@e?f?aBf@_BcBfE`>eAdAf<_?bDdC_@`Gd=OH%=&",&+-11R)PF&8&$8#&;#FK$umq+es%hr(iw)kz*k0s5n5r1s,jv+ao)gj'ir&lu(nx&gv&g|*{2DHA65z/y(w+u,r|*z*x.y2./|0~,.1/+,*}-t*ns'jo)cm$bf'_a$X["NS"GQGN AH=D>B;B@FGK"NUKQ"EO#>D DHCJFN"JO DK@G II!OO"PV"IO!?F:BBFIO![\"pg'y,}0zv)ur(|-32841{}247:9967<8444}.zy+fu.J[*=J$=?;B05'*+1#)&+18)4") $ %!'(+_R Ultovtzwyuyz|}z(D:&)%-WZ,Ē׭ԯקר۸ܮݲ᭏ܮ๗䵓峗߸ຕ寘繕絗忖깔迕Ŝě›Ó[$;;& $#)PV_>b?_b;e;c?cA_?b?f;d?b;bAjAa?c=dCd?cBc=i?f?iAc=eB`?g>fAb@cCcCaAfDHB&;/!,&,,6 3S+KI&8''5!&:"EJ&yiu$l|)pz'lv'gr)hy)m|-q~,p}+pz'jn&cj#aj(gp&pt'kv)jz'q/6HID60|/{*w|*tw)rz&pz+s+w146411-/2/,~+z*px*kp&di&ah%Ya$T["OR#LQEJAGCE>GAHBJJR!JS$GN!CJBI GI EJGJCJ!DHHK!MORR#PR$AM!=99:75fy3F],9K'?@;B/4'+44$)%*.9)4#) % %%*(hU#Vkqrrtvuwv}{|€)C:"((.]b+ץذᰏݬಎ߭ᲒطⰗດⴑ帕峓⻖깕踠췛뼙꿜~;ݘÑڜáƖř[$;9'&#*RW"a@g?b:f:e>cg@fb?g>c@gAh;f?e?kAeCd?hAg@mAe@i?i@b?m?cCfAl?kFlDiCiDeAkEdDeCfGLE$<*$+'/13 ì3T+NI&9&&8"&8!DJ%y~.y/x0x1r.o~)hq&dh%`h$_f#ac"[d'V[ ]b#eh%kr'p{-t,z/6>@:~2}-z{)ru(kn'lo'gn'kv*3BG@2r-y{*t~+q,vz*u,/~2v0r{*is)cf'Yb$R\%OS$IN!FLEH!IN"NO OS"NV$IP!IO LP!UV!QT$KO"DMFI!IK#NR QY#KS"AL#?GFFMKTU!kb&jm*tv*}0693~x*|s)ys*~,69:6x|1tq/~w,6:@2}x*zo)xt*}/8>>cy3G[+:O*BC>E05"-06@$*(-1:)6%*!&!(#()-sb(_oqp|yz{~}}{)@5%+*0di.ȓ۩ڲඖഘ㹔ౘ鲓澒幗齞滗켞뿞ž¢ģڝ̡͡˞ɛşǠŠ΢ƤɞT#67&!(&+W`"b>`=gg=fAgAd=d>dd=eAgCl>g?kBg@h?hDh@jAj@dDk=fCf>iBeBjCjBhBhBgBgAJD#=,#,%.36!6V)LN(7&(8"):$CK&uw0w/{/}0z/p-lu+ck&bc$_]&]^#WY#ZW#]\#]a$jn$rx)t*{-06;5/x,x+ss(km$lo&gp)r+5GJ>~6q~*su+ov)nq)in'p{)w/~/z/p}+oq)ei*\e$R_"TR#LNIOKP LQTU$LU%MRHK!HL!KP#RW$NU$IR#FLJK!OR!QW$JU$EO =EBEML VU ed#vn(no(ol(vt*2:85/xw.vx-46=6vs-rm(rk)0==7|+w,zz)|,394&,+2ij3˗ޯ䳑㯗ೖດ絔豙ﺛ贝뻝帚쾚ロáėƣƠˤȚĩȜǠƥΟǢšǝV"55 (!'&-Z`!a@c?egAmAh?fCf?k@k@jAhCk>k?iCg>d?jCiCiBdCjDj?kDkClBiDgChCjDJK(<*#-'/3:ȵ8V*OO"8'(6#'7#BJ'px-w1|3}0/w+pu(el&bf$\^$YX!VV"SW"WZ$Y`$gm"lv)|,/4684+t/ou)mo&no&ln)mu'u.9GE?{2ox*pn)ik'kj'ge$im'q{-{.t/v*kv)ei&^g(XY"MT!MQ"LQ!JR TV#O[%MR$HM#GJ!QNMT!RU"ER#DL!CH!ON!TY&TZ'KQ%DK#@IGJ \R"pc%ts(~)|z+xt)zy,.3;;y}-qo-xq&}+8=6v0vr-vu)}-9<:521}126>^|6J]*>K)CF@F".9+.)6 )*,/:+5#)") &%&--xg'asts{w}}y~zv(;3'+-1mp3Ԙ䳑ා㹕ᷗ㻜븗뾛羛轛黟ĠƜĞåğȟΦƠǣşѢ̢˙МV#51)#&*-Wd!aDlBgAi;fAi:f?i>i=f>h@k@iAhAfAh@lAi@jAiFkDdDhDjChAjGiBlDfEgCkBgEgGfBmDiDeEKH&<)$+'/5<"Ѻ9W+LO$9%&5#(;#?H#rw-}-12~-u/s{+ho$bd%c]%WY!WY"VW#TY"__ fj$sx'u+22454z1x|+op(hm"hl(qq$uw-x,6@E7|2mt*mj%fd#ec%bd#fh'rt(w.}0w.kv+bp']f&U\%RU#PS"NU$LU"TW$LU#JO!DM!MN MS"OT$IS"BJ!FH KK"UU"LV$MU!EM#=F!CH!WR!ia"yr+0/{0sr.rk)x~,9?9|~0nn*qk(}{+3;;200.59=>6}}2zq-{r/0?[x>J_->L*CD ?H!.7'/*2 (-,19+5$+$)!("),.g(_lsy||~|~v(;.'./3ou7֞淛贙洛㳘溛볞쿔罗꽟뻙ﶞŜßğ§ʪȢ͠ɤ̠ͥ͠ǤЦҤ̢ˠΛP$52!+ ('-Yb&fDjAh?i?km@jBlBjAlBo?fCjGmDn?lChBdCh@iAiCeAjCiDkCjDg@jDjBgEkEkFGM);*$.*25< һ14-,&x-~)-02v.w*lo&di'^d&Z]%[X ST"TX$d`%gj&q}'z*~1021-y0v},nm'jn(lj'hq&qv)t/488~3y/ns%gg&^_"c_%a\!ce$gp%x(}.v/lx)dn(_f$U_#RX$QS!RV$R[%NV"LR"HQ LN MQ"QS$FS!CJ#DHJJ!JQ TT$PT!DM"AE BHLK a\"uo'185v|0nj'mi)wv+5@>4|z*zw({*3;=;:2438BE9{w-mp*vo,}18Yt3J],cBk@g@kBf?g?mCmBkDnCkEkBlDiBkCkDlFiCiBfFlFlBqBjFjEkCjDkDkBHH(:)!.)38<"׼=Z'KN&5$$4)7!DF#sxePH>71*'&ng&_["SH"IAB5">18+ 5(4# 2#"/#00 /,--y/y-|.0~0~/v,qw*hh&fb$b\$[[$YX"YZ"e_#ol&uz(}*12422v,w|)ps(kk'nk(ik$tu(y-043{1q}.sr&og&ia$[`"^\"d^"lk'v,w/{.p|-in(]f&Z^$RT&RZ$SZ$S\%OW'NS#QP PV"PV&MT"DM @J"GIKQ!QS#OY%IP'@K!AH!IM"UZ kc%}x,4==|0sm(ql'xs(/:@830159>A<2{z1{z*4?E:|+w.y+.~8Xs3IY)@K$EI@J!.9-3+4!)/02< ,3$*!($' )//p(cqu{y~yo{'8-'.04w~:٤䴕꼛纟ﺙ>껞:￟¡ÞàǞʢĦƧš͢ʦǫШ̪ѫͦӬСO 2/#&!'(.]g$hCh>jlAl@lDgAjGdEjFgElDnBqCjGpCnHmCjBjEnChELL'8&%1*6 9@%ݾ@N'AD&1 &3(5 7B#`q^TF=94/.t*p_+`Q(VG'K8&F2&B-&?,&;)&:'%6#$5"%4#"2""1"/!!. .+- *,- +-,.-) ,-,,+0.20}0}0v*nu*hm&af']`"^[#^\'][$`a%ip(tx'{---021~/{+{w)op'fk%hl'mu'y|,01~/x-xy+tt*pi)jc%g`#`]$`a$dj&q{'w-~.r/gs)_f'U]&RW#QV"V\(R[#MS%MS!RU$SU$OY'JS$AK!FH!MM!QU#RU$JT"AL$CG"GKRW!e]&oi(}x*/881|{,{-.2:?A;0|w/wx,1;A;/|y,{u-18*':'&:%%8&':#':"'7"(9#"3"%7'7!'5 %3!%4 &2#4&2%4 !2#1!/ ++ ())+ +(!)**+)( +, **++)413.1}/}+tv)kj&de$e_!^]$`a#^^#b_#ji&wx*,/..3/.}/ux)rt'di'ee%jr(xv,-}2){~,sv+tr*um&tc$h`&e`$fa#kh%pt*s.}/v|1hq)]f(W]%XY"VY'VX'OT%LR OP!VY$PZ"KQ$FL#FI#HL#QU$WX&OV%DM"EJAJ!VT#_a&oj*{y-vq*y-49532|4}344wt+wn)~-mCmClBlBtJnBhCmAlClGnClGmCoEjAmFkGfBhCjBnGlDfGmEoIiJJK'<('3".5!8@$CxiYNB=808yy/kd*`[+RH+L=*F5*B.)?,'<+%:'%:#'7#&7#$5&&6 !6!&3$2#2&3#/&0"2!&5$5#3&5&4 $5$3&3 &3$1 %2$4'1$1#2#2$/&2 0%/!.+*!) ((&( ( )()+) +!'(!* *!(* ++!)162333-xz(ns'ji$ac%d`"`a&b^$ed"jm&py(-+3,02.,{-ot*ml'ih%ki#pt&|,},*}})}x'vv(ut*rm%nh&dd'j_%gh&ps'oz*{.t0kt(gk'``'[_&Ya'U]#QR!QT#SW#RS"KU%HM#BL"JM"MQ OT%LV#KR#GL!GJ OQ!db%xq'+1}y-~~-08?;2}{/st.y{/5>>5w)w&,3=?621x}127=D6{x1wr*kr,Ul1J\&;J%LK#=H",7/3)9#(12/%+<'(:%)9'*8$)7$&8")8#'9!(7#(5$%5 %6&&2!%6"'4 %2!#3#2#0"1 #2%2"0#0$0#0$."0(2&1$4%0"3$2&2)1&/%3"0 0$0",$0#-%/!-$+!)!)!(!(()#*"*#(&)#)%+'+(**,-*/+.-;-?/?0H2K3K4u-34644~0{,tu+mn'kk(bg$ch'be&fj%jo'uv)y-{.}0-+.-0}+zx,rn(oj#li(ss+x~-,,},~'|*{y*yu)pm(of'me%hh#hk'os'u,s2nx(jj'ee'bb&^d'V]&QS#OX$OW&LS'FO$BJ CLLO#PV#NV#IO$FM"FM"NM _`%ys+240|w/su/{/6>:5|{+|v+{,3@=:2/179;>8|/ts0xu.1@E>|.w/|z-Ro8I[*=G'IH :D"/913*;$)153= (6$-"('*(*04~3grv}}`w(:J(.68|Bޮ귟ﻚŞœ¢ǡŦʩǥˤʥǧΪ̭ϫӨ̭ҪӨӬԪӰת֭ҭϨI".+#*!*(/`r*iHkDh>gBoAkAl?hBpAlEmAjEgDkCmDjGlGhDkDiDhE_E`F_E[FZCSHODHEB|A?zC6p>2iB3a@+\?-];)M9(?/+4!(5!*: 1;".G&/G/0F1/A/1C-.B)/?'.>)/?',>*)=',<&)9%,;%(=$+<#+:%)8)(6!*8$%:"*6"(6"%8!(8 %6 %7"'6 )5!&5%2""5 $4 %3&4 &7'2'3!%3 %4#3 $5#3!0".$1%/#-'1&0)1$0*0&1'2'1)/'0)/,0-000,4103142:18/=1?-K0U2X5^7d8j:p;s>yBBEGH L JL M#L OQOQ~M r+u0s33652~.y|,qv*ns(or&ih&jj'mj(jq&u{)u+110/0/0.}.tt%ql%om%tn'}|)}+/+*.+w*|u*rm'ih&kh'kk(np)q{,w.uy+jn*dh%fe&Z_&QY%RY%QW$OO%HO"BK"BH PP"UW"UY$NT%JL$GL!KM!eW$ql(15;~1ss)op&xu)18@;/-139AB89}1y}33<>7~-zv,yu%-:C@312Ui3N[+?J%IG >I!05/2+9"+15/>+3!.%*$*'+230guw|~}_y+6%*12:I㮖뼠ﶡɤ¨Şͦģģ¢ɥʦʪ̪ίѩʫ̭ͮШ˫ȭέԪѮϨӮѮޠC#.) *")*,ds+eFg?jBc@k@eCeBbBbC\BVDSCRFNDDF?{A7o>3j>2c=,W:,S8&M3'G-#@-!='#8%$3#$0!".$.%, , .",!,%.&. (3)2*7"*5"*4!*7!,; +<",;#(:%):&-9%)8$):#+:#+:"+9$+9#*9!(7"*7#*4$'4 (7'4"'6!$6")5 %4 $4'5 &7!(6%5(3&4%5$7$7 &2&3(6 %5$6 (4$4&5#1$1$1%0!/&-52E5O5V6\;c=kAo@uF|EF!IH MP N T"V!R#S!R"T$V#T"U!V$U"V"W#X#U$X%W!Y#T#X"X#X"X UU#V$XW$P!m{,l-m.n0z3<932v|+sy*qw'pr*os$mp'ts({),-1~10/131,w{'ur+sp(ux'z),./,/+(|)ts(nn%ro&mm'nq'px+x-v})no*fh![a(YZ'VW$X[$QX!GP$FJ"DJ KP!TZ$O['NV%LN#FH PN"[V$jf#|s*1994~v+~v*y,19==87236=A?5},~y-.:<:/-01:=@<6y4Xl+JX-:F'HH8C -602(6"*/4/=+6%+#+%)%,237lvx|~^w+8%*069 NⰚæ¢ƥʤáȣǨǤʧʟȧ̧ȤѨҢҤϦϫêϣʧѡʞĞޛ֐;!,#!*!*(,F_+DuB;pA4f;/]8.Y:)T5'J3(E/&B-$<*#7'"6!#0!"/#,!,,"+ (!' ) )"''"(!' (#( )"*"*!($)"(#)&,'0(2 +4(6(7*6$*6 *7!*8$)9,7$(8 ):);$,8"+:!(7$%7$)9")9 '8!)7!'6(8"(7 '5(7&8,9(7 (;(8 (; *< -;,<*@+C,H!2I 3M!5P";T:\#Ac#Dh%Fq&Do(2a-#8 $0"0#.41Ia$f*d)f'g*d*d)e)f&b%a'f'b(c)b&^$\']&Z"Z%Y#]#Y"\"Y%Z&W!W!U"V![$X$\"X!Y$Z$Z$T!V!X!V VV!P dp(eu*ew/dy.s3A@;4,|*z,ww'to&vw'}/.010/-2434.},uw){t(|x*}-0.0/0//},vv'uu+sp'xq)ro&vt*r,}.qw+jj)h`&^_)[_'W\)RY$EP#FJ"FN#RW$W[&QV$IQ%KL$JM!XW#he(zt){|,}23951.015==4475:?F9sy/Ri1J[.CI&LK"=C /524)8$+263> ,6%-#*%)$)452luQz+5(+09;K뮟﹥›Ø￞¡Ȝţɛà×Ǖ罋Á޽ԸtͯoǴc^MHA;~4v0kt.[m&6V%)$&#("($, -!*!+!*")#*!( *"(!'#' '!' )'!) & %( &!)"("&!' & (&#("("( )!) *$,(*+/)2(5)4+4)5'5"*7!)9#*8#+8#-;$+;".;!/?"-;#-A#.@#1? 0B"/B!3E"2G!8P"6P#8S%=Y%@b#Ag&Fm(Gr'G~,M.M/L2L4K9R;P>RCO?PBQERDODPCSCMELI3yK$8$$1%/"->5T"d+l)j*k&f%h)j)k(f$f'g)e&c(`#d&`'a%]$_$]%Z$^#[#\#Z#["\!Y#Y$^#Y"W#X$Y#[#V \!U"X#T!W"U!V!Tep(bp(`r'g{,{5FB<2~0}(x.|~,t{+p+x,|/2491012730z)}y+~y(|(-0.0.1.-,~w,pt'vo'uq(qp'vt(x}-~0{{,ln*fh&ae'ae*[a'KU$FM"CJ"MQ!RW&NW<$FM"DK"YU#ef&{x(/}}.~027<;67{207=>4}/x+-5<=:532::?@61ur0{t,4>B5tt-Pj-HX*EI'LL#8E"-517(7#*274=*6%+#)&)$(344px{|~Lx+4"(/39O׳޼ݾӭӬ̬}ʳxtj[XOKC:~~8rt8hk5bc2YV0SP2K>.C=.A3->*):()8$,4#(5!+1(1'0&0$.#+$)#( $#'"& &"& $!& ' &&& &%% ( $#"'%&'"'!&!'&!'!( (!''#( (!($'#)'+%-(3+3.9$*9#(5(2!(6)54?@<61|,3=@9|0~y*}w+.8C7w/Ph-EX+CH%PQ!7B 1546(:"*462@+4&.%*$*#(744jst}}}}{쇶~셦瀟܁ր{x8jf)0!(0,5 8b?8u~5ks3ei/[W3WM0NI.I?.D9.B30>*.<)-<%*:',8%*7!,; (6*6!+4!,5-4*5,3+0 *1(2)0*.&/&/(.#-(-$+'*%)#)")")"(#% &!&"( (!'(!'!("'"&#'"($("'!'!(&)%*$-%+(+(-*1+/41"42568:$=>%AA&ID*IG+PM2WX8Y_@SaF;WD-9')4+4"/6 Wm'YOWGXJYN[MWNYLWQWNZNZJYM]NVMTIYKZLWIWIVISISHWIXLQGSGTHRHUGVJSGPHRHPGOLLIJGPENGRIOC.~C$9!$2$0'/81T d*l)l&m+h)k*j(k&l*h%f'g&a&a$^"_&`&^$['_%[%\%_#]%[!["\$Y#[$Z"X'[!W#Z"[$[![#WZ"U"Y#T!S#W bk&eo*hu-t4C;5~w+}x+18?831/38C>9Ok0DS*@F!KL"8C!-346+6 #+452:-7%,%)#&%*05p5}kwlroen^oWiPlIcA}Z@r^;iQ8bL5]I6U=5L71H/0D-.=''2 (0'.(1(0*3 *4+6+5",3.1(2+5)3+5+2*7.4+5-2*6.5,5,3-4,5-3,4-3-3*2.2-3*1+2*0*1/0+/)-',$+"("'")#($(#)'(','.*.,/..11 3444 :7"B;"B<&E@(HD+KH/OM6SN9WT;VWDZYL\YRZcUWa]Xe\[dj[gg[giYgq]o^nzcnxfvx`w{[u{=dq):/)6 (8-;"U|*]R^O]K[MZO\M[NZPVJZKWLYLXLVGUKTNVJWMUIYOUJWIUNVJTLSJTKVKPISKTKQHSHNKQIRGRDSGRJPKNF1E$7%"1&0(.81T"k+k(k(m(m(k*l(h)d(f&e&b$`$b$_$\%^$_#b%_$\$\'["]%\#[$\#`'^!`%\#^"Z#]"\!Y Y"W%Z W"Y!X!X!V cj%eh(fv+y3?FC<93.~-x-v,lz*gw+fy08FIA:856//-/213//.3173..||+yx(vr*tq)xx*|-/2-uy*hl'W`)IR%IP$PR"T]&Q]'HT$GN#MO!a[#mn)07C6}|/rs0vr)/5=;6334:>GA5|~0|{029>A3-,06??38566(4#-"*$)&)&,'7(;(+9$*6")8#+9,4*6.3 (4+3*3(6,2*4)2+3*1(3'0&1&/(/+0-1*2-5-4,3,3/4-3.7.4/5/425373518294998 7=8<<==>>>BACBGEMIPL!]R cXn^wcvk"9X!'-$+#)#*C9FC)KE.SI5TL3PP9UUAWVEZXGZ]SS_Z]a_\fa[bd]cm[fkahr\gsbjw\hx^izak^l^jbkam`l_l_m_m^oYr`wawdvew]zZy@gz,:0*4 ,6/:!R+\OZQ]M[LZS]OXOYO^N[KXOXMYQ[NWNUMUM[MWPTNUJUMUHSLVLRFTKUJQJUJQGSNQIONRFOHQHRJMDMHOK/~F$: #1"/$/:1Vj'o(n'k)j)f(j(f)e'd&b%b$]!a%^$b$]$^#^$`'\"]%^%]$\%]&]#_$\#`$]#Z"`$Y!\!Z#Z%Y#Y"V"Y V"W"X!\f&eh%io(n-~8?<:8.~./z/z/qx+jz(n-8FI@:52240.~-35512-/22000+~z*us(wn%up(sy'.-}/x|,gm&S]'OM"LO!TW$S\'PW%LO!LO#\V#jf%~s,0496/.-/2=?@;:~~239>@5|z-yy+.5A@74236:>@73}w.|/6ACQh0DU+EJ"FN"5B",236'6$*470>*5$-$+')#)&($+).%-'/'/)/,0'0+-*0+1)1,3-3*1)0*1)2(0*.(.+/,/,2.55768888;;;>@ACFFKGOL SQ\V^Zgb!sh$l$u&''Ǥ**15479BFPUZciPV&1#*$(+.SS9Zb_Zgo]g|Wgx\j`g}_kbk_g]j[k_i]h_j_i\l\iai]j_m^kap]k\map^n[o]pao[r^ogscvfycyay^xD;}0w-t,2<>Rf-HS&EI#FM":A '351&8 $+3:2>*5$-%*$)&*$*(-*.)0*0*0,4-2.4-4162728287<9>;@>A>C@E.?*0+063mN~q"~#'-å)ٰ-026@>0~x0w-4;E:3./13y9Qe.FU)DJ!HL#7A#*488)4(,2<0; +7*1$)%+')+-78;??DELFOQTXW bdjlss%}~&*+.169@?=8.4*3VE3Y_ahghmpqqtpxuyzzx}}{zyy||{~P[(1%)'*-1WZB_lt[m\jdj`i_nbm^l]hZn_k]k\mcp]m`k_l]l^ldo`nbm^k`n_j`l`kapbqcubzfwivf~h{czax=es+:,'6#'6 +9!R,YS]Q^R^Q`RbR_R\Q\Q`N[N[O[O[PXOYL\OXJVNYN[MWKTJVIVGTOXLVLSJVJUIRIRKSJUKQKUHOFSIUJOH2I':!"0%,'.62V m)p'm(l)h'd%e&f#d'a%c$f&h&c%a&f%g&c%b%e!a#a$c&b#d$a#_$_$_#^ Z%b#^%_$Z#]#[!X#["[!X!Z"W!U#`a$_f'hj(ms*u+0545/0}.+{/|-~.29;36;8:53}+t~.q07GG?40/---2225.u'vk(rf'xp'xv(}|+mu(`e&O[#NW&Ya%Rd(ER"SP#[^&nm(~+14s/qt-zx-59;4~|.{,09:<94416=BB8}3}x-05:94--.5=A844.4v4Qe/EV'EJ#FP!:A"+4<=&7"*4:/= ,5',&(&)(+86x'6!U,YP`P]Q^MbM]P^QaPZS^Q_PZQ[LXQ]N\M[OWMYM\M[PYKXLVLUGUKYHSLUKTJQHWKUKTLRHUHQISGSOSLRI1G&;!%.%-(0;3Sk+j(h&i'h%e#h&d%d$e%c%g$d#f#d$d#b"c&e&b$c'c$`%_#a"b#b$b#_"\$\$[#\$^#^$]'Y[!\!V"U!Y"W Y!`b%hg%km$u|*x-/443/|-},0-2-0855446623~,|+}.8LI:60//~)v+s.1;>2yx(nm)qk'yo&xu%qs+gl(Q^(=;62368C>61}z.}/p|/T_,IR&EJFJ"8B!-4B?'6&,5:/; *2&.%('.(+DD9\bjgkionrssusuqtxvC\+62:fZHsqrrrpurutvv{ws|~zyyx}{|~KX+4%-$,02\]D`nxaocobl_m_nbqgm_k^o`ofmcpcn`nZnalbman^pfm`r_m_t_scoesesexlzj|g~hc|h}d~`~G#GP$SW%\Y&lj*}x*/363|y.v,z/.6@=;6947CB=5}}021;=:6204:515?C9.{.|/s}.Tf.HX*BE%BJ!8? .6CC)6(,8>4=+5%-&*%,)/EH<_nhlonoowwuzxxuvzz?W.92:j["Lqrtxsrxvvu{z|}z~|{|~~~JU)4(,(,34 Y^Kaq~^ken^n`ncoaobndn]ncoaqbpcjbrcobp`pao^oct`ocs_obuhofyfwd}ih|i}f}f{eddy9bx+9(*4#*7#.?"[1^U]R_R`P\O]Q]Q_WaR^P[R]NZN]R[O[M]OVMZN[OWS[NULXQUMTOUNVOWIPNWKSHUIVLUNUJQKSMPGTNOJ2J%:#$1'.$-8/Ti)k%i$l'h%i%h%g%f%h&f&i&e%c&c$i$h'c(d#j%g$f%c$h#c"a(a!b$`"_#`$`#Y#]%]"]%\"Z#X%["U [%W!W!io(no+qw%z+.04313.}/x.w}-u+{,}./2/12.21/*~-04>873-~~+}-ux(mv(nz+3?E:y{)ql(qj%nk)jn'Vc'AS%6H!7@ >F!GIPX"ie'zx-054761/.27?B=5{-}y1.:A9/2.1:>>99429CH=5{-y+-7?932/1[l3JZ,SM!WY!7E"+3IB*3&*8:1= ,4'.).%,&/HF@^fmkinprusmvvrqyxx>T092:m^ Mm{mvsyqz{u~x}|~~}~}IT*1$.'-/3Y^L^lzco^pbm`o^kbq]kgl^naq`pcpbqdo_qamfq]wbuepbsclbqbsbvizm}g}dfd|e{fxb~eb|<`}*7,(5)6!+<#V.`P^U^T]S[RcQ^Q^R^UYOaS]O\O^RXL\PWNYL]OXRZKSMUNZJULWJUJYKULUJVLNHTMUKUKTLTNSHSMSIPI2I$:"#/"*$-4,Qd'j%i%k&j&h&i%h(k'f(h$j&d%g#g&e%h&f%d&g&c&a$c&a'b%c!a#b#` a%] a"]#a"] ]"`"Y\"Z!Z$Y"Y!X"nu+xy)x-/.015752y.|+t}*q|+t~*z,*151224/1,--02430,|+yy*sv)tt+w.6>E5wz+qh&if%jj'[h'JV&8H#6D5> 6D"CJ"SW$po(.7614:9;4|{4~15@=5z.~z+-7>@74387>BA82}-1:@A2//3/= *7&,(+%,).KL?eerrkpmrrurrz{t|ww>S0=3<tcTtrt{w}tv{vvw|~y|~}FU)0(,%.34^]O_maodngm`oapbr]mamdmbqhrcqeqcrcpbqbrardscrfrapdrfrizmyi~l}f|hb}gvc{f~f~d~:b~,8,,4 *8"-< Y2[T]Q\R]T_O`RaW]T[P]P\S^NYTWOYRYM^Q\MZLXLWNZMVKVKTOVL]FUNZGSIXNPKYHUIUJTJSLNIXJTKPF0I"8"", *#(3+Mf#i&l&j+k'k'h)g(k'k)i'g%j'h'f$g'j(f%j&e&f&c%b$d"b&e&a$c$a#_%_%^$_%a"_$]#]"["\!]!Z!]W$Z$r{*z,},//{-327430~,s},q}){~,{++23320/10-./..2110z{+|z*wv+rz)y+5>>2yv*mj)id(b_&LY&;H$9C 7C!9C6B=JRX!tp,13404=>50y,~/3=97/142>9419;<8../7?B<582:#Z1YT\R_Q[ObT_PeQ_K[S`QcS`R[T]RWNZMYN^M\OZM[QWLZMZKWMVQWMZQXHYNZKXIWMZJUHZGUHYKTIVNQL1H%6"!+!' (5+Rl)k%k%n&k(k'm'k%j'i%o'j)j&h'h'j*g(f%j(f&g&c%i&e&a#b!_$a#b"e%^$`"^ a"]"^$]$_"[ ^!Z#Z["Z u)}+},|2|/~/1212///,x*x*|.--134000-/,)++}1}-/~~-zt+vp(sq(rp,wz,{264~~0so'qf'bb(PZ"2231572047AC52-/8<91/109BC@>845!.4'/$+&,-2XUHfmpnrvtulvzvyxz~yu9J3>6=o!Vqvv|xx{}}{~~~~BO+3(0).67[cVcs}eset_sbtbndocpctatgsesbvkubqdrdtetbtfvetgui{kyk~o|jm~nn|lmr}jkid~7^y-;*(9$+7 .@"^4`V^RdW]W`OaR\R`OaQ\T[M`Q[T\T\SZR[RbRXO[LXP\PYK[M^MZLWPWRWKYOVJVJXMVLWQZNREWKSKOKLH-~G5 (!)%(6.Pj(o&l)n'm(m'p'j'm(l(m&o)l&n'l&i%k'k'h&j&h&i%f%f&c&d%b#`%a&b$`#d"`&_$\$a$]"_"\$]#Z"]"Y$\!x+.00/|.~.|1v.|,//-/.}+-/,245-./*-...~+y~*,,},y'uq+rp'no&oj(os(sq'{r*xq(ag%X^%JS(;F%5D5A5@!1@3C!4B 4? 1A 6A6E#:N$IX&Uc'Xh+br0l9=>831.7@@4//.5;@84565?HC63{.-6>=4/133;>GCb8MX*@R+1:!3:.7(*/8'-'-9C!2=(5&.'.'0)1\_Pfmnppuuwvwuy|||{}y?{I5<9>t']yvw|z|y|z}}|?K(4)1&/98cfZdpcugpbseogscodpcrfvitatapitircscteudwm{hyn{m~kmo~m~oiplkipjm`:^z)5+(6"(9#.@Z5cT_WaS\WaTaS`N_S\R`Q`N_MYT]O_R`R[Q_R]P\P[OXLSQYP\MWOYMYOWMYPSNVJVNUORPSLMKQJRIPKLG-~F"4 !+#)#(4-Vm'p(n&p*p*p(r,l(q(s*n(p(m*n(m&i'i&i%i)e#k&h'g$c$g&c&c"d&d%c$b#a#`#`"_"_&\!]"\"^$[#\V$]"z01775/1/|-|.|-011///1/.2..2/+../-.~-,+,},zz*zq-tr%rh$re(ri(pj%^d&N\$=I$9F!:A 7C5?5B!4?2@ 2B2>2@ 4@4?!5A4C"7@5A 7C 7E$;M$:M'BS&W_(_f+lq3m|1x1A?=50059@=1/16::85635:?F?4048?Da:M\)>S*.5 06+5%)29&-)-5>0<-4)1*/(.-1__Ognsqpwp|u{{yzy~~x;xI0<=>w!^|xw{zzz|zy~w}~~AH)2(1&-::_gXhvhrdsitesfwirirdsmtgxevhqiuiseshzcugwi|nznrmkjqnqkmnjnne`9d,7%*5#(7$.B_3_VaUbSbSaP\RaQaSbObQ_T_PaR^R`SaR`O`S^V\SZO^N`Q]P\LWNVNYQXMWO[MVLWSUHRNSMNIRIUIMIRC/D 4"("*$+5-P l&m)l+r&q'p(s(q'o'l*k)k'i(n(i'n'm'l'd$e'i&c%e&e'f#f%f'd#`%c$b%b `#a!^!`"^#]"\ ^ \!\"W!\#~,06<5744z3}0z.}/}1/24022/2.4./0/3//)/),.'}.}w*q*vm(uj)lh%fe&V^(DO%8F 8D6C4C"8A7C7A5A 4D2@3@!3A 2> 5?!3C2A8A5B4C 6@ 5B"8D6L$@R(EV,IZ*Yh1k3x!+4(/%/'..2nd Uchttvnstzxy}y~|;tF2?8@x"axy{}z}}: bh[hqfqbvgvethtdsivjshsdufqithtdwiuevfwjzo}p~okgplrrrkjmkljkb8e~*:&(6#(6 2A c3aUaV`RaYcUgQ`TcSbS^U`PeVdR_S]V_R_V`T_O`N\P[QXRZS[R[N[RZRWQVMXLWOZLQNSLNKSGUJULRISD0B"6!",!+$)7,Tk+r(p's*u)p*q+s'r+o(o)n(p)m(o&j'm)k'i(k(l'h%k&d$h'h&e$f%c$d#c$a!b%_&a"c"_!^$]&`#]#\!Z!Z!q,t3{6=>>=40{--~*}-y/45411040//.-..0001.--,,{|,}v)yq*lm'le(V]$DR#;F$9B 8C!5? 6A"6B /> 2@#5@2B!4>3B!4B 3A0A 3B6@2? 4?1A 5@3?!5B!9D 7B6F#5E":M%CZ,@]-EY,Vc(cn*kt1sz.}39@?<5547CA84..5>A42019B^~;Q_)>Q,+605*4'-19%,+06A"2<#*6'/).'0(2jhRnruuvuvx|x~{ywz}~{:tD4;:=%`uy|~y}y~~6= 2?3@!7?4B 1A 8@"5A4?!7B!8B!6C5D!6D!8C!8L#BT$H\*J^'^m/p3}>A~:3223?A75126<=<5639A^x7Kd+ 3@ 5A"4C!3A 6@!4@ 9C 7A#9C!7A 6C 8E"7D!8H#?M"J_,Ok4Pj5\i/ir0vz0}2.=>;84388=A@61/8[u2O`0:L*.60:)5*+/9',..:D"3<"/5*/+3&/,5vn"Xjonqtnuy{xu{}||~y~8j@4:?C"exww{{}|;D-5(1/0=>!elYkvgtaueseqfvgsdrlugthxhsfsfxiznvm|qpkonmsonomlrnigmkl^6c~)9))6!/:#4C#d9dVaVbUbZbSaUbWdT_ScTcUaRaTbWaWdO^M^R^M_T`S[P_VZR]R\R[SVP\RVHTNTNVOQIUPPKXJWKSMTNSE4J#7!".#-&.;2Xr)w)r'u+x(p'r,s)v+p(s+s*m*m+i*m)k(k)k'k)k%g%i'h'f(d%c&d&i%c&f$e$a#d"`#`%a"\ _"a#] ^$]#\iv-h0w5@VK?81},s-z+r*r},r.w69A;521{0|,~.~,036754//.+-~+~,oq*\e'CU%;J"6A%5D3C 8B!5B"6A2C!3@!7D"5@!4C!5C 6B5?4A#5B2A3@"0A 4> 3@!2C 5?6B5B!3A5B!7A!2A!6@!5@3@!7B"2B7@7A!8D6E$9J&8F"9L$EU'U_+\k)`n.fu1;CC?7359;?7.03Yt5J`,>Q-2629&3-/3<(/.05F#4?*4)0)0)/15ss!_koswzuwyvv~{x8d=5>;A%l{t{}~8{E*5)0'0B=flfjtfxmxisevgvivgvhwevgzkxitkyg{jyl|nrrrmuomnpoqmkkmjmke2_}(9(+6 (9!4A!b8_VaQdO^UcVaUdSaUeT`ZdRcSbWbW]W_Y^UaU`S`OWU]PZRYQZU[RXRUOYLUNVKTOQNPOULUNTLRIVORLRL1I%7#!.#/'.;3X!r,u(u+x-t-u-o,q)s+w+q'r(p)o&o,o(l&k&k&i'k(f'i'd&h'e&g%c'f$_%d'c$b#c#b%c%`&[%]"^"_#] ]"\!ly*p2}:HQL?50~+w*z+w}+pw,iy,s4;D=93.|y,x{*z}+-|32;@;30-.+~-{/w|,ln*N['L(?K'AT'Wc.i:{>y<{5524;>6106Wo4Kb-:O)-5-6(3-./<'-,27D3>*5'.)1(127zx"Wlpm{wuyzz|{zz}~~9a?3<S&;I#6F!8A5A$2D"5D8A 8C3B 5D"7A3E!3D#7@ 5A5C8C!4B 6A6E8E 7C2@!5B!5E 4B 8A3@5C!7@ 1>1? 6A"6? 5A8>3@ 4A4?$9@6A5D :@"3E!3B8A5A!8B >K#B\*Ld6Qi1]k1go.ow4}1;>@>85Qo2EV';L)/61;(4!-/0@C'nuwz~~~8u?,4(1*0E>!kigiwmykzjwhvkthvkyjseylvnwkwf{ryrputtstrsptnqnloqkqpik1`,:%)3!):!1C$c;eVeSdRaVaUcXaXmPcUfTeTaRdT_T_T`QbSaT`T_T^S^MZQ[RXMWNZJWNUNWNWO\JWJUNUMTMTMXMXMXPTK5J%;$%2(0(.;4Z!z*v,x+x)t+t(u+s+t+u(p)r(o*t+p(o&m&m'l)i'l)j(k)g$i&i&e%g&h$e$c$e%g&d%b#b!c#^&^$_#_"a"^$_"oz1s17FIBC71~/z0|/u-p+x18HLB71|/vv,rv.mo*pu+q-7CMF960+u{/xx*ju)Vg*?R&:J!;D"6D"7D!5C"4C 4D7E0D!8C 8B"7D!4E7D 5A6B!5A"0B!5A 3A 6B7?!5A!7@3D!2A6@ 5?!5?4C"7A!4A :C!4@5B"6D"6D"6@#6@5?!7B 4A6>!4A!8C"4C4A!8>3B"5B!8G"7F&9H$>M$FX)J^-Tg,gy1<@<53Ol4M\+=P).54:(4,10;!*2149E#3=,4)2(1)3.6$^lswwu|{z{|z~~x9^64=?Cę'o{y~~~||}9s;05*2)/G>!gqggukvlylxkwixkvlvnzfwkxjwi|kyqqsrursprovopnmrnornrrg6^w,:%(8!);#3D e>`Y_VgQhTbR^VdV_WcT_WcTcQdXfSdWaVcVdYaW]U]P_O\OYP\Q\PRQXOWMYOUQ[OYOVPVKTRVMWPUPUQSL5M&<$%1'1(0>3\ v+v)v*v,v-w+y,t*r+u't(k)o(r*q'q'o(n'k'k&k&k(m+j'l)f&c%f'h%f%e&f&e#f%e$^'d$_%_$a#a"_"]'`!mw*q}/y1>CD;711}+w-r-y+z5;HI@520sv(qu+ut*u{,{19JKE=2~,|x+ux+jr,Vc)CV&;H"9D!6E 7D"4A 5C!7D 7E!3C!8C 6D7@4A"7B"6C4B3D 7C 3D!7@ 4@ 3B6A!5B 3A!4A4C 7B!5B!5C3B"3A!6A!5B!3A"4>!2@6@6A3@7@"2?1?5?6?2>!7?5A!4B 2? 3> 3B 5@!6B 5B":E":F"8I!DW&Og-Om2Uj0bm.qt/Mi6M[+9L),539'3+.,9&.438C 0?*6'/&/+215$]krqtwz|}}|x}}x~z8[26==A!՟'nz}}~~1m=,7+1+1E?"fpklwkzmxlynxkvkxjvgvhuj|q}iyo{s~ruvuxpotrouiprqmtpqppb1\t*8((7"+;#2C"c?bVdW]WdUcVcTaTdR`TfTeQaSfUcOcV`U_RdS[W\RbV\N]Q\P\O^NZUTTXRWQWT[QWM[NUSZMYPZO\RWMZM3K&;$%2%/'092Xt,v-x,u,u,z.t'u*u*r(u+p)r)o*o*o'n'o*n*l'n(m&j'j'j'l%f&d)d%b%h%b$h&b'd$c$f'^%_$`"_"]%\$^"qv)sz,}-4>>812/w-{,v-x21 7B!3A 7A7>6C!4B 5A 8> 6@#5A 5C8>"6B 5B6@4C 4@5>!5@5A 7A 5A6@!4B3?"5?7A8A 6C 6E!7D4C!9E">36/x},}u)kr)nx0x17GJF@7.t~,lr)_i+K[%?L%9H#8C%7F 7B!9C%2@ 3E!8F!6C!9E8E!4C"6C":?8D"7D 6C:B!7D4F7E!5B!6C 5A 2A"6C 2D#6A 4A#7F!7D4C7A#4A6A!7A!6> 7C5B"6B!6B 9? 2B5A5B 4C5@ 4B 5A!/B4B5?5?8A 8B7?!6C#6C"9B"7F!5D!6C#:G!8F!PR#Sg4Jb0BE+x{}2h9-3*0-2JD&hqomymxmzpymzixm{kylvjymzomwrssqxysxstuwqupqprsqroe5]u+9&)9"*9 3H"c;hTcYfVhVeUdWbVgZhXbTgU`SfTjTbUeTbTaUZRWV^R[QbQYQZR^RXTWQXSWSVQ[OVSXNXMZN\NWNZOWPWO7L&=$&1'0(1;5X x+u+z+z-y/v,t*v,w-t-s,u)r*t)q)p*m's,o'm)m'l'm&f'l(i)h(h&m&g&g'c'e&d&b'e$a&a$b&`#b#a$a'^"lv,v*{04799532|./|-0~/38813z-qz.tv*kn)pn&rv/x37==91|~1tw,ck)Oa'@R$7H"7D"!6@!5A!7D5B6C 9B"7B!5E 5C9C#8E9D#NU#Of1I^16G*.93;%201*>)1487D"2?)6%2*/*00:)dqyq}y|~~6O/4<AF+zz~|3g6*6+2*1JD%kuilzn|k~hynuoyjxizpzp~rturztwrssrvwqupruqxprqtmqh3]r,;'+;!*9#4F$eBbViUgWfXeUgYf[gVdXgVdYeVfQiU`UbUfT`WZVYU^QbS]W[SaN\QXOXSWOZN\TYP\M[QZS[QZQYPYRWR\L6L&:$)0'.+1@2["w,w*w-{+x,w+{,x+t.v)v+u*p*p*r*q,q)r)l+m)o(o(i(n&k(k&m)d)g'h&g&e(g'e$i%c$d(`$a%b&b#_%a%^%w|*{~.}03357531101/3/331.z,u{+os&pp+nn*np*qv+|/~052/~|,hr-Sb'CU'>E!8F#9.@#$1369E"6>*7)2(0(15:)huu||{~|}|6N-4>@D (wy{6d5-6*2+2KF%jqnozlym{lxlym}fxq|nzk}qxz{ztwvvrwrqtwtoxvunrmqrtd4\p.8%*9"):"8H$g;eZf^hXfXeXhTbTdUeYgXaZhUc[fW`TeYbS^V\Z^W]R_T[U]R\NYPZSZR\P]PZR\O[TYT[Q]Q[S^QVMYUUN4K%<)2(2;4\y,t+v+z.{)y)y*y.z-u*x,w,q*t+s)r'p(n(p)o(l&l&p*j'l+i&f(e'h&h'c(g%h&c)c%d$f&_#a&b#]!]&^&Z$s}.x+|/368752222331/20/0}}0v{-su)mn*gh)il,pn)ty+z.-0w0rx-[h*CV(5?#5C 5B"6E!8C9D"6B!8@#6D7A$6B 8B >E"[W Oh5M^33K*/92>!(/26.?#$.4:9D!5>#-4)2*/*23:&dorv|}}~~~4N*3<BE +}~{2`7.7,3,1KD$nxrrznzlylzkzm{j}nyp}ttxx{xtxuvsssuwyuxvyqurotspk2]q*;%(9#+<"2H#fBbZgZdUfVfQlVhVaWfYbZeYdRgVbU`WbXaS_UaO^TaV`R^Q_R]V\TYWaR\N\R_R`R_TXR]RXS\QZT_QYR[M;M&=#&3)0*092["x,z){/|/}+z+y,u.w+v.y+u.u+w*r(w)j(o*o+o+r)q'n$j*o'j)j'g)g&h'h&f'g'd#h$g&d'b%c%e%d%c&_']&y~-{~/}/2588945203223231z/}-{{/st+jk)ei)ik'il)pr*py,||,{}-sx,_m,L^*>L#7I"5D!7C 8G#:C#6D!7C"6E!4D$7F5E!8E!4C"8D"9B!6E"8D4A 7C 6B#5A"5C"8B!7C"5B"7D"7D 9D!3B#5B!6C 9C 8E!5A"5B!5A 5D6C"9D6D!7B7@ ;C 5D7C!9@ 9A8D#2C 4C!7@"8B 6?"8C4B 6C!9D#7B8D 7C!4C 7C 4C$3C6F#5@"5^!y,u.x+|*w.{+{+w,w+w,v+w+t+v(v,t*o+q+p(q(o)l)n)m*k)i'l*g&h'k*f(g$j)f&d&a&c&`'_$b&a$_&c%^%|.z-135656622337414/~.z.wx/rw-lq+jg*le+ig'oi*pm)us*uw*xs-co+M`*9/9 %.:98G"4@*5)2(2*16;-hsy|{{~~7K(1?DE-~~4W..5*3+1OH'lyrkyn}k~k~n|n|qrwvyvvvpxyzxxyvuuxwzxsyxpxxulf5Ws+6%,9!,=!6N gBe^kYhZiWgZgTdZg\gYbY_X`UdXeUbY_[aV]T]YcX`U`T\TbXdS_V]X`V`XcU_]hTZX_T`R`R\NaQ]SZW[S6R(<('5&5)0<5^"z-|*}/0{.+|.x.y/x/x-q,u.s,s-u(q,t+r(s+p'n,q-k*k(k+o*j(m)e)g&f&i(c'g%f'e%b&a$c&b&`&b&`%5-~0263675588773531|.{{+rq,rp(nk*if,ce'jd&ig(pj&ql(il+`g*EY)=L%9H!6G$:C!:I 7G"9E#7D"7F 5D!5C"5D 4F"3E!5C 3E5F!3A"6A3@ 4A 9E!6C5D#9C!9A"4B"7A!;D"6D#5D 7E#6D 6B"6B7B$6A#7A6B 9D 4C!7D!7C!8D!7C!5F5B 7D!9C 7B"7@7A 5A5A :B"8A!7B 9C"5C#8C!7C"8A!;C!7C#8D"9C"6B!6D8B"9E"`\%Ne3F]14D'182: #-;:+7#-8<7C 2>-8+0(/,08;/jsv{y}w~3H%3;BE01R/+4*1*1SL(pyxp{p{r}o}kpxx}zuz{xytzutxswustzn{uxolqvmmg2]m'9&*: .; 6K#fDi`hXc\k[h`f[e[jXgUdWbUaXdVeYfSb[dT_UcX_V_X`Oi[dVbWaRaUcSaS]VaZ\W_P^S^Q^U]O^RaNZQVO5O'=%#3&2(285\#{0x0}/~/w/y-{)|.{.s/w.t-t-x-u,v,s*s+p-p-m+o(o.m)l(o+n(k(l(j(j(f'g(k'e(e&i'd&d(c&e%a$a&a%71,166476479;64343/{|-uu*vp(mj'ij*hg(dk)kg'mk*kl(bf(K\'=O%!090<(/<<,8 '-8=9F#2?.6(1'1+16;0gx}}z}}s1G$/>EG-}/Q--4*1.3SO'iuxm{n{v~n~swzw~w|}~uy{yrsyuywuxwquuxwuuqpmi1Zm+8"(:".9"6K!hGf]d]bYeVb\dYaWdVeVbYdZcWaVcW_WaUaYbVb[]UdYfZcReYgWfQcZ`XdXdX]X\W_X_S]T_R^VaS\S`U[S7R*;&'1(3*1;7["z/}2{.y/{/}-|-z)z0x*y,x-{,v+{-w+p,v/p*s*p(n,r)k*o+l)m)l'g*h'j(h'h'd'i'f'd&e)g&a'`%_&b&a$=1+034:67549;99632/.wx,sp,po*pj)ki*kh'kl(lk+ci+L`'DR':I$9I 8F"8H"7F#6F 7F#7D 7E%6J!8F#5F"5G"7B9E 7C"5A#4D 4D!4B 6B"5C!8D 5A6C 3C8E"5C!8A!5C 6G4E"!'0B>)8'.:=8F"3@",5(3+1+17<4mz~y|p؁3D'29GJ3~2M*,2+2+2 XO-iwys~pmstz{|{|w{w|xxwurruxxwzw{v~xvvurrsj3Xm,9$+9!)= 9L#jFh\e^g[cYa\dWa[gXhXhWd[cX_[cU`U`WbVgXeWbYeZfW`Wd]dU^RaUdV^X]W[VdQ]RXX\W\V]S_X\U[UVS7Q'A)'3!(2*496]$v0{1|,y){./y,z-y0x-z-y,w+u-u-s+r*t.t-q.p+n*q)n)m*m)k*i'j)g)k&d(h)d(f+e(g$b&b&`,_'[&]$^#A70.24854331;6;;;44/|.|w*tm,sj)nk)ln*im*bj&Wc(BT(9G%:G"7H"9D#6H"6E%6E"6F!5F$9H!8D"7B":G!7D"6C$9B!4C":C 7C4D!5D!4G#7B 4E 6C 8B!7B"6E"7F$4C"6G!8E"6D!7E!8D!7A#5D!8C#3B"3B!=D!6B7A#4A8A$7B 3B8B!7C 6E8C#6B$6A"5D!9A#7E!9B"7C 8C";D#4C#5A$9@"9D#9E";D%;C"8E =C"8D#:F#E'8A#9@&=D)B931223435045::::830~-yz.uq,wo+sl-no(fk*Xf-CX';M#9I%9H%:H!7G"7E$9I"9E$8E!8E!7G#8D!7F$9C!9F#7F 5C"6D 8C4D#5D!6E#7C!6C":E!6C"8B"5E"6B!6C"6C"8E 6B#5D!:G#8C 8B!6F"9D!3D 7D 6C!=G 5D 8E7C"6C!6B!4B 7E7A 6B;B"6A 5E";D#7F!2E!6C#:B#7C!7F$7B!9F#2C"8G$;F#6C#7D :D!;B!;D#>F!eg'Sa-H\./= /84=!'/FB.8&08>9D"0>(4'1(2,18>7hwz|~~_~1C%/9FE5.I()5&3-1XN*jwwo}ortq{wv|{uxuwqqtmtrpmouif~rmnolmhkibg2Vo*8'*9 *:!9L"jH]^[YZVXV[W\[V[YUYUVUUUVYR[RRPWL[OTMZJ[J^GWK[DXHTEVDX=S?U?P:R9R7N:N:J3K3J4J1H/|F-|J.vJ*JH$6#(7&5!(4!*48B ;I(6G,3D(2E*4F*0C&0A%1A%/>$-@#-=#-<#.;",;%+9")9 *8 ,8"&6!(9(6 (4 (6'2 &/!)3 (0(4%1'2$2(0(2#/%0&/&-".#,#.$.&.#/",=?354031743179=>?8444|/zu*xq+rr)np+dm,I^+AM$:I$:K"9G!8H%8G%;E"9I";E#9G#8E#7E"6D%;C!7E!;E"8E!5G 6E#5E!5D"9D8A!9C!4E#:B"4D!:G!7D#7E 5D!9E!7F"8D ;D!9D"8E8F 9D 6G!6B"5D 5D!;E"5G8E 8A!:D"8B"6C7C"5F#8B 8B!8C"4D!6D$6B"7G"8C#8A!8E%:D#9B!4G";D :C 9C!9D 8D"7C!8E##'/BC)9 (/9>8D$2=!,4)2(1(17>8is}}{[̄3@#3:IF!:.F-(3)1*3LO)]rk]scv`u`xZx^w]yYw[tYxXvUuXsUoMoQrNpJnFmHmEkGhBe~?aw;Zl<[f<`f:al7cl5`j6ak8[k5\c3^d2\p1W{.Re((*C$)>%(>#)?$(>$)=!+;%'=");!&8$*;"(9$*9 (8#):"(7(6!"6 #5'5!(3 '2 )7 )6(5(5 ,7 +5'7!+5*7 '4"*4 (6 *8)4+3!)3!(1'4&3 *1$5'3(2!(3'2(2'1&1'2"2%1$1&1'0#3'3%0$/%1"0!/$."-#-!.AC?86146335y4{5|8=GB<;51|/{.tv-ur,al,Qb(@Q'8J(;K%:J&8H$7F%7H$:G!:F";I#9G$5F"6D"7G$7E$8C!9E$8E!7D6F"6I"7H#:F#3D!8E 5D 7G"6D#;D!7F$9C#8E";D#5D#8B!7E:E":F"8F!7D"8E%8C$:A!7E!:E!6C"9D"8C!9D":B 8F"9A"8F!8D :E":D!9F"2?!+6*2'0+17=ivv||~}NNJ0>%19=D6{{{|z耤x{zvwu|qvtqpkoekakZj`eVeOdI\6pT+3!)2(0*1)<"(A=,??-?>+>:-A;+?7*<8+@1+@0+<0,90-;.08-+;+/9*+7)*:&(6(*9'+6&)7('6$*6&)7#)8''5&(9(*4'+6'5%(:#+5#(6#+8!'4!*8"(6%%6!*6!,7!'7 &9)6 *9!'8 (9*9%,<#+=#*<"&:$':!*:$*:$(8#':",9%+#,>$,:',@$->#+<%*:%(:%)<(*;%+=#);%)<"*<$%9$);"(<#+:$(9!'9!'7"(7!(6$5)6 '3 '2*5!'4 +5*6!%4!*6!+5 +6!)5"*6!*4"(7#(5!&7 (8 &7 (5"+5(6'4")5%6$*5#'5!+4!%3*6!&4(4!&3 &2!&0 '0 %2$0 $2$3'5&2 &0$1%3 #/"/".?@C?434520y-p0s2u3?LMA8812z.wy+dm-Rd)AU):M!"5<#2=!4; /9 -:-4)4&1)/+0(2'2)1)1*2(4+3*5 +4(3*4,5 (3)3*3,2(3 +4)5'4)3 (4!'4 '4 *3%2 )3!(5(4 &4 &4&6+4+7 (2 '6*8%5!%6(4 '6%4 &:(6!(6%):#-;")<$)=%+?%,=$*;#*;"-;&*=$*:$)=%+>&+>$*=&,@$,=$->)/<'/=$-@'+?&*>%,>%->$,;%(=$)=&)=$.=$*?#)<$(=$*<&);$)9%(<#(<"(;%':$%8#&6%6"(4!)6 '7"+6)5 ):")4#+8%'8!,9$'8"):#*9 )8"*6"):#(9$+7%(:!,9"*9#(8!'6"(:$'8#(8$*6!):!+8"(7$$6"'7!&;!)5!'5##8!(3!(7!&5#%8#'6!$5 %5!!4!"3&4!&3!"7!$2;AHA9671311u0t1w4=NPC<1/{1|}+jv,]j+BW(>L$=I$J#8H":I$9K":J#6G"8F$8G"9F!7F"6F!8H!9F"7F ;F"7F#9H";G$8E$6G";H$8E$9E#9F"$290:#'/@E*6&.@@8D 1?)6,1(1(1+0-6-8-9/9 0:!-;0;08/< 2="1>"2="5>4=!0?09 3; ,9"2;.9-5.64827!2;2< 3:09 6=!4&/?&-@$.A(0@'.@&*?%-?&,A%-@&1B&,A(*B'.D'.A(0E&/G*0C'.E+0C'/D)1D*-C'2D(.C'2A*/C(.@'1A(.C)-A)1C&/B+/?(-@*,A'-B&,>(/>"+>%);&&7$)6$&5"*8")9!-;$2<&0?%/A'.B$0A&4?'0A(3@(4@*3C'2B%1@(4B&0B+4B)3A'5@)4A(2C)3A)4D&3D)3C+4B'4C&3E*4B&7D'5I(8D)6C(7H'6D(8H(;G(9F'8J(=L*=K':K'@N+@N'AM*?P)=@EB>642.13~1|29GWRB:~4~/y/sz.cm0J\*@Q( 1:0;0:0;36 .7/8-6070:0;!3; 19 6=4:!6:694"79"6= 7=49 29 2;!1;!5&7H&BN*Q,?S,BV-CT/FX-JY/G[-J]/J]-Nc0Pd2Si-Qk2Yi0Vl2Ul/Xq3^u5`v2`z2b|4c0j~1i3l4n4q1r5w6z6078898N3)F)(<&):&):#5=%m)=FHMLRTXY[_eaimpsruy}ނ݇:;=C>9610|0~437>JTNE:|4}/py,dq.Oc(>R'G"8E";C 8F!9F#AK!@O"?J"HM$RU%L['AQ&;L#>J"ER$AO%BM$[b+5e>Q`,E`-1="39.;!(0=C,8(->? 7G"5=#)5(1*2(1,3.4.8283<2<"3;5< 7:7;!3=!7?"6=$7A"6C!7?#7;"8>!8@ 6@!0;"+617396: 4<:<":?<:92.113;BHF?@/z/kz,dq*Sd+CT(9M$=I":L#:F#7J#5G"9H 8I#9H$4E"1G 9F#7F6F!5G"7B!6C$9F!7F :C"8D$6D#8F!5F"8F#7G"5F6F"7G#:G"8!h,999A=BDDFHKMY[][b_hgqqv}ʧ*;)+1(3+6dn$mGuEmGmGkEpKoKnNoOqNqPwRoVjSuVnTsZoXoVsUqWrWoXmWmZtXmYl^kXsTpXsXmYn\pUr]s]s\/pU,=#.B&8E%0r1Y_(>,(<%0=%>H)p;5:>@>:42{//47>A?:84{1hp*Yg*EX*>L'8K!:J$;G%;I$8J"9I"H!;H#;K#F :H%6F%:D!8G":I ?J$P[*Ze-HZ*AO#P[(wq,j}5I\,9K$Wk2ku0T_*nw,=nCH`2P_)m:]v>OZ*;Q,/;59,;$*0?J!,7(/:B(.@'?J(q|;46;@C:31../46863.y.qz1[l*FX*?N$>J$:I"7J!6H#8I!9I$6D%8G!8I$4H#4F"7G"8E!8H#8E$8H"5G"5F"8E"9E!6E!5D!9F6E#4D 6G$7H#9G#:D"9F"K"EN#LP&GR&:I$:H#8C"8D"CN"bi+t4^yG$+5)15A7D$1<#,5&1*2,5XPQ2?(3:ML#g.<*+4*6/8k+sTnRrXsWsSsYpWrVpWqWtYoWlWo]sYr[pZsZpWsWoWwZlXpYp[z[p[o[k_q[n^pXqZsYv[u`v_p^0uH-A%,B(9D(3z2[^+D-*?(.B)AM+loD80:;<:44-/+~0.100-wx._n.L`(AR%=K";K"K":I#J%:E" -6-3+1.4^U!S2C'4<#MN$g/=*-3-31;j.oWsRoVuSsYnXlYpVpWs\pUp[sVqZrZnXqXtWu[s\vZt[q[s]p[x[sZsYr]t^o^s\pWt\u[vZx^t^4qF-D&/E%3E)0w2_a-@,+A&.B*AO-ndJx<5579;8210,w+v},v,~,w~,wy*cn*Oc'@O$;I#9J#6G";F#>I$6H#8H$7H$5H6E!9G"8G#:F!7G$6G#5E#7F%8F#5E$7G!:F$S%9I#8C#9F$6G$FQ%^k-r:Zz9[g.}9BpDw7tQ/rRObIr>476;>7/-{-~*x({|,xz+is*Vf(CS$9H!7D3G3E 4B!3@ 7D4E!5G!4D4B"2D"7F"8F 4D!6C"4C 7D 6C#7F!6C":F"@M$R`)k}2d@F\)5K"8G :H:E#AM#Xg0s$_R&zv0<&)2,3/:i.qXpToWqVpYoXmToWnWpVoWr[sYs[r\p[oVsZsVvZvVu[p]sVqWrZu^qZwZq[pYs]xa|e{fxbz^m]/hE,?$+<%1E'4u1^^/G10C./D(DN/qNOXKhG|@78;;<21,*~~-w{(ls)^k'HW#M$=H#@K!Xb,?yKPg3K[(k2FIx9Tp/KW'ow0@KINJUYX\iGG]/S[(Pn;PX);N+/95?(:#52>O%,2-39G"6F&4> ,1+3)405y`!J7A(5@%d[%o.<(,6*3/=m0nUoWsXxUoWqZm\l[xZpYt^pTvZwXtZw^vZq\vYsZu]vZqWwWrZtYuYwWt[vZy_w]w_u`|hy`{[ra.gE*?!,?&5G(/z1b],D/.B+1F/BN0oMQTM\MrE889=9311)},sv,`m(L[':K#6E 7B 5A6D4C 3A 4@6B5C7B5E6D8A9D3D!6D 8D"5E3A 6B!1E4B"7B6D EV&Zp2u>Wx=@S%7G":I!5D#;I$HU&^t4BvE?}Kn>B}QpGNh0CU$`o1BNOXPRHRYNPl9>M';F"EJ"R_&{aj*{5EYK_FTe.y6JZVSQO][UvLMb1S[&Oq&h[*l.;%)7,7.=k2qWqZrXvZt[oVsYuWoZtWn^vYrSoYvVtUrZ|YqYt\vXxZr]t[p\r^u[t\v^td{_xd|byb{ct`|^n],eG,?#,@#7F#0x3a^-F--F+3F,IR2sRNNOWL_Fw:78;?820{-u|)eq*R_&?L#:E!6B!8E#7A 7D!3> 5D!4A4@ 8@8E!4B"6B 4B7A$6E 5B!6C5D"6F3E6B!5@ 1C"5B :L"Pd,p6f@F\*9I":G ;F!=G$LU$n}5AIFP|EuCp?ASv>FV+N_*i9HRYW~NnD|IMvSTj5NW'TW"ai*z2=PL?BP^X[GRe0r5INUSTIXUTN\s8dh+Po:FU*8E".95@+8"677N',9-0;C#"(6!:68M&(5,1=F!9F$4?"-3*1+105t&B4A(6=!jU'e,;#,8+55> j3uVnYtTtWpWuWn\rSpTpZrYq]pXwTu_qUu[s[xTuYu\s[tUu[{Xr]ybzay`{^zfzbt_q^paxZx_m_/cB,A#*?!8F'4|4a`1H/.F+2F,BT2tSKMONORReGy=69;<>5w-em)IY)8H"7F$7C 5C6C5C 5B8B!4C 4A!5A 3A"6E"5D!6F!5B#5E"5B#6G#7D"7H&6E"8C :E"9F EN#R`(^j,l}2}=IG|;rK$$6I,5s4cb.J4/F,0J/CW1tR~IG~PKPRJZGi@668:<3ez+R_(8J)(3-29D!5E"/>!)4)2*/25|'I4B'6C"n`)]-9&+6)95Ar6uWwWuVt[u\tUtXtVq^rXr[tXwXv]x[xYtWwXs]tYtYrXqZzYsZtW{[z^|a|d|huft_sht^v`w\nX.^@,>#-@$3H)4z6d_0H0.D,2H-BW/uM|FLQKSOORL_Hk7}35=8h3Sj-BS$8G!6E 7D2A 7E!6C6C!6@9C!4D 7D 7C5B 6C#5D!7D4F!4D"7F%:D!7C"7D"7E#7H8G#9N$M[(du1hIhFkIxLQgSOyEDl;@]5=O*EP%`i+lHnz;Hf89M%8C$.65? (B%BA!4I(*3/5:A!5C#1;!+3'/(//5+A5@(6=&rehU,6&+7!+74? v7yVqWsWtYv[pZw\tXsYvYu[tW|[s[u_kYu\p]tZp^vWwYvYt[v[{\{]}a}e}fucv`x_o_ocp\s\q\-^>*B#/@%6L+6x5d]-I1/J*0E/@W4rX{BNPIQKRQMSL_Ii8e7m3a2Qj+?T&:H 4B9C 5E6C 8A!4D 5D 5A!5C"6A5C!6C#6D7D 7E"6E!7D!9B 4C!5E#:D!5E$:E#9D%6D!;G%9L%9Z,;X0>R,E^-Zt:xBgAI]-?N&?M(?M$HT%]n/@VVWRSUPPdHDZ.Tb*u;RUTRT|BLV[J?T)6H"4C"9H!M])q8uDQl6Xg,w>jJAX1;I$;J!G\+^|:bGQ|DGl@B_2Sg2Tp6D]/H[-Kd6hr4Ff8=M&6C".53A!(3D?1I&)414;E 6E$1>"*1'3)117 )>7A'6@&}h(S/9$*8/6 2@u9oVpWrTmVw[xWt[yXtUx[v\uXyZsZt]w\tZp\uXtXvWs[t`y\u]zX{b{dz`v_yctbvdqcr^p_tap]+\>-@!.D":K&í9u3cc,J80I.2J/CT0sUu=MOILKNLULUOOPES?M~?Cg59S(4F"5F 1A3A!5B!5A3C6? 4A0@"3C 8@4E!5D!5D6F!6C#6D!5B!4F 8A!6C#5G!9C"8E"7H"LX~T~VrIlAvOMbI?W,GU(Zn2vFGOQ]IKj7_z:zCQxA:I(5E6A!5G"DO!Yj0e~>Gf9CX+Qm-Ll8;M):F#2B 6F":M(%k+T/:$*7.76@t7qTt[qWrXvXsRxWsZtUzVzZuVqWs\qZuXwXuUtZt`u\p_y[r_w^z^z]z^w^v]udreraqeu_p]v[p\1\=,@#.A$8D'ð6r7ca3G6.G.2J/ET2y[s:N}NJPGTISLSJPMOLOLxJ?f8;Q'8D 6B3B 0@6C3@!4B!5D5A 4C4C!4A 4C8G!5C 7D!8E!8F"5D"5D"6D#6G#5F$8C#5F"6F":F":F$;F"6G!=H#KV'Yf)m2!3A"3>5C 3A4B2@!4?!2B5C#3A"5D 4@ 8E!8B 7E 7D#5C#8E!7D :C#6C"8E$6G"8H#9E!7F%9G!EP(Xe,z9DNRQJ|FaCI\0?O&K^+`x6kJZ{@^;^z@C[/F[,Tm3Ll: 5@3@ 6?!5B6?5A!5B5@8? 5A 3@!4B5@ 4A 7C pm'Ba6J])2I+.85D$%4ID/E)&3.5:D!6E#0;%(2,.+109ܟ.?:>'6A$m+P/<%-8!*74C"x=xXpYvZzYqZsWyZxYrSsZv[tXuZr\xUwXoZsZpWuXr`s^qVz^xby_z^z]zct_vel^tascpfpbv_o],[8,B&0A'6J)±5y5db/K6-G-0J,FT3z`l7RxIKPIQINHLIQKTHVKRF{JDj@;U.4E$1?!3?/@5=/B 7@2A 2C4A4B 3B8D"6C#6A 2E!3E 4C7D 6B4E!5D!7D"7E$3G!8F#6E"6I;G$=R$Qe.dL,=I%:J'7M*9G#9C#6B#8E8C!6G!4H$7F"8D!8E"8D":D"7A6@!8B!8A 6?6? 1B8B4?6C7?5B!6> 4A 7? 4>!3?4B3?3B!3A 9A3@!6A;A ut(D`$,A(6H(Ų:z6fd-H4.F01H/CT2vgg3XxFNPHOKPKSIRLNLNNQINIvD>`99P(4D4B"2?7B2? 5@2@5A3C2A2A7C5B 7B7A6D 8D"9E":A#6E#6E;E!;D$4D"8G 9G 8G"9E%9J#:R)=Y0:W1>S*;O*L$:J%:G$8L$;L'8H(:I#6? 5?3B7>9>!8?3>3@8@9B"}+Bd?>G%4@ 372@"(2FB0?$%3563B4@ 3C 4A4D6B!7B"5C!4E"5D 5C#7E!4F!5E"9E!4F"7G!9F6F!7D$8D$8I$8J!7G$9I&8H$9J$:G$=G$9F#;K#7H#7G$:J$:J%9H#9G";G%9G$7E!9G$8E 5C#8A!7C"=E7C"5F":D!7E!9B 2?6A0A 4> 3@0?!8C /@4B 4A 5B4B6B 7E7E"7D!7H!7D 6H 9E#7H$9E%7F"5> 3A3?!2?5B 4@9D4Kb7EX/5B&.65@"'1SD3@#&339 3B0@4@4A4A5A 4>3?2A3? 4B 5B!8?0A5B!6B6C!9D2B!8F 8E7D2F"7F#7F#:H$9F"8G&9F#8F$8F$9H#:H"9H'8? 5A7>!6?5>4A 4>;D!7Ig2JW.4@!073?"&1TI0D)'3265G"3A!.9*3+2+5;?!>=gd5>#9B$/@/:#-7 *78D!t?p[pWu\rYu]tYrSvZpYv]sUuVr^tZq\qZu\t\x]t\wZv_ta{_yat_r^r^q[s\v]w`r_sepbr`y^j`-W8.C&.C&;N(޳:|4bb,I32G/3H.EU2xla+ak4O}HMNJQIXJRMVJOOVMMHQNMHwLAiA6Q05C"3D 2?5B5F5A3@2A2B6C!4A!3A1@4A2D 2A3?0C"1C!7C!7B 3@"6E :C":E!6D"6D"9E 7E 9I";E!5G$7G!7I";I#:H#7F$:H$:I#8E$K"R\*i{5o=B|FDFCDCzA{?{@x?w>v;xI!@F"=E";B!9D!:@ 8B!5B 5@8A ?B"ERf5J`/4D'07.B%)1YR0C%(3 :77D"3D"/A"J@d\5@)>A$0?/:".7,68HnDpXq\sZv\uZtXyVrUpZsZqYrUsZn]v\q`r\pVu\q\v]yby`ybx`s`q]t_v]tUw_xarfocqfsdugi\/W7-B$/F(9N)9z6bb/J2/F.1I-@S2zq_)ei0SzGILJRIPMNFQIRLQHNKQKRDzF>e<8L-5E"0C2B 5A6@7B!6F!6E 4A3D 3B1@ 1B 3E 5B 3B!4B!4A4?3A 3A"4C 5A!5C!5B!5D 9E5G"5B#7G9G!;F#;G!7F#9F#:G"9I"8G"6I!:H#6E"7G#:H#8G%7E"9F#9G$5F$9E#9G!7E$;K$JZ(Zu;k?tINTRTOQSOOOQRROLzFl;Xo0We.P_)JY(ER&?M%BL!=G!(277A$*1SO"/@!&368:D 4@"/rZr[u[q]oZuXrTrYtWoWrZtZu]pYvXqYr[u_r^v^qazaw]sgp]s_p^l`vWu_r]w^satasevdu`g\/U9*@#.B)zFLSOVORQVNTORRPRIEz@j;^v1Xg1Sb+QY(JX'LU'JS$CO"HN!RD]-Ca3/>&082?#&0LQ.>"&156;A"6?",8!*1*2,5;BM:\U7B%N$9H%7C 6C6C 3A 4A7> 5@4> 3A!4A 3?2D 5@4A"7B!4C7@6B7D!8E!3F"8B"8C$8E"8F!;D#8D#7E"6D#7H&8D"7F$7G%6F!9G#8D"8E#9F&8E!9F#:J#JV&Vg2Xo5`|9l@NVYXZ[VSSTXTVWNTSTJ|Ab|;[p3Zj0Ui1\g.Sd.N_,S`+ZSc/@]1/=!394>#'2MK5?!#1197C"3@#/8!'3+5+8BB!V9WM4@(;B&ڛ/9.8 (5)4 :GsGqVvWoXq[tVtZrZsYrVq[tZu[sYrWtWv`xYv]u[y[s]xdr`v_p]mao[n_rZw\x`zZp_o`pct\q_nY.V5,?#0@'8K+8r4b\0E3.F00H/AT4~q_(gc.\p9POGOLNOPJQKPISNLNMIuI9_96L+3E"4E"5C4A5C$ 5C 2A5A3B 3D5A!5@4A!4B!3@ 6F!2B"6D5B!6D"6C!8E"6C!7F!8E!7G#6H$4E$7D!8D 9D$9F":D#7E8E"9E#8E#7E!:E"!%.299F!5A#,9+1+2-7AH$YN#J\(Pg/Pf/Og/Re0Qd+Yd*K^%>K!7E!4E2A5< 6@2> 4C5@ 5A4A5A5C"6A!8D!5B4F"4E#7E"7C"7G!7A%6F#:E!9E'7F7D"6F 8F$6F"7B8D7B"8B!8F"8E#6D#5C":E$?N$Pa'Uj3\r3o9G__[TUVV[_Z]a^e^cbceXC@@B=};;pIe/K_32@!/8/@%&0JQ$0;*/168A"3? +: )2*0/2CG!Y;SL5>$=C&58+9!,8+7!*1PW)/;%45;6B"6?"/9"+6 )3.5?F!c7RH2>%:B'86-:",6 (5:L rMvZt\tUo[rYo_oTsYp]s[qXs\q\x[wZq\s\w[}bw_|_v_vcs_t^o_lao^tZs]w[{]v]zfz^r`t`l`/T4-D#0C&;L,9r0_^*G3-E-0F,@T2~wY#m^'fi3U}GLUMONROTJRJPMQBsC:[79I#7E!7A 6A!6B 7G";M%MY)Qi.Tg4Rm1Zn2i2@NP|G`u2EV%7G!4F6@ 6C8A4B 4B3@ 9D=H$HT'Q_+Q_.Qc,P^*KY)JX)CS&@Q&BK!Re_c`[Y\^Tf/CX1/=1=/?#(/ET#0; %2296C 4>$+7!'3'3-5DI!e5P?2=';B$<6*7%'3)3=K yJmSrRq\pRoYrVrYrWq\s[u\s\w\uXv]wXtZv^x^|]|bpcpamar\p\p_sanaq^uZv[{]v_{]u^xbf_/P3,>&0@';K*:o.^a-F5,D,-C.@S1{sY%r_)fi2WzAMOMNNRLSKUKPF|N@mB8O*6D"3@!2? 5C 3E ;H#@S$H_+Nh0Pg/Rm2^t4v9IWVI}Gcu5EZ%K%@H";I$7F!:J#:G"8D"9F"8E ;@#8D";E!D%AH$@I&@J#HK$HL#YQ%ve(4L`ibQ}>{<|AIXm4H_33=1;*<'(.CQ(16%0686C!1?")6'.+1+2GE!n6P?5<">B%>3-7 (5+7=JwKrYsTqTsViXoXpYn]q`m[nWsXu\w_vX{[u[mYz\s_t^u^sgn_q^l_s^yat^u\x[y\{\vcxbn`q^cb-R2+A#/C&7M)8s1[],B+,<+/A+>R/~z[%r^'he.Zs?RNORLTHROQJNFvH>b94K&6D3@!4D 6C 8C!=H#FV'Lf,Mi0Mj2Tl0d}6}=PX{J>F~Jh}7I[#;J!9D 5B4C5C ;C=J#I[)Pi3Oo3Zt;b=mDuIE|FvDs?t:d;dx1\o1Se-M`,L]'FS(FO&AN&:I!=J#7G"8G":F!8H#:K#AT&Uf,Tn3^r5w?OX{@fb'EQ'@F$:B#;D"=C$:D#9A&9D#D#AG%QM'o_(6KgiZ{Cvj,d](_X&{/Nh1J]5/>#/:+<%*0DP(/9$18;2A /@ ,7 '1+0-1GH$s5M=3=$@C$A5}+7"*6.6AJsIzVrToYrToVqVmTkVqXrYuZt\vZrZt[z[x[w^y\w]w_u^tYt^j_t_n^papbq[x`uXv]x^t_ucrba^*P3,=$.A%;J*9o*Z_*F-*@+*@+?P0}z`%w`#mi.[q8MNONJOLSNTM~PBmD7Q21H"8E#3B3C 6D"8I"=S'K_*Mg0Nl1Se0Zt2n9GP~Moz6r|8zQ)Nc,Tk2]t3x=IXGjh.HP):G$;E%?E';H&>F$>E&>E%?H'EJ*HQ*PR+k^,6NceRut8cm.CL*BI%qs&Ld/@Z/,="2;+:$)0FO#2:&-394@"1;!)4#&.+/,3HI"x3M;09"=C"A4{|*4")3)6?PvKrXvUqVpWqZoZlTk]r_s]xYr[sWu[u[vZtWyY}]w`sbt_rau^sdrby^u^pbt[s`v\u^s^udxdpcca+Q2,A$.C$:H*>p-^])D/(?,,?)@O/wxZ"v`%ja)]s5O~MHQKOKSINEtK?b=6J*5E$3D4D6C!8E G!HT'Lg,Pg2Nk/Wm6[t4t;HVWTWQVUSQOMIFz=f=Zp2HZ+?N':L$9F!K$MW&Ig/Pl/Rm1Yq4j8ASPny:Zh-IV&LX(`m/x9FJo=Oe+?M"=I"@O&M[(Nk0Tj3Pn1Xk2g~6CW__^\^ZV\VTUMMSMrFc:Qf+BS&H&AH(FK,CJ+GK)FL/JO.K]3Ob",4)1(/(2?E 3A3+8 ;@#C1on)0'0)4BPyQoXsWsToYtWnTnWpYw[q]w]uYzWpXuYuYxX{Z{ax^|`uZuZpZn^t]zYu_q`tZu[tXz]u^z_u]vec`0L1-?"-@&;H(6n.X^&@0(>(+?(?L*v]'v_"s`'fh.TyHPNMPLSG}J>hA4J-2C"4C2C5D$3F!8K AR#Jb+Mf0Qk2Rj3[s5r9HWsIgn0O^+CP'@M#MX)]f.v8EKp@Sg,CT&EV&Qg/Ok1Ti3Uo6ar3x7J[ZOQVZ\^b\\]Z[VSOMuBZs4IZ*AN%GR$P]+Si2Ul4e~7D[Rwu3UY(?J%AE#?G(BJ+FL/FK+DL+LV/Rc;Jd@Q[5ga,2JW{Kno0T\*;F'0? )4(0%0%1,7.\57iO5u\7{c8n)'?):J,v{_%s]$u^)ig.YyBMMLOIO>rE=^:2F$2@#2@0?!1A!6H!;K"EU%Mg+Pj0Qh/Un6b}8BNPk|:\k-FS(?M&=K&DM'LR(\f.v|6CMtB]v2Wh,Uo-Om4Th4Vm2cx5?TVyFkw6lt8ky9w<|CIKVX`]\W\^[VNy<_m-Yh+Yk.Yo2Zp3f{5@XUo|6R\+AJ'=H&>G(@H,CJ-EI*DK+JR0R_:Kg?N^9f`11ERnz?gh*BM&8B$=E$EH'3kUl:?T.-5"0=*;$21?Q*26'/4:5?19&3'/(-&.*2'1,2+6 *6-5#,8"+:%)9!,7#2:"/;%-8%-;&.9#,='-='3=',;',9&)6!*6)2!*3,9$-8%/;&-:'-;'-8)+;&+;(.<',=+,@.-A,,E./I1-J6/K81R;1UE2\G2]N3mW1s]5ug4yn8{:|@@GGLQTVVS)7Z'/'/(2.FAFAPGPJNHRHSOSQRPUXZ[XYV^TaUdSeUjTjWlZhXmSgSmVqVm\oXnVm\pWnXn\l\pbpYrYq_p^k`fa+K-,;#)="6G'6p.UW(>,$:'(>*8K*zy`%}\$u^&hc,[s>NRMNI{KBkC6P0/C .@1?.>3?5CAM"G[)Pg.Tg1Qj1Xs4o;FSqKcq3O_.@N&AK'=K&DL)CO+GR(Zb,q7CK}Fg8Zu3Sn0Qo/\n4n8GXNpv8ek-RZ-MX%RV'W[+^d/fo3lu6u<{EGNRYYX[ZWLAp9a9[u5`y8DSTq~:\_+BM&=F%@E'BG*FJ)AI.GJ-KT1O_8Nh=K]5c^20?Grp2T_-;G$V0,7 /;'6 44?W,38#3/93= 1;*0&.',).)0(1)2*2+2)4(6*4(6!+9 ,4 .6!*4,5!-4 +6,7 +5*6*4,3+1*3'3,2*0,/*1*1&.)/ '2*1,0+1*1!(2+2 )2'0,0 )2!*4 )0 *2(0'2'2(1+3 +3 )3!.4"*5#+6 +4$.6 )3#+5 &4!(0(2&.'0'1*1(5(1(7&4+8)7+9!&:(;&:(;!(>!+B$*A%&H&(L&,P*,S-,X4*W3(\6,^1)a6+a8,k?.qA.qC4pC2vJ1K2G5Q;N:T;R<\@\;c(@0-<"->7C'6k*PU)<*$8&&:%8E)m_&w`%r^%oc+\t9LLJMIsL?c=;L'5B!0> /=0=3@!5J ?R%M`,Oc1Sg0Pk6`{4w@LUoAah*IT)@K'?L'AJ*BL,AM*CL)LS(Ua/mu5FNIs?]u5Xp4bv5>M[xJml1P[-@L'=G%AN$BM'KL'KM&MS$UV(Y[+^d,dl3lu7r;{@ENUdaYOqCk>i|9};SVv?`b*CM'?H%CE$BF(DI)AI-CK,IR.P^9Tj@PZ:_^.w09px?gf,EQ*>C$>A&@F'FK(ī:dNj8;S0/:1> &7$45$-H'5Q96UC2^D4`H3fI9lQ8oZ:ua;q9z=<;?>?@CICFLNP[ZcnvyW)JP$9)):(':&1@)mwa'{[$v^%p_)cl6S~KJ|JBlC;W35D$4A!/=->/>1> 0G#MLh?a~:r:EVUjz<`i/NQ(;I'>H'Z,3:&3273<.:(1*.&-(.*4:H=P?N!8N8O";M!9O7L!6J 5I 0F4G3C.C/C!0A/>1; *;+7(2'1)/'.(.)1'/(,(/'-'0%+(, ',(-#,%-'-'.&,$,%,&-$+',%+#,$-%-&,'-)-'/(/&0(.%/&/%0*.'.','.&-).*,%-&/'.*.'/%,(.)1(0*/'1(1*1,2&4*3+4(4&3%1&0&0&/(1+2)6'4'5'7(5'3+3)5(5+8'5*5,8 *;):#,= ->&/>%+D&0D'1C(/D*0G+4G+0H)3H*0F,3H*/E.0I*1K,4J,1I,1H01J.8I02I20G/4M00J22H10L//I1/M22L3/L41N20M80S92O71P9/P:2RK$I&@I'AH*@L&AH)BJ'?H&?G%1=?24/)@0(@3*@3%B5(A5(B5&A6(A4(B5*B6$C9&E6(F;&F<)G9*F?%F?&IA'HG&IH&ME)LJ%NN%MR(PR(NU'TW)U[)Y]'[g%^h(dlza$}b#w^&pb&kk4VvBK}FJtFB]6I'?I&AM+AL*EP,BO-GQ.DO,CO*EN,FP&U\,io3z>JQPXOpC`k/FS(?H)DG'BK&HL*HN-CO-DN*FK/CK(IR+IZ0L[1L\2NY/cd/z1BT_`YSTVWP][Joi-GR'CG%GJ@FI=DHDFF=DCBHB?EAAFABD?CC9CC6EB:?B8<@13<)&0(-(,).>/X<fDhBi?a=Y>W=O9M<I7B7A7B4=5>5;678<9 8843/3/1,0,113.506/204/6/6*7 -8,4,5-4*5*9-6+6*9!,9".:$1?#4B"3E"4F%3F#5F$2F$2G%5G$2I&3H'3F&2J(4F'2I'3E(2K)2H)3F(2F(1H)3G(0E(/G%0G&.I%1D(0E'-D)/C%/G)0E(.E&/C(0E(-C(,E(+@*0C'-E(+B)'=&%<&$5#!:!#5"!3""3"#5" 6$"4" 4%"4%#2"!4$#5#!3$"6&!5'#7* 3'&8%%9+%9+(<*$<)'<'&<,&<* ;+%<)#9*%:)&;*%8+#8("7*"7+"7($:(&8(#9(#9*!6'":)"6)9'!5*!5( 6'!4("9$"4&"3&b(}_&y^$qa'ih0[w>M~LLxIDm?>Z,8I#3C-?,> /= -;0> 6D%@O$La-fz4ENrFei-HZ+>G&=F%@H'@H*BM-DM1BO,CO,CL*EN-@L+AN'BO)PZ)gq/}=LYZ{Mjm3R_.?J'=H%"*8"&/%0'/(00:H3F?FBJBIALIRCLDKGQIOHNESNPKOPPKQMKGNL*_='/%.(.<=-CMVEKXDHa=I\FKU@I[DHX@H[AJ[@IX@K]BK[CG\FIaAKd@I\DI[@KdDK_DJZ?MbCJcCI]?J^EK^BNcFReEO^BOaGO]BO_GPgCQcCK^:JO(0'$-(.'-X;X,Y5Y2^1^3[6_0]0]/\2Z.X,Z,Y-Y,Z-],[*V)W'T)O(L#L"L&M%M"N"K vK!oK tJhF"bF[EZAO@ I>!8@-6-8!-:$1@ [H#ko$fm)_k)Ze)Yd'T`+N['JZ&FV'FU(CT%BU)AQ(CO(=Q(@O&;L':K%9K';L(8M)6J)8L(6J'5J*4L*3J#2I(2H&2H'0G%4H'3G'0G&/E(0D'/D&/B%,A&)B%*B&';$"8"%6!%6#"0" 3!$3% 0!!2#!0" 1$ 14$3% 2$!3'4& 1& 3$#5##6&$9)#:'$8(#:'"9)"8&$4'5'!9%#5($8&!6'"7( 6! 4%5&!7& 5% 4$!6% 4&"4$"2%!3$"3&1$"0!3$0"!0#~e%c%_&u`%mf+]u9U~JJIMwFDd;:U(3E"1@/:+="1> /=2? 6E"CX'[t4FRl@`g-JS+@H(;I'>I*CK*AO-BK.CM,?M.BN/BM-AM-FO)AM)BL%QV+fj/x;MQl~?`h,HT)>I&=F%?M(CM*IQ*EM+EO/IN,GR/R^6[r?[{EQtARf=ij60DSbd^^Z]YQGIMLlr1VY%AI%D&DG+CI,CI(GO/O[5Ne=IW9ZX1ra)`g-@L+=A%;A"?C&@E(EH)IL/?VB\1.B*-5.:!&6=6:R*09'./70;)7$.'-$/'/.=B6KBICLDIHMFNGLHMIOHNFQHQMOISMQJKLOKKJ+^?&0&-$/==-AHWHHY>Kd@IXBHZBI`AGX?H\BKaAI[?Jf@IcDGbCJf>L`DK_@J\AJ`CI]@KdBJ]BLgAG^CHdCLcIOfBOaBOcFOcEQqENcGOnHQfFKa9H[&.*&+'+*/];[.b1^4a6f8b8a6c;d6d6e6e9f9d7c4f4j8h6i5f7c6b8d4b5g3f4d8g8h:i8f7g6j9f8d4f3b2]3]Z6-;$-9-; N&4F"&B"%8!!7!1!2 /!$0"#1 #3$ 6$"4&$3"$6$"4!#3$!2%!4$!3%$4%&8%"9(%9&%:("8'%7("6)$7'$7(#6&"6'%9' 5$!9$#4%"6%$6$!4%!3%4#!3$!3%!2# 4$!2$"2"2"1%0#!0".! . i)a({`%xb&mi+`q8SIMQI|NFuD?`14J$2C3>0=/=0@-? 4A=L%Le.e=yMvDhu3[\%AO$>H'AI'=K)BL,BM+AO,DM+FN-BJ.BM.BM,CL*AJ-FN'MS(]l0qu4t:hp1S`,@N&:E$@I&CK*IM*BO-EN+EO+GO1LW3^n7`DW}IQjE]g6}r5:L[YWVO}Ev?i{:hl7qg/w/=Mnx9_]*AI"F$@I(@K+FJ)EN+JZ3Ob>GY7SX,g_(OY,=A"9A!;@$=D%DF*CM+JP,JZOe32D$.52;(1FA3M0/9&2.64;*6$.(.&/'/3@B8K@MDHAIDMGEFMDLGJFKLODKHMJQLOMQPPMPN,Z9%/$.(0<=,L_?I^AKZ@J_BIcAF^?K`=J_?IaEIbAL`BG_>H^AHaDG]AH[AIb@Ki>JaAKfAK`GOhINdEP`DMfGNgFP[HRkLPmFMb8H_$/+&+',(.^;`5b1b5e5d8d6c3e3e3b3d7c1e5e5f7e3g2i6h4d5b7g2d5h3f:j7j;i7j;k;h=j;h?k:j8g7f6g5g]:.:#-9/:>F"1wbZW$A%"53!1%1 n[(s>o;j=f<_7Zw7[q5Ot0Qf4Fd0D].@\.>Y.:U.8S,4M-2M/3K*/I--F*(F-,A*+@++>)'=)%<)$<*&:("9'&7&(8'#7(!8%!6%#5("4&!3#"4% 2$"1$1"#0!0 p'e&c(y`$od+cq5[INSKNI{IEo?;U,2F 0?!3=1:/=.90>5D =T%Lf-b9yCxAis/ZZ'IQ#AK'?G*CJ*?K,BM*?O*AN-BN*BM)EN.CM.L)@M%JR)TY)a`/_a,FT);H'?G$>G(BM)DM.DK*FN.FN.IU1Ue4a}>`JPpFXdio9af/\])WV(US&UP'ZY#qm(9Lo>]^&@I"?C#@G&=I*FG)CH*DM-IW0G\H]>I_?G\AJ]?H`?H[BG_=I[;J]=KcAJ`BJ]@Jd?JcBG`AIfCFb@I`EHb@Ef@Ha?J`DGeDKiBMhBOeGMcDMfGPnBP^HNnIMhGOb6Hg&+(%-'+),_:a3_6_0b6b4c5a3b1b4b3c4h:e5e5c5e1h4i7f8f2c6b1f6g0g6j4j3g7g;k:h8h:i@F!+g(G3 6"!3!!1 $6 vD}҈}{Հswt~z{yu{{urzuަvٙs֓sʏjŇsl}pomkj]hamXgSiR^MfE[C\BTAT|ATt;Wq7Ot7Fg5o+f&~e'}a$rd)fm2W~GPRPTQPIoFCe97N&1B 2B0>3;2</; 2?3@ ;O(H_,[u9qCyCk{6Zb*KQ&BJ%>H*>H)@I-@K,@K-?H,AM*DJ+BO-AM+CI,@I&>J'GQ&PR$QW&>I&G+DH+EH0EN.HS5CR7GL'HK#9E%6@#>B$-@IUAIXBGb@FW=G[AGb;Gb=KbAM`>H^CJ`CI]AIb>GcCH`>G`BJb>G`>G^ >G.`+K/#6!!4 "4 &8!vHք~}}}wy{{|{|uzr{szttuworpommimkglmekbbh׾c̶t*i(}e(vc'wd&mk/[yBSNOTROJLFsC;\16H$0A"5=3? /<2@,</?1D 7H%D[+Ss5l>xFn:]g+LT&@J)H&AJ+FR+CN+DK-EO0JW0[g7`y>WFMnCWe7rm109rs0cf+KQ%DN%?H%;C#7B#8B!=G#G&EI'YU'x.={Bgd*IM!>C%?D%AE(@H'CG+DJ,DK+EO3@M1BI'>F"8A#6B#?D#EE'AE*AG-@J+MO.VWNe3/=&+33=&2PB/I1,6&//80<)4&-%/%-'/5DF6GBJFLBIHJIKEMFMKLFSGOJOHNINHPMNQOIII(T;%,$*$-?=/=FY>H_BGb>H[I`CI`AG`?G^@J\AJ_AGbAFc>IdAGdEJ^AGc?JgAJ[CGcDJf@KfAKgEKcANbHQkDRgBM]EPoHJjDKe6Fc(*'%)$,(*e;_3b2^3`4f7d1d5e2c3c2b6c2f5e4f5d6f5h5i6c2b4a2d5d3h3i4g9g7i;j8g7j:j6h5e4f3j7e9h]9/:",9!0=!?G"1d߰&N0%3!#7 %3$(;#qD{{{{y~{|xx|w~t~y}qpoqponoipinmkcmibbiي}.j+f(ze&we)im/^x>RMMQMQMPK{ICl@9S*2C"2@0>/?/>!0> -> /?1D 2H#CU(On3g=zGt=an)RS'BM%I,AK*>I+AK*>G,AK-=K+DK+;H*>K%9E%=G%:F)Cp9Z_*EL#@#=F&@I)EN)EO/UU,yg'8z/@HUBIcAJ_I]AGb?G`J\=Hc@Ga>J[BJ`@G_?Jc?KfCJkDMbDMeGOhBLhELZEOjGMk@Nd3Aa%*%#*'*+*g9]0b7\4_7b3b2a3f3c2c3`2c3c1d0e4g5f3e6g4c5c3c1a2c2e4h4i6i4f6c7f8i:h7l8i6f7j9f4i\:.:$,72=-=,:2@3@ 6H"?R(Kk0f;uCv@eo.QW&BJ%J,?I-@M->F)BJ0=L.;K+>I'F(>F(FJ*CJ)DM.DM+GO.KT.Zi8_z@V|GPjAXb6|q/6HS{Ddd,HM#F+CG(CF,BH,AH*?E,>F&B(@E*@J*FJ,BP.SY3g[dHc6+<%.419 $1LD/F(/7%108/;'4$,"+!-$03GE;IAJCKBH?KBJGIINHLHNHLFNJNKNJKLOKOEMH&J6!-!*%+:@.?DVDG_@Ee>FZ=DWBI[?H`>F[?H]>F`=Ce=J\?Fa>E\=J`=IdH_CGhFMhGLfFIlFOgAHWAQhELkDKd2D^%)$$)#'&*f9b2b3\3_5`5b7_/`3a/c2b3^2`/e1b4g1g4h7f7h3_2a0`4c3e2h7e5e8f7h5g4g8h:j9h6g4g7i7n[8-:"+:0= =E"-bߨ)H/#5 "4!3!%6$tGz|zvz|~~{yytxrxpuouqwrnlonliimhklkekdޣ9u+g)e({f)sm*gu8ZNSQPUQPLMM}MDlE:\02I%2B.<3=1=.= 1@0=1> 0>!4B#=P%Ic0]}9wDw@iv3U[&IL(>E%:D(;F+;H/K,?L.EJ.CN.JP-R`/Yr;^COqEWd>ij41FX]Nfk+OQ'@G#;D"@F&AG)BH(DG*GO*KU/FW:HS0`[)zt/7fi-RP&E$>G)@H)BG)@I+@D-BF*@D*AE(?E*;G&AF(?I+JK-KV2P\4Tc;wRQEb5-:!,41:&-HH2@$,7'..71:#5#.&,$,).8KD:HAFALEHDKEJGNDKEKFHHMINIOOOMMGOIKHJI%M4 .!*$*<=2>ET=F[@Gd>FY@JT>JZH`?F_?D^AE^?If=J_AF[>Ib?I`?FaDE`?Hg>H_@G^>H^CGbBGb@J[BKfDLiALgDNoFKSJNjHJfBIf3Cf$*!$($)+)f;^2`5Y5]3]2a0`1b0b3c3^1c2`3`4`5d4f6k4e8b4`3b3a1a1e4h5h7d5h7i4g6g8h.@/= 3="2 0=/<2@"5M&D].Xr5lBwEf8\_&KO(=I);E'6F'7E(;J,=E*:G+N.FJ-IV1Ug;ZxBOzGPf=\g4v+>Nc]Qi|7UW(>F$8?#9B'?E)AK,H.=E)@E'?D*;D+CH+5=FXAEY>Fc9D[=EY?G`?D]BH^@Ga;G_Ga?F]@G_@H\?Ha@Gb=Ec?GfI_AKa?DeBGa@KdCIb@KfBLgDMfGHYFPjBLkE"2\ݮ&J/$5 3!2#7"yExzzt|~x|xqx|{uxqtmnhsojnmgogkcfglbeehᵬ@2q*h)c'yg+ls1^DUORUSQTPNMFNBrD>]78L#2A!0> /? 1>2>1?.?1>-;"1=/B 5G!@Y*So4g@Cq;_f.QS&AH&E);I+;I+:D,@E,?F+=G->I-?I,?H.AN.CM-M^2Um9VzELiDVa7qi06HWWRRpC_['AI#9B$8A$:E'AG,?F*BH.CM/JV6DV3NS.j_(vs1di.YU&;C"6?!:@%E->F+AE)?H,CG)DL/S_6SmAKnDTl?Pt;DUF\@F_AI_@I`E`=Ea@Jc:GaAE_BKdDHe@HkCMfDJgFGTBKkFKmBJa/@a!)!%(#(**r<\4_2[/\/a2`4]/b0a2^3`2`1d2^4^0e4e8f9g:c3d0_2^2`1h4f3g3f6g3f4c6c8d9f7f3d3b3d6iX3*8,5-<0? -@!0? 0?!.=!/; -=.>3H!$8C$;B&>C*J+GV3ET7IR0`Z*wk+kk0^[&?E$5>":>$;D(?D)>E'Cg9BQ=GY=Hd;C^?HU=E_>F[@H^F^=EfIeBFf?Hd@KdDMhCKiAJeBHWDNjBMjAKd.>_$( $(%)*)m:Z2^4Z3\2^4_4a.^2`2[4_0`/b4e5_1e5f4f;g5`3b2^/^6b1b3c6e8`4f7f4d6d5e9f6d4b2i4e8^Y2,8 *6/9:E0[ڤ&C-%9 #4! 3 #7$mKy|zyu{u}|}}{yxxutpvstrplqjmglknkiihbefabdŹC;x-q+k)|c'vl0d{9S,6G#/@3?!1= .? /="1>!.= 3=-?/=!.A5I#E[-Yx8i>yJzDg{4Z\(DL#=E'9F&8E*K,?J-EQ/I^4Ii=Id@W\8ul15HVnOUz=h9MMeq2QM%7@#7? 7<&:A(:?);F+F)>E)JCDBICKHIFJKNFKKHIOKJHJKKGJGLL!=**!)#+7?9?GUEW9F_;Eb@Fa=H^BG^@H[=G_>Fa?I]=Ee>EbBI^@Fb?Dh!8E ?U*Nh3Tx5h?wI{Dn|8Yc)IN&?J%;C'9C+7E+:F*;F-;I,=G,;J-=J,AK,BM0DV6I^:JW6Xa2|z2AQW]EUl0]v3|DLl?VV':C!28"4:!;<%$5=(9A(:D';C*?@*:A+7D-G]@H]>E\:Gd=E_>B[=Fa:Ga=G_>G]=C_=Fe=FcCF`AFc@Ld@LfCIjFIc?JSHJo@Km>I[-?]!("&!&))n<Y3\3Y1^3^2Z/]1]/^0_1`1^1\4`3`4e5h;c5c4`4_5_0`2a3b3`2c3c3b1b4b6b8_:d6c1b3g5`5\U2,6-4-:U/6G$0B 0@0=2<2<0< 1=0=/;"1A:L%E[+Ha0Kk0Vv7d>zEIp9Zd-JP#:E%4C(9F+H-=F-=H,=I/@I+=H.?K.CU0EY2GW2UX.mo.;USd=Xm/Un4q;MvF`^+CE4; 09"5>$8='8@(9E*?J0CV6@Q6IQ,[P)q]&gZ(FN%4A%6=&6@'8B&9B,7>EZ>G\=Hi=DTG\:G_9G^?D_;G`@E^?H_=Fb;F`?F` 0>0?4>!7C"BT%G[-G`/Fb0Ki0d|8|ELwFZk1KW*8E&4A&9C'9G/:G-;F/;G.BJ.@I-AH-AI.BN,BP1CP.HO)UW)lp/>KGk:]r3e9HJ^n1JN"5;184=%7>'9?)9E-=I.?U4=S9DR1SP*nW&k^*LR)4B#4=#2=$:B*ET?E[=Gh:ET=G_7G[=GW>Ga>G`=C_?Fd;D]Ge;D^>DY>C`@DhG`AIg?Me@J_?Ga>HbCI[EKpCHg=Ja*>Y"("%%'(*p>]4\/Y+^1_0]3^0a/^3_0\/^4^4_6_4`4d8c:`2a3^0c2`1`0d4b4a3b/_4d2d6c4d7f5c3`3g/e0[T6-4 ,6.:;E0Tԟ'F*"4!!0!0#4!nLzz{{tzwzxux|xtxrurztwnouspjklekgglhkfeige`gOûH<{/o+j+vn-xp3`DZSWROSRTSSMYHNGOEoF:^=5G%2C 2@/A2@ />0<0>1<"4?;J#BX'G].E`2H`.Nj/i9FSlE]c->Q.6B"5@"5C(H-=J+@K.?K,=N.?L+BM+DK'OY*hn3{8MPf@h5{@Mi}=OU#;< .8 29!6=&8?&:B*R1EV6EQ4NM*iV%l\(TW+7B%2?%7?%9@,;E,9C+:C*;D*8B,=C*>J,P\2\o@JwJ?a@S\6th.=Ui3?Y1+6(5,7&*VS#.8'2)-,5)7$-!) *#+$.7UD;A@BBFAEFHCEDHFJDGEKEJIMFNHHELGJFKEAG!7%* '$)8A?;CT>F\=CgHZ?FX9G\?G^:G`;Eg=F`=F_:E^=J`>E^?EaH\>Fd=Hd=F^@F^CFcAHe?LbALb1@3A 0>1<2>!3FCL$GZ*I^-E^)Kd0[p0t>N|Nat=Tb);I&3?$8@$;D&8E+:G+:J-:G-=I/@K/@J*=J-AG-@J+AI+BI.?I(CK&LR&el0{8FIsA{?LxD]_(BF"08 28 5=&9A'8C';G-CN3AU5CU5GM.cT&n\*YX*;D&3@'3>$6A(6B*<>)9A.;D+FBFCFCGBFAIDHEICGBHGKGDIHFMHHMLMHG?L"3#( ($*:>?=CYADT@H`G[;HZ=JY>H[;D`;I`=D];F^;F`8FZ;Ed=Dd6C[=GY@G]9Fa:GfAFZ>D^AHbCKdDK_=J`?KhCH\HIs@Hg?J]+;U"'"($*+(v?Z1Y0[2\.]1^2^1[4\0_/[4^0^._3`3]4b/_3_1_3`1]3\3^3`4a3`1^/e1_4b4^4c5a3a5`1f1e2\T3)5,5/7:C3Oמ$F*!32!/ $6!wB|tvtwuy|u|w|xurrksnqpqlmfhdkljmmahaga\ed]FB1t,n+n){q/j}3> 0>1>5@ 8I$AS(Da+D_0H].Og1d~5AVkG^g0FT)5E&6?&:C'9E)8G*I+@I-BJ+AJ-@K)@F)CJ&LP(\b+qz7IIKLJdp0IP$6<09 4=$7?):D+1= 1?0> 2>2=!7D!?K&H\*I]-G`0K_0Vo1n8H|Ofz@Q`(;N&6@$4B#3C(;G+=H-;I/BK.?M1DR2CO0:M0=K- /9"5:$8A(;C);E.?M/>S4?Z;@T4QQ.mY)^](>G(6>&5?&7@(;B/:>.9B+7C,@G-DM.Re5XyAEpFHZ;^_3{/C]Oa29H((4'2)7$)LT"07,5(/+6*5!*"'!)!)$,7^ F>@@D?E@GADCHEDEHDKEIDFEGIIDFHHJJEIDCZE_>C\H_>F[@E^>I^K`@G]?I_?He@F]DItAE_>Ga+:S $#'#((%v?X1X/Z/Y2[0]1]-Y0\0_1Z/\/_4[1^2_2b5`0_2^2]1^6`4Z6_1_1_2_1Y2^0c3_6b2_4a6c2c2_2SQ3*4/5-9?F2Sҟ#@)!5"20!#4"zKz{wxz}rsxt{uyqomuookokjiffjjhhbdde``ga`ad`]RJ8}/t,n+|l+kz3ZHTSUQRSVPOSI|KAgD6M*2A!4A1B1> 1B 1>1=/<1?6H"?R&D\,E`.F`.Lf/`z2{ASvH[j4HX*7C$2A#7D$8G+=H*8F.=K*DP4E]8Fe:=W4@O1?K/=I*BI-AJ-?G)DK,@J*@G+B,7B.` C;DAG@FFEEIBHBDBLAHHGDHEJGHELKGKIECE6J!1!(%'',;@><@X;B_Fa=Hb=Gh?J]=J]?IaAHbDE_EIp=Gc>HV)8P&%!'*)x=/W+Y-\4X0Z1\1Y2Z1\1^0]1[0\1`1`3^2\1[3\4]3\5]3`0^/^/_2^1^/`3\2b7^5`2a2_4a-TO4(5+4,7:D4Mԣ$B*"3.!/&4 xH|{xys{txsurpuourtnqklfpjmoohghfdgcfe``_]^[`[I>1u.q*~q-rx1fKWNVTTQXSOPIyG<];6I"4@"4B!4?"1@2> 1= 1=!3@1B9H"@W)F^.J`.Kc-Sk5l9GMiCVa-=Q*6A$4@$2E&;E*=G,AH/BQ0O_8OjAFhBA[8@O5=J.=H,>K+?K*>J,AM+AI+@H->J(;F)I.:K1@R6BZ:DV;KS0aY-h\-DR+6C'2C%3A)8B*:D-;C,:G/BM1Vf7ZvAGrJD\>a^3y2GVaMb/;R)*6(2*7 $,EW&.5(4*/*6+5 *(!( *'.EAHFJEHEFDIDIIBCIHEFIIMFID8K 1"(!((,:AB;DV;E[:H_=ESD[>E\:Df>F];EZHiAI_?J^>Jf@HaAG`BGi?E_>F\*8O!&!&#%+(pAV/W0U1W1[/[0]/Y2Z2]2]/\0\4_3[3\3_0\2\2_2^3Z4_1\2[4]2[0_0`1^1^/^5_7b5`3_1_3d2UR3*3+4*6;E0Qқ%C+$3! 4 0"4!rKw{tt~xyqxptroyrunqjpkmgjjjhhgdegei^a`caa_b]^hMC3x/r*q+yw1bAXQRPQURNPNEpB>U15D!2C 4A!2A 0=0?!0>!.A!2?!3C$:H"?W(B_.Cb/Kc/^t5|@LpL[l5IX&8C$2?%1A%6G(&7@#;?#KM$[i-s;}Eds>PQ$9>"39"6?'9G'9H,;K3>O4BY;AY:HR5XX-i[)LT-6D&3B%7@(9C,6A-7C-;H.IV2XoBPyJDhBSZ7nf29LZUnH^/:P,)1'3'5!%+:U/+4%1&+*4+4,)(++;`F:EAAAGAG@DDCCB@DDBCHGIHJHEEDIHEFEGD6G -((),7AE9DV;FY=E\;AU:EW;E`:C^9EXEf?HcBGbAJ] 0@1A 0@0@ 1E8L$AV)G]/Rh/f9DLgFYa,AQ)6B$7B#6B%L.DW2ThF+=B*6B&6?'1=":?"DK%_b*jm4go:YP(?E!1;"3?%9F);G/=K1=M5EU5BX?@Y5WU0]\(SW+3E'4>$7D*8E*9D-CV=DY8BW;Cc8D\8CZ=D`>DZ9EYJ^BH^F`?H\@Ho?F_?EW(9T &#&#')(wAW0W0V.X0Z/\1\0\3Y/X4[._0[/[1Z1^.Z/\/]1\2^5[2_3_0\.]/]/]/[/[2[0]2e5_1\1a.^7`1PO0+3)6-9>C3Oϛ(A*!520&5uIw|yyzqzvxsvrnosrnsjplkhkljghffefehcebff]^a_`XJ=/t/q+uu2j{9bKWVRWONGvD>[7G'G)"2A&6F+=J29N1=Q4AR7B];BY;MR0`Y-V[-8E&3C+6C+;I,>I->J/IX2Pj?RzGHgEMY;pf07LZbI7bEa-6M,&1'2&5")+@N)14#1(.*4+6)!+)!*#/;b'B;C@DCAAG@BDECFCC@GEGFCHGGEHIBHFIIDF3H .)!',+;AF;B[@HW9E^:EQ9D[;EXE[;C\:BY9DY7C_8AY8D_:Fb9E^;DZ8HcHe>IS>KmAG[=JZ(6Q %'!%&&p?X4X/X/V0Y0X1Z0Z4[2]1[0\0\1\0\0Z-\0[3\0Z/[2[0[.[2[5^0_1Z0\0]1^3_4c4`7_2_3^4`2JM.'3*1-8;B7LԚ&@)!1/1#5yLt}vrwnymz{lsnrqvlrijijglaidgeecfd``aaad`a]][dOB5w.p+}o/my6`MXRUPNKFm?>V-;J$5G!5E2@3A2?!4@"1=4@ 0H&@G*>F(;H,9A)9A&4A'7;$3<&4?#8? ?B$LF$ZM"UN"?D"2@$9E.9K2M2AT1IZ4Ni=Jn@H_>[`.s0?O|WCoC.aI]/0H**0'0$5(,K?CIEEGGJEFGFJDHHG3K!- '''+9=F:EZ=GS8Ec7AS9C]8Bb8BVF` 4>1>3@ 4> />,=0>!0E=O!Hd)l;}MrEam+OW)=H$8B&7F$5F,:H-AT0Nd8PpBGrGId@Yg6w}8BQ_Mz>gq-]\&HL%>H$:D$9B%7@)8@'8?%9>%8>(:@*E_$8S$ $!%('v@W.V-V,Z0X0Y.X0\3W/[2X0[/W.W2U2Y0\0X/Y2Z4]2Z.W2Z2Z0Y3Z1[/].\/]0_2]4^.\6^0^3[2HK0(2)3-79C4K˙#>(2/!,#0qMvztvxumutuvrngmkjjnlrgffliihc_febbd`^___\`]XI7}-t+u,sy4hDUSXRN{GC\1=S&>N#:H#7E#3B!0A 7@2@ /B!1?0A3>1?/A 4@3D#OqCEjDQd9go8=M\lUgEvJ{?my3[_'NQ"@G%l*B9F>ABAADAHCBAE@@DEEJBHDHAEDCDEDH?FF3|D -($'+.4BK;FX9EU7E`;CM7CV9F^H\?JbHk>Gd>Ea$6S!$ &!&&'tAT/W.V/X/X/^/X/[2X2\1Z/Z3Z.[0_/Y3Z4Z/^2Z.\1[3]2^1Z0X-X/X-Z/^/^3]0^4`2[4]0d2]0GM0*1-2,77B6M˕$@+!4 . 2#2wKwyusuvsrsusrklmmmpqkioiqekcfdc^da`dede``h^\_]UA2u*r+vt2j@\OUOOyFEd3BV&?M#6H5H!5@6B0B!3C 1>1@ 2> />1?-=0@ /B!/E 9U(Fd/Zw8jCs?iv2U^'EO'?L)"69&3='7?&EM1Jb6Kl@>]9AP1VS(eZ#XV&?L)7G+6J-;K2:J2@M2AS4@X9?W9GT3\X,d\,i],g_)h^)l`)pe,of*og,sm+|u+4H\_PF@BCABECE@JBHFDBEGGDGHGHFJGBGF-wC - &)(-8CN:BW9C[5Ca8AG:D]8B^:CS:CX9F^9CZ9Cb8B[8BV7BW?C^8Ca8@Y8BZ;E^8D_Ij:D\8F^%4T $' $#&zAS-W.T/Y.X.Z5[0V3Z/W3X/Y0U.Z0W/[-Z-Z0W0Z/Z/W1[4Z1W/Z/[-[/Z-Z/[0[/^3^3Y2W/^3\.IP1)0*1-55C9Mʙ#@'"33"1!5uKtwwstwvorqjmqmsnmhimojhiegbahe`hah_b^aef_]Y`fRH1|+s,xt2j|:[MYMPIJp=BZ*>P%;I%4D 5D3@"3A!4?3C!/=1>4?/> 0?0> 1?!,@"3D!:J$?Z)Lo3a>nFm;_j-PZ(IQ,>T/A\5Fe>Sg;rtBBHDCDD@E?H@CCECCAIBGGIDFHECCC-vE,('./5AO.>/=!0? /A 2C5G#;T(He1\~:sBr>fx3Wa+JY*HY1P]6dl77L`cT@f;6I)4C#7H#@Q(Ok1c?wC{>gp/US#EC!7="6D%;S5<[;?T;JP2j\),9cr2NV)7H-8H,8I,>@@@ED<@?HDGAEHCEFEEAFBGAIBDEDGEDGF.xC!,&(/-7?J9DM7DY:B^7AL7D_5CYDPBFmAEa8L̓(D*%;!%5#5'8rF{vxu~uootuxrnpnmnllljkhkikigdbcbdba_]^]a]]\\ZK?1u(}s)k|6cK[TSMPILs=A^+>Q$7H"6B2A 2A 2>!2?/@!1A0>/>1A.=0>1<,;0=/@ 2C%8Q&D`.Ty5gFsEm:`k-[^/_e6x{8BUk\M|K8U12G*1C#3@"4E Lv@Mw:Fh<;S26F%6F$:H#5K>X+,@%$0*2&3+.3L()2"+(1*2(6",*(!*&2=t*?D@AAEAFBFDG@E@DFCEEFDHIDDKEEHH*xB,''..8>L7EN5F_8C\6BM9DY9BW8B[;D[:EX8CU8D[9AY:CX;CY8@`:A\6B]7Ca6D[9DR:CZ>F]:G`:E^HlBCd:Ba'6O %%!%''~BW1S2W/\1Y0W2T1V/U-W+[-W.W0W.X.V.W-X-V/Y0W2X0Y/[/\.X/X/Y1X.[-Y1[1\1^1[2[.[3Z2DK1)4(1*7:@9Fʞ*F)%9!!7#4$9vSvzryrvytwuqtnwnsjojikgiieccdce^e\c^^`c^^^_\\`NE2v/v.vy6^EZPWPPMN{IFg5?S&8H!4B!3A4A0C 1? 2< 1?2>1?-> 1<-> /?.<1<".:0>!.A3M$@[,Rm4_=nGsCr~4qx4=S_VS;]97P+2G(1A"/<0>3A 6I#?W+To2kBvDm|7W_%HK">D'CD*WS-xk):JUyIZg1FQ*8G(5G*8F.:H/9I/=M2AU6?V6GR2_e,>BBDE?A@AA?ABCFBBDCDFEEEDFEECEHG*jC"* )'0.6AI9CS8E]:DW6BN7EY9CS<@[5Cc9CS9AZ6DV7EY4CY7A^8BW9BV:B[Gg9E\$2O$ &!&)(B Z1R/U3U0X3V/W-W,V/T/[+X.Y0V/V,W-W.W/Y1X/X0T.W0W1Y2V/W.X1X2\1W+[.\1]0[2\/\0Y/DM.(/'1*4;?9DǓ'B'%8!"4"3"8!tRyyustsvovsstmrovnhfkphehcdacgcYe]``ba^^]\_Y`gPI7x1t.xx5b=YQWPZRSKNuAEY-7K$4G"5B!3D!1B 3@3?/?/?!-A!1?2=1?.>,>,@-=+;3>".A 2J&:Q*Gc/Xy>pFIBL_l]GwE:T04O-2G)1C%0=1: 1=1?5@"Q2DR4DM0[Z,y5LpNEa29I#5E#7C$7C"7E"5C4C!8E"6F#5C!;BA>BC@BAD@DAEDABGDBEDDAGFCJ+cD +' (447@HF]=Gd;Ee;G[?BR;HSBHn /@1?/>0> />.</<-A )=.> .>!/>"2D%7M)C`-Ut:hGRXs[MN<_:6S24N,4E)1@ /:0>2=0=3=1?7G#AV-Uq4h@p@lp/nh'-BSzQtPQkCZ]*>J$3@'6@(9A*4D+9C,G[>GU=F]?Jf>G^>E];FX>GW?Iq;Fg:D_#1K!&!&!(''}BU2U4W0X/U1X.V.V-V,U/V.S/U0U.T/W.T.W.V-W-X-U-U-U-Y1Z1T4Z0Z/[1X2X0\3Y2Z/Z2X/\2>J.'.%0'46?9?Œ#>%3 //%6mSmzwrtrnrxropknpopokkggfgdbada`bb__\a\]]\WXXUUNF2w0}y0j;[MXPWQWOO}JInC:X-3G"6A#2C 0C 0?!2@ 0? 0B 2B.>/=/>1<->-<-= -<,>1>.<".@".B$3J&=X.Oo9^FdSXQ?g>:U25R06M-2C$2@"2<1>1>-81>-82:1B =N(Mi.d?yB9>MkQXCb?}ItG[c1BK'/?%2>'6A(5?*4@*:C,?N29K/EK*hf+ 3@0@2@ 4@#3A2E"0?%3A":G 3F`BS))>!'1)1"/200F((/ *%/!&4(3!* () )!&"+/!.*!-$.$+"1#,%/".#-!/!.!1/#4 6$ 9#.&)()"0%21'6C'7B*8H+6D.H1=K0@I4@P2@P6@N1BS1CZ3@W6AU8BZ8AU:CZ6CW9A\8FhId;Ha@H]7GY9?#9&!1..#5hLqzvjqooklkglfokmemikmfedcefcab\_\`]\][YZSWW[bNK6y0|v.n6cH^SURXRQII}GEi;8N(4E!2@ 3@ 2@0@!2A0A2C0? /@.=0@0;2= .<0:,<1A 0> .@"0@!0D%4I*7R*?^4Bg9:a:7U58V/5R15K*/C#1= /=/>0:1;.:+:/9+5*82G!C_,`8F~JkOQyDIb4Zp7xE|H]q8KM)7'4<*:D+M2=F,ZX(z6IiD;Q'/> 39-<1:1> 3@1?!1> 1>!8B!=D|a@X,)<%%.-4!,83-A.'1"*&1*3*5!+ (#)*!* .%.".#.!.%,%.$/%/&/#-".". -"-"-!,!)"-!, )' )!'#(*"((+") * -$!-&!,( -.0.!1/!5;$2=(5:*5>+9F)7E-8F-;I/=Q3@P2AP7AK:DO8FY:GZ6GU4DR5GV:E`>Gp;Fi9FZ$6G!( &#&-(zE#R4W1Z.X*T*T+Q,V*T)X.T*V,U,U-U+S-Y+W/V,X-W0U,Y1S.U2T0V-W-Y0X4Y2Z/Z0X0Y/W0Y.Y0>D,%.&/(14=:=$<$ 2-.#5 pOqtqrxrnlslkqhlgjihgigaecf_b_^]^]_\XYX]^ZYYW۽YrON>2y0gy8^G\PVUSNPMPIHp@=U-5I%5@ 5C!3A0? 2@ 1D"1D!3? -A.@/=-9!.= /; /=!,=,? ->$,A#-D%1C&/E$2H(2O,4L*2O05Q/7S14Q.1O)0E&-; -;0;/<1:19+6(5(2&0&53?=Y)Pu6X}GIp>4O1OR%5=4618"3<'7?-9B*8K.:M2?K,MM(wo,BrIAZ/-<*7,5/8,7,8-8.:.<4A#E0$/&0)34>:=:#0,,#2mOmkjqwnmiokmjjjgflhhgeecdd_`cfZ\X\XY\_[[YYWVͿYUJC~5{/q}4`EVRVOPRSQPNKzG?d<6N$5D#6C 3B3A3A 4D"5H!1E!-@0?0A!/=,>0</<.< /?.>/@"0A!0B#2@&1E'3I*4L,3P.5P-8V34P24J)/B#.(:<<3m1_q.Zg-Q_(FR&CM&8F!5C#2>"5>".< ,6(8'7'0%/ - ,!)!-!*!,!,)"(!)"*#*"+*!) * )!**&!'!) '!&(')(!)"+!*!+#) '()!*")$ )! '&!&'!(+728+;<-=?,GA.JE,VH-]J+cO.lP,yP-zO/{R+{Q*T.S,Q,S(T,T-T/V/T+R-T.R3S1U/S1U.U/X.W+X+T0W,Y-Z1tS17D-%."-(34<;="<"0-+!1dQmqtlqmmnkjglkfkfadcfbdac`^[a]\\X]^[[YWXVSXSѻT[MH:y~1vu3i/= .>.= ->-=-=!.> 0= .@ 1B!0?"/A"0E#1G(/I'3J*1N,5R-5T17V32K,3D&.< -:/:-8.9,6'6(3).#-#,%0&/'/&-(,)0+76B#K_*m=uCck4XRXINFNBMCLB IF"IF(HF(TK&k\'6IXy?3B"'2$/$.'/'/&/'/'1/8GCl?=Q+#9 '0-3",48*=#&1$+%1*1'2* ' )$,{e"ucSݲJ73|+g|*2W($0"+#,-0,4,4+6!(1 '0%-&/(-&/#0%-$,%-!*!,!,!+ *"*!*!(' )$*"+$-!+!* *"*"* ) *()"(( '!% )$%")$(*#+#+#'#*$,&,'0'1)3$.6'39'6:*><*C@,JD+SH,YK/\I-dO,nQ0nO.~Q/Q.R.P.Q1T-R.V/}S/R1T/V0X0rR.8B-#,$0&12:?:!6%/+*1lMsjmimmpjdd_kjngdgaddj`b^_b]a\^`\YZX[VY[YRRS˾UjPI:z5x}2e:ZKTOSOQQMNL~KHzFAg=8P*3C2D 0> 5E"8L#>V$4L!1D0?0> 0>!/<.</@!,? +@!1?"/>$/A!.B$0E$-F%1J(4L(2L+3Q.7V19Q40L0.A&09+6-8)8*6!*6'3#1#,!,"*'.%.$-%/%,%,'1*5;J!^p4uDvBy|.vt/pq.mm'ng'ng&nd$ga'k`$k^$rk"3C`A:M'&2%.%(&,#,%.#.%-,6M?`<@S,$7!%.-8 -88(?!#.#*&-)3'1* + +(,t+I$3$%-*2v+ÿ[LA:0q-^k)P]'GS&>J$:B!2<#27"/8 +3!)3!(.'2#. $-%/%-$+&.%/$/$,%.$-.#,#) ,"* (!'*!("% (#'!* )#("*#($'")!+!&"(#*!&!)#(!'(!'!)!*&("+#,".%0 &4!)7%-5)1<,8<.A?.FC,NF0TH1SK/gK/sQ0xQ1lO/4B/#-#-#/.;>:!4%!/-- 2kQmljknpkmhighkgfidffd^eabd]^___]U]WYYZXVVURTX~RK?t8q1j9\IVSXRXSRMLMI{IDnA0? .>"/>.=+=0;!0@,? 1?#/C%-D$1C'3F'2F+0J)3M)4O.0Q.2S/2H),?"+9+4'4)3*3$1%0#-!,#,!+#+%,(+$+#+!,%+&/07@U&\v5lGkEsD{AvB{@E{@}=;}=9CDlF;X1(3#*#,%-!+"+&,#.-4RD^67Q+&6'.*6*64(8"!-$)%.'4)3!)!("*)0,A%5#%/+1߹?΀޾^̳NB30r+^l'NW%FM#=H!4A!6="1;#16!.5!+4+1'/&0'.&,$+"+"+!(!(")"'!+",$*#(#+#'")!($' ' ' '(%&#(!((' '(( &&$)''(!)"'*") ("+".$0'1'3"!.!#+!-$-(4957-+) 0oMllklngehgjehdggkhbb[_ch]_]b^[Y\\WU][UUTUTTRӾWYJ@s6p6i6]JXOQQOPSQOMH|KHzHAd;8R'4E 3A!7H!=W!F_$5R#0C#-?!/= .:.="->*; ,=!/@!.@!/?".A"1@%1H$1K'/H'0I+.O)2M0.K./F),A'+8 &3&2'1%/%/%-#/!- )!( -$+%.&,#-%-%*%+".&/-<7N&B].Cc2Dh7Il;Mt9Qu8.m'Uj&OX#BO&:","*$*$*'*$.$,$-"-$,'*"*#,#(#+"+")!*!* *!)"'*#'!'&(%!& $ '"&!&( ')'!*"( ("'#(")#* '!*,$.$5&<#(C'*K*(X1,f<.M0X3`8nAMe|ԥ75"*))$/hVqgnimhneehafcfheac`d`^_`a_a]`Y_VV^RWYWYTVSQѾTfOGu5h7i7ZEUMPNRRNMSHOMIzLDpA9\45J$5D!8K!FX%Dd(9U$0B .@.?1? 0?/> 1=!/?-?!1?"2B%0A$0D$/D(2H&2F&1G01H*0G)-C++?('9!(3&1$,$-#-"-#*"+$+")#,#*%,&,#,%-$)$,"-$)$,$-"2%1'6'9+:)<$*?!-B$.E%2G(3K+7P+:R.8W-:Y12J-'5#&-!+%*$*$+"+#+&,,2TAW+8M*%6%/-7!*;5)3 !.%*#/,2&3*(!*(2/>'8$$2 08#P*$, *"++.|Z%vv-hh&U[#IT >H7A2=+7)2)/&,%-&,$,$-%+"-!+#*"(#)!'*(!) (!("'('(( ) )"*!(")!()!*) * *1"/%2#/#4%6$4%:$6%8%8%8"8%:%> $B#&I)&P0*\4-p=*I,V6`2p>zHYr̕癐96#+*)!0hPoillndjdddhjgggdadbc`\`d`^`X`YYZ_XYYXZWTUQVӻQmLIy9k5f7\AWPRNSUPLVGOKIHDvFAe:7U+3G#;N#A^#Ff(.>*=.@.>.=0=.@ ,A"0A$+C'/F$+G#-E%-B(*@'*>((9$&7 $1'/#.!-#,"+!)",$+!-!* ,"+%,#,$)#*$,#,"*#,"+#+#,#*!*$+&,",&*!-$,%/%.#/(-$2$1#.#+$,$+")#)!+ )#)",/2a>V0BU*%8"',)5 +=;*5!2')$/*4%6!('$,*10;%5%#2".;#Q*#0!*$,+3P朢މ琝ݑ۔܃ςi]QB5}.p(`n$T]FN7D3=,8,4).&/%,&,!)") )!+!+"("(!* )!(#( ) ( **)+*+ ,!./#/&1#3"/"1"1 0!/ 100!1 24"6"2"5"4!7"4#5"6#8!<"; $=!#B&&I)&N+%_4&j?(H)V+_/m7xJObʐ){2 *+("/]FaѼ]cggg]dcgdh_cg^d`ac_```]\^W\U\ZXZWUVTWQXMR̼SxME|$.A%+>!)?%'="*9"%6!%4$2&."- -%,$,"*+!*#)%*$*"*"+"+!+!)%+$+$*"*","+"+"+#*'($*&,$*!,#+#)#+#*$*!+")+#)#+$+")'(")!)%("(%*-5y@V+YKSRSOSJU>R@LQEJFvE@i>;V*:T%Hd$Ik(@]'3I!1?+=,?-B,> .> 1?"1?!,>!-@".C .:");!(9!)8!)3&5&1$.!0$,#*",!,#, +!+#,#*$*!*!'!+$)"+"*$-"+#*%*!*&+#*","*#*$-!(!*"+!)&-#,$)$*#+$*")*")"*#)'"(#)(#,#,16|?Q-;O*%8 (0+7)>:&5%/&+'/(4&3!, *$-(2.:)8($5!27$X,#/%,$-*3N撗呙韥盥헣루髢륡띜薣䊓|p_NE7q.0l*+!*!+#**/(/&0'/!."/&0%/%/!/,+,, .-!/"/-+--,,+++ .- ,-++.*+++**))'('&&$%%%$&( &!(#'!(&)%,,,./44:4@;EBQC_QdUsas!f!u%|,2399BDJOOMSTƷRQOJ¾TýO¾NSSF@l6_:\9VITLSKVKOAS8MDLGFzCGqCBc=A](Im'El'=c&2I"2?!1>/;,>-;.<+?.@.?,?",>+<&6 (6&6&.%/&1$/#-"-$,#+"+#+"+#*!)!+!."*!,!) ,!+"*!* ,!+#*!*"(!)%+$)%+&*!*"(&*"&&)%)!+ '!*")"*#(#(!'$)!* '!)"' &%*15?S+=M+#4#(/*5(9=#4!,$*#1'6*2#) +!,+528(5##3 1: [+$0#+&--2Qꎚꏙ铝秛諸令쟨謹異9!+! + *"*XZ&Yz@Qx@Us8Zj0Wg-Se'L\"EU"AK 7F/A.;'4%6$1!0#/"-.- ,*.+* ,*.-,*)*)(+))(('%$$"""##!$$ #!"##""&#"####!#"$"$"'&$&%'&))*)0-50;3B9J?PBWLeRkWu!`}$e&t(w/28]GEw4e6]6UAQLPNSFO?S6M?H}IH}IFrFEnBDg3Iq)Dt(Dc#2M!3B!0@/;,?-=.;+>-=.;"+: ):&7'3%1$.%/$-%-$-!-",#+ +!+#*#,#+#+"+!*"*!*!)!) (!*"*#(")!* )#,"*$)!)#*!*", *!)!(!*")!)")") )!''!(!("("'#'#'!($)")38=P(5L($3!'/+5'64+/!*')&0*3(4 ,")"+)543'5%)1 .;!Z(". "*%.,4P摞쌘无钢袤杠뭣즧ﮦ7!+ ' )!*Z`"[WU^X\\V]]V\W^WW^Y\ZXTXR[QVzJSw@Ps=Uh:Qd1Qc+MW'EM$ +>-> +=,<,:,;*:)9)7%1%2(0&0$.%.&-$,"+%+%+#*"*$)+"*#* (#* *!)#)) )#*"*%*!("*%*"*$+#)")((!' )!*)"(!('!'"*$' '%(!'"(") )"(#(!)")!*44;N':M)&2'0,6 (6<$1!*%+&/)4'3!)!*",,534%7%$3!8?$_(%1#.%,/5Q钓ꐖ嗜顢ꥤ眝餢죣멢骨ꥥ쨰ꪩ좥念훗; .!))!(U`#V_[YXSZZ\_VeWcWYX]X]X]X[U^V]Y`T\T[U_U]SZUXUZQTXVQQO{NT|ENrCKn=Id8Ga3KZ.BW%@M"=K 9B 2A(<%4!0-*'$$#"#"###!"!!!"  ! ! }LB=i1Z4W6WBSKPFM?T3S8K}AH}NGzGD}DJu:Iv/Hu*Ff&8R$3C .@ 1> /=/</: +=,8):(7'2$0$.!/&/#-"-!."-$,!)$)!*$*"',!)"*'",%)!*!& (") (&") ("*())"* '!( ("& ("'"*) (#'"(&")%) )"(!))) '!("(!'"*368N)7M)%4 (1(5 (::"1"+%+$/'3&2(!+"-.4ȳ83&6%'0!5="_+%/!#,%-.5U܏퓙矛蟡蘭쨝줡졢쥞8-*)!-Zb$[[Y]WVU]_`_bZ^W]T[U_V`Q\Y\Z_X[S\X^V_VbUYW]O\TZV`P^PYUVQZNZOXMXMTOTQVKSH{RJ|NFzHKuDEvJEqBDd@=1"!!"#$,#/!/()&&###!##         QD;v4d3\5W;WHQFS?a<>Y/Hd+Jq(Ks*Dj';Y%7G"0?"-?+=-?.;+8(6)5#1&/&0#.%-$.$,"-#,"+ +$-")"*"+*#)",")!* * *#( (") (!(")&#) '") ( &!) '"' '#(%#("&' ("''#( )( %''!&'&!% ) &#)59iǵ?N'8I'%1&0(5&9;$. &$+'.(4$2"* *"+.8!ͷB.$6)#3 7>"s'w%0", -14Vᐖꖣ睛眠矢鞛룘颜쬡쨛鞟멜잚隆죠맘뜗3*#!'' *Ua$[VW]Y\W[__[]Z_Z[^_\^\]VZW^__[[RZTY[\TaMXO^U\OYOYS~VMSNZQZNZKZOXK}WNVQ~WJ[NTO{ZH~UGPFxQGVKxRCF"")> ,E2+H2.E/-E3,E/*D1)G.,C0+E-*C.'E.)C,+D.)D/)B/'D0(?.'>)%>+&?(&?)%=%#:%$9!#3!#0#4!/!+)'&#"  !qOF6k/Z.U3U8SB[~AU0P~2Nu1Oe2NQ(IW#Mf#Mt,Ju+Gl*>]&4H0A,: .?->/<,9-8+7+5'/%/$.$/"0#,"+#-#,#,!*#+#*!*"*#*"*!) ($)!(#)"("*"+!)!( '!'#' ((( '( '$ '!'"( ' )!(!("'#((&"'(#&"'"'$("' ("()8:_ý=J,8N+$/'/%5'/B&1*&*&/'4%2(,"*.6!ѷ@-$5&'0:@$}'m#0".$,45Z攖蘝릟쟟㣚륝稝띡꩚맟먛쭡랕쥞劣쥝4!,!*(#*Xd(ZXT[WXX[W__b]e^]c`bg]gXb]]a]YdP_Y_\[W\Y]V]YbUZT^Q]S]PWQZM[N[RZMVKXM]K\IVI}XKWFUK~XK|VDxVBB# !*="+F/*H2*G1)G0)G.-F1(F1(A0'F/(D1+D3)E0)A2&C1)D/'F-&B1)E/&A/)E.'A/$B-&>0%A/%>-$>-&<+&@*%>-!@-#>'&@)#<&"<(#8)$9$#6%$7""3$!2 2$../L@8j4[.Z1U1X}5V~;T-T|.Ou,Xc&]U![\#Tj)Iv(Lr+Gm'AZ&5H#1@1>1;+9*9/;2?-A'5%3"-%0#/%-%-"+",$,#,"+#,%+"( '$+"+!) *$*#."(#+%)$.%.#*"+"( ("& &'"'#% %(!'& (!''!'!)!(% )"'(*'' &#'(&'#(::UAJ$9J)&/(0!3&27',&$+'.'3$0"*",#++7ػI.u(4%&0!?A#)g$0!,#,25`䋘ᘜ➛蠜㦝䩝쥟읜盕䣡蠟栟蜘蠠렡蟚멚멜祚똒럖皎Ꚑꘔꢙ靓ꖐ훗4) *("(Vb&WXWZZVUXY[Wc\b\`]]bb]e[_Yc\]^b[`W\\`XbUbY`W\UcRZWaPWLZS[R\Q[OZPYJXPWQYNSKYH~XPRL{QFTExO>A"  )?-I.*F,+C4(C2)F0,D5)F.-E/)H1*E0*B1'C-(D1*D,+B1&C/(?/(B0'>1(G/'B/%?.$?/$@-'>+'@0'>-%@*";+$>,&A1$>,%;+!=-"=+"<,#/;4G6J!-I (6(1%/%0".#-#-#/$,#+ ($.#*#+!)"+!)$-"*$+"*#+&/+1+7(2$.#,!)' )'"( )"("'&!) )#( (#& ' ) '!('"(#' (!'#%&)"' '&!&!)B;Q;K(9L(%/(0&3%4;%0&&,&-'2 .!+,!+/7 ֿO,v%8%(3"BE"(h .#,#-86`搓㚛顙堙㡠ޥ⟗隖螜䣝褛闕螖馠ꜝ렛죕⧟褚윒뢓욓왒자욛흙맗띚뛑钐흑3!,!()*Vc&Y^U[T\VXWY^g\]X\Y``i^dY_VaZbZhXaZ^WdY^VeZ^V_R`W\V[R[R]R\UXQYRYWZP\T[MVIVM[LXMTMYHWDyUBH&"$""-=-G1,I1,H.,F1*H.*F3,H0,G2*H3-G/(E/.D0)C1)F/+B.*D,)D0*B2*A0)@-'B.'A,(C1&A0&B+'A,'?/$>-'=/&>,(?,&>.$>*$>+&>.%>*#?,%=*#:+%=*#;,$8*!:+ 9(dD>}/f-].T,R-X{-T.S}+Rz(Tt,Za$Xb"Qq(Is(Is+Mn'Nd(UY#XM!VFJH JDAG =Q 8V!3L *5)2&+(/%.%-&0!+$-&.!)!,!)$+#,#, +",#-%,(3-71A1B,;&6!* (*!) *)!'"'!)#'#'( )"'")#'")"()&#&!')(!(#& &!'!'"%!&"&!&?=I:I&7I& 1'1"2'2;!-%%+&1(21) ,",09Q0n$3"$2CC"'a#0!,%.97b▖ᛚᥖ㝛顕䜝㜗雖埞裗皔裒枝흘ꘙ者骢雛Ꙓ棚렜韙Ꝑ蟏왏镇잇۞롗ꤛ뢘靉떏蝔2, *'(Qb&SZV\UXP[U\^aZ_\`X`]\YaV[X^XbYfVcV_WaWdS]ZZT_S^WXV`SZSXU`R^R\R]T^SZRXK\MWRWMTHTNUKYFyT @@'$$#$-@"/H0-K1(G/,H1,K/-F2-G2.E0,F/-G1'D2*G.,D0-F/*D/*G1&G4)D0)B/)C.)?.'A.$B.&B.$A/'@,%B.'B.&B0'C+%@/&A+'=+$@-(A*&A)%=+"?,&:,#=+#;)#?(";, 8(}HB3lz+_/X+U.R~.S.Q~,Tz+Pr+Vk%Ui%Kp)Js+Jr)Kr)Qi(ZX"aQ bN ]L"ROIU Ba"?\#AF =79301+0*.*,$-%+#*#*$+",%+"*",#*$.'0+9/@4I7I-K,A$1-!) ((&+"(!*"(!,"( *"("' ' ("' '!'$&'")!' '!&& ' ''' $!' '#&@=H-$>,$>*%@-%>-$=+$9.#=-&=-&>,!=*%<,|MA7q{,_}+W*X+U+T)N|*T|(Nw*So(Mo%Ms*Ju)Kp(Np(Oh&[\#eQdN\Q!VV!Jd$Ed&JY$PF!UAN<J8E8>55400*2+.*.%*&+%,$-)/.51:4D6O9T5V3J(>!-")!*!(!*'$) ($)#)") (!(%)#("'#)"'(!))#(("&!& &"%'!& )!(!$!%$'!&K@E:J)7I&!,(5'0!%-:(-&$-)-&1#-+ +!+.:[,bp%4%'2"DI#'Yu%/!#/!-;: jےޛ㚗䢕ߛ♓⑎╗㖏䕌盒堖蘒斗좟ꨗ쟔ꜜ䣖㡟瘗띓堛硐盆꜎Ꝑ嚖왒㣛噎蘌햎薉듐--') )Tb(UWWZRXSVUY\\XaX`YZ`[W^W]V^\]WbU][_Y^UbSbT`U^P_RWZ[R]RWQVN^SZP]OWJXOZP]JVOSLZKQN{SEUB~O=?%$!"'-?!/E.*I.,F6)F/,L/.G3+J0-I0+D3-I0*F0)G/)G/(D1,B0*E1(D-&G/&A-(@/)A+&A-'B.(C-'C-'C,&A,(>,%?-$@.'>+'@.%A,'?)&>*(?,&?.$>-(>*'@+#?-&>)%=*$<*vsZ@;u}-cv.\0R}/N~-T~.P,O*Sz)Ps)Ls&Ir)Iy)Ku(Hq'Ol)X^&_T ^T TX"Gc%Bi#Kc'NW ]G[C]BW>V@Q:P<K<D7<6>0./)1-2.93B6K9hٜޞޖߗܝ㜖ᒒ䕑ޑߒ㎏䛋ݘ蔖晖蛓띚뛑⢔ࠚ砗㤚堒䛒롎욓益햊皎쟛睛蕗뜊杍앋퓇-)(( )Oe%NWT~UQWSWT^X]\_Z`Y[Y`\bU`Z_XbZaV^X^YaRaT]UZWbTaTWRYT]OYSZQ`T\O[NWJXPUO\KTPVH{XM~UL}UE~TK|M>E&"%%%*B -H0-E1+I.,H-+G./D1*H+-G/,E/+E2+C1)J0,C1+D/(E/)D0(B.)D-(C/(C/(B2'A-&B0)A,%@,%>.(@,$>0'A+&@+$?,%?-%B,&?0$@*#>,'?,&A*%>-%=,%>-$=)&;+$>*negdD=0jt*X|+V~-T}.O~+U)P,Qy*Hu&Fs(Is'Gt*Gs(Hp)Oj%W^%^R VY!L`!Eg#Hh%Gd"QY#^I^F^B]A[@[@ZAXAV>O;I=@@7E7K9P=V;[=]!:X"3L &=&.%,&+#*#(!)"(!(%)!("("("*"*"+ +("'#(' &!&!&'!&( '!%"$ &!& &$& &&'"%'QF?\lؚۜޑᜒߟޔ␏ᑆ䙐嘍┌㕕圖嗏囋䗑垖䝖ទ韒饙朐桌䙒ᘊ완搊藔蟗⟓㝍ޗឍ╈唉.)(((Nb&SQQ~ZTWSSPZX^\aU[V_Z\XZXaUWU^W]W]UYS\VaS]UZQYN]R]T[N\LYNXO[M[QXLZNTLTNYJTLySI~OI~RH|QITG{O>=$$#!#+? 0E1-G3,F/,H2,F1,C1)F0*F.)E.)H1)F0+F.)C0&F-(E/)D-+B0(D-)B.(B.)D,&B.&A-)A0%>-$@.$?+%=,#>,)?.$=,#@,%>, >,(>+%<%'?+!<+$<)$>+$:,$<+&?)%:,}_Q^hH>3mn,[x+Y|(R}*S}-N},O+M},Kx(Js*Hq'It*Jr+Jp-Kj+S`$TZ M`$Dh$Ei'Hh#Gb%RU!YJ_F_C_AaE\C[@XBQFKJHM?S=Y <_>_!D_!D\#FUDH:=72-.),++&+$*$+!)$* )#)%*$( ("&"*#&")"(!)$'"$!'!) '!&!&&$'&&!&& %&'#%( )^W;r9I&2H(#+'2"2(,:#.$#,&1'2!,' ),5;s,OV'2#%1 RS%ؿ&Qa"- -.@;p݌֒ؑޕٖܖ反ޖݒڒ䔏ޖޓ蓉⚎⒒蛋虓䠑㚏响杕ߜ䞐暐朎䚄搈睋⟒嗑曋✎☇撂ݐ-*&&)Jc&OXTVOYOXO\Y^\`Y_Y[X`][W`S[X]XZW^S^X]V`M_R[UZOaOYRXO]KWSWSZIXNXSYITIWJ|XHWM}VHzVG}RLxQH|TB|R<=%$""$),$?+&>+";,"?(#@*%>,$=*#=+&?+"=+%=,$>, ;+';+fLIVjP?6rs'`s)X|+S,O,R|,O~,Qx-Ju+Ip)Dm+Fr(Hq(Gn(Jo)Ji%J`#Fj)Dj#Gi&Dg$Ic"ST ]H_D`D^DXDUENMJQDRDY ;^!?b#?b"Aa"Cb!JX"LQ XLX=U9P7H8D3>22/00.-),*)%*%)%*%,&(#*"+$'#)"(!)"(#'"&"&#&( &&%&$!% %!&'&'#&"%cM5oJ8M#-F'$+'4!0$.8#+%#,%1'1!,*!*!,5?!(MT"6"$2RS%'Q]#.!.#,:>uܓܒٕݚܠᎋ܎ݓۊ⒌ᑏۍ⒌Ⓥ㙋阐꜉ޝ族똋㝔埕曍ᘖ䟒嘋蕅晏蘎敌畏ߝ嘅虀撃ߑ*+)&'K_+VSRYPVRWOVX[Y_Y^XZZ^WcT`X_U[YYWaP\T\TYN`Q]S\S]NVQZL_OXMZP[NYLYM[JULUH|\GQISI|QH~VJuVC~VAzP-&?.'B2&@,',%?,$B)$=)(>+%?,&=-$=+"=*#<,#;& ='nSFFQb`@>|v,fn'Yy(Q{*T|-R)Ly+N{*Pv*Ft'Gp(Er'Nr+Ho(Gq'In*Fi&Am%Dj(Cg%Cc"H\"QP ]D\EWGQJIPIRBV=Z>`!?`!?`#?a#Ba#HZ!NS XNXE[@\;\>^<W;W;W=R8N7F3C1;.5/2.-,*)')',')#($($'"& ' %#&#!% & % %(&&%!$'!%"%& )$&j_:dA7K&3E% +'1$/%)4*##,&.)0-*#(,5?"(LM#1!$0SX%λ׸&NY".!-$.;@ qԖێ؍ܘ֒ڏؒ܉׍ݐޑ䒇ߏᐎ䖌嗈║ޚۜᝒޔ㗏㟑♊╏皆蓆ᔇ뙉ᗍߙܙ┅ᒂᕉ*+'&*Nh(PTS~SP~YQ\RYT[[]T^[dYVUcW`W_XZT\P_RZSZT]OXNXSWOYMXUXRYLVPWNXJTMRN~XLYKVI}SGVI~VH|TG~OHyNEsQDxL=9&$""$*?!-F+-G0*D-+E2'E/+D2(D.(B,*E0*F/+F0)E0,B1)C/&D+)C.&C+'B0)B0(B/&A-%B/(=,*@-#A*%?-$@)%?,$?-&>,%A,$<,%>+$=+#=-%>+#<)%=)&>*#>*$?+">( <($<(x]IAAL^jE>}0lp&]o(Qu+Mx+Oy+Qx'Mz+Mt(Ip&Ir&In'Ho(Es(Hr*Fm)Fm'Gl'Ah'Bh!Cf"H_$RSRLMPFSBW!=[ =[ @a";_"A^!>`#=a#E_!H\ RRYJ^AZ=_?^?\@[>_@`;_>];\9V;V9R9R9J3I5=2708,0-,,')'*'+$(%(!*#'!& &"&"'"& $&&!'% &%#%& (n\<\A9H%,D("*(00&):")'%-%.&2,( )#+8>)JE#3"&0!XW$½߹$MT!. !,#*=>r͓׋דב׋ڈ׊ݒَڇܒ؏܅ޔݐ呇嘎ޑޔߔ◒ٔޚݝ♗坊ޔ᐀㘌ᒏ㓊ߞ♋ޖ曇ߍ*}((% 'Kc)OyOQzXQ|VQYOSSZYXW]U\SZW\W\ZZR^VYTaQXP\S[L]SYPSRYM[PSNXN[NWOWJTKXNSHQK}QL}SE}PJxQJyUG|PF|QDyTBxM79##""%)@".F0+D.)H.+F0+I--E0(C/(D.*E-)D-(@0(D-*A/$B.(C.*C/%C.(A+'?,)A1(>+%?.(@-%>)#B/&>,'>*&<+$>(&?,&@,(@/$<+#>,$?+&?)&>("=-(?*#<)"<*&9+#<&";)nPD}E}?EUlL@9uo(_n(Su,S}+M}*O|,Kz,Kx*Er'Ho'Ir(Fp*Jp'Eq)Dr(Bi&Dl%Bi'@e%Cd$E^$HWEZ?[ @_"A]">d#;a">c#@`$?`"A^ F]"LTOOZBZ?bA\>]@b>]@_@`@_=a@_?`?\?[>Z;Z>\=[;V:U6T8J4,H3>2;,2-/,,)'(&)''$'"'#& &&$&"%!& & %%' $% 'iY!4^16H&0B(!*)2!,'&6*$",%0%1)(( -3B!'FE"2"&0_X%ҺֻƼҹب$KN#-",!-??rЏӇЈԏڈڈؒՍڒڋ؏Պ܌ړݑ唆蔋ߔݒޏ♑ڛڔݝߕޜ㞎ߖᑌᔈ䘏☈ߕᛅᚃ}ލ(})&&&Kc+L{MP{QS~TNXMXRYZ^V_Q\V[X^V^RYTYU_W_KVR[VZNYRTQXN[LWIWN[HWMRN|SLSLXLXJUITKyTI|VI|PAyXE{SLzPGxS?tN;8%##!%(A")H/(D0*E0,D2(E1(E/+E1)E/'E.*F0'B+'C.(C,(D+)@/&E,&C,%C-&>*'A-%B*&@1$?.'?,%>-%:,$>*#=-'<*$@+#<)%>+#=+!=+%=*#;)";)#>*#<+#A(%<*#:*#=*#=(rXC~<~AAASeRF@pr,hm&]s)Ux)Pv*Pz*Ju)Is'Ht*Is%Fp*Ir*Go&Go)Em*Dm$Cl&Be$@e$Ad$Ad">a!>c$>`!Ab"b >_!;`$?_#B_%IX#PR]E_?\>b>^=]?_=_A[>`@`=`=]=a>`=[>^=b:`?_@]=a<b:^<\<Y9U9T8Q5I5F1;0:+2+,)+*%'&&#&"&"#!&"#&%&!&%"&|^7W28H%+;$!,'2". %)5!'$#-'.'2)( '#-;A$CC!0 &1bZ(ź¼ʹٸнױ&NO"/+!0EA{rʑ׈ӍӋՎ֊Ԑ҉փڎ֒ލݖݍߖܓُۓܙݛ㗊◉ێ~瑈ߗޓޔؘ┄ۏw֏'z(&& 'Ja%MzOOvRP}UMyXKYUZX]U^QYN[X^VYUYT\W[RZP[R`U[QZNUM[R^NRLWOZK}XLXP}WJVJ|VHWE}SJSH|WE|RGRIvPH{QDvODwRAsN6:$## $)> *F)*D2+G1,E-*F0)D-*F.*E,)C1&D.'A.*C/'A/'E-*D.'B+'F,(=,(B-%A-'B*&@,&A+(?+$=*&=-$<.'=-&C(#>,%<+'>*%>+$;,#<*#>+%=)%=( <($>($;+"<'"9)"<({eEy@z=~;|<=K[`B>{q*dh#Yn(Ty)Nu+Kz)Lw+Ku(Hq*In'Gm)Ep&Dn&Eo%En%Ei(@g%?g&Cb%Cd#?f#>a$9b#?d!B`"?`#?b">_#=]!D[#JU!QMZCX@^?\?_<\>`@^@\@^?a?c?_=`>`<a@^?`<_<_;d?b=c;^<\=a>a>]<`;Z:Y9X8Z6T6M4I1B2>-5*0)*'(&$& %$%!##&%&!'db4T1tQ57$%!"$*>$)D-*C1)D0*C/)C2,E/)B+(D-+C,(F*(C.(C)*C-&A-(C,)A-%C'$@.%A.&A,%@,$A-%A*%>)$=(%>*%<'$=*%=,#<+&=,$=.#=*">-$@*#<&!<)&<)"=* ;)":(%;%#;+"<*lP}C|?vf";c#?b"?c#>`"@^"HX#NQYG\>]?]=]?[<[=[@`>`=a?]>`Aa<_<c=^?]>a=a<a>a>b=_=d?h=_=]<c?a=d=a=_<b?^=^;Z:Z:[7T4M4Q1D.?0<-6*-*)))&%$$# &e]9T*;N%)A$&*%2*$$&;+%!+&1$2'%&!,;F#&?7$/!)1mf$÷̴̺Ƿ̲οԲ̿ýݾݿ؍&BK!+ ,"-AEpΈτψˉӈԈԈӎՎՎՍՒ؏ََݍڊ֐}ۉz؎׎ߎڑݘڙכۙړⓅ㘅ޕ▇┍ٙۗڎٕzړ%v)%&"(Hd+NwQNyNOzUEyTHTRSUVU[QVQ[UXT\S[P\QWSXO]R]MWOXLXNTL~YLZLWN}SJSIVM}XG~QK~TJ}WIyWF|QGzRF{REzPGxQDwLFvOBwO=rL65$##!$'>#+E+,A.&D0)D/*G.*D,(@/*F,*@0(A-*C,'C0)C,&?.'C*(A/'B,&B.'@)&>-'B-'=-$A*%?+%?+"=*%A+!<,$=()=)"?+$=($<*#=*":*$;*#>'"9(%;, :*":&#=)#;(";&vVCyDzBx=w;>};?SfO=0qe$bf$Xo)Oz&Mv(Mt)Io*Hp'Go(Eq'Hn'Dl(Gn&Bm%Ci$>f%Ac$`"C]#MU"RN XCY>Y>^@U>\Ab>`@^>]>c>]@_>`>_>_=[>^<`:b=b=a<_:a>`=^?`>b?_;]=]=]<b>]>\;b<a8_<`;[9_;Z9X6\8S5R5S1I/E1@*7-2)1+{`7S+6L'+=#"*)4,$*%7 )& +&.&0(&()>B $=4#.#.tf(ҰŽɲϸȳѹ׾ɾֿУ܍#?D!, ,$+GB}m|̆~͈̃|φщчЅЊՍЄՇ֌֑ЊێُՓ؍ۍٍ֒ؤڑܗۘכԕژޓڎ|ܕٔԔ~Ӎ}ڍ'r)&''Fd0JzPO~NLzPM|TMzVR[UYUZTXOXSYSYP[QWPYP\OSLVNYNWP]MUQ|YJ}TLQO~VK~WISJ{UG|UCzSHxQFwREPFxVHtMDwNJwPEvOB|ODvR@tL47$"  &)A"(G,)E/&F+(E.,E,'C/&B.%D,(A0'C,*C.)B+'@,%A,+@+'@.&A0%?+%?,'?+'=-#>.$B+#=)">+$=+$>)'=)">'#:)%<)%;+#?/";)%=%!:)!=*$;*#: )!;+$:)!;'"<%d|D{@{Ax=x?w:v>x=[?Y@X=^@]>]=`?^@b=^>Z:^=^=\<[;a>a<^?^;b@^A^>]<^>_<a=`@]<];a:];a<a;`<`;^;X:^9^;c;\9^9\8X8\7U3Q2Q5K1~i4M':H#)?%#+)4*$)'8 ($"-(/$1%%%(?Bz$:2!.$/vj'Ĭ¸ȼԵŸҷʺ˾νֶȿҶ۸۽ԲΜ @A+!,!+@C{qz΃~Ȋ|ɉ΃҉щҋՈ·ԈЋՊЎڍٍ͆֒Ԉ|Ԓ{щԋzՇӓؒؓטՒڐڑړ،ጅڎ׎ܐ֒{։ԍ&vz(&( 'Gb+I{MJ{PM{SN{WGzQO~SO[W[TZLWNUQXPWO[L~XOSMZMUNVP~VLTJ~YKSJWG}WL{WH|YD~QHwWGxWF~RJzTDxRI}TJvVHvQCyMGtRRsPEvP>tN$(E-(C,(E/'D-%E-&B.(A/%B-'D-'B-)@.(?,&@*'A-%@*(A,'B,&=+#A+&?+$A+%;/$?,#=)$=,#<)!?(#<*&<(#<*$<*#;*#;*#?)$;' =&#<*!<)%8(";)#:(!7(!9)";&oS~@{>t>{>w;s?p>z=|;HZf@9x,rg$^f'Pq)Rt'Kv)Jq)Jn&Gn%Dp'Do'Cn'Bj(Bi#@d"Cg"Af#Ac$?h"?a#?b!^>[@\?^<^>W>a>d<a<a:`=\=\?`<d=]=]:`=b=c=Y;^=_;`?_;`;^8c:_8[8]9b:]9^<\>^:_;c8[9`9V9\9zo9M&7K&&;#%,'4)&*!2 )#"+#0%1$%%*ECp&;1%.!$0vk)˲ų͵ǹϻиٴ˽ȾҲܼt%#(G()D.)D1&C/(D-(C,(E.'C,&?-&C0(A+'@,'D-%A0&A,%?/'@,&>.&?,"@.'@*$<*$>,#:("=+$>+$=+$='"=,$;'#<)$:,$<)!;&#>("<+#=)#;(%;' 8(%8( ;&":&!:'w[CvBs>{=r=td#<`#Bc%b#=b#?]!;^?\ >Z!@Y@T ASAT AODNFMDNLLMJLGLERFYFRBR@_?Z@[?X>Y=[;`;[=_=Y>[=]=_:a=_>c8_=`<a;_;[;^9b<^:a:\9_;^9_:_9_:^:^;]8\:\9`:_;w!;O(2J%%8 #*'1(%)&1'$#*$0%2''()KEd!5, 0 $0xr*µƳպ̱ļǸһǻƽӷϹ׽ʾ׻ѿډ#;B-+#+GDxl{}yȈȃ̅~ωˇ~ΆӉǎΉˉˋόωӐՕӉ|ԕА҆v͌{чzԇؑՎԑԌԒӚѓ}Ր~ےڌԇٕԏϐw׃%my*&($*Ff-GxRJ{RKuSOzOL{RNWRVR[R[NVOXMWMYOZJSOXKYL~RSTMYLWL}TM{QE|TISLTJzRDyUExQJvRE{SGuQCuVDwQBtOBrQBuLAuMArKAtLCpM8lI5/" %()%=*$@,$=*#:)%;+#<+!>)$9)"<*$=+ <) 9(#;,#<)!:'$<)%:)";&$8(#=%";$ 8&bKv>u=z@s8y=sc$_"Aa#=e!@_"=_#>_#<`=^&;^!=\!>^ ;\"@Z!9\;\ AY#>U=XBWDRAU!BSDPFRCNHKHILGKFPBPAO=RAY<R?Z<\>^=Z=]<^;a=_9_=_>`;]<Z<];^8_9a9a9[8[9b8`9]:^:`6\7[9\8_9t|#6J%7B$"7",'2(&*$2(!"+#-"/%#$'QG!b!5-/"0{t)Ū̶өǪѬ¹ôŴ޳̾¼̽ͻѾ9<,*"*HH{nyz|}~ņɀȃɊ΅ʎɈԃΎ̌~҇|ωϑՉԍύ~Ѝ҇~ͅ}͌~҆{׋~юӏ֓ӑЎ|ؑ|э׋x؆}؈}Ҏא}ЎzЊ#kv)%%#(If.GwOJuMKyOHwTIzWKzPLSNZPWKWMVQVOVKTKTNYNXETJTJ{VJUFVH|WE{XI{RL{QK|TDzVKzNCvVBvQDxQGuLCzOEtMDrNBtI@sHBrOApKBlK:oH10""  #)>#&C,(@-&?,'@/&A.'C+(?/&B,(A-&B,&@.%A+'A)%=+&A($=,"?*%A+#A,%;+&=)";+&?(%:-!<,$<+";(#;*#<*#;( <'"9)!8(#7&$<(#7(!;$!:+"5'!>'8) ;'!9(6(SyBw?w?v9t9t9q:u;u9q\#=` ?]<_#<]!<`#?]#<] =] =` >\%<^!?\<]"?Z ;\!>Y=Z >Y>V @U"DU@R@OBRDMBODKHLHHIHJEPDTCR@T?X?Z>[<Y=Z=\=Z<W=_9\;_9]8]9\:a<^<^9Z9Z9_;\9^;\:pl!3H!6J$';!%+,3)((#3($#*%0".#$$'UOX!4)+ $-}|*®DZөѸаļǻδЭȻķ׹Զ˾Ⱦٽֿڿſ}"99 +","+PIuowǃÂĂx̅}Ŋˊ{Ƀ|ˏɋ΅Ўˑ̌ʌыԈ΋Б΋yψzь{ȋzӂ{ԍx؈ЅԏՑђГҐ}ԉ|ڄ|׍Ւב~Ίʌ#jv(''!)Gd2HvPLxMKvRKvSJwSHRPXRZOWMWL~VPUSUKWJRL{VL~WLYHUM~TI}TD~RIyTL}QDQJxQEsPKwVGyQEtQFwPFvPCuPBuTCrPAqN?sJArN@qM=oH>jL8mN12#!! %)A!(B))D,'@/'B+&@-'A.'@.&@)'B/(@+%B,%@-%A+%?/%>,&<+%>*$<)'>,%;)$<)":+&=*#<*!=)$<)<*$:,#=(";)$;'$9+<(!9(":'%8(%9'8)"<+#9(!7&:("9'"8$vGz@t>t=r9u;s9o?p9o;o9p8v9FYbB6}2oa%eZ ^c&_a%Y^$Xa#U`#Ua$M_#Sc#K`&K["L\&H^"F\#C\#B]$D\!G[#C]>\!C]#>_"B^!B]"C]%A_ [#B[#@\!?] >\ B_#=]=]!?]@Z!B\>Z?Y=^ >[ ;X@V!?V=W>U rLAnK@rI@rJ6jI2,!" #$'>$)C+'D,'C,(A.&@-)A*'@*$@)'@-(?.)@(&?-%?*%A-&?(%=.%?($?*"?)&;,$<+#=/%:)#<'$=(#;(!?)";(#;)#:+!>)":+"<)!9'!7*#7*";("9($:'!;(!<% 7)"6# 6(y@v3"JE#WX+to0=O`B1&)$0&ĨĪóͩӭīùϺȳºǾпظձ̺ļϿܿv44+, )MHumy}yȆ}ƃć|Ƅŋ}ʌ|ˈ|ˊɋˆ{ʅwˎɋ~ɉɊ}Ɋ~ȇyʆ|̈xɅzʉwΈ~̓z͎}Ϗ͎zҒόϑzԈyՈ~тzЄ}Ήʈ{ȇfp(%&#*Dc1JrMFxKGuNItNJqTO}PKTKPJ}QKWJ}UP{SOXKUKWKUG{UIUE{OH{SHxQH|RDyMFzRD{TFwPGvPBuUEzMCrPAuNFuMFrVAvM@tM*&B.%?,'@.$A+&>.&@.&@-%?/%?*&=+%>+$>*"=($<,$>'&=+#<(%=%$9*!<)&='#:($;*=)";$ ;*#9'$:(";&!;'!:(%8' 8("8&!9'7(#5%"9&7&!8("7(!6(x;ysKCpN>qIArI/&?,$?,%>,%>**B,&A*(<+%@*%>+!A)&>*%E,$>,%>($=+#;($;'"<)";%"=)&=)#=)"<'$:&#:& <'#9&!;("<&"<'!7&!8*7)#9%"9(7'!8# 7(#4%r>t=o;t>q=qZ>WAYCWA]@]BT@[AZA[>W?Z>YBUAX@\?Z>WBYAZ@W>T@Z@ZC[BZ=W@\@XAW@X>ZBZA\@W?Y?]?V@Z@W<W<W<X=[:V:Y>V:[9^8_;l{(6F 7F$"4 (.'1$$( 0$$"-$,!-""!"$$%#&''(*)'&)*,/ /-!"0#0%+%'''D $fc,}{7H\oα䪔ǫ§ǵȶгƺ˾ӸͻвŽλոֻc50+(!*PKwty~~zȂzĆz{tĈrÇ|dž~čÇ{džzɎ}ʍ{̎~ʁɈ{̉~ˋyʃ{ǃwʋyDžẁsτzˆsς|։ύƈwʎtԋ|҈tυvΆ|ʃzƄuă"`j(&$",Ib2GrIBwJDrMHrNEuPN{VHNLOJUL}SIPLzQLzRH{TH}VKzSGyRFyPEyUIvLEySAyPIuQDvQAxPAvMFsQCxNBwKCvQBtK@rNAqN?oO@oJ@pJ?oH@oG?gJ=oE>mF7gK/-$!"!$&?$%D.&B,#?.'@-(A.'B*&>,&B+&?,$=)#A*"?)$>+"?+$<+#=*$>(%;+%=(#=("<)";*!;(%;'#;+!:'%;("9($<%#;):)&;(!;&"9&"8&"8'!7'6$7&:'!8(6&5%7$p;p9n9m9rYBY>U@\CX@Y?XAZAU?[?[?[?Y>Z=Y>[>Y>]>Y>X?^<]=[<W;Y9W<W;Y<Y<U8V<[9W:W:W;Z:]:]=V;Y;]>^;];[>Y:Y;[<X;^<]8X:Z8Y9Z8X8]8Z7X8[7Z7d9c26?5H# 8!#,)2$*+0%"$,"/!,"!#" #"!&$%%$#%'%'&((('&('%%&),,"/(4. ?4!IH[\&sm0jJ?nJ@rG?iK=lH#&D''>,%?-&C,&=(#>*$>.%@-&@*">,$>((>+%;*$=*$<+%:+"=)$<*!<'!='#9*":(&=+$;)!9("8(#8* :(!:'!8%"9)$9( 7) ;'#9'#5&6%!8%"9' 7("6%!6%7$ 7&^;0K8$P<L9M:Q; N9X;K5HOgQו>:'XUO6/7q"! !  !   !   :7"#!!"&#01C=UPhavb-6[t_`{caaddbefgibcghdca^^`\ceegjhe}febghjdde506L9KM;J9K9S=J:H:M;L8O7N9K6M8O;G7J7K6J3H9H6I.G' #+!',*!+, )( +))+++()')*'***(&&)()')&&&''%&&&'&&' \ No newline at end of file diff --git a/examples/libs/jpeg_encoder/test.c b/examples/libs/jpeg_encoder/test.c index 815e122d5..7ef4e3b8c 100644 --- a/examples/libs/jpeg_encoder/test.c +++ b/examples/libs/jpeg_encoder/test.c @@ -20,23 +20,27 @@ #include "gaplib/jpeg_encoder.h" #include "gaplib/ImgIO.h" +#define __XSTR(__s) __STR(__s) +#define __STR(__s) #__s + static int test_entry() { jpeg_encoder_t enc; - unsigned int width=324, height=244; + unsigned int width=IMG_W, height=IMG_H,channels=IMG_C; int image_size = width*height; int pgm_header_size; - uint8_t *image = pmsis_l2_malloc(width*height); + uint8_t *image = pmsis_l2_malloc(width*height*channels); + char *ImageName = __XSTR(IMAGE_FILE); // First read input image - if (ReadImageFromFile("../../../imgTest0.pgm", width, height, 1, image, width*height, IMGIO_OUTPUT_CHAR, 0)){ + if (ReadImageFromFile(ImageName, IMG_W, IMG_H, IMG_C, image, IMG_W*IMG_H*IMG_C, IMGIO_OUTPUT_CHAR, 0)){ printf("Error reading input image"); pmsis_exit(-1); } // Allocate output jpeg image - uint8_t *jpeg_image = pi_l2_malloc(1024*20); + uint8_t *jpeg_image = pi_l2_malloc(1024*150); if (jpeg_image == NULL) return -1; @@ -53,6 +57,12 @@ static int test_entry() #else enc_conf.flags=0x0; #endif + + #if COLOR_JPG + //For color Jpeg this flag can be added + enc_conf.flags |= JPEG_ENCODER_FLAGS_COLOR; + #endif + enc_conf.width = width; enc_conf.height = height; @@ -125,9 +135,18 @@ static int test_entry() for(int i=0;ientry = &RunNetwork; + pi_cluster_task(task, &RunNetwork, NULL); task->stack_size = STACK_SIZE; task->slave_stack_size = SLAVE_STACK_SIZE; - task->arg = NULL; printf("Constructor\n"); @@ -100,7 +98,7 @@ void start() pi_gpio_pin_configure(NULL, LED, PI_GPIO_OUTPUT); pi_gpio_pin_write(NULL, LED, 1); #endif - pi_cluster_send_task_to_cl(&cluster_dev, task); + pi_cluster_send_task(&cluster_dev, task); #ifdef __GAP8__ pi_gpio_pin_write(NULL, LED, 0); #endif diff --git a/examples/pmsis/bsp/ble/ble_nina_b112/gaptest.yml b/examples/pmsis/bsp/ble/ble_nina_b112/gaptest.yml new file mode 100644 index 000000000..d822d0849 --- /dev/null +++ b/examples/pmsis/bsp/ble/ble_nina_b112/gaptest.yml @@ -0,0 +1,17 @@ +name: ble_nina_b112 +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/bsp/ble/ble_read_test/gaptest.yml b/examples/pmsis/bsp/ble/ble_read_test/gaptest.yml new file mode 100644 index 000000000..42f5e834a --- /dev/null +++ b/examples/pmsis/bsp/ble/ble_read_test/gaptest.yml @@ -0,0 +1,17 @@ +name: ble_read_test +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/bsp/blink_led/gaptest.yml b/examples/pmsis/bsp/blink_led/gaptest.yml new file mode 100644 index 000000000..0c9b4f4fd --- /dev/null +++ b/examples/pmsis/bsp/blink_led/gaptest.yml @@ -0,0 +1,17 @@ +name: blink_led +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/bsp/cameras/camera_ir_thermeye/always_on/gaptest.yml b/examples/pmsis/bsp/cameras/camera_ir_thermeye/always_on/gaptest.yml new file mode 100644 index 000000000..650f15570 --- /dev/null +++ b/examples/pmsis/bsp/cameras/camera_ir_thermeye/always_on/gaptest.yml @@ -0,0 +1,25 @@ +name: camera_ir_thermeye_always_on +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true + async: + name: async + tags: + - integration + - release + duration: standard + flags: ASYNC=1 + compile_only: true diff --git a/examples/pmsis/bsp/cameras/camera_ir_thermeye/lower_power_mode/gaptest.yml b/examples/pmsis/bsp/cameras/camera_ir_thermeye/lower_power_mode/gaptest.yml new file mode 100644 index 000000000..42151ac50 --- /dev/null +++ b/examples/pmsis/bsp/cameras/camera_ir_thermeye/lower_power_mode/gaptest.yml @@ -0,0 +1,25 @@ +name: camera_ir_thermeye_low_power_mode +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true + async: + name: async + tags: + - integration + - release + duration: standard + flags: ASYNC=1 + compile_only: true diff --git a/examples/pmsis/bsp/cameras/test_camera_gc0308/gaptest.yml b/examples/pmsis/bsp/cameras/test_camera_gc0308/gaptest.yml new file mode 100644 index 000000000..4392330e0 --- /dev/null +++ b/examples/pmsis/bsp/cameras/test_camera_gc0308/gaptest.yml @@ -0,0 +1,17 @@ +name: camera_gc0308 +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/bsp/cameras/test_camera_io/gaptest.yml b/examples/pmsis/bsp/cameras/test_camera_io/gaptest.yml new file mode 100644 index 000000000..15922f463 --- /dev/null +++ b/examples/pmsis/bsp/cameras/test_camera_io/gaptest.yml @@ -0,0 +1,25 @@ +name: camera_io +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true + async: + name: async + tags: + - integration + - release + duration: standard + flags: ASYNC=1 + compile_only: true diff --git a/examples/pmsis/bsp/cameras/test_camera_lcd/gaptest.yml b/examples/pmsis/bsp/cameras/test_camera_lcd/gaptest.yml new file mode 100644 index 000000000..6c0f08da0 --- /dev/null +++ b/examples/pmsis/bsp/cameras/test_camera_lcd/gaptest.yml @@ -0,0 +1,25 @@ +name: camera_lcd +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true + async: + name: async + tags: + - integration + - release + duration: standard + flags: ASYNC=1 + compile_only: true diff --git a/examples/pmsis/bsp/cameras/test_camera_ov5640/gaptest.yml b/examples/pmsis/bsp/cameras/test_camera_ov5640/gaptest.yml new file mode 100644 index 000000000..93049af03 --- /dev/null +++ b/examples/pmsis/bsp/cameras/test_camera_ov5640/gaptest.yml @@ -0,0 +1,17 @@ +name: camera_ov5640 +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/bsp/cameras/test_camera_ov7670/gaptest.yml b/examples/pmsis/bsp/cameras/test_camera_ov7670/gaptest.yml new file mode 100644 index 000000000..35f06b52a --- /dev/null +++ b/examples/pmsis/bsp/cameras/test_camera_ov7670/gaptest.yml @@ -0,0 +1,17 @@ +name: camera_ov7670 +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/bsp/cameras/test_camera_ov7670/ov7670_config.h b/examples/pmsis/bsp/cameras/test_camera_ov7670/ov7670_config.h old mode 100755 new mode 100644 diff --git a/examples/pmsis/bsp/cameras/test_camera_pixart/gaptest.yml b/examples/pmsis/bsp/cameras/test_camera_pixart/gaptest.yml new file mode 100644 index 000000000..d496534f3 --- /dev/null +++ b/examples/pmsis/bsp/cameras/test_camera_pixart/gaptest.yml @@ -0,0 +1,25 @@ +name: camera_pixart +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true + async: + name: async + tags: + - integration + - release + duration: standard + flags: ASYNC=1 + compile_only: true diff --git a/examples/pmsis/bsp/cameras/test_camera_stream/gaptest.yml b/examples/pmsis/bsp/cameras/test_camera_stream/gaptest.yml new file mode 100644 index 000000000..fea31f653 --- /dev/null +++ b/examples/pmsis/bsp/cameras/test_camera_stream/gaptest.yml @@ -0,0 +1,17 @@ +name: camera_stream +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/bsp/filesystem/fs_to_l3_copy/gaptest.yml b/examples/pmsis/bsp/filesystem/fs_to_l3_copy/gaptest.yml new file mode 100644 index 000000000..10d486d39 --- /dev/null +++ b/examples/pmsis/bsp/filesystem/fs_to_l3_copy/gaptest.yml @@ -0,0 +1,18 @@ +name: fs_to_l3_copy +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/bsp/filesystem/littlefs/native_lfs/gaptest.yml b/examples/pmsis/bsp/filesystem/littlefs/native_lfs/gaptest.yml new file mode 100644 index 000000000..aba58f9e7 --- /dev/null +++ b/examples/pmsis/bsp/filesystem/littlefs/native_lfs/gaptest.yml @@ -0,0 +1,18 @@ +name: littlefs_native_lfs +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/bsp/filesystem/readfs/gaptest.yml b/examples/pmsis/bsp/filesystem/readfs/gaptest.yml new file mode 100644 index 000000000..64fe4a473 --- /dev/null +++ b/examples/pmsis/bsp/filesystem/readfs/gaptest.yml @@ -0,0 +1,18 @@ +name: readfs +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/bsp/flash/hyper_flash/gaptest.yml b/examples/pmsis/bsp/flash/hyper_flash/gaptest.yml new file mode 100644 index 000000000..b2eb78659 --- /dev/null +++ b/examples/pmsis/bsp/flash/hyper_flash/gaptest.yml @@ -0,0 +1,26 @@ +name: hyper_flash +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true + async: + name: async + tags: + - integration + - release + duration: standard + flags: ASYNC=1 + compile_only: true diff --git a/examples/pmsis/bsp/flash/hyper_flash_multi_thread/gaptest.yml b/examples/pmsis/bsp/flash/hyper_flash_multi_thread/gaptest.yml new file mode 100644 index 000000000..81e854c32 --- /dev/null +++ b/examples/pmsis/bsp/flash/hyper_flash_multi_thread/gaptest.yml @@ -0,0 +1,25 @@ +name: hyper_flash_multi_thread +platforms: + - gvsoc +os: + - freertos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true + async: + name: async + tags: + - integration + - release + duration: standard + flags: ASYNC=1 + compile_only: true diff --git a/examples/pmsis/bsp/lcd/gapuino_himax_with_lcd/gaptest.yml b/examples/pmsis/bsp/lcd/gapuino_himax_with_lcd/gaptest.yml new file mode 100644 index 000000000..98de5fade --- /dev/null +++ b/examples/pmsis/bsp/lcd/gapuino_himax_with_lcd/gaptest.yml @@ -0,0 +1,17 @@ +name: gapuino_himax_with_lcd +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/bsp/microphones/vesper/vm3011_wakeup/gaptest.yml b/examples/pmsis/bsp/microphones/vesper/vm3011_wakeup/gaptest.yml new file mode 100644 index 000000000..edfb6290f --- /dev/null +++ b/examples/pmsis/bsp/microphones/vesper/vm3011_wakeup/gaptest.yml @@ -0,0 +1,17 @@ +name: microphones_vesper_vm3011_wakeup +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/bsp/ram/hyper_ram/gaptest.yml b/examples/pmsis/bsp/ram/hyper_ram/gaptest.yml new file mode 100644 index 000000000..2539ec88b --- /dev/null +++ b/examples/pmsis/bsp/ram/hyper_ram/gaptest.yml @@ -0,0 +1,26 @@ +name: hyper_ram +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true + async: + name: async + tags: + - integration + - release + duration: standard + flags: ASYNC=1 + compile_only: true diff --git a/examples/pmsis/bsp/ram/hyper_ram_flash/gaptest.yml b/examples/pmsis/bsp/ram/hyper_ram_flash/gaptest.yml new file mode 100644 index 000000000..387122e40 --- /dev/null +++ b/examples/pmsis/bsp/ram/hyper_ram_flash/gaptest.yml @@ -0,0 +1,26 @@ +name: hyper_ram_flash +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true + async: + name: async + tags: + - integration + - release + duration: standard + flags: ASYNC=1 + compile_only: true diff --git a/examples/pmsis/bsp/ram/hyper_ram_multi_thread/gaptest.yml b/examples/pmsis/bsp/ram/hyper_ram_multi_thread/gaptest.yml new file mode 100644 index 000000000..f0c34f889 --- /dev/null +++ b/examples/pmsis/bsp/ram/hyper_ram_multi_thread/gaptest.yml @@ -0,0 +1,25 @@ +name: hyper_ram_multi_thread +platforms: + - gvsoc +os: + - freertos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true + async: + name: async + tags: + - integration + - release + duration: standard + flags: ASYNC=1 + compile_only: true diff --git a/examples/pmsis/bsp/wifi/nina_b112_example/gaptest.yml b/examples/pmsis/bsp/wifi/nina_b112_example/gaptest.yml new file mode 100644 index 000000000..67a08ccad --- /dev/null +++ b/examples/pmsis/bsp/wifi/nina_b112_example/gaptest.yml @@ -0,0 +1,17 @@ +name: wifi_nina_b112 +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/features/aes128_sw/gaptest.yml b/examples/pmsis/features/aes128_sw/gaptest.yml new file mode 100644 index 000000000..ec524aa63 --- /dev/null +++ b/examples/pmsis/features/aes128_sw/gaptest.yml @@ -0,0 +1,17 @@ +name: aes128_sw +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ diff --git a/examples/pmsis/features/aes128_sw/main.c b/examples/pmsis/features/aes128_sw/main.c index 8514d59c0..6f12a2188 100644 --- a/examples/pmsis/features/aes128_sw/main.c +++ b/examples/pmsis/features/aes128_sw/main.c @@ -1,16 +1,12 @@ #include "pmsis.h" #include "AesLib.h" -#define TEST_BUFF_SIZE (40600) +#define TEST_BUFF_SIZE (40600) #define TEST_KEY_HI (0x1122334455667788) #define TEST_KEY_LO (0x9900AABBCCDDEEFF) #define TEST_IV (0x1122334455667788) -#if defined (__PULP_OS__) -RT_FC_DATA aes_data_t aes_data; -#else -GAP_FC_DATA aes_data_t aes_data; -#endif +PI_FC_L1 aes_data_t aes_data; static void load_key(unsigned char * key, unsigned char * iv) { @@ -58,7 +54,7 @@ void aes128() pi_perf_start(); cycles[0] = pi_perf_read(PI_PERF_CYCLES); - + AesBuildLUT(&aes_data); pi_perf_stop(); @@ -77,7 +73,7 @@ void aes128() cycles[3] = pi_perf_read(PI_PERF_CYCLES); for(int i=0 ; ientry = master_entry; - task->arg = &cl_arg; + + pi_cluster_task(task, master_entry, &cl_arg); printf("Sending task.\n"); #if defined(ASYNC) diff --git a/examples/pmsis/features/cluster/cluster_fork/gaptest.yml b/examples/pmsis/features/cluster/cluster_fork/gaptest.yml new file mode 100644 index 000000000..77c63156b --- /dev/null +++ b/examples/pmsis/features/cluster/cluster_fork/gaptest.yml @@ -0,0 +1,17 @@ +name: cluster_fork +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ diff --git a/examples/pmsis/features/cluster/cluster_malloc/gaptest.yml b/examples/pmsis/features/cluster/cluster_malloc/gaptest.yml new file mode 100644 index 000000000..e3d9e19f4 --- /dev/null +++ b/examples/pmsis/features/cluster/cluster_malloc/gaptest.yml @@ -0,0 +1,24 @@ +name: cluster_malloc +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + async: + name: async + tags: + - integration + - release + duration: standard + flags: ASYNC=1 diff --git a/examples/pmsis/features/efuse_burner/Makefile b/examples/pmsis/features/efuse_burner/Makefile deleted file mode 100644 index 74e05b110..000000000 --- a/examples/pmsis/features/efuse_burner/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -APP = test -APP_SRCS += example.c -APP_INC += - -ifdef EFUSE_WRITE -APP_CFLAGS += -DEFUSE_WRITE=1 -endif - -include $(RULES_DIR)/pmsis_rules.mk diff --git a/examples/pmsis/features/efuse_burner/example.c b/examples/pmsis/features/efuse_burner/example.c deleted file mode 100644 index 9000bea24..000000000 --- a/examples/pmsis/features/efuse_burner/example.c +++ /dev/null @@ -1,57 +0,0 @@ -// This example shows how to program efuses. -// -// This is a permanent operation. Once and efuse is programmed, the same value is -// read, even after power-up. This can be used to remember some settings. -// Be careful that there are some efuses reserved for the ROM to specify the -// boot mode, check the specifications to know which efuses can be used. - -#include - - -static int entry() -{ - printf("Entering main controller\n"); - -#ifdef EFUSE_WRITE - printf("Writing efuse 50 with value 0x12\n"); - - // Before writing the efuse, we must activate the program operation - // Once activated, we can wrote as many efuses as we want - plp_efuse_startProgram(); - - plp_efuse_writeByte(80, 0x12); - - // Close the current operation once done - plp_efuse_sleep(); -#else - printf("Efuse has not been written, recompile with make clean all run EFUSE_WRITE=1, be careful that this is a permanent operation !!!\n"); -#endif - - - // Before reading the efuse, we must activate the read operation - // Once activated, we can wrote as many efuses as we want - plp_efuse_startRead(); - - int value = plp_efuse_readWord(80); - - // Close the current operation once done - plp_efuse_sleep(); - - printf("Read efuse 50: 0x%x\n", value); - - return 0; -} - - -static void pmsis_wrapper(void) -{ - int retval = entry(); - pmsis_exit(retval); -} - - -int main(void) -{ - return pmsis_kickoff((void *)pmsis_wrapper); -} - diff --git a/examples/pmsis/features/helloworld_cxx/gaptest.yml b/examples/pmsis/features/helloworld_cxx/gaptest.yml new file mode 100644 index 000000000..7d9864113 --- /dev/null +++ b/examples/pmsis/features/helloworld_cxx/gaptest.yml @@ -0,0 +1,16 @@ +name: helloworld_cxx +platforms: + - gvsoc +os: + - freertos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ diff --git a/examples/pmsis/features/hyper_ram_delegate/gaptest.yml b/examples/pmsis/features/hyper_ram_delegate/gaptest.yml new file mode 100644 index 000000000..811611f76 --- /dev/null +++ b/examples/pmsis/features/hyper_ram_delegate/gaptest.yml @@ -0,0 +1,26 @@ +name: hyper_ram_delegate +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true + async: + name: async + tags: + - integration + - release + duration: standard + flags: ASYNC=1 + compile_only: true diff --git a/examples/pmsis/features/test_malloc/gaptest.yml b/examples/pmsis/features/test_malloc/gaptest.yml new file mode 100644 index 000000000..85043c25c --- /dev/null +++ b/examples/pmsis/features/test_malloc/gaptest.yml @@ -0,0 +1,17 @@ +name: test_malloc +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ diff --git a/examples/pmsis/features/test_malloc/test_malloc.c b/examples/pmsis/features/test_malloc/test_malloc.c index b631acf9e..1874b1931 100644 --- a/examples/pmsis/features/test_malloc/test_malloc.c +++ b/examples/pmsis/features/test_malloc/test_malloc.c @@ -116,9 +116,8 @@ void test_malloc(void) pmsis_l2_malloc_free(conf, sizeof(struct pi_cluster_conf)); pmsis_exit(-5); } - memset(task, 0, sizeof(struct pi_cluster_task)); - task->entry = master_entry; - task->arg = NULL; + + pi_cluster_task(task, master_entry, NULL); /* Sending task to cluster. */ pi_cluster_send_task_to_cl(cluster_dev, task); diff --git a/examples/pmsis/features/uart_delegate/gaptest.yml b/examples/pmsis/features/uart_delegate/gaptest.yml new file mode 100644 index 000000000..008a9e7a5 --- /dev/null +++ b/examples/pmsis/features/uart_delegate/gaptest.yml @@ -0,0 +1,18 @@ +name: uart_delegate +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/helloworld/gaptest.yml b/examples/pmsis/helloworld/gaptest.yml new file mode 100644 index 000000000..6bedf8220 --- /dev/null +++ b/examples/pmsis/helloworld/gaptest.yml @@ -0,0 +1,18 @@ +name: helloworld +platforms: + - gvsoc + - board +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ diff --git a/examples/pmsis/periph/dmacpy/gaptest.yml b/examples/pmsis/periph/dmacpy/gaptest.yml new file mode 100644 index 000000000..67cd62962 --- /dev/null +++ b/examples/pmsis/periph/dmacpy/gaptest.yml @@ -0,0 +1,26 @@ +name: dmacpy +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true + async: + name: async + tags: + - integration + - release + duration: standard + flags: ASYNC=1 + compile_only: true diff --git a/examples/pmsis/periph/gpio/gpio_input/gaptest.yml b/examples/pmsis/periph/gpio/gpio_input/gaptest.yml new file mode 100644 index 000000000..0cb0c762c --- /dev/null +++ b/examples/pmsis/periph/gpio/gpio_input/gaptest.yml @@ -0,0 +1,18 @@ +name: gpio_input +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/gpio/gpio_input/gpio.c b/examples/pmsis/periph/gpio/gpio_input/gpio.c index 0c3005e75..80f4de0ae 100644 --- a/examples/pmsis/periph/gpio/gpio_input/gpio.c +++ b/examples/pmsis/periph/gpio/gpio_input/gpio.c @@ -6,6 +6,15 @@ /* PMSIS includes */ #include "pmsis.h" +/* Defines */ +#if defined(__GAP8__) +#define GPIO_PIN (PI_GPIO_A0_PAD_12_A3) +#elif defined(__GAP9__) +#define GPIO_PIN (PI_GPIO_A68) +#else +#error "Unknown chip" +#endif + /* Variables used. */ struct pi_device gpio; @@ -34,7 +43,7 @@ void test_gpio(void) } pi_task_t cb_gpio; - pi_gpio_e gpio_in = PI_GPIO_A0_PAD_12_A3; + pi_gpio_e gpio_in = GPIO_PIN; pi_gpio_notif_e irq_type = PI_GPIO_NOTIF_RISE; pi_gpio_flags_e cfg_flags = PI_GPIO_INPUT|PI_GPIO_PULL_DISABLE|PI_GPIO_DRIVE_STRENGTH_LOW; diff --git a/examples/pmsis/periph/gpio/gpio_irq_cb/gaptest.yml b/examples/pmsis/periph/gpio/gpio_irq_cb/gaptest.yml new file mode 100644 index 000000000..ead916f96 --- /dev/null +++ b/examples/pmsis/periph/gpio/gpio_irq_cb/gaptest.yml @@ -0,0 +1,18 @@ +name: gpio_irq_cb +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/gpio/gpio_irq_cb/gpio.c b/examples/pmsis/periph/gpio/gpio_irq_cb/gpio.c index 1b6a64a26..851226b49 100644 --- a/examples/pmsis/periph/gpio/gpio_irq_cb/gpio.c +++ b/examples/pmsis/periph/gpio/gpio_irq_cb/gpio.c @@ -6,6 +6,15 @@ /* PMSIS includes */ #include "pmsis.h" +/* Defines */ +#if defined(__GAP8__) +#define GPIO_PIN (PI_GPIO_A0_PAD_12_A3) +#elif defined(__GAP9__) +#define GPIO_PIN (PI_GPIO_A68) +#else +#error "Unknown chip" +#endif + /* Variables used. */ struct pi_device gpio; @@ -51,7 +60,7 @@ void test_gpio(void) pmsis_exit(errors); } - pi_gpio_e gpio_in = PI_GPIO_A0_PAD_12_A3; + pi_gpio_e gpio_in = GPIO_PIN; pi_gpio_notif_e irq_type = PI_GPIO_NOTIF_RISE; pi_gpio_flags_e cfg_flags = PI_GPIO_INPUT|PI_GPIO_PULL_DISABLE|PI_GPIO_DRIVE_STRENGTH_LOW; diff --git a/examples/pmsis/periph/gpio/gpio_output/gaptest.yml b/examples/pmsis/periph/gpio/gpio_output/gaptest.yml new file mode 100644 index 000000000..8bc059d75 --- /dev/null +++ b/examples/pmsis/periph/gpio/gpio_output/gaptest.yml @@ -0,0 +1,18 @@ +name: gpio_output +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/gpio/gpio_output/gpio.c b/examples/pmsis/periph/gpio/gpio_output/gpio.c index 5aeb07ffd..850f22ef2 100644 --- a/examples/pmsis/periph/gpio/gpio_output/gpio.c +++ b/examples/pmsis/periph/gpio/gpio_output/gpio.c @@ -6,6 +6,26 @@ /* PMSIS includes */ #include "pmsis.h" +/* Defines */ +#if defined(__GAP8__) + +#define GPIO_PAD1 (PI_PAD_12_A3_RF_PACTRL0) +#define GPIO_PIN1 (PI_GPIO_A0_PAD_12_A3) + +#define GPIO_PAD2 (PI_PAD_15_B1_RF_PACTRL3) +#define GPIO_PIN2 (PI_GPIO_A3_PAD_15_B1) + +#elif defined(__GAP9__) +#define GPIO_PAD1 (PI_PAD_068) +#define GPIO_PIN1 (PI_GPIO_A68) + +#define GPIO_PAD2 (PI_PAD_086) +#define GPIO_PIN2 (PI_GPIO_A86) + +#else +#error "Unknown chip" +#endif + #define DELAY_MS 500 /* Variables used. */ @@ -19,12 +39,12 @@ void test_gpio(void) uint32_t value = 0; //Setting pad to alternate 1 //GPIO A1 - pi_pad_set_function(PI_PAD_12_A3_RF_PACTRL0, PI_PAD_12_A3_GPIO_A0_FUNC1); + pi_pad_set_function(GPIO_PAD1, PI_PAD_FUNC1); //GPIO LED (A3) - pi_pad_set_function(PI_PAD_15_B1_RF_PACTRL3, PI_PAD_FUNC1); - - pi_gpio_e gpio_out_a1 = PI_GPIO_A0_PAD_12_A3; - pi_gpio_e gpio_out_led = PI_GPIO_A3_PAD_15_B1; + pi_pad_set_function(GPIO_PAD2, PI_PAD_FUNC1); + + pi_gpio_e gpio_out_a1 = GPIO_PIN1; + pi_gpio_e gpio_out_led = GPIO_PIN2; /* Configure gpio output. */ pi_gpio_flags_e cfg_flags = PI_GPIO_OUTPUT; diff --git a/examples/pmsis/periph/i2c/i2c_bmp280/gaptest.yml b/examples/pmsis/periph/i2c/i2c_bmp280/gaptest.yml new file mode 100644 index 000000000..964cb67c7 --- /dev/null +++ b/examples/pmsis/periph/i2c/i2c_bmp280/gaptest.yml @@ -0,0 +1,18 @@ +name: i2c_bmp280 +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/i2c/i2c_detect/gaptest.yml b/examples/pmsis/periph/i2c/i2c_detect/gaptest.yml new file mode 100644 index 000000000..88c99bd11 --- /dev/null +++ b/examples/pmsis/periph/i2c/i2c_detect/gaptest.yml @@ -0,0 +1,17 @@ +name: i2c_detect +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/i2c/i2c_eeprom_pulp_fmc/gaptest.yml b/examples/pmsis/periph/i2c/i2c_eeprom_pulp_fmc/gaptest.yml new file mode 100644 index 000000000..2acc38e5e --- /dev/null +++ b/examples/pmsis/periph/i2c/i2c_eeprom_pulp_fmc/gaptest.yml @@ -0,0 +1,17 @@ +name: i2c_eeprom_pulp_fmc +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/i2c/i2c_scan/Makefile b/examples/pmsis/periph/i2c/i2c_scan/Makefile index c210b96ed..ad43981fc 100644 --- a/examples/pmsis/periph/i2c/i2c_scan/Makefile +++ b/examples/pmsis/periph/i2c/i2c_scan/Makefile @@ -7,14 +7,11 @@ APP_INC += APP_CFLAGS += -runner_args =--trace=corruptor --trace-level=trace -#runner_args =--trace=board.*i2c --trace-level=trace -#runner_args =--trace=board.*i2c:gvsoc.log --trace-level=trace -#runner_args =--trace=eeprom -#runner_args +=--trace-level=trace +ifeq '$(platform)' 'gvsoc' # Overwrite the default target so that GVSOC simulates our board # First name is the class name, second one is the python module export GAPY_PY_TARGET=My_board@my_board +endif # Append current directory to python path so that it finds our board and module export PYTHONPATH:=$(CURDIR):$(PYTHONPATH) diff --git a/examples/pmsis/periph/i2c/i2c_scan/gaptest.yml b/examples/pmsis/periph/i2c/i2c_scan/gaptest.yml new file mode 100644 index 000000000..208865a38 --- /dev/null +++ b/examples/pmsis/periph/i2c/i2c_scan/gaptest.yml @@ -0,0 +1,17 @@ +name: i2c_scan +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/i2c/i2c_slave/gaptest.yml b/examples/pmsis/periph/i2c/i2c_slave/gaptest.yml new file mode 100644 index 000000000..251436da8 --- /dev/null +++ b/examples/pmsis/periph/i2c/i2c_slave/gaptest.yml @@ -0,0 +1,17 @@ +name: i2c_slave_loopback +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/i2s/pcm/gaptest.yml b/examples/pmsis/periph/i2s/pcm/gaptest.yml new file mode 100644 index 000000000..bbdd53305 --- /dev/null +++ b/examples/pmsis/periph/i2s/pcm/gaptest.yml @@ -0,0 +1,18 @@ +name: i2s_pcm +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/i2s/pdm/gaptest.yml b/examples/pmsis/periph/i2s/pdm/gaptest.yml new file mode 100644 index 000000000..4cb332ece --- /dev/null +++ b/examples/pmsis/periph/i2s/pdm/gaptest.yml @@ -0,0 +1,18 @@ +name: i2s_pdm +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/i2s/pdm_4mic/gaptest.yml b/examples/pmsis/periph/i2s/pdm_4mic/gaptest.yml new file mode 100644 index 000000000..cd88be255 --- /dev/null +++ b/examples/pmsis/periph/i2s/pdm_4mic/gaptest.yml @@ -0,0 +1,18 @@ +name: i2s_pdm_4mic +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/i2s/pdm_async/gaptest.yml b/examples/pmsis/periph/i2s/pdm_async/gaptest.yml new file mode 100644 index 000000000..3d99bb3f0 --- /dev/null +++ b/examples/pmsis/periph/i2s/pdm_async/gaptest.yml @@ -0,0 +1,18 @@ +name: i2s_pdm_async +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/i2s/wav_out/gaptest.yml b/examples/pmsis/periph/i2s/wav_out/gaptest.yml new file mode 100644 index 000000000..e91dfe000 --- /dev/null +++ b/examples/pmsis/periph/i2s/wav_out/gaptest.yml @@ -0,0 +1,18 @@ +name: i2s_wav_out +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/i2s/wav_out_long/gaptest.yml b/examples/pmsis/periph/i2s/wav_out_long/gaptest.yml new file mode 100644 index 000000000..d9ddabd7a --- /dev/null +++ b/examples/pmsis/periph/i2s/wav_out_long/gaptest.yml @@ -0,0 +1,18 @@ +name: i2s_wav_out_long +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/i2s/wav_out_one_shot/gaptest.yml b/examples/pmsis/periph/i2s/wav_out_one_shot/gaptest.yml new file mode 100644 index 000000000..6cc8975f6 --- /dev/null +++ b/examples/pmsis/periph/i2s/wav_out_one_shot/gaptest.yml @@ -0,0 +1,18 @@ +name: i2s_wav_out_one_shot +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/perf/gaptest.yml b/examples/pmsis/periph/perf/gaptest.yml new file mode 100644 index 000000000..d7a791e20 --- /dev/null +++ b/examples/pmsis/periph/perf/gaptest.yml @@ -0,0 +1,17 @@ +name: perf +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ diff --git a/examples/pmsis/periph/pwm/gaptest.yml b/examples/pmsis/periph/pwm/gaptest.yml new file mode 100644 index 000000000..fa57415f0 --- /dev/null +++ b/examples/pmsis/periph/pwm/gaptest.yml @@ -0,0 +1,18 @@ +name: pwm +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/rtc/rtc_alarm/gaptest.yml b/examples/pmsis/periph/rtc/rtc_alarm/gaptest.yml new file mode 100644 index 000000000..44cb70c4c --- /dev/null +++ b/examples/pmsis/periph/rtc/rtc_alarm/gaptest.yml @@ -0,0 +1,18 @@ +name: rtc_alarm +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/rtc/rtc_calendar/gaptest.yml b/examples/pmsis/periph/rtc/rtc_calendar/gaptest.yml new file mode 100644 index 000000000..7c35557ff --- /dev/null +++ b/examples/pmsis/periph/rtc/rtc_calendar/gaptest.yml @@ -0,0 +1,18 @@ +name: rtc_calendar +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/rtc/rtc_counter/gaptest.yml b/examples/pmsis/periph/rtc/rtc_counter/gaptest.yml new file mode 100644 index 000000000..ae74bd85d --- /dev/null +++ b/examples/pmsis/periph/rtc/rtc_counter/gaptest.yml @@ -0,0 +1,18 @@ +name: rtc_counter +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/spi/spi_master/gaptest.yml b/examples/pmsis/periph/spi/spi_master/gaptest.yml new file mode 100644 index 000000000..c3ef7ba4f --- /dev/null +++ b/examples/pmsis/periph/spi/spi_master/gaptest.yml @@ -0,0 +1,18 @@ +name: spi_master +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/uart/uart_helloworld/gaptest.yml b/examples/pmsis/periph/uart/uart_helloworld/gaptest.yml new file mode 100644 index 000000000..67a176fa8 --- /dev/null +++ b/examples/pmsis/periph/uart/uart_helloworld/gaptest.yml @@ -0,0 +1,18 @@ +name: uart_helloworld +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/uart/uart_helloworld_timeout/gaptest.yml b/examples/pmsis/periph/uart/uart_helloworld_timeout/gaptest.yml new file mode 100644 index 000000000..df9d7562b --- /dev/null +++ b/examples/pmsis/periph/uart/uart_helloworld_timeout/gaptest.yml @@ -0,0 +1,16 @@ +name: uart_helloworld_timeout +platforms: + - gvsoc +os: + - freertos +chips: + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/uart/uart_input/gaptest.yml b/examples/pmsis/periph/uart/uart_input/gaptest.yml new file mode 100644 index 000000000..a7e409203 --- /dev/null +++ b/examples/pmsis/periph/uart/uart_input/gaptest.yml @@ -0,0 +1,18 @@ +name: uart_input +platforms: + - gvsoc +os: + - freertos + - pulpos +chips: + - gap8 + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/examples/pmsis/periph/uart/uart_input_timeout/gaptest.yml b/examples/pmsis/periph/uart/uart_input_timeout/gaptest.yml new file mode 100644 index 000000000..c49ab3ee9 --- /dev/null +++ b/examples/pmsis/periph/uart/uart_input_timeout/gaptest.yml @@ -0,0 +1,16 @@ +name: uart_input_timeout +platforms: + - gvsoc +os: + - freertos +chips: + - gap9 +variants: + std: + name: standard + tags: + - integration + - release + duration: standard + flags: ~ + compile_only: true diff --git a/gap8/gap8.mk b/gap8/gap8.mk index a4b7e9772..f743412e8 100644 --- a/gap8/gap8.mk +++ b/gap8/gap8.mk @@ -74,7 +74,7 @@ minimal: pulp-os freertos gapy.all openocd_tools.all plptest.all # Compat sdk: all -mini_checkout: pmsis-bsp.checkout pmsis-api.checkout examples.checkout +mini_checkout: examples.checkout freertos: freertos.all mini_checkout @@ -87,13 +87,6 @@ install_others: | $(INSTALL_BIN_DIR) $(CP) $(GAP_SDK_HOME)/utils/rules $(INSTALL_DIR) -# Sources -pmsis-bsp.checkout: - git submodule update --init rtos/pmsis/pmsis_bsp - -pmsis-api.checkout: - git submodule update --init rtos/pmsis/pmsis_api - # This rules is to compile pmsis-bsp for pulp os on gap8, wihtout having to recompile the whole sdk pmsis-bsp.build: $(MAKE) -C $(GAP_SDK_HOME)/rtos/pmsis/pmsis_bsp all diff --git a/gvsoc/CMakeLists.txt b/gvsoc/CMakeLists.txt index 85379e2b8..9ab32103a 100644 --- a/gvsoc/CMakeLists.txt +++ b/gvsoc/CMakeLists.txt @@ -73,3 +73,16 @@ add_subdirectory(gvsoc_gap) if(UDMA_HAS_SFU) add_subdirectory(gvsoc_gap_sfu) endif() + +if("${CONFIG_GVSOC_SKIP_UDMA_BUILD}" EQUAL "1") + message(STATUS "Installing precompiled files") + vp_files(FILES "gvsoc_libs/debug/pulp/udma/udma_v4_gap9_v2_impl.so" + PREFIX "debug/pulp/udma/") + + vp_files(FILES "gvsoc_libs/sv/pulp/udma/udma_v4_gap9_v2_impl.so" + PREFIX "sv/pulp/udma/") + + vp_files(FILES "gvsoc_libs/pulp/udma/udma_v4_gap9_v2_impl.so" + PREFIX "pulp/udma/") + +endif() diff --git a/gvsoc/gvsoc/bin/pulp-pc-info b/gvsoc/gvsoc/bin/pulp-pc-info index 62bff025e..ab816b189 100755 --- a/gvsoc/gvsoc/bin/pulp-pc-info +++ b/gvsoc/gvsoc/bin/pulp-pc-info @@ -63,12 +63,15 @@ toolchain = os.environ.get('PULP_RISCV_GCC_TOOLCHAIN_CI') if toolchain is None: toolchain = os.environ.get('PULP_RISCV_GCC_TOOLCHAIN') -if toolchain is not None: - readelf = toolchain + '/bin/riscv32-unknown-elf-readelf' - addr2line = toolchain + '/bin/riscv32-unknown-elf-addr2line' -else: - readelf = 'riscv32-unknown-elf-readelf' - addr2line = 'riscv32-unknown-elf-addr2line' +# if toolchain is not None: +# readelf = toolchain + '/bin/riscv32-unknown-elf-readelf' +# addr2line = toolchain + '/bin/riscv32-unknown-elf-addr2line' +# else: +# readelf = 'riscv32-unknown-elf-readelf' +# addr2line = 'riscv32-unknown-elf-addr2line' + +readelf = 'readelf' +addr2line = 'addr2line' process = Popen((readelf + ' -s %s' % args.file).split(), stdin=PIPE, stdout=PIPE) diff --git a/gvsoc/gvsoc/engine/include/gv/power.hpp b/gvsoc/gvsoc/engine/include/gv/power.hpp index df4853d35..2f43e6049 100644 --- a/gvsoc/gvsoc/engine/include/gv/power.hpp +++ b/gvsoc/gvsoc/engine/include/gv/power.hpp @@ -148,9 +148,41 @@ namespace vp */ void setup(double temp, double volt, double freq); + /** + * @brief Turn on a power source + * + * This power source should be turned on when its power domain is turned on, in order to start consuming power + */ + void turn_on(); + + /** + * @brief Turn off a power source + * + * This power source should be turned off when its power domain is turned off, in order to stop consuming power + */ + void turn_off(); + + /** + * @brief Turn on a power source + * + * This power source should be turned on when its power domain is turned on, in order to start consuming power + */ + void turn_dynamic_power_on(); + + /** + * @brief Turn off a power source + * + * This power source should be turned off when its power domain is turned off, in order to stop consuming power + */ + void turn_dynamic_power_off(); + private: - Linear_table *table = NULL; // Table of power values for all supported temperatures and voltages - // imported from the json configuration given when trace was initialized. + void check(); + + Linear_table *dyn_table = NULL; // Table of power values for all supported temperatures and voltages + // imported from the json configuration given when trace was initialized. + Linear_table *leakage_table = NULL; // Table of power values for all supported temperatures and voltages + // imported from the json configuration given when trace was initialized. double quantum; // Current quantumm of energy, for quantum-based power consumption. // The current value is estimated depending on voltage and temperature according // to the provided json configuration. @@ -162,7 +194,12 @@ namespace vp // to the provided json configuration. component *top; // Top component containing the power source power_trace *trace; // Power trace where the power consumption should be reported. - bool is_on = false; // True is the source is on and backgroun-power and leakage should be reported + bool is_dynamic_power_started = false; // True is the source consuming dynamic backgroun power + bool is_leakage_power_started = false; // True is the source should start consuming leakage power + bool is_on = false; // True is the power domain containing the power source is on and backgroun-power and leakage should be reported + bool is_dynamic_power_on = false; // True is the power domain containing the power source is on and backgroun-power and leakage should be reported + bool dynamic_power_is_on_sync = false; + bool leakage_power_is_on_sync = false; }; @@ -327,12 +364,16 @@ namespace vp // power consumed. void account_leakage_power(); - // Check if the current amount of cycle energy is not for the current cycle + // Check if the current amount of power due to quantum of energies + // is not for the current cycle // (by checking the timestamp), and if not, reset it to zero. - inline void flush_dynamic_energy_for_cycle(); + inline void flush_quantum_power_for_cycle(); - // Get the amount of energy spent in the current cycle - inline double get_dynamic_energy_for_cycle(); + // Get the average power of the current cycle due to quantums of energy + inline double get_quantum_power_for_cycle(); + + // Get the energy spent in the current cycle due to quantums of energy + inline double get_quantum_energy_for_cycle(); // Return the total amount of dynamic energy spent since the beginning // of the report windows (since report_start was called) @@ -363,7 +404,7 @@ namespace vp int64_t curent_cycle_timestamp; // Timestamp of the current cycle, used to compute energy spent in the // current cycle. As soon as current time is different, the timestamp // is set to current time and the current energy is set to 0. - double dynamic_energy_for_cycle; // Amount of energy spent in the current cycle. + double quantum_power_for_cycle; // Power spent by quentum of energy in the current cycle. // It is increased everytime a quantum of energy is // spent and reset to zero when the current cycle is // over. It is mostly used to compute the instant power @@ -468,6 +509,15 @@ namespace vp */ vp::power::power_trace *get_power_trace() { return &this->power_trace; } + /** + * @brief Set power supply state + * + * This sets the power supply for this component and all his childs. + * + * @param state Supply state + */ + void power_supply_set_all(int state); + protected: /** * @brief Get the report energy from childs object @@ -516,10 +566,15 @@ namespace vp // Get instant power for this component and the whole hierarchy below him. double get_power_from_self_and_childs(); + // Set power supply state + static void power_supply_sync(void *_this, int state); + component ⊤ // Component containing the power component object vp::power::power_trace power_trace; // Default power trace of this component std::vector traces; // Vector of power traces of this component + std::vector sources; // Vector of power sources of this component power::engine *engine = NULL; // Power engine + vp::wire_slave power_port; // Slave port for setting power supply state }; @@ -542,6 +597,8 @@ namespace vp */ engine(vp::component *top); + ~engine(); + /** * @brief Start power report generation * @@ -570,6 +627,8 @@ namespace vp std::vector traces; // Vector of all traces. vp::component *top; // Top component of the simulated architecture + + FILE *file; // File where the power reports are dumped }; }; diff --git a/gvsoc/gvsoc/engine/include/vp/component.hpp b/gvsoc/gvsoc/engine/include/vp/component.hpp index dd336a587..44b05070c 100644 --- a/gvsoc/gvsoc/engine/include/vp/component.hpp +++ b/gvsoc/gvsoc/engine/include/vp/component.hpp @@ -397,6 +397,7 @@ namespace vp { { friend class component_clock; + friend class vp::power::component_power; public: component(js::config *config); @@ -410,6 +411,7 @@ namespace vp { virtual void quit(int status) {} virtual void pre_reset() {} virtual void reset(bool active) {} + virtual void power_supply_set(int state) {} virtual void load() {} virtual void elab(); virtual void run() {} @@ -568,6 +570,14 @@ namespace vp { vp::component *__gv_create(std::string config_path, struct gv_conf *gv_conf); + class top + { + public: + component *top_instance; + power::engine *power_engine; + private: + }; + }; #endif diff --git a/gvsoc/gvsoc/engine/include/vp/power/power_source.hpp b/gvsoc/gvsoc/engine/include/vp/power/power_source.hpp index 10bb99434..bcea94c18 100644 --- a/gvsoc/gvsoc/engine/include/vp/power/power_source.hpp +++ b/gvsoc/gvsoc/engine/include/vp/power/power_source.hpp @@ -25,51 +25,78 @@ #include "vp/vp_data.hpp" +inline void vp::power::power_source::turn_on() +{ + this->is_on = true; + this->is_dynamic_power_on = true; + this->check(); +} + + +inline void vp::power::power_source::turn_off() +{ + this->is_on = false; + this->is_dynamic_power_on = false; + this->check(); +} + +inline void vp::power::power_source::turn_dynamic_power_on() +{ + this->is_dynamic_power_on = true; + this->check(); +} + +inline void vp::power::power_source::turn_dynamic_power_off() +{ + this->is_dynamic_power_on = false; + this->check(); +} + inline void vp::power::power_source::leakage_power_start() { - // Only start accounting leakage if not already done and if leakage is defined - if (!this->is_on && this->leakage != -1) + // Only start if leakage is defined + if (this->leakage != -1) { - this->trace->inc_leakage_power(this->leakage); + this->is_leakage_power_started = true; + this->check(); } - this->is_on = true; } inline void vp::power::power_source::leakage_power_stop() { - // Only stop accounting leakage if not already done and if leakage is defined - if (this->is_on && this->leakage != -1) + // Only stop if leakage is defined + if (this->leakage != -1) { - this->trace->inc_leakage_power(-this->leakage); + this->is_leakage_power_started = false; + this->check(); } - this->is_on = false; } inline void vp::power::power_source::dynamic_power_start() { - // Only start accounting background power if not already done and if it is is defined - if (!this->is_on && this->background_power != -1) + // Only start accounting background power if it is is defined + if (this->background_power != -1) { - this->trace->inc_dynamic_power(this->background_power); + this->is_dynamic_power_started = true; + this->check(); } - this->is_on = true; } inline void vp::power::power_source::dynamic_power_stop() { - // Only stop accounting background power if not already done and if it is is defined - if (this->is_on && this->background_power != -1) + // Only stop accounting background power if it is is defined + if (this->background_power != -1) { - this->trace->inc_dynamic_power(-this->background_power); + this->is_dynamic_power_started = false; + this->check(); } - this->is_on = false; } @@ -77,7 +104,7 @@ inline void vp::power::power_source::dynamic_power_stop() inline void vp::power::power_source::account_energy_quantum() { // Only account energy is a quantum is defined - if (this->quantum != -1) + if (this->is_on && this->is_dynamic_power_on && this->quantum != -1) { this->trace->inc_dynamic_energy(this->quantum); } diff --git a/gvsoc/gvsoc/engine/include/vp/power/power_trace.hpp b/gvsoc/gvsoc/engine/include/vp/power/power_trace.hpp index 6d833599b..fe33eaa79 100644 --- a/gvsoc/gvsoc/engine/include/vp/power/power_trace.hpp +++ b/gvsoc/gvsoc/engine/include/vp/power/power_trace.hpp @@ -32,25 +32,43 @@ inline double vp::power::power_trace::get_power() -inline double vp::power::power_trace::get_dynamic_energy_for_cycle() +inline double vp::power::power_trace::get_quantum_power_for_cycle() { // First check if the current energy is for an old cycle - this->flush_dynamic_energy_for_cycle(); + this->flush_quantum_power_for_cycle(); // And return the current total - return this->dynamic_energy_for_cycle; + return this->quantum_power_for_cycle; } +inline double vp::power::power_trace::get_quantum_energy_for_cycle() +{ + double power = this->get_quantum_power_for_cycle(); -inline void vp::power::power_trace::flush_dynamic_energy_for_cycle() + if (power != 0) + { + return power * this->top->get_period(); + } + + return 0; +} + + + +inline void vp::power::power_trace::flush_quantum_power_for_cycle() { // Clear the current total if it is not for the current cycle - if (this->curent_cycle_timestamp < this->top->get_time()) + if (this->quantum_power_for_cycle && this->curent_cycle_timestamp < this->top->get_time()) { - this->curent_cycle_timestamp = this->top->get_time(); - this->dynamic_energy_for_cycle = 0; + if (this->parent) + { + this->parent->inc_dynamic_power(-this->quantum_power_for_cycle); + } + this->quantum_power_for_cycle = 0; } + + this->curent_cycle_timestamp = this->top->get_time(); } diff --git a/gvsoc/gvsoc/engine/include/vp/trace/event_dumper.hpp b/gvsoc/gvsoc/engine/include/vp/trace/event_dumper.hpp index 4f5da18ea..6340ba80d 100644 --- a/gvsoc/gvsoc/engine/include/vp/trace/event_dumper.hpp +++ b/gvsoc/gvsoc/engine/include/vp/trace/event_dumper.hpp @@ -71,7 +71,7 @@ namespace vp { class Event_dumper { public: - Event_dumper(vp::component *comp) : comp(comp) {} + Event_dumper(vp::component *comp) : comp(comp) { this->user_vcd = NULL; } Event_trace *get_trace(string trace_name, string file_name, int width, bool is_real=false, bool is_string=false); Event_trace *get_trace_real(string trace_name, string file_name); Event_trace *get_trace_string(string trace_name, string file_name); @@ -83,6 +83,7 @@ namespace vp { private: std::map event_traces; std::map event_files; + gv::Vcd_user *user_vcd; }; class Vcd_file : public Event_file diff --git a/gvsoc/gvsoc/engine/python/gv/gvsoc.py b/gvsoc/gvsoc/engine/python/gv/gvsoc.py index 04f900465..d711756d8 100644 --- a/gvsoc/gvsoc/engine/python/gv/gvsoc.py +++ b/gvsoc/gvsoc/engine/python/gv/gvsoc.py @@ -146,7 +146,8 @@ def conf(self): def __gen_debug_info(self, full_config, gvsoc_config): for binary in full_config.get('**/debug_binaries').get_dict(): - if os.system('pulp-pc-info --file %s --all-file %s' % (binary.replace('.debugInfo', ''), binary)) != 0: + if os.system('gen-debug-info %s %s' % (binary.replace('.debugInfo', ''), binary)) != 0: + # if os.system('pulp-pc-info --file %s --all-file %s' % (binary.replace('.debugInfo', ''), binary)) != 0: raise errors.InputError('Error while generating debug symbols information, make sure the toolchain and the binaries are accessible ') diff --git a/gvsoc/gvsoc/engine/src/launcher.cpp b/gvsoc/gvsoc/engine/src/launcher.cpp index 63908857c..1dc3b727a 100644 --- a/gvsoc/gvsoc/engine/src/launcher.cpp +++ b/gvsoc/gvsoc/engine/src/launcher.cpp @@ -43,6 +43,7 @@ class Gvsoc_launcher : public gv::Gvsoc private: + void *handler; vp::component *instance; }; @@ -53,19 +54,20 @@ gv::Gvsoc *gv::gvsoc_new() void Gvsoc_launcher::open(std::string config_path) { - this->instance = vp::__gv_create(config_path, NULL); + this->handler = vp::__gv_create(config_path, NULL); + this->instance = ((vp::top *)this->handler)->top_instance; - gv_start((void *)this->instance); + gv_start(this->handler); } void Gvsoc_launcher::close() { - gv_destroy((void *)this->instance); + gv_destroy(this->handler); } void Gvsoc_launcher::run() { - gv_step((void *)this->instance, 0); + gv_step(this->handler, 0); } int64_t Gvsoc_launcher::stop() @@ -76,7 +78,7 @@ int64_t Gvsoc_launcher::stop() int64_t Gvsoc_launcher::step(int64_t duration) { - gv_step((void *)this->instance, duration); + gv_step(this->handler, duration); return 0; } @@ -92,10 +94,10 @@ void Gvsoc_launcher::vcd_bind(gv::Vcd_user *user) void Gvsoc_launcher::event_add(std::string path, bool is_regex) { - + this->instance->traces.get_trace_manager()->conf_trace(1, path, 1); } void Gvsoc_launcher::event_exclude(std::string path, bool is_regex) { - + this->instance->traces.get_trace_manager()->conf_trace(1, path, 0); } diff --git a/gvsoc/gvsoc/engine/src/power/component_power.cpp b/gvsoc/gvsoc/engine/src/power/component_power.cpp index 310a00b7a..d8930b94c 100644 --- a/gvsoc/gvsoc/engine/src/power/component_power.cpp +++ b/gvsoc/gvsoc/engine/src/power/component_power.cpp @@ -41,6 +41,9 @@ void vp::power::component_power::build() { this->get_engine()->reg_trace(trace); } + + this->power_port.set_sync_meth(&vp::power::component_power::power_supply_sync); + this->top.new_slave_port(this, "power_supply", &this->power_port); } @@ -69,6 +72,8 @@ int vp::power::component_power::new_power_source(std::string name, power_source source->setup(VP_POWER_DEFAULT_TEMP, VP_POWER_DEFAULT_VOLT, VP_POWER_DEFAULT_FREQ); + this->sources.push_back(source); + return 0; } @@ -150,3 +155,51 @@ void vp::power::component_power::dump_child_traces(FILE *file, double total) x->power.dump(file, total); } } + +void vp::power::component_power::power_supply_sync(void *__this, int state) +{ + vp::power::component_power *_this = (vp::power::component_power *)__this; + _this->power_supply_set_all(state); +} + + +void vp::power::component_power::power_supply_set_all(int state) +{ + this->top.power_supply_set(state); + + for (auto &x : this->top.childs) + { + x->power.power_supply_set_all(state); + } + + + + if (state >= 2) + { + for (auto &x : this->sources) + { + if (state == 3) + { + x->turn_dynamic_power_on(); + } + else + { + x->turn_dynamic_power_off(); + } + } + } + else + { + for (auto &x : this->sources) + { + if (state == 1) + { + x->turn_on(); + } + else + { + x->turn_off(); + } + } + } +} diff --git a/gvsoc/gvsoc/engine/src/power/power_engine.cpp b/gvsoc/gvsoc/engine/src/power/power_engine.cpp index c7661f6a9..19652c069 100644 --- a/gvsoc/gvsoc/engine/src/power/power_engine.cpp +++ b/gvsoc/gvsoc/engine/src/power/power_engine.cpp @@ -46,14 +46,11 @@ void vp::power::engine::start_capture() void vp::power::engine::stop_capture() { // When stopping, dump recursively all traces to a file - FILE *file = fopen("power_report.csv", "w"); - if (file == NULL) + + if (this->file) { - // vp_warning_always(&this->warning, "Failed to open power report file (path: %s)\n", "power_report.csv"); - return; + this->top->dump_traces_recursive(file); } - - this->top->dump_traces_recursive(file); } @@ -64,4 +61,19 @@ vp::power::engine::engine(vp::component *top) // Declare power service, each component will ask the connection to it top->new_service("power", this); + + this->file = fopen("power_report.csv", "w"); + if (this->file == NULL) + { + //vp_warning_always(&this->warning, "Failed to open power report file (path: %s)\n", "power_report.csv"); + } +} + + +vp::power::engine::~engine() +{ + if (this->file) + { + fclose(this->file); + } } diff --git a/gvsoc/gvsoc/engine/src/power/power_source.cpp b/gvsoc/gvsoc/engine/src/power/power_source.cpp index 579e27f07..c28ded02a 100644 --- a/gvsoc/gvsoc/engine/src/power/power_source.cpp +++ b/gvsoc/gvsoc/engine/src/power/power_source.cpp @@ -30,15 +30,15 @@ void vp::power::power_source::setup(double temp, double volt, double freq) // dynamic background power or leakage if they are defined, which is the case if they are not -1 if (this->quantum != -1) { - this->quantum = this->table->get(temp, volt, freq); + this->quantum = this->dyn_table->get(temp, volt, freq); } if (this->background_power != -1) { - this->background_power = this->table->get(temp, volt, freq); + this->background_power = this->dyn_table->get(temp, volt, freq); } if (this->leakage != -1) { - this->leakage = this->table->get(temp, volt, freq); + this->leakage = this->leakage_table->get(temp, volt, freq); } } @@ -130,7 +130,14 @@ int vp::power::power_source::init(component *top, std::string name, js::config * return -1; } - this->table = new Linear_table(values); + if (is_leakage) + { + this->leakage_table = new Linear_table(values); + } + else + { + this->dyn_table = new Linear_table(values); + } } else { @@ -147,3 +154,44 @@ int vp::power::power_source::init(component *top, std::string name, js::config * return 0; } + + +void vp::power::power_source::check() +{ + bool leakage_power_is_on = this->is_on && this->is_leakage_power_started; + bool dynamic_power_is_on = this->is_on && this->is_dynamic_power_on && this->is_dynamic_power_started; + + if (this->dynamic_power_is_on_sync != dynamic_power_is_on) + { + if (this->background_power) + { + if (dynamic_power_is_on) + { + this->trace->inc_dynamic_power(this->background_power); + } + else + { + this->trace->inc_dynamic_power(-this->background_power); + } + } + + this->dynamic_power_is_on_sync = dynamic_power_is_on; + } + + if (this->leakage_power_is_on_sync != leakage_power_is_on) + { + if (this->leakage) + { + if (leakage_power_is_on) + { + this->trace->inc_leakage_power(this->leakage); + } + else + { + this->trace->inc_leakage_power(-this->leakage); + } + } + + this->leakage_power_is_on_sync = leakage_power_is_on; + } +} diff --git a/gvsoc/gvsoc/engine/src/power/power_trace.cpp b/gvsoc/gvsoc/engine/src/power/power_trace.cpp index 3bda6a8b4..c5e5001b8 100644 --- a/gvsoc/gvsoc/engine/src/power/power_trace.cpp +++ b/gvsoc/gvsoc/engine/src/power/power_trace.cpp @@ -28,7 +28,7 @@ int vp::power::power_trace::init(component *top, std::string name, vp::power::po { this->top = top; top->traces.new_trace_event_real(name, &this->trace); - this->dynamic_energy_for_cycle = 0; + this->quantum_power_for_cycle = 0; this->report_dynamic_energy = 0; this->report_leakage_energy = 0; this->curent_cycle_timestamp = 0; @@ -37,7 +37,7 @@ int vp::power::power_trace::init(component *top, std::string name, vp::power::po if (parent == NULL) { vp::component *component = top->get_parent(); - if (component) + if (component && component->get_path() != "") { parent = component->power.get_power_trace(); } @@ -73,10 +73,13 @@ void vp::power::power_trace::trace_handler(void *__this, vp::clock_event *event) void vp::power::power_trace::report_start() { + this->account_dynamic_power(); + this->account_leakage_power(); + // Since the report start may be triggered in the middle of several events // for power consumptions, include what has already be accounted // in the same cycle. - this->report_dynamic_energy = this->get_dynamic_energy_for_cycle(); + this->report_dynamic_energy = this->get_quantum_energy_for_cycle(); this->report_leakage_energy = 0; this->report_start_timestamp = this->top->get_time(); } @@ -93,12 +96,9 @@ void vp::power::power_trace::get_report_energy(double *dynamic, double *leakage) void vp::power::power_trace::get_report_power(double *dynamic, double *leakage) { - double childs_dynamic = 0, childs_leakage = 0; - // To get the power on the report window, we just get the total energy and divide by the window duration - this->top->power.get_report_energy_from_childs(&childs_dynamic, &childs_leakage); - *dynamic = (childs_dynamic + this->get_report_dynamic_energy()) / (this->top->get_time() - this->report_start_timestamp); - *leakage = (childs_leakage + this->get_report_leakage_energy()) / (this->top->get_time() - this->report_start_timestamp); + *dynamic = (this->get_report_dynamic_energy()) / (this->top->get_time() - this->report_start_timestamp); + *leakage = (this->get_report_leakage_energy()) / (this->top->get_time() - this->report_start_timestamp); } @@ -127,43 +127,25 @@ void vp::power::power_trace::dump_vcd_trace() if (this->top->get_path() == "") return; - double power = 0.0; - // To dump the VCD trace, we need to compute the instant power, since this is what is reported. // This is easy for background and leakage power. For enery quantum, we get the amount of energy for the current // cycle and compute the instant power using the clock engine period. - // Some component do not have clocks. They cannot use energy quantum but they can still use background - // power and leakage - if (this->top->get_clock()) - { - int64_t period = this->top->get_period(); - if (period != 0) - { - power += this->get_dynamic_energy_for_cycle() / period; - } - } + double quantum_power = this->get_quantum_power_for_cycle(); double power_background = this->current_dynamic_power + this->current_leakage_power; // Also account the power from childs since VCD traces are hierarchical - double childs_power = this->top->power.get_power_from_childs(); - this->current_power = power + power_background + childs_power; + this->current_power = quantum_power + power_background; // Dump the instant power to trace this->trace.event_real(current_power); // If there was a contribution from energy quantum, schedule an event in the next cycle so that we dump again // the trace since teh quantum implicitely disappears and overal power is modified - if (!this->trace_event->is_enqueued() && power > 0) + if (!this->trace_event->is_enqueued() && quantum_power > 0) { this->top->event_enqueue(this->trace_event, 1); } - - // Notify the parent that this trace was dumped so that the upper traces can be dumped as well - if (this->parent) - { - this->parent->dump_vcd_trace(); - } } @@ -213,15 +195,26 @@ void vp::power::power_trace::account_leakage_power() void vp::power::power_trace::inc_dynamic_energy(double quantum) { + if (this->top->get_period() == 0) + { + return; + } + // Since we need to account the energy for the current amount of the cycle, check if it needs to be flushed - this->flush_dynamic_energy_for_cycle(); + this->flush_quantum_power_for_cycle(); // Then account it to both the total amount and to the cycle amount - this->dynamic_energy_for_cycle += quantum; + double power = quantum / this->top->get_period(); + this->quantum_power_for_cycle += power; this->report_dynamic_energy += quantum; - // Redump VCD trace since teh instant power is impacted + // Redump VCD trace since the instant power is impacted this->dump_vcd_trace(); + + if (this->parent) + { + this->parent->inc_dynamic_power(power); + } } @@ -235,14 +228,24 @@ void vp::power::power_trace::inc_dynamic_power(double power_incr) this->account_dynamic_power(); this->current_dynamic_power += power_incr; - // Redump VCD trace since teh instant power is impacted + // Redump VCD trace since the instant power is impacted this->dump_vcd_trace(); + + if (this->parent) + { + this->parent->inc_dynamic_power(power_incr); + } } void vp::power::power_trace::inc_leakage_power(double power_incr) { + // TODO this is wasting time and should be removed once fake component such as time domain and trace domain + // are not in the component hierarchy anymore + if (this->top->get_path() == "") + return; + // Leakage and dynamic are handled differently since they are reported separately, // In both cases, first compute the power on current period, start a new one, // and change the power so that it is constant over the period, to properly @@ -250,6 +253,11 @@ void vp::power::power_trace::inc_leakage_power(double power_incr) this->account_leakage_power(); this->current_leakage_power += power_incr; - // Redump VCD trace since teh instant power is impacted + // Redump VCD trace since the instant power is impacted this->dump_vcd_trace(); + + if (this->parent) + { + this->parent->inc_leakage_power(power_incr); + } } diff --git a/gvsoc/gvsoc/engine/src/trace/event.cpp b/gvsoc/gvsoc/engine/src/trace/event.cpp index ae0f0475a..579880226 100644 --- a/gvsoc/gvsoc/engine/src/trace/event.cpp +++ b/gvsoc/gvsoc/engine/src/trace/event.cpp @@ -102,6 +102,11 @@ vp::Event_trace *vp::Event_dumper::get_trace(string trace_name, string file_name trace = new Event_trace(trace_name, event_file, width, is_real, is_string); event_traces[trace_name] = trace; + + if (this->user_vcd) + { + trace->set_vcd_user(this->user_vcd); + } } return trace; @@ -135,6 +140,8 @@ void vp::Event_dumper::close() void vp::Event_dumper::set_vcd_user(gv::Vcd_user *user) { + this->user_vcd = user; + for (auto const& x : event_traces) { x.second->set_vcd_user(user); diff --git a/gvsoc/gvsoc/engine/src/vp.cpp b/gvsoc/gvsoc/engine/src/vp.cpp index 271e0078a..f733d8e3d 100644 --- a/gvsoc/gvsoc/engine/src/vp.cpp +++ b/gvsoc/gvsoc/engine/src/vp.cpp @@ -67,6 +67,7 @@ char vp_error[VP_ERROR_SIZE]; static Gv_proxy *proxy = NULL; + uint64_t vp::reg::get_field(int offset, int width) { uint64_t value = 0; @@ -329,6 +330,7 @@ void vp::component_clock::clk_reg(component *_this, component *clock) } } + void vp::component::reset_all(bool active, bool from_itf) { // Small hack to not propagate the reset from top level if the reset has @@ -1686,12 +1688,15 @@ vp::component *vp::__gv_create(std::string config_path, struct gv_conf *gv_conf) vp::component *instance = constructor(js_config); - new vp::power::engine(instance); + vp::top *top = new vp::top(); + + top->top_instance = instance; + top->power_engine = new vp::power::engine(instance); instance->set_vp_config(gv_config); instance->set_gv_conf(gv_conf); - return instance; + return (vp::component *)top; } @@ -1708,7 +1713,8 @@ extern "C" void gv_destroy(void *arg) extern "C" void gv_start(void *arg) { - vp::component *instance = (vp::component *)arg; + vp::top *top = (vp::top *)arg; + vp::component *instance = (vp::component *)top->top_instance; instance->pre_pre_build(); instance->pre_build(); @@ -1736,7 +1742,8 @@ extern "C" void gv_start(void *arg) extern "C" void gv_step(void *arg, int64_t timestamp) { - vp::component *instance = (vp::component *)arg; + vp::top *top = (vp::top *)arg; + vp::component *instance = (vp::component *)top->top_instance; instance->step(timestamp); } @@ -1744,7 +1751,8 @@ extern "C" void gv_step(void *arg, int64_t timestamp) extern "C" int64_t gv_time(void *arg) { - vp::component *instance = (vp::component *)arg; + vp::top *top = (vp::top *)arg; + vp::component *instance = (vp::component *)top->top_instance; return instance->get_time_engine()->get_next_event_time(); } @@ -1989,9 +1997,10 @@ vp::time_event *vp::time_scheduler::enqueue(time_event *event, int64_t time) -extern "C" int gv_run(void *_instance) +extern "C" int gv_run(void *arg) { - vp::component *instance = (vp::component *)_instance; + vp::top *top = (vp::top *)arg; + vp::component *instance = (vp::component *)top->top_instance; if (!proxy) { @@ -2014,9 +2023,10 @@ extern "C" void gv_init(struct gv_conf *gv_conf) } -extern "C" void gv_stop(void *_instance, int retval) +extern "C" void gv_stop(void *arg, int retval) { - vp::component *instance = (vp::component *)_instance; + vp::top *top = (vp::top *)arg; + vp::component *instance = (vp::component *)top->top_instance; if (proxy) { @@ -2024,6 +2034,8 @@ extern "C" void gv_stop(void *_instance, int retval) } instance->stop(); + + delete top->power_engine; } @@ -2059,6 +2071,7 @@ void vp::fatal(const char *fmt, ...) extern "C" void *gv_chip_pad_bind(void *handle, char *name, int ext_handle) { - vp::component *instance = (vp::component *)handle; + vp::top *top = (vp::top *)handle; + vp::component *instance = (vp::component *)top->top_instance; return instance->external_bind(name, "", (void *)(long)ext_handle); } diff --git a/gvsoc/gvsoc/engine/vp/trace_domain_impl.cpp b/gvsoc/gvsoc/engine/vp/trace_domain_impl.cpp index 76f4757b3..9cd9aa576 100644 --- a/gvsoc/gvsoc/engine/vp/trace_domain_impl.cpp +++ b/gvsoc/gvsoc/engine/vp/trace_domain_impl.cpp @@ -474,7 +474,7 @@ void trace_domain::conf_trace(int event, std::string path_str, bool enabled) if (trace != NULL) { if (event) - { + { if (enabled) { vp::Event_trace *event_trace; diff --git a/gvsoc/gvsoc/models/cpu/iss/include/pulp_v2.hpp b/gvsoc/gvsoc/models/cpu/iss/include/pulp_v2.hpp index 778ab4d58..4d23e13f6 100644 --- a/gvsoc/gvsoc/models/cpu/iss/include/pulp_v2.hpp +++ b/gvsoc/gvsoc/models/cpu/iss/include/pulp_v2.hpp @@ -26,13 +26,13 @@ #define PULPV2_HWLOOP_LPEND0 1 #define PULPV2_HWLOOP_LPCOUNT0 2 -#define PULPV2_HWLOOP_LPSTART1 3 -#define PULPV2_HWLOOP_LPEND1 4 -#define PULPV2_HWLOOP_LPCOUNT1 5 +#define PULPV2_HWLOOP_LPSTART1 4 +#define PULPV2_HWLOOP_LPEND1 5 +#define PULPV2_HWLOOP_LPCOUNT1 6 -#define PULPV2_HWLOOP_LPSTART(x) (PULPV2_HWLOOP_LPSTART0 + (x)*3) -#define PULPV2_HWLOOP_LPEND(x) (PULPV2_HWLOOP_LPEND0 + (x)*3) -#define PULPV2_HWLOOP_LPCOUNT(x) (PULPV2_HWLOOP_LPCOUNT0 + (x)*3) +#define PULPV2_HWLOOP_LPSTART(x) (PULPV2_HWLOOP_LPSTART0 + (x)*4) +#define PULPV2_HWLOOP_LPEND(x) (PULPV2_HWLOOP_LPEND0 + (x)*4) +#define PULPV2_HWLOOP_LPCOUNT(x) (PULPV2_HWLOOP_LPCOUNT0 + (x)*4) static inline iss_insn_t *LB_RR_exec_fast(iss_t *iss, iss_insn_t *insn) { @@ -595,7 +595,7 @@ static inline iss_insn_t *hwloop_check_exec(iss_t *iss, iss_insn_t *insn) static inline void hwloop_set_start(iss_t *iss, iss_insn_t *insn, int index, iss_reg_t start) { iss->cpu.pulpv2.hwloop_regs[PULPV2_HWLOOP_LPSTART(index)] = start; - iss->cpu.state.hwloop_start_insn[index] = insn_cache_get(iss, start); + iss->cpu.state.hwloop_start_insn[index] = insn_cache_get(iss, start); } static inline void hwloop_set_end(iss_t *iss, iss_insn_t *insn, int index, iss_reg_t end) diff --git a/gvsoc/gvsoc/models/cpu/iss/src/csr.cpp b/gvsoc/gvsoc/models/cpu/iss/src/csr.cpp index 8258e80f0..84f4ca5d2 100644 --- a/gvsoc/gvsoc/models/cpu/iss/src/csr.cpp +++ b/gvsoc/gvsoc/models/cpu/iss/src/csr.cpp @@ -940,6 +940,18 @@ static bool hwloop_read(iss_t *iss, int reg, iss_reg_t *value) { static bool hwloop_write(iss_t *iss, int reg, unsigned int value) { iss->cpu.pulpv2.hwloop_regs[reg] = value; + + // Since the HW loop is using decode instruction for the HW loop start to jump faster + // we need to recompute it when it is modified. + if (reg == 0) + { + iss->cpu.state.hwloop_start_insn[0] = insn_cache_get(iss, value); + } + else if (reg == 4) + { + iss->cpu.state.hwloop_start_insn[1] = insn_cache_get(iss, value); + } + return false; } diff --git a/gvsoc/gvsoc/models/cpu/iss/vp/include/iss_wrapper.hpp b/gvsoc/gvsoc/models/cpu/iss/vp/include/iss_wrapper.hpp index f7e234e1c..9ae3c3fe4 100644 --- a/gvsoc/gvsoc/models/cpu/iss/vp/include/iss_wrapper.hpp +++ b/gvsoc/gvsoc/models/cpu/iss/vp/include/iss_wrapper.hpp @@ -113,6 +113,7 @@ class iss_wrapper : public vp::component, vp::Gdbserver_core vp::wire_slave irq_req_itf; vp::wire_master irq_ack_itf; + vp::wire_master busy_itf; vp::wire_master flush_cache_req_itf; vp::wire_slave flush_cache_ack_itf; @@ -142,8 +143,7 @@ class iss_wrapper : public vp::component, vp::Gdbserver_core vp::reg_1 do_step; std::vector insn_groups_power; - vp::power::power_source clock_gated_power; - vp::power::power_source leakage_power; + vp::power::power_source background_power; vp::trace state_event; vp::trace pc_trace_event; diff --git a/gvsoc/gvsoc/models/cpu/iss/vp/src/iss_wrapper.cpp b/gvsoc/gvsoc/models/cpu/iss/vp/src/iss_wrapper.cpp index 69df9a4e0..9825fa0df 100644 --- a/gvsoc/gvsoc/models/cpu/iss/vp/src/iss_wrapper.cpp +++ b/gvsoc/gvsoc/models/cpu/iss/vp/src/iss_wrapper.cpp @@ -287,6 +287,11 @@ void iss_wrapper::clock_sync(void *__this, bool active) _this->clock_active = active; + if (_this->busy_itf.is_bound()) + { + _this->busy_itf.sync(active); + } + // TODO this could be better handler is the clock would be taken into // account in the core state machine uint8_t value = active && _this->is_active_reg.get(); @@ -1330,8 +1335,7 @@ int iss_wrapper::build() this->insn_groups_power.resize(1); power.new_power_source("power_insn", &this->insn_groups_power[0], this->get_js_config()->get("**/insn")); } - power.new_power_source("power_clock_gated", &clock_gated_power, this->get_js_config()->get("**/clock_gated")); - power.new_power_source("leakage", &leakage_power, this->get_js_config()->get("**/leakage")); + power.new_power_source("background", &background_power, this->get_js_config()->get("**/power_models/background")); data.set_resp_meth(&iss_wrapper::data_response); data.set_grant_meth(&iss_wrapper::data_grant); @@ -1354,6 +1358,8 @@ int iss_wrapper::build() new_slave_port("irq_req", &irq_req_itf); new_master_port("irq_ack", &irq_ack_itf); + new_master_port("busy", &busy_itf); + fetchen_itf.set_sync_meth(&iss_wrapper::fetchen_sync); new_slave_port("fetchen", &fetchen_itf); @@ -1424,14 +1430,6 @@ void iss_wrapper::start() iss_register_debug_info(this, x->get_str().c_str()); } - if (this->get_js_config()->get("**/binaries") != NULL) - { - for (auto x:this->get_js_config()->get("**/binaries")->get_elems()) - { - this->binaries_trace_event.event_string("static enable " + x->get_str()); - } - } - trace.msg("ISS start (fetch: %d, is_active: %d, boot_addr: 0x%lx)\n", fetch_enable_reg.get(), is_active_reg.get(), get_config_int("boot_addr")); #ifdef USE_TRDB @@ -1439,7 +1437,8 @@ void iss_wrapper::start() INIT_LIST_HEAD(&this->trdb_packet_list); #endif - this->leakage_power.leakage_power_start(); + this->background_power.leakage_power_start(); + this->background_power.dynamic_power_start(); this->gdbserver = (vp::Gdbserver_engine *)this->get_service("gdbserver"); @@ -1495,6 +1494,14 @@ void iss_wrapper::reset(bool active) this->halted.set(true); } + if (this->get_js_config()->get("**/binaries") != NULL) + { + for (auto x:this->get_js_config()->get("**/binaries")->get_elems()) + { + this->binaries_trace_event.event_string("static enable " + x->get_str()); + } + } + check_state(); } } diff --git a/gvsoc/gvsoc/models/devices/CMakeLists.txt b/gvsoc/gvsoc/models/devices/CMakeLists.txt index d87ee0b38..cfb0dccc5 100644 --- a/gvsoc/gvsoc/models/devices/CMakeLists.txt +++ b/gvsoc/gvsoc/models/devices/CMakeLists.txt @@ -4,6 +4,7 @@ add_subdirectory(hyperbus) add_subdirectory(i2c) add_subdirectory(jtag) add_subdirectory(sound) +add_subdirectory(gpio) add_subdirectory(spiflash) add_subdirectory(testbench) add_subdirectory(uart) diff --git a/gvsoc/gvsoc/models/devices/gpio/CMakeLists.txt b/gvsoc/gvsoc/models/devices/gpio/CMakeLists.txt new file mode 100644 index 000000000..f2aa7d662 --- /dev/null +++ b/gvsoc/gvsoc/models/devices/gpio/CMakeLists.txt @@ -0,0 +1,6 @@ + +set(GPIO_PREFIX "devices/gpio") + +vp_model(NAME fxl6408 + PREFIX ${GPIO_PREFIX} + SOURCES "fxl6408.cpp") diff --git a/gvsoc/gvsoc/models/devices/gpio/fxl6408.cpp b/gvsoc/gvsoc/models/devices/gpio/fxl6408.cpp new file mode 100644 index 000000000..f148aa47d --- /dev/null +++ b/gvsoc/gvsoc/models/devices/gpio/fxl6408.cpp @@ -0,0 +1,471 @@ +/* + * Copyright (C) 2020 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Authors: Germain Haugou, GreenWaves Technologies (germain.haugou@greenwaves-technologies.com) + */ + + +#include +#include + + + +typedef enum +{ + I2C_STATE_WAIT_START, + I2C_STATE_WAIT_ADDRESS, + I2C_STATE_GET_DATA, + I2C_STATE_SAMPLE_DATA, + I2C_STATE_ACK, + I2C_STATE_READ_ACK +} I2c_state_e; + + +class Fxl6408 : public vp::component +{ +public: + Fxl6408(js::config *config); + + int build(); + +protected: + static void i2c_sync(void *__this, int scl, int sda); + void i2c_start(unsigned int address, bool is_read); + void i2c_handle_byte(uint8_t byte); + void i2c_stop(); + void i2c_get_data(); + void i2c_send_byte(uint8_t byte); + + void handle_reg_write(uint8_t address, uint8_t value); + uint8_t handle_reg_read(uint8_t address); + + void start(); + + vp::trace trace; + vp::i2c_master i2c_itf; + + unsigned int device_address; + + bool i2c_being_addressed; + unsigned int i2c_address; + uint8_t i2c_pending_data; + bool i2c_is_read; + I2c_state_e i2c_state; + int i2c_pending_bits; + int i2c_prev_sda; + int i2c_prev_scl; + unsigned int i2c_pending_send_byte; + uint8_t reg_address; + bool waiting_reg_address; + + uint8_t device_id; + uint8_t io_dir; + uint8_t output_state; + uint8_t output_high_z; + uint8_t input_default_state; + uint8_t pull_enable; + uint8_t pull_down_up; + uint8_t input_status; + uint8_t interrupt_mask; + uint8_t interrupt_status; +}; + + +Fxl6408::Fxl6408(js::config *config) + : vp::component(config) +{ +} + + +void Fxl6408::start() +{ + this->i2c_itf.sync(1, 1); +} + + +void Fxl6408::i2c_sync(void *__this, int scl, int sda) +{ + Fxl6408 *_this = (Fxl6408 *)__this; + + _this->trace.msg(vp::trace::LEVEL_TRACE, "I2C sync (scl: %d, sda: %d)\n", scl, sda); + + int sdo = 1; + + if (scl == 1 && _this->i2c_prev_sda != sda) + { + if (_this->i2c_prev_sda == 1) + { + _this->trace.msg(vp::trace::LEVEL_TRACE, "Detected start\n"); + + _this->i2c_state = I2C_STATE_WAIT_ADDRESS; + _this->i2c_address = 0; + _this->i2c_pending_bits = 8; + } + else + { + _this->i2c_state = I2C_STATE_WAIT_START; + _this->i2c_stop(); + } + goto end; + } + + if (!_this->i2c_prev_scl && scl) + { + switch (_this->i2c_state) + { + case I2C_STATE_WAIT_START: + { + sdo = 1; + break; + } + + case I2C_STATE_WAIT_ADDRESS: + { + if (_this->i2c_pending_bits > 1) + { + _this->i2c_address = (_this->i2c_address << 1) | sda; + _this->trace.msg(vp::trace::LEVEL_TRACE, "Received address bit (bit: %d, address: 0x%x, pending_bits: %d)\n", sda, _this->i2c_address, _this->i2c_pending_bits); + } + else + { + _this->i2c_is_read = sda; + } + _this->i2c_pending_bits--; + if (_this->i2c_pending_bits == 0) + { + _this->i2c_start(_this->i2c_address, _this->i2c_is_read); + _this->i2c_state = I2C_STATE_ACK; + _this->i2c_pending_bits = 8; + } + break; + } + + case I2C_STATE_SAMPLE_DATA: + { + _this->i2c_pending_data = (_this->i2c_pending_data << 1) | sda; + _this->trace.msg(vp::trace::LEVEL_TRACE, "Sampling data (bit: %d, pending_value: 0x%x, pending_bits: %d)\n", sda, _this->i2c_pending_data, _this->i2c_pending_bits); + _this->i2c_pending_bits--; + if (_this->i2c_pending_bits == 0) + { + _this->i2c_pending_bits = 8; + _this->i2c_handle_byte(_this->i2c_pending_data); + _this->i2c_state = I2C_STATE_ACK; + } + break; + } + + case I2C_STATE_ACK: { + _this->trace.msg(vp::trace::LEVEL_TRACE, "Ack (being_addressed: %d)\n", _this->i2c_being_addressed); + if (_this->i2c_being_addressed) + { + if (_this->i2c_is_read) + { + _this->i2c_state = I2C_STATE_GET_DATA; + _this->i2c_pending_bits = 8; + _this->i2c_get_data(); + } + else + { + _this->i2c_state = I2C_STATE_SAMPLE_DATA; + } + } + else + { + _this->i2c_state = I2C_STATE_WAIT_START; + } + + break; + } + + case I2C_STATE_READ_ACK: { + _this->i2c_state = I2C_STATE_WAIT_START; + break; + } + } + } + + if (_this->i2c_prev_scl && !scl) + { + switch (_this->i2c_state) + { + case I2C_STATE_ACK: + { + _this->trace.msg(vp::trace::LEVEL_TRACE, "Ack (being_addressed: %d)\n", _this->i2c_being_addressed); + sdo = !_this->i2c_being_addressed; + break; + } + + case I2C_STATE_READ_ACK: + { + _this->trace.msg(vp::trace::LEVEL_TRACE, "Read ack\n"); + sdo = 0; + break; + } + + case I2C_STATE_GET_DATA: + { + sdo = (_this->i2c_pending_send_byte >> 7) & 1; + _this->trace.msg(vp::trace::LEVEL_TRACE, "Sending bit (bit: %d, pending_value: 0x%x, pending_bits: %d)\n", sdo, _this->i2c_pending_send_byte, _this->i2c_pending_bits); + _this->i2c_pending_send_byte <<= 1; + _this->i2c_pending_bits--; + if (_this->i2c_pending_bits == 0) + { + _this->i2c_state = I2C_STATE_READ_ACK; + } + break; + } + } + } + +end: + if (_this->i2c_prev_scl && !scl) + { + _this->trace.msg(vp::trace::LEVEL_TRACE, "Sync sda (value: %d)\n", sdo); + _this->i2c_itf.sync(1, sdo); + } + _this->i2c_prev_sda = sda; + _this->i2c_prev_scl = scl; +} + +void Fxl6408::i2c_start(unsigned int address, bool is_read) +{ + this->trace.msg(vp::trace::LEVEL_TRACE, "Received header (address: 0x%x, is_read: %d)\n", address, is_read); + + this->i2c_being_addressed = address == this->device_address; + if (this->i2c_being_addressed && is_read) + { + this->i2c_send_byte(this->handle_reg_read(this->reg_address)); + } +} + +void Fxl6408::i2c_handle_byte(uint8_t byte) +{ + this->trace.msg(vp::trace::LEVEL_TRACE, "Handle byte (value: 0x%x)\n", byte); + + if (this->waiting_reg_address) + { + this->reg_address = byte; + this->waiting_reg_address = false; + } + else + { + this->handle_reg_write(this->reg_address, byte); + this->waiting_reg_address = true; + } +} + +void Fxl6408::i2c_stop() +{ + this->trace.msg(vp::trace::LEVEL_TRACE, "Received stop bit\n"); + +} + +void Fxl6408::i2c_get_data() +{ + this->trace.msg(vp::trace::LEVEL_TRACE, "Getting data\n"); +} + +void Fxl6408::i2c_send_byte(uint8_t byte) +{ + this->i2c_pending_send_byte = byte; +} + + +void Fxl6408::handle_reg_write(uint8_t address, uint8_t value) +{ + this->trace.msg(vp::trace::LEVEL_TRACE, "Register write (address: 0x%x, value: 0x%x)\n", address, value); + + switch (address) + { + case 0x01: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Device ID & Ctrl", value); + this->device_id = value; + break; + } + case 0x03: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "IO Direction", value); + this->io_dir = value; + break; + } + case 0x05: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Output State", value); + this->output_state = value; + break; + } + case 0x07: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Output High-Z", value); + this->output_high_z = value; + break; + } + case 0x09: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Input Default State", value); + this->input_default_state = value; + break; + } + case 0x0B: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Pull Enable", value); + this->pull_enable = value; + break; + } + case 0x0D: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Pull-Down/Pull-Up", value); + this->pull_down_up = value; + break; + } + case 0x0F: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Input Status", value); + this->input_status = value; + break; + } + case 0x11: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Interrupt Mask", value); + this->interrupt_mask = value; + break; + } + case 0x13: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "interrupt Status", value); + this->interrupt_status = value; + break; + } + default: + this->trace.force_warning("Writing invalid register (address: 0x%x)\n", address); + break; + } + +} + + +uint8_t Fxl6408::handle_reg_read(uint8_t address) +{ + this->trace.msg(vp::trace::LEVEL_DEBUG, "Register read (address: 0x%x)\n", address); + + uint8_t value = 0xFF; + + switch (address) + { + case 0x01: + { + value = this->device_id; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Device ID & Ctrl", value); + break; + } + case 0x03: + { + value = this->io_dir; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "IO Direction", value); + break; + } + case 0x05: + { + value = this->output_state; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Output State", value); + break; + } + case 0x07: + { + value = this->output_high_z; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Output High-Z", value); + break; + } + case 0x09: + { + value = this->input_default_state; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Input Default State", value); + break; + } + case 0x0B: + { + value = this->pull_enable; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Pull Enable", value); + break; + } + case 0x0D: + { + value = this->pull_down_up; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Pull-Down/Pull-Up", value); + break; + } + case 0x0F: + { + value = this->input_status; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Input Status", value); + break; + } + case 0x11: + { + value = this->interrupt_mask; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Interrupt Mask", value); + break; + } + case 0x13: + { + value = this->interrupt_status; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Interrupt Status", value); + break; + } + default: + this->trace.force_warning("Reading invalid register (address: 0x%x)\n", address); + break; + } + + return value; +} + + +int Fxl6408::build() +{ + traces.new_trace("trace", &trace, vp::DEBUG); + + this->i2c_itf.set_sync_meth(&Fxl6408::i2c_sync); + this->new_master_port("i2c", &this->i2c_itf); + + this->i2c_state = I2C_STATE_WAIT_START; + this->i2c_prev_sda = 1; + this->i2c_prev_scl = 1; + this->i2c_being_addressed = false; + this->device_address = 0x43; + this->waiting_reg_address = true; + + this->device_id = 0xC2; + this->io_dir = 0x00; + this->output_state = 0x00; + this->output_high_z = 0xFF; + this->input_default_state = 0x00; + this->pull_enable = 0xFF; + this->pull_down_up = 0x00; + this->input_status = 0xFF; + this->interrupt_mask = 0x00; + this->interrupt_status = 0xFF; + + return 0; +} + + +extern "C" vp::component *vp_constructor(js::config *config) +{ + return new Fxl6408(config); +} diff --git a/gvsoc/gvsoc/models/devices/i2c/helper/i2c_helper.cpp b/gvsoc/gvsoc/models/devices/i2c/helper/i2c_helper.cpp index 22ed95106..7f024bb02 100644 --- a/gvsoc/gvsoc/models/devices/i2c/helper/i2c_helper.cpp +++ b/gvsoc/gvsoc/models/devices/i2c/helper/i2c_helper.cpp @@ -15,27 +15,29 @@ * along with this program. If not, see . */ +// The same library is compiled with same flags for all gvsoc mode (normal, debug and system verilog) +// Force trace support to be able to have them. +#define VP_TRACE_ACTIVE 1 + #include "i2c_helper.hpp" #include #include -//#define I2C_HELPER_DEBUG(...) (fprintf(stderr, "[I2C-HLP] " __VA_ARGS__)) -#define I2C_HELPER_DEBUG(...) - namespace { void null_callback(i2c_operation_e id, i2c_status_e status, int value) { (void) id; (void) status; (void) value; - I2C_HELPER_DEBUG("null callback: id=%d, status=%d, value=%d\n", - id, status, value); + //this->trace.msg(vp::trace::LEVEL_TRACE, "null callback: id=%d, status=%d, value=%d\n", + // id, status, value); } } I2C_helper::I2C_helper(vp::component* parent, vp::i2c_master* itf, - i2c_enqueue_event_fn_t enqueue_event, i2c_cancel_event_fn_t cancel_event) : + i2c_enqueue_event_fn_t enqueue_event, i2c_cancel_event_fn_t cancel_event, + std::string trace_path) : parent(parent), itf(itf), enqueue_event(enqueue_event), @@ -51,28 +53,24 @@ I2C_helper::I2C_helper(vp::component* parent, vp::i2c_master* itf, is_starting(false), is_stopping(false), is_clock_enabled(false), - is_clock_low(false), + clock_value(1), is_driving_scl(false), is_driving_sda(false), cb_master_operation(null_callback), clock_event(parent, this, I2C_helper::st_clock_event_handler), - data_event(parent, this, I2C_helper::st_data_event_handler) + fsm_event(parent, this, I2C_helper::fsm_event_handler) { assert(NULL != this->parent); assert(NULL != this->itf); - I2C_HELPER_DEBUG("Initializing helper interface\n"); -} + parent->traces.new_trace(trace_path + "/i2c_helper", &this->trace, vp::DEBUG); -void I2C_helper::st_data_event_handler(void* __this, vp::clock_event* event) -{ - assert(NULL != __this); - assert(NULL != event); + this->trace.msg(vp::trace::LEVEL_TRACE, "Initializing helper interface\n"); - I2C_HELPER_DEBUG("st_data_event_handler: none\n"); - I2C_helper* _this = (I2C_helper*) __this; - _this->desired_sda = _this->expected_bit_value; - _this->sync_pins(); + this->pending_data_bits = 0; + this->fsm_waiting = false; + this->input_scl = 1; + this->input_sda = 1; } void I2C_helper::st_clock_event_handler(void* __this, vp::clock_event* event) @@ -80,29 +78,70 @@ void I2C_helper::st_clock_event_handler(void* __this, vp::clock_event* event) assert(NULL != __this); assert(NULL != event); - I2C_HELPER_DEBUG("st_clock_event_handler: none\n"); I2C_helper* _this = (I2C_helper*) __this; _this->clock_event_handler(event); } + +void I2C_helper::clock_toggle(void) +{ + if (this->is_clock_enabled) + { + this->clock_value ^= 1; + + this->enqueue_clock_toggle(); + } +} + +void I2C_helper::enqueue_clock_toggle(void) +{ + if (this->is_clock_enabled) + { + if (this->clock_event.is_enqueued()) + { + this->cancel_event(&this->clock_event); + } + + const uint64_t delay = this->clock_value ? this->delay_low_ps : this->delay_high_ps; + this->enqueue_event(&this->clock_event, delay); + } +} + + +void I2C_helper::fsm_enqueue_event(int64_t delay) +{ + if (!this->fsm_event.is_enqueued()) + { + this->enqueue_event(&this->fsm_event, delay); + } +} + + +void I2C_helper::fsm_event_handler(void *__this, vp::clock_event* event) +{ + I2C_helper* _this = (I2C_helper *) __this; + + _this->fsm_waiting = false; + _this->fsm_step(); +} + + void I2C_helper::clock_event_handler(vp::clock_event* event) { assert(NULL != event); - I2C_HELPER_DEBUG("clock_event_handler: none\n"); /* clock toggling */ if (this->is_clock_enabled) { - if (this->is_clock_low) + this->trace.msg(vp::trace::LEVEL_TRACE, "Toggling clock (value: %d)\n", this->clock_value); + if (this->clock_value) { - I2C_HELPER_DEBUG("clock_event_handler: LOW (switch to high)\n"); /* switch to high */ this->desired_scl = 1; this->sync_pins(); } else { - I2C_HELPER_DEBUG("clock_event_handler: HIGH (switch to low)\n"); /* switch to low */ this->desired_scl = 0; this->sync_pins(); @@ -112,29 +151,23 @@ void I2C_helper::clock_event_handler(vp::clock_event* event) void I2C_helper::register_callback(i2c_callback_t callback) { - I2C_HELPER_DEBUG("register_callback: none\n"); + this->trace.msg(vp::trace::LEVEL_TRACE, "register_callback: none\n"); this->cb_master_operation = callback; } -void I2C_helper::update_pins(int scl, int sda) -{ - this->fsm_step(scl, sda); -} - - void I2C_helper::sync_pins(void) { - int res_scl = this->is_driving_scl ? this->desired_scl : 1; - int res_sda = this->is_driving_sda ? this->desired_sda : 1; + int res_scl = this->internal_state != I2C_INTERNAL_IDLE ? this->desired_scl : 1; + int res_sda = this->internal_state != I2C_INTERNAL_IDLE ? this->desired_sda : 1; - I2C_HELPER_DEBUG("sync_pins: scl=%d, sda=%d\n", res_scl, res_sda); + this->trace.msg(vp::trace::LEVEL_TRACE, "Synchronizing pins (scl:%d, sda:%d)\n", res_scl, res_sda); this->itf->sync(res_scl, res_sda); } void I2C_helper::set_timings(uint64_t delay_low_ps, uint64_t delay_high_ps) { - I2C_HELPER_DEBUG("set_timings: delay_low_ps=%ld, delay_high_ps=%ld\n", + this->trace.msg(vp::trace::LEVEL_TRACE, "set_timings: delay_low_ps=%ld, delay_high_ps=%ld\n", delay_low_ps, delay_high_ps); this->delay_low_ps = delay_low_ps; @@ -143,35 +176,28 @@ void I2C_helper::set_timings(uint64_t delay_low_ps, uint64_t delay_high_ps) void I2C_helper::send_start(void) { - I2C_HELPER_DEBUG("send_start: none\n"); - if (!this->is_busy()) - { - I2C_HELPER_DEBUG("send_start: sda=%d, scl=%d\n", this->sda, this->scl); - I2C_HELPER_DEBUG("send_start: this=%p\n", (void*) this); - this->is_driving_scl = true; - this->is_driving_sda = true; - this->desired_scl = 1; - this->desired_sda = 0; - this->sync_pins(); - this->start_clock(); - } - else - { - this->is_starting = true; - } + this->trace.msg(vp::trace::LEVEL_TRACE, "Request to send start\n"); + + this->is_starting = true; + this->fsm_enqueue_event(1); +} + +void I2C_helper::release_pins(void) +{ + } -bool I2C_helper::is_busy(void) +void I2C_helper::update_pins(int scl, int sda) { - return (this->internal_state != I2C_INTERNAL_IDLE); + this->input_scl = scl; + this->input_sda = sda; + this->fsm_enqueue_event(1); } void I2C_helper::send_address(int addr, bool is_write, bool is_10bits) { - I2C_HELPER_DEBUG("send_address: addr=%d, is_write=%s, is_10bits=%s\n", - addr, - is_write ? "true" : "false", - is_10bits ? "true" : "false"); + this->trace.msg(vp::trace::LEVEL_TRACE, "Request to send address (addr: 0x%x, is_write:%d, is_10bits:%d)\n", + addr, is_write, is_10bits); //TODO support 10 bits mode assert(!is_10bits); @@ -180,337 +206,274 @@ void I2C_helper::send_address(int addr, bool is_write, bool is_10bits) this->send_data(addr_byte); } +void I2C_helper::send_ack(bool ack) +{ + // I2C_HELPER_DEBUG("send_ack: ack=%s\n", ack ? "true" : "false"); + // //TODO + // this->expected_bit_value = ack ? 0 : 1; + // this->is_driving_sda = 1; + // this->enqueue_data_change(this->expected_bit_value); +} + void I2C_helper::send_data(int byte) { - I2C_HELPER_DEBUG("send_data: byte=%d\n", byte); - // TODO verify that we are in data mode ? + this->trace.msg(vp::trace::LEVEL_TRACE, "Request to send data (value: 0x%x)\n", byte); - /* load byte in sending queue */ - for (int i = 7; i >= 0; i--) + if (this->pending_data_bits) { - int bit = (byte >> i) & 1; - I2C_HELPER_DEBUG("push to send bit queue:%d\n", bit); - this->send_bit_queue.push(bit); + this->trace.force_warning("Trying to send data while there is already one pending\n"); } - - /* enqueue data change if clock is low, - * else will be done automatically at next falling scl */ - if (this->is_clock_low && this->internal_state == I2C_INTERNAL_DATA) + else { - I2C_HELPER_DEBUG("Directly enqueueing!\n"); - this->expected_bit_value = this->send_bit_queue.front(); - this->send_bit_queue.pop(); - this->is_driving_sda = true; - this->enqueue_data_change(this->expected_bit_value); + this->pending_data = byte; + this->pending_data_bits = 8; + this->fsm_enqueue_event(1); } } -void I2C_helper::send_ack(bool ack) -{ - I2C_HELPER_DEBUG("send_ack: ack=%s\n", ack ? "true" : "false"); - //TODO - this->expected_bit_value = ack ? 0 : 1; - this->is_driving_sda = 1; - this->enqueue_data_change(this->expected_bit_value); -} - void I2C_helper::send_stop(void) { - I2C_HELPER_DEBUG("send_stop: none\n"); - if(this->is_busy()) - { - this->is_stopping = true; - this->is_driving_sda = true; - this->expected_bit_value = 0; - this->enqueue_data_change(this->expected_bit_value); - } -} - -void I2C_helper::release_pins(void) -{ - // release everything that could hold the bus - this->empty_queues(); - this->stop_clock(); + this->trace.msg(vp::trace::LEVEL_TRACE, "Request to stop\n"); + this->is_stopping = true; } void I2C_helper::start_clock(void) { - I2C_HELPER_DEBUG("Starting clock\n"); + this->trace.msg(vp::trace::LEVEL_TRACE, "Starting clock\n"); //start high then loop(low -> high) this->is_clock_enabled = true; - this->is_clock_low = false; + this->clock_value = this->scl ^ 1; this->enqueue_clock_toggle(); } void I2C_helper::stop_clock(void) { - I2C_HELPER_DEBUG("Stop clock\n"); + this->trace.msg(vp::trace::LEVEL_TRACE, "Stopping clock\n"); this->is_clock_enabled =false; this->cancel_event(&this->clock_event); +} + +std::string I2C_helper::get_state_name(i2c_internal_state_e state) +{ + switch (state) + { + case I2C_INTERNAL_IDLE: return "idle"; + case I2C_INTERNAL_WAIT_START: return "wait_start"; + case I2C_INTERNAL_WAIT_STOP: return "wait_stop"; + case I2C_INTERNAL_START: return "start"; + case I2C_INTERNAL_WAIT_DATA: return "wait_data"; + case I2C_INTERNAL_DATA: return "data"; + case I2C_INTERNAL_DATA_READ: return "data_read"; + case I2C_INTERNAL_ACK: return "ack"; + case I2C_INTERNAL_STOP_CLOCK: return "stop_clock"; + case I2C_INTERNAL_STOP_CLOCK_WAIT: return "stop_clock_wait"; + case I2C_INTERNAL_RESTART: return "restart"; + case I2C_INTERNAL_STOP_0: return "stop_0"; + case I2C_INTERNAL_STOP_1: return "stop_1"; + default: return "unknown"; + } +} - this->desired_scl = 1; - this->is_driving_scl = false; - this->is_driving_sda = false; - this->enqueue_data_change(1); +void I2C_helper::send_data_bit() +{ + int bit = (this->pending_data >> 7) & 1; + this->trace.msg(vp::trace::LEVEL_TRACE, "Sending bit (bit: %d)\n", bit); + this->desired_sda = bit; + this->pending_data <<= 1; + this->pending_data_bits--; } -void I2C_helper::fsm_step(int input_scl, int input_sda) + +void I2C_helper::fsm_step() { - bool scl_rising = (input_scl == 1 && this->scl == 0); - bool scl_falling = (input_scl == 0 && this->scl == 1); - bool scl_steady = (input_scl == this->scl); + if (this->fsm_waiting) + { + return; + } + + this->trace.msg(vp::trace::LEVEL_TRACE, "FSM update (state: %s, prev_scl: %d, prev_sda: %d, scl: %d, sda: %d)\n", + this->get_state_name(this->internal_state).c_str(), this->scl, this->sda, this->input_scl, this->input_sda); - bool sda_rising = (input_sda == 1 && this->sda == 0); - bool sda_falling = (input_sda == 0 && this->sda == 1); - I2C_HELPER_DEBUG("\n\n\n"); - I2C_HELPER_DEBUG("fsm_step: input_scl=%d, input_sda=%d\n", input_scl, input_sda); - I2C_HELPER_DEBUG("fsm_step: scl=%d, this->scl=%d\n", input_scl, this->scl); - I2C_HELPER_DEBUG("fsm_step: sda=%d, this->sda=%d\n", input_sda, this->sda); - I2C_HELPER_DEBUG("fsm_step: this=%p\n", (void*) this); + bool scl_rising = (this->input_scl == 1 && this->scl == 0); + bool scl_falling = (this->input_scl == 0 && this->scl == 1); + bool scl_steady = (this->input_scl == this->scl); - this->scl = input_scl; - this->sda = input_sda; + bool sda_rising = (this->input_sda == 1 && this->sda == 0); + bool sda_falling = (this->input_sda == 0 && this->sda == 1); + + this->scl = this->input_scl; + this->sda =this-> input_sda; /* clock management */ if (!scl_steady) { - /* manages clock synchronization and clock stretching automatically */ - if (scl_rising) - { - this->is_clock_low = false; - } - else if (scl_falling) - { - this->is_clock_low = true; - } - - if (this->is_clock_enabled) - { - this->enqueue_clock_toggle(); - } + // Renqueue a clock toggle each time it toggles + this->clock_toggle(); } - /* I2C logic */ - if (scl_steady) + switch (this->internal_state) { - /* START/STOP detection */ - if (this->scl == 1) - { - if (sda_falling && !this->is_busy()) + case I2C_INTERNAL_IDLE: + if (is_starting) { + this->trace.msg(vp::trace::LEVEL_TRACE, "Waiting start\n"); + this->internal_state = I2C_INTERNAL_WAIT_START; this->is_starting = false; + this->desired_sda = 0; + this->desired_scl = 1; } - else if (sda_rising && this->is_busy()) + break; + + case I2C_INTERNAL_WAIT_START: + if (scl_steady && sda_falling) { - this->internal_state = I2C_INTERNAL_IDLE; - this->is_stopping = false; - /* stop clock */ - this->stop_clock(); - this->empty_queues(); + this->trace.msg(vp::trace::LEVEL_TRACE, "Detected start, waiting for data\n"); + this->internal_state = I2C_INTERNAL_WAIT_DATA; + this->cb_master_operation(I2C_OP_START, I2C_STATUS_OK, 0); + } + break; - I2C_HELPER_DEBUG("STOP DETECTED\n"); + case I2C_INTERNAL_WAIT_STOP: + if (scl_steady && sda_rising) + { + this->trace.msg(vp::trace::LEVEL_TRACE, "Detected stop\n"); + this->internal_state = I2C_INTERNAL_IDLE; this->cb_master_operation(I2C_OP_STOP, I2C_STATUS_OK, 0); } - } - } - else if (!this->is_busy() && scl_falling && this->sda == 0) - { - /* propagate start condition */ - this->internal_state = I2C_INTERNAL_START; + break; - this->sda_rise = this ->sda; - this->empty_queues(); - I2C_HELPER_DEBUG("START DETECTED\n"); - this->cb_master_operation(I2C_OP_START, I2C_STATUS_OK, 0); - } - else if (this->is_busy()) - { - /* sampling bit*/ - if (scl_rising) + case I2C_INTERNAL_WAIT_DATA: + if (this->pending_data_bits) + { + this->trace.msg(vp::trace::LEVEL_TRACE, "Detected data, starting clock\n"); + this->internal_state = I2C_INTERNAL_DATA; + } + this->start_clock(); + break; + + case I2C_INTERNAL_DATA: { - I2C_HELPER_DEBUG("SCL rising\n"); - I2C_HELPER_DEBUG("fsm_step: sampling rising bit\n"); - this->sda_rise = this->sda; - //TODO add check expected_bit_value - if (is_stopping) + if (scl_falling) { - this->is_driving_sda = true; - this->expected_bit_value = 1; - this->enqueue_data_change(this->expected_bit_value); + this->send_data_bit(); } - else if (is_starting) + else if (scl_rising) { - /* drive sda pin down */ - this->is_driving_sda = true; - this->expected_bit_value = 0; - this->enqueue_data_change(this->expected_bit_value); + if (this->pending_data_bits == 0) + { + this->internal_state = I2C_INTERNAL_ACK; + } } + break; + } - if (this->is_driving_sda && this->desired_sda != this->sda && this->desired_sda != 0) + case I2C_INTERNAL_DATA_READ: + { + if (scl_rising) { - // we lost arbitration - i2c_operation_e operation = I2C_OP_DATA; + this->pending_data = (this->pending_data << 1) | this->sda; + this->trace.msg(vp::trace::LEVEL_TRACE, "Sampled data (bit: %d, pending_value: 0x%x, pending_bits: %d)\n", this->sda, this->pending_data, this->pending_data_bits); + this->pending_data_bits--; - if (this->is_stopping) - { - operation = I2C_OP_STOP; - } - else if (this->internal_state == I2C_INTERNAL_DATA) + if (this->pending_data_bits == 0) { - operation = I2C_OP_DATA; - } - else if (this->internal_state == I2C_INTERNAL_ACK) - { - operation = I2C_OP_ACK; + this->cb_master_operation(I2C_OP_DATA, I2C_STATUS_OK, this->pending_data); + this->internal_state = I2C_INTERNAL_ACK; } - - this->cb_master_operation( - operation, - I2C_STATUS_ERROR_ARBITRATION, - 0); } + break; } - else if (scl_falling) + + case I2C_INTERNAL_ACK: { - I2C_HELPER_DEBUG("SCL falling\n"); - I2C_HELPER_DEBUG("INTERNAL_STATE = %d\n", this->internal_state); - if (this->internal_state != I2C_INTERNAL_START) + if (scl_rising) { - if (this->sda_rise == this->sda) - { - this->recv_bit_queue.push(this->sda); - } - else - { - //TODO framing error ? - //TODO empty queue - I2C_HELPER_DEBUG("FRAMING ERROR!, sda_rise=%d, sda=%d\n", this->sda_rise, this->sda); - this->cb_master_operation(I2C_OP_STOP, I2C_STATUS_ERROR_FRAMING, 0); - } + int ack = this->sda; + + this->trace.msg(vp::trace::LEVEL_TRACE, "Sampled ack (value: %d)\n", ack); + const i2c_status_e status = (ack == 1) ? I2C_STATUS_KO : I2C_STATUS_OK; + this->cb_master_operation(I2C_OP_ACK, status, 0); + this->internal_state = I2C_INTERNAL_STOP_CLOCK; } - else + break; + } + + case I2C_INTERNAL_STOP_CLOCK: + { + if (scl_falling) { - this->internal_state = I2C_INTERNAL_DATA; + this->desired_sda = 1; + this->stop_clock(); + this->internal_state = I2C_INTERNAL_STOP_CLOCK_WAIT; + this->fsm_waiting = true; + this->fsm_enqueue_event(this->delay_high_ps); } + break; + } - if (is_stopping) + case I2C_INTERNAL_STOP_CLOCK_WAIT: + { + if (this->pending_data_bits) { - this->is_driving_sda = true; - this->expected_bit_value = 0; - this->enqueue_data_change(this->expected_bit_value); + // We must continue immediately with another byte of data + // Send a bit now since there is no falling edge and let the usual + // state continue + this->send_data_bit(); + this->start_clock(); + this->internal_state = I2C_INTERNAL_DATA; + } - else if (is_starting) + else if (this->is_starting) { - this->is_driving_sda = true; - this->expected_bit_value = 1; - this->enqueue_data_change(this->expected_bit_value); + this->internal_state = I2C_INTERNAL_RESTART; + this->is_starting = false; + this->desired_scl = 1; + this->fsm_waiting = true; + this->fsm_enqueue_event(this->delay_high_ps); } - else if (this->internal_state == I2C_INTERNAL_DATA) + else if (this->is_stopping) { - /* send data */ - if (!this->send_bit_queue.empty()) - { - assert(this->send_bit_queue.size() <= 8); - - int bit = this->send_bit_queue.front(); - this->send_bit_queue.pop(); - this->expected_bit_value = bit; - - this->is_driving_sda = true; - this->enqueue_data_change(this->expected_bit_value); - } - else - { - /* release sda pin */ - this->is_driving_sda = false; - this->enqueue_data_change(this->expected_bit_value); - } - - /* receiving data */ - if (this->recv_bit_queue.size() == 8) - { - int byte = 0; - /* full byte received */ - for (int i = 0; i < 8; i++) - { - int bit = this->recv_bit_queue.front(); - this->recv_bit_queue.pop(); - byte = byte << 1 | bit; - } - assert(this->recv_bit_queue.empty()); - - I2C_HELPER_DEBUG("fsm_step: byte received=%d\n", byte); - - this->internal_state = I2C_INTERNAL_ACK; - this->empty_queues(); - - this->cb_master_operation(I2C_OP_DATA, I2C_STATUS_OK, byte); - } + this->internal_state = I2C_INTERNAL_STOP_0; + this->is_stopping = false; + this->desired_sda = 0; + this->fsm_waiting = true; + this->fsm_enqueue_event(this->delay_high_ps); } - else if (this->internal_state == I2C_INTERNAL_ACK) + else { - if (this->recv_bit_queue.size() == 1) - { - const int bit = this->recv_bit_queue.front(); - this->recv_bit_queue.pop(); - - I2C_HELPER_DEBUG("fsm_step: ACK received=%d\n", bit); - - const i2c_status_e status = (bit == 1) ? I2C_STATUS_KO : I2C_STATUS_OK; - assert(this->recv_bit_queue.empty()); - - this->internal_state = I2C_INTERNAL_DATA; - this->empty_queues(); - - /* release sda pin */ - this->is_driving_sda = false; - this->expected_bit_value = 1; - this->enqueue_data_change(this->expected_bit_value); - - this->cb_master_operation(I2C_OP_ACK, status, 0); - - } + this->start_clock(); + this->pending_data_bits = 8; + this->internal_state = I2C_INTERNAL_DATA_READ; } + break; } - } -} -void I2C_helper::enqueue_clock_toggle(void) -{ - I2C_HELPER_DEBUG("enqueue_clock_toggle: clock_low=%s\n", - this->is_clock_low ? "true" : "false"); - if (this->is_clock_enabled) - { - if (this->clock_event.is_enqueued()) + case I2C_INTERNAL_STOP_0: { - this->cancel_event(&this->clock_event); + this->internal_state = I2C_INTERNAL_STOP_1; + this->desired_scl = 1; + this->fsm_waiting = true; + this->fsm_enqueue_event(this->delay_high_ps); + break; } - const uint64_t delay = this->is_clock_low ? this->delay_low_ps : this->delay_high_ps; - this->enqueue_event(&this->clock_event, delay); - } -} - -void I2C_helper::enqueue_data_change(int new_sda) -{ - I2C_HELPER_DEBUG("enqueue_data_change: %d\n", new_sda); - if (!this->data_event.is_enqueued()) - { - this->enqueue_event(&this->data_event, 1); - } -} + case I2C_INTERNAL_STOP_1: + { + this->internal_state = I2C_INTERNAL_WAIT_STOP; + this->desired_sda = 1; + break; + } -void I2C_helper::empty_queues(void) -{ - while(!this->send_bit_queue.empty()) - { - this->send_bit_queue.pop(); + case I2C_INTERNAL_RESTART: + { + this->trace.msg(vp::trace::LEVEL_TRACE, "Waiting start\n"); + this->internal_state = I2C_INTERNAL_WAIT_START; + this->desired_sda = 0; + break; + } } - while(!this->recv_bit_queue.empty()) - { - this->recv_bit_queue.pop(); - } + this->sync_pins(); } diff --git a/gvsoc/gvsoc/models/devices/i2c/helper/i2c_helper.hpp b/gvsoc/gvsoc/models/devices/i2c/helper/i2c_helper.hpp index a9e863471..cb8289c98 100644 --- a/gvsoc/gvsoc/models/devices/i2c/helper/i2c_helper.hpp +++ b/gvsoc/gvsoc/models/devices/i2c/helper/i2c_helper.hpp @@ -41,9 +41,18 @@ typedef enum { typedef enum { I2C_INTERNAL_IDLE, + I2C_INTERNAL_WAIT_START, + I2C_INTERNAL_WAIT_STOP, I2C_INTERNAL_START, + I2C_INTERNAL_WAIT_DATA, I2C_INTERNAL_DATA, + I2C_INTERNAL_DATA_READ, I2C_INTERNAL_ACK, + I2C_INTERNAL_STOP_CLOCK, + I2C_INTERNAL_STOP_CLOCK_WAIT, + I2C_INTERNAL_RESTART, + I2C_INTERNAL_STOP_0, + I2C_INTERNAL_STOP_1, } i2c_internal_state_e; typedef std::function i2c_callback_t; @@ -66,7 +75,7 @@ typedef std::function i2c_cancel_event_fn_t; */ class I2C_helper { public: - I2C_helper(vp::component* parent, vp::i2c_master* itf, i2c_enqueue_event_fn_t event, i2c_cancel_event_fn_t cancel_event); + I2C_helper(vp::component* parent, vp::i2c_master* itf, i2c_enqueue_event_fn_t event, i2c_cancel_event_fn_t cancel_event, std::string trace_path=""); // TO be called when pin values change void update_pins(int scl, int sda); @@ -106,7 +115,7 @@ class I2C_helper { /******************/ /* Static methods */ /******************/ - static void st_data_event_handler(void* __this, vp::clock_event* event); + static void fsm_event_handler(void* __this, vp::clock_event* event); static void st_clock_event_handler(void* __this, vp::clock_event* event); static void i2c_sync(void *__this, int scl, int sda); @@ -117,13 +126,17 @@ class I2C_helper { void start_clock(void); void stop_clock(void); + void clock_toggle(void); void enqueue_clock_toggle(void); void enqueue_data_change(int new_sda); + void fsm_enqueue_event(int64_t delay); + void send_data_bit(); - void fsm_step(int scl, int sda); + void fsm_step(); void sync_pins(void); - void empty_queues(void); + + std::string get_state_name(i2c_internal_state_e state); /*************/ /* Externals */ @@ -149,7 +162,7 @@ class I2C_helper { /* Runtime data */ /****************/ vp::clock_event clock_event; - vp::clock_event data_event; + vp::clock_event fsm_event; i2c_internal_state_e internal_state; @@ -164,8 +177,6 @@ class I2C_helper { int sda_rise; /* sda sampled on scl rising edge */ - std::queue send_bit_queue; - std::queue recv_bit_queue; int expected_bit_value; /* checked when scl is rising */ bool check_sent; @@ -175,5 +186,16 @@ class I2C_helper { bool is_starting; bool is_clock_enabled; - bool is_clock_low; /* tell if clock is in low or high state */ + int clock_value; + + vp::trace trace; + + int ack_value; + + uint8_t pending_data; + int pending_data_bits; + bool fsm_waiting; + + int input_scl; + int input_sda; }; diff --git a/gvsoc/gvsoc/models/devices/i2c/i2c_bus.cpp b/gvsoc/gvsoc/models/devices/i2c/i2c_bus.cpp index b16036c39..81b0da6bd 100644 --- a/gvsoc/gvsoc/models/devices/i2c/i2c_bus.cpp +++ b/gvsoc/gvsoc/models/devices/i2c/i2c_bus.cpp @@ -46,6 +46,9 @@ class I2c_bus : public vp::component vp::reg_1 bus_scl; vp::reg_1 bus_sda; + + bool pending_resolve; + bool do_resolve; }; @@ -68,6 +71,8 @@ int I2c_bus::build() this->bus_scl.set(1); this->bus_sda.set(1); + this->pending_resolve = false; + return 0; } @@ -76,42 +81,61 @@ void I2c_bus::sync(void *__this, int scl, int sda, int id) { I2c_bus *_this = (I2c_bus *)__this; - _this->trace.msg(vp::trace::LEVEL_TRACE, " => bus update [id=%d]: scl=%d, sda=%d\n", + _this->trace.msg(vp::trace::LEVEL_TRACE, " => bus sync [id=%d]: scl=%d, sda=%d\n", id, scl, sda); /* store incoming values in maps */ _this->i2c_values[id].scl = scl; _this->i2c_values[id].sda = sda; - /* browse all values and compute resulting SCL and SDA */ - int res_scl_value = 1; - int res_sda_value = 1; + _this->do_resolve = true; + + if (_this->pending_resolve) + { + return; + } + + _this->trace.msg(vp::trace::LEVEL_TRACE, " => bus update\n"); - for (std::pair i2c_val : _this->i2c_values) + _this->pending_resolve = true; + + while (_this->do_resolve) { - _this->trace.msg(vp::trace::LEVEL_TRACE, "bus values [id=%d]: scl=%d, sda=%d\n", - i2c_val.first, - i2c_val.second.scl, - i2c_val.second.sda); - if (i2c_val.second.scl == 0) + _this->do_resolve = false; + + /* browse all values and compute resulting SCL and SDA */ + int res_scl_value = 1; + int res_sda_value = 1; + + for (std::pair i2c_val : _this->i2c_values) { - res_scl_value = 0; + _this->trace.msg(vp::trace::LEVEL_TRACE, "bus values [id=%d]: scl=%d, sda=%d\n", + i2c_val.first, + i2c_val.second.scl, + i2c_val.second.sda); + if (i2c_val.second.scl == 0) + { + res_scl_value = 0; + } + if (i2c_val.second.sda == 0) + { + res_sda_value = 0; + } } - if (i2c_val.second.sda == 0) + + /* broadcast the values to all peripherals if needed */ + if (res_scl_value != _this->bus_scl.get() || res_sda_value != _this->bus_sda.get()) { - res_sda_value = 0; + /* only propagate changes */ + _this->bus_scl.set(res_scl_value); + _this->bus_sda.set(res_sda_value); + _this->trace.msg(vp::trace::LEVEL_TRACE, "I2C: scl=%d, sda=%d\n", + _this->bus_scl.get(), _this->bus_sda.get()); + _this->in.sync(res_scl_value, res_sda_value); } } - /* broadcast the values to all peripherals if needed */ - if (res_scl_value != _this->bus_scl.get() || res_sda_value != _this->bus_sda.get()) - { - /* only propagate changes */ - _this->bus_scl.set(res_scl_value); - _this->bus_sda.set(res_sda_value); - _this->trace.msg(vp::trace::LEVEL_TRACE, "I2C: scl=%d, sda=%d\n", - _this->bus_scl.get(), _this->bus_sda.get()); - _this->in.sync(res_scl_value, res_sda_value); - } + _this->pending_resolve = false; + _this->trace.msg(vp::trace::LEVEL_TRACE, " => bus update done[id=%d]\n", id); } diff --git a/gvsoc/gvsoc/models/devices/sound/CMakeLists.txt b/gvsoc/gvsoc/models/devices/sound/CMakeLists.txt index fead9b06a..47da2a0d4 100644 --- a/gvsoc/gvsoc/models/devices/sound/CMakeLists.txt +++ b/gvsoc/gvsoc/models/devices/sound/CMakeLists.txt @@ -1,3 +1,4 @@ +add_subdirectory(dac) set(SOUND_PREFIX "devices/sound") diff --git a/gvsoc/gvsoc/models/devices/sound/dac/CMakeLists.txt b/gvsoc/gvsoc/models/devices/sound/dac/CMakeLists.txt new file mode 100644 index 000000000..7eb9285ee --- /dev/null +++ b/gvsoc/gvsoc/models/devices/sound/dac/CMakeLists.txt @@ -0,0 +1,6 @@ + +set(DAC_PREFIX "devices/sound/dac") + +vp_model(NAME ak4332 + PREFIX ${DAC_PREFIX} + SOURCES "ak4332.cpp") diff --git a/gvsoc/gvsoc/models/devices/sound/dac/ak4332.cpp b/gvsoc/gvsoc/models/devices/sound/dac/ak4332.cpp new file mode 100644 index 000000000..5cff4d467 --- /dev/null +++ b/gvsoc/gvsoc/models/devices/sound/dac/ak4332.cpp @@ -0,0 +1,638 @@ +/* + * Copyright (C) 2020 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Authors: Germain Haugou, GreenWaves Technologies (germain.haugou@greenwaves-technologies.com) + */ + + +#include +#include + + + +typedef enum +{ + I2C_STATE_WAIT_START, + I2C_STATE_WAIT_ADDRESS, + I2C_STATE_GET_DATA, + I2C_STATE_SAMPLE_DATA, + I2C_STATE_ACK, + I2C_STATE_READ_ACK +} I2c_state_e; + + +class Ak4332 : public vp::component +{ +public: + Ak4332(js::config *config); + + int build(); + +protected: + static void i2c_sync(void *__this, int scl, int sda); + void i2c_start(unsigned int address, bool is_read); + void i2c_handle_byte(uint8_t byte); + void i2c_stop(); + void i2c_get_data(); + void i2c_send_byte(uint8_t byte); + + void handle_reg_write(uint8_t address, uint8_t value); + uint8_t handle_reg_read(uint8_t address); + + void start(); + + vp::trace trace; + vp::i2c_master i2c_itf; + + unsigned int device_address; + + bool i2c_being_addressed; + unsigned int i2c_address; + uint8_t i2c_pending_data; + bool i2c_is_read; + I2c_state_e i2c_state; + int i2c_pending_bits; + int i2c_prev_sda; + int i2c_prev_scl; + unsigned int i2c_pending_send_byte; + uint8_t reg_address; + bool waiting_reg_address; + uint8_t power_1; + uint8_t power_2; + uint8_t power_3; + uint8_t power_4; + uint8_t output_mode; + uint8_t clock_mode; + uint8_t digital_filter; + uint8_t dac_mono_mixing; + uint8_t pdm_control; + uint8_t dac_volume_control; + uint8_t hp_volume_control; + uint8_t pll_clk_selection; + uint8_t pll_ref_clk_div_1; + uint8_t pll_ref_clk_div_2; + uint8_t pll_fb_clk_div_1; + uint8_t pll_fb_clk_div_2; + uint8_t dac_clk_source; + uint8_t dac_clk_divider; + uint8_t audio_format; + uint8_t pdm_err; + uint8_t dac_adjustment_1; + uint8_t dac_adjustment_2; +}; + + +Ak4332::Ak4332(js::config *config) + : vp::component(config) +{ +} + + +void Ak4332::start() +{ + this->i2c_itf.sync(1, 1); +} + + +void Ak4332::i2c_sync(void *__this, int scl, int sda) +{ + Ak4332 *_this = (Ak4332 *)__this; + + _this->trace.msg(vp::trace::LEVEL_TRACE, "I2C sync (scl: %d, sda: %d)\n", scl, sda); + + int sdo = 1; + + if (scl == 1 && _this->i2c_prev_sda != sda) + { + if (_this->i2c_prev_sda == 1) + { + _this->trace.msg(vp::trace::LEVEL_TRACE, "Detected start\n"); + + _this->i2c_state = I2C_STATE_WAIT_ADDRESS; + _this->i2c_address = 0; + _this->i2c_pending_bits = 8; + } + else + { + _this->i2c_state = I2C_STATE_WAIT_START; + _this->i2c_stop(); + } + goto end; + } + + if (!_this->i2c_prev_scl && scl) + { + switch (_this->i2c_state) + { + case I2C_STATE_WAIT_START: + { + sdo = 1; + break; + } + + case I2C_STATE_WAIT_ADDRESS: + { + if (_this->i2c_pending_bits > 1) + { + _this->i2c_address = (_this->i2c_address << 1) | sda; + _this->trace.msg(vp::trace::LEVEL_TRACE, "Received address bit (bit: %d, address: 0x%x, pending_bits: %d)\n", sda, _this->i2c_address, _this->i2c_pending_bits); + } + else + { + _this->i2c_is_read = sda; + } + _this->i2c_pending_bits--; + if (_this->i2c_pending_bits == 0) + { + _this->i2c_start(_this->i2c_address, _this->i2c_is_read); + _this->i2c_state = I2C_STATE_ACK; + _this->i2c_pending_bits = 8; + } + break; + } + + case I2C_STATE_SAMPLE_DATA: + { + _this->i2c_pending_data = (_this->i2c_pending_data << 1) | sda; + _this->trace.msg(vp::trace::LEVEL_TRACE, "Sampling data (bit: %d, pending_value: 0x%x, pending_bits: %d)\n", sda, _this->i2c_pending_data, _this->i2c_pending_bits); + _this->i2c_pending_bits--; + if (_this->i2c_pending_bits == 0) + { + _this->i2c_pending_bits = 8; + _this->i2c_handle_byte(_this->i2c_pending_data); + _this->i2c_state = I2C_STATE_ACK; + } + break; + } + + case I2C_STATE_ACK: { + _this->trace.msg(vp::trace::LEVEL_TRACE, "Ack (being_addressed: %d)\n", _this->i2c_being_addressed); + if (_this->i2c_being_addressed) + { + if (_this->i2c_is_read) + { + _this->i2c_state = I2C_STATE_GET_DATA; + _this->i2c_pending_bits = 8; + _this->i2c_get_data(); + } + else + { + _this->i2c_state = I2C_STATE_SAMPLE_DATA; + } + } + else + { + _this->i2c_state = I2C_STATE_WAIT_START; + } + + break; + } + + case I2C_STATE_READ_ACK: { + _this->i2c_state = I2C_STATE_WAIT_START; + break; + } + } + } + + if (_this->i2c_prev_scl && !scl) + { + switch (_this->i2c_state) + { + case I2C_STATE_ACK: + { + _this->trace.msg(vp::trace::LEVEL_TRACE, "Ack (being_addressed: %d)\n", _this->i2c_being_addressed); + sdo = !_this->i2c_being_addressed; + break; + } + + case I2C_STATE_READ_ACK: + { + _this->trace.msg(vp::trace::LEVEL_TRACE, "Read ack\n"); + sdo = 0; + break; + } + + case I2C_STATE_GET_DATA: + { + sdo = (_this->i2c_pending_send_byte >> 7) & 1; + _this->trace.msg(vp::trace::LEVEL_TRACE, "Sending bit (bit: %d, pending_value: 0x%x, pending_bits: %d)\n", sdo, _this->i2c_pending_send_byte, _this->i2c_pending_bits); + _this->i2c_pending_send_byte <<= 1; + _this->i2c_pending_bits--; + if (_this->i2c_pending_bits == 0) + { + _this->i2c_state = I2C_STATE_READ_ACK; + } + break; + } + } + } + +end: + if (_this->i2c_prev_scl && !scl) + { + _this->trace.msg(vp::trace::LEVEL_TRACE, "Sync sda (value: %d)\n", sdo); + _this->i2c_itf.sync(1, sdo); + } + _this->i2c_prev_sda = sda; + _this->i2c_prev_scl = scl; +} + +void Ak4332::i2c_start(unsigned int address, bool is_read) +{ + this->trace.msg(vp::trace::LEVEL_TRACE, "Received header (address: 0x%x, is_read: %d)\n", address, is_read); + + this->i2c_being_addressed = address == this->device_address; + if (is_read) + { + this->i2c_send_byte(this->handle_reg_read(this->reg_address)); + } +} + +void Ak4332::i2c_handle_byte(uint8_t byte) +{ + this->trace.msg(vp::trace::LEVEL_TRACE, "Handle byte (value: 0x%x)\n", byte); + + if (this->waiting_reg_address) + { + this->reg_address = byte; + this->waiting_reg_address = false; + } + else + { + this->handle_reg_write(this->reg_address, byte); + this->waiting_reg_address = true; + } +} + +void Ak4332::i2c_stop() +{ + this->trace.msg(vp::trace::LEVEL_TRACE, "Received stop bit\n"); + +} + +void Ak4332::i2c_get_data() +{ + this->trace.msg(vp::trace::LEVEL_TRACE, "Getting data\n"); +} + +void Ak4332::i2c_send_byte(uint8_t byte) +{ + this->i2c_pending_send_byte = byte; +} + + +void Ak4332::handle_reg_write(uint8_t address, uint8_t value) +{ + this->trace.msg(vp::trace::LEVEL_TRACE, "Register write (address: 0x%x, value: 0x%x)\n", address, value); + + switch (address) + { + case 0x00: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Power Management 1", value); + this->power_1 = value; + break; + } + case 0x01: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Power Management 2", value); + this->power_2 = value; + break; + } + case 0x02: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Power Management 3", value); + this->power_3 = value; + break; + } + case 0x03: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Power Management 4", value); + this->power_4 = value; + break; + } + case 0x04: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Output Mode Setting", value); + this->output_mode = value; + break; + } + case 0x05: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Clock Mode Selection", value); + this->clock_mode = value; + break; + } + case 0x06: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Digital Filter Selection", value); + this->digital_filter = value; + break; + } + case 0x07: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "DAC Mono Mixing", value); + this->dac_mono_mixing = value; + break; + } + case 0x08: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "PDM I/F Control", value); + this->pdm_control = value; + break; + } + case 0x0B: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "DAC Output Volume", value); + this->dac_volume_control = value; + break; + } + case 0x0D: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "HP Volume Control", value); + this->hp_volume_control = value; + break; + } + case 0x0E: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "PLL CLK Source Selection", value); + this->pll_clk_selection = value; + break; + } + case 0x0F: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "PLL Ref CLK Divider 1", value); + this->pll_ref_clk_div_1 = value; + break; + } + case 0x10: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "PLL Ref CLK Divider 2", value); + this->pll_ref_clk_div_2 = value; + break; + } + case 0x11: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "PLL FB CLK Divider 1", value); + this->pll_fb_clk_div_1 = value; + break; + } + case 0x12: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "PLL FB CLK Divider 2", value); + this->pll_fb_clk_div_2 = value; + break; + } + case 0x13: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "DAC CLK Source", value); + this->dac_clk_source = value; + break; + } + case 0x14: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "DAC CLK Divider", value); + this->dac_clk_divider = value; + break; + } + case 0x15: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "Audio I/F Format", value); + this->audio_format = value; + break; + } + case 0x17: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "PDMERR", value); + this->pdm_err = value; + break; + } + case 0x26: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "DAC Adjustment 1", value); + this->dac_adjustment_1 = value; + break; + } + case 0x27: + { + this->trace.msg(vp::trace::LEVEL_INFO, "Writing register (name: %s, value: 0x%x)\n", "DAC Adjustment 2", value); + this->dac_adjustment_2 = value; + break; + } + default: + this->trace.force_warning("Writing invalid register (address: 0x%x)\n", address); + break; + } + +} + + +uint8_t Ak4332::handle_reg_read(uint8_t address) +{ + this->trace.msg(vp::trace::LEVEL_DEBUG, "Register read (address: 0x%x)\n", address); + + uint8_t value = 0xFF; + + switch (address) + { + case 0x00: + { + value = this->power_1; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Power Management 1", value); + break; + } + case 0x01: + { + value = this->power_2; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Power Management 2", value); + break; + } + case 0x02: + { + value = this->power_3; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Power Management 3", value); + break; + } + case 0x03: + { + value = this->power_4; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Power Management 4", value); + break; + } + case 0x04: + { + value = this->output_mode; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Output Mode Setting", value); + break; + } + case 0x05: + { + value = this->clock_mode; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Clock Mode Selection", value); + break; + } + case 0x06: + { + value = this->digital_filter; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Digital Filter Selection", value); + break; + } + case 0x07: + { + value = this->dac_mono_mixing; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "DAC Mono Mixing", value); + break; + } + case 0x08: + { + value = this->pdm_control; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "PDM I/F Control", value); + break; + } + case 0x0B: + { + value = this->dac_volume_control; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "DAC Output Volume", value); + break; + } + case 0x0D: + { + value = this->hp_volume_control; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "HP Volume Control", value); + break; + } + case 0x0E: + { + value = this->pll_clk_selection; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "PLL CLK Source Selection", value); + break; + } + case 0x0F: + { + value = this->pll_ref_clk_div_1; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "PLL Ref CLK Divider 1", value); + break; + } + case 0x10: + { + value = this->pll_ref_clk_div_2; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "PLL Ref CLK Divider 2", value); + break; + } + case 0x11: + { + value = this->pll_fb_clk_div_1; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "PLL FB CLK Divider 1", value); + break; + } + case 0x12: + { + value = this->pll_fb_clk_div_2; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "PLL FB CLK Divider 2", value); + break; + } + case 0x13: + { + value = this->dac_clk_source; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "DAC CLK Source", value); + break; + } + case 0x14: + { + value = this->dac_clk_divider; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "DAC CLK Divider", value); + break; + } + case 0x15: + { + value = this->audio_format; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "Audio I/F Format", value); + break; + } + case 0x17: + { + value = this->pdm_err; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "PDMERR", value); + break; + } + case 0x26: + { + value = this->dac_adjustment_1; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "DAC Adjustment 1", value); + break; + } + case 0x27: + { + value = this->dac_adjustment_2; + this->trace.msg(vp::trace::LEVEL_INFO, "Reading register (name: %s, value: 0x%x)\n", "DAC Adjustment 2", value); + break; + } + default: + this->trace.force_warning("Reading invalid register (address: 0x%x)\n", address); + break; + } + + return value; +} + + +int Ak4332::build() +{ + traces.new_trace("trace", &trace, vp::DEBUG); + + this->i2c_itf.set_sync_meth(&Ak4332::i2c_sync); + this->new_master_port("i2c", &this->i2c_itf); + + this->i2c_state = I2C_STATE_WAIT_START; + this->i2c_prev_sda = 1; + this->i2c_prev_scl = 1; + this->i2c_being_addressed = false; + this->device_address = 0x10; + this->waiting_reg_address = true; + + this->power_1 = 0x00; + this->power_2 = 0x00; + this->power_3 = 0x00; + this->power_4 = 0x00; + this->output_mode = 0x00; + this->clock_mode = 0x00; + this->digital_filter = 0x00; + this->dac_mono_mixing = 0x00; + this->pdm_control = 0x00; + this->dac_volume_control = 0x19; + this->hp_volume_control = 0x65; + this->pll_clk_selection = 0x00; + this->pll_ref_clk_div_1 = 0x00; + this->pll_ref_clk_div_2 = 0x00; + this->pll_fb_clk_div_1 = 0x00; + this->pll_fb_clk_div_2 = 0x00; + this->dac_clk_source = 0x00; + this->dac_clk_divider = 0x00; + this->audio_format = 0x00; + this->pdm_err = 0x00; + this->dac_adjustment_1 = 0x6C; + this->dac_adjustment_2 = 0x40; + + return 0; +} + + +extern "C" vp::component *vp_constructor(js::config *config) +{ + return new Ak4332(config); +} diff --git a/gvsoc/gvsoc/models/devices/testbench/i2s_verif.cpp b/gvsoc/gvsoc/models/devices/testbench/i2s_verif.cpp index 289acf5a6..8d696e332 100644 --- a/gvsoc/gvsoc/models/devices/testbench/i2s_verif.cpp +++ b/gvsoc/gvsoc/models/devices/testbench/i2s_verif.cpp @@ -74,7 +74,7 @@ class Rx_stream_libsnd_file : public Rx_stream class Rx_stream_raw_file : public Rx_stream { public: - Rx_stream_raw_file(Slot *slot, string filepath, int width, bool is_bin); + Rx_stream_raw_file(Slot *slot, string filepath, int width, bool is_bin, pi_testbench_i2s_verif_start_config_file_encoding_type_e encoding); uint32_t get_sample(int channel_id); Slot *slot; @@ -82,13 +82,14 @@ class Rx_stream_raw_file : public Rx_stream FILE *infile; int width; bool is_bin; + pi_testbench_i2s_verif_start_config_file_encoding_type_e encoding; }; class Tx_stream_raw_file : public Tx_stream { public: - Tx_stream_raw_file(Slot *slot, string filepath, int width, bool is_bin); + Tx_stream_raw_file(Slot *slot, string filepath, int width, bool is_bin, pi_testbench_i2s_verif_start_config_file_encoding_type_e encoding); void push_sample(uint32_t sample, int channel_id); Slot *slot; @@ -96,6 +97,7 @@ class Tx_stream_raw_file : public Tx_stream FILE *outfile; int width; bool is_bin; + pi_testbench_i2s_verif_start_config_file_encoding_type_e encoding; }; @@ -565,10 +567,11 @@ void I2s_verif::start(pi_testbench_i2s_verif_start_config_t *config) } -Tx_stream_raw_file::Tx_stream_raw_file(Slot *slot, std::string filepath, int width, bool is_bin) +Tx_stream_raw_file::Tx_stream_raw_file(Slot *slot, std::string filepath, int width, bool is_bin, pi_testbench_i2s_verif_start_config_file_encoding_type_e encoding) { this->width = width; this->is_bin = is_bin; + this->encoding = encoding; this->slot = slot; this->outfile = fopen(filepath.c_str(), "w"); this->slot->trace.msg(vp::trace::LEVEL_INFO, "Opening dumper (path: %s)\n", filepath.c_str()); @@ -583,6 +586,17 @@ void Tx_stream_raw_file::push_sample(uint32_t sample, int channel_id) { if (this->is_bin) { + if (this->encoding == PI_TESTBENCH_I2S_VERIF_FILE_ENCODING_TYPE_PLUSMINUS) + { + // Convert encoding from 0/1 to -1/+1 + if (sample == 0) + sample = (uint32_t)-1; + else if (sample == 1) + sample = 1; + else + sample = 0; // Error + } + int nb_bytes = (this->width + 7) / 8; if (fwrite((void *)&sample, nb_bytes, 1, this->outfile) != 1) { @@ -666,10 +680,11 @@ void Tx_stream_libsnd_file::push_sample(uint32_t data, int channel) } -Rx_stream_raw_file::Rx_stream_raw_file(Slot *slot, std::string filepath, int width, bool is_bin) +Rx_stream_raw_file::Rx_stream_raw_file(Slot *slot, std::string filepath, int width, bool is_bin, pi_testbench_i2s_verif_start_config_file_encoding_type_e encoding) { this->width = width; this->is_bin = is_bin; + this->encoding = encoding; this->slot = slot; this->infile = fopen(filepath.c_str(), "r"); if (this->infile == NULL) @@ -685,10 +700,26 @@ uint32_t Rx_stream_raw_file::get_sample(int channel_id) { int nb_bytes = (this->width + 7) / 8; uint32_t result = 0; - if (fread((void *)&result, nb_bytes, 1, this->infile) != 1) + int freadres = fread((void *)&result, nb_bytes, 1, this->infile); + + // this->slot->top->trace.msg(vp::trace::LEVEL_TRACE, "channel_id=%d, nb_bytes=%d, freadres=%d, result=%d\n", channel_id, nb_bytes, freadres, result); + + if (freadres != 1) { return 0; } + + if (this->encoding == PI_TESTBENCH_I2S_VERIF_FILE_ENCODING_TYPE_PLUSMINUS) + { + // Convert encoding from -1/+1 to 0/1 + if ((int32_t)result == -1) + result = 0; + else if ((int32_t)result == 1) + result = 1; + else + result = 0; + } + return result; } else @@ -872,7 +903,12 @@ void Slot::start(pi_testbench_i2s_verif_slot_start_config_t *config, Slot *reuse { if (config->tx_file_dumper.type == PI_TESTBENCH_I2S_VERIF_TX_FILE_DUMPER_TYPE_RAW || config->tx_file_dumper.type == PI_TESTBENCH_I2S_VERIF_RX_FILE_READER_TYPE_BIN) { - this->outstream = new Tx_stream_raw_file(this, filepath, config->tx_file_dumper.width, config->tx_file_dumper.type == PI_TESTBENCH_I2S_VERIF_RX_FILE_READER_TYPE_BIN); + this->outstream = new Tx_stream_raw_file( + this, + filepath, + config->tx_file_dumper.width, + config->tx_file_dumper.type == PI_TESTBENCH_I2S_VERIF_RX_FILE_READER_TYPE_BIN, + (pi_testbench_i2s_verif_start_config_file_encoding_type_e)config->tx_file_dumper.encoding); } else { @@ -904,7 +940,12 @@ void Slot::start(pi_testbench_i2s_verif_slot_start_config_t *config, Slot *reuse { if (config->rx_file_reader.type == PI_TESTBENCH_I2S_VERIF_RX_FILE_READER_TYPE_RAW || config->rx_file_reader.type == PI_TESTBENCH_I2S_VERIF_RX_FILE_READER_TYPE_BIN) { - this->instream = new Rx_stream_raw_file(this, filepath, config->rx_file_reader.width, config->rx_file_reader.type == PI_TESTBENCH_I2S_VERIF_RX_FILE_READER_TYPE_BIN); + this->instream = new Rx_stream_raw_file( + this, + filepath, + config->rx_file_reader.width, + config->rx_file_reader.type == PI_TESTBENCH_I2S_VERIF_RX_FILE_READER_TYPE_BIN, + (pi_testbench_i2s_verif_start_config_file_encoding_type_e)config->rx_file_reader.encoding); } else { diff --git a/gvsoc/gvsoc/models/devices/testbench/testbench.cpp b/gvsoc/gvsoc/models/devices/testbench/testbench.cpp index 2975e770d..0d2823038 100644 --- a/gvsoc/gvsoc/models/devices/testbench/testbench.cpp +++ b/gvsoc/gvsoc/models/devices/testbench/testbench.cpp @@ -1353,6 +1353,21 @@ std::string Testbench::handle_command(Gv_proxy *proxy, FILE *req_file, FILE *rep config->rx_file_reader.type = 0; } } + else if (name == "encoding") + { + if (value_str == "asis") + { + config->rx_file_reader.encoding = PI_TESTBENCH_I2S_VERIF_FILE_ENCODING_TYPE_ASIS; + } + else if (value_str == "plusminus") + { + config->rx_file_reader.encoding = PI_TESTBENCH_I2S_VERIF_FILE_ENCODING_TYPE_PLUSMINUS; + } + else + { + config->rx_file_reader.encoding = PI_TESTBENCH_I2S_VERIF_FILE_ENCODING_TYPE_ASIS; + } + } } config->type = PI_TESTBENCH_I2S_VERIF_RX_FILE_READER; @@ -1410,6 +1425,21 @@ std::string Testbench::handle_command(Gv_proxy *proxy, FILE *req_file, FILE *rep config->tx_file_dumper.type = 0; } } + else if (name == "encoding") + { + if (value_str == "asis") + { + config->tx_file_dumper.encoding = PI_TESTBENCH_I2S_VERIF_FILE_ENCODING_TYPE_ASIS; + } + else if (value_str == "plusminus") + { + config->tx_file_dumper.encoding = PI_TESTBENCH_I2S_VERIF_FILE_ENCODING_TYPE_PLUSMINUS; + } + else + { + config->tx_file_dumper.encoding = PI_TESTBENCH_I2S_VERIF_FILE_ENCODING_TYPE_ASIS; + } + } } config->type = PI_TESTBENCH_I2S_VERIF_TX_FILE_DUMPER; diff --git a/gvsoc/gvsoc/models/devices/testbench/testbench.hpp b/gvsoc/gvsoc/models/devices/testbench/testbench.hpp index d5830608f..079f25abd 100644 --- a/gvsoc/gvsoc/models/devices/testbench/testbench.hpp +++ b/gvsoc/gvsoc/models/devices/testbench/testbench.hpp @@ -240,6 +240,11 @@ typedef enum PI_TESTBENCH_I2S_VERIF_TX_FILE_DUMPER_TYPE_AU, } pi_testbench_i2s_verif_start_config_tx_file_dumper_type_e; +typedef enum +{ + PI_TESTBENCH_I2S_VERIF_FILE_ENCODING_TYPE_ASIS = 0, // Keep as is (default) + PI_TESTBENCH_I2S_VERIF_FILE_ENCODING_TYPE_PLUSMINUS, // Assume file contains -1/+1 values (usable for PDM only) +} pi_testbench_i2s_verif_start_config_file_encoding_type_e; // This structure can be used to describe what an I2S slot should do typedef struct @@ -261,6 +266,7 @@ typedef struct uint32_t filepath_len; uint8_t type; uint8_t width; + uint8_t encoding; } tx_file_dumper; struct { @@ -269,6 +275,7 @@ typedef struct uint32_t filepath_len; uint8_t type; uint8_t width; + uint8_t encoding; } rx_file_reader; }; diff --git a/gvsoc/gvsoc/models/memory/memory_impl.cpp b/gvsoc/gvsoc/models/memory/memory_impl.cpp index 4f7b748d2..da3edb540 100644 --- a/gvsoc/gvsoc/models/memory/memory_impl.cpp +++ b/gvsoc/gvsoc/models/memory/memory_impl.cpp @@ -40,7 +40,6 @@ class memory : public vp::component private: - static void power_callback(void *__this, vp::clock_event *event); static void power_ctrl_sync(void *__this, bool value); vp::trace trace; @@ -60,14 +59,13 @@ class memory : public vp::component bool power_trigger; bool powered_up; - vp::power::power_source idle_power; vp::power::power_source read_8_power; vp::power::power_source read_16_power; vp::power::power_source read_32_power; vp::power::power_source write_8_power; vp::power::power_source write_16_power; vp::power::power_source write_32_power; - vp::power::power_source leakage_power; + vp::power::power_source background_power; vp::clock_event *power_event; int64_t last_access_timestamp; @@ -79,15 +77,6 @@ memory::memory(js::config *config) } -void memory::power_callback(void *__this, vp::clock_event *event) -{ - memory *_this = (memory *)__this; - if (_this->last_access_timestamp < _this->get_time()) - { - _this->idle_power.dynamic_power_start(); - } -} - vp::io_req_status_e memory::req(void *__this, vp::io_req *req) { memory *_this = (memory *)__this; @@ -142,9 +131,6 @@ vp::io_req_status_e memory::req(void *__this, vp::io_req *req) else if (size == 4) _this->read_32_power.account_energy_quantum(); } - - if (!_this->power_event->is_enqueued()) - _this->event_enqueue(_this->power_event, 1); } #ifdef VP_TRACE_ACTIVE @@ -223,8 +209,7 @@ int memory::build() js::config *config = get_js_config()->get("power_trigger"); this->power_trigger = config != NULL && config->get_bool(); - power.new_power_source("leakage", &leakage_power, this->get_js_config()->get("**/leakage")); - power.new_power_source("idle", &idle_power, this->get_js_config()->get("**/idle")); + power.new_power_source("leakage", &background_power, this->get_js_config()->get("**/background")); power.new_power_source("read_8", &read_8_power, this->get_js_config()->get("**/read_8")); power.new_power_source("read_16", &read_16_power, this->get_js_config()->get("**/read_16")); power.new_power_source("read_32", &read_32_power, this->get_js_config()->get("**/read_32")); @@ -232,8 +217,6 @@ int memory::build() power.new_power_source("write_16", &write_16_power, this->get_js_config()->get("**/write_16")); power.new_power_source("write_32", &write_32_power, this->get_js_config()->get("**/write_32")); - power_event = this->event_new(memory::power_callback); - return 0; } @@ -287,8 +270,8 @@ void memory::start() } } - this->leakage_power.leakage_power_start(); - this->idle_power.dynamic_power_start(); + this->background_power.leakage_power_start(); + this->background_power.dynamic_power_start(); this->last_access_timestamp = -1; } diff --git a/gvsoc/gvsoc/models/utils/composite_impl.cpp b/gvsoc/gvsoc/models/utils/composite_impl.cpp index 907075e82..d5cf33847 100644 --- a/gvsoc/gvsoc/models/utils/composite_impl.cpp +++ b/gvsoc/gvsoc/models/utils/composite_impl.cpp @@ -37,6 +37,7 @@ class composite : public vp::component int build(); void start(); + void power_supply_set(int state); void dump_traces(FILE *file); @@ -83,6 +84,10 @@ void composite::add_port(std::string name, vp::port *port) this->ports[name] = port; } +void composite::power_supply_set(int state) +{ + //printf("%s power set %d\n", this->get_path().c_str(), state); +} extern "C" vp::component *vp_constructor(js::config *config) diff --git a/gvsoc/gvsoc_gap/models/gap9/CMakeLists.txt b/gvsoc/gvsoc_gap/models/gap9/CMakeLists.txt index 9f4db84d7..693e03c7d 100644 --- a/gvsoc/gvsoc_gap/models/gap9/CMakeLists.txt +++ b/gvsoc/gvsoc_gap/models/gap9/CMakeLists.txt @@ -1 +1,8 @@ add_subdirectory(cpu) + +set(CLUSTER_PREFIX "gap9") + +vp_model(NAME cluster + PREFIX ${CLUSTER_PREFIX} + SOURCES "cluster.cpp" + ) diff --git a/gvsoc/gvsoc_gap/models/gap9/cluster.cpp b/gvsoc/gvsoc_gap/models/gap9/cluster.cpp new file mode 100644 index 000000000..a9da7bf70 --- /dev/null +++ b/gvsoc/gvsoc_gap/models/gap9/cluster.cpp @@ -0,0 +1,232 @@ +/* + * Copyright (C) 2020 GreenWaves Technologies, SAS, ETH Zurich and + * University of Bologna + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Authors: Germain Haugou, GreenWaves Technologies (germain.haugou@greenwaves-technologies.com) + */ + +#include + + + +class cluster : public vp::component +{ + +public: + cluster(js::config *config); + + vp::port *get_slave_port(std::string name) { return this->ports[name]; } + vp::port *get_master_port(std::string name) { return this->ports[name]; } + + void add_slave_port(std::string name, vp::slave_port *port) { this->add_port(name, port); } + void add_master_port(std::string name, vp::master_port *port) { this->add_port(name, port); } + + int build(); + void start(); + void reset(bool active); + void power_supply_set(int state); + + void dump_traces(FILE *file); + + static void cluster_clock_gating_en_sync(void *__this, bool value); + static void timer_busy_sync(void *__this, bool value, int id); + static void ne16_busy_sync(void *__this, bool value); + static void ico_busy_sync(void *__this, bool value); + static void dma_busy_sync(void *__this, bool value); + static void cores_busy_sync(void *__this, bool value, int id); + +private: + void add_port(std::string name, vp::port *port); + std::map ports; + void check_clock_gating(); + + vp::wire_slave cluster_clock_gating_en_itf; + vp::wire_slave timer_busy_itf[2]; + vp::wire_slave ne16_busy_itf; + vp::wire_slave ico_busy_itf; + vp::wire_slave dma_busy_itf; + vp::wire_slave cores_busy_itf[9]; + + int timer_busy; + bool ne16_busy; + bool ico_busy; + bool dma_busy; + int cores_busy; + + bool busy_sync; + + bool clock_gating_en; + + vp::trace trace; + + vp::power::power_source background_power; +}; + + + +cluster::cluster(js::config *config) + : vp::component(config) +{ +} + + +void cluster::dump_traces(FILE *file) +{ + this->power.get_power_trace()->dump(file); +} + + +void cluster::check_clock_gating() +{ + this->trace.msg(vp::trace::LEVEL_DEBUG, "Checking cluster clock gating (timer: 0x%x, ne16: %d, ico: %d, dma: %d, cores: 0x%x)\n", + this->timer_busy, this->ne16_busy, this->ico_busy, this->dma_busy, this->cores_busy); + + bool busy = this->timer_busy || this->ne16_busy || this->ico_busy || this->dma_busy || this->cores_busy; + + if (busy != this->busy_sync) + { + if (this->clock_gating_en && !busy) + { + this->power.power_supply_set_all(2); + } + else + { + this->power.power_supply_set_all(3); + } + this->busy_sync = busy; + } +} + +void cluster::cluster_clock_gating_en_sync(void *__this, bool value) +{ + cluster *_this = (cluster *)__this; + _this->clock_gating_en = value; + _this->check_clock_gating(); +} + +void cluster::timer_busy_sync(void *__this, bool value, int id) +{ + cluster *_this = (cluster *)__this; + _this->timer_busy = (_this->timer_busy & ~(1<check_clock_gating(); +} + +void cluster::ne16_busy_sync(void *__this, bool value) +{ + printf("%d BUSY %d\n", __LINE__, value); + +} + +void cluster::ico_busy_sync(void *__this, bool value) +{ + printf("%d BUSY %d\n", __LINE__, value); + +} + +void cluster::dma_busy_sync(void *__this, bool value) +{ + cluster *_this = (cluster *)__this; + _this->dma_busy = value; + _this->check_clock_gating(); +} + +void cluster::cores_busy_sync(void *__this, bool value, int id) +{ + cluster *_this = (cluster *)__this; + _this->cores_busy = (_this->cores_busy & ~(1<check_clock_gating(); +} + +void cluster::reset(bool active) +{ + if (active) + { + this->busy_sync = false; + this->timer_busy = 0; + this->ne16_busy = 0; + this->ico_busy = 0; + this->dma_busy = 0; + this->cores_busy = 0; + this->clock_gating_en = 0; + } +} + + +int cluster::build() +{ + traces.new_trace("trace", &trace, vp::DEBUG); + + this->cluster_clock_gating_en_itf.set_sync_meth(&cluster::cluster_clock_gating_en_sync); + new_slave_port("cluster_clock_gating_en", &this->cluster_clock_gating_en_itf); + + for (int i=0; i<2; i++) + { + this->timer_busy_itf[i].set_sync_meth_muxed(&cluster::timer_busy_sync, i); + new_slave_port("timer" + std::to_string(i) + "_busy", &this->timer_busy_itf[i]); + } + + this->ne16_busy_itf.set_sync_meth(&cluster::ne16_busy_sync); + new_slave_port("ne16_busy", &this->ne16_busy_itf); + + this->ico_busy_itf.set_sync_meth(&cluster::ico_busy_sync); + new_slave_port("ico_busy", &this->ico_busy_itf); + + this->dma_busy_itf.set_sync_meth(&cluster::dma_busy_sync); + new_slave_port("dma_busy", &this->dma_busy_itf); + + for (int i=0; i<9; i++) + { + this->cores_busy_itf[i].set_sync_meth_muxed(&cluster::cores_busy_sync, i); + new_slave_port("core_busy_" + std::to_string(i), &this->cores_busy_itf[i]); + } + + this->power.new_power_source("background", &this->background_power, this->get_js_config()->get("power_models/background")); + + this->create_comps(); + this->create_ports(); + this->create_bindings(); + + return 0; +} + + +void cluster::start() +{ + this->background_power.leakage_power_start(); + this->background_power.dynamic_power_start(); +} + + + +void cluster::add_port(std::string name, vp::port *port) +{ + vp_assert_always(port != NULL, this->get_trace(), "Adding NULL port\n"); + //vp_assert_always(this->ports[name] == NULL, this->get_trace(), "Adding already existing port\n"); + this->ports[name] = port; +} + +void cluster::power_supply_set(int state) +{ + + //printf("%s power set %d\n", this->get_path().c_str(), state); +} + + +extern "C" vp::component *vp_constructor(js::config *config) +{ + return new cluster(config); +} diff --git a/gvsoc/gvsoc_gap/models/pulp/cluster/cluster_ctrl_v2_impl.cpp b/gvsoc/gvsoc_gap/models/pulp/cluster/cluster_ctrl_v2_impl.cpp index dc1c3bca0..8e44c267c 100644 --- a/gvsoc/gvsoc_gap/models/pulp/cluster/cluster_ctrl_v2_impl.cpp +++ b/gvsoc/gvsoc_gap/models/pulp/cluster/cluster_ctrl_v2_impl.cpp @@ -68,6 +68,8 @@ class cluster_ctrl : public vp::component uint32_t dbg_halt_mask; uint32_t dbg_halt_status; uint32_t dbg_halt_status_sync; + + vp::wire_master clock_gating_en_itf; }; cluster_ctrl::cluster_ctrl(js::config *config) @@ -111,6 +113,10 @@ vp::io_req_status_e cluster_ctrl::req(void *__this, vp::io_req *req) } else if (offset == ARCHI_CLUSTER_CTRL_CLUSTER_CLK_GATE) { + if (_this->clock_gating_en_itf.is_bound()) + { + _this->clock_gating_en_itf.sync((*data) & 1); + } return vp::IO_REQ_OK; } else if (offset == ARCHI_CLUSTER_CTRL_DBG_STATUS) @@ -258,6 +264,8 @@ int cluster_ctrl::build() in.set_req_meth(&cluster_ctrl::req); new_slave_port("input", &in); + this->new_master_port("clock_gating_en", &this->clock_gating_en_itf); + for (int i = 0; itrace.msg("Locking mutex (mutex: %d, coreId: %d)\n", id, core); mutex->locked = 1; + + *(uint32_t *)req->get_data() = mutex->value; } else { @@ -1522,6 +1525,26 @@ Dispatch_unit::Dispatch_unit(Event_unit *top) dispatches = new Dispatch[size]; } + void Dispatch_unit::consume_dispatch() + { + + for (int core_id=0; core_idtop->nb_core; core_id++) + { + int id = core[core_id].tail; + Dispatch *dispatch = &dispatches[id]; + + // In case we found ready elements where this core is not involved, bypass them all + while ((dispatch->status_mask.get() & (1<config_mask.get() & (1<status_mask.set(dispatch->status_mask.get() & (~(1<trace.msg("Incrementing core counter to bypass entry (coreId: %d, newIndex: %d)\n", core_id, id); + } + } + } + void Dispatch_unit::reset() { fifo_head = 0; @@ -1562,7 +1585,7 @@ Dispatch_unit::Dispatch_unit(Event_unit *top) // When pushing to the FIFO, the global config is pushed to the elected dispatcher dispatch->config_mask.set(config); // Cores that will get a valid value - top->trace.msg("Pushing dispatch value (dispatch: %d, value: 0x%x, coreMask: 0x%x)\n", id, *data, dispatch->config_mask); + top->trace.msg("Pushing dispatch value (dispatch: %d, value: 0x%x, coreMask: 0x%x)\n", id, *data, dispatch->config_mask.get()); // Case where the master push a value dispatch->value.set(*data); @@ -1570,6 +1593,7 @@ Dispatch_unit::Dispatch_unit(Event_unit *top) dispatch->status_mask.set(-1); // Then wake-up the waiting cores unsigned int mask = dispatch->waiting_mask.get() & dispatch->status_mask.get(); + for (int i=0; i<32 && mask; i++) { if (mask & (1<consume_dispatch(); + return vp::IO_REQ_OK; } @@ -1662,7 +1688,7 @@ Dispatch_unit::Dispatch_unit(Event_unit *top) else { // Nothing is ready, go to sleep - top->trace.msg("No ready dispatch value, going to sleep (dispatch: %d, value: %x, dispatchStatus: 0x%x)\n", id, dispatch->value, dispatch->status_mask); + top->trace.msg("No ready dispatch value, going to sleep (dispatch: %d, value: %x, dispatchStatus: 0x%x)\n", id, dispatch->value, dispatch->status_mask.get()); return enqueue_sleep(dispatch, req, core_id); } @@ -1674,6 +1700,7 @@ Dispatch_unit::Dispatch_unit(Event_unit *top) else if (offset == EU_DISPATCH_TEAM_CONFIG) { config = *data; + top->trace.msg("Setting dispatch config (config: 0x%x)\n", config); return vp::IO_REQ_OK; } else diff --git a/gvsoc/gvsoc_gap/models/pulp/mchan/mchan_v7_impl.cpp b/gvsoc/gvsoc_gap/models/pulp/mchan/mchan_v7_impl.cpp index 00fa69358..d2bc7db97 100644 --- a/gvsoc/gvsoc_gap/models/pulp/mchan/mchan_v7_impl.cpp +++ b/gvsoc/gvsoc_gap/models/pulp/mchan/mchan_v7_impl.cpp @@ -196,6 +196,7 @@ class mchan : public vp::component void account_transfered_bytes(Mchan_cmd *cmd, int bytes); void send_req_to_ext(Mchan_cmd *cmd, vp::io_req *req); void handle_ext_write_req_end(Mchan_cmd *cmd, vp::io_req *req); + void cmd_start(int cmd_id); vp::trace trace; @@ -239,8 +240,13 @@ class mchan : public vp::component int64_t *loc_port_ready_cycle; bool ext_is_stalled; + int nb_cmd_started; vp::trace cmd_events[MCHAN_NB_COUNTERS]; + + vp::wire_master busy_itf; + vp::power::power_source background_power; + vp::power::power_source active_power; }; void Mchan_channel::reset() @@ -396,8 +402,7 @@ bool Mchan_channel::check_command(Mchan_cmd *cmd) top->trace.msg(vp::trace::LEVEL_TRACE, "Incrementing counter (id: %d, bytes: %d, remaining bytes: %d)\n", current_counter, cmd->size, top->pending_bytes[current_counter]); // Enqueue the command to the core queue - uint8_t one = 1; - this->top->cmd_events[cmd->counter_id].event(&one); + this->top->cmd_start(cmd->counter_id); pending_cmds->push(cmd); @@ -526,6 +531,20 @@ void Mchan_channel::trigger_event(Mchan_cmd *cmd) } } +void mchan::cmd_start(int cmd_id) +{ + uint8_t one = 1; + this->cmd_events[cmd_id].event(&one); + this->nb_cmd_started++; + if (this->nb_cmd_started == 1) + { + if (this->busy_itf.is_bound()) + { + this->active_power.dynamic_power_start(); + this->busy_itf.sync(1); + } + } +} void mchan::ext_grant(void *__this, vp::io_req *req) { @@ -876,6 +895,10 @@ void mchan::send_req() { ext_is_stalled = true; } + else + { + trace.force_warning("Got error during transfer (addr: 0x%lx, size: 0x%x)\n", cmd->source, size); + } } void mchan::check_ext_read_handler(void *__this, vp::clock_event *event) @@ -920,8 +943,17 @@ void mchan::check_ext_write_handler(void *__this, vp::clock_event *event) void mchan::handle_cmd_termination(Mchan_cmd *cmd) { - this->cmd_events[cmd->counter_id].event(NULL); - free_command(cmd); + this->cmd_events[cmd->counter_id].event(NULL); + this->nb_cmd_started--; + if (this->nb_cmd_started == 0) + { + if (this->busy_itf.is_bound()) + { + this->active_power.dynamic_power_stop(); + this->busy_itf.sync(0); + } + } + free_command(cmd); } void mchan::account_transfered_bytes(Mchan_cmd *cmd, int bytes) @@ -1148,6 +1180,7 @@ void mchan::check_queue() int mchan::build() { traces.new_trace("trace", &this->trace, vp::DEBUG); + new_master_port("busy", &this->busy_itf); for (int i=0; icmd_events[i], 8); } + this->power.new_power_source("background", &this->background_power, this->get_js_config()->get("**/power_models/background")); + this->power.new_power_source("active", &this->active_power, this->get_js_config()->get("**/power_models/active")); + return 0; } void mchan::start() { + this->background_power.leakage_power_start(); + this->background_power.dynamic_power_start(); } void mchan::reset(bool active) @@ -1187,6 +1225,7 @@ void mchan::reset(bool active) loc_port_ready_cycle[i] = 0; } + this->nb_cmd_started = 0; first_alloc_pending_req = NULL; last_alloc_pending_req = NULL; nb_core_read_cmd = 0; diff --git a/gvsoc/gvsoc_gap/models/pulp/ne16/src/ne16_debug.cpp b/gvsoc/gvsoc_gap/models/pulp/ne16/src/ne16_debug.cpp index 23131fa14..4bff46f71 100644 --- a/gvsoc/gvsoc_gap/models/pulp/ne16/src/ne16_debug.cpp +++ b/gvsoc/gvsoc_gap/models/pulp/ne16/src/ne16_debug.cpp @@ -23,13 +23,13 @@ void Ne16::debug_x_buffer() { if(this->mode_linear) { std::ostringstream stringStream; - stringStream << "x_buffer[32,16] = \n" << (this->trace_format?std::hex:std::dec) << std::setw(2) << this->x_buffer_linear << std::dec << "\n"; + stringStream << "x_buffer[32,16] = \n" << (this->trace_format?std::hex:std::dec) << this->x_buffer_linear << std::dec << "\n"; std::string copyOfStr = stringStream.str(); this->trace.msg(vp::trace::LEVEL_DEBUG, copyOfStr.c_str()); } else { std::ostringstream stringStream; - stringStream << "x_buffer[5,5,16] = \n" << (this->trace_format?std::hex:std::dec) << std::setw(2) << this->x_buffer << std::dec << "\n"; + stringStream << "x_buffer[5,5,16] = \n" << (this->trace_format?std::hex:std::dec) << this->x_buffer << std::dec << "\n"; std::string copyOfStr = stringStream.str(); this->trace.msg(vp::trace::LEVEL_DEBUG, copyOfStr.c_str()); } @@ -47,7 +47,7 @@ void Ne16::debug_x_array() { // } // else { std::ostringstream stringStream; - stringStream << "x_array[9,9,16] = \n" << xt::print_options::threshold(10000) << (this->trace_format?std::hex:std::dec) << std::setw(2) << this->x_array << std::dec << "\n"; + stringStream << "x_array[9,9,16] = \n" << xt::print_options::threshold(10000) << (this->trace_format?std::hex:std::dec) << this->x_array << std::dec << "\n"; std::string copyOfStr = stringStream.str(); this->trace.msg(vp::trace::LEVEL_DEBUG, copyOfStr.c_str()); // } @@ -55,7 +55,7 @@ void Ne16::debug_x_array() { void Ne16::debug_accum(){ std::ostringstream stringStream; - stringStream << "accum[9,32] = \n" << (this->trace_format?std::hex:std::dec) << std::setw(8) << xt::cast(this->accum) << std::dec << "\n"; + stringStream << "accum[9,32] = \n" << (this->trace_format?std::hex:std::dec) << xt::cast(this->accum) << std::dec << "\n"; std::string copyOfStr = stringStream.str(); this->trace.msg(vp::trace::LEVEL_DEBUG, copyOfStr.c_str()); } @@ -69,7 +69,7 @@ void Ne16::debug_accum(){ void Ne16::debug_psum_block(){ std::ostringstream stringStream; - stringStream << "psum_block[9,9] = \n" << (this->trace_format?std::hex:std::dec) << std::setw(8) << xt::cast(this->psum_block) << std::dec << "\n"; + stringStream << "psum_block[9,9] = \n" << (this->trace_format?std::hex:std::dec) << xt::cast(this->psum_block) << std::dec << "\n"; std::string copyOfStr = stringStream.str(); this->trace.msg(vp::trace::LEVEL_DEBUG, copyOfStr.c_str()); } diff --git a/gvsoc/gvsoc_gap/models/pulp/pmu/pmu_v4_impl.cpp b/gvsoc/gvsoc_gap/models/pulp/pmu/pmu_v4_impl.cpp index ab9d559a2..a048ba4ef 100644 --- a/gvsoc/gvsoc_gap/models/pulp/pmu/pmu_v4_impl.cpp +++ b/gvsoc/gvsoc_gap/models/pulp/pmu/pmu_v4_impl.cpp @@ -236,6 +236,7 @@ class pmu_icu : public pmu_picl_slave private: pmu *top; vp::wire_master reset_itf; + vp::wire_master power_itf; pmu_icu_state states[16]; int index; int current_supply_state; @@ -706,6 +707,11 @@ void pmu_icu::icu_ctrl_req(bool is_write, uint16_t pwdata) } } + if (this->power_itf.is_bound()) + { + this->power_itf.sync(state->supply == MAESTRO_ICU_SUPPLY_ON); + } + this->current_supply_state = state->supply; top->picl_reply(); @@ -797,6 +803,7 @@ pmu_icu::pmu_icu(pmu *top, int index) : pmu_picl_slave(top), top(top), index(index) { top->new_master_port("icu" + std::to_string(index) + "_reset", &this->reset_itf); + top->new_master_port("icu" + std::to_string(index) + "_power", &this->power_itf); for (int i=0; i<16; i++) { diff --git a/gvsoc/gvsoc_gap/models/pulp/timer/timer_v2_impl.cpp b/gvsoc/gvsoc_gap/models/pulp/timer/timer_v2_impl.cpp index a1c9c4db2..bcc09ba9c 100644 --- a/gvsoc/gvsoc_gap/models/pulp/timer/timer_v2_impl.cpp +++ b/gvsoc/gvsoc_gap/models/pulp/timer/timer_v2_impl.cpp @@ -61,8 +61,10 @@ class timer : public vp::component uint64_t get_compare_value(bool is_64, int counter); uint64_t get_value(bool is_64, int counter); void set_value(bool is_64, int counter, uint64_t new_value); + void set_enable(int counter, bool enabled); vp::wire_master irq_itf[2]; + vp::wire_master busy_itf; vp::clock_slave ref_clock_itf; uint32_t value[2]; @@ -143,6 +145,16 @@ void timer::set_value(bool is_64, int counter, uint64_t new_value) else value[counter] = new_value; } +void timer::set_enable(int counter, bool enabled) +{ + this->is_enabled[counter] = enabled; + + if (this->busy_itf.is_bound()) + { + this->busy_itf.sync(enabled); + } +} + void timer::check_state_counter(bool is_64, int counter) { if (is_enabled[counter] && get_compare_value(is_64, counter) == get_value(is_64, counter)) @@ -165,7 +177,7 @@ void timer::check_state_counter(bool is_64, int counter) if (one_shot[counter]) { this->trace.msg(vp::trace::LEVEL_DEBUG, "Reached one-shot end (timer: %d)\n", counter); - is_enabled[counter] = false; + this->set_enable(counter, false); } } @@ -300,7 +312,7 @@ vp::io_req_status_e timer::handle_compare(int counter, uint32_t *data, unsigned void timer::depack_config(int counter, uint32_t configuration) { - is_enabled[counter] = (configuration >> TIMER_CFG_LO_ENABLE_BIT) & 1; + this->set_enable(counter, (configuration >> TIMER_CFG_LO_ENABLE_BIT) & 1); irq_enabled[counter] = (configuration >> TIMER_CFG_LO_IRQEN_BIT) & 1; iem[counter] = (configuration >> TIMER_CFG_LO_IEM_BIT) & 1; cmp_clr[counter] = (configuration >> TIMER_CFG_LO_MODE_BIT) & 1; @@ -385,6 +397,8 @@ int timer::build() new_master_port("irq_itf_0", &irq_itf[0]); new_master_port("irq_itf_1", &irq_itf[1]); + new_master_port("busy", &busy_itf); + ref_clock_itf.set_sync_meth(&timer::ref_clock_sync); new_slave_port("ref_clock", &ref_clock_itf); diff --git a/gvsoc/gvsoc_gap/models/pulp/udma/ffc/udma_ffc_v1.cpp b/gvsoc/gvsoc_gap/models/pulp/udma/ffc/udma_ffc_v1.cpp index f0b448356..c6dd9d543 100644 --- a/gvsoc/gvsoc_gap/models/pulp/udma/ffc/udma_ffc_v1.cpp +++ b/gvsoc/gvsoc_gap/models/pulp/udma/ffc/udma_ffc_v1.cpp @@ -22,9 +22,9 @@ using namespace std::placeholders; /* delay needed to replicate real performances */ -/* this should be 1 because ffc is 1 data/cycle, but 14 is the closest value +/* this should be 1 because ffc is 1 data/cycle, but 2 is the closest value * to replicate performance */ -#define FFC_DELAY_CYCLES (14) +#define FFC_DELAY_CYCLES (2) Ffc_periph::Ffc_periph(udma *top, int id, int itf_id) : Udma_periph(top, id) { @@ -47,6 +47,9 @@ Ffc_periph::Ffc_periph(udma *top, int id, int itf_id) : Udma_periph(top, id) /* setup event handlers */ this->event_convert = top->event_new(this, Ffc_periph::handle_event); + + /* Busy signal for VCD tracing */ + this->top->new_reg(itf_name + "/busy", &this->busy, 8); } @@ -56,6 +59,9 @@ void Ffc_periph::reset(bool active) this->rx_channel->reset(active); this->tx_channel->reset(active); + + // Since busy signal is displayed as a state, we need to release it when the FFC is not busy. */ + this->busy.release(); } @@ -96,6 +102,7 @@ vp::io_req_status_e Ffc_periph::custom_req(vp::io_req *req, uint64_t offset) this->trace.msg(vp::trace::LEVEL_TRACE, "Received START access\n"); /* start converting data */ this->enqueue_event(); + this->busy.set(1); break; default: break; @@ -207,6 +214,8 @@ void Ffc_periph::handle_event(void* __this, vp::clock_event* event) { /* done with conversion */ _this->state = FFC_STATE_IDLE; + // Since busy signal is displayed as a state, we need to release it when the FFC is not busy. */ + _this->busy.release(); } else if (!_this->ffc_queue.empty()) { @@ -570,6 +579,7 @@ void Ffc_periph::convert_to_fixed(uint8_t* src, printf("Invalid float type\n"); break; } + this->push_data((uint8_t*) &dst, 4); } break; @@ -583,7 +593,7 @@ void Ffc_periph::enqueue_event(void) { if (!(this->event_convert)->is_enqueued()) { - this->top->get_periph_clock()->enqueue(this->event_convert, FFC_DELAY_CYCLES); + this->top->event_enqueue(this->event_convert, FFC_DELAY_CYCLES); } } diff --git a/gvsoc/gvsoc_gap/models/pulp/udma/ffc/udma_ffc_v1.hpp b/gvsoc/gvsoc_gap/models/pulp/udma/ffc/udma_ffc_v1.hpp index 8b142491f..345c65715 100644 --- a/gvsoc/gvsoc_gap/models/pulp/udma/ffc/udma_ffc_v1.hpp +++ b/gvsoc/gvsoc_gap/models/pulp/udma/ffc/udma_ffc_v1.hpp @@ -281,6 +281,9 @@ class Ffc_periph : public Udma_periph /** FFC TX channel, used to transmit data to the FFC */ Ffc_tx_channel *tx_channel; + + /** Busy signal for VCD tracing */ + vp::reg_8 busy; }; diff --git a/gvsoc/gvsoc_gap/models/pulp/udma/i2c/udma_i2c_v2.cpp b/gvsoc/gvsoc_gap/models/pulp/udma/i2c/udma_i2c_v2.cpp index 0a351268a..aad3c8d80 100644 --- a/gvsoc/gvsoc_gap/models/pulp/udma/i2c/udma_i2c_v2.cpp +++ b/gvsoc/gvsoc_gap/models/pulp/udma/i2c/udma_i2c_v2.cpp @@ -108,6 +108,7 @@ void I2c_tx_channel::handle_pending_word(void *__this, vp::clock_event *event) if (_this->periph->waiting_rx) { _this->periph->prev_scl ^= 1; + _this->periph->trace.msg("Sync (scl: %d, sda: %d)\n", _this->periph->prev_scl, 0); _this->periph->i2c_itf.sync(_this->periph->prev_scl, 0); if (_this->periph->prev_scl) diff --git a/gvsoc/gvsoc_gap/models/pulp/udma/i2c/v4/udma_i2c.cpp b/gvsoc/gvsoc_gap/models/pulp/udma/i2c/v4/udma_i2c.cpp index 8a589314f..411559042 100644 --- a/gvsoc/gvsoc_gap/models/pulp/udma/i2c/v4/udma_i2c.cpp +++ b/gvsoc/gvsoc_gap/models/pulp/udma/i2c/v4/udma_i2c.cpp @@ -38,7 +38,8 @@ I2c_periph::I2c_periph(udma *top, int id, int itf_id) : _2), std::bind(&I2c_periph::i2c_cancel_event, this, - _1) + _1), + "i2c" + std::to_string(itf_id) ), is_waiting_i2c_start(false), is_waiting_i2c_data(false), @@ -295,7 +296,7 @@ void I2c_periph::i2c_sync(void *__this, int scl, int sda) void I2c_periph::ucode_handler(ucode_data_t data) { - //I2C_PERIPH_FPRINTF("[I2C] ucode_handler: data.id=%d\n", data.id); + I2C_PERIPH_FPRINTF("[I2C] ucode_handler: data.id=0x%x\n", data.id); switch(data.id) { case CMD_MISC_NOP: @@ -367,11 +368,10 @@ void I2c_periph::ucode_handler(ucode_data_t data) } break; case CMD_LEAD_RECV: - if (this->repeat_downcounter == 0) + if (this->repeat_downcounter > 0) { - this->repeat_downcounter = 1; + this->is_waiting_i2c_data = true; } - this->is_waiting_i2c_data = true; break; case CMD_LEAD_RECV_LAST: // TODO @@ -576,7 +576,7 @@ void I2c_periph::i2c_helper_callback(i2c_operation_e id, i2c_status_e status, in void I2c_periph::i2c_start(void) { - if (!this->i2c_helper.is_busy()) + if (1) //!this->i2c_helper.is_busy()) { I2C_PERIPH_FPRINTF("Sending start directly\n"); this->is_waiting_i2c_start = true; diff --git a/gvsoc/gvsoc_gap/models/pulp/udma/udma_v4_addrgens.cpp b/gvsoc/gvsoc_gap/models/pulp/udma/udma_v4_addrgens.cpp index 43d48b9cb..0dea6be56 100644 --- a/gvsoc/gvsoc_gap/models/pulp/udma/udma_v4_addrgens.cpp +++ b/gvsoc/gvsoc_gap/models/pulp/udma/udma_v4_addrgens.cpp @@ -134,6 +134,7 @@ void Udma_addrgen_linear::cfg_ctrl_req(uint64_t reg_offset, int size, uint8_t *v vp::io_req_status_e Udma_addrgen_linear::access(uint64_t offset, int size, uint8_t *value, bool is_write) { + if (this->regmap.access(offset, size, value, is_write)) return vp::IO_REQ_INVALID; diff --git a/libs/gap_lib/include/gaplib/jpeg_encoder.h b/libs/gap_lib/include/gaplib/jpeg_encoder.h index 641a72944..721799ff4 100644 --- a/libs/gap_lib/include/gaplib/jpeg_encoder.h +++ b/libs/gap_lib/include/gaplib/jpeg_encoder.h @@ -52,6 +52,8 @@ typedef struct jpeg_encoder_s int bitstream_size; pi_task_t *end_task; void *l1_constants; + int color; + int comp; } jpeg_encoder_t; diff --git a/libs/gap_lib/jpeg/cluster.c b/libs/gap_lib/jpeg/cluster.c index 9b8e8bd7d..4f9fd4191 100644 --- a/libs/gap_lib/jpeg/cluster.c +++ b/libs/gap_lib/jpeg/cluster.c @@ -30,8 +30,38 @@ #ifdef PMSIS_DRIVERS #define RT_USER_EVENT (CL_USER_EVENT) #define eu_evt_trig_from_id(x,y) (hal_eu_cluster_evt_trig_set(x,y)) +#if defined(__GAP9__) + #define eu_evt_maskWaitAndClr(x) (hal_cl_eu_evt_mask_wait_and_clear(x)) +#else #define eu_evt_maskWaitAndClr(x) (hal_cl_eu_evt_mask_wait_clear(x)) #endif +#else + #define RT_USER_EVENT 6 +#endif + +#define FLOAT2FIX(f) ((int)((f) * (1 << 11))) +#define FIXQ 11 + +void cl_rgb_to_y(unsigned char r, unsigned char g, unsigned char b, short int *y) +{ + int a = FLOAT2FIX( 0.2990f) * r + FLOAT2FIX(0.5870f) * g + FLOAT2FIX(0.1140f) * b - ((short int)128 << FIXQ); + //printf("%f ",FIX2FP(*y,11)); + //if(*y > (105<<11)) *y = 105 << 11; + *y = (short int) (a >> (FIXQ - 1)); + //printf("%f\n",FIX2FP(*y,0)); +} +void cl_rgb_to_cb(unsigned char r, unsigned char g, unsigned char b, short int *u) +{ + int a = FLOAT2FIX(-0.1687f) * r - FLOAT2FIX(0.3313f) * g + FLOAT2FIX(0.5000f) * b; + *u = (short int) (a >> (FIXQ - 1)); +} + +void cl_rgb_to_cr(unsigned char r, unsigned char g, unsigned char b, short int *v) +{ + int a = FLOAT2FIX( 0.5000f) * r - FLOAT2FIX(0.4187f) * g - FLOAT2FIX(0.0813f) * b ; + *v = (short int)(a >> (FIXQ - 1)); +} + static inline void queue_init(block_queue_t *queue) { @@ -279,7 +309,12 @@ static inline int pop_ready_block(cl_enc_t *enc) static int exec_dct(cl_enc_t *enc, cl_enc_block_t *block) { const signed short *FDctFactors = enc->constants->FDCT_FACTORS; - const unsigned char *QuantLUT = enc->constants->QUANT_TAB_LUMIN; + unsigned char *QuantLUT; + + if(enc->comp==0) + QuantLUT = (unsigned char *) enc->constants->QUANT_TAB_LUMIN; + else + QuantLUT = (unsigned char *) enc->constants->QUANT_TAB_CHROM; short int *DU = block->data; //printf("[%p] DCT\n", block); @@ -326,8 +361,12 @@ static int exec_dct(cl_enc_t *enc, cl_enc_block_t *block) static void exec_quantization(cl_enc_t *enc, cl_enc_block_t *block) { + unsigned char *QuantLUT; const unsigned char *ZigZagLUT = enc->constants->ZIGZAG_LUT; - const unsigned char *QuantLUT = enc->constants->QUANT_TAB_LUMIN; + if(enc->comp==0) + QuantLUT = (unsigned char *) enc->constants->QUANT_TAB_LUMIN; + else + QuantLUT = (unsigned char *) enc->constants->QUANT_TAB_CHROM; short int *DU = block->data; //printf("[%p] Quantization\n", block); @@ -392,11 +431,23 @@ static void exec_quantization(cl_enc_t *enc, cl_enc_block_t *block) static void exec_bitstream(cl_enc_t *enc, cl_enc_block_t *block) { - const unsigned short *RLE_DC_LUT = enc->constants->HUFTAB_LUMIN_DC_Code; - const unsigned char *RLE_DC_Size_LUT = enc->constants->HUFTAB_LUMIN_DC_Size; - const unsigned short *RLE_AC_LUT = enc->constants->HUFTAB_LUMIN_AC_Code; - const unsigned char *RLE_AC_Size_LUT = enc->constants->HUFTAB_LUMIN_AC_Size; + unsigned short *RLE_DC_LUT; + unsigned char *RLE_DC_Size_LUT; + unsigned short *RLE_AC_LUT; + unsigned char *RLE_AC_Size_LUT; + + if(enc->comp==0){ + RLE_DC_LUT = (unsigned short *) enc->constants->HUFTAB_LUMIN_DC_Code; + RLE_DC_Size_LUT = (unsigned char *) enc->constants->HUFTAB_LUMIN_DC_Size; + RLE_AC_LUT = (unsigned short *) enc->constants->HUFTAB_LUMIN_AC_Code; + RLE_AC_Size_LUT = (unsigned char *) enc->constants->HUFTAB_LUMIN_AC_Size; + }else{ + RLE_DC_LUT = (unsigned short *) enc->constants->HUFTAB_CHROM_DC_Code; + RLE_DC_Size_LUT = (unsigned char *) enc->constants->HUFTAB_CHROM_DC_Size; + RLE_AC_LUT = (unsigned short *) enc->constants->HUFTAB_CHROM_AC_Code; + RLE_AC_Size_LUT = (unsigned char *) enc->constants->HUFTAB_CHROM_AC_Size; + } // As only 1 core at the same time can produce the bitstream, loop until we can't // produce it anymore to free blocks as fast as possible. while(1) @@ -548,12 +599,18 @@ static int check_fetch_block(cl_enc_t *enc) if (!block->prev_du) block->vp = enc->prev_du; pi_cl_team_critical_exit(); - uint32_t ext = enc->image + enc->width * block->y + block->x; + //printf("[%p] Fetching block (id: %d, x: %d, y: %d, ext: 0x%lx, loc: 0x%lx)\n", block, block->id, block->x, block->y, ext, (uint32_t)block->data); - - pi_cl_dma_cmd_2d(ext, (uint32_t)block->data, 64, enc->width, 8, PI_CL_DMA_DIR_EXT2LOC, &block->dma_cmd); - + + if(enc->color==1){ + uint32_t ext = enc->image + (enc->width * block->y + block->x)*3; + pi_cl_dma_cmd_2d(ext, (uint32_t)block->data, 64*3, enc->width*3, 8*3, PI_CL_DMA_DIR_EXT2LOC, &block->dma_cmd); + } + else{ + uint32_t ext = enc->image + (enc->width * block->y + block->x); + pi_cl_dma_cmd_2d(ext, (uint32_t)block->data, 64, enc->width, 8, PI_CL_DMA_DIR_EXT2LOC, &block->dma_cmd); + } pi_cl_team_critical_enter(); queue_push(&enc->fetched_blocks, block); @@ -605,6 +662,42 @@ static void __jpeg_encoder_process_pe_entry(void *arg) unsigned char *data = (unsigned char *)block->data; signed short *data_s = block->data; + if(enc->color==1){ + if(enc->comp==0){ + for (int i=0; i<64; i++) + { + cl_rgb_to_y(data[i*3], + data[i*3+1], + data[i*3+2], + &data_s[i]); + } + } + else if(enc->comp==1){ + for (int i=0; i<64; i++) + { + cl_rgb_to_cb(data[i*3], + data[i*3+1], + data[i*3+2], + &data_s[i]); + } + } + else if(enc->comp==2){ + for (int i=0; i<64; i++) + { + cl_rgb_to_cr(data[i*3], + data[i*3+1], + data[i*3+2], + &data_s[i]); + } + } + } + + else{ + for (int i=63; i>=0; i--) + { + data_s[i] = ((signed short)data[i] - 128) << 1; + } + } if (block->y + 8 > enc->height || block->x + 8 > enc->width) { @@ -621,17 +714,12 @@ static void __jpeg_encoder_process_pe_entry(void *arg) { if (i >= y || j >= x) { - data[i*8+j] = 0x1; + data_s[i*8+j] = 0x0; } } } } - for (int i=63; i>=0; i--) - { - data_s[i] = ((signed short)data[i] - 128) << 2; - } - process_du_cluster(enc, block, 0); } else @@ -673,6 +761,8 @@ static void __jpeg_encoder_process_cl_entry(void *arg) cl_enc.current_bitstream = &cl_enc.l1_bitstream[0][0]; cl_enc.current_ext_bitstream = cl_enc.bitstream; cl_enc.pending_dma = 0; + cl_enc.color=enc->color; + cl_enc.comp=enc->comp; queue_init(&cl_enc.fetched_blocks); queue_init(&cl_enc.dct_blocks); @@ -748,7 +838,8 @@ void __jpeg_encoder_process_cl(jpeg_encoder_t *enc, pi_buffer_t *image, pi_buffe pi_cluster_task(&enc->cluster_task, __jpeg_encoder_process_cl_entry, enc); - pi_cluster_send_task_to_cl_async(&enc->cluster_dev, &enc->cluster_task, task); + pi_cluster_send_task_to_cl(&enc->cluster_dev, &enc->cluster_task); + } diff --git a/libs/gap_lib/jpeg/cluster.h b/libs/gap_lib/jpeg/cluster.h index 09a9cdc6e..4fd76a368 100644 --- a/libs/gap_lib/jpeg/cluster.h +++ b/libs/gap_lib/jpeg/cluster.h @@ -52,7 +52,7 @@ typedef struct cl_enc_block_s short int vc; // Block first quantized value short int vp; // Previous block first quantized value int next_vc_done; // Next block got first quantized value, which means this block can be released - short int data[64]; // Block data + short int data[64*3]; // Block data int output[64*3]; // Block output data. Contains bitstream symbols which should be encoded. pi_cl_dma_cmd_t dma_cmd; // DMA node. } cl_enc_block_t; @@ -104,6 +104,8 @@ typedef struct unsigned char *current_ext_bitstream; // Current position in L2 output bistream pi_cl_dma_cmd_t dma_cmd; // DMA node used for output bistream copy int pending_dma; // 1 if a DMA copy is pending for output bistream + int color; + int comp; } cl_enc_t; diff --git a/libs/gap_lib/jpeg/dct.c b/libs/gap_lib/jpeg/dct.c index 5c58fc9d8..e90c8bc3d 100755 --- a/libs/gap_lib/jpeg/dct.c +++ b/libs/gap_lib/jpeg/dct.c @@ -133,7 +133,7 @@ void Dct8x8(short int *__restrict__ data, const short int *__restrict__ ftab) dataptr++; /* advance pointer to next column */ } - for (ctr = 0; ctr < 64; ctr++) data[ctr] = __builtin_pulp_mulfsN(data[ctr], ftab[ctr], Q11 + 2); + for (ctr = 0; ctr < 64; ctr++) data[ctr] = __builtin_pulp_mulfsN(data[ctr], ftab[ctr], Q11 + 1); } #else diff --git a/libs/gap_lib/jpeg/jpeg_encoder.c b/libs/gap_lib/jpeg/jpeg_encoder.c index 67c413b28..4ba370cc2 100644 --- a/libs/gap_lib/jpeg/jpeg_encoder.c +++ b/libs/gap_lib/jpeg/jpeg_encoder.c @@ -356,19 +356,19 @@ int process_du( void rgb_to_y(unsigned char r, unsigned char g, unsigned char b, int *y) { - *y = FLOAT2FIX( 0.2990f) * r + FLOAT2FIX(0.5870f) * g + FLOAT2FIX(0.1140f) * b - (128 << FIXQ); - *y >>= FIXQ - 2; + *y = FLOAT2FIX( 0.2990f) * r + FLOAT2FIX(0.5870f) * g + FLOAT2FIX(0.1140f) * b - ((int)128 << FIXQ); + *y >>= FIXQ - 1; } void rgb_to_cb(unsigned char r, unsigned char g, unsigned char b, int *u) { - *u = FLOAT2FIX(-0.1678f) * r - FLOAT2FIX(0.3313f) * g + FLOAT2FIX(0.5000f) * b; - *u >>= FIXQ - 2; + *u = FLOAT2FIX(-0.1687f) * r - FLOAT2FIX(0.3313f) * g + FLOAT2FIX(0.5000f) * b; + *u >>= FIXQ - 1; } void rgb_to_cr(unsigned char r, unsigned char g, unsigned char b, int *v) { *v = FLOAT2FIX( 0.5000f) * r - FLOAT2FIX(0.4187f) * g - FLOAT2FIX(0.0813f) * b ; - *v >>= FIXQ - 2; + *v >>= FIXQ - 1; } @@ -379,7 +379,7 @@ void gray_to_y(int r, int *y) *y = FLOAT2FIX(1.0f) * r - (128 << FIXQ); *y >>= FIXQ - 2; #else - *y = (r - 128) << 2; + *y = (r - 128) << 1; #endif } @@ -619,8 +619,44 @@ void jpeg_encoder_process_async(jpeg_encoder_t *enc, pi_buffer_t *image, pi_buff if(enc->flags & JPEG_ENCODER_FLAGS_COLOR){ if (enc->flags & JPEG_ENCODER_FLAGS_CLUSTER_OFFLOAD) { - printf("Error: Color Jpeg not yet implemented on cluster\n"); - return; + //Set colors + enc->color=1; + + uint32_t written_size=0,encoded_size; + jpeg_y_header(enc, encoded_bitstream, &encoded_size); + + encoded_bitstream->data = encoded_bitstream->data+encoded_size; + written_size+=encoded_size; + enc->current_du_x=0; + enc->current_du_y=0; + enc->comp=0; + __jpeg_encoder_process_cl(enc, image, encoded_bitstream, task); + encoded_bitstream->data = encoded_bitstream->data+task->arg[2]; + written_size+=task->arg[2]; + task->arg[2]=0; + jpeg_cb_header(enc, encoded_bitstream, &encoded_size); + + encoded_bitstream->data = encoded_bitstream->data+encoded_size; + written_size+=encoded_size; + enc->current_du_x=0; + enc->current_du_y=0; + enc->comp=1; + __jpeg_encoder_process_cl(enc, image, encoded_bitstream, task); + encoded_bitstream->data = encoded_bitstream->data+task->arg[2]; + written_size+=task->arg[2]; + task->arg[2]=0; + jpeg_cr_header(enc, encoded_bitstream, &encoded_size); + + encoded_bitstream->data = encoded_bitstream->data+encoded_size; + written_size+=encoded_size; + enc->current_du_x=0; + enc->current_du_y=0; + enc->comp=2; + __jpeg_encoder_process_cl(enc, image, encoded_bitstream, task); + encoded_bitstream->data = encoded_bitstream->data+task->arg[2]; + written_size+=task->arg[2]; + task->arg[2] = written_size; + pi_task_push(task); } else{ uint32_t written_size=0,encoded_size; @@ -664,7 +700,10 @@ void jpeg_encoder_process_async(jpeg_encoder_t *enc, pi_buffer_t *image, pi_buff { if (enc->flags & JPEG_ENCODER_FLAGS_CLUSTER_OFFLOAD) { + enc->color=0; + enc->comp=0; __jpeg_encoder_process_cl(enc, image, encoded_bitstream, task); + pi_task_push(task); } else{ jpeg_encoder_process_fc(enc, image, encoded_bitstream, task,0,0); diff --git a/libs/gap_lib/testbench/testbench.h b/libs/gap_lib/testbench/testbench.h index 3eece6c29..5bbd70444 100644 --- a/libs/gap_lib/testbench/testbench.h +++ b/libs/gap_lib/testbench/testbench.h @@ -122,6 +122,12 @@ typedef enum PI_TESTBENCH_I2S_VERIF_RX_FILE_READER } pi_testbench_i2s_verif_start_config_type_e; +typedef enum +{ + PI_TESTBENCH_I2S_VERIF_FILE_ENCODING_TYPE_ASIS = 0, // Keep as is (default) + PI_TESTBENCH_I2S_VERIF_FILE_ENCODING_TYPE_PLUSMINUS, // Assume file contains -1/+1 values (usable for PDM only) +} pi_testbench_i2s_verif_start_config_file_encoding_type_e; + // This structure can be used to describe what an I2S slot should do typedef struct { @@ -142,6 +148,7 @@ typedef struct uint32_t filepath_len; uint8_t type; uint8_t width; + uint8_t encoding; } tx_file_dumper; struct { @@ -150,6 +157,7 @@ typedef struct uint32_t filepath_len; uint8_t type; uint8_t width; + uint8_t encoding; } rx_file_reader; }; diff --git a/libs/gap_lib/testbench/testlib.c b/libs/gap_lib/testbench/testlib.c index 063221819..36cfc0209 100644 --- a/libs/gap_lib/testbench/testlib.c +++ b/libs/gap_lib/testbench/testlib.c @@ -10,7 +10,6 @@ #include "pmsis.h" #include "testbench.h" #include "testlib.h" -#include #include @@ -195,8 +194,36 @@ void i2s_slot_deinit(i2s_slot_test_t *i2s_slot) pi_i2s_channel_conf_set(i2s_slot->i2s, i2s_slot->slot, &i2s_conf); } - pi_l2_free(i2s_slot->buffers[0], i2s_slot->buffer_size); - pi_l2_free(i2s_slot->buffers[1], i2s_slot->buffer_size); + if (i2s_slot->flags.use_slab) + { + if (i2s_slot->frame) + { + if (__FF1(i2s_slot->frame) == i2s_slot->slot) + { + pi_l2_free(i2s_slot->slab.buffer, i2s_slot->buffer_size * __builtin_popcount(i2s_slot->frame) * i2s_slot->slab.num_blocks); + } + } + else + { + pi_l2_free(i2s_slot->slab.buffer, i2s_slot->buffer_size * i2s_slot->slab.num_blocks); + } + } + else + { + if (i2s_slot->frame) + { + if (__FF1(i2s_slot->frame) == i2s_slot->slot) + { + pi_l2_free(i2s_slot->buffers[0], i2s_slot->buffer_size*__builtin_popcount(i2s_slot->frame)); + pi_l2_free(i2s_slot->buffers[1], i2s_slot->buffer_size*__builtin_popcount(i2s_slot->frame)); + } + } + else + { + pi_l2_free(i2s_slot->buffers[0], i2s_slot->buffer_size); + pi_l2_free(i2s_slot->buffers[1], i2s_slot->buffer_size); + } + } } } @@ -416,24 +443,28 @@ void i2s_slot_callback_tx_file_dumper(void *arg) { i2s_slot_test_t *i2s_slot = (i2s_slot_test_t *)arg; - int error = pi_i2s_write_status(&i2s_slot->task); + int error = pi_i2s_write_status(&i2s_slot->task[i2s_slot->current_handled_task]); + i2s_slot->current_handled_task ^= 1; if (error) { - i2s_slot->retval++; - pi_task_push(&i2s_slot->end_task); - return; + i2s_slot->retval = 1; } - if (i2s_slot->nb_sample > 0) + if (i2s_slot->nb_sample_done != -1) { - i2s_slot->nb_sample -= i2s_slot->nb_elem; + i2s_slot->nb_sample_done -= i2s_slot->nb_elem; } if (i2s_slot->nb_sample > 0 || i2s_slot->nb_sample == -1) { void *buffer; + if (i2s_slot->nb_sample > 0) + { + i2s_slot->nb_sample -= i2s_slot->nb_elem; + } + if (i2s_slot->flags.use_slab) { pi_mem_slab_alloc(&i2s_slot->slab, (void **)&buffer, 0); @@ -470,19 +501,23 @@ void i2s_slot_callback_tx_file_dumper(void *arg) } - + pi_task_t *task = &i2s_slot->task[i2s_slot->current_task]; + i2s_slot->current_task ^= 1; if (i2s_slot->frame) { - int err = pi_i2s_frame_write_async(i2s_slot->i2s, i2s_slot->frame, buffer, i2s_slot->buffer_size, pi_task_callback(&i2s_slot->task, i2s_slot_callback_tx_file_dumper, (void *)i2s_slot)); + int err = pi_i2s_frame_write_async(i2s_slot->i2s, i2s_slot->frame, buffer, i2s_slot->buffer_size, pi_task_callback(task, i2s_slot_callback_tx_file_dumper, (void *)i2s_slot)); } else { - int err = pi_i2s_channel_write_async(i2s_slot->i2s, i2s_slot->slot, buffer, i2s_slot->buffer_size, pi_task_callback(&i2s_slot->task, i2s_slot_callback_tx_file_dumper, (void *)i2s_slot)); + int err = pi_i2s_channel_write_async(i2s_slot->i2s, i2s_slot->slot, buffer, i2s_slot->buffer_size, pi_task_callback(task, i2s_slot_callback_tx_file_dumper, (void *)i2s_slot)); } } else { - pi_task_push(&i2s_slot->end_task); + if (i2s_slot->nb_sample_done == 0) + { + pi_task_push(&i2s_slot->end_task); + } } } @@ -546,6 +581,7 @@ int i2s_slot_callback_rx_iter_check(i2s_slot_test_t *i2s_slot, void *chunk, int { printf("Detected error (itf: %d, slot: %d, index: %d, nb_elem: %d, expected: 0x%x, got: 0x%x, address: %p)\n", i2s_slot->itf, i2s_slot->slot, i, nb_elem, current_value, value, address); i2s_slot->retval++; + exit(1); return 1; } @@ -564,7 +600,7 @@ void i2s_slot_callback_rx_iter(void *arg) void *chunk; int size; - if (pi_i2s_read_status(&i2s_slot->task, &chunk, (size_t *)&size)) + if (pi_i2s_read_status(&i2s_slot->task[0], &chunk, (size_t *)&size)) { i2s_slot->retval++; goto end; @@ -585,7 +621,7 @@ void i2s_slot_callback_rx_iter(void *arg) buffer += size; } - pi_i2s_frame_read_async(i2s_slot->i2s, i2s_slot->frame, pi_task_callback(&i2s_slot->task, i2s_slot_callback_rx_iter, (void *)i2s_slot)); + pi_i2s_frame_read_async(i2s_slot->i2s, i2s_slot->frame, pi_task_callback(&i2s_slot->task[0], i2s_slot_callback_rx_iter, (void *)i2s_slot)); if (i2s_slot->flags.use_slab) { @@ -597,7 +633,7 @@ void i2s_slot_callback_rx_iter(void *arg) if (i2s_slot_callback_rx_iter_check(i2s_slot, chunk, size)) goto end; - pi_i2s_channel_read_async(i2s_slot->i2s, i2s_slot->slot, pi_task_callback(&i2s_slot->task, i2s_slot_callback_rx_iter, (void *)i2s_slot)); + pi_i2s_channel_read_async(i2s_slot->i2s, i2s_slot->slot, pi_task_callback(&i2s_slot->task[0], i2s_slot_callback_rx_iter, (void *)i2s_slot)); if (i2s_slot->flags.use_slab) { @@ -643,11 +679,11 @@ int i2s_slot_start(i2s_slot_test_t *i2s_slot, i2s_slot_start_config_t *config) { if (i2s_slot->frame) { - pi_i2s_frame_read_async(i2s_slot->i2s, i2s_slot->frame, pi_task_callback(&i2s_slot->task, i2s_slot_callback_rx_iter, (void *)i2s_slot)); + pi_i2s_frame_read_async(i2s_slot->i2s, i2s_slot->frame, pi_task_callback(&i2s_slot->task[0], i2s_slot_callback_rx_iter, (void *)i2s_slot)); } else { - pi_i2s_channel_read_async(i2s_slot->i2s, i2s_slot->slot, pi_task_callback(&i2s_slot->task, i2s_slot_callback_rx_iter, (void *)i2s_slot)); + pi_i2s_channel_read_async(i2s_slot->i2s, i2s_slot->slot, pi_task_callback(&i2s_slot->task[0], i2s_slot_callback_rx_iter, (void *)i2s_slot)); } } } @@ -658,6 +694,7 @@ int i2s_slot_start(i2s_slot_test_t *i2s_slot, i2s_slot_start_config_t *config) i2s_slot->incr_value = config->tx_iter.incr_value; i2s_slot->current_value = config->tx_iter.incr_start; i2s_slot->nb_sample = config->tx_iter.nb_samples; + i2s_slot->nb_sample_done = config->tx_iter.nb_samples; if (i2s_slot->incr_value >= i2s_slot->incr_end) i2s_slot->incr_value = 0; @@ -738,14 +775,26 @@ int i2s_slot_start(i2s_slot_test_t *i2s_slot, i2s_slot_start_config_t *config) if (i2s_slot->frame) { i2s_slot_test_t *first_slot = &i2s_slot->test->slot_test_tx[__FF1(i2s_slot->frame)]; - pi_i2s_frame_write_async(first_slot->i2s, first_slot->frame, buffers[0], first_slot->buffer_size, pi_task_callback(&first_slot->task, i2s_slot_callback_tx_file_dumper, (void *)first_slot)); - pi_i2s_frame_write_async(first_slot->i2s, first_slot->frame, buffers[1], first_slot->buffer_size, pi_task_callback(&first_slot->task, i2s_slot_callback_tx_file_dumper, (void *)first_slot)); + if (first_slot->nb_sample > 0) + { + first_slot->nb_sample -= 2*first_slot->nb_elem; + } + first_slot->current_task = 0; + first_slot->current_handled_task = 0; + pi_i2s_frame_write_async(first_slot->i2s, first_slot->frame, buffers[0], first_slot->buffer_size, pi_task_callback(&first_slot->task[0], i2s_slot_callback_tx_file_dumper, (void *)first_slot)); + pi_i2s_frame_write_async(first_slot->i2s, first_slot->frame, buffers[1], first_slot->buffer_size, pi_task_callback(&first_slot->task[1], i2s_slot_callback_tx_file_dumper, (void *)first_slot)); } else { - pi_i2s_channel_write_async(i2s_slot->i2s, i2s_slot->slot, buffers[0], i2s_slot->buffer_size, pi_task_callback(&i2s_slot->task, i2s_slot_callback_tx_file_dumper, (void *)i2s_slot)); - pi_i2s_channel_write_async(i2s_slot->i2s, i2s_slot->slot, buffers[1], i2s_slot->buffer_size, pi_task_callback(&i2s_slot->task, i2s_slot_callback_tx_file_dumper, (void *)i2s_slot)); + if (i2s_slot->nb_sample > 0) + { + i2s_slot->nb_sample -= 2*i2s_slot->nb_elem; + } + i2s_slot->current_task = 0; + i2s_slot->current_handled_task = 0; + pi_i2s_channel_write_async(i2s_slot->i2s, i2s_slot->slot, buffers[0], i2s_slot->buffer_size, pi_task_callback(&i2s_slot->task[0], i2s_slot_callback_tx_file_dumper, (void *)i2s_slot)); + pi_i2s_channel_write_async(i2s_slot->i2s, i2s_slot->slot, buffers[1], i2s_slot->buffer_size, pi_task_callback(&i2s_slot->task[1], i2s_slot_callback_tx_file_dumper, (void *)i2s_slot)); } } } @@ -1058,128 +1107,3 @@ int i2s_test_stop(i2s_test_t *test) return 0; } - - -void testlib_hyperram_trafficgen_conf_init(testlib_hyperram_trafficgen_config_t *config) -{ - config->transfer_size = 8192; - config->itf = -1; - config->cs = -1; - config->frequency = -1; -} - - -int testlib_hyperram_trafficgen_init(testlib_hyperram_trafficgen_t *data, testlib_hyperram_trafficgen_config_t *config) -{ - struct pi_hyperram_conf conf; - pi_hyperram_conf_init(&conf); - - if (config->itf != -1) - { - conf.hyper_itf = config->itf; - } - if (config->cs != -1) - { - conf.hyper_cs = config->cs; - } - if (config->frequency != -1) - { - conf.baudrate = config->frequency; - } - - pi_open_from_conf(&data->dev, &conf); - - if (pi_ram_open(&data->dev)) - goto error0; - - if (pi_ram_alloc(&data->dev, &data->hyper_addr, config->transfer_size)) - goto error1; - - data->transfer_size = config->transfer_size; - - data->buffer = pi_l2_malloc(config->transfer_size); - if (data->buffer == NULL) goto error2; - - for (int i=0; itransfer_size/4; i++) - { - ((uint32_t *)data->buffer)[i] = i; - } - - return 0; - -error2: - pi_ram_free(&data->dev, data->hyper_addr, config->transfer_size); -error1: - pi_ram_close(&data->dev); -error0: - return -1; -} - - -static void testlib_hyperram_callback(void *arg) -{ - testlib_hyperram_trafficgen_t *data = (testlib_hyperram_trafficgen_t *)arg; - - if (data->end) - { - data->pending--; - if (data->pending == 0) - { - pi_task_push(&data->end_task); - } - return; - } - - if (data->is_read) - { - data->is_read = 0; - pi_ram_read_async(&data->dev, data->hyper_addr, data->buffer, data->transfer_size, pi_task_callback(&data->read_task, testlib_hyperram_callback, (void *)data)); - } - else - { - data->is_read = 1; - pi_ram_write_async(&data->dev, data->hyper_addr, data->buffer, data->transfer_size, pi_task_callback(&data->write_task, testlib_hyperram_callback, (void *)data)); - } -} - - -int testlib_hyperram_trafficgen_start(testlib_hyperram_trafficgen_t *data) -{ - data->is_read = 0; - data->end = 0; - data->pending = 2; - pi_task_block(&data->end_task); - pi_ram_write_async(&data->dev, data->hyper_addr, data->buffer, data->transfer_size, pi_task_callback(&data->read_task, testlib_hyperram_callback, (void *)data)); - pi_ram_read_async(&data->dev, data->hyper_addr, data->buffer, data->transfer_size, pi_task_callback(&data->write_task, testlib_hyperram_callback, (void *)data)); - return 0; -} - - -int testlib_hyperram_trafficgen_stop(testlib_hyperram_trafficgen_t *data) -{ - int errors = 0; - - data->end = 1; - - pi_task_wait_on(&data->end_task); - - for (int i=0; itransfer_size/4; i++) - { - uint32_t expected = i; - if (expected != ((uint32_t *)data->buffer)[i]) - { - errors++; - } - } - - return errors; -} - - -int testlib_hyperram_trafficgen_deinit(testlib_hyperram_trafficgen_t *data) -{ - pi_ram_free(&data->dev, data->hyper_addr, data->transfer_size); - pi_ram_close(&data->dev); - return 0; -} - diff --git a/libs/gap_lib/testbench/testlib.h b/libs/gap_lib/testbench/testlib.h index 1526893cc..650af5d7e 100644 --- a/libs/gap_lib/testbench/testlib.h +++ b/libs/gap_lib/testbench/testlib.h @@ -13,6 +13,9 @@ #include "pmsis.h" #include "testbench.h" +#include "testlib_i2s.h" +#include "testlib_uart.h" +#include "testlib_i2c.h" #define I2S_SLOT_STATIC_INIT {0} @@ -114,12 +117,15 @@ typedef struct int slot; int word_size; int elem_size; - pi_task_t task; + pi_task_t task[2]; + int current_task; + int current_handled_task; uint32_t incr_start; uint32_t incr_end; uint32_t incr_value; uint32_t current_value; int nb_sample; + int nb_sample_done; int is_rx; int buffer_size; int nb_elem; diff --git a/libs/gap_lib/testbench/testlib_hyper.c b/libs/gap_lib/testbench/testlib_hyper.c new file mode 100644 index 000000000..6ac967bc9 --- /dev/null +++ b/libs/gap_lib/testbench/testlib_hyper.c @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2017 GreenWaves Technologies + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD license. See the LICENSE file for details. + * + */ + +#include "pmsis.h" +#include "testbench.h" +#include "testlib.h" +#include +#include + + +void testlib_hyperram_trafficgen_conf_init(testlib_hyperram_trafficgen_config_t *config) +{ + config->transfer_size = 8192; + config->itf = -1; + config->cs = -1; + config->frequency = -1; +} + + +int testlib_hyperram_trafficgen_init(testlib_hyperram_trafficgen_t *data, testlib_hyperram_trafficgen_config_t *config) +{ + struct pi_hyperram_conf conf; + pi_hyperram_conf_init(&conf); + + if (config->itf != -1) + { + conf.hyper_itf = config->itf; + } + if (config->cs != -1) + { + conf.hyper_cs = config->cs; + } + if (config->frequency != -1) + { + conf.baudrate = config->frequency; + } + + pi_open_from_conf(&data->dev, &conf); + + if (pi_ram_open(&data->dev)) + goto error0; + + if (pi_ram_alloc(&data->dev, &data->hyper_addr, config->transfer_size)) + goto error1; + + data->transfer_size = config->transfer_size; + + data->buffer = pi_l2_malloc(config->transfer_size); + if (data->buffer == NULL) goto error2; + + for (int i=0; itransfer_size/4; i++) + { + ((uint32_t *)data->buffer)[i] = i; + } + + return 0; + +error2: + pi_ram_free(&data->dev, data->hyper_addr, config->transfer_size); +error1: + pi_ram_close(&data->dev); +error0: + return -1; +} + + +static void testlib_hyperram_callback(void *arg) +{ + testlib_hyperram_trafficgen_t *data = (testlib_hyperram_trafficgen_t *)arg; + + if (data->end) + { + data->pending--; + if (data->pending == 0) + { + pi_task_push(&data->end_task); + } + return; + } + + if (data->is_read) + { + data->is_read = 0; + pi_ram_read_async(&data->dev, data->hyper_addr, data->buffer, data->transfer_size, pi_task_callback(&data->read_task, testlib_hyperram_callback, (void *)data)); + } + else + { + data->is_read = 1; + pi_ram_write_async(&data->dev, data->hyper_addr, data->buffer, data->transfer_size, pi_task_callback(&data->write_task, testlib_hyperram_callback, (void *)data)); + } +} + + +int testlib_hyperram_trafficgen_start(testlib_hyperram_trafficgen_t *data) +{ + data->is_read = 0; + data->end = 0; + data->pending = 2; + pi_task_block(&data->end_task); + pi_ram_write_async(&data->dev, data->hyper_addr, data->buffer, data->transfer_size, pi_task_callback(&data->read_task, testlib_hyperram_callback, (void *)data)); + pi_ram_read_async(&data->dev, data->hyper_addr, data->buffer, data->transfer_size, pi_task_callback(&data->write_task, testlib_hyperram_callback, (void *)data)); + return 0; +} + + +int testlib_hyperram_trafficgen_stop(testlib_hyperram_trafficgen_t *data) +{ + int errors = 0; + + data->end = 1; + + pi_task_wait_on(&data->end_task); + + for (int i=0; itransfer_size/4; i++) + { + uint32_t expected = i; + if (expected != ((uint32_t *)data->buffer)[i]) + { + errors++; + } + } + + return errors; +} + + +int testlib_hyperram_trafficgen_deinit(testlib_hyperram_trafficgen_t *data) +{ + pi_ram_free(&data->dev, data->hyper_addr, data->transfer_size); + pi_ram_close(&data->dev); + return 0; +} + diff --git a/libs/gap_lib/testbench/testlib_i2c.c b/libs/gap_lib/testbench/testlib_i2c.c new file mode 100644 index 000000000..69ce83bfd --- /dev/null +++ b/libs/gap_lib/testbench/testlib_i2c.c @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2017 GreenWaves Technologies + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD license. See the LICENSE file for details. + * + */ + +#include "pmsis.h" +#include "testbench.h" +#include "testlib.h" +#include + + +void testlib_i2c_trafficgen_conf_init(testlib_i2c_trafficgen_config_t *config) +{ + config->transfer_size = 32; + config->itf = 0; + config->baudrate = 400000; +} + + +int testlib_i2c_trafficgen_init(testlib_i2c_trafficgen_t *data, testlib_i2c_trafficgen_config_t *config) +{ + struct pi_i2c_conf conf; + + data->transfer_size = config->transfer_size; + data->tx_buffers[0] = pi_l2_malloc(config->transfer_size); + data->tx_buffers[1] = pi_l2_malloc(config->transfer_size); + + if (data->tx_buffers[0] == NULL || data->tx_buffers[1] == NULL) + { + return -1; + } + + for (int i=0; itransfer_size; i++) + { + ((uint8_t *)data->tx_buffers[0])[i] = i; + ((uint8_t *)data->tx_buffers[1])[i] = i; + } + + pi_i2c_conf_init(&conf); + + conf.itf = config->itf; + //conf.max_baudrate = config->baudrate; + conf.cs = 0xA0; + + pi_open_from_conf(&data->dev, &conf); + + if (pi_i2c_open(&data->dev)) + { + return -1; + } + + return 0; +} + + +static void testlib_i2c_tx_callback(void *arg) +{ + testlib_i2c_trafficgen_t *data = (testlib_i2c_trafficgen_t *)arg; + + if (data->end) + { + data->tx_pending--; + if (data->tx_pending == 0) + { + pi_task_push(&data->tx_end_task); + } + return; + } + + pi_i2c_write_async(&data->dev, data->tx_buffers[data->tx_current_task], data->transfer_size, 0, pi_task_irq_callback(&data->tx_tasks[data->tx_current_task], testlib_i2c_tx_callback, (void *)data)); + data->tx_current_task ^= 1; +} + + +int testlib_i2c_trafficgen_start(testlib_i2c_trafficgen_t *data) +{ + data->end = 0; + + data->tx_pending = 2; + data->tx_current_task = 0; + pi_task_block(&data->tx_end_task); + pi_i2c_write_async(&data->dev, data->tx_buffers[0], data->transfer_size, 0, pi_task_irq_callback(&data->tx_tasks[0], testlib_i2c_tx_callback, (void *)data)); + pi_i2c_write_async(&data->dev, data->tx_buffers[1], data->transfer_size, 0, pi_task_irq_callback(&data->tx_tasks[1], testlib_i2c_tx_callback, (void *)data)); + + return 0; +} +int testlib_i2c_trafficgen_stop(testlib_i2c_trafficgen_t *data) +{ + int errors = 0; + + data->end = 1; + + pi_task_wait_on(&data->tx_end_task); + + return errors; +} + + +int testlib_i2c_trafficgen_deinit(testlib_i2c_trafficgen_t *data) +{ + pi_l2_free(data->tx_buffers[0], data->transfer_size); + pi_l2_free(data->tx_buffers[1], data->transfer_size); + pi_i2c_close(&data->dev); + return 0; +} + diff --git a/libs/gap_lib/testbench/testlib_i2c.h b/libs/gap_lib/testbench/testlib_i2c.h new file mode 100644 index 000000000..c97cbfd84 --- /dev/null +++ b/libs/gap_lib/testbench/testlib_i2c.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2017 GreenWaves Technologies + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD license. See the LICENSE file for details. + * + */ + +#pragma once + +#include "pmsis.h" + +typedef struct +{ + int itf; + int transfer_size; + int baudrate; +} testlib_i2c_trafficgen_config_t; + + +typedef struct +{ + pi_device_t dev; + uint32_t frame; + void *tx_buffers[2]; + pi_task_t tx_tasks[2]; + int tx_pending; + int tx_current_task; + pi_task_t tx_end_task; + int transfer_size; + int end; +} testlib_i2c_trafficgen_t; + + +void testlib_i2c_trafficgen_conf_init(testlib_i2c_trafficgen_config_t *config); +int testlib_i2c_trafficgen_init(testlib_i2c_trafficgen_t *data, testlib_i2c_trafficgen_config_t *config); +int testlib_i2c_trafficgen_start(testlib_i2c_trafficgen_t *data); +int testlib_i2c_trafficgen_stop(testlib_i2c_trafficgen_t *data); +int testlib_i2c_trafficgen_deinit(testlib_i2c_trafficgen_t *data); diff --git a/libs/gap_lib/testbench/testlib_i2s.c b/libs/gap_lib/testbench/testlib_i2s.c new file mode 100644 index 000000000..80d48128d --- /dev/null +++ b/libs/gap_lib/testbench/testlib_i2s.c @@ -0,0 +1,202 @@ +/* + * Copyright (C) 2017 GreenWaves Technologies + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD license. See the LICENSE file for details. + * + */ + +#include "pmsis.h" +#include "testbench.h" +#include "testlib.h" +#include + + +void testlib_i2s_trafficgen_conf_init(testlib_i2s_trafficgen_config_t *config) +{ + config->transfer_size = 128; + config->itf = 0; + config->sample_rate = 48000; + config->nb_slots = 16; + config->word_size = 32; +} + + +int testlib_i2s_trafficgen_init(testlib_i2s_trafficgen_t *data, testlib_i2s_trafficgen_config_t *config) +{ + struct pi_i2s_conf i2s_conf; + pi_i2s_conf_init(&i2s_conf); + + i2s_conf.frame_clk_freq = config->sample_rate; + i2s_conf.itf = config->itf; + i2s_conf.word_size = config->word_size; + i2s_conf.channels = config->nb_slots; + i2s_conf.options = PI_I2S_OPT_TDM | PI_I2S_OPT_FULL_DUPLEX; + + pi_open_from_conf(&data->dev, &i2s_conf); + if (pi_i2s_open(&data->dev)) + { + printf("Error opening i2s\n"); + return -3; + } + + struct pi_i2s_channel_conf i2s_slot_conf; + pi_i2s_channel_conf_init(&i2s_slot_conf); + uint16_t frame = (1 << config->nb_slots) - 1; + data->frame = frame; + for (int i=0; inb_slots; i++) + { + i2s_slot_conf.options = PI_I2S_OPT_IS_RX | PI_I2S_OPT_PINGPONG | PI_I2S_OPT_ENABLED; + i2s_slot_conf.word_size = config->word_size; + i2s_slot_conf.block_size = config->transfer_size; + + if (i == 0) + { + data->transfer_size = config->transfer_size * config->nb_slots; + i2s_slot_conf.pingpong_buffers[0] = pi_l2_malloc(data->transfer_size); + i2s_slot_conf.pingpong_buffers[1] = pi_l2_malloc(data->transfer_size); + data->rx_buffers[0] = i2s_slot_conf.pingpong_buffers[0]; + data->rx_buffers[1]= i2s_slot_conf.pingpong_buffers[1]; + + if (i2s_slot_conf.pingpong_buffers[0] == NULL || i2s_slot_conf.pingpong_buffers[1] == NULL) + { + printf("Error allocating memory\n"); + return -1; + } + } + + if (pi_i2s_frame_channel_conf_set(&data->dev, frame, i, &i2s_slot_conf)) + { + printf("Error setting conf channel\n"); + return -4; + } + } + + pi_i2s_channel_conf_init(&i2s_slot_conf); + for (int i=0; inb_slots; i++) + { + i2s_slot_conf.options = PI_I2S_OPT_IS_TX | PI_I2S_OPT_PINGPONG | PI_I2S_OPT_ENABLED; + i2s_slot_conf.word_size = config->word_size; + i2s_slot_conf.block_size = config->transfer_size; + + if (i == 0) + { + i2s_slot_conf.pingpong_buffers[0] = pi_l2_malloc(config->transfer_size * config->nb_slots); + i2s_slot_conf.pingpong_buffers[1] = pi_l2_malloc(config->transfer_size * config->nb_slots); + data->tx_buffers[0] = i2s_slot_conf.pingpong_buffers[0]; + data->tx_buffers[1]= i2s_slot_conf.pingpong_buffers[1]; + + if (i2s_slot_conf.pingpong_buffers[0] == NULL || i2s_slot_conf.pingpong_buffers[1] == NULL) + { + printf("Error allocating memory\n"); + return -1; + } + for (int i=0; itransfer_size * config->nb_slots; i++) + { + ((uint8_t *)i2s_slot_conf.pingpong_buffers[0])[i] = i; + ((uint8_t *)i2s_slot_conf.pingpong_buffers[1])[i] = i; + } + + } + + if (pi_i2s_frame_channel_conf_set(&data->dev, frame, i, &i2s_slot_conf)) + { + printf("Error setting conf channel\n"); + return -4; + } + } + + return 0; +} + + +static void testlib_i2s_rx_callback(void *arg) +{ + testlib_i2s_trafficgen_t *data = (testlib_i2s_trafficgen_t *)arg; + + if (data->end) + { + data->rx_pending--; + if (data->rx_pending == 0) + { + pi_task_push(&data->rx_end_task); + } + return; + } + + pi_i2s_frame_read_async(&data->dev, data->frame, pi_task_irq_callback(&data->rx_tasks[data->rx_current_task], testlib_i2s_rx_callback, (void *)data)); + data->rx_current_task ^= 1; +} + +static void testlib_i2s_tx_callback(void *arg) +{ + testlib_i2s_trafficgen_t *data = (testlib_i2s_trafficgen_t *)arg; + + if (data->end) + { + data->tx_pending--; + if (data->tx_pending == 0) + { + pi_task_push(&data->tx_end_task); + } + return; + } + + pi_i2s_frame_write_async(&data->dev, data->frame, NULL, 0, pi_task_irq_callback(&data->tx_tasks[data->tx_current_task], testlib_i2s_tx_callback, (void *)data)); + data->tx_current_task ^= 1; +} + + +int testlib_i2s_trafficgen_start(testlib_i2s_trafficgen_t *data) +{ + data->end = 0; + + data->tx_pending = 2; + data->tx_current_task = 0; + pi_task_block(&data->tx_end_task); + pi_i2s_frame_write_async(&data->dev, data->frame, NULL, 0, pi_task_irq_callback(&data->tx_tasks[0], testlib_i2s_tx_callback, (void *)data)); + pi_i2s_frame_write_async(&data->dev, data->frame, NULL, 0, pi_task_irq_callback(&data->tx_tasks[1], testlib_i2s_tx_callback, (void *)data)); + + data->rx_pending = 2; + data->rx_current_task = 0; + pi_task_block(&data->rx_end_task); + pi_i2s_frame_read_async(&data->dev, data->frame, pi_task_irq_callback(&data->rx_tasks[0], testlib_i2s_rx_callback, (void *)data)); + pi_i2s_frame_read_async(&data->dev, data->frame, pi_task_irq_callback(&data->rx_tasks[1], testlib_i2s_rx_callback, (void *)data)); + + if (pi_i2s_ioctl(&data->dev, PI_I2S_IOCTL_START, NULL)) + { + return -4; + } + return 0; +} + + +int testlib_i2s_trafficgen_stop(testlib_i2s_trafficgen_t *data) +{ + int errors = 0; + + data->end = 1; + + pi_task_wait_on(&data->tx_end_task); + pi_task_wait_on(&data->rx_end_task); + + if (pi_i2s_ioctl(&data->dev, PI_I2S_IOCTL_STOP, NULL)) + { + return -4; + } + + return errors; +} + + +int testlib_i2s_trafficgen_deinit(testlib_i2s_trafficgen_t *data) +{ + pi_l2_free(data->tx_buffers[0], data->transfer_size); + pi_l2_free(data->tx_buffers[1], data->transfer_size); + pi_l2_free(data->rx_buffers[0], data->transfer_size); + pi_l2_free(data->rx_buffers[1], data->transfer_size); + pi_i2s_close(&data->dev); + return 0; +} + diff --git a/libs/gap_lib/testbench/testlib_i2s.h b/libs/gap_lib/testbench/testlib_i2s.h new file mode 100644 index 000000000..2c4a2b2ce --- /dev/null +++ b/libs/gap_lib/testbench/testlib_i2s.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2017 GreenWaves Technologies + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD license. See the LICENSE file for details. + * + */ + +#pragma once + +#include "pmsis.h" + +typedef struct +{ + int itf; + int transfer_size; + int sample_rate; + int nb_slots; + int word_size; +} testlib_i2s_trafficgen_config_t; + + +typedef struct +{ + pi_device_t dev; + uint32_t frame; + void *tx_buffers[2]; + void *rx_buffers[2]; + pi_task_t rx_tasks[2]; + pi_task_t tx_tasks[2]; + int tx_pending; + int tx_current_task; + pi_task_t tx_end_task; + int rx_pending; + int rx_current_task; + pi_task_t rx_end_task; + int transfer_size; + int end; +} testlib_i2s_trafficgen_t; + + +void testlib_i2s_trafficgen_conf_init(testlib_i2s_trafficgen_config_t *config); +int testlib_i2s_trafficgen_init(testlib_i2s_trafficgen_t *data, testlib_i2s_trafficgen_config_t *config); +int testlib_i2s_trafficgen_start(testlib_i2s_trafficgen_t *data); +int testlib_i2s_trafficgen_stop(testlib_i2s_trafficgen_t *data); +int testlib_i2s_trafficgen_deinit(testlib_i2s_trafficgen_t *data); diff --git a/libs/gap_lib/testbench/testlib_uart.c b/libs/gap_lib/testbench/testlib_uart.c new file mode 100644 index 000000000..74b484b3e --- /dev/null +++ b/libs/gap_lib/testbench/testlib_uart.c @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2017 GreenWaves Technologies + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD license. See the LICENSE file for details. + * + */ + +#include "pmsis.h" +#include "testbench.h" +#include "testlib.h" +#include + + +void testlib_uart_trafficgen_conf_init(testlib_uart_trafficgen_config_t *config) +{ + config->transfer_size = 128; + config->itf = 0; + config->baudrate = 1000000; + config->control_flow = 1; +} + + +int testlib_uart_trafficgen_init(testlib_uart_trafficgen_t *data, testlib_uart_trafficgen_config_t *config) +{ + struct pi_uart_conf conf; + + data->transfer_size = config->transfer_size; + data->rx_buffers[0] = pi_l2_malloc(config->transfer_size); + data->rx_buffers[1] = pi_l2_malloc(config->transfer_size); + data->tx_buffers[0] = pi_l2_malloc(config->transfer_size); + data->tx_buffers[1] = pi_l2_malloc(config->transfer_size); + + if (data->rx_buffers[0] == NULL || data->rx_buffers[1] == NULL || data->tx_buffers[0] == NULL || data->tx_buffers[1] == NULL) + { + return -1; + } + + for (int i=0; itransfer_size; i++) + { + ((uint8_t *)data->tx_buffers[0])[i] = i; + ((uint8_t *)data->tx_buffers[1])[i] = i; + } + + pi_uart_conf_init(&conf); + + conf.use_ctrl_flow = config->control_flow; + conf.enable_tx = 1; + conf.enable_rx = 1; + conf.uart_id = config->itf; + conf.baudrate_bps = config->baudrate; + + pi_open_from_conf(&data->dev, &conf); + + if (pi_uart_open(&data->dev)) + { + return -1; + } + + return 0; +} + + +static void testlib_uart_rx_callback(void *arg) +{ + testlib_uart_trafficgen_t *data = (testlib_uart_trafficgen_t *)arg; + + if (data->end) + { + data->rx_pending--; + if (data->rx_pending == 0) + { + pi_task_push(&data->rx_end_task); + } + return; + } + + pi_uart_read_async(&data->dev, data->rx_buffers[data->rx_current_task], data->transfer_size, pi_task_irq_callback(&data->rx_tasks[data->rx_current_task], testlib_uart_rx_callback, (void *)data)); + data->rx_current_task ^= 1; +} + +static void testlib_uart_tx_callback(void *arg) +{ + testlib_uart_trafficgen_t *data = (testlib_uart_trafficgen_t *)arg; + + if (data->end) + { + data->tx_pending--; + if (data->tx_pending == 0) + { + pi_task_push(&data->tx_end_task); + } + return; + } + + pi_uart_write_async(&data->dev, data->tx_buffers[data->tx_current_task], data->transfer_size, pi_task_irq_callback(&data->tx_tasks[data->tx_current_task], testlib_uart_tx_callback, (void *)data)); + data->tx_current_task ^= 1; +} + + +int testlib_uart_trafficgen_start(testlib_uart_trafficgen_t *data) +{ + data->end = 0; + + data->tx_pending = 2; + data->tx_current_task = 0; + pi_task_block(&data->tx_end_task); + pi_uart_write_async(&data->dev, data->tx_buffers[0], data->transfer_size, pi_task_irq_callback(&data->tx_tasks[0], testlib_uart_tx_callback, (void *)data)); + pi_uart_write_async(&data->dev, data->tx_buffers[1], data->transfer_size, pi_task_irq_callback(&data->tx_tasks[1], testlib_uart_tx_callback, (void *)data)); + + data->rx_pending = 2; + data->rx_current_task = 0; + pi_task_block(&data->rx_end_task); + pi_uart_read_async(&data->dev, data->rx_buffers[0], data->transfer_size, pi_task_irq_callback(&data->rx_tasks[0], testlib_uart_rx_callback, (void *)data)); + pi_uart_read_async(&data->dev, data->rx_buffers[1], data->transfer_size, pi_task_irq_callback(&data->rx_tasks[1], testlib_uart_rx_callback, (void *)data)); + + return 0; +} + + +int testlib_uart_trafficgen_stop(testlib_uart_trafficgen_t *data) +{ + int errors = 0; + + data->end = 1; + + pi_task_wait_on(&data->tx_end_task); + pi_task_wait_on(&data->rx_end_task); + + return errors; +} + + +int testlib_uart_trafficgen_deinit(testlib_uart_trafficgen_t *data) +{ + pi_l2_free(data->tx_buffers[0], data->transfer_size); + pi_l2_free(data->tx_buffers[1], data->transfer_size); + pi_l2_free(data->rx_buffers[0], data->transfer_size); + pi_l2_free(data->rx_buffers[1], data->transfer_size); + pi_uart_close(&data->dev); + return 0; +} + diff --git a/libs/gap_lib/testbench/testlib_uart.h b/libs/gap_lib/testbench/testlib_uart.h new file mode 100644 index 000000000..f776509a1 --- /dev/null +++ b/libs/gap_lib/testbench/testlib_uart.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2017 GreenWaves Technologies + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD license. See the LICENSE file for details. + * + */ + +#pragma once + +#include "pmsis.h" + +typedef struct +{ + int itf; + int transfer_size; + int baudrate; + int control_flow; +} testlib_uart_trafficgen_config_t; + + +typedef struct +{ + pi_device_t dev; + uint32_t frame; + void *tx_buffers[2]; + void *rx_buffers[2]; + pi_task_t rx_tasks[2]; + pi_task_t tx_tasks[2]; + int tx_pending; + int tx_current_task; + pi_task_t tx_end_task; + int rx_pending; + int rx_current_task; + pi_task_t rx_end_task; + int transfer_size; + int end; +} testlib_uart_trafficgen_t; + + +void testlib_uart_trafficgen_conf_init(testlib_uart_trafficgen_config_t *config); +int testlib_uart_trafficgen_init(testlib_uart_trafficgen_t *data, testlib_uart_trafficgen_config_t *config); +int testlib_uart_trafficgen_start(testlib_uart_trafficgen_t *data); +int testlib_uart_trafficgen_stop(testlib_uart_trafficgen_t *data); +int testlib_uart_trafficgen_deinit(testlib_uart_trafficgen_t *data); diff --git a/libs/openmp/lib/omp.c b/libs/openmp/lib/omp.c index 745e1ae47..fb7cbcc58 100644 --- a/libs/openmp/lib/omp.c +++ b/libs/openmp/lib/omp.c @@ -1,12 +1,12 @@ #include "pmsis.h" #include "omp.h" -int omp_get_thread_num(void) +__attribute__((weak)) int omp_get_thread_num(void) { return pi_core_id(); } -int omp_get_num_threads(void) +__attribute__((weak)) int omp_get_num_threads(void) { return pi_cl_team_nb_cores(); } diff --git a/libs/openmp/tests/barrier/barrier.c b/libs/openmp/tests/barrier/barrier.c index cf74c5ed6..576830f3a 100644 --- a/libs/openmp/tests/barrier/barrier.c +++ b/libs/openmp/tests/barrier/barrier.c @@ -46,8 +46,8 @@ void helloworld(void) uint32_t core_id = pi_core_id(), cluster_id = pi_cluster_id(); printf("[%d %d] Hello World!\n", cluster_id, core_id); - struct pi_device cluster_dev = {0}; - struct pi_cluster_conf cl_conf = {0}; + struct pi_device cluster_dev; + struct pi_cluster_conf cl_conf; /* Init cluster configuration structure. */ pi_cluster_conf_init(&cl_conf); @@ -60,10 +60,9 @@ void helloworld(void) pmsis_exit(-1); } - /* Prepare cluster task and send it to cluster. */ - struct pi_cluster_task cl_task = {0}; - cl_task.entry = cluster_delegate; - cl_task.arg = NULL; + /* Prepare cluster task and se nd it to cluster. */ + struct pi_cluster_task cl_task; + pi_cluster_task(&cl_task, cluster_delegate, NULL); pi_cluster_send_task_to_cl(&cluster_dev, &cl_task); diff --git a/libs/openmp/tests/benchmark/bench.c b/libs/openmp/tests/benchmark/bench.c index 9220ef8f4..f9a4ae6bf 100644 --- a/libs/openmp/tests/benchmark/bench.c +++ b/libs/openmp/tests/benchmark/bench.c @@ -169,8 +169,8 @@ void launch_test(void) uint32_t errors = 0; uint32_t core_id = pi_core_id(), cluster_id = pi_cluster_id(); - struct pi_device cluster_dev = {0}; - struct pi_cluster_conf cl_conf = {0}; + struct pi_device cluster_dev; + struct pi_cluster_conf cl_conf; /* Init cluster configuration structure. */ pi_cluster_conf_init(&cl_conf); @@ -184,9 +184,8 @@ void launch_test(void) } /* Prepare cluster task and send it to cluster. */ - struct pi_cluster_task cl_task = {0}; - cl_task.entry = test_entry; - cl_task.arg = NULL; + struct pi_cluster_task cl_task; + pi_cluster_task(&cl_task, test_entry, NULL); pi_cluster_send_task_to_cl(&cluster_dev, &cl_task); diff --git a/libs/openmp/tests/benchmark/testset.cfg b/libs/openmp/tests/benchmark/testset.cfg index daa17de0c..cf85c9156 100644 --- a/libs/openmp/tests/benchmark/testset.cfg +++ b/libs/openmp/tests/benchmark/testset.cfg @@ -1,4 +1,5 @@ from plptest import * +import os TestConfig = c = {} diff --git a/libs/openmp/tests/for_simple/for_simple.c b/libs/openmp/tests/for_simple/for_simple.c index 8a1b0532e..598755205 100644 --- a/libs/openmp/tests/for_simple/for_simple.c +++ b/libs/openmp/tests/for_simple/for_simple.c @@ -52,8 +52,8 @@ void helloworld(void) uint32_t core_id = pi_core_id(), cluster_id = pi_cluster_id(); printf("[%d %d] Hello World!\n", cluster_id, core_id); - struct pi_device cluster_dev = {0}; - struct pi_cluster_conf cl_conf = {0}; + struct pi_device cluster_dev; + struct pi_cluster_conf cl_conf; /* Init cluster configuration structure. */ pi_cluster_conf_init(&cl_conf); @@ -67,9 +67,9 @@ void helloworld(void) } /* Prepare cluster task and send it to cluster. */ - struct pi_cluster_task cl_task = {0}; - cl_task.entry = cluster_delegate; - cl_task.arg = NULL; + struct pi_cluster_task cl_task; + + pi_cluster_task(&cl_task, cluster_delegate, NULL); pi_cluster_send_task_to_cl(&cluster_dev, &cl_task); diff --git a/libs/openmp/tests/for_variable/for_variable.c b/libs/openmp/tests/for_variable/for_variable.c index 2c636d77f..2395e18e6 100644 --- a/libs/openmp/tests/for_variable/for_variable.c +++ b/libs/openmp/tests/for_variable/for_variable.c @@ -63,8 +63,8 @@ void helloworld(void) uint32_t core_id = pi_core_id(), cluster_id = pi_cluster_id(); printf("[%d %d] Hello World!\n", cluster_id, core_id); - struct pi_device cluster_dev = {0}; - struct pi_cluster_conf cl_conf = {0}; + struct pi_device cluster_dev; + struct pi_cluster_conf cl_conf; /* Init cluster configuration structure. */ pi_cluster_conf_init(&cl_conf); @@ -78,9 +78,8 @@ void helloworld(void) } /* Prepare cluster task and send it to cluster. */ - struct pi_cluster_task cl_task = {0}; - cl_task.entry = cluster_delegate; - cl_task.arg = NULL; + struct pi_cluster_task cl_task; + pi_cluster_task(&cl_task, cluster_delegate, NULL); pi_cluster_send_task_to_cl(&cluster_dev, &cl_task); diff --git a/libs/openmp/tests/helloworld/helloworld.c b/libs/openmp/tests/helloworld/helloworld.c index 67fcb7330..63a481a3c 100644 --- a/libs/openmp/tests/helloworld/helloworld.c +++ b/libs/openmp/tests/helloworld/helloworld.c @@ -22,8 +22,8 @@ void helloworld(void) uint32_t core_id = pi_core_id(), cluster_id = pi_cluster_id(); printf("[%d %d] Hello World!\n", cluster_id, core_id); - struct pi_device cluster_dev = {0}; - struct pi_cluster_conf cl_conf = {0}; + struct pi_device cluster_dev; + struct pi_cluster_conf cl_conf; /* Init cluster configuration structure. */ pi_cluster_conf_init(&cl_conf); @@ -37,9 +37,9 @@ void helloworld(void) } /* Prepare cluster task and send it to cluster. */ - struct pi_cluster_task cl_task = {0}; - cl_task.entry = cluster_delegate; - cl_task.arg = NULL; + struct pi_cluster_task cl_task; + + pi_cluster_task(&cl_task, cluster_delegate, NULL); pi_cluster_send_task_to_cl(&cluster_dev, &cl_task); diff --git a/libs/openmp/tests/single/single.c b/libs/openmp/tests/single/single.c index 71737552c..95295e0b8 100644 --- a/libs/openmp/tests/single/single.c +++ b/libs/openmp/tests/single/single.c @@ -42,8 +42,8 @@ void helloworld(void) printf("Entering main controller\n"); uint32_t core_id = pi_core_id(), cluster_id = pi_cluster_id(); - struct pi_device cluster_dev = {0}; - struct pi_cluster_conf cl_conf = {0}; + struct pi_device cluster_dev; + struct pi_cluster_conf cl_conf; /* Init cluster configuration structure. */ pi_cluster_conf_init(&cl_conf); @@ -57,9 +57,8 @@ void helloworld(void) } /* Prepare cluster task and send it to cluster. */ - struct pi_cluster_task cl_task = {0}; - cl_task.entry = cluster_delegate; - cl_task.arg = NULL; + struct pi_cluster_task cl_task; + pi_cluster_task(&cl_task, cluster_delegate, NULL); pi_cluster_send_task_to_cl(&cluster_dev, &cl_task); diff --git a/requirements.txt b/requirements.txt index 39374240d..b88eaaa7f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ -pyelftools==0.24 +pyelftools>=0.24 prettytable==0.7.2 +pexpect>=4.0.0,<5 configparser argcomplete requests diff --git a/rtos/freeRTOS/CMakeLists.txt b/rtos/freeRTOS/CMakeLists.txt index 1f33fff5e..b46d43a4b 100644 --- a/rtos/freeRTOS/CMakeLists.txt +++ b/rtos/freeRTOS/CMakeLists.txt @@ -96,7 +96,7 @@ add_subdirectory(vendors/gwt) add_subdirectory(demos/gwt/config/gap9) add_subdirectory(freertos_kernel) add_subdirectory(freertos_kernel/portable) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../pmsis/pmsis_api ${CMAKE_CURRENT_BINARY_DIR}/pmsis_api) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../pmsis ${CMAKE_CURRENT_BINARY_DIR}/pmsis) @@ -121,6 +121,7 @@ target_link_libraries(freertos PUBLIC pmsis_implem_gap9) target_link_libraries(freertos PUBLIC pmsis_freertos) target_link_libraries(freertos PUBLIC freertos_libs) target_link_libraries(freertos PUBLIC pmsis_api) +target_link_libraries(freertos PUBLIC pmsis_implem) target_link_libraries(freertos PUBLIC freertos_printf) target_link_libraries(freertos PUBLIC freertos_kernel) target_link_libraries(freertos PUBLIC freertos_config_gap9) @@ -133,12 +134,12 @@ endif() if(CONFIG_USE_BSP) install(TARGETS freertos ri5cy-gap9 freertos_gap9 pmsis_implem_gap9 pmsis_freertos - freertos_libs pmsis_api freertos_printf freertos_kernel freertos_config_gap9 + freertos_libs pmsis_api freertos_printf freertos_kernel pmsis_implem freertos_config_gap9 pmsis_rtos freertos_pmsis_backend bsp EXPORT freertosTargets) else() install(TARGETS freertos ri5cy-gap9 freertos_gap9 pmsis_implem_gap9 pmsis_freertos - freertos_libs pmsis_api freertos_printf freertos_kernel freertos_config_gap9 + freertos_libs pmsis_api freertos_printf freertos_kernel pmsis_implem freertos_config_gap9 pmsis_rtos freertos_pmsis_backend EXPORT freertosTargets) diff --git a/rtos/freeRTOS/freertos_kernel/include/FreeRTOS.h b/rtos/freeRTOS/freertos_kernel/include/FreeRTOS.h index 5e443a629..05f007802 100644 --- a/rtos/freeRTOS/freertos_kernel/include/FreeRTOS.h +++ b/rtos/freeRTOS/freertos_kernel/include/FreeRTOS.h @@ -871,7 +871,7 @@ #endif #ifndef configTASK_NOTIFICATION_ARRAY_ENTRIES - #define configTASK_NOTIFICATION_ARRAY_ENTRIES 1 + #define configTASK_NOTIFICATION_ARRAY_ENTRIES 2 #endif #if configTASK_NOTIFICATION_ARRAY_ENTRIES < 1 diff --git a/rtos/freeRTOS/vendors/gwt/gap8/include/device/system_gap8.h b/rtos/freeRTOS/vendors/gwt/gap8/include/device/system_gap8.h index 5a2cfacdc..df7858606 100644 --- a/rtos/freeRTOS/vendors/gwt/gap8/include/device/system_gap8.h +++ b/rtos/freeRTOS/vendors/gwt/gap8/include/device/system_gap8.h @@ -67,6 +67,15 @@ void system_init(void); */ void system_setup_systick(uint32_t tick_rate_hz); + +/** + * @brief Setup timer used for wait_time. + * + * This function sets up high timer at REF CLK / 2 tick rate. + * + */ +void system_setup_timer(void); + /** * @brief Update the SystemCoreClock variable. * diff --git a/rtos/freeRTOS/vendors/gwt/gap8/pmsis/include/cores/TARGET_RISCV_32/core_gap.h b/rtos/freeRTOS/vendors/gwt/gap8/pmsis/include/cores/TARGET_RISCV_32/core_gap.h index 3630ecbdc..d1d624f2f 100644 --- a/rtos/freeRTOS/vendors/gwt/gap8/pmsis/include/cores/TARGET_RISCV_32/core_gap.h +++ b/rtos/freeRTOS/vendors/gwt/gap8/pmsis/include/cores/TARGET_RISCV_32/core_gap.h @@ -523,6 +523,10 @@ typedef struct __IOM uint32_t MASK_IRQ_AND; /**< EU_DEMUX mask irq and register, offset: 0x10 */ __IOM uint32_t MASK_IRQ_OR; /**< EU_DEMUX mask irq or register, offset: 0x14 */ __IOM uint32_t STATUS; /**< EU_DEMUX Status register, offset: 0x18 */ + __IOM uint32_t BUFFER; /**< EU_DEMUX buffer register, offset: 0x1C */ + __IOM uint32_t BUFFER_MASKED; /**< EU_DEMUX buffer masked register, offset: 0x20 */ + __IOM uint32_t BUFFER_IRQ_MASKED; /**< EU_DEMUX buffer irq masked register, offset: 0x24 */ + __IOM uint32_t BUFFER_CLEAR; /**< EU_DEMUX buffer clear register, offset: 0x28 */ } NVIC_Type; /*@} end of group CMSIS_NVIC */ @@ -1302,6 +1306,7 @@ __STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) */ __STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) { + NVIC->BUFFER_CLEAR = 1 << IRQn; } diff --git a/rtos/freeRTOS/vendors/gwt/gap8/pmsis/include/pmsis/implem/drivers/drivers.h b/rtos/freeRTOS/vendors/gwt/gap8/pmsis/include/pmsis/implem/drivers/drivers.h index f5a72ddec..85e653ab6 100644 --- a/rtos/freeRTOS/vendors/gwt/gap8/pmsis/include/pmsis/implem/drivers/drivers.h +++ b/rtos/freeRTOS/vendors/gwt/gap8/pmsis/include/pmsis/implem/drivers/drivers.h @@ -38,6 +38,7 @@ #include "pmsis/chips/gap8/pad.h" #include "pmsis/chips/gap8/gpio.h" #include "pmsis/chips/gap8/pmu.h" +#include "pmsis/chips/gap8/timer.h" /* Drivers. */ #include "pmsis/drivers/cpi.h" diff --git a/rtos/freeRTOS/vendors/gwt/gap8/pmsis/include/pmsis/implem/drivers/timer/timer.h b/rtos/freeRTOS/vendors/gwt/gap8/pmsis/include/pmsis/implem/drivers/timer/timer.h index da1ea6a48..ae15ecdac 100644 --- a/rtos/freeRTOS/vendors/gwt/gap8/pmsis/include/pmsis/implem/drivers/timer/timer.h +++ b/rtos/freeRTOS/vendors/gwt/gap8/pmsis/include/pmsis/implem/drivers/timer/timer.h @@ -32,6 +32,7 @@ #define __PI_TIMER_H__ #include +#include "pmsis/chips/gap8/timer.h" #include "pmsis/targets/target.h" #include "pmsis/implem/hal/hal.h" @@ -56,6 +57,7 @@ *****************************************************************************/ /* @brief Timers. */ +#if 0 typedef enum { SYS_TIMER = 0, /*!< FC_TIMER_0 used as SysTick timer by preemptive RTOS. */ @@ -64,6 +66,8 @@ typedef enum CL_TIMER_0 = 2, /*!< Cluster Timer_Low. */ CL_TIMER_1 = 3 /*!< Cluster Timer_High. */ } timer_e; +#endif +typedef pi_timer_e timer_e; /******************************************************************************* * Function declaration diff --git a/rtos/freeRTOS/vendors/gwt/gap8/src/device/gap8_iet.S b/rtos/freeRTOS/vendors/gwt/gap8/src/device/gap8_iet.S index 7beb6b35b..da3d51049 100644 --- a/rtos/freeRTOS/vendors/gwt/gap8/src/device/gap8_iet.S +++ b/rtos/freeRTOS/vendors/gwt/gap8/src/device/gap8_iet.S @@ -49,6 +49,7 @@ .extern fc_soc_event_handler .extern pi_cl_dma_2d_handler .extern uTaskCheckQuantum + .extern __pi_task_timer_irq .extern pi_task_delayed_increment_push .extern ASM_FUNC_SAVE_MINIMAL_CONTEXT .extern ASM_FUNC_SAVE_SAVE_CONTEXT @@ -201,6 +202,27 @@ _no_switch: .endfunc + DECLARE hi_res_timer_handler + /* FC hi res timer handler */ + addi sp, sp, -(PI_GAP8_FULL_CONTEXT_SIZE * PI_WORD_SIZE) + sw ra, 0*PI_WORD_SIZE(sp) + jal ra, ASM_FUNC_SAVE_MINIMAL_CONTEXT + lw tp, pxCurrentTCB + sw sp, 0*0(tp) + + /* ISR Stack. */ + la sp, __stack_irq_start__ + jal ra, __pi_task_timer_irq + + /* Restore current context. */ + lw tp, pxCurrentTCB + lw sp, 0*0(tp) + jal ra, ASM_FUNC_RESTORE_MINIMAL_CONTEXT + lw ra, 0*PI_WORD_SIZE(sp) + addi sp, sp, +(PI_GAP8_FULL_CONTEXT_SIZE * PI_WORD_SIZE) + mret + .endfunc + /* FC SOC event Handler. */ DECLARE fc_event_handler /* Save current context. */ diff --git a/rtos/freeRTOS/vendors/gwt/gap8/src/device/startup_gap8.S b/rtos/freeRTOS/vendors/gwt/gap8/src/device/startup_gap8.S index b7be24e00..fe4f1e84b 100644 --- a/rtos/freeRTOS/vendors/gwt/gap8/src/device/startup_gap8.S +++ b/rtos/freeRTOS/vendors/gwt/gap8/src/device/startup_gap8.S @@ -151,7 +151,7 @@ _jump2main: /* Jump to main */ j default_handler /* IRQ=8 : undefined */ j dma_irq_handler /* IRQ=9 : DMA IRQ Handler. */ j systick_handler /* IRQ=10 : Systick Handler. */ - j default_handler /* IRQ=11 : undefined */ + j hi_res_timer_handler /* IRQ=11 : hi res timer irq handler */ j default_handler /* IRQ=12 : undefined */ j default_handler /* IRQ=13 : undefined */ j default_handler /* IRQ=14 : undefined */ diff --git a/rtos/freeRTOS/vendors/gwt/gap8/src/device/system_gap8.c b/rtos/freeRTOS/vendors/gwt/gap8/src/device/system_gap8.c index da84e0e9e..b9d56565e 100644 --- a/rtos/freeRTOS/vendors/gwt/gap8/src/device/system_gap8.c +++ b/rtos/freeRTOS/vendors/gwt/gap8/src/device/system_gap8.c @@ -33,7 +33,7 @@ /* PMSIS includes. */ #include "pmsis.h" -#include "../driver/semihost.h" +#include "semihost.h" /* FC & L2 heaps. */ extern char __heapfcram_start; @@ -44,6 +44,7 @@ extern char __heapl2ram_size; volatile uint32_t SystemCoreClock = (uint32_t) ARCHI_FREQ_INIT; static volatile uint32_t tick_rate = 0; +static volatile uint32_t timer_tick_rate = 0; void system_init(void) { @@ -105,6 +106,34 @@ void system_core_clock_update(uint32_t new_freq) cfg.field.mode = 1; uint32_t cmp_val = ((SystemCoreClock / tick_rate) - 1); pi_timer_init(SYS_TIMER, cfg, cmp_val); + // Init precise timer + pi_timer_stop(FC_TIMER_1); + + /* Systick timer configuration. */ + timer_cfg_u cfg_timer = {0}; + cfg_timer.field.enable = 1; + cfg_timer.field.reset = 1; + cfg_timer.field.irq_en = 1; + cfg_timer.field.mode = 1; + /* Start the timer by putting a CMP value. */ + cmp_val = ((SystemCoreClock / timer_tick_rate) - 1); + pi_timer_init(FC_TIMER_1, cfg_timer, cmp_val); + /* Enable IRQ from Systick timer. */ +} + +void system_setup_timer(void) +{ + /* Systick timer configuration. */ + timer_cfg_u cfg = {0}; + cfg.field.enable = 1; + cfg.field.reset = 1; + cfg.field.irq_en = 1; + cfg.field.mode = 1; + cfg.field.clk_source = 1; + /* Start the timer by putting a CMP value. */ + uint32_t cmp_val = 2; //((32768 / timer_tick_rate) - 1); + pi_timer_init(FC_TIMER_1, cfg, cmp_val); + /* Enable IRQ from Systick timer. */ } uint32_t system_core_clock_get(void) diff --git a/rtos/freeRTOS/vendors/gwt/gap8/include/driver/semihost.h b/rtos/freeRTOS/vendors/gwt/libs/include/semihost.h similarity index 63% rename from rtos/freeRTOS/vendors/gwt/gap8/include/driver/semihost.h rename to rtos/freeRTOS/vendors/gwt/libs/include/semihost.h index fba61196c..81ba11c44 100644 --- a/rtos/freeRTOS/vendors/gwt/gap8/include/driver/semihost.h +++ b/rtos/freeRTOS/vendors/gwt/libs/include/semihost.h @@ -20,6 +20,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + enum semihosting_operation_numbers { /* * ARM/openocd semihosting operations. @@ -64,7 +68,7 @@ enum semihosting_operation_numbers { #define SEMIHOST_EXIT_SUCCESS 0x20026 #define SEMIHOST_EXIT_ERROR 0x20023 -extern long __syscall_error(long); +//extern long __syscall_error(long); /* riscv semihosting standard: * IN: a0 holds syscall number @@ -101,20 +105,52 @@ __internal_semihost(long n, long _a1) // roughly this is the last stage of printf: // print a string until '\0' -void semihost_write0(const char *print_string); - -int semihost_open(const char *name, int mode); +static inline void semihost_write0(const char *print_string) +{ + __internal_semihost(SEMIHOSTING_SYS_WRITE0, (long) print_string); +} -int semihost_close(int fd); +static inline int semihost_open(const char *name, int mode) +{ + uint32_t len = strlen(name); + volatile uint32_t args[3] = {(uint32_t)name,mode,len}; + return __internal_semihost(SEMIHOSTING_SYS_OPEN, (long) args); +} -int semihost_read(int fd, uint8_t *buffer, int len); +static inline int semihost_close(int fd) +{ + //uint32_t args[3] = {name,mode,len}; + return __internal_semihost(SEMIHOSTING_SYS_CLOSE, (long) fd); +} -int semihost_write(int fd, uint8_t *buffer, int len); +static inline int semihost_read(int fd, uint8_t *buffer, int len) +{ + volatile uint32_t args[3] = {(uint32_t)fd,(uint32_t)buffer,(uint32_t)len}; + return __internal_semihost(SEMIHOSTING_SYS_READ, (long) args); +} -int semihost_seek(int fd, uint32_t pos); +static inline int semihost_write(int fd, uint8_t *buffer, int len) +{ + volatile uint32_t args[3] = {(uint32_t)fd,(uint32_t)buffer,(uint32_t)len}; + return __internal_semihost(SEMIHOSTING_SYS_WRITE, (long) args); +} -int semihost_flen(int fd); +static inline int semihost_seek(int fd, uint32_t pos) +{ + volatile uint32_t args[2] = {(uint32_t)fd,pos}; + return __internal_semihost(SEMIHOSTING_SYS_SEEK, (long) args); +} -int semihost_exit(int code); +static inline int semihost_flen(int fd) +{ + return __internal_semihost(SEMIHOSTING_SYS_FLEN, (long) fd); +} +static inline int semihost_exit(int code) +{ + return __internal_semihost(SEMIHOSTING_SYS_EXIT, (long) code); +} +#ifdef __cplusplus +} +#endif #endif diff --git a/rtos/freeRTOS/vendors/gwt/pmsis/backend/pmsis_backend_native_task_api.c b/rtos/freeRTOS/vendors/gwt/pmsis/backend/pmsis_backend_native_task_api.c index 48aaa506f..15e67449a 100644 --- a/rtos/freeRTOS/vendors/gwt/pmsis/backend/pmsis_backend_native_task_api.c +++ b/rtos/freeRTOS/vendors/gwt/pmsis/backend/pmsis_backend_native_task_api.c @@ -2,6 +2,9 @@ #include "pmsis.h" #include "driver/gap_io.h" + +void pi_task_timer_enqueue(struct pi_task *task, uint32_t delay_us); + /** * Kickoff the first "main" os task and scheduler */ @@ -62,21 +65,30 @@ void pi_time_wait_us(int time_us) //time_us--; if (time_us > 0) { +#ifdef __GAP8__ + // correct the setup time if wait is short, -10 us ==> about 500 cycles max + // also do not go below 100 us resolution + + uint32_t wait_time = time_us < 100 ? 100 : time_us; + pi_task_t task_block; + pi_task_block(&task_block); + pi_task_timer_enqueue(&task_block, wait_time); + pi_task_wait_on(&task_block); +#else /* Wait less than 1 ms. */ if (time_us < 1000) { - uint32_t irq = pi_irq_disable(); - uint32_t freq_fc = pi_freq_get(PI_FREQ_DOMAIN_FC); - //uint64_t counter = (uint64_t) (((uint64_t) time_us) * freq_fc) / 1000000; - //uint64_t counter = (uint64_t) (((uint64_t) time_us) * freq_fc); - uint64_t freq = (uint64_t) ((uint64_t) time_us * (uint64_t) freq_fc); - uint32_t counter = (uint32_t) ((freq) >> 20); - //counter >>= 20; /* Div 10^6 */ - //uint32_t counter = (uint32_t) time_us; - //counter = (counter * freq_fc) / 1000000; - //printf("counter=%ld, freq=%ld, time_us=%d\n", counter, freq_fc, time_us); +#ifdef __VEGA__ + int irq = pi_irq_disable(); + for (volatile int i = 0; i < time_us; i++){}; pi_irq_restore(irq); - for (volatile uint32_t i=0; idata[8] = ((delay_us)/ref_clk_us) + + (((delay_us)%ref_clk_us) > 0); + //printf("ticks: %i\n ref_clk_us: %i\n rem: %i\n",task->data[8] + // ,ref_clk_us + // ,(((delay_us)%ref_clk_us) > 0)); + task->next = NULL; + if (delayed_task.fifo_head == NULL) + { + delayed_task.fifo_head = task; + // IRQ might have been disabled due to no timer pending + system_setup_timer(); + NVIC_ClearPendingIRQ(FC_IRQ_TIMER0_HI_EVT); + NVIC_EnableIRQ(FC_IRQ_TIMER0_HI_EVT); + } + else + { + delayed_task.fifo_tail->next = task; + } + delayed_task.fifo_tail = task; +} + + +// push timer pi task to unlock +// --> No callback is allowed here, only timed waits +void __pi_task_timer_irq(void) +{ + struct pi_task *task = delayed_task.fifo_head; + struct pi_task *prev_task = delayed_task.fifo_head; + while (task != NULL) + { + task->data[8]--; + if ((int32_t) task->data[8] <= 0) + { + if (task == delayed_task.fifo_head) + { + delayed_task.fifo_head = task->next; + } + else + { + prev_task->next = task->next; + } + // pi task is mandatorily a blocking task + pi_task_release(task); + } + prev_task = task; + task = task->next; + } + if(!delayed_task.fifo_head) + {// no tasks at all --> disable irq + pi_timer_stop(FC_TIMER_1); + NVIC_DisableIRQ(FC_IRQ_TIMER0_HI_EVT); + } +} +#endif /* __GAP8__ */ + // return value allows to skip some OS logic when a switch has already been triggered int pi_task_delayed_increment_push(void) { diff --git a/rtos/freeRTOS/vendors/gwt/pmsis/include/pmsis/backend/implementation_specific_defines.h b/rtos/freeRTOS/vendors/gwt/pmsis/include/pmsis/backend/implementation_specific_defines.h index c18724f57..02fd95137 100644 --- a/rtos/freeRTOS/vendors/gwt/pmsis/include/pmsis/backend/implementation_specific_defines.h +++ b/rtos/freeRTOS/vendors/gwt/pmsis/include/pmsis/backend/implementation_specific_defines.h @@ -26,7 +26,8 @@ #define pi_data_free(x,y) pmsis_l2_malloc_free(x,y) #define PI_TASK_IMPLEM \ - uint8_t destroy; + uint8_t destroy; \ + uint32_t time; #define PI_TASK_IMPLEM_NB_DATA 9 diff --git a/rtos/freeRTOS/vendors/gwt/pmsis/include/pmsis/backend/pmsis_backend_native_task_api.h b/rtos/freeRTOS/vendors/gwt/pmsis/include/pmsis/backend/pmsis_backend_native_task_api.h index 3fc2f7763..7ce9bfd03 100644 --- a/rtos/freeRTOS/vendors/gwt/pmsis/include/pmsis/backend/pmsis_backend_native_task_api.h +++ b/rtos/freeRTOS/vendors/gwt/pmsis/include/pmsis/backend/pmsis_backend_native_task_api.h @@ -154,7 +154,7 @@ static inline int __os_native_api_sync_obj_deinit(void *sync_obj) static inline void __os_native_api_sync_obj_take(void *sync_obj) { - ulTaskNotifyTake(pdTRUE, portMAX_DELAY); + ulTaskNotifyTakeIndexed(1, pdTRUE, portMAX_DELAY); } static inline void __os_native_api_sync_obj_release(void *sync_obj) @@ -162,7 +162,7 @@ static inline void __os_native_api_sync_obj_release(void *sync_obj) uint32_t irq = __disable_irq(); BaseType_t higher_priority_task_woken = pdFALSE; TaskHandle_t task_handler = (TaskHandle_t) sync_obj; - vTaskNotifyGiveFromISR(task_handler, &higher_priority_task_woken); + vTaskNotifyGiveIndexedFromISR(task_handler, 1, &higher_priority_task_woken); portYIELD_FROM_ISR(higher_priority_task_woken); __restore_irq(irq); } diff --git a/rtos/freeRTOS/vendors/gwt/pmsis/rtos/include/pmsis/rtos/os/pmsis_task.h b/rtos/freeRTOS/vendors/gwt/pmsis/rtos/include/pmsis/rtos/os/pmsis_task.h index 78e06acd8..38b08f218 100644 --- a/rtos/freeRTOS/vendors/gwt/pmsis/rtos/include/pmsis/rtos/os/pmsis_task.h +++ b/rtos/freeRTOS/vendors/gwt/pmsis/rtos/include/pmsis/rtos/os/pmsis_task.h @@ -55,21 +55,6 @@ */ pi_task_t *__pi_task_block(pi_task_t *task); -/** - * \brief Prepare an event task with callback. - * - * This function initializes an instance of event task. - * This event task executes the callback given in argument. - * - * \param callback_task Pointer to event task. - * \param func Callback function. - * \param arg Callback function argument. - * - * \return task This function returns the event task initialized. - */ -pi_task_t *__pi_task_callback(pi_task_t *callback_task, - void (*func)(void *), void *arg); - /** * \brief Wait on an event task. * @@ -110,6 +95,21 @@ void __pi_task_destroy(pi_task_t *task); */ void pi_task_delayed_fifo_enqueue(struct pi_task *task, uint32_t delay_us); + +static inline void __pi_task_push_no_irq(pi_task_t *task) +{ + pmsis_event_push(pmsis_event_get_default_scheduler(), task); +} + +static inline void __pi_task_push_exec_irq_safe(pi_task_t *task) +{ + pi_callback_func_t func = (pi_callback_func_t) task->arg[0]; + void *arg = (void *) task->arg[1]; + func(arg); +} + +void __pi_task_push_locked(pi_task_t * task); + /******************************************************************************* * API implementation ******************************************************************************/ @@ -122,15 +122,24 @@ static inline pi_task_t *pi_task_block(pi_task_t *task) static inline pi_task_t *pi_task_callback(pi_task_t *task, void (*callback)(void*), void *arg) { - return __pi_task_callback(task, callback, arg); + task->id = PI_TASK_CALLBACK_ID; + task->arg[0] = (uintptr_t) callback; + task->arg[1] = (uintptr_t) arg; + task->done = 0; + task->sync_obj = NULL; + //task->destroy = 0; + task->core_id = -1; + task->timeout = 0; + task->next = NULL; + return task; } static inline pi_task_t *pi_task_irq_callback(pi_task_t *task, - void (*callback)(void*), void *arg) + void (*callback)(void*), void *arg) { task->id = PI_TASK_IRQ_ID; - task->arg[0] = (uintptr_t)callback; - task->arg[1] = (uintptr_t)arg; + task->arg[0] = (uintptr_t) callback; + task->arg[1] = (uintptr_t) arg; return task; } @@ -139,19 +148,16 @@ static inline void pi_task_wait_on(pi_task_t *task) __pi_task_wait_on(task); } +static inline void pi_task_push_irq_safe(pi_task_t *task) +{ + __pi_task_push_locked(task); +} + static inline void pi_task_push(pi_task_t *task) { - switch (task->id) - { - case PI_TASK_NONE_ID : - pi_task_release(task); - break; - case PI_TASK_CALLBACK_ID : - __pi_task_push(task); - break; - default : - return; - } + uint32_t irq = pi_irq_disable(); + __pi_task_push_locked(task); + pi_irq_restore(irq); } static inline void pi_task_destroy(pi_task_t *task) @@ -169,6 +175,16 @@ static inline int32_t pi_task_transfer_end_result_get(pi_task_t *task) return task->arg[3]; } +static inline int32_t pi_task_status_get(pi_task_t *task) +{ + return task->arg[3]; +} + +static inline void pi_task_status_set(pi_task_t *task, int32_t status) +{ + task->arg[3] = status; +} + static inline void pi_task_timeout_callback_set(pi_task_t *task, pi_callback_func_t func, void *arg) { diff --git a/rtos/freeRTOS/vendors/gwt/pmsis/rtos/os/pmsis_task.c b/rtos/freeRTOS/vendors/gwt/pmsis/rtos/os/pmsis_task.c index ee3ae0893..83bbc2956 100644 --- a/rtos/freeRTOS/vendors/gwt/pmsis/rtos/os/pmsis_task.c +++ b/rtos/freeRTOS/vendors/gwt/pmsis/rtos/os/pmsis_task.c @@ -43,22 +43,7 @@ pi_task_t *__pi_task_block(pi_task_t *callback_task) callback_task->id = PI_TASK_NONE_ID; callback_task->done = 0; pi_sync_obj_init((void *) &(callback_task->sync_obj)); - callback_task->destroy = 1; - callback_task->core_id = -1; - callback_task->timeout = 0; - callback_task->next = NULL; - return callback_task; -} - -pi_task_t *__pi_task_callback(pi_task_t *callback_task, - pi_callback_func_t func, void *arg) -{ - callback_task->id = PI_TASK_CALLBACK_ID; - callback_task->arg[0] = (uintptr_t) func; - callback_task->arg[1] = (uintptr_t) arg; - callback_task->done = 0; - callback_task->sync_obj = NULL; - callback_task->destroy = 0; + //callback_task->destroy = 1; callback_task->core_id = -1; callback_task->timeout = 0; callback_task->next = NULL; @@ -67,16 +52,16 @@ pi_task_t *__pi_task_callback(pi_task_t *callback_task, void __pi_task_destroy(pi_task_t *task) { - if (task->destroy) + //if (task->destroy) { - task->destroy = 0; + //task->destroy = 0; // if the mutex is only virtual (e.g. wait on soc event) - hal_compiler_barrier(); + //hal_compiler_barrier(); if (task->sync_obj != NULL) { pi_sync_obj_deinit((void *) &(task->sync_obj)); } - hal_compiler_barrier(); + //hal_compiler_barrier(); } } @@ -96,12 +81,14 @@ void __pi_task_wait_on(pi_task_t *task) __pi_task_destroy(task); } +#if 0 void __pi_task_push(pi_task_t *task) { uint32_t irq = disable_irq(); pmsis_event_push(pmsis_event_get_default_scheduler(), task); restore_irq(irq); } +#endif /******************************************************************************* * API implementation @@ -118,13 +105,34 @@ pi_task_t *pi_task_block_no_mutex(pi_task_t *callback_task) callback_task->id = PI_TASK_NONE_ID; callback_task->done = 0; callback_task->sync_obj = NULL; - callback_task->destroy = 0; + //callback_task->destroy = 0; callback_task->core_id = -1; callback_task->timeout = 0; callback_task->next = NULL; return callback_task; } +void __pi_task_push_locked(pi_task_t * task) +{ + switch (task->id) + { + case PI_TASK_NONE_ID : + pi_task_release(task); + break; + + case PI_TASK_CALLBACK_ID : + __pi_task_push_no_irq(task); + break; + + case PI_TASK_IRQ_ID : + __pi_task_push_exec_irq_safe(task); + break; + + default : + return; + } +} + void pi_task_release(pi_task_t *task) { DEBUG_PRINTF("[%s] releasing task %p\n",__func__,task); diff --git a/rtos/freeRTOS/vendors/gwt/rules/freeRTOS_rules.mk b/rtos/freeRTOS/vendors/gwt/rules/freeRTOS_rules.mk index 9a2dfe3a0..e2e16f5aa 100644 --- a/rtos/freeRTOS/vendors/gwt/rules/freeRTOS_rules.mk +++ b/rtos/freeRTOS/vendors/gwt/rules/freeRTOS_rules.mk @@ -46,6 +46,7 @@ GWT_DEVICE_INC = $(GWT_TARGET)/$(chip_lowercase)/include GWT_DRIVER_INC = $(GWT_TARGET)/$(chip_lowercase)/include/driver GWT_PMSIS_BACKEND = $(GWT_PMSIS)/backend GWT_PMSIS_IMPLEM = $(GWT_TARGET)/$(chip_lowercase)/pmsis +GWT_PMSIS_SHARED_IMPLEM = $(PMSIS_HOME)/pmsis_implem GWT_PMSIS_API = $(GAP_SDK_HOME)/rtos/pmsis/pmsis_api @@ -272,6 +273,7 @@ INC_PATH += $(GWT_LIBS)/printf # PMSIS PMSIS_IMPLEM_DIR = $(GWT_PMSIS_IMPLEM) +PMSIS_SHARED_IMPLEM_DIR = $(GWT_PMSIS_SHARED_IMPLEM) -include $(GWT_PMSIS_IMPLEM)/src.mk -include $(GWT_PMSIS)/src.mk PMSIS_BACKEND_SRC = $(shell find $(GWT_PMSIS_BACKEND) -iname "*.c") @@ -406,13 +408,16 @@ $(BIN).size: $(BIN) flash: $(BIN) - gapy $(GAPY_TARGET_OPT) --platform=$(platform) --work-dir=$(BUILDDIR) $(config_args) $(gapy_args) run --flash --force --binary=$(BIN) $(runner_args) + gapy $(GAPY_TARGET_OPT) --platform=$(platform) --work-dir=$(BUILDDIR) $(config_args) $(gapy_args) run --flash --force --binary=$(BIN) $(runner_args) $(WSL_ENV) -flash_fs: $(BIN) +flash_noforce: $(BIN) gapy $(GAPY_TARGET_OPT) --platform=$(platform) --work-dir=$(BUILDDIR) $(config_args) $(gapy_args) run --flash --binary=$(BIN) $(runner_args) +flash_fs: $(BIN) image + gapy $(GAPY_TARGET_OPT) --platform=$(platform) --work-dir=$(BUILDDIR) $(config_args) $(gapy_args) run --flash --binary=$(BIN) $(runner_args) $(WSL_ENV) + image: $(BIN) - gapy $(GAPY_TARGET_OPT) --platform=$(platform) --work-dir=$(BUILDDIR) $(config_args) $(gapy_args) run --image --binary=$(BIN) $(runner_args) + gapy $(GAPY_TARGET_OPT) --platform=$(platform) --work-dir=$(BUILDDIR) $(config_args) $(gapy_args) run --image --binary=$(BIN) $(runner_args) $(WSL_ENV) run: $(BIN) gapy $(GAPY_TARGET_OPT) --platform=$(platform) --work-dir=$(BUILDDIR) $(config_args) $(gapy_args) run --exec-prepare --exec --binary=$(BIN) $(runner_args) $(WSL_ENV) diff --git a/rtos/pmsis/.gitignore b/rtos/pmsis/.gitignore new file mode 100644 index 000000000..c0afc6f4d --- /dev/null +++ b/rtos/pmsis/.gitignore @@ -0,0 +1,5 @@ +*.swp +*.orig +build/ +__pycache__/ +junit-reports/ diff --git a/rtos/pmsis/CMakeLists.txt b/rtos/pmsis/CMakeLists.txt new file mode 100644 index 000000000..5f29fd68a --- /dev/null +++ b/rtos/pmsis/CMakeLists.txt @@ -0,0 +1,3 @@ + +add_subdirectory(pmsis_api) +add_subdirectory(pmsis_implem) diff --git a/rtos/pmsis/README.md b/rtos/pmsis/README.md new file mode 100644 index 000000000..6085b177f --- /dev/null +++ b/rtos/pmsis/README.md @@ -0,0 +1,3 @@ +# Pmsis + +PULP Microprocessor Software Interface Standard (PMSIS) provides a software framework for embedded applications that run on all PULP based microprocessors. \ No newline at end of file diff --git a/rtos/pmsis/pmsis_api/.gitignore b/rtos/pmsis/pmsis_api/.gitignore deleted file mode 100644 index 188ec9394..000000000 --- a/rtos/pmsis/pmsis_api/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.swp -*.orig diff --git a/rtos/pmsis/pmsis_api/docs/rtos.rst b/rtos/pmsis/pmsis_api/docs/rtos.rst index 35500b4f4..3bb11eed1 100644 --- a/rtos/pmsis/pmsis_api/docs/rtos.rst +++ b/rtos/pmsis/pmsis_api/docs/rtos.rst @@ -9,6 +9,14 @@ Task :private-members: :protected-members: +Event_Task +.... + +.. doxygengroup:: Event_Task + :members: + :private-members: + :protected-members: + Memory allocation ................. diff --git a/rtos/pmsis/pmsis_api/include/pmsis/chips/gap8/timer.h b/rtos/pmsis/pmsis_api/include/pmsis/chips/gap8/timer.h new file mode 100644 index 000000000..7cb15c00d --- /dev/null +++ b/rtos/pmsis/pmsis_api/include/pmsis/chips/gap8/timer.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2021 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \ingroup groupChips + * + * \addtogroup GAP8 + * \{ + * + * \defgroup GAP8_Timers GAP8 Timers + * + * \brief GAP8 Timers + * + * This part enumerates available Timers on chip **GAP8**. + * + * There are a total of 4 timers : + * * 2 on Fabric Controller + * * 2 on Cluster + * + * \addtogroup GAP8_Timers + * \{ + */ + +/** + * \enum pi_timer_e + * + * \brief Timers. + * + * List of available timers. + */ +typedef enum +{ + SYS_TIMER = 0, /*!< FC_TIMER_0 used as SysTick timer by preemptive RTOS. */ + FC_TIMER_0 = 0, /*!< FC Timer_Low. */ + FC_TIMER_1 = 1, /*!< FC Timer_High, can be used as perf counter. */ + CL_TIMER_0 = 2, /*!< Cluster Timer_Low. */ + CL_TIMER_1 = 3 /*!< Cluster Timer_High. */ +} pi_timer_e; + +/** + * \} end of GAP8_Timers + * + * \} end of GAP8 + */ + +#ifdef __cplusplus +} +#endif diff --git a/rtos/pmsis/pmsis_api/include/pmsis/chips/gap9/timer.h b/rtos/pmsis/pmsis_api/include/pmsis/chips/gap9/timer.h new file mode 100644 index 000000000..dfa9b21c5 --- /dev/null +++ b/rtos/pmsis/pmsis_api/include/pmsis/chips/gap9/timer.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2021 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \ingroup groupChips + * + * \addtogroup GAP9 + * \{ + * + * \defgroup GAP9_Timers GAP9 Timers + * + * \brief GAP9 Timers + * + * This part enumerates available Timers on chip **GAP9**. + * + * There are a total of 4 timers : + * * 4 on Fabric Controller + * * 2 on Cluster + * + * \addtogroup GAP9_Timers + * \{ + */ + +/** + * \enum pi_timer_e + * + * \brief Timers. + * + * List of available timers. + */ +typedef enum +{ + SYS_TIMER = 0, /*!< FC TIMER_0 used as SysTick timer by preemptive RTOS. */ + FC_TIMER_0 = 0, /*!< FC Timer_0_Low. FC_TIMER_0 and FC_TIMER_1 can be used + together to form a 64 bits timer. */ + FC_TIMER_1 = 1, /*!< FC Timer_0_High. */ + FC_TIMER_2 = 2, /*!< FC Timer_1_Low. FC_TIMER_2 and FC_TIMER_3 can be used + together to form a 64 bits timer. */ + FC_TIMER_3 = 3, /*!< FC Timer_1_High. */ + CL_TIMER_0 = 4, /*!< Cluster Timer_0_Low. */ + CL_TIMER_1 = 5 /*!< Cluster Timer_0_High. */ +} pi_timer_e; + +/** + * \} end of GAP9_Timers + * + * \} end of GAP9 + */ + +#ifdef __cplusplus +} +#endif diff --git a/rtos/pmsis/pmsis_api/include/pmsis/cluster/cl_pmsis_types.h b/rtos/pmsis/pmsis_api/include/pmsis/cluster/cl_pmsis_types.h index 93231352a..3e4b55c0f 100644 --- a/rtos/pmsis/pmsis_api/include/pmsis/cluster/cl_pmsis_types.h +++ b/rtos/pmsis/pmsis_api/include/pmsis/cluster/cl_pmsis_types.h @@ -58,6 +58,7 @@ struct pi_cluster_conf { // do not move this one, might be accessed in various hackish way pi_device_e device_type; /*!< Device type. */ int id; /*!< Cluster ID, starting from 0. */ + int cc_stack_size; /*!< Cluster controller stack size (0x800) */ void *heap_start; /* Reserved for internal usage. */ uint32_t heap_size; /* Reserved for internal usage. */ struct pmsis_event_kernel_wrap* event_kernel; /* Reserved for internal @@ -74,6 +75,8 @@ struct pi_cluster_conf { /// @cond IMPLEM +#define PI_CL_CC_STACK_SIZE 0x800 + #ifndef CLUSTER_TASK_IMPLEM #define CLUSTER_TASK_IMPLEM #endif @@ -84,7 +87,7 @@ struct pi_cluster_conf { #ifndef CLUSTER_TASK_CUSTOM -struct pi_cluster_task { +typedef struct pi_cluster_task { // entry function and its argument(s) void (*entry)(void*); void *arg; @@ -101,7 +104,7 @@ struct pi_cluster_task { struct pi_cluster_task *next; CLUSTER_TASK_IMPLEM; -}; +} pi_cluster_task_t; #endif diff --git a/rtos/pmsis/pmsis_api/include/pmsis/cluster/cluster_sync/fc_to_cl_delegate.h b/rtos/pmsis/pmsis_api/include/pmsis/cluster/cluster_sync/fc_to_cl_delegate.h index a4bf4a5ab..5c51f1f78 100644 --- a/rtos/pmsis/pmsis_api/include/pmsis/cluster/cluster_sync/fc_to_cl_delegate.h +++ b/rtos/pmsis/pmsis_api/include/pmsis/cluster/cluster_sync/fc_to_cl_delegate.h @@ -219,6 +219,18 @@ static inline int pi_cluster_send_task_async(struct pi_device *device, struct pi return pi_cluster_send_task_to_cl_async(device, cluster_task, task); } +#if defined(__PULPOS2__) + +static inline int pi_cluster_send_workgroup_async(pi_device_t *device, pi_cluster_task_t *cluster_task, pi_task_t *task) +{ + cluster_task->event_based = 1; + return pi_cluster_send_task_to_cl_async(device, cluster_task, task); +} + +static inline int pi_cluster_send_workgroup(pi_device_t *device, pi_cluster_task_t *cluster_task); + +#endif + /** \brief check if any cluster is on */ uint8_t pi_cluster_is_on(void); @@ -278,6 +290,7 @@ static inline struct pi_cluster_task *pi_cluster_task(struct pi_cluster_task *ta task->arg = arg; task->stacks = (void *)0; task->stack_size = 0; + task->slave_stack_size = 0; task->nb_cores = 0; return task; } diff --git a/rtos/pmsis/pmsis_api/include/pmsis/drivers/i2s.h b/rtos/pmsis/pmsis_api/include/pmsis/drivers/i2s.h index 2a170bcc5..4431cb2ca 100644 --- a/rtos/pmsis/pmsis_api/include/pmsis/drivers/i2s.h +++ b/rtos/pmsis/pmsis_api/include/pmsis/drivers/i2s.h @@ -1195,7 +1195,7 @@ PI_INLINE_I2S_LVL_0 int pi_i2s_frame_write(struct pi_device *dev, uint32_t frame * @retval 0 If successful. * @retval -1 An error occured. */ -PI_INLINE_I2S_LVL_0 int pi_i2s_frame_write_async(struct pi_device *dev, +int pi_i2s_frame_write_async(struct pi_device *dev, uint32_t frame, void *mem_block, size_t size, pi_task_t *task); /** diff --git a/rtos/pmsis/pmsis_api/include/pmsis/drivers/timer.h b/rtos/pmsis/pmsis_api/include/pmsis/drivers/timer.h new file mode 100644 index 000000000..b4bcdc7d2 --- /dev/null +++ b/rtos/pmsis/pmsis_api/include/pmsis/drivers/timer.h @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2021 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \ingroup groupDrivers + * + * \defgroup Timer Timer + * + * \brief Timer + * + * The timer driver includes API to manage different timers available on + * chips, for both Fabric Controller side and Cluster side. + */ + +/** + * \addtogroup Timer + * \{ + */ + + +/** + * \struct pi_timer_conf_s + * + * \brief Timer configuration structure. + * + * This structure is used to pass the desired timer configuration to the + * runtime when opening the device. + */ +struct pi_timer_conf_s +{ + uint32_t time_us; /*!< Timer value to compare. */ + uint8_t timer_id; /*!< Timer ID, refer to \ref pi_timer_e. */ + uint8_t one_shot; /*!< One shot timer, after reaching time_us, timer is disabled. */ + uint8_t irq_en; /*!< Enable timer IRQ. */ + uint8_t clk_src; /*!< Timer clock source: FLL=0, REF_CLK=1. */ + uint8_t timer_reset; /*!< When value is reached: CONTINUE=0, RESET=1. */ + //uint8_t timer_64; /*!< Enable a 64-bit timer, using two 32-bit timers. */ +}; + + +/** + * \brief Initialize a timer configuration with default values. + * + * This function can be called to get default values for all parameters before + * setting some of them. + * The structure containing the configuration must be kept alive until the I2S + * device is opened. + * + * \param conf Pointer to the timer configuration. + * + * \note Only FC_TIMER_2 and FC_TIMER_3 timers are available. + */ +void pi_timer_conf_init(struct pi_timer_conf_s *conf); + +/** + * \brief Open a timer. + * + * This function will do all the needed configuration to initialize a timer(on + * FC or Cluster) with given configuration. + * + * \param device Pointer to device structure. + * + * \retval 0 If operation is successfull. + * \retval ERRNO An error code otherwise. + * + * \note This function must be called before the timer device can be used. + * \note For preemptive RTOS using time slicing, the FC_Timer_0 should be used as + * SysTick timer. Thus a 64 bit timer can not be used on FC side. + */ +int pi_timer_open(struct pi_device *device); + +/** + * \brief Close an opened timer device. + * + * This function closes a timer device. + * + * \param device Pointer to device structure. + */ +void pi_timer_close(struct pi_device *device); + +/** + * \brief Start a timer. + * + * This function starts a timer. + * + * \param device Pointer to device structure. + * + * \retval 0 If operation is successfull. + * \retval ERRNO An error code otherwise. + */ +int pi_timer_start(struct pi_device *device); + +/** + * \brief Stop a timer. + * + * This function stops a timer. + * + * \param device Pointer to device structure. + */ +void pi_timer_stop(struct pi_device *device); + +/** + * \brief Reset a timer counter. + * + * This function resets a timer's counter register. + * + * \param device Pointer to device structure. + * + * \note This function does not reset a timer's configuration. + * To fully reset a timer, stop first the timer, then reinitialize + * the timer using pi_timer_init() function. + */ +void pi_timer_reset(struct pi_device *device); + +/** + * \brief Get a timer's counter value. + * + * This function reads the current counter value of a timer and stores it in the + * given buffer. + * + * \param device Pointer to device structure. + * \param value Buffer to store counter value. + * + * \retval 0 If operation is successfull. + * \retval ERRNO An error code otherwise. + */ +int pi_timer_current_value_read(struct pi_device *device, uint32_t *value); + +int pi_timer_task_add(struct pi_device *device, uint32_t time_us, pi_task_t *task); + +/** + * \} end of Timer + */ + +#ifdef __cplusplus +} +#endif diff --git a/rtos/pmsis/pmsis_api/include/pmsis/rtos/pi_log.h b/rtos/pmsis/pmsis_api/include/pmsis/rtos/pi_log.h index 4770f588c..e70c60ca6 100644 --- a/rtos/pmsis/pmsis_api/include/pmsis/rtos/pi_log.h +++ b/rtos/pmsis/pmsis_api/include/pmsis/rtos/pi_log.h @@ -410,10 +410,10 @@ static inline int pi_log_default_vprintf(const char *format, va_list list) #define HYPER_DBG(fmt, ...) PI_LOG_DBG(HYPER_TAG, fmt, ##__VA_ARGS__) #define HYPER_TRC(fmt, ...) PI_LOG_TRC(HYPER_TAG, fmt, ##__VA_ARGS__) -#define MRAM_TAG "mram" +//#define MRAM_TAG "mram" #define MRAM_ERR(fmt, ...) PI_LOG_ERR(MRAM_TAG, fmt, ##__VA_ARGS__) #define MRAM_WNG(fmt, ...) PI_LOG_WNG(MRAM_TAG, fmt, ##__VA_ARGS__) -#define MRAM_INF(fmt, ...) PI_LOG_INF(MRAM_TAG, fmt, ##__VA_ARGS__) +#define MRAM_INF(fmt, ...) #define MRAM_DBG(fmt, ...) PI_LOG_DBG(MRAM_TAG, fmt, ##__VA_ARGS__) #define MRAM_TRC(fmt, ...) PI_LOG_TRC(MRAM_TAG, fmt, ##__VA_ARGS__) diff --git a/rtos/pmsis/pmsis_api/include/pmsis/task.h b/rtos/pmsis/pmsis_api/include/pmsis/task.h index 3d4189d8c..c6ae9ba3f 100644 --- a/rtos/pmsis/pmsis_api/include/pmsis/task.h +++ b/rtos/pmsis/pmsis_api/include/pmsis/task.h @@ -182,13 +182,22 @@ static inline pi_callback_t *pi_callback_init(pi_callback_t *callback, static inline void pi_task_timeout_set(pi_task_t *task, uint32_t timeout_us); /** - * \brief Query result end of transfer. + * \brief Query task status. * - * This function can be used to check the end result of a transfer. + * This function can be used to check if a task completed successfully. * - * \return ERRNO Value corresponding to end of transfer. + * \return ERRNO Value corresponding to task status. */ -static inline int32_t pi_task_transfer_end_result_get(pi_task_t *task); +static inline int32_t pi_task_status_get(pi_task_t *task); + +/** + * \brief Set task status. + * + * This function can be used to tell if a task completed successfully. + * + * \param status Value corresponding to task status. + */ +static inline void pi_task_status_set(pi_task_t *task, int32_t status); /** * @} diff --git a/rtos/pmsis/pmsis_bsp/.gitignore b/rtos/pmsis/pmsis_bsp/.gitignore deleted file mode 100644 index 6acd1da57..000000000 --- a/rtos/pmsis/pmsis_bsp/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -build/ -__pycache__/ -junit-reports/ \ No newline at end of file diff --git a/rtos/pmsis/pmsis_bsp/CMakeLists.txt b/rtos/pmsis/pmsis_bsp/CMakeLists.txt index 77c951b92..b2abc381a 100644 --- a/rtos/pmsis/pmsis_bsp/CMakeLists.txt +++ b/rtos/pmsis/pmsis_bsp/CMakeLists.txt @@ -1,5 +1,5 @@ set(BSP_READFS_SRC fs/read_fs/read_fs.c) -set(BSP_HOSTFS_SRC fs/host_fs/semihost.c fs/host_fs/host_fs.c) +set(BSP_HOSTFS_SRC fs/host_fs/host_fs.c) set(BSP_LFS_SRC fs/lfs/lfs.c fs/lfs/lfs_util.c fs/lfs/pi_lfs.c) set(BSP_FS_SRC fs/fs.c) set(BSP_FLASH_SRC diff --git a/rtos/pmsis/pmsis_bsp/adc/ads1014.c b/rtos/pmsis/pmsis_bsp/adc/ads1014.c new file mode 100644 index 000000000..45b5835d4 --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/adc/ads1014.c @@ -0,0 +1,349 @@ +#include "pmsis.h" +#include "bsp/bsp.h" +#include "bsp/adc/ads1014.h" + +/**************/ +/* Structures */ +/**************/ + +enum ads1014_registers { + ADS1014_REGISTER_VALUE = 0x0, + ADS1014_REGISTER_CONF = 0x1, + ADS1014_REGISTER_THRESHOLD_LOW = 0x2, + ADS1014_REGISTER_THRESHOLD_HIGH = 0x3, +}; + +typedef union __attribute__((__packed__)) { + struct __attribute__((packed)) { + uint8_t _unused :4; + int16_t value :12; + } reg; + uint16_t value; +} ads1014_register_value_t; + +typedef union __attribute__((__packed__)) { + struct __attribute__((__packed__)) { + enum ads1014_comparator_status comparator_status :2; + enum ads1014_comparator_latch comparator_latch :1; + enum ads1014_comparator_polarity comparator_polarity :1; + enum ads1014_comparator_mode comparator_mode :1; + enum ads1014_data_rate data_rate :3; + enum ads1014_operating_mode operating_mode :1; + enum ads1014_pga pga :3; + uint8_t _unused: 3; + uint8_t converting :1; + } reg; + uint16_t value; +} ads1014_register_conf_t; + +typedef struct { + pi_device_t i2c_device; + ads1014_register_conf_t adc_conf; +} ads1014_data_t; + +/********************/ +/* Static functions */ +/********************/ + +static int +__ads1014_update_configuration(pi_device_t *device) { + ads1014_data_t *data = (ads1014_data_t*) device->data; + + /* set the adc to trigger a conversion (useful in single shot mode) */ + data->adc_conf.reg.converting = 1; + + uint16_t packed_conf = data->adc_conf.value; + uint8_t payload[3] = { ADS1014_REGISTER_CONF, + (packed_conf >> 8) & 0xFF, + packed_conf & 0xFF, + }; + + int status = pi_i2c_write(&data->i2c_device, payload, 3, + PI_I2C_XFER_START | PI_I2C_XFER_STOP); + return status; +}; + +/** + * + * Convert a float value (in mV) to fit in a comparator threshold register + * + * @param[in] pga ads1014 pga setting (to know the scale) + * @param[in] f float to convert + * @param[out] reg register that will contain the final 12 bit value + * + * @return PI_OK if operation was successful, + * an error otherwise + */ +static inline int +__convert_float_to_register_value(enum ads1014_pga pga, float f, + ads1014_register_value_t *reg) +{ + if (NULL == reg) { + return PI_ERR_INVALID_ARG; + } + + /* Change the scale according to the ADC PGA */ + switch(pga) { + case ADS1014_PGA_FSR_6V144: + f /= 3; + break; + case ADS1014_PGA_FSR_4V096: + f /= 2; + break; + case ADS1014_PGA_FSR_2V048: + /* nothing, f *= 1*/ + break; + case ADS1014_PGA_FSR_1V024: + f *= 2; + break; + case ADS1014_PGA_FSR_0V512: + f *= 4; + break; + case ADS1014_PGA_FSR_0V256: /* fallthrough */ + default: + f *= 8; + break; + } + + /* fit into 12 bits */ + int32_t i = f; + /* check if it fits in 12 bits */ + if (__builtin_pulp_clb(i) < 20) { + return PI_ERR_INVALID_STATE; + } + reg->reg.value = f; + + return PI_OK; +} + +/** + * Helper to write a comparator register + * + * @param[in] device pointer to the ads1014 device (not checked) + * @param[in] reg register to write + * @param[in] value value to write in the register + * + * @return PI_OK if operation was succesful, an error code otherwise + */ +static inline int +__write_comparator_register(pi_device_t *device, enum ads1014_registers reg, + ads1014_register_value_t value) +{ + ads1014_data_t *data = (ads1014_data_t*) device->data; + + uint16_t packed_conf = value.value; + uint8_t payload[3] = { reg, + (packed_conf >> 8) & 0xFF, + packed_conf & 0xFF, + }; + + int status = pi_i2c_write(&data->i2c_device, payload, 3, + PI_I2C_XFER_START | PI_I2C_XFER_STOP); + return status; +} + +/*****************/ +/* API functions */ +/*****************/ + +void pi_ads1014_conf_init(struct pi_ads1014_conf *conf) { + if (NULL == conf) { + return; + } + + /* I2C related */ + conf->i2c_itf = 1; //TODO retrieve from BSP + conf->i2c_addr = 0x90; //TODO retrieve from BSP + + /* ADC General settings */ + conf->operating_mode = ADS1014_OPERATING_MODE_SINGLE_SHOT; + conf->pga = ADS1014_PGA_FSR_2V048; + conf->data_rate = ADS1014_DATA_RATE_SPS_1600; + + /* ADC comparator settings */ + conf->comparator_status = ADS1014_COMPARATOR_STATUS_DISABLED; + conf->comparator_mode = ADS1014_COMPARATOR_MODE_TRADITIONAL; + conf->comparator_latch = ADS1014_COMPARATOR_LATCH_DISABLED; + conf->comparator_polarity = ADS1014_COMPARATOR_POLARITY_ACTIVE_LOW; +} + +int pi_ads1014_open(pi_device_t *device) { + if (NULL == device) { + return PI_ERR_INVALID_ARG; + } + + struct pi_ads1014_conf *conf = (struct pi_ads1014_conf *) device->config; + + /* allocate memory for runtime data */ + ads1014_data_t *ads1014 = (ads1014_data_t *) pi_l2_malloc(sizeof(ads1014_data_t)); + if (NULL == ads1014) { + return PI_ERR_L2_NO_MEM; + } + device->data = (void*) ads1014; + + /* open bsp */ + //TODO + + /* initialize configuration register */ + { + ads1014->adc_conf.reg.operating_mode = conf->operating_mode; + ads1014->adc_conf.reg.pga = conf->pga; + ads1014->adc_conf.reg.data_rate = conf->data_rate; + ads1014->adc_conf.reg.comparator_status = conf->comparator_status; + ads1014->adc_conf.reg.comparator_mode = conf->comparator_mode; + ads1014->adc_conf.reg.comparator_latch = conf->comparator_latch; + ads1014->adc_conf.reg.comparator_mode = conf->comparator_mode; + ads1014->adc_conf.reg.comparator_polarity = conf->comparator_polarity; + ads1014->adc_conf.reg.converting = 1; /* initial trigger */ + } + + /* initialize I2C device */ + { + struct pi_i2c_conf i2c_conf; + pi_i2c_conf_init(&i2c_conf); + i2c_conf.itf = conf->i2c_itf; + i2c_conf.max_baudrate = 100000; + pi_i2c_conf_set_slave_addr(&i2c_conf, conf->i2c_addr, 0); + + pi_open_from_conf(&ads1014->i2c_device, &i2c_conf); + + if (PI_OK != pi_i2c_open(&ads1014->i2c_device)) { + pi_l2_free(device->data, sizeof(ads1014_data_t)); + return PI_ERR_INVALID_STATE; + } + } + + /* ADC configuration */ + int status = __ads1014_update_configuration(device); + if (status != PI_OK) { + pi_i2c_close(&ads1014->i2c_device); + pi_l2_free(device->data, sizeof(ads1014_data_t)); + return PI_ERR_INVALID_STATE; + } + + return PI_OK; +} + +void pi_ads1014_close(pi_device_t *device) { + if (NULL == device || NULL == device->data) { + return; + } + + ads1014_data_t *data = (ads1014_data_t*) device->data; + + /* close devices */ + pi_i2c_close(&data->i2c_device); + + /* free memory */ + pi_l2_free(data, sizeof(ads1014_data_t)); + device->data = NULL; +} + +int pi_ads1014_read(pi_device_t *device, float *value) { + if (NULL == device || NULL == device->data || NULL == value) { + return PI_ERR_INVALID_ARG; + } + + ads1014_data_t *data = (ads1014_data_t*) device->data; + + int status = PI_OK; + + // if ADC is in continous mode, no need to trigger a conversion. + // else we need to trigger for a single shot measurement + if (data->adc_conf.reg.operating_mode == ADS1014_OPERATING_MODE_SINGLE_SHOT) { + status = __ads1014_update_configuration(device); + if (PI_OK != status) { + return PI_ERR_INVALID_STATE; + } + + //TODO wait for the end of the conversion ? + } + + uint8_t write_payload = ADS1014_REGISTER_VALUE; + ads1014_register_value_t result; + + status = pi_i2c_write(&data->i2c_device, &write_payload, 1, + PI_I2C_XFER_START | PI_I2C_XFER_STOP); + + if (status != PI_OK) { + return PI_ERR_INVALID_STATE; + } + + status = pi_i2c_read(&data->i2c_device, (uint8_t*) &result, 2, + PI_I2C_XFER_START | PI_I2C_XFER_STOP); + + if (status != PI_OK) { + return PI_ERR_INVALID_STATE; + } + + result.value= (result.value << 8) | (result.value >> 8); + + /* conversion depending on the pga */ + switch(data->adc_conf.reg.pga) { + case ADS1014_PGA_FSR_6V144: + *value = result.reg.value * 3; + break; + case ADS1014_PGA_FSR_4V096: + *value = result.reg.value * 2; + break; + case ADS1014_PGA_FSR_2V048: + *value = result.reg.value * 1; + break; + case ADS1014_PGA_FSR_1V024: + *value = result.reg.value * 0.5; + break; + case ADS1014_PGA_FSR_0V512: + *value = result.reg.value * 0.25; + break; + case ADS1014_PGA_FSR_0V256: /* fallthrough */ + default: + *value = result.reg.value * 0.125; + break; + } + + return PI_OK; +} + +int pi_ads1014_set_comparator_thresholds(pi_device_t *device, + float threshold_low, float threshold_high) +{ + if (NULL == device || NULL == device->data) { + return PI_ERR_INVALID_ARG; + } + + ads1014_data_t *data = (ads1014_data_t*) device->data; + + ads1014_register_value_t low_th_reg; + ads1014_register_value_t high_th_reg; + + /* Convert threshold to 12bits */ + { + /* return an error if they do not fit inside 12 bits */ + enum ads1014_pga pga = data->adc_conf.reg.pga; + + if (PI_OK != __convert_float_to_register_value(pga, threshold_low, + &low_th_reg)) { + return PI_ERR_INVALID_STATE; + } + + if (PI_OK != __convert_float_to_register_value(pga, threshold_high, + &high_th_reg)) { + return PI_ERR_INVALID_STATE; + } + } + + /* write values to registers */ + int status = __write_comparator_register(device, + ADS1014_REGISTER_THRESHOLD_LOW, low_th_reg); + if (PI_OK != status) { + return status; + } + + status = __write_comparator_register(device, + ADS1014_REGISTER_THRESHOLD_HIGH, high_th_reg); + if (PI_OK != status) { + return status; + } + + return PI_OK; +} diff --git a/rtos/pmsis/pmsis_bsp/audio/adc/tlv320.c b/rtos/pmsis/pmsis_bsp/audio/adc/tlv320.c new file mode 100644 index 000000000..1f471ece0 --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/audio/adc/tlv320.c @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2018 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Authors: Germain Haugou, GreenWaves Technologies (germain.haugou@greenwaves-technologies.com) + */ + +#include "pmsis.h" +#include "bsp/bsp.h" + + +typedef struct +{ + struct pi_device i2c; +} tlv320_t; + + +static int __pi_tlv320_reg_write(pi_device_t *dev, uint8_t addr, uint8_t value) +{ + uint8_t buffer[2] = { addr, value }; + if (pi_i2c_write(dev, buffer, 2, PI_I2C_XFER_START | PI_I2C_XFER_STOP)) + { + return -1; + } + return 0; +} + + +static uint8_t __pi_tlv320_reg_read(pi_device_t *dev, uint8_t addr) +{ + uint8_t result; + pi_i2c_write_read(dev, &addr, &result, 1, 1); + return result; +} + + +int pi_tlv320_open(struct pi_device *device) +{ + struct pi_tlv320_conf *conf = (struct pi_tlv320_conf *)device->config; + + tlv320_t *tlv320 = (tlv320_t *)pmsis_l2_malloc(sizeof(tlv320_t)); + if (tlv320 == NULL) + { + return -1; + } + + device->data = (void *)tlv320; + + if (bsp_tlv320_open(conf)) + { + goto error; + } + + struct pi_i2c_conf i2c_conf; + pi_i2c_conf_init(&i2c_conf); + i2c_conf.itf = conf->i2c_itf; + i2c_conf.max_baudrate = 100000; + pi_i2c_conf_set_slave_addr(&i2c_conf, 0x98, 0); + + pi_open_from_conf(&tlv320->i2c, &i2c_conf); + if (pi_i2c_open(&tlv320->i2c)) goto error; + + //tlv320 write i2c config (and read for debug) + + uint8_t expected , read; + + // Select page 0 (configuration register page) + expected = 0x00; + __pi_tlv320_reg_write(&tlv320->i2c, 0x00, expected); + read = __pi_tlv320_reg_read(&tlv320->i2c, 0x00); + printf("Read page 0x%x \n",read); + if (read == expected) + printf("Page ok \n"); + else printf("Page failed \n",read); + + // Wake-up device by I2C write into P0_R2 using internal AREG + __pi_tlv320_reg_write(&tlv320->i2c, 0x02, 0x81); + expected = 0x81; + __pi_tlv320_reg_write(&tlv320->i2c, 0x02, expected); + read = __pi_tlv320_reg_read(&tlv320->i2c, 0x02); + if (read == expected) + printf("Wake up ok \n"); + else printf("Wake up failed \n",read); + + //wait at least 1ms to complete init + pi_time_wait_us(2000); + + // Enable Input Ch-1,2,3,4 by I2C write into P0_R115 + //__pi_tlv320_reg_write(&tlv320->i2c, 0x73, 0xF0); + //only channel 2 + expected = 0x40; + __pi_tlv320_reg_write(&tlv320->i2c, 0x73, expected); + read = __pi_tlv320_reg_read(&tlv320->i2c, 0x73); + if (read == expected) + printf("Enable channel 2 ok \n"); + else printf("Enable channel 2 failed \n",read); + + // Enable ASI Output Ch-1,2,3,4 slot by I2C write into P0_R116 + //__pi_tlv320_reg_write(&tlv320->i2c, 0x74, 0xF0); + //only channel 2 + expected = 0x40; + __pi_tlv320_reg_write(&tlv320->i2c, 0x74, expected); + read = __pi_tlv320_reg_read(&tlv320->i2c, 0x74); + if (read == expected) + printf("Enable ASI out channel 2 ok \n"); + else printf("Enable ASI out channel 2 failed \n",read); + + // Power-up ADC, MICBIAS and PLL by I2C write into P0_R117 + //__pi_tlv320_reg_write(&tlv320->i2c, 0x75, 0xe0); + //power up only ADC and PLL + expected = 0x60; + __pi_tlv320_reg_write(&tlv320->i2c, 0x75, expected); + read = __pi_tlv320_reg_read(&tlv320->i2c, 0x75); + if (read == expected) + printf("Power up ADC and PLL ok \n"); + else printf("Power Up ADC and PLL failed \n",read); + + + // TDM 32bits mode + //__pi_tlv320_reg_write(&tlv320->i2c, 0x7, 0x30); + expected = 0x30; + __pi_tlv320_reg_write(&tlv320->i2c, 0x7, expected); + read = __pi_tlv320_reg_read(&tlv320->i2c, 0x7); + if (read == expected) + printf("TDM 32 bit ok \n"); + else printf("TDM 32 bit failed \n",read); + + // TX OFFSET. set to 1 to match our ws_delay of 1, but not sure it is the right value -- seems to work + expected = 0x1; + __pi_tlv320_reg_write(&tlv320->i2c, 0x8, expected); + read = __pi_tlv320_reg_read(&tlv320->i2c, 0x8); + if (read == expected) + printf("Tx offset 1 ok \n"); + else printf("Tx offset 1 failed \n",read); + + + + //configure AC single - ended + //channel1 + //__pi_tlv320_reg_write(&tlv320->i2c, 0x3C, 0x20); + //channel2 + __pi_tlv320_reg_write(&tlv320->i2c, 0x41, 0x20); + //channel3 + //__pi_tlv320_reg_write(&tlv320->i2c, 0x46, 0x20); + //channel4 + //__pi_tlv320_reg_write(&tlv320->i2c, 0x4B, 0x20); + + return 0; + +error: + pmsis_l2_malloc_free(tlv320, sizeof(tlv320_t)); + return -2; +} + + +void pi_tlv320_close(struct pi_device *device) +{ + tlv320_t *tlv320 = (tlv320_t *)device->data; + pmsis_l2_malloc_free(tlv320, sizeof(tlv320_t)); +} + + +void pi_tlv320_conf_init(struct pi_tlv320_conf *conf) +{ + bsp_tlv320_conf_init(conf); +} + diff --git a/rtos/pmsis/pmsis_bsp/audio/dac/ak4332.c b/rtos/pmsis/pmsis_bsp/audio/dac/ak4332.c new file mode 100644 index 000000000..120457112 --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/audio/dac/ak4332.c @@ -0,0 +1,183 @@ +/* + * Copyright (C) 2018 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Authors: Germain Haugou, GreenWaves Technologies (germain.haugou@greenwaves-technologies.com) + */ + +#include "pmsis.h" +#include "bsp/bsp.h" + + +typedef struct +{ + struct pi_device i2c; +} ak4332_t; + + +static int __pi_ak4332_reg_write(pi_device_t *dev, uint8_t addr, uint8_t value) +{ + uint8_t buffer[2] = { addr, value }; + if (pi_i2c_write(dev, buffer, 2, PI_I2C_XFER_START | PI_I2C_XFER_STOP)) + { + return -1; + } + return 0; +} + + +static uint8_t __pi_ak4332_reg_read(pi_device_t *dev, uint8_t addr) +{ + uint8_t result; + pi_i2c_write_read(dev, &addr, &result, 1, 1); + return result; +} + + +int pi_ak4332_open(struct pi_device *device) +{ + struct pi_ak4332_conf *conf = (struct pi_ak4332_conf *)device->config; + + ak4332_t *ak4332 = (ak4332_t *)pmsis_l2_malloc(sizeof(ak4332_t)); + if (ak4332 == NULL) + { + return -1; + } + + device->data = (void *)ak4332; + + if (bsp_ak4332_open(conf)) + { + goto error; + } + + struct pi_i2c_conf i2c_conf; + pi_i2c_conf_init(&i2c_conf); + i2c_conf.itf = conf->i2c_itf; + i2c_conf.max_baudrate = 100000; + pi_i2c_conf_set_slave_addr(&i2c_conf, 0x20, 0); + + pi_open_from_conf(&ak4332->i2c, &i2c_conf); + if (pi_i2c_open(&ak4332->i2c)) goto error; + + // DAC initial settings + __pi_ak4332_reg_write(&ak4332->i2c, 0x26, 0x02); + + __pi_ak4332_reg_write(&ak4332->i2c, 0x27, 0xC0); + + // Select left channel + __pi_ak4332_reg_write(&ak4332->i2c, 0x07, 0x1); + + // Set 32bits samples + __pi_ak4332_reg_write(&ak4332->i2c, 0x15, 0b110); + + // Set 48KHz sampling rate + // and CM to 512 + __pi_ak4332_reg_write(&ak4332->i2c, 0x5, 0x2A); + + //Set HP Gain to 0 + __pi_ak4332_reg_write(&ak4332->i2c, 0x0d, 0b101); + //Set DAC volume to max + __pi_ak4332_reg_write(&ak4332->i2c, 0x0b, 0x1F); + + // Configure PLL to take BLCK as input clock + __pi_ak4332_reg_write(&ak4332->i2c, 0x0E, 0x1); + + // Configure DAC to take PLL as input clock + __pi_ak4332_reg_write(&ak4332->i2c, 0x13, 0x1); + + + int pld = 3; + __pi_ak4332_reg_write(&ak4332->i2c, 0x0F, pld >> 8); + __pi_ak4332_reg_write(&ak4332->i2c, 0x10, pld & 0xff); + int plm = 31; + __pi_ak4332_reg_write(&ak4332->i2c, 0x11, plm >> 8); + __pi_ak4332_reg_write(&ak4332->i2c, 0x12, plm & 0xff); + + // set volume to max + //__pi_ak4332_reg_write(&ak4332->i2c, 0x0b, 0x1f); + //__pi_ak4332_reg_write(&ak4332->i2c, 0x0d, 0x7); + + // Power-up PLL + __pi_ak4332_reg_write(&ak4332->i2c, 0x00, 0x1); + + pi_time_wait_us(20000); + + // Power-up PMTIM + __pi_ak4332_reg_write(&ak4332->i2c, 0x00, 0x3); + + // Power-up charge pump for both channels + __pi_ak4332_reg_write(&ak4332->i2c, 0x01, 0x1); + + pi_time_wait_us(65000); + + // Power-up LDO1 + __pi_ak4332_reg_write(&ak4332->i2c, 0x01, 0x31); + + pi_time_wait_us(5000); + + // Power up charge pump 2 + __pi_ak4332_reg_write(&ak4332->i2c, 0x01, 0x33); + + // Power-up DAC + __pi_ak4332_reg_write(&ak4332->i2c, 0x02, 0x1); + + // Power-up Amplifier + __pi_ak4332_reg_write(&ak4332->i2c, 0x03, 0x1); + + return 0; + +error: + pmsis_l2_malloc_free(ak4332, sizeof(ak4332_t)); + return -2; +} + + +int pi_ak4332_set_dac_volume(pi_device_t *device, uint8_t volume) +{ + ak4332_t *ak4332 = (ak4332_t *)device->data; + if (volume > 0x1F) + { + return -1; + } + + return __pi_ak4332_reg_write(&ak4332->i2c, 0x0b, volume); +} + +int pi_ak4332_set_hp_volume(pi_device_t *device, uint8_t volume) +{ + ak4332_t *ak4332 = (ak4332_t *)device->data; + if (volume > 0x7) + { + return -1; + } + + return __pi_ak4332_reg_write(&ak4332->i2c, 0x0d, volume); +} + + +void pi_ak4332_close(struct pi_device *device) +{ + ak4332_t *ak4332 = (ak4332_t *)device->data; + pmsis_l2_malloc_free(ak4332, sizeof(ak4332_t)); +} + + +void pi_ak4332_conf_init(struct pi_ak4332_conf *conf) +{ + bsp_ak4332_conf_init(conf); +} + diff --git a/rtos/pmsis/pmsis_bsp/bsp/gap9_evk.c b/rtos/pmsis/pmsis_bsp/bsp/gap9_evk.c new file mode 100644 index 000000000..124ceff6f --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/bsp/gap9_evk.c @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2019 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "pmsis.h" + +#include "bsp/bsp.h" +#include "bsp/camera/himax.h" +#include "bsp/flash/hyperflash.h" +#include "bsp/ram/hyperram.h" +#include "bsp/ram/spiram.h" +#include "bsp/eeprom/24xx1025.h" +#include "bsp/eeprom/virtual_eeprom.h" + +static int __bsp_init_pads_done = 0; + +static void __bsp_init_pads() +{ + if (!__bsp_init_pads_done) + { + __bsp_init_pads_done = 1; + } +} + +void bsp_aps25xxxn_conf_init(struct pi_aps25xxxn_conf *conf) +{ + conf->ram_start = CONFIG_APS25XXXN_START; + conf->ram_size = CONFIG_APS25XXXN_SIZE; + conf->spi_itf = CONFIG_APS25XXXN_SPI_ITF; + conf->spi_cs = CONFIG_APS25XXXN_SPI_CS; +} + +int bsp_aps25xxxn_open(struct pi_aps25xxxn_conf *conf) +{ + return 0; +} + + +int bsp_24xx1025_open(struct pi_24xx1025_conf *conf) +{ + pi_pad_set_function(CONFIG_24XX1025_I2C_SCL_PAD, CONFIG_24XX1025_I2C_SCL_PADFUN); + pi_pad_set_function(CONFIG_24XX1025_I2C_SDA_PAD, CONFIG_24XX1025_I2C_SDA_PADFUN); + +#ifdef CONFIG_24XX1025_I2C_SCL_PADMUX_GROUP + pi_pad_set_mux_group(CONFIG_24XX1025_I2C_SCL_PAD, CONFIG_24XX1025_I2C_SCL_PADMUX_GROUP); +#endif + +#ifdef CONFIG_24XX1025_I2C_SDA_PADMUX_GROUP + pi_pad_set_mux_group(CONFIG_24XX1025_I2C_SDA_PAD, CONFIG_24XX1025_I2C_SDA_PADMUX_GROUP); +#endif + + return 0; +} + +void bsp_24xx1025_conf_init(struct pi_24xx1025_conf *conf) +{ + conf->i2c_addr = CONFIG_24XX1025_I2C_ADDR; + conf->i2c_itf = CONFIG_24XX1025_I2C_ITF; +} + +void bsp_virtual_eeprom_conf_init(struct pi_virtual_eeprom_conf *conf) +{ + conf->i2c_addr = CONFIG_VIRTUAL_EEPROM_I2C_ADDR; + conf->i2c_itf = CONFIG_VIRTUAL_EEPROM_I2C_ITF; +} + + +void bsp_mx25u51245g_conf_init(struct pi_mx25u51245g_conf *conf) +{ + conf->spi_itf = CONFIG_MX25U51245G_SPI_ITF; + conf->spi_cs = CONFIG_MX25U51245G_SPI_CS; + conf->baudrate = 200000000; +} + +int bsp_mx25u51245g_open(struct pi_mx25u51245g_conf *conf) +{ + return 0; +} + + + +void bsp_himax_conf_init(struct pi_himax_conf *conf) +{ + conf->i2c_itf = CONFIG_HIMAX_I2C_ITF; + conf->cpi_itf = CONFIG_HIMAX_CPI_ITF; +} + +int bsp_himax_open(struct pi_himax_conf *conf) +{ + __bsp_init_pads(); + return 0; +} + +void bsp_init() +{ +} + + +void pi_bsp_init_profile(int profile) +{ +} + + + +// This function is automatically called by the OS during init +void pi_bsp_init() +{ + // Set the pads alternate so that we have by default flash/ram and uart + // working. + // Flash and ram are on hyperbus0, pads 0 to 12 included. + // Uart is on pad 44 and 45 +#ifdef __FREERTOS__ + // TODO freertos is setting everything to 0 by default, keep it for now to not break everything + uint32_t pad_values[] = { 0, 0, 0, 0, 0, 0 }; +#else + uint32_t pad_values[] = { 0x54000000, 0x55555555, 0x50555555, 0x55555555, 0x55555555, 0x55555555 }; +#endif + pi_pad_init(pad_values); + + // Since pad 44 and 45 are for i2c, we need to configure the pad mux + pi_pad_set_mux_group(PI_PAD_044, PI_PAD_MUX_GROUP_UART1_RX); + pi_pad_set_mux_group(PI_PAD_045, PI_PAD_MUX_GROUP_UART1_TX); + + pi_bsp_init_profile(PI_BSP_PROFILE_DEFAULT); + +#if defined(CONFIG_GAP9_EVK_AUDIO_ADDON) + __bsp_audio_addon_init(); +#endif +} diff --git a/rtos/pmsis/pmsis_bsp/bsp/gap9_evk_audio_addon.c b/rtos/pmsis/pmsis_bsp/bsp/gap9_evk_audio_addon.c new file mode 100644 index 000000000..cffee3e17 --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/bsp/gap9_evk_audio_addon.c @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2019 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "pmsis.h" + +#include "bsp/bsp.h" +#include "bsp/boards/gap9_evk/audio_addon.h" + + +#if defined(CONFIG_FXL6408) +static pi_device_t __pi_bsp_fxl6408; +#if !defined(__FREERTOS__) +static PI_FC_TINY uint8_t __pi_bsp_fxl6408_is_init; +#else +static uint8_t __pi_bsp_fxl6408_is_init; +#endif + + +void bsp_fxl6408_conf_init(struct pi_fxl6408_conf *conf) +{ + pi_fxl6408_conf_init(conf); + conf->i2c_itf = CONFIG_FXL6408UMX_I2C_ITF; + conf->interrupt_pin = PI_PAD_089; +} + + +static __attribute__((noinline)) int __pi_bsp_fxl6408_do_init() +{ + struct pi_fxl6408_conf conf; + pi_fxl6408_conf_init(&conf); + pi_open_from_conf(&__pi_bsp_fxl6408, &conf); + if (pi_fxl6408_open(&__pi_bsp_fxl6408)) + { + return - 1; + } + + __pi_bsp_fxl6408_is_init = 1; + + return 0; +} + +static inline __attribute__((always_inline)) int __pi_bsp_fxl6408_check_init() +{ + if (!__pi_bsp_fxl6408_is_init) + { + return __pi_bsp_fxl6408_do_init(); + } + + return 0; +} +#endif + + +#if defined(CONFIG_AK4332) +void bsp_ak4332_conf_init(struct pi_ak4332_conf *conf) +{ + conf->i2c_itf = CONFIG_AK4332_I2C_ITF; +} + +int bsp_ak4332_open(struct pi_ak4332_conf *conf) +{ + if (__pi_bsp_fxl6408_check_init()) + { + return -1; + } + + pi_fxl6408_gpio_conf_t gpio_conf; + pi_fxl6408_gpio_conf_init(&gpio_conf); + gpio_conf.id = CONFIG_FXL6408UMX_AK4332_GPIO; + gpio_conf.direction = FXL6408_GPIO_DIR_OUTPUT; + gpio_conf.output_state = FXL6408_GPIO_OUTPUT_STATE_HIGH; + + if (PI_OK != pi_fxl6408_gpio_set(&__pi_bsp_fxl6408, &gpio_conf)) + { + return -1; + } + + // Wait at least 1ms after ak4332 power-up + // TODO took 2x as margin, check we can switch back to 1 + pi_time_wait_us(2000); + + return 0; +} +#endif + + +#if defined(CONFIG_TLV320) +void bsp_tlv320_conf_init(struct pi_tlv320_conf *conf) +{ + conf->i2c_itf = CONFIG_TLV320_I2C_ITF; +} + +int bsp_tlv320_open(struct pi_tlv320_conf *conf) +{ + if (__pi_bsp_fxl6408_check_init()) + { + return -1; + } + + pi_fxl6408_gpio_conf_t gpio_conf; + pi_fxl6408_gpio_conf_init(&gpio_conf); + gpio_conf.id = CONFIG_FXL6408UMX_TLV320_GPIO; + gpio_conf.direction = FXL6408_GPIO_DIR_OUTPUT; + gpio_conf.output_state = FXL6408_GPIO_OUTPUT_STATE_HIGH; + + if (PI_OK != pi_fxl6408_gpio_set(&__pi_bsp_fxl6408, &gpio_conf)) + { + return -1; + } + + return 0; +} +#endif + + +void __bsp_audio_addon_init() +{ +#if defined(CONFIG_FXL6408) + // Initialize this global state here to work well with retentive wake-up + __pi_bsp_fxl6408_is_init = 0; +#endif + + // Configure padframe for I2C1 + // TODO should use real pad names when available + pi_pad_set_function(PI_PAD_042, PI_PAD_FUNC0); + pi_pad_set_function(PI_PAD_043, PI_PAD_FUNC0); + + // configure gpio for gpio expander interrupt + pi_pad_set_function(PI_PAD_089, PI_PAD_FUNC1); +} diff --git a/rtos/pmsis/pmsis_bsp/docs/adc.rst b/rtos/pmsis/pmsis_bsp/docs/adc.rst new file mode 100644 index 000000000..e033027ad --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/docs/adc.rst @@ -0,0 +1,10 @@ +ADC +--- + +ADS1014 +""""""" + +.. doxygengroup:: ADS1014 + :members: + :private-members: + :protected-members: diff --git a/rtos/pmsis/pmsis_bsp/docs/gpio.rst b/rtos/pmsis/pmsis_bsp/docs/gpio.rst new file mode 100644 index 000000000..c56fd18e7 --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/docs/gpio.rst @@ -0,0 +1,10 @@ +GPIO +---- + +FXL6408 +""""""" + +.. doxygengroup:: FXL6408 + :members: + :private-members: + :protected-members: diff --git a/rtos/pmsis/pmsis_bsp/docs/index.rst b/rtos/pmsis/pmsis_bsp/docs/index.rst index 0db979642..2be0a4424 100644 --- a/rtos/pmsis/pmsis_bsp/docs/index.rst +++ b/rtos/pmsis/pmsis_bsp/docs/index.rst @@ -38,9 +38,11 @@ Drivers .. toctree:: :maxdepth: 2 - ram.rst - flash.rst - camera.rst - fs.rst + adc.rst ble.rst + camera.rst display.rst + flash.rst + fs.rst + gpio.rst + ram.rst diff --git a/rtos/pmsis/pmsis_bsp/flash/mram/mram-v2.c b/rtos/pmsis/pmsis_bsp/flash/mram/mram-v2.c index 5bd728cce..3cddb5001 100644 --- a/rtos/pmsis/pmsis_bsp/flash/mram/mram-v2.c +++ b/rtos/pmsis/pmsis_bsp/flash/mram/mram-v2.c @@ -24,7 +24,7 @@ #include "archi/chips/gap9_v2/pulp_archi.h" #else #include "pmsis/targets/target.h" -#include "pmsis/implem/drivers/udma/udma_core/udma_core.h" +#include "chips/gap9/drivers/udma/udma_core.h" #define ARCHI_UDMA_NB_MRAM UDMA_NB_MRAM #define pos_task_push_locked pi_task_push #define ARCHI_UDMA_MRAM_ID UDMA_MRAM_ID @@ -177,6 +177,9 @@ static void __rt_mram_do_trim(pos_mram_t *mram, void *_trim_cfg_buff) mram->pending_copy = pi_task_block(&task); __rt_mram_trim_cfg_exec(mram, trim_cfg_buff, 0, TRIM_CFG_SIZE*4); pi_task_wait_on(&task); + + // Specs require to wait 20us before erase or program + pi_time_wait_us(20); } static void pos_mram_null_handler(void* arg) @@ -227,11 +230,7 @@ static void pos_mram_handle_pending_tasks(void *arg) } -#ifndef PMSIS_DRIVERS -PI_LOCAL_CODE static void pos_mram_handle_event(int event, void *arg) -#else -static void pos_mram_handle_event(void *arg) -#endif +PI_LOCAL_CODE static void pos_mram_handle_event(uint32_t event, void *arg) { pi_device_t *dev = (pi_device_t *)arg; pos_mram_t *mram = (pos_mram_t *)(pos_mram_t *)dev->data; @@ -307,8 +306,8 @@ static int mram_open(struct pi_device *device) pos_soc_event_register_callback(ARCHI_SOC_EVENT_MRAM_TRIM, pos_mram_handle_event, (void *)device); #else // set rx/tx channel, no attached handler here (mram has its own fixed events) - mram->rx_channel = pi_udma_core_lin_alloc(pos_mram_null_handler, NULL); - mram->tx_channel = pi_udma_core_lin_alloc(pos_mram_null_handler, NULL); + mram->rx_channel = pi_udma_core_lin_alloc(); + mram->tx_channel = pi_udma_core_lin_alloc(); hal_udma_core_lin_reset(hal_udma_core_lin_get(mram->rx_channel)); hal_udma_core_lin_reset(hal_udma_core_lin_get(mram->tx_channel)); @@ -324,10 +323,10 @@ static int mram_open(struct pi_device *device) pi_fc_event_handler_set(SOC_EVENT_UDMA_MRAM_TRIM_EVT(id), pos_mram_handle_event, (void *)device); pi_fc_event_handler_set(SOC_EVENT_UDMA_MRAM_RX_EVT(id), pos_mram_handle_event, (void *)device); // activate events - hal_soc_eu_set_fc_mask(SOC_EVENT_UDMA_MRAM_ERASE_EVT(id)); - hal_soc_eu_set_fc_mask(SOC_EVENT_UDMA_MRAM_TX_EVT(id)); - hal_soc_eu_set_fc_mask(SOC_EVENT_UDMA_MRAM_TRIM_EVT(id)); - hal_soc_eu_set_fc_mask(SOC_EVENT_UDMA_MRAM_RX_EVT(id)); + pi_soc_eu_fc_mask_set(SOC_EVENT_UDMA_MRAM_ERASE_EVT(id)); + pi_soc_eu_fc_mask_set(SOC_EVENT_UDMA_MRAM_TX_EVT(id)); + pi_soc_eu_fc_mask_set(SOC_EVENT_UDMA_MRAM_TRIM_EVT(id)); + pi_soc_eu_fc_mask_set(SOC_EVENT_UDMA_MRAM_RX_EVT(id)); #endif #ifndef CONFIG_XIP_MRAM @@ -339,7 +338,9 @@ static int mram_open(struct pi_device *device) // In XIP mode, we need to lock XIP refills to avoid having a read while the flash is doing the program operation. udma_mram_trans_mode_set(base, UDMA_MRAM_TRANS_MODE_AUTO_ENA(1) | UDMA_MRAM_TRANS_MODE_XIP_EN(1) | UDMA_MRAM_TRANS_MODE_XIP_AUTO_HALTED(1)); #else - udma_mram_trans_mode_set(base, UDMA_MRAM_TRANS_MODE_AUTO_ENA(1)); + udma_mram_trans_mode_set(base, UDMA_MRAM_TRANS_MODE_AUTO_ENA(1) + | UDMA_MRAM_TRANS_MODE_XIP_EN(conf->xip_en) + | UDMA_MRAM_TRANS_MODE_XIP_AUTO_HALTED(conf->xip_en)); #endif #ifndef CONFIG_XIP_MRAM @@ -897,4 +898,5 @@ void pi_mram_conf_init(struct pi_mram_conf *conf) conf->flash.api = &mram_api; conf->itf = 0; conf->baudrate = 15000000; + conf->xip_en = 0; } diff --git a/rtos/pmsis/pmsis_bsp/flash/spiflash/atxp032.c b/rtos/pmsis/pmsis_bsp/flash/spiflash/atxp032.c index de792089f..5b3a14628 100644 --- a/rtos/pmsis/pmsis_bsp/flash/spiflash/atxp032.c +++ b/rtos/pmsis/pmsis_bsp/flash/spiflash/atxp032.c @@ -61,7 +61,7 @@ #define ATXP032_PROGRAM_FLAGS (PI_OCTOSPI_FLAG_CMD_SIZE_1 | PI_OCTOSPI_FLAG_ADDR_SIZE_4 | PI_OCTOSPI_FLAG_LINE_OCTO | PI_OCTOSPI_FLAG_CMD_STR | PI_OCTOSPI_FLAG_ADDR_DTR | PI_OCTOSPI_FLAG_DATA_DTR) #define ATXP032_READ_CMD (0x0B | PI_OCTOSPI_CMD_ADDR_EVEN) -#define ATXP032_READ_LATENCY 22 +#define ATXP032_READ_LATENCY 5 #define ATXP032_READ_FLAGS (PI_OCTOSPI_FLAG_CMD_SIZE_1 | PI_OCTOSPI_FLAG_ADDR_SIZE_4 | PI_OCTOSPI_FLAG_LINE_OCTO | PI_OCTOSPI_FLAG_CMD_STR | PI_OCTOSPI_FLAG_ADDR_DTR | PI_OCTOSPI_FLAG_DATA_DTR) #define SECTOR_SIZE (1<<12) @@ -248,7 +248,7 @@ static int atxp032_open(struct pi_device *device) // Activate octospi mode and DTR and unprotect all sectors - uint32_t data = 0x1b880200; + uint32_t data = 0x17880200; pi_octospi_op_conf_t op_ws = { .cmd=ATXP032_WRITE_STATUS_CMD, .latency=ATXP032_WRITE_STATUS_LATENCY_SPI, .flags=ATXP032_WRITE_STATUS_FLAGS_SPI }; pi_octospi_write(&atxp032->octospi_device, 0, &data, 4, &op_ws); @@ -262,7 +262,7 @@ static int atxp032_open(struct pi_device *device) // Activate octospi mode and DTR and unprotect all sectors // Since the UDMA does not support 1 byte address in DDR mode, we pack it into the data - char status_regs[5] = { 0x00, 0x00, 0x02, 0x88, 0x1b }; + char status_regs[5] = { 0x00, 0x00, 0x02, 0x88, 0x17 }; pi_octospi_op_conf_t op_ws = { .cmd=ATXP032_WRITE_STATUS_CMD, .latency=ATXP032_WRITE_STATUS_LATENCY_OCTO, .flags=ATXP032_WRITE_STATUS_FLAGS_OCTO }; pi_octospi_write(&atxp032->octospi_device, 0, status_regs, 5, &op_ws); @@ -271,6 +271,12 @@ static int atxp032_open(struct pi_device *device) // In the spec writing to volatile status register should take 200ns but RTL model take 10us to update it pi_time_wait_us(20); + + if(conf->xip_en) + { + pi_octospi_ioctl(&atxp032->octospi_device, PI_OCTOSPI_IOCTL_SET_XIP_OP, (void *)&atxp032_read_op); + } + return 0; error: diff --git a/rtos/pmsis/pmsis_bsp/flash/spiflash/mx25u51245g.c b/rtos/pmsis/pmsis_bsp/flash/spiflash/mx25u51245g.c new file mode 100644 index 000000000..44fc4e4ed --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/flash/spiflash/mx25u51245g.c @@ -0,0 +1,900 @@ +/* + * Copyright (C) 2018 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Authors: Germain Haugou, GreenWaves Technologies (germain.haugou@greenwaves-technologies.com) + */ + +// Driver for the octo spi flash Adesto MX25U + +#include "pmsis.h" +#include "bsp/bsp.h" +#include "pmsis/drivers/octospi.h" + +#ifndef PI_LOCAL_CODE +#define PI_LOCAL_CODE +#endif + +#if defined(CONFIG_XIP) +// For now we always activate XIP locking since we only have flash which do not support concurrent read and write. +// This has to be deactivated for flash which support it (e.g. ATXP064R) +#define MX25U_LOCK_XIP +#endif + +#define MX25U_READ_STATUS_CMD_SPI (0x05 | PI_OCTOSPI_CMD_ADDR_EVEN) +#define MX25U_READ_STATUS_CMD_OCTO (0x05FA | PI_OCTOSPI_CMD_ADDR_EVEN) +#define MX25U_READ_STATUS_LATENCY_SPI 0 +#define MX25U_READ_STATUS_LATENCY_OCTO 4 +#define MX25U_READ_STATUS_FLAGS_SPI (PI_OCTOSPI_FLAG_CMD_SIZE_1 | PI_OCTOSPI_FLAG_ADDR_SIZE_0 | PI_OCTOSPI_FLAG_LINE_SINGLE | PI_OCTOSPI_FLAG_CMD_STR | PI_OCTOSPI_FLAG_ADDR_STR | PI_OCTOSPI_FLAG_DATA_STR) +#define MX25U_READ_STATUS_FLAGS_OCTO (PI_OCTOSPI_FLAG_CMD_SIZE_2 | PI_OCTOSPI_FLAG_ADDR_SIZE_4 | PI_OCTOSPI_FLAG_LINE_OCTO | PI_OCTOSPI_FLAG_CMD_DTR | PI_OCTOSPI_FLAG_ADDR_DTR | PI_OCTOSPI_FLAG_DATA_DTR) + +#define MX25U_WRITE_STATUS_CMD (0x71 | PI_OCTOSPI_CMD_ADDR_EVEN) +#define MX25U_WRITE_STATUS_LATENCY_SPI 0 +#define MX25U_WRITE_STATUS_LATENCY_OCTO 0 +#define MX25U_WRITE_STATUS_FLAGS_SPI (PI_OCTOSPI_FLAG_CMD_SIZE_1 | PI_OCTOSPI_FLAG_ADDR_SIZE_4 | PI_OCTOSPI_FLAG_LINE_SINGLE | PI_OCTOSPI_FLAG_CMD_STR | PI_OCTOSPI_FLAG_ADDR_STR | PI_OCTOSPI_FLAG_DATA_STR) +#define MX25U_WRITE_STATUS_FLAGS_OCTO (PI_OCTOSPI_FLAG_CMD_SIZE_1 | PI_OCTOSPI_FLAG_ADDR_SIZE_0 | PI_OCTOSPI_FLAG_LINE_OCTO | PI_OCTOSPI_FLAG_CMD_STR | PI_OCTOSPI_FLAG_ADDR_DTR | PI_OCTOSPI_FLAG_DATA_DTR) + +#define MX25U_READ_CONFREG_CMD_SPI (0x71 | PI_OCTOSPI_CMD_ADDR_EVEN) +#define MX25U_READ_CONFREG_CMD_OCTO (0x718E | PI_OCTOSPI_CMD_ADDR_EVEN) +#define MX25U_READ_CONFREG_LATENCY_SPI 0 +#define MX25U_READ_CONFREG_LATENCY_OCTO 4 +#define MX25U_READ_CONFREG_FLAGS_SPI (PI_OCTOSPI_FLAG_CMD_SIZE_1 | PI_OCTOSPI_FLAG_ADDR_SIZE_4 | PI_OCTOSPI_FLAG_LINE_SINGLE | PI_OCTOSPI_FLAG_CMD_STR | PI_OCTOSPI_FLAG_ADDR_STR | PI_OCTOSPI_FLAG_DATA_STR) +#define MX25U_READ_CONFREG_FLAGS_OCTO (PI_OCTOSPI_FLAG_CMD_SIZE_2 | PI_OCTOSPI_FLAG_ADDR_SIZE_4 | PI_OCTOSPI_FLAG_LINE_OCTO | PI_OCTOSPI_FLAG_CMD_DTR | PI_OCTOSPI_FLAG_ADDR_DTR | PI_OCTOSPI_FLAG_DATA_DTR) + +#define MX25U_WRITE_CONFREG_CMD (0x72 | PI_OCTOSPI_CMD_ADDR_EVEN) +#define MX25U_WRITE_CONFREG_LATENCY_SPI 0 +#define MX25U_WRITE_CONFREG_LATENCY_OCTO 0 +#define MX25U_WRITE_CONFREG_FLAGS_SPI (PI_OCTOSPI_FLAG_CMD_SIZE_1 | PI_OCTOSPI_FLAG_ADDR_SIZE_4 | PI_OCTOSPI_FLAG_LINE_SINGLE | PI_OCTOSPI_FLAG_CMD_STR | PI_OCTOSPI_FLAG_ADDR_STR | PI_OCTOSPI_FLAG_DATA_STR) +#define MX25U_WRITE_CONFREG_FLAGS_OCTO (PI_OCTOSPI_FLAG_CMD_SIZE_1 | PI_OCTOSPI_FLAG_ADDR_SIZE_0 | PI_OCTOSPI_FLAG_LINE_OCTO | PI_OCTOSPI_FLAG_CMD_STR | PI_OCTOSPI_FLAG_ADDR_DTR | PI_OCTOSPI_FLAG_DATA_DTR) + +#define MX25U_WRITE_ENABLE_CMD_SPI (0x0006 | PI_OCTOSPI_CMD_ADDR_EVEN) +#define MX25U_WRITE_ENABLE_CMD_OCTO (0x06F9 | PI_OCTOSPI_CMD_ADDR_EVEN) +#define MX25U_WRITE_ENABLE_LATENCY_SPI 0 +#define MX25U_WRITE_ENABLE_LATENCY_OCTO 0 +#define MX25U_WRITE_ENABLE_FLAGS_SPI (PI_OCTOSPI_FLAG_CMD_SIZE_1 | PI_OCTOSPI_FLAG_LINE_SINGLE | PI_OCTOSPI_FLAG_CMD_STR | PI_OCTOSPI_FLAG_DATA_STR) +#define MX25U_WRITE_ENABLE_FLAGS_OCTO (PI_OCTOSPI_FLAG_CMD_SIZE_2 | PI_OCTOSPI_FLAG_LINE_OCTO | PI_OCTOSPI_FLAG_CMD_DTR | PI_OCTOSPI_FLAG_DATA_DTR) + +#define MX25U_ERASE_CMD (0x21DE | PI_OCTOSPI_CMD_ADDR_EVEN) +#define MX25U_ERASE_LATENCY 0 +#define MX25U_ERASE_FLAGS (PI_OCTOSPI_FLAG_CMD_SIZE_2 | PI_OCTOSPI_FLAG_ADDR_SIZE_4 | PI_OCTOSPI_FLAG_LINE_OCTO | PI_OCTOSPI_FLAG_CMD_DTR | PI_OCTOSPI_FLAG_ADDR_DTR | PI_OCTOSPI_FLAG_DATA_DTR) + +#define MX25U_PROGRAM_CMD (0x12ED | PI_OCTOSPI_CMD_ADDR_EVEN) +#define MX25U_PROGRAM_LATENCY 0 +#define MX25U_PROGRAM_FLAGS (PI_OCTOSPI_FLAG_CMD_SIZE_2 | PI_OCTOSPI_FLAG_ADDR_SIZE_4 | PI_OCTOSPI_FLAG_LINE_OCTO | PI_OCTOSPI_FLAG_CMD_DTR | PI_OCTOSPI_FLAG_ADDR_DTR | PI_OCTOSPI_FLAG_DATA_DTR | PI_OCTOSPI_FLAG_DATA_DTR_MSB) + +#define MX25U_READ_CMD (0xEE11 | PI_OCTOSPI_CMD_ADDR_EVEN) +#define MX25U_READ_LATENCY 20 +#define MX25U_READ_FLAGS (PI_OCTOSPI_FLAG_CMD_SIZE_2 | PI_OCTOSPI_FLAG_ADDR_SIZE_4 | PI_OCTOSPI_FLAG_LINE_OCTO | PI_OCTOSPI_FLAG_CMD_DTR | PI_OCTOSPI_FLAG_ADDR_DTR | PI_OCTOSPI_FLAG_DATA_DTR | PI_OCTOSPI_FLAG_DATA_DTR_MSB) + +#define SECTOR_SIZE (1<<12) + +#define STALL_TASK_PROGRAM 0 +#define STALL_TASK_ERASE_CHIP 1 +#define STALL_TASK_ERASE_SECTOR 2 +#define STALL_TASK_REG_SET 3 +#define STALL_TASK_REG_GET 4 +#define STALL_TASK_READ 5 +#define STALL_TASK_READ_2D 6 + +typedef struct { + struct pi_device octospi_device; + // Used for communications with mx25u through udma + uint16_t udma_buffer[2]; + + // Waiting queue for common operations (only 1 is handled at the same time) + pi_task_t *waiting_first; + pi_task_t *waiting_last; + + // Task to be enqueued when the on-going operation is done + pi_task_t *pending_task; + + // Waiting queue for erase operation (only 1 is handled at the same time) as it needs a + // second level FSM + pi_task_t *erase_waiting_first; + pi_task_t *erase_waiting_last; + + // Task to be enqueued when the on-going erase operation is done + pi_task_t *erase_task; + + // Task used for internal FSM scheduling for common operations + pi_task_t task; + + // Task used for internal second-level FSM scheduling (for erase operation) + pi_task_t task2; + + // Description of on-going task for common operations. The FSM will keep executing + // until this operation is done + uint32_t pending_octospi_addr; + uint32_t pending_data; + uint32_t pending_size; + + // Description of on-going task for erase operation. The FSM will keep executing + // until this operation is done + uint32_t pending_erase_octospi_addr; + uint32_t pending_erase_size; + +} mx25u_t; + + +static pi_octospi_op_conf_t mx25u_erase_op = { .cmd=MX25U_ERASE_CMD, .latency=MX25U_ERASE_LATENCY, .flags=MX25U_ERASE_FLAGS }; + +static pi_octospi_op_conf_t mx25u_program_op = { .cmd=MX25U_PROGRAM_CMD, .latency=MX25U_PROGRAM_LATENCY, .flags=MX25U_PROGRAM_FLAGS }; + +static pi_octospi_op_conf_t mx25u_read_op = { .cmd=MX25U_READ_CMD, .latency=MX25U_READ_LATENCY, .flags=MX25U_READ_FLAGS }; + + + +static void mx25u_program_async(struct pi_device *device, uint32_t octospi_addr, const void *data, uint32_t size, pi_task_t *task); + +static void mx25u_check_program(void *arg); + +static void mx25u_erase_async(struct pi_device *device, uint32_t addr, int size, pi_task_t *task); + +static int mx25u_stall_task(mx25u_t *mx25u, pi_task_t *task, uint32_t id, uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4); + +static void mx25u_handle_pending_task(void *arg); + +static void mx25u_erase_chip_async(struct pi_device *device, pi_task_t *task); + +static void mx25u_erase_sector_async(struct pi_device *device, uint32_t addr, pi_task_t *task); + +static void mx25u_set_reg_exec(mx25u_t *mx25u, unsigned int addr, unsigned short value) +{ + mx25u->udma_buffer[0] = value; + //pi_octospi_write(&mx25u->octospi_device, addr, mx25u->udma_buffer, 2); +} + + + +// TODO should be moved to pmsis api +static void pi_task_enqueue(pi_task_t *task) +{ + pi_task_push(task); +} + + + +static unsigned short mx25u_get_reg_exec(mx25u_t *mx25u, unsigned int addr) +{ + //pi_octospi_read(&mx25u->octospi_device, addr, mx25u->udma_buffer, 4); + return mx25u->udma_buffer[0]; +} + + +#ifdef CONFIG_XIP + +PI_LOCAL_CODE static uint32_t mx25u_get_status(mx25u_t *mx25u) +{ + struct pi_task task; + uint32_t data; + pi_octospi_op_conf_t op = { .cmd=MX25U_READ_STATUS_CMD_OCTO, .latency=MX25U_READ_STATUS_LATENCY_OCTO, .flags=MX25U_READ_STATUS_FLAGS_OCTO }; + pi_octospi_read_async(&mx25u->octospi_device, 0, &data, 4, &op, pi_task_block(&task)); + pi_task_wait_on_xip(&task); + return data; +} + +#else + +static uint32_t mx25u_get_status(mx25u_t *mx25u) +{ + uint32_t data; + pi_octospi_op_conf_t op = { .cmd=MX25U_READ_STATUS_CMD_OCTO, .latency=MX25U_READ_STATUS_LATENCY_OCTO, .flags=MX25U_READ_STATUS_FLAGS_OCTO }; + pi_octospi_read(&mx25u->octospi_device, 0, &data, 4, &op); + return data; +} + +#endif + + +PI_LOCAL_CODE static int mx25u_is_busy(mx25u_t *mx25u) +{ + uint32_t value = mx25u_get_status(mx25u); + return (value >> 0) & 1; +} + + +static void mx25u_write_enable(mx25u_t *mx25u) +{ + pi_octospi_op_conf_t op = { .cmd=MX25U_WRITE_ENABLE_CMD_OCTO, .latency=MX25U_WRITE_ENABLE_LATENCY_OCTO, .flags=MX25U_WRITE_ENABLE_FLAGS_OCTO }; + int dummy = 0; + pi_octospi_write(&mx25u->octospi_device, 0, &dummy, 0, &op); +} + + + +static int mx25u_open(struct pi_device *device) +{ + struct pi_mx25u51245g_conf *conf = (struct pi_mx25u51245g_conf *)device->config; + + mx25u_t *mx25u = (mx25u_t *)pmsis_l2_malloc(sizeof(mx25u_t)); + if (mx25u == NULL) + { + return -1; + } + + device->data = (void *)mx25u; + + if (bsp_mx25u51245g_open(conf)) + { + goto error; + } + + struct pi_octospi_conf octospi_conf; + pi_octospi_conf_init(&octospi_conf); + + octospi_conf.id = (unsigned char) conf->spi_itf; + octospi_conf.cs = conf->spi_cs; + octospi_conf.type = PI_OCTOSPI_TYPE_FLASH; + octospi_conf.xip_en = conf->xip_en; + octospi_conf.baudrate = conf->baudrate; + + pi_open_from_conf(&mx25u->octospi_device, &octospi_conf); + + int32_t error = pi_octospi_open(&mx25u->octospi_device); + if (error) + { + goto error; + } + + mx25u->pending_task = NULL; + mx25u->waiting_first = NULL; + + mx25u->erase_task = NULL; + mx25u->erase_waiting_first = NULL; + + // Activate DTR octospi mode and DTR + { + pi_octospi_op_conf_t op_we = { .cmd=MX25U_WRITE_ENABLE_CMD_SPI, .latency=MX25U_WRITE_ENABLE_LATENCY_SPI, .flags=MX25U_WRITE_ENABLE_FLAGS_SPI }; + pi_octospi_write(&mx25u->octospi_device, 0, NULL, 0, &op_we); + + pi_octospi_op_conf_t op_ws = { .cmd=MX25U_WRITE_CONFREG_CMD, .latency=MX25U_WRITE_CONFREG_LATENCY_SPI, .flags=MX25U_WRITE_CONFREG_FLAGS_SPI }; + uint32_t data = 1 << 1; + pi_octospi_write(&mx25u->octospi_device, 0, &data, 1, &op_ws); + + pi_time_wait_us(60); + } + + return 0; + +error: + pmsis_l2_malloc_free(mx25u, sizeof(mx25u_t)); + return -2; +} + + + +static void mx25u_close(struct pi_device *device) +{ + mx25u_t *mx25u = (mx25u_t *)device->data; + pi_octospi_close(&mx25u->octospi_device); + pmsis_l2_malloc_free(mx25u, sizeof(mx25u_t)); +} + + + +static int32_t mx25u_ioctl(struct pi_device *device, uint32_t cmd, void *arg) +{ + switch (cmd) + { + case PI_FLASH_IOCTL_INFO: + { + struct pi_flash_info *flash_info = (struct pi_flash_info *)arg; + flash_info->sector_size = 1<<18; + // TODO find a way to know what is on the flash, as they may be a boot binary + flash_info->flash_start = flash_info->sector_size; + } + } + return 0; +} + + +void pi_mx25u_deep_sleep_enter(pi_device_t *device) +{ + mx25u_t *mx25u = (mx25u_t *)device->data; + pi_octospi_op_conf_t op_we = { + .cmd=0xB9, + .latency=0, + .flags=PI_OCTOSPI_FLAG_CMD_SIZE_1 | PI_OCTOSPI_FLAG_LINE_OCTO | PI_OCTOSPI_FLAG_CMD_STR | PI_OCTOSPI_FLAG_DATA_DTR + }; + int dummy = 0; + pi_octospi_write(&mx25u->octospi_device, 0, &dummy, 1, &op_we); +} + + +void pi_mx25u_deep_sleep_exit(pi_device_t *device) +{ + mx25u_t *mx25u = (mx25u_t *)device->data; + pi_octospi_op_conf_t op_we = { + .cmd=0xAB, + .latency=0, + .flags=PI_OCTOSPI_FLAG_CMD_SIZE_1 | PI_OCTOSPI_FLAG_LINE_OCTO | PI_OCTOSPI_FLAG_CMD_STR | PI_OCTOSPI_FLAG_DATA_DTR + }; + int dummy = 0; + pi_octospi_write(&mx25u->octospi_device, 0, &dummy, 1, &op_we); +} + + +static void mx25u_reg_set_async(struct pi_device *device, uint32_t addr, uint8_t *value, pi_task_t *task) +{ + mx25u_t *mx25u = (mx25u_t *)device->data; + + if (mx25u_stall_task(mx25u, task, STALL_TASK_REG_SET, addr, (uint32_t)value, 0, 0, 0)) + return; + + mx25u_set_reg_exec(mx25u, addr, *(uint16_t *)value); + + mx25u_handle_pending_task(device); +} + + + +static void mx25u_reg_get_async(struct pi_device *device, uint32_t addr, uint8_t *value, pi_task_t *task) +{ + mx25u_t *mx25u = (mx25u_t *)device->data; + + if (mx25u_stall_task(mx25u, task, STALL_TASK_REG_GET, addr, (uint32_t)value, 0, 0, 0)) + return; + + *(uint16_t *)value = mx25u_get_reg_exec(mx25u, addr); + + mx25u_handle_pending_task(device); +} + + + +static void mx25u_read_async(struct pi_device *device, uint32_t addr, void *data, uint32_t size, pi_task_t *task) +{ + mx25u_t *mx25u = (mx25u_t *)device->data; + + if (mx25u_stall_task(mx25u, task, STALL_TASK_READ, addr, (uint32_t)data, size, 0, 0)) + return; + + pi_octospi_read_async(&mx25u->octospi_device, addr, data, size, &mx25u_read_op, pi_task_callback(&mx25u->task, mx25u_handle_pending_task, device)); +} + + + +static void mx25u_read_2d_async(struct pi_device *device, uint32_t addr, void *data, uint32_t size, uint32_t stride, uint32_t length, pi_task_t *task) +{ + mx25u_t *mx25u = (mx25u_t *)device->data; + + if (mx25u_stall_task(mx25u, task, STALL_TASK_READ_2D, addr, (uint32_t)data, size, stride, length)) + { + return; + } + + pi_octospi_read_2d_async(&mx25u->octospi_device, addr, data, size, stride, length, &mx25u_read_op, pi_task_callback(&mx25u->task, mx25u_handle_pending_task, device)); +} + + + +static void mx25u_handle_pending_task(void *arg) +{ + struct pi_device *device = (struct pi_device *)arg; + mx25u_t *mx25u = (mx25u_t *)device->data; + + uint32_t irq = disable_irq(); + + pi_task_enqueue(mx25u->pending_task); + mx25u->pending_task = NULL; + + pi_task_t *task = mx25u->waiting_first; + + if (task) + { + mx25u->waiting_first = task->next; + } + + restore_irq(irq); + + if (task) + { + if (task->data[0] == STALL_TASK_PROGRAM) + { + mx25u_program_async(device, task->data[1], (void *)task->data[2], task->data[3], task); + } + else if (task->data[0] == STALL_TASK_ERASE_CHIP) + { + mx25u_erase_chip_async(device, task); + } + else if (task->data[0] == STALL_TASK_ERASE_SECTOR) + { + mx25u_erase_sector_async(device, task->data[1], task); + } + else if (task->data[0] == STALL_TASK_REG_SET) + { + mx25u_reg_set_async(device, task->data[1], (uint8_t *)task->data[2], task); + } + else if (task->data[0] == STALL_TASK_REG_GET) + { + mx25u_reg_get_async(device, task->data[1], (uint8_t *)task->data[2], task); + } + else if (task->data[0] == STALL_TASK_READ) + { + mx25u_read_async(device, task->data[1], (void *)task->data[2], task->data[3], task); + } + else if (task->data[0] == STALL_TASK_READ_2D) + { + mx25u_read_2d_async(device, task->data[1], (void *)task->data[2], task->data[3], task->data[4], task->data[5], task); + } + } +} + + + +static void mx25u_handle_pending_erase_task(void *arg) +{ + struct pi_device *device = (struct pi_device *)arg; + mx25u_t *mx25u = (mx25u_t *)device->data; + + uint32_t irq = disable_irq(); + + pi_task_enqueue(mx25u->erase_task); + mx25u->erase_task = NULL; + + pi_task_t *task = mx25u->erase_waiting_first; + if (task) + { + mx25u->erase_waiting_first = task->next; + } + + restore_irq(irq); + + if (task) + { + mx25u_erase_async(device, task->data[1], task->data[2], task); + } +} + + + +static int mx25u_stall_task(mx25u_t *mx25u, pi_task_t *task, uint32_t id, uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4) +{ + uint32_t irq = disable_irq(); + + if (mx25u->pending_task != NULL) + { + task->data[0] = id; + task->data[1] = arg0; + task->data[2] = arg1; + task->data[3] = arg2; + task->data[4] = arg3; + task->data[5] = arg4; + task->next = NULL; + + if (mx25u->waiting_first) + { + mx25u->waiting_last->next = task; + } + else + { + mx25u->waiting_first = task; + } + + mx25u->waiting_last = task; + + restore_irq(irq); + return 1; + } + + mx25u->pending_task = task; + + restore_irq(irq); + return 0; +} + + + +static int mx25u_stall_erase_task(mx25u_t *mx25u, pi_task_t *task, uint32_t id, uint32_t arg0, uint32_t arg1, uint32_t arg2) +{ + uint32_t irq = disable_irq(); + + if (mx25u->erase_task != NULL) + { + task->data[0] = id; + task->data[1] = arg0; + task->data[2] = arg1; + task->data[3] = arg2; + task->next = NULL; + + if (mx25u->erase_waiting_first) + { + mx25u->erase_waiting_last->next = task; + } + else + { + mx25u->erase_waiting_first = task; + } + + mx25u->erase_waiting_last = task; + + restore_irq(irq); + return 1; + } + + mx25u->erase_task = task; + + restore_irq(irq); + return 0; +} + + +PI_LOCAL_CODE static void mx25u_program_resume(void *arg) +{ + struct pi_device *device = (struct pi_device *)arg; + mx25u_t *mx25u = (mx25u_t *)device->data; + + if (mx25u->pending_size == 0) + { + mx25u_handle_pending_task(device); + } + else + { + #ifdef MX25U_LOCK_XIP + // When XIP is active and flash does not support concurrent read and write, loop on the program operation until it is done + // Since XIP can not work at the same time. + // On multi-threaded systems, we should also put on hold any request to this driver and resume them after the program operation is done, + // since the octosp drover will let other requests execute between 2 operations, to let other devices being used. + while (mx25u->pending_size > 0) + { + mx25u_write_enable(mx25u); + + unsigned int iter_size = 256 - (mx25u->pending_octospi_addr & 0xff); + if (iter_size > mx25u->pending_size) + iter_size = mx25u->pending_size; + + uint32_t octospi_addr = mx25u->pending_octospi_addr; + uint32_t data = mx25u->pending_data; + + mx25u->pending_octospi_addr += iter_size; + mx25u->pending_data += iter_size; + mx25u->pending_size -= iter_size; + + // In XIP mode, we need to lock XIP refills to avoid having a read while the flash is doing the program operation. + pi_octospi_xip_lock(&mx25u->octospi_device); + + // Even though the operation should be asynchronous, do everything synchronously to avoid XIP refills until the operation is done + struct pi_task task; + pi_octospi_write_async(&mx25u->octospi_device, octospi_addr, (void *)data, iter_size, &mx25u_program_op, pi_task_block(&task)); + pi_task_wait_on_xip(&task); + while (mx25u_is_busy(mx25u)) + { + for (int i=0; i<32768/1000; i++) + { + pos_wait_for_event(1<octospi_device); + } + + mx25u_handle_pending_task(device); + #else + unsigned int iter_size = 256 - (mx25u->pending_octospi_addr & 0xff); + if (iter_size > mx25u->pending_size) + iter_size = mx25u->pending_size; + + uint32_t octospi_addr = mx25u->pending_octospi_addr; + uint32_t data = mx25u->pending_data; + + mx25u->pending_octospi_addr += iter_size; + mx25u->pending_data += iter_size; + mx25u->pending_size -= iter_size; + + mx25u_write_enable(mx25u); + pi_octospi_write_async(&mx25u->octospi_device, octospi_addr, (void *)data, iter_size, &mx25u_program_op, pi_task_callback(&mx25u->task, mx25u_check_program, device)); + #endif + } +} + + + +static void mx25u_check_program(void *arg) +{ + struct pi_device *device = (struct pi_device *)arg; + mx25u_t *mx25u = (mx25u_t *)device->data; + + if (mx25u_is_busy(mx25u)) + { + // Typical buffer programming time is 4ms. Note that this could be optimzed by taking into account buffer size + pi_task_push_delayed_us(pi_task_callback(&mx25u->task, mx25u_check_program, device), 1000); + } + else + { + mx25u_program_resume(device); + } +} + + + +PI_LOCAL_CODE static void mx25u_program_async(struct pi_device *device, uint32_t octospi_addr, const void *data, uint32_t size, pi_task_t *task) +{ + mx25u_t *mx25u = (mx25u_t *)device->data; + + if (mx25u_stall_task(mx25u, task, STALL_TASK_PROGRAM, octospi_addr, (uint32_t)data, size, 0, 0)) + return; + + mx25u->pending_octospi_addr = octospi_addr; + mx25u->pending_data = (uint32_t)data; + mx25u->pending_size = size; + + mx25u_program_resume(device); +} + + + + + +static void mx25u_check_erase(void *arg) +{ + struct pi_device *device = (struct pi_device *)arg; + mx25u_t *mx25u = (mx25u_t *)device->data; + + uint32_t reg_status; // = mx25u_get_status_reg(mx25u); + if (mx25u_is_busy(mx25u)) + { + // Typical sector erase time is 25ms but keep it short as this time is shorter or some platform + pi_task_push_delayed_us(pi_task_callback(&mx25u->task, mx25u_check_erase, device), 10000); + } + else + { + mx25u_handle_pending_task(device); + } +} + + +static void mx25u_erase_chip_async(struct pi_device *device, pi_task_t *task) +{ + mx25u_t *mx25u = (mx25u_t *)device->data; + + if (mx25u_stall_task(mx25u, task, STALL_TASK_ERASE_CHIP, 0, 0, 0, 0, 0)) + return; + + + + pi_task_push_delayed_us(pi_task_callback(&mx25u->task, mx25u_check_erase, device), 100000); +} + + +static void mx25u_erase_sector_async(struct pi_device *device, uint32_t addr, pi_task_t *task) +{ + mx25u_t *mx25u = (mx25u_t *)device->data; + + if (mx25u_stall_task(mx25u, task, STALL_TASK_ERASE_SECTOR, addr, 0, 0, 0, 0)) + return; + + mx25u_write_enable(mx25u); + + // We don't need to send data but UDMA needs at least 1 byte, this will be ignored by the flash + pi_octospi_write_async(&mx25u->octospi_device, addr, mx25u->udma_buffer, 0, &mx25u_erase_op, pi_task_callback(&mx25u->task, mx25u_check_erase, device)); +} + + + +PI_LOCAL_CODE static void mx25u_erase_resume(void *arg) +{ + struct pi_device *device = (struct pi_device *)arg; + mx25u_t *mx25u = (mx25u_t *)device->data; + + if (mx25u->pending_erase_size == 0) + { + mx25u_handle_pending_erase_task(device); + } + else + { + #ifdef MX25U_LOCK_XIP + // When XIP is active and flash does not support concurrent read and write, loop on the erase operation until it is done + // Since XIP can not work at the same time. + // On multi-threaded systems, we should also put on hold any request to this driver and resume them after the program operation is done, + // since the octosp drover will let other requests execute between 2 operations, to let other devices being used. + while (mx25u->pending_erase_size > 0) + { + mx25u_write_enable(mx25u); + + // In XIP mode, we need to lock XIP refills to avoid having a read while the flash is doing the program operation. + pi_octospi_xip_lock(&mx25u->octospi_device); + + unsigned int iter_size = SECTOR_SIZE - (mx25u->pending_erase_octospi_addr & (SECTOR_SIZE - 1)); + if (iter_size > mx25u->pending_erase_size) + iter_size = mx25u->pending_erase_size; + + uint32_t octospi_addr = mx25u->pending_erase_octospi_addr; + + mx25u->pending_erase_octospi_addr += iter_size; + mx25u->pending_erase_size -= iter_size; + + struct pi_task task; + + // We don't need to send data but UDMA needs at least 1 byte, this will be ignored by the flash + pi_octospi_write_async(&mx25u->octospi_device, octospi_addr, mx25u->udma_buffer, 1, &mx25u_erase_op, pi_task_block(&task)); + pi_task_wait_on_xip(&task); + + while (mx25u_is_busy(mx25u)) + { + for (int i=0; i<32768/100; i++) + { + pos_wait_for_event(1<octospi_device); + } + + mx25u_handle_pending_erase_task(device); + #else + unsigned int iter_size = SECTOR_SIZE - (mx25u->pending_erase_octospi_addr & (SECTOR_SIZE - 1)); + if (iter_size > mx25u->pending_erase_size) + iter_size = mx25u->pending_erase_size; + + uint32_t octospi_addr = mx25u->pending_erase_octospi_addr; + mx25u_erase_sector_async(device, octospi_addr, pi_task_callback(&mx25u->task2, mx25u_erase_resume, device)); + + mx25u->pending_erase_octospi_addr += iter_size; + mx25u->pending_erase_size -= iter_size; + #endif + } +} + + + +static void mx25u_erase_async(struct pi_device *device, uint32_t addr, int size, pi_task_t *task) +{ + mx25u_t *mx25u = (mx25u_t *)device->data; + + if (mx25u_stall_erase_task(mx25u, task, 3, addr, size, 0)) + { + return; + } + + mx25u->pending_erase_octospi_addr = addr; + mx25u->pending_erase_size = size; + + mx25u_erase_resume(device); +} + + + +static int mx25u_copy_async(struct pi_device *device, uint32_t flash_addr, void *buffer, uint32_t size, int ext2loc, pi_task_t *task) +{ + if (!ext2loc) + mx25u_program_async(device, flash_addr, buffer, size, task); + else + mx25u_read_async(device, flash_addr, buffer, size, task); + + return 0; +} + + + +static int mx25u_copy_2d_async(struct pi_device *device, uint32_t flash_addr, void *buffer, uint32_t size, uint32_t stride, uint32_t length, int ext2loc, pi_task_t *task) +{ + if (!ext2loc) + return -1; + + mx25u_read_2d_async(device, flash_addr, buffer, size, stride, length, task); + + return 0; +} + +static int mx25u_read(struct pi_device *device, uint32_t pi_flash_addr, void *data, uint32_t size) +{ + pi_task_t task; + mx25u_read_async(device, pi_flash_addr, data, size, pi_task_block(&task)); + pi_task_wait_on(&task); + return 0; +} + + +static int mx25u_program(struct pi_device *device, uint32_t pi_flash_addr, const void *data, uint32_t size) +{ + pi_task_t task; + mx25u_program_async(device, pi_flash_addr, data, size, pi_task_block(&task)); + pi_task_wait_on(&task); + return 0; +} + +static inline int mx25u_erase_chip(struct pi_device *device) +{ + pi_task_t task; + mx25u_erase_chip_async(device, pi_task_block(&task)); + pi_task_wait_on(&task); + return 0; +} + +static inline int mx25u_erase_sector(struct pi_device *device, uint32_t pi_flash_addr) +{ + pi_task_t task; + mx25u_erase_sector_async(device, pi_flash_addr, pi_task_block(&task)); + pi_task_wait_on(&task); + return 0; +} + +static inline int mx25u_erase(struct pi_device *device, uint32_t pi_flash_addr, int size) +{ + pi_task_t task; + pi_task_block(&task); + mx25u_erase_async(device, pi_flash_addr, size, &task); + pi_task_wait_on(&task); + return 0; +} + +static inline int mx25u_reg_set(struct pi_device *device, uint32_t pi_flash_addr, uint8_t *value) +{ + pi_task_t task; + mx25u_reg_set_async(device, pi_flash_addr, value, pi_task_block(&task)); + pi_task_wait_on(&task); + return 0; +} + +static inline int mx25u_reg_get(struct pi_device *device, uint32_t pi_flash_addr, uint8_t *value) +{ + pi_task_t task; + mx25u_reg_get_async(device, pi_flash_addr, value, pi_task_block(&task)); + pi_task_wait_on(&task); + return 0; +} + +static inline int mx25u_copy(struct pi_device *device, uint32_t pi_flash_addr, void *buffer, uint32_t size, int ext2loc) +{ + pi_task_t task; + pi_task_block(&task); + if (mx25u_copy_async(device, pi_flash_addr, buffer, size, ext2loc, &task)) + return -1; + pi_task_wait_on(&task); + return 0; +} + +static inline int mx25u_copy_2d(struct pi_device *device, uint32_t pi_flash_addr, void *buffer, uint32_t size, uint32_t stride, uint32_t length, int ext2loc) +{ + pi_task_t task; + pi_task_block(&task); + if (mx25u_copy_2d_async(device, pi_flash_addr, buffer, size, stride, length, ext2loc, &task)) + return -1; + pi_task_wait_on(&task); + return 0; +} + +static pi_flash_api_t mx25u_api = { + .open = &mx25u_open, + .close = &mx25u_close, + .ioctl = &mx25u_ioctl, + .read_async = &mx25u_read_async, + .program_async = &mx25u_program_async, + .erase_chip_async = &mx25u_erase_chip_async, + .erase_sector_async = &mx25u_erase_sector_async, + .erase_async = &mx25u_erase_async, + .reg_set_async = &mx25u_reg_set_async, + .reg_get_async = &mx25u_reg_get_async, + .copy_async = &mx25u_copy_async, + .copy_2d_async = &mx25u_copy_2d_async, + .read = &mx25u_read, + .program = &mx25u_program, + .erase_chip = &mx25u_erase_chip, + .erase_sector = &mx25u_erase_sector, + .erase = &mx25u_erase, + .reg_set = &mx25u_reg_set, + .reg_get = &mx25u_reg_get, + .copy = &mx25u_copy, + .copy_2d = &mx25u_copy_2d, +}; + + + +void pi_mx25u51245g_conf_init(struct pi_mx25u51245g_conf *conf) +{ + conf->flash.api = &mx25u_api; + bsp_mx25u51245g_conf_init(conf); + __flash_conf_init(&conf->flash); + conf->xip_en = 0; +} diff --git a/rtos/pmsis/pmsis_bsp/fs/fs.c b/rtos/pmsis/pmsis_bsp/fs/fs.c index 1b79329df..f47fcb449 100644 --- a/rtos/pmsis/pmsis_bsp/fs/fs.c +++ b/rtos/pmsis/pmsis_bsp/fs/fs.c @@ -340,19 +340,21 @@ void __pi_cl_fs_copy_req_exec(void *_req); void __pi_cl_fs_copy_req_done(void *_req) { pi_cl_fs_req_t *req = (pi_cl_fs_req_t *)_req; + pi_cl_fs_req_t *next_req; pi_fs_file_t *file = req->file; pi_fs_data_t *fs = req->file->fs_data; pi_task_t *task = &fs->cl_req_task; - cl_notify_task_done(&(req->copy.done), req->copy.cid); - uint32_t irq = disable_irq(); fs->cluster_reqs_first = (void *)req->callback.next; - req = fs->cluster_reqs_first; + next_req = fs->cluster_reqs_first; restore_irq(irq); - if (req) + + cl_notify_task_done(&(req->copy.done), req->copy.cid); + + if (next_req) { - __pi_cl_fs_copy_req_exec(req); + __pi_cl_fs_copy_req_exec(next_req); } } diff --git a/rtos/pmsis/pmsis_bsp/fs/host_fs/semihost.c b/rtos/pmsis/pmsis_bsp/fs/host_fs/semihost.c deleted file mode 100644 index 016237eee..000000000 --- a/rtos/pmsis/pmsis_bsp/fs/host_fs/semihost.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "semihost.h" -#include "string.h" - -// roughly this is the last stage of printf: -// print a string until '\0' -void semihost_write0(const char *print_string) -{ - __internal_semihost(SEMIHOSTING_SYS_WRITE0, (long) print_string); -} - -int semihost_open(const char *name, int mode) -{ - uint32_t len = strlen(name); - volatile uint32_t args[3] = {(uint32_t)name,mode,len}; - return __internal_semihost(SEMIHOSTING_SYS_OPEN, (long) args); -} - -int semihost_close(int fd) -{ - //uint32_t args[3] = {name,mode,len}; - return __internal_semihost(SEMIHOSTING_SYS_CLOSE, (long) fd); -} - -int semihost_read(int fd, uint8_t *buffer, int len) -{ - volatile uint32_t args[3] = {(uint32_t)fd,(uint32_t)buffer,(uint32_t)len}; - return __internal_semihost(SEMIHOSTING_SYS_READ, (long) args); -} - -int semihost_write(int fd, uint8_t *buffer, int len) -{ - volatile uint32_t args[3] = {(uint32_t)fd,(uint32_t)buffer,(uint32_t)len}; - return __internal_semihost(SEMIHOSTING_SYS_WRITE, (long) args); -} - -int semihost_seek(int fd, uint32_t pos) -{ - volatile uint32_t args[2] = {(uint32_t)fd,pos}; - return __internal_semihost(SEMIHOSTING_SYS_SEEK, (long) args); -} - -int semihost_flen(int fd) -{ - return __internal_semihost(SEMIHOSTING_SYS_FLEN, (long) fd); -} - -int semihost_exit(int code) -{ - return __internal_semihost(SEMIHOSTING_SYS_EXIT, (long) code); -} diff --git a/rtos/pmsis/pmsis_bsp/fs/host_fs/semihost.h b/rtos/pmsis/pmsis_bsp/fs/host_fs/semihost.h index fba61196c..4d58a542e 100644 --- a/rtos/pmsis/pmsis_bsp/fs/host_fs/semihost.h +++ b/rtos/pmsis/pmsis_bsp/fs/host_fs/semihost.h @@ -98,23 +98,52 @@ __internal_semihost(long n, long _a1) #endif } - // roughly this is the last stage of printf: // print a string until '\0' -void semihost_write0(const char *print_string); +static inline void semihost_write0(const char *print_string) +{ + __internal_semihost(SEMIHOSTING_SYS_WRITE0, (long) print_string); +} -int semihost_open(const char *name, int mode); +static inline int semihost_open(const char *name, int mode) +{ + uint32_t len = strlen(name); + volatile uint32_t args[3] = {(uint32_t)name,mode,len}; + return __internal_semihost(SEMIHOSTING_SYS_OPEN, (long) args); +} -int semihost_close(int fd); +static inline int semihost_close(int fd) +{ + //uint32_t args[3] = {name,mode,len}; + return __internal_semihost(SEMIHOSTING_SYS_CLOSE, (long) fd); +} -int semihost_read(int fd, uint8_t *buffer, int len); +static inline int semihost_read(int fd, uint8_t *buffer, int len) +{ + volatile uint32_t args[3] = {(uint32_t)fd,(uint32_t)buffer,(uint32_t)len}; + return __internal_semihost(SEMIHOSTING_SYS_READ, (long) args); +} -int semihost_write(int fd, uint8_t *buffer, int len); +static inline int semihost_write(int fd, uint8_t *buffer, int len) +{ + volatile uint32_t args[3] = {(uint32_t)fd,(uint32_t)buffer,(uint32_t)len}; + return __internal_semihost(SEMIHOSTING_SYS_WRITE, (long) args); +} -int semihost_seek(int fd, uint32_t pos); +static inline int semihost_seek(int fd, uint32_t pos) +{ + volatile uint32_t args[2] = {(uint32_t)fd,pos}; + return __internal_semihost(SEMIHOSTING_SYS_SEEK, (long) args); +} -int semihost_flen(int fd); +static inline int semihost_flen(int fd) +{ + return __internal_semihost(SEMIHOSTING_SYS_FLEN, (long) fd); +} -int semihost_exit(int code); +static inline int semihost_exit(int code) +{ + return __internal_semihost(SEMIHOSTING_SYS_EXIT, (long) code); +} #endif diff --git a/rtos/pmsis/pmsis_bsp/gpio/fxl6408.c b/rtos/pmsis/pmsis_bsp/gpio/fxl6408.c new file mode 100644 index 000000000..bf26b3544 --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/gpio/fxl6408.c @@ -0,0 +1,466 @@ +/* + * Copyright (C) 2022 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use fxl6408 file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "pmsis.h" +#include "bsp/gpio/fxl6408.h" + +/**************/ +/* Structures */ +/**************/ + +typedef enum { + FXL6408_REG_DEVICE_ID_CTRL = 0x1, + FXL6408_REG_IO_DIRECTION = 0x3, + FXL6408_REG_OUTPUT_STATE = 0x5, + FXL6408_REG_OUTPUT_HIGHZ = 0x7, + FXL6408_REG_INPUT_DEFAULT_STATE = 0x9, + FXL6408_REG_PULL_ENABLE = 0xB, + FXL6408_REG_PULL_UP_DOWN = 0xD, + FXL6408_REG_INPUT_STATUS = 0xF, + FXL6408_REG_INTERRUPT_MASK = 0x11, + FXL6408_REG_INTERRUPT_STATUS = 0x13, +} fxl6408_register_e; + +/* values for the IO direction register */ +enum { + __GPIO_MODE_INPUT = 0x0, + __GPIO_MODE_OUTPUT = 0x1, +}; + +/* values for the output highz register */ +enum { + __GPIO_HIGHZ_DISABLED = 0x0, + __GPIO_HIGHZ_ENABLED = 0x1, +}; + +/* values for the output value register */ +enum { + __GPIO_OUTPUT_LOW = 0x0, + __GPIO_OUTPUT_HIGH = 0x1, +}; + +/* values for the interrupt mask register */ +enum { + __GPIO_INTERRUPT_ENABLED = 0x0, + __GPIO_INTERRUPT_DISABLED = 0x1, +}; + +/* values for the input default state register */ +enum { + __GPIO_TRIGGER_RISING = 0x0, + __GPIO_TRIGGER_FALLING = 0x1, +}; + +/* values for the pull enable register */ +enum { + __GPIO_PULL_DISABLED = 0x0, + __GPIO_PULL_ENABLED = 0x1, +}; + +/* values for the pull up down register */ +enum { + __GPIO_PULL_DOWN = 0x0, + __GPIO_PULL_UP = 0x1, +}; + +typedef struct { + pi_device_t i2c; + pi_device_t gpio_irq; + + /* store device registers value locally to avoid reading and writing back */ + uint8_t gpio_dir; + uint8_t gpio_value; + uint8_t gpio_high_z; + uint8_t gpio_trigger; + uint8_t gpio_pull_enable; + uint8_t gpio_pull_updown; + uint8_t gpio_interrupt_mask; + + /* gpio irq status related */ + pi_task_t gpio_irq_cb; + pi_task_t i2c_interrupt_status_cb; + /* this value will be set by the i2c write read async */ + uint8_t i2c_interrupt_status_payload; //1-byte payload + uint8_t i2c_interrupt_status; + pi_task_t *irq_tasks[8]; +} fxl6408_t; + +/********************/ +/* Static functions */ +/********************/ + +static int __pi_fxl6408_reg_write(pi_device_t *dev, fxl6408_register_e addr, + uint8_t value) +{ + uint8_t buffer[2] = { addr, value }; + if (pi_i2c_write(dev, buffer, 2, PI_I2C_XFER_START | PI_I2C_XFER_STOP)) + { + return -1; + } + return 0; +} + + +static uint8_t __pi_fxl6408_reg_read(pi_device_t *dev, + fxl6408_register_e addr) +{ + uint8_t result; + pi_i2c_write_read(dev, &addr, &result, 1, 1); + return result; +} + + +static int __pi_fxl6408_reset(fxl6408_t *fxl6408) +{ + // To reset the IO expander, just make sure it does not drive gpio outputs + // Set all GPIO to input + fxl6408->gpio_dir = 0x00; + if (__pi_fxl6408_reg_write(&fxl6408->i2c, + FXL6408_REG_IO_DIRECTION, fxl6408->gpio_dir)) { + return -1; + } + + // Set all GPIO output value to 0 + fxl6408->gpio_value = 0x00; + if (__pi_fxl6408_reg_write(&fxl6408->i2c, + FXL6408_REG_OUTPUT_STATE, fxl6408->gpio_value)) { + return -1; + } + + // Set all GPIO to high-Z + fxl6408->gpio_high_z = 0xFF; + if (__pi_fxl6408_reg_write(&fxl6408->i2c, + FXL6408_REG_OUTPUT_HIGHZ, fxl6408->gpio_high_z)) { + return -1; + } + + return 0; +} + +static void __attribute__((noinline)) +__i2c_interrupt_status_cb(void *arg) +{ + fxl6408_t* fxl6408 = (fxl6408_t *) arg; + // retrieve the status of the interrupt and + // schedule corresponding pi_task + + uint8_t irq_status = fxl6408->i2c_interrupt_status; + for (int i = 0; i < 8; i++) { + if (irq_status & (1 << i)) { + /* irq has been triggered */ + if (fxl6408->irq_tasks[i] != NULL) { + /* schedule the task */ + pi_task_push(fxl6408->irq_tasks[i]); + } + } + } +} + +static void __attribute__((noinline)) +__gpio_irq_cb(void* arg) +{ + fxl6408_t* fxl6408 = (fxl6408_t *) arg; + // read the interrupt status (async call) will call another callback. + pi_task_callback(&fxl6408->i2c_interrupt_status_cb, + __i2c_interrupt_status_cb, (void*) fxl6408); + fxl6408->i2c_interrupt_status_payload = FXL6408_REG_INTERRUPT_STATUS; + pi_i2c_write_read_async(&fxl6408->i2c, + &fxl6408->i2c_interrupt_status_payload, + &fxl6408->i2c_interrupt_status, + 1, 1, + &fxl6408->i2c_interrupt_status_cb); +} + +/*****************/ +/* API Functions */ +/*****************/ + +int pi_fxl6408_open(pi_device_t *device) +{ + struct pi_fxl6408_conf *conf = (struct pi_fxl6408_conf *) device->config; + + fxl6408_t *fxl6408 = (fxl6408_t *) pmsis_l2_malloc(sizeof(fxl6408_t)); + if (fxl6408 == NULL) + { + return -1; + } + + device->data = (void *) fxl6408; + + struct pi_i2c_conf i2c_conf; + pi_i2c_conf_init(&i2c_conf); + i2c_conf.itf = conf->i2c_itf; + i2c_conf.max_baudrate = 100000; + pi_i2c_conf_set_slave_addr(&i2c_conf, 0x86, 0); + + pi_open_from_conf(&fxl6408->i2c, &i2c_conf); + if (pi_i2c_open(&fxl6408->i2c)) goto error; + + /* Reset the IO expander to a known state in case, in case it was kept on + * after chip reset */ + if (__pi_fxl6408_reset(fxl6408)) goto error2; + + /* initialize gpio input irq tasks */ + for (int i = 0; i < 8; i++) + { + fxl6408->irq_tasks[i] = NULL; + } + + /* initiliaze gpio irq callback */ + { + pi_gpio_e gpio_pin = conf->interrupt_pin; + struct pi_gpio_conf gpio_conf; + + pi_gpio_conf_init(&gpio_conf); + gpio_conf.port = PI_PAD_089 / 32; + + pi_open_from_conf(&fxl6408->gpio_irq, &gpio_conf); + if (PI_OK != pi_gpio_open(&fxl6408->gpio_irq)) { + goto error2; + } + + pi_gpio_notif_e irq_type = PI_GPIO_NOTIF_FALL; + pi_gpio_flags_e cfg_flags = PI_GPIO_INPUT + | PI_GPIO_PULL_DISABLE + | PI_GPIO_DRIVE_STRENGTH_LOW; + + pi_gpio_pin_configure(&fxl6408->gpio_irq, gpio_pin, cfg_flags); + pi_gpio_pin_notif_configure(&fxl6408->gpio_irq, gpio_pin, irq_type); + + pi_task_callback(&fxl6408->gpio_irq_cb, __gpio_irq_cb, (void*) fxl6408); + + if (PI_OK != pi_gpio_pin_task_add(&fxl6408->gpio_irq, gpio_pin, + &fxl6408->gpio_irq_cb, irq_type)) + { + goto error3; + } + } + + /* clears the reset int else interrupt wont trigger the int pin + * (value is not important) */ + __pi_fxl6408_reg_read(&fxl6408->i2c, FXL6408_REG_DEVICE_ID_CTRL); + /* clears the interrupt status (value is not important) */ + __pi_fxl6408_reg_read(&fxl6408->i2c, FXL6408_REG_INTERRUPT_STATUS); + + return 0; + +error3: + //pi_gpio_close(&fxl6408->gpio_irq); //not implemented on pulpos2 ? +error2: + pi_i2c_close(&fxl6408->i2c); +error: + pmsis_l2_malloc_free(fxl6408, sizeof(fxl6408_t)); + return -2; +} + +int pi_fxl6408_gpio_set(pi_device_t *device, pi_fxl6408_gpio_conf_t *gpio_conf) +{ + if (NULL == device || NULL == device->data || NULL == gpio_conf) + { + return PI_ERR_INVALID_ARG; + } + + fxl6408_t *fxl6408 = (fxl6408_t *)device->data; + + if (gpio_conf->direction == FXL6408_GPIO_DIR_OUTPUT) + { + /* pin is in output mode, only set registers that have an effect */ + fxl6408->gpio_dir = __BITINSERT_R(fxl6408->gpio_dir, + __GPIO_MODE_OUTPUT, 1, gpio_conf->id); + if (__pi_fxl6408_reg_write(&fxl6408->i2c, FXL6408_REG_IO_DIRECTION, fxl6408->gpio_dir)) + { + return PI_ERR_INVALID_STATE; + } + + if (gpio_conf->output_state == FXL6408_GPIO_OUTPUT_STATE_DISABLED) + { + fxl6408->gpio_high_z = __BITINSERT_R(fxl6408->gpio_high_z, + __GPIO_HIGHZ_ENABLED, 1, gpio_conf->id); + } + else { + fxl6408->gpio_high_z = __BITINSERT_R(fxl6408->gpio_high_z, + __GPIO_HIGHZ_DISABLED, 1, gpio_conf->id); + + if (gpio_conf->output_state == FXL6408_GPIO_OUTPUT_STATE_LOW) + { + fxl6408->gpio_value = __BITINSERT_R(fxl6408->gpio_value, + __GPIO_OUTPUT_LOW, 1, gpio_conf->id); + } + else + { + fxl6408->gpio_value = __BITINSERT_R(fxl6408->gpio_value, + __GPIO_OUTPUT_HIGH, 1, gpio_conf->id); + } + + if (__pi_fxl6408_reg_write(&fxl6408->i2c, FXL6408_REG_OUTPUT_STATE, fxl6408->gpio_value)) + { + return PI_ERR_INVALID_STATE; + } + } + if (__pi_fxl6408_reg_write(&fxl6408->i2c, FXL6408_REG_OUTPUT_HIGHZ, fxl6408->gpio_high_z)) + { + return PI_ERR_INVALID_STATE; + } + } + else + { + /* pin is in input mode, only set registers that have an effect */ + fxl6408->gpio_dir = __BITINSERT_R(fxl6408->gpio_dir, + __GPIO_MODE_INPUT, 1, gpio_conf->id); + if (__pi_fxl6408_reg_write(&fxl6408->i2c, FXL6408_REG_IO_DIRECTION, fxl6408->gpio_dir)) + { + return PI_ERR_INVALID_STATE; + } + + // input trigger => (disabled, rising, falling) + if (gpio_conf->input_trigger == FXL6408_GPIO_INPUT_TRIGGER_DISABLED) + { + fxl6408->gpio_interrupt_mask = __BITINSERT_R(fxl6408->gpio_interrupt_mask, + __GPIO_INTERRUPT_DISABLED, 1, gpio_conf->id); + } + else { + fxl6408->gpio_interrupt_mask = __BITINSERT_R(fxl6408->gpio_interrupt_mask, + __GPIO_INTERRUPT_ENABLED, 1, gpio_conf->id); + + if (gpio_conf->input_trigger == FXL6408_GPIO_INPUT_TRIGGER_FALLING) + { + fxl6408->gpio_trigger = __BITINSERT_R(fxl6408->gpio_trigger, + __GPIO_TRIGGER_FALLING, 1, gpio_conf->id); + } + else + { + fxl6408->gpio_trigger = __BITINSERT_R(fxl6408->gpio_trigger, + __GPIO_TRIGGER_RISING, 1, gpio_conf->id); + } + + if (__pi_fxl6408_reg_write(&fxl6408->i2c, FXL6408_REG_INPUT_DEFAULT_STATE, + fxl6408->gpio_trigger)) + { + return PI_ERR_INVALID_STATE; + } + + + /* set the irq task */ + if (NULL != gpio_conf->irq_task) + { + fxl6408->irq_tasks[gpio_conf->id] = gpio_conf->irq_task; + } + } + if (__pi_fxl6408_reg_write(&fxl6408->i2c, FXL6408_REG_INTERRUPT_MASK, + fxl6408->gpio_interrupt_mask)) + { + return PI_ERR_INVALID_STATE; + } + + // pull state => (disabled, pull-up, pull-down) + if (gpio_conf->pull_state == FXL6408_GPIO_PULL_STATE_DISABLED) + { + fxl6408->gpio_pull_enable = __BITINSERT_R(fxl6408->gpio_pull_enable, + __GPIO_PULL_DISABLED, 1, gpio_conf->id); + } + else { + fxl6408->gpio_pull_enable = __BITINSERT_R(fxl6408->gpio_pull_enable, + __GPIO_PULL_ENABLED, 1, gpio_conf->id); + + if (gpio_conf->pull_state == FXL6408_GPIO_PULL_STATE_DOWN) + { + fxl6408->gpio_pull_updown = __BITINSERT_R(fxl6408->gpio_pull_updown, + __GPIO_PULL_DOWN, 1, gpio_conf->id); + } + else + { + fxl6408->gpio_pull_updown = __BITINSERT_R(fxl6408->gpio_pull_updown, + __GPIO_PULL_UP, 1, gpio_conf->id); + } + + if (__pi_fxl6408_reg_write(&fxl6408->i2c, FXL6408_REG_PULL_UP_DOWN, + fxl6408->gpio_pull_updown)) + { + return PI_ERR_INVALID_STATE; + } + } + if (__pi_fxl6408_reg_write(&fxl6408->i2c, FXL6408_REG_PULL_ENABLE, + fxl6408->gpio_pull_enable)) + { + return PI_ERR_INVALID_STATE; + } + } + + return PI_OK; +} + +int pi_fxl6408_input_status_get(pi_device_t *device, uint8_t *input_status) +{ + if (NULL == device || NULL == device->data || NULL == input_status) + { + return PI_ERR_INVALID_ARG; + } + + fxl6408_t *fxl6408 = (fxl6408_t *)device->data; + *input_status = __pi_fxl6408_reg_read(&fxl6408->i2c, FXL6408_REG_INPUT_STATUS); + + return PI_OK; +} + +int pi_fxl6408_interrupt_status_get(pi_device_t *device, uint8_t *interrupt_status) +{ + if (NULL == device || NULL == device->data || NULL == interrupt_status) + { + return PI_ERR_INVALID_ARG; + } + + fxl6408_t *fxl6408 = (fxl6408_t *)device->data; + *interrupt_status = __pi_fxl6408_reg_read(&fxl6408->i2c, FXL6408_REG_INTERRUPT_STATUS); + + return PI_OK; +} + + +void pi_fxl6408_close(pi_device_t *device) +{ + fxl6408_t *fxl6408 = (fxl6408_t *)device->data; + // Make sure it is not driving anymore any gpio output + __pi_fxl6408_reset(fxl6408); + pi_i2c_close(&fxl6408->i2c); + pmsis_l2_malloc_free(fxl6408, sizeof(fxl6408_t)); +} + + +void pi_fxl6408_conf_init(struct pi_fxl6408_conf *conf) +{ + conf->i2c_itf = 0; + conf->interrupt_pin = 0; +} + +void pi_fxl6408_gpio_conf_init(pi_fxl6408_gpio_conf_t *gpio_conf) +{ + if (NULL == gpio_conf) + { + return; + } + + gpio_conf->id = 0; + + /* set the pin as output high impedance */ + gpio_conf->direction = FXL6408_GPIO_DIR_OUTPUT; + gpio_conf->output_state = FXL6408_GPIO_OUTPUT_STATE_DISABLED; + + /* no effect */ + gpio_conf->input_trigger = FXL6408_GPIO_INPUT_TRIGGER_DISABLED; + gpio_conf->pull_state = FXL6408_GPIO_PULL_STATE_DISABLED; + + gpio_conf->irq_task = NULL; +} diff --git a/rtos/pmsis/pmsis_bsp/include/bsp/adc/ads1014.h b/rtos/pmsis/pmsis_bsp/include/bsp/adc/ads1014.h new file mode 100644 index 000000000..df4eb24be --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/include/bsp/adc/ads1014.h @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2021 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "pmsis.h" + +#pragma once + +/** + * @addtogroup ADC + * @{ + */ + +/** + * @defgroup ADS1014 ADS1014 + * + * TI ADS1014 Analog-To-Digital-Converter + * + * @warning Support for comparator IRQ handling is not implemented. + */ + +/** + * @addtogroup ADS1014 + * @{ + */ + +/** + * ADS1014 PGA (Programmable Gain Amplifier) values + * + * It is the range of the measured value. + * The absolute value of the measured voltage will never go above the + * power supply voltage value. + */ +enum ads1014_pga { + ADS1014_PGA_FSR_6V144 = 0x0, + ADS1014_PGA_FSR_4V096 = 0x1, + ADS1014_PGA_FSR_2V048 = 0x2, + ADS1014_PGA_FSR_1V024 = 0x3, + ADS1014_PGA_FSR_0V512 = 0x4, + ADS1014_PGA_FSR_0V256 = 0x5, +}; + +/** + * ADS1014 operating mode values + */ +enum ads1014_operating_mode { + /** The ADC measures continuously. */ + ADS1014_OPERATING_MODE_CONTINUOUS = 0x0, + /** The ADC only measures once, and goes back to power-saving mode */ + ADS1014_OPERATING_MODE_SINGLE_SHOT = 0x1, +}; + +/** + * ADS1014 Sampling rate (samples per second) + */ +enum ads1014_data_rate { + ADS1014_DATA_RATE_SPS_128 = 0x0, + ADS1014_DATA_RATE_SPS_250 = 0x1, + ADS1014_DATA_RATE_SPS_490 = 0x2, + ADS1014_DATA_RATE_SPS_920 = 0x3, + ADS1014_DATA_RATE_SPS_1600 = 0x4, + ADS1014_DATA_RATE_SPS_2400 = 0x5, + ADS1014_DATA_RATE_SPS_3300 = 0x6, +}; + +/** + * ADS1014 Comparator mode + */ +enum ads1014_comparator_mode { + /** + * The comparator triggers when the measured value goes above the high + * threshold, and resets when the value goes below the low threshold. + */ + ADS1014_COMPARATOR_MODE_TRADITIONAL = 0x0, + /** + * The comparator triggers if the measured value goes outside the window, + * i.e. above the high threshold or below the low threshold. + */ + ADS1014_COMPARATOR_MODE_WINDOW = 0x1, +}; + +/** + * ADS1014 Alert/Ready comparator pin polarity + * + * Controls the ADC Alert/Ready pin active polarity + */ +enum ads1014_comparator_polarity { + ADS1014_COMPARATOR_POLARITY_ACTIVE_LOW = 0x0, + ADS1014_COMPARATOR_POLARITY_ACTIVE_HIGH = 0x1, +}; + +/** + * ADS1014 comparator latching mode + * + * Determines whether the comparator latches after triggering. + * When the comparator is set to latch, it will only be cleared by reading + * the ADC measured value. + */ +enum ads1014_comparator_latch { + ADS1014_COMPARATOR_LATCH_DISABLED = 0x0, + ADS1014_COMPARATOR_LATCH_ENABLED = 0x1, +}; + +/** + * ADS1014 comparator status + * + * Determines after how many out-of-bounds conversions the comparator will + * trigger. + */ +enum ads1014_comparator_status { + /** triggers after 1 conversion */ + ADS1014_COMPARATOR_STATUS_ASSERT_ONE = 0x0, + /** triggers after 2 out-of-bounds conversions */ + ADS1014_COMPARATOR_STATUS_ASSERT_TWO = 0x1, + /** triggers after 3 out-of-bounds conversions */ + ADS1014_COMPARATOR_STATUS_ASSERT_THREE = 0x2, + /** the comparator is disabled */ + ADS1014_COMPARATOR_STATUS_DISABLED = 0x3, +}; + +/* @brief Structure holding ADS1014 configuration */ +struct pi_ads1014_conf +{ + /** I2C interface which is connected to the ADC */ + uint8_t i2c_itf; + /** Address of the ADC */ + uint8_t i2c_addr; + + /** ADC operating mode (single or continous) */ + enum ads1014_operating_mode operating_mode; + /** range of the measured value */ + enum ads1014_pga pga; + /** sampling rate */ + enum ads1014_data_rate data_rate; + + /** ADC comparator status (enabled&trigger conditions, or disabled) */ + enum ads1014_comparator_status comparator_status; + /** ADC comparator mode (traditional or window) */ + enum ads1014_comparator_mode comparator_mode; + /** ADC comparator latch setting */ + enum ads1014_comparator_latch comparator_latch; + /** ADC comparator triggered polarity */ + enum ads1014_comparator_polarity comparator_polarity; +}; + +/** + * @brief Initialize an ADS1014 configuration with default values. + * + * The structure containing the configuration must be kept alive until + * the device is opened. + * It can only be called from fabric-controller side. + * + * @param[inout] conf Pointer to the device configuration. + */ +void pi_ads1014_conf_init(struct pi_ads1014_conf *conf); + +/** + * Open a ADS1014 device + * + * @param[inout] device pointer to the ADS1014 device + * + * @return PI_OK if operation was sucessful, + * an error code otherwise + */ +int pi_ads1014_open(pi_device_t *device); + +/** + * Close a ADS1014 device + * + * @param[inout] device pointer to the ADS1014 device + */ +void pi_ads1014_close(pi_device_t *device); + + +/** + * Read the value measured by the ADC. + * + * @param[in] device pointer to the ads1014 device + * @param[out] value value in mV returned by the ADC + * + * @return PI_OK if operation was successful, + * an error code otherwise + */ +int pi_ads1014_read(pi_device_t *device, float *value); + +/** + * Set the comparator thresholds (low and high) + * + * @param[in] device pointer to the ads1014 device + * @param[in] threshold_low new value for comparator low threshold (in mV) + * @param[in] threshold_high new value for comparator high threshold (in mV) + * + * @return PI_OK if operation was successful, + * an error code otherwise + */ +int pi_ads1014_set_comparator_thresholds(pi_device_t *device, + float threshold_low, float threshold_high); + + +/** + * @} + */ + +/** + * @} + */ diff --git a/rtos/pmsis/pmsis_bsp/include/bsp/audio/adc/tlv320.h b/rtos/pmsis/pmsis_bsp/include/bsp/audio/adc/tlv320.h new file mode 100644 index 000000000..c78aa4cd7 --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/include/bsp/audio/adc/tlv320.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2019 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "pmsis.h" + +#pragma once + +/** + * @addtogroup ADC + * @{ + */ + +/** + * @defgroup tlv320 tlv320 + * + * DAC tlv320 + */ + +/** + * @addtogroup tlv320 + * @{ + */ + +/* @brief Struct holding tlv320 display config. */ +struct pi_tlv320_conf +{ + int i2c_itf; +}; + +/** + * @brief Initialize an tlv320 configuration with default values. + * + * The structure containing the configuration must be kept alive until + * the device is opened. + * It can only be called from fabric-controller side. + * + * @param conf Pointer to the device configuration. + */ +void pi_tlv320_conf_init(struct pi_tlv320_conf *conf); + +int pi_tlv320_open(pi_device_t *device); + +void pi_tlv320_close(struct pi_device *device); + +/** + * @} + */ + +/** + * @} + */ diff --git a/rtos/pmsis/pmsis_bsp/include/bsp/audio/dac/ak4332.h b/rtos/pmsis/pmsis_bsp/include/bsp/audio/dac/ak4332.h new file mode 100644 index 000000000..f2c3833e0 --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/include/bsp/audio/dac/ak4332.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2019 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "pmsis.h" + +#pragma once + +/** + * @addtogroup Dac + * @{ + */ + +/** + * @defgroup Ak4332 Ak4332 + * + * DAC AK4332 + */ + +/** + * @addtogroup Ak4332 + * @{ + */ + +/* @brief Struct holding ak4332 display config. */ +struct pi_ak4332_conf +{ + int i2c_itf; /*!< I2C interface number where the device is connected. */ +}; + +/** + * @brief Initialize an ak4332 configuration with default values. + * + * The structure containing the configuration must be kept alive until + * the device is opened. + * It can only be called from fabric-controller side. + * + * @param conf Pointer to the device configuration. + */ +void pi_ak4332_conf_init(struct pi_ak4332_conf *conf); + +/** \brief Open a ak4332 device. + * + * This function must be called before the ak4332 device can be used. + * It will do all the needed configuration to make it usable and initialize + * the handle used to refer to this opened device when calling other functions. + * + * \param device A pointer to the device structure of the device to open. + * This structure is allocated by the called and must be kept alive until the + * device is closed. + * \return 0 if the operation is successfull, -1 if there was an error. + */ +int pi_ak4332_open(pi_device_t *device); + +/** + * @brief Set DAC digital input volume + * + * The volume can be set to 0 to mute it or from 0x01 (-12dB) to 0x1F (+3.0dB). + * + * @param device Pointer to the device structure. + * \return 0 if the operation is successfull, -1 if there was an error. + */ +int pi_ak4332_set_dac_volume(pi_device_t *device, uint8_t volume); + +/** + * @brief Set headphone amplifier volume + * + * The volume can be set from 0x00 (-10dB) to 0x7 (+4dB). + * + * @param device Pointer to the device structure. + * \return 0 if the operation is successfull, -1 if there was an error. + */ +int pi_ak4332_set_hp_volume(pi_device_t *device, uint8_t volume); + +/** \brief Close an opened ak4332 device. + * + * This function can be called to close an opened ak4332 device once it is + * not needed anymore, in order to free all allocated resources. Once this + * function is called, the device is not accessible anymore and must be opened + * again before being used. + * + * \param device The device structure of the device to close. + */ +void pi_ak4332_close(struct pi_device *device); + +/** + * @} + */ + +/** + * @} + */ diff --git a/rtos/pmsis/pmsis_bsp/include/bsp/boards/gap9_evk/audio_addon.h b/rtos/pmsis/pmsis_bsp/include/bsp/boards/gap9_evk/audio_addon.h new file mode 100644 index 000000000..47ed8bfc5 --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/include/bsp/boards/gap9_evk/audio_addon.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2019 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#define CONFIG_AK4332_I2C_ITF 1 +#define CONFIG_AK4332_I2S_ITF 2 + +#define CONFIG_TLV320_I2C_ITF 1 +#define CONFIG_TLV320_I2S_ITF 2 + +#ifdef __cplusplus +extern "C" { +#endif + +int pi_bsp_ak4332_power_ctrl(int power_enable); + +int pi_bsp_ak4332_power_ctrl(int power_enable); + +uint8_t pi_bsp_fxl6408_read_id(); + + +/// @cond IMPLEM + +void __bsp_audio_addon_init(); + +#define CONFIG_FXL6408UMX_I2C_ITF 1 +#define CONFIG_FXL6408UMX_AK4332_GPIO 1 +#define CONFIG_FXL6408UMX_TLV320_GPIO 2 +/// @endcond + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/tools/nntool/autotiler/math_funcs/float_math_funcs.h b/rtos/pmsis/pmsis_bsp/include/bsp/boards/gap9_evk/bsp.h similarity index 62% rename from tools/nntool/autotiler/math_funcs/float_math_funcs.h rename to rtos/pmsis/pmsis_bsp/include/bsp/boards/gap9_evk/bsp.h index 5d254b96c..1c9d708fa 100644 --- a/tools/nntool/autotiler/math_funcs/float_math_funcs.h +++ b/rtos/pmsis/pmsis_bsp/include/bsp/boards/gap9_evk/bsp.h @@ -1,5 +1,5 @@ /* - * Copyright 2021 GreenWaves Technologies, SAS + * Copyright (C) 2019 GreenWaves Technologies * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,14 +14,5 @@ * limitations under the License. */ +#pragma once -#ifndef __FLOAT_MATH_FUNCS_H__ -#define __FLOAT_MATH_FUNCS_H__ -#include -#include "pulp_dsp/plp_math_extract.h" - -float32_t ffast_cos(float32_t val); -float32_t ffast_sin(float32_t val); -float32_t ffast_sigmoid(float32_t val, float32_t alpha); -float32_t fsigmoid(float32_t val); -#endif \ No newline at end of file diff --git a/rtos/pmsis/pmsis_bsp/include/bsp/bsp.h b/rtos/pmsis/pmsis_bsp/include/bsp/bsp.h index 8606c8e7b..bda0383c2 100644 --- a/rtos/pmsis/pmsis_bsp/include/bsp/bsp.h +++ b/rtos/pmsis/pmsis_bsp/include/bsp/bsp.h @@ -53,9 +53,13 @@ #include #endif +#if defined(CONFIG_GAP9_EVK) +#include +#else #if defined(CONFIG_GAP9_V2) #include #endif +#endif /* Include debug helper. */ #include "bsp/debug.h" @@ -174,6 +178,12 @@ void bsp_atxp032_conf_init(struct pi_atxp032_conf *conf); int bsp_atxp032_open(struct pi_atxp032_conf *conf); #endif +#if defined(CONFIG_MX25U51245G) +#include "bsp/flash/mx25u51245g.h" +void bsp_mx25u51245g_conf_init(struct pi_mx25u51245g_conf *conf); +int bsp_mx25u51245g_open(struct pi_mx25u51245g_conf *conf); +#endif + #if defined(CONFIG_NINA_W10) #include "bsp/transport/nina_w10.h" void bsp_nina_w10_conf_init(struct pi_nina_w10_conf *conf); @@ -194,6 +204,25 @@ void bsp_thermeye_conf_init(struct pi_thermeye_conf *conf); int bsp_thermeye_open(struct pi_thermeye_conf *conf); #endif /* CONFIG_THERMEYE */ +#if defined(CONFIG_AK4332) +#include "audio/dac/ak4332.h" +void bsp_ak4332_conf_init(struct pi_ak4332_conf *conf); +int bsp_ak4332_open(struct pi_ak4332_conf *conf); +#endif /* CONFIG_AK4332 */ + +#if defined(CONFIG_TLV320) +#include "audio/adc/tlv320.h" +void bsp_tlv320_conf_init(struct pi_tlv320_conf *conf); +int bsp_tlv320_open(struct pi_tlv320_conf *conf); +#endif /* CONFIG_TLV320 */ + +#if defined(CONFIG_FXL6408) +#include "gpio/fxl6408.h" +void bsp_fxl6408_conf_init(struct pi_fxl6408_conf *conf); +int bsp_fxl6408_open(struct pi_fxl6408_conf *conf); +int bsp_fxl6408_close(struct pi_fxl6408_conf *conf); +#endif /* CONFIG_FXL6408 */ + void bsp_init(); void pi_bsp_init(); diff --git a/rtos/pmsis/pmsis_bsp/include/bsp/flash/mram.h b/rtos/pmsis/pmsis_bsp/include/bsp/flash/mram.h index 4e57bc943..face1328e 100644 --- a/rtos/pmsis/pmsis_bsp/include/bsp/flash/mram.h +++ b/rtos/pmsis/pmsis_bsp/include/bsp/flash/mram.h @@ -49,6 +49,7 @@ struct pi_mram_conf int itf; /*!< Mram interface where the flash is connected. */ int baudrate; /*!< Baudrate in byte/s. */ + int xip_en; }; /** \brief Initialize an Mram configuration with default values. diff --git a/rtos/pmsis/pmsis_bsp/include/bsp/flash/mx25u51245g.h b/rtos/pmsis/pmsis_bsp/include/bsp/flash/mx25u51245g.h new file mode 100644 index 000000000..d2cb1fa88 --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/include/bsp/flash/mx25u51245g.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2019 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __BSP__FLASH__MX25U51245G_H__ +#define __BSP__FLASH__MX25U51245G_H__ + +#include "bsp/flash.h" + +/** + * @addtogroup Flash + * @{ + */ + +/** + * @defgroup Mx25u51245g Mx25u51245g + * + */ + +/** + * @addtogroup Mx25u51245g + * @{ + */ + +/**@{*/ + +/** \struct pi_mx25u51245g_conf + * \brief Mx25u51245g configuration structure. + * + * This structure is used to pass the desired Mx25u51245g configuration to the + * runtime when opening the device. + */ +struct pi_mx25u51245g_conf +{ + struct pi_flash_conf flash; /*!< Generic flash configuration. */ + int spi_itf; /*!< SPI interface where the RAM is + connected. */ + int spi_cs; /*!< Chip select where the RAM is connected. */ + int xip_en; + uint32_t baudrate; /*!< Baudrate (in bytes/second). */ +}; + +/** \brief Initialize an Mx25u51245g configuration with default values. + * + * The structure containing the configuration must be kept alive until the + * mx25u51245g device is opened. + * + * \param conf A pointer to the mx25u51245g configuration. + */ +void pi_mx25u51245g_conf_init(struct pi_mx25u51245g_conf *conf); + + +//!@} + +/** + * @} end of Mx25u51245g + */ + +/** + * @} end of Flash + */ + +#endif diff --git a/rtos/pmsis/pmsis_bsp/include/bsp/gap9_evk.h b/rtos/pmsis/pmsis_bsp/include/bsp/gap9_evk.h new file mode 100644 index 000000000..9a0cebbc8 --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/include/bsp/gap9_evk.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2019 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __BSP__GAP9_EVK_H__ +#define __BSP__GAP9_EVK_H__ + +#if defined(CONFIG_GAP9_EVK_AUDIO_ADDON) +#include "bsp/boards/gap9_evk/audio_addon.h" +#endif + +#define CONFIG_HIMAX +#define CONFIG_MRAM +#define CONFIG_24XX1025 +#define CONFIG_APS25XXXN +#define CONFIG_VIRTUAL_EEPROM +#define CONFIG_MX25U51245G +#define CONFIG_NINA_B112 + +#define CONFIG_HIMAX_CPI_ITF 0 +#define CONFIG_HIMAX_I2C_ITF 0 + +#define CONFIG_APS25XXXN_SPI_ITF 0 +#define CONFIG_APS25XXXN_SPI_CS 1 +#define CONFIG_APS25XXXN_START 0 +#define CONFIG_APS25XXXN_SIZE (1<<25) + +#define CONFIG_MX25U51245G_SPI_ITF 0 +#define CONFIG_MX25U51245G_SPI_CS 0 + +#define CONFIG_24XX1025_I2C_ADDR 0xA0 +#define CONFIG_24XX1025_I2C_ITF 0 +#define CONFIG_24XX1025_I2C_SCL_PAD PI_PAD_040 +#define CONFIG_24XX1025_I2C_SCL_PADFUN PI_PAD_FUNC0 +#define CONFIG_24XX1025_I2C_SDA_PAD PI_PAD_041 +#define CONFIG_24XX1025_I2C_SDA_PADFUN PI_PAD_FUNC0 + +#define CONFIG_VIRTUAL_EEPROM_I2C_ADDR 0x14 +#define CONFIG_VIRTUAL_EEPROM_I2C_ITF 0 + +#define CONFIG_NINA_B112_UART_ID ( 1 ) +/* BLE Nina. */ +#define GPIOA2_NINA_RST ( PI_PAD_040) +#define GPIOA21_NINA17 ( PI_PAD_041) +#define GPIO_NINA_PWRON ( PI_PAD_042) +#define GPIO_NINA17_DSR ( PI_PAD_043) + +#define pi_default_flash_conf pi_mx25u51245g_conf +#define pi_default_flash_conf_init pi_mx25u51245g_conf_init + +#define pi_default_ram_conf pi_aps25xxxn_conf +#define pi_default_ram_conf_init pi_aps25xxxn_conf_init + +#endif diff --git a/rtos/pmsis/pmsis_bsp/include/bsp/gap9_v2.h b/rtos/pmsis/pmsis_bsp/include/bsp/gap9_v2.h index e935802f3..7eba5d772 100644 --- a/rtos/pmsis/pmsis_bsp/include/bsp/gap9_v2.h +++ b/rtos/pmsis/pmsis_bsp/include/bsp/gap9_v2.h @@ -45,13 +45,13 @@ #define CONFIG_SPIRAM_START 0 #define CONFIG_SPIRAM_SIZE (1<<20) -#define CONFIG_APS25XXXN_SPI_ITF 1 -#define CONFIG_APS25XXXN_SPI_CS 0 +#define CONFIG_APS25XXXN_SPI_ITF 0 +#define CONFIG_APS25XXXN_SPI_CS 1 #define CONFIG_APS25XXXN_START 0 #define CONFIG_APS25XXXN_SIZE (1<<25) -#define CONFIG_ATXP032_SPI_ITF 1 -#define CONFIG_ATXP032_SPI_CS 1 +#define CONFIG_ATXP032_SPI_ITF 0 +#define CONFIG_ATXP032_SPI_CS 0 #define CONFIG_SPIFLASH_SPI_ITF 0 #define CONFIG_SPIFLASH_SPI_CS 0 @@ -76,4 +76,22 @@ #define GPIO_NINA_PWRON ( PI_PAD_042) #define GPIO_NINA17_DSR ( PI_PAD_043) +#if defined(__PLATFORM_GVSOC__) + +#define pi_default_flash_conf pi_hyperflash_conf +#define pi_default_flash_conf_init pi_hyperflash_conf_init + +#define pi_default_ram_conf pi_hyperram_conf +#define pi_default_ram_conf_init pi_hyperram_conf_init + +#else + +#define pi_default_flash_conf pi_atxp032_conf +#define pi_default_flash_conf_init pi_atxp032_conf_init + +#define pi_default_ram_conf pi_aps25xxxn_conf +#define pi_default_ram_conf_init pi_aps25xxxn_conf_init + +#endif + #endif diff --git a/rtos/pmsis/pmsis_bsp/include/bsp/gpio/fxl6408.h b/rtos/pmsis/pmsis_bsp/include/bsp/gpio/fxl6408.h new file mode 100644 index 000000000..268733dae --- /dev/null +++ b/rtos/pmsis/pmsis_bsp/include/bsp/gpio/fxl6408.h @@ -0,0 +1,196 @@ +/* + * Copyright (C) 2022 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "pmsis.h" + +#pragma once + +/** + * @addtogroup GPIO + * @{ + */ + +/** + * @defgroup FXL6408 FXL6408 + * + * I2C Controlled GPIO Expander (8 configurable IOs) + */ + +/** + * @addtogroup FXL6408 + * @{ + */ + +/** @brief Struct holding FXL6408 display config. */ +struct pi_fxl6408_conf +{ + int i2c_itf; /*!< I2C interface number where the device is connected. */ + pi_gpio_e interrupt_pin; /*!< interrupt pin */ +}; + +/** + * Direction of a GPIO (input or output) + */ +typedef enum { + FXL6408_GPIO_DIR_INPUT = 0x0, + FXL6408_GPIO_DIR_OUTPUT = 0x1, +} fxl6408_gpio_dir_e; + +/** + * GPIO Output state + * + * This has no effect in input mode. + */ +typedef enum { + /** GPIO is in High-Z (impedance) mode */ + FXL6408_GPIO_OUTPUT_STATE_DISABLED = 0x0, + /** GPIO is in low voltage level, or 0 */ + FXL6408_GPIO_OUTPUT_STATE_LOW = 0x1, + /** GPIO is in high voltage level, or 1 */ + FXL6408_GPIO_OUTPUT_STATE_HIGH = 0x2, +} fxl6408_gpio_output_state_e; + +/** + * GPIO Input trigger conditions (disabled, rising or falling edge) + * + * This has no effect in output mode. + */ +typedef enum { + /** Input will trigger on a rising edge */ + FXL6408_GPIO_INPUT_TRIGGER_RISING = 0x0, + /** Input will trigger on a falling edge */ + FXL6408_GPIO_INPUT_TRIGGER_FALLING = 0x1, + /** Input will never trigger */ + FXL6408_GPIO_INPUT_TRIGGER_DISABLED = 0x2, +} fxl6408_gpio_input_trigger_e; + +/** GPIO Pull up/down state + * + * This has no effect in output mode. + */ +typedef enum { + /** GPIO is set to pull down */ + FXL6408_GPIO_PULL_STATE_DOWN = 0x0, + /** GPIO is set to pull up */ + FXL6408_GPIO_PULL_STATE_UP = 0x1, + /** GPIO pull is disabled */ + FXL6408_GPIO_PULL_STATE_DISABLED = 0x2, +} fxl6408_gpio_pull_state_e; + +/** Structure holding the configuration of a FXL6408 GPIO */ +typedef struct { + /** GPIO id(from 0 to 7) */ + uint8_t id; + /** Direction (input or output) */ + fxl6408_gpio_dir_e direction; + /** Output State (disabled/High-Z, 0 or 1) */ + fxl6408_gpio_output_state_e output_state; + /** Input trigger (trigger on falling edge, rising edge or disabled) */ + fxl6408_gpio_input_trigger_e input_trigger; + /** pull state (pull-up, pull-down, disabled) */ + fxl6408_gpio_pull_state_e pull_state; + /** task executed when an irq is detected */ + pi_task_t *irq_task; +} pi_fxl6408_gpio_conf_t; + +/** + * @brief Initialize an FXL6408 configuration with default values. + * + * The structure containing the configuration must be kept alive until + * the device is opened. + * It can only be called from fabric-controller side. + * It is not thread-safe and cannot be called from a pmsis task callback or + * interrupt handler. + * + * @param[inout] conf Pointer to the device configuration. + */ +void pi_fxl6408_conf_init(struct pi_fxl6408_conf *conf); + +/** + * @brief Open an FXL6408 device. + * + * It can only be called from fabric-controller side. + * It is not thread-safe and cannot be called from a pmsis task callback or + * interrupt handler. + * + * @param[inout] device Pointer to the device. + * + * @return 0 if successfull or any other value otherwise + */ +int pi_fxl6408_open(pi_device_t *device); + +/** + * Close an FXL6408 device. + * + * @param[inout] device device to be closed + */ +void pi_fxl6408_close(pi_device_t *device); + +/** + * Initialize the configuration of a GPIO (Output, High-Z) + * + * @param[inout] gpio_conf configuration of the gpio + */ +void pi_fxl6408_gpio_conf_init(pi_fxl6408_gpio_conf_t *gpio_conf); + +/** + * @brief Set a GPIO state. + * + * It can only be called from fabric-controller side. + * It is not thread-safe and cannot be called from a pmsis task callback or + * interrupt handler. + * + * @param[in] device Pointer to the device. + * @param[in] gpio_conf GPIO configuration + * @return PI_OK if successfull or any other value otherwise + */ +int pi_fxl6408_gpio_set(pi_device_t *device, pi_fxl6408_gpio_conf_t *gpio_conf); + +/** + * Return the current status of inputs + * + * Each bit of the input status is the status of the corresponding + * gpio input. + * + * @param[in] device pointer to the device + * @param[out] input_status value of the input status register + * + * @return PI_OK if operation was successful, an error code otherwise. + */ +int pi_fxl6408_input_status_get(pi_device_t *device, uint8_t *input_status); + +/** + * Return the current status of interrupts + * + * This will clear the interrupt status register. + * + * Each bit of the interrupt status is the status of the corresponding + * gpio interrupt. + * + * @param[in] device pointer to the device + * @param[out] interrupt_status value of the interrupt status register + * + * @return PI_OK if operation was successful, an error code otherwise. + */ +int pi_fxl6408_interrupt_status_get(pi_device_t *device, uint8_t *interrupt_status); + +/** + * @} + */ + +/** + * @} + */ diff --git a/rtos/pmsis/pmsis_bsp/ram/hyperram/hyperram.c b/rtos/pmsis/pmsis_bsp/ram/hyperram/hyperram.c index d1ced37ad..853297d77 100644 --- a/rtos/pmsis/pmsis_bsp/ram/hyperram/hyperram.c +++ b/rtos/pmsis/pmsis_bsp/ram/hyperram/hyperram.c @@ -92,6 +92,18 @@ static int hyperram_open(struct pi_device *device) goto error2; } + +#if defined(WINBOND_HYPER) + hyper_crt0_set(REG_ACCESS); + hyper_crt1_set(REG_ACCESS); + hyperram->reg_value = 0x9f10; + pi_hyper_write(&hyperram->hyper_device, 0x1000, &hyperram->reg_value, 2); + pi_hyper_read(&hyperram->hyper_device, 0x1000, &hyperram->reg_value, 2); + //printf("Reg value of 0x80001000 = %lx\n", hyperram->reg_value); + hyper_crt0_set(MEM_ACCESS); + hyper_crt1_set(MEM_ACCESS); +#endif + #if defined(__GAP9__) pi_hyper_ioctl(&hyperram->hyper_device, PI_HYPER_IOCTL_ENABLE_AES, (void*) 0); diff --git a/rtos/pmsis/pmsis_bsp/ram/spiram/aps25xxxn.c b/rtos/pmsis/pmsis_bsp/ram/spiram/aps25xxxn.c index f19c892aa..529b89d71 100644 --- a/rtos/pmsis/pmsis_bsp/ram/spiram/aps25xxxn.c +++ b/rtos/pmsis/pmsis_bsp/ram/spiram/aps25xxxn.c @@ -215,6 +215,10 @@ void pi_aps25xxxn_conf_init(struct pi_aps25xxxn_conf *conf) conf->baudrate = 0; conf->xip_en = 0; conf->reserve_addr_0 = 1; + #if defined(__GAP9__) + conf->ram.aes_conf.enabled = 0; + conf->ram.aes_conf.qk_en = 0; + #endif bsp_aps25xxxn_conf_init(conf); } diff --git a/rtos/pmsis/pmsis_bsp/rules/freertos_bsp_rules.mk b/rtos/pmsis/pmsis_bsp/rules/freertos_bsp_rules.mk index a6e1acd7d..d5bf804f8 100644 --- a/rtos/pmsis/pmsis_bsp/rules/freertos_bsp_rules.mk +++ b/rtos/pmsis/pmsis_bsp/rules/freertos_bsp_rules.mk @@ -19,21 +19,23 @@ include $(PMSIS_BSP_DIR)/src.mk ifeq ($(BOARD_NAME), gapuino) -PMSIS_BSP_SRC = $(GAPUINO_SRC) +PMSIS_BSP_SRC += $(GAPUINO_SRC) else ifeq ($(BOARD_NAME), gapoc_a) -PMSIS_BSP_SRC = $(GAPOC_A_SRC) +PMSIS_BSP_SRC += $(GAPOC_A_SRC) else ifeq ($(BOARD_NAME), gapoc_a_revb) -PMSIS_BSP_SRC = $(GAPOC_A_SRC) +PMSIS_BSP_SRC += $(GAPOC_A_SRC) else ifeq ($(BOARD_NAME), gapoc_b) -PMSIS_BSP_SRC = $(GAPOC_B_SRC) +PMSIS_BSP_SRC += $(GAPOC_B_SRC) else ifeq ($(BOARD_NAME), gapoc_b_revb) -PMSIS_BSP_SRC = $(GAPOC_B_SRC) +PMSIS_BSP_SRC += $(GAPOC_B_SRC) else ifeq ($(BOARD_NAME), vega) -PMSIS_BSP_SRC = $(VEGA_SRC) +PMSIS_BSP_SRC += $(VEGA_SRC) else ifeq ($(BOARD_NAME), gap9_v2) -PMSIS_BSP_SRC = $(GAP9_SRC) +PMSIS_BSP_SRC += $(GAP9_SRC) else ifeq ($(BOARD_NAME), ai_deck) -PMSIS_BSP_SRC = $(AI_DECK_SRC) +PMSIS_BSP_SRC += $(AI_DECK_SRC) +else ifeq ($(BOARD_NAME), gap9_evk) +PMSIS_BSP_SRC += $(GAP9_EVK_SRC) endif EXCLUDE_FROM_SRCS= transport/transport.c transport/nina_w10/nina_w10.c diff --git a/rtos/pmsis/pmsis_bsp/rules/pulpos/src.mk b/rtos/pmsis/pmsis_bsp/rules/pulpos/src.mk index 29f00f270..96493e41f 100644 --- a/rtos/pmsis/pmsis_bsp/rules/pulpos/src.mk +++ b/rtos/pmsis/pmsis_bsp/rules/pulpos/src.mk @@ -18,8 +18,6 @@ endif BOARD_PROFILE_UPPER = $(shell echo $(PULPOS_BOARD_PROFILE) | tr 'a-z' 'A-Z') PULP_CFLAGS += -DCONFIG_PROFILE_$(BOARD_PROFILE_UPPER) - - # BSP is needed if i2s is used to properly configure pads ifeq '$(CONFIG_I2S)' '1' CONFIG_BSP = 1 @@ -112,3 +110,6 @@ endif ifeq '$(CONFIG_BLE_NINA_B112)' '1' PULP_SRCS += $(BSP_BLE_NINA_B112_SRC) endif + +PULP_SRCS += $(PMSIS_BSP_SRC) +PULP_CFLAGS += $(PMSIS_BSP_CFLAGS) \ No newline at end of file diff --git a/rtos/pmsis/pmsis_bsp/src.mk b/rtos/pmsis/pmsis_bsp/src.mk index 2b36a6c36..326ee544c 100644 --- a/rtos/pmsis/pmsis_bsp/src.mk +++ b/rtos/pmsis/pmsis_bsp/src.mk @@ -1,5 +1,5 @@ BSP_READFS_SRC = fs/read_fs/read_fs.c -BSP_HOSTFS_SRC = fs/host_fs/semihost.c fs/host_fs/host_fs.c +BSP_HOSTFS_SRC = fs/host_fs/host_fs.c BSP_LFS_SRC = fs/lfs/lfs.c fs/lfs/lfs_util.c fs/lfs/pi_lfs.c BSP_FS_SRC = fs/fs.c BSP_FLASH_SRC = flash/flash.c partition/partition.c partition/flash_partition.c \ @@ -21,6 +21,10 @@ BSP_CAMERA_SRC = camera/camera.c BSP_HIMAX_SRC = camera/himax/himax.c BSP_HM0360_SRC = camera/hm0360/hm0360.c BSP_BLE_NINA_B112_SRC= ble/ble.c ble/nina_b112/nina_b112.c ble/nina_b112/nina_b112_old.c +BSP_AK4332_SRC = audio/dac/ak4332.c +BSP_TLV320_SRC = audio/adc/tlv320.c +BSP_FXL6408_SRC = gpio/fxl6408.c +BSP_ADC_ADS1014_SRC = adc/ads1014.c COMMON_SRC = \ $(BSP_FLASH_SRC) \ @@ -44,6 +48,9 @@ VEGA_SRC = \ eeprom/m24c02.c \ $(BSP_24XX1025_SRC) +BSP_GAP9_EVK_AUDIO_ADDON = \ + bsp/gap9_evk_audio_addon.c + GAP9_SRC = \ $(COMMON_SRC) \ eeprom/24XX1025.c \ @@ -53,10 +60,8 @@ GAP9_SRC = \ $(BSP_HIMAX_SRC) \ $(BSP_HYPERFLASH_SRC) \ $(BSP_HYPERRAM_SRC) \ - $(BSP_RAM_SRC) \ $(BSP_MRAM_SRC) \ $(BSP_OSPI_FLASH_SRC) \ - $(BSP_OSPI_RAM_SRC) \ $(BSP_BLE_NINA_B112_SRC) WOLFE_SRC = \ @@ -101,6 +106,11 @@ AI_DECK_SRC = \ $(BSP_SPIFLASH_SRC) \ $(BSP_RAM_SRC) +GAP9_EVK_SRC = \ + $(COMMON_SRC) \ + $(BSP_MRAM_SRC) \ + bsp/gap9_evk.c + GAPOC_A_SRC = \ $(COMMON_SRC) \ bsp/gapoc_a.c \ @@ -148,3 +158,66 @@ GAPOC_B_SRC = \ camera/ov5640/ov5640.c endif # TARGET_CHIP +ifeq '$(BOARD_NAME)' 'gap9_evk' +# Configure the right spi flash +CONFIG_MX25U51245G=1 +CONFIG_APS25XXXN=1 +CONFIG_IO_UART_ITF=1 +CONFIG_IO_UART_BAUDRATE=115200 +endif + +ifeq '$(BOARD_NAME)' 'gap9_v2' +# Configure the right spi flash +CONFIG_ATXP032=1 +CONFIG_HYPERFLASH=1 +CONFIG_HYPERRAM=1 +CONFIG_APS25XXXN=1 +endif + +ifneq (,$(findstring $(BOARD_FEATURES),audio_addon)) + PMSIS_BSP_SRC += $(BSP_GAP9_EVK_AUDIO_ADDON) + PMSIS_BSP_CFLAGS += -DCONFIG_GAP9_EVK_AUDIO_ADDON=1 +endif + +CONFIG_OCTOSPI = 1 +ifeq '$(CONFIG_AK4332)' '1' +PMSIS_BSP_SRC += $(BSP_AK4332_SRC) +CONFIG_FXL6408 = 1 +CONFIG_I2C = 1 +PMSIS_BSP_CFLAGS += -DCONFIG_AK4332=1 +endif + +ifeq '$(CONFIG_TLV320)' '1' +PMSIS_BSP_SRC += $(BSP_TLV320_SRC) +CONFIG_FXL6408 = 1 +CONFIG_I2C = 1 +PMSIS_BSP_CFLAGS += -DCONFIG_TLV320=1 +endif + +ifeq '$(CONFIG_FXL6408)' '1' +PMSIS_BSP_SRC += $(BSP_FXL6408_SRC) +PMSIS_BSP_CFLAGS += -DCONFIG_FXL6408=1 +CONFIG_I2C = 1 +endif + +ifeq '$(CONFIG_MX25U51245G)' '1' +PMSIS_BSP_SRC += flash/spiflash/mx25u51245g.c +CONFIG_FLASH = 1 +CONFIG_OCTOSPI = 1 +endif + +ifeq '$(CONFIG_APS25XXXN)' '1' +PMSIS_BSP_SRC += ram/spiram/aps25xxxn.c +CONFIG_RAM = 1 +CONFIG_OCTOSPI = 1 +endif + +ifeq '$(CONFIG_RAM)' '1' +PMSIS_BSP_SRC += $(BSP_RAM_SRC) +CONFIG_BSP = 1 +endif + +ifeq '$(CONFIG_ADS1014)' '1' +PMSIS_BSP_SRC += $(BSP_ADC_ADS1014_SRC) +PMSIS_BSP_CFLAGS += -DCONFIG_ADS1014=1 +endif diff --git a/rtos/pmsis/pmsis_bsp/zephyr/CMakeLists.txt b/rtos/pmsis/pmsis_bsp/zephyr/CMakeLists.txt index 69a891dcc..dcf7d9e70 100644 --- a/rtos/pmsis/pmsis_bsp/zephyr/CMakeLists.txt +++ b/rtos/pmsis/pmsis_bsp/zephyr/CMakeLists.txt @@ -8,7 +8,6 @@ zephyr_sources( ../fs/read_fs/read_fs.c ../fs/fs.c ../fs/host_fs/host_fs.c - ../fs/host_fs/semihost.c ../flash/flash.c ../flash/hyperflash/hyperflash.c ../ram/ram.c @@ -20,4 +19,4 @@ zephyr_compile_options( -DCONFIG_GAPUINO ) -zephyr_include_directories(../include) \ No newline at end of file +zephyr_include_directories(../include) diff --git a/rtos/pmsis/pmsis_implem/CMakeLists.txt b/rtos/pmsis/pmsis_implem/CMakeLists.txt new file mode 100644 index 000000000..f4eb2da9d --- /dev/null +++ b/rtos/pmsis/pmsis_implem/CMakeLists.txt @@ -0,0 +1,16 @@ +# Driver sources +LIST(APPEND PMSIS_SRC + chips/gap9/drivers/i2s/i2s.c + chips/gap9/drivers/spim/spim.c + chips/gap9/drivers/udma/udma_core.c + chips/gap9/drivers/udma/udma_datamove.c + chips/gap9/drivers/udma/udma_ffc.c + chips/gap9/drivers/udma/udma_timeout.c + chips/gap9/drivers/udma/udma_timestamp.c + chips/gap9/drivers/i2c/i2c.c + chips/gap9/drivers/i2c/i2c_slave.c + ) + +add_library(pmsis_implem STATIC ${PMSIS_SRC}) +target_link_libraries(pmsis_implem PRIVATE freertos) +target_include_directories(pmsis_implem PUBLIC include) diff --git a/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/i2c.c b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/i2c.c new file mode 100644 index 000000000..7bad66e79 --- /dev/null +++ b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/i2c.c @@ -0,0 +1,893 @@ +/* + * Copyright (C) 2022 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "pmsis.h" +#include "pmsis/drivers/i2c.h" +#include "i2c_internal.h" + + +//#define USE_TIMEOUT 1 + + +i2c_itf_data_t *__pi_i2c_itf_data[UDMA_NB_I2C]; + + +static int __pi_i2c_prepare_write_cmd_buf(i2c_slave_data_t *slave_data, uint32_t *write_buffer, + int size, pi_i2c_xfer_flags_e flags); + +static int __pi_i2c_prepare_read_cmd_buf(i2c_slave_data_t *slave_data, uint32_t *write_buffer, + int size, pi_i2c_xfer_flags_e flags); + +static int __pi_i2c_prepare_dual_cmd_buf(i2c_slave_data_t *slave_data, uint32_t *write_buffer, + int size, pi_i2c_xfer_flags_e flags); + +static int __pi_i2c_prepare_write_read_buf(i2c_slave_data_t *slave_data, + uint32_t *buffer, int size0, int size1); + +static int __pi_i2c_prepare_write_dual_buf(i2c_slave_data_t *slave_data, + uint32_t *buffer, int size0, int size1); + + +static void __pi_i2c_write_exec(i2c_slave_data_t *slave_data, uint8_t *buffer, int size, + pi_i2c_xfer_flags_e flags, pi_task_t *task) +{ + uint16_t slave_addr = slave_data->slave_addr; + i2c_itf_data_t *itf_data = slave_data->itf_data; + +#if defined(USE_TIMEOUT) + // TODO this does not take into account errors. Timeout should be restarted with proper time + uint32_t timeout_us = task->timeout; + if (timeout_us) + { + __pi_i2c_timeout_config_set(task, slave_data->itf_data->tx_timeout_id, + slave_data->itf_data->tx_chan_id, timeout_us, + __pi_i2c_timeout_abort, slave_data->itf_data); + } +#endif + int cmd_buf_size = __pi_i2c_prepare_write_cmd_buf(slave_data, itf_data->cmd_buf, + size, flags); + pi_udma_core_lin_enqueue(itf_data->tx_chan_addr, (uint32_t)buffer, size, 0); + pi_udma_core_lin_enqueue(itf_data->cmd_chan_addr, (uint32_t)itf_data->cmd_buf, + cmd_buf_size*sizeof(uint32_t), 0); +} + + +static void __pi_i2c_read_exec(i2c_slave_data_t *slave_data, uint8_t *buffer, int size, + pi_i2c_xfer_flags_e flags, pi_task_t *task) +{ + uint16_t slave_addr = slave_data->slave_addr; + i2c_itf_data_t *itf_data = slave_data->itf_data; + +#if defined(USE_TIMEOUT) + uint32_t timeout_us = task->timeout; + if (timeout_us) + { + __pi_i2c_timeout_config_set(task, slave_data->itf_data->rx_timeout_id, + slave_data->itf_data->rx_chan_id, timeout_us, + __pi_i2c_timeout_abort, slave_data->itf_data); + } +#endif + int cmd_buf_size = __pi_i2c_prepare_read_cmd_buf(slave_data, itf_data->cmd_buf, size, + flags); + pi_udma_core_lin_enqueue(itf_data->rx_chan_addr, (uint32_t)buffer, size, 0); + pi_udma_core_lin_enqueue(itf_data->cmd_chan_addr, (uint32_t)itf_data->cmd_buf, + cmd_buf_size*sizeof(uint32_t), 0); +} + + +static void __pi_i2c_write_read_exec(i2c_slave_data_t *slave_data, void *tx_buffer, + void *rx_buffer, uint32_t tx_size, uint32_t rx_size, pi_task_t *task) +{ + uint16_t slave_addr = slave_data->slave_addr; + i2c_itf_data_t *itf_data = slave_data->itf_data; + int8_t bits = slave_data->is_10_bits; + + pi_udma_core_lin_enqueue(itf_data->tx_chan_addr, (uint32_t)tx_buffer, tx_size, 0); + pi_udma_core_lin_enqueue(itf_data->rx_chan_addr, (uint32_t)rx_buffer, rx_size, 0); + + int cmd_buf_size = __pi_i2c_prepare_write_read_buf(slave_data, itf_data->cmd_buf, + tx_size, rx_size); + pi_udma_core_lin_enqueue(itf_data->cmd_chan_addr, (uint32_t)itf_data->cmd_buf, + sizeof(i2c_cmd_t)*cmd_buf_size, 0); +} + +static void __pi_i2c_write_dual_exec(i2c_slave_data_t *slave_data, void *tx_buffer0, + void *tx_buffer1, uint32_t tx_size0, uint32_t tx_size1, pi_task_t *task) +{ + uint16_t slave_addr = slave_data->slave_addr; + i2c_itf_data_t *itf_data = slave_data->itf_data; + + pi_udma_core_lin_enqueue(itf_data->tx_chan_addr, (uint32_t)tx_buffer0, tx_size0, 0); + pi_udma_core_lin_enqueue(itf_data->tx_chan_addr, (uint32_t)tx_buffer1, tx_size1, 0); + int cmd_buf_size = __pi_i2c_prepare_write_dual_buf(slave_data, itf_data->cmd_buf, + tx_size0, tx_size1); + pi_udma_core_lin_enqueue(itf_data->cmd_chan_addr, (uint32_t)itf_data->cmd_buf, + sizeof(i2c_cmd_t)*cmd_buf_size, 0); +} + + +static inline void __pi_i2c_send_request_from_irq(i2c_itf_data_t* itf_data, pi_task_t* task) +{ + int cmd_buf_size; + + pi_device_t *device = (pi_device_t *)task->data[3]; + i2c_slave_data_t *slave_data = (i2c_slave_data_t *)device->data; + + if(task->data[0] == I2C_WRITE) + { + __pi_i2c_write_exec(slave_data, (void*) task->data[1], task->data[2], task->data[4], task); + } + else if(task->data[0] == I2C_READ) + { + __pi_i2c_read_exec(slave_data, (void*) task->data[1], task->data[2], task->data[4], task); + } + else if(task->data[0] == I2C_WRITE_READ) + { + __pi_i2c_write_read_exec(slave_data, (void*)task->data[1], (void *)task->data[2], + task->data[4], task->data[5], task); + } + else if(task->data[0] == I2C_WRITE_DUAL) + { + __pi_i2c_write_dual_exec(slave_data, (void*)task->data[1], (void *)task->data[2], + task->data[4], task->data[5], task); + } +} + +static inline void __pi_i2c_handle_error(int device_id, i2c_itf_data_t* itf_data) +{ + I2C_TRACE("I2C(%d)->lead_error_handler\n", device_id); + uint32_t nack = __pi_i2c_get_event_status(itf_data->base, I2C_STATUS_ERROR_NACK_EVENT); + uint32_t arlo = __pi_i2c_get_event_status(itf_data->base, I2C_STATUS_ERROR_ARLO_EVENT); + uint32_t framing = __pi_i2c_get_event_status(itf_data->base, I2C_STATUS_ERROR_FRAMING_EVENT); + if (nack || arlo || framing) + { + // 1) stop cmd, rx and tx leader udma addr gen + pi_udma_core_lin_stop(itf_data->rx_chan_addr); + pi_udma_core_lin_stop(itf_data->tx_chan_addr); + pi_udma_core_lin_stop(itf_data->cmd_chan_addr); + + // 2) clear event, unlock and purge + udma_i2c_status_reg_idx_set(itf_data->base, + (nack << I2C_STATUS_ERROR_NACK_EVENT) | + (arlo << I2C_STATUS_ERROR_ARLO_EVENT) | + (framing << I2C_STATUS_ERROR_FRAMING_EVENT) | + (1 << I2C_FLAG_UNLOCK_EVENT_O) | + (1 << I2C_FLAG_PURGE_EVENT_O)); + } + + // 3) depends on error: + if (nack) + { + I2C_TRACE_ERR("I2C(%d)->lead_error_handler - nack error\n", device_id); + // NACK => report error + itf_data->end_task->data[0] = PI_ERR_I2C_NACK; + itf_data->end_task->arg[3] = 0; + pi_task_push_irq_safe(itf_data->end_task); + itf_data->end_task = NULL; + } + else if (arlo || framing) + { + I2C_TRACE_ERR("I2C(%d)->lead_error_handler - arbitration loss or framing error\n", device_id); + // ARLO and FRAMING error => restart current CMD buffer + __pi_i2c_send_request_from_irq(itf_data, itf_data->end_task); + } +} + +__attribute__((section(".text"))) __noinline +void __pi_i2c_lead_event_handler(uint32_t event, void *arg) +{ + i2c_itf_data_t *itf_data = arg; + int device_id = itf_data->id; + I2C_TRACE("I2C(%d)->lead_event_handler\n", device_id); + + // I2C_FLAG_CMD_EVENT is basically our EOT? + if(__pi_i2c_get_event_status(itf_data->base,I2C_FLAG_CMD_EVENT_I)) + { + // set the return status to OK + itf_data->end_task->data[0] = PI_OK; + itf_data->end_task->arg[3] = 0; + // if it's a mutex, release on the spot + pi_task_push_irq_safe(itf_data->end_task); + itf_data->end_task = NULL; + udma_i2c_status_reg_idx_set(itf_data->base, 1<end_task = next_task; + } + return; +} + +/** + * \brief internal helper function for preparing write command buffer + */ +static int __pi_i2c_prepare_write_cmd_buf(i2c_slave_data_t *slave_data, uint32_t *buffer, + int size, pi_i2c_xfer_flags_e flags) +{ + uint16_t slave_addr = slave_data->slave_addr; + int index = 0; + + if(!(flags & PI_I2C_XFER_NO_START) || (flags & PI_I2C_XFER_RESTART)) + { // generate a start condition + buffer[index++] = slave_data->cfg; + buffer[index++] = I2C_CMD_LEAD_START(1); + } + // slave addr, no rnw bit since it's a write + if(!slave_data->is_10_bits) + { + buffer[index++] = I2C_CMD_LEAD_SEND_IMM_ADDR(0, slave_addr & 0xFE); + } + else + { + slave_addr = slave_addr & 0x3FF; + uint16_t slave_addrh = (((slave_addr>>7)|0)&0x7) | 0xF0; + uint16_t slave_addrl = (slave_addr&0xFF); + buffer[index++] = I2C_CMD_LEAD_SEND_IMM_ADDR(1, (slave_addrh << 8) + | slave_addrl); + } + + buffer[index++] = I2C_CMD_RPT(size); + buffer[index++] = I2C_CMD_MISC_SEND(1); + if(!(flags & PI_I2C_XFER_NO_STOP)) + { + buffer[index++] = I2C_CMD_STOP(1); + } + + if(slave_data->wait_cycles) + { + buffer[index++] = I2C_CMD_RPT(slave_data->wait_cycles); + buffer[index++] = I2C_CMD_MISC_WAIT(1); + } + + buffer[index++] = I2C_CMD_EVENT(1); + + return index; +} + +/** + * \brief internal helper function for preparing read command buffer + */ +static inline int __pi_i2c_prepare_read_cmd_buf(i2c_slave_data_t *slave_data, uint32_t *buffer, + int size, pi_i2c_xfer_flags_e flags) +{ + uint16_t slave_addr = slave_data->slave_addr; + int index = 0; + + if(!(flags & PI_I2C_XFER_NO_START) || (flags & PI_I2C_XFER_RESTART)) + { + buffer[index++] = slave_data->cfg; + buffer[index++] = I2C_CMD_LEAD_START(1); + } + + // slave addr + rnw bit + if(!slave_data->is_10_bits) + { + buffer[index++] = I2C_CMD_LEAD_SEND_IMM_ADDR(0, (slave_addr &0xFE)|1); + } + else + { // for 10 bits, need to use write mode first + slave_addr = slave_addr & 0x3FF; + uint16_t slave_addrh = (((slave_addr>>7)|0)&0x7) | 0xF0; + uint16_t slave_addrl = (slave_addr&0xFF); + buffer[index++] = I2C_CMD_LEAD_SEND_IMM_ADDR(1, (slave_addrh << 8) + | slave_addrl); + buffer[index++] = I2C_CMD_LEAD_START(1); + buffer[index++] = I2C_CMD_LEAD_SEND_IMM(slave_addrh|1); + } + buffer[index++] = I2C_CMD_RPT(size - 1); + // receive -1 byte because there is a "last" + buffer[index++] = I2C_CMD_MISC_RECEIVE(1); + buffer[index++] = I2C_CMD_MISC_RECEIVE_LAST(1); + + if(!(flags & PI_I2C_XFER_NO_STOP)) + { + buffer[index++] = I2C_CMD_STOP(1); + } + + if(slave_data->wait_cycles) + { + buffer[index++] = I2C_CMD_RPT(slave_data->wait_cycles); + buffer[index++] = I2C_CMD_MISC_WAIT(1); + } + buffer[index++] = I2C_CMD_EVENT(1); + + return index; +} + + +/** + * \brief internal helper function for preparing write&read command buffer + */ +static int __pi_i2c_prepare_write_read_buf(i2c_slave_data_t *slave_data, + uint32_t *buffer, int size0, int size1) +{ + int index = 0; + + buffer[index++] = slave_data->cfg; + buffer[index++] = I2C_CMD_LEAD_START(1); + // slave addr, no rnw bit since it's a write + buffer[index++] = I2C_CMD_LEAD_SEND_IMM_ADDR(0, slave_data->slave_addr); + buffer[index++] = I2C_CMD_RPT(size0); + buffer[index++] = I2C_CMD_MISC_SEND(1); + buffer[index++] = I2C_CMD_LEAD_START(1); + // slave addr + rnw bit + if(!slave_data->is_10_bits) + { + buffer[index++] = I2C_CMD_LEAD_SEND_IMM_ADDR(0, slave_data->slave_addr|1); + } + else + {// for 10 bits, need to use write mode first + buffer[index++] = I2C_CMD_LEAD_SEND_IMM_ADDR(1, slave_data->slave_addr); + buffer[index++] = I2C_CMD_LEAD_START(1); + buffer[index++] = I2C_CMD_LEAD_SEND_IMM(slave_data->slave_addrh|1); + } + buffer[index++] = I2C_CMD_RPT(size1-1); + // receive -1 byte because there is a "last" + buffer[index++] = I2C_CMD_MISC_RECEIVE(1); + buffer[index++] = I2C_CMD_MISC_RECEIVE_LAST(1); + buffer[index++] = I2C_CMD_STOP(1); + buffer[index++] = I2C_CMD_EVENT(1); + + return index; +} + + +/** + * \brief internal helper function for preparing write&read command buffer + */ +static int __pi_i2c_prepare_write_dual_buf(i2c_slave_data_t *slave_data, + uint32_t *buffer, int size0, int size1) +{ + int index = 0; + + buffer[index++] = slave_data->cfg; + buffer[index++] = I2C_CMD_LEAD_START(1); + // slave addr, no rnw bit since it's a write + buffer[index++] = I2C_CMD_LEAD_SEND_IMM_ADDR(0, slave_data->slave_addr); + buffer[index++] = I2C_CMD_RPT(size0); + buffer[index++] = I2C_CMD_MISC_SEND(1); + buffer[index++] = I2C_CMD_RPT(size1); + buffer[index++] = I2C_CMD_MISC_SEND(1); + buffer[index++] = I2C_CMD_STOP(1); + buffer[index++] = I2C_CMD_EVENT(1); + + return index; +} + + +static void __pi_i2c_timestamp_enable(i2c_itf_data_t *itf_data, struct pi_i2c_conf *conf) +{ +#if defined(__FREERTOS__) + uint8_t is_rx = conf->ts_ch; + + uint32_t base = UDMA_CTRL_ADDR; + uint8_t evt_id = conf->ts_evt_id; + uint8_t soc_evt = is_rx ? SOC_EVENT_UDMA_CHAN_LIN(itf_data->rx_chan_id) : SOC_EVENT_UDMA_CHAN_LIN(itf_data->tx_chan_id); + + uint32_t cfg_evt_val = (udma_ctrl_cfg_event_get(base) & ~(0xFF<config)); + + i2c_slave_data_t *slave_data; + struct pi_i2c_conf *conf = device->config; + i2c_itf_data_t *itf_data = NULL; + + // check interface first + I2C_TRACE("I2C(%d)->lead_open\n", conf->itf); + int irq = disable_irq(); + + slave_data = pi_fc_l1_malloc(sizeof(i2c_slave_data_t)); + if (slave_data == NULL) goto error0; + + if(!(itf_data = __pi_i2c_itf_data[conf->itf])) + { + uint32_t i2c_base = UDMA_I2C_ADDR(conf->itf); + + // prepare itf struct + itf_data = pi_fc_l1_malloc(sizeof(i2c_itf_data_t)); + I2C_TRACE("I2C(%d)->itf_data=%x\n", conf->itf, itf_data); + if(itf_data == NULL) goto error1; + + itf_data->rx_chan_id = pi_udma_core_lin_alloc(); + if (itf_data->rx_chan_id == -1) goto error2; + itf_data->tx_chan_id = pi_udma_core_lin_alloc(); + if (itf_data->tx_chan_id == -1) goto error3; + itf_data->cmd_chan_id = pi_udma_core_lin_alloc(); + if (itf_data->cmd_chan_id == -1) goto error4; + + __pi_i2c_itf_data[conf->itf] = itf_data; + itf_data->id = conf->itf; + itf_data->fifo_head = NULL; + itf_data->end_task = NULL; + itf_data->base = i2c_base; + itf_data->open_nb = 0; + + // disable udma reset before setting regs + udma_ctrl_cfg_rstn_set_set(UDMA_CTRL_ADDR, 1 << UDMA_I2C_ID(conf->itf)); + udma_ctrl_cfg_cg_set_set(UDMA_CTRL_ADDR, 1 << UDMA_I2C_ID(conf->itf)); + + udma_i2c_lead_udma_rx_dest_reg_idx_set(i2c_base, itf_data->rx_chan_id); + udma_i2c_lead_udma_tx_dest_reg_idx_set(i2c_base, itf_data->tx_chan_id); + udma_i2c_udma_cmd_dest_reg_idx_set(i2c_base, itf_data->cmd_chan_id); + + itf_data->rx_chan_addr = pi_udma_core_lin_addr_get(itf_data->rx_chan_id); + itf_data->tx_chan_addr = pi_udma_core_lin_addr_get(itf_data->tx_chan_id); + itf_data->cmd_chan_addr = pi_udma_core_lin_addr_get(itf_data->cmd_chan_id); + +#if defined(USE_TIMEOUT) + itf_data->rx_timeout_id = 0xFF; + itf_data->tx_timeout_id = 0xFF; +#endif + + udma_i2c_status_reg_idx_set(i2c_base, 1<itf), + __pi_i2c_lead_event_handler, itf_data); + pi_soc_eu_fc_mask_set(SOC_EVENT_UDMA_I2C_LEAD_EVT(conf->itf)); + } + + slave_data->itf_data = itf_data; + slave_data->is_10_bits = conf->is_10_bits; + slave_data->wait_cycles = conf->wait_cycles; + slave_data->cfg = __i2c_prepare_timing(conf->max_baudrate, pi_freq_get(PI_FREQ_DOMAIN_PERIPH)); + + if (conf->is_10_bits) + { + uint16_t slave_addr = conf->cs & 0x3FF; + uint16_t slave_addrh = (((slave_addr>>7)|0)&0x7) | 0xF0; + uint16_t slave_addrl = (slave_addr&0xFF); + slave_data->slave_addr = (slave_addrh << 8) | slave_addrl; + slave_data->slave_addrh = slave_addrh; + } + else + { + slave_data->slave_addr = conf->cs & 0xFE; + } + + device->data = (void *)slave_data; + + itf_data->open_nb++; + restore_irq(irq); + return 0; + +error4: + pi_udma_core_lin_free(itf_data->tx_chan_id); +error3: + pi_udma_core_lin_free(itf_data->rx_chan_id); +error2: + pi_fc_l1_free(itf_data, sizeof(i2c_itf_data_t)); +error1: + pi_fc_l1_free(slave_data, sizeof(i2c_slave_data_t)); +error0: + restore_irq(irq); + return -1; +} + + +void pi_i2c_close(pi_device_t *device) +{ + i2c_slave_data_t *slave_data = (i2c_slave_data_t *)device->data; + + I2C_TRACE("I2C->i2c_close\n"); + int irq = disable_irq(); + i2c_itf_data_t *itf_data = slave_data->itf_data; + pi_fc_l1_free(slave_data,sizeof(*slave_data)); + + itf_data->open_nb--; + if(itf_data->open_nb == 0) + { + // flush channels + pi_udma_core_lin_free(itf_data->rx_chan_id); + pi_udma_core_lin_free(itf_data->tx_chan_id); + pi_udma_core_lin_free(itf_data->cmd_chan_id); + + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->rx_chan_id)); + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->tx_chan_id)); + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->cmd_chan_id)); + + pi_udma_core_lin_reset(itf_data->rx_chan_addr); + pi_udma_core_lin_reset(itf_data->tx_chan_addr); + pi_udma_core_lin_reset(itf_data->cmd_chan_addr); + + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_I2C_LEAD_EVT(itf_data->id)); + + udma_ctrl_cfg_cg_clr_set(UDMA_CTRL_ADDR, 1 << UDMA_I2C_ID(itf_data->id)); + udma_ctrl_cfg_rstn_clr_set(UDMA_CTRL_ADDR, 1 << UDMA_I2C_ID(itf_data->id)); + __pi_i2c_itf_data[itf_data->id] = NULL; + pi_fc_l1_free(itf_data,sizeof(*itf_data)); + } + restore_irq(irq); +} + + +static void __pi_i2c_baudrate_set(i2c_itf_data_t *driver_data) +{ +} + + +#if defined(USE_TIMEOUT) +void __pi_i2c_timeout_abort(void* arg) +{ + i2c_itf_data_t *driver_data = (i2c_itf_data_t*) arg; + uint32_t device_id = driver_data->id; + int irq = pi_irq_disable(); + /* Stop UDMA channels. */ + udma_core_lin_t *udma_core = NULL; + if (driver_data->cmd_chan_id != 0xFF) + { + pi_udma_core_lin_reset(driver_data->rx_chan_addr); + } + if (driver_data->tx_chan_id != 0xFF) + { + if (driver_data->end_task->data[0] == I2C_WRITE) + { + driver_data->end_task->arg[3] = pi_udma_core_lin_bytes_left_get(driver_data->base); + } + pi_udma_core_lin_reset(driver_data->tx_chan_addr); + } + if (driver_data->rx_chan_id != 0xFF) + { + if (driver_data->end_task->data[0] == I2C_READ) + { + driver_data->end_task->arg[3] = pi_udma_core_lin_bytes_left_get(driver_data->base); + } + pi_udma_core_lin_reset(driver_data->rx_chan_addr); + } + + /* Status events clear. */ + uint32_t status_mask = (1 << UDMA_I2C_STATUS_REG_IDX_STATUS_LEAD_UNLOCK_EVENT_O_IDX_BIT | + 1 << UDMA_I2C_STATUS_REG_IDX_STATUS_LEAD_PURGE_EVENT_O_IDX_BIT | + 1 << UDMA_I2C_STATUS_REG_IDX_STATUS_I2C_SOFT_RESET_EVENT_O_IDX_BIT); + udma_i2c_status_reg_idx_set(driver_data->base, status_mask); + + /* Pop current aborted task. */ + driver_data->end_task = NULL; + pi_task_t *next_task = __pi_i2c_drv_fifo_pop(driver_data); + if (next_task) + { + driver_data->end_task = next_task; + __pi_i2c_send_request_from_irq(driver_data, next_task); + } + pi_irq_restore(irq); +} + +static void __pi_i2c_udma_timeout_rx_set(i2c_itf_data_t *driver_data, + uint8_t timeout_id) +{ + driver_data->rx_timeout_id = timeout_id; +} + +static void __pi_i2c_udma_timeout_tx_set(i2c_itf_data_t *driver_data, + uint8_t timeout_id) +{ + driver_data->tx_timeout_id = timeout_id; +} +#endif + +void pi_i2c_ioctl(struct pi_device *device, uint32_t cmd, void *arg) +{ + i2c_slave_data_t *slave_data = (i2c_slave_data_t *)device->data; + + I2C_TRACE("I2C(%d) : ioctl cmd=%lx, arg=%lx\n", slave_data->itf_data->id, cmd, arg); + + uint32_t irq = disable_irq(); + uint8_t udma_timeout_id = 0xFF; + switch (cmd) + { + case PI_I2C_CTRL_SET_MAX_BAUDRATE : + __pi_i2c_baudrate_set(slave_data->itf_data); + break; + + case PI_I2C_IOCTL_ABORT_RX : + __pi_i2c_timeout_abort(slave_data->itf_data); + break; + + case PI_I2C_IOCTL_ABORT_TX : + __pi_i2c_timeout_abort(slave_data->itf_data); + break; + + case PI_I2C_IOCTL_ATTACH_TIMEOUT_RX : +#if defined(USE_TIMEOUT) + udma_timeout_id = (uint32_t) arg; + __pi_i2c_udma_timeout_rx_set(slave_data->itf_data, udma_timeout_id); +#endif + break; + + case PI_I2C_IOCTL_DETACH_TIMEOUT_RX : +#if defined(USE_TIMEOUT) + __pi_i2c_udma_timeout_rx_set(slave_data->itf_data, udma_timeout_id); +#endif + break; + + case PI_I2C_IOCTL_ATTACH_TIMEOUT_TX : +#if defined(USE_TIMEOUT) + udma_timeout_id = (uint32_t) arg; + __pi_i2c_udma_timeout_tx_set(slave_data->itf_data, udma_timeout_id); +#endif + break; + + case PI_I2C_IOCTL_DETACH_TIMEOUT_TX : +#if defined(USE_TIMEOUT) + __pi_i2c_udma_timeout_tx_set(slave_data->itf_data, udma_timeout_id); +#endif + break; + + case PI_I2C_IOCTL_EN_TIMESTAMP : + __pi_i2c_timestamp_enable(slave_data->itf_data, (struct pi_i2c_conf *) arg); + break; + + default : + break; + } + restore_irq(irq); +} + + +void pi_i2c_conf_init(pi_i2c_conf_t *conf) +{ + pi_assert(NULL != conf); + + conf->max_baudrate = 400000; + conf->itf = 0; + conf->cs = 0; + conf->wait_cycles = 0; + conf->is_10_bits = 0; +} + +void pi_i2c_conf_set_wait_cycles(struct pi_i2c_conf *conf, uint16_t wait_cycles) +{ + pi_assert(NULL != conf); + + conf->wait_cycles = wait_cycles; +} + +/** accessors **/ +void pi_i2c_conf_set_slave_addr(struct pi_i2c_conf *conf, uint16_t slave_addr, + int8_t is_10_bits) +{ + pi_assert(NULL != conf); + + conf->cs = slave_addr; + conf->is_10_bits = is_10_bits; +} + +int pi_i2c_write(struct pi_device *device, uint8_t *tx_data, int length, pi_i2c_xfer_flags_e flags) +{ + pi_task_t task_block; + pi_task_block(&task_block); + pi_i2c_write_async(device, (void*)tx_data, (uint32_t)length, flags, &task_block); + pi_task_wait_on(&task_block); + return pi_i2c_get_request_status(&task_block); +} + +int pi_i2c_read (struct pi_device *device, uint8_t *rx_buff, int length, + pi_i2c_xfer_flags_e flags) +{ + pi_task_t task_block; + pi_task_block(&task_block); + pi_i2c_read_async(device, (void*)rx_buff, (uint32_t)length, flags, &task_block); + pi_task_wait_on(&task_block); + return pi_i2c_get_request_status(&task_block); +} + +void pi_i2c_read_async(struct pi_device *device, uint8_t *buffer, int size, + pi_i2c_xfer_flags_e flags, pi_task_t *task) +{ + pi_assert(NULL != device); + pi_assert((NULL != rx_buff) && (IS_BUFF_IN_L2(rx_buff))); + pi_assert(0 != length); + pi_assert(NULL != task); + + i2c_slave_data_t *slave_data = (i2c_slave_data_t *)device->data; + + i2c_itf_data_t *itf_data = slave_data->itf_data; + uint16_t slave_addr = slave_data->slave_addr; + + task->data[0] = I2C_READ; + task->data[1] = (uintptr_t)buffer; + task->data[2] = (uintptr_t)size; + task->data[3] = (uintptr_t)device; + task->data[4] = (uintptr_t)flags; + + int irq = disable_irq(); + if (!itf_data->end_task) + { // exec transfer + __pi_i2c_read_exec(slave_data, buffer, size, flags, task); + itf_data->end_task = task; + } + else + { + __pi_i2c_drv_fifo_enqueue(itf_data, task); + } + restore_irq(irq); +} + +void pi_i2c_write_async(struct pi_device *device, uint8_t *buffer, int size, + pi_i2c_xfer_flags_e flags, pi_task_t *task) +{ + pi_assert(NULL != device); + pi_assert((NULL != tx_data) && (IS_BUFF_IN_L2(tx_data))); + pi_assert(0 != length); + pi_assert(NULL != task); + + i2c_slave_data_t *slave_data = (i2c_slave_data_t *)device->data; + + int irq = disable_irq(); + i2c_itf_data_t *itf_data = slave_data->itf_data; + + task->data[0] = I2C_WRITE; + task->data[1] = (uintptr_t)buffer; + task->data[2] = (uintptr_t)size; + task->data[3] = (uintptr_t)device; + task->data[4] = (uintptr_t)flags; + + if(!itf_data->end_task) + { // exec transfer + __pi_i2c_write_exec(slave_data, buffer, size, flags, task); + itf_data->end_task = task; + } + else + { + __pi_i2c_drv_fifo_enqueue(itf_data, task); + } + restore_irq(irq); +} + +int pi_i2c_read_timeout(struct pi_device *device, uint8_t *rx_buff, int length, + pi_i2c_xfer_flags_e flags, uint32_t timeout_us) +{ + pi_assert(NULL != device); + pi_assert((NULL != rx_buff) && (IS_BUFF_IN_L2(rx_buff))); + pi_assert(0 != length); + + pi_task_t task_block = {0}; + pi_task_block(&task_block); +#if defined(USE_TIMEOUT) + pi_task_timeout_set(&task_block, timeout_us); +#endif + pi_i2c_read_async(device, rx_buff, length, flags, &task_block); + pi_task_wait_on(&task_block); + int status = pi_task_status_get(&task_block); + //return ((status == -1) ? -1 : 0); + return status; +} + + +int pi_i2c_write_timeout(struct pi_device *device, uint8_t *tx_data, int length, + pi_i2c_xfer_flags_e flags, uint32_t timeout_us) +{ + pi_assert(NULL != device); + pi_assert((NULL != tx_data) && (IS_BUFF_IN_L2(tx_data))); + pi_assert(0 != length); + + pi_task_t task_block = {0}; + pi_task_block(&task_block); +#if defined(USE_TIMEOUT) + pi_task_timeout_set(&task_block, timeout_us); +#endif + pi_i2c_write_async(device, tx_data, length, flags, &task_block); + pi_task_wait_on(&task_block); + int status = pi_task_status_get(&task_block); + //return ((status == -1) ? -1 : 0); + return status; +} + +int pi_i2c_get_request_status(pi_task_t* task) +{ + pi_assert(NULL != task); + + return (int) (task->data[0]); +} + + +void pi_i2c_write_read(struct pi_device *device, void *tx_buffer, + void *rx_buffer, uint32_t tx_size, uint32_t rx_size) +{ + pi_task_t task_block; + pi_task_block(&task_block); + pi_i2c_write_read_async(device, tx_buffer, rx_buffer, tx_size, rx_size, &task_block); + pi_task_wait_on(&task_block); +} + + +void pi_i2c_write_read_async(struct pi_device *device, void *tx_buffer, + void *rx_buffer, uint32_t tx_size, uint32_t rx_size, + pi_task_t *task) +{ + pi_assert(NULL != device); + pi_assert((NULL != tx_buffer) && (IS_BUFF_IN_L2(tx_buffer))); + pi_assert((NULL != rx_buffer) && (IS_BUFF_IN_L2(rx_buffer))); + pi_assert(0 != tx_size); + pi_assert(0 != rx_size); + pi_assert(NULL != task); + + i2c_slave_data_t *slave_data = (i2c_slave_data_t *)device->data; + + int irq = disable_irq(); + i2c_itf_data_t *itf_data = slave_data->itf_data; + + task->data[0] = I2C_WRITE_READ; + task->data[1] = (uintptr_t)tx_buffer; + task->data[2] = (uintptr_t)rx_buffer; + task->data[3] = (uintptr_t)device; + task->data[4] = (uintptr_t)tx_size; + task->data[5] = (uintptr_t)rx_size; + + if(!itf_data->end_task) + { + __pi_i2c_write_read_exec(slave_data, tx_buffer, rx_buffer, tx_size, rx_size, task); + itf_data->end_task = task; + } + else + { + __pi_i2c_drv_fifo_enqueue(itf_data, task); + } + restore_irq(irq); +} + +void pi_i2c_write_dual_async(struct pi_device *device, void *tx_buffer0, + void *tx_buffer1, uint32_t tx_size0, uint32_t tx_size1, + pi_task_t *task) +{ + pi_assert(NULL != device); + pi_assert((NULL != tx_buffer0) && (IS_BUFF_IN_L2(tx_buffer0))); + pi_assert((NULL != tx_buffer1) && (IS_BUFF_IN_L2(tx_buffer1))); + pi_assert(0 != tx_size0); + pi_assert(0 != tx_size1); + pi_assert(NULL != task); + + i2c_slave_data_t *slave_data = (i2c_slave_data_t *)device->data; + + int irq = disable_irq(); + i2c_itf_data_t *itf_data = slave_data->itf_data; + + task->data[0] = I2C_WRITE_DUAL; + task->data[1] = (uintptr_t)tx_buffer0; + task->data[2] = (uintptr_t)tx_buffer1; + task->data[3] = (uintptr_t)device; + task->data[4] = (uintptr_t)tx_size0; + task->data[5] = (uintptr_t)tx_size1; + + if(!itf_data->end_task) + { + __pi_i2c_write_dual_exec(slave_data, tx_buffer0, tx_buffer1, tx_size0, tx_size1, task); + itf_data->end_task = task; + } + else + { + __pi_i2c_drv_fifo_enqueue(itf_data, task); + } + restore_irq(irq); +} + diff --git a/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/i2c_internal.h b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/i2c_internal.h new file mode 100644 index 000000000..ed833146c --- /dev/null +++ b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/i2c_internal.h @@ -0,0 +1,202 @@ +/* + * Copyright (C) 2022 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "stdlib.h" +#include "pmsis.h" +#include "pmsis/drivers/i2c.h" +#include "udma_i2c.h" +#include + +#if !defined(__FREERTOS__) +#if !defined(__TRACE_ALL__) && !defined(__TRACE_I2C__) +#define I2C_TRACE(x...) +#define I2C_TRACE_ERR(...) ((void) 0) +#else +#define I2C_TRACE(level, x...) POS_TRACE(level, "[I2C] " x) +#define I2C_TRACE_ERR(...) PI_LOG_ERR(__func__, __VA_ARGS__) +#endif +#endif + +/*! @brief UART request structure. */ +#define i2c_req_t udma_req_t + +#define I2C_READ 0 +#define I2C_WRITE 1 +#define I2C_WRITE_READ 2 +#define I2C_WRITE_DUAL 3 + +#define I2C_CMD_BUF_SIZE 14 + +#define I2C_BUF_START_POS 6 +#define I2C_BUF_WRITE_RPT_POS 8 + +#define I2C_W_R_BUF_WR_POS 2 +#define I2C_W_R_BUF_RESTART_POS 4 +#define RD_BUF_RPT(bits) ((bits) ? 10 : 8) +#define W_R_BUF_RD(bits) ((bits) ? 8 : 6) + +#define RD_BUF_STOP_ID(bits) (RD_BUF_RPT((bits)) + 3) +#define WR_BUF_STOP_ID 10 + +#define I2C_SLAVE_GET_ITF(slave) (slave->itf_data) + + +typedef uint32_t i2c_cmd_t; + +typedef struct i2c_slave_data +{ + struct i2c_itf_data *itf_data; + uint32_t cfg; + // a slave might answer to up to two addresses, 7 or 10 bits + int16_t wait_cycles; + uint16_t slave_addr; + uint16_t slave_addrh; + int8_t is_10_bits; +} i2c_slave_data_t; + +typedef struct i2c_itf_data { + uint32_t base; + pi_task_t *fifo_head; + pi_task_t *fifo_tail; + pi_task_t *end_task; + i2c_cmd_t cmd_buf[I2C_CMD_BUF_SIZE]; + uint32_t rx_chan_addr; + uint32_t tx_chan_addr; + uint32_t cmd_chan_addr; + // per itf + uint8_t open_nb; + uint8_t id; + // --- channel event --- + int8_t rx_chan_id; + int8_t tx_chan_id; + int8_t cmd_chan_id; + // --- timeout channel --- + uint8_t rx_timeout_id; + uint8_t tx_timeout_id; +} i2c_itf_data_t; + + +// Has to be synchronized with irq_disabled since irq handler might pop at the same time +static inline void __pi_i2c_drv_fifo_enqueue(struct i2c_itf_data *data, + pi_task_t *pi_task) +{ + if (data->fifo_head) + { + data->fifo_tail->next = pi_task; + } + else + { + data->fifo_head = pi_task; + } + + pi_task->next = NULL; + data->fifo_tail = pi_task; +} + +static inline pi_task_t *__pi_i2c_drv_fifo_pop(struct i2c_itf_data *data) +{ + pi_task_t *ret_task = data->fifo_head; + if (ret_task) + { + data->fifo_head = ret_task->next; + } + return ret_task; +} + +/* + * @brief compute input divisor for i2c ip + * Input divisor is not the same as hw/real divisor, so compute an input + * divisor as near as possible to satisfy constraint + */ +static inline uint32_t __i2c_prepare_timing(uint32_t max_baudrate, + uint32_t periph_clock) +{ + pi_i2c_mode_e mode; + // TODO: HW, discuss plain divisor, this makes no sense + uint32_t input_div = 0, hw_div=0, targetL, targetH, divH, divL, cmd; + + // second, determine mode: + if(max_baudrate < 200000) + { + mode = PI_I2C_STD_MODE; + } + else if(max_baudrate >= 200000 && max_baudrate < 750000) + { + mode = PI_I2C_FAST_MODE; + } + else if(max_baudrate >= 750000) + { + mode = PI_I2C_FAST_MODE_PLUS; + } + + // choose target L and H (depend on std = 100KHz, fast mode=400KHz) + // we try to get the best frequency, without going faster than what standard + // allows + switch(mode) + { + case PI_I2C_STD_MODE: // 100KHz - up to 200 + targetL = 4700; // 4.7 µs + targetH = 4000; // 4.0 µs + break; + case PI_I2C_FAST_MODE: // 400KHz + targetL = 1300; // 1.3 µs + targetH = 600; // 0.6 µs + break; + case PI_I2C_FAST_MODE_PLUS: // 1MHz + targetL = 500; // 0.5 µs + targetH = 260; // 0.260 µs + break; + default: + return PI_FAIL; + } + + /* timing method extracted from IP designer python script */ + input_div = 0; + divL = 15; + divH = 15; + + uint32_t dio = 3; + uint32_t f_pclk_mega = periph_clock / 1000000; + input_div = targetL * f_pclk_mega / (1000 * (15 + 1 + dio)); + divL = targetL * f_pclk_mega / (1000 * (input_div + 1)) - dio; + divH = targetH * f_pclk_mega / (1000 * (input_div + 1)) - dio; + + if (divL > 15) + { + input_div = input_div + 1; + divL = 1000 * targetL * f_pclk_mega / (input_div + 1) - dio; + divH = 1000 * targetH * f_pclk_mega / (input_div + 1) - dio; + } + + cmd = I2C_CMD_TIMING(((input_div&0xFF) << 8) | ((divH&0xF) << 4) + | (divL&0xF)); + return cmd; +} + +void __pi_i2c_timeout_abort(void* arg); + +static inline void __pi_i2c_timeout_config_set(pi_task_t *task, uint8_t timeout_id, + uint8_t udma_chan_id, uint32_t timeout_us, + pi_callback_func_t abort_func, + void *arg) +{ +#if defined(__FREERTOS__) + pi_udma_timeout_config_set(task, timeout_id, udma_chan_id, timeout_us); + pi_task_timeout_callback_set(task, abort_func, arg); +#endif +} diff --git a/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/i2c_slave.c b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/i2c_slave.c new file mode 100644 index 000000000..25e378d9b --- /dev/null +++ b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/i2c_slave.c @@ -0,0 +1,387 @@ +/* + * Copyright (C) 2022 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "pmsis.h" +#include "i2c_internal.h" +#include "pmsis/drivers/i2c_slave.h" +#include "i2c_slave_internal.h" + + +/** Internal defines **/ +#define I2C_SLAVE_ADDR0 0 +#define I2C_SLAVE_ADDR1 1 +#define I2C_ADDR_PUSH_DISABLE 0 +#define I2C_ADDR_PUSH_ENABLE 1 + +struct i2c_slave_itf_data *__global_i2c_slave_itf_data[UDMA_NB_I2C]; + + +static void __pi_i2c_slave_handle_error(struct i2c_slave_itf_data *itf_data) +{ + I2C_TRACE("I2C_slave(%d)->slave_error_handler\n", device_id); + // I2C_STATUS_FOLL_ERROR_ARLO_EVENT & I2C_STATUS_FOLL_ERROR_FRAMING_EVENT + // => clear status, unlock and purge + int device_id = itf_data->id; + uint32_t arlo = __pi_i2c_get_event_status(itf_data->base, I2C_STATUS_FOLL_ERROR_ARLO_EVENT); + uint32_t framing = __pi_i2c_get_event_status(itf_data->base, I2C_STATUS_FOLL_ERROR_FRAMING_EVENT); + if (arlo || framing) + { + I2C_TRACE("I2C_slave(%d)->slave_error_handler - arbitration loss or framing error\n", device_id); + udma_i2c_status_reg_idx_set(itf_data->base, + (arlo << I2C_STATUS_FOLL_ERROR_ARLO_EVENT) | + (framing << I2C_STATUS_FOLL_ERROR_FRAMING_EVENT) | + (1 << I2C_FLAG_FOLL_UNLOCK_EVENT_O) | + (1 << I2C_FLAG_FOLL_PURGE_EVENT_O)); + } +} + +__attribute__((section(".text"))) __noinline +void __pi_i2c_slave_event_handler(uint32_t event, void *arg) +{ + struct i2c_slave_itf_data *itf_data = arg; + int device_id = itf_data->id; + I2C_TRACE("I2C_slave(%d)->slave_event_handler\n", device_id); + + // even for tx, there is a pseudo rx for addr matcher byte + uint8_t *l2_buffer = itf_data->rx_buffer; + + uint8_t addr_byte = *l2_buffer; + uint8_t match = addr_byte >> 6; + l2_buffer++; + + struct pi_i2c_slave_args slave_args = { + .slave_addr = itf_data->addr[match], + .handle = arg, + .ret = PI_FAIL, // if callee does not fill it, consider it a failure + .itf_id = device_id, + }; + + // First check whether we're here because of read or send + // then let the user supplied callback execute + // User will have the responsibility of unlocking the udma once callback + // is done + if(__pi_i2c_get_event_status(itf_data->base, I2C_STATUS_FOLL_ERROR_ARLO_EVENT) + ||__pi_i2c_get_event_status(itf_data->base, I2C_STATUS_FOLL_ERROR_FRAMING_EVENT)) + { + // TODO should we execute callback if there is an error ? + __pi_i2c_slave_handle_error(itf_data); + } + if(__pi_i2c_get_event_status(itf_data->base, I2C_STATUS_FOLL_EOF_RCV_EVENT)) + { + uint32_t bytes_left = pi_udma_core_lin_bytes_left_get(itf_data->rx_chan_addr); + uint32_t size = itf_data->rx_buffer_size - bytes_left; + slave_args.nb_bytes = size - 1; // remove push byte + slave_args.l2_buffer = l2_buffer; // take buffer minus first byte + if(itf_data->rx_callback) + { + itf_data->rx_callback(&slave_args); + } + } + if(__pi_i2c_get_event_status(itf_data->base, + I2C_STATUS_FOLL_EOF_SND_EVENT)) + { + uint32_t bytes_left = pi_udma_core_lin_bytes_left_get(itf_data->tx_chan_addr); + uint32_t size = itf_data->tx_buffer_size - bytes_left; + slave_args.nb_bytes = size; + slave_args.l2_buffer = itf_data->tx_buffer; + if(itf_data->tx_callback) + { + itf_data->tx_callback(&slave_args); + } + } + return; +} + +/* + * @brief Internal open of i2c interface + * Caller must provide synchronization + */ +int pi_i2c_slave_open(struct pi_device *device) +{ + pi_assert((NULL != device) && (NULL != device->config)); + struct pi_i2c_slave_conf *conf = device->config; + + struct i2c_slave_itf_data *itf_data = NULL; + // check interface first + I2C_TRACE("I2C_slave(%d)->open_slave\n", conf->itf); + int irq = disable_irq(); + if(!(itf_data = __global_i2c_slave_itf_data[conf->itf])) + { + uint32_t i2c_base = UDMA_I2C_ADDR(conf->itf); + + // prepare itf struct + itf_data = pi_fc_l1_malloc(sizeof(struct i2c_slave_itf_data)); + I2C_TRACE("I2C_slave(%d)->itf_data=%x\n", conf->itf, itf_data); + if(itf_data == NULL) + { + restore_irq(irq); + return -1; + } + __global_i2c_slave_itf_data[conf->itf] = itf_data; + memset(itf_data,0,sizeof(struct i2c_slave_itf_data)); + itf_data->id = conf->itf; + itf_data->base = i2c_base; + + // disable udma reset before setting regs + udma_ctrl_cfg_rstn_set_set(UDMA_CTRL_ADDR, 1 << UDMA_I2C_ID(conf->itf)); + udma_ctrl_cfg_cg_set_set(UDMA_CTRL_ADDR, 1 << UDMA_I2C_ID(conf->itf)); + + itf_data->rx_chan_id = pi_udma_core_lin_alloc(); + I2C_TRACE("I2C(%d)->rx chan id = %x\n", conf->itf, itf_data->rx_chan_id); + itf_data->tx_chan_id = pi_udma_core_lin_alloc(); + itf_data->cmd_chan_id = pi_udma_core_lin_alloc(); + udma_i2c_udma_cmd_dest_reg_idx_set(i2c_base, itf_data->cmd_chan_id); + + itf_data->rx_chan_addr = pi_udma_core_lin_addr_get(itf_data->rx_chan_id); + itf_data->tx_chan_addr = pi_udma_core_lin_addr_get(itf_data->tx_chan_id); + itf_data->cmd_chan_addr = pi_udma_core_lin_addr_get(itf_data->cmd_chan_id); + + // Master init procedure + int cmd_buf_id = 0; + uint32_t cmd_buf[8]; + + udma_i2c_status_reg_idx_set(i2c_base, 1<max_baudrate, + pi_freq_get(PI_FREQ_DOMAIN_PERIPH)); + if(conf->addr0 != 0) + { + itf_data->addr[0] = conf->addr0; + cmd_buf[cmd_buf_id++] = CMD_FOLL_ADDR(I2C_SLAVE_ADDR0, + I2C_ADDR_PUSH_ENABLE, conf->addr0_10_bit, conf->addr0, + conf->mask0, conf->sof0, conf->eof0); + } + if(conf->addr1 != 0) + { + itf_data->addr[1] = conf->addr1; + cmd_buf[cmd_buf_id++] = CMD_FOLL_ADDR(I2C_SLAVE_ADDR1, + I2C_ADDR_PUSH_ENABLE, conf->addr1_10_bit, conf->addr1, + conf->mask1, conf->sof1, conf->eof1); + } + cmd_buf[cmd_buf_id++] = I2C_CMD_EVENT(1); + pi_udma_core_lin_enqueue(itf_data->cmd_chan_addr, (uint32_t)cmd_buf, + cmd_buf_id*sizeof(uint32_t), 0); + + while(!__pi_i2c_get_event_status(i2c_base,I2C_FLAG_CMD_EVENT_I)) + { + pi_time_wait_us(1); + } + udma_i2c_status_reg_idx_set(i2c_base, 1<rx_chan_id); + udma_i2c_foll_udma_tx_dest_reg_idx_set(i2c_base, itf_data->tx_chan_id); + pi_fc_event_handler_set(SOC_EVENT_UDMA_I2C_SLAVE_EVT(conf->itf), + __pi_i2c_slave_event_handler, itf_data); + pi_soc_eu_fc_mask_set(SOC_EVENT_UDMA_I2C_SLAVE_EVT(conf->itf)); + + itf_data->rx_callback = conf->rx_callback; + itf_data->tx_callback = conf->tx_callback; + + } + device->data = itf_data; + itf_data->open_nb++; + restore_irq(irq); + return 0; +} + +void pi_i2c_slave_close(struct pi_device *device) +{ + pi_assert(NULL != device); + + struct i2c_slave_itf_data *itf_data = (struct i2c_slave_itf_data *)device->data; + + int irq = disable_irq(); + itf_data->open_nb--; + if(itf_data->open_nb == 0) + { + // flush channels + pi_udma_core_lin_free(itf_data->rx_chan_id); + pi_udma_core_lin_free(itf_data->tx_chan_id); + pi_udma_core_lin_free(itf_data->cmd_chan_id); + + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->rx_chan_id)); + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->tx_chan_id)); + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->cmd_chan_id)); + + pi_udma_core_lin_reset(itf_data->rx_chan_addr); + pi_udma_core_lin_reset(itf_data->tx_chan_addr); + pi_udma_core_lin_reset(itf_data->cmd_chan_addr); + + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_I2C_SLAVE_EVT(itf_data->id)); + + // disable udma reset before setting regs + udma_ctrl_cfg_cg_clr_set(ARCHI_UDMA_ADDR, 1 << UDMA_I2C_ID(itf_data->id)); + udma_ctrl_cfg_rstn_clr_set(ARCHI_UDMA_ADDR, 1 << UDMA_I2C_ID(itf_data->id)); + __global_i2c_slave_itf_data[itf_data->id] = NULL; + pi_fc_l1_free(itf_data,sizeof(itf_data)); + } + restore_irq(irq); +} + + +void pi_i2c_slave_conf_init(pi_i2c_slave_conf_t *conf) +{ + pi_assert(NULL != conf); + + conf->max_baudrate = 400000; + conf->itf = 0; + conf->addr0 = 0; + conf->addr1 = 0; + conf->sof0 = 0; + conf->eof0 = 0; + conf->sof1 = 0; + conf->eof1 = 0; + conf->addr0_10_bit = 0; + conf->addr1_10_bit = 0; + conf->mask0 = 0x1F; + conf->mask1 = 0x1F; + conf->addr0 = 0; + conf->addr1 = 0; + conf->rx_callback = NULL; + conf->tx_callback = NULL; +} + + +/** accessors **/ + +void pi_i2c_slave_conf_set_addr0(struct pi_i2c_slave_conf *conf, uint16_t addr, + uint8_t mask, uint8_t is_10_bit, uint8_t eof, uint8_t sof) +{ + pi_assert(NULL != conf); + + conf->addr0 = addr; + conf->mask0 = mask; + conf->addr0_10_bit = is_10_bit; + conf->eof0 = eof; + conf->sof0 = sof; +} + +void pi_i2c_slave_conf_set_addr1(struct pi_i2c_slave_conf *conf, uint16_t addr, + uint8_t mask, uint8_t is_10_bit, uint8_t eof, uint8_t sof) +{ + pi_assert(NULL != conf); + + conf->addr1 = addr; + conf->mask1 = mask; + conf->addr1_10_bit = is_10_bit; + conf->eof1 = eof; + conf->sof1 = sof; +} + +void pi_i2c_slave_set_rx_channel(void *handle, + void *l2_addr, uint32_t size) +{ + struct i2c_slave_itf_data *itf_data = (struct i2c_slave_itf_data *)handle; + + pi_assert(NULL != itf_data); + pi_assert((NULL != l2_addr) && (IS_BUFF_IN_L2(l2_addr))); + pi_assert(0 != size); + + int irq = disable_irq(); + pi_udma_core_lin_enqueue(itf_data->rx_chan_addr, (uint32_t)l2_addr, size, 0); + itf_data->rx_buffer = l2_addr; + itf_data->rx_buffer_size = size; + restore_irq(irq); +} + +void pi_i2c_slave_set_tx_channel(void *handle, + void *l2_addr, uint32_t size) +{ + struct i2c_slave_itf_data *itf_data = (struct i2c_slave_itf_data *)handle; + + pi_assert(NULL != itf_data); + pi_assert((NULL != l2_addr) && (IS_BUFF_IN_L2(l2_addr))); + pi_assert(0 != size); + + int irq = disable_irq(); + pi_udma_core_lin_enqueue(itf_data->tx_chan_addr, (uint32_t)l2_addr, size, 0); + itf_data->tx_buffer = l2_addr; + itf_data->tx_buffer_size = size; + restore_irq(irq); +} + +void pi_i2c_slave_unlock(void *handle, int is_rd) +{ + struct i2c_slave_itf_data *itf_data = (struct i2c_slave_itf_data *)handle; + + pi_assert(NULL != handle); + + int device_id = itf_data->id; + if(is_rd) + { + udma_i2c_status_reg_idx_set(itf_data->base,(1<base,(1<rx_chan_addr, (uint32_t)l2_addr, size, 0); + itf_data->rx_buffer = l2_addr; + itf_data->rx_buffer_size = size; + restore_irq(irq); +} + +void pi_i2c_slave_set_tx(void *handle, void *l2_addr, + uint32_t size) +{ + struct i2c_slave_itf_data *itf_data = (struct i2c_slave_itf_data *)handle; + + pi_assert(NULL != itf_data); + pi_assert((NULL != l2_addr) && (IS_BUFF_IN_L2(l2_addr))); + pi_assert(0 != size); + + int irq = disable_irq(); + pi_udma_core_lin_enqueue(itf_data->tx_chan_addr, (uint32_t)l2_addr, size, 0); + itf_data->tx_buffer = l2_addr; + itf_data->tx_buffer_size = size; + restore_irq(irq); +} + +void pi_i2c_slave_stop_rx(void *handle) +{ + struct i2c_slave_itf_data *itf_data = (struct i2c_slave_itf_data *)handle; + + pi_assert(NULL != itf_data); + + int irq = disable_irq(); + pi_udma_core_lin_stop(itf_data->rx_chan_addr); + restore_irq(irq); +} + +void pi_i2c_slave_stop_tx(void *handle) +{ + struct i2c_slave_itf_data *itf_data = (struct i2c_slave_itf_data *)handle; + + pi_assert(NULL != itf_data); + + int irq = disable_irq(); + pi_udma_core_lin_stop(itf_data->tx_chan_addr); + restore_irq(irq); +} diff --git a/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/i2c_slave_internal.h b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/i2c_slave_internal.h new file mode 100644 index 000000000..70ec112cf --- /dev/null +++ b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/i2c_slave_internal.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2022 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "stdlib.h" +#include "pmsis.h" +#include "pmsis/drivers/i2c_slave.h" + +#ifndef I2C_DRIVER_DATA_IMPLEM_SPECIFC + #define I2C_DRIVER_DATA_IMPLEM_SPECIFC +#endif + +/*! @brief UART request structure. */ +#define i2c_req_t udma_req_t + +typedef uint32_t i2c_cmd_t; + +struct i2c_slave_itf_data { + uint32_t base; + + // per itf + uint32_t rx_chan_addr; + uint32_t tx_chan_addr; + uint32_t cmd_chan_addr; + + uint8_t open_nb; + uint8_t id; + // --- channel event --- + uint8_t rx_chan_id; + uint8_t tx_chan_id; + uint8_t cmd_chan_id; + // -- addresses to which we answer + uint8_t addr0_10_bit; + uint8_t addr1_10_bit; + uint8_t addr0_mask; + uint8_t addr1_mask; + uint16_t addr[4]; + // in handler callbacks + pi_i2c_callback_t rx_callback; + pi_i2c_callback_t tx_callback; + // buffers + void *rx_buffer; + uint32_t rx_buffer_size; + void *tx_buffer; + uint32_t tx_buffer_size; + I2C_DRIVER_DATA_IMPLEM_SPECIFC +}; diff --git a/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/udma_i2c.h b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/udma_i2c.h new file mode 100644 index 000000000..02244b182 --- /dev/null +++ b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2c/udma_i2c.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2022 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +typedef enum i2c_mode { + PI_I2C_STD_MODE, + PI_I2C_FAST_MODE, + PI_I2C_FAST_MODE_PLUS, + PI_I2C_NB_MODES +} pi_i2c_mode_e; + +// TEMPORARY, until can be generated +#define I2C_STATUS_FOLL_EOF_RCV_EVENT 2 +#define I2C_STATUS_FOLL_EOF_SND_EVENT 3 +#define I2C_STATUS_FOLL_ERROR_ARLO_EVENT 4 +#define I2C_STATUS_FOLL_ERROR_FRAMING_EVENT 5 +#define I2C_FLAG_CMD_EVENT_I 19 +#define I2C_FLAG_FOLL_UNLOCK_EVENT_O 14 +#define I2C_FLAG_FOLL_PURGE_EVENT_O 15 +#define I2C_STATUS_ERROR_NACK_EVENT 16 +#define I2C_STATUS_ERROR_ARLO_EVENT 17 +#define I2C_STATUS_ERROR_FRAMING_EVENT 18 +#define I2C_FLAG_UNLOCK_EVENT_O 22 +#define I2C_FLAG_PURGE_EVENT_O 23 +#define I2C_FLAG_SOFT_RESET_EVENT 24 +#define I2C_FLAG_PRESC_DIV10_EVENT_O 25 + +#define I2C_CMD_TIMING(T) ((0x10 << 24) | (T)) +#define I2C_CMD_EVENT(T) ((0x41 << 24)) + + +#define CMD_FOLL_ADDR(match_id,push_en,addr_10_bit,slave_addr,mask,sof,eof) \ + ((0x20 << 24) | (match_id << 22) | (push_en << 21) | (eof << 20) \ + | (sof << 19) | (eof << 18) | (sof << 17) | (addr_10_bit << 16) \ + | ((!(addr_10_bit)) << 15) | (mask << 10) \ + | ((addr_10_bit) ? (slave_addr) : ((slave_addr)>>1) << 0)) + +/* enable automatic sending of stop when receiving a nack error */ +#define __I2C_NACK_STOP ((1 << 23)) + + +#define I2C_CMD_LEAD_START(T) ((0x30 << 24) | __I2C_NACK_STOP) +#define I2C_CMD_MISC_WAIT(T) ((0x3<<24)) +#define I2C_CMD_NOP(T) ((0x0<<24)) +// add -1, well, hw guys saving on bits... +#define I2C_CMD_RPT(T) ((0x02 << 24) | (((T)&0xFFFF))) +#define I2C_CMD_LEAD_SEND_IMM(T) ((0x32 << 24) | __I2C_NACK_STOP | ((T)&0xFF)) +#define I2C_CMD_LEAD_SEND_IMM_ADDR(IS_10BITS, T) ((0x37 << 24) | __I2C_NACK_STOP | (IS_10BITS << 15) | ((T)&0xFFFF)) +#define I2C_CMD_MISC_RECEIVE(T) ((0x33 << 24) | __I2C_NACK_STOP) +#define I2C_CMD_MISC_RECEIVE_LAST(T) ((0x34 << 24) | __I2C_NACK_STOP) +#define I2C_CMD_MISC_SEND(T) ((0x31 << 24) | __I2C_NACK_STOP) +#define I2C_CMD_STOP(T) ((0x36 << 24) | __I2C_NACK_STOP) +#define I2C_CMD_UDMA_TX_CHAN_CFG(T) (( 0x50 << 24 ) | (T)) +#define I2C_CMD_UDMA_RX_CHAN_CFG(T) (( 0x51 << 24 ) | (T)) + +#define I2C_CHAN_ADDR_REG 0x0 +#define I2C_CHAN_SIZE_REG 0x2 +#define I2C_CHAN_CFG_REG 0x7 + + + +/** get_current value of event in i2c event register. Defined as a macro to work with O0 **/ +#define __pi_i2c_get_event_status(base, event_id) __BITEXTRACT(udma_i2c_status_reg_idx_get(base), 1, event_id) diff --git a/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2s/i2s.c b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2s/i2s.c new file mode 100644 index 000000000..44c869014 --- /dev/null +++ b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/i2s/i2s.c @@ -0,0 +1,1431 @@ +/* + * Copyright (C) 2018 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Authors: Germain Haugou, GreenWaves Technologies (germain.haugou@greenwaves-technologies.com) + */ + +#include +#include + +#define I2S_NB_SLOTS 16 + +typedef struct +{ + void **buffer; + uint8_t nb_elem; + uint8_t head; + uint8_t tail; + uint8_t current_nb_elem; +} __pi_ringbuffer_t; + +typedef struct __pi_i2s_s __pi_i2s_t; + +typedef struct +{ + __pi_i2s_t *i2s; + uint32_t channel_base; + pi_task_t *waiting_first; + pi_task_t *waiting_last; + size_t block_size; + void *pingpong_buffers[2]; + pi_mem_slab_t *mem_slab; + __pi_ringbuffer_t ring_buffer; + pi_task_t *tx_task0; + pi_task_t *tx_task1; + void *tx_buffer0; + void *tx_buffer1; + uint16_t frame; + uint8_t nb_ready_buffer; + uint8_t udma_channel; + uint8_t reenqueue; + uint8_t current_buffer; + uint8_t error_id; + uint8_t is_rx; + uint8_t error; + uint8_t loopback; + uint8_t ignore_first_error; // This flag is set to 1 after the slot is enabled, since we can get a false error at + // the very beginning of the transfer, in order to ignore it. This false error can happen + // in some rare cases depending on the activity because the DC fifo take more time + // than expected to propagate the first sample. +} __pi_i2s_slot_t; + + +typedef struct __pi_i2s_s +{ + struct pi_i2s_conf conf; + uint8_t open_count; + int i2s_freq; + __pi_i2s_slot_t *rx_slots[I2S_NB_SLOTS]; + __pi_i2s_slot_t *tx_slots[I2S_NB_SLOTS]; + uint32_t cfg; + uint32_t clk_cfg; + uint32_t slot_en; + uint32_t base; + uint32_t errors; + uint32_t frame_period_us; + // TODO this is used when stopping the slot to wait for 2 clock periods + // This consumes a lot of memory, this could be done with callbacks if the + // structure of callbacks is having what is needed for tasks. + pi_task_t task; + uint32_t pending_stop; + uint32_t waiting_stop; + pi_task_t *stop_pending_tasks; + pi_task_t *stop_waiting_tasks; + uint8_t itf; +} __pi_i2s_t; + + +PI_FC_L1 static __pi_i2s_t __pi_i2s[ARCHI_UDMA_NB_I2S]; + + +static inline void __pi_i2s_enqueue_buffer(__pi_i2s_slot_t *slot, void *buffer); +static inline void __pi_i2s_enqueue_buffer_for_frame(__pi_i2s_slot_t *slot, uint32_t buffer); + + +void pi_i2s_setup(uint32_t flags) +{ +} + + +void pi_i2s_conf_init(struct pi_i2s_conf *conf) +{ + conf->itf = 0; + conf->frame_clk_freq = 44100; + conf->format = PI_I2S_CH_FMT_DATA_ORDER_MSB | + PI_I2S_CH_FMT_DATA_ALIGN_LEFT | + PI_I2S_CH_FMT_DATA_SIGN_NO_EXTEND; + conf->options = PI_I2S_OPT_PINGPONG | PI_I2S_OPT_IS_RX | PI_I2S_OPT_ENABLED; + conf->word_size = 16; + conf->ws_delay = 1; + conf->mem_word_size = -1; + conf->channels = 1; + conf->pingpong_buffers[0] = NULL; + conf->pingpong_buffers[1] = NULL; + conf->mem_slab = NULL; + conf->pdm_polarity=0; + conf->pdm_diff=0; + conf->channel_id = 0; + conf->asrc_channel = -1; + conf->ws_type = 0; +} + + +static void *__pi_i2s_ring_buffer_pop(__pi_i2s_slot_t *slot) +{ + if (slot->ring_buffer.current_nb_elem == 0) + return NULL; + + void *buffer = slot->ring_buffer.buffer[slot->ring_buffer.tail++]; + if (slot->ring_buffer.tail == slot->ring_buffer.nb_elem) + slot->ring_buffer.tail = 0; + + slot->ring_buffer.current_nb_elem--; + + return buffer; +} + + +static void __pi_i2s_handle_rx_frame(uint32_t event, void *arg) +{ + __pi_i2s_slot_t *frame_slot = (__pi_i2s_slot_t *)arg; + __pi_i2s_t *i2s = frame_slot->i2s; + uint32_t frame = frame_slot->frame; + int block_size = frame_slot->block_size; + + // Get error code. Be careful that reading it is clearing the error code for all + // slots. Save it for all slots to not lose the information. + i2s->errors |= udma_i2s_err_status_get(i2s->base); + uint32_t errors = i2s->errors & frame_slot->frame; + + if (!errors) + { + if (frame_slot->is_rx) + { + void *buffer; + if (frame_slot->mem_slab) + { + pi_mem_slab_alloc(frame_slot->mem_slab, (void **)&buffer, 0); + } + else + { + // Reenqueue pingpong buffer in UDMA + int buffer_index = frame_slot->current_buffer; + buffer = frame_slot->pingpong_buffers[buffer_index]; + frame_slot->current_buffer = buffer_index ^ 1; + } + + if (buffer) + { + __pi_i2s_enqueue_buffer_for_frame(frame_slot, (uint32_t)buffer); + } + + //And check if we give the finished buffer to a waiting task or we just flag it + pi_task_t *waiting = frame_slot->waiting_first; + + if (waiting) + { + waiting->data[1] = (int)__pi_i2s_ring_buffer_pop(frame_slot); + frame_slot->waiting_first = waiting->next; + pi_task_push_irq_safe(waiting); + } + else + { + frame_slot->nb_ready_buffer++; + } + } + else + { + if (frame_slot->mem_slab) + { + pi_mem_slab_free(frame_slot->mem_slab, &frame_slot->tx_buffer0); + } + + frame_slot->tx_buffer0 = frame_slot->tx_buffer1; + frame_slot->tx_buffer1 = __pi_i2s_ring_buffer_pop(frame_slot); + + if (frame_slot->tx_buffer1) + { + uint32_t frame = frame_slot->frame; + int block_size = frame_slot->block_size; + uint32_t buffer = (uint32_t)frame_slot->tx_buffer1; + + while (frame) + { + int slot_id = __FF1(frame); + + frame = __BITCLR_R(frame, 1, slot_id); + + __pi_i2s_slot_t *slot = frame_slot->i2s->tx_slots[slot_id]; + uint32_t base = slot->channel_base; + + udma_core_lin_addrgen_cfg_sa_buf0_set(base, buffer); + + udma_core_lin_addrgen_cfg_ctrl_set(base, UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_EN(1)); + + buffer += block_size; + } + } + + pi_task_t *waiting = frame_slot->waiting_first; + + if (waiting) + { + frame_slot->waiting_first = waiting->next; + pi_task_push_irq_safe(waiting); + } + } + } + else + { + // In case of errors, cancel all pending tasks and return an error + pi_task_t *waiting; + + i2s->errors = __BITCLR_R(i2s->errors, 16, errors); + + while ((waiting = frame_slot->waiting_first) != NULL) + { + waiting->data[0] = -1; + frame_slot->waiting_first = waiting->next; + pi_task_push_irq_safe(waiting); + } + } +} + +static void __pi_i2s_handle_tx_frame(uint32_t event, void *arg) +{ + __pi_i2s_slot_t *frame_slot = (__pi_i2s_slot_t *)arg; + __pi_i2s_t *i2s = frame_slot->i2s; + uint32_t frame = frame_slot->frame; + int block_size = frame_slot->block_size; + + // Get error code. Be careful that reading it is clearing the error code for all + // slots. Save it for all slots to not lose the information. + i2s->errors |= udma_i2s_err_status_get(i2s->base); + uint32_t errors = i2s->errors & frame_slot->frame; + i2s->errors = __BITCLR_R(i2s->errors, 16, errors); + + // Check if we get the error because this is the beginning of the transfer. + if (frame_slot->ignore_first_error) + { + // Always clear it, since we ignore it only for the first transfer, we need to detected the following ones. + frame_slot->ignore_first_error = 0; + errors = 0; + } + + pi_task_t *waiting = frame_slot->tx_task0; + + if (frame_slot->mem_slab) + { + void *buffer = (void *)waiting->data[3]; + pi_mem_slab_free(frame_slot->mem_slab, &buffer); + } + + frame_slot->tx_task0 = frame_slot->tx_task1; + frame_slot->tx_task1 = frame_slot->waiting_first; + if (frame_slot->waiting_first) + { + frame_slot->waiting_first = frame_slot->waiting_first->next; + } + + if (frame_slot->tx_task1) + { + uint32_t frame = frame_slot->frame; + int block_size = frame_slot->block_size; + uint32_t buffer = frame_slot->tx_task1->data[3]; + + while (frame) + { + int slot_id = __FF1(frame); + + frame = __BITCLR_R(frame, 1, slot_id); + + __pi_i2s_slot_t *slot = frame_slot->i2s->tx_slots[slot_id]; + uint32_t base = slot->channel_base; + + udma_core_lin_addrgen_cfg_sa_buf0_set(base, buffer); + + udma_core_lin_addrgen_cfg_ctrl_set(base, UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_EN(1)); + + buffer += block_size; + } + } + + waiting->data[0] = errors; + pi_task_push_irq_safe(waiting); +} + + +static void __pi_i2s_handle_rx_channel(uint32_t event, void *arg) +{ + __pi_i2s_slot_t *slot = (__pi_i2s_slot_t *)arg; + __pi_i2s_t *i2s = slot->i2s; + int task_done = 1; + void *buffer; + + // Get error code. Be careful that reading it is clearing the error code for all + // slots. Save it for all slots to not lose the information. + i2s->errors |= udma_i2s_err_status_get(i2s->base); + slot->error = __BITEXTRACTU_R(i2s->errors, 1, slot->error_id); + + // Check if we get the error because this is the beginning of the transfer. + if (slot->ignore_first_error) + { + // Always clear it, since we ignore it only for the first transfer, we need to detected the following ones. + slot->ignore_first_error = 0; + slot->error = 0; + i2s->errors = __BITCLR_R(i2s->errors, 1, slot->error_id); + } + + // Reenqueue pingpong buffer in UDMA + if (!slot->error) + { + if (slot->is_rx) + { + if (slot->mem_slab) + { + pi_mem_slab_alloc(slot->mem_slab, (void **)&buffer, 0); + } + else + { + int buffer_index = slot->current_buffer; + buffer = slot->pingpong_buffers[buffer_index]; + slot->current_buffer = buffer_index ^ 1; + } + + if (buffer) + { + __pi_i2s_enqueue_buffer(slot, buffer); + } + + //And check if we give the finished buffer to a waiting task or we just flag it + pi_task_t *waiting = slot->waiting_first; + + if (waiting) + { + waiting->data[1] = (int)__pi_i2s_ring_buffer_pop(slot); + slot->waiting_first = waiting->next; + pi_task_push_irq_safe(waiting); + } + else + { + slot->nb_ready_buffer++; + } + } + else + { + if (slot->mem_slab) + { + pi_mem_slab_free(slot->mem_slab, &slot->tx_buffer0); + } + + slot->tx_buffer0 = slot->tx_buffer1; + slot->tx_buffer1 = __pi_i2s_ring_buffer_pop(slot); + + if (slot->tx_buffer1) + { + uint32_t base = slot->channel_base; + udma_core_lin_addrgen_cfg_sa_buf0_set(base, (int)slot->tx_buffer1); + udma_core_lin_addrgen_cfg_ctrl_set(base, UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_EN(1)); + } + + pi_task_t *waiting = slot->waiting_first; + + if (waiting) + { + slot->waiting_first = waiting->next; + pi_task_push_irq_safe(waiting); + } + } + + } + else + { + // In case of errors, cancel all pending tasks and return an error + pi_task_t *waiting; + + i2s->errors = __BITCLR_R(i2s->errors, 1, slot->error_id); + + while ((waiting = slot->waiting_first) != NULL) + { + waiting->data[0] = -1; + slot->waiting_first = waiting->next; + pi_task_push_irq_safe(waiting); + } + } +} + +static void __pi_i2s_handle_tx_channel(uint32_t event, void *arg) +{ + __pi_i2s_slot_t *slot = (__pi_i2s_slot_t *)arg; + __pi_i2s_t *i2s = slot->i2s; + + // Get error code. Be careful that reading it is clearing the error code for all + // slots. Save it for all slots to not lose the information. + i2s->errors |= udma_i2s_err_status_get(i2s->base); + int error = __BITEXTRACTU_R(i2s->errors, 1, slot->error_id); + i2s->errors = __BITCLR_R(i2s->errors, 1, slot->error_id); + + // Check if we get the error because this is the beginning of the transfer. + if (slot->ignore_first_error) + { + // Always clear it, since we ignore it only for the first transfer, we need to detected the following ones. + slot->ignore_first_error = 0; + error = 0; + } + + pi_task_t *waiting = slot->tx_task0; + + // Reenqueue pingpong buffer in UDMA + if (slot->mem_slab) + { + void *buffer = (void *)waiting->data[3]; + pi_mem_slab_free(slot->mem_slab, &buffer); + } + + slot->tx_task0 = slot->tx_task1; + slot->tx_task1 = slot->waiting_first; + if (slot->waiting_first) + { + slot->waiting_first = slot->waiting_first->next; + } + + if (slot->tx_task1) + { + uint32_t base = slot->channel_base; + uint32_t buffer = slot->tx_task1->data[3]; + udma_core_lin_addrgen_cfg_sa_buf0_set(base, buffer); + udma_core_lin_addrgen_cfg_ctrl_set(base, UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_EN(1)); + } + + waiting->data[0] = error; + pi_task_push_irq_safe(waiting); +} + + +static void __pi_i2s_slot_free(__pi_i2s_slot_t *slot) +{ + if (slot->pingpong_buffers[0] && !slot->loopback) + { + udma_core_lin_addrgen_cfg_ctrl_set(slot->channel_base, + UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_STOP(1) + ); + + pi_udma_core_lin_free(slot->udma_channel); + soc_eu_fc_mask_set_set(SOC_EU_ADDR, ARCHI_SOC_EVENT_LINEAR_CHANNEL_FIRST + slot->udma_channel); + } + + pi_fc_l1_free(slot, sizeof(__pi_i2s_slot_t)); +} + + +static inline void __pi_i2s_enqueue_buffer(__pi_i2s_slot_t *slot, void *buffer) +{ + uint32_t base = slot->channel_base; + + udma_core_lin_addrgen_cfg_sa_buf0_set(base, (int)buffer); + + udma_core_lin_addrgen_cfg_ctrl_set(base, + UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_EN(1) + ); + + slot->ring_buffer.buffer[slot->ring_buffer.head++] = buffer; + if (slot->ring_buffer.head == slot->ring_buffer.nb_elem) + slot->ring_buffer.head = 0; + + slot->ring_buffer.current_nb_elem++; +} + + +static void __pi_i2s_slot_enqueue_buffers(__pi_i2s_slot_t *slot) +{ + void *buffer0; + void *buffer1; + + if (slot->mem_slab) + { + pi_mem_slab_alloc(slot->mem_slab, (void **)&buffer0, 0); + pi_mem_slab_alloc(slot->mem_slab, (void **)&buffer1, 0); + } + else + { + buffer0 = slot->pingpong_buffers[0]; + buffer1 = slot->pingpong_buffers[1]; + } + + if (buffer0) + { + __pi_i2s_enqueue_buffer(slot, buffer0); + } + if (buffer1) + { + __pi_i2s_enqueue_buffer(slot, buffer1); + } +} + + +static inline void __pi_i2s_enqueue_buffer_for_frame(__pi_i2s_slot_t *first_slot, uint32_t buffer) +{ + uint32_t frame = first_slot->frame; + int block_size = first_slot->block_size; + + first_slot->ring_buffer.buffer[first_slot->ring_buffer.head++] = (void *)buffer; + if (first_slot->ring_buffer.head == first_slot->ring_buffer.nb_elem) + first_slot->ring_buffer.head = 0; + + first_slot->ring_buffer.current_nb_elem++; + + while (frame) + { + int slot_id = __FF1(frame); + frame = __BITCLR_R(frame, 1, slot_id); + + __pi_i2s_slot_t *slot = first_slot->is_rx ? first_slot->i2s->rx_slots[slot_id] : first_slot->i2s->tx_slots[slot_id]; + uint32_t base = slot->channel_base; + + udma_core_lin_addrgen_cfg_sa_buf0_set(base, buffer); + + udma_core_lin_addrgen_cfg_ctrl_set(base, UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_EN(1)); + + buffer += block_size; + } +} + + +static void __pi_i2s_slot_enqueue_buffers_for_frame(__pi_i2s_slot_t *slot) +{ + void *buffer0; + void *buffer1; + + if (slot->mem_slab) + { + pi_mem_slab_alloc(slot->mem_slab, (void **)&buffer0, 0); + pi_mem_slab_alloc(slot->mem_slab, (void **)&buffer1, 0); + } + else + { + buffer0 = slot->pingpong_buffers[0]; + buffer1 = slot->pingpong_buffers[1]; + } + + __pi_i2s_enqueue_buffer_for_frame(slot, (uint32_t)buffer0); + __pi_i2s_enqueue_buffer_for_frame(slot, (uint32_t)buffer1); +} + + +void pi_i2s_channel_conf_init(struct pi_i2s_channel_conf *conf) +{ + conf->format = PI_I2S_CH_FMT_DATA_ORDER_MSB | + PI_I2S_CH_FMT_DATA_ALIGN_LEFT | + PI_I2S_CH_FMT_DATA_SIGN_NO_EXTEND; + conf->options = PI_I2S_OPT_PINGPONG | PI_I2S_OPT_IS_RX | PI_I2S_OPT_ENABLED; + conf->word_size = 16; + conf->mem_word_size = -1; + conf->pingpong_buffers[0] = NULL; + conf->pingpong_buffers[1] = NULL; + conf->mem_slab = NULL; + conf->asrc_channel = -1; + conf->slot_enable = 1; +} + + +int __pi_i2s_channel_conf_set(struct pi_device *device, uint32_t frame, int slot_id, struct pi_i2s_channel_conf *conf) +{ + unsigned int is_rx = __BITEXTRACTU(conf->options, 1, PI_I2S_OPT_RX_TX_SHIFT); + __pi_i2s_slot_t *slot; + uint32_t new_cfg = 0; + __pi_i2s_t *i2s = (__pi_i2s_t *)device->data; + + int irq = pi_irq_disable(); + + unsigned int is_enabled = __BITEXTRACTU(conf->options, 1, PI_I2S_OPT_CH_ENABLE_SHIFT); + + if (!is_enabled) + { + //I2S_INF("Disabling I2S channel (itf: %d, channel: %d, is_rx: %d)\n", i2s->itf, slot_id, is_rx); + slot = is_rx ? i2s->rx_slots[slot_id] : i2s->tx_slots[slot_id]; + __pi_i2s_slot_free(slot); + slot = NULL; + new_cfg = 0xff; + if (is_rx) + { + i2s->rx_slots[slot_id] = NULL; + } + else + { + i2s->tx_slots[slot_id] = NULL; + } + + } + else + { + // Allocate slot and channel + unsigned int loopback = __BITEXTRACTU(conf->options, 1, PI_I2S_OPT_LOOPBACK_ENA_SHIFT); + int ring_buffer_nb_elem = conf->mem_slab ? conf->mem_slab->num_blocks : 2; + int ring_buffer_size = sizeof(void *) * ring_buffer_nb_elem; + + slot = pi_fc_l1_malloc(sizeof(__pi_i2s_slot_t) + ring_buffer_size); + if (slot == NULL) + { + I2S_WNG("Failed to allocate memory\n"); + goto error; + } + + if (is_rx) + { + i2s->rx_slots[slot_id] = slot; + } + else + { + i2s->tx_slots[slot_id] = slot; + } + + // Copy configuration + slot->pingpong_buffers[0] = conf->pingpong_buffers[0]; + slot->pingpong_buffers[1] = conf->pingpong_buffers[1]; + slot->mem_slab = conf->mem_slab; + slot->error_id = is_rx ? slot_id : slot_id + 16; + slot->error = 0; + slot->i2s = i2s; + slot->is_rx = is_rx; + slot->loopback = loopback; + slot->frame = frame; + slot->tx_buffer0 = NULL; + slot->tx_buffer1 = NULL; + slot->tx_task0 = NULL; + slot->tx_task1 = NULL; + slot->ignore_first_error = 0; + + if (conf->asrc_channel == -1 && loopback == 0) + { + int channel = pi_udma_core_lin_alloc(); + if (channel == -1) + { + I2S_WNG("Failed to allocate channel\n"); + pi_fc_l1_free(slot, sizeof(__pi_i2s_slot_t)); + goto error; + } + + slot->udma_channel = channel; + + slot->ring_buffer.nb_elem = ring_buffer_nb_elem; + slot->ring_buffer.current_nb_elem = 0; + slot->ring_buffer.head = 0; + slot->ring_buffer.tail = 0; + slot->ring_buffer.buffer = (void *)((uint32_t)slot + sizeof(__pi_i2s_slot_t)); + + slot->block_size = conf->block_size; + slot->current_buffer = 0; + + slot->nb_ready_buffer = 0; + slot->waiting_first = NULL; + + slot->channel_base = pi_udma_core_lin_addr_get(slot->udma_channel); + int event = ARCHI_SOC_EVENT_LINEAR_CHANNEL_FIRST + slot->udma_channel; + + if (frame == 0) + { + pi_fc_event_handler_set(event, is_rx ? __pi_i2s_handle_rx_channel : __pi_i2s_handle_tx_channel, (void *)slot); + soc_eu_fc_mask_clr_set(SOC_EU_ADDR, event); + udma_core_lin_addrgen_cfg_size_set(slot->channel_base, slot->block_size); + if (is_rx) + { + __pi_i2s_slot_enqueue_buffers(slot); + } + } + else + { + int last_slot_id = __FL1(frame); + int first_slot_id = __FF1(frame); + __pi_i2s_slot_t *first_slot = is_rx ? i2s->rx_slots[first_slot_id] : i2s->tx_slots[first_slot_id]; + udma_core_lin_addrgen_cfg_size_set(slot->channel_base, slot->block_size); + + if (slot_id == last_slot_id) + { + pi_fc_event_handler_set(event, is_rx ? __pi_i2s_handle_rx_frame : __pi_i2s_handle_tx_frame, (void *)first_slot); + soc_eu_fc_mask_clr_set(SOC_EU_ADDR, event); + if (is_rx) + { + __pi_i2s_slot_enqueue_buffers_for_frame(first_slot); + } + } + } + } + else if (conf->asrc_channel != -1) + { + slot->udma_channel = 0xe0 + conf->asrc_channel; + } + else + { + slot->udma_channel = 0; + } + + // Store the word size + // There are 2 slots per register + int reg_offset = (slot_id >> 1) << 2; + // Slot 0 RX at 0, slot 0 TX at 1, slot 1 RX at 16 and slot 1 TX at 24 + int bit = (slot_id & 1) << 4; + if (!is_rx) + { + bit += 8; + } + + uint32_t reg_value = udma_i2s_word_size_0_1_get(i2s->base + reg_offset); + reg_value = GAP_BINSERT_R(reg_value, conf->word_size-1, UDMA_I2S_WORD_SIZE_0_1_WORD_SIZE_RX_0_WIDTH, bit); + udma_i2s_word_size_0_1_set(i2s->base + reg_offset, reg_value); + + + // Now compute slot configuration + //I2S_INF("Configuring I2S channel (itf: %d, channel: %d, is_rx: %d, enabled: 1, word_size: %d)\n", + // i2s->itf, slot_id, is_rx, conf->word_size); + + unsigned int is_pdm = __BITEXTRACTU(conf->format, 1, PI_I2S_FMT_DATA_FORMAT_SHIFT); + + if (!is_pdm) + { + int mem_word_size = conf->mem_word_size; + if (mem_word_size == -1) mem_word_size = i2s->conf.word_size; + + unsigned int udma_size = (mem_word_size / 8) - 1; + unsigned int left_aligned = !__BITEXTRACTU(conf->format, 1, PI_I2S_CH_FMT_DATA_ALIGN_SHIFT); + unsigned int msb_first = !__BITEXTRACTU(conf->format, 1, PI_I2S_CH_FMT_DATA_ORDER_SHIFT); + unsigned int sign = __BITEXTRACTU(conf->format, 1, PI_I2S_CH_FMT_DATA_SIGN_SHIFT); + unsigned int loopback = __BITEXTRACTU(conf->options, 1, PI_I2S_OPT_LOOPBACK_ENA_SHIFT); + + new_cfg = + UDMA_I2S_SLOT_CFG_0_ID_RX(slot->udma_channel) | + UDMA_I2S_SLOT_CFG_0_RX_MSB_FIRST(msb_first) | + UDMA_I2S_SLOT_CFG_0_RX_LEFT_ALIGN(left_aligned) | + UDMA_I2S_SLOT_CFG_0_RX_DSIZE(udma_size) | + UDMA_I2S_SLOT_CFG_0_RX_SIGN(sign) | + UDMA_I2S_SLOT_CFG_0_RX_EN(1) | + loopback << 15; + } + + } + + // Finally update the config in the HW register + uint32_t reg_offset = i2s->base + (slot_id << 2); + uint32_t cfg = udma_i2s_slot_cfg_0_get(reg_offset); + cfg = GAP_BINSERT_R(cfg, new_cfg, 16, (!is_rx)*16); + + udma_i2s_slot_cfg_0_set(reg_offset, cfg); + + if (slot && is_enabled && conf->slot_enable) + { + pi_i2s_slots_enable(device, 1<config; + int itf_id = conf->itf; + __pi_i2s_t *i2s = &__pi_i2s[itf_id]; + int is_tdm = (conf->options & PI_I2S_OPT_TDM) != 0; + + int is_pdm = (conf->format & PI_I2S_FMT_DATA_FORMAT_PDM)>>PI_I2S_FMT_DATA_FORMAT_SHIFT; + + //I2S_INF("Opening I2S driver (itf: %d)\n", conf->itf); + + device->data = (void *)i2s; + + memcpy(&i2s->conf, conf, sizeof(struct pi_i2s_conf)); + + i2s->open_count++; + if (i2s->open_count == 1) + { + int periph_id = UDMA_I2S_ID(itf_id); + udma_ctrl_cfg_rstn_set_set(UDMA_CTRL_ADDR, 1 << periph_id); + udma_ctrl_cfg_cg_set_set(UDMA_CTRL_ADDR, 1 << periph_id); + + i2s->itf = itf_id; + i2s->errors = 0; + i2s->pending_stop = 0; + i2s->waiting_stop = 0; + i2s->stop_pending_tasks = NULL; + i2s->stop_waiting_tasks = NULL; + + for (int i=0; irx_slots[i] = NULL; + i2s->tx_slots[i] = NULL; + } + } + + i2s->slot_en = 0; + i2s->base = UDMA_I2S_ADDR(itf_id); + + unsigned int ext_clk = __BITEXTRACTU(conf->options, 1, PI_I2S_OPT_CLK_SRC_SHIFT); + unsigned int ext_ws = __BITEXTRACTU(conf->options, 1, PI_I2S_OPT_WS_SRC_SHIFT); + unsigned int ext_clk_int = __BITEXTRACTU(conf->options, 1, PI_I2S_OPT_CLK_INT_ROUTED_SHIFT); + unsigned int ext_ws_int = __BITEXTRACTU(conf->options, 1, PI_I2S_OPT_WS_INT_ROUTED_SHIFT); + unsigned int clk_polarity = __BITEXTRACTU(conf->options, 1, PI_I2S_OPT_CLK_POLARITY_SHIFT); + unsigned int ws_polarity = __BITEXTRACTU(conf->options, 1, PI_I2S_OPT_WS_POLARITY_SHIFT); + unsigned int clk_gen_en = (!ext_clk) && (!ext_clk_int); + //I2S_INF("ext_clk (%x), ext_ws (%x), ext_clk_int(%x), ext_ws_int(%x), clk_gen_en (%x)\n", ext_clk, ext_ws, ext_clk_int, ext_ws_int, clk_gen_en); + + i2s->clk_cfg = UDMA_I2S_CLKCFG_SETUP_CLK_EN(clk_gen_en) | + UDMA_I2S_CLKCFG_SETUP_CLK_SRC(ext_clk) | + UDMA_I2S_CLKCFG_SETUP_CLK_EXT_SRC(ext_clk_int) | + UDMA_I2S_CLKCFG_SETUP_CLK_EDGE(clk_polarity) | + UDMA_I2S_CLKCFG_SETUP_WS_SRC(ext_ws) | + UDMA_I2S_CLKCFG_SETUP_WS_EXT_SRC (ext_ws_int) | + UDMA_I2S_CLKCFG_SETUP_WS_EDGE(ws_polarity) | + UDMA_I2S_CLKCFG_SETUP_WS_TYPE(conf->ws_type); + + i2s->cfg = UDMA_I2S_GLB_SETUP_FRAME_LENGTH(conf->channels-1) | + UDMA_I2S_GLB_SETUP_SLOT_WIDTH(is_pdm? 0 : (conf->word_size-1)) | + UDMA_I2S_GLB_SETUP_WS_DELAY(is_pdm? 0 :(conf->ws_delay)) | + UDMA_I2S_GLB_SETUP_FULL_DUPLEX_EN(0) | + UDMA_I2S_GLB_SETUP_PDM_EN(is_pdm) | + UDMA_I2S_GLB_SETUP_PDM_POL(conf->pdm_polarity) | + UDMA_I2S_GLB_SETUP_PDM_DIFF(conf->pdm_diff); + + if (conf->options & PI_I2S_OPT_FULL_DUPLEX) + { + i2s->cfg |= UDMA_I2S_GLB_SETUP_FULL_DUPLEX_EN(1); + } + + /* TODO: correct the frequency calculation for PDM */ + if (is_pdm) + i2s->i2s_freq = conf->frame_clk_freq; + else + i2s->i2s_freq = conf->frame_clk_freq * conf->word_size * conf->channels; + + i2s->frame_period_us = (1000000 + conf->frame_clk_freq - 1) / conf->frame_clk_freq; + + if (!is_tdm) + { + struct pi_i2s_channel_conf channel_conf = { + .block_size = conf->block_size, .mem_slab=conf->mem_slab, + .pingpong_buffers[0] = conf->pingpong_buffers[0], .pingpong_buffers[1] = conf->pingpong_buffers[1], + .format = conf->format, .word_size=conf->word_size, .mem_word_size=conf->mem_word_size, + .options = conf->options | PI_I2S_OPT_ENABLED | PI_I2S_OPT_IS_RX, .slot_enable=1 + }; + + pi_i2s_channel_conf_set(device, 0, &channel_conf); + + struct pi_i2s_channel_conf channel_conf_tx = { + .block_size = conf->block_size, .mem_slab=conf->mem_slab, + .pingpong_buffers[0] = conf->pingpong_buffers[0], .pingpong_buffers[1] = conf->pingpong_buffers[1], + .format = conf->format, .word_size=conf->word_size, .mem_word_size=conf->mem_word_size, + .options = conf->options | PI_I2S_OPT_ENABLED | PI_I2S_OPT_IS_TX, .slot_enable=1 + }; + + pi_i2s_channel_conf_set(device, 0, &channel_conf_tx); + } + + //unsigned int base = hal_udma_channel_base(i2s->channel); + int periph_freq = 0; + if (i2s->conf.options & PI_I2S_OPT_REF_CLK_FAST) + { + periph_freq = CONFIG_FAST_OSC_FREQUENCY; + udma_i2s_clk_fast_set(UDMA_I2S_ADDR(i2s->conf.itf), UDMA_I2S_CLK_FAST_FAST_EN(1)); + } + else + { + periph_freq = pi_freq_get(PI_FREQ_DOMAIN_PERIPH); + } + int div = periph_freq / i2s->i2s_freq; + + udma_i2s_clkcfg_setup_set(UDMA_I2S_ADDR(i2s->conf.itf), + UDMA_I2S_CLKCFG_SETUP_CLK_DIV(div) | + i2s->clk_cfg + ); + + return 0; +} + + +static __attribute__((noinline)) void __pi_i2s_suspend(__pi_i2s_t *i2s) +{ + // Stop the clock now + udma_i2s_glb_setup_set(UDMA_I2S_ADDR(i2s->conf.itf), + UDMA_I2S_GLB_SETUP_GLOBAL_EN(0) + ); + + // Once the clock is down, the udma can still write samples until the end + // of the current frame. Wait for one frame period to be sure + // everything is flushed + pi_time_wait_us(i2s->frame_period_us); +} + + +void pi_i2s_close(struct pi_device *device) +{ + __pi_i2s_t *i2s = (__pi_i2s_t *)device->data; + + i2s->open_count--; + if (i2s->open_count == 0) + { + // Close all active slots + udma_i2s_slot_en_set(i2s->base, 0); + + for (int i=0; irx_slots[i]) + { + __pi_i2s_slot_free(i2s->rx_slots[i]); + } + if (i2s->tx_slots[i]) + { + __pi_i2s_slot_free(i2s->tx_slots[i]); + } + } + + // And deactivated device + int periph_id = UDMA_I2S_ID(i2s->itf); + udma_ctrl_cfg_rstn_clr_set(UDMA_CTRL_ADDR, 1 << periph_id); + udma_ctrl_cfg_cg_clr_set(UDMA_CTRL_ADDR, 1 << periph_id); + } +} + + +static void __pi_i2s_slots_enable(__pi_i2s_t *i2s, uint32_t channels, int enabled) +{ + if (enabled) + { + i2s->slot_en |= channels; + + while(channels) + { + int channel_id = __FF1(channels); + channels = __BITCLR_R(channels, 1, channel_id); + + // Due the HW issue with first transfer, we need to remember to ignore errors on the first transfer. + __pi_i2s_slot_t *slot = i2s->tx_slots[channel_id]; + if (slot) + { + slot->ignore_first_error = 1; + } + } + } + else + { + i2s->slot_en &= ~channels; + } + udma_i2s_slot_en_set(i2s->base, i2s->slot_en); +} + + + +int pi_i2s_slots_enable(struct pi_device *device, uint32_t channels, int enabled) +{ + __pi_i2s_t *i2s = (__pi_i2s_t *)device->data; + + int irq = pi_irq_disable(); + __pi_i2s_slots_enable(i2s, channels, enabled); + pi_irq_restore(irq); + + return 0; +} + + +static void __pi_i2s_slot_stop(__pi_i2s_slot_t *slot) +{ + if (slot == NULL) + { + return; + } + + // Be careful to read the size left before stoppping, otherwise it goes to zero + int size_left = udma_core_lin_addrgen_cfg_bytes_left_get(slot->channel_base); + + udma_core_lin_addrgen_cfg_ctrl_set(slot->channel_base, UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_STOP(1)); + + if (slot->waiting_first) + { + slot->waiting_first->data[2] = slot->block_size - size_left; + } + + if (slot->is_rx) + { + __pi_i2s_handle_rx_channel(0, slot); + } + else + { + __pi_i2s_handle_tx_channel(0, slot); + } +} + + +static void __pi_i2s_channel_stop(void *arg) +{ + __pi_i2s_t *i2s = (__pi_i2s_t *)arg; + + int irq = pi_irq_disable(); + + uint32_t pending_stop = i2s->pending_stop; + + // Stop all specified slots + while (pending_stop) + { + int slot = __FF1(pending_stop); + __pi_i2s_slot_stop(i2s->rx_slots[slot]); + __pi_i2s_slot_stop(i2s->tx_slots[slot]); + pending_stop = __BITCLR_R(pending_stop, 1, slot); + } + + // Unclock all tasks waiting for this stop + pi_task_t *task = i2s->stop_pending_tasks; + while(task) + { + pi_task_push_irq_safe(task); + task = task->next; + } + + // In case another set of tasks were waiting for stopping channels, + // Start now their delay to be sure they wait full 2 frame clocks. + if (i2s->waiting_stop) + { + i2s->pending_stop = i2s->waiting_stop; + i2s->waiting_stop = 0; + i2s->stop_pending_tasks = i2s->stop_waiting_tasks; + i2s->stop_waiting_tasks = NULL; + // UDMA needs one full frame period to disable a lot, so we must wait 2 periods + pi_task_push_delayed_us(pi_task_callback(&i2s->task, __pi_i2s_channel_stop, (void *)i2s), 2*i2s->frame_period_us); + } + else + { + i2s->pending_stop = 0; + } + + pi_irq_restore(irq); +} + + +int pi_i2s_slots_stop_async(struct pi_device *device, uint32_t channel_mask, pi_task_t *task) +{ + __pi_i2s_t *i2s = (__pi_i2s_t *)device->data; + + int irq = pi_irq_disable(); + + // First disable the slots + __pi_i2s_slots_enable(i2s, channel_mask, 0); + + // Don't know why, the udma should stop after 1 frame period, but it actually continues a bit, + // probably a HW issue, just wait one more period. + if (i2s->pending_stop) + { + // If a stop is already pending, just remember that we need to wait another 2 frame clocks. + // In case we are already waiting for a stop, this is also fine, because we wait 2 frame clocks + // at least starting from now. + i2s->waiting_stop |= channel_mask; + task->next = i2s->stop_waiting_tasks; + i2s->stop_waiting_tasks = task; + } + else + { + i2s->pending_stop = channel_mask; + task->next = i2s->stop_pending_tasks; + i2s->stop_pending_tasks = task; + // UDMA needs one full frame period to disable a lot, so we must wait 2 periods + pi_task_push_delayed_us(pi_task_callback(&i2s->task, __pi_i2s_channel_stop, (void *)i2s), 2*i2s->frame_period_us); + } + + pi_irq_restore(irq); + + return 0; +} + + +int pi_i2s_slots_stop(struct pi_device *device, uint32_t channel_mask) +{ + pi_task_t task; + if (pi_i2s_slots_stop_async(device, channel_mask, pi_task_block(&task))) + { + return -1; + } + pi_task_wait_on(&task); + + return 0; +} + + +static void __pi_i2s_resume(struct pi_device *device, __pi_i2s_t *i2s) +{ + //I2S_INF("Resuming (i2s: %d)\n", i2s->conf.itf); + + udma_i2s_glb_setup_set(i2s->base, + UDMA_I2S_GLB_SETUP_GLOBAL_EN(1) | + i2s->cfg + ); +} + + +static void __pi_i2s_sync(struct pi_device *device, __pi_i2s_t *i2s, unsigned int team) +{ + uint32_t value = udma_i2s_glb_setup_get(i2s->base); + value |= UDMA_I2S_GLB_SETUP_BLOCK_COMMIT(team); + udma_i2s_glb_setup_set(i2s->base, value); +} + + + +static void __pi_i2s_ch_conf_get(__pi_i2s_t *i2s, struct pi_i2s_conf *conf) +{ + //__pi_i2s_slot_t *slot = &i2s->slots[conf->channel_id]; + //struct pi_i2s_conf *ch_conf = conf->options & PI_I2S_OPT_IS_RX ? &slot->rx_conf : &slot->tx_conf; + //memcpy(conf, ch_conf, sizeof(struct pi_i2s_conf)); +} + + +int pi_i2s_channel_timestamp_set(struct pi_device *device, int slot_id, struct pi_i2s_channel_conf *conf) +{ + __pi_i2s_t *i2s = (__pi_i2s_t *)device->data; + + unsigned int is_rx = __BITEXTRACTU(conf->options, 1, PI_I2S_OPT_RX_TX_SHIFT); + __pi_i2s_slot_t *slot = is_rx ? i2s->rx_slots[slot_id] : i2s->tx_slots[slot_id]; + + uint32_t base = ARCHI_UDMA_ADDR; + uint8_t evt_id = conf->ts_evt_id; + uint8_t soc_evt = slot->udma_channel; + + uint32_t cfg_evt_val = (udma_ctrl_cfg_event_get(base) & ~(0xFF<data; + int err = 0; + + //I2S_INF("Ioctl (cmd: %ld, arg: %p)\n", cmd, arg); + + int irq = pi_irq_disable(); + + switch (cmd) + { + case PI_I2S_IOCTL_SYNC: + __pi_i2s_sync(device, i2s, (int)arg); + break; + + case PI_I2S_IOCTL_START: + __pi_i2s_resume(device, i2s); + break; + + case PI_I2S_IOCTL_STOP: + __pi_i2s_suspend(i2s); + break; + + default: + pi_irq_restore(irq); + return -1; + } + + pi_irq_restore(irq); + + return err; +} + +int pi_i2s_channel_read_async(struct pi_device *device, int channel, pi_task_t *task) +{ + __pi_i2s_t *i2s = (__pi_i2s_t *)device->data; + __pi_i2s_slot_t *slot = i2s->rx_slots[channel]; + + int irq = pi_irq_disable(); + + if (slot->error) + { + task->data[0] = -1; + pi_task_push_irq_safe(task); + pi_irq_restore(irq); + return -1; + } + + // Prepare now the task results, the IRQ handler can still overwrite + // them if they are different. + task->data[0] = 0; + + task->data[2] = slot->block_size; + + if (slot->nb_ready_buffer) + { + task->data[1] = (int)__pi_i2s_ring_buffer_pop(slot); + slot->nb_ready_buffer--; + pi_task_push_irq_safe(task); + } + else + { + if (slot->waiting_first) + slot->waiting_last->next = task; + else + slot->waiting_first = task; + + task->next = NULL; + slot->waiting_last = task; + } + + pi_irq_restore(irq); + + return 0; +} + + +int pi_i2s_channel_write_async(struct pi_device *dev, int channel, + void *mem_block, size_t size, pi_task_t *task) +{ + __pi_i2s_t *i2s = (__pi_i2s_t *)dev->data; + __pi_i2s_slot_t *slot = i2s->tx_slots[channel]; + + int irq = pi_irq_disable(); + + // Prepare now the task results, the IRQ handler can still overwrite + // them if they are different. + task->data[0] = 0; + + if (slot->pingpong_buffers[0]) + { + int buffer_index = slot->current_buffer; + mem_block = slot->pingpong_buffers[buffer_index]; + slot->current_buffer = buffer_index ^ 1; + } + + task->data[3] = (uint32_t)mem_block; + + if (slot->tx_task0 == NULL || slot->tx_task1 == NULL) + { + uint32_t base = slot->channel_base; + + udma_core_lin_addrgen_cfg_sa_buf0_set(base, (int)mem_block); + udma_core_lin_addrgen_cfg_ctrl_set(base, UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_EN(1)); + + if (slot->tx_task0 == NULL) + { + slot->tx_task0 = task; + } + else + { + slot->tx_task1 = task; + } + } + else + { + if (slot->waiting_first) + slot->waiting_last->next = task; + else + slot->waiting_first = task; + + task->next = NULL; + slot->waiting_last = task; + } + + pi_irq_restore(irq); + + return 0; +} + + +int pi_i2s_frame_write_async(struct pi_device *dev, uint32_t frame, + void *mem_block, size_t size, pi_task_t *task) +{ + int channel = __FF1(frame); + __pi_i2s_t *i2s = (__pi_i2s_t *)dev->data; + __pi_i2s_slot_t *slot = i2s->tx_slots[channel]; + + int irq = pi_irq_disable(); + + // Prepare now the task results, the IRQ handler can still overwrite + // them if they are different. + task->data[0] = 0; + + if (!slot->mem_slab) + { + int buffer_index = slot->current_buffer; + mem_block = slot->pingpong_buffers[buffer_index]; + slot->current_buffer = buffer_index ^ 1; + } + + task->data[3] = (uint32_t)mem_block; + + if (slot->tx_task0 == NULL || slot->tx_task1 == NULL) + { + uint32_t frame = slot->frame; + int block_size = slot->block_size; + uint32_t buffer = (uint32_t)mem_block; + + while (frame) + { + int slot_id = __FF1(frame); + + frame = __BITCLR_R(frame, 1, slot_id); + + __pi_i2s_slot_t *slot_iter = slot->i2s->tx_slots[slot_id]; + uint32_t base = slot_iter->channel_base; + + udma_core_lin_addrgen_cfg_sa_buf0_set(base, buffer); + + udma_core_lin_addrgen_cfg_ctrl_set(base, UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_EN(1)); + + buffer += block_size; + } + + if (slot->tx_task0 == NULL) + { + slot->tx_task0 = task; + } + else + { + slot->tx_task1 = task; + } + } + else + { + if (slot->waiting_first) + slot->waiting_last->next = task; + else + slot->waiting_first = task; + + task->next = NULL; + slot->waiting_last = task; + } + + pi_irq_restore(irq); + + return 0; +} + + +int pi_i2s_read_async(struct pi_device *device, pi_task_t *task) +{ + return pi_i2s_channel_read_async(device, 0, task); +} + + +int pi_i2s_read_status(pi_task_t *task, void **mem_block, size_t *size) +{ + if (mem_block) + *mem_block = (void *)task->data[1]; + if (size) + *size = task->data[2]; + + return task->data[0]; +} + + +int pi_i2s_write_status(pi_task_t *task) +{ + return task->data[0]; +} + + +int pi_i2s_read(struct pi_device *dev, void **mem_block, size_t *size) +{ + pi_task_t task; + pi_i2s_read_async(dev, pi_task_block(&task)); + pi_task_wait_on(&task); + + return pi_i2s_read_status(&task, mem_block, size); +} + + +int pi_i2s_channel_read(struct pi_device *dev, int channel, void **mem_block, size_t *size) +{ + pi_task_t task; + pi_i2s_channel_read_async(dev, channel, pi_task_block(&task)); + pi_task_wait_on(&task); + + return pi_i2s_read_status(&task, mem_block, size); +} + +int pi_i2s_channel_write(struct pi_device *dev, int channel, void *mem_block, + size_t size) +{ + pi_task_t task; + pi_i2s_channel_write_async(dev, channel, mem_block, size, pi_task_block(&task)); + pi_task_wait_on(&task); + + return pi_i2s_write_status(&task); +} + +int pi_i2s_channel_write_async(struct pi_device *dev, int channel, + void *mem_block, size_t size, pi_task_t *task); + + +int pi_i2s_write(struct pi_device *dev, void *mem_block, size_t size) +{ + return pi_i2s_channel_write(dev, 0, mem_block, size); +} + +int pi_i2s_write_async(struct pi_device *dev, + void *mem_block, size_t size, pi_task_t *task) +{ + return pi_i2s_channel_write_async(dev, 0, mem_block, size, task); +} + +#if !defined(__FREERTOS__) +static void __attribute__((constructor)) ____pi_i2s_init() +{ + for (int i=0; i +#include +#include "pmsis.h" + +#include "spim_v4.h" +#include "chips/gap9/drivers/udma/udma_core.h" +#include "pmsis/task.h" + +#if !defined(__FREERTOS__) +#define SOC_EVENT_UDMA_SPIM_EOT(id) (80 + id + 0) +#else +#define likely(x) (__builtin_expect(x, 1)) +#endif /* __FREERTOS__ */ + +#ifndef SPIM_TRACE +#if !defined(__TRACE_ALL__) && !defined(__TRACE_SPIM__) +#define SPIM_TRACE(x...) +#else +#define SPIM_TRACE(level, x...) POS_TRACE(level, "[SPIM] " x) +#endif +#endif + +#define PI_SPIM_UDMA_CMD_SIZE 4 + +typedef struct +{ + uint32_t *temp_buff; + uint32_t addr; + uint32_t size; + uint32_t end; +} pi_spim_pending_transfert_t; + + +typedef struct +{ + uint32_t udma_cmd[PI_SPIM_UDMA_CMD_SIZE]; + uint32_t temp_buff[2]; +} pi_spim_l2_t; + +typedef struct +{ + pi_task_t *pending_copy; + pi_task_t *waiting_first; + pi_task_t *waiting_last; + unsigned int pending_repeat_base; + unsigned int pending_repeat_callback; + unsigned int pending_repeat_asm_callback; + unsigned int pending_repeat_misaligned_size; + unsigned int pending_repeat_misaligned_addr; + unsigned int pending_repeat_misaligned_ram_addr; + unsigned int pending_repeat_misaligned_end; + unsigned int pending_repeat_misaligned_length; + unsigned int pending_repeat_misaligned_stride; + unsigned int pending_repeat_misaligned_2d_size; + unsigned int pending_chunk_size; + unsigned int pending_send_cmd; + unsigned int pending_eot; + void (*pending_callback)(uint32_t event, void *arg); + uint32_t udma_cmd[PI_SPIM_UDMA_CMD_SIZE]; + int open_count; + int id; + int is_slave; + pi_task_t task; + unsigned int pending_repeat_addr; + unsigned int pending_repeat_dup_addr; + unsigned int pending_repeat_send; + unsigned int pending_repeat_flags; + pi_spim_pending_transfert_t pending_transfers[2]; + int pending_transfer_index; + int pending_transfer_read_index; + struct pi_device *pending_repeat_device; + uint32_t periph_base; + uint32_t rx_cmd; + uint32_t tx_cmd; + int channel; + int pending_is_auto; + uint32_t cmd_channel_base; + uint32_t tx_channel_base; + uint32_t rx_channel_base; + int cmd_channel; + int tx_channel; + int rx_channel; +} pi_spim_t; + +#define PI_SPIM_T_PENDING_COPY 0 +#define PI_SPIM_T_WAITING_FIRST 4 +#define PI_SPIM_T_WAITING_LAST 8 +#define PI_SPIM_T_REPEAT_BASE 12 +//#define PI_SPIM_T_REPEAT_LEN 16 +#define PI_SPIM_T_REPEAT_CALLBACK 16 +#define PI_SPIM_T_REPEAT_ASM_CALLBACK 20 + +typedef struct +{ + pi_spim_t *spim; + uint32_t rx_cmd; + uint32_t tx_cmd; + uint8_t *receive_addr_ucode; + uint32_t receive_addr_ucode_size; + uint8_t *send_addr_ucode; + uint32_t send_addr_ucode_size; + uint32_t *udma_receive_cmd; + uint32_t *udma_send_cmd; + uint32_t udma_receive_cmd_size; + uint32_t udma_send_cmd_size; + int max_baudrate; + unsigned int cfg; + unsigned int periph_base; + char cs; + char wordsize; + char big_endian; + char channel; + char byte_align; + unsigned char div; + char polarity; + char phase; + uint32_t max_rcv_size; + uint32_t max_snd_size; +} pi_spim_cs_t; + +typedef struct { + unsigned int cmd[4]; +} pi_spim_cmd_t; + + +static PI_L2 pi_spim_t g_spim_data[ARCHI_UDMA_NB_SPIM]; + +void pi_spim_handle_waiting_copy(pi_task_t *task); + +void pi_spim_handle_eot(uint32_t event, void *arg) +{ + pi_spim_t *spim = (pi_spim_t *) arg; + + pi_task_t *task = spim->pending_copy; + spim->pending_copy = NULL; + + /* handle current task end */ + pi_task_push_irq_safe(task); + + task = spim->waiting_first; + if (task) + { + spim->waiting_first = task->next; + pi_spim_handle_waiting_copy(task); + } +} + +void pi_spim_handle_rx_copy(uint32_t event, void *arg) +{ + pi_soc_eu_fc_mask_clear(event); + pi_spim_handle_eot(event, arg); +} + +void pi_spim_handle_tx_copy(uint32_t event, void *arg) +{ + pi_soc_eu_fc_mask_clear(event); + pi_spim_handle_eot(event, arg); +} + + +static int pi_spim_get_div(uint32_t spi_freq) +{ + uint32_t periph_freq = pi_freq_get(PI_FREQ_DOMAIN_PERIPH); + + if (spi_freq >= periph_freq) + { + return 0; + } + else + { + // Round-up the divider to obtain an SPI frequency which is below the maximum + int div = (periph_freq + spi_freq - 1)/ spi_freq; + // The SPIM always divide by 2 once we activate the divider, thus increase by 1 + // in case it is even to not go above the max frequency. + if (div & 1) div += 1; + return div; + } +} + + + +static inline int pi_spim_get_byte_align(int wordsize, int big_endian) +{ + return wordsize == PI_SPI_WORDSIZE_32 && big_endian; +} + +static void pi_spim_apply_conf(pi_spim_cs_t *spim_cs) +{ + if (spim_cs->udma_receive_cmd) + { + spim_cs->udma_receive_cmd[0] = spim_cs->cfg; + spim_cs->udma_receive_cmd[1] = SPI_CMD_SOT(spim_cs->cs); + } + + if (spim_cs->udma_send_cmd) + { + spim_cs->udma_send_cmd[0] = spim_cs->cfg; + spim_cs->udma_send_cmd[1] = SPI_CMD_SOT(spim_cs->cs); + } + + spim_cs->rx_cmd = SPI_CMD_RX_DATA(1, SPI_CMD_4_WORD_PER_TRANSF, 8, 0, 0); + spim_cs->tx_cmd = SPI_CMD_TX_DATA(1, SPI_CMD_4_WORD_PER_TRANSF, 8, 0, 0); +} + +int pi_spi_open(struct pi_device *device) +{ + uint32_t irq = pi_irq_disable(); + + struct pi_spi_conf *conf = (struct pi_spi_conf *) device->config; + + int periph_id = ARCHI_UDMA_SPIM_ID(conf->itf); + + SPIM_TRACE(POS_LOG_INFO, "Opening SPIM device (device: %p, id: %d, cs: %d, max_baudrate: %d, wordsize: %d, big_endian: %d, polarity: %d, phase: %d)\n", + device, conf->itf, conf->cs, conf->max_baudrate, conf->wordsize, conf->big_endian, conf->polarity, conf->phase); + + pi_spim_t *spim = &g_spim_data[conf->itf]; + + pi_spim_cs_t *spim_cs = pmsis_l2_malloc(sizeof(pi_spim_cs_t)); + if (spim_cs == NULL) + { + SPIM_TRACE(POS_LOG_WARNING, "Failed to allocate spim structure\n"); + goto error; + } + + device->data = (void *) spim_cs; + + spim_cs->channel = periph_id; + spim_cs->periph_base = (uint32_t) UDMA_SPIM_ADDR(conf->itf); + spim_cs->spim = spim; + spim_cs->wordsize = conf->wordsize; + spim_cs->big_endian = conf->big_endian; + spim_cs->polarity = conf->polarity; + spim_cs->phase = conf->phase; + spim_cs->max_baudrate = conf->max_baudrate; + spim_cs->cs = conf->cs; + spim_cs->byte_align = pi_spim_get_byte_align(conf->wordsize, conf->big_endian); + spim_cs->max_rcv_size = conf->max_rcv_chunk_size; + spim_cs->max_snd_size = conf->max_snd_chunk_size; + spim_cs->udma_send_cmd = NULL; + spim_cs->udma_receive_cmd = NULL; + + int div = pi_spim_get_div(spim_cs->max_baudrate); + spim_cs->div = div; + + spim_cs->cfg = SPI_CMD_CFG(div, conf->polarity, conf->phase); + + spim->open_count++; + if (spim->open_count == 1) + { + spim->is_slave = conf->is_slave; + + spim->rx_channel = pi_udma_core_lin_alloc(); + spim->tx_channel = pi_udma_core_lin_alloc(); + spim->cmd_channel = pi_udma_core_lin_alloc(); + + if (spim->rx_channel < 0 || spim->tx_channel < 0 || spim->cmd_channel < 0) + { + pi_udma_core_lin_free(spim->rx_channel); + pi_udma_core_lin_free(spim->tx_channel); + pi_udma_core_lin_free(spim->cmd_channel); + + SPIM_TRACE(POS_LOG_WARNING, "Failed to allocate channels\n"); + goto error; + } + + spim->rx_channel_base = pi_udma_core_lin_addr_get(spim->rx_channel); + spim->tx_channel_base = pi_udma_core_lin_addr_get(spim->tx_channel); + spim->cmd_channel_base = pi_udma_core_lin_addr_get(spim->cmd_channel); + + + udma_ctrl_cfg_rstn_set_set(ARCHI_UDMA_ADDR, (1 << periph_id)); + udma_ctrl_cfg_cg_set_set(ARCHI_UDMA_ADDR, (1 << periph_id)); + + uint32_t event = SOC_EVENT_UDMA_SPIM_EOT(conf->itf); + + pi_fc_event_handler_set(event, pi_spim_handle_eot, (void *) spim); + pi_soc_eu_fc_mask_set(event); + + udma_spim_rx_dest_set(spim_cs->periph_base, spim->rx_channel); + udma_spim_tx_dest_set(spim_cs->periph_base, spim->tx_channel); + udma_spim_cmd_dest_set(spim_cs->periph_base, spim->cmd_channel); + + udma_spim_config_set(spim_cs->periph_base, UDMA_SPIM_CONFIG_SPI_SLAVE_MODE(conf->is_slave)); + } + + pi_irq_restore(irq); + + return 0; + +error: + pi_irq_restore(irq); + return -1; +} + +static void __pi_spi_timestamp_enable(pi_spim_cs_t *spim_cs, struct pi_spi_conf *conf) +{ + pi_spim_t *spim = spim_cs->spim; + uint8_t is_rx = conf->ts_ch; + + uint32_t base = ARCHI_UDMA_ADDR; + uint8_t evt_id = conf->ts_evt_id; + uint8_t soc_evt = is_rx ? spim->rx_channel : spim->tx_channel; + + uint32_t cfg_evt_val = (udma_ctrl_cfg_event_get(base) & ~(0xFF<data; + uint32_t arg = (uint32_t) _arg; + + int polarity = (cmd >> __PI_SPI_CTRL_CPOL_BIT) & 3; + int phase = (cmd >> __PI_SPI_CTRL_CPHA_BIT) & 3; + int set_freq = (cmd >> __PI_SPI_CTRL_SET_MAX_BAUDRATE_BIT) & 1; + int wordsize = (cmd >> __PI_SPI_CTRL_WORDSIZE_BIT) & 3; + int big_endian = (cmd >> __PI_SPI_CTRL_ENDIANNESS_BIT) & 3; + int ts_spi = (cmd >> __PI_SPI_CTRL_SET_TIMESTAMP) & 1; + + if (ts_spi) + { + __pi_spi_timestamp_enable(spim_cs, (struct pi_spi_conf *) _arg); + } + else + { + if (set_freq) + { + spim_cs->max_baudrate = arg; + spim_cs->div = pi_spim_get_div(arg); + } + + if (polarity) + { + spim_cs->polarity = polarity >> 1; + } + if (phase) + { + spim_cs->phase = phase >> 1; + } + if (wordsize) + { + spim_cs->wordsize = wordsize >> 1; + } + if (big_endian) + { + spim_cs->big_endian = big_endian >> 1; + } + + spim_cs->cfg = SPI_CMD_CFG(spim_cs->div, spim_cs->polarity, spim_cs->phase); + spim_cs->byte_align = pi_spim_get_byte_align(spim_cs->wordsize, spim_cs->big_endian); + } + + pi_irq_restore(irq); +} + +void pi_spi_close(struct pi_device *device) +{ + int irq = pi_irq_disable(); + pi_spim_cs_t *spim_cs = (pi_spim_cs_t *) device->data; + pi_spim_t *spim = spim_cs->spim; + + SPIM_TRACE(POS_LOG_INFO, "Closing SPIM device (device: %p)\n", device); + + spim->open_count--; + + if (spim->open_count == 0) + { + // Deactivate SPIM channels + udma_spim_rx_dest_set(spim_cs->periph_base, 0xFF); + udma_spim_tx_dest_set(spim_cs->periph_base, 0xFF); + udma_spim_cmd_dest_set(spim_cs->periph_base, 0xFF); + + // And free them + pi_udma_core_lin_free(spim->rx_channel); + pi_udma_core_lin_free(spim->tx_channel); + pi_udma_core_lin_free(spim->cmd_channel); + + // Deactivate event routing + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_SPIM_EOT(spim->id)); + + // Reactivate clock-gating and reset + // Reactivate clock-gating and reset + udma_ctrl_cfg_cg_clr_set(ARCHI_UDMA_ADDR, (1 << spim_cs->channel)); + udma_ctrl_cfg_rstn_clr_set(ARCHI_UDMA_ADDR, (1 << spim_cs->channel)); + } + + pi_l2_free(spim_cs, sizeof(pi_spim_cs_t)); + + pi_irq_restore(irq); +} + + + +static void __attribute__((noinline)) pi_spim_enqueue_to_pending(pi_spim_t *spim, pi_task_t *task, uint32_t data0, uint32_t data1, uint32_t data2, uint32_t data3, uint32_t data4) +{ + task->data[0] = data0; + task->data[1] = data1; + task->data[2] = data2; + task->data[3] = data3; + task->data[4] = data4; + + if (spim->waiting_first) + { + spim->waiting_last->next = task; + } + else + { + spim->waiting_first = task; + } + spim->waiting_last = task; + task->next = NULL; +} + + + +static void __attribute__((noinline)) pi_spim_enqueue_to_pending_7(pi_spim_t *spim, pi_task_t *task, uint32_t data0, uint32_t data1, uint32_t data2, uint32_t data3, uint32_t data4, uint32_t data5, uint32_t data6, uint32_t data7) +{ + task->data[0] = data0; + task->data[1] = data1; + task->data[2] = data2; + task->data[3] = data3; + task->data[4] = data4; + task->data[5] = data5; + task->data[6] = data6; + task->data[7] = data7; + + if (spim->waiting_first) + { + spim->waiting_last->next = task; + } + else + { + spim->waiting_first = task; + } + spim->waiting_last = task; + task->next = NULL; +} + + + +void pi_spi_send_async(struct pi_device *device, void *data, size_t len, pi_spi_flags_e flags, pi_task_t *task) +{ + int irq = pi_irq_disable(); + + SPIM_TRACE(POS_LOG_TRACE, "Sending bitstream (device: %p, buffer: %p, len: 0x%x, flags: 0x%x, task: %p)\n", device, data, len, flags, task); + + pi_spim_cs_t *spim_cs = (pi_spim_cs_t *) device->data; + pi_spim_t *spim = spim_cs->spim; + int qspi = ((flags >> 2) & 0x3) == 1; + int cs_mode = (flags >> 0) & 0x3; + + if (spim->pending_copy) + { + task->data[0] = 0; + task->data[1] = (int)device; + task->data[2] = (int)data; + task->data[3] = len; + task->data[4] = flags; + + if (spim->waiting_first) + { + spim->waiting_last->next = task; + } + else + { + spim->waiting_first = task; + } + spim->waiting_last = task; + task->next = NULL; + + goto end; + } + + int buffer_size = (len+7)/8; + + spim->pending_copy = task; + + int size = (len + 7) >> 3; + int endianness = spim_cs->big_endian ? SPI_CMD_MSB_FIRST : SPI_CMD_LSB_FIRST; + + // First enqueue the header with SPI config, cs, and send command. + // The rest will be sent by the assembly code. + // First the user data and finally an epilogue with the EOT command. + + pi_udma_core_lin_enqueue(spim->tx_channel_base, (uint32_t) data, buffer_size, 0); + + if (!spim->is_slave) + { + spim->udma_cmd[0] = spim_cs->cfg; + spim->udma_cmd[1] = SPI_CMD_SOT(spim_cs->cs); + + if (spim_cs->wordsize == PI_SPI_WORDSIZE_8) + { + spim->udma_cmd[2] = SPI_CMD_TX_DATA(len/8, SPI_CMD_4_WORD_PER_TRANSF, 8, qspi, endianness); + } + else if (spim_cs->wordsize == PI_SPI_WORDSIZE_16) + { + spim->udma_cmd[2] = SPI_CMD_TX_DATA(len/16, SPI_CMD_2_WORD_PER_TRANSF, 16, qspi, endianness); + } + else + { + spim->udma_cmd[2] = SPI_CMD_TX_DATA(len/32, SPI_CMD_1_WORD_PER_TRANSF, 32, qspi, endianness); + } + spim->udma_cmd[3] = SPI_CMD_EOT(1, cs_mode == PI_SPI_CS_KEEP); + + pi_udma_core_lin_enqueue(spim->cmd_channel_base, (uint32_t) spim->udma_cmd, 4*4, 0); + } + else + { + spim->udma_cmd[0] = SPI_CMD_SLAVE_TX_DATA(len>>3, 0); + spim->udma_cmd[1] = SPI_CMD_SLAVE_EOT(); + + pi_udma_core_lin_enqueue(spim->cmd_channel_base, (uint32_t) spim->udma_cmd, 8, 0); + } + +end: + pi_irq_restore(irq); +} + + +void pi_spi_send(struct pi_device *device, void *data, size_t len, pi_spi_flags_e flags) +{ + pi_task_t task; + pi_spi_send_async(device, data, len, flags, pi_task_block(&task)); + pi_task_wait_on(&task); +} + + + +void pi_spi_receive_async(struct pi_device *device, void *data, size_t len, pi_spi_flags_e flags, pi_task_t *task) +{ + SPIM_TRACE(POS_LOG_TRACE, "Receive bitstream (device: %p, buffer: %p, len: 0x%x, flags: 0x%x, task: %p)\n", device, data, len, flags, task); + + int irq = pi_irq_disable(); + + pi_spim_cs_t *spim_cs = (pi_spim_cs_t *)device->data; + pi_spim_t *spim = spim_cs->spim; + int qspi = ((flags >> 2) & 0x3) == 1; + int cs_mode = (flags >> 0) & 0x3; + + if (spim->pending_copy) + { + task->data[0] = 1; + task->data[1] = (int)device; + task->data[2] = (int)data; + task->data[3] = len; + task->data[4] = flags; + + if (spim->waiting_first) + { + spim->waiting_last->next = task; + } + else + { + spim->waiting_first = task; + } + + spim->waiting_last = task; + task->next = NULL; + + goto end; + } + + spim->pending_copy = task; + + int size = (len + 7) >> 3; + int endianness = spim_cs->big_endian ? SPI_CMD_MSB_FIRST : SPI_CMD_LSB_FIRST; + + pi_udma_core_lin_enqueue(spim->rx_channel_base, (uint32_t) data, size, 0); + + if (!spim->is_slave) + { + spim->udma_cmd[0] = spim_cs->cfg; + spim->udma_cmd[1] = SPI_CMD_SOT(spim_cs->cs); + + if (spim_cs->wordsize == PI_SPI_WORDSIZE_8) + { + spim->udma_cmd[2] = SPI_CMD_RX_DATA(len/8, SPI_CMD_4_WORD_PER_TRANSF, 8, qspi, endianness); + } + else if (spim_cs->wordsize == PI_SPI_WORDSIZE_16) + { + spim->udma_cmd[2] = SPI_CMD_RX_DATA(len/16, SPI_CMD_2_WORD_PER_TRANSF, 16, qspi, endianness); + } + else + { + spim->udma_cmd[2] = SPI_CMD_RX_DATA(len/32, SPI_CMD_1_WORD_PER_TRANSF, 32, qspi, endianness); + } + + spim->udma_cmd[3] = SPI_CMD_EOT(1, cs_mode == PI_SPI_CS_KEEP); + + pi_udma_core_lin_enqueue(spim->cmd_channel_base, (uint32_t) spim->udma_cmd, 4*4, 0); + } + else + { + spim->udma_cmd[0] = SPI_CMD_SLAVE_RX_DATA(len>>3, 0); + spim->udma_cmd[1] = SPI_CMD_SLAVE_EOT(); + + pi_udma_core_lin_enqueue(spim->cmd_channel_base, (uint32_t) spim->udma_cmd, 8, 0); + } + +end: + pi_irq_restore(irq); +} + +void pi_spi_receive(struct pi_device *device, void *data, size_t len, pi_spi_flags_e flags) +{ + pi_task_t task; + pi_spi_receive_async(device, data, len, flags, pi_task_block(&task)); + pi_task_wait_on(&task); +} + + +void pi_spi_transfer_async(struct pi_device *device, void *tx_data, void *rx_data, size_t len, pi_spi_flags_e flags, pi_task_t *task) +{ + SPIM_TRACE(POS_LOG_TRACE, "Transfering bitstream (device: %p, tx_buffer: %p, rx_buffer: %p, len: 0x%x, flags: 0x%x, task: %p)\n", device, tx_data, rx_data, len, flags, task); + + int irq = pi_irq_disable(); + + pi_spim_cs_t *spim_cs = (pi_spim_cs_t *)device->data; + pi_spim_t *spim = spim_cs->spim; + int cs_mode = (flags >> 0) & 0x3; + + if (spim->pending_copy) + { + task->data[0] = 2; + task->data[1] = (int)device; + task->data[2] = (int)tx_data; + task->data[3] = (int)rx_data; + task->data[4] = len; + task->data[5] = cs_mode; + + if (spim->waiting_first) + spim->waiting_last->next = task; + else + spim->waiting_first = task; + + spim->waiting_last = task; + task->next = NULL; + + goto end; + } + + //int channel_id = UDMA_CHANNEL_ID(spim_cs->channel); + + int endianness = spim_cs->big_endian ? SPI_CMD_MSB_FIRST : SPI_CMD_LSB_FIRST; + + spim->pending_copy = task; + + int size = (len + 7) >> 3; + + pi_udma_core_lin_enqueue(spim->rx_channel_base, (uint32_t) rx_data, size, 0); + pi_udma_core_lin_enqueue(spim->tx_channel_base, (uint32_t) tx_data, size, 0); + + if (!spim->is_slave) + { + // First enqueue the header with SPI config, cs, and send command. + // The rest will be sent by the assembly code. + // First the user data and finally an epilogue with the EOT command. + spim->udma_cmd[0] = spim_cs->cfg; + spim->udma_cmd[1] = SPI_CMD_SOT(spim_cs->cs); + + if (spim_cs->wordsize == PI_SPI_WORDSIZE_8) + { + spim->udma_cmd[2] = SPI_CMD_FUL(len/8, SPI_CMD_4_WORD_PER_TRANSF, 8, endianness); + } + else if (spim_cs->wordsize == PI_SPI_WORDSIZE_16) + { + spim->udma_cmd[2] = SPI_CMD_FUL(len/16, SPI_CMD_2_WORD_PER_TRANSF, 16, endianness); + } + else + { + spim->udma_cmd[2] = SPI_CMD_FUL(len/32, SPI_CMD_1_WORD_PER_TRANSF, 32, endianness); + } + + spim->udma_cmd[3] = SPI_CMD_EOT(1, cs_mode == PI_SPI_CS_KEEP); + + pi_udma_core_lin_enqueue(spim->cmd_channel_base, (uint32_t) spim->udma_cmd, 4*4, 0); + } + else + { + spim->udma_cmd[0] = SPI_CMD_SLAVE_FUL(len>>3, 0); + spim->udma_cmd[1] = SPI_CMD_SLAVE_EOT(); + + pi_udma_core_lin_enqueue(spim->cmd_channel_base, (uint32_t) spim->udma_cmd, 8, 0); + } + +end: + pi_irq_restore(irq); +} + +void pi_spi_transfer(struct pi_device *device, void *tx_data, void *rx_data, + size_t len, pi_spi_flags_e flags) +{ + pi_task_t task; + pi_spi_transfer_async(device, tx_data, rx_data, len, flags, pi_task_block(&task)); + pi_task_wait_on(&task); +} + +void pi_spi_copy_2d(struct pi_device *device, uint32_t addr, void *data, + uint32_t size, uint32_t stride, uint32_t length, pi_spi_flags_e flags) +{ + pi_task_t task; + pi_spi_copy_2d_async(device, addr, data, size, stride, length, flags, pi_task_block(&task)); + pi_task_wait_on(&task); +} + + +static __attribute__((noinline)) void pi_spim_send_enqueue_transfer(uint32_t event, void *arg) +{ + pi_spim_cs_t *spim_cs = (pi_spim_cs_t *) arg; + pi_spim_t *spim = (pi_spim_t *) spim_cs->spim; + + uint32_t addr = spim->pending_repeat_misaligned_addr; + uint32_t size = spim->pending_repeat_misaligned_size; + uint32_t chunk_size = spim_cs->max_snd_size; + + uint32_t cmd_size; + uint32_t *cmd; + + SPIM_TRACE(POS_LOG_TRACE, "Enqueueing send transfer (addr: 0x%lx, ram_addr: 0x%x, pending size: 0x%lx)\n", addr, spim->pending_repeat_misaligned_ram_addr, size); + + memcpy(spim_cs->send_addr_ucode, &spim->pending_repeat_misaligned_ram_addr, spim_cs->send_addr_ucode_size); + + + + cmd_size = spim_cs->udma_send_cmd_size; + cmd = spim_cs->udma_send_cmd; + + void *callback = pi_spim_send_enqueue_transfer; + + if (size > chunk_size) + { + size = chunk_size; + } + + SPIM_TRACE(POS_LOG_TRACE, "Enqueueing aligned send chunk (addr: 0x%x, size: 0x%lx)\n", spim->pending_repeat_misaligned_addr, size); + + spim->pending_repeat_misaligned_ram_addr += size; + spim->pending_repeat_misaligned_addr += size; + spim->pending_repeat_misaligned_size -= size; + + cmd[cmd_size++] = __BITINSERT(spim->tx_cmd, size-1, SPI_CMD_TX_DATA_SIZE_WIDTH, SPI_CMD_TX_DATA_SIZE_OFFSET); + cmd[cmd_size++] = SPI_CMD_EOT(1, 0); + + if (spim->pending_repeat_misaligned_size == 0) + { + if (spim->pending_repeat_misaligned_2d_size > 0) + { + uint32_t size = spim->pending_repeat_misaligned_length; + + if (size > spim->pending_repeat_misaligned_2d_size) + { + size = spim->pending_repeat_misaligned_2d_size; + } + + spim->pending_repeat_misaligned_2d_size -= size; + + spim->pending_repeat_misaligned_size = size; + spim->pending_repeat_misaligned_ram_addr = spim->pending_repeat_misaligned_ram_addr - spim->pending_repeat_misaligned_length + spim->pending_repeat_misaligned_stride; + } + else + { + callback = pi_spim_handle_eot; + } + } + + pi_fc_event_handler_set_func(SOC_EVENT_UDMA_SPIM_EOT(spim->id), callback); + + pi_udma_core_lin_enqueue(spim->cmd_channel_base, (uint32_t) cmd, cmd_size*4, 0); + pi_udma_core_lin_enqueue(spim->tx_channel_base, (uint32_t) addr, size, 0); +} + + + +static void __attribute__((noinline)) pi_spim_send_handle_misaligned(pi_spim_cs_t *spim_cs, uint32_t addr, uint32_t data, uint32_t size, pi_spim_t *spim) +{ + SPIM_TRACE(POS_LOG_TRACE, "Handling SPIM chunk (addr: 0x%lx, size: 0x%lx)\n", addr, size); + + spim->pending_repeat_misaligned_ram_addr = addr; + spim->pending_repeat_misaligned_addr = data; + spim->pending_repeat_misaligned_size = size; + spim->pending_repeat_misaligned_2d_size = 0; + + pi_fc_event_handler_set_args(SOC_EVENT_UDMA_SPIM_EOT(spim->id), spim_cs); + + pi_spim_send_enqueue_transfer(0, spim_cs); +} + + +static void __attribute__((noinline)) pi_spim_send_handle_misaligned_2d(pi_spim_cs_t *spim_cs, uint32_t addr, uint32_t data, uint32_t size, uint32_t stride, uint32_t length, pi_spim_t *spim) +{ + SPIM_TRACE(POS_LOG_TRACE, "Sending SPIM 2D chunk (addr: 0x%lx, data: 0x%lx, size: 0x%lx, stride: 0x%lx, length: 0x%lx)\n", addr, data, size, stride, length); + + int transfer_size = size > length ? length : size; + + spim->pending_repeat_misaligned_ram_addr = addr; + spim->pending_repeat_misaligned_addr = data; + spim->pending_repeat_misaligned_size = transfer_size; + spim->pending_repeat_misaligned_length = length; + spim->pending_repeat_misaligned_stride = stride; + spim->pending_repeat_misaligned_2d_size = size - transfer_size; + + pi_fc_event_handler_set_args(SOC_EVENT_UDMA_SPIM_EOT(spim->id), spim_cs); + + pi_spim_send_enqueue_transfer(0, spim_cs); +} + +static __attribute__((noinline)) void pi_spim_receive_enqueue_transfer(uint32_t event, void *arg) +{ + pi_spim_cs_t *spim_cs = (pi_spim_cs_t *) arg; + pi_spim_t *spim = (pi_spim_t *) spim_cs->spim; + + pi_fc_event_handler_set_func(SOC_EVENT_UDMA_SPIM_EOT(spim->id), spim->pending_callback); + + uint32_t addr = spim->pending_repeat_misaligned_addr; + uint32_t size = spim->pending_repeat_misaligned_size; + uint32_t chunk_size = spim_cs->max_rcv_size; + + if (size == 0) + { + return; + } + + uint32_t cmd_size; + uint32_t *cmd; + + SPIM_TRACE(POS_LOG_TRACE, "Enqueueing receive transfer (addr: 0x%lx, ram_addr: 0x%x, pending size: 0x%lx)\n", addr, spim->pending_repeat_misaligned_ram_addr, size); + + memcpy(spim_cs->receive_addr_ucode, &spim->pending_repeat_misaligned_ram_addr, spim_cs->receive_addr_ucode_size); + + cmd_size = spim_cs->udma_receive_cmd_size; + cmd = spim_cs->udma_receive_cmd; + + spim->pending_callback = pi_spim_receive_enqueue_transfer; + + if (size > chunk_size) + { + size = chunk_size; + } + else + { + size &= ~0x3; + } + + SPIM_TRACE(POS_LOG_TRACE, "Enqueueing aligned receive chunk (addr: 0x%x, size: 0x%lx)\n", spim->pending_repeat_misaligned_addr, size); + + spim->pending_repeat_misaligned_ram_addr += size; + spim->pending_repeat_misaligned_addr += size; + spim->pending_repeat_misaligned_size -= size; + + cmd[cmd_size++] = __BITINSERT(spim->rx_cmd, size*8-1, SPI_CMD_RX_DATA_SIZE_WIDTH, SPI_CMD_RX_DATA_SIZE_OFFSET); + cmd[cmd_size++] = SPI_CMD_EOT(1, 0); + + if (spim->pending_repeat_misaligned_size == 0) + { + if (spim->pending_repeat_misaligned_2d_size > 0) + { + uint32_t size = spim->pending_repeat_misaligned_length; + + if (size > spim->pending_repeat_misaligned_2d_size) + { + size = spim->pending_repeat_misaligned_2d_size; + } + + spim->pending_repeat_misaligned_2d_size -= size; + + spim->pending_repeat_misaligned_size = size; + spim->pending_repeat_misaligned_ram_addr = spim->pending_repeat_misaligned_ram_addr - spim->pending_repeat_misaligned_length + spim->pending_repeat_misaligned_stride; + } + else + { + spim->pending_callback = pi_spim_handle_eot; + } + } + + + pi_udma_core_lin_enqueue(spim->rx_channel_base, (uint32_t) addr, size, 0); + pi_udma_core_lin_enqueue(spim->cmd_channel_base, (uint32_t) cmd, cmd_size*4, 0); +} + + + +static void __attribute__((noinline)) pi_spim_receive_handle_misaligned(pi_spim_cs_t *spim_cs, uint32_t addr, uint32_t data, uint32_t size, pi_spim_t *spim) +{ + SPIM_TRACE(POS_LOG_TRACE, "Receiving SPIM chunk (addr: 0x%lx, size: 0x%lx)\n", addr, size); + + spim->pending_repeat_misaligned_ram_addr = addr; + spim->pending_repeat_misaligned_addr = data; + spim->pending_repeat_misaligned_size = size; + spim->pending_repeat_misaligned_2d_size = 0; + + pi_fc_event_handler_set_args(SOC_EVENT_UDMA_SPIM_EOT(spim->id), spim_cs); + + pi_spim_receive_enqueue_transfer(0, spim_cs); + + if (spim->pending_repeat_misaligned_size) + { + pi_spim_receive_enqueue_transfer(0, spim_cs); + } + else + { + pi_fc_event_handler_set_func(SOC_EVENT_UDMA_SPIM_EOT(spim->id), spim->pending_callback); + } + +} + + + +static void __attribute__((noinline)) pi_spim_receive_handle_misaligned_2d( + pi_spim_cs_t *spim_cs, uint32_t addr, uint32_t data, uint32_t size, + uint32_t stride, uint32_t length, pi_spim_t *spim) +{ + SPIM_TRACE(POS_LOG_TRACE, "Receiving SPIM 2D chunk (addr: 0x%lx, data: 0x%lx, size: 0x%lx, stride: 0x%lx, length: 0x%lx)\n", addr, data, size, stride, length); + + int transfer_size = size > length ? length : size; + + spim->pending_repeat_misaligned_ram_addr = addr; + spim->pending_repeat_misaligned_addr = data; + spim->pending_repeat_misaligned_size = transfer_size; + spim->pending_repeat_misaligned_length = length; + spim->pending_repeat_misaligned_stride = stride; + spim->pending_repeat_misaligned_2d_size = size - transfer_size; + + pi_fc_event_handler_set_args(SOC_EVENT_UDMA_SPIM_EOT(spim->id), spim_cs); + + pi_spim_receive_enqueue_transfer(0, spim_cs); + + if (spim->pending_repeat_misaligned_size) + { + pi_spim_receive_enqueue_transfer(0, spim_cs); + } + else + { + pi_fc_event_handler_set_func(SOC_EVENT_UDMA_SPIM_EOT(spim->id), spim->pending_callback); + } +} + + +void pi_spi_copy_2d_async(struct pi_device *device, uint32_t addr, void *data, + uint32_t size, uint32_t stride, uint32_t length, + pi_spi_flags_e flags, pi_task_t *task) +{ + SPIM_TRACE(POS_LOG_DEBUG, "Copy 2D bitstream (device: %p, ext2loc: %d, addr: 0x%lx, buffer: %p, size: 0x%lx, stride: 0x%lx, length: 0x%lx, flags: 0x%x, task: %p)\n", device, __BITEXTRACT(flags, 1, 5), addr, data, size, stride, length, flags, task); + + pi_spim_cs_t *spim_cs = (pi_spim_cs_t *) device->data; + pi_spim_t *spim = spim_cs->spim; + + uint32_t irq = pi_irq_disable(); + + if (likely(!spim->pending_copy)) + { + int qspi = __BITEXTRACT(flags, 2, 2) == 1; + int cs_mode = __BITEXTRACT(flags, 2, 0); + int ext2loc = __BITEXTRACT(flags, 1, 4); + + spim->pending_copy = task; + spim->pending_is_auto = cs_mode == PI_SPI_CS_AUTO; + + if (ext2loc) + { + spim->rx_cmd = __BITINSERT(spim_cs->rx_cmd, qspi, SPI_CMD_RX_DATA_QPI_WIDTH, SPI_CMD_RX_DATA_QPI_OFFSET); + pi_spim_receive_handle_misaligned_2d(spim_cs, addr, (uint32_t) data, size, stride, length, spim); + } + else + { + spim->tx_cmd = __BITINSERT(spim_cs->tx_cmd, qspi, SPI_CMD_TX_DATA_QPI_WIDTH, SPI_CMD_TX_DATA_QPI_OFFSET); + pi_spim_send_handle_misaligned_2d(spim_cs, addr, (uint32_t) data, size, stride, length, spim); + } + } + else + { + pi_spim_enqueue_to_pending_7(spim, task, 4, (int) device, addr, (int) data, size, stride, length, flags); + } + + pi_irq_restore(irq); +} + + + +void pi_spi_copy(struct pi_device *device, uint32_t addr, void *data, + uint32_t size, pi_spi_flags_e flags) +{ + pi_task_t task; + pi_spi_copy_async(device, addr, data, size, flags, pi_task_block(&task)); + pi_task_wait_on(&task); +} + + + +void pi_spi_copy_async(struct pi_device *device, uint32_t addr, void *data, + uint32_t size, pi_spi_flags_e flags, pi_task_t *task) +{ + SPIM_TRACE(POS_LOG_DEBUG, "Copy bitstream (device: %p, ext2loc: %d, addr: 0x%lx, buffer: %p, size: 0x%lx, flags: 0x%x, task: %p)\n", device, __BITEXTRACT(flags, 1, 4), addr, data, size, flags, task); + + pi_spim_cs_t *spim_cs = (pi_spim_cs_t *) device->data; + pi_spim_t *spim = spim_cs->spim; + + uint32_t irq = pi_irq_disable(); + + if (likely(!spim->pending_copy)) + { + int qspi = __BITEXTRACT(flags, 2, 2) == 1; + int cs_mode = __BITEXTRACT(flags, 2, 0); + int ext2loc = __BITEXTRACT(flags, 1, 4); + + spim->pending_copy = task; + spim->pending_is_auto = cs_mode == PI_SPI_CS_AUTO; + + if (ext2loc) + { + spim->rx_cmd = __BITINSERT(spim_cs->rx_cmd, qspi, SPI_CMD_RX_DATA_QPI_WIDTH, SPI_CMD_RX_DATA_QPI_OFFSET); + pi_spim_receive_handle_misaligned(spim_cs, addr, (uint32_t) data, size, spim); + } + else + { + spim->tx_cmd = __BITINSERT(spim_cs->tx_cmd, qspi, SPI_CMD_TX_DATA_QPI_WIDTH, SPI_CMD_TX_DATA_QPI_OFFSET); + pi_spim_send_handle_misaligned(spim_cs, addr, (uint32_t) data, size, spim); + } + } + else + { + pi_spim_enqueue_to_pending_7(spim, task, 3, (int) device, addr, (int) data, size, flags, 0, 0); + } + + pi_irq_restore(irq); +} + + + +void *pi_spi_receive_ucode_set(struct pi_device *device, uint8_t *ucode, + uint32_t ucode_size) +{ + pi_spim_cs_t *spim_cs = (pi_spim_cs_t *) device->data; + + if (spim_cs->udma_receive_cmd) + { + pi_l2_free(spim_cs->udma_receive_cmd, (spim_cs->udma_receive_cmd_size + 2)*4); + } + + spim_cs->udma_receive_cmd = pi_l2_malloc(ucode_size + 4*4); + if (spim_cs->udma_receive_cmd == NULL) + { + return NULL; + } + + pi_spim_apply_conf(spim_cs); + + memcpy(&spim_cs->udma_receive_cmd[2], ucode, ucode_size); + spim_cs->udma_receive_cmd_size = 2 + (ucode_size >> 2); + + return (void *)&spim_cs->udma_receive_cmd[2]; +} + + + +void pi_spi_receive_ucode_set_addr_info(struct pi_device *device, uint8_t *ucode, + uint32_t ucode_size) +{ + pi_spim_cs_t *spim_cs = (pi_spim_cs_t *) device->data; + + spim_cs->receive_addr_ucode = ucode; + spim_cs->receive_addr_ucode_size = ucode_size; +} + + + +void *pi_spi_send_ucode_set(struct pi_device *device, uint8_t *ucode, uint32_t ucode_size) +{ + pi_spim_cs_t *spim_cs = (pi_spim_cs_t *)device->data; + + if (spim_cs->udma_send_cmd) + { + pi_l2_free(spim_cs->udma_send_cmd, (spim_cs->udma_send_cmd_size + 2)*4); + } + + spim_cs->udma_send_cmd = pi_l2_malloc(ucode_size + 4*4); + if (spim_cs->udma_send_cmd == NULL) + { + return NULL; + } + + pi_spim_apply_conf(spim_cs); + + memcpy(&spim_cs->udma_send_cmd[2], ucode, ucode_size); + spim_cs->udma_send_cmd_size = 2 + (ucode_size >> 2); + + return (void *)&spim_cs->udma_send_cmd[2]; +} + + + +void pi_spi_send_ucode_set_addr_info(struct pi_device *device, uint8_t *ucode, + uint32_t ucode_size) +{ + pi_spim_cs_t *spim_cs = (pi_spim_cs_t *)device->data; + + spim_cs->send_addr_ucode = ucode; + spim_cs->send_addr_ucode_size = ucode_size; +} + + + +void pi_spim_handle_waiting_copy(pi_task_t *task) +{ + if (task->data[0] == 0) + { + pi_spi_send_async((struct pi_device *)task->data[1], (void *)task->data[2], + task->data[3], task->data[4], task); + } + else if (task->data[0] == 1) + { + pi_spi_receive_async((struct pi_device *)task->data[1], (void *)task->data[2], + task->data[3], task->data[4], task); + } + else + { + pi_spi_transfer_async((struct pi_device *)task->data[1], (void *)task->data[2], + (void *)task->data[3], task->data[4], task->data[5], task); + } +} + +void pi_spi_conf_init(struct pi_spi_conf *conf) +{ + conf->wordsize = PI_SPI_WORDSIZE_8; + conf->big_endian = 0; + conf->max_baudrate = 10000000; + conf->cs = -1; + conf->itf = 0; + conf->polarity = 0; + conf->phase = 0; + conf->max_rcv_chunk_size = -1; + conf->max_snd_chunk_size = -1; + conf->is_slave = 0; +} + +#if !defined(__FREERTOS__) +static void __attribute__((constructor)) pi_spim_init() +{ + for (int i=0; i +#include +#include + +static int spi_init(struct device *device) +{ + ARG_UNUSED(device); + + pi_spim_init(); + + return 0; +} + +struct spi_config { +}; + +struct spi_data { +}; + +static const struct spi_config spi_cfg = { +}; + +static struct spi_data spi_data = { +}; + +DEVICE_INIT(spi, "spi", &spi_init, + &spi_data, &spi_cfg, + PRE_KERNEL_2, CONFIG_KERNEL_INIT_PRIORITY_DEVICE); + +#endif diff --git a/rtos/pmsis/pmsis_implem/chips/gap9/drivers/spim/spim_v4.h b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/spim/spim_v4.h new file mode 100644 index 000000000..8a6d56e7c --- /dev/null +++ b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/spim/spim_v4.h @@ -0,0 +1,206 @@ +/* + * Copyright (C) 2019 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __ARCHI_UDMA_SPIM_SPIM_V4_H__ +#define __ARCHI_UDMA_SPIM_SPIM_V4_H__ + +// SPI commands IDS definition +#define SPI_CMD_CFG_ID 0 +#define SPI_CMD_SOT_ID 1 +#define SPI_CMD_SEND_CMD_ID 2 +#define SPI_CMD_SEND_BITS_ID 2 +#define SPI_CMD_SEND_ADDR_ID 3 +#define SPI_CMD_DUMMY_ID 4 +#define SPI_CMD_WAIT_ID 5 +#define SPI_CMD_TX_DATA_ID 6 +#define SPI_CMD_RX_DATA_ID 7 +#define SPI_CMD_RPT_ID 8 +#define SPI_CMD_EOT_ID 9 +#define SPI_CMD_RPT_END_ID 10 +#define SPI_CMD_RX_CHECK_ID 11 +#define SPI_CMD_FUL_ID 12 + +// SPI command fields offset, mask, value definition +// SPI commands fields offsets +#define SPI_CMD_ID_OFFSET 28 + +// COMMON definitions +#define SPI_CMD_QPI_ENA 1 +#define SPI_CMD_QPI_DIS 0 +#define SPI_CMD_LSB_FIRST 1 +#define SPI_CMD_MSB_FIRST 0 +#define SPI_CMD_4_WORD_PER_TRANSF 2 +#define SPI_CMD_2_WORD_PER_TRANSF 1 +#define SPI_CMD_1_WORD_PER_TRANSF 0 +#define SPI_CMD_DATA_WITDH(val) (val) +#define SPI_CMD_CMD_SIZE(val) (val) + +// CFG +#define SPI_CMD_CFG_CLK_DIV_OFFSET 0 +#define SPI_CMD_CFG_CLK_DIV_WIDTH 8 +#define SPI_CMD_CFG_CPHA_OFFSET 8 +#define SPI_CMD_CFG_CPOL_OFFSET 9 + +#define SPI_CMD_CFG_CLKDIV(val) (val) +#define SPI_CMD_CFG_CPOL_POS 1 +#define SPI_CMD_CFG_CPOL_NEG 0 +#define SPI_CMD_CFG_CPHA_STD 1 +#define SPI_CMD_CFG_CPHA_OPP 0 + +// SOT +#define SPI_CMD_SOT_CS_OFFSET 0 +#define SPI_CMD_SOT_CS_WIDTH 2 + +#define SPI_CMD_SOT_CS0 0 +#define SPI_CMD_SOT_CS1 1 +#define SPI_CMD_SOT_CS2 2 +#define SPI_CMD_SOT_CS3 3 + +// SEND_CMD +#define SPI_CMD_SEND_CMD_CMD_OFFSET 0 +#define SPI_CMD_SEND_CMD_CMD_WIDTH 16 +#define SPI_CMD_SEND_CMD_SIZE_OFFSET 16 +#define SPI_CMD_SEND_CMD_SIZE_WIDTH 4 +#define SPI_CMD_SEND_CMD_QPI_OFFSET 27 + +// SEND_CMD +#define SPI_CMD_SEND_BITS_BITS_OFFSET 0 +#define SPI_CMD_SEND_BITS_BITS_WIDTH 16 +#define SPI_CMD_SEND_BITS_SIZE_OFFSET 16 +#define SPI_CMD_SEND_BITS_SIZE_WIDTH 4 +#define SPI_CMD_SEND_BITS_QPI_OFFSET 27 + +// SEND_ADDR +#define SPI_CMD_SEND_ADDR_SIZE_OFFSET 16 +#define SPI_CMD_SEND_ADDR_SIZE_WIDTH 5 +#define SPI_CMD_SEND_ADDR_QPI_OFFSET 27 + +//#define SPI_CMD_SEND_ADDR_VALUE(value) ((((value) & 0xff000000) >> 24) | (((value) & 0xff0000) >> 8) | (((value) & 0xff00) << 8) | (((value) & 0xff) << 24)) +#define SPI_CMD_SEND_ADDR_VALUE(value) (value) + + +// SEND_DUMMY +#define SPI_CMD_DUMMY_CYCLE_OFFSET 16 +#define SPI_CMD_DUMMY_CYCLE_WIDTH 5 + +// TX_DATA +#define SPI_CMD_TX_DATA_SIZE_OFFSET 0 +#define SPI_CMD_TX_DATA_SIZE_WIDTH 16 +#define SPI_CMD_TX_DATA_QPI_OFFSET 27 +#define SPI_CMD_TX_DATA_QPI_WIDTH 1 +#define SPI_CMD_TX_DATA_WORDTRANS_OFFSET 21 +#define SPI_CMD_TX_DATA_WORDTRANS_WIDTH 2 +#define SPI_CMD_TX_DATA_LSBFIRST_OFFSET 26 +#define SPI_CMD_TX_DATA_BITSWORD_OFFSET 16 +#define SPI_CMD_TX_DATA_BITSWORD_WIDTH 5 + +// SLAVE_TX_DATA +#define SPI_CMD_SLAVE_TX_DATA_SIZE_OFFSET 0 +#define SPI_CMD_SLAVE_TX_DATA_SIZE_WIDTH 16 +#define SPI_CMD_SLAVE_TX_DATA_IGNORE_CS_OFFSET 16 +#define SPI_CMD_SLAVE_TX_DATA_IGNORE_CS_WIDTH 1 + + +// RX_DATA +#define SPI_CMD_RX_DATA_SIZE_OFFSET 0 +#define SPI_CMD_RX_DATA_SIZE_WIDTH 16 +#define SPI_CMD_RX_DATA_QPI_OFFSET 27 +#define SPI_CMD_RX_DATA_QPI_WIDTH 1 +#define SPI_CMD_RX_DATA_WORDTRANS_OFFSET 21 +#define SPI_CMD_RX_DATA_WORDTRANS_WIDTH 2 +#define SPI_CMD_RX_DATA_LSBFIRST_OFFSET 26 +#define SPI_CMD_RX_DATA_BITSWORD_OFFSET 16 +#define SPI_CMD_RX_DATA_BITSWORD_WIDTH 5 + + +// RPT +#define SPI_CMD_RPT_NB_OFFSET 0 +#define SPI_CMD_RPT_NB_WIDTH 16 + +// EOT +#define SPI_CMD_EOT_GEN_EVT_OFFSET 0 +#define SPI_CMD_EOT_CS_KEEP_OFFSET 1 + +#define SPI_CMD_EOT_EVENT_ENA 1 +#define SPI_CMD_EOT_EVENT_DIS 0 + +// WAIT +#define SPI_CMD_WAIT_EVENT_OFFSET 0 +#define SPI_CMD_WAIT_EVENT_WIDTH 2 + +// RX_CHECK +#define SPI_CMD_RX_CHECK_VALUE_OFFSET 0 +#define SPI_CMD_RX_CHECK_VALUE_WIDTH 16 + +#define SPI_CMD_RX_CHECK_SIZE_OFFSET 16 +#define SPI_CMD_RX_CHECK_SIZE_WIDTH 4 + +#define SPI_CMD_RX_CHECK_MODE_OFFSET 24 +#define SPI_CMD_RX_CHECK_MODE_WIDTH 2 + +#define SPI_CMD_RX_CHECK_BYTE_ALIGN_OFFSET 26 + +#define SPI_CMD_RX_CHECK_QPI_OFFSET 27 + +#define SPI_CMD_RX_CHECK_MODE_MATCH 0 +#define SPI_CMD_RX_CHECK_MODE_ONES 1 +#define SPI_CMD_RX_CHECK_MODE_ZEROS 2 +#define SPI_CMD_RX_CHECK_MODE_MASK 3 + +// FULL DUPLEX +#define SPI_CMD_FUL_SIZE_OFFSET 0 +#define SPI_CMD_FUL_SIZE_WIDTH 16 +#define SPI_CMD_FUL_WORDTRANS_OFFSET 21 +#define SPI_CMD_FUL_WORDTRANS_WIDTH 2 +#define SPI_CMD_FUL_LSBFIRST_OFFSET 26 +#define SPI_CMD_FUL_BITSWORD_OFFSET 16 +#define SPI_CMD_FUL_BITSWORD_WIDTH 5 + +#define SPI_CMD_SETUP_UC_TXRXEN_OFFSET 27 +#define SPI_CMD_SETUP_UC_DS_OFFSET 25 + +// SPI CMD encoding +#define SPI_CMD_CFG(clockDiv,cpol,cpha) ((SPI_CMD_CFG_ID< +#include "pmsis.h" +#include "chips/gap9/drivers/udma/udma_core.h" + + +/******************************************************************************* + * Definitions + ******************************************************************************/ +#define RX_CHANNEL 0 +#define TX_CHANNEL 1 +#define CMD_CHANNEL 2 + +/******************************************************************************* + * Driver data + ******************************************************************************/ + +char *udma_chan_str[3] = { + [RX_CHANNEL] = "RX_CHANNEL", + [TX_CHANNEL] = "TX_CHANNEL", + [CMD_CHANNEL] = "CMD_CHANNEL"}; + +PI_FC_TINY uint32_t __pi_udma_chan_lin[PI_NB_UDMA_CHAN_LIN_REGS]; +PI_FC_TINY uint32_t __pi_udma_chan_2d = 0; +PI_FC_TINY uint32_t __pi_udma_chan_fifo = 0; + +/******************************************************************************* + * API implementation + ******************************************************************************/ diff --git a/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_datamove.c b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_datamove.c new file mode 100644 index 000000000..362620967 --- /dev/null +++ b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_datamove.c @@ -0,0 +1,433 @@ +/* + * Copyright (c) 2020, GreenWaves Technologies, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * o Redistributions of source code must retain the above copyright notice, this list + * of conditions and the following disclaimer. + * + * o Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * o Neither the name of GreenWaves Technologies, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "pmsis.h" + +/******************************************************************************* + * Definitions + ******************************************************************************/ + +#if !defined(__FREERTOS__) +#define SOC_EVENT_UDMA_CHAN_LIN(id) ( (id) ) +#define SOC_EVENT_UDMA_CHAN_2D(id) ( ARCHI_UDMA_NB_2D_ADDRGEN + (id) ) +#define UDMA_NB_CHAN_LIN ( ARCHI_UDMA_NB_LIN_ADDRGEN ) +#endif /* __FREERTOS__ */ + +#define __UDMA_NB_DATAMOVE ( 2 ) + +typedef struct pi_udma_datamove_data_s +{ + struct pi_udma_datamove_itf_data_s *itf_data; + pi_udma_datamove_transf_cfg_t src_trf_cfg; /*!< Source data transfer configuration */ + pi_udma_datamove_transf_cfg_t dst_trf_cfg; /*!< Destination data transfer configuration */ +} pi_udma_datamove_data_t; + +typedef struct pi_udma_datamove_itf_data_s +{ + uint8_t device_id; + pi_task_t* fifo_head; + pi_task_t* fifo_tail; + pi_task_t* end_task; + int32_t nb_open; /*!< number of devices opened */ + int32_t rx_lin_chan_id; + int32_t tx_lin_chan_id; + int32_t rx_2d_chan_id; + int32_t tx_2d_chan_id; +} pi_udma_datamove_itf_data_t; + +/******************************************************************************* + * Driver data + ******************************************************************************/ + +static pi_udma_datamove_itf_data_t* g_udma_datamove_itf_data[__UDMA_NB_DATAMOVE]; + +/******************************************************************************* + * Internal functions + ******************************************************************************/ + +static inline void __pi_udma_datamove_task_fifo_enqueue(pi_udma_datamove_itf_data_t *itf_data, + pi_task_t *pi_task) +{ + //uint32_t irq = pi_irq_disable(); + if (itf_data->fifo_tail) + { + // tail insert + itf_data->fifo_tail->next = pi_task; + itf_data->fifo_tail = itf_data->fifo_tail->next; + itf_data->fifo_tail->next = NULL; + } + else + { + // Initialize the list + itf_data->fifo_head = pi_task; + itf_data->fifo_head->next = NULL; + // set the base tail + itf_data->fifo_tail = itf_data->fifo_head; + } + //pi_irq_restore(irq); +} + +static inline pi_task_t* __pi_udma_datamove_task_fifo_pop(pi_udma_datamove_itf_data_t *itf_data) +{ + //uint32_t irq = pi_irq_disable(); + pi_task_t *ret_task = NULL; + if (itf_data->fifo_head != NULL) + { + ret_task = itf_data->fifo_head; + hal_compiler_barrier(); + itf_data->fifo_head = itf_data->fifo_head->next; + if (itf_data->fifo_head == NULL) + { + itf_data->fifo_tail = NULL; + } + } + //pi_irq_restore(irq); + return ret_task; +} + +static inline void __pi_udma_datamove_copy_start(pi_udma_datamove_itf_data_t* itf_data) +{ + if (NULL == itf_data->end_task) + { + return; + } + + uint32_t src = itf_data->end_task->data[0]; + uint32_t dst = itf_data->end_task->data[1]; + uint32_t len = itf_data->end_task->data[2]; + + pi_udma_datamove_data_t* dev_data = (pi_udma_datamove_data_t*) itf_data->end_task->data[3]; + uint32_t udma_ctrl_base = (uint32_t) ARCHI_UDMA_ADDR; + + /* select the rx_channel according to the device configuration */ + int32_t rx_chan = -1; + if (dev_data->dst_trf_cfg.type == PI_UDMA_DATAMOVE_TRF_LINEAR) + { + rx_chan = itf_data->rx_lin_chan_id; + } + else + { + rx_chan = itf_data->rx_2d_chan_id; + } + /* select the tx_channel according to the device configuration */ + int32_t tx_chan = -1; + if (dev_data->src_trf_cfg.type == PI_UDMA_DATAMOVE_TRF_LINEAR) + { + tx_chan = itf_data->tx_lin_chan_id; + } + else + { + tx_chan = itf_data->tx_2d_chan_id; + } + + if (0 == itf_data->device_id) + { + /* set the channels to use */ + //hal_udma_ctrl_datamove0_cfg_set_ids(tx_chan, rx_chan); + udma_ctrl_datamove_cfg_source_id_0_set(udma_ctrl_base, tx_chan); + udma_ctrl_datamove_cfg_dest_id_0_set(udma_ctrl_base, rx_chan); + + /* launch the copy, also activate clock for udma channels */ + //hal_udma_ctrl_datamove0_enable(); + udma_ctrl_datamove0_size_en_set(udma_ctrl_base, 1); + } + else + { + /* set the channels to use */ + //hal_udma_ctrl_datamove1_cfg_set_ids(tx_chan, rx_chan); + udma_ctrl_datamove_cfg_source_id_1_set(udma_ctrl_base, tx_chan); + udma_ctrl_datamove_cfg_dest_id_1_set(udma_ctrl_base, rx_chan); + + /* launch the copy, also activate clock for udma channels */ + //hal_udma_ctrl_datamove1_enable(); + udma_ctrl_datamove1_size_en_set(udma_ctrl_base, 1); + } + + /* setup and launch channels */ + if (dev_data->dst_trf_cfg.type == PI_UDMA_DATAMOVE_TRF_LINEAR) + { + uint32_t udma_core = pi_udma_core_lin_addr_get(rx_chan); + uint32_t config = UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_EN(1); + pi_udma_core_lin_enqueue(udma_core, dst, len, config); + } + else + { + uint32_t udma_core = pi_udma_core_2d_addr_get(rx_chan - UDMA_NB_CHAN_LIN); + uint32_t config = UDMA_CORE_2D_ADDRGEN_CFG_CTRL_EN(1); + pi_udma_core_2d_enqueue(udma_core, dst, 0, len, dev_data->dst_trf_cfg.stride, + dev_data->dst_trf_cfg.row_len, config); + } + + if (dev_data->src_trf_cfg.type == PI_UDMA_DATAMOVE_TRF_LINEAR) + { + uint32_t udma_core = pi_udma_core_lin_addr_get(tx_chan); + uint32_t config = UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_EN(1); + pi_udma_core_lin_enqueue(udma_core, src, len, config); + } + else + { + uint32_t udma_core = pi_udma_core_2d_addr_get(tx_chan - UDMA_NB_CHAN_LIN); + uint32_t config = UDMA_CORE_2D_ADDRGEN_CFG_CTRL_EN(1); + pi_udma_core_2d_enqueue(udma_core, src, 0, len, dev_data->src_trf_cfg.stride, + dev_data->src_trf_cfg.row_len, config); + } +} + + +static void __pi_udma_datamove_event_handler(uint32_t event, void* arg) +{ + pi_udma_datamove_itf_data_t* itf_data = (pi_udma_datamove_itf_data_t*) arg; + pi_task_t* task = itf_data->end_task; + uint32_t udma_ctrl_base = (uint32_t) ARCHI_UDMA_ADDR; + + /* stop the DATAMOVE */ + if (0 == itf_data->device_id) + { + //hal_udma_ctrl_datamove0_stop(); + udma_ctrl_datamove0_size_stop_set(udma_ctrl_base, 1); + } + else + { + //hal_udma_ctrl_datamove1_stop(); + udma_ctrl_datamove1_size_stop_set(udma_ctrl_base, 1); + } + + /* handle current task end */ + if (task != NULL) + { + pi_task_push_irq_safe(task); + } + + itf_data->end_task = NULL; + + /* start new task if needed */ + pi_task_t *next_task = __pi_udma_datamove_task_fifo_pop(itf_data); + if (next_task) + { + itf_data->end_task = next_task; + __pi_udma_datamove_copy_start(itf_data); + } +} + +/******************************************************************************* + * API implementation + ******************************************************************************/ + +void pi_udma_datamove_conf_init(pi_udma_datamove_conf_t *conf) +{ + conf->device_id = 0; + conf->src_trf_cfg.type = PI_UDMA_DATAMOVE_TRF_LINEAR; + conf->src_trf_cfg.row_len = 0; + conf->src_trf_cfg.stride = 0; + conf->dst_trf_cfg.type = PI_UDMA_DATAMOVE_TRF_LINEAR; + conf->dst_trf_cfg.row_len = 0; + conf->dst_trf_cfg.stride = 0; +} + +int pi_udma_datamove_open(pi_device_t *device) +{ + int status = PI_OK; + uint32_t irq = pi_irq_disable(); + pi_udma_datamove_conf_t *conf = (pi_udma_datamove_conf_t*) device->config; + + if (conf->device_id >= __UDMA_NB_DATAMOVE) + { + pi_irq_restore(irq); + return PI_FAIL; + } + + pi_udma_datamove_itf_data_t* itf_data = g_udma_datamove_itf_data[conf->device_id]; + + if (NULL == itf_data) + { + /* allocate itf data */ + itf_data = pi_fc_l1_malloc(sizeof(pi_udma_datamove_itf_data_t)); + if (NULL == itf_data) + { + pi_irq_restore(irq); + return PI_ERR_NO_MEM; + } + g_udma_datamove_itf_data[conf->device_id] = itf_data; + + /* allocate lin channels */ + itf_data->rx_lin_chan_id = pi_udma_core_lin_alloc(); + itf_data->tx_lin_chan_id = pi_udma_core_lin_alloc(); + if ((0 > itf_data->rx_lin_chan_id) || (0 > itf_data->tx_lin_chan_id)) + { + pi_udma_core_lin_free(itf_data->rx_lin_chan_id); + pi_udma_core_lin_free(itf_data->tx_lin_chan_id); + pi_fc_l1_free(itf_data, sizeof(pi_udma_datamove_itf_data_t)); + g_udma_datamove_itf_data[conf->device_id] = NULL; + pi_irq_restore(irq); + return PI_FAIL; + } + + /* enable lin events */ + pi_soc_eu_fc_mask_set(SOC_EVENT_UDMA_CHAN_LIN(itf_data->rx_lin_chan_id)); + pi_fc_event_handler_set(SOC_EVENT_UDMA_CHAN_LIN(itf_data->rx_lin_chan_id), + __pi_udma_datamove_event_handler, itf_data); + /* allocate 2d channels */ + itf_data->rx_2d_chan_id = pi_udma_core_2d_alloc(); + itf_data->tx_2d_chan_id = pi_udma_core_2d_alloc(); + if ((itf_data->rx_2d_chan_id < 0) || (itf_data->tx_2d_chan_id < 0)) + { + pi_udma_core_2d_free(itf_data->rx_2d_chan_id); + pi_udma_core_2d_free(itf_data->tx_2d_chan_id); + pi_udma_core_lin_free(itf_data->rx_lin_chan_id); + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->rx_lin_chan_id)); + pi_udma_core_lin_free(itf_data->tx_lin_chan_id); + pi_fc_l1_free(itf_data, sizeof(pi_udma_datamove_itf_data_t)); + g_udma_datamove_itf_data[conf->device_id] = NULL; + pi_irq_restore(irq); + return PI_FAIL; + } + /* enable 2D events */ + pi_soc_eu_fc_mask_set(itf_data->rx_2d_chan_id); + pi_fc_event_handler_set(itf_data->rx_2d_chan_id, + __pi_udma_datamove_event_handler, itf_data); + + /* Initialize itf data */ + itf_data->nb_open = 1; + itf_data->end_task = NULL; + itf_data->fifo_head = NULL; + itf_data->fifo_tail = NULL; + itf_data->device_id = conf->device_id; + } + else + { + itf_data->nb_open++; + } + + /* allocate device data */ + device->data = pi_fc_l1_malloc(sizeof(pi_udma_datamove_data_t)); + if (NULL == device->data) + { + /* the device we are opening initialized the interface */ + /* we need to close it */ + if (itf_data->nb_open == 1) + { + /* clear events, disable IRQs && free allocated udma channels */ + pi_udma_core_2d_free(itf_data->rx_2d_chan_id); + pi_udma_core_2d_free(itf_data->tx_2d_chan_id); + pi_udma_core_lin_free(itf_data->rx_lin_chan_id); + pi_udma_core_lin_free(itf_data->tx_lin_chan_id); + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->rx_lin_chan_id)); + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_2D((itf_data->rx_2d_chan_id - UDMA_NB_CHAN_LIN))); + /* free itf data */ + g_udma_datamove_itf_data[itf_data->device_id] = NULL; + pi_fc_l1_free(itf_data, sizeof(pi_udma_datamove_itf_data_t)); + } + pi_irq_restore(irq); + return PI_ERR_NO_MEM; + } + + /* initialize device data */ + pi_udma_datamove_data_t* dev_data = (pi_udma_datamove_data_t*) device->data; + dev_data->itf_data = itf_data; + dev_data->src_trf_cfg.type = conf->src_trf_cfg.type; + dev_data->src_trf_cfg.row_len = conf->src_trf_cfg.row_len; + dev_data->src_trf_cfg.stride = conf->src_trf_cfg.stride; + dev_data->dst_trf_cfg.type = conf->dst_trf_cfg.type; + dev_data->dst_trf_cfg.row_len = conf->dst_trf_cfg.row_len; + dev_data->dst_trf_cfg.stride = conf->dst_trf_cfg.stride; + + pi_irq_restore(irq); + return status; +} + +void pi_udma_datamove_close(pi_device_t *device) +{ + uint32_t irq = pi_irq_disable(); + pi_udma_datamove_data_t* dev_data = (pi_udma_datamove_data_t*) device->data; + pi_udma_datamove_itf_data_t* itf_data = dev_data->itf_data; + + itf_data->nb_open--; + + if (0 == itf_data->nb_open) + { + /* clear events, disable IRQs && free allocated udma channels */ + pi_udma_core_2d_free(itf_data->rx_2d_chan_id); + pi_udma_core_2d_free(itf_data->tx_2d_chan_id); + pi_udma_core_lin_free(itf_data->rx_lin_chan_id); + pi_udma_core_lin_free(itf_data->tx_lin_chan_id); + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->rx_lin_chan_id)); + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_2D((itf_data->rx_2d_chan_id - UDMA_NB_CHAN_LIN))); + /* free itf data */ + g_udma_datamove_itf_data[itf_data->device_id] = NULL; + pi_fc_l1_free(itf_data, sizeof(pi_udma_datamove_itf_data_t)); + } + + /* free device data */ + pi_fc_l1_free(dev_data, sizeof(pi_udma_datamove_data_t)); + + pi_irq_restore(irq); +} + +int32_t pi_udma_datamove_copy_async(pi_device_t *device, void* src, void* dst, + uint32_t len, pi_task_t* task) +{ + uint32_t irq = pi_irq_disable(); + + pi_udma_datamove_data_t *dev_data = (pi_udma_datamove_data_t*) device->data; + task->data[0] = (uint32_t) src; + task->data[1] = (uint32_t) dst; + task->data[2] = (uint32_t) len; + task->data[3] = (uint32_t) dev_data; + + pi_udma_datamove_itf_data_t *itf_data = dev_data->itf_data; + + /* if a request is in progress, enqueue this one */ + /* else, execute it */ + if (NULL == itf_data->end_task) + { + itf_data->end_task = task; + __pi_udma_datamove_copy_start(itf_data); + } + else + { + __pi_udma_datamove_task_fifo_enqueue(itf_data, task); + } + + pi_irq_restore(irq); + return PI_OK; +} + +int32_t pi_udma_datamove_copy(pi_device_t *device, void* src, void* dst, uint32_t len) +{ + pi_task_t task; + pi_task_block(&task); + int32_t status = pi_udma_datamove_copy_async(device, src, dst, len, &task); + if (PI_OK == status) + { + pi_task_wait_on(&task); + } + pi_task_destroy(&task); + return status; +} diff --git a/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_ffc.c b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_ffc.c new file mode 100644 index 000000000..794b0950d --- /dev/null +++ b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_ffc.c @@ -0,0 +1,517 @@ +/* + * Copyright (c) 2020, GreenWaves Technologies, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * o Redistributions of source code must retain the above copyright notice, this list + * of conditions and the following disclaimer. + * + * o Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * o Neither the name of GreenWaves Technologies, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "pmsis.h" +#include "chips/gap9/drivers/udma/udma_core.h" + +#if !defined(__FREERTOS__) +#include +#endif /* */ + +/******************************************************************************* + * Definitions + ******************************************************************************/ + +/******************************************************************************* + * Driver data + ******************************************************************************/ + +typedef struct pi_ffc_data_s +{ + struct pi_ffc_itf_data_s *itf_data; + pi_ffc_fixed_type_e fixed_type; + uint32_t fixed_scale; + uint32_t fixed_precision; + pi_ffc_float_type_e float_type; + pi_ffc_mode_e mode; + pi_ffc_io_mode_e io_mode; + uint8_t continuous_mode; +} pi_ffc_data_t; + +typedef struct pi_ffc_itf_data_s +{ + pi_task_t *fifo_head; /*!< head of the tasks FIFO */ + pi_task_t *fifo_tail; /*!< tail of the tasks FIFO */ + pi_task_t *end_task; /*!< current callback task */ + void* latest_conf; /*!< last used FFC configuration */ + int32_t rx_chan_id; /*!< RX udma channel */ + int32_t tx_chan_id; /*!< TX udma channel */ + uint8_t device_id; /*!< Device ID */ + int32_t nb_open; /*!< number of devices opened */ +} pi_ffc_itf_data_t; + +static pi_ffc_itf_data_t* g_ffc_itf_data[ARCHI_UDMA_NB_FFC]; + +/******************** + * Static functions + *******************/ + +static inline uint32_t __ffc_compute_udma_lin_shift(uint8_t is_rx, + pi_ffc_mode_e mode, + pi_ffc_float_type_e fl_type, + pi_ffc_fixed_type_e fp_type) +{ + uint32_t fp_shift = 0; + uint32_t fl_shift = 0; + switch (fl_type) + { + case PI_FFC_FLOAT_FP16: + case PI_FFC_FLOAT_BFP16: + fl_shift = 1; + break; + + default: + fl_shift = 2; + break; + } + + switch (fp_type) + { + case PI_FFC_FIXED_8: + fp_shift = 0; + break; + + case PI_FFC_FIXED_16: + fp_shift = 1; + break; + + default: + fp_shift = 2; + break; + } + + if (0 != is_rx) + { + return (PI_FFC_FIXED_TO_FLOAT == mode) ? fp_shift : fl_shift; + } + else + { + return (PI_FFC_FLOAT_TO_FIXED == mode) ? fp_shift : fl_shift; + } +} + +// Has to be synchronized with irq_disabled(done in convert_async) +// since irq handler might pop at the same time +static inline void __ffc_drv_fifo_enqueue(pi_ffc_itf_data_t *itf_data, + pi_task_t *pi_task) +{ + //uint32_t irq = pi_irq_disable(); + if (itf_data->fifo_tail) + { + // tail insert + itf_data->fifo_tail->next = pi_task; + itf_data->fifo_tail = itf_data->fifo_tail->next; + itf_data->fifo_tail->next = NULL; + } + else + { + // Initialize the list + itf_data->fifo_head = pi_task; + itf_data->fifo_head->next = NULL; + // set the base tail + itf_data->fifo_tail = itf_data->fifo_head; + } + //pi_irq_restore(irq); +} + +static inline pi_task_t *__ffc_drv_fifo_pop(pi_ffc_itf_data_t *itf_data) +{ + pi_task_t *ret_task = NULL; + if (itf_data->fifo_head != NULL) + { + ret_task = itf_data->fifo_head; + hal_compiler_barrier(); + itf_data->fifo_head = itf_data->fifo_head->next; + if (itf_data->fifo_head == NULL) + { + itf_data->fifo_tail = NULL; + } + } + return ret_task; +} + +static void __pi_ffc_change_continuous_mode(pi_ffc_data_t* dev_data, + uint8_t continuous_mode) +{ + uint32_t base = (uint32_t) UDMA_FFC_ADDR(dev_data->itf_data->device_id); + + if (continuous_mode != dev_data->continuous_mode) + { + if (continuous_mode != 0) + { + udma_ffc_start_set(base, 1); + } + else + { + udma_ffc_start_set(base, 0); + } + dev_data->continuous_mode = continuous_mode; + } +} + +static void __pi_ffc_change_event_source(pi_ffc_itf_data_t* itf_data) +{ + /* change event source according to io mode */ + uint32_t base = (uint32_t) UDMA_FFC_ADDR(itf_data->device_id); + + pi_ffc_data_t* dev_data = (pi_ffc_data_t*) itf_data->end_task->data[3]; + + switch(dev_data->io_mode) + { + case PI_FFC_MEMORY_IN_MEMORY_OUT: + //fallthrough + case PI_FFC_STREAM_IN_MEMORY_OUT: + { + /* use output channel as event source */ + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->tx_chan_id)); + pi_soc_eu_fc_mask_set(SOC_EVENT_UDMA_CHAN_LIN(itf_data->rx_chan_id)); + break; + } + + case PI_FFC_MEMORY_IN_STREAM_OUT: + { + /* use input channel as event source */ + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->rx_chan_id)); + pi_soc_eu_fc_mask_set(SOC_EVENT_UDMA_CHAN_LIN(itf_data->tx_chan_id)); + break; + } + + case PI_FFC_STREAM_IN_STREAM_OUT: + { + /* FFC has no control over data flow, no event source */ + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->rx_chan_id)); + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->tx_chan_id)); + break; + } + + default: + //invalid choice + break; + } +} + +static void __pi_ffc_conf_apply(pi_ffc_itf_data_t* itf_data) +{ + uint32_t base = (uint32_t) UDMA_FFC_ADDR(itf_data->device_id); + + pi_ffc_data_t* dev_data = (pi_ffc_data_t*) itf_data->end_task->data[3]; + + /* retrieve current task */ + if (itf_data->latest_conf != dev_data) + { + itf_data->latest_conf = dev_data; + + udma_ffc_fp_format_set(base, dev_data->fixed_type); + udma_ffc_fl_format_set(base, dev_data->float_type); + udma_ffc_fp_prec_set(base, dev_data->fixed_precision); + udma_ffc_fp_scale_set(base, dev_data->fixed_scale); + udma_ffc_mode_direction_set(base, dev_data->mode); + udma_ffc_mode_io_mode_set(base, dev_data->io_mode); + __pi_ffc_change_event_source(itf_data); + } + udma_ffc_rx_dest_set(base, itf_data->rx_chan_id); + udma_ffc_tx_dest_set(base, itf_data->tx_chan_id); + + /* set stream as blocking */ + udma_ctrl_stream_cfg_set((uint32_t) ARCHI_UDMA_ADDR, 1 << (18 + itf_data->device_id)); +} + +static void __pi_ffc_conversion_start(pi_ffc_itf_data_t* itf_data) +{ + uint32_t chan_id; + + if (NULL == itf_data->end_task) + { + return; + } + + uint32_t src = itf_data->end_task->data[0]; + uint32_t dst = itf_data->end_task->data[1]; + uint32_t len = itf_data->end_task->data[2]; + pi_ffc_data_t* dev_data = (pi_ffc_data_t*) itf_data->end_task->data[3]; + + __pi_ffc_conf_apply(itf_data); + + uint32_t base = (uint32_t) UDMA_FFC_ADDR(itf_data->device_id); + + /* launch the conversion */ + if (dev_data->continuous_mode != 0) + { + udma_ffc_conv_num_set(base, 0); + } + else + { + udma_ffc_conv_num_set(base, len); + udma_ffc_start_set(base, 1); + } + + /* setup & launching channels */ + + if (0 == (dev_data->io_mode & 2)) + { + chan_id = udma_ffc_rx_dest_get(base); + uint32_t udma_core = pi_udma_core_lin_addr_get(chan_id); + uint32_t rx_shift = __ffc_compute_udma_lin_shift(0, dev_data->mode, dev_data->float_type, dev_data->fixed_type); + pi_udma_core_lin_enqueue(udma_core, (uint32_t) dst, len << rx_shift, 0); + } + + if (0 == (dev_data->io_mode & 1)) + { + chan_id = udma_ffc_tx_dest_get(base); + uint32_t udma_core = pi_udma_core_lin_addr_get(chan_id); + uint32_t tx_shift = __ffc_compute_udma_lin_shift(1, dev_data->mode, dev_data->float_type, dev_data->fixed_type); + pi_udma_core_lin_enqueue(udma_core, (uint32_t) src, len << tx_shift, 0); + } +} + +/******************** + * Callback + ********************/ + +static void __pi_ffc_event_handler(uint32_t event, void *arg) +{ + + pi_ffc_itf_data_t* itf_data = (pi_ffc_itf_data_t*) arg; + pi_task_t* task = itf_data->end_task; + + /* handle current task end */ + if (task != NULL) + { + pi_task_push_irq_safe(task); + } + + itf_data->end_task = NULL; + + /* start new task if needed */ + pi_task_t *next_task = __ffc_drv_fifo_pop(itf_data); + if (next_task) + { + itf_data->end_task = next_task; + __pi_ffc_conversion_start(itf_data); + } +} + + +/******************************************************************************* + * API implementation + ******************************************************************************/ + +void pi_ffc_conf_init(pi_ffc_conf_t *conf) +{ + conf->itf = 0; + conf->mode = PI_FFC_FLOAT_TO_FIXED; + conf->io_mode = PI_FFC_MEMORY_IN_MEMORY_OUT; + conf->fixed_type = PI_FFC_FIXED_32; + conf->fixed_scale = 0; + conf->fixed_precision = 0; + conf->float_type = PI_FFC_FLOAT_FP32; +} + +int pi_ffc_open(pi_device_t *device) +{ + uint32_t irq = pi_irq_disable(); + pi_ffc_conf_t *conf = (pi_ffc_conf_t*) device->config; + pi_ffc_itf_data_t *itf_data = g_ffc_itf_data[conf->itf]; + + if (NULL == itf_data) + { + /* allocate itf data */ + itf_data = pi_fc_l1_malloc(sizeof(pi_ffc_itf_data_t)); + if (NULL == itf_data) + { + pi_irq_restore(irq); + return PI_ERR_NO_MEM; + } + g_ffc_itf_data[conf->itf] = itf_data; + + /* allocate 2 udma lin channels */ + /* set both of them to trigger event handler, io_mode will decide which + * one to use */ + int32_t tx_chan_id = pi_udma_core_lin_alloc(); + int32_t rx_chan_id = pi_udma_core_lin_alloc(); + if (rx_chan_id < 0 || tx_chan_id < 0) + { + pi_fc_l1_free(itf_data, sizeof(pi_ffc_itf_data_t)); + pi_irq_restore(irq); + return PI_FAIL; + } + itf_data->rx_chan_id = rx_chan_id; + itf_data->tx_chan_id = tx_chan_id; + + pi_fc_event_handler_set(SOC_EVENT_UDMA_CHAN_LIN(itf_data->rx_chan_id), + __pi_ffc_event_handler, itf_data); + pi_fc_event_handler_set(SOC_EVENT_UDMA_CHAN_LIN(itf_data->tx_chan_id), + __pi_ffc_event_handler, itf_data); + /* use rx as default */ + pi_soc_eu_fc_mask_set(SOC_EVENT_UDMA_CHAN_LIN(itf_data->rx_chan_id)); + + itf_data->nb_open = 1; + itf_data->device_id = conf->itf; + itf_data->fifo_head = NULL; + itf_data->fifo_tail = NULL; + itf_data->end_task = NULL; + itf_data->latest_conf = NULL; + + /* disable udma reset before setting regs */ + uint32_t periph_id = ARCHI_UDMA_FFC_ID(itf_data->device_id); + udma_ctrl_cfg_rstn_set_set(ARCHI_UDMA_ADDR, (1 << periph_id)); + udma_ctrl_cfg_cg_set_set(ARCHI_UDMA_ADDR, (1 << periph_id)); + } + else + { + itf_data->nb_open++; + } + + /* allocate device data */ + device->data = pi_fc_l1_malloc(sizeof(pi_ffc_data_t)); + if (NULL == device->data) + { + pi_irq_restore(irq); + return PI_ERR_L2_NO_MEM; + } + + /* initialize device data */ + pi_ffc_data_t* dev_data = (pi_ffc_data_t*) device->data; + dev_data->itf_data = itf_data; + dev_data->fixed_type = conf->fixed_type; + dev_data->fixed_scale = conf->fixed_scale; + dev_data->fixed_precision = conf->fixed_precision; + dev_data->float_type = conf->float_type; + dev_data->mode = conf->mode; + dev_data->io_mode = conf->io_mode; + dev_data->continuous_mode = 0; /* continuous mode disabled by default */ + + pi_irq_restore(irq); + return PI_OK; +} + +void pi_ffc_close(pi_device_t *device) +{ + uint32_t irq = pi_irq_disable(); + pi_ffc_data_t *dev_data = (pi_ffc_data_t*) device->data; + pi_ffc_itf_data_t* itf_data = dev_data->itf_data; + + /* decrement number of devices opened */ + itf_data->nb_open--; + + if (itf_data->nb_open == 0) + { + /* clear events, disable IRQs & free allocated udma channels */ + pi_udma_core_lin_reset(pi_udma_core_lin_addr_get(itf_data->rx_chan_id)); + pi_udma_core_lin_reset(pi_udma_core_lin_addr_get(itf_data->tx_chan_id)); + + pi_udma_core_lin_free(itf_data->rx_chan_id); + pi_udma_core_lin_free(itf_data->tx_chan_id); + + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->rx_chan_id)); + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_CHAN_LIN(itf_data->tx_chan_id)); + + uint32_t periph_id = ARCHI_UDMA_FFC_ID(itf_data->device_id); + udma_ctrl_cfg_rstn_clr_set(ARCHI_UDMA_ADDR, (1 << periph_id)); + udma_ctrl_cfg_cg_clr_set(ARCHI_UDMA_ADDR, (1 << periph_id)); + + /* free itf data */ + g_ffc_itf_data[itf_data->device_id] = NULL; + pi_fc_l1_free(itf_data, sizeof(pi_ffc_itf_data_t)); + } + /* free device data */ + pi_fc_l1_free(device->data, sizeof(pi_ffc_data_t)); + pi_irq_restore(irq); +} + +int32_t pi_ffc_ioctl(pi_device_t *device, uint32_t cmd, void *arg) +{ + uint32_t irq = pi_irq_disable(); + switch (cmd) + { + case PI_FFC_IOCTL_SET_IO_MODE: + { + pi_ffc_data_t *dev_data = (pi_ffc_data_t*) device->data; + dev_data->io_mode = (pi_ffc_io_mode_e)((uintptr_t) arg); + /* make last config invalid */ + dev_data->itf_data->latest_conf = NULL; + break; + } + + case PI_FFC_IOCTL_CONTINUOUS_ENABLE: + { + pi_ffc_data_t *dev_data = (pi_ffc_data_t*) device->data; + + uint8_t continuous_mode = (uint8_t)((uintptr_t) arg); + __pi_ffc_change_continuous_mode(dev_data, continuous_mode); + /* make last config invalid */ + dev_data->itf_data->latest_conf = NULL; + break; + } + + default: + pi_irq_restore(irq); + return PI_FAIL; + } + pi_irq_restore(irq); + return PI_OK; +} + +void pi_ffc_convert(pi_device_t *device, void* src, void* dst, uint16_t size) +{ + pi_task_t block; + pi_task_block(&block); + pi_ffc_convert_async(device, src, dst, size, &block); + pi_task_wait_on(&block); + pi_task_destroy(&block); +} + +void pi_ffc_convert_async(pi_device_t* device, void* src, void* dst, + uint16_t size, pi_task_t* task) +{ + uint32_t irq = pi_irq_disable(); + + pi_ffc_data_t *dev_data = (pi_ffc_data_t*) device->data; + task->data[0] = (uint32_t) src; + task->data[1] = (uint32_t) dst; + task->data[2] = (uint32_t) size; + task->data[3] = (uint32_t) dev_data; + + pi_ffc_itf_data_t *itf_data = dev_data->itf_data; + + /* if a request is in progress, enqueue this one */ + /* else, execute it */ + if (NULL == itf_data->end_task) + { + itf_data->end_task = task; + __pi_ffc_conversion_start(itf_data); + } + else + { + __ffc_drv_fifo_enqueue(itf_data, task); + } + + pi_irq_restore(irq); +} diff --git a/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_timeout.c b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_timeout.c new file mode 100644 index 000000000..88f7e780c --- /dev/null +++ b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_timeout.c @@ -0,0 +1,349 @@ +/* + * Copyright (c) 2021, GreenWaves Technologies, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * o Redistributions of source code must retain the above copyright notice, this list + * of conditions and the following disclaimer. + * + * o Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * o Neither the name of GreenWaves Technologies, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "pmsis.h" +#include "chips/gap9/drivers/udma/udma_timeout.h" + +/******************************************************************************* + * Definitions + ******************************************************************************/ + +#if !defined(__FREERTOS__) +#define UDMA_NB_TIMEOUT ( 8 ) +#endif /* __FREERTOS__ */ + +/******************************************************************************* + * Driver data + ******************************************************************************/ + +static struct pi_udma_timeout_s *g_udma_timeout[UDMA_NB_TIMEOUT]; + +/******************************************************************************* + * Function declaration + ******************************************************************************/ + +/* Event handler. */ +static void __pi_udma_timeout_event_handler(uint32_t event, void *arg); + +/* Enqueue task in SW fifo. */ +static inline void __pi_udma_timeout_task_push(struct pi_udma_timeout_s *driver_data, + pi_task_t *task); + +/* Pop task from SW fifo. */ +static inline pi_task_t *__pi_udma_timeout_task_pop(struct pi_udma_timeout_s *driver_data); + +/* Start a UDMA timer, when in SW trigger mode. */ +static void __pi_udma_timeout_start(uint8_t timeout_id); + +/* Stop a UDMA timer. */ +static void __pi_udma_timeout_stop(uint8_t timeout_id); + +/******************************************************************************* + * Internal functions + ******************************************************************************/ + +/** TIMEOUT_PRE Register. */ +static inline uint32_t __pi_udma_ctrl_timeout_prescaler_conf_get(uint8_t timeout_id) +{ + uint32_t reg_offset = (UDMA_CTRL_TIMEOUT_PRE0_OFFSET + (timeout_id << 3)); + uint32_t prescaler = GAP_READ((uint32_t) ARCHI_UDMA_ADDR, reg_offset); + return prescaler; +} + +static inline uint32_t __pi_udma_ctrl_timeout_prescaler_enabled(uint8_t timeout_id) +{ + uint32_t prescaler = __pi_udma_ctrl_timeout_prescaler_conf_get(timeout_id); + prescaler &= UDMA_CTRL_TIMEOUT_PRE0_EN_MASK; + prescaler >>= UDMA_CTRL_TIMEOUT_PRE0_EN_BIT; + return prescaler; +} + +static inline void __pi_udma_ctrl_timeout_prescaler_set(uint8_t timeout_id, + uint16_t presc_value, + uint8_t enable) +{ + uint32_t reg_offset = (UDMA_CTRL_TIMEOUT_PRE0_OFFSET + (timeout_id << 3)); + uint32_t prescaler = (UDMA_CTRL_TIMEOUT_PRE0_CNT(presc_value) | + UDMA_CTRL_TIMEOUT_PRE0_EN(enable)); + GAP_WRITE((uint32_t) ARCHI_UDMA_ADDR, reg_offset, prescaler); +} + +static inline void __pi_udma_ctrl_timeout_prescaler_reset(uint8_t timeout_id) +{ + uint32_t reg_offset = (UDMA_CTRL_TIMEOUT_PRE0_OFFSET + (timeout_id << 3)); + udma_ctrl_timeout_pre0_t prescaler = {0}; + prescaler.raw = GAP_READ((uint32_t) ARCHI_UDMA_ADDR, reg_offset); + prescaler.clr = 1; + GAP_WRITE((uint32_t) ARCHI_UDMA_ADDR, reg_offset, prescaler.raw); +} + +static inline void __pi_udma_ctrl_timeout_prescaler_start(uint8_t timeout_id) +{ + uint32_t reg_offset = (UDMA_CTRL_TIMEOUT_PRE0_OFFSET + (timeout_id << 3)); + udma_ctrl_timeout_pre0_t prescaler = {0}; + prescaler.raw = GAP_READ((uint32_t) ARCHI_UDMA_ADDR, reg_offset); + prescaler.en = 1; + GAP_WRITE((uint32_t) ARCHI_UDMA_ADDR, reg_offset, prescaler.raw); +} + +static inline void __pi_udma_ctrl_timeout_prescaler_stop(uint8_t timeout_id) +{ + uint32_t reg_offset = (UDMA_CTRL_TIMEOUT_PRE0_OFFSET + (timeout_id << 3)); + udma_ctrl_timeout_pre0_t prescaler = {0}; + prescaler.raw = GAP_READ((uint32_t) ARCHI_UDMA_ADDR, reg_offset); + prescaler.en = 0; + GAP_WRITE((uint32_t) ARCHI_UDMA_ADDR, reg_offset, prescaler.raw); +} + + +/** TIMEOUT_CHX Register. */ +static inline uint32_t __pi_udma_ctrl_timeout_timeout_get(uint8_t timeout_id) +{ + uint32_t reg_offset = (UDMA_CTRL_TIMEOUT_CH0_OFFSET + (timeout_id << 3)); + uint32_t timeout = GAP_READ((uint32_t) ARCHI_UDMA_ADDR, reg_offset); + return timeout; +} + +static inline void __pi_udma_ctrl_timeout_timeout_set(uint8_t timeout_id, + uint8_t udma_chan_id, + uint8_t mode, + uint16_t timeout_val, + uint8_t enable) +{ + uint32_t reg_offset = (UDMA_CTRL_TIMEOUT_CH0_OFFSET + (timeout_id << 3)); + uint32_t timeout = (UDMA_CTRL_TIMEOUT_CH0_SOURCE_ID(udma_chan_id) | + UDMA_CTRL_TIMEOUT_CH0_MODE(mode) | + UDMA_CTRL_TIMEOUT_CH0_EN(enable) | + UDMA_CTRL_TIMEOUT_CH0_CNT(timeout_val)); + GAP_WRITE((uint32_t) ARCHI_UDMA_ADDR, reg_offset, timeout); + +} +static inline void __pi_udma_ctrl_timeout_mode_set(uint8_t timeout_id, uint8_t mode) +{ + uint32_t reg_offset = (UDMA_CTRL_TIMEOUT_CH0_OFFSET + (timeout_id << 3)); + udma_ctrl_timeout_ch0_t timeout = {0}; + timeout.raw = GAP_READ((uint32_t) ARCHI_UDMA_ADDR, reg_offset); + timeout.mode = mode; + GAP_WRITE((uint32_t) ARCHI_UDMA_ADDR, reg_offset, timeout.raw); +} + +static inline void __pi_udma_ctrl_timeout_timeout_start(uint8_t timeout_id) +{ + uint32_t reg_offset = (UDMA_CTRL_TIMEOUT_CH0_OFFSET + (timeout_id << 3)); + udma_ctrl_timeout_ch0_t timeout = {0}; + timeout.raw = GAP_READ((uint32_t) ARCHI_UDMA_ADDR, reg_offset); + timeout.en = 1; + GAP_WRITE((uint32_t) ARCHI_UDMA_ADDR, reg_offset, timeout.raw); +} + +static inline void __pi_udma_ctrl_timeout_timeout_stop(uint8_t timeout_id) +{ + uint32_t reg_offset = (UDMA_CTRL_TIMEOUT_CH0_OFFSET + (timeout_id << 3)); + udma_ctrl_timeout_ch0_t timeout = {0}; + timeout.raw = GAP_READ((uint32_t) ARCHI_UDMA_ADDR, reg_offset); + timeout.en = 0; + GAP_WRITE((uint32_t) ARCHI_UDMA_ADDR, reg_offset, timeout.raw); +} + + +static void __pi_udma_timeout_event_handler(uint32_t event, void *arg) +{ + uint32_t timeout_id = (uint32_t) arg; + //TIMEOUT_TRACE("Timeout id=%ld event\n", timeout_id); + struct pi_udma_timeout_s *driver_data = g_udma_timeout[timeout_id]; + struct pi_task *task = __pi_udma_timeout_task_pop(driver_data); + __pi_udma_timeout_stop(timeout_id); + if (task != NULL) + { + //TIMEOUT_TRACE("Handle task=%lx\n", task); + //printf("Handle task=%lx, arg=%lx\n", task, task->arg[3]); + /* Timeout reached, abort transfer. */ + pi_callback_func_t func = (pi_callback_func_t) task->arg[2]; + func((void *) task->arg[3]); + + /* Set transfer end result. */ + task->arg[2] = -1; + + /* Release event task. */ + pi_task_push(task); + } +} + +static inline void __pi_udma_timeout_task_push(struct pi_udma_timeout_s *driver_data, + pi_task_t *task) +{ + uint32_t irq = disable_irq(); + if ((driver_data->fifo_head == NULL) || (driver_data->fifo_head == (void *) 0xFFFFFFFF)) + { + driver_data->fifo_head = task; + } + else + { + driver_data->fifo_tail->next = task; + } + driver_data->fifo_tail = task; + restore_irq(irq); +} + +static inline pi_task_t *__pi_udma_timeout_task_pop(struct pi_udma_timeout_s *driver_data) +{ + pi_task_t *task_return = NULL; + if (driver_data->fifo_head != NULL) + { + task_return = driver_data->fifo_head; + driver_data->fifo_head = driver_data->fifo_head->next; + } + return task_return; +} + +static void __pi_udma_timeout_start(uint8_t timeout_id) +{ + __pi_udma_ctrl_timeout_prescaler_stop(timeout_id); + __pi_udma_ctrl_timeout_prescaler_reset(timeout_id); + __pi_udma_ctrl_timeout_timeout_start(timeout_id); + __pi_udma_ctrl_timeout_prescaler_start(timeout_id); +} + +static void __pi_udma_timeout_stop(uint8_t timeout_id) +{ + __pi_udma_ctrl_timeout_prescaler_stop(timeout_id); + __pi_udma_ctrl_timeout_timeout_stop(timeout_id); +} + +int32_t pi_udma_timeout_config_set(pi_task_t *task, uint8_t timeout_id, + uint8_t udma_chan_id, uint32_t timeout_us) +{ + int32_t status = 0; + /* Fast clock used by timeout. */ + float periph_freq = (float) ARCHI_FLL_REF_CLOCK; /* 24MHz. */ + float nb_tick_us = periph_freq / 1000000.0; + float timeout_val = ((float) timeout_us) * nb_tick_us; + uint16_t prescaler = 0; + TIMEOUT_TRACE("Timeout_%d : configure udma_chan=%d, timeout_us=%ld, task=%lx\n", + timeout_id, udma_chan_id, timeout_us, task); + TIMEOUT_TRACE("Periph_freq=%f, timeout_us=%ld, nb_tick_us=%f, timeout_val=%f\n", + periph_freq, timeout_us, nb_tick_us, timeout_val); + prescaler = (timeout_val > 0xFFFF); + while (timeout_val > 0xFFFF) + { + prescaler <<= 1; + timeout_val /= 2; + } + if (__pi_udma_ctrl_timeout_prescaler_enabled(timeout_id)) + { + /* Timeout already in use. */ + TIMEOUT_TRACE_ERR("Timeout id=%ld already in use\n", timeout_id); + return -11; + } + + __pi_udma_timeout_task_push(g_udma_timeout[timeout_id], task); + + uint32_t mode = g_udma_timeout[timeout_id]->mode; + uint8_t enable = (mode != PI_UDMA_TIMEOUT_MODE_SW_TRIGGER); + TIMEOUT_TRACE("Timeout_%d : mode=%d, prescaler=%d, timeout=%f, enable=%d\n", + timeout_id, mode, prescaler, timeout_val, enable); + __pi_udma_ctrl_timeout_prescaler_set(timeout_id, prescaler, enable); + __pi_udma_ctrl_timeout_timeout_set(timeout_id, udma_chan_id, mode, + (uint16_t) timeout_val, enable); + __pi_udma_ctrl_timeout_prescaler_reset(timeout_id); + return status; +} + +pi_task_t *__pi_udma_timeout_task_remove(uint8_t timeout_id) +{ + return __pi_udma_timeout_task_pop(g_udma_timeout[timeout_id]); +} + +/******************************************************************************* + * API implementation + ******************************************************************************/ + +int32_t pi_udma_timeout_alloc(pi_udma_timeout_mode_e mode) +{ + int32_t timeout_id = -1; + for (uint32_t tid = 0; tid < (uint32_t) UDMA_NB_TIMEOUT; tid++) + { + if ((g_udma_timeout[tid] == NULL) || (g_udma_timeout[tid]->fifo_head == NULL)) + { + /* Alloc UDMA timeout struct. */ + g_udma_timeout[tid] = pi_fc_l1_malloc(sizeof(struct pi_udma_timeout_s)); + if (g_udma_timeout[tid] == NULL) + { + TIMEOUT_TRACE_ERR("Timeout struct alloc failed !\n"); + timeout_id = -11; + break; + } + g_udma_timeout[tid]->fifo_head = (void *) 0xFFFFFFFF; + g_udma_timeout[tid]->mode = mode; + /* Set FC event handler. */ + pi_fc_event_handler_set(SOC_EVENT_UDMA_TIMEOUT(tid), + __pi_udma_timeout_event_handler, + (void *) tid); + /* Enable SoC events propagation to FC. */ + pi_soc_eu_fc_mask_set(SOC_EVENT_UDMA_TIMEOUT(tid)); + timeout_id = tid; + TIMEOUT_TRACE("Timeout id=%ld allocated\n", timeout_id); + break; + } + } + return timeout_id; +} + +void pi_udma_timeout_free(int32_t timeout_id) +{ + TIMEOUT_TRACE("Timeout_%ld : free timeout.\n", timeout_id); + g_udma_timeout[timeout_id]->fifo_head = NULL; + /* Free UDMA timeout struct. */ + pi_fc_l1_free(g_udma_timeout[timeout_id], sizeof(struct pi_udma_timeout_s)); + /* Clear FC event handler. */ + pi_fc_event_handler_clear(SOC_EVENT_UDMA_TIMEOUT(timeout_id)); + /* Disable SoC events propagation. */ + pi_soc_eu_fc_mask_clear(SOC_EVENT_UDMA_TIMEOUT(timeout_id)); +} + +int32_t pi_udma_timeout_ioctl(int32_t timeout_id, uint32_t cmd, void *arg) +{ + TIMEOUT_TRACE("Timeout_%ld : ioctl cmd=%ld, arg=%lx\n", timeout_id, cmd, arg); + int32_t status = 0; + switch (cmd) + { + case PI_UDMA_TIMEOUT_IOCTL_START : + __pi_udma_timeout_start(timeout_id); + break; + + case PI_UDMA_TIMEOUT_IOCTL_STOP : + __pi_udma_timeout_stop(timeout_id); + break; + + default : + status = -1; + } + return status; +} diff --git a/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_timestamp.c b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_timestamp.c new file mode 100644 index 000000000..dbe04185c --- /dev/null +++ b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_timestamp.c @@ -0,0 +1,399 @@ +/* + * Copyright (c) 2020, GreenWaves Technologies, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * o Redistributions of source code must retain the above copyright notice, this list + * of conditions and the following disclaimer. + * + * o Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * o Neither the name of GreenWaves Technologies, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "pmsis.h" +#include "udma_timestamp.h" + +/******************************************************************************* + * Definitions + ******************************************************************************/ + +#if !defined(__FREERTOS__) +#define UDMA_TIMESTAMP_ID(id) ( ARCHI_UDMA_TS_ID((id)) ) +#define UDMA_TIMESTAMP(id) ( UDMA_TS_ADDR((id)) ) +#define UDMA_NB_TIMESTAMP ( ARCHI_UDMA_NB_TS ) +#define TIMESTAMP_TRACE(...) ( (void) 0 ) +#define TIMESTAMP_TRACE_ERR(...) ( (void) 0 ) +#endif /* __FREERTOS__ */ + +/******************************************************************************* + * Driver data + ******************************************************************************/ + +static struct pi_udma_timestamp_cnt_t timestamp_cnt[UDMA_NB_TIMESTAMP]; +static struct pi_udma_ts_evt_t ts_evt[UDMA_NB_TIMESTAMP_EVT]; +static struct pi_udma_ts_input_t ts_input[UDMA_NB_TIMESTAMP_INPUT]; +static uint8_t evt_mask = 0xF; +static uint8_t input_mask = 0xFF; + +/******************************************************************************* + * Function declaration + ******************************************************************************/ + +/******************************************************************************* + * Internal functions + ******************************************************************************/ + +static void __pi_udma_timestamp_cnt_clr(uint32_t base) +{ + udma_timestamp_reg_cmd_cnt_clr_set(base, 1); +} + +static void __pi_udma_timestamp_cnt_stop(uint32_t base) +{ + udma_timestamp_reg_cmd_cnt_stop_set(base, 1); +} + +static void __pi_udma_timestamp_cnt_close(struct pi_udma_timestamp_cnt_t *ts) +{ + /* Stop the timestamp counter */ + __pi_udma_timestamp_cnt_stop(ts->base); + + ts->cnt_en = 0; + + if (ts->cnt_trig_gpio != 0xFF) + { + udma_timestamp_reg_setup_cnt_ext_sel_set(ts->base, 0); + udma_timestamp_reg_setup_cnt_ext_type_set(ts->base, 0); + udma_timestamp_reg_setup_cnt_ext_en_set(ts->base, 0); + } + + udma_timestamp_reg_clk_cfg_clk_mux_set(ts->base, 0); + udma_timestamp_reg_clk_cfg_gpio_sel_set(ts->base, 0); + udma_timestamp_reg_clk_cfg_pwm_sel_set(ts->base, 0); + udma_timestamp_reg_clk_cfg_prescaler_set(ts->base, 0); + udma_timestamp_reg_clk_cfg_clk_mux_en_set(ts->base, 0); + + //TODO: clean the ts + //memset(ts,0,sizeof(struct pi_udma_timestamp_cnt_t)); +} + +static void __pi_udma_evt_cfg_init(void) +{ + uint32_t base = ARCHI_UDMA_ADDR; + // Init all the cfg event in udma ctrl to 0xFF + udma_ctrl_cfg_event_cmp_evt0_set(base, 0xFF); + udma_ctrl_cfg_event_cmp_evt1_set(base, 0xFF); + udma_ctrl_cfg_event_cmp_evt2_set(base, 0xFF); + udma_ctrl_cfg_event_cmp_evt3_set(base, 0xFF); +} + + +static int __pi_udma_timestamp_evt_alloc(uint32_t ts_base, pi_timestamp_event_t * evt) +{ + uint8_t src_id = 0; + if(evt_mask) + { + src_id = __builtin_pulp_fl1((evt_mask)); + evt->ts_evt_id = src_id; + evt_mask &= ~(1<ts_evt_id].dest_id = evt->dest_id; + + switch (evt->ts_evt_id) + { + case 0: + udma_timestamp_reg_event_dest_id_evt_0_set(ts_base, evt->dest_id); + break; + case 1: + udma_timestamp_reg_event_dest_id_evt_1_set(ts_base, evt->dest_id); + break; + case 2: + udma_timestamp_reg_event_dest_id_evt_2_set(ts_base, evt->dest_id); + break; + case 3: + udma_timestamp_reg_event_dest_id_evt_3_set(ts_base, evt->dest_id); + break; + default: + TIMESTAMP_TRACE_ERR("Unknown timestamp event numbe= %d\n", evt->ts_evt_id); + break; + } + return 0; +} + +static int __pi_udma_timestamp_input_set(uint32_t base, pi_timestamp_input_t * input) +{ + + uint8_t src_id = 0; + if(input_mask) + { + src_id = __builtin_pulp_fl1((input_mask)); + ts_input[src_id].ts_input_id = src_id; + ts_input[src_id].dest_id = input->dest_id; + ts_input[src_id].input_sel = input->input_sel; + ts_input[src_id].input_type = input->input_type; + input->ts_input_id = src_id; + input_mask &= ~(1<input_sel >> 6) + { + TIMESTAMP_TRACE_ERR("GPIO ID bigger than 63\n"); + return -1; + } + else + { + switch (input->ts_input_id) + { + case 0: + udma_timestamp_reg_setup_ch0_input_sel_set(base, input->input_sel); + udma_timestamp_reg_setup_ch0_input_type_set(base, input->input_type); + udma_timestamp_reg_setup_ch0_input_en_set(base, 1); + udma_timestamp_reg_setup_ch0_dest_id_set(base, input->dest_id); + break; + case 1: + udma_timestamp_reg_setup_ch1_input_sel_set(base, input->input_sel); + udma_timestamp_reg_setup_ch1_input_type_set(base, input->input_type); + udma_timestamp_reg_setup_ch1_input_en_set(base, 1); + udma_timestamp_reg_setup_ch1_dest_id_set(base, input->dest_id); + break; + case 2: + udma_timestamp_reg_setup_ch2_input_sel_set(base, input->input_sel); + udma_timestamp_reg_setup_ch2_input_type_set(base, input->input_type); + udma_timestamp_reg_setup_ch2_input_en_set(base, 1); + udma_timestamp_reg_setup_ch2_dest_id_set(base, input->dest_id); + break; + case 3: + udma_timestamp_reg_setup_ch3_input_sel_set(base, input->input_sel); + udma_timestamp_reg_setup_ch3_input_type_set(base, input->input_type); + udma_timestamp_reg_setup_ch3_input_en_set(base, 1); + udma_timestamp_reg_setup_ch3_dest_id_set(base, input->dest_id); + break; + case 4: + udma_timestamp_reg_setup_ch4_input_sel_set(base, input->input_sel); + udma_timestamp_reg_setup_ch4_input_type_set(base, input->input_type); + udma_timestamp_reg_setup_ch4_input_en_set(base, 1); + udma_timestamp_reg_setup_ch4_dest_id_set(base, input->dest_id); + break; + case 5: + udma_timestamp_reg_setup_ch5_input_sel_set(base, input->input_sel); + udma_timestamp_reg_setup_ch5_input_type_set(base, input->input_type); + udma_timestamp_reg_setup_ch5_input_en_set(base, 1); + udma_timestamp_reg_setup_ch5_dest_id_set(base, input->dest_id); + break; + case 6: + udma_timestamp_reg_setup_ch6_input_sel_set(base, input->input_sel); + udma_timestamp_reg_setup_ch6_input_type_set(base, input->input_type); + udma_timestamp_reg_setup_ch6_input_en_set(base, 1); + udma_timestamp_reg_setup_ch6_dest_id_set(base, input->dest_id); + break; + case 7: + udma_timestamp_reg_setup_ch7_input_sel_set(base, input->input_sel); + udma_timestamp_reg_setup_ch7_input_type_set(base, input->input_type); + udma_timestamp_reg_setup_ch7_input_en_set(base, 1); + udma_timestamp_reg_setup_ch7_dest_id_set(base, input->dest_id); + break; + + default: + break; + } + + } + return 0; +} + +/******************************************************************************* + * API implementation + ******************************************************************************/ + +void pi_timestamp_conf_init(struct pi_timestamp_conf *conf) +{ + conf->itf = 0; + conf->cnt_trig_gpio = 0xFF; + conf->cnt_trig_type = PI_TIMESTAMP_AUX_INPUT; + conf->cnt_src = PI_TIMESTAMP_CNT_REF_CLK_QUICK; + conf->cnt_src_id = 0xFF; + conf->prescaler = 0; +} + +void pi_udma_timestamp_open(struct pi_device * device) +{ + uint32_t irq = pi_irq_disable(); + struct pi_timestamp_conf *conf = (struct pi_timestamp_conf *) device -> config; + struct pi_udma_timestamp_cnt_t *ts = ×tamp_cnt[conf->itf]; + + device->data = (void *)ts; + + if (ts->cnt_en) + { + TIMESTAMP_TRACE("Timestamp counter already set, ignore this counter init"); + } + else + { + ts->base = UDMA_TIMESTAMP(conf->itf); + /* Disable UDMA CG and reset periph. */ + uint32_t periph_id = UDMA_TIMESTAMP_ID(conf->itf); + udma_ctrl_cfg_rstn_set_set(ARCHI_UDMA_ADDR, (1 << periph_id)); + udma_ctrl_cfg_cg_set_set(ARCHI_UDMA_ADDR, (1 << periph_id)); + + if (conf->cnt_trig_gpio != 0xFF) + { + udma_timestamp_reg_setup_cnt_ext_sel_set(ts->base, conf->cnt_trig_gpio); + udma_timestamp_reg_setup_cnt_ext_type_set(ts->base, conf->cnt_trig_type); + udma_timestamp_reg_setup_cnt_ext_en_set(ts->base, 1); + } + + if (conf->cnt_src != PI_TIMESTAMP_CNT_SOC_CLK) + { + udma_timestamp_reg_clk_cfg_clk_mux_set(ts->base, conf->cnt_src); + if (conf->cnt_src == PI_TIMESTAMP_CNT_GPIO) + { + udma_timestamp_reg_clk_cfg_gpio_sel_set(ts->base, conf->cnt_src_id); + } + else if(conf->cnt_src == PI_TIMESTAMP_CNT_PWM) + { + udma_timestamp_reg_clk_cfg_pwm_sel_set(ts->base, conf->cnt_src_id); + } + udma_timestamp_reg_clk_cfg_clk_mux_en_set(ts->base, 1); + + } + + if (conf->prescaler) + { + udma_timestamp_reg_clk_cfg_prescaler_set(ts->base, conf->prescaler); + } + + ts->device_id = conf->itf; + ts->cnt_trig_gpio = conf->cnt_trig_gpio; + ts->cnt_trig_type = conf->cnt_trig_type; + ts->cnt_src = conf->cnt_src; + ts->cnt_src_id = conf->cnt_src_id; + ts->prescaler = conf->prescaler; + ts->cnt_en = 1; + + /* Set all the event to 0xFF */ + __pi_udma_evt_cfg_init(); + } + pi_irq_restore(irq); +} + +void pi_udma_timestamp_close(struct pi_device *device) +{ + uint32_t irq = pi_irq_disable(); + struct pi_udma_timestamp_cnt_t *ts = (struct pi_udma_timestamp_cnt_t *) device->data; + + __pi_udma_timestamp_cnt_close(ts); + + /* Set all the event to 0xFF */ + __pi_udma_evt_cfg_init(); + + /* Enable UDMA CG and reset periph. */ + uint32_t periph_id = UDMA_TIMESTAMP_ID(ts->device_id); + udma_ctrl_cfg_rstn_clr_set(ARCHI_UDMA_ADDR, (1 << periph_id)); + udma_ctrl_cfg_cg_clr_set(ARCHI_UDMA_ADDR, (1 << periph_id)); + + /* Free all the udma timestamp allocated. */ + //TODO: clean all the event and input + /* + for (uint32_t tid = 0; tid < (uint32_t) UDMA_NB_TIMESTAMP_EVT; tid++) + { + if(ts_evt[tid].soc_evt) + soc_eu_prEventMask_setEvent(ts_evt[tid].soc_evt); + } + */ + + evt_mask = 0xF; + input_mask = 0xFF; + pi_irq_restore(irq); +} + + +int32_t pi_udma_timestamp_ioctl(struct pi_device *device, uint32_t cmd, void *arg) +{ + uint32_t irq = pi_irq_disable(); + struct pi_udma_timestamp_cnt_t *ts = (struct pi_udma_timestamp_cnt_t *) device->data; + int32_t status = 0; + int src_id = 0; + + switch (cmd) + { + case PI_UDMA_TIMESTAMP_IOCTL_CLR : + __pi_udma_timestamp_cnt_clr(ts->base); + break; + + case PI_UDMA_TIMESTAMP_IOCTL_STOP : + __pi_udma_timestamp_cnt_stop(ts->base); + break; + + case PI_UDMA_TIMESTAMP_IOCTL_EVT_ALLOC: + __pi_udma_timestamp_evt_alloc(ts->base, arg); + break; + + case PI_UDMA_TIMESTAMP_IOCTL_SET_EVT : + status = __pi_udma_timestamp_evt_cfg(ts->base, arg); + break; + + case PI_UDMA_TIMESTAMP_IOCTL_SET_INPUT : + status = __pi_udma_timestamp_input_set(ts->base, arg); + break; + + // TODO: complete these cases + case PI_UDMA_TIMESTAMP_IOCTL_FREE_EVT : + break; + + case PI_UDMA_TIMESTAMP_IOCTL_FREE_INPUT : + break; + + default : + TIMESTAMP_TRACE_ERR("Unknown timestamp command, cmd=%ld\n", cmd); + } + pi_irq_restore(irq); + return status; +} + +/** Not in PMSIS_API. */ +#if 0 +void pi_udma_timestamp_read_async(unsigned char src_type, unsigned char ts_id, + void *buffer, int32_t size, pi_task_t *task) +{ + pos_udma_channel_t *channel = src_type? &ts_evt[ts_id].channel : &ts_input[ts_id].channel; + + uint32_t irq = pi_irq_disable(); + pos_udma_enqueue(channel, task, (int)buffer, size); + pi_irq_restore(irq); +} +#endif /* 0 */ diff --git a/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_timestamp.h b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_timestamp.h new file mode 100644 index 000000000..395a9def4 --- /dev/null +++ b/rtos/pmsis/pmsis_implem/chips/gap9/drivers/udma/udma_timestamp.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2020, GreenWaves Technologies, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * o Redistributions of source code must retain the above copyright notice, this list + * of conditions and the following disclaimer. + * + * o Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * o Neither the name of GreenWaves Technologies, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + + +/******************************************************************************* + * Definitions + ******************************************************************************/ + +#define UDMA_NB_TIMESTAMP_EVT (4) +#define UDMA_NB_TIMESTAMP_INPUT (8) + +struct pi_udma_timestamp_cnt_t +{ + uint32_t base; /*!< base addr of TS */ + uint8_t device_id; /*!< device ID for timestamp */ + uint8_t cnt_trig_gpio; /*!< gpio number for trigger the timestamp cnter */ + uint8_t cnt_trig_type; /*!< how the gpio trigger the timestamp counter */ + uint8_t cnt_src; /*!< timestamp counter source */ + uint8_t cnt_src_id; /*!< GPIO/PWM number depends on the counter source */ + uint8_t prescaler; /*!< Prescaler for timestamp counter */ + uint8_t cnt_en; /*!< If the counter is enabled */ +}; + +struct pi_udma_ts_evt_t +{ + uint8_t dest_id; /*!< fifo ID for timestamp */ + uint8_t soc_evt; /*!< soc event ID which should be propagated to periph */ + uint8_t ts_evt_id; /*!< The udma cfg evt number */ +}; + +struct pi_udma_ts_input_t +{ + uint8_t dest_id; + uint8_t ts_input_id; /*!< Timestamp input ID, max 8 input. Reg0-7 */ + uint8_t input_sel; /*!< Timestamp input selction: + if input_type=3, then 0-7 are SFU, 8-10 are SAI. + Else input sel are GPIO 0-63 */ + uint8_t input_type; /*!< Timestamp input GPIO trigger or input from AUX */ +}; + +/******************************************************************************* + * Driver data + ******************************************************************************/ + +/******************************************************************************* + * Function declaration + ******************************************************************************/ diff --git a/rtos/pmsis/pmsis_implem/include/chips/gap9/drivers/i2s/i2s.h b/rtos/pmsis/pmsis_implem/include/chips/gap9/drivers/i2s/i2s.h new file mode 100644 index 000000000..95efda427 --- /dev/null +++ b/rtos/pmsis/pmsis_implem/include/chips/gap9/drivers/i2s/i2s.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2019 GreenWaves Technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Authors: Germain Haugou, GreenWaves Technologies (germain.haugou@greenwaves-technologies.com) + */ + +#pragma once + +static inline int pi_i2s_frame_read(struct pi_device *dev, uint32_t frame, void **mem_block, size_t *size) +{ + return pi_i2s_channel_read(dev, __FF1(frame), mem_block, size); +} + +static inline int pi_i2s_frame_read_async(struct pi_device *dev, uint32_t frame, pi_task_t *task) +{ + return pi_i2s_channel_read_async(dev, __FF1(frame), task); +} + +int __pi_i2s_channel_conf_set(struct pi_device *device, uint32_t frame, int slot_id, struct pi_i2s_channel_conf *conf); + +static inline int pi_i2s_channel_conf_set(struct pi_device *dev, int channel, struct pi_i2s_channel_conf *conf) +{ + return __pi_i2s_channel_conf_set(dev, 0, channel, conf); +} + +static inline int pi_i2s_frame_channel_conf_set(struct pi_device *dev, uint32_t frame, int channel, struct pi_i2s_channel_conf *conf) +{ + return __pi_i2s_channel_conf_set(dev, frame, channel, conf); +} diff --git a/rtos/pmsis/pmsis_implem/include/chips/gap9/drivers/udma/udma_core.h b/rtos/pmsis/pmsis_implem/include/chips/gap9/drivers/udma/udma_core.h new file mode 100644 index 000000000..bb11d8454 --- /dev/null +++ b/rtos/pmsis/pmsis_implem/include/chips/gap9/drivers/udma/udma_core.h @@ -0,0 +1,290 @@ +/* + * Copyright (c) 2021, GreenWaves Technologies, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * o Redistributions of source code must retain the above copyright notice, this list + * of conditions and the following disclaimer. + * + * o Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * o Neither the name of GreenWaves Technologies, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + + +/******************************************************************************* + * Definitions + ******************************************************************************/ + +#if !defined(__FREERTOS__) +#define UDMA_NB_CHAN_LIN ( ARCHI_UDMA_NB_LIN_ADDRGEN ) +#define UDMA_NB_CHAN_2D ( ARCHI_UDMA_NB_2D_ADDRGEN ) +#define UDMA_NB_CHAN_FIFO ( ARCHI_UDMA_NB_FIFO_ADDRGEN ) +#define UDMA_CHAN_LIN(id) ( UDMA_LIN_ADDRGEN_ADDR((id)) ) +#define UDMA_CHAN_2D(id) ( 0x1A103800 + 0x20 * id ) +#define UDMA_CHAN_FIFO(id) ( 0x1A103900 + 0x20 * id ) +#define UDMA_CHAN_LIN_ID(id) ( (id) ) +#define UDMA_CHAN_2D_ID(id) ( ARCHI_UDMA_NB_LIN_ADDRGEN + (id) ) +#define UDMA_CHAN_FIFO_ID(id) ( ARCHI_UDMA_NB_LIN_ADDRGEN + ARCHI_UDMA_NB_2D_ADDRGEN + (id) ) +#define SOC_EVENT_UDMA_CHAN_LIN(id) ( (id) ) +#endif /* __FREERTOS__ */ + + +#define __PI_NB_UDMA_CHAN_PER_REG ( 32 ) +#define __PI_NB_UDMA_CHAN_PER_REG_LOG2 ( 5 ) +#define PI_NB_UDMA_CHAN_LIN ( UDMA_NB_CHAN_LIN ) +#define PI_NB_UDMA_CHAN_LIN_REGS ( (PI_NB_UDMA_CHAN_LIN + (__PI_NB_UDMA_CHAN_PER_REG - 1)) >> __PI_NB_UDMA_CHAN_PER_REG_LOG2 ) + +/******************************************************************************* + * Driver data + ******************************************************************************/ + +extern PI_FC_TINY uint32_t __pi_udma_chan_lin[]; +extern PI_FC_TINY uint32_t __pi_udma_chan_2d; +extern PI_FC_TINY uint32_t __pi_udma_chan_fifo; + +/******************************************************************************* + * Function implementation + ******************************************************************************/ + +static inline void pi_udma_core_channels_init(void) +{ + uint32_t mask = 0; + /* UDMA_CHAN_LIN */ + uint32_t nb_udma_lin = (uint32_t) UDMA_NB_CHAN_LIN; + for (uint32_t reg=0; reg<(uint32_t) PI_NB_UDMA_CHAN_LIN_REGS; reg++) + { + uint32_t shift = nb_udma_lin > 32 ? 32 : nb_udma_lin; + mask = (1ULL << shift) - 1; + __pi_udma_chan_lin[reg] = mask; + nb_udma_lin -= 32; + } + __pi_udma_chan_lin[0] = __BITCLR_R(__pi_udma_chan_lin[0], 1, 0); /* Reserved. */ + /* UDMA_CHAN_2D */ + uint32_t nb_udma_2d = (uint32_t) UDMA_NB_CHAN_2D; + mask = (1 << nb_udma_2d) - 1; + __pi_udma_chan_2d = mask; + __pi_udma_chan_2d = __BITCLR_R(__pi_udma_chan_2d, 1, 0); /* Reserved. */ + + /* UDMA_CHAN_FIFO */ + uint32_t nb_udma_fifo = (uint32_t) UDMA_NB_CHAN_FIFO; + mask = (1 << nb_udma_fifo) - 1; + __pi_udma_chan_fifo = mask; +} + +/** + * UDMA_CHANNEL_LINEAR + */ +static inline int32_t pi_udma_core_lin_alloc(void) +{ + int32_t chan_id = -1; + uint32_t reg_status = 0; + for (uint32_t reg=0; reg<(uint32_t) PI_NB_UDMA_CHAN_LIN_REGS; reg++) + { + reg_status = __pi_udma_chan_lin[reg]; + if (0x0 != reg_status) + { + chan_id = __FF1(reg_status); + __pi_udma_chan_lin[reg] = __BITCLR_R(reg_status, 1, chan_id); + return (chan_id + (reg << __PI_NB_UDMA_CHAN_PER_REG_LOG2)); + } + } + return chan_id; +} + +static inline void pi_udma_core_lin_free(int32_t chan_id) +{ + if (-1 != chan_id) + { + uint32_t chan_reg = (chan_id >> __PI_NB_UDMA_CHAN_PER_REG_LOG2); + uint32_t chan_pos = (chan_id & 0x1F); + __pi_udma_chan_lin[chan_reg] = __BITSET_R(__pi_udma_chan_lin[chan_reg], 1, chan_pos); + } +} + +static inline uint32_t pi_udma_core_lin_addr_get(int32_t chan_id) +{ + return UDMA_CHAN_LIN(chan_id); +} + +static inline void pi_udma_core_lin_enqueue(uint32_t udma_core_base, + uint32_t buf, + uint32_t size, uint32_t config) +{ + config |= UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_EN(1); + udma_core_lin_addrgen_cfg_sa_buf0_set(udma_core_base, buf); + udma_core_lin_addrgen_cfg_size_set(udma_core_base, size); + udma_core_lin_addrgen_cfg_ctrl_set(udma_core_base, config); +} + +static inline void pi_udma_core_lin_stop(uint32_t udma_core_base) +{ + uint32_t config = UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_STOP(1); + udma_core_lin_addrgen_cfg_ctrl_set(udma_core_base, config); +} + +static inline void pi_udma_core_lin_reset(uint32_t udma_core_base) +{ + uint32_t config = UDMA_CORE_LIN_ADDRGEN_CFG_CTRL_STOP(1); + /* udma_core_lin_addrgen_cfg_sa_buf0_set(udma_core_base, 0); */ + /* udma_core_lin_addrgen_cfg_sa_buf1_set(udma_core_base, 0); */ + /* udma_core_lin_addrgen_cfg_size_set(udma_core_base, 0); */ + udma_core_lin_addrgen_cfg_ctrl_set(udma_core_base, config); +} + +static inline uint32_t pi_udma_core_lin_curr_addr_get(uint32_t udma_core_base) +{ + return udma_core_lin_addrgen_cfg_curr_addr_get(udma_core_base); +} + +static inline uint32_t pi_udma_core_lin_bytes_left_get(uint32_t udma_core_base) +{ + return udma_core_lin_addrgen_cfg_bytes_left_get(udma_core_base); +} + + + +/** + * UDMA_CHANNEL_2D + */ +static inline int32_t pi_udma_core_2d_alloc(void) +{ + int32_t chan_id = -1; + if (0x0 != __pi_udma_chan_2d) + { + chan_id = __FF1(__pi_udma_chan_2d); + __pi_udma_chan_2d = __BITCLR_R(__pi_udma_chan_2d, 1, chan_id); + return (chan_id + UDMA_CHAN_2D_ID(0)); + } + return chan_id; +} + +static inline void pi_udma_core_2d_free(int32_t chan_id) +{ + if (-1 != chan_id) + { + __pi_udma_chan_2d = __BITSET_R(__pi_udma_chan_2d, 1, chan_id - UDMA_CHAN_2D_ID(0)); + } +} + +static inline uint32_t pi_udma_core_2d_addr_get(int32_t chan_id) +{ + return UDMA_CHAN_2D(chan_id); +} + +static inline void pi_udma_core_2d_enqueue(uint32_t udma_core_base, + uint32_t buf_0, uint32_t buf_1, + uint32_t size, uint32_t stride, + uint32_t length, uint32_t config) +{ + config |= UDMA_CORE_2D_ADDRGEN_CFG_CTRL_EN(1); + udma_core_2d_addrgen_cfg_sa_buf0_set(udma_core_base, buf_0); + udma_core_2d_addrgen_cfg_sa_buf1_set(udma_core_base, buf_1); + udma_core_2d_addrgen_cfg_size_set(udma_core_base, size); + udma_core_2d_addrgen_cfg_stride_set(udma_core_base, stride); + udma_core_2d_addrgen_cfg_row_len_set(udma_core_base, length); + udma_core_2d_addrgen_cfg_ctrl_set(udma_core_base, config); +} + +static inline void pi_udma_core_2d_stop(uint32_t udma_core_base) +{ + uint32_t config = UDMA_CORE_2D_ADDRGEN_CFG_CTRL_STOP(1); + udma_core_2d_addrgen_cfg_ctrl_set(udma_core_base, config); +} + +static inline void pi_udma_core_2d_reset(uint32_t udma_core_base) +{ + uint32_t config = UDMA_CORE_2D_ADDRGEN_CFG_CTRL_STOP(1); + /* udma_core_2d_addrgen_cfg_sa_buf0_set(udma_core_base, 0); */ + /* udma_core_2d_addrgen_cfg_sa_buf1_set(udma_core_base, 0); */ + /* udma_core_2d_addrgen_cfg_size_set(udma_core_base, 0); */ + /* udma_core_2d_addrgen_cfg_stride_set(udma_core_base, 0); */ + /* udma_core_2d_addrgen_cfg_row_len_set(udma_core_base, 0); */ + udma_core_2d_addrgen_cfg_ctrl_set(udma_core_base, config); +} + +static inline uint32_t pi_udma_core_2d_curr_addr_get(uint32_t udma_core_base) +{ + return udma_core_2d_addrgen_cfg_curr_addr_get(udma_core_base); +} + +static inline uint32_t pi_udma_core_2d_bytes_left_get(uint32_t udma_core_base) +{ + return udma_core_2d_addrgen_cfg_bytes_left_get(udma_core_base); +} + +/** + * UDMA_CHANNEL_FIFO + */ +static inline int32_t pi_udma_core_fifo_alloc(void) +{ + int32_t chan_id = -1; + if (0x0 != __pi_udma_chan_fifo) + { + chan_id = __FF1(__pi_udma_chan_fifo); + __pi_udma_chan_fifo = __BITCLR_R(__pi_udma_chan_fifo, 1, chan_id); + return (chan_id + UDMA_CHAN_FIFO_ID(0)); + } + return chan_id; +} + +static inline void pi_udma_core_fifo_free(int32_t chan_id) +{ + if (-1 != chan_id) + { + __pi_udma_chan_fifo = __BITSET_R(__pi_udma_chan_fifo, 1, chan_id - UDMA_CHAN_FIFO_ID(0)); + } +} + +static inline uint32_t pi_udma_core_fifo_addr_get(int32_t chan_id) +{ + return UDMA_CHAN_FIFO(chan_id); +} + +static inline void pi_udma_core_fifo_enqueue(uint32_t udma_core_base, + uint32_t buf, + uint32_t size, + uint32_t config) +{ + config |= UDMA_CORE_FIFO_CFG_CTRL_EN(1); + udma_core_fifo_cfg_sa_buffer_set(udma_core_base, buf); + udma_core_fifo_cfg_size_set(udma_core_base, size); + udma_core_fifo_cfg_ctrl_set(udma_core_base, config); +} + +static inline void pi_udma_core_fifo_stop(uint32_t udma_core_base) +{ + uint32_t config = UDMA_CORE_FIFO_CFG_CTRL_STOP(1); + udma_core_fifo_cfg_ctrl_set(udma_core_base, config); +} + +static inline void pi_udma_core_fifo_event_enable(uint32_t udma_core_base, + uint8_t enable) +{ + udma_core_fifo_cfg_evt_en_set(udma_core_base, enable); +} + +static inline void pi_udma_core_fifo_event_set_threshold(uint32_t udma_core_base, + uint32_t threshold) +{ + udma_core_fifo_cfg_evt_num_bytes_set(udma_core_base, threshold); +} diff --git a/rtos/pmsis/pmsis_implem/include/chips/gap9/drivers/udma/udma_timeout.h b/rtos/pmsis/pmsis_implem/include/chips/gap9/drivers/udma/udma_timeout.h new file mode 100644 index 000000000..8085819c1 --- /dev/null +++ b/rtos/pmsis/pmsis_implem/include/chips/gap9/drivers/udma/udma_timeout.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2020, GreenWaves Technologies, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * o Redistributions of source code must retain the above copyright notice, this list + * of conditions and the following disclaimer. + * + * o Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * o Neither the name of GreenWaves Technologies, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + + +/******************************************************************************* + * Definitions + ******************************************************************************/ + +struct pi_udma_timeout_s +{ + struct pi_task *fifo_head; + struct pi_task *fifo_tail; + //uint8_t tid; + pi_udma_timeout_mode_e mode; +}; + +/******************************************************************************* + * Driver data + ******************************************************************************/ + +/******************************************************************************* + * Function declaration + ******************************************************************************/ + +int32_t pi_udma_timeout_config_set(pi_task_t *task, uint8_t timeout_id, + uint8_t udma_chan_id, uint32_t timeout_us); + +pi_task_t *__pi_udma_timeout_task_remove(uint8_t timeout_id); diff --git a/rtos/pulp/gap_archi/Makefile b/rtos/pulp/gap_archi/Makefile index e4118ba67..77119939a 100644 --- a/rtos/pulp/gap_archi/Makefile +++ b/rtos/pulp/gap_archi/Makefile @@ -1,7 +1,5 @@ -DOC_IP ?= rtc soc_eu efuse udma gpio adv_timer fc_mpu fc_icache_ctrl cluster_ctrl_unit apb_soc_ctrl cl_dma timer_unit ne16 i3c cluster_icache_ctrl fc_itc power_manager secured_riscv_debug non_secured_riscv_debug xip csi2 sfu fll riscv_dbg rom +DOC_IP ?= rtc soc_eu efuse udma gpio adv_timer fc_mpu fc_icache_ctrl cluster_ctrl_unit cluster_event_unit apb_soc_ctrl cl_dma new_decompr timer_unit ne16 i3c cluster_icache_ctrl fc_itc power_manager xip csi2 sfu fll riscv_dbg rom quiddikey -#TODO this doc has been removed: quiddikey -#TODO add back udma AES when markdown is added xip: ./regmap/bin/regmap --name=xip \ @@ -32,6 +30,11 @@ rtc: --input-md=$(GAP9_V2_HOME)/fe/ips/rtc_dolphin/docs/RTC_reference.md \ --header=include/archi/chips/gap9_v2/rtc/rtc \ --rst=doc/ips/rtc_v1.rst + ./regmap/bin/regmap --name=rtc_internals --pretty-name='indirectly accessed registers' \ + --input=fe/ips/rtc_dolphin/docs/RTC_reference_internals.md \ + --input-md=$(GAP9_V2_HOME)/fe/ips/rtc_dolphin/docs/RTC_reference_internals.md \ + --header=include/archi/chips/gap9_v2/rtc/rtc_internals \ + --rst=doc/ips/rtc_v1_internals.rst fc_icache_ctrl: ./regmap/bin/regmap --name=fc_icache_ctrl \ @@ -75,6 +78,43 @@ cluster_ctrl_unit: --header=include/archi/chips/gap9_v2/cluster_ctrl_unit/cluster_ctrl_unit \ --rst=doc/ips/cluster_ctrl_unit.rst +cluster_event_unit: + ./regmap/bin/regmap --name=cluster_event_unit_core --pretty-name='core events' \ + --input=docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_core.md \ + --input-md=$(GAP9_V2_HOME)/docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_core.md \ + --header=include/archi/chips/gap9_v2/cluster_event_unit/cluster_event_unit \ + --rst=doc/ips/cluster_event_unit_core.rst + ./regmap/bin/regmap --name=cluster_event_unit_mutex --pretty-name='mutex events' \ + --input=docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_mutex.md \ + --input-md=$(GAP9_V2_HOME)/docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_mutex.md \ + --header=include/archi/chips/gap9_v2/cluster_event_unit/cluster_event_unit \ + --rst=doc/ips/cluster_event_unit_mutex.rst + ./regmap/bin/regmap --name=cluster_event_unit_sw_events --pretty-name='software events' \ + --input=docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_sw_events.md \ + --input-md=$(GAP9_V2_HOME)/docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_sw_events.md \ + --header=include/archi/chips/gap9_v2/cluster_event_unit/cluster_event_unit \ + --rst=doc/ips/cluster_event_unit_sw_events.rst + ./regmap/bin/regmap --name=cluster_event_unit_soc_evt --pretty-name='SoC events' \ + --input=docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_soc_evt.md \ + --input-md=$(GAP9_V2_HOME)/docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_soc_evt.md \ + --header=include/archi/chips/gap9_v2/cluster_event_unit/cluster_event_unit \ + --rst=doc/ips/cluster_event_unit_soc_evt.rst + ./regmap/bin/regmap --name=cluster_event_unit_barrier --pretty-name='hardware barriers' \ + --input=docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_barrier.md \ + --input-md=$(GAP9_V2_HOME)/docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_barrier.md \ + --header=include/archi/chips/gap9_v2/cluster_event_unit/cluster_event_unit \ + --rst=doc/ips/cluster_event_unit_barrier.rst + ./regmap/bin/regmap --name=cluster_event_unit_semaphore --pretty-name='semaphores' \ + --input=docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_semaphore.md \ + --input-md=$(GAP9_V2_HOME)/docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_semaphore.md \ + --header=include/archi/chips/gap9_v2/cluster_event_unit/cluster_event_unit \ + --rst=doc/ips/cluster_event_unit_semaphore.rst + ./regmap/bin/regmap --name=cluster_event_unit_bitfield --pretty-name='bitfields' \ + --input=docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_bitfield.md \ + --input-md=$(GAP9_V2_HOME)/docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_bitfield.md \ + --header=include/archi/chips/gap9_v2/cluster_event_unit/cluster_event_unit \ + --rst=doc/ips/cluster_event_unit_bitfield.rst + cluster_icache_ctrl: ./regmap/bin/regmap --name=cluster_icache_ctrl \ --input=fe/ips/hier-icache/DOC/CLUSTER_ICACHE_CTRL_reference.md \ @@ -90,7 +130,7 @@ apb_soc_ctrl: --rst=doc/ips/apb_soc_ctrl.rst rom: - ./regmap/bin/regmap --name=rom \ + ./regmap/bin/regmap --name=rom --pretty-name='reserved eFuses'\ --input=docs/IP_REFERENCES/GAP9_ROM.md \ --input-md=$(GAP9_V2_HOME)/docs/IP_REFERENCES/GAP9_ROM.md \ --header=include/archi/chips/gap9_v2/rom/rom \ @@ -103,6 +143,13 @@ cl_dma: --header=include/archi/chips/gap9_v2/cl_dma/cl_dma \ --rst=doc/ips/cl_dma.rst +new_decompr: + ./regmap/bin/regmap --name=new_decompr \ + --input=fe/ips/mchan/doc/CL_DMA_reference.md \ + --input-md=$(GAP9_V2_HOME)/fe/ips/new_decompr/README.md \ + --header=include/archi/chips/gap9_v2/new_decompr/new_decompr \ + --rst=doc/ips/new_decompr.rst + timer_unit: ./regmap/bin/regmap --name=timer_unit \ --input=fe/ips/timer_unit/doc/TIMER_UNIT_reference.md \ @@ -293,7 +340,7 @@ udma_aes_dual_core: --header=include/archi/chips/gap9_v2/udma_aes_dual_core/udma_aes_dual_core \ --rst=doc/ips/udma_aes_dual_core.rst -udma: udma_filter udma_qspi udma_hyper udma_ctrl udma_core_fifo udma_core_lin udma_core_2d udma_mram udma_i2s udma_uart udma_cpi udma_i2c udma_aes udma_aes_dual_core udma_timestamp +udma: udma_filter udma_qspi udma_hyper udma_ctrl udma_core_fifo udma_core_lin udma_core_2d udma_mram udma_i2s udma_uart udma_cpi udma_i2c udma_aes udma_aes_dual_core udma_timestamp udma_ffc gpio: ./regmap/bin/regmap \ diff --git a/rtos/pulp/gap_archi/doc/ips/adv_timer.rst b/rtos/pulp/gap_archi/doc/ips/adv_timer.rst index 476f34cab..202b1cddd 100644 --- a/rtos/pulp/gap_archi/doc/ips/adv_timer.rst +++ b/rtos/pulp/gap_archi/doc/ips/adv_timer.rst @@ -8,987 +8,806 @@ Register map Overview """""""" -.. table:: - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - | Name |Offset|Width| Description | - +=======================================================+======+=====+========================================================+ - |:ref:`T0_CMD` | 0| 32|ADV_TIMER0 command register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T0_CONFIG` | 4| 32|ADV_TIMER0 configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T0_THRESHOLD` | 8| 32|ADV_TIMER0 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T0_TH_CHANNEL0` | 12| 32|ADV_TIMER0 channel 0 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T0_TH_CHANNEL1` | 16| 32|ADV_TIMER0 channel 1 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T0_TH_CHANNEL2` | 20| 32|ADV_TIMER0 channel 2 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T0_TH_CHANNEL3` | 24| 32|ADV_TIMER0 channel 3 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T0_TH_CHANNEL0_LUT`| 28| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T0_TH_CHANNEL1_LUT`| 32| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T0_TH_CHANNEL2_LUT`| 36| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T0_TH_CHANNEL3_LUT`| 40| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T0_COUNTER` | 44| 32|ADV_TIMER0 counter register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T1_CMD` | 64| 32|ADV_TIMER1 command register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T1_CONFIG` | 68| 32|ADV_TIMER1 configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T1_THRESHOLD` | 72| 32|ADV_TIMER1 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T1_TH_CHANNEL0` | 76| 32|ADV_TIMER1 channel 0 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T1_TH_CHANNEL1` | 80| 32|ADV_TIMER1 channel 1 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T1_TH_CHANNEL2` | 84| 32|ADV_TIMER1 channel 2 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T1_TH_CHANNEL3` | 88| 32|ADV_TIMER1 channel 3 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T1_TH_CHANNEL0_LUT`| 92| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T1_TH_CHANNEL1_LUT`| 96| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T1_TH_CHANNEL2_LUT`| 100| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T1_TH_CHANNEL3_LUT`| 104| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T1_COUNTER` | 108| 32|ADV_TIMER1 counter register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T2_CMD` | 128| 32|ADV_TIMER2 command register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T2_CONFIG` | 132| 32|ADV_TIMER2 configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T2_THRESHOLD` | 136| 32|ADV_TIMER2 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T2_TH_CHANNEL0` | 140| 32|ADV_TIMER2 channel 0 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T2_TH_CHANNEL1` | 144| 32|ADV_TIMER2 channel 1 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T2_TH_CHANNEL2` | 148| 32|ADV_TIMER2 channel 2 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T2_TH_CHANNEL3` | 152| 32|ADV_TIMER2 channel 3 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T2_TH_CHANNEL0_LUT`| 156| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T2_TH_CHANNEL1_LUT`| 160| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T2_TH_CHANNEL2_LUT`| 164| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T2_TH_CHANNEL3_LUT`| 168| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T2_COUNTER` | 172| 32|ADV_TIMER2 counter register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T3_CMD` | 192| 32|ADV_TIMER3 command register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T3_CONFIG` | 196| 32|ADV_TIMER3 configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T3_THRESHOLD` | 200| 32|ADV_TIMER3 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T3_TH_CHANNEL0` | 204| 32|ADV_TIMER3 channel 0 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T3_TH_CHANNEL1` | 208| 32|ADV_TIMER3 channel 1 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T3_TH_CHANNEL2` | 212| 32|ADV_TIMER3 channel 2 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T3_TH_CHANNEL3` | 216| 32|ADV_TIMER3 channel 3 threshold configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T3_TH_CHANNEL0_LUT`| 220| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T3_TH_CHANNEL1_LUT`| 224| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T3_TH_CHANNEL2_LUT`| 228| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T3_TH_CHANNEL3_LUT`| 232| 32|(Not be connected in RTL) | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`T3_COUNTER` | 236| 32|ADV_TIMER3 counter register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`EVENT_CFG` | 256| 32|ADV_TIMERS events configuration register. | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`CG` | 260| 32|ADV_TIMERS channels clock gating configuration register.| - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`CH_MUX` | 264| 32|ADV_TIMER channel select | - +-------------------------------------------------------+------+-----+--------------------------------------------------------+ - -.. _adv_timer_T0_CMD: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +------------------------------------------------+------+-----+-----------------------------------------+ + | Name |Offset|Width| Description | + +================================================+======+=====+=========================================+ + |:ref:`T0_CMD` | 0| 32|Timer 0 command | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T0_CONFIG` | 4| 32|Timer 0 configuration | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T0_THRESHOLD` | 8| 32|Timer 0 threshold configuration | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T0_TH_CHANNEL0`| 12| 32|Timer 0 channel 0 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T0_TH_CHANNEL1`| 16| 32|Timer 0 channel 1 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T0_TH_CHANNEL2`| 20| 32|Timer 0 channel 2 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T0_TH_CHANNEL3`| 24| 32|Timer 0 channel 3 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T0_COUNTER` | 44| 32|Timer 0 counter | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T1_CMD` | 64| 32|Timer 1 command | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T1_CONFIG` | 68| 32|Timer 1 configuration | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T1_THRESHOLD` | 72| 32|Timer 1 threshold configuration | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T1_TH_CHANNEL0`| 76| 32|Timer 1 channel 0 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T1_TH_CHANNEL1`| 80| 32|Timer 1 channel 1 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T1_TH_CHANNEL2`| 84| 32|Timer 1 channel 2 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T1_TH_CHANNEL3`| 88| 32|Timer 1 channel 3 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T1_COUNTER` | 108| 32|Timer 1 counter | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T2_CMD` | 128| 32|Timer 2 command | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T2_CONFIG` | 132| 32|Timer 2 configuration | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T2_THRESHOLD` | 136| 32|Timer 2 threshold configuration | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T2_TH_CHANNEL0`| 140| 32|Timer 2 channel 0 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T2_TH_CHANNEL1`| 144| 32|Timer 2 channel 1 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T2_TH_CHANNEL2`| 148| 32|Timer 2 channel 2 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T2_TH_CHANNEL3`| 152| 32|Timer 2 channel 3 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T2_COUNTER` | 172| 32|Timer 2 counter | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T3_CMD` | 192| 32|Timer 3 command | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T3_CONFIG` | 196| 32|Timer 3 configuration | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T3_THRESHOLD` | 200| 32|Timer 3 threshold configuration | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T3_TH_CHANNEL0`| 204| 32|Timer 3 channel 0 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T3_TH_CHANNEL1`| 208| 32|Timer 3 channel 1 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T3_TH_CHANNEL2`| 212| 32|Timer 3 channel 2 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T3_TH_CHANNEL3`| 216| 32|Timer 3 channel 3 threshold configuration| + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`T3_COUNTER` | 236| 32|Timer 3 counter | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`EVENT_CFG` | 256| 32|Output events configuration | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`CG` | 260| 32|Channels clock gating configuration | + +------------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`CH_MUX` | 264| 32|Channels output configuration | + +------------------------------------------------+------+-----+-----------------------------------------+ + +.. _adv_timer__T0_CMD: T0_CMD """""" -ADV_TIMER0 command register. +Timer 0 command .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+===================================+ - | 0|W |START |ADV_TIMER0 start command bitfield. | - +-----+---+------+-----------------------------------+ - | 1|W |STOP |ADV_TIMER0 stop command bitfield. | - +-----+---+------+-----------------------------------+ - | 2|W |UPDATE|ADV_TIMER0 update command bitfield.| - +-----+---+------+-----------------------------------+ - | 3|W |RESET |ADV_TIMER0 reset command bitfield. | - +-----+---+------+-----------------------------------+ - | 4|W |ARM |ADV_TIMER0 arm command bitfield. | - +-----+---+------+-----------------------------------+ + +-----+---+------+-----+-------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=========================+ + | 0|W |START |0x0 |Write 1 to start timer 0 | + +-----+---+------+-----+-------------------------+ + | 1|W |STOP |0x0 |Write 1 to stop timer 0 | + +-----+---+------+-----+-------------------------+ + | 2|W |UPDATE|0x0 |Write 1 to update timer 0| + +-----+---+------+-----+-------------------------+ + | 3|W |RESET |0x0 |Write 1 to reset timer 0 | + +-----+---+------+-----+-------------------------+ + | 4|W |ARM |0x0 |Write 1 to arm timer 0 | + +-----+---+------+-----+-------------------------+ -.. _adv_timer_T0_CONFIG: +.. _adv_timer__T0_CONFIG: T0_CONFIG """"""""" -ADV_TIMER0 configuration register. +Timer 0 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+============================================================================================================================================================================================================================================================================================================================================================================================================================================================+ - |7:0 |R/W|INSEL |ADV_TIMER0 input source configuration bitfield: 0-31: GPIO[0] to GPIO[31] 32-35: Channel 0 to 3 of ADV_TIMER0, 36-39: Channel 0 to 3 of ADV_TIMER1, 40-43: Channel 0 to 3 of ADV_TIMER2, 44-47: Channel 0 to 3 of ADV_TIMER3 | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10:8 |R/W|MODE |ADV_TIMER0 trigger mode configuration bitfield 3'h0: trigger event at each clock cycle. 3'h1: trigger event if input source is 0 3'h2: trigger event if input source is 1 3'h3: trigger event on input source rising edge 3'h4: trigger event on input source falling edge 3'h5: trigger event on input source falling or rising edge 3'h6: trigger event on input source rising edge when armed 3'h7: trigger event on input source falling edge when armed| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |11 |R/W|CLKSEL |ADV_TIMER0 clock source configuration bitfield: 1'b0: FLL 1'b1: reference clock at 32kHz | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |12 |R/W|UPDOWNSEL|ADV_TIMER0 center-aligned mode configuration bitfield: 1'b0: The counter counts up and down alternatively. 1'b1: The counter counts up and resets to 0 when reach threshold. | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |23:16|R/W|PRESC |ADV_TIMER0 prescaler value configuration bitfield. | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+========================================================================================================================================================================================================================================================================================================================================================================================================================+ + |7:0 |R/W|INSEL |0x0 |Timer 0 input source: 0-31: GPIO[0] to GPIO[31]; 32-35: Channel 0 to 3 of timer 0; 36-39: Channel 0 to 3 of timer 1; 40-43: Channel 0 to 3 of timer 2; 44-47: Channel 0 to 3 of timer 3 | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10:8 |R/W|MODE |0x0 |Timer 0 trigger mode: 0: trigger event at each clock cycle; 1: trigger event if input source is 0; 2: trigger event if input source is 1; 3: trigger event on input source rising edge; 4: trigger event on input source falling edge; 5: trigger event on input source both falling and rising edges; 6: trigger event on input source rising edge when armed; 7: trigger event on input source falling edge when armed| + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |11 |R/W|CLKSEL |0x0 |Timer 0 counting clock: 0: main timer clock; 1: slow clock | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|UPDOWNSEL|0x1 |timer 0 center-aligned mode: 0: the counter counts up and down alternatively; 1: the counter counts up and resets to 0 when it reaches the threshold | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|PRESC |0x0 |Timer 0 prescaler value | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T0_THRESHOLD: +.. _adv_timer__T0_THRESHOLD: T0_THRESHOLD """""""""""" -ADV_TIMER0 threshold configuration register. +Timer 0 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-------------------------------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+=====================================================================================+ - |15:0 |R/W|TH_LO|ADV_TIMER0 threshold low part configuration bitfield. It defines start counter value.| - +-----+---+-----+-------------------------------------------------------------------------------------+ - |31:16|R/W|TH_HI|ADV_TIMER0 threshold high part configuration bitfield. It defines end counter value. | - +-----+---+-----+-------------------------------------------------------------------------------------+ + +-----+---+-----+-----+----------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+================================================================+ + |15:0 |R/W|TH_LO|0x0 |Timer 0 low threshold. It defines the start value of the counter| + +-----+---+-----+-----+----------------------------------------------------------------+ + |31:16|R/W|TH_HI|0x0 |Timer 0 high threshold. It defines the end value of the counter | + +-----+---+-----+-----+----------------------------------------------------------------+ -.. _adv_timer_T0_TH_CHANNEL0: +.. _adv_timer__T0_TH_CHANNEL0: T0_TH_CHANNEL0 """""""""""""" -ADV_TIMER0 channel 0 threshold configuration register. +Timer 0 channel 0 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER0 channel 0 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER0 channel 0 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 0 channel 0 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 0 channel 0 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T0_TH_CHANNEL1: +.. _adv_timer__T0_TH_CHANNEL1: T0_TH_CHANNEL1 """""""""""""" -ADV_TIMER0 channel 1 threshold configuration register. +Timer 0 channel 1 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER0 channel 1 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER0 channel 1 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 0 channel 1 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 0 channel 1 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T0_TH_CHANNEL2: +.. _adv_timer__T0_TH_CHANNEL2: T0_TH_CHANNEL2 """""""""""""" -ADV_TIMER0 channel 2 threshold configuration register. +Timer 0 channel 2 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER0 channel 2 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER0 channel 2 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 0 channel 2 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 0 channel 2 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T0_TH_CHANNEL3: +.. _adv_timer__T0_TH_CHANNEL3: T0_TH_CHANNEL3 """""""""""""" -ADV_TIMER0 channel 3 threshold configuration register. - -.. table:: - - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER0 channel 3 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER0 channel 3 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _adv_timer_T0_TH_CHANNEL0_LUT: - -T0_TH_CHANNEL0_LUT -"""""""""""""""""" - -(Not be connected in RTL) - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _adv_timer_T0_TH_CHANNEL1_LUT: - -T0_TH_CHANNEL1_LUT -"""""""""""""""""" - -(Not be connected in RTL) - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _adv_timer_T0_TH_CHANNEL2_LUT: - -T0_TH_CHANNEL2_LUT -"""""""""""""""""" - -(Not be connected in RTL) - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _adv_timer_T0_TH_CHANNEL3_LUT: - -T0_TH_CHANNEL3_LUT -"""""""""""""""""" - -(Not be connected in RTL) +Timer 0 channel 3 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 0 channel 3 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 0 channel 3 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T0_COUNTER: +.. _adv_timer__T0_COUNTER: T0_COUNTER """""""""" -ADV_TIMER0 counter register. +Timer 0 counter .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+=========================+ - |15:0 |R |COUNTER|ADV_TIMER0 counter value.| - +-----+---+-------+-------------------------+ + +-----+---+-------+-----+---------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=====================+ + |15:0 |R |COUNTER|0x0 |Timer 0 counter value| + +-----+---+-------+-----+---------------------+ -.. _adv_timer_T1_CMD: +.. _adv_timer__T1_CMD: T1_CMD """""" -ADV_TIMER1 command register. +Timer 1 command .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+===================================+ - | 0|R/W|START |ADV_TIMER1 start command bitfield. | - +-----+---+------+-----------------------------------+ - | 1|R/W|STOP |ADV_TIMER1 stop command bitfield | - +-----+---+------+-----------------------------------+ - | 2|R/W|UPDATE|ADV_TIMER1 update command bitfield.| - +-----+---+------+-----------------------------------+ - | 3|R/W|RESET |ADV_TIMER1 reset command bitfield. | - +-----+---+------+-----------------------------------+ - | 4|R/W|ARM |ADV_TIMER1 arm command bitfield. | - +-----+---+------+-----------------------------------+ + +-----+---+------+-----+-------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=========================+ + | 0|R/W|START |0x0 |Write 1 to start timer 1 | + +-----+---+------+-----+-------------------------+ + | 1|R/W|STOP |0x0 |Write 1 to stop timer 1 | + +-----+---+------+-----+-------------------------+ + | 2|R/W|UPDATE|0x0 |Write 1 to update timer 1| + +-----+---+------+-----+-------------------------+ + | 3|R/W|RESET |0x0 |Write 1 to reset timer 1 | + +-----+---+------+-----+-------------------------+ + | 4|R/W|ARM |0x0 |Write 1 to arm timer 1 | + +-----+---+------+-----+-------------------------+ -.. _adv_timer_T1_CONFIG: +.. _adv_timer__T1_CONFIG: T1_CONFIG """"""""" -ADV_TIMER1 configuration register. +Timer 1 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+============================================================================================================================================================================================================================================================================================================================================================================================================================================================+ - |7:0 |R/W|INSEL |ADV_TIMER1 input source configuration bitfield: 0-31: GPIO[0] to GPIO[31] 32-35: Channel 0 to 3 of ADV_TIMER0, 36-39: Channel 0 to 3 of ADV_TIMER1, 40-43: Channel 0 to 3 of ADV_TIMER2, 44-47: Channel 0 to 3 of ADV_TIMER3 | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10:8 |R/W|MODE |ADV_TIMER1 trigger mode configuration bitfield 3'h0: trigger event at each clock cycle. 3'h1: trigger event if input source is 0 3'h2: trigger event if input source is 1 3'h3: trigger event on input source rising edge 3'h4: trigger event on input source falling edge 3'h5: trigger event on input source falling or rising edge 3'h6: trigger event on input source rising edge when armed 3'h7: trigger event on input source falling edge when armed| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |11 |R/W|CLKSEL |ADV_TIMER1 clock source configuration bitfield: 1'b0: FLL 1'b1: reference clock at 32kHz | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |12 |R/W|UPDOWNSEL|ADV_TIMER1 center-aligned mode configuration bitfield: 1'b0: The counter counts up and down alternatively. 1'b1: The counter counts up and resets to 0 when reach threshold. | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |23:16|R/W|PRESC |ADV_TIMER1 prescaler value configuration bitfield. | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+========================================================================================================================================================================================================================================================================================================================================================================================================================+ + |7:0 |R/W|INSEL |0x0 |Timer 1 input source: 0-31: GPIO[0] to GPIO[31]; 32-35: Channel 0 to 3 of timer 0; 36-39: Channel 0 to 3 of timer 1; 40-43: Channel 0 to 3 of timer 2; 44-47: Channel 0 to 3 of timer 3 | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10:8 |R/W|MODE |0x0 |Timer 1 trigger mode: 0: trigger event at each clock cycle; 1: trigger event if input source is 0; 2: trigger event if input source is 1; 3: trigger event on input source rising edge; 4: trigger event on input source falling edge; 5: trigger event on input source both falling and rising edges; 6: trigger event on input source rising edge when armed; 7: trigger event on input source falling edge when armed| + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |11 |R/W|CLKSEL |0x0 |Timer 1 counting clock: 0: main timer clock; 1: slow clock | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|UPDOWNSEL|0x1 |timer 1 center-aligned mode: 0: the counter counts up and down alternatively; 1: the counter counts up and resets to 0 when it reaches the threshold | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|PRESC |0x0 |Timer 1 prescaler value | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T1_THRESHOLD: +.. _adv_timer__T1_THRESHOLD: T1_THRESHOLD """""""""""" -ADV_TIMER1 threshold configuration register. +Timer 1 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-------------------------------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+=====================================================================================+ - |15:0 |R/W|TH_LO|ADV_TIMER1 threshold low part configuration bitfield. It defines start counter value.| - +-----+---+-----+-------------------------------------------------------------------------------------+ - |31:16|R/W|TH_HI|ADV_TIMER1 threshold high part configuration bitfield. It defines end counter value. | - +-----+---+-----+-------------------------------------------------------------------------------------+ + +-----+---+-----+-----+----------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+================================================================+ + |15:0 |R/W|TH_LO|0x0 |Timer 1 low threshold. It defines the start value of the counter| + +-----+---+-----+-----+----------------------------------------------------------------+ + |31:16|R/W|TH_HI|0x0 |Timer 1 high threshold. It defines the end value of the counter | + +-----+---+-----+-----+----------------------------------------------------------------+ -.. _adv_timer_T1_TH_CHANNEL0: +.. _adv_timer__T1_TH_CHANNEL0: T1_TH_CHANNEL0 """""""""""""" -ADV_TIMER1 channel 0 threshold configuration register. +Timer 1 channel 0 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER1 channel 0 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER1 channel 0 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 1 channel 0 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 1 channel 0 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T1_TH_CHANNEL1: +.. _adv_timer__T1_TH_CHANNEL1: T1_TH_CHANNEL1 """""""""""""" -ADV_TIMER1 channel 1 threshold configuration register. +Timer 1 channel 1 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER1 channel 1 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER1 channel 1 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 1 channel 1 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 1 channel 1 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T1_TH_CHANNEL2: +.. _adv_timer__T1_TH_CHANNEL2: T1_TH_CHANNEL2 """""""""""""" -ADV_TIMER1 channel 2 threshold configuration register. +Timer 1 channel 2 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER1 channel 2 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER1 channel 2 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 1 channel 2 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 1 channel 2 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T1_TH_CHANNEL3: +.. _adv_timer__T1_TH_CHANNEL3: T1_TH_CHANNEL3 """""""""""""" -ADV_TIMER1 channel 3 threshold configuration register. - -.. table:: - - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER1 channel 3 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER1 channel 3 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _adv_timer_T1_TH_CHANNEL0_LUT: - -T1_TH_CHANNEL0_LUT -"""""""""""""""""" - -(Not be connected in RTL) - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _adv_timer_T1_TH_CHANNEL1_LUT: - -T1_TH_CHANNEL1_LUT -"""""""""""""""""" - -(Not be connected in RTL) - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _adv_timer_T1_TH_CHANNEL2_LUT: - -T1_TH_CHANNEL2_LUT -"""""""""""""""""" - -(Not be connected in RTL) - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _adv_timer_T1_TH_CHANNEL3_LUT: - -T1_TH_CHANNEL3_LUT -"""""""""""""""""" - -(Not be connected in RTL) +Timer 1 channel 3 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 1 channel 3 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 1 channel 3 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T1_COUNTER: +.. _adv_timer__T1_COUNTER: T1_COUNTER """""""""" -ADV_TIMER1 counter register. +Timer 1 counter .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+=========================+ - |15:0 |R |COUNTER|ADV_TIMER1 counter value.| - +-----+---+-------+-------------------------+ + +-----+---+-------+-----+---------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=====================+ + |15:0 |R |COUNTER|0x0 |Timer 1 counter value| + +-----+---+-------+-----+---------------------+ -.. _adv_timer_T2_CMD: +.. _adv_timer__T2_CMD: T2_CMD """""" -ADV_TIMER2 command register. +Timer 2 command .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+===================================+ - | 0|R/W|START |ADV_TIMER2 start command bitfield. | - +-----+---+------+-----------------------------------+ - | 1|R/W|STOP |ADV_TIMER2 stop command bitfield | - +-----+---+------+-----------------------------------+ - | 2|R/W|UPDATE|ADV_TIMER2 update command bitfield.| - +-----+---+------+-----------------------------------+ - | 3|R/W|RESET |ADV_TIMER2 reset command bitfield. | - +-----+---+------+-----------------------------------+ - | 4|R/W|ARM |ADV_TIMER2 arm command bitfield. | - +-----+---+------+-----------------------------------+ + +-----+---+------+-----+-------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=========================+ + | 0|R/W|START |0x0 |Write 1 to start timer 2 | + +-----+---+------+-----+-------------------------+ + | 1|R/W|STOP |0x0 |Write 1 to stop timer 2 | + +-----+---+------+-----+-------------------------+ + | 2|R/W|UPDATE|0x0 |Write 1 to update timer 2| + +-----+---+------+-----+-------------------------+ + | 3|R/W|RESET |0x0 |Write 1 to reset timer 2 | + +-----+---+------+-----+-------------------------+ + | 4|R/W|ARM |0x0 |Write 1 to arm timer 2 | + +-----+---+------+-----+-------------------------+ -.. _adv_timer_T2_CONFIG: +.. _adv_timer__T2_CONFIG: T2_CONFIG """"""""" -ADV_TIMER2 configuration register. +Timer 2 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+============================================================================================================================================================================================================================================================================================================================================================================================================================================================+ - |7:0 |R/W|INSEL |ADV_TIMER2 input source configuration bitfield: 0-31: GPIO[0] to GPIO[31] 32-35: Channel 0 to 3 of ADV_TIMER0, 36-39: Channel 0 to 3 of ADV_TIMER1, 40-43: Channel 0 to 3 of ADV_TIMER2, 44-47: Channel 0 to 3 of ADV_TIMER3 | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10:8 |R/W|MODE |ADV_TIMER2 trigger mode configuration bitfield 3'h0: trigger event at each clock cycle. 3'h1: trigger event if input source is 0 3'h2: trigger event if input source is 1 3'h3: trigger event on input source rising edge 3'h4: trigger event on input source falling edge 3'h5: trigger event on input source falling or rising edge 3'h6: trigger event on input source rising edge when armed 3'h7: trigger event on input source falling edge when armed| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |11 |R/W|CLKSEL |ADV_TIMER2 clock source configuration bitfield: 1'b0: FLL 1'b1: reference clock at 32kHz | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |12 |R/W|UPDOWNSEL|ADV_TIMER2 center-aligned mode configuration bitfield: 1'b0: The counter counts up and down alternatively. 1'b1: The counter counts up and resets to 0 when reach threshold. | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |23:16|R/W|PRESC |ADV_TIMER2 prescaler value configuration bitfield. | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+========================================================================================================================================================================================================================================================================================================================================================================================================================+ + |7:0 |R/W|INSEL |0x0 |Timer 2 input source: 0-31: GPIO[0] to GPIO[31]; 32-35: Channel 0 to 3 of timer 0; 36-39: Channel 0 to 3 of timer 1; 40-43: Channel 0 to 3 of timer 2; 44-47: Channel 0 to 3 of timer 3 | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10:8 |R/W|MODE |0x0 |Timer 2 trigger mode: 0: trigger event at each clock cycle; 1: trigger event if input source is 0; 2: trigger event if input source is 1; 3: trigger event on input source rising edge; 4: trigger event on input source falling edge; 5: trigger event on input source both falling and rising edges; 6: trigger event on input source rising edge when armed; 7: trigger event on input source falling edge when armed| + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |11 |R/W|CLKSEL |0x0 |Timer 2 counting clock: 0: main timer clock; 1: slow clock | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|UPDOWNSEL|0x1 |Timer 2 center-aligned mode: 0: the counter counts up and down alternatively; 1: the counter counts up and resets to 0 when it reaches the threshold | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|PRESC |0x0 |Timer 2 prescaler value | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T2_THRESHOLD: +.. _adv_timer__T2_THRESHOLD: T2_THRESHOLD """""""""""" -ADV_TIMER2 threshold configuration register. +Timer 2 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-------------------------------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+=====================================================================================+ - |15:0 |R/W|TH_LO|ADV_TIMER2 threshold low part configuration bitfield. It defines start counter value.| - +-----+---+-----+-------------------------------------------------------------------------------------+ - |31:16|R/W|TH_HI|ADV_TIMER2 threshold high part configuration bitfield. It defines end counter value. | - +-----+---+-----+-------------------------------------------------------------------------------------+ + +-----+---+-----+-----+----------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+================================================================+ + |15:0 |R/W|TH_LO|0x0 |Timer 2 low threshold. It defines the start value of the counter| + +-----+---+-----+-----+----------------------------------------------------------------+ + |31:16|R/W|TH_HI|0x0 |Timer 2 high threshold. It defines the end value of the counter | + +-----+---+-----+-----+----------------------------------------------------------------+ -.. _adv_timer_T2_TH_CHANNEL0: +.. _adv_timer__T2_TH_CHANNEL0: T2_TH_CHANNEL0 """""""""""""" -ADV_TIMER2 channel 0 threshold configuration register. +Timer 2 channel 0 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER2 channel 0 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER2 channel 0 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 2 channel 0 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 2 channel 0 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T2_TH_CHANNEL1: +.. _adv_timer__T2_TH_CHANNEL1: T2_TH_CHANNEL1 """""""""""""" -ADV_TIMER2 channel 1 threshold configuration register. +Timer 2 channel 1 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER2 channel 1 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER2 channel 1 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 2 channel 1 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 2 channel 1 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T2_TH_CHANNEL2: +.. _adv_timer__T2_TH_CHANNEL2: T2_TH_CHANNEL2 """""""""""""" -ADV_TIMER2 channel 2 threshold configuration register. +Timer 2 channel 2 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER2 channel 2 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER2 channel 2 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 2 channel 2 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 2 channel 2 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T2_TH_CHANNEL3: +.. _adv_timer__T2_TH_CHANNEL3: T2_TH_CHANNEL3 """""""""""""" -ADV_TIMER2 channel 3 threshold configuration register. +Timer 2 channel 3 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER2 channel 3 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER2 channel 3 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 2 channel 3 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 2 channel 3 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T2_TH_CHANNEL0_LUT: - -T2_TH_CHANNEL0_LUT -"""""""""""""""""" - -(Not be connected in RTL) - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _adv_timer_T2_TH_CHANNEL1_LUT: - -T2_TH_CHANNEL1_LUT -"""""""""""""""""" - -(Not be connected in RTL) - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _adv_timer_T2_TH_CHANNEL2_LUT: - -T2_TH_CHANNEL2_LUT -"""""""""""""""""" - -(Not be connected in RTL) - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _adv_timer_T2_TH_CHANNEL3_LUT: - -T2_TH_CHANNEL3_LUT -"""""""""""""""""" - -(Not be connected in RTL) - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _adv_timer_T2_COUNTER: +.. _adv_timer__T2_COUNTER: T2_COUNTER """""""""" -ADV_TIMER2 counter register. +Timer 2 counter .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+=========================+ - |15:0 |R |COUNTER|ADV_TIMER2 counter value.| - +-----+---+-------+-------------------------+ + +-----+---+-------+-----+---------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=====================+ + |15:0 |R |COUNTER|0x0 |Timer 2 counter value| + +-----+---+-------+-----+---------------------+ -.. _adv_timer_T3_CMD: +.. _adv_timer__T3_CMD: T3_CMD """""" -ADV_TIMER3 command register. +Timer 3 command .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+===================================+ - | 0|R/W|START |ADV_TIMER3 start command bitfield. | - +-----+---+------+-----------------------------------+ - | 1|R/W|STOP |ADV_TIMER3 stop command bitfield | - +-----+---+------+-----------------------------------+ - | 2|R/W|UPDATE|ADV_TIMER3 update command bitfield.| - +-----+---+------+-----------------------------------+ - | 3|R/W|RESET |ADV_TIMER3 reset command bitfield. | - +-----+---+------+-----------------------------------+ - | 4|R/W|ARM |ADV_TIMER3 arm command bitfield. | - +-----+---+------+-----------------------------------+ + +-----+---+------+-----+-------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=========================+ + | 0|R/W|START |0x0 |Write 1 to start timer 3 | + +-----+---+------+-----+-------------------------+ + | 1|R/W|STOP |0x0 |Write 1 to stop timer 3 | + +-----+---+------+-----+-------------------------+ + | 2|R/W|UPDATE|0x0 |Write 1 to update timer 3| + +-----+---+------+-----+-------------------------+ + | 3|R/W|RESET |0x0 |Write 1 to reset timer 3 | + +-----+---+------+-----+-------------------------+ + | 4|R/W|ARM |0x0 |Write 1 to arm timer 3 | + +-----+---+------+-----+-------------------------+ -.. _adv_timer_T3_CONFIG: +.. _adv_timer__T3_CONFIG: T3_CONFIG """"""""" -ADV_TIMER3 configuration register. +Timer 3 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+============================================================================================================================================================================================================================================================================================================================================================================================================================================================+ - |7:0 |R/W|INSEL |ADV_TIMER3 input source configuration bitfield: 0-31: GPIO[0] to GPIO[31] 32-35: Channel 0 to 3 of ADV_TIMER0, 36-39: Channel 0 to 3 of ADV_TIMER1, 40-43: Channel 0 to 3 of ADV_TIMER2, 44-47: Channel 0 to 3 of ADV_TIMER3 | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10:8 |R/W|MODE |ADV_TIMER3 trigger mode configuration bitfield 3'h0: trigger event at each clock cycle. 3'h1: trigger event if input source is 0 3'h2: trigger event if input source is 1 3'h3: trigger event on input source rising edge 3'h4: trigger event on input source falling edge 3'h5: trigger event on input source falling or rising edge 3'h6: trigger event on input source rising edge when armed 3'h7: trigger event on input source falling edge when armed| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |11 |R/W|CLKSEL |ADV_TIMER3 clock source configuration bitfield: 1'b0: FLL 1'b1: reference clock at 32kHz | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |12 |R/W|UPDOWNSEL|ADV_TIMER3 center-aligned mode configuration bitfield: 1'b0: The counter counts up and down alternatively. 1'b1: The counter counts up and resets to 0 when reach threshold. | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |23:16|R/W|PRESC |ADV_TIMER3 prescaler value configuration bitfield. | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+========================================================================================================================================================================================================================================================================================================================================================================================================================+ + |7:0 |R/W|INSEL |0x0 |Timer 3 input source: 0-31: GPIO[0] to GPIO[31]; 32-35: Channel 0 to 3 of timer 0; 36-39: Channel 0 to 3 of timer 1; 40-43: Channel 0 to 3 of timer 2; 44-47: Channel 0 to 3 of timer 3 | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10:8 |R/W|MODE |0x0 |Timer 3 trigger mode: 0: trigger event at each clock cycle; 1: trigger event if input source is 0; 2: trigger event if input source is 1; 3: trigger event on input source rising edge; 4: trigger event on input source falling edge; 5: trigger event on input source both falling and rising edges; 6: trigger event on input source rising edge when armed; 7: trigger event on input source falling edge when armed| + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |11 |R/W|CLKSEL |0x0 |Timer 3 counting clock: 0: main timer clock; 1: slow clock | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|UPDOWNSEL|0x1 |Timer 3 center-aligned mode: 0: the counter counts up and down alternatively; 1: the counter counts up and resets to 0 when it reaches the threshold | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|PRESC |0x0 |Timer 3 prescaler value | + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T3_THRESHOLD: +.. _adv_timer__T3_THRESHOLD: T3_THRESHOLD """""""""""" -ADV_TIMER3 threshold configuration register. +Timer 3 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-------------------------------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+=====================================================================================+ - |15:0 |R/W|TH_LO|ADV_TIMER3 threshold low part configuration bitfield. It defines start counter value.| - +-----+---+-----+-------------------------------------------------------------------------------------+ - |31:16|R/W|TH_HI|ADV_TIMER3 threshold high part configuration bitfield. It defines end counter value. | - +-----+---+-----+-------------------------------------------------------------------------------------+ + +-----+---+-----+-----+----------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+================================================================+ + |15:0 |R/W|TH_LO|0x0 |Timer 3 low threshold. It defines the start value of the counter| + +-----+---+-----+-----+----------------------------------------------------------------+ + |31:16|R/W|TH_HI|0x0 |Timer 3 high threshold. It defines the end value of the counter | + +-----+---+-----+-----+----------------------------------------------------------------+ -.. _adv_timer_T3_TH_CHANNEL0: +.. _adv_timer__T3_TH_CHANNEL0: T3_TH_CHANNEL0 """""""""""""" -ADV_TIMER3 channel 0 threshold configuration register. +Timer 3 channel 0 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER3 channel 0 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER3 channel 0 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 3 channel 0 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 3 channel 0 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T3_TH_CHANNEL1: +.. _adv_timer__T3_TH_CHANNEL1: T3_TH_CHANNEL1 """""""""""""" -ADV_TIMER3 channel 1 threshold configuration register. +Timer 3 channel 1 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER3 channel 1 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER3 channel 1 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 3 channel 1 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 3 channel 1 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T3_TH_CHANNEL2: +.. _adv_timer__T3_TH_CHANNEL2: T3_TH_CHANNEL2 """""""""""""" -ADV_TIMER3 channel 2 threshold configuration register. +Timer 3 channel 2 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER3 channel 2 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER3 channel 2 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 3 channel 2 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 3 channel 2 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T3_TH_CHANNEL3: +.. _adv_timer__T3_TH_CHANNEL3: T3_TH_CHANNEL3 """""""""""""" -ADV_TIMER3 channel 3 threshold configuration register. - -.. table:: - - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================================================================================================================================================================================================================+ - |15:0 |R/W|TH |ADV_TIMER3 channel 3 threshold configuration bitfield. | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18:16|R/W|MODE|ADV_TIMER3 channel 3 threshold match action on channel output signal configuration bitfield 3'h0: set. 3'h1: toggle then next threshold match action is clear. 3'h2: set then next threshold match action is clear. 3'h3: toggle. 3'h4: clear. 3'h5: toggle then next threshold match action is set. 3'h6: clear then next threshold match action is set.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _adv_timer_T3_TH_CHANNEL0_LUT: - -T3_TH_CHANNEL0_LUT -"""""""""""""""""" - -(Not be connected in RTL) - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _adv_timer_T3_TH_CHANNEL1_LUT: - -T3_TH_CHANNEL1_LUT -"""""""""""""""""" - -(Not be connected in RTL) - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _adv_timer_T3_TH_CHANNEL2_LUT: - -T3_TH_CHANNEL2_LUT -"""""""""""""""""" - -(Not be connected in RTL) - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _adv_timer_T3_TH_CHANNEL3_LUT: - -T3_TH_CHANNEL3_LUT -"""""""""""""""""" - -(Not be connected in RTL) +Timer 3 channel 3 threshold configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TH |0x0 |Timer 3 channel 3 threshold | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18:16|R/W|MODE|0x0 |Action triggered on timer 3 channel 3 output when the channel threshold is reached: 0: set to 1; 1: toggle value at odd occurrence, clear to 0 at even occurrence; 2: set to 1 at odd occurrence, clear to 0 at even occurrence; 3: toggle value; 4: clear to 0; 5: toggle value at odd occurrence, set to 1 at even occurrence; 6: clear to 0 at odd occurrence, set to 1 at even occurrence| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_T3_COUNTER: +.. _adv_timer__T3_COUNTER: T3_COUNTER """""""""" -ADV_TIMER3 counter register. +Timer 3 counter .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+=========================+ - |15:0 |R |COUNTER|ADV_TIMER3 counter value.| - +-----+---+-------+-------------------------+ + +-----+---+-------+-----+---------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=====================+ + |15:0 |R |COUNTER|0x0 |Timer 3 counter value| + +-----+---+-------+-----+---------------------+ -.. _adv_timer_EVENT_CFG: +.. _adv_timer__EVENT_CFG: EVENT_CFG """"""""" -ADV_TIMERS events configuration register. +Output events configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================+ - |3:0 |R/W|SEL0|ADV_TIMER output event 0 source configuration bitfiled: 4'h0: ADV_TIMER0 channel 0 4'h1: ADV_TIMER0 channel 1 4'h2: ADV_TIMER0 channel 2 4'h3: ADV_TIMER0 channel 3 4'h4: ADV_TIMER1 channel 0 4'h5: ADV_TIMER1 channel 1 4'h6: ADV_TIMER1 channel 2 4'h7: ADV_TIMER1 channel 3 4'h8: ADV_TIMER2 channel 0 4'h9: ADV_TIMER2 channel 1 4'hA: ADV_TIMER2 channel 2 4'hB: ADV_TIMER2 channel 3 4'hC: ADV_TIMER3 channel 0 4'hD: ADV_TIMER3 channel 1 4'hE: ADV_TIMER3 channel 2 4'hF: ADV_TIMER3 channel 3.| - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |7:4 |R/W|SEL1|ADV_TIMER output event 0 source configuration bitfiled: 4'h0: ADV_TIMER0 channel 0 4'h1: ADV_TIMER0 channel 1 4'h2: ADV_TIMER0 channel 2 4'h3: ADV_TIMER0 channel 3 4'h4: ADV_TIMER1 channel 0 4'h5: ADV_TIMER1 channel 1 4'h6: ADV_TIMER1 channel 2 4'h7: ADV_TIMER1 channel 3 4'h8: ADV_TIMER2 channel 0 4'h9: ADV_TIMER2 channel 1 4'hA: ADV_TIMER2 channel 2 4'hB: ADV_TIMER2 channel 3 4'hC: ADV_TIMER3 channel 0 4'hD: ADV_TIMER3 channel 1 4'hE: ADV_TIMER3 channel 2 4'hF: ADV_TIMER3 channel 3.| - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |11:8 |R/W|SEL2|ADV_TIMER output event 0 source configuration bitfiled: 4'h0: ADV_TIMER0 channel 0 4'h1: ADV_TIMER0 channel 1 4'h2: ADV_TIMER0 channel 2 4'h3: ADV_TIMER0 channel 3 4'h4: ADV_TIMER1 channel 0 4'h5: ADV_TIMER1 channel 1 4'h6: ADV_TIMER1 channel 2 4'h7: ADV_TIMER1 channel 3 4'h8: ADV_TIMER2 channel 0 4'h9: ADV_TIMER2 channel 1 4'hA: ADV_TIMER2 channel 2 4'hB: ADV_TIMER2 channel 3 4'hC: ADV_TIMER3 channel 0 4'hD: ADV_TIMER3 channel 1 4'hE: ADV_TIMER3 channel 2 4'hF: ADV_TIMER3 channel 3.| - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15:12|R/W|SEL3|ADV_TIMER output event 0 source configuration bitfiled: 4'h0: ADV_TIMER0 channel 0 4'h1: ADV_TIMER0 channel 1 4'h2: ADV_TIMER0 channel 2 4'h3: ADV_TIMER0 channel 3 4'h4: ADV_TIMER1 channel 0 4'h5: ADV_TIMER1 channel 1 4'h6: ADV_TIMER1 channel 2 4'h7: ADV_TIMER1 channel 3 4'h8: ADV_TIMER2 channel 0 4'h9: ADV_TIMER2 channel 1 4'hA: ADV_TIMER2 channel 2 4'hB: ADV_TIMER2 channel 3 4'hC: ADV_TIMER3 channel 0 4'hD: ADV_TIMER3 channel 1 4'hE: ADV_TIMER3 channel 2 4'hF: ADV_TIMER3 channel 3.| - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |19:16|R/W|ENA |ADV_TIMER output event enable configuration bitfield. ENA[i]=1 enables output event i generation. | - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+======================================================================================================================================================================================================================+ + |3:0 |R/W|SEL0|0x0 |Select source of output event 0: 0: timer 0 channel 0; 1: timer 0 channel 1; 2: timer 0 channel 2; 3: timer 0 channel 3; 4: timer 1 channel 0; 5: timer 1 channel 1; ... 14: timer 3 channel 2; 15: timer 3 channel 3| + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:4 |R/W|SEL1|0x0 |Select source of output event 1: 0: timer 0 channel 0; 1: timer 0 channel 1; 2: timer 0 channel 2; 3: timer 0 channel 3; 4: timer 1 channel 0; 5: timer 1 channel 1; ... 14: timer 3 channel 2; 15: timer 3 channel 3| + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |11:8 |R/W|SEL2|0x0 |Select source of output event 2: 0: timer 0 channel 0; 1: timer 0 channel 1; 2: timer 0 channel 2; 3: timer 0 channel 3; 4: timer 1 channel 0; 5: timer 1 channel 1; ... 14: timer 3 channel 2; 15: timer 3 channel 3| + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:12|R/W|SEL3|0x0 |Select source of output event 3: 0: timer 0 channel 0; 1: timer 0 channel 1; 2: timer 0 channel 2; 3: timer 0 channel 3; 4: timer 1 channel 0; 5: timer 1 channel 1; ... 14: timer 3 channel 2; 15: timer 3 channel 3| + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |19:16|R/W|ENA |0x0 |Output events enable: generation of event i is enabled if bit i=1 | + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _adv_timer_CG: +.. _adv_timer__CG: CG "" -ADV_TIMERS channels clock gating configuration register. +Channels clock gating configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================+ - |3:0 |R/W|ENA |ADV_TIMER clock gating configuration bitfield. ENA[i]=0: clock gate ADV_TIMERi. ENA[i]=1: enable ADV_TIMERi. | - +-----+---+----+-----------------------------------------------------------------------------------------------------------------------------------------+ - |7:4 |R/W|MUX |ADV_TIMER clock mux configuration bitfield. MUX[i]=0: Use SoC clock as clock source. MUX[i]=1: Use fast reference clock as clock source. | - +-----+---+----+-----------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==================================================================================================+ + |3:0 |R/W|ENA |0x0 |Enable timers: bit i=0 gates the clock of timer i, bit i=1 enables timer i | + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ + |7:4 |R/W|MUX |0x0 |Timers main clock selection: bit i=0: timer i uses SOC clock; bit i=1: timer i uses REF FAST clock| + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ -.. _adv_timer_CH_MUX: +.. _adv_timer__CH_MUX: CH_MUX """""" -ADV_TIMER channel select - -.. table:: - - +-----+---+--------+-----------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+===================================================================================================================================+ - |2:0 |R/W|CH_SEL_0|Selects channel to output to pads: 4'h0 to 4'h3 ADV_TIMER0 counter channel bit 0-3, 4'h4 to 4'h7 ADV_TIMER1 counter channel bit 0-3| - +-----+---+--------+-----------------------------------------------------------------------------------------------------------------------------------+ - |5:3 |R/W|CH_SEL_1|Selects channel to output to pads: 4'h0 to 4'h3 ADV_TIMER2 counter channel bit 0-3, 4'h4 to 4'h7 ADV_TIMER3 counter channel bit 0-3| - +-----+---+--------+-----------------------------------------------------------------------------------------------------------------------------------+ - |8:6 |R/W|CH_SEL_2|Selects channel to output to pads: 4'h0 to 4'h3 ADV_TIMER0 counter channel bit 0-3, 4'h4 to 4'h7 ADV_TIMER1 counter channel bit 0-3| - +-----+---+--------+-----------------------------------------------------------------------------------------------------------------------------------+ - |11:9 |R/W|CH_SEL_3|Selects channel to output to pads: 4'h0 to 4'h3 ADV_TIMER2 counter channel bit 0-3, 4'h4 to 4'h7 ADV_TIMER3 counter channel bit 0-3| - +-----+---+--------+-----------------------------------------------------------------------------------------------------------------------------------+ - |14:12|R/W|CH_SEL_4|Selects channel to output to pads: 4'h0 to 4'h3 ADV_TIMER0 counter channel bit 0-3, 4'h4 to 4'h7 ADV_TIMER1 counter channel bit 0-3| - +-----+---+--------+-----------------------------------------------------------------------------------------------------------------------------------+ - |17:15|R/W|CH_SEL_5|Selects channel to output to pads: 4'h0 to 4'h3 ADV_TIMER2 counter channel bit 0-3, 4'h4 to 4'h7 ADV_TIMER3 counter channel bit 0-3| - +-----+---+--------+-----------------------------------------------------------------------------------------------------------------------------------+ - |20:18|R/W|CH_SEL_6|Selects channel to output to pads: 4'h0 to 4'h3 ADV_TIMER0 counter channel bit 0-3, 4'h4 to 4'h7 ADV_TIMER1 counter channel bit 0-3| - +-----+---+--------+-----------------------------------------------------------------------------------------------------------------------------------+ - |23:21|R/W|CH_SEL_7|Selects channel to output to pads: 4'h0 to 4'h3 ADV_TIMER2 counter channel bit 0-3, 4'h4 to 4'h7 ADV_TIMER3 counter channel bit 0-3| - +-----+---+--------+-----------------------------------------------------------------------------------------------------------------------------------+ +Channels output configuration + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+================================================================================================================+ + |2:0 |R/W|CH_SEL_0|0x0 |Selects channel output sent to PWM0 output: 0 to 3: channel 0 to 3 of timer 0; 4 to 7: channel 0 to 3 of timer 1| + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------+ + |5:3 |R/W|CH_SEL_1|0x0 |Selects channel output sent to PWM1 output: 0 to 3: channel 0 to 3 of timer 2; 4 to 7: channel 0 to 3 of timer 3| + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------+ + |8:6 |R/W|CH_SEL_2|0x0 |Selects channel output sent to PWM2 output: 0 to 3: channel 0 to 3 of timer 0; 4 to 7: channel 0 to 3 of timer 1| + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------+ + |11:9 |R/W|CH_SEL_3|0x0 |Selects channel output sent to PWM3 output: 0 to 3: channel 0 to 3 of timer 2; 4 to 7: channel 0 to 3 of timer 3| + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------+ + |14:12|R/W|CH_SEL_4|0x0 |Selects channel output sent to PWM4 output: 0 to 3: channel 0 to 3 of timer 0; 4 to 7: channel 0 to 3 of timer 1| + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------+ + |17:15|R/W|CH_SEL_5|0x0 |Selects channel output sent to PWM5 output: 0 to 3: channel 0 to 3 of timer 2; 4 to 7: channel 0 to 3 of timer 3| + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------+ + |20:18|R/W|CH_SEL_6|0x0 |Selects channel output sent to PWM6 output: 0 to 3: channel 0 to 3 of timer 0; 4 to 7: channel 0 to 3 of timer 1| + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------+ + |23:21|R/W|CH_SEL_7|0x0 |Selects channel output sent to PWM7 output: 0 to 3: channel 0 to 3 of timer 2; 4 to 7: channel 0 to 3 of timer 3| + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/apb_soc_ctrl.rst b/rtos/pulp/gap_archi/doc/ips/apb_soc_ctrl.rst index 4d94e1e2a..050bf878a 100644 --- a/rtos/pulp/gap_archi/doc/ips/apb_soc_ctrl.rst +++ b/rtos/pulp/gap_archi/doc/ips/apb_soc_ctrl.rst @@ -8,193 +8,182 @@ Register map Overview """""""" -.. table:: - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - | Name |Offset|Width| Description | - +====================================================================+======+=====+===========================================================+ - |:ref:`INFO` | 0| 32|Core information register. | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`FC_BOOT` | 4| 32|Boot address | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`FC_FETCH` | 8| 32|FC Fetch enable | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CL_ISOLATE` | 12| 32|Isolate cluster register | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADFUN0` | 16| 32|Mux config register (pad 0-15) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADFUN1` | 20| 32|Mux config register (pad 16-31) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADFUN2` | 24| 32|Mux config register (pad 32-47) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADFUN3` | 28| 32|Mux config register (pad 48-63) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADFUN4` | 32| 32|Mux config register (pad 64-79) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADFUN5` | 36| 32|Mux config register (pad 80-89) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`FEATURE_DISABLEMENT_SOC`| 40| 32|Feature disablement from SoC domain | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED0` | 44| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG0` | 48| 32|Function register (pad 0 to 3) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG1` | 52| 32|Function register (pad 4 to 7) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG2` | 56| 32|Function register (pad 8 to 11) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG3` | 60| 32|Function register (pad 12 to 15) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG4` | 64| 32|Function register (pad 16 to 19) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG5` | 68| 32|Function register (pad 20 to 23) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG6` | 72| 32|Function register (pad 24 to 27) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG7` | 76| 32|Function register (pad 28 to 31) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG8` | 80| 32|Function register (pad 32 to 35) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG9` | 84| 32|Function register (pad 36 to 39) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG10` | 88| 32|Function register (pad 40 to 43) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG11` | 92| 32|Function register (pad 44 to 47) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG12` | 96| 32|Function register (pad 48 to 51) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG13` | 100| 32|Function register (pad 52 to 55) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG14` | 104| 32|Function register (pad 56 to 59) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG15` | 108| 32|Function register (pad 60 to 63) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG16` | 112| 32|Function register (pad 64 to 67) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG17` | 116| 32|Function register (pad 68 to 71) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG18` | 120| 32|Function register (pad 72 to 75) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG19` | 124| 32|Function register (pad 76 to 79) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG20` | 128| 32|Function register (pad 80 to 83) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG21` | 132| 32|Function register (pad 84 to 87) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG22` | 136| 32|Function register (pad 88 to 89, only first 16 bits used) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`REG_REPROG_PAD0` | 144| 32|Controls reprogrammable pads 27,28,29,30,34 | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`REG_REPROG_PAD1` | 148| 32|Controls reprogrammable pads 35,40,41,42,43 | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`REG_REPROG_PAD2` | 152| 32|Controls reprogrammable pads 44,45,60,61,62 | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`REG_REPROG_PAD3` | 156| 32|Controls reprogrammable pads 63,65,66,67,68 | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED1` | 160| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED2` | 164| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED3` | 168| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED4` | 172| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CL_BUSY` | 176| 32|Cluster busy register | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`JTAGREG` | 180| 32|JTAG external register | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`REF_FAST_CLK_DIV` | 184| 32|Read only, reference fast clk divided by power of 2 | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SW_RST` | 188| 32|Software reset, reboot | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CORESTATUS` | 192| 32|EOC and chip status register | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`BOOTSEL` | 196| 32|Value of pad bootsel | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`WD_RST_RST` | 200| 32|Rearm WD timeout | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`WD_RST_SET` | 204| 32|Set WD timer | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RWM_CSI2` | 208| 32|RWM for CSI2 | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`IDLE_MODE` | 212| 32|Activates IDLE MODE | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RWM_ANC` | 216| 32|RWM for ANC | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`REF_CLK_MUX` | 220| 32|Ref clock mux 0: 32Khz 1: ref fast | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SUPERVISOR_DBG` | 224| 32| | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`DBG_CTRL` | 228| 32|Debug access control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED5` | 232| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED6` | 236| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CLK_DIV_I3C` | 240| 32|Clock divider for I3C | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CLK_EN_QUIDDIKEY` | 244| 32|Clock divider for QUIDDIKEY | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_CTRL_INFO` | 248| 32|Safe domain's Sleep control info | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`VERSION` | 252| 32|Show chip version | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_SPIS_CTRL` | 256| 32|Sleep SPIS control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_CTRL` | 260| 32|Sleep control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_GPIO_CTRL` | 264| 32|Sleep GPIO control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_CNT_CTRL` | 268| 32|Sleep Counter control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`REG_OSC_CTRL` | 272| 32|Controls fast oscillator | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED7` | 236| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CLK_DIV_REF_FAST_POW2` | 280| 32|Controls fast oscillator pow2 divider | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`FEATURE_DISABLEMENT` | 288| 32|Feature disablement from always on (safe) domain | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_PAD_CFG0` | 320| 32|Sleep pad control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_PAD_CFG1` | 324| 32|Sleep pad control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_PAD_CFG2` | 328| 32|Sleep pad control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_PAD_CFG3` | 332| 32|Sleep pad control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_PAD_CFG4` | 336| 32|Sleep pad control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_PAD_CFG5` | 340| 32|Sleep pad control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_PAD_CFG6` | 344| 32|Sleep pad control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`L2_CTRL_ACTIVE` | 348| 32|Controls L2 power | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`L2_PWR_ACTIVE` | 352| 32|Controls L2 power | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`NEVACFG` | 356| 32|NEVA config | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`TRCCFG` | 360| 32|TRC config | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RWM_L2_MEM` | 364| 32|Read/write margins for L2 and ROM memories | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CLU_SW_RSTN` | 368| 32|Cluster software reset | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`L2_PWR` | 372| 32|Controls L2 power | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`L2_CTRL` | 376| 32|Controls L2 power | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`BORCFG` | 384| 32|Controls the brown-out reset | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RARMODE` | 388| 32|Controls configuration of the DC-DC modulation at low loads| - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`ABBCFG` | 392| 32|Used to disable adaptive body-bias | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`L2_ACK` | 396| 32|Acknowledge/status signals from L2 memories | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - -.. _apb_soc_ctrl_INFO: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + | Name |Offset|Width| Description | + +=================================================================+======+=====+===========================================================+ + |:ref:`INFO` | 0| 32|Core information register. | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`FC_BOOT` | 4| 32|Boot address | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`FC_FETCH` | 8| 32|FC Fetch enable | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CL_ISOLATE` | 12| 32|Isolate cluster register | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADFUN0` | 16| 32|Mux config register (pad 0-15) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADFUN1` | 20| 32|Mux config register (pad 16-31) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADFUN2` | 24| 32|Mux config register (pad 32-47) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADFUN3` | 28| 32|Mux config register (pad 48-63) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADFUN4` | 32| 32|Mux config register (pad 64-79) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADFUN5` | 36| 32|Mux config register (pad 80-89) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`FEATURE_DISABLE_QK` | 40| 32|Feature disablement for Quiddikey features | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG0` | 48| 32|Function register (pad 0 to 3) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG1` | 52| 32|Function register (pad 4 to 7) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG2` | 56| 32|Function register (pad 8 to 11) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG3` | 60| 32|Function register (pad 12 to 15) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG4` | 64| 32|Function register (pad 16 to 19) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG5` | 68| 32|Function register (pad 20 to 23) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG6` | 72| 32|Function register (pad 24 to 27) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG7` | 76| 32|Function register (pad 28 to 31) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG8` | 80| 32|Function register (pad 32 to 35) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG9` | 84| 32|Function register (pad 36 to 39) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG10` | 88| 32|Function register (pad 40 to 43) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG11` | 92| 32|Function register (pad 44 to 47) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG12` | 96| 32|Function register (pad 48 to 51) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG13` | 100| 32|Function register (pad 52 to 55) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG14` | 104| 32|Function register (pad 56 to 59) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG15` | 108| 32|Function register (pad 60 to 63) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG16` | 112| 32|Function register (pad 64 to 67) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG17` | 116| 32|Function register (pad 68 to 71) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG18` | 120| 32|Function register (pad 72 to 75) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG19` | 124| 32|Function register (pad 76 to 79) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG20` | 128| 32|Function register (pad 80 to 83) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG21` | 132| 32|Function register (pad 84 to 87) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG22` | 136| 32|Function register (pad 88 to 89) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`REG_REPROG_PAD0` | 144| 32|Controls reprogrammable pads 27,28,29,30,34 | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`REG_REPROG_PAD1` | 148| 32|Controls reprogrammable pads 35,40,41,42,43 | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`REG_REPROG_PAD2` | 152| 32|Controls reprogrammable pads 44,45,60,61,62 | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`REG_REPROG_PAD3` | 156| 32|Controls reprogrammable pads 63,65,66,67,68 | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CL_BUSY` | 176| 32|Cluster busy register | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`JTAGREG` | 180| 32|JTAG external register | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`REF_FAST_CLK_DIV` | 184| 32|Read only, reference fast clk divided by power of 2 | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SW_RST` | 188| 32|Software reset, reboot | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CORESTATUS` | 192| 32|EOC and chip status register | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`BOOTSEL` | 196| 32|Value of pad bootsel | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`WD_RST_RST` | 200| 32|Rearm WD timeout | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`WD_RST_SET` | 204| 32|Set WD timer | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`RWM_CSI2` | 208| 32|Margin adjust settings for CSI2 Controller | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`IDLE_MODE` | 212| 32|Activates IDLE MODE | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`RWM_ANC` | 216| 32|Margin adjust settings for SFU | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`REF_CLK_MUX` | 220| 32|Reference clock selection | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SUPERVISOR_DBG` | 224| 32| | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`DBG_CTRL` | 228| 32|Debug access control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CLK_DIV_I3C` | 240| 32|Clock divider for I3C | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CLK_EN_QUIDDIKEY` | 244| 32|Quiddikey enablement | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_CTRL_INFO` | 248| 32|Safe domain's Sleep control info | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`VERSION` | 252| 32|Show chip version (User controlled) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_SPIS_CTRL` | 256| 32|Sleep SPIS control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_CTRL` | 260| 32|Sleep control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_GPIO_CTRL` | 264| 32|Sleep GPIO control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_CNT_CTRL` | 268| 32|Sleep Counter control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`REG_OSC_CTRL` | 272| 32|Controls fast oscillator | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CLK_DIV_REF_FAST_POW2`| 280| 32|Controls fast oscillator pow2 divider | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`FEATURE_DISABLE` | 288| 32|Feature disablement from always on (safe) domain | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_PAD_CFG0` | 320| 32|Sleep pad control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_PAD_CFG1` | 324| 32|Sleep pad control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_PAD_CFG2` | 328| 32|Sleep pad control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_PAD_CFG3` | 332| 32|Sleep pad control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_PAD_CFG4` | 336| 32|Sleep pad control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_PAD_CFG5` | 340| 32|Sleep pad control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_PAD_CFG6` | 344| 32|Sleep pad control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`L2_CTRL_ACTIVE` | 348| 32|Controls L2 power when SOC is powered on | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`L2_PWR_ACTIVE` | 352| 32|Controls L2 power when SOC is powered on | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`NEVACFG` | 356| 32|NEVA config | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`TRCCFG` | 360| 32|TRC config | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`RWM_L2_MEM` | 364| 32|Read/write margins for L2 and ROM memories | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CLU_SW_RSTN` | 368| 32|Cluster software reset | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`L2_PWR` | 372| 32|Controls L2 power when SOC is off (deepsleep) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`L2_CTRL` | 376| 32|Controls L2 power when SOC is off (deepsleep) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`BORCFG` | 384| 32|Controls the brown-out reset | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`RARMODE` | 388| 32|Controls configuration of the DC-DC modulation at low loads| + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`ABBCFG` | 392| 32|Used to disable adaptive body-bias | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`L2_ACK` | 396| 32|Acknowledge/status signals from L2 memories | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + +.. _apb_soc_ctrl__INFO: INFO """" @@ -202,16 +191,18 @@ INFO Core information register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+==================+ - |15:0 |R |NB_CL |Number of clusters| - +-----+---+--------+------------------+ - |31:16|R |NB_CORES|Number of cores | - +-----+---+--------+------------------+ + +-----+---+--------+------+------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+========+======+==================+ + |15:0 |R |NB_CL |0x0008|Number of clusters| + +-----+---+--------+------+------------------+ + |31:16|R |NB_CORES|0x0001|Number of cores | + +-----+---+--------+------+------------------+ -.. _apb_soc_ctrl_FC_BOOT: +.. _apb_soc_ctrl__FC_BOOT: FC_BOOT """"""" @@ -219,14 +210,16 @@ FC_BOOT Boot address .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===============+ - |31:0 |R/W|ADDR|FC Boot Address| - +-----+---+----+---------------+ + +-----+---+----+----------+---------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+===============+ + |31:0 |R/W|ADDR|0x1A000000|FC Boot Address| + +-----+---+----+----------+---------------+ -.. _apb_soc_ctrl_FC_FETCH: +.. _apb_soc_ctrl__FC_FETCH: FC_FETCH """""""" @@ -234,14 +227,16 @@ FC_FETCH FC Fetch enable .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+---------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+===============+ - | 0|R/W|FC_FE|FC Fetch Enable| - +-----+---+-----+---------------+ + +-----+---+-----+-----+---------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===============+ + | 0|R/W|FC_FE|0x0 |FC Fetch Enable| + +-----+---+-----+-----+---------------+ -.. _apb_soc_ctrl_CL_ISOLATE: +.. _apb_soc_ctrl__CL_ISOLATE: CL_ISOLATE """""""""" @@ -249,14 +244,16 @@ CL_ISOLATE Isolate cluster register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===============================================================================================+ - | 0|R/W|EN |Isolate cluster. Inhibits AXI transactions from cluster to SoC: - 1'b0: Disable - 1'b1: Enable| - +-----+---+----+-----------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=======================================================================================+ + | 0|R/W|EN |0x1 |Isolate cluster. Inhibits AXI transactions from cluster to SoC: b0: Disable; b1: Enable| + +-----+---+----+-----+---------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_PADFUN0: +.. _apb_soc_ctrl__PADFUN0: PADFUN0 """"""" @@ -264,44 +261,46 @@ PADFUN0 Mux config register (pad 0-15) .. table:: - - +-----+---+---------+-------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+=====================================+ - |1:0 |R/W|Padmux_0 |Selects between: hyper0_ckn / gpio0 | - +-----+---+---------+-------------------------------------+ - |3:2 |R/W|Padmux_1 |Selects between: hyper0_ck / gpio1 | - +-----+---+---------+-------------------------------------+ - |5:4 |R/W|Padmux_2 |Selects between: hyper0_dq0 / gpio2 | - +-----+---+---------+-------------------------------------+ - |7:6 |R/W|Padmux_3 |Selects between: hyper0_dq1 / gpio3 | - +-----+---+---------+-------------------------------------+ - |9:8 |R/W|Padmux_4 |Selects between: hyper0_dq2 / gpio4 | - +-----+---+---------+-------------------------------------+ - |11:10|R/W|Padmux_5 |Selects between: hyper0_dq3 / gpio5 | - +-----+---+---------+-------------------------------------+ - |13:12|R/W|Padmux_6 |Selects between: hyper0_dq4 / gpio6 | - +-----+---+---------+-------------------------------------+ - |15:14|R/W|Padmux_7 |Selects between: hyper0_dq5 / gpio7 | - +-----+---+---------+-------------------------------------+ - |17:16|R/W|Padmux_8 |Selects between: hyper0_dq6 / gpio8 | - +-----+---+---------+-------------------------------------+ - |19:18|R/W|Padmux_9 |Selects between: hyper0_dq7 / gpio9 | - +-----+---+---------+-------------------------------------+ - |21:20|R/W|Padmux_10|Selects between: hyper0_csn0 / gpio10| - +-----+---+---------+-------------------------------------+ - |23:22|R/W|Padmux_11|Selects between: hyper0_csn1 / gpio11| - +-----+---+---------+-------------------------------------+ - |25:24|R/W|Padmux_12|Selects between: hyper0_rwds / gpio12| - +-----+---+---------+-------------------------------------+ - |27:26|R/W|Padmux_13|Selects between: hyper1_ckn / gpio13 | - +-----+---+---------+-------------------------------------+ - |29:28|R/W|Padmux_14|Selects between: hyper1_ck / gpio14 | - +-----+---+---------+-------------------------------------+ - |31:30|R/W|Padmux_15|Selects between: hyper1_dq0 / gpio15 | - +-----+---+---------+-------------------------------------+ - -.. _apb_soc_ctrl_PADFUN1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+-------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=====================================+ + |1:0 |R/W|PADMUX_0 |0x0 |Selects between: hyper0_ckn / gpio0 | + +-----+---+---------+-----+-------------------------------------+ + |3:2 |R/W|PADMUX_1 |0x0 |Selects between: hyper0_ck / gpio1 | + +-----+---+---------+-----+-------------------------------------+ + |5:4 |R/W|PADMUX_2 |0x0 |Selects between: hyper0_dq0 / gpio2 | + +-----+---+---------+-----+-------------------------------------+ + |7:6 |R/W|PADMUX_3 |0x0 |Selects between: hyper0_dq1 / gpio3 | + +-----+---+---------+-----+-------------------------------------+ + |9:8 |R/W|PADMUX_4 |0x0 |Selects between: hyper0_dq2 / gpio4 | + +-----+---+---------+-----+-------------------------------------+ + |11:10|R/W|PADMUX_5 |0x0 |Selects between: hyper0_dq3 / gpio5 | + +-----+---+---------+-----+-------------------------------------+ + |13:12|R/W|PADMUX_6 |0x0 |Selects between: hyper0_dq4 / gpio6 | + +-----+---+---------+-----+-------------------------------------+ + |15:14|R/W|PADMUX_7 |0x0 |Selects between: hyper0_dq5 / gpio7 | + +-----+---+---------+-----+-------------------------------------+ + |17:16|R/W|PADMUX_8 |0x0 |Selects between: hyper0_dq6 / gpio8 | + +-----+---+---------+-----+-------------------------------------+ + |19:18|R/W|PADMUX_9 |0x0 |Selects between: hyper0_dq7 / gpio9 | + +-----+---+---------+-----+-------------------------------------+ + |21:20|R/W|PADMUX_10|0x0 |Selects between: hyper0_csn0 / gpio10| + +-----+---+---------+-----+-------------------------------------+ + |23:22|R/W|PADMUX_11|0x0 |Selects between: hyper0_csn1 / gpio11| + +-----+---+---------+-----+-------------------------------------+ + |25:24|R/W|PADMUX_12|0x0 |Selects between: hyper0_rwds / gpio12| + +-----+---+---------+-----+-------------------------------------+ + |27:26|R/W|PADMUX_13|0x0 |Selects between: hyper1_ckn / gpio13 | + +-----+---+---------+-----+-------------------------------------+ + |29:28|R/W|PADMUX_14|0x0 |Selects between: hyper1_ck / gpio14 | + +-----+---+---------+-----+-------------------------------------+ + |31:30|R/W|PADMUX_15|0x0 |Selects between: hyper1_dq0 / gpio15 | + +-----+---+---------+-----+-------------------------------------+ + +.. _apb_soc_ctrl__PADFUN1: PADFUN1 """"""" @@ -309,44 +308,46 @@ PADFUN1 Mux config register (pad 16-31) .. table:: - - +-----+---+---------+------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+================================================+ - |1:0 |R/W|Padmux_16|Selects between: hyper1_dq1 / gpio16 | - +-----+---+---------+------------------------------------------------+ - |3:2 |R/W|Padmux_17|Selects between: hyper1_dq2 / gpio17 | - +-----+---+---------+------------------------------------------------+ - |5:4 |R/W|Padmux_18|Selects between: hyper1_dq3 / gpio18 | - +-----+---+---------+------------------------------------------------+ - |7:6 |R/W|Padmux_19|Selects between: hyper1_dq4 / gpio19 | - +-----+---+---------+------------------------------------------------+ - |9:8 |R/W|Padmux_20|Selects between: hyper1_dq5 / gpio20 | - +-----+---+---------+------------------------------------------------+ - |11:10|R/W|Padmux_21|Selects between: hyper1_dq6 / gpio21 | - +-----+---+---------+------------------------------------------------+ - |13:12|R/W|Padmux_22|Selects between: hyper1_dq7 / gpio22 | - +-----+---+---------+------------------------------------------------+ - |15:14|R/W|Padmux_23|Selects between: hyper1_csn0 / gpio23 | - +-----+---+---------+------------------------------------------------+ - |17:16|R/W|Padmux_24|Selects between: hyper1_csn1 / gpio24 | - +-----+---+---------+------------------------------------------------+ - |19:18|R/W|Padmux_25|Selects between: hyper1_rwds / gpio25 | - +-----+---+---------+------------------------------------------------+ - |21:20|R/W|Padmux_26|Selects between: spi0_sck / gpio26 | - +-----+---+---------+------------------------------------------------+ - |23:22|R/W|Padmux_27|Selects between: mux_group_sel_spi0_cs0 / gpio27| - +-----+---+---------+------------------------------------------------+ - |25:24|R/W|Padmux_28|Selects between: mux_group_sel_spi0_cs1 / gpio28| - +-----+---+---------+------------------------------------------------+ - |27:26|R/W|Padmux_29|Selects between: mux_group_sel_spi0_cs2 / gpio29| - +-----+---+---------+------------------------------------------------+ - |29:28|R/W|Padmux_30|Selects between: mux_group_sel_spi0_cs3 / gpio30| - +-----+---+---------+------------------------------------------------+ - |31:30|R/W|Padmux_31|Selects between: spi0_sdo / gpio31 | - +-----+---+---------+------------------------------------------------+ - -.. _apb_soc_ctrl_PADFUN2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+================================================+ + |1:0 |R/W|PADMUX_16|0x0 |Selects between: hyper1_dq1 / gpio16 | + +-----+---+---------+-----+------------------------------------------------+ + |3:2 |R/W|PADMUX_17|0x0 |Selects between: hyper1_dq2 / gpio17 | + +-----+---+---------+-----+------------------------------------------------+ + |5:4 |R/W|PADMUX_18|0x0 |Selects between: hyper1_dq3 / gpio18 | + +-----+---+---------+-----+------------------------------------------------+ + |7:6 |R/W|PADMUX_19|0x0 |Selects between: hyper1_dq4 / gpio19 | + +-----+---+---------+-----+------------------------------------------------+ + |9:8 |R/W|PADMUX_20|0x0 |Selects between: hyper1_dq5 / gpio20 | + +-----+---+---------+-----+------------------------------------------------+ + |11:10|R/W|PADMUX_21|0x0 |Selects between: hyper1_dq6 / gpio21 | + +-----+---+---------+-----+------------------------------------------------+ + |13:12|R/W|PADMUX_22|0x0 |Selects between: hyper1_dq7 / gpio22 | + +-----+---+---------+-----+------------------------------------------------+ + |15:14|R/W|PADMUX_23|0x0 |Selects between: hyper1_csn0 / gpio23 | + +-----+---+---------+-----+------------------------------------------------+ + |17:16|R/W|PADMUX_24|0x0 |Selects between: hyper1_csn1 / gpio24 | + +-----+---+---------+-----+------------------------------------------------+ + |19:18|R/W|PADMUX_25|0x0 |Selects between: hyper1_rwds / gpio25 | + +-----+---+---------+-----+------------------------------------------------+ + |21:20|R/W|PADMUX_26|0x0 |Selects between: spi0_sck / gpio26 | + +-----+---+---------+-----+------------------------------------------------+ + |23:22|R/W|PADMUX_27|0x0 |Selects between: mux_group_sel_spi0_cs0 / gpio27| + +-----+---+---------+-----+------------------------------------------------+ + |25:24|R/W|PADMUX_28|0x0 |Selects between: mux_group_sel_spi0_cs1 / gpio28| + +-----+---+---------+-----+------------------------------------------------+ + |27:26|R/W|PADMUX_29|0x0 |Selects between: mux_group_sel_spi0_cs2 / gpio29| + +-----+---+---------+-----+------------------------------------------------+ + |29:28|R/W|PADMUX_30|0x0 |Selects between: mux_group_sel_spi0_cs3 / gpio30| + +-----+---+---------+-----+------------------------------------------------+ + |31:30|R/W|PADMUX_31|0x0 |Selects between: spi0_sdo / gpio31 | + +-----+---+---------+-----+------------------------------------------------+ + +.. _apb_soc_ctrl__PADFUN2: PADFUN2 """"""" @@ -354,44 +355,46 @@ PADFUN2 Mux config register (pad 32-47) .. table:: - - +-----+---+---------+-----------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+===========================================================+ - |1:0 |R/W|Padmux_32|Selects between: spi0_sdi / gpio32 | - +-----+---+---------+-----------------------------------------------------------+ - |3:2 |R/W|Padmux_33|Selects between: spi1_sck / gpio33 / uart3_clk | - +-----+---+---------+-----------------------------------------------------------+ - |5:4 |R/W|Padmux_34|Selects between: mux_group_sel_spi1_cs0 / gpio34 | - +-----+---+---------+-----------------------------------------------------------+ - |7:6 |R/W|Padmux_35|Selects between: mux_group_sel_spi1_cs1 / gpio35 | - +-----+---+---------+-----------------------------------------------------------+ - |9:8 |R/W|Padmux_36|Selects between: spi1_cs2 / gpio36 / uart3_cts / spi1_sdio2| - +-----+---+---------+-----------------------------------------------------------+ - |11:10|R/W|Padmux_37|Selects between: spi1_cs3 / gpio37 / uart3_rts / spi1_sdio3| - +-----+---+---------+-----------------------------------------------------------+ - |13:12|R/W|Padmux_38|Selects between: spi1_sdo / gpio38 | - +-----+---+---------+-----------------------------------------------------------+ - |15:14|R/W|Padmux_39|Selects between: spi1_sdi / gpio39 | - +-----+---+---------+-----------------------------------------------------------+ - |17:16|R/W|Padmux_40|Selects between: mux_group_sel_i2c0_sda / gpio40 | - +-----+---+---------+-----------------------------------------------------------+ - |19:18|R/W|Padmux_41|Selects between: mux_group_sel_i2c0_scl / gpio41 | - +-----+---+---------+-----------------------------------------------------------+ - |21:20|R/W|Padmux_42|Selects between: mux_group_sel_i2c1_sda / gpio42 | - +-----+---+---------+-----------------------------------------------------------+ - |23:22|R/W|Padmux_43|Selects between: mux_group_sel_i2c1_scl / gpio43 | - +-----+---+---------+-----------------------------------------------------------+ - |25:24|R/W|Padmux_44|Selects between: mux_group_sel_i2c2_sda / gpio44 | - +-----+---+---------+-----------------------------------------------------------+ - |27:26|R/W|Padmux_45|Selects between: mux_group_sel_i2c2_scl / gpio45 | - +-----+---+---------+-----------------------------------------------------------+ - |29:28|R/W|Padmux_46|Selects between: i3c_sda / gpio46 / i2c3_sda / spi0_sdio2 | - +-----+---+---------+-----------------------------------------------------------+ - |31:30|R/W|Padmux_47|Selects between: i3c_scl / gpio47 / i2c3_scl / spi0_sdio3 | - +-----+---+---------+-----------------------------------------------------------+ - -.. _apb_soc_ctrl_PADFUN3: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+===========================================================+ + |1:0 |R/W|PADMUX_32|0x0 |Selects between: spi0_sdi / gpio32 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |3:2 |R/W|PADMUX_33|0x0 |Selects between: spi1_sck / gpio33 / uart3_clk | + +-----+---+---------+-----+-----------------------------------------------------------+ + |5:4 |R/W|PADMUX_34|0x0 |Selects between: mux_group_sel_spi1_cs0 / gpio34 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |7:6 |R/W|PADMUX_35|0x0 |Selects between: mux_group_sel_spi1_cs1 / gpio35 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |9:8 |R/W|PADMUX_36|0x0 |Selects between: spi1_cs2 / gpio36 / uart3_cts / spi1_sdio2| + +-----+---+---------+-----+-----------------------------------------------------------+ + |11:10|R/W|PADMUX_37|0x0 |Selects between: spi1_cs3 / gpio37 / uart3_rts / spi1_sdio3| + +-----+---+---------+-----+-----------------------------------------------------------+ + |13:12|R/W|PADMUX_38|0x0 |Selects between: spi1_sdo / gpio38 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |15:14|R/W|PADMUX_39|0x0 |Selects between: spi1_sdi / gpio39 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |17:16|R/W|PADMUX_40|0x0 |Selects between: mux_group_sel_i2c0_sda / gpio40 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |19:18|R/W|PADMUX_41|0x0 |Selects between: mux_group_sel_i2c0_scl / gpio41 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |21:20|R/W|PADMUX_42|0x0 |Selects between: mux_group_sel_i2c1_sda / gpio42 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |23:22|R/W|PADMUX_43|0x0 |Selects between: mux_group_sel_i2c1_scl / gpio43 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |25:24|R/W|PADMUX_44|0x0 |Selects between: mux_group_sel_i2c2_sda / gpio44 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |27:26|R/W|PADMUX_45|0x0 |Selects between: mux_group_sel_i2c2_scl / gpio45 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |29:28|R/W|PADMUX_46|0x0 |Selects between: i3c_sda / gpio46 / i2c3_sda / spi0_sdio2 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |31:30|R/W|PADMUX_47|0x0 |Selects between: i3c_scl / gpio47 / i2c3_scl / spi0_sdio3 | + +-----+---+---------+-----+-----------------------------------------------------------+ + +.. _apb_soc_ctrl__PADFUN3: PADFUN3 """"""" @@ -399,44 +402,46 @@ PADFUN3 Mux config register (pad 48-63) .. table:: - - +-----+---+---------+-------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+=================================================+ - |1:0 |R/W|Padmux_48|Selects between: i2s0_sck / gpio48 / uart2_clk | - +-----+---+---------+-------------------------------------------------+ - |3:2 |R/W|Padmux_49|Selects between: i2s0_ws / gpio49 | - +-----+---+---------+-------------------------------------------------+ - |5:4 |R/W|Padmux_50|Selects between: i2s0_sdi / gpio50 | - +-----+---+---------+-------------------------------------------------+ - |7:6 |R/W|Padmux_51|Selects between: i2s0_sdo / gpio51 | - +-----+---+---------+-------------------------------------------------+ - |9:8 |R/W|Padmux_52|Selects between: i2s1_sck / gpio52 | - +-----+---+---------+-------------------------------------------------+ - |11:10|R/W|Padmux_53|Selects between: i2s1_ws / gpio53 / spi2_cs1 | - +-----+---+---------+-------------------------------------------------+ - |13:12|R/W|Padmux_54|Selects between: i2s1_sdi / gpio54 / spi2_cs2 | - +-----+---+---------+-------------------------------------------------+ - |15:14|R/W|Padmux_55|Selects between: i2s1_sdo / gpio55 / spi2_cs3 | - +-----+---+---------+-------------------------------------------------+ - |17:16|R/W|Padmux_56|Selects between: i2s2_sck / gpio56 / spi2_sck | - +-----+---+---------+-------------------------------------------------+ - |19:18|R/W|Padmux_57|Selects between: i2s2_ws / gpio57 / spi2_cs0 | - +-----+---+---------+-------------------------------------------------+ - |21:20|R/W|Padmux_58|Selects between: i2s2_sdi / gpio58 / spi2_sdi | - +-----+---+---------+-------------------------------------------------+ - |23:22|R/W|Padmux_59|Selects between: i2s2_sdo / gpio59 / spi2_sdo | - +-----+---+---------+-------------------------------------------------+ - |25:24|R/W|Padmux_60|Selects between: mux_group_sel_uart0_rx / gpio60 | - +-----+---+---------+-------------------------------------------------+ - |27:26|R/W|Padmux_61|Selects between: mux_group_sel_uart0_tx / gpio61 | - +-----+---+---------+-------------------------------------------------+ - |29:28|R/W|Padmux_62|Selects between: mux_group_sel_uart0_cts / gpio62| - +-----+---+---------+-------------------------------------------------+ - |31:30|R/W|Padmux_63|Selects between: mux_group_sel_uart0_rts / gpio63| - +-----+---+---------+-------------------------------------------------+ - -.. _apb_soc_ctrl_PADFUN4: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+-------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=================================================+ + |1:0 |R/W|PADMUX_48|0x0 |Selects between: i2s0_sck / gpio48 / uart2_clk | + +-----+---+---------+-----+-------------------------------------------------+ + |3:2 |R/W|PADMUX_49|0x0 |Selects between: i2s0_ws / gpio49 | + +-----+---+---------+-----+-------------------------------------------------+ + |5:4 |R/W|PADMUX_50|0x0 |Selects between: i2s0_sdi / gpio50 | + +-----+---+---------+-----+-------------------------------------------------+ + |7:6 |R/W|PADMUX_51|0x0 |Selects between: i2s0_sdo / gpio51 | + +-----+---+---------+-----+-------------------------------------------------+ + |9:8 |R/W|PADMUX_52|0x0 |Selects between: i2s1_sck / gpio52 | + +-----+---+---------+-----+-------------------------------------------------+ + |11:10|R/W|PADMUX_53|0x0 |Selects between: i2s1_ws / gpio53 / spi2_cs1 | + +-----+---+---------+-----+-------------------------------------------------+ + |13:12|R/W|PADMUX_54|0x0 |Selects between: i2s1_sdi / gpio54 / spi2_cs2 | + +-----+---+---------+-----+-------------------------------------------------+ + |15:14|R/W|PADMUX_55|0x0 |Selects between: i2s1_sdo / gpio55 / spi2_cs3 | + +-----+---+---------+-----+-------------------------------------------------+ + |17:16|R/W|PADMUX_56|0x0 |Selects between: i2s2_sck / gpio56 / spi2_sck | + +-----+---+---------+-----+-------------------------------------------------+ + |19:18|R/W|PADMUX_57|0x0 |Selects between: i2s2_ws / gpio57 / spi2_cs0 | + +-----+---+---------+-----+-------------------------------------------------+ + |21:20|R/W|PADMUX_58|0x0 |Selects between: i2s2_sdi / gpio58 / spi2_sdi | + +-----+---+---------+-----+-------------------------------------------------+ + |23:22|R/W|PADMUX_59|0x0 |Selects between: i2s2_sdo / gpio59 / spi2_sdo | + +-----+---+---------+-----+-------------------------------------------------+ + |25:24|R/W|PADMUX_60|0x0 |Selects between: mux_group_sel_uart0_rx / gpio60 | + +-----+---+---------+-----+-------------------------------------------------+ + |27:26|R/W|PADMUX_61|0x0 |Selects between: mux_group_sel_uart0_tx / gpio61 | + +-----+---+---------+-----+-------------------------------------------------+ + |29:28|R/W|PADMUX_62|0x0 |Selects between: mux_group_sel_uart0_cts / gpio62| + +-----+---+---------+-----+-------------------------------------------------+ + |31:30|R/W|PADMUX_63|0x0 |Selects between: mux_group_sel_uart0_rts / gpio63| + +-----+---+---------+-----+-------------------------------------------------+ + +.. _apb_soc_ctrl__PADFUN4: PADFUN4 """"""" @@ -444,44 +449,46 @@ PADFUN4 Mux config register (pad 64-79) .. table:: - - +-----+---+---------+-----------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+===========================================================+ - |1:0 |R/W|Padmux_64|Selects between: uart0_clk / gpio64 | - +-----+---+---------+-----------------------------------------------------------+ - |3:2 |R/W|Padmux_65|Selects between: mux_group_sel_uart1_rx / gpio65 | - +-----+---+---------+-----------------------------------------------------------+ - |5:4 |R/W|Padmux_66|Selects between: mux_group_sel_uart1_tx / gpio66 | - +-----+---+---------+-----------------------------------------------------------+ - |7:6 |R/W|Padmux_67|Selects between: mux_group_sel_pwm0 / gpio67 | - +-----+---+---------+-----------------------------------------------------------+ - |9:8 |R/W|Padmux_68|Selects between: mux_group_sel_pwm1 / gpio68 | - +-----+---+---------+-----------------------------------------------------------+ - |11:10|R/W|Padmux_69|Selects between: uart1_clk / gpio69 | - +-----+---+---------+-----------------------------------------------------------+ - |13:12|R/W|Padmux_70|Selects between: cam_pclk / gpio70 / spi3_sck | - +-----+---+---------+-----------------------------------------------------------+ - |15:14|R/W|Padmux_71|Selects between: cam_hsync / gpio71 / spi3_cs0 / csi2_hsync| - +-----+---+---------+-----------------------------------------------------------+ - |17:16|R/W|Padmux_72|Selects between: cam_data0 / gpio72 / spi3_cs1 | - +-----+---+---------+-----------------------------------------------------------+ - |19:18|R/W|Padmux_73|Selects between: cam_data1 / gpio73 / spi3_cs2 | - +-----+---+---------+-----------------------------------------------------------+ - |21:20|R/W|Padmux_74|Selects between: cam_data2 / gpio74 / spi3_cs3 | - +-----+---+---------+-----------------------------------------------------------+ - |23:22|R/W|Padmux_75|Selects between: cam_data3 / gpio75 / spi3_sdo | - +-----+---+---------+-----------------------------------------------------------+ - |25:24|R/W|Padmux_76|Selects between: cam_data4 / gpio76 / spi3_sdi | - +-----+---+---------+-----------------------------------------------------------+ - |27:26|R/W|Padmux_77|Selects between: cam_data5 / gpio77 / observability1 | - +-----+---+---------+-----------------------------------------------------------+ - |29:28|R/W|Padmux_78|Selects between: cam_data6 / gpio78 / observability2 | - +-----+---+---------+-----------------------------------------------------------+ - |31:30|R/W|Padmux_79|Selects between: cam_data7 / gpio79 / observability3 | - +-----+---+---------+-----------------------------------------------------------+ - -.. _apb_soc_ctrl_PADFUN5: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+===========================================================+ + |1:0 |R/W|PADMUX_64|0x0 |Selects between: uart0_clk / gpio64 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |3:2 |R/W|PADMUX_65|0x0 |Selects between: mux_group_sel_uart1_rx / gpio65 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |5:4 |R/W|PADMUX_66|0x0 |Selects between: mux_group_sel_uart1_tx / gpio66 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |7:6 |R/W|PADMUX_67|0x0 |Selects between: mux_group_sel_pwm0 / gpio67 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |9:8 |R/W|PADMUX_68|0x0 |Selects between: mux_group_sel_pwm1 / gpio68 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |11:10|R/W|PADMUX_69|0x0 |Selects between: uart1_clk / gpio69 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |13:12|R/W|PADMUX_70|0x0 |Selects between: cam_pclk / gpio70 / spi3_sck | + +-----+---+---------+-----+-----------------------------------------------------------+ + |15:14|R/W|PADMUX_71|0x0 |Selects between: cam_hsync / gpio71 / spi3_cs0 / csi2_hsync| + +-----+---+---------+-----+-----------------------------------------------------------+ + |17:16|R/W|PADMUX_72|0x0 |Selects between: cam_data0 / gpio72 / spi3_cs1 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |19:18|R/W|PADMUX_73|0x0 |Selects between: cam_data1 / gpio73 / spi3_cs2 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |21:20|R/W|PADMUX_74|0x0 |Selects between: cam_data2 / gpio74 / spi3_cs3 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |23:22|R/W|PADMUX_75|0x0 |Selects between: cam_data3 / gpio75 / spi3_sdo | + +-----+---+---------+-----+-----------------------------------------------------------+ + |25:24|R/W|PADMUX_76|0x0 |Selects between: cam_data4 / gpio76 / spi3_sdi | + +-----+---+---------+-----+-----------------------------------------------------------+ + |27:26|R/W|PADMUX_77|0x0 |Selects between: cam_data5 / gpio77 / observability1 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |29:28|R/W|PADMUX_78|0x0 |Selects between: cam_data6 / gpio78 / observability2 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |31:30|R/W|PADMUX_79|0x0 |Selects between: cam_data7 / gpio79 / observability3 | + +-----+---+---------+-----+-----------------------------------------------------------+ + +.. _apb_soc_ctrl__PADFUN5: PADFUN5 """"""" @@ -489,66 +496,55 @@ PADFUN5 Mux config register (pad 80-89) .. table:: - - +-----+---+---------+-----------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+=================================================================+ - |1:0 |R/W|Padmux_80|Selects between: cam_vsync / gpio80 / observability4 / csi2_vsync| - +-----+---+---------+-----------------------------------------------------------------+ - |3:2 |R/W|Padmux_81|Selects between: jtag_tck / gpio81 / uart4_clk | - +-----+---+---------+-----------------------------------------------------------------+ - |5:4 |R/W|Padmux_82|Selects between: jtag_tdi / gpio82 / uart4_rx | - +-----+---+---------+-----------------------------------------------------------------+ - |7:6 |R/W|Padmux_83|Selects between: jtag_tdo / gpio83 / uart4_tx | - +-----+---+---------+-----------------------------------------------------------------+ - |9:8 |R/W|Padmux_84|Selects between: jtag_tms / gpio84 / uart4_cts | - +-----+---+---------+-----------------------------------------------------------------+ - |11:10|R/W|Padmux_85|Selects between: jtag_trst / gpio85 / uart4_rts | - +-----+---+---------+-----------------------------------------------------------------+ - |13:12|R/W|Padmux_86|Selects between: wakeup_spi2_sck / gpio86 | - +-----+---+---------+-----------------------------------------------------------------+ - |15:14|R/W|Padmux_87|Selects between: wakeup_spi2_sdi / gpio87 | - +-----+---+---------+-----------------------------------------------------------------+ - |17:16|R/W|Padmux_88|Selects between: wakeup_spi2_sdo / gpio88 | - +-----+---+---------+-----------------------------------------------------------------+ - |19:18|R/W|Padmux_89|Selects between: wakeup_spi2_cs0 / gpio89 | - +-----+---+---------+-----------------------------------------------------------------+ - -.. _apb_soc_ctrl_FEATURE_DISABLEMENT_SOC: - -FEATURE_DISABLEMENT_SOC -""""""""""""""""""""""" - -Feature disablement from SoC domain - -.. table:: - - +-----+---+------------------------+---------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========================+===============================================================================================================+ - | 0|R/W|DISABLE_QUIDDIKEY_UNWRAP|Disable quiddikey unwrap | - +-----+---+------------------------+---------------------------------------------------------------------------------------------------------------+ - | 1|R/W|DISABLE_QUIDDIKEY_ENROLL|Disable quiddikey enroll | - +-----+---+------------------------+---------------------------------------------------------------------------------------------------------------+ - | 31|R/W|DISABLE_LOCK |When set, DISABLE_* registers cannot be written to zero. Configuration is lost when SoC domain is switched off.| - +-----+---+------------------------+---------------------------------------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_RESERVED0: - -RESERVED0 -""""""""" - -Reserved - -.. table:: - - +-----+---+----+----------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================+ - | 0|R |BUSY|Cluster busy flag (i.e. It's 1 if there is at least 1 active block in the cluster)| - +-----+---+----+----------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG0: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+-----------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=================================================================+ + |1:0 |R/W|PADMUX_80|0x0 |Selects between: cam_vsync / gpio80 / observability4 / csi2_vsync| + +-----+---+---------+-----+-----------------------------------------------------------------+ + |3:2 |R/W|PADMUX_81|0x0 |Selects between: jtag_tck / gpio81 / uart4_clk | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |5:4 |R/W|PADMUX_82|0x0 |Selects between: jtag_tdi / gpio82 / uart4_rx | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |7:6 |R/W|PADMUX_83|0x0 |Selects between: jtag_tdo / gpio83 / uart4_tx | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |9:8 |R/W|PADMUX_84|0x0 |Selects between: jtag_tms / gpio84 / uart4_cts | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |11:10|R/W|PADMUX_85|0x0 |Selects between: jtag_trst / gpio85 / uart4_rts | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |13:12|R/W|PADMUX_86|0x0 |Selects between: wakeup_spi2_sck / gpio86 | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |15:14|R/W|PADMUX_87|0x0 |Selects between: wakeup_spi2_sdi / gpio87 | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |17:16|R/W|PADMUX_88|0x0 |Selects between: wakeup_spi2_sdo / gpio88 | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |19:18|R/W|PADMUX_89|0x0 |Selects between: wakeup_spi2_cs0 / gpio89 | + +-----+---+---------+-----+-----------------------------------------------------------------+ + +.. _apb_soc_ctrl__FEATURE_DISABLE_QK: + +FEATURE_DISABLE_QK +"""""""""""""""""" + +Feature disablement for Quiddikey features + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------------------+-----+---------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========================+=====+===============================================================================================================+ + | 0|R/W|DISABLE_QUIDDIKEY_UNWRAP|0x0 |Disable quiddikey unwrap | + +-----+---+------------------------+-----+---------------------------------------------------------------------------------------------------------------+ + | 1|R/W|DISABLE_QUIDDIKEY_ENROLL|0x0 |Disable quiddikey enroll | + +-----+---+------------------------+-----+---------------------------------------------------------------------------------------------------------------+ + | 31|R/W|DISABLE_LOCK |0x0 |When set, DISABLE_* registers cannot be written to zero. Configuration is lost when SoC domain is switched off.| + +-----+---+------------------------+-----+---------------------------------------------------------------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG0: PADCFG0 """"""" @@ -556,36 +552,38 @@ PADCFG0 Function register (pad 0 to 3) .. table:: - - +-----+---+--------------------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+====================+==============================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+--------------------+------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+--------------------+------------------------------+ - |11:10|R/W|Pad 1 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+--------------------+------------------------------+ - |19:18|R/W|Pad 2 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+--------------------+------------------------------+ - |27:26|R/W|Pad 3 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - -.. _apb_soc_ctrl_PADCFG1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+====================+=====+===============================+ + | 0|R/W|PAD_0_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |3:2 |R/W|PAD_0_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + | 8|R/W|PAD_1_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 9|R/W|PAD_1_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |11:10|R/W|PAD_1_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + | 16|R/W|PAD_2_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 17|R/W|PAD_2_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |19:18|R/W|PAD_2_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + | 24|R/W|PAD_3_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 25|R/W|PAD_3_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |27:26|R/W|PAD_3_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + +.. _apb_soc_ctrl__PADCFG1: PADCFG1 """"""" @@ -593,36 +591,38 @@ PADCFG1 Function register (pad 4 to 7) .. table:: - - +-----+---+--------------------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+====================+==============================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+--------------------+------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+--------------------+------------------------------+ - |11:10|R/W|Pad 1 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+--------------------+------------------------------+ - |19:18|R/W|Pad 2 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+--------------------+------------------------------+ - |27:26|R/W|Pad 3 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - -.. _apb_soc_ctrl_PADCFG2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+====================+=====+===============================+ + | 0|R/W|PAD_4_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 1|R/W|PAD_4_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |3:2 |R/W|PAD_4_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + | 8|R/W|PAD_5_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 9|R/W|PAD_5_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |11:10|R/W|PAD_5_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + | 16|R/W|PAD_6_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 17|R/W|PAD_6_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |19:18|R/W|PAD_6_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + | 24|R/W|PAD_7_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 25|R/W|PAD_7_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |27:26|R/W|PAD_7_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + +.. _apb_soc_ctrl__PADCFG2: PADCFG2 """"""" @@ -630,36 +630,38 @@ PADCFG2 Function register (pad 8 to 11) .. table:: - - +-----+---+--------------------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+====================+==============================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+--------------------+------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+--------------------+------------------------------+ - |11:10|R/W|Pad 1 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+--------------------+------------------------------+ - |19:18|R/W|Pad 2 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+--------------------+------------------------------+ - |27:26|R/W|Pad 3 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - -.. _apb_soc_ctrl_PADCFG3: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+===============================+ + | 0|R/W|PAD_8_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 1|R/W|PAD_8_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |3:2 |R/W|PAD_8_DRIVE_STRENGTH |0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 8|R/W|PAD_9_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 9|R/W|PAD_9_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |11:10|R/W|PAD_9_DRIVE_STRENGTH |0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 16|R/W|PAD_10_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 17|R/W|PAD_10_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |19:18|R/W|PAD_10_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 24|R/W|PAD_11_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 25|R/W|PAD_11_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |27:26|R/W|PAD_11_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + +.. _apb_soc_ctrl__PADCFG3: PADCFG3 """"""" @@ -667,36 +669,38 @@ PADCFG3 Function register (pad 12 to 15) .. table:: - - +-----+---+--------------------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+====================+==============================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+--------------------+------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+--------------------+------------------------------+ - |11:10|R/W|Pad 1 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+--------------------+------------------------------+ - |19:18|R/W|Pad 2 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+--------------------+------------------------------+ - |27:26|R/W|Pad 3 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - -.. _apb_soc_ctrl_PADCFG4: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+===============================+ + | 0|R/W|PAD_12_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 1|R/W|PAD_12_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |3:2 |R/W|PAD_12_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 8|R/W|PAD_13_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 9|R/W|PAD_13_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |11:10|R/W|PAD_13_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 16|R/W|PAD_14_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 17|R/W|PAD_14_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |19:18|R/W|PAD_14_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 24|R/W|PAD_15_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 25|R/W|PAD_15_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |27:26|R/W|PAD_15_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + +.. _apb_soc_ctrl__PADCFG4: PADCFG4 """"""" @@ -704,36 +708,38 @@ PADCFG4 Function register (pad 16 to 19) .. table:: - - +-----+---+--------------------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+====================+==============================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+--------------------+------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+--------------------+------------------------------+ - |11:10|R/W|Pad 1 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+--------------------+------------------------------+ - |19:18|R/W|Pad 2 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+--------------------+------------------------------+ - |27:26|R/W|Pad 3 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - -.. _apb_soc_ctrl_PADCFG5: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+===============================+ + | 0|R/W|PAD_16_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 1|R/W|PAD_16_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |3:2 |R/W|PAD_16_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 8|R/W|PAD_17_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 9|R/W|PAD_17_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |11:10|R/W|PAD_17_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 16|R/W|PAD_18_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 17|R/W|PAD_18_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |19:18|R/W|PAD_18_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 24|R/W|PAD_19_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 25|R/W|PAD_19_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |27:26|R/W|PAD_19_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + +.. _apb_soc_ctrl__PADCFG5: PADCFG5 """"""" @@ -741,36 +747,38 @@ PADCFG5 Function register (pad 20 to 23) .. table:: - - +-----+---+--------------------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+====================+==============================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+--------------------+------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+--------------------+------------------------------+ - |11:10|R/W|Pad 1 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+--------------------+------------------------------+ - |19:18|R/W|Pad 2 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+--------------------+------------------------------+ - |27:26|R/W|Pad 3 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - -.. _apb_soc_ctrl_PADCFG6: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+===============================+ + | 0|R/W|PAD_20_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 1|R/W|PAD_20_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |3:2 |R/W|PAD_20_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 8|R/W|PAD_21_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 9|R/W|PAD_21_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |11:10|R/W|PAD_21_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 16|R/W|PAD_22_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 17|R/W|PAD_22_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |19:18|R/W|PAD_22_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 24|R/W|PAD_23_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 25|R/W|PAD_23_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |27:26|R/W|PAD_23_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + +.. _apb_soc_ctrl__PADCFG6: PADCFG6 """"""" @@ -778,44 +786,46 @@ PADCFG6 Function register (pad 24 to 27) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG7: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_24_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_24_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_24_DRIVE_STRENGTH |0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_25_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_25_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_25_DRIVE_STRENGTH |0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_26_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_26_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_26_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_26_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_26_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_27_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_27_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_27_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_27_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_27_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG7: PADCFG7 """"""" @@ -823,52 +833,54 @@ PADCFG7 Function register (pad 28 to 31) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG8: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_28_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_28_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_28_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_28_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_28_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_29_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_29_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_29_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_29_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_29_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_30_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_30_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_30_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_30_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_30_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_31_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_31_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_31_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_31_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_31_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG8: PADCFG8 """"""" @@ -876,52 +888,54 @@ PADCFG8 Function register (pad 32 to 35) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG9: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_32_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_32_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_32_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_32_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_32_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_33_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_33_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_33_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_33_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_33_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_34_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_34_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_34_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_34_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_34_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_35_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_35_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_35_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_35_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_35_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG9: PADCFG9 """"""" @@ -929,52 +943,54 @@ PADCFG9 Function register (pad 36 to 39) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG10: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_36_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_36_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_36_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_36_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_36_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_37_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_37_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_37_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_37_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_37_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_38_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_38_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_38_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_38_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_38_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_39_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_39_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_39_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_39_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_39_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG10: PADCFG10 """""""" @@ -982,52 +998,54 @@ PADCFG10 Function register (pad 40 to 43) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG11: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_40_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_40_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_40_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_40_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_40_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_41_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_41_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_41_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_41_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_41_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_42_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_42_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_42_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_42_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_42_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_43_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_43_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_43_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_43_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_43_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG11: PADCFG11 """""""" @@ -1035,52 +1053,54 @@ PADCFG11 Function register (pad 44 to 47) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG12: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_44_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_44_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_44_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_44_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_44_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_45_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_45_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_45_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_45_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_45_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_46_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_46_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_46_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_46_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_46_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_47_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_47_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_47_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_47_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_47_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG12: PADCFG12 """""""" @@ -1088,52 +1108,54 @@ PADCFG12 Function register (pad 48 to 51) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG13: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_48_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_48_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_48_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_48_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_48_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_49_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_49_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_49_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_49_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_49_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_50_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_50_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_50_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_50_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_50_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_51_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_51_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_51_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_51_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_51_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG13: PADCFG13 """""""" @@ -1141,52 +1163,54 @@ PADCFG13 Function register (pad 52 to 55) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG14: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_52_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_52_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_52_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_52_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_52_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_53_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_53_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_53_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_53_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_53_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_54_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_54_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_54_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_54_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_54_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_55_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_55_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_55_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_55_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_55_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG14: PADCFG14 """""""" @@ -1194,52 +1218,54 @@ PADCFG14 Function register (pad 56 to 59) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG15: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_56_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_56_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_56_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_56_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_56_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_57_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_57_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_57_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_57_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_57_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_58_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_58_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_58_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_58_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_58_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_59_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_59_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_59_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_59_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_59_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG15: PADCFG15 """""""" @@ -1247,52 +1273,54 @@ PADCFG15 Function register (pad 60 to 63) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG16: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_60_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_60_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_60_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_60_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_60_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_61_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_61_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_61_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_61_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_61_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_62_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_62_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_62_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_62_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_62_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_63_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_63_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_63_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_63_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_63_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG16: PADCFG16 """""""" @@ -1300,52 +1328,54 @@ PADCFG16 Function register (pad 64 to 67) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG17: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_64_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_64_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_64_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_64_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_64_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_65_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_65_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_65_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_65_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_65_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_66_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_66_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_66_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_66_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_66_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_67_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_67_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_67_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_67_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_67_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG17: PADCFG17 """""""" @@ -1353,52 +1383,54 @@ PADCFG17 Function register (pad 68 to 71) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG18: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_68_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_68_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_68_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_68_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_68_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_69_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_69_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_69_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_69_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_69_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_70_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_70_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_70_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_70_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_70_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_71_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_71_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_71_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_71_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_71_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG18: PADCFG18 """""""" @@ -1406,52 +1438,54 @@ PADCFG18 Function register (pad 72 to 75) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG19: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_72_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_72_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_72_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_72_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_72_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_73_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_73_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_73_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_73_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_73_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_74_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_74_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_74_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_74_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_74_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_75_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_75_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_75_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_75_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_75_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG19: PADCFG19 """""""" @@ -1459,52 +1493,54 @@ PADCFG19 Function register (pad 76 to 79) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG20: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_76_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_76_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_76_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_76_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_76_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_77_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_77_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_77_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_77_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_77_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_78_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_78_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_78_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_78_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_78_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_79_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_79_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_79_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_79_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_79_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG20: PADCFG20 """""""" @@ -1512,52 +1548,54 @@ PADCFG20 Function register (pad 80 to 83) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG21: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_80_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_80_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_80_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_80_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_80_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_81_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_81_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_81_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_81_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_81_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_82_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_82_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_82_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_82_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_82_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_83_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_83_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_83_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_83_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_83_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG21: PADCFG21 """""""" @@ -1565,105 +1603,89 @@ PADCFG21 Function register (pad 84 to 87) .. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG22: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_84_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_84_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_84_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_84_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_84_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_85_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_85_PULL_UP |0x1 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_85_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_85_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_85_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_86_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_86_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_86_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_86_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_86_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_87_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_87_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_87_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_87_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_87_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG22: PADCFG22 """""""" -Function register (pad 88 to 89, only first 16 bits used) - -.. table:: - - +-----+---+---------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 4|R/W|Pad 0 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 5|R/W|Pad 0 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |11:10|R/W|Pad 1 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 12|R/W|Pad 1 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 13|R/W|Pad 1 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |19:18|R/W|Pad 2 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 20|R/W|Pad 2 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 21|R/W|Pad 2 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+---------------------+----------------------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+---------------------+----------------------------------------------+ - |27:26|R/W|Pad 3 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+---------------------+----------------------------------------------+ - | 28|R/W|Pad 3 Schmitt Trigger| | - +-----+---+---------------------+----------------------------------------------+ - | 29|R/W|Pad 3 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+---------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_REG_REPROG_PAD0: +Function register (pad 88 to 89) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_88_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_88_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_88_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_88_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_88_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_89_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_89_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_89_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_89_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_89_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__REG_REPROG_PAD0: REG_REPROG_PAD0 """"""""""""""" @@ -1671,22 +1693,24 @@ REG_REPROG_PAD0 Controls reprogrammable pads 27,28,29,30,34 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------------------+--------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+====================================================================+ - |5:0 |R/W|mux_group_sel_spi0_cs0|Selects an alternate from the mux group. Default alternate: spi0_cs0| - +-----+---+----------------------+--------------------------------------------------------------------+ - |11:6 |R/W|mux_group_sel_spi0_cs1|Selects an alternate from the mux group. Default alternate: spi0_cs1| - +-----+---+----------------------+--------------------------------------------------------------------+ - |17:12|R/W|mux_group_sel_spi0_cs2|Selects an alternate from the mux group. Default alternate: spi0_cs2| - +-----+---+----------------------+--------------------------------------------------------------------+ - |23:18|R/W|mux_group_sel_spi0_cs3|Selects an alternate from the mux group. Default alternate: spi0_cs3| - +-----+---+----------------------+--------------------------------------------------------------------+ - |29:24|R/W|mux_group_sel_spi1_cs0|Selects an alternate from the mux group. Default alternate: spi1_cs0| - +-----+---+----------------------+--------------------------------------------------------------------+ + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+======================================================================+ + |5:0 |R/W|MUX_GROUP_SEL_SPI0_CS0|0x00 |Selects function for reprogrammable pad 27. Default function: SPI0_CS0| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |11:6 |R/W|MUX_GROUP_SEL_SPI0_CS1|0x01 |Selects function for reprogrammable pad 28. Default function: SPI0_CS1| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |17:12|R/W|MUX_GROUP_SEL_SPI0_CS2|0x02 |Selects function for reprogrammable pad 29. Default function: SPI0_CS2| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |23:18|R/W|MUX_GROUP_SEL_SPI0_CS3|0x03 |Selects function for reprogrammable pad 30. Default function: SPI0_CS3| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |29:24|R/W|MUX_GROUP_SEL_SPI1_CS0|0x04 |Selects function for reprogrammable pad 34. Default function: SPI1_CS0| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ -.. _apb_soc_ctrl_REG_REPROG_PAD1: +.. _apb_soc_ctrl__REG_REPROG_PAD1: REG_REPROG_PAD1 """"""""""""""" @@ -1694,22 +1718,24 @@ REG_REPROG_PAD1 Controls reprogrammable pads 35,40,41,42,43 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------------------+----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+======================================================================+ - |5:0 |R/W|mux_group_sel_spi1_cs1|Selects an alternate from the mux group. Default alternate: spi1_cs1 | - +-----+---+----------------------+----------------------------------------------------------------------+ - |11:6 |R/W|mux_group_sel_i2c0_sda|Selects an alternate from the mux group. Default alternate: i2c0_sda | - +-----+---+----------------------+----------------------------------------------------------------------+ - |17:12|R/W|mux_group_sel_i2c0_scl|Selects an alternate from the mux group. Default alternate: i2c0_scl | - +-----+---+----------------------+----------------------------------------------------------------------+ - |23:18|R/W|mux_group_sel_i2c1_sda|Selects an alternate from the mux group. Default alternate: i2c1_sda_o| - +-----+---+----------------------+----------------------------------------------------------------------+ - |29:24|R/W|mux_group_sel_i2c1_scl|Selects an alternate from the mux group. Default alternate: i2c1_scl_o| - +-----+---+----------------------+----------------------------------------------------------------------+ + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+======================================================================+ + |5:0 |R/W|MUX_GROUP_SEL_SPI1_CS1|0x06 |Selects function for reprogrammable pad 35. Default function: SPI1_CS1| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |11:6 |R/W|MUX_GROUP_SEL_I2C0_SDA|0x08 |Selects function for reprogrammable pad 40. Default function: I2C0_SDA| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |17:12|R/W|MUX_GROUP_SEL_I2C0_SCL|0x09 |Selects function for reprogrammable pad 41. Default function: I2C0_SCL| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |23:18|R/W|MUX_GROUP_SEL_I2C1_SDA|0x0A |Selects function for reprogrammable pad 42. Default function: I2C1_SDA| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |29:24|R/W|MUX_GROUP_SEL_I2C1_SCL|0x0C |Selects function for reprogrammable pad 43. Default function: I2C1_SCL| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ -.. _apb_soc_ctrl_REG_REPROG_PAD2: +.. _apb_soc_ctrl__REG_REPROG_PAD2: REG_REPROG_PAD2 """"""""""""""" @@ -1717,22 +1743,24 @@ REG_REPROG_PAD2 Controls reprogrammable pads 44,45,60,61,62 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======================+=======================================================================+ - |5:0 |R/W|mux_group_sel_i2c2_sda |Selects an alternate from the mux group. Default alternate: i2c2_sda_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |11:6 |R/W|mux_group_sel_i2c2_scl |Selects an alternate from the mux group. Default alternate: i2c2_scl_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |17:12|R/W|mux_group_sel_uart0_rx |Selects an alternate from the mux group. Default alternate: uart0_rx_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |23:18|R/W|mux_group_sel_uart0_tx |Selects an alternate from the mux group. Default alternate: uart0_tx_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |29:24|R/W|mux_group_sel_uart0_cts|Selects an alternate from the mux group. Default alternate: uart0_cts_o| - +-----+---+-----------------------+-----------------------------------------------------------------------+ + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======================+=====+=======================================================================+ + |5:0 |R/W|MUX_GROUP_SEL_I2C2_SDA |0x0E |Selects function for reprogrammable pad 44. Default function: I2C2_SDA | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |11:6 |R/W|MUX_GROUP_SEL_I2C2_SCL |0x10 |Selects function for reprogrammable pad 45. Default function: I2C2_SCL | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |17:12|R/W|MUX_GROUP_SEL_UART0_RX |0x12 |Selects function for reprogrammable pad 60. Default function: UART0_RX | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |23:18|R/W|MUX_GROUP_SEL_UART0_TX |0x13 |Selects function for reprogrammable pad 61. Default function: UART0_TX | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |29:24|R/W|MUX_GROUP_SEL_UART0_CTS|0x14 |Selects function for reprogrammable pad 62. Default function: UART0_CTS| + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ -.. _apb_soc_ctrl_REG_REPROG_PAD3: +.. _apb_soc_ctrl__REG_REPROG_PAD3: REG_REPROG_PAD3 """"""""""""""" @@ -1740,82 +1768,24 @@ REG_REPROG_PAD3 Controls reprogrammable pads 63,65,66,67,68 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======================+=======================================================================+ - |5:0 |R/W|mux_group_sel_uart0_rts|Selects an alternate from the mux group. Default alternate: uart0_rts_o| - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |11:6 |R/W|mux_group_sel_uart1_rx |Selects an alternate from the mux group. Default alternate: uart1_rx_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |17:12|R/W|mux_group_sel_uart1_tx |Selects an alternate from the mux group. Default alternate: uart1_tx_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |23:18|R/W|mux_group_sel_pwm0 |Selects an alternate from the mux group. Default alternate: pwm0_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |29:24|R/W|mux_group_sel_pwm1 |Selects an alternate from the mux group. Default alternate: pwm1_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - -.. _apb_soc_ctrl_RESERVED1: - -RESERVED1 -""""""""" + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======================+=====+=======================================================================+ + |5:0 |R/W|MUX_GROUP_SEL_UART0_RTS|0x16 |Selects function for reprogrammable pad 63. Default function: UART0_RTS| + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |11:6 |R/W|MUX_GROUP_SEL_UART1_RX |0x18 |Selects function for reprogrammable pad 65. Default function: UART1_RX | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |17:12|R/W|MUX_GROUP_SEL_UART1_TX |0x1B |Selects function for reprogrammable pad 66. Default function: UART1_TX | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |23:18|R/W|MUX_GROUP_SEL_PWM0 |0x1E |Selects function for reprogrammable pad 67. Default function: PWM0 | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |29:24|R/W|MUX_GROUP_SEL_PWM1 |0x21 |Selects function for reprogrammable pad 68. Default function: PWM1 | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ -Reserved - -.. table:: - - +-----+---+----+----------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================+ - | 0|R |BUSY|Cluster busy flag (i.e. It's 1 if there is at least 1 active block in the cluster)| - +-----+---+----+----------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_RESERVED2: - -RESERVED2 -""""""""" - -Reserved - -.. table:: - - +-----+---+----+----------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================+ - | 0|R |BUSY|Cluster busy flag (i.e. It's 1 if there is at least 1 active block in the cluster)| - +-----+---+----+----------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_RESERVED3: - -RESERVED3 -""""""""" - -Reserved - -.. table:: - - +-----+---+----+----------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================+ - | 0|R |BUSY|Cluster busy flag (i.e. It's 1 if there is at least 1 active block in the cluster)| - +-----+---+----+----------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_RESERVED4: - -RESERVED4 -""""""""" - -Reserved - -.. table:: - - +-----+---+----+----------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================+ - | 0|R |BUSY|Cluster busy flag (i.e. It's 1 if there is at least 1 active block in the cluster)| - +-----+---+----+----------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_CL_BUSY: +.. _apb_soc_ctrl__CL_BUSY: CL_BUSY """"""" @@ -1823,14 +1793,16 @@ CL_BUSY Cluster busy register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+----------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================+ - | 0|R |BUSY|Cluster busy flag (i.e. It's 1 if there is at least 1 active block in the cluster)| - +-----+---+----+----------------------------------------------------------------------------------+ + +-----+---+----+-----+----------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==================================================================================+ + | 0|R |BUSY|0x0 |Cluster busy flag (i.e. It's 1 if there is at least 1 active block in the cluster)| + +-----+---+----+-----+----------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_JTAGREG: +.. _apb_soc_ctrl__JTAGREG: JTAGREG """"""" @@ -1838,16 +1810,18 @@ JTAGREG JTAG external register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+======================================================================+ - |3:0 |R/W|INTERNAL|JTAG internal register used for synchronisation from external debugger| - +-----+---+--------+----------------------------------------------------------------------+ - |11:8 |R |EXTERNAL|JTAG external register used for synchronisation from external debugger| - +-----+---+--------+----------------------------------------------------------------------+ + +-----+---+--------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+======================================================================+ + |3:0 |R/W|INTERNAL|0x0 |JTAG internal register used for synchronisation from external debugger| + +-----+---+--------+-----+----------------------------------------------------------------------+ + |11:8 |R |EXTERNAL|0x0 |JTAG external register used for synchronisation from external debugger| + +-----+---+--------+-----+----------------------------------------------------------------------+ -.. _apb_soc_ctrl_REF_FAST_CLK_DIV: +.. _apb_soc_ctrl__REF_FAST_CLK_DIV: REF_FAST_CLK_DIV """""""""""""""" @@ -1855,13 +1829,16 @@ REF_FAST_CLK_DIV Read only, reference fast clk divided by power of 2 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================================+ + | 0|R |CLK |0x0 |Current value of the divided REF FAST clock| + +-----+---+----+-----+-------------------------------------------+ -.. _apb_soc_ctrl_SW_RST: +.. _apb_soc_ctrl__SW_RST: SW_RST """""" @@ -1869,14 +1846,16 @@ SW_RST Software reset, reboot .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+===============================+ - | 0|R |RESET|Writing 1 triggers a chip reset| - +-----+---+-----+-------------------------------+ + +-----+---+-----+-----+-------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===============================+ + | 0|R |RESET|0x0 |Writing 1 triggers a chip reset| + +-----+---+-----+-----+-------------------------------+ -.. _apb_soc_ctrl_CORESTATUS: +.. _apb_soc_ctrl__CORESTATUS: CORESTATUS """""""""" @@ -1884,16 +1863,18 @@ CORESTATUS EOC and chip status register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+---------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+=========================================================================================================+ - |31:0 |R/W|STATUS|Chip status register. The SW can store the exit value value so that the external loader can get it. | - +-----+---+------+---------------------------------------------------------------------------------------------------------+ - |31 |R/W|EOC |End Of Computation. The SW can store 1 here to notify the external loader that the execution is finished.| - +-----+---+------+---------------------------------------------------------------------------------------------------------+ + +-----+---+------+-----+---------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=========================================================================================================+ + |31:0 |R/W|STATUS|0x0 |Chip status register. The SW can store the exit value value so that the external loader can get it. | + +-----+---+------+-----+---------------------------------------------------------------------------------------------------------+ + |31 |R/W|EOC |0x0 |End Of Computation. The SW can store 1 here to notify the external loader that the execution is finished.| + +-----+---+------+-----+---------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_BOOTSEL: +.. _apb_soc_ctrl__BOOTSEL: BOOTSEL """"""" @@ -1901,14 +1882,16 @@ BOOTSEL Value of pad bootsel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+============================================================================================================+ - |1:0 |R |BOOTSEL|Boot mode. These bits can be used by the ROM to select the boot mode, see ROM documentation for more details| - +-----+---+-------+------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+============================================================================================================+ + |1:0 |R |BOOTSEL|0x0 |Boot mode. These bits can be used by the ROM to select the boot mode, see ROM documentation for more details| + +-----+---+-------+-----+------------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_WD_RST_RST: +.. _apb_soc_ctrl__WD_RST_RST: WD_RST_RST """""""""" @@ -1916,14 +1899,16 @@ WD_RST_RST Rearm WD timeout .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+---------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+===============================================================+ - |31:0 |R |CLEAR|Any write to this register re-arms the watchdog timeout counter| - +-----+---+-----+---------------------------------------------------------------+ + +-----+---+-----+-----+---------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===============================================================+ + |31:0 |R |CLEAR|0x0 |Any write to this register re-arms the watchdog timeout counter| + +-----+---+-----+-----+---------------------------------------------------------------+ -.. _apb_soc_ctrl_WD_RST_SET: +.. _apb_soc_ctrl__WD_RST_SET: WD_RST_SET """""""""" @@ -1931,30 +1916,35 @@ WD_RST_SET Set WD timer .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------+----------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+==================================================================================================================================+ - |23:0 |R |REF_COUNTER|Watchdog timeout counter, in periods of the SOC ref clock (maximum 2^16 * 1 / 32.768KHZ = 2s when using the 32kHz reference clock)| - +-----+---+-----------+----------------------------------------------------------------------------------------------------------------------------------+ - |31 |R |ENABLE |Enable the watchdog: triggers chip reset if the timeout counter expires without being re-armed | - +-----+---+-----------+----------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-----------+-------+----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+===========+=======+==================================================================================================================================+ + |23:0 |R |REF_COUNTER|0xFFFFF|Watchdog timeout counter, in periods of the SOC ref clock (maximum 2^16 * 1 / 32.768KHZ = 2s when using the 32kHz reference clock)| + +-----+---+-----------+-------+----------------------------------------------------------------------------------------------------------------------------------+ + |31 |R |ENABLE |0x0 |Enable the watchdog: triggers chip reset if the timeout counter expires without being re-armed | + +-----+---+-----------+-------+----------------------------------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_RWM_CSI2: +.. _apb_soc_ctrl__RWM_CSI2: RWM_CSI2 """""""" -RWM for CSI2 +Margin adjust settings for CSI2 Controller .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+--------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+============================================+ + |5:0 |R/W|RWM_CSI2|0x00 |Margin settings for CSI2 controller memories| + +-----+---+--------+-----+--------------------------------------------+ -.. _apb_soc_ctrl_IDLE_MODE: +.. _apb_soc_ctrl__IDLE_MODE: IDLE_MODE """"""""" @@ -1962,47 +1952,62 @@ IDLE_MODE Activates IDLE MODE .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------+------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+==================================================================+ - |15:0 |R/W|REF_COUNTER|IDLE MODE Counter, maximum 2^16 * 1 / 32.768KHZ = 2s | - +-----+---+-----------+------------------------------------------------------------------+ - |31 |R/W|ENABLE |Enable IDLE MODE on READ return status of idle mode(0=normal mode)| - +-----+---+-----------+------------------------------------------------------------------+ + +-----+---+-----------+------+-------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+===========+======+===================================================================+ + |15:0 |R/W|REF_COUNTER|0xFFFF|IDLE MODE Counter, maximum 2^16 * 1 / 32.768KHZ = 2s | + +-----+---+-----------+------+-------------------------------------------------------------------+ + |31 |R/W|ENABLE |0x0 |Enable IDLE MODE on READ return status of idle mode (0=normal mode)| + +-----+---+-----------+------+-------------------------------------------------------------------+ -.. _apb_soc_ctrl_RWM_ANC: +.. _apb_soc_ctrl__RWM_ANC: RWM_ANC """"""" -RWM for ANC +Margin adjust settings for SFU .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------------+-----+-------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+=================================================+ + |5:0 |R/W|RWM_ASRC_DPRAM|0x00 |Margin settings for SFU ASRC dual-port memories | + +-----+---+--------------+-----+-------------------------------------------------+ + |12:6 |R/W|RWM_ASRC_RAM |0x40 |Margin settings for SFU ASRC single-port memories| + +-----+---+--------------+-----+-------------------------------------------------+ + |18:13|R/W|RWM_GFU_DPRAM |0x00 |Margin settings for SFU GFU dual-port memories | + +-----+---+--------------+-----+-------------------------------------------------+ + |25:19|R/W|RWM_POLY_RAM |0x40 |Margin settings for SFU Polyphase Filter memories| + +-----+---+--------------+-----+-------------------------------------------------+ + |29:26|R/W|RWM_GFU_R1PL |0x00 |Margin settings for SFU GFU single-port memories | + +-----+---+--------------+-----+-------------------------------------------------+ -.. _apb_soc_ctrl_REF_CLK_MUX: +.. _apb_soc_ctrl__REF_CLK_MUX: REF_CLK_MUX """"""""""" -Ref clock mux 0: 32Khz 1: ref fast +Reference clock selection .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+----------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+================================================================+ - | 0|R/W|SOC |Ref clock select for soc : 0 - 32Khz; 1 - ref fast clock div | - +-----+---+-------+----------------------------------------------------------------+ - | 1|R/W|CLUSTER|Ref clock select for cluster : 0 - 32Khz; 1 - ref fast clock div| - +-----+---+-------+----------------------------------------------------------------+ + +-----+---+-------+-----+-----------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=========================================================================================+ + | 0|R/W|SOC |0x0 |Reference clock selection for SOC: 0: 32Khz REF SLOW clock; 1: divided REF FAST clock | + +-----+---+-------+-----+-----------------------------------------------------------------------------------------+ + | 1|R/W|CLUSTER|0x0 |Reference clock selection for cluster: 0: 32Khz REF SLOW clock; 1: divided REF FAST clock| + +-----+---+-------+-----+-----------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_SUPERVISOR_DBG: +.. _apb_soc_ctrl__SUPERVISOR_DBG: SUPERVISOR_DBG """""""""""""" @@ -2010,13 +2015,16 @@ SUPERVISOR_DBG .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+---------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=======================================+ + | 0|R/W|MODE|0x0 |Write 1 to enable supervisor debug mode| + +-----+---+----+-----+---------------------------------------+ -.. _apb_soc_ctrl_DBG_CTRL: +.. _apb_soc_ctrl__DBG_CTRL: DBG_CTRL """""""" @@ -2024,43 +2032,34 @@ DBG_CTRL Debug access control .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _apb_soc_ctrl_RESERVED5: - -RESERVED5 -""""""""" - -Reserved - -.. table:: - - +-----+---+----+----------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================+ - | 0|R |BUSY|Cluster busy flag (i.e. It's 1 if there is at least 1 active block in the cluster)| - +-----+---+----+----------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_RESERVED6: - -RESERVED6 -""""""""" - -Reserved - -.. table:: - - +-----+---+----+----------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================+ - | 0|R |BUSY|Cluster busy flag (i.e. It's 1 if there is at least 1 active block in the cluster)| - +-----+---+----+----------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_CLK_DIV_I3C: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-----------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================+ + | 0|R/W|HART_CL_CORE0|0x0 |Write 1 to enable HART for cluster core 0| + +-----+---+-------------+-----+-----------------------------------------+ + | 1|R/W|HART_CL_CORE1|0x0 |Write 1 to enable HART for cluster core 1| + +-----+---+-------------+-----+-----------------------------------------+ + | 2|R/W|HART_CL_CORE2|0x0 |Write 1 to enable HART for cluster core 2| + +-----+---+-------------+-----+-----------------------------------------+ + | 3|R/W|HART_CL_CORE3|0x0 |Write 1 to enable HART for cluster core 3| + +-----+---+-------------+-----+-----------------------------------------+ + | 4|R/W|HART_CL_CORE4|0x0 |Write 1 to enable HART for cluster core 4| + +-----+---+-------------+-----+-----------------------------------------+ + | 5|R/W|HART_CL_CORE5|0x0 |Write 1 to enable HART for cluster core 5| + +-----+---+-------------+-----+-----------------------------------------+ + | 6|R/W|HART_CL_CORE6|0x0 |Write 1 to enable HART for cluster core 6| + +-----+---+-------------+-----+-----------------------------------------+ + | 7|R/W|HART_CL_CORE7|0x0 |Write 1 to enable HART for cluster core 7| + +-----+---+-------------+-----+-----------------------------------------+ + | 8|R/W|HART_CL_CORE8|0x0 |Write 1 to enable HART for cluster core 8| + +-----+---+-------------+-----+-----------------------------------------+ + | 9|R/W|HART_FC_CORE |0x1 |Write 1 to enable HART for FC core | + +-----+---+-------------+-----+-----------------------------------------+ + +.. _apb_soc_ctrl__CLK_DIV_I3C: CLK_DIV_I3C """"""""""" @@ -2068,27 +2067,37 @@ CLK_DIV_I3C Clock divider for I3C .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+===============================+ + | 0|R/W|CLK_EN |0x0 |Write 1 to enable clock for I3C| + +-----+---+-----------+-----+-------------------------------+ + |15:8 |R/W|CLK_DIVIDER|0x0 |Integer divider for I3C | + +-----+---+-----------+-----+-------------------------------+ -.. _apb_soc_ctrl_CLK_EN_QUIDDIKEY: +.. _apb_soc_ctrl__CLK_EN_QUIDDIKEY: CLK_EN_QUIDDIKEY """""""""""""""" -Clock divider for QUIDDIKEY +Quiddikey enablement .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+---------+-----+------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+======================================================+ + | 0|R/W|QK_CLK_EN|0x0 |Write 1 to enable clock for the Quiddikey | + +-----+---+---------+-----+------------------------------------------------------+ + | 1|R/W|QK_RSTN |0x0 |Control the value of the active low reset of Quiddikey| + +-----+---+---------+-----+------------------------------------------------------+ -.. _apb_soc_ctrl_SLEEP_CTRL_INFO: +.. _apb_soc_ctrl__SLEEP_CTRL_INFO: SLEEP_CTRL_INFO """"""""""""""" @@ -2096,44 +2105,49 @@ SLEEP_CTRL_INFO Safe domain's Sleep control info .. table:: - - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+====================================================================================================+ - |7:0 |R |REBOOT |SW config. This field is only interpreted by ROM and runtime to keep information accross deep sleep.| - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |8 |R |RTC_WAKE_EN |Enable RTC wakeup | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |9 |R |RTC_EVENT |RTC event | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |10 |R |EXT_WAKEUP_EN|Enable external wakeup | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |26:11|R |EXT_EVENT |External event on wake-up I/Os | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |28:27|R |WAKEUP_CFG |Selected wake-up sequence | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |29 |R |FORCE_AO_PADS|Force always-on I/Os into their sleep mode configuration (see SLEEPPADCFGx registers) | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |30 |R |CNT_WAKE_EN |Enable counter wakeup | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |31 |R |CNT_EVENT |Counter event | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_VERSION: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+====================================================================================================+ + |7:0 |R |REBOOT |0x0 |SW config. This field is only interpreted by ROM and runtime to keep information accross deep sleep.| + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |8 |R |RTC_WAKE_EN |0x0 |Enable RTC wakeup | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |9 |R |RTC_EVENT |0x0 |RTC event | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |10 |R |EXT_WAKEUP_EN|0x0 |Enable external wakeup | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |26:11|R |EXT_EVENT |0x0 |External event on wake-up I/Os | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |28:27|R |WAKEUP_CFG |0x0 |Selected wake-up sequence | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |29 |R |FORCE_AO_PADS|0x0 |Force always-on I/Os into their sleep mode configuration (see SLEEPPADCFGx registers) | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |30 |R |CNT_WAKE_EN |0x0 |Enable counter wakeup | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |31 |R |CNT_EVENT |0x0 |Counter event | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + +.. _apb_soc_ctrl__VERSION: VERSION """"""" -Show chip version +Show chip version (User controlled) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=================================================+ + |3:0 |R/W|VERSION|0x0 |4-bit field available to SW to store chip version| + +-----+---+-------+-----+-------------------------------------------------+ -.. _apb_soc_ctrl_SLEEP_SPIS_CTRL: +.. _apb_soc_ctrl__SLEEP_SPIS_CTRL: SLEEP_SPIS_CTRL """"""""""""""" @@ -2141,20 +2155,22 @@ SLEEP_SPIS_CTRL Sleep SPIS control .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------+--------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+================================================================================+ - | 0|R/W|MUX |Enable wake-up interface, 0: GPIO-only external wake-up; 1: SPIS wake-up enabled| - +-----+---+------------+--------------------------------------------------------------------------------+ - |2:1 |R/W|SPIS_MODE |SPI slave controller CPOL and CPHA | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 3|R/W|SPIS_RSTN |Reset the SPI Slave wakeup controller | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 4|R/W|SPIS_SW_DONE|Notify outside device wakeup done | - +-----+---+------------+--------------------------------------------------------------------------------+ + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+================================================================================+ + | 0|R/W|MUX |0x0 |Enable wake-up interface, 0: GPIO-only external wake-up; 1: SPIS wake-up enabled| + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + |2:1 |R/W|SPIS_MODE |0x0 |SPI slave controller CPOL and CPHA | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 3|R/W|SPIS_RSTN |0x1 |Reset the SPI Slave wakeup controller | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 4|R/W|SPIS_SW_DONE|0x0 |Notify outside device wakeup done | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_SLEEP_CTRL: +.. _apb_soc_ctrl__SLEEP_CTRL: SLEEP_CTRL """""""""" @@ -2162,26 +2178,28 @@ SLEEP_CTRL Sleep control .. table:: - - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+====================================================================================================+ - |7:0 |R/W|REBOOT |SW config. This field is only interpreted by ROM and runtime to keep information accross deep sleep.| - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |8 |R/W|RTC_WAKE_EN |Enable RTC wakeup | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |9 |R/W|RTC_EVENT |RTC event | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |10 |R/W|EXT_WAKEUP_EN|Enable external wakeup | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |26:11|R/W|EXT_EVENT |External event. Bit order corresponds to the numbering in SLEEP_GPIO_CTRL register. | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |28:27|R/W|WAKEUP_CFG |Selected wake-up sequence | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |29 |R/W|FORCE_AO_PADS|Force always-on I/Os into their sleep mode configuration (see SLEEPPADCFGx registers) | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_GPIO_CTRL: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+====================================================================================================+ + |7:0 |R/W|REBOOT |0x0 |SW config. This field is only interpreted by ROM and runtime to keep information accross deep sleep.| + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |8 |R/W|RTC_WAKE_EN |0x0 |Enable RTC wakeup | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |9 |R/W|RTC_EVENT |0x0 |RTC event | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |10 |R/W|EXT_WAKEUP_EN|0x0 |Enable external wakeup | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |26:11|R/W|EXT_EVENT |0x0 |External event. Bit order corresponds to the numbering in SLEEP_GPIO_CTRL register. | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |28:27|R/W|WAKEUP_CFG |0x0 |Selected wake-up sequence | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |29 |R/W|FORCE_AO_PADS|0x0 |Force always-on I/Os into their sleep mode configuration (see SLEEPPADCFGx registers) | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_GPIO_CTRL: SLEEP_GPIO_CTRL """"""""""""""" @@ -2189,44 +2207,46 @@ SLEEP_GPIO_CTRL Sleep GPIO control .. table:: - - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===================+===========================================================================================+ - |1:0 |R/W|GPIO_WAKEUP_0_TYPE |Wake-up on I2C1_SDA pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |3:2 |R/W|GPIO_WAKEUP_1_TYPE |Wake-up on I2C1_SCL pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |5:4 |R/W|GPIO_WAKEUP_2_TYPE |Wake-up on UART1_RX pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |7:6 |R/W|GPIO_WAKEUP_3_TYPE |Wake-up on UART1_TX pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |9:8 |R/W|GPIO_WAKEUP_4_TYPE |Wake-up on PWM0 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |11:10|R/W|GPIO_WAKEUP_5_TYPE |Wake-up on PWM1 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |13:12|R/W|GPIO_WAKEUP_6_TYPE |Wake-up on WAKEUP_CS0 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal| - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |15:14|R/W|GPIO_WAKEUP_7_TYPE |Wake-up on WAKEUP_SDO pad. b00: disabled; b01: wake on high signal; b10: wake on low signal| - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |17:16|R/W|GPIO_WAKEUP_8_TYPE |Wake-up on I2C0_SDA pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |19:18|R/W|GPIO_WAKEUP_9_TYPE |Wake-up on I2C0_SCL pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |21:20|R/W|GPIO_WAKEUP_10_TYPE|Wake-up on SPI1_CS0 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |23:22|R/W|GPIO_WAKEUP_11_TYPE|Wake-up on SPI1_CS1 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |25:24|R/W|GPIO_WAKEUP_12_TYPE|Wake-up on SPI1_CS2 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |27:26|R/W|GPIO_WAKEUP_13_TYPE|Wake-up on SPI1_CS3 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |29:28|R/W|GPIO_WAKEUP_14_TYPE|Wake-up on SPI1_SDI pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |31:30|R/W|GPIO_WAKEUP_15_TYPE|Wake-up on SPI1_SDO pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_CNT_CTRL: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===================+=====+===========================================================================================+ + |1:0 |R/W|GPIO_WAKEUP_0_TYPE |0x0 |Wake-up on I2C1_SDA pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |3:2 |R/W|GPIO_WAKEUP_1_TYPE |0x0 |Wake-up on I2C1_SCL pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |5:4 |R/W|GPIO_WAKEUP_2_TYPE |0x0 |Wake-up on UART1_RX pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |7:6 |R/W|GPIO_WAKEUP_3_TYPE |0x0 |Wake-up on UART1_TX pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |9:8 |R/W|GPIO_WAKEUP_4_TYPE |0x0 |Wake-up on PWM0 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |11:10|R/W|GPIO_WAKEUP_5_TYPE |0x0 |Wake-up on PWM1 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |13:12|R/W|GPIO_WAKEUP_6_TYPE |0x0 |Wake-up on WAKEUP_CS0 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal| + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |15:14|R/W|GPIO_WAKEUP_7_TYPE |0x0 |Wake-up on WAKEUP_SDO pad. b00: disabled; b01: wake on high signal; b10: wake on low signal| + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |17:16|R/W|GPIO_WAKEUP_8_TYPE |0x0 |Wake-up on I2C0_SDA pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |19:18|R/W|GPIO_WAKEUP_9_TYPE |0x0 |Wake-up on I2C0_SCL pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |21:20|R/W|GPIO_WAKEUP_10_TYPE|0x0 |Wake-up on SPI1_CS0 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |23:22|R/W|GPIO_WAKEUP_11_TYPE|0x0 |Wake-up on SPI1_CS1 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |25:24|R/W|GPIO_WAKEUP_12_TYPE|0x0 |Wake-up on SPI1_CS2 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |27:26|R/W|GPIO_WAKEUP_13_TYPE|0x0 |Wake-up on SPI1_CS3 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |29:28|R/W|GPIO_WAKEUP_14_TYPE|0x0 |Wake-up on SPI1_SDI pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |31:30|R/W|GPIO_WAKEUP_15_TYPE|0x0 |Wake-up on SPI1_SDO pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_CNT_CTRL: SLEEP_CNT_CTRL """""""""""""" @@ -2234,18 +2254,20 @@ SLEEP_CNT_CTRL Sleep Counter control .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+====================================+ - |19:0 |R/W|VALUE |Counter target value | - +-----+---+---------+------------------------------------+ - |20 |R/W|EN |Counter enable | - +-----+---+---------+------------------------------------+ - |21 |R/W|CNT_EVENT|Counter event (target value reached)| - +-----+---+---------+------------------------------------+ + +-----+---+---------+-----+------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+====================================+ + |19:0 |R/W|VALUE |0x0 |Counter target value | + +-----+---+---------+-----+------------------------------------+ + |20 |R/W|EN |0x0 |Counter enable | + +-----+---+---------+-----+------------------------------------+ + |21 |R/W|CNT_EVENT|0x0 |Counter event (target value reached)| + +-----+---+---------+-----+------------------------------------+ -.. _apb_soc_ctrl_REG_OSC_CTRL: +.. _apb_soc_ctrl__REG_OSC_CTRL: REG_OSC_CTRL """""""""""" @@ -2253,33 +2275,20 @@ REG_OSC_CTRL Controls fast oscillator .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+===========================================================================================================================+ - | 0|R/W|FAST_OSC_EN |0 - Power Down, 1 - Enables fast oscillator | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|SLOW_OSC_EN |0 - Power Down, 1 - Enables 32KHz oscillator | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - | 2|R/W|BYPASS_FAST_OSC|0 - Use fast oscillator to generate FAST REF clock, 1 - Use external signal on USART0_CLK/FAST_REF_CK pad as FAST REF clock| - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_RESERVED7: - -RESERVED7 -""""""""" - -Reserved - -.. table:: - - +-----+---+----+----------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================+ - | 0|R |BUSY|Cluster busy flag (i.e. It's 1 if there is at least 1 active block in the cluster)| - +-----+---+----+----------------------------------------------------------------------------------+ + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+=========================================================================================================================+ + | 0|R/W|FAST_OSC_EN |0x0 |0: Power Down, 1: Enables fast oscillator | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|SLOW_OSC_EN |0x0 |0: Power Down, 1: Enables 32KHz oscillator | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------+ + | 2|R/W|BYPASS_FAST_OSC|0x0 |0: Use fast oscillator to generate FAST REF clock, 1: Use external signal on USART0_CLK/FAST_REF_CK pad as FAST REF clock| + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_CLK_DIV_REF_FAST_POW2: +.. _apb_soc_ctrl__CLK_DIV_REF_FAST_POW2: CLK_DIV_REF_FAST_POW2 """"""""""""""""""""" @@ -2287,41 +2296,45 @@ CLK_DIV_REF_FAST_POW2 Controls fast oscillator pow2 divider .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+==========================================+ - |2:0 |R/W|DIVIDER|Fast clock divider (division is 2^DIVIDER)| - +-----+---+-------+------------------------------------------+ - |3 |R/W|EN |Enable divider | - +-----+---+-------+------------------------------------------+ + +-----+---+-------+-----+------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==========================================+ + |2:0 |R/W|DIVIDER|0x0 |Fast clock divider (division is 2^DIVIDER)| + +-----+---+-------+-----+------------------------------------------+ + |3 |R/W|EN |0x0 |Enable divider | + +-----+---+-------+-----+------------------------------------------+ -.. _apb_soc_ctrl_FEATURE_DISABLEMENT: +.. _apb_soc_ctrl__FEATURE_DISABLE: -FEATURE_DISABLEMENT -""""""""""""""""""" +FEATURE_DISABLE +""""""""""""""" Feature disablement from always on (safe) domain .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------------------+--------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+======================================================================================================================================+ - | 0|R/W|DISABLE_JTAG |Disable jtag. It is disabled at reset and may be enabled back by the bootloader | - +-----+---+---------------------+--------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|DISABLE_CRYPTO |Disable aes and quiddikey | - +-----+---+---------------------+--------------------------------------------------------------------------------------------------------------------------------------+ - | 2|R/W|DISABLE_MRAM |Disable mram | - +-----+---+---------------------+--------------------------------------------------------------------------------------------------------------------------------------+ - | 3|R/W|DISABLE_EFUSE_PROGRAM|Disable efuse programming | - +-----+---+---------------------+--------------------------------------------------------------------------------------------------------------------------------------+ - | 4|R/W|DISABLE_SAFE_JTAG |Disable safe domain jtag to avoid accidental toggling when alternates are used | - +-----+---+---------------------+--------------------------------------------------------------------------------------------------------------------------------------+ - | 31|R/W|DISABLE_LOCK |When set, DISABLE_* registers cannot be written to zero until next whole chip reset or power-up. Configuration is kept in sleep modes.| - +-----+---+---------------------+--------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+======================================================================================================================================+ + | 0|R/W|DISABLE_JTAG |0x1 |Disable jtag. It is disabled at reset and may be enabled back by the bootloader | + +-----+---+---------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|DISABLE_CRYPTO |0x0 |Disable aes and quiddikey | + +-----+---+---------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + | 2|R/W|DISABLE_MRAM |0x0 |Disable mram | + +-----+---+---------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + | 3|R/W|DISABLE_EFUSE_PROGRAM|0x0 |Disable eFuse programming | + +-----+---+---------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + | 4|R/W|DISABLE_SAFE_JTAG |0x0 |Disable safe domain jtag to avoid accidental toggling when alternates are used | + +-----+---+---------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + | 31|R/W|DISABLE_LOCK |0x0 |When set, DISABLE_* registers cannot be written to zero until next whole chip reset or power-up. Configuration is kept in sleep modes.| + +-----+---+---------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_SLEEP_PAD_CFG0: +.. _apb_soc_ctrl__SLEEP_PAD_CFG0: SLEEP_PAD_CFG0 """""""""""""" @@ -2329,52 +2342,54 @@ SLEEP_PAD_CFG0 Sleep pad control .. table:: - - +-----+---+---------------+--------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==============================================================+ - | 0|R/W|PAD_0_PULL_DOWN|Pad 33 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 1|R/W|PAD_0_PULL_UP |Pad 33 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |3:2 |R/W|PAD_0_DRIVE |Pad 33 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 4|R/W|PAD_0_OUT |Pad 33 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 5|R/W|PAD_0_OEN |Pad 33 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 8|R/W|PAD_1_PULL_DOWN|Pad 34 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 9|R/W|PAD_1_PULL_UP |Pad 34 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |11:10|R/W|PAD_1_DRIVE |Pad 34 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 12|R/W|PAD_1_OUT |Pad 34 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 13|R/W|PAD_1_OEN |Pad 34 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 16|R/W|PAD_2_PULL_DOWN|Pad 35 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 17|R/W|PAD_2_PULL_UP |Pad 35 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |19:18|R/W|PAD_2_DRIVE |Pad 35 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 20|R/W|PAD_2_OUT |Pad 35 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 21|R/W|PAD_2_OEN |Pad 35 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 24|R/W|PAD_3_PULL_DOWN|Pad 36 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 25|R/W|PAD_3_PULL_UP |Pad 36 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |27:26|R/W|PAD_3_DRIVE |Pad 36 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 28|R/W|PAD_3_OUT |Pad 36 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 29|R/W|PAD_3_OEN |Pad 36 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_PAD_CFG1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+--------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==============================================================+ + | 0|R/W|PAD_0_PULL_DOWN|0x0 |Pad 33 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x0 |Pad 33 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |3:2 |R/W|PAD_0_DRIVE |0x0 |Pad 33 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 4|R/W|PAD_0_OUT |0x0 |Pad 33 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 5|R/W|PAD_0_OEN |0x1 |Pad 33 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 8|R/W|PAD_1_PULL_DOWN|0x0 |Pad 34 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 9|R/W|PAD_1_PULL_UP |0x0 |Pad 34 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |11:10|R/W|PAD_1_DRIVE |0x0 |Pad 34 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 12|R/W|PAD_1_OUT |0x0 |Pad 34 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 13|R/W|PAD_1_OEN |0x1 |Pad 34 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 16|R/W|PAD_2_PULL_DOWN|0x0 |Pad 35 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 17|R/W|PAD_2_PULL_UP |0x0 |Pad 35 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |19:18|R/W|PAD_2_DRIVE |0x0 |Pad 35 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 20|R/W|PAD_2_OUT |0x0 |Pad 35 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 21|R/W|PAD_2_OEN |0x1 |Pad 35 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 24|R/W|PAD_3_PULL_DOWN|0x0 |Pad 36 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 25|R/W|PAD_3_PULL_UP |0x0 |Pad 36 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |27:26|R/W|PAD_3_DRIVE |0x0 |Pad 36 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 28|R/W|PAD_3_OUT |0x0 |Pad 36 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 29|R/W|PAD_3_OEN |0x1 |Pad 36 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_PAD_CFG1: SLEEP_PAD_CFG1 """""""""""""" @@ -2382,52 +2397,54 @@ SLEEP_PAD_CFG1 Sleep pad control .. table:: - - +-----+---+---------------+--------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==============================================================+ - | 0|R/W|PAD_0_PULL_DOWN|Pad 37 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 1|R/W|PAD_0_PULL_UP |Pad 37 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |3:2 |R/W|PAD_0_DRIVE |Pad 37 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 4|R/W|PAD_0_OUT |Pad 37 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 5|R/W|PAD_0_OEN |Pad 37 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 8|R/W|PAD_1_PULL_DOWN|Pad 38 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 9|R/W|PAD_1_PULL_UP |Pad 38 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |11:10|R/W|PAD_1_DRIVE |Pad 38 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 12|R/W|PAD_1_OUT |Pad 38 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 13|R/W|PAD_1_OEN |Pad 38 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 16|R/W|PAD_2_PULL_DOWN|Pad 39 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 17|R/W|PAD_2_PULL_UP |Pad 39 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |19:18|R/W|PAD_2_DRIVE |Pad 39 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 20|R/W|PAD_2_OUT |Pad 39 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 21|R/W|PAD_2_OEN |Pad 39 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 24|R/W|PAD_3_PULL_DOWN|Pad 40 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 25|R/W|PAD_3_PULL_UP |Pad 40 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |27:26|R/W|PAD_3_DRIVE |Pad 40 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 28|R/W|PAD_3_OUT |Pad 40 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 29|R/W|PAD_3_OEN |Pad 40 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_PAD_CFG2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+--------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==============================================================+ + | 0|R/W|PAD_0_PULL_DOWN|0x0 |Pad 37 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x0 |Pad 37 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |3:2 |R/W|PAD_0_DRIVE |0x0 |Pad 37 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 4|R/W|PAD_0_OUT |0x0 |Pad 37 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 5|R/W|PAD_0_OEN |0x1 |Pad 37 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 8|R/W|PAD_1_PULL_DOWN|0x0 |Pad 38 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 9|R/W|PAD_1_PULL_UP |0x0 |Pad 38 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |11:10|R/W|PAD_1_DRIVE |0x0 |Pad 38 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 12|R/W|PAD_1_OUT |0x0 |Pad 38 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 13|R/W|PAD_1_OEN |0x1 |Pad 38 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 16|R/W|PAD_2_PULL_DOWN|0x0 |Pad 39 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 17|R/W|PAD_2_PULL_UP |0x0 |Pad 39 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |19:18|R/W|PAD_2_DRIVE |0x0 |Pad 39 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 20|R/W|PAD_2_OUT |0x0 |Pad 39 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 21|R/W|PAD_2_OEN |0x1 |Pad 39 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 24|R/W|PAD_3_PULL_DOWN|0x0 |Pad 40 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 25|R/W|PAD_3_PULL_UP |0x0 |Pad 40 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |27:26|R/W|PAD_3_DRIVE |0x0 |Pad 40 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 28|R/W|PAD_3_OUT |0x0 |Pad 40 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 29|R/W|PAD_3_OEN |0x1 |Pad 40 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_PAD_CFG2: SLEEP_PAD_CFG2 """""""""""""" @@ -2435,52 +2452,54 @@ SLEEP_PAD_CFG2 Sleep pad control .. table:: - - +-----+---+---------------+--------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==============================================================+ - | 0|R/W|PAD_0_PULL_DOWN|Pad 41 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 1|R/W|PAD_0_PULL_UP |Pad 41 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |3:2 |R/W|PAD_0_DRIVE |Pad 41 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 4|R/W|PAD_0_OUT |Pad 41 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 5|R/W|PAD_0_OEN |Pad 41 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 8|R/W|PAD_1_PULL_DOWN|Pad 42 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 9|R/W|PAD_1_PULL_UP |Pad 42 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |11:10|R/W|PAD_1_DRIVE |Pad 42 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 12|R/W|PAD_1_OUT |Pad 42 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 13|R/W|PAD_1_OEN |Pad 42 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 16|R/W|PAD_2_PULL_DOWN|Pad 43 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 17|R/W|PAD_2_PULL_UP |Pad 43 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |19:18|R/W|PAD_2_DRIVE |Pad 43 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 20|R/W|PAD_2_OUT |Pad 43 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 21|R/W|PAD_2_OEN |Pad 43 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 24|R/W|PAD_3_PULL_DOWN|Pad 65 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 25|R/W|PAD_3_PULL_UP |Pad 65 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |27:26|R/W|PAD_3_DRIVE |Pad 65 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 28|R/W|PAD_3_OUT |Pad 65 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 29|R/W|PAD_3_OEN |Pad 65 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_PAD_CFG3: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+--------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==============================================================+ + | 0|R/W|PAD_0_PULL_DOWN|0x0 |Pad 41 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x0 |Pad 41 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |3:2 |R/W|PAD_0_DRIVE |0x0 |Pad 41 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 4|R/W|PAD_0_OUT |0x0 |Pad 41 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 5|R/W|PAD_0_OEN |0x1 |Pad 41 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 8|R/W|PAD_1_PULL_DOWN|0x0 |Pad 42 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 9|R/W|PAD_1_PULL_UP |0x0 |Pad 42 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |11:10|R/W|PAD_1_DRIVE |0x0 |Pad 42 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 12|R/W|PAD_1_OUT |0x0 |Pad 42 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 13|R/W|PAD_1_OEN |0x1 |Pad 42 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 16|R/W|PAD_2_PULL_DOWN|0x0 |Pad 43 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 17|R/W|PAD_2_PULL_UP |0x0 |Pad 43 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |19:18|R/W|PAD_2_DRIVE |0x0 |Pad 43 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 20|R/W|PAD_2_OUT |0x0 |Pad 43 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 21|R/W|PAD_2_OEN |0x1 |Pad 43 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 24|R/W|PAD_3_PULL_DOWN|0x0 |Pad 65 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 25|R/W|PAD_3_PULL_UP |0x0 |Pad 65 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |27:26|R/W|PAD_3_DRIVE |0x0 |Pad 65 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 28|R/W|PAD_3_OUT |0x0 |Pad 65 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 29|R/W|PAD_3_OEN |0x1 |Pad 65 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_PAD_CFG3: SLEEP_PAD_CFG3 """""""""""""" @@ -2488,52 +2507,54 @@ SLEEP_PAD_CFG3 Sleep pad control .. table:: - - +-----+---+---------------+--------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==============================================================+ - | 0|R/W|PAD_0_PULL_DOWN|Pad 66 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 1|R/W|PAD_0_PULL_UP |Pad 66 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |3:2 |R/W|PAD_0_DRIVE |Pad 66 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 4|R/W|PAD_0_OUT |Pad 66 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 5|R/W|PAD_0_OEN |Pad 66 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 8|R/W|PAD_1_PULL_DOWN|Pad 67 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 9|R/W|PAD_1_PULL_UP |Pad 67 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |11:10|R/W|PAD_1_DRIVE |Pad 67 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 12|R/W|PAD_1_OUT |Pad 67 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 13|R/W|PAD_1_OEN |Pad 67 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 16|R/W|PAD_2_PULL_DOWN|Pad 68 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 17|R/W|PAD_2_PULL_UP |Pad 68 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |19:18|R/W|PAD_2_DRIVE |Pad 68 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 20|R/W|PAD_2_OUT |Pad 68 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 21|R/W|PAD_2_OEN |Pad 68 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 24|R/W|PAD_3_PULL_DOWN|Pad 69 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 25|R/W|PAD_3_PULL_UP |Pad 69 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |27:26|R/W|PAD_3_DRIVE |Pad 69 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 28|R/W|PAD_3_OUT |Pad 69 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 29|R/W|PAD_3_OEN |Pad 69 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_PAD_CFG4: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+--------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==============================================================+ + | 0|R/W|PAD_0_PULL_DOWN|0x0 |Pad 66 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x0 |Pad 66 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |3:2 |R/W|PAD_0_DRIVE |0x0 |Pad 66 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 4|R/W|PAD_0_OUT |0x0 |Pad 66 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 5|R/W|PAD_0_OEN |0x1 |Pad 66 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 8|R/W|PAD_1_PULL_DOWN|0x0 |Pad 67 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 9|R/W|PAD_1_PULL_UP |0x0 |Pad 67 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |11:10|R/W|PAD_1_DRIVE |0x0 |Pad 67 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 12|R/W|PAD_1_OUT |0x0 |Pad 67 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 13|R/W|PAD_1_OEN |0x1 |Pad 67 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 16|R/W|PAD_2_PULL_DOWN|0x0 |Pad 68 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 17|R/W|PAD_2_PULL_UP |0x0 |Pad 68 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |19:18|R/W|PAD_2_DRIVE |0x0 |Pad 68 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 20|R/W|PAD_2_OUT |0x0 |Pad 68 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 21|R/W|PAD_2_OEN |0x1 |Pad 68 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 24|R/W|PAD_3_PULL_DOWN|0x0 |Pad 69 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 25|R/W|PAD_3_PULL_UP |0x0 |Pad 69 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |27:26|R/W|PAD_3_DRIVE |0x0 |Pad 69 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 28|R/W|PAD_3_OUT |0x0 |Pad 69 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 29|R/W|PAD_3_OEN |0x1 |Pad 69 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_PAD_CFG4: SLEEP_PAD_CFG4 """""""""""""" @@ -2541,52 +2562,54 @@ SLEEP_PAD_CFG4 Sleep pad control .. table:: - - +-----+---+---------------+--------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==============================================================+ - | 0|R/W|PAD_0_PULL_DOWN|Pad 81 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 1|R/W|PAD_0_PULL_UP |Pad 81 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |3:2 |R/W|PAD_0_DRIVE |Pad 81 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 4|R/W|PAD_0_OUT |Pad 81 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 5|R/W|PAD_0_OEN |Pad 81 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 8|R/W|PAD_1_PULL_DOWN|Pad 82 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 9|R/W|PAD_1_PULL_UP |Pad 82 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |11:10|R/W|PAD_1_DRIVE |Pad 82 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 12|R/W|PAD_1_OUT |Pad 82 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 13|R/W|PAD_1_OEN |Pad 82 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 16|R/W|PAD_2_PULL_DOWN|Pad 83 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 17|R/W|PAD_2_PULL_UP |Pad 83 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |19:18|R/W|PAD_2_DRIVE |Pad 83 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 20|R/W|PAD_2_OUT |Pad 83 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 21|R/W|PAD_2_OEN |Pad 83 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 24|R/W|PAD_3_PULL_DOWN|Pad 84 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 25|R/W|PAD_3_PULL_UP |Pad 84 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |27:26|R/W|PAD_3_DRIVE |Pad 84 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 28|R/W|PAD_3_OUT |Pad 84 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 29|R/W|PAD_3_OEN |Pad 84 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_PAD_CFG5: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+--------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==============================================================+ + | 0|R/W|PAD_0_PULL_DOWN|0x0 |Pad 81 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x0 |Pad 81 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |3:2 |R/W|PAD_0_DRIVE |0x0 |Pad 81 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 4|R/W|PAD_0_OUT |0x0 |Pad 81 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 5|R/W|PAD_0_OEN |0x1 |Pad 81 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 8|R/W|PAD_1_PULL_DOWN|0x0 |Pad 82 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 9|R/W|PAD_1_PULL_UP |0x0 |Pad 82 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |11:10|R/W|PAD_1_DRIVE |0x0 |Pad 82 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 12|R/W|PAD_1_OUT |0x0 |Pad 82 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 13|R/W|PAD_1_OEN |0x1 |Pad 82 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 16|R/W|PAD_2_PULL_DOWN|0x0 |Pad 83 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 17|R/W|PAD_2_PULL_UP |0x0 |Pad 83 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |19:18|R/W|PAD_2_DRIVE |0x0 |Pad 83 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 20|R/W|PAD_2_OUT |0x0 |Pad 83 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 21|R/W|PAD_2_OEN |0x1 |Pad 83 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 24|R/W|PAD_3_PULL_DOWN|0x0 |Pad 84 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 25|R/W|PAD_3_PULL_UP |0x0 |Pad 84 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |27:26|R/W|PAD_3_DRIVE |0x0 |Pad 84 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 28|R/W|PAD_3_OUT |0x0 |Pad 84 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 29|R/W|PAD_3_OEN |0x1 |Pad 84 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_PAD_CFG5: SLEEP_PAD_CFG5 """""""""""""" @@ -2594,52 +2617,54 @@ SLEEP_PAD_CFG5 Sleep pad control .. table:: - - +-----+---+---------------+--------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==============================================================+ - | 0|R/W|PAD_0_PULL_DOWN|Pad 85 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 1|R/W|PAD_0_PULL_UP |Pad 85 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |3:2 |R/W|PAD_0_DRIVE |Pad 85 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 4|R/W|PAD_0_OUT |Pad 85 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 5|R/W|PAD_0_OEN |Pad 85 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 8|R/W|PAD_1_PULL_DOWN|Pad 86 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 9|R/W|PAD_1_PULL_UP |Pad 86 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |11:10|R/W|PAD_1_DRIVE |Pad 86 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 12|R/W|PAD_1_OUT |Pad 86 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 13|R/W|PAD_1_OEN |Pad 86 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 16|R/W|PAD_2_PULL_DOWN|Pad 87 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 17|R/W|PAD_2_PULL_UP |Pad 87 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |19:18|R/W|PAD_2_DRIVE |Pad 87 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 20|R/W|PAD_2_OUT |Pad 87 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 21|R/W|PAD_2_OEN |Pad 87 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 24|R/W|PAD_3_PULL_DOWN|Pad 88 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 25|R/W|PAD_3_PULL_UP |Pad 88 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |27:26|R/W|PAD_3_DRIVE |Pad 88 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 28|R/W|PAD_3_OUT |Pad 88 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 29|R/W|PAD_3_OEN |Pad 88 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_PAD_CFG6: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+--------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==============================================================+ + | 0|R/W|PAD_0_PULL_DOWN|0x0 |Pad 85 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x1 |Pad 85 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |3:2 |R/W|PAD_0_DRIVE |0x0 |Pad 85 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 4|R/W|PAD_0_OUT |0x0 |Pad 85 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 5|R/W|PAD_0_OEN |0x1 |Pad 85 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 8|R/W|PAD_1_PULL_DOWN|0x0 |Pad 86 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 9|R/W|PAD_1_PULL_UP |0x0 |Pad 86 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |11:10|R/W|PAD_1_DRIVE |0x0 |Pad 86 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 12|R/W|PAD_1_OUT |0x0 |Pad 86 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 13|R/W|PAD_1_OEN |0x1 |Pad 86 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 16|R/W|PAD_2_PULL_DOWN|0x0 |Pad 87 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 17|R/W|PAD_2_PULL_UP |0x0 |Pad 87 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |19:18|R/W|PAD_2_DRIVE |0x0 |Pad 87 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 20|R/W|PAD_2_OUT |0x0 |Pad 87 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 21|R/W|PAD_2_OEN |0x1 |Pad 87 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 24|R/W|PAD_3_PULL_DOWN|0x0 |Pad 88 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 25|R/W|PAD_3_PULL_UP |0x0 |Pad 88 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |27:26|R/W|PAD_3_DRIVE |0x0 |Pad 88 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 28|R/W|PAD_3_OUT |0x0 |Pad 88 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 29|R/W|PAD_3_OEN |0x1 |Pad 88 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_PAD_CFG6: SLEEP_PAD_CFG6 """""""""""""" @@ -2647,50 +2672,62 @@ SLEEP_PAD_CFG6 Sleep pad control .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------------+--------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==============================================================+ - | 0|R/W|PAD_0_PULL_DOWN|Pad 89 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 1|R/W|PAD_0_PULL_UP |Pad 89 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |3:2 |R/W|PAD_0_DRIVE |Pad 89 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 4|R/W|PAD_0_OUT |Pad 89 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 5|R/W|PAD_0_OEN |Pad 89 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ + +-----+---+---------------+-----+--------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==============================================================+ + | 0|R/W|PAD_0_PULL_DOWN|0x0 |Pad 89 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x0 |Pad 89 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |3:2 |R/W|PAD_0_DRIVE |0x0 |Pad 89 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 4|R/W|PAD_0_OUT |0x0 |Pad 89 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 5|R/W|PAD_0_OEN |0x1 |Pad 89 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ -.. _apb_soc_ctrl_L2_CTRL_ACTIVE: +.. _apb_soc_ctrl__L2_CTRL_ACTIVE: L2_CTRL_ACTIVE """""""""""""" -Controls L2 power +Controls L2 power when SOC is powered on .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------------------+-----+------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===================+=====+========================================================================+ + |11:0 |R/W|INTLVD_L2_POWERGATE|0x0 |Force value of POWERGATE of INTERVLEAVED RAM banks when SOC domain is on| + +-----+---+-------------------+-----+------------------------------------------------------------------------+ + |27:16|R/W|INTLVD_L2_DEEPSLEEP|0x0 |Force value of DEEPSLEEP of INTERVLEAVED RAM banks when SOC domain is on| + +-----+---+-------------------+-----+------------------------------------------------------------------------+ -.. _apb_soc_ctrl_L2_PWR_ACTIVE: +.. _apb_soc_ctrl__L2_PWR_ACTIVE: L2_PWR_ACTIVE """"""""""""" -Controls L2 power +Controls L2 power when SOC is powered on .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===================+=====+=====================================================================================================================================+ + |11:0 |R/W|INTLVD_L2_SD_ARRAY |0x0 |Power switch control for memory array of INTERLEAVED banks when SOC domain is on (bit i=1 shuts down array supply for bank i) | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------+ + |11:0 |R/W|INTLVD_L2_SD_PERIPH|0x0 |Power switch control for memory periphery of INTERLEAVED banks when SOC domain is on (bit i=1 shuts down periphery supply for bank i)| + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_NEVACFG: +.. _apb_soc_ctrl__NEVACFG: NEVACFG """"""" @@ -2698,28 +2735,30 @@ NEVACFG NEVA config .. table:: - - +-----+---+----------------+------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+================+======================================================+ - |4:0 |R/W|NEVA_IO_LS_TSEL |Max output current when switching on switchable I/Os | - +-----+---+----------------+------------------------------------------------------+ - |5 |R/W|NEVA_IO_LS_FORCE|Force NEVA switch status for switchable I/Os | - +-----+---+----------------+------------------------------------------------------+ - |6 |R/W|NEVA_IO_LS_EN |EN signal value for switchable I/Os in force mode | - +-----+---+----------------+------------------------------------------------------+ - |7 |R/W|NEVA_IO_LS_SD |SD signal value for switchable I/Os in force mode | - +-----+---+----------------+------------------------------------------------------+ - |12:8 |R/W|NEVA_IO_HS_TSEL |Max output current when switching on memory interfaces| - +-----+---+----------------+------------------------------------------------------+ - |13 |R/W|NEVA_IO_HS_FORCE|Force NEVA switch status for memory interfaces | - +-----+---+----------------+------------------------------------------------------+ - |14 |R/W|NEVA_IO_HS_EN |EN signal value for memory interfaces in force mode | - +-----+---+----------------+------------------------------------------------------+ - |15 |R/W|NEVA_IO_HS_SD |SD signal value for memory interfaces in force mode | - +-----+---+----------------+------------------------------------------------------+ - -.. _apb_soc_ctrl_TRCCFG: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------+-----+------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+================+=====+======================================================+ + |4:0 |R/W|NEVA_IO_LS_TSEL |0x1F |Max output current when switching on switchable I/Os | + +-----+---+----------------+-----+------------------------------------------------------+ + |5 |R/W|NEVA_IO_LS_FORCE|0x0 |Force NEVA switch status for switchable I/Os | + +-----+---+----------------+-----+------------------------------------------------------+ + |6 |R/W|NEVA_IO_LS_EN |0x0 |EN signal value for switchable I/Os in force mode | + +-----+---+----------------+-----+------------------------------------------------------+ + |7 |R/W|NEVA_IO_LS_SD |0x0 |SD signal value for switchable I/Os in force mode | + +-----+---+----------------+-----+------------------------------------------------------+ + |12:8 |R/W|NEVA_IO_HS_TSEL |0x1F |Max output current when switching on memory interfaces| + +-----+---+----------------+-----+------------------------------------------------------+ + |13 |R/W|NEVA_IO_HS_FORCE|0x0 |Force NEVA switch status for memory interfaces | + +-----+---+----------------+-----+------------------------------------------------------+ + |14 |R/W|NEVA_IO_HS_EN |0x0 |EN signal value for memory interfaces in force mode | + +-----+---+----------------+-----+------------------------------------------------------+ + |15 |R/W|NEVA_IO_HS_SD |0x0 |SD signal value for memory interfaces in force mode | + +-----+---+----------------+-----+------------------------------------------------------+ + +.. _apb_soc_ctrl__TRCCFG: TRCCFG """""" @@ -2727,32 +2766,34 @@ TRCCFG TRC config .. table:: - - +-----+---+-----------------+--------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=================+========================================================+ - |1:0 |R/W|CSI2_PROGDELAY |CSI2 domain power switch controller PROGDELAY setting | - +-----+---+-----------------+--------------------------------------------------------+ - |4:2 |R/W|CSI2_CURRSET |CSI2 domain power switch controller CURRSET setting | - +-----+---+-----------------+--------------------------------------------------------+ - |6:5 |R/W|MRAM_PROGDELAY |MRAM domain power switch controller PROGDELAY setting | - +-----+---+-----------------+--------------------------------------------------------+ - |9:7 |R/W|MRAM_CURRSET |MRAM domain power switch controller CURRSET setting | - +-----+---+-----------------+--------------------------------------------------------+ - |11:10|R/W|SOC_PROGDELAY |SOC domain power switch controller PROGDELAY setting | - +-----+---+-----------------+--------------------------------------------------------+ - |14:12|R/W|SOC_CURRSET |SOC domain power switch controller CURRSET setting | - +-----+---+-----------------+--------------------------------------------------------+ - |16:15|R/W|CLUSTER_PROGDELAY|CLUSTER domain power switch controller PROGDELAY setting| - +-----+---+-----------------+--------------------------------------------------------+ - |19:17|R/W|CLUSTER_CURRSET |CLUSTER domain power switch controller CURRSET setting | - +-----+---+-----------------+--------------------------------------------------------+ - |21:20|R/W|SFU_PROGDELAY |SFU domain power switch controller PROGDELAY setting | - +-----+---+-----------------+--------------------------------------------------------+ - |24:22|R/W|SFU_CURRSET |SFU domain power switch controller CURRSET setting | - +-----+---+-----------------+--------------------------------------------------------+ - -.. _apb_soc_ctrl_RWM_L2_MEM: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------------+-----+--------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=================+=====+========================================================+ + |1:0 |R/W|CSI2_PROGDELAY |0x0 |CSI2 domain power switch controller PROGDELAY setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |4:2 |R/W|CSI2_CURRSET |0x7 |CSI2 domain power switch controller CURRSET setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |6:5 |R/W|MRAM_PROGDELAY |0x0 |MRAM domain power switch controller PROGDELAY setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |9:7 |R/W|MRAM_CURRSET |0x7 |MRAM domain power switch controller CURRSET setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |11:10|R/W|SOC_PROGDELAY |0x0 |SOC domain power switch controller PROGDELAY setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |14:12|R/W|SOC_CURRSET |0x7 |SOC domain power switch controller CURRSET setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |16:15|R/W|CLUSTER_PROGDELAY|0x0 |CLUSTER domain power switch controller PROGDELAY setting| + +-----+---+-----------------+-----+--------------------------------------------------------+ + |19:17|R/W|CLUSTER_CURRSET |0x7 |CLUSTER domain power switch controller CURRSET setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |21:20|R/W|SFU_PROGDELAY |0x0 |SFU domain power switch controller PROGDELAY setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |24:22|R/W|SFU_CURRSET |0x7 |SFU domain power switch controller CURRSET setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + +.. _apb_soc_ctrl__RWM_L2_MEM: RWM_L2_MEM """""""""" @@ -2760,24 +2801,26 @@ RWM_L2_MEM Read/write margins for L2 and ROM memories .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------------+-----------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===========================================================+ - |5:0 |R/W|RWM_L2_INTLVD |Margin setting for L2 interleaved banks | - +-----+---+--------------+-----------------------------------------------------------+ - |13:8 |R/W|RWM_L2_PRIVATE|Margin setting for L2 private banks | - +-----+---+--------------+-----------------------------------------------------------+ - |16 |R/W|RWM_L2_FORCE |0 - use default RWM values, 1 - use RWML2* values | - +-----+---+--------------+-----------------------------------------------------------+ - |21:20|R/W|RWM_ROM_SAWL |SAWL margin setting for ROM | - +-----+---+--------------+-----------------------------------------------------------+ - |22 |R/W|RWM_ROM_WL |WL margin setting for ROM | - +-----+---+--------------+-----------------------------------------------------------+ - |24 |R/W|RWM_ROM_FORCE |0 - use default RWM values, 1 - use RWMROM* values| - +-----+---+--------------+-----------------------------------------------------------+ + +-----+---+--------------+-----+--------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+==================================================+ + |5:0 |R/W|RWM_L2_INTLVD |0x20 |Margin setting for L2 interleaved banks | + +-----+---+--------------+-----+--------------------------------------------------+ + |13:8 |R/W|RWM_L2_PRIVATE|0x20 |Margin setting for L2 private banks | + +-----+---+--------------+-----+--------------------------------------------------+ + |16 |R/W|RWM_L2_FORCE |0x0 |0: use default RWM values, 1: use RWM_L2_* values | + +-----+---+--------------+-----+--------------------------------------------------+ + |21:20|R/W|RWM_ROM_SAWL |0x2 |SAWL margin setting for ROM | + +-----+---+--------------+-----+--------------------------------------------------+ + |22 |R/W|RWM_ROM_WL |0x0 |WL margin setting for ROM | + +-----+---+--------------+-----+--------------------------------------------------+ + |24 |R/W|RWM_ROM_FORCE |0x1 |0: use default RWM values, 1: use RWM_ROM_* values| + +-----+---+--------------+-----+--------------------------------------------------+ -.. _apb_soc_ctrl_CLU_SW_RSTN: +.. _apb_soc_ctrl__CLU_SW_RSTN: CLU_SW_RSTN """"""""""" @@ -2785,48 +2828,54 @@ CLU_SW_RSTN Cluster software reset .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+===================================+ - | 0|R/W|CLUSTER_RSTN|Cluster software reset (active low)| - +-----+---+------------+-----------------------------------+ + +-----+---+------------+-----+-----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===================================+ + | 0|R/W|CLUSTER_RSTN|0x1 |Cluster software reset (active low)| + +-----+---+------------+-----+-----------------------------------+ -.. _apb_soc_ctrl_L2_PWR: +.. _apb_soc_ctrl__L2_PWR: L2_PWR """""" -Controls L2 power +Controls L2 power when SOC is off (deepsleep) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------+------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+======================================================+ - |13:0 |R/W|L2_MEM_RET |L2 retention control for private and interleaved banks| - +-----+---+-----------+------------------------------------------------------+ - |27:16|R/W|L2_MEM_PDWN|L2 power control for interleaved banks | - +-----+---+-----------+------------------------------------------------------+ + +-----+---+-------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===================+=====+======================================================================================================================================+ + |11:0 |R/W|INTLVD_L2_SD_ARRAY |0x0 |Power switch control for memory array of INTERLEAVED banks when chip is in retentive mode (bit i=1 shuts down array supply for bank i)| + +-----+---+-------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + |1:0 |R/W|PRIVATE_L2_SD_ARRAY|0x0 |Power switch control for memory array of PRIVATE banks when chip is in retentive mode (bit i=1 shuts down array supply for bank i) | + +-----+---+-------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_L2_CTRL: +.. _apb_soc_ctrl__L2_CTRL: L2_CTRL """"""" -Controls L2 power +Controls L2 power when SOC is off (deepsleep) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------------+-------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+================+=======================================================+ - |13:0 |R/W|L2_MEM_POWERGATE|L2 power gate control for private and interleaved banks| - +-----+---+----------------+-------------------------------------------------------+ - |27:16|R/W|L2_MEM_DEEPSLEEP|L2 deep sleep for interleaved banks | - +-----+---+----------------+-------------------------------------------------------+ + +-----+---+-------------------+-----+---------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===================+=====+===========================================================================================================================+ + |11:0 |R/W|INTLVD_L2_DEEPSLEEP|0x0 |Force INTERLEAVED banks into deepsleep (data is lost) when chip is in retentive mode (bit i=1 enables deepsleep for bank i)| + +-----+---+-------------------+-----+---------------------------------------------------------------------------------------------------------------------------+ + |13:12|R/W|PRI_L2_DEEPSLEEP |0x0 |Force PRIVATE banks into deepsleep (data is lost) when chip is in retentive mode (bit i=1 enables deepsleep for bank i) | + +-----+---+-------------------+-----+---------------------------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_BORCFG: +.. _apb_soc_ctrl__BORCFG: BORCFG """""" @@ -2834,16 +2883,18 @@ BORCFG Controls the brown-out reset .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------+---------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+=================================================================================+ - | 0|R/W|BOR_ENABLE|Set to 1 to enable BOR monitoring of power supply | - +-----+---+----------+---------------------------------------------------------------------------------+ - |5:1 |R/W|BOR_VSEL |Threshold of detection of power supply drops. Recommended values: 00100 or 00011.| - +-----+---+----------+---------------------------------------------------------------------------------+ + +-----+---+----------+-----+---------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+=================================================================================+ + | 0|R/W|BOR_ENABLE|0x0 |Set to 1 to enable BOR monitoring of power supply | + +-----+---+----------+-----+---------------------------------------------------------------------------------+ + |5:1 |R/W|BOR_VSEL |0x04 |Threshold of detection of power supply drops. Recommended values: 00100 or 00011.| + +-----+---+----------+-----+---------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_RARMODE: +.. _apb_soc_ctrl__RARMODE: RARMODE """"""" @@ -2851,18 +2902,20 @@ RARMODE Controls configuration of the DC-DC modulation at low loads .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+===================================================================+ - | 0|R/W|ACTIVESKIPB |Enables standard DC-DC behavior (pulse-skipping off, decimation on)| - +-----+---+-------------+-------------------------------------------------------------------+ - | 1|R/W|EN_DECIM_SKIP|Enables decimation when in pulse-skipping mode | - +-----+---+-------------+-------------------------------------------------------------------+ - | 2|R/W|DISABLE_VREF |Disable generation of 0.6V Vref to save power if eMRAM is not used | - +-----+---+-------------+-------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+===================================================================+ + | 0|R/W|ACTIVESKIPB |0x0 |Enables standard DC-DC behavior (pulse-skipping off, decimation on)| + +-----+---+-------------+-----+-------------------------------------------------------------------+ + | 1|R/W|EN_DECIM_SKIP|0x0 |Enables decimation when in pulse-skipping mode | + +-----+---+-------------+-----+-------------------------------------------------------------------+ + | 2|R/W|DISABLE_VREF |0x0 |Disable generation of 0.6V Vref to save power if eMRAM is not used | + +-----+---+-------------+-----+-------------------------------------------------------------------+ -.. _apb_soc_ctrl_ABBCFG: +.. _apb_soc_ctrl__ABBCFG: ABBCFG """""" @@ -2870,16 +2923,18 @@ ABBCFG Used to disable adaptive body-bias .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------------+--------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===================+==========================+ - | 0|R/W|SOC_ABB_DISABLE |Disable SOC domain ABB | - +-----+---+-------------------+--------------------------+ - | 1|R/W|CLUSTER_ABB_DISABLE|Disable CLUSTER domain ABB| - +-----+---+-------------------+--------------------------+ + +-----+---+-------------------+-----+--------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===================+=====+==========================+ + | 0|R/W|SOC_ABB_DISABLE |0x0 |Disable SOC domain ABB | + +-----+---+-------------------+-----+--------------------------+ + | 1|R/W|CLUSTER_ABB_DISABLE|0x0 |Disable CLUSTER domain ABB| + +-----+---+-------------------+-----+--------------------------+ -.. _apb_soc_ctrl_L2_ACK: +.. _apb_soc_ctrl__L2_ACK: L2_ACK """""" @@ -2887,13 +2942,15 @@ L2_ACK Acknowledge/status signals from L2 memories .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------------------+----------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==========================================================+ - |11:0 |R |INTLVD_ARRAY_WAKE_ACK |Wake status of the arrays of interleaved L2 banks | - +-----+---+----------------------+----------------------------------------------------------+ - |27:16|R |INTLVD_PERIPH_WAKE_ACK|Wake status of the periphery logic of interleaved L2 banks| - +-----+---+----------------------+----------------------------------------------------------+ - |31:30|R |PRIVATE_ARRAY_WAKE_ACK|Wake status of the arrays of private L2 banks | - +-----+---+----------------------+----------------------------------------------------------+ + +-----+---+----------------------+-----+----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+==========================================================+ + |11:0 |R |INTLVD_ARRAY_WAKE_ACK |0x0 |Wake status of the arrays of interleaved L2 banks | + +-----+---+----------------------+-----+----------------------------------------------------------+ + |27:16|R |INTLVD_PERIPH_WAKE_ACK|0x0 |Wake status of the periphery logic of interleaved L2 banks| + +-----+---+----------------------+-----+----------------------------------------------------------+ + |31:30|R |PRIVATE_ARRAY_WAKE_ACK|0x0 |Wake status of the arrays of private L2 banks | + +-----+---+----------------------+-----+----------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/apb_soc_ctrl.rst.ref b/rtos/pulp/gap_archi/doc/ips/apb_soc_ctrl.rst.ref index 5ee123734..050bf878a 100644 --- a/rtos/pulp/gap_archi/doc/ips/apb_soc_ctrl.rst.ref +++ b/rtos/pulp/gap_archi/doc/ips/apb_soc_ctrl.rst.ref @@ -8,193 +8,182 @@ Register map Overview """""""" -.. table:: - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - | Name |Offset|Width| Description | - +====================================================================+======+=====+===========================================================+ - |:ref:`INFO` | 0| 32|Core information register. | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`FC_BOOT` | 4| 32|Boot address | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`FC_FETCH` | 8| 32|FC Fetch enable | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CL_ISOLATE` | 12| 32|Isolate cluster register | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADFUN0` | 16| 32|Mux config register (pad 0-15) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADFUN1` | 20| 32|Mux config register (pad 16-31) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADFUN2` | 24| 32|Mux config register (pad 32-47) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADFUN3` | 28| 32|Mux config register (pad 48-63) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADFUN4` | 32| 32|Mux config register (pad 64-79) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADFUN5` | 36| 32|Mux config register (pad 80-89) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`FEATURE_DISABLEMENT_SOC`| 40| 32|Feature disablement from SoC domain | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED0` | 44| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG0` | 48| 32|Function register (pad 0 to 3) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG1` | 52| 32|Function register (pad 4 to 7) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG2` | 56| 32|Function register (pad 8 to 11) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG3` | 60| 32|Function register (pad 12 to 15) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG4` | 64| 32|Function register (pad 16 to 19) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG5` | 68| 32|Function register (pad 20 to 23) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG6` | 72| 32|Function register (pad 24 to 27) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG7` | 76| 32|Function register (pad 28 to 31) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG8` | 80| 32|Function register (pad 32 to 35) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG9` | 84| 32|Function register (pad 36 to 39) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG10` | 88| 32|Function register (pad 40 to 43) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG11` | 92| 32|Function register (pad 44 to 47) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG12` | 96| 32|Function register (pad 48 to 51) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG13` | 100| 32|Function register (pad 52 to 55) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG14` | 104| 32|Function register (pad 56 to 59) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG15` | 108| 32|Function register (pad 60 to 63) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG16` | 112| 32|Function register (pad 64 to 67) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG17` | 116| 32|Function register (pad 68 to 71) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG18` | 120| 32|Function register (pad 72 to 75) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG19` | 124| 32|Function register (pad 76 to 79) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG20` | 128| 32|Function register (pad 80 to 83) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG21` | 132| 32|Function register (pad 84 to 87) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`PADCFG22` | 136| 32|Function register (pad 88 to 89) | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`REG_REPROG_PAD0` | 144| 32|Controls reprogrammable pads 27,28,29,30,34 | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`REG_REPROG_PAD1` | 148| 32|Controls reprogrammable pads 35,40,41,42,43 | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`REG_REPROG_PAD2` | 152| 32|Controls reprogrammable pads 44,45,60,61,62 | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`REG_REPROG_PAD3` | 156| 32|Controls reprogrammable pads 63,65,66,67,68 | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED1` | 160| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED2` | 164| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED3` | 168| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED4` | 172| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CL_BUSY` | 176| 32|Cluster busy register | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`JTAGREG` | 180| 32|JTAG external register | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`REF_FAST_CLK_DIV` | 184| 32|Read only, reference fast clk divided by power of 2 | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SW_RST` | 188| 32|Software reset, reboot | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CORESTATUS` | 192| 32|EOC and chip status register | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`BOOTSEL` | 196| 32|Value of pad bootsel | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`WD_RST_RST` | 200| 32|Rearm WD timeout | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`WD_RST_SET` | 204| 32|Set WD timer | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RWM_CSI2` | 208| 32|RWM for CSI2 | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`IDLE_MODE` | 212| 32|Activates IDLE MODE | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RWM_ANC` | 216| 32|RWM for ANC | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`REF_CLK_MUX` | 220| 32|Ref clock mux 0: 32Khz 1: ref fast | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SUPERVISOR_DBG` | 224| 32| | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`DBG_CTRL` | 228| 32|Debug access control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED5` | 232| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED6` | 236| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CLK_DIV_I3C` | 240| 32|Clock divider for I3C | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CLK_EN_QUIDDIKEY` | 244| 32|Clock divider for QUIDDIKEY | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_CTRL_INFO` | 248| 32|Safe domain's Sleep control info | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`VERSION` | 252| 32|Show chip version | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_SPIS_CTRL` | 256| 32|Sleep SPIS control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_CTRL` | 260| 32|Sleep control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_GPIO_CTRL` | 264| 32|Sleep GPIO control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_CNT_CTRL` | 268| 32|Sleep Counter control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`REG_OSC_CTRL` | 272| 32|Controls fast oscillator | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RESERVED7` | 236| 32|Reserved | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CLK_DIV_REF_FAST_POW2` | 280| 32|Controls fast oscillator pow2 divider | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`FEATURE_DISABLEMENT` | 288| 32|Feature disablement from always on (safe) domain | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_PAD_CFG0` | 320| 32|Sleep pad control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_PAD_CFG1` | 324| 32|Sleep pad control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_PAD_CFG2` | 328| 32|Sleep pad control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_PAD_CFG3` | 332| 32|Sleep pad control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_PAD_CFG4` | 336| 32|Sleep pad control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_PAD_CFG5` | 340| 32|Sleep pad control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLEEP_PAD_CFG6` | 344| 32|Sleep pad control | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`L2_CTRL_ACTIVE` | 348| 32|Controls L2 power | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`L2_PWR_ACTIVE` | 352| 32|Controls L2 power | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`NEVACFG` | 356| 32|NEVA config | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`TRCCFG` | 360| 32|TRC config | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RWM_L2_MEM` | 364| 32|Read/write margins for L2 and ROM memories | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CLU_SW_RSTN` | 368| 32|Cluster software reset | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`L2_PWR` | 372| 32|Controls L2 power | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`L2_CTRL` | 376| 32|Controls L2 power | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`BORCFG` | 384| 32|Controls the brown-out reset | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`RARMODE` | 388| 32|Controls configuration of the DC-DC modulation at low loads| - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`ABBCFG` | 392| 32|Used to disable adaptive body-bias | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`L2_ACK` | 396| 32|Acknowledge/status signals from L2 memories | - +--------------------------------------------------------------------+------+-----+-----------------------------------------------------------+ - -.. _apb_soc_ctrl_INFO: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + | Name |Offset|Width| Description | + +=================================================================+======+=====+===========================================================+ + |:ref:`INFO` | 0| 32|Core information register. | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`FC_BOOT` | 4| 32|Boot address | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`FC_FETCH` | 8| 32|FC Fetch enable | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CL_ISOLATE` | 12| 32|Isolate cluster register | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADFUN0` | 16| 32|Mux config register (pad 0-15) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADFUN1` | 20| 32|Mux config register (pad 16-31) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADFUN2` | 24| 32|Mux config register (pad 32-47) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADFUN3` | 28| 32|Mux config register (pad 48-63) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADFUN4` | 32| 32|Mux config register (pad 64-79) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADFUN5` | 36| 32|Mux config register (pad 80-89) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`FEATURE_DISABLE_QK` | 40| 32|Feature disablement for Quiddikey features | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG0` | 48| 32|Function register (pad 0 to 3) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG1` | 52| 32|Function register (pad 4 to 7) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG2` | 56| 32|Function register (pad 8 to 11) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG3` | 60| 32|Function register (pad 12 to 15) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG4` | 64| 32|Function register (pad 16 to 19) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG5` | 68| 32|Function register (pad 20 to 23) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG6` | 72| 32|Function register (pad 24 to 27) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG7` | 76| 32|Function register (pad 28 to 31) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG8` | 80| 32|Function register (pad 32 to 35) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG9` | 84| 32|Function register (pad 36 to 39) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG10` | 88| 32|Function register (pad 40 to 43) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG11` | 92| 32|Function register (pad 44 to 47) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG12` | 96| 32|Function register (pad 48 to 51) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG13` | 100| 32|Function register (pad 52 to 55) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG14` | 104| 32|Function register (pad 56 to 59) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG15` | 108| 32|Function register (pad 60 to 63) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG16` | 112| 32|Function register (pad 64 to 67) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG17` | 116| 32|Function register (pad 68 to 71) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG18` | 120| 32|Function register (pad 72 to 75) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG19` | 124| 32|Function register (pad 76 to 79) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG20` | 128| 32|Function register (pad 80 to 83) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG21` | 132| 32|Function register (pad 84 to 87) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`PADCFG22` | 136| 32|Function register (pad 88 to 89) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`REG_REPROG_PAD0` | 144| 32|Controls reprogrammable pads 27,28,29,30,34 | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`REG_REPROG_PAD1` | 148| 32|Controls reprogrammable pads 35,40,41,42,43 | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`REG_REPROG_PAD2` | 152| 32|Controls reprogrammable pads 44,45,60,61,62 | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`REG_REPROG_PAD3` | 156| 32|Controls reprogrammable pads 63,65,66,67,68 | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CL_BUSY` | 176| 32|Cluster busy register | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`JTAGREG` | 180| 32|JTAG external register | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`REF_FAST_CLK_DIV` | 184| 32|Read only, reference fast clk divided by power of 2 | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SW_RST` | 188| 32|Software reset, reboot | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CORESTATUS` | 192| 32|EOC and chip status register | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`BOOTSEL` | 196| 32|Value of pad bootsel | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`WD_RST_RST` | 200| 32|Rearm WD timeout | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`WD_RST_SET` | 204| 32|Set WD timer | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`RWM_CSI2` | 208| 32|Margin adjust settings for CSI2 Controller | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`IDLE_MODE` | 212| 32|Activates IDLE MODE | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`RWM_ANC` | 216| 32|Margin adjust settings for SFU | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`REF_CLK_MUX` | 220| 32|Reference clock selection | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SUPERVISOR_DBG` | 224| 32| | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`DBG_CTRL` | 228| 32|Debug access control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CLK_DIV_I3C` | 240| 32|Clock divider for I3C | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CLK_EN_QUIDDIKEY` | 244| 32|Quiddikey enablement | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_CTRL_INFO` | 248| 32|Safe domain's Sleep control info | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`VERSION` | 252| 32|Show chip version (User controlled) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_SPIS_CTRL` | 256| 32|Sleep SPIS control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_CTRL` | 260| 32|Sleep control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_GPIO_CTRL` | 264| 32|Sleep GPIO control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_CNT_CTRL` | 268| 32|Sleep Counter control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`REG_OSC_CTRL` | 272| 32|Controls fast oscillator | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CLK_DIV_REF_FAST_POW2`| 280| 32|Controls fast oscillator pow2 divider | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`FEATURE_DISABLE` | 288| 32|Feature disablement from always on (safe) domain | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_PAD_CFG0` | 320| 32|Sleep pad control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_PAD_CFG1` | 324| 32|Sleep pad control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_PAD_CFG2` | 328| 32|Sleep pad control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_PAD_CFG3` | 332| 32|Sleep pad control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_PAD_CFG4` | 336| 32|Sleep pad control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_PAD_CFG5` | 340| 32|Sleep pad control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLEEP_PAD_CFG6` | 344| 32|Sleep pad control | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`L2_CTRL_ACTIVE` | 348| 32|Controls L2 power when SOC is powered on | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`L2_PWR_ACTIVE` | 352| 32|Controls L2 power when SOC is powered on | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`NEVACFG` | 356| 32|NEVA config | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`TRCCFG` | 360| 32|TRC config | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`RWM_L2_MEM` | 364| 32|Read/write margins for L2 and ROM memories | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CLU_SW_RSTN` | 368| 32|Cluster software reset | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`L2_PWR` | 372| 32|Controls L2 power when SOC is off (deepsleep) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`L2_CTRL` | 376| 32|Controls L2 power when SOC is off (deepsleep) | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`BORCFG` | 384| 32|Controls the brown-out reset | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`RARMODE` | 388| 32|Controls configuration of the DC-DC modulation at low loads| + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`ABBCFG` | 392| 32|Used to disable adaptive body-bias | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`L2_ACK` | 396| 32|Acknowledge/status signals from L2 memories | + +-----------------------------------------------------------------+------+-----+-----------------------------------------------------------+ + +.. _apb_soc_ctrl__INFO: INFO """" @@ -202,16 +191,18 @@ INFO Core information register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+==================+ - |15:0 |R |NB_CL |Number of clusters| - +-----+---+--------+------------------+ - |31:16|R |NB_CORES|Number of cores | - +-----+---+--------+------------------+ + +-----+---+--------+------+------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+========+======+==================+ + |15:0 |R |NB_CL |0x0008|Number of clusters| + +-----+---+--------+------+------------------+ + |31:16|R |NB_CORES|0x0001|Number of cores | + +-----+---+--------+------+------------------+ -.. _apb_soc_ctrl_FC_BOOT: +.. _apb_soc_ctrl__FC_BOOT: FC_BOOT """"""" @@ -219,14 +210,16 @@ FC_BOOT Boot address .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===============+ - |31:0 |R/W|ADDR|FC Boot Address| - +-----+---+----+---------------+ + +-----+---+----+----------+---------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+===============+ + |31:0 |R/W|ADDR|0x1A000000|FC Boot Address| + +-----+---+----+----------+---------------+ -.. _apb_soc_ctrl_FC_FETCH: +.. _apb_soc_ctrl__FC_FETCH: FC_FETCH """""""" @@ -234,14 +227,16 @@ FC_FETCH FC Fetch enable .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+---------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+===============+ - | 0|R/W|FC_FE|FC Fetch Enable| - +-----+---+-----+---------------+ + +-----+---+-----+-----+---------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===============+ + | 0|R/W|FC_FE|0x0 |FC Fetch Enable| + +-----+---+-----+-----+---------------+ -.. _apb_soc_ctrl_CL_ISOLATE: +.. _apb_soc_ctrl__CL_ISOLATE: CL_ISOLATE """""""""" @@ -249,14 +244,16 @@ CL_ISOLATE Isolate cluster register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===============================================================================================+ - | 0|R/W|EN |Isolate cluster. Inhibits AXI transactions from cluster to SoC: - 1'b0: Disable - 1'b1: Enable| - +-----+---+----+-----------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=======================================================================================+ + | 0|R/W|EN |0x1 |Isolate cluster. Inhibits AXI transactions from cluster to SoC: b0: Disable; b1: Enable| + +-----+---+----+-----+---------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_PADFUN0: +.. _apb_soc_ctrl__PADFUN0: PADFUN0 """"""" @@ -264,44 +261,46 @@ PADFUN0 Mux config register (pad 0-15) .. table:: - - +-----+---+---------+-------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+=====================================+ - |1:0 |R/W|Padmux_0 |Selects between: hyper0_ckn / gpio0 | - +-----+---+---------+-------------------------------------+ - |3:2 |R/W|Padmux_1 |Selects between: hyper0_ck / gpio1 | - +-----+---+---------+-------------------------------------+ - |5:4 |R/W|Padmux_2 |Selects between: hyper0_dq0 / gpio2 | - +-----+---+---------+-------------------------------------+ - |7:6 |R/W|Padmux_3 |Selects between: hyper0_dq1 / gpio3 | - +-----+---+---------+-------------------------------------+ - |9:8 |R/W|Padmux_4 |Selects between: hyper0_dq2 / gpio4 | - +-----+---+---------+-------------------------------------+ - |11:10|R/W|Padmux_5 |Selects between: hyper0_dq3 / gpio5 | - +-----+---+---------+-------------------------------------+ - |13:12|R/W|Padmux_6 |Selects between: hyper0_dq4 / gpio6 | - +-----+---+---------+-------------------------------------+ - |15:14|R/W|Padmux_7 |Selects between: hyper0_dq5 / gpio7 | - +-----+---+---------+-------------------------------------+ - |17:16|R/W|Padmux_8 |Selects between: hyper0_dq6 / gpio8 | - +-----+---+---------+-------------------------------------+ - |19:18|R/W|Padmux_9 |Selects between: hyper0_dq7 / gpio9 | - +-----+---+---------+-------------------------------------+ - |21:20|R/W|Padmux_10|Selects between: hyper0_csn0 / gpio10| - +-----+---+---------+-------------------------------------+ - |23:22|R/W|Padmux_11|Selects between: hyper0_csn1 / gpio11| - +-----+---+---------+-------------------------------------+ - |25:24|R/W|Padmux_12|Selects between: hyper0_rwds / gpio12| - +-----+---+---------+-------------------------------------+ - |27:26|R/W|Padmux_13|Selects between: hyper1_ckn / gpio13 | - +-----+---+---------+-------------------------------------+ - |29:28|R/W|Padmux_14|Selects between: hyper1_ck / gpio14 | - +-----+---+---------+-------------------------------------+ - |31:30|R/W|Padmux_15|Selects between: hyper1_dq0 / gpio15 | - +-----+---+---------+-------------------------------------+ - -.. _apb_soc_ctrl_PADFUN1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+-------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=====================================+ + |1:0 |R/W|PADMUX_0 |0x0 |Selects between: hyper0_ckn / gpio0 | + +-----+---+---------+-----+-------------------------------------+ + |3:2 |R/W|PADMUX_1 |0x0 |Selects between: hyper0_ck / gpio1 | + +-----+---+---------+-----+-------------------------------------+ + |5:4 |R/W|PADMUX_2 |0x0 |Selects between: hyper0_dq0 / gpio2 | + +-----+---+---------+-----+-------------------------------------+ + |7:6 |R/W|PADMUX_3 |0x0 |Selects between: hyper0_dq1 / gpio3 | + +-----+---+---------+-----+-------------------------------------+ + |9:8 |R/W|PADMUX_4 |0x0 |Selects between: hyper0_dq2 / gpio4 | + +-----+---+---------+-----+-------------------------------------+ + |11:10|R/W|PADMUX_5 |0x0 |Selects between: hyper0_dq3 / gpio5 | + +-----+---+---------+-----+-------------------------------------+ + |13:12|R/W|PADMUX_6 |0x0 |Selects between: hyper0_dq4 / gpio6 | + +-----+---+---------+-----+-------------------------------------+ + |15:14|R/W|PADMUX_7 |0x0 |Selects between: hyper0_dq5 / gpio7 | + +-----+---+---------+-----+-------------------------------------+ + |17:16|R/W|PADMUX_8 |0x0 |Selects between: hyper0_dq6 / gpio8 | + +-----+---+---------+-----+-------------------------------------+ + |19:18|R/W|PADMUX_9 |0x0 |Selects between: hyper0_dq7 / gpio9 | + +-----+---+---------+-----+-------------------------------------+ + |21:20|R/W|PADMUX_10|0x0 |Selects between: hyper0_csn0 / gpio10| + +-----+---+---------+-----+-------------------------------------+ + |23:22|R/W|PADMUX_11|0x0 |Selects between: hyper0_csn1 / gpio11| + +-----+---+---------+-----+-------------------------------------+ + |25:24|R/W|PADMUX_12|0x0 |Selects between: hyper0_rwds / gpio12| + +-----+---+---------+-----+-------------------------------------+ + |27:26|R/W|PADMUX_13|0x0 |Selects between: hyper1_ckn / gpio13 | + +-----+---+---------+-----+-------------------------------------+ + |29:28|R/W|PADMUX_14|0x0 |Selects between: hyper1_ck / gpio14 | + +-----+---+---------+-----+-------------------------------------+ + |31:30|R/W|PADMUX_15|0x0 |Selects between: hyper1_dq0 / gpio15 | + +-----+---+---------+-----+-------------------------------------+ + +.. _apb_soc_ctrl__PADFUN1: PADFUN1 """"""" @@ -309,44 +308,46 @@ PADFUN1 Mux config register (pad 16-31) .. table:: - - +-----+---+---------+------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+================================================+ - |1:0 |R/W|Padmux_16|Selects between: hyper1_dq1 / gpio16 | - +-----+---+---------+------------------------------------------------+ - |3:2 |R/W|Padmux_17|Selects between: hyper1_dq2 / gpio17 | - +-----+---+---------+------------------------------------------------+ - |5:4 |R/W|Padmux_18|Selects between: hyper1_dq3 / gpio18 | - +-----+---+---------+------------------------------------------------+ - |7:6 |R/W|Padmux_19|Selects between: hyper1_dq4 / gpio19 | - +-----+---+---------+------------------------------------------------+ - |9:8 |R/W|Padmux_20|Selects between: hyper1_dq5 / gpio20 | - +-----+---+---------+------------------------------------------------+ - |11:10|R/W|Padmux_21|Selects between: hyper1_dq6 / gpio21 | - +-----+---+---------+------------------------------------------------+ - |13:12|R/W|Padmux_22|Selects between: hyper1_dq7 / gpio22 | - +-----+---+---------+------------------------------------------------+ - |15:14|R/W|Padmux_23|Selects between: hyper1_csn0 / gpio23 | - +-----+---+---------+------------------------------------------------+ - |17:16|R/W|Padmux_24|Selects between: hyper1_csn1 / gpio24 | - +-----+---+---------+------------------------------------------------+ - |19:18|R/W|Padmux_25|Selects between: hyper1_rwds / gpio25 | - +-----+---+---------+------------------------------------------------+ - |21:20|R/W|Padmux_26|Selects between: spi0_sck / gpio26 | - +-----+---+---------+------------------------------------------------+ - |23:22|R/W|Padmux_27|Selects between: mux_group_sel_spi0_cs0 / gpio27| - +-----+---+---------+------------------------------------------------+ - |25:24|R/W|Padmux_28|Selects between: mux_group_sel_spi0_cs1 / gpio28| - +-----+---+---------+------------------------------------------------+ - |27:26|R/W|Padmux_29|Selects between: mux_group_sel_spi0_cs2 / gpio29| - +-----+---+---------+------------------------------------------------+ - |29:28|R/W|Padmux_30|Selects between: mux_group_sel_spi0_cs3 / gpio30| - +-----+---+---------+------------------------------------------------+ - |31:30|R/W|Padmux_31|Selects between: spi0_sdo / gpio31 | - +-----+---+---------+------------------------------------------------+ - -.. _apb_soc_ctrl_PADFUN2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+================================================+ + |1:0 |R/W|PADMUX_16|0x0 |Selects between: hyper1_dq1 / gpio16 | + +-----+---+---------+-----+------------------------------------------------+ + |3:2 |R/W|PADMUX_17|0x0 |Selects between: hyper1_dq2 / gpio17 | + +-----+---+---------+-----+------------------------------------------------+ + |5:4 |R/W|PADMUX_18|0x0 |Selects between: hyper1_dq3 / gpio18 | + +-----+---+---------+-----+------------------------------------------------+ + |7:6 |R/W|PADMUX_19|0x0 |Selects between: hyper1_dq4 / gpio19 | + +-----+---+---------+-----+------------------------------------------------+ + |9:8 |R/W|PADMUX_20|0x0 |Selects between: hyper1_dq5 / gpio20 | + +-----+---+---------+-----+------------------------------------------------+ + |11:10|R/W|PADMUX_21|0x0 |Selects between: hyper1_dq6 / gpio21 | + +-----+---+---------+-----+------------------------------------------------+ + |13:12|R/W|PADMUX_22|0x0 |Selects between: hyper1_dq7 / gpio22 | + +-----+---+---------+-----+------------------------------------------------+ + |15:14|R/W|PADMUX_23|0x0 |Selects between: hyper1_csn0 / gpio23 | + +-----+---+---------+-----+------------------------------------------------+ + |17:16|R/W|PADMUX_24|0x0 |Selects between: hyper1_csn1 / gpio24 | + +-----+---+---------+-----+------------------------------------------------+ + |19:18|R/W|PADMUX_25|0x0 |Selects between: hyper1_rwds / gpio25 | + +-----+---+---------+-----+------------------------------------------------+ + |21:20|R/W|PADMUX_26|0x0 |Selects between: spi0_sck / gpio26 | + +-----+---+---------+-----+------------------------------------------------+ + |23:22|R/W|PADMUX_27|0x0 |Selects between: mux_group_sel_spi0_cs0 / gpio27| + +-----+---+---------+-----+------------------------------------------------+ + |25:24|R/W|PADMUX_28|0x0 |Selects between: mux_group_sel_spi0_cs1 / gpio28| + +-----+---+---------+-----+------------------------------------------------+ + |27:26|R/W|PADMUX_29|0x0 |Selects between: mux_group_sel_spi0_cs2 / gpio29| + +-----+---+---------+-----+------------------------------------------------+ + |29:28|R/W|PADMUX_30|0x0 |Selects between: mux_group_sel_spi0_cs3 / gpio30| + +-----+---+---------+-----+------------------------------------------------+ + |31:30|R/W|PADMUX_31|0x0 |Selects between: spi0_sdo / gpio31 | + +-----+---+---------+-----+------------------------------------------------+ + +.. _apb_soc_ctrl__PADFUN2: PADFUN2 """"""" @@ -354,44 +355,46 @@ PADFUN2 Mux config register (pad 32-47) .. table:: - - +-----+---+---------+-----------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+===========================================================+ - |1:0 |R/W|Padmux_32|Selects between: spi0_sdi / gpio32 | - +-----+---+---------+-----------------------------------------------------------+ - |3:2 |R/W|Padmux_33|Selects between: spi1_sck / gpio33 / uart3_clk | - +-----+---+---------+-----------------------------------------------------------+ - |5:4 |R/W|Padmux_34|Selects between: mux_group_sel_spi1_cs0 / gpio34 | - +-----+---+---------+-----------------------------------------------------------+ - |7:6 |R/W|Padmux_35|Selects between: mux_group_sel_spi1_cs1 / gpio35 | - +-----+---+---------+-----------------------------------------------------------+ - |9:8 |R/W|Padmux_36|Selects between: spi1_cs2 / gpio36 / uart3_cts / spi1_sdio2| - +-----+---+---------+-----------------------------------------------------------+ - |11:10|R/W|Padmux_37|Selects between: spi1_cs3 / gpio37 / uart3_rts / spi1_sdio3| - +-----+---+---------+-----------------------------------------------------------+ - |13:12|R/W|Padmux_38|Selects between: spi1_sdo / gpio38 | - +-----+---+---------+-----------------------------------------------------------+ - |15:14|R/W|Padmux_39|Selects between: spi1_sdi / gpio39 | - +-----+---+---------+-----------------------------------------------------------+ - |17:16|R/W|Padmux_40|Selects between: mux_group_sel_i2c0_sda / gpio40 | - +-----+---+---------+-----------------------------------------------------------+ - |19:18|R/W|Padmux_41|Selects between: mux_group_sel_i2c0_scl / gpio41 | - +-----+---+---------+-----------------------------------------------------------+ - |21:20|R/W|Padmux_42|Selects between: mux_group_sel_i2c1_sda / gpio42 | - +-----+---+---------+-----------------------------------------------------------+ - |23:22|R/W|Padmux_43|Selects between: mux_group_sel_i2c1_scl / gpio43 | - +-----+---+---------+-----------------------------------------------------------+ - |25:24|R/W|Padmux_44|Selects between: mux_group_sel_i2c2_sda / gpio44 | - +-----+---+---------+-----------------------------------------------------------+ - |27:26|R/W|Padmux_45|Selects between: mux_group_sel_i2c2_scl / gpio45 | - +-----+---+---------+-----------------------------------------------------------+ - |29:28|R/W|Padmux_46|Selects between: i3c_sda / gpio46 / i2c3_sda / spi0_sdio2 | - +-----+---+---------+-----------------------------------------------------------+ - |31:30|R/W|Padmux_47|Selects between: i3c_scl / gpio47 / i2c3_scl / spi0_sdio3 | - +-----+---+---------+-----------------------------------------------------------+ - -.. _apb_soc_ctrl_PADFUN3: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+===========================================================+ + |1:0 |R/W|PADMUX_32|0x0 |Selects between: spi0_sdi / gpio32 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |3:2 |R/W|PADMUX_33|0x0 |Selects between: spi1_sck / gpio33 / uart3_clk | + +-----+---+---------+-----+-----------------------------------------------------------+ + |5:4 |R/W|PADMUX_34|0x0 |Selects between: mux_group_sel_spi1_cs0 / gpio34 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |7:6 |R/W|PADMUX_35|0x0 |Selects between: mux_group_sel_spi1_cs1 / gpio35 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |9:8 |R/W|PADMUX_36|0x0 |Selects between: spi1_cs2 / gpio36 / uart3_cts / spi1_sdio2| + +-----+---+---------+-----+-----------------------------------------------------------+ + |11:10|R/W|PADMUX_37|0x0 |Selects between: spi1_cs3 / gpio37 / uart3_rts / spi1_sdio3| + +-----+---+---------+-----+-----------------------------------------------------------+ + |13:12|R/W|PADMUX_38|0x0 |Selects between: spi1_sdo / gpio38 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |15:14|R/W|PADMUX_39|0x0 |Selects between: spi1_sdi / gpio39 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |17:16|R/W|PADMUX_40|0x0 |Selects between: mux_group_sel_i2c0_sda / gpio40 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |19:18|R/W|PADMUX_41|0x0 |Selects between: mux_group_sel_i2c0_scl / gpio41 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |21:20|R/W|PADMUX_42|0x0 |Selects between: mux_group_sel_i2c1_sda / gpio42 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |23:22|R/W|PADMUX_43|0x0 |Selects between: mux_group_sel_i2c1_scl / gpio43 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |25:24|R/W|PADMUX_44|0x0 |Selects between: mux_group_sel_i2c2_sda / gpio44 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |27:26|R/W|PADMUX_45|0x0 |Selects between: mux_group_sel_i2c2_scl / gpio45 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |29:28|R/W|PADMUX_46|0x0 |Selects between: i3c_sda / gpio46 / i2c3_sda / spi0_sdio2 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |31:30|R/W|PADMUX_47|0x0 |Selects between: i3c_scl / gpio47 / i2c3_scl / spi0_sdio3 | + +-----+---+---------+-----+-----------------------------------------------------------+ + +.. _apb_soc_ctrl__PADFUN3: PADFUN3 """"""" @@ -399,44 +402,46 @@ PADFUN3 Mux config register (pad 48-63) .. table:: - - +-----+---+---------+-------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+=================================================+ - |1:0 |R/W|Padmux_48|Selects between: i2s0_sck / gpio48 / uart2_clk | - +-----+---+---------+-------------------------------------------------+ - |3:2 |R/W|Padmux_49|Selects between: i2s0_ws / gpio49 | - +-----+---+---------+-------------------------------------------------+ - |5:4 |R/W|Padmux_50|Selects between: i2s0_sdi / gpio50 | - +-----+---+---------+-------------------------------------------------+ - |7:6 |R/W|Padmux_51|Selects between: i2s0_sdo / gpio51 | - +-----+---+---------+-------------------------------------------------+ - |9:8 |R/W|Padmux_52|Selects between: i2s1_sck / gpio52 | - +-----+---+---------+-------------------------------------------------+ - |11:10|R/W|Padmux_53|Selects between: i2s1_ws / gpio53 / spi2_cs1 | - +-----+---+---------+-------------------------------------------------+ - |13:12|R/W|Padmux_54|Selects between: i2s1_sdi / gpio54 / spi2_cs2 | - +-----+---+---------+-------------------------------------------------+ - |15:14|R/W|Padmux_55|Selects between: i2s1_sdo / gpio55 / spi2_cs3 | - +-----+---+---------+-------------------------------------------------+ - |17:16|R/W|Padmux_56|Selects between: i2s2_sck / gpio56 / spi2_sck | - +-----+---+---------+-------------------------------------------------+ - |19:18|R/W|Padmux_57|Selects between: i2s2_ws / gpio57 / spi2_cs0 | - +-----+---+---------+-------------------------------------------------+ - |21:20|R/W|Padmux_58|Selects between: i2s2_sdi / gpio58 / spi2_sdi | - +-----+---+---------+-------------------------------------------------+ - |23:22|R/W|Padmux_59|Selects between: i2s2_sdo / gpio59 / spi2_sdo | - +-----+---+---------+-------------------------------------------------+ - |25:24|R/W|Padmux_60|Selects between: mux_group_sel_uart0_rx / gpio60 | - +-----+---+---------+-------------------------------------------------+ - |27:26|R/W|Padmux_61|Selects between: mux_group_sel_uart0_tx / gpio61 | - +-----+---+---------+-------------------------------------------------+ - |29:28|R/W|Padmux_62|Selects between: mux_group_sel_uart0_cts / gpio62| - +-----+---+---------+-------------------------------------------------+ - |31:30|R/W|Padmux_63|Selects between: mux_group_sel_uart0_rts / gpio63| - +-----+---+---------+-------------------------------------------------+ - -.. _apb_soc_ctrl_PADFUN4: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+-------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=================================================+ + |1:0 |R/W|PADMUX_48|0x0 |Selects between: i2s0_sck / gpio48 / uart2_clk | + +-----+---+---------+-----+-------------------------------------------------+ + |3:2 |R/W|PADMUX_49|0x0 |Selects between: i2s0_ws / gpio49 | + +-----+---+---------+-----+-------------------------------------------------+ + |5:4 |R/W|PADMUX_50|0x0 |Selects between: i2s0_sdi / gpio50 | + +-----+---+---------+-----+-------------------------------------------------+ + |7:6 |R/W|PADMUX_51|0x0 |Selects between: i2s0_sdo / gpio51 | + +-----+---+---------+-----+-------------------------------------------------+ + |9:8 |R/W|PADMUX_52|0x0 |Selects between: i2s1_sck / gpio52 | + +-----+---+---------+-----+-------------------------------------------------+ + |11:10|R/W|PADMUX_53|0x0 |Selects between: i2s1_ws / gpio53 / spi2_cs1 | + +-----+---+---------+-----+-------------------------------------------------+ + |13:12|R/W|PADMUX_54|0x0 |Selects between: i2s1_sdi / gpio54 / spi2_cs2 | + +-----+---+---------+-----+-------------------------------------------------+ + |15:14|R/W|PADMUX_55|0x0 |Selects between: i2s1_sdo / gpio55 / spi2_cs3 | + +-----+---+---------+-----+-------------------------------------------------+ + |17:16|R/W|PADMUX_56|0x0 |Selects between: i2s2_sck / gpio56 / spi2_sck | + +-----+---+---------+-----+-------------------------------------------------+ + |19:18|R/W|PADMUX_57|0x0 |Selects between: i2s2_ws / gpio57 / spi2_cs0 | + +-----+---+---------+-----+-------------------------------------------------+ + |21:20|R/W|PADMUX_58|0x0 |Selects between: i2s2_sdi / gpio58 / spi2_sdi | + +-----+---+---------+-----+-------------------------------------------------+ + |23:22|R/W|PADMUX_59|0x0 |Selects between: i2s2_sdo / gpio59 / spi2_sdo | + +-----+---+---------+-----+-------------------------------------------------+ + |25:24|R/W|PADMUX_60|0x0 |Selects between: mux_group_sel_uart0_rx / gpio60 | + +-----+---+---------+-----+-------------------------------------------------+ + |27:26|R/W|PADMUX_61|0x0 |Selects between: mux_group_sel_uart0_tx / gpio61 | + +-----+---+---------+-----+-------------------------------------------------+ + |29:28|R/W|PADMUX_62|0x0 |Selects between: mux_group_sel_uart0_cts / gpio62| + +-----+---+---------+-----+-------------------------------------------------+ + |31:30|R/W|PADMUX_63|0x0 |Selects between: mux_group_sel_uart0_rts / gpio63| + +-----+---+---------+-----+-------------------------------------------------+ + +.. _apb_soc_ctrl__PADFUN4: PADFUN4 """"""" @@ -444,44 +449,46 @@ PADFUN4 Mux config register (pad 64-79) .. table:: - - +-----+---+---------+-----------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+===========================================================+ - |1:0 |R/W|Padmux_64|Selects between: uart0_clk / gpio64 | - +-----+---+---------+-----------------------------------------------------------+ - |3:2 |R/W|Padmux_65|Selects between: mux_group_sel_uart1_rx / gpio65 | - +-----+---+---------+-----------------------------------------------------------+ - |5:4 |R/W|Padmux_66|Selects between: mux_group_sel_uart1_tx / gpio66 | - +-----+---+---------+-----------------------------------------------------------+ - |7:6 |R/W|Padmux_67|Selects between: mux_group_sel_pwm0 / gpio67 | - +-----+---+---------+-----------------------------------------------------------+ - |9:8 |R/W|Padmux_68|Selects between: mux_group_sel_pwm1 / gpio68 | - +-----+---+---------+-----------------------------------------------------------+ - |11:10|R/W|Padmux_69|Selects between: uart1_clk / gpio69 | - +-----+---+---------+-----------------------------------------------------------+ - |13:12|R/W|Padmux_70|Selects between: cam_pclk / gpio70 / spi3_sck | - +-----+---+---------+-----------------------------------------------------------+ - |15:14|R/W|Padmux_71|Selects between: cam_hsync / gpio71 / spi3_cs0 / csi2_hsync| - +-----+---+---------+-----------------------------------------------------------+ - |17:16|R/W|Padmux_72|Selects between: cam_data0 / gpio72 / spi3_cs1 | - +-----+---+---------+-----------------------------------------------------------+ - |19:18|R/W|Padmux_73|Selects between: cam_data1 / gpio73 / spi3_cs2 | - +-----+---+---------+-----------------------------------------------------------+ - |21:20|R/W|Padmux_74|Selects between: cam_data2 / gpio74 / spi3_cs3 | - +-----+---+---------+-----------------------------------------------------------+ - |23:22|R/W|Padmux_75|Selects between: cam_data3 / gpio75 / spi3_sdo | - +-----+---+---------+-----------------------------------------------------------+ - |25:24|R/W|Padmux_76|Selects between: cam_data4 / gpio76 / spi3_sdi | - +-----+---+---------+-----------------------------------------------------------+ - |27:26|R/W|Padmux_77|Selects between: cam_data5 / gpio77 / observability1 | - +-----+---+---------+-----------------------------------------------------------+ - |29:28|R/W|Padmux_78|Selects between: cam_data6 / gpio78 / observability2 | - +-----+---+---------+-----------------------------------------------------------+ - |31:30|R/W|Padmux_79|Selects between: cam_data7 / gpio79 / observability3 | - +-----+---+---------+-----------------------------------------------------------+ - -.. _apb_soc_ctrl_PADFUN5: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+===========================================================+ + |1:0 |R/W|PADMUX_64|0x0 |Selects between: uart0_clk / gpio64 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |3:2 |R/W|PADMUX_65|0x0 |Selects between: mux_group_sel_uart1_rx / gpio65 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |5:4 |R/W|PADMUX_66|0x0 |Selects between: mux_group_sel_uart1_tx / gpio66 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |7:6 |R/W|PADMUX_67|0x0 |Selects between: mux_group_sel_pwm0 / gpio67 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |9:8 |R/W|PADMUX_68|0x0 |Selects between: mux_group_sel_pwm1 / gpio68 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |11:10|R/W|PADMUX_69|0x0 |Selects between: uart1_clk / gpio69 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |13:12|R/W|PADMUX_70|0x0 |Selects between: cam_pclk / gpio70 / spi3_sck | + +-----+---+---------+-----+-----------------------------------------------------------+ + |15:14|R/W|PADMUX_71|0x0 |Selects between: cam_hsync / gpio71 / spi3_cs0 / csi2_hsync| + +-----+---+---------+-----+-----------------------------------------------------------+ + |17:16|R/W|PADMUX_72|0x0 |Selects between: cam_data0 / gpio72 / spi3_cs1 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |19:18|R/W|PADMUX_73|0x0 |Selects between: cam_data1 / gpio73 / spi3_cs2 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |21:20|R/W|PADMUX_74|0x0 |Selects between: cam_data2 / gpio74 / spi3_cs3 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |23:22|R/W|PADMUX_75|0x0 |Selects between: cam_data3 / gpio75 / spi3_sdo | + +-----+---+---------+-----+-----------------------------------------------------------+ + |25:24|R/W|PADMUX_76|0x0 |Selects between: cam_data4 / gpio76 / spi3_sdi | + +-----+---+---------+-----+-----------------------------------------------------------+ + |27:26|R/W|PADMUX_77|0x0 |Selects between: cam_data5 / gpio77 / observability1 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |29:28|R/W|PADMUX_78|0x0 |Selects between: cam_data6 / gpio78 / observability2 | + +-----+---+---------+-----+-----------------------------------------------------------+ + |31:30|R/W|PADMUX_79|0x0 |Selects between: cam_data7 / gpio79 / observability3 | + +-----+---+---------+-----+-----------------------------------------------------------+ + +.. _apb_soc_ctrl__PADFUN5: PADFUN5 """"""" @@ -489,58 +496,55 @@ PADFUN5 Mux config register (pad 80-89) .. table:: - - +-----+---+---------+-----------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+=================================================================+ - |1:0 |R/W|Padmux_80|Selects between: cam_vsync / gpio80 / observability4 / csi2_vsync| - +-----+---+---------+-----------------------------------------------------------------+ - |3:2 |R/W|Padmux_81|Selects between: jtag_tck / gpio81 / uart4_clk | - +-----+---+---------+-----------------------------------------------------------------+ - |5:4 |R/W|Padmux_82|Selects between: jtag_tdi / gpio82 / uart4_rx | - +-----+---+---------+-----------------------------------------------------------------+ - |7:6 |R/W|Padmux_83|Selects between: jtag_tdo / gpio83 / uart4_tx | - +-----+---+---------+-----------------------------------------------------------------+ - |9:8 |R/W|Padmux_84|Selects between: jtag_tms / gpio84 / uart4_cts | - +-----+---+---------+-----------------------------------------------------------------+ - |11:10|R/W|Padmux_85|Selects between: jtag_trst / gpio85 / uart4_rts | - +-----+---+---------+-----------------------------------------------------------------+ - |13:12|R/W|Padmux_86|Selects between: wakeup_spi2_sck / gpio86 | - +-----+---+---------+-----------------------------------------------------------------+ - |15:14|R/W|Padmux_87|Selects between: wakeup_spi2_sdi / gpio87 | - +-----+---+---------+-----------------------------------------------------------------+ - |17:16|R/W|Padmux_88|Selects between: wakeup_spi2_sdo / gpio88 | - +-----+---+---------+-----------------------------------------------------------------+ - |19:18|R/W|Padmux_89|Selects between: wakeup_spi2_cs0 / gpio89 | - +-----+---+---------+-----------------------------------------------------------------+ - -.. _apb_soc_ctrl_FEATURE_DISABLEMENT_SOC: - -FEATURE_DISABLEMENT_SOC -""""""""""""""""""""""" - -Feature disablement from SoC domain - -.. table:: - - +-----+---+------------------------+---------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========================+===============================================================================================================+ - | 0|R/W|DISABLE_QUIDDIKEY_UNWRAP|Disable quiddikey unwrap | - +-----+---+------------------------+---------------------------------------------------------------------------------------------------------------+ - | 1|R/W|DISABLE_QUIDDIKEY_ENROLL|Disable quiddikey enroll | - +-----+---+------------------------+---------------------------------------------------------------------------------------------------------------+ - | 31|R/W|DISABLE_LOCK |When set, DISABLE_* registers cannot be written to zero. Configuration is lost when SoC domain is switched off.| - +-----+---+------------------------+---------------------------------------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_RESERVED0: - -RESERVED0 -""""""""" - -Reserved - -.. _apb_soc_ctrl_PADCFG0: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+-----------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=================================================================+ + |1:0 |R/W|PADMUX_80|0x0 |Selects between: cam_vsync / gpio80 / observability4 / csi2_vsync| + +-----+---+---------+-----+-----------------------------------------------------------------+ + |3:2 |R/W|PADMUX_81|0x0 |Selects between: jtag_tck / gpio81 / uart4_clk | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |5:4 |R/W|PADMUX_82|0x0 |Selects between: jtag_tdi / gpio82 / uart4_rx | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |7:6 |R/W|PADMUX_83|0x0 |Selects between: jtag_tdo / gpio83 / uart4_tx | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |9:8 |R/W|PADMUX_84|0x0 |Selects between: jtag_tms / gpio84 / uart4_cts | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |11:10|R/W|PADMUX_85|0x0 |Selects between: jtag_trst / gpio85 / uart4_rts | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |13:12|R/W|PADMUX_86|0x0 |Selects between: wakeup_spi2_sck / gpio86 | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |15:14|R/W|PADMUX_87|0x0 |Selects between: wakeup_spi2_sdi / gpio87 | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |17:16|R/W|PADMUX_88|0x0 |Selects between: wakeup_spi2_sdo / gpio88 | + +-----+---+---------+-----+-----------------------------------------------------------------+ + |19:18|R/W|PADMUX_89|0x0 |Selects between: wakeup_spi2_cs0 / gpio89 | + +-----+---+---------+-----+-----------------------------------------------------------------+ + +.. _apb_soc_ctrl__FEATURE_DISABLE_QK: + +FEATURE_DISABLE_QK +"""""""""""""""""" + +Feature disablement for Quiddikey features + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------------------+-----+---------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========================+=====+===============================================================================================================+ + | 0|R/W|DISABLE_QUIDDIKEY_UNWRAP|0x0 |Disable quiddikey unwrap | + +-----+---+------------------------+-----+---------------------------------------------------------------------------------------------------------------+ + | 1|R/W|DISABLE_QUIDDIKEY_ENROLL|0x0 |Disable quiddikey enroll | + +-----+---+------------------------+-----+---------------------------------------------------------------------------------------------------------------+ + | 31|R/W|DISABLE_LOCK |0x0 |When set, DISABLE_* registers cannot be written to zero. Configuration is lost when SoC domain is switched off.| + +-----+---+------------------------+-----+---------------------------------------------------------------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG0: PADCFG0 """"""" @@ -548,36 +552,38 @@ PADCFG0 Function register (pad 0 to 3) .. table:: - - +-----+---+--------------------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+====================+==============================+ - | 0|R/W|Pad 0 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 1|R/W|Pad 0 Pull Up | | - +-----+---+--------------------+------------------------------+ - |3:2 |R/W|Pad 0 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 8|R/W|Pad 1 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 9|R/W|Pad 1 Pull Up | | - +-----+---+--------------------+------------------------------+ - |11:10|R/W|Pad 1 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 16|R/W|Pad 2 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 17|R/W|Pad 2 Pull Up | | - +-----+---+--------------------+------------------------------+ - |19:18|R/W|Pad 2 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 24|R/W|Pad 3 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 25|R/W|Pad 3 Pull Up | | - +-----+---+--------------------+------------------------------+ - |27:26|R/W|Pad 3 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - -.. _apb_soc_ctrl_PADCFG1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+====================+=====+===============================+ + | 0|R/W|PAD_0_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |3:2 |R/W|PAD_0_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + | 8|R/W|PAD_1_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 9|R/W|PAD_1_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |11:10|R/W|PAD_1_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + | 16|R/W|PAD_2_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 17|R/W|PAD_2_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |19:18|R/W|PAD_2_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + | 24|R/W|PAD_3_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 25|R/W|PAD_3_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |27:26|R/W|PAD_3_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + +.. _apb_soc_ctrl__PADCFG1: PADCFG1 """"""" @@ -585,36 +591,38 @@ PADCFG1 Function register (pad 4 to 7) .. table:: - - +-----+---+--------------------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+====================+==============================+ - | 0|R/W|Pad 4 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 1|R/W|Pad 4 Pull Up | | - +-----+---+--------------------+------------------------------+ - |3:2 |R/W|Pad 4 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 8|R/W|Pad 5 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 9|R/W|Pad 5 Pull Up | | - +-----+---+--------------------+------------------------------+ - |11:10|R/W|Pad 5 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 16|R/W|Pad 6 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 17|R/W|Pad 6 Pull Up | | - +-----+---+--------------------+------------------------------+ - |19:18|R/W|Pad 6 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - | 24|R/W|Pad 7 Pull Down | | - +-----+---+--------------------+------------------------------+ - | 25|R/W|Pad 7 Pull Up | | - +-----+---+--------------------+------------------------------+ - |27:26|R/W|Pad 7 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+--------------------+------------------------------+ - -.. _apb_soc_ctrl_PADCFG2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+====================+=====+===============================+ + | 0|R/W|PAD_4_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 1|R/W|PAD_4_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |3:2 |R/W|PAD_4_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + | 8|R/W|PAD_5_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 9|R/W|PAD_5_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |11:10|R/W|PAD_5_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + | 16|R/W|PAD_6_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 17|R/W|PAD_6_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |19:18|R/W|PAD_6_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + | 24|R/W|PAD_7_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+--------------------+-----+-------------------------------+ + | 25|R/W|PAD_7_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+--------------------+-----+-------------------------------+ + |27:26|R/W|PAD_7_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+--------------------+-----+-------------------------------+ + +.. _apb_soc_ctrl__PADCFG2: PADCFG2 """"""" @@ -622,36 +630,38 @@ PADCFG2 Function register (pad 8 to 11) .. table:: - - +-----+---+---------------------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================+ - | 0|R/W|Pad 8 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 1|R/W|Pad 8 Pull Up | | - +-----+---+---------------------+------------------------------+ - |3:2 |R/W|Pad 8 Drive Strength |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - | 8|R/W|Pad 9 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 9|R/W|Pad 9 Pull Up | | - +-----+---+---------------------+------------------------------+ - |11:10|R/W|Pad 9 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - | 16|R/W|Pad 10 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 17|R/W|Pad 10 Pull Up | | - +-----+---+---------------------+------------------------------+ - |19:18|R/W|Pad 10 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - | 24|R/W|Pad 11 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 25|R/W|Pad 11 Pull Up | | - +-----+---+---------------------+------------------------------+ - |27:26|R/W|Pad 11 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - -.. _apb_soc_ctrl_PADCFG3: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+===============================+ + | 0|R/W|PAD_8_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 1|R/W|PAD_8_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |3:2 |R/W|PAD_8_DRIVE_STRENGTH |0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 8|R/W|PAD_9_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 9|R/W|PAD_9_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |11:10|R/W|PAD_9_DRIVE_STRENGTH |0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 16|R/W|PAD_10_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 17|R/W|PAD_10_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |19:18|R/W|PAD_10_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 24|R/W|PAD_11_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 25|R/W|PAD_11_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |27:26|R/W|PAD_11_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + +.. _apb_soc_ctrl__PADCFG3: PADCFG3 """"""" @@ -659,36 +669,38 @@ PADCFG3 Function register (pad 12 to 15) .. table:: - - +-----+---+---------------------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================+ - | 0|R/W|Pad 12 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 1|R/W|Pad 12 Pull Up | | - +-----+---+---------------------+------------------------------+ - |3:2 |R/W|Pad 12 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - | 8|R/W|Pad 13 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 9|R/W|Pad 13 Pull Up | | - +-----+---+---------------------+------------------------------+ - |11:10|R/W|Pad 13 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - | 16|R/W|Pad 14 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 17|R/W|Pad 14 Pull Up | | - +-----+---+---------------------+------------------------------+ - |19:18|R/W|Pad 14 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - | 24|R/W|Pad 15 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 25|R/W|Pad 15 Pull Up | | - +-----+---+---------------------+------------------------------+ - |27:26|R/W|Pad 15 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - -.. _apb_soc_ctrl_PADCFG4: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+===============================+ + | 0|R/W|PAD_12_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 1|R/W|PAD_12_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |3:2 |R/W|PAD_12_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 8|R/W|PAD_13_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 9|R/W|PAD_13_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |11:10|R/W|PAD_13_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 16|R/W|PAD_14_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 17|R/W|PAD_14_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |19:18|R/W|PAD_14_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 24|R/W|PAD_15_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 25|R/W|PAD_15_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |27:26|R/W|PAD_15_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + +.. _apb_soc_ctrl__PADCFG4: PADCFG4 """"""" @@ -696,36 +708,38 @@ PADCFG4 Function register (pad 16 to 19) .. table:: - - +-----+---+---------------------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================+ - | 0|R/W|Pad 16 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 1|R/W|Pad 16 Pull Up | | - +-----+---+---------------------+------------------------------+ - |3:2 |R/W|Pad 16 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - | 8|R/W|Pad 17 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 9|R/W|Pad 17 Pull Up | | - +-----+---+---------------------+------------------------------+ - |11:10|R/W|Pad 17 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - | 16|R/W|Pad 18 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 17|R/W|Pad 18 Pull Up | | - +-----+---+---------------------+------------------------------+ - |19:18|R/W|Pad 18 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - | 24|R/W|Pad 19 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 25|R/W|Pad 19 Pull Up | | - +-----+---+---------------------+------------------------------+ - |27:26|R/W|Pad 19 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - -.. _apb_soc_ctrl_PADCFG5: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+===============================+ + | 0|R/W|PAD_16_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 1|R/W|PAD_16_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |3:2 |R/W|PAD_16_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 8|R/W|PAD_17_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 9|R/W|PAD_17_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |11:10|R/W|PAD_17_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 16|R/W|PAD_18_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 17|R/W|PAD_18_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |19:18|R/W|PAD_18_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 24|R/W|PAD_19_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 25|R/W|PAD_19_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |27:26|R/W|PAD_19_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + +.. _apb_soc_ctrl__PADCFG5: PADCFG5 """"""" @@ -733,36 +747,38 @@ PADCFG5 Function register (pad 20 to 23) .. table:: - - +-----+---+---------------------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+==============================+ - | 0|R/W|Pad 20 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 1|R/W|Pad 20 Pull Up | | - +-----+---+---------------------+------------------------------+ - |3:2 |R/W|Pad 20 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - | 8|R/W|Pad 21 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 9|R/W|Pad 21 Pull Up | | - +-----+---+---------------------+------------------------------+ - |11:10|R/W|Pad 21 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - | 16|R/W|Pad 22 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 17|R/W|Pad 22 Pull Up | | - +-----+---+---------------------+------------------------------+ - |19:18|R/W|Pad 22 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - | 24|R/W|Pad 23 Pull Down | | - +-----+---+---------------------+------------------------------+ - | 25|R/W|Pad 23 Pull Up | | - +-----+---+---------------------+------------------------------+ - |27:26|R/W|Pad 23 Drive Strength|0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA| - +-----+---+---------------------+------------------------------+ - -.. _apb_soc_ctrl_PADCFG6: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+===============================+ + | 0|R/W|PAD_20_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 1|R/W|PAD_20_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |3:2 |R/W|PAD_20_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 8|R/W|PAD_21_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 9|R/W|PAD_21_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |11:10|R/W|PAD_21_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 16|R/W|PAD_22_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 17|R/W|PAD_22_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |19:18|R/W|PAD_22_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + | 24|R/W|PAD_23_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down| + +-----+---+---------------------+-----+-------------------------------+ + | 25|R/W|PAD_23_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+---------------------+-----+-------------------------------+ + |27:26|R/W|PAD_23_DRIVE_STRENGTH|0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+---------------------+-----+-------------------------------+ + +.. _apb_soc_ctrl__PADCFG6: PADCFG6 """"""" @@ -770,44 +786,46 @@ PADCFG6 Function register (pad 24 to 27) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 24 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 24 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 24 Drive Strength |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 25 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 25 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 25 Drive Strength |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 26 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 26 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 26 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 26 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 26 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 27 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 27 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 27 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 27 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 27 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG7: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_24_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_24_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_24_DRIVE_STRENGTH |0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_25_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_25_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_25_DRIVE_STRENGTH |0x0 |0: 1mA, 1: 2mA, 2: 4mA, 3: 8mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_26_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_26_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_26_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_26_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_26_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_27_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_27_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_27_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_27_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_27_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG7: PADCFG7 """"""" @@ -815,52 +833,54 @@ PADCFG7 Function register (pad 28 to 31) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 28 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 28 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 28 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 28 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 28 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 29 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 29 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 29 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 29 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 29 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 30 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 30 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 30 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 30 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 30 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 31 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 31 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 31 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 31 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 31 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG8: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_28_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_28_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_28_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_28_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_28_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_29_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_29_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_29_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_29_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_29_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_30_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_30_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_30_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_30_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_30_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_31_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_31_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_31_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_31_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_31_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG8: PADCFG8 """"""" @@ -868,52 +888,54 @@ PADCFG8 Function register (pad 32 to 35) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 32 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 32 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 32 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 32 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 32 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 33 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 33 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 33 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 33 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 33 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 34 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 34 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 34 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 34 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 34 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 35 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 35 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 35 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 35 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 35 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG9: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_32_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_32_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_32_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_32_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_32_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_33_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_33_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_33_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_33_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_33_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_34_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_34_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_34_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_34_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_34_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_35_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_35_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_35_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_35_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_35_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG9: PADCFG9 """"""" @@ -921,52 +943,54 @@ PADCFG9 Function register (pad 36 to 39) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 36 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 36 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 36 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 36 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 36 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 37 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 37 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 37 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 37 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 37 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 38 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 38 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 38 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 38 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 38 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 39 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 39 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 39 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 39 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 39 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG10: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_36_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_36_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_36_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_36_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_36_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_37_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_37_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_37_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_37_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_37_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_38_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_38_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_38_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_38_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_38_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_39_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_39_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_39_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_39_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_39_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG10: PADCFG10 """""""" @@ -974,52 +998,54 @@ PADCFG10 Function register (pad 40 to 43) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 40 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 40 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 40 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 40 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 40 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 41 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 41 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 41 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 41 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 41 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 42 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 42 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 42 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 42 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 42 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 43 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 43 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 43 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 43 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 43 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG11: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_40_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_40_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_40_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_40_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_40_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_41_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_41_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_41_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_41_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_41_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_42_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_42_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_42_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_42_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_42_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_43_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_43_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_43_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_43_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_43_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG11: PADCFG11 """""""" @@ -1027,52 +1053,54 @@ PADCFG11 Function register (pad 44 to 47) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 44 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 44 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 44 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 44 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 44 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 45 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 45 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 45 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 45 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 45 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 46 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 46 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 46 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 46 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 46 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 47 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 47 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 47 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 47 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 47 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG12: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_44_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_44_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_44_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_44_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_44_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_45_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_45_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_45_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_45_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_45_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_46_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_46_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_46_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_46_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_46_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_47_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_47_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_47_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_47_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_47_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG12: PADCFG12 """""""" @@ -1080,52 +1108,54 @@ PADCFG12 Function register (pad 48 to 51) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 48 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 48 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 48 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 48 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 48 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 49 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 49 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 49 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 49 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 49 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 50 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 50 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 50 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 50 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 50 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 51 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 51 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 51 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 51 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 51 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG13: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_48_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_48_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_48_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_48_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_48_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_49_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_49_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_49_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_49_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_49_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_50_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_50_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_50_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_50_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_50_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_51_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_51_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_51_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_51_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_51_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG13: PADCFG13 """""""" @@ -1133,52 +1163,54 @@ PADCFG13 Function register (pad 52 to 55) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 52 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 52 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 52 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 52 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 52 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 53 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 53 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 53 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 53 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 53 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 54 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 54 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 54 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 54 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 54 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 55 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 55 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 55 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 55 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 55 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG14: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_52_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_52_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_52_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_52_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_52_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_53_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_53_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_53_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_53_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_53_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_54_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_54_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_54_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_54_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_54_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_55_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_55_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_55_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_55_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_55_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG14: PADCFG14 """""""" @@ -1186,52 +1218,54 @@ PADCFG14 Function register (pad 56 to 59) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 56 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 56 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 56 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 56 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 56 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 57 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 57 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 57 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 57 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 57 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 58 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 58 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 58 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 58 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 58 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 59 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 59 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 59 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 59 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 59 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG15: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_56_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_56_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_56_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_56_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_56_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_57_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_57_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_57_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_57_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_57_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_58_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_58_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_58_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_58_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_58_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_59_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_59_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_59_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_59_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_59_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG15: PADCFG15 """""""" @@ -1239,52 +1273,54 @@ PADCFG15 Function register (pad 60 to 63) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 60 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 60 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 60 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 60 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 60 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 61 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 61 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 61 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 61 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 61 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 62 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 62 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 62 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 62 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 62 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 63 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 63 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 63 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 63 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 63 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG16: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_60_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_60_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_60_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_60_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_60_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_61_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_61_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_61_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_61_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_61_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_62_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_62_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_62_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_62_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_62_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_63_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_63_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_63_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_63_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_63_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG16: PADCFG16 """""""" @@ -1292,52 +1328,54 @@ PADCFG16 Function register (pad 64 to 67) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 64 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 64 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 64 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 64 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 64 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 65 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 65 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 65 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 65 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 65 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 66 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 66 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 66 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 66 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 66 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 67 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 67 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 67 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 67 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 67 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG17: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_64_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_64_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_64_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_64_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_64_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_65_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_65_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_65_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_65_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_65_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_66_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_66_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_66_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_66_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_66_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_67_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_67_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_67_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_67_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_67_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG17: PADCFG17 """""""" @@ -1345,52 +1383,54 @@ PADCFG17 Function register (pad 68 to 71) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 68 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 68 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 68 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 68 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 68 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 69 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 69 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 69 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 69 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 69 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 70 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 70 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 70 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 70 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 70 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 71 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 71 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 71 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 71 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 71 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG18: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_68_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_68_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_68_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_68_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_68_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_69_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_69_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_69_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_69_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_69_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_70_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_70_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_70_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_70_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_70_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_71_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_71_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_71_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_71_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_71_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG18: PADCFG18 """""""" @@ -1398,52 +1438,54 @@ PADCFG18 Function register (pad 72 to 75) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 72 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 72 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 72 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 72 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 72 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 73 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 73 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 73 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 73 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 73 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 74 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 74 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 74 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 74 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 74 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 75 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 75 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 75 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 75 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 75 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG19: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_72_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_72_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_72_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_72_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_72_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_73_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_73_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_73_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_73_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_73_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_74_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_74_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_74_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_74_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_74_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_75_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_75_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_75_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_75_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_75_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG19: PADCFG19 """""""" @@ -1451,52 +1493,54 @@ PADCFG19 Function register (pad 76 to 79) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 76 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 76 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 76 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 76 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 76 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 77 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 77 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 77 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 77 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 77 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 78 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 78 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 78 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 78 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 78 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 79 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 79 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 79 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 79 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 79 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG20: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_76_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_76_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_76_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_76_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_76_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_77_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_77_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_77_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_77_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_77_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_78_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_78_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_78_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_78_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_78_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_79_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_79_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_79_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_79_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_79_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG20: PADCFG20 """""""" @@ -1504,52 +1548,54 @@ PADCFG20 Function register (pad 80 to 83) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 80 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 80 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 80 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 80 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 80 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 81 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 81 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 81 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 81 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 81 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 82 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 82 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 82 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 82 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 82 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 83 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 83 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 83 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 83 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 83 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG21: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_80_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_80_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_80_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_80_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_80_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_81_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_81_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_81_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_81_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_81_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_82_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_82_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_82_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_82_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_82_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_83_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_83_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_83_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_83_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_83_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG21: PADCFG21 """""""" @@ -1557,52 +1603,54 @@ PADCFG21 Function register (pad 84 to 87) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 84 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 84 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 84 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 84 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 84 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 85 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 85 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 85 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 85 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 85 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 16|R/W|Pad 86 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 17|R/W|Pad 86 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |19:18|R/W|Pad 86 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 20|R/W|Pad 86 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 21|R/W|Pad 86 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 24|R/W|Pad 87 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 25|R/W|Pad 87 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |27:26|R/W|Pad 87 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 28|R/W|Pad 87 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 29|R/W|Pad 87 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_PADCFG22: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_84_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_84_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_84_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_84_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_84_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_85_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_85_PULL_UP |0x1 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_85_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_85_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_85_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 16|R/W|PAD_86_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 17|R/W|PAD_86_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |19:18|R/W|PAD_86_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 20|R/W|PAD_86_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 21|R/W|PAD_86_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 24|R/W|PAD_87_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 25|R/W|PAD_87_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |27:26|R/W|PAD_87_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 28|R/W|PAD_87_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 29|R/W|PAD_87_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__PADCFG22: PADCFG22 """""""" @@ -1610,32 +1658,34 @@ PADCFG22 Function register (pad 88 to 89) .. table:: - - +-----+---+----------------------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==============================================+ - | 0|R/W|Pad 88 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 1|R/W|Pad 88 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |3:2 |R/W|Pad 88 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 4|R/W|Pad 88 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 5|R/W|Pad 88 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - | 8|R/W|Pad 89 Pull Down | | - +-----+---+----------------------+----------------------------------------------+ - | 9|R/W|Pad 89 Pull Up | | - +-----+---+----------------------+----------------------------------------------+ - |11:10|R/W|Pad 89 Drive Strength |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | - +-----+---+----------------------+----------------------------------------------+ - | 12|R/W|Pad 89 Schmitt Trigger| | - +-----+---+----------------------+----------------------------------------------+ - | 13|R/W|Pad 89 Slew Rate |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V| - +-----+---+----------------------+----------------------------------------------+ - -.. _apb_soc_ctrl_REG_REPROG_PAD0: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=======================================================+ + | 0|R/W|PAD_88_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 1|R/W|PAD_88_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |3:2 |R/W|PAD_88_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 4|R/W|PAD_88_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 5|R/W|PAD_88_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 8|R/W|PAD_89_PULL_DOWN |0x0 |Write 1 to enable I/O pull-down | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 9|R/W|PAD_89_PULL_UP |0x0 |Write 1 to enable I/O pull-up | + +-----+---+----------------------+-----+-------------------------------------------------------+ + |11:10|R/W|PAD_89_DRIVE_STRENGTH |0x0 |0: 2mA, 1: 4mA, 2: 8mA, 3: 12mA | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 12|R/W|PAD_89_SCHMITT_TRIGGER|0x0 |Write 1 to enable Schmitt trigger on this I/O | + +-----+---+----------------------+-----+-------------------------------------------------------+ + | 13|R/W|PAD_89_SLEW_RATE |0x0 |0: When VDDIO = 1.8V, 1: When VDDIO = 1.5/1.2V (unused)| + +-----+---+----------------------+-----+-------------------------------------------------------+ + +.. _apb_soc_ctrl__REG_REPROG_PAD0: REG_REPROG_PAD0 """"""""""""""" @@ -1643,22 +1693,24 @@ REG_REPROG_PAD0 Controls reprogrammable pads 27,28,29,30,34 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------------------+--------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+====================================================================+ - |5:0 |R/W|mux_group_sel_spi0_cs0|Selects an alternate from the mux group. Default alternate: spi0_cs0| - +-----+---+----------------------+--------------------------------------------------------------------+ - |11:6 |R/W|mux_group_sel_spi0_cs1|Selects an alternate from the mux group. Default alternate: spi0_cs1| - +-----+---+----------------------+--------------------------------------------------------------------+ - |17:12|R/W|mux_group_sel_spi0_cs2|Selects an alternate from the mux group. Default alternate: spi0_cs2| - +-----+---+----------------------+--------------------------------------------------------------------+ - |23:18|R/W|mux_group_sel_spi0_cs3|Selects an alternate from the mux group. Default alternate: spi0_cs3| - +-----+---+----------------------+--------------------------------------------------------------------+ - |29:24|R/W|mux_group_sel_spi1_cs0|Selects an alternate from the mux group. Default alternate: spi1_cs0| - +-----+---+----------------------+--------------------------------------------------------------------+ + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+======================================================================+ + |5:0 |R/W|MUX_GROUP_SEL_SPI0_CS0|0x00 |Selects function for reprogrammable pad 27. Default function: SPI0_CS0| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |11:6 |R/W|MUX_GROUP_SEL_SPI0_CS1|0x01 |Selects function for reprogrammable pad 28. Default function: SPI0_CS1| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |17:12|R/W|MUX_GROUP_SEL_SPI0_CS2|0x02 |Selects function for reprogrammable pad 29. Default function: SPI0_CS2| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |23:18|R/W|MUX_GROUP_SEL_SPI0_CS3|0x03 |Selects function for reprogrammable pad 30. Default function: SPI0_CS3| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |29:24|R/W|MUX_GROUP_SEL_SPI1_CS0|0x04 |Selects function for reprogrammable pad 34. Default function: SPI1_CS0| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ -.. _apb_soc_ctrl_REG_REPROG_PAD1: +.. _apb_soc_ctrl__REG_REPROG_PAD1: REG_REPROG_PAD1 """"""""""""""" @@ -1666,22 +1718,24 @@ REG_REPROG_PAD1 Controls reprogrammable pads 35,40,41,42,43 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------------------+----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+======================================================================+ - |5:0 |R/W|mux_group_sel_spi1_cs1|Selects an alternate from the mux group. Default alternate: spi1_cs1 | - +-----+---+----------------------+----------------------------------------------------------------------+ - |11:6 |R/W|mux_group_sel_i2c0_sda|Selects an alternate from the mux group. Default alternate: i2c0_sda | - +-----+---+----------------------+----------------------------------------------------------------------+ - |17:12|R/W|mux_group_sel_i2c0_scl|Selects an alternate from the mux group. Default alternate: i2c0_scl | - +-----+---+----------------------+----------------------------------------------------------------------+ - |23:18|R/W|mux_group_sel_i2c1_sda|Selects an alternate from the mux group. Default alternate: i2c1_sda_o| - +-----+---+----------------------+----------------------------------------------------------------------+ - |29:24|R/W|mux_group_sel_i2c1_scl|Selects an alternate from the mux group. Default alternate: i2c1_scl_o| - +-----+---+----------------------+----------------------------------------------------------------------+ + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+======================================================================+ + |5:0 |R/W|MUX_GROUP_SEL_SPI1_CS1|0x06 |Selects function for reprogrammable pad 35. Default function: SPI1_CS1| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |11:6 |R/W|MUX_GROUP_SEL_I2C0_SDA|0x08 |Selects function for reprogrammable pad 40. Default function: I2C0_SDA| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |17:12|R/W|MUX_GROUP_SEL_I2C0_SCL|0x09 |Selects function for reprogrammable pad 41. Default function: I2C0_SCL| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |23:18|R/W|MUX_GROUP_SEL_I2C1_SDA|0x0A |Selects function for reprogrammable pad 42. Default function: I2C1_SDA| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ + |29:24|R/W|MUX_GROUP_SEL_I2C1_SCL|0x0C |Selects function for reprogrammable pad 43. Default function: I2C1_SCL| + +-----+---+----------------------+-----+----------------------------------------------------------------------+ -.. _apb_soc_ctrl_REG_REPROG_PAD2: +.. _apb_soc_ctrl__REG_REPROG_PAD2: REG_REPROG_PAD2 """"""""""""""" @@ -1689,22 +1743,24 @@ REG_REPROG_PAD2 Controls reprogrammable pads 44,45,60,61,62 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======================+=======================================================================+ - |5:0 |R/W|mux_group_sel_i2c2_sda |Selects an alternate from the mux group. Default alternate: i2c2_sda_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |11:6 |R/W|mux_group_sel_i2c2_scl |Selects an alternate from the mux group. Default alternate: i2c2_scl_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |17:12|R/W|mux_group_sel_uart0_rx |Selects an alternate from the mux group. Default alternate: uart0_rx_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |23:18|R/W|mux_group_sel_uart0_tx |Selects an alternate from the mux group. Default alternate: uart0_tx_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |29:24|R/W|mux_group_sel_uart0_cts|Selects an alternate from the mux group. Default alternate: uart0_cts_o| - +-----+---+-----------------------+-----------------------------------------------------------------------+ + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======================+=====+=======================================================================+ + |5:0 |R/W|MUX_GROUP_SEL_I2C2_SDA |0x0E |Selects function for reprogrammable pad 44. Default function: I2C2_SDA | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |11:6 |R/W|MUX_GROUP_SEL_I2C2_SCL |0x10 |Selects function for reprogrammable pad 45. Default function: I2C2_SCL | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |17:12|R/W|MUX_GROUP_SEL_UART0_RX |0x12 |Selects function for reprogrammable pad 60. Default function: UART0_RX | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |23:18|R/W|MUX_GROUP_SEL_UART0_TX |0x13 |Selects function for reprogrammable pad 61. Default function: UART0_TX | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |29:24|R/W|MUX_GROUP_SEL_UART0_CTS|0x14 |Selects function for reprogrammable pad 62. Default function: UART0_CTS| + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ -.. _apb_soc_ctrl_REG_REPROG_PAD3: +.. _apb_soc_ctrl__REG_REPROG_PAD3: REG_REPROG_PAD3 """"""""""""""" @@ -1712,50 +1768,24 @@ REG_REPROG_PAD3 Controls reprogrammable pads 63,65,66,67,68 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======================+=======================================================================+ - |5:0 |R/W|mux_group_sel_uart0_rts|Selects an alternate from the mux group. Default alternate: uart0_rts_o| - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |11:6 |R/W|mux_group_sel_uart1_rx |Selects an alternate from the mux group. Default alternate: uart1_rx_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |17:12|R/W|mux_group_sel_uart1_tx |Selects an alternate from the mux group. Default alternate: uart1_tx_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |23:18|R/W|mux_group_sel_pwm0 |Selects an alternate from the mux group. Default alternate: pwm0_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - |29:24|R/W|mux_group_sel_pwm1 |Selects an alternate from the mux group. Default alternate: pwm1_o | - +-----+---+-----------------------+-----------------------------------------------------------------------+ - -.. _apb_soc_ctrl_RESERVED1: - -RESERVED1 -""""""""" - -Reserved - -.. _apb_soc_ctrl_RESERVED2: + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======================+=====+=======================================================================+ + |5:0 |R/W|MUX_GROUP_SEL_UART0_RTS|0x16 |Selects function for reprogrammable pad 63. Default function: UART0_RTS| + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |11:6 |R/W|MUX_GROUP_SEL_UART1_RX |0x18 |Selects function for reprogrammable pad 65. Default function: UART1_RX | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |17:12|R/W|MUX_GROUP_SEL_UART1_TX |0x1B |Selects function for reprogrammable pad 66. Default function: UART1_TX | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |23:18|R/W|MUX_GROUP_SEL_PWM0 |0x1E |Selects function for reprogrammable pad 67. Default function: PWM0 | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ + |29:24|R/W|MUX_GROUP_SEL_PWM1 |0x21 |Selects function for reprogrammable pad 68. Default function: PWM1 | + +-----+---+-----------------------+-----+-----------------------------------------------------------------------+ -RESERVED2 -""""""""" - -Reserved - -.. _apb_soc_ctrl_RESERVED3: - -RESERVED3 -""""""""" - -Reserved - -.. _apb_soc_ctrl_RESERVED4: - -RESERVED4 -""""""""" - -Reserved - -.. _apb_soc_ctrl_CL_BUSY: +.. _apb_soc_ctrl__CL_BUSY: CL_BUSY """"""" @@ -1763,14 +1793,16 @@ CL_BUSY Cluster busy register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+----------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================+ - | 0|R |BUSY|Cluster busy flag (i.e. It's 1 if there is at least 1 active block in the cluster)| - +-----+---+----+----------------------------------------------------------------------------------+ + +-----+---+----+-----+----------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==================================================================================+ + | 0|R |BUSY|0x0 |Cluster busy flag (i.e. It's 1 if there is at least 1 active block in the cluster)| + +-----+---+----+-----+----------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_JTAGREG: +.. _apb_soc_ctrl__JTAGREG: JTAGREG """"""" @@ -1778,16 +1810,18 @@ JTAGREG JTAG external register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+======================================================================+ - |3:0 |R/W|INTERNAL|JTAG internal register used for synchronisation from external debugger| - +-----+---+--------+----------------------------------------------------------------------+ - |11:8 |R |EXTERNAL|JTAG external register used for synchronisation from external debugger| - +-----+---+--------+----------------------------------------------------------------------+ + +-----+---+--------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+======================================================================+ + |3:0 |R/W|INTERNAL|0x0 |JTAG internal register used for synchronisation from external debugger| + +-----+---+--------+-----+----------------------------------------------------------------------+ + |11:8 |R |EXTERNAL|0x0 |JTAG external register used for synchronisation from external debugger| + +-----+---+--------+-----+----------------------------------------------------------------------+ -.. _apb_soc_ctrl_REF_FAST_CLK_DIV: +.. _apb_soc_ctrl__REF_FAST_CLK_DIV: REF_FAST_CLK_DIV """""""""""""""" @@ -1795,13 +1829,16 @@ REF_FAST_CLK_DIV Read only, reference fast clk divided by power of 2 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================================+ + | 0|R |CLK |0x0 |Current value of the divided REF FAST clock| + +-----+---+----+-----+-------------------------------------------+ -.. _apb_soc_ctrl_SW_RST: +.. _apb_soc_ctrl__SW_RST: SW_RST """""" @@ -1809,14 +1846,16 @@ SW_RST Software reset, reboot .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+===============================+ - | 0|R |RESET|Writing 1 triggers a chip reset| - +-----+---+-----+-------------------------------+ + +-----+---+-----+-----+-------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===============================+ + | 0|R |RESET|0x0 |Writing 1 triggers a chip reset| + +-----+---+-----+-----+-------------------------------+ -.. _apb_soc_ctrl_CORESTATUS: +.. _apb_soc_ctrl__CORESTATUS: CORESTATUS """""""""" @@ -1824,16 +1863,18 @@ CORESTATUS EOC and chip status register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+---------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+=========================================================================================================+ - |31:0 |R/W|STATUS|Chip status register. The SW can store the exit value value so that the external loader can get it. | - +-----+---+------+---------------------------------------------------------------------------------------------------------+ - |31 |R/W|EOC |End Of Computation. The SW can store 1 here to notify the external loader that the execution is finished.| - +-----+---+------+---------------------------------------------------------------------------------------------------------+ + +-----+---+------+-----+---------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=========================================================================================================+ + |31:0 |R/W|STATUS|0x0 |Chip status register. The SW can store the exit value value so that the external loader can get it. | + +-----+---+------+-----+---------------------------------------------------------------------------------------------------------+ + |31 |R/W|EOC |0x0 |End Of Computation. The SW can store 1 here to notify the external loader that the execution is finished.| + +-----+---+------+-----+---------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_BOOTSEL: +.. _apb_soc_ctrl__BOOTSEL: BOOTSEL """"""" @@ -1841,14 +1882,16 @@ BOOTSEL Value of pad bootsel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+============================================================================================================+ - |1:0 |R |BOOTSEL|Boot mode. These bits can be used by the ROM to select the boot mode, see ROM documentation for more details| - +-----+---+-------+------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+============================================================================================================+ + |1:0 |R |BOOTSEL|0x0 |Boot mode. These bits can be used by the ROM to select the boot mode, see ROM documentation for more details| + +-----+---+-------+-----+------------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_WD_RST_RST: +.. _apb_soc_ctrl__WD_RST_RST: WD_RST_RST """""""""" @@ -1856,14 +1899,16 @@ WD_RST_RST Rearm WD timeout .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+---------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+===============================================================+ - |31:0 |R |CLEAR|Any write to this register re-arms the watchdog timeout counter| - +-----+---+-----+---------------------------------------------------------------+ + +-----+---+-----+-----+---------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===============================================================+ + |31:0 |R |CLEAR|0x0 |Any write to this register re-arms the watchdog timeout counter| + +-----+---+-----+-----+---------------------------------------------------------------+ -.. _apb_soc_ctrl_WD_RST_SET: +.. _apb_soc_ctrl__WD_RST_SET: WD_RST_SET """""""""" @@ -1871,30 +1916,35 @@ WD_RST_SET Set WD timer .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------+----------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+==================================================================================================================================+ - |23:0 |R |REF_COUNTER|Watchdog timeout counter, in periods of the SOC ref clock (maximum 2^16 * 1 / 32.768KHZ = 2s when using the 32kHz reference clock)| - +-----+---+-----------+----------------------------------------------------------------------------------------------------------------------------------+ - |31 |R |ENABLE |Enable the watchdog: triggers chip reset if the timeout counter expires without being re-armed | - +-----+---+-----------+----------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-----------+-------+----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+===========+=======+==================================================================================================================================+ + |23:0 |R |REF_COUNTER|0xFFFFF|Watchdog timeout counter, in periods of the SOC ref clock (maximum 2^16 * 1 / 32.768KHZ = 2s when using the 32kHz reference clock)| + +-----+---+-----------+-------+----------------------------------------------------------------------------------------------------------------------------------+ + |31 |R |ENABLE |0x0 |Enable the watchdog: triggers chip reset if the timeout counter expires without being re-armed | + +-----+---+-----------+-------+----------------------------------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_RWM_CSI2: +.. _apb_soc_ctrl__RWM_CSI2: RWM_CSI2 """""""" -RWM for CSI2 +Margin adjust settings for CSI2 Controller .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+--------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+============================================+ + |5:0 |R/W|RWM_CSI2|0x00 |Margin settings for CSI2 controller memories| + +-----+---+--------+-----+--------------------------------------------+ -.. _apb_soc_ctrl_IDLE_MODE: +.. _apb_soc_ctrl__IDLE_MODE: IDLE_MODE """"""""" @@ -1902,47 +1952,62 @@ IDLE_MODE Activates IDLE MODE .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------+------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+==================================================================+ - |15:0 |R/W|REF_COUNTER|IDLE MODE Counter, maximum 2^16 * 1 / 32.768KHZ = 2s | - +-----+---+-----------+------------------------------------------------------------------+ - |31 |R/W|ENABLE |Enable IDLE MODE on READ return status of idle mode(0=normal mode)| - +-----+---+-----------+------------------------------------------------------------------+ + +-----+---+-----------+------+-------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+===========+======+===================================================================+ + |15:0 |R/W|REF_COUNTER|0xFFFF|IDLE MODE Counter, maximum 2^16 * 1 / 32.768KHZ = 2s | + +-----+---+-----------+------+-------------------------------------------------------------------+ + |31 |R/W|ENABLE |0x0 |Enable IDLE MODE on READ return status of idle mode (0=normal mode)| + +-----+---+-----------+------+-------------------------------------------------------------------+ -.. _apb_soc_ctrl_RWM_ANC: +.. _apb_soc_ctrl__RWM_ANC: RWM_ANC """"""" -RWM for ANC +Margin adjust settings for SFU .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------------+-----+-------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+=================================================+ + |5:0 |R/W|RWM_ASRC_DPRAM|0x00 |Margin settings for SFU ASRC dual-port memories | + +-----+---+--------------+-----+-------------------------------------------------+ + |12:6 |R/W|RWM_ASRC_RAM |0x40 |Margin settings for SFU ASRC single-port memories| + +-----+---+--------------+-----+-------------------------------------------------+ + |18:13|R/W|RWM_GFU_DPRAM |0x00 |Margin settings for SFU GFU dual-port memories | + +-----+---+--------------+-----+-------------------------------------------------+ + |25:19|R/W|RWM_POLY_RAM |0x40 |Margin settings for SFU Polyphase Filter memories| + +-----+---+--------------+-----+-------------------------------------------------+ + |29:26|R/W|RWM_GFU_R1PL |0x00 |Margin settings for SFU GFU single-port memories | + +-----+---+--------------+-----+-------------------------------------------------+ -.. _apb_soc_ctrl_REF_CLK_MUX: +.. _apb_soc_ctrl__REF_CLK_MUX: REF_CLK_MUX """"""""""" -Ref clock mux 0: 32Khz 1: ref fast +Reference clock selection .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+----------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+================================================================+ - | 0|R/W|SOC |Ref clock select for soc : 0 - 32Khz; 1 - ref fast clock div | - +-----+---+-------+----------------------------------------------------------------+ - | 1|R/W|CLUSTER|Ref clock select for cluster : 0 - 32Khz; 1 - ref fast clock div| - +-----+---+-------+----------------------------------------------------------------+ + +-----+---+-------+-----+-----------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=========================================================================================+ + | 0|R/W|SOC |0x0 |Reference clock selection for SOC: 0: 32Khz REF SLOW clock; 1: divided REF FAST clock | + +-----+---+-------+-----+-----------------------------------------------------------------------------------------+ + | 1|R/W|CLUSTER|0x0 |Reference clock selection for cluster: 0: 32Khz REF SLOW clock; 1: divided REF FAST clock| + +-----+---+-------+-----+-----------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_SUPERVISOR_DBG: +.. _apb_soc_ctrl__SUPERVISOR_DBG: SUPERVISOR_DBG """""""""""""" @@ -1950,13 +2015,16 @@ SUPERVISOR_DBG .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+---------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=======================================+ + | 0|R/W|MODE|0x0 |Write 1 to enable supervisor debug mode| + +-----+---+----+-----+---------------------------------------+ -.. _apb_soc_ctrl_DBG_CTRL: +.. _apb_soc_ctrl__DBG_CTRL: DBG_CTRL """""""" @@ -1964,27 +2032,34 @@ DBG_CTRL Debug access control .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _apb_soc_ctrl_RESERVED5: - -RESERVED5 -""""""""" - -Reserved - -.. _apb_soc_ctrl_RESERVED6: - -RESERVED6 -""""""""" - -Reserved - -.. _apb_soc_ctrl_CLK_DIV_I3C: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-----------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================+ + | 0|R/W|HART_CL_CORE0|0x0 |Write 1 to enable HART for cluster core 0| + +-----+---+-------------+-----+-----------------------------------------+ + | 1|R/W|HART_CL_CORE1|0x0 |Write 1 to enable HART for cluster core 1| + +-----+---+-------------+-----+-----------------------------------------+ + | 2|R/W|HART_CL_CORE2|0x0 |Write 1 to enable HART for cluster core 2| + +-----+---+-------------+-----+-----------------------------------------+ + | 3|R/W|HART_CL_CORE3|0x0 |Write 1 to enable HART for cluster core 3| + +-----+---+-------------+-----+-----------------------------------------+ + | 4|R/W|HART_CL_CORE4|0x0 |Write 1 to enable HART for cluster core 4| + +-----+---+-------------+-----+-----------------------------------------+ + | 5|R/W|HART_CL_CORE5|0x0 |Write 1 to enable HART for cluster core 5| + +-----+---+-------------+-----+-----------------------------------------+ + | 6|R/W|HART_CL_CORE6|0x0 |Write 1 to enable HART for cluster core 6| + +-----+---+-------------+-----+-----------------------------------------+ + | 7|R/W|HART_CL_CORE7|0x0 |Write 1 to enable HART for cluster core 7| + +-----+---+-------------+-----+-----------------------------------------+ + | 8|R/W|HART_CL_CORE8|0x0 |Write 1 to enable HART for cluster core 8| + +-----+---+-------------+-----+-----------------------------------------+ + | 9|R/W|HART_FC_CORE |0x1 |Write 1 to enable HART for FC core | + +-----+---+-------------+-----+-----------------------------------------+ + +.. _apb_soc_ctrl__CLK_DIV_I3C: CLK_DIV_I3C """"""""""" @@ -1992,27 +2067,37 @@ CLK_DIV_I3C Clock divider for I3C .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+===============================+ + | 0|R/W|CLK_EN |0x0 |Write 1 to enable clock for I3C| + +-----+---+-----------+-----+-------------------------------+ + |15:8 |R/W|CLK_DIVIDER|0x0 |Integer divider for I3C | + +-----+---+-----------+-----+-------------------------------+ -.. _apb_soc_ctrl_CLK_EN_QUIDDIKEY: +.. _apb_soc_ctrl__CLK_EN_QUIDDIKEY: CLK_EN_QUIDDIKEY """""""""""""""" -Clock divider for QUIDDIKEY +Quiddikey enablement .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+---------+-----+------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+======================================================+ + | 0|R/W|QK_CLK_EN|0x0 |Write 1 to enable clock for the Quiddikey | + +-----+---+---------+-----+------------------------------------------------------+ + | 1|R/W|QK_RSTN |0x0 |Control the value of the active low reset of Quiddikey| + +-----+---+---------+-----+------------------------------------------------------+ -.. _apb_soc_ctrl_SLEEP_CTRL_INFO: +.. _apb_soc_ctrl__SLEEP_CTRL_INFO: SLEEP_CTRL_INFO """"""""""""""" @@ -2020,44 +2105,49 @@ SLEEP_CTRL_INFO Safe domain's Sleep control info .. table:: - - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+====================================================================================================+ - |7:0 |R |REBOOT |SW config. This field is only interpreted by ROM and runtime to keep information accross deep sleep.| - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |8 |R |RTC_WAKE_EN |Enable RTC wakeup | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |9 |R |RTC_EVENT |RTC event | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |10 |R |EXT_WAKEUP_EN|Enable external wakeup | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |26:11|R |EXT_EVENT |External event on wake-up I/Os | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |28:27|R |WAKEUP_CFG |Selected wake-up sequence | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |29 |R |FORCE_AO_PADS|Force always-on I/Os into their sleep mode configuration (see SLEEPPADCFGx registers) | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |30 |R |CNT_WAKE_EN |Enable counter wakeup | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |31 |R |CNT_EVENT |Counter event | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_VERSION: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+====================================================================================================+ + |7:0 |R |REBOOT |0x0 |SW config. This field is only interpreted by ROM and runtime to keep information accross deep sleep.| + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |8 |R |RTC_WAKE_EN |0x0 |Enable RTC wakeup | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |9 |R |RTC_EVENT |0x0 |RTC event | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |10 |R |EXT_WAKEUP_EN|0x0 |Enable external wakeup | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |26:11|R |EXT_EVENT |0x0 |External event on wake-up I/Os | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |28:27|R |WAKEUP_CFG |0x0 |Selected wake-up sequence | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |29 |R |FORCE_AO_PADS|0x0 |Force always-on I/Os into their sleep mode configuration (see SLEEPPADCFGx registers) | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |30 |R |CNT_WAKE_EN |0x0 |Enable counter wakeup | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |31 |R |CNT_EVENT |0x0 |Counter event | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + +.. _apb_soc_ctrl__VERSION: VERSION """"""" -Show chip version +Show chip version (User controlled) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=================================================+ + |3:0 |R/W|VERSION|0x0 |4-bit field available to SW to store chip version| + +-----+---+-------+-----+-------------------------------------------------+ -.. _apb_soc_ctrl_SLEEP_SPIS_CTRL: +.. _apb_soc_ctrl__SLEEP_SPIS_CTRL: SLEEP_SPIS_CTRL """"""""""""""" @@ -2065,20 +2155,22 @@ SLEEP_SPIS_CTRL Sleep SPIS control .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------+--------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+================================================================================+ - | 0|R/W|MUX |Enable wake-up interface, 0: GPIO-only external wake-up; 1: SPIS wake-up enabled| - +-----+---+------------+--------------------------------------------------------------------------------+ - |2:1 |R/W|SPIS_MODE |SPI slave controller CPOL and CPHA | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 3|R/W|SPIS_RSTN |Reset the SPI Slave wakeup controller | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 4|R/W|SPIS_SW_DONE|Notify outside device wakeup done | - +-----+---+------------+--------------------------------------------------------------------------------+ + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+================================================================================+ + | 0|R/W|MUX |0x0 |Enable wake-up interface, 0: GPIO-only external wake-up; 1: SPIS wake-up enabled| + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + |2:1 |R/W|SPIS_MODE |0x0 |SPI slave controller CPOL and CPHA | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 3|R/W|SPIS_RSTN |0x1 |Reset the SPI Slave wakeup controller | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 4|R/W|SPIS_SW_DONE|0x0 |Notify outside device wakeup done | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_SLEEP_CTRL: +.. _apb_soc_ctrl__SLEEP_CTRL: SLEEP_CTRL """""""""" @@ -2086,26 +2178,28 @@ SLEEP_CTRL Sleep control .. table:: - - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+====================================================================================================+ - |7:0 |R/W|REBOOT |SW config. This field is only interpreted by ROM and runtime to keep information accross deep sleep.| - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |8 |R/W|RTC_WAKE_EN |Enable RTC wakeup | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |9 |R/W|RTC_EVENT |RTC event | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |10 |R/W|EXT_WAKEUP_EN|Enable external wakeup | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |26:11|R/W|EXT_EVENT |External event. Bit order corresponds to the numbering in SLEEP_GPIO_CTRL register. | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |28:27|R/W|WAKEUP_CFG |Selected wake-up sequence | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - |29 |R/W|FORCE_AO_PADS|Force always-on I/Os into their sleep mode configuration (see SLEEPPADCFGx registers) | - +-----+---+-------------+----------------------------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_GPIO_CTRL: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+====================================================================================================+ + |7:0 |R/W|REBOOT |0x0 |SW config. This field is only interpreted by ROM and runtime to keep information accross deep sleep.| + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |8 |R/W|RTC_WAKE_EN |0x0 |Enable RTC wakeup | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |9 |R/W|RTC_EVENT |0x0 |RTC event | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |10 |R/W|EXT_WAKEUP_EN|0x0 |Enable external wakeup | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |26:11|R/W|EXT_EVENT |0x0 |External event. Bit order corresponds to the numbering in SLEEP_GPIO_CTRL register. | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |28:27|R/W|WAKEUP_CFG |0x0 |Selected wake-up sequence | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + |29 |R/W|FORCE_AO_PADS|0x0 |Force always-on I/Os into their sleep mode configuration (see SLEEPPADCFGx registers) | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_GPIO_CTRL: SLEEP_GPIO_CTRL """"""""""""""" @@ -2113,44 +2207,46 @@ SLEEP_GPIO_CTRL Sleep GPIO control .. table:: - - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===================+===========================================================================================+ - |1:0 |R/W|GPIO_WAKEUP_0_TYPE |Wake-up on I2C1_SDA pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |3:2 |R/W|GPIO_WAKEUP_1_TYPE |Wake-up on I2C1_SCL pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |5:4 |R/W|GPIO_WAKEUP_2_TYPE |Wake-up on UART1_RX pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |7:6 |R/W|GPIO_WAKEUP_3_TYPE |Wake-up on UART1_TX pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |9:8 |R/W|GPIO_WAKEUP_4_TYPE |Wake-up on PWM0 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |11:10|R/W|GPIO_WAKEUP_5_TYPE |Wake-up on PWM1 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |13:12|R/W|GPIO_WAKEUP_6_TYPE |Wake-up on WAKEUP_CS0 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal| - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |15:14|R/W|GPIO_WAKEUP_7_TYPE |Wake-up on WAKEUP_SDO pad. b00: disabled; b01: wake on high signal; b10: wake on low signal| - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |17:16|R/W|GPIO_WAKEUP_8_TYPE |Wake-up on I2C0_SDA pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |19:18|R/W|GPIO_WAKEUP_9_TYPE |Wake-up on I2C0_SCL pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |21:20|R/W|GPIO_WAKEUP_10_TYPE|Wake-up on SPI1_CS0 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |23:22|R/W|GPIO_WAKEUP_11_TYPE|Wake-up on SPI1_CS1 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |25:24|R/W|GPIO_WAKEUP_12_TYPE|Wake-up on SPI1_CS2 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |27:26|R/W|GPIO_WAKEUP_13_TYPE|Wake-up on SPI1_CS3 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |29:28|R/W|GPIO_WAKEUP_14_TYPE|Wake-up on SPI1_SDI pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - |31:30|R/W|GPIO_WAKEUP_15_TYPE|Wake-up on SPI1_SDO pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | - +-----+---+-------------------+-------------------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_CNT_CTRL: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===================+=====+===========================================================================================+ + |1:0 |R/W|GPIO_WAKEUP_0_TYPE |0x0 |Wake-up on I2C1_SDA pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |3:2 |R/W|GPIO_WAKEUP_1_TYPE |0x0 |Wake-up on I2C1_SCL pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |5:4 |R/W|GPIO_WAKEUP_2_TYPE |0x0 |Wake-up on UART1_RX pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |7:6 |R/W|GPIO_WAKEUP_3_TYPE |0x0 |Wake-up on UART1_TX pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |9:8 |R/W|GPIO_WAKEUP_4_TYPE |0x0 |Wake-up on PWM0 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |11:10|R/W|GPIO_WAKEUP_5_TYPE |0x0 |Wake-up on PWM1 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |13:12|R/W|GPIO_WAKEUP_6_TYPE |0x0 |Wake-up on WAKEUP_CS0 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal| + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |15:14|R/W|GPIO_WAKEUP_7_TYPE |0x0 |Wake-up on WAKEUP_SDO pad. b00: disabled; b01: wake on high signal; b10: wake on low signal| + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |17:16|R/W|GPIO_WAKEUP_8_TYPE |0x0 |Wake-up on I2C0_SDA pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |19:18|R/W|GPIO_WAKEUP_9_TYPE |0x0 |Wake-up on I2C0_SCL pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |21:20|R/W|GPIO_WAKEUP_10_TYPE|0x0 |Wake-up on SPI1_CS0 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |23:22|R/W|GPIO_WAKEUP_11_TYPE|0x0 |Wake-up on SPI1_CS1 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |25:24|R/W|GPIO_WAKEUP_12_TYPE|0x0 |Wake-up on SPI1_CS2 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |27:26|R/W|GPIO_WAKEUP_13_TYPE|0x0 |Wake-up on SPI1_CS3 pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |29:28|R/W|GPIO_WAKEUP_14_TYPE|0x0 |Wake-up on SPI1_SDI pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + |31:30|R/W|GPIO_WAKEUP_15_TYPE|0x0 |Wake-up on SPI1_SDO pad. b00: disabled; b01: wake on high signal; b10: wake on low signal | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_CNT_CTRL: SLEEP_CNT_CTRL """""""""""""" @@ -2158,18 +2254,20 @@ SLEEP_CNT_CTRL Sleep Counter control .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+====================================+ - |19:0 |R/W|VALUE |Counter target value | - +-----+---+---------+------------------------------------+ - |20 |R/W|EN |Counter enable | - +-----+---+---------+------------------------------------+ - |21 |R/W|CNT_EVENT|Counter event (target value reached)| - +-----+---+---------+------------------------------------+ + +-----+---+---------+-----+------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+====================================+ + |19:0 |R/W|VALUE |0x0 |Counter target value | + +-----+---+---------+-----+------------------------------------+ + |20 |R/W|EN |0x0 |Counter enable | + +-----+---+---------+-----+------------------------------------+ + |21 |R/W|CNT_EVENT|0x0 |Counter event (target value reached)| + +-----+---+---------+-----+------------------------------------+ -.. _apb_soc_ctrl_REG_OSC_CTRL: +.. _apb_soc_ctrl__REG_OSC_CTRL: REG_OSC_CTRL """""""""""" @@ -2177,25 +2275,20 @@ REG_OSC_CTRL Controls fast oscillator .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+===========================================================================================================================+ - | 0|R/W|FAST_OSC_EN |0 - Power Down, 1 - Enables fast oscillator | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|SLOW_OSC_EN |0 - Power Down, 1 - Enables 32KHz oscillator | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - | 2|R/W|BYPASS_FAST_OSC|0 - Use fast oscillator to generate FAST REF clock, 1 - Use external signal on USART0_CLK/FAST_REF_CK pad as FAST REF clock| - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - -.. _apb_soc_ctrl_RESERVED7: - -RESERVED7 -""""""""" - -Reserved + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+=========================================================================================================================+ + | 0|R/W|FAST_OSC_EN |0x0 |0: Power Down, 1: Enables fast oscillator | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|SLOW_OSC_EN |0x0 |0: Power Down, 1: Enables 32KHz oscillator | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------+ + | 2|R/W|BYPASS_FAST_OSC|0x0 |0: Use fast oscillator to generate FAST REF clock, 1: Use external signal on USART0_CLK/FAST_REF_CK pad as FAST REF clock| + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_CLK_DIV_REF_FAST_POW2: +.. _apb_soc_ctrl__CLK_DIV_REF_FAST_POW2: CLK_DIV_REF_FAST_POW2 """"""""""""""""""""" @@ -2203,41 +2296,45 @@ CLK_DIV_REF_FAST_POW2 Controls fast oscillator pow2 divider .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+==========================================+ - |2:0 |R/W|DIVIDER|Fast clock divider (division is 2^DIVIDER)| - +-----+---+-------+------------------------------------------+ - |3 |R/W|EN |Enable divider | - +-----+---+-------+------------------------------------------+ + +-----+---+-------+-----+------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==========================================+ + |2:0 |R/W|DIVIDER|0x0 |Fast clock divider (division is 2^DIVIDER)| + +-----+---+-------+-----+------------------------------------------+ + |3 |R/W|EN |0x0 |Enable divider | + +-----+---+-------+-----+------------------------------------------+ -.. _apb_soc_ctrl_FEATURE_DISABLEMENT: +.. _apb_soc_ctrl__FEATURE_DISABLE: -FEATURE_DISABLEMENT -""""""""""""""""""" +FEATURE_DISABLE +""""""""""""""" Feature disablement from always on (safe) domain .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------------------+--------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+======================================================================================================================================+ - | 0|R/W|DISABLE_JTAG |Disable jtag. It is disabled at reset and may be enabled back by the bootloader | - +-----+---+---------------------+--------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|DISABLE_CRYPTO |Disable aes and quiddikey | - +-----+---+---------------------+--------------------------------------------------------------------------------------------------------------------------------------+ - | 2|R/W|DISABLE_MRAM |Disable mram | - +-----+---+---------------------+--------------------------------------------------------------------------------------------------------------------------------------+ - | 3|R/W|DISABLE_EFUSE_PROGRAM|Disable efuse programming | - +-----+---+---------------------+--------------------------------------------------------------------------------------------------------------------------------------+ - | 4|R/W|DISABLE_SAFE_JTAG |Disable safe domain jtag to avoid accidental toggling when alternates are used | - +-----+---+---------------------+--------------------------------------------------------------------------------------------------------------------------------------+ - | 31|R/W|DISABLE_LOCK |When set, DISABLE_* registers cannot be written to zero until next whole chip reset or power-up. Configuration is kept in sleep modes.| - +-----+---+---------------------+--------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+======================================================================================================================================+ + | 0|R/W|DISABLE_JTAG |0x1 |Disable jtag. It is disabled at reset and may be enabled back by the bootloader | + +-----+---+---------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|DISABLE_CRYPTO |0x0 |Disable aes and quiddikey | + +-----+---+---------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + | 2|R/W|DISABLE_MRAM |0x0 |Disable mram | + +-----+---+---------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + | 3|R/W|DISABLE_EFUSE_PROGRAM|0x0 |Disable eFuse programming | + +-----+---+---------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + | 4|R/W|DISABLE_SAFE_JTAG |0x0 |Disable safe domain jtag to avoid accidental toggling when alternates are used | + +-----+---+---------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + | 31|R/W|DISABLE_LOCK |0x0 |When set, DISABLE_* registers cannot be written to zero until next whole chip reset or power-up. Configuration is kept in sleep modes.| + +-----+---+---------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_SLEEP_PAD_CFG0: +.. _apb_soc_ctrl__SLEEP_PAD_CFG0: SLEEP_PAD_CFG0 """""""""""""" @@ -2245,52 +2342,54 @@ SLEEP_PAD_CFG0 Sleep pad control .. table:: - - +-----+---+---------------+--------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==============================================================+ - | 0|R/W|PAD_0_PULL_DOWN|Pad 33 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 1|R/W|PAD_0_PULL_UP |Pad 33 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |3:2 |R/W|PAD_0_DRIVE |Pad 33 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 4|R/W|PAD_0_OUT |Pad 33 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 5|R/W|PAD_0_OEN |Pad 33 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 8|R/W|PAD_1_PULL_DOWN|Pad 34 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 9|R/W|PAD_1_PULL_UP |Pad 34 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |11:10|R/W|PAD_1_DRIVE |Pad 34 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 12|R/W|PAD_1_OUT |Pad 34 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 13|R/W|PAD_1_OEN |Pad 34 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 16|R/W|PAD_2_PULL_DOWN|Pad 35 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 17|R/W|PAD_2_PULL_UP |Pad 35 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |19:18|R/W|PAD_2_DRIVE |Pad 35 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 20|R/W|PAD_2_OUT |Pad 35 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 21|R/W|PAD_2_OEN |Pad 35 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 24|R/W|PAD_3_PULL_DOWN|Pad 36 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 25|R/W|PAD_3_PULL_UP |Pad 36 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |27:26|R/W|PAD_3_DRIVE |Pad 36 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 28|R/W|PAD_3_OUT |Pad 36 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 29|R/W|PAD_3_OEN |Pad 36 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_PAD_CFG1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+--------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==============================================================+ + | 0|R/W|PAD_0_PULL_DOWN|0x0 |Pad 33 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x0 |Pad 33 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |3:2 |R/W|PAD_0_DRIVE |0x0 |Pad 33 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 4|R/W|PAD_0_OUT |0x0 |Pad 33 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 5|R/W|PAD_0_OEN |0x1 |Pad 33 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 8|R/W|PAD_1_PULL_DOWN|0x0 |Pad 34 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 9|R/W|PAD_1_PULL_UP |0x0 |Pad 34 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |11:10|R/W|PAD_1_DRIVE |0x0 |Pad 34 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 12|R/W|PAD_1_OUT |0x0 |Pad 34 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 13|R/W|PAD_1_OEN |0x1 |Pad 34 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 16|R/W|PAD_2_PULL_DOWN|0x0 |Pad 35 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 17|R/W|PAD_2_PULL_UP |0x0 |Pad 35 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |19:18|R/W|PAD_2_DRIVE |0x0 |Pad 35 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 20|R/W|PAD_2_OUT |0x0 |Pad 35 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 21|R/W|PAD_2_OEN |0x1 |Pad 35 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 24|R/W|PAD_3_PULL_DOWN|0x0 |Pad 36 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 25|R/W|PAD_3_PULL_UP |0x0 |Pad 36 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |27:26|R/W|PAD_3_DRIVE |0x0 |Pad 36 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 28|R/W|PAD_3_OUT |0x0 |Pad 36 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 29|R/W|PAD_3_OEN |0x1 |Pad 36 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_PAD_CFG1: SLEEP_PAD_CFG1 """""""""""""" @@ -2298,52 +2397,54 @@ SLEEP_PAD_CFG1 Sleep pad control .. table:: - - +-----+---+---------------+--------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==============================================================+ - | 0|R/W|PAD_0_PULL_DOWN|Pad 37 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 1|R/W|PAD_0_PULL_UP |Pad 37 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |3:2 |R/W|PAD_0_DRIVE |Pad 37 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 4|R/W|PAD_0_OUT |Pad 37 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 5|R/W|PAD_0_OEN |Pad 37 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 8|R/W|PAD_1_PULL_DOWN|Pad 38 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 9|R/W|PAD_1_PULL_UP |Pad 38 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |11:10|R/W|PAD_1_DRIVE |Pad 38 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 12|R/W|PAD_1_OUT |Pad 38 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 13|R/W|PAD_1_OEN |Pad 38 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 16|R/W|PAD_2_PULL_DOWN|Pad 39 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 17|R/W|PAD_2_PULL_UP |Pad 39 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |19:18|R/W|PAD_2_DRIVE |Pad 39 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 20|R/W|PAD_2_OUT |Pad 39 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 21|R/W|PAD_2_OEN |Pad 39 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 24|R/W|PAD_3_PULL_DOWN|Pad 40 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 25|R/W|PAD_3_PULL_UP |Pad 40 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |27:26|R/W|PAD_3_DRIVE |Pad 40 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 28|R/W|PAD_3_OUT |Pad 40 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 29|R/W|PAD_3_OEN |Pad 40 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_PAD_CFG2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+--------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==============================================================+ + | 0|R/W|PAD_0_PULL_DOWN|0x0 |Pad 37 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x0 |Pad 37 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |3:2 |R/W|PAD_0_DRIVE |0x0 |Pad 37 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 4|R/W|PAD_0_OUT |0x0 |Pad 37 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 5|R/W|PAD_0_OEN |0x1 |Pad 37 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 8|R/W|PAD_1_PULL_DOWN|0x0 |Pad 38 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 9|R/W|PAD_1_PULL_UP |0x0 |Pad 38 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |11:10|R/W|PAD_1_DRIVE |0x0 |Pad 38 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 12|R/W|PAD_1_OUT |0x0 |Pad 38 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 13|R/W|PAD_1_OEN |0x1 |Pad 38 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 16|R/W|PAD_2_PULL_DOWN|0x0 |Pad 39 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 17|R/W|PAD_2_PULL_UP |0x0 |Pad 39 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |19:18|R/W|PAD_2_DRIVE |0x0 |Pad 39 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 20|R/W|PAD_2_OUT |0x0 |Pad 39 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 21|R/W|PAD_2_OEN |0x1 |Pad 39 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 24|R/W|PAD_3_PULL_DOWN|0x0 |Pad 40 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 25|R/W|PAD_3_PULL_UP |0x0 |Pad 40 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |27:26|R/W|PAD_3_DRIVE |0x0 |Pad 40 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 28|R/W|PAD_3_OUT |0x0 |Pad 40 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 29|R/W|PAD_3_OEN |0x1 |Pad 40 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_PAD_CFG2: SLEEP_PAD_CFG2 """""""""""""" @@ -2351,52 +2452,54 @@ SLEEP_PAD_CFG2 Sleep pad control .. table:: - - +-----+---+---------------+--------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==============================================================+ - | 0|R/W|PAD_0_PULL_DOWN|Pad 41 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 1|R/W|PAD_0_PULL_UP |Pad 41 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |3:2 |R/W|PAD_0_DRIVE |Pad 41 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 4|R/W|PAD_0_OUT |Pad 41 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 5|R/W|PAD_0_OEN |Pad 41 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 8|R/W|PAD_1_PULL_DOWN|Pad 42 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 9|R/W|PAD_1_PULL_UP |Pad 42 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |11:10|R/W|PAD_1_DRIVE |Pad 42 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 12|R/W|PAD_1_OUT |Pad 42 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 13|R/W|PAD_1_OEN |Pad 42 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 16|R/W|PAD_2_PULL_DOWN|Pad 43 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 17|R/W|PAD_2_PULL_UP |Pad 43 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |19:18|R/W|PAD_2_DRIVE |Pad 43 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 20|R/W|PAD_2_OUT |Pad 43 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 21|R/W|PAD_2_OEN |Pad 43 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 24|R/W|PAD_3_PULL_DOWN|Pad 65 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 25|R/W|PAD_3_PULL_UP |Pad 65 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |27:26|R/W|PAD_3_DRIVE |Pad 65 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 28|R/W|PAD_3_OUT |Pad 65 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 29|R/W|PAD_3_OEN |Pad 65 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_PAD_CFG3: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+--------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==============================================================+ + | 0|R/W|PAD_0_PULL_DOWN|0x0 |Pad 41 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x0 |Pad 41 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |3:2 |R/W|PAD_0_DRIVE |0x0 |Pad 41 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 4|R/W|PAD_0_OUT |0x0 |Pad 41 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 5|R/W|PAD_0_OEN |0x1 |Pad 41 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 8|R/W|PAD_1_PULL_DOWN|0x0 |Pad 42 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 9|R/W|PAD_1_PULL_UP |0x0 |Pad 42 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |11:10|R/W|PAD_1_DRIVE |0x0 |Pad 42 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 12|R/W|PAD_1_OUT |0x0 |Pad 42 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 13|R/W|PAD_1_OEN |0x1 |Pad 42 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 16|R/W|PAD_2_PULL_DOWN|0x0 |Pad 43 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 17|R/W|PAD_2_PULL_UP |0x0 |Pad 43 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |19:18|R/W|PAD_2_DRIVE |0x0 |Pad 43 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 20|R/W|PAD_2_OUT |0x0 |Pad 43 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 21|R/W|PAD_2_OEN |0x1 |Pad 43 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 24|R/W|PAD_3_PULL_DOWN|0x0 |Pad 65 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 25|R/W|PAD_3_PULL_UP |0x0 |Pad 65 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |27:26|R/W|PAD_3_DRIVE |0x0 |Pad 65 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 28|R/W|PAD_3_OUT |0x0 |Pad 65 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 29|R/W|PAD_3_OEN |0x1 |Pad 65 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_PAD_CFG3: SLEEP_PAD_CFG3 """""""""""""" @@ -2404,52 +2507,54 @@ SLEEP_PAD_CFG3 Sleep pad control .. table:: - - +-----+---+---------------+--------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==============================================================+ - | 0|R/W|PAD_0_PULL_DOWN|Pad 66 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 1|R/W|PAD_0_PULL_UP |Pad 66 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |3:2 |R/W|PAD_0_DRIVE |Pad 66 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 4|R/W|PAD_0_OUT |Pad 66 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 5|R/W|PAD_0_OEN |Pad 66 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 8|R/W|PAD_1_PULL_DOWN|Pad 67 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 9|R/W|PAD_1_PULL_UP |Pad 67 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |11:10|R/W|PAD_1_DRIVE |Pad 67 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 12|R/W|PAD_1_OUT |Pad 67 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 13|R/W|PAD_1_OEN |Pad 67 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 16|R/W|PAD_2_PULL_DOWN|Pad 68 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 17|R/W|PAD_2_PULL_UP |Pad 68 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |19:18|R/W|PAD_2_DRIVE |Pad 68 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 20|R/W|PAD_2_OUT |Pad 68 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 21|R/W|PAD_2_OEN |Pad 68 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 24|R/W|PAD_3_PULL_DOWN|Pad 69 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 25|R/W|PAD_3_PULL_UP |Pad 69 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |27:26|R/W|PAD_3_DRIVE |Pad 69 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 28|R/W|PAD_3_OUT |Pad 69 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 29|R/W|PAD_3_OEN |Pad 69 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_PAD_CFG4: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+--------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==============================================================+ + | 0|R/W|PAD_0_PULL_DOWN|0x0 |Pad 66 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x0 |Pad 66 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |3:2 |R/W|PAD_0_DRIVE |0x0 |Pad 66 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 4|R/W|PAD_0_OUT |0x0 |Pad 66 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 5|R/W|PAD_0_OEN |0x1 |Pad 66 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 8|R/W|PAD_1_PULL_DOWN|0x0 |Pad 67 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 9|R/W|PAD_1_PULL_UP |0x0 |Pad 67 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |11:10|R/W|PAD_1_DRIVE |0x0 |Pad 67 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 12|R/W|PAD_1_OUT |0x0 |Pad 67 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 13|R/W|PAD_1_OEN |0x1 |Pad 67 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 16|R/W|PAD_2_PULL_DOWN|0x0 |Pad 68 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 17|R/W|PAD_2_PULL_UP |0x0 |Pad 68 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |19:18|R/W|PAD_2_DRIVE |0x0 |Pad 68 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 20|R/W|PAD_2_OUT |0x0 |Pad 68 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 21|R/W|PAD_2_OEN |0x1 |Pad 68 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 24|R/W|PAD_3_PULL_DOWN|0x0 |Pad 69 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 25|R/W|PAD_3_PULL_UP |0x0 |Pad 69 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |27:26|R/W|PAD_3_DRIVE |0x0 |Pad 69 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 28|R/W|PAD_3_OUT |0x0 |Pad 69 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 29|R/W|PAD_3_OEN |0x1 |Pad 69 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_PAD_CFG4: SLEEP_PAD_CFG4 """""""""""""" @@ -2457,52 +2562,54 @@ SLEEP_PAD_CFG4 Sleep pad control .. table:: - - +-----+---+---------------+--------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==============================================================+ - | 0|R/W|PAD_0_PULL_DOWN|Pad 81 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 1|R/W|PAD_0_PULL_UP |Pad 81 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |3:2 |R/W|PAD_0_DRIVE |Pad 81 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 4|R/W|PAD_0_OUT |Pad 81 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 5|R/W|PAD_0_OEN |Pad 81 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 8|R/W|PAD_1_PULL_DOWN|Pad 82 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 9|R/W|PAD_1_PULL_UP |Pad 82 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |11:10|R/W|PAD_1_DRIVE |Pad 82 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 12|R/W|PAD_1_OUT |Pad 82 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 13|R/W|PAD_1_OEN |Pad 82 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 16|R/W|PAD_2_PULL_DOWN|Pad 83 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 17|R/W|PAD_2_PULL_UP |Pad 83 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |19:18|R/W|PAD_2_DRIVE |Pad 83 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 20|R/W|PAD_2_OUT |Pad 83 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 21|R/W|PAD_2_OEN |Pad 83 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 24|R/W|PAD_3_PULL_DOWN|Pad 84 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 25|R/W|PAD_3_PULL_UP |Pad 84 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |27:26|R/W|PAD_3_DRIVE |Pad 84 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 28|R/W|PAD_3_OUT |Pad 84 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 29|R/W|PAD_3_OEN |Pad 84 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_PAD_CFG5: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+--------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==============================================================+ + | 0|R/W|PAD_0_PULL_DOWN|0x0 |Pad 81 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x0 |Pad 81 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |3:2 |R/W|PAD_0_DRIVE |0x0 |Pad 81 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 4|R/W|PAD_0_OUT |0x0 |Pad 81 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 5|R/W|PAD_0_OEN |0x1 |Pad 81 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 8|R/W|PAD_1_PULL_DOWN|0x0 |Pad 82 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 9|R/W|PAD_1_PULL_UP |0x0 |Pad 82 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |11:10|R/W|PAD_1_DRIVE |0x0 |Pad 82 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 12|R/W|PAD_1_OUT |0x0 |Pad 82 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 13|R/W|PAD_1_OEN |0x1 |Pad 82 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 16|R/W|PAD_2_PULL_DOWN|0x0 |Pad 83 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 17|R/W|PAD_2_PULL_UP |0x0 |Pad 83 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |19:18|R/W|PAD_2_DRIVE |0x0 |Pad 83 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 20|R/W|PAD_2_OUT |0x0 |Pad 83 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 21|R/W|PAD_2_OEN |0x1 |Pad 83 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 24|R/W|PAD_3_PULL_DOWN|0x0 |Pad 84 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 25|R/W|PAD_3_PULL_UP |0x0 |Pad 84 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |27:26|R/W|PAD_3_DRIVE |0x0 |Pad 84 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 28|R/W|PAD_3_OUT |0x0 |Pad 84 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 29|R/W|PAD_3_OEN |0x1 |Pad 84 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_PAD_CFG5: SLEEP_PAD_CFG5 """""""""""""" @@ -2510,52 +2617,54 @@ SLEEP_PAD_CFG5 Sleep pad control .. table:: - - +-----+---+---------------+--------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==============================================================+ - | 0|R/W|PAD_0_PULL_DOWN|Pad 85 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 1|R/W|PAD_0_PULL_UP |Pad 85 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |3:2 |R/W|PAD_0_DRIVE |Pad 85 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 4|R/W|PAD_0_OUT |Pad 85 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 5|R/W|PAD_0_OEN |Pad 85 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 8|R/W|PAD_1_PULL_DOWN|Pad 86 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 9|R/W|PAD_1_PULL_UP |Pad 86 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |11:10|R/W|PAD_1_DRIVE |Pad 86 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 12|R/W|PAD_1_OUT |Pad 86 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 13|R/W|PAD_1_OEN |Pad 86 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 16|R/W|PAD_2_PULL_DOWN|Pad 87 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 17|R/W|PAD_2_PULL_UP |Pad 87 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |19:18|R/W|PAD_2_DRIVE |Pad 87 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 20|R/W|PAD_2_OUT |Pad 87 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 21|R/W|PAD_2_OEN |Pad 87 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 24|R/W|PAD_3_PULL_DOWN|Pad 88 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 25|R/W|PAD_3_PULL_UP |Pad 88 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |27:26|R/W|PAD_3_DRIVE |Pad 88 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 28|R/W|PAD_3_OUT |Pad 88 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 29|R/W|PAD_3_OEN |Pad 88 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - -.. _apb_soc_ctrl_SLEEP_PAD_CFG6: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+--------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==============================================================+ + | 0|R/W|PAD_0_PULL_DOWN|0x0 |Pad 85 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x1 |Pad 85 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |3:2 |R/W|PAD_0_DRIVE |0x0 |Pad 85 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 4|R/W|PAD_0_OUT |0x0 |Pad 85 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 5|R/W|PAD_0_OEN |0x1 |Pad 85 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 8|R/W|PAD_1_PULL_DOWN|0x0 |Pad 86 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 9|R/W|PAD_1_PULL_UP |0x0 |Pad 86 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |11:10|R/W|PAD_1_DRIVE |0x0 |Pad 86 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 12|R/W|PAD_1_OUT |0x0 |Pad 86 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 13|R/W|PAD_1_OEN |0x1 |Pad 86 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 16|R/W|PAD_2_PULL_DOWN|0x0 |Pad 87 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 17|R/W|PAD_2_PULL_UP |0x0 |Pad 87 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |19:18|R/W|PAD_2_DRIVE |0x0 |Pad 87 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 20|R/W|PAD_2_OUT |0x0 |Pad 87 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 21|R/W|PAD_2_OEN |0x1 |Pad 87 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 24|R/W|PAD_3_PULL_DOWN|0x0 |Pad 88 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 25|R/W|PAD_3_PULL_UP |0x0 |Pad 88 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |27:26|R/W|PAD_3_DRIVE |0x0 |Pad 88 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 28|R/W|PAD_3_OUT |0x0 |Pad 88 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 29|R/W|PAD_3_OEN |0x1 |Pad 88 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + +.. _apb_soc_ctrl__SLEEP_PAD_CFG6: SLEEP_PAD_CFG6 """""""""""""" @@ -2563,50 +2672,62 @@ SLEEP_PAD_CFG6 Sleep pad control .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------------+--------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==============================================================+ - | 0|R/W|PAD_0_PULL_DOWN|Pad 89 pull-down enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 1|R/W|PAD_0_PULL_UP |Pad 89 pull-up enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - |3:2 |R/W|PAD_0_DRIVE |Pad 89 driver length in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ - | 4|R/W|PAD_0_OUT |Pad 89 output value when output is enabled in deep sleep mode.| - +-----+---+---------------+--------------------------------------------------------------+ - | 5|R/W|PAD_0_OEN |Pad 89 output enabled in deep sleep mode. | - +-----+---+---------------+--------------------------------------------------------------+ + +-----+---+---------------+-----+--------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==============================================================+ + | 0|R/W|PAD_0_PULL_DOWN|0x0 |Pad 89 pull-down enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 1|R/W|PAD_0_PULL_UP |0x0 |Pad 89 pull-up enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + |3:2 |R/W|PAD_0_DRIVE |0x0 |Pad 89 driver length in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 4|R/W|PAD_0_OUT |0x0 |Pad 89 output value when output is enabled in deep sleep mode.| + +-----+---+---------------+-----+--------------------------------------------------------------+ + | 5|R/W|PAD_0_OEN |0x1 |Pad 89 output enabled in deep sleep mode. | + +-----+---+---------------+-----+--------------------------------------------------------------+ -.. _apb_soc_ctrl_L2_CTRL_ACTIVE: +.. _apb_soc_ctrl__L2_CTRL_ACTIVE: L2_CTRL_ACTIVE """""""""""""" -Controls L2 power +Controls L2 power when SOC is powered on .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------------------+-----+------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===================+=====+========================================================================+ + |11:0 |R/W|INTLVD_L2_POWERGATE|0x0 |Force value of POWERGATE of INTERVLEAVED RAM banks when SOC domain is on| + +-----+---+-------------------+-----+------------------------------------------------------------------------+ + |27:16|R/W|INTLVD_L2_DEEPSLEEP|0x0 |Force value of DEEPSLEEP of INTERVLEAVED RAM banks when SOC domain is on| + +-----+---+-------------------+-----+------------------------------------------------------------------------+ -.. _apb_soc_ctrl_L2_PWR_ACTIVE: +.. _apb_soc_ctrl__L2_PWR_ACTIVE: L2_PWR_ACTIVE """"""""""""" -Controls L2 power +Controls L2 power when SOC is powered on .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===================+=====+=====================================================================================================================================+ + |11:0 |R/W|INTLVD_L2_SD_ARRAY |0x0 |Power switch control for memory array of INTERLEAVED banks when SOC domain is on (bit i=1 shuts down array supply for bank i) | + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------+ + |11:0 |R/W|INTLVD_L2_SD_PERIPH|0x0 |Power switch control for memory periphery of INTERLEAVED banks when SOC domain is on (bit i=1 shuts down periphery supply for bank i)| + +-----+---+-------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_NEVACFG: +.. _apb_soc_ctrl__NEVACFG: NEVACFG """"""" @@ -2614,28 +2735,30 @@ NEVACFG NEVA config .. table:: - - +-----+---+----------------+------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+================+======================================================+ - |4:0 |R/W|NEVA_IO_LS_TSEL |Max output current when switching on switchable I/Os | - +-----+---+----------------+------------------------------------------------------+ - |5 |R/W|NEVA_IO_LS_FORCE|Force NEVA switch status for switchable I/Os | - +-----+---+----------------+------------------------------------------------------+ - |6 |R/W|NEVA_IO_LS_EN |EN signal value for switchable I/Os in force mode | - +-----+---+----------------+------------------------------------------------------+ - |7 |R/W|NEVA_IO_LS_SD |SD signal value for switchable I/Os in force mode | - +-----+---+----------------+------------------------------------------------------+ - |12:8 |R/W|NEVA_IO_HS_TSEL |Max output current when switching on memory interfaces| - +-----+---+----------------+------------------------------------------------------+ - |13 |R/W|NEVA_IO_HS_FORCE|Force NEVA switch status for memory interfaces | - +-----+---+----------------+------------------------------------------------------+ - |14 |R/W|NEVA_IO_HS_EN |EN signal value for memory interfaces in force mode | - +-----+---+----------------+------------------------------------------------------+ - |15 |R/W|NEVA_IO_HS_SD |SD signal value for memory interfaces in force mode | - +-----+---+----------------+------------------------------------------------------+ - -.. _apb_soc_ctrl_TRCCFG: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------+-----+------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+================+=====+======================================================+ + |4:0 |R/W|NEVA_IO_LS_TSEL |0x1F |Max output current when switching on switchable I/Os | + +-----+---+----------------+-----+------------------------------------------------------+ + |5 |R/W|NEVA_IO_LS_FORCE|0x0 |Force NEVA switch status for switchable I/Os | + +-----+---+----------------+-----+------------------------------------------------------+ + |6 |R/W|NEVA_IO_LS_EN |0x0 |EN signal value for switchable I/Os in force mode | + +-----+---+----------------+-----+------------------------------------------------------+ + |7 |R/W|NEVA_IO_LS_SD |0x0 |SD signal value for switchable I/Os in force mode | + +-----+---+----------------+-----+------------------------------------------------------+ + |12:8 |R/W|NEVA_IO_HS_TSEL |0x1F |Max output current when switching on memory interfaces| + +-----+---+----------------+-----+------------------------------------------------------+ + |13 |R/W|NEVA_IO_HS_FORCE|0x0 |Force NEVA switch status for memory interfaces | + +-----+---+----------------+-----+------------------------------------------------------+ + |14 |R/W|NEVA_IO_HS_EN |0x0 |EN signal value for memory interfaces in force mode | + +-----+---+----------------+-----+------------------------------------------------------+ + |15 |R/W|NEVA_IO_HS_SD |0x0 |SD signal value for memory interfaces in force mode | + +-----+---+----------------+-----+------------------------------------------------------+ + +.. _apb_soc_ctrl__TRCCFG: TRCCFG """""" @@ -2643,32 +2766,34 @@ TRCCFG TRC config .. table:: - - +-----+---+-----------------+--------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=================+========================================================+ - |1:0 |R/W|CSI2_PROGDELAY |CSI2 domain power switch controller PROGDELAY setting | - +-----+---+-----------------+--------------------------------------------------------+ - |4:2 |R/W|CSI2_CURRSET |CSI2 domain power switch controller CURRSET setting | - +-----+---+-----------------+--------------------------------------------------------+ - |6:5 |R/W|MRAM_PROGDELAY |MRAM domain power switch controller PROGDELAY setting | - +-----+---+-----------------+--------------------------------------------------------+ - |9:7 |R/W|MRAM_CURRSET |MRAM domain power switch controller CURRSET setting | - +-----+---+-----------------+--------------------------------------------------------+ - |11:10|R/W|SOC_PROGDELAY |SOC domain power switch controller PROGDELAY setting | - +-----+---+-----------------+--------------------------------------------------------+ - |14:12|R/W|SOC_CURRSET |SOC domain power switch controller CURRSET setting | - +-----+---+-----------------+--------------------------------------------------------+ - |16:15|R/W|CLUSTER_PROGDELAY|CLUSTER domain power switch controller PROGDELAY setting| - +-----+---+-----------------+--------------------------------------------------------+ - |19:17|R/W|CLUSTER_CURRSET |CLUSTER domain power switch controller CURRSET setting | - +-----+---+-----------------+--------------------------------------------------------+ - |21:20|R/W|SFU_PROGDELAY |SFU domain power switch controller PROGDELAY setting | - +-----+---+-----------------+--------------------------------------------------------+ - |24:22|R/W|SFU_CURRSET |SFU domain power switch controller CURRSET setting | - +-----+---+-----------------+--------------------------------------------------------+ - -.. _apb_soc_ctrl_RWM_L2_MEM: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------------+-----+--------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=================+=====+========================================================+ + |1:0 |R/W|CSI2_PROGDELAY |0x0 |CSI2 domain power switch controller PROGDELAY setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |4:2 |R/W|CSI2_CURRSET |0x7 |CSI2 domain power switch controller CURRSET setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |6:5 |R/W|MRAM_PROGDELAY |0x0 |MRAM domain power switch controller PROGDELAY setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |9:7 |R/W|MRAM_CURRSET |0x7 |MRAM domain power switch controller CURRSET setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |11:10|R/W|SOC_PROGDELAY |0x0 |SOC domain power switch controller PROGDELAY setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |14:12|R/W|SOC_CURRSET |0x7 |SOC domain power switch controller CURRSET setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |16:15|R/W|CLUSTER_PROGDELAY|0x0 |CLUSTER domain power switch controller PROGDELAY setting| + +-----+---+-----------------+-----+--------------------------------------------------------+ + |19:17|R/W|CLUSTER_CURRSET |0x7 |CLUSTER domain power switch controller CURRSET setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |21:20|R/W|SFU_PROGDELAY |0x0 |SFU domain power switch controller PROGDELAY setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + |24:22|R/W|SFU_CURRSET |0x7 |SFU domain power switch controller CURRSET setting | + +-----+---+-----------------+-----+--------------------------------------------------------+ + +.. _apb_soc_ctrl__RWM_L2_MEM: RWM_L2_MEM """""""""" @@ -2676,24 +2801,26 @@ RWM_L2_MEM Read/write margins for L2 and ROM memories .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------------+-----------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===========================================================+ - |5:0 |R/W|RWM_L2_INTLVD |Margin setting for L2 interleaved banks | - +-----+---+--------------+-----------------------------------------------------------+ - |13:8 |R/W|RWM_L2_PRIVATE|Margin setting for L2 private banks | - +-----+---+--------------+-----------------------------------------------------------+ - |16 |R/W|RWM_L2_FORCE |0 - use default RWM values, 1 - use RWML2* values | - +-----+---+--------------+-----------------------------------------------------------+ - |21:20|R/W|RWM_ROM_SAWL |SAWL margin setting for ROM | - +-----+---+--------------+-----------------------------------------------------------+ - |22 |R/W|RWM_ROM_WL |WL margin setting for ROM | - +-----+---+--------------+-----------------------------------------------------------+ - |24 |R/W|RWM_ROM_FORCE |0 - use default RWM values, 1 - use RWMROM* values| - +-----+---+--------------+-----------------------------------------------------------+ + +-----+---+--------------+-----+--------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+==================================================+ + |5:0 |R/W|RWM_L2_INTLVD |0x20 |Margin setting for L2 interleaved banks | + +-----+---+--------------+-----+--------------------------------------------------+ + |13:8 |R/W|RWM_L2_PRIVATE|0x20 |Margin setting for L2 private banks | + +-----+---+--------------+-----+--------------------------------------------------+ + |16 |R/W|RWM_L2_FORCE |0x0 |0: use default RWM values, 1: use RWM_L2_* values | + +-----+---+--------------+-----+--------------------------------------------------+ + |21:20|R/W|RWM_ROM_SAWL |0x2 |SAWL margin setting for ROM | + +-----+---+--------------+-----+--------------------------------------------------+ + |22 |R/W|RWM_ROM_WL |0x0 |WL margin setting for ROM | + +-----+---+--------------+-----+--------------------------------------------------+ + |24 |R/W|RWM_ROM_FORCE |0x1 |0: use default RWM values, 1: use RWM_ROM_* values| + +-----+---+--------------+-----+--------------------------------------------------+ -.. _apb_soc_ctrl_CLU_SW_RSTN: +.. _apb_soc_ctrl__CLU_SW_RSTN: CLU_SW_RSTN """"""""""" @@ -2701,48 +2828,54 @@ CLU_SW_RSTN Cluster software reset .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+===================================+ - | 0|R/W|CLUSTER_RSTN|Cluster software reset (active low)| - +-----+---+------------+-----------------------------------+ + +-----+---+------------+-----+-----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===================================+ + | 0|R/W|CLUSTER_RSTN|0x1 |Cluster software reset (active low)| + +-----+---+------------+-----+-----------------------------------+ -.. _apb_soc_ctrl_L2_PWR: +.. _apb_soc_ctrl__L2_PWR: L2_PWR """""" -Controls L2 power +Controls L2 power when SOC is off (deepsleep) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------+------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+======================================================+ - |13:0 |R/W|L2_MEM_RET |L2 retention control for private and interleaved banks| - +-----+---+-----------+------------------------------------------------------+ - |27:16|R/W|L2_MEM_PDWN|L2 power control for interleaved banks | - +-----+---+-----------+------------------------------------------------------+ + +-----+---+-------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===================+=====+======================================================================================================================================+ + |11:0 |R/W|INTLVD_L2_SD_ARRAY |0x0 |Power switch control for memory array of INTERLEAVED banks when chip is in retentive mode (bit i=1 shuts down array supply for bank i)| + +-----+---+-------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ + |1:0 |R/W|PRIVATE_L2_SD_ARRAY|0x0 |Power switch control for memory array of PRIVATE banks when chip is in retentive mode (bit i=1 shuts down array supply for bank i) | + +-----+---+-------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_L2_CTRL: +.. _apb_soc_ctrl__L2_CTRL: L2_CTRL """"""" -Controls L2 power +Controls L2 power when SOC is off (deepsleep) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------------+-------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+================+=======================================================+ - |13:0 |R/W|L2_MEM_POWERGATE|L2 power gate control for private and interleaved banks| - +-----+---+----------------+-------------------------------------------------------+ - |27:16|R/W|L2_MEM_DEEPSLEEP|L2 deep sleep for interleaved banks | - +-----+---+----------------+-------------------------------------------------------+ + +-----+---+-------------------+-----+---------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===================+=====+===========================================================================================================================+ + |11:0 |R/W|INTLVD_L2_DEEPSLEEP|0x0 |Force INTERLEAVED banks into deepsleep (data is lost) when chip is in retentive mode (bit i=1 enables deepsleep for bank i)| + +-----+---+-------------------+-----+---------------------------------------------------------------------------------------------------------------------------+ + |13:12|R/W|PRI_L2_DEEPSLEEP |0x0 |Force PRIVATE banks into deepsleep (data is lost) when chip is in retentive mode (bit i=1 enables deepsleep for bank i) | + +-----+---+-------------------+-----+---------------------------------------------------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_BORCFG: +.. _apb_soc_ctrl__BORCFG: BORCFG """""" @@ -2750,16 +2883,18 @@ BORCFG Controls the brown-out reset .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------+---------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+=================================================================================+ - | 0|R/W|BOR_ENABLE|Set to 1 to enable BOR monitoring of power supply | - +-----+---+----------+---------------------------------------------------------------------------------+ - |5:1 |R/W|BOR_VSEL |Threshold of detection of power supply drops. Recommended values: 00100 or 00011.| - +-----+---+----------+---------------------------------------------------------------------------------+ + +-----+---+----------+-----+---------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+=================================================================================+ + | 0|R/W|BOR_ENABLE|0x0 |Set to 1 to enable BOR monitoring of power supply | + +-----+---+----------+-----+---------------------------------------------------------------------------------+ + |5:1 |R/W|BOR_VSEL |0x04 |Threshold of detection of power supply drops. Recommended values: 00100 or 00011.| + +-----+---+----------+-----+---------------------------------------------------------------------------------+ -.. _apb_soc_ctrl_RARMODE: +.. _apb_soc_ctrl__RARMODE: RARMODE """"""" @@ -2767,18 +2902,20 @@ RARMODE Controls configuration of the DC-DC modulation at low loads .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+===================================================================+ - | 0|R/W|ACTIVESKIPB |Enables standard DC-DC behavior (pulse-skipping off, decimation on)| - +-----+---+-------------+-------------------------------------------------------------------+ - | 1|R/W|EN_DECIM_SKIP|Enables decimation when in pulse-skipping mode | - +-----+---+-------------+-------------------------------------------------------------------+ - | 2|R/W|DISABLE_VREF |Disable generation of 0.6V Vref to save power if eMRAM is not used | - +-----+---+-------------+-------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+===================================================================+ + | 0|R/W|ACTIVESKIPB |0x0 |Enables standard DC-DC behavior (pulse-skipping off, decimation on)| + +-----+---+-------------+-----+-------------------------------------------------------------------+ + | 1|R/W|EN_DECIM_SKIP|0x0 |Enables decimation when in pulse-skipping mode | + +-----+---+-------------+-----+-------------------------------------------------------------------+ + | 2|R/W|DISABLE_VREF |0x0 |Disable generation of 0.6V Vref to save power if eMRAM is not used | + +-----+---+-------------+-----+-------------------------------------------------------------------+ -.. _apb_soc_ctrl_ABBCFG: +.. _apb_soc_ctrl__ABBCFG: ABBCFG """""" @@ -2786,16 +2923,18 @@ ABBCFG Used to disable adaptive body-bias .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------------+--------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===================+==========================+ - | 0|R/W|SOC_ABB_DISABLE |Disable SOC domain ABB | - +-----+---+-------------------+--------------------------+ - | 1|R/W|CLUSTER_ABB_DISABLE|Disable CLUSTER domain ABB| - +-----+---+-------------------+--------------------------+ + +-----+---+-------------------+-----+--------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===================+=====+==========================+ + | 0|R/W|SOC_ABB_DISABLE |0x0 |Disable SOC domain ABB | + +-----+---+-------------------+-----+--------------------------+ + | 1|R/W|CLUSTER_ABB_DISABLE|0x0 |Disable CLUSTER domain ABB| + +-----+---+-------------------+-----+--------------------------+ -.. _apb_soc_ctrl_L2_ACK: +.. _apb_soc_ctrl__L2_ACK: L2_ACK """""" @@ -2803,13 +2942,15 @@ L2_ACK Acknowledge/status signals from L2 memories .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------------------+----------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+==========================================================+ - |11:0 |R |INTLVD_ARRAY_WAKE_ACK |Wake status of the arrays of interleaved L2 banks | - +-----+---+----------------------+----------------------------------------------------------+ - |27:16|R |INTLVD_PERIPH_WAKE_ACK|Wake status of the periphery logic of interleaved L2 banks| - +-----+---+----------------------+----------------------------------------------------------+ - |31:30|R |PRIVATE_ARRAY_WAKE_ACK|Wake status of the arrays of private L2 banks | - +-----+---+----------------------+----------------------------------------------------------+ + +-----+---+----------------------+-----+----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+==========================================================+ + |11:0 |R |INTLVD_ARRAY_WAKE_ACK |0x0 |Wake status of the arrays of interleaved L2 banks | + +-----+---+----------------------+-----+----------------------------------------------------------+ + |27:16|R |INTLVD_PERIPH_WAKE_ACK|0x0 |Wake status of the periphery logic of interleaved L2 banks| + +-----+---+----------------------+-----+----------------------------------------------------------+ + |31:30|R |PRIVATE_ARRAY_WAKE_ACK|0x0 |Wake status of the arrays of private L2 banks | + +-----+---+----------------------+-----+----------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/cl_dma.rst b/rtos/pulp/gap_archi/doc/ips/cl_dma.rst index 587cd7d69..1042b5b0b 100644 --- a/rtos/pulp/gap_archi/doc/ips/cl_dma.rst +++ b/rtos/pulp/gap_archi/doc/ips/cl_dma.rst @@ -8,40 +8,214 @@ Register map Overview """""""" + +Refer to :ref:`GAP9 address map` for the base address to be used. + .. table:: + :align: center + :widths: 40 12 12 90 - +----------------------------+------+-----+-----------------------------------+ - | Name |Offset|Width| Description | - +============================+======+=====+===================================+ - |:ref:`CMD` | 0| 32|Cluster DMA configuration register.| - +----------------------------+------+-----+-----------------------------------+ - |:ref:`STATUS`| 4| 32|Cluster DMA status register. | - +----------------------------+------+-----+-----------------------------------+ + +-----------------------------+------+-----+----------------------------------+ + | Name |Offset|Width| Description | + +=============================+======+=====+==================================+ + |:ref:`CMD` | 0| 32|Cluster DMA configuration register| + +-----------------------------+------+-----+----------------------------------+ + |:ref:`STATUS`| 4| 32|Cluster DMA status register | + +-----------------------------+------+-----+----------------------------------+ -.. _cl_dma_CMD: +.. _cl_dma__CMD: CMD """ -Cluster DMA configuration register. +Cluster DMA configuration register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+------+------------------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+=======+======+==========================================+ + |31:0 |R/W|COMMAND|0x0000|DMA command -- Format is command-dependent| + +-----+---+-------+------+------------------------------------------+ -.. _cl_dma_STATUS: +.. _cl_dma__STATUS: STATUS """""" -Cluster DMA status register. +Cluster DMA status register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+------+------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+=========+======+======================================================================================================+ + |15:0 |R/W|TID_TR |0x0000|When read, bit=1 means that transfer with TID i is active. Write 1 to cancel/free transfer with TID i.| + +-----+---+---------+------+------------------------------------------------------------------------------------------------------+ + |31:16|R |TID_ALLOC|0x0000|Bit 16+i is read as 1 if when transfer allocator with TID i is reserved, else it is free. | + +-----+---+---------+------+------------------------------------------------------------------------------------------------------+ + +DMA commands encoding +^^^^^^^^^^^^^^^^^^^^^ + +.. table:: + :align: center + :widths: 45 15 15 80 + + +------------------------------------------------------+-----+------------+---------------------------------------------------------------------------------------------------+ + | Command name |Width|Command code| Description | + +======================================================+=====+============+===================================================================================================+ + |:ref:`GET_TID` | 32|N/A |(Triggered by reading CMD register before configuring a transfer) Get transfer identifier. | + +------------------------------------------------------+-----+------------+---------------------------------------------------------------------------------------------------+ + |:ref:`NEW_TRANS` | 32|N/A |Start to configure a new transfer. | + +------------------------------------------------------+-----+------------+---------------------------------------------------------------------------------------------------+ + |:ref:`TCDM_ADDR` | 32|N/A |Configure TCDM address of the transfer. | + +------------------------------------------------------+-----+------------+---------------------------------------------------------------------------------------------------+ + |:ref:`L2_ADDR` | 32|N/A |Configure L2 address of the transfer. | + +------------------------------------------------------+-----+------------+---------------------------------------------------------------------------------------------------+ + |:ref:`L2_COUNT` | 32|N/A |For a 2D transfer on L2 side, configure the length of the linear chucks of data for the transfer. | + +------------------------------------------------------+-----+------------+---------------------------------------------------------------------------------------------------+ + |:ref:`L2_STRIDE` | 32|N/A |For a 2D transfer on L2 side, configure the stride of the transfer. | + +------------------------------------------------------+-----+------------+---------------------------------------------------------------------------------------------------+ + |:ref:`TCDM_COUNT` | 32|N/A |For a 2D transfer on TCDM side, configure the length of the linear chucks of data for the transfer.| + +------------------------------------------------------+-----+------------+---------------------------------------------------------------------------------------------------+ + |:ref:`TCDM_STRIDE`| 32|N/A |For a 2D transfer on TCDM side, configure the stride of the transfer. | + +------------------------------------------------------+-----+------------+---------------------------------------------------------------------------------------------------+ + +.. _DMA commands encoding__GET_TID: + +GET_TID +""""""" + +.. table:: + :align: center + :widths: 15 45 90 + + +-----+----+---------------------------------+ + |Bit #|Name| Description | + +=====+====+=================================+ + |3:0 |TID |Value of the transfer identifier.| + +-----+----+---------------------------------+ + +.. _DMA commands encoding__NEW_TRANS: + +NEW_TRANS +""""""""" + +.. table:: + :align: center + :widths: 15 45 90 + + +-----+-------+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #| Name | Description | + +=====+=======+====================================================================================================================================================+ + |16:0 |LEN |Transfer length in bytes. | + +-----+-------+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |17 |TYPE |Transfer direction: b0: TCDM to L2; b1: L2 to TCDM. | + +-----+-------+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |18 |INC |Set to 1 to configure an incremental transfer. | + +-----+-------+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |19 |L2_2D |Transfer type on L2 side: b0: linear; b1: 2D transfer. | + +-----+-------+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |20 |ELE |Set to 1 to enable event generation for the transfer. | + +-----+-------+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |21 |ILE |Set to 1 to enable interrupt generation for the transfer. | + +-----+-------+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |22 |BLE |Set to 1 to broadcast event and interrupts to all cluster cores. If 0, events and interrupts are only sent to the core which initiated the transfer.| + +-----+-------+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |23 |TCDM_2D|Transfer type on TCDM side: b0: linear; b1: 2D transfer. | + +-----+-------+----------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _DMA commands encoding__TCDM_ADDR: + +TCDM_ADDR +""""""""" + +.. table:: + :align: center + :widths: 15 45 90 + + +-----+----+-----------------------------------+ + |Bit #|Name| Description | + +=====+====+===================================+ + |31:0 |ADDR|TCDM base address for the transfer.| + +-----+----+-----------------------------------+ + +.. _DMA commands encoding__L2_ADDR: + +L2_ADDR +""""""" + +.. table:: + :align: center + :widths: 15 45 90 + + +-----+----+---------------------------------+ + |Bit #|Name| Description | + +=====+====+=================================+ + |31:0 |ADDR|L2 base address for the transfer.| + +-----+----+---------------------------------+ + +.. _DMA commands encoding__L2_COUNT: + +L2_COUNT +"""""""" + +.. table:: + :align: center + :widths: 15 45 90 + + +-----+------+-----------------------------------------+ + |Bit #| Name | Description | + +=====+======+=========================================+ + |31:0 |2D_CNT|Length of a linear part of a 2D transfer.| + +-----+------+-----------------------------------------+ + +.. _DMA commands encoding__L2_STRIDE: + +L2_STRIDE +""""""""" + +.. table:: + :align: center + :widths: 15 45 90 + + +-----+---------+------------------------------------------------------------------------------------+ + |Bit #| Name | Description | + +=====+=========+====================================================================================+ + |31:0 |2D_STRIDE|Length of a stride of a 2D transfer (i.e. from a linear chunck of data to the next).| + +-----+---------+------------------------------------------------------------------------------------+ + +.. _DMA commands encoding__TCDM_COUNT: + +TCDM_COUNT +"""""""""" + +.. table:: + :align: center + :widths: 15 45 90 + + +-----+------+-----------------------------------------+ + |Bit #| Name | Description | + +=====+======+=========================================+ + |31:0 |2D_CNT|Length of a linear part of a 2D transfer.| + +-----+------+-----------------------------------------+ + +.. _DMA commands encoding__TCDM_STRIDE: + +TCDM_STRIDE +""""""""""" .. table:: + :align: center + :widths: 15 45 90 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---------+------------------------------------------------------------------------------------+ + |Bit #| Name | Description | + +=====+=========+====================================================================================+ + |31:0 |2D_STRIDE|Length of a stride of a 2D transfer (i.e. from a linear chunck of data to the next).| + +-----+---------+------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/cluster_ctrl_unit.rst b/rtos/pulp/gap_archi/doc/ips/cluster_ctrl_unit.rst index dfc43479b..80ee33c28 100644 --- a/rtos/pulp/gap_archi/doc/ips/cluster_ctrl_unit.rst +++ b/rtos/pulp/gap_archi/doc/ips/cluster_ctrl_unit.rst @@ -8,49 +8,54 @@ Register map Overview """""""" -.. table:: - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +=========================================================================+======+=====+=====================================================================+ - |:ref:`EOC` | 0| 32|End Of Computation status register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`FETCH_EN` | 8| 32|Cluster cores fetch enable configuration register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`CLOCK_GATE` | 32| 32|Cluster clock gate configuration register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`DBG_RESUME` | 40| 32|Cluster cores debug resume register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`DBG_HALT_STATUS` | 40| 32|Cluster cores debug halt status register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`DBG_HALT_MASK` | 56| 32|Cluster cores debug halt mask configuration register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`BOOT_ADDR0` | 64| 32|Cluster core 0 boot address configuration register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`BOOT_ADDR1` | 68| 32|Cluster core 1 boot address configuration register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`BOOT_ADDR2` | 72| 32|Cluster core 2 boot address configuration register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`BOOT_ADDR3` | 76| 32|Cluster core 3 boot address configuration register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`BOOT_ADDR4` | 80| 32|Cluster core 4 boot address configuration register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`BOOT_ADDR5` | 84| 32|Cluster core 5 boot address configuration register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`BOOT_ADDR6` | 88| 32|Cluster core 6 boot address configuration register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`BOOT_ADDR7` | 92| 32|Cluster core 7 boot address configuration register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`TCDM_ARB_POLICY_CH0` | 128| 32|TCDM arbitration policy ch0 for cluster cores configuration register.| - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`TCDM_ARB_POLICY_CH1` | 136| 32|TCDM arbitration policy ch1 for DMA/HWCE configuration register. | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`TCDM_ARB_POLICY_CH0_REP`| 192| 32|Read only duplicate of TCDM_ARB_POLICY_CH0 register | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - |:ref:`TCDM_ARB_POLICY_CH1_REP`| 200| 32|Read only duplicate of TCDM_ARB_POLICY_CH1 register | - +-------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ - -.. _cluster_ctrl_unit_EOC: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +==========================================================================+======+=====+=====================================================================+ + |:ref:`EOC` | 0| 32|End Of Computation status register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`FETCH_EN` | 8| 32|Cluster cores fetch enable configuration register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`CLOCK_GATE` | 32| 32|Cluster clock gate configuration register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`DBG_RESUME` | 40| 32|Cluster cores debug resume register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`DBG_HALT_STATUS` | 40| 32|Cluster cores debug halt status register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`DBG_HALT_MASK` | 56| 32|Cluster cores debug halt mask configuration register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`BOOT_ADDR0` | 64| 32|Cluster core 0 boot address configuration register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`BOOT_ADDR1` | 68| 32|Cluster core 1 boot address configuration register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`BOOT_ADDR2` | 72| 32|Cluster core 2 boot address configuration register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`BOOT_ADDR3` | 76| 32|Cluster core 3 boot address configuration register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`BOOT_ADDR4` | 80| 32|Cluster core 4 boot address configuration register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`BOOT_ADDR5` | 84| 32|Cluster core 5 boot address configuration register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`BOOT_ADDR6` | 88| 32|Cluster core 6 boot address configuration register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`BOOT_ADDR7` | 92| 32|Cluster core 7 boot address configuration register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`TCDM_ARB_POLICY_CH0` | 128| 32|TCDM arbitration policy ch0 for cluster cores configuration register.| + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`TCDM_ARB_POLICY_CH1` | 136| 32|TCDM arbitration policy ch1 for DMA/HWCE configuration register. | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`TCDM_ARB_POLICY_CH0_REP`| 192| 32|Read only duplicate of TCDM_ARB_POLICY_CH0 register | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + |:ref:`TCDM_ARB_POLICY_CH1_REP`| 200| 32|Read only duplicate of TCDM_ARB_POLICY_CH1 register | + +--------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------+ + +.. _cluster_ctrl_unit__EOC: EOC """ @@ -58,13 +63,16 @@ EOC End Of Computation status register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================+ + | 0|R/W|EOC |0x0 |End of computation status flag: b0: program execution ongoing; b1: end of computation reached| + +-----+---+----+-----+---------------------------------------------------------------------------------------------+ -.. _cluster_ctrl_unit_FETCH_EN: +.. _cluster_ctrl_unit__FETCH_EN: FETCH_EN """""""" @@ -72,13 +80,30 @@ FETCH_EN Cluster cores fetch enable configuration register. .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _cluster_ctrl_unit_CLOCK_GATE: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+----------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+==============================================+ + | 0|R/W|CORE0|0x0 |Core 0 fetch enable: b0: disabled; b1: enabled| + +-----+---+-----+-----+----------------------------------------------+ + | 1|R/W|CORE1|0x0 |Core 1 fetch enable: b0: disabled; b1: enabled| + +-----+---+-----+-----+----------------------------------------------+ + | 2|R/W|CORE2|0x0 |Core 2 fetch enable: b0: disabled; b1: enabled| + +-----+---+-----+-----+----------------------------------------------+ + | 3|R/W|CORE3|0x0 |Core 3 fetch enable: b0: disabled; b1: enabled| + +-----+---+-----+-----+----------------------------------------------+ + | 4|R/W|CORE4|0x0 |Core 4 fetch enable: b0: disabled; b1: enabled| + +-----+---+-----+-----+----------------------------------------------+ + | 5|R/W|CORE5|0x0 |Core 5 fetch enable: b0: disabled; b1: enabled| + +-----+---+-----+-----+----------------------------------------------+ + | 6|R/W|CORE6|0x0 |Core 6 fetch enable: b0: disabled; b1: enabled| + +-----+---+-----+-----+----------------------------------------------+ + | 7|R/W|CORE7|0x0 |Core 7 fetch enable: b0: disabled; b1: enabled| + +-----+---+-----+-----+----------------------------------------------+ + +.. _cluster_ctrl_unit__CLOCK_GATE: CLOCK_GATE """""""""" @@ -86,13 +111,16 @@ CLOCK_GATE Cluster clock gate configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+---------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================+ + | 0|R/W|EN |0x0 |Cluster clock gate: b0: disabled; b1: enabled| + +-----+---+----+-----+---------------------------------------------+ -.. _cluster_ctrl_unit_DBG_RESUME: +.. _cluster_ctrl_unit__DBG_RESUME: DBG_RESUME """""""""" @@ -100,13 +128,30 @@ DBG_RESUME Cluster cores debug resume register. .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _cluster_ctrl_unit_DBG_HALT_STATUS: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+--------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+====================================================================+ + | 0|W |CORE0|0x0 |Core 0 debug resume: b0: stay halted; b1: resume execution on core 0| + +-----+---+-----+-----+--------------------------------------------------------------------+ + | 1|W |CORE1|0x0 |Core 1 debug resume: b0: stay halted; b1: resume execution on core 1| + +-----+---+-----+-----+--------------------------------------------------------------------+ + | 2|W |CORE2|0x0 |Core 2 debug resume: b0: stay halted; b1: resume execution on core 2| + +-----+---+-----+-----+--------------------------------------------------------------------+ + | 3|W |CORE3|0x0 |Core 3 debug resume: b0: stay halted; b1: resume execution on core 3| + +-----+---+-----+-----+--------------------------------------------------------------------+ + | 4|W |CORE4|0x0 |Core 4 debug resume: b0: stay halted; b1: resume execution on core 4| + +-----+---+-----+-----+--------------------------------------------------------------------+ + | 5|W |CORE5|0x0 |Core 5 debug resume: b0: stay halted; b1: resume execution on core 5| + +-----+---+-----+-----+--------------------------------------------------------------------+ + | 6|W |CORE6|0x0 |Core 6 debug resume: b0: stay halted; b1: resume execution on core 6| + +-----+---+-----+-----+--------------------------------------------------------------------+ + | 7|W |CORE7|0x0 |Core 7 debug resume: b0: stay halted; b1: resume execution on core 7| + +-----+---+-----+-----+--------------------------------------------------------------------+ + +.. _cluster_ctrl_unit__DBG_HALT_STATUS: DBG_HALT_STATUS """"""""""""""" @@ -114,13 +159,30 @@ DBG_HALT_STATUS Cluster cores debug halt status register. .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _cluster_ctrl_unit_DBG_HALT_MASK: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+-------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=================================================+ + | 0|R |CORE0|0x0 |Core 0 debug halt status: b0: running; b1: halted| + +-----+---+-----+-----+-------------------------------------------------+ + | 1|R |CORE1|0x0 |Core 1 debug halt status: b0: running; b1: halted| + +-----+---+-----+-----+-------------------------------------------------+ + | 2|R |CORE2|0x0 |Core 2 debug halt status: b0: running; b1: halted| + +-----+---+-----+-----+-------------------------------------------------+ + | 3|R |CORE3|0x0 |Core 3 debug halt status: b0: running; b1: halted| + +-----+---+-----+-----+-------------------------------------------------+ + | 4|R |CORE4|0x0 |Core 4 debug halt status: b0: running; b1: halted| + +-----+---+-----+-----+-------------------------------------------------+ + | 5|R |CORE5|0x0 |Core 5 debug halt status: b0: running; b1: halted| + +-----+---+-----+-----+-------------------------------------------------+ + | 6|R |CORE6|0x0 |Core 6 debug halt status: b0: running; b1: halted| + +-----+---+-----+-----+-------------------------------------------------+ + | 7|R |CORE7|0x0 |Core 7 debug halt status: b0: running; b1: halted| + +-----+---+-----+-----+-------------------------------------------------+ + +.. _cluster_ctrl_unit__DBG_HALT_MASK: DBG_HALT_MASK """"""""""""" @@ -128,13 +190,30 @@ DBG_HALT_MASK Cluster cores debug halt mask configuration register. .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _cluster_ctrl_unit_BOOT_ADDR0: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================================================================================================================+ + | 0|R/W|CORE0|0x0 |Core 0 debug halt mask: when set, the core is part of the mask group and stops when one of the members of the group stops| + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|CORE1|0x0 |Core 1 debug halt mask: when set, the core is part of the mask group and stops when one of the members of the group stops| + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------------------+ + | 2|R/W|CORE2|0x0 |Core 2 debug halt mask: when set, the core is part of the mask group and stops when one of the members of the group stops| + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------------------+ + | 3|R/W|CORE3|0x0 |Core 3 debug halt mask: when set, the core is part of the mask group and stops when one of the members of the group stops| + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------------------+ + | 4|R/W|CORE4|0x0 |Core 4 debug halt mask: when set, the core is part of the mask group and stops when one of the members of the group stops| + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------------------+ + | 5|R/W|CORE5|0x0 |Core 5 debug halt mask: when set, the core is part of the mask group and stops when one of the members of the group stops| + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------------------+ + | 6|R/W|CORE6|0x0 |Core 6 debug halt mask: when set, the core is part of the mask group and stops when one of the members of the group stops| + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------------------+ + | 7|R/W|CORE7|0x0 |Core 7 debug halt mask: when set, the core is part of the mask group and stops when one of the members of the group stops| + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_ctrl_unit__BOOT_ADDR0: BOOT_ADDR0 """""""""" @@ -142,13 +221,16 @@ BOOT_ADDR0 Cluster core 0 boot address configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================================+ + |31:0 |R/W|BA |0x0 |Boot address for corresponding cluster core| + +-----+---+----+-----+-------------------------------------------+ -.. _cluster_ctrl_unit_BOOT_ADDR1: +.. _cluster_ctrl_unit__BOOT_ADDR1: BOOT_ADDR1 """""""""" @@ -156,13 +238,16 @@ BOOT_ADDR1 Cluster core 1 boot address configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================================+ + |31:0 |R/W|BA |0x0 |Boot address for corresponding cluster core| + +-----+---+----+-----+-------------------------------------------+ -.. _cluster_ctrl_unit_BOOT_ADDR2: +.. _cluster_ctrl_unit__BOOT_ADDR2: BOOT_ADDR2 """""""""" @@ -170,13 +255,16 @@ BOOT_ADDR2 Cluster core 2 boot address configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================================+ + |31:0 |R/W|BA |0x0 |Boot address for corresponding cluster core| + +-----+---+----+-----+-------------------------------------------+ -.. _cluster_ctrl_unit_BOOT_ADDR3: +.. _cluster_ctrl_unit__BOOT_ADDR3: BOOT_ADDR3 """""""""" @@ -184,13 +272,16 @@ BOOT_ADDR3 Cluster core 3 boot address configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================================+ + |31:0 |R/W|BA |0x0 |Boot address for corresponding cluster core| + +-----+---+----+-----+-------------------------------------------+ -.. _cluster_ctrl_unit_BOOT_ADDR4: +.. _cluster_ctrl_unit__BOOT_ADDR4: BOOT_ADDR4 """""""""" @@ -198,13 +289,16 @@ BOOT_ADDR4 Cluster core 4 boot address configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================================+ + |31:0 |R/W|BA |0x0 |Boot address for corresponding cluster core| + +-----+---+----+-----+-------------------------------------------+ -.. _cluster_ctrl_unit_BOOT_ADDR5: +.. _cluster_ctrl_unit__BOOT_ADDR5: BOOT_ADDR5 """""""""" @@ -212,13 +306,16 @@ BOOT_ADDR5 Cluster core 5 boot address configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================================+ + |31:0 |R/W|BA |0x0 |Boot address for corresponding cluster core| + +-----+---+----+-----+-------------------------------------------+ -.. _cluster_ctrl_unit_BOOT_ADDR6: +.. _cluster_ctrl_unit__BOOT_ADDR6: BOOT_ADDR6 """""""""" @@ -226,13 +323,16 @@ BOOT_ADDR6 Cluster core 6 boot address configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================================+ + |31:0 |R/W|BA |0x0 |Boot address for corresponding cluster core| + +-----+---+----+-----+-------------------------------------------+ -.. _cluster_ctrl_unit_BOOT_ADDR7: +.. _cluster_ctrl_unit__BOOT_ADDR7: BOOT_ADDR7 """""""""" @@ -240,13 +340,16 @@ BOOT_ADDR7 Cluster core 7 boot address configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================================+ + |31:0 |R/W|BA |0x0 |Boot address for corresponding cluster core| + +-----+---+----+-----+-------------------------------------------+ -.. _cluster_ctrl_unit_TCDM_ARB_POLICY_CH0: +.. _cluster_ctrl_unit__TCDM_ARB_POLICY_CH0: TCDM_ARB_POLICY_CH0 """"""""""""""""""" @@ -254,13 +357,16 @@ TCDM_ARB_POLICY_CH0 TCDM arbitration policy ch0 for cluster cores configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+--------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+================================================================================+ + | 0|R/W|POL |0x0 |TCDM arbitration policy for cluster cores: b0: fair round robin; b1: fixed order| + +-----+---+----+-----+--------------------------------------------------------------------------------+ -.. _cluster_ctrl_unit_TCDM_ARB_POLICY_CH1: +.. _cluster_ctrl_unit__TCDM_ARB_POLICY_CH1: TCDM_ARB_POLICY_CH1 """"""""""""""""""" @@ -268,13 +374,16 @@ TCDM_ARB_POLICY_CH1 TCDM arbitration policy ch1 for DMA/HWCE configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===============================================================================+ + | 0|R/W|POL |0x0 |TCDM arbitration policy for DMA and NE16: b0: fair round robin; b1: fixed order| + +-----+---+----+-----+-------------------------------------------------------------------------------+ -.. _cluster_ctrl_unit_TCDM_ARB_POLICY_CH0_REP: +.. _cluster_ctrl_unit__TCDM_ARB_POLICY_CH0_REP: TCDM_ARB_POLICY_CH0_REP """"""""""""""""""""""" @@ -282,13 +391,16 @@ TCDM_ARB_POLICY_CH0_REP Read only duplicate of TCDM_ARB_POLICY_CH0 register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+--------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+================================================================================+ + | 0|R |POL |0x0 |TCDM arbitration policy for cluster cores: b0: fair round robin; b1: fixed order| + +-----+---+----+-----+--------------------------------------------------------------------------------+ -.. _cluster_ctrl_unit_TCDM_ARB_POLICY_CH1_REP: +.. _cluster_ctrl_unit__TCDM_ARB_POLICY_CH1_REP: TCDM_ARB_POLICY_CH1_REP """"""""""""""""""""""" @@ -296,8 +408,11 @@ TCDM_ARB_POLICY_CH1_REP Read only duplicate of TCDM_ARB_POLICY_CH1 register .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+-------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===============================================================================+ + | 0|R |POL |0x0 |TCDM arbitration policy for DMA and NE16: b0: fair round robin; b1: fixed order| + +-----+---+----+-----+-------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_barrier.rst b/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_barrier.rst new file mode 100644 index 000000000..9347d35e9 --- /dev/null +++ b/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_barrier.rst @@ -0,0 +1,153 @@ +.. + Input file: docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_barrier.md + +Register map for hardware barriers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + +Overview +"""""""" + + +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-----------------------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +=========================================================================================+======+=====+=========================================================================================+ + |:ref:`HW_BARR_TRIGGER_MASK` | 0| 32|Trigger mask for HW barrier | + +-----------------------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------+ + |:ref:`HW_BARR_STATUS` | 4| 32|Current status of HW barrier | + +-----------------------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------+ + |:ref:`HW_BARR_TARGET_MASK` | 12| 32|Barrier target mask | + +-----------------------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------+ + |:ref:`HW_BARR_TRIGGER` | 16| 32|Trigger the HW barrier | + +-----------------------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------+ + |:ref:`HW_BARR_TRIGGER_SELF` | 20| 32|Self-trigger the HW barrier (only accessible from CL_EVENT_UNIT_DEMUX) | + +-----------------------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------+ + |:ref:`HW_BARR_TRIGGER_WAIT` | 24| 32|Self-trigger and go to sleep (only accessible from CL_EVENT_UNIT_DEMUX) | + +-----------------------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------+ + |:ref:`HW_BARR_TRIGGER_WAIT_CLEAR`| 28| 32|Self-trigger, go to sleep and clear on wake-up (only accessible from CL_EVENT_UNIT_DEMUX)| + +-----------------------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_barrier__HW_BARR_TRIGGER_MASK: + +HW_BARR_TRIGGER_MASK +"""""""""""""""""""" + +Trigger mask for HW barrier + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+============================================================================================================================================================================+ + |8:0 |R/W|MASK|0x000|Trigger mask for barrier to match: every bit set to b1 in MASK must be set in HW_BARR_STATUS for the barrier to be triggered. Writing all bits to b0 disables the HW barrier| + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_barrier__HW_BARR_STATUS: + +HW_BARR_STATUS +"""""""""""""" + +Current status of HW barrier + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=========================================================================================================================================================================================================================================+ + |8:0 |R |STATUS|0x000|Current status of the barrier: a bit reading as b1 means that the corresponding bit has already been triggered. This field is cleared to 0x000 when the barrier triggers, i.e. when status matches the mask value in HW_BARR_TRIGGER_MASK| + +-----+---+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_barrier__HW_BARR_TARGET_MASK: + +HW_BARR_TARGET_MASK +""""""""""""""""""" + +Barrier target mask + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=======================================================================================================================================================================================================================================+ + |8:0 |R |CORE_MASK|0x000|Target cores mask: once the HW barrier triggers, i.e. when HW_BARR_STATUS matches HW_BARR_TRIGGER_MASK, the event line corresponding to this barrier is asserted for all cores which have the corresponding bit set to b1 in this field| + +-----+---+---------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_barrier__HW_BARR_TRIGGER: + +HW_BARR_TRIGGER +""""""""""""""" + +Trigger the HW barrier + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================================================================================================================+ + |8:0 |R |VALUE|0x000|Every bit written as b1 triggers the corresponding bit of HW barrier, i.e. the corresponding bit is set in HW_BARR_STATUS| + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_barrier__HW_BARR_TRIGGER_SELF: + +HW_BARR_TRIGGER_SELF +"""""""""""""""""""" + +Self-trigger the HW barrier (only accessible from CL_EVENT_UNIT_DEMUX) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+----------+-----------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+=========================================================================================================================================+ + |31:0 |R |DUMMY|0x00000000|When read, the bit corresponding to current cluster core is triggered in the barrier, i.e. the corresponding bit is set in HW_BARR_STATUS| + +-----+---+-----+----------+-----------------------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_barrier__HW_BARR_TRIGGER_WAIT: + +HW_BARR_TRIGGER_WAIT +"""""""""""""""""""" + +Self-trigger and go to sleep (only accessible from CL_EVENT_UNIT_DEMUX) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+======================================================================================================================================================================================+ + |31:0 |R |EVENT|0x00000000|Same behavior as HW_BARR_TRIGGER_SELF, but the core then goes to sleep. On wakeup, the read data is identical to the content of the EU_CORE_BUFFER_MASKED register of the issuing core| + +-----+---+-----+----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_barrier__HW_BARR_TRIGGER_WAIT_CLEAR: + +HW_BARR_TRIGGER_WAIT_CLEAR +"""""""""""""""""""""""""" + +Self-trigger, go to sleep and clear on wake-up (only accessible from CL_EVENT_UNIT_DEMUX) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+----------+-------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+===========================================================================================================================================+ + |31:0 |R |EVENT|0x00000000|Same behavior as HW_BARR_TRIGGER_WAIT, except that bits of EU_CORE_BUFFER that are set to 1 in EU_CORE_MASK are cleared to 0 after the read| + +-----+---+-----+----------+-------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_bitfield.rst b/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_bitfield.rst new file mode 100644 index 000000000..d53743df2 --- /dev/null +++ b/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_bitfield.rst @@ -0,0 +1,96 @@ +.. + Input file: docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_bitfield.md + +Register map for bitfields +^^^^^^^^^^^^^^^^^^^^^^^^^^ + + +Overview +"""""""" + + +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +------------------------------------------------+------+-----+------------------------------------------------+ + | Name |Offset|Width| Description | + +================================================+======+=====+================================================+ + |:ref:`VALUE`| 0| 32|Set or get the value of the bitfield | + +------------------------------------------------+------+-----+------------------------------------------------+ + |:ref:`SET` | 4| 32|Selectively set bitfield bits | + +------------------------------------------------+------+-----+------------------------------------------------+ + |:ref:`CLEAR`| 8| 32|Selectively clear bitfield bits | + +------------------------------------------------+------+-----+------------------------------------------------+ + |:ref:`ALLOC`| 12| 32|Get position and clear least significant set bit| + +------------------------------------------------+------+-----+------------------------------------------------+ + +.. _cluster_event_unit_bitfield__VALUE: + +VALUE +""""" + +Set or get the value of the bitfield + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+----------+-----------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+=============================+ + |31:0 |R/W|BITS|0x00000000|Current value of the bitfield| + +-----+---+----+----------+-----------------------------+ + +.. _cluster_event_unit_bitfield__SET: + +SET +""" + +Selectively set bitfield bits + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+----------+------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+========================================================================+ + |31:0 |W |SET_MASK|0x00000000|Write b1 to 1 or more bits to set the corresponding bits of the bitfield| + +-----+---+--------+----------+------------------------------------------------------------------------+ + +.. _cluster_event_unit_bitfield__CLEAR: + +CLEAR +""""" + +Selectively clear bitfield bits + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+----------+--------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==========================================================================+ + |31:0 |W |CLEAR_MASK|0x00000000|Write b1 to 1 or more bits to clear the corresponding bits of the bitfield| + +-----+---+----------+----------+--------------------------------------------------------------------------+ + +.. _cluster_event_unit_bitfield__ALLOC: + +ALLOC +""""" + +Get position and clear least significant set bit + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+----------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+=========+==========+========================================================================================================================================================+ + |31:0 |R |FIRST_ONE|0x00000000|Reading this field returns the position (from 0 to 31) of the least significant bit set at 1, and clears it to 0. If no bit is set, the read value is 32| + +-----+---+---------+----------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_core.rst b/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_core.rst new file mode 100644 index 000000000..4428d4996 --- /dev/null +++ b/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_core.rst @@ -0,0 +1,324 @@ +.. + Input file: docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_core.md + +Register map for core events +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + +Overview +"""""""" + + +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +======================================================================================+======+=====+======================================================================+ + |:ref:`EU_CORE_MASK` | 0| 32|Core event mask register | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_MASK_AND` | 4| 32|Clear bits of core event mask register | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_MASK_OR` | 8| 32|Set bits of core event mask register | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_MASK_IRQ` | 12| 32|Core intrerrupt mask register | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_MASK_IRQ_AND` | 16| 32|Clear bits of core intrerrupt mask register | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_MASK_IRQ_OR` | 20| 32|Set bits of core intrerrupt mask register | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_STATUS` | 24| 32|Core status register | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_BUFFER` | 28| 32|Event status register | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_BUFFER_MASKED` | 32| 32|Event status register with event mask applied | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_BUFFER_IRQ_MASKED` | 36| 32|Event status register with interrupt mask applied | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_BUFFER_CLEAR` | 40| 32|Clear bits of event status register | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_SW_EVENTS_MASK` | 44| 32|Target core mask for SW wait events | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_SW_EVENTS_MASK_AND`| 48| 32|Clear bits of target core mask for SW wait events | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_SW_EVENTS_MASK_OR` | 52| 32|Set bits of target core mask for SW wait events | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_EVENT_WAIT` | 56| 32|Wait for event (only accessible from CL_EVENT_UNIT_DEMUX) | + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`EU_CORE_EVENT_WAIT_CLEAR` | 60| 32|Wait for event and clear it (only accessible from CL_EVENT_UNIT_DEMUX)| + +--------------------------------------------------------------------------------------+------+-----+----------------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_MASK: + +EU_CORE_MASK +"""""""""""" + +Core event mask register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+----------+----------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+====================================================================================================+ + |31:0 |R/W|EVENT_MASK|0x00000000|Mask bits for events: set a bit to b1 to enable corresponding event as a wake-up source for the core| + +-----+---+----------+----------+----------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_MASK_AND: + +EU_CORE_MASK_AND +"""""""""""""""" + +Clear bits of core event mask register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+----------+--------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+==========================================================================+ + |31:0 |W |MASK_CLR|0x00000000|Write b1 to 1 or more bits to clear the corresponding bits of EU_CORE_MASK| + +-----+---+--------+----------+--------------------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_MASK_OR: + +EU_CORE_MASK_OR +""""""""""""""" + +Set bits of core event mask register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+----------+------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+========================================================================+ + |31:0 |W |MASK_SET|0x00000000|Write b1 to 1 or more bits to set the corresponding bits of EU_CORE_MASK| + +-----+---+--------+----------+------------------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_MASK_IRQ: + +EU_CORE_MASK_IRQ +"""""""""""""""" + +Core intrerrupt mask register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+----------+-------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+=======================================================================================================+ + |31:0 |R/W|EVENT_MASK|0x00000000|Mask bits for events: set a bit to b1 to enable corresponding event as an interrupt source for the core| + +-----+---+----------+----------+-------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_MASK_IRQ_AND: + +EU_CORE_MASK_IRQ_AND +"""""""""""""""""""" + +Clear bits of core intrerrupt mask register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+----------+------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+==============================================================================+ + |31:0 |W |MASK_CLR|0x00000000|Write b1 to 1 or more bits to clear the corresponding bits of EU_CORE_MASK_IRQ| + +-----+---+--------+----------+------------------------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_MASK_IRQ_OR: + +EU_CORE_MASK_IRQ_OR +""""""""""""""""""" + +Set bits of core intrerrupt mask register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+----------+----------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+============================================================================+ + |31:0 |W |MASK_SET|0x00000000|Write b1 to 1 or more bits to set the corresponding bits of EU_CORE_MASK_IRQ| + +-----+---+--------+----------+----------------------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_STATUS: + +EU_CORE_STATUS +"""""""""""""" + +Core status register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+----------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+================================================================+ + | 0|R |CLK_STATUS|0x0 |Status of core clock: b0: clock is stopped; b1: clock is running| + +-----+---+----------+-----+----------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_BUFFER: + +EU_CORE_BUFFER +"""""""""""""" + +Event status register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------+----------+----------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+======+==========+============================================================================================================================+ + |31:0 |R |EVENTS|0x00000000|Status bits for events: a bit reads as b1 when the corresponding event has occurred at least once since this bit was cleared| + +-----+---+------+----------+----------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_BUFFER_MASKED: + +EU_CORE_BUFFER_MASKED +""""""""""""""""""""" + +Event status register with event mask applied + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+----------+--------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==============================================================+ + |31:0 |R |MASKED_EVT|0x00000000|Holds the value of EU_CORE_BUFFER masked by EU_CORE_MASK value| + +-----+---+----------+----------+--------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_BUFFER_IRQ_MASKED: + +EU_CORE_BUFFER_IRQ_MASKED +""""""""""""""""""""""""" + +Event status register with interrupt mask applied + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+----------+------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==================================================================+ + |31:0 |R |MASKED_EVT|0x00000000|Holds the value of EU_CORE_BUFFER masked by EU_CORE_MASK_IRQ value| + +-----+---+----------+----------+------------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_BUFFER_CLEAR: + +EU_CORE_BUFFER_CLEAR +"""""""""""""""""""" + +Clear bits of event status register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------+----------+------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+=======+==========+==========================================================================================================================================+ + |31:0 |W |EVT_CLR|0x00000000|Write b1 to one or more bits to clear the corresponding bits in EU_CORE_BUFFER. Note that an event occuring at the same time may be missed| + +-----+---+-------+----------+------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_SW_EVENTS_MASK: + +EU_CORE_SW_EVENTS_MASK +"""""""""""""""""""""" + +Target core mask for SW wait events + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+=============+======+==================================================================================================================================================================================================================================================+ + |7:0 |R/W|CL_INTERN_EVT|0x0000|Mask bits used when a SW event is triggered from EU_CORE_TRIGG_SW_EVENT_WAIT or EU_CORE_TRIGG_SW_EVENT_WAIT_CLEAR. Note that for no-wait SW event triggering, the used mask is set independently when writting the EU_CORE_TRIGG_SW_EVENT register| + +-----+---+-------------+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_SW_EVENTS_MASK_AND: + +EU_CORE_SW_EVENTS_MASK_AND +"""""""""""""""""""""""""" + +Clear bits of target core mask for SW wait events + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+----------+------------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+====================================================================================+ + |31:0 |W |MASK_CLR|0x00000000|Write b1 to 1 or more bits to clear the corresponding bits of EU_CORE_SW_EVENTS_MASK| + +-----+---+--------+----------+------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_SW_EVENTS_MASK_OR: + +EU_CORE_SW_EVENTS_MASK_OR +""""""""""""""""""""""""" + +Set bits of target core mask for SW wait events + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+----------+----------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+==================================================================================+ + |31:0 |W |MASK_SET|0x00000000|Write b1 to 1 or more bits to set the corresponding bits of EU_CORE_SW_EVENTS_MASK| + +-----+---+--------+----------+----------------------------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_EVENT_WAIT: + +EU_CORE_EVENT_WAIT +"""""""""""""""""" + +Wait for event (only accessible from CL_EVENT_UNIT_DEMUX) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+============================================================================================================================================================================================+ + |31:0 |R |EVENT|0x00000000|Reading this register stops the clock of the core until at least one event with the corresponding mask bit set to 1 occurs. The returned value is identical to that of EU_CORE_BUFFER_MASKED| + +-----+---+-----+----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_core__EU_CORE_EVENT_WAIT_CLEAR: + +EU_CORE_EVENT_WAIT_CLEAR +"""""""""""""""""""""""" + +Wait for event and clear it (only accessible from CL_EVENT_UNIT_DEMUX) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+===============================================================================================================================================================================+ + |31:0 |R |EVENT|0x00000000|Reading this register has the same behavior as reading EU_CORE_EVENT_WAIT, except that bits of EU_CORE_BUFFER that are set to 1 in EU_CORE_MASK are cleared to 0 after the read| + +-----+---+-----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_mutex.rst b/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_mutex.rst new file mode 100644 index 000000000..0ef4b3133 --- /dev/null +++ b/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_mutex.rst @@ -0,0 +1,172 @@ +.. + Input file: docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_mutex.md + +Register map for mutex events +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + +Overview +"""""""" + + +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +---------------------------------------------------------------------+------+-----+---------------------------------------------------------------+ + | Name |Offset|Width| Description | + +=====================================================================+======+=====+===============================================================+ + |:ref:`EU_CORE_HW_MUTEX0`| 0| 32|Access to HW mutex 0 (only accessible from CL_EVENT_UNIT_DEMUX)| + +---------------------------------------------------------------------+------+-----+---------------------------------------------------------------+ + |:ref:`EU_CORE_HW_MUTEX1`| 4| 32|Access to HW mutex 1 (only accessible from CL_EVENT_UNIT_DEMUX)| + +---------------------------------------------------------------------+------+-----+---------------------------------------------------------------+ + |:ref:`EU_CORE_HW_MUTEX2`| 8| 32|Access to HW mutex 2 (only accessible from CL_EVENT_UNIT_DEMUX)| + +---------------------------------------------------------------------+------+-----+---------------------------------------------------------------+ + |:ref:`EU_CORE_HW_MUTEX3`| 12| 32|Access to HW mutex 3 (only accessible from CL_EVENT_UNIT_DEMUX)| + +---------------------------------------------------------------------+------+-----+---------------------------------------------------------------+ + |:ref:`EU_CORE_HW_MUTEX4`| 16| 32|Access to HW mutex 4 (only accessible from CL_EVENT_UNIT_DEMUX)| + +---------------------------------------------------------------------+------+-----+---------------------------------------------------------------+ + |:ref:`EU_CORE_HW_MUTEX5`| 20| 32|Access to HW mutex 5 (only accessible from CL_EVENT_UNIT_DEMUX)| + +---------------------------------------------------------------------+------+-----+---------------------------------------------------------------+ + |:ref:`EU_CORE_HW_MUTEX6`| 24| 32|Access to HW mutex 6 (only accessible from CL_EVENT_UNIT_DEMUX)| + +---------------------------------------------------------------------+------+-----+---------------------------------------------------------------+ + |:ref:`EU_CORE_HW_MUTEX7`| 28| 32|Access to HW mutex 7 (only accessible from CL_EVENT_UNIT_DEMUX)| + +---------------------------------------------------------------------+------+-----+---------------------------------------------------------------+ + +.. _cluster_event_unit_mutex__EU_CORE_HW_MUTEX0: + +EU_CORE_HW_MUTEX0 +""""""""""""""""" + +Access to HW mutex 0 (only accessible from CL_EVENT_UNIT_DEMUX) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+===================================================================================================================================================================================================================================================================================================================================================================+ + |31:0 |R/W|VALUE|0x00000000|Reading tries to lock the corresponding mutex, writing unlocks it. The value written during an unlock is transmitted to the core which locks the mutex next. Note that there is no protection against illegal unlocks in hardware, i.e. the runtime SW is responsible for making sure that only the core that has locked a mutex performs a write on this register.| + +-----+---+-----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_mutex__EU_CORE_HW_MUTEX1: + +EU_CORE_HW_MUTEX1 +""""""""""""""""" + +Access to HW mutex 1 (only accessible from CL_EVENT_UNIT_DEMUX) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+----------+----------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+============================+ + |31:0 |R/W|VALUE|0x00000000|Same behavior as HW mutex 0.| + +-----+---+-----+----------+----------------------------+ + +.. _cluster_event_unit_mutex__EU_CORE_HW_MUTEX2: + +EU_CORE_HW_MUTEX2 +""""""""""""""""" + +Access to HW mutex 2 (only accessible from CL_EVENT_UNIT_DEMUX) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+----------+----------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+============================+ + |31:0 |R/W|VALUE|0x00000000|Same behavior as HW mutex 0.| + +-----+---+-----+----------+----------------------------+ + +.. _cluster_event_unit_mutex__EU_CORE_HW_MUTEX3: + +EU_CORE_HW_MUTEX3 +""""""""""""""""" + +Access to HW mutex 3 (only accessible from CL_EVENT_UNIT_DEMUX) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+----------+----------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+============================+ + |31:0 |R/W|VALUE|0x00000000|Same behavior as HW mutex 0.| + +-----+---+-----+----------+----------------------------+ + +.. _cluster_event_unit_mutex__EU_CORE_HW_MUTEX4: + +EU_CORE_HW_MUTEX4 +""""""""""""""""" + +Access to HW mutex 4 (only accessible from CL_EVENT_UNIT_DEMUX) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+----------+----------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+============================+ + |31:0 |R/W|VALUE|0x00000000|Same behavior as HW mutex 0.| + +-----+---+-----+----------+----------------------------+ + +.. _cluster_event_unit_mutex__EU_CORE_HW_MUTEX5: + +EU_CORE_HW_MUTEX5 +""""""""""""""""" + +Access to HW mutex 5 (only accessible from CL_EVENT_UNIT_DEMUX) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+----------+----------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+============================+ + |31:0 |R/W|VALUE|0x00000000|Same behavior as HW mutex 0.| + +-----+---+-----+----------+----------------------------+ + +.. _cluster_event_unit_mutex__EU_CORE_HW_MUTEX6: + +EU_CORE_HW_MUTEX6 +""""""""""""""""" + +Access to HW mutex 6 (only accessible from CL_EVENT_UNIT_DEMUX) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+----------+----------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+============================+ + |31:0 |R/W|VALUE|0x00000000|Same behavior as HW mutex 0.| + +-----+---+-----+----------+----------------------------+ + +.. _cluster_event_unit_mutex__EU_CORE_HW_MUTEX7: + +EU_CORE_HW_MUTEX7 +""""""""""""""""" + +Access to HW mutex 7 (only accessible from CL_EVENT_UNIT_DEMUX) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+----------+----------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+============================+ + |31:0 |R/W|VALUE|0x00000000|Same behavior as HW mutex 0.| + +-----+---+-----+----------+----------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_semaphore.rst b/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_semaphore.rst new file mode 100644 index 000000000..e7fcfcd32 --- /dev/null +++ b/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_semaphore.rst @@ -0,0 +1,77 @@ +.. + Input file: docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_semaphore.md + +Register map for semaphores +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + +Overview +"""""""" + + +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-------------------------------------------------------+------+-----+----------------------------------------------------------+ + | Name |Offset|Width| Description | + +=======================================================+======+=====+==========================================================+ + |:ref:`VALUE` | 0| 32|Set or get the value of the semaphore | + +-------------------------------------------------------+------+-----+----------------------------------------------------------+ + |:ref:`COUNTER` | 4| 32|Atomically increase or decrease the value of the semaphore| + +-------------------------------------------------------+------+-----+----------------------------------------------------------+ + |:ref:`COUNTER2`| 8| 32|Read and increase the value of the semaphore | + +-------------------------------------------------------+------+-----+----------------------------------------------------------+ + +.. _cluster_event_unit_semaphore__VALUE: + +VALUE +""""" + +Set or get the value of the semaphore + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+----------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+==================================+ + |11:0 |R/W|COUNT|0x000|Current value of semaphore counter| + +-----+---+-----+-----+----------------------------------+ + +.. _cluster_event_unit_semaphore__COUNTER: + +COUNTER +""""""" + +Atomically increase or decrease the value of the semaphore + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=============================================================================================================================================================+ + |11:0 |R/W|INC_DEC|0x000|Writing to this register increases the value of the semaphore by the value written; reading this register returns current value and decrements it, atomically| + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_semaphore__COUNTER2: + +COUNTER2 +"""""""" + +Read and increase the value of the semaphore + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==========================================================================================+ + |11:0 |R |COUNT_INC|0x000|Reading this register returns current value of the semaphore and increments it, atomically| + +-----+---+---------+-----+------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_soc_evt.rst b/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_soc_evt.rst new file mode 100644 index 000000000..91fef6882 --- /dev/null +++ b/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_soc_evt.rst @@ -0,0 +1,41 @@ +.. + Input file: docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_soc_evt.md + +Register map for SoC events +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + +Overview +"""""""" + + +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-------------------------------------------------------------------------------+------+-----+-------------------------------------------------------------+ + | Name |Offset|Width| Description | + +===============================================================================+======+=====+=============================================================+ + |:ref:`EU_CORE_CURRENT_EVENT`| 0| 32|Access to SoC event FIFO (only accessible from CL_EVENT_UNIT)| + +-------------------------------------------------------------------------------+------+-----+-------------------------------------------------------------+ + +.. _cluster_event_unit_soc_evt__EU_CORE_CURRENT_EVENT: + +EU_CORE_CURRENT_EVENT +""""""""""""""""""""" + +Access to SoC event FIFO (only accessible from CL_EVENT_UNIT) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+========================================================================================================================================================+ + |7:0 |R |EVENT_ID|0x00 |Oldest SoC peripheral event ID that was written into the FIFO. After a read of this register, the next event ID (if any) will be read at the next access| + +-----+---+--------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |R |VALID |0x0 |Valid bit: if read as b1, the EVENT_ID field is valid | + +-----+---+--------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_sw_events.rst b/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_sw_events.rst new file mode 100644 index 000000000..c9bf788a4 --- /dev/null +++ b/rtos/pulp/gap_archi/doc/ips/cluster_event_unit_sw_events.rst @@ -0,0 +1,476 @@ +.. + Input file: docs/IP_REFERENCES/CLUSTER_EVENT_UNIT_sw_events.md + +Register map for software events +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + +Overview +"""""""" + + +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + | Name |Offset|Width| Description | + +===========================================================================================================+======+=====+====================================================+ + |:ref:`EU_CORE_TRIGG_SW_EVENT0` | 0| 32|Trigger SW event 0 | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT1` | 4| 32|Trigger SW event 1 | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT2` | 8| 32|Trigger SW event 2 | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT3` | 12| 32|Trigger SW event 3 | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT4` | 16| 32|Trigger SW event 4 | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT5` | 20| 32|Trigger SW event 5 | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT6` | 24| 32|Trigger SW event 6 | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT7` | 28| 32|Trigger SW event 7 | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT0_WAIT` | 64| 32|Trigger SW event 0 and go to sleep | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT1_WAIT` | 68| 32|Trigger SW event 1 and go to sleep | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT2_WAIT` | 72| 32|Trigger SW event 2 and go to sleep | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT3_WAIT` | 76| 32|Trigger SW event 3 and go to sleep | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT4_WAIT` | 64| 32|Trigger SW event 4 and go to sleep | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT5_WAIT` | 68| 32|Trigger SW event 5 and go to sleep | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT6_WAIT` | 72| 32|Trigger SW event 6 and go to sleep | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT7_WAIT` | 76| 32|Trigger SW event 7 and go to sleep | + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT0_WAIT_CLEAR`| 128| 32|Trigger SW event 0, go to sleep and clear on wake-up| + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT1_WAIT_CLEAR`| 132| 32|Trigger SW event 1, go to sleep and clear on wake-up| + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT2_WAIT_CLEAR`| 136| 32|Trigger SW event 2, go to sleep and clear on wake-up| + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT3_WAIT_CLEAR`| 140| 32|Trigger SW event 3, go to sleep and clear on wake-up| + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT4_WAIT_CLEAR`| 128| 32|Trigger SW event 4, go to sleep and clear on wake-up| + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT5_WAIT_CLEAR`| 132| 32|Trigger SW event 5, go to sleep and clear on wake-up| + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT6_WAIT_CLEAR`| 136| 32|Trigger SW event 6, go to sleep and clear on wake-up| + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + |:ref:`EU_CORE_TRIGG_SW_EVENT7_WAIT_CLEAR`| 140| 32|Trigger SW event 7, go to sleep and clear on wake-up| + +-----------------------------------------------------------------------------------------------------------+------+-----+----------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT0: + +EU_CORE_TRIGG_SW_EVENT0 +""""""""""""""""""""""" + +Trigger SW event 0 + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+-----+-------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============================================================================================================+ + |8:0 |W |EVT_MASK|0x000|Writing to this register triggers software event with ID 0 for all cores with corresponding bit written as b1| + +-----+---+--------+-----+-------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT1: + +EU_CORE_TRIGG_SW_EVENT1 +""""""""""""""""""""""" + +Trigger SW event 1 + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+======================================================================+ + |8:0 |W |EVT_MASK|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0, except for the event ID used| + +-----+---+--------+-----+----------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT2: + +EU_CORE_TRIGG_SW_EVENT2 +""""""""""""""""""""""" + +Trigger SW event 2 + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+======================================================================+ + |8:0 |W |EVT_MASK|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0, except for the event ID used| + +-----+---+--------+-----+----------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT3: + +EU_CORE_TRIGG_SW_EVENT3 +""""""""""""""""""""""" + +Trigger SW event 3 + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+======================================================================+ + |8:0 |W |EVT_MASK|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0, except for the event ID used| + +-----+---+--------+-----+----------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT4: + +EU_CORE_TRIGG_SW_EVENT4 +""""""""""""""""""""""" + +Trigger SW event 4 + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+======================================================================+ + |8:0 |W |EVT_MASK|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0, except for the event ID used| + +-----+---+--------+-----+----------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT5: + +EU_CORE_TRIGG_SW_EVENT5 +""""""""""""""""""""""" + +Trigger SW event 5 + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+======================================================================+ + |8:0 |W |EVT_MASK|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0, except for the event ID used| + +-----+---+--------+-----+----------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT6: + +EU_CORE_TRIGG_SW_EVENT6 +""""""""""""""""""""""" + +Trigger SW event 6 + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+======================================================================+ + |8:0 |W |EVT_MASK|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0, except for the event ID used| + +-----+---+--------+-----+----------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT7: + +EU_CORE_TRIGG_SW_EVENT7 +""""""""""""""""""""""" + +Trigger SW event 7 + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+======================================================================+ + |8:0 |W |EVT_MASK|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0, except for the event ID used| + +-----+---+--------+-----+----------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT0_WAIT: + +EU_CORE_TRIGG_SW_EVENT0_WAIT +"""""""""""""""""""""""""""" + +Trigger SW event 0 and go to sleep + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=============================================================================================================================================================================================================================================+ + |8:0 |W |EVENT|0x000|Reading from this register triggers software event with ID 0 for all cores with corresponding bit written as b1 in EU_CORE_SW_EVENTS_MASK register. Current core then goes to sleep with the same behavior as when reading EU_CORE_EVENT_WAIT| + +-----+---+-----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT1_WAIT: + +EU_CORE_TRIGG_SW_EVENT1_WAIT +"""""""""""""""""""""""""""" + +Trigger SW event 1 and go to sleep + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================================================+ + |8:0 |W |EVENT|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0_WAIT, except for the event ID used| + +-----+---+-----+-----+---------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT2_WAIT: + +EU_CORE_TRIGG_SW_EVENT2_WAIT +"""""""""""""""""""""""""""" + +Trigger SW event 2 and go to sleep + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================================================+ + |8:0 |W |EVENT|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0_WAIT, except for the event ID used| + +-----+---+-----+-----+---------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT3_WAIT: + +EU_CORE_TRIGG_SW_EVENT3_WAIT +"""""""""""""""""""""""""""" + +Trigger SW event 3 and go to sleep + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================================================+ + |8:0 |W |EVENT|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0_WAIT, except for the event ID used| + +-----+---+-----+-----+---------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT4_WAIT: + +EU_CORE_TRIGG_SW_EVENT4_WAIT +"""""""""""""""""""""""""""" + +Trigger SW event 4 and go to sleep + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================================================+ + |8:0 |W |EVENT|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0_WAIT, except for the event ID used| + +-----+---+-----+-----+---------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT5_WAIT: + +EU_CORE_TRIGG_SW_EVENT5_WAIT +"""""""""""""""""""""""""""" + +Trigger SW event 5 and go to sleep + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================================================+ + |8:0 |W |EVENT|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0_WAIT, except for the event ID used| + +-----+---+-----+-----+---------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT6_WAIT: + +EU_CORE_TRIGG_SW_EVENT6_WAIT +"""""""""""""""""""""""""""" + +Trigger SW event 6 and go to sleep + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================================================+ + |8:0 |W |EVENT|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0_WAIT, except for the event ID used| + +-----+---+-----+-----+---------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT7_WAIT: + +EU_CORE_TRIGG_SW_EVENT7_WAIT +"""""""""""""""""""""""""""" + +Trigger SW event 7 and go to sleep + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================================================+ + |8:0 |W |EVENT|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0_WAIT, except for the event ID used| + +-----+---+-----+-----+---------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT0_WAIT_CLEAR: + +EU_CORE_TRIGG_SW_EVENT0_WAIT_CLEAR +"""""""""""""""""""""""""""""""""" + +Trigger SW event 0, go to sleep and clear on wake-up + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===================================================================================================================================================================================================================================================+ + |8:0 |W |EVENT|0x000|Reading from this register triggers software event with ID 0 for all cores with corresponding bit written as b1 in EU_CORE_SW_EVENTS_MASK register. Current core then goes to sleep with the same behavior as when reading EU_CORE_EVENT_WAIT_CLEAR| + +-----+---+-----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT1_WAIT_CLEAR: + +EU_CORE_TRIGG_SW_EVENT1_WAIT_CLEAR +"""""""""""""""""""""""""""""""""" + +Trigger SW event 1, go to sleep and clear on wake-up + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=================================================================================+ + |8:0 |W |EVENT|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0_WAIT_CLEAR, except for the event ID used| + +-----+---+-----+-----+---------------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT2_WAIT_CLEAR: + +EU_CORE_TRIGG_SW_EVENT2_WAIT_CLEAR +"""""""""""""""""""""""""""""""""" + +Trigger SW event 2, go to sleep and clear on wake-up + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=================================================================================+ + |8:0 |W |EVENT|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0_WAIT_CLEAR, except for the event ID used| + +-----+---+-----+-----+---------------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT3_WAIT_CLEAR: + +EU_CORE_TRIGG_SW_EVENT3_WAIT_CLEAR +"""""""""""""""""""""""""""""""""" + +Trigger SW event 3, go to sleep and clear on wake-up + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=================================================================================+ + |8:0 |W |EVENT|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0_WAIT_CLEAR, except for the event ID used| + +-----+---+-----+-----+---------------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT4_WAIT_CLEAR: + +EU_CORE_TRIGG_SW_EVENT4_WAIT_CLEAR +"""""""""""""""""""""""""""""""""" + +Trigger SW event 4, go to sleep and clear on wake-up + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=================================================================================+ + |8:0 |W |EVENT|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0_WAIT_CLEAR, except for the event ID used| + +-----+---+-----+-----+---------------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT5_WAIT_CLEAR: + +EU_CORE_TRIGG_SW_EVENT5_WAIT_CLEAR +"""""""""""""""""""""""""""""""""" + +Trigger SW event 5, go to sleep and clear on wake-up + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=================================================================================+ + |8:0 |W |EVENT|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0_WAIT_CLEAR, except for the event ID used| + +-----+---+-----+-----+---------------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT6_WAIT_CLEAR: + +EU_CORE_TRIGG_SW_EVENT6_WAIT_CLEAR +"""""""""""""""""""""""""""""""""" + +Trigger SW event 6, go to sleep and clear on wake-up + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=================================================================================+ + |8:0 |W |EVENT|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0_WAIT_CLEAR, except for the event ID used| + +-----+---+-----+-----+---------------------------------------------------------------------------------+ + +.. _cluster_event_unit_sw_events__EU_CORE_TRIGG_SW_EVENT7_WAIT_CLEAR: + +EU_CORE_TRIGG_SW_EVENT7_WAIT_CLEAR +"""""""""""""""""""""""""""""""""" + +Trigger SW event 7, go to sleep and clear on wake-up + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=================================================================================+ + |8:0 |W |EVENT|0x000|Same behavior as EU_CORE_TRIGG_SW_EVENT0_WAIT_CLEAR, except for the event ID used| + +-----+---+-----+-----+---------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/cluster_icache_ctrl.rst b/rtos/pulp/gap_archi/doc/ips/cluster_icache_ctrl.rst index 32dbae5d2..d0ccbebb6 100644 --- a/rtos/pulp/gap_archi/doc/ips/cluster_icache_ctrl.rst +++ b/rtos/pulp/gap_archi/doc/ips/cluster_icache_ctrl.rst @@ -8,25 +8,30 @@ Register map Overview """""""" -.. table:: - +-------------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +===============================================================================+======+=====+===============================================================================================================+ - |:ref:`ENABLE` | 0| 32|Cluster instruction cache unit enable configuration register. | - +-------------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------------------------------------------------+ - |:ref:`FLUSH` | 4| 32|Cluster instruction cache unit flush command register. | - +-------------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------------------------------------------------+ - |:ref:`L0_FLUSH` | 8| 32|Cluster level 0 instruction cache unit flush command register. | - +-------------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------------------------------------------------+ - |:ref:`SEL_FLUSH` | 12| 32|Cluster instruction cache unit selective flush command register. | - +-------------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------------------------------------------------+ - |:ref:`ENABLE_SPECIAL_CORE_CACHE`| 24| 32|When use 9th core, the number 8 core can have seperated icache or its own icache. Use this register to control.| - +-------------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------------------------------------------------+ - |:ref:`ENABLE_L1_L15_PREFETCH` | 28| 32|For each Level 0 private cache, enable L0 to L0.5, (also called L1 to L1.5) prefetch | - +-------------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------------------------------------------------+ - -.. _cluster_icache_ctrl_ENABLE: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +--------------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +================================================================================+======+=====+===============================================================================================================+ + |:ref:`ENABLE` | 0| 32|Cluster instruction cache unit enable configuration register. | + +--------------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------------------------------------------------+ + |:ref:`FLUSH` | 4| 32|Cluster instruction cache unit flush command register. | + +--------------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------------------------------------------------+ + |:ref:`L0_FLUSH` | 8| 32|Cluster level 0 instruction cache unit flush command register. | + +--------------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------------------------------------------------+ + |:ref:`SEL_FLUSH` | 12| 32|Cluster instruction cache unit selective flush command register. | + +--------------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------------------------------------------------+ + |:ref:`ENABLE_SPECIAL_CORE_CACHE`| 24| 32|When use 9th core, the number 8 core can have seperated icache or its own icache. Use this register to control.| + +--------------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------------------------------------------------+ + |:ref:`ENABLE_L1_L15_PREFETCH` | 28| 32|For each Level 0 private cache, enable L0 to L0.5, (also called L1 to L1.5) prefetch | + +--------------------------------------------------------------------------------+------+-----+---------------------------------------------------------------------------------------------------------------+ + +.. _cluster_icache_ctrl__ENABLE: ENABLE """""" @@ -34,13 +39,18 @@ ENABLE Cluster instruction cache unit enable configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+---------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=============================================================================================+ + |8:0 |W |EN_PRI|0x0 |Enable private banks of cluster instruction cache (1 bit per core): b0: disabled; b1: enabled| + +-----+---+------+-----+---------------------------------------------------------------------------------------------+ + |10:9 |W |EN_SH |0x0 |Enable shared banks of cluster instruction cache (1 bit per bank): b0: disabled; b1: enabled | + +-----+---+------+-----+---------------------------------------------------------------------------------------------+ -.. _cluster_icache_ctrl_FLUSH: +.. _cluster_icache_ctrl__FLUSH: FLUSH """"" @@ -48,13 +58,18 @@ FLUSH Cluster instruction cache unit flush command register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+---------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+===========================================================================+ + |8:0 |W |FL_PRI|0x0 |Write 1 to bit i to fully flush private instruction cache of cluster core i| + +-----+---+------+-----+---------------------------------------------------------------------------+ + |10:9 |W |FL_SH |0x0 |Write 1 to bit i to fully flush shared bank i of cluster instruction cache | + +-----+---+------+-----+---------------------------------------------------------------------------+ -.. _cluster_icache_ctrl_L0_FLUSH: +.. _cluster_icache_ctrl__L0_FLUSH: L0_FLUSH """""""" @@ -62,13 +77,16 @@ L0_FLUSH Cluster level 0 instruction cache unit flush command register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-----------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=======================================================================+ + |8:0 |W |L0_FL|0x0 |Write 1 to bit i to fully flush level 0 of instruction cache for core i| + +-----+---+-----+-----+-----------------------------------------------------------------------+ -.. _cluster_icache_ctrl_SEL_FLUSH: +.. _cluster_icache_ctrl__SEL_FLUSH: SEL_FLUSH """"""""" @@ -76,13 +94,16 @@ SEL_FLUSH Cluster instruction cache unit selective flush command register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+----------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+========================================+ + |31:0 |W |ADDR|0x0 |Write an address to selectively flush it| + +-----+---+----+-----+----------------------------------------+ -.. _cluster_icache_ctrl_ENABLE_SPECIAL_CORE_CACHE: +.. _cluster_icache_ctrl__ENABLE_SPECIAL_CORE_CACHE: ENABLE_SPECIAL_CORE_CACHE """"""""""""""""""""""""" @@ -90,13 +111,16 @@ ENABLE_SPECIAL_CORE_CACHE When use 9th core, the number 8 core can have seperated icache or its own icache. Use this register to control. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+---------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=====================================================================+ + | 0|W |ENABLE|0x0 |Enable or disable core 9 seperated i-cache: b0: disabled; b1: enabled| + +-----+---+------+-----+---------------------------------------------------------------------+ -.. _cluster_icache_ctrl_ENABLE_L1_L15_PREFETCH: +.. _cluster_icache_ctrl__ENABLE_L1_L15_PREFETCH: ENABLE_L1_L15_PREFETCH """""""""""""""""""""" @@ -104,8 +128,11 @@ ENABLE_L1_L15_PREFETCH For each Level 0 private cache, enable L0 to L0.5, (also called L1 to L1.5) prefetch .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=================================================================================================+ + |8:0 |W |ENABLE|0x0 |Enable or disable the prefetchers for private i-cache (1 bit per core): b0: disabled; b1: enabled| + +-----+---+------+-----+-------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/csi2_ctrl.rst b/rtos/pulp/gap_archi/doc/ips/csi2_ctrl.rst index 3b8bf8922..22abd6dce 100644 --- a/rtos/pulp/gap_archi/doc/ips/csi2_ctrl.rst +++ b/rtos/pulp/gap_archi/doc/ips/csi2_ctrl.rst @@ -8,45 +8,50 @@ Register map for MIPI CSI2 Controller Overview """""""" -.. table:: - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - | Name |Offset|Width| Description | - +=======================================================+======+=====+==================================================+ - |:ref:`CONFIG` | 384| 32|Configuration of the number of active lanes | - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`ERR_MSB1` | 388| 32|Error status MSB1 | - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`ERR_MSB` | 392| 32|Error status MSB | - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`ERR_LSB` | 396| 32|Error status LSB | - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`HS_RX_TIMEOUT_MSB2`| 400| 32|Configuration of timeout in high speed mode (MSB2)| - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`HS_RX_TIMEOUT_MSB1`| 404| 32|Configuration of timeout in high speed mode (MSB1)| - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`HS_RX_TIMEOUT_LSB` | 408| 32|Configuration of timeout in high speed mode (LSB) | - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`VCCFG` | 412| 32|Virtual Channel configuration | - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`POLARITY` | 416| 32|Vsync and Hsync polarity | - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`CCI_ADDRESS` | 420| 32|CCI address | - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`CCI_WRITE_DATA` | 424| 32|CCI write data | - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`CCI_READ_DATA` | 428| 32|CCI read data | - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`CCI_READ_WRITE` | 432| 32|CCI R/W | - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`CCI_STATUS` | 436| 32|CCI status | - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`CCI_DEV_ADDR` | 440| 32|CCI device ID | - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - |:ref:`ULPS_STATUS` | 444| 32|CSI2 ULPS status | - +-------------------------------------------------------+------+-----+--------------------------------------------------+ - -.. _csi2_ctrl_CONFIG: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + | Name |Offset|Width| Description | + +========================================================+======+=====+==================================================+ + |:ref:`CONFIG` | 384| 32|Configuration of the number of active lanes | + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`ERR_MSB1` | 388| 32|Error status MSB1 | + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`ERR_MSB` | 392| 32|Error status MSB | + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`ERR_LSB` | 396| 32|Error status LSB | + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`HS_RX_TIMEOUT_MSB2`| 400| 32|Configuration of timeout in high speed mode (MSB2)| + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`HS_RX_TIMEOUT_MSB1`| 404| 32|Configuration of timeout in high speed mode (MSB1)| + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`HS_RX_TIMEOUT_LSB` | 408| 32|Configuration of timeout in high speed mode (LSB) | + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`VCCFG` | 412| 32|Virtual Channel configuration | + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`POLARITY` | 416| 32|Vsync and Hsync polarity | + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`CCI_ADDRESS` | 420| 32|CCI address | + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`CCI_WRITE_DATA` | 424| 32|CCI write data | + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`CCI_READ_DATA` | 428| 32|CCI read data | + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`CCI_READ_WRITE` | 432| 32|CCI R/W | + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`CCI_STATUS` | 436| 32|CCI status | + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`CCI_DEV_ADDR` | 440| 32|CCI device ID | + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`ULPS_STATUS` | 444| 32|CSI2 ULPS status | + +--------------------------------------------------------+------+-----+--------------------------------------------------+ + +.. _csi2_ctrl__CONFIG: CONFIG """""" @@ -54,14 +59,16 @@ CONFIG Configuration of the number of active lanes .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------+-------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+=========================================================================+ - |1:0 |R/W|CSI_CONFIG|Number of active lanes: b00: single lane, b01: two lanes, b11: four lanes| - +-----+---+----------+-------------------------------------------------------------------------+ + +-----+---+----------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+=========================================================================+ + |1:0 |R/W|CSI_CONFIG|0x00 |Number of active lanes: b00: single lane, b01: two lanes, b11: four lanes| + +-----+---+----------+-----+-------------------------------------------------------------------------+ -.. _csi2_ctrl_ERR_MSB1: +.. _csi2_ctrl__ERR_MSB1: ERR_MSB1 """""""" @@ -69,16 +76,18 @@ ERR_MSB1 Error status MSB1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------------+--------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+============================================================================================+ - | 0|R |CRC_ERROR_VC_3|Set to 1 if there is a checksum error on virtual channel 3 (Checksum Error Long packet only)| - +-----+---+--------------+--------------------------------------------------------------------------------------------+ - | 1|R |ERR_ESC |Set to 1 if there is an error in escape entry command | - +-----+---+--------------+--------------------------------------------------------------------------------------------+ + +-----+---+--------------+-----+--------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+============================================================================================+ + | 0|R |CRC_ERROR_VC_3|0x0 |Set to 1 if there is a checksum error on virtual channel 3 (Checksum Error Long packet only)| + +-----+---+--------------+-----+--------------------------------------------------------------------------------------------+ + | 1|R |ERR_ESC |0x0 |Set to 1 if there is an error in escape entry command | + +-----+---+--------------+-----+--------------------------------------------------------------------------------------------+ -.. _csi2_ctrl_ERR_MSB: +.. _csi2_ctrl__ERR_MSB: ERR_MSB """"""" @@ -86,28 +95,30 @@ ERR_MSB Error status MSB .. table:: - - +-----+---+--------------+----------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+====================================================================================================+ - | 0|R |INVLD_PKT_LEN |Set to 1 if there is an invalid packet length (invalid transmission length) | - +-----+---+--------------+----------------------------------------------------------------------------------------------------+ - | 1|R |FRAME_SYNC_ERR|Set to 1 if a frame end is received but not paired with a frame start in the same virtual channel | - +-----+---+--------------+----------------------------------------------------------------------------------------------------+ - | 2|R |ECC_NO_ERR |Set to 1 when ECC check shows no error (either no error or more than 2 bits of error) | - +-----+---+--------------+----------------------------------------------------------------------------------------------------+ - | 3|R |ECC_BIT_ERROR |Set to 1 if there is an error in the ECC field | - +-----+---+--------------+----------------------------------------------------------------------------------------------------+ - | 4|R |ERR_FRAME_DATA|If a CRC error is present in the data packet, then this error is set to 1 when vsync end is received| - +-----+---+--------------+----------------------------------------------------------------------------------------------------+ - | 5|R |HS_RX_TO_ERR |Set to 1 in case of HS RX timeout | - +-----+---+--------------+----------------------------------------------------------------------------------------------------+ - | 6|R |CRC_ERROR_VC1 |Set to 1 if there is a checksum error on virtual channel 1 (Checksum Error Long packet only) | - +-----+---+--------------+----------------------------------------------------------------------------------------------------+ - | 7|R |CRC_ERROR_VC2 |Set to 1 if there is a checksum error on virtual channel 2 (Checksum Error Long packet only) | - +-----+---+--------------+----------------------------------------------------------------------------------------------------+ - -.. _csi2_ctrl_ERR_LSB: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+-----+----------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+====================================================================================================+ + | 0|R |INVLD_PKT_LEN |0x0 |Set to 1 if there is an invalid packet length (invalid transmission length) | + +-----+---+--------------+-----+----------------------------------------------------------------------------------------------------+ + | 1|R |FRAME_SYNC_ERR|0x0 |Set to 1 if a frame end is received but not paired with a frame start in the same virtual channel | + +-----+---+--------------+-----+----------------------------------------------------------------------------------------------------+ + | 2|R |ECC_NO_ERR |0x0 |Set to 1 when ECC check shows no error (either no error or more than 2 bits of error) | + +-----+---+--------------+-----+----------------------------------------------------------------------------------------------------+ + | 3|R |ECC_BIT_ERROR |0x0 |Set to 1 if there is an error in the ECC field | + +-----+---+--------------+-----+----------------------------------------------------------------------------------------------------+ + | 4|R |ERR_FRAME_DATA|0x0 |If a CRC error is present in the data packet, then this error is set to 1 when vsync end is received| + +-----+---+--------------+-----+----------------------------------------------------------------------------------------------------+ + | 5|R |HS_RX_TO_ERR |0x0 |Set to 1 in case of HS RX timeout | + +-----+---+--------------+-----+----------------------------------------------------------------------------------------------------+ + | 6|R |CRC_ERROR_VC1 |0x0 |Set to 1 if there is a checksum error on virtual channel 1 (Checksum Error Long packet only) | + +-----+---+--------------+-----+----------------------------------------------------------------------------------------------------+ + | 7|R |CRC_ERROR_VC2 |0x0 |Set to 1 if there is a checksum error on virtual channel 2 (Checksum Error Long packet only) | + +-----+---+--------------+-----+----------------------------------------------------------------------------------------------------+ + +.. _csi2_ctrl__ERR_LSB: ERR_LSB """"""" @@ -115,28 +126,30 @@ ERR_LSB Error status LSB .. table:: - - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+===========================================================================================================================+ - | 0|R |SOT_ERR |Set to 1 if there is an error with start of frame (SoT Error) | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - | 1|R |SOT_SYNC_ERR |Set to 1 if there is an error in synchronization of Start of Transfer (SoT Sync Error) | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - | 2|R |FALSE_CTRL |Set to 1 if there is a False Control Error | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - | 3|R |ECC_ERR_SINGLE |Set to 1 if there is a single bit error, even when it is corrected using ECC (ECC Error, single-bit detected and corrected)| - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - | 4|R |ECC_ERR_MULT |Set to 1 if there is a two-bit error in the packet (ECC Error, multi-bit detected not corrected) | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - | 5|R |CRC_ERROR_VC0 |Set to 1 if there is a checksum error on virtual channel 0 (Checksum Error Long packet only) | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - | 6|R |INVLD_DATA_TYPE|Set to 1 if the received data is invalid (CSI Data Type Not Recognized) | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - | 7|R |INVLD_VC_ID |Set to 1 in case of invalid virtual channel ID (CSI VC ID Invalid) | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------+ - -.. _csi2_ctrl_HS_RX_TIMEOUT_MSB2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+===========================================================================================================================+ + | 0|R |SOT_ERR |0x0 |Set to 1 if there is an error with start of frame (SoT Error) | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------+ + | 1|R |SOT_SYNC_ERR |0x0 |Set to 1 if there is an error in synchronization of Start of Transfer (SoT Sync Error) | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------+ + | 2|R |FALSE_CTRL |0x0 |Set to 1 if there is a False Control Error | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------+ + | 3|R |ECC_ERR_SINGLE |0x0 |Set to 1 if there is a single bit error, even when it is corrected using ECC (ECC Error, single-bit detected and corrected)| + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------+ + | 4|R |ECC_ERR_MULT |0x0 |Set to 1 if there is a two-bit error in the packet (ECC Error, multi-bit detected not corrected) | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------+ + | 5|R |CRC_ERROR_VC0 |0x0 |Set to 1 if there is a checksum error on virtual channel 0 (Checksum Error Long packet only) | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------+ + | 6|R |INVLD_DATA_TYPE|0x0 |Set to 1 if the received data is invalid (CSI Data Type Not Recognized) | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------+ + | 7|R |INVLD_VC_ID |0x0 |Set to 1 in case of invalid virtual channel ID (CSI VC ID Invalid) | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------+ + +.. _csi2_ctrl__HS_RX_TIMEOUT_MSB2: HS_RX_TIMEOUT_MSB2 """""""""""""""""" @@ -144,14 +157,16 @@ HS_RX_TIMEOUT_MSB2 Configuration of timeout in high speed mode (MSB2) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+--------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+========================================================+ - |7:0 |R/W|TIME_OUT|High speed request timeout configuration (bits 16 to 23)| - +-----+---+--------+--------------------------------------------------------+ + +-----+---+--------+-----+--------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+========================================================+ + |7:0 |R/W|TIME_OUT|0xFF |High speed request timeout configuration (bits 16 to 23)| + +-----+---+--------+-----+--------------------------------------------------------+ -.. _csi2_ctrl_HS_RX_TIMEOUT_MSB1: +.. _csi2_ctrl__HS_RX_TIMEOUT_MSB1: HS_RX_TIMEOUT_MSB1 """""""""""""""""" @@ -159,14 +174,16 @@ HS_RX_TIMEOUT_MSB1 Configuration of timeout in high speed mode (MSB1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+-------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+=======================================================+ - |7:0 |R/W|TIME_OUT|High speed request timeout configuration (bits 8 to 15)| - +-----+---+--------+-------------------------------------------------------+ + +-----+---+--------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=======================================================+ + |7:0 |R/W|TIME_OUT|0xFF |High speed request timeout configuration (bits 8 to 15)| + +-----+---+--------+-----+-------------------------------------------------------+ -.. _csi2_ctrl_HS_RX_TIMEOUT_LSB: +.. _csi2_ctrl__HS_RX_TIMEOUT_LSB: HS_RX_TIMEOUT_LSB """"""""""""""""" @@ -174,14 +191,16 @@ HS_RX_TIMEOUT_LSB Configuration of timeout in high speed mode (LSB) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+======================================================+ - |7:0 |R/W|TIME_OUT|High speed request timeout configuration (bits 0 to 7)| - +-----+---+--------+------------------------------------------------------+ + +-----+---+--------+-----+------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+======================================================+ + |7:0 |R/W|TIME_OUT|0xFF |High speed request timeout configuration (bits 0 to 7)| + +-----+---+--------+-----+------------------------------------------------------+ -.. _csi2_ctrl_VCCFG: +.. _csi2_ctrl__VCCFG: VCCFG """"" @@ -189,14 +208,16 @@ VCCFG Virtual Channel configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+=============================================================+ - | 0|R/W|VCCFG|Set bit to 1 to enable virtual channel (default: VC0 enabled)| - +-----+---+-----+-------------------------------------------------------------+ + +-----+---+-----+-----+-------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=============================================================+ + | 0|R/W|VCCFG|0x1 |Set bit to 1 to enable virtual channel (default: VC0 enabled)| + +-----+---+-----+-----+-------------------------------------------------------------+ -.. _csi2_ctrl_POLARITY: +.. _csi2_ctrl__POLARITY: POLARITY """""""" @@ -204,16 +225,18 @@ POLARITY Vsync and Hsync polarity .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+---------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+=============================================+ - | 0|R/W|VSYNC|VSYNC polarity: 0: active high, 1: active low| - +-----+---+-----+---------------------------------------------+ - | 1|R/W|HSYNC|HSYNC polarity: 0: active high, 1: active low| - +-----+---+-----+---------------------------------------------+ + +-----+---+-----+-----+---------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=============================================+ + | 0|R/W|VSYNC|0x0 |VSYNC polarity: 0: active high, 1: active low| + +-----+---+-----+-----+---------------------------------------------+ + | 1|R/W|HSYNC|0x0 |HSYNC polarity: 0: active high, 1: active low| + +-----+---+-----+-----+---------------------------------------------+ -.. _csi2_ctrl_CCI_ADDRESS: +.. _csi2_ctrl__CCI_ADDRESS: CCI_ADDRESS """"""""""" @@ -221,14 +244,16 @@ CCI_ADDRESS CCI address .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+---------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+=====================+ - |7:0 |R/W|ADDRESS|CCI interface address| - +-----+---+-------+---------------------+ + +-----+---+-------+-----+---------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=====================+ + |7:0 |R/W|ADDRESS|0x00 |CCI interface address| + +-----+---+-------+-----+---------------------+ -.. _csi2_ctrl_CCI_WRITE_DATA: +.. _csi2_ctrl__CCI_WRITE_DATA: CCI_WRITE_DATA """""""""""""" @@ -236,14 +261,16 @@ CCI_WRITE_DATA CCI write data .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+========================+ - |7:0 |R/W|WR_DATA|CCI interface write data| - +-----+---+-------+------------------------+ + +-----+---+-------+-----+------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+========================+ + |7:0 |R/W|WR_DATA|0x00 |CCI interface write data| + +-----+---+-------+-----+------------------------+ -.. _csi2_ctrl_CCI_READ_DATA: +.. _csi2_ctrl__CCI_READ_DATA: CCI_READ_DATA """"""""""""" @@ -251,14 +278,16 @@ CCI_READ_DATA CCI read data .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-----------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+=======================+ - |7:0 |R |RD_DATA|CCI interface read data| - +-----+---+-------+-----------------------+ + +-----+---+-------+-----+-----------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=======================+ + |7:0 |R |RD_DATA|0x00 |CCI interface read data| + +-----+---+-------+-----+-----------------------+ -.. _csi2_ctrl_CCI_READ_WRITE: +.. _csi2_ctrl__CCI_READ_WRITE: CCI_READ_WRITE """""""""""""" @@ -266,16 +295,18 @@ CCI_READ_WRITE CCI R/W .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+-----------+ - |Bit #|R/W| Name |Description| - +=====+===+=========+===========+ - |6:0 |R/W|CCI_BYTE |CCI byte | - +-----+---+---------+-----------+ - |7 |W |CCI_WRITE|CCI write | - +-----+---+---------+-----------+ + +-----+---+---------+-----+-----------+ + |Bit #|R/W| Name |Reset|Description| + +=====+===+=========+=====+===========+ + |6:0 |R/W|CCI_BYTE |0x00 |CCI byte | + +-----+---+---------+-----+-----------+ + |7 |W |CCI_WRITE|0x0 |CCI write | + +-----+---+---------+-----+-----------+ -.. _csi2_ctrl_CCI_STATUS: +.. _csi2_ctrl__CCI_STATUS: CCI_STATUS """""""""" @@ -283,16 +314,18 @@ CCI_STATUS CCI status .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+-------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+===========================================+ - | 0|R/W|RW_DONE |Read/write transfer done (write 1 to clear)| - +-----+---+---------+-------------------------------------------+ - | 1|R |READ_READ|Is set to 1 if CCI read data available | - +-----+---+---------+-------------------------------------------+ + +-----+---+---------+-----+-------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+===========================================+ + | 0|R/W|RW_DONE |0x0 |Read/write transfer done (write 1 to clear)| + +-----+---+---------+-----+-------------------------------------------+ + | 1|R |READ_READ|0x0 |Is set to 1 if CCI read data available | + +-----+---+---------+-----+-------------------------------------------+ -.. _csi2_ctrl_CCI_DEV_ADDR: +.. _csi2_ctrl__CCI_DEV_ADDR: CCI_DEV_ADDR """""""""""" @@ -300,14 +333,16 @@ CCI_DEV_ADDR CCI device ID .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================+ - |6:0 |R/W|ADDR|CCI device address| - +-----+---+----+------------------+ + +-----+---+----+-----+------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==================+ + |6:0 |R/W|ADDR|0x3C |CCI device address| + +-----+---+----+-----+------------------+ -.. _csi2_ctrl_ULPS_STATUS: +.. _csi2_ctrl__ULPS_STATUS: ULPS_STATUS """"""""""" @@ -315,13 +350,15 @@ ULPS_STATUS CSI2 ULPS status .. table:: - - +-----+---+-----------------+-----------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=================+===========================================================+ - | 0|R |ULPS_ACTIVE_LANE0|Set to 1 if ultra low power state is active for data lane 0| - +-----+---+-----------------+-----------------------------------------------------------+ - | 1|R |ULPS_ACTIVE_LANE1|Set to 1 if ultra low power state is active for data lane 1| - +-----+---+-----------------+-----------------------------------------------------------+ - | 4|R |ULPS_ACTIVE_CLK |Set to 1 if ultra low power state is active for clock lane | - +-----+---+-----------------+-----------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=================+=====+===========================================================+ + | 0|R |ULPS_ACTIVE_LANE0|0x0 |Set to 1 if ultra low power state is active for data lane 0| + +-----+---+-----------------+-----+-----------------------------------------------------------+ + | 1|R |ULPS_ACTIVE_LANE1|0x0 |Set to 1 if ultra low power state is active for data lane 1| + +-----+---+-----------------+-----+-----------------------------------------------------------+ + | 4|R |ULPS_ACTIVE_CLK |0x0 |Set to 1 if ultra low power state is active for clock lane | + +-----+---+-----------------+-----+-----------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/csi2_phy.rst b/rtos/pulp/gap_archi/doc/ips/csi2_phy.rst index 6f667726d..dcef61110 100644 --- a/rtos/pulp/gap_archi/doc/ips/csi2_phy.rst +++ b/rtos/pulp/gap_archi/doc/ips/csi2_phy.rst @@ -8,39 +8,44 @@ Register map for MIPI Digital PHY Overview """""""" -.. table:: - +----------------------------+------+-----+--------------------------------------------------------------+ - | Name |Offset|Width| Description | - +============================+======+=====+==============================================================+ - |:ref:`REG00`| 0| 32|CSI2 DPHY Data lane and clock lane enable register | - +----------------------------+------+-----+--------------------------------------------------------------+ - |:ref:`REG0D`| 52| 32|CSI2 DPHY Digital clock sample manual phase selection register| - +----------------------------+------+-----+--------------------------------------------------------------+ - |:ref:`REG0E`| 56| 32|CSI2 DPHY Clock lane manual phase selection register | - +----------------------------+------+-----+--------------------------------------------------------------+ - |:ref:`REG0F`| 60| 32|CSI2 DPHY Data lanes manual phase selection register | - +----------------------------+------+-----+--------------------------------------------------------------+ - |:ref:`REG12`| 72| 32|CSI2 DPHY Reverse digital sample clock register | - +----------------------------+------+-----+--------------------------------------------------------------+ - |:ref:`REG20`| 128| 32|CSI2 DPHY Digital reset register | - +----------------------------+------+-----+--------------------------------------------------------------+ - |:ref:`REG4A`| 296| 32|CSI2 DPHY Clock lane continuous mode register | - +----------------------------+------+-----+--------------------------------------------------------------+ - |:ref:`REG58`| 352| 32|CSI2 DPHY Clock lane TSH_SETTLE register | - +----------------------------+------+-----+--------------------------------------------------------------+ - |:ref:`REG5A`| 360| 32|CSI2 DPHY Clock lane calibration reception register | - +----------------------------+------+-----+--------------------------------------------------------------+ - |:ref:`REG78`| 480| 32|CSI2 DPHY Data lane 0 TSH_SETTLE register | - +----------------------------+------+-----+--------------------------------------------------------------+ - |:ref:`REG7A`| 488| 32|CSI2 DPHY Data lane 0 calibration reception register | - +----------------------------+------+-----+--------------------------------------------------------------+ - |:ref:`REG98`| 608| 32|CSI2 DPHY Data lane 1 TSH_SETTLE register | - +----------------------------+------+-----+--------------------------------------------------------------+ - |:ref:`REG9A`| 616| 32|CSI2 DPHY Data lane 1 calibration reception register | - +----------------------------+------+-----+--------------------------------------------------------------+ - -.. _csi2_phy_REG00: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-----------------------------+------+-----+--------------------------------------------------------------+ + | Name |Offset|Width| Description | + +=============================+======+=====+==============================================================+ + |:ref:`REG00`| 0| 32|CSI2 DPHY Data lane and clock lane enable register | + +-----------------------------+------+-----+--------------------------------------------------------------+ + |:ref:`REG0D`| 52| 32|CSI2 DPHY Digital clock sample manual phase selection register| + +-----------------------------+------+-----+--------------------------------------------------------------+ + |:ref:`REG0E`| 56| 32|CSI2 DPHY Clock lane manual phase selection register | + +-----------------------------+------+-----+--------------------------------------------------------------+ + |:ref:`REG0F`| 60| 32|CSI2 DPHY Data lanes manual phase selection register | + +-----------------------------+------+-----+--------------------------------------------------------------+ + |:ref:`REG12`| 72| 32|CSI2 DPHY Reverse digital sample clock register | + +-----------------------------+------+-----+--------------------------------------------------------------+ + |:ref:`REG20`| 128| 32|CSI2 DPHY Digital reset register | + +-----------------------------+------+-----+--------------------------------------------------------------+ + |:ref:`REG4A`| 296| 32|CSI2 DPHY Clock lane continuous mode register | + +-----------------------------+------+-----+--------------------------------------------------------------+ + |:ref:`REG58`| 352| 32|CSI2 DPHY Clock lane TSH_SETTLE register | + +-----------------------------+------+-----+--------------------------------------------------------------+ + |:ref:`REG5A`| 360| 32|CSI2 DPHY Clock lane calibration reception register | + +-----------------------------+------+-----+--------------------------------------------------------------+ + |:ref:`REG78`| 480| 32|CSI2 DPHY Data lane 0 TSH_SETTLE register | + +-----------------------------+------+-----+--------------------------------------------------------------+ + |:ref:`REG7A`| 488| 32|CSI2 DPHY Data lane 0 calibration reception register | + +-----------------------------+------+-----+--------------------------------------------------------------+ + |:ref:`REG98`| 608| 32|CSI2 DPHY Data lane 1 TSH_SETTLE register | + +-----------------------------+------+-----+--------------------------------------------------------------+ + |:ref:`REG9A`| 616| 32|CSI2 DPHY Data lane 1 calibration reception register | + +-----------------------------+------+-----+--------------------------------------------------------------+ + +.. _csi2_phy__REG00: REG00 """"" @@ -48,18 +53,20 @@ REG00 CSI2 DPHY Data lane and clock lane enable register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------+------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+====================================+ - | 2|R/W|LANE_EN0 |Enable D-PHY lane 0: active high | - +-----+---+-----------+------------------------------------+ - | 3|R/W|LANE_EN1 |Enable D-PHY lane 1: active high | - +-----+---+-----------+------------------------------------+ - | 6|R/W|LANE_CLK_EN|Enable D-PHY clock lane: active high| - +-----+---+-----------+------------------------------------+ + +-----+---+-----------+-----+------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+====================================+ + | 2|R/W|LANE_EN0 |0x0 |Enable D-PHY lane 0: active high | + +-----+---+-----------+-----+------------------------------------+ + | 3|R/W|LANE_EN1 |0x0 |Enable D-PHY lane 1: active high | + +-----+---+-----------+-----+------------------------------------+ + | 6|R/W|LANE_CLK_EN|0x0 |Enable D-PHY clock lane: active high| + +-----+---+-----------+-----+------------------------------------+ -.. _csi2_phy_REG0D: +.. _csi2_phy__REG0D: REG0D """"" @@ -67,14 +74,16 @@ REG0D CSI2 DPHY Digital clock sample manual phase selection register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------+---------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+=========================================================================================================+ - |2:0 |R/W|SAMPLE_PHASE|Manual phase selection for digital clock sample: 0 to 7, 0 is earliest, 7 is the latest, phase step ~40ps| - +-----+---+------------+---------------------------------------------------------------------------------------------------------+ + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+=========================================================================================================+ + |2:0 |R/W|SAMPLE_PHASE|0x0 |Manual phase selection for digital clock sample: 0 to 7, 0 is earliest, 7 is the latest, phase step ~40ps| + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------+ -.. _csi2_phy_REG0E: +.. _csi2_phy__REG0E: REG0E """"" @@ -82,14 +91,16 @@ REG0E CSI2 DPHY Clock lane manual phase selection register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------+-----------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+===============================================================================================+ - |6:4 |R/W|CLOCK_PHASE|Manual phase selection for clock lane: 0 to 7, 0 is earliest, 7 is the latest, phase step ~40ps| - +-----+---+-----------+-----------------------------------------------------------------------------------------------+ + +-----+---+-----------+-----+-----------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+===============================================================================================+ + |6:4 |R/W|CLOCK_PHASE|0x3 |Manual phase selection for clock lane: 0 to 7, 0 is earliest, 7 is the latest, phase step ~40ps| + +-----+---+-----------+-----+-----------------------------------------------------------------------------------------------+ -.. _csi2_phy_REG0F: +.. _csi2_phy__REG0F: REG0F """"" @@ -97,16 +108,18 @@ REG0F CSI2 DPHY Data lanes manual phase selection register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------+------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+================================================================================================+ - |2:0 |R/W|DATA0_PHASE|Manual phase selection for data lane 0: 0 to 7, 0 is earliest, 7 is the latest, phase step ~40ps| - +-----+---+-----------+------------------------------------------------------------------------------------------------+ - |5:3 |R/W|DATA1_PHASE|Manual phase selection for data lane 1: 0 to 7, 0 is earliest, 7 is the latest, phase step ~40ps| - +-----+---+-----------+------------------------------------------------------------------------------------------------+ + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+================================================================================================+ + |2:0 |R/W|DATA0_PHASE|0x3 |Manual phase selection for data lane 0: 0 to 7, 0 is earliest, 7 is the latest, phase step ~40ps| + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------+ + |5:3 |R/W|DATA1_PHASE|0x3 |Manual phase selection for data lane 1: 0 to 7, 0 is earliest, 7 is the latest, phase step ~40ps| + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------+ -.. _csi2_phy_REG12: +.. _csi2_phy__REG12: REG12 """"" @@ -114,14 +127,16 @@ REG12 CSI2 DPHY Reverse digital sample clock register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------------+--------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+============================================+ - | 7|R/W|SAMPLE_REVERSE|Set to 1 to reverse the digital sample clock| - +-----+---+--------------+--------------------------------------------+ + +-----+---+--------------+-----+--------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+============================================+ + | 7|R/W|SAMPLE_REVERSE|0x0 |Set to 1 to reverse the digital sample clock| + +-----+---+--------------+-----+--------------------------------------------+ -.. _csi2_phy_REG20: +.. _csi2_phy__REG20: REG20 """"" @@ -129,14 +144,16 @@ REG20 CSI2 DPHY Digital reset register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+-----------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+=============================+ - | 0|R/W|DIG_RSTN|Set to 0 to reset digital PHY| - +-----+---+--------+-----------------------------+ + +-----+---+--------+-----+-----------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============================+ + | 0|R/W|DIG_RSTN|0x1 |Set to 0 to reset digital PHY| + +-----+---+--------+-----+-----------------------------+ -.. _csi2_phy_REG4A: +.. _csi2_phy__REG4A: REG4A """"" @@ -144,14 +161,16 @@ REG4A CSI2 DPHY Clock lane continuous mode register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+--------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+==================================================+ - |5:4 |R/W|CLK_CONTINOUS|Continuous clock mode: b00: disabled, b11: enabled| - +-----+---+-------------+--------------------------------------------------+ + +-----+---+-------------+-----+--------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+==================================================+ + |5:4 |R/W|CLK_CONTINOUS|0x0 |Continuous clock mode: b00: disabled, b11: enabled| + +-----+---+-------------+-----+--------------------------------------------------+ -.. _csi2_phy_REG58: +.. _csi2_phy__REG58: REG58 """"" @@ -159,14 +178,16 @@ REG58 CSI2 DPHY Clock lane TSH_SETTLE register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+=======================================================================================================================================================================+ - |7:0 |R/W|THS_SETTLE|Configure the count time of the THS_SETTLE by protocol. After count done, D-PHY will begin to receive the high speed data. See the note below for configuration values.| - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+=======================================================================================================================================================================+ + |7:0 |R/W|THS_SETTLE|0x1B |Configure the count time of the THS_SETTLE by protocol. After count done, D-PHY will begin to receive the high speed data. See the note below for configuration values.| + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _csi2_phy_REG5A: +.. _csi2_phy__REG5A: REG5A """"" @@ -174,14 +195,16 @@ REG5A CSI2 DPHY Clock lane calibration reception register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+---------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+===============================================================+ - | 7|R/W|CALIBRATE|Calibration reception enable - 1'b0 : disable ; - 1'b1 : enable| - +-----+---+---------+---------------------------------------------------------------+ + +-----+---+---------+-----+---------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+===============================================================+ + | 7|R/W|CALIBRATE|0x0 |Calibration reception enable - 1'b0 : disable ; - 1'b1 : enable| + +-----+---+---------+-----+---------------------------------------------------------------+ -.. _csi2_phy_REG78: +.. _csi2_phy__REG78: REG78 """"" @@ -189,14 +212,16 @@ REG78 CSI2 DPHY Data lane 0 TSH_SETTLE register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+=======================================================================================================================================================================+ - |7:0 |R/W|THS_SETTLE|Configure the count time of the THS_SETTLE by protocol. After count done, D-PHY will begin to receive the high speed data. See the note below for configuration values.| - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+=======================================================================================================================================================================+ + |7:0 |R/W|THS_SETTLE|0x1B |Configure the count time of the THS_SETTLE by protocol. After count done, D-PHY will begin to receive the high speed data. See the note below for configuration values.| + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _csi2_phy_REG7A: +.. _csi2_phy__REG7A: REG7A """"" @@ -204,14 +229,16 @@ REG7A CSI2 DPHY Data lane 0 calibration reception register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+---------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+===============================================================+ - | 7|R/W|CALIBRATE|Calibration reception enable - 1'b0 : disable ; - 1'b1 : enable| - +-----+---+---------+---------------------------------------------------------------+ + +-----+---+---------+-----+---------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+===============================================================+ + | 7|R/W|CALIBRATE|0x0 |Calibration reception enable - 1'b0 : disable ; - 1'b1 : enable| + +-----+---+---------+-----+---------------------------------------------------------------+ -.. _csi2_phy_REG98: +.. _csi2_phy__REG98: REG98 """"" @@ -219,14 +246,16 @@ REG98 CSI2 DPHY Data lane 1 TSH_SETTLE register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+=======================================================================================================================================================================+ - |7:0 |R/W|THS_SETTLE|Configure the count time of the THS_SETTLE by protocol. After count done, D-PHY will begin to receive the high speed data. See the note below for configuration values.| - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+=======================================================================================================================================================================+ + |7:0 |R/W|THS_SETTLE|0x1B |Configure the count time of the THS_SETTLE by protocol. After count done, D-PHY will begin to receive the high speed data. See the note below for configuration values.| + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _csi2_phy_REG9A: +.. _csi2_phy__REG9A: REG9A """"" @@ -234,9 +263,11 @@ REG9A CSI2 DPHY Data lane 1 calibration reception register .. table:: - - +-----+---+---------+---------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+===============================================================+ - | 7|R/W|CALIBRATE|Calibration reception enable - 1'b0 : disable ; - 1'b1 : enable| - +-----+---+---------+---------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+---------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+===============================================================+ + | 7|R/W|CALIBRATE|0x0 |Calibration reception enable - 1'b0 : disable ; - 1'b1 : enable| + +-----+---+---------+-----+---------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/efuse.rst b/rtos/pulp/gap_archi/doc/ips/efuse.rst index bbc66939f..8d2218ebd 100644 --- a/rtos/pulp/gap_archi/doc/ips/efuse.rst +++ b/rtos/pulp/gap_archi/doc/ips/efuse.rst @@ -8,38 +8,45 @@ Register map Overview """""""" + +Refer to :ref:`GAP9 address map` for the base address to be used. + .. table:: + :align: center + :widths: 40 12 12 90 - +---------------------------------------+------+-----+---------------------------------------------+ - | Name |Offset|Width| Description | - +=======================================+======+=====+=============================================+ - |:ref:`CMD` | 0| 32|CMD register for efuses | - +---------------------------------------+------+-----+---------------------------------------------+ - |:ref:`CFG` | 4| 32|CFG register for timings | - +---------------------------------------+------+-----+---------------------------------------------+ - |:ref:`PAGE_PROTECT`| 8| 32|Protection (RO mode) register for efuse pages| - +---------------------------------------+------+-----+---------------------------------------------+ + +----------------------------------------+------+-----+---------------------------------------------+ + | Name |Offset|Width| Description | + +========================================+======+=====+=============================================+ + |:ref:`CMD` | 0| 32|CMD register for eFuses | + +----------------------------------------+------+-----+---------------------------------------------+ + |:ref:`CFG` | 4| 32|CFG register for timings | + +----------------------------------------+------+-----+---------------------------------------------+ + |:ref:`PAGE_PROTECT`| 8| 32|Protection (RO mode) register for eFuse pages| + +----------------------------------------+------+-----+---------------------------------------------+ -.. _efuse_CMD: +.. _efuse__CMD: CMD """ -CMD register for efuses +CMD register for eFuses .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-----------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+=================+ - | 0|R/W|READ |Enable read mode | - +-----+---+-----+-----------------+ - | 1|R/W|WRITE|Enable write mode| - +-----+---+-----+-----------------+ - | 2|R/W|IDLE |Enable idle mode | - +-----+---+-----+-----------------+ + +-----+---+-----+-----+-----------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=================+ + | 0|R/W|READ |0x0 |Enable read mode | + +-----+---+-----+-----+-----------------+ + | 1|R/W|WRITE|0x0 |Enable write mode| + +-----+---+-----+-----+-----------------+ + | 2|R/W|IDLE |0x0 |Enable idle mode | + +-----+---+-----+-----+-----------------+ -.. _efuse_CFG: +.. _efuse__CFG: CFG """ @@ -47,29 +54,36 @@ CFG CFG register for timings .. table:: - - +-----+---+-----------+----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+==================================+ - |5:0 |R/W|CNT_TARGET0|Enable or Disable TLB mode | - +-----+---+-----------+----------------------------------+ - |15:6 |R/W|CNT_TARGET1|Flag to check whether device is RO| - +-----+---+-----------+----------------------------------+ - |29:16|R/W|CNT_TARGET2|Flag to check whether device is RO| - +-----+---+-----------+----------------------------------+ - |31:30|R/W|MARGIN |Flag to check whether device is RO| - +-----+---+-----------+----------------------------------+ - -.. _efuse_PAGE_PROTECT: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------+-----+---------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+=======================================+ + |5:0 |R/W|CNT_TARGET0|0x2 |Counter value to generate short delays | + +-----+---+-----------+-----+---------------------------------------+ + |15:6 |R/W|CNT_TARGET1|0x32 |Counter value to generate medium delays| + +-----+---+-----------+-----+---------------------------------------+ + |29:16|R/W|CNT_TARGET2|0x1F4|Counter value to generate long delays | + +-----+---+-----------+-----+---------------------------------------+ + |31:30|R/W|MARGIN |0x0 |EFuse read margin | + +-----+---+-----------+-----+---------------------------------------+ + +.. _efuse__PAGE_PROTECT: PAGE_PROTECT """""""""""" -Protection (RO mode) register for efuse pages +Protection (RO mode) register for eFuse pages .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+-----------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=================================================================+ + |7:0 |R/W|PROTECTED|0x0 |Protected pages. Bit *i* is 1 means page *i* is in read only mode| + +-----+---+---------+-----+-----------------------------------------------------------------+ + |31 |R/W|LOCK |0x0 |If 1, PAGE_PROTECT register cannot be overwritten | + +-----+---+---------+-----+-----------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/fc_icache_ctrl.rst b/rtos/pulp/gap_archi/doc/ips/fc_icache_ctrl.rst index 705c7a334..6f03055c4 100644 --- a/rtos/pulp/gap_archi/doc/ips/fc_icache_ctrl.rst +++ b/rtos/pulp/gap_archi/doc/ips/fc_icache_ctrl.rst @@ -8,21 +8,26 @@ Register map Overview """""""" -.. table:: - +------------------------------------------+------+-----+-----------------------------------------------------------+ - | Name |Offset|Width| Description | - +==========================================+======+=====+===========================================================+ - |:ref:`ENABLE` | 0| 32|FC instruction cache unit enable configuration register. | - +------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`FLUSH` | 4| 32|FC instruction cache unit flush command register. | - +------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SEL_FLUSH`| 8| 32|FC instruction cache unit selective flush command register.| - +------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`STATUS` | 12| 32|FC instruction cache unit status register. | - +------------------------------------------+------+-----+-----------------------------------------------------------+ +Refer to :ref:`GAP9 address map` for the base address to be used. -.. _fc_icache_ctrl_ENABLE: +.. table:: + :align: center + :widths: 40 12 12 90 + + +-------------------------------------------+------+-----+-----------------------------------------------------------+ + | Name |Offset|Width| Description | + +===========================================+======+=====+===========================================================+ + |:ref:`ENABLE` | 0| 32|FC instruction cache unit enable configuration register. | + +-------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`FLUSH` | 4| 32|FC instruction cache unit flush command register. | + +-------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SEL_FLUSH`| 8| 32|FC instruction cache unit selective flush command register.| + +-------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`STATUS` | 12| 32|FC instruction cache unit status register. | + +-------------------------------------------+------+-----+-----------------------------------------------------------+ + +.. _fc_icache_ctrl__ENABLE: ENABLE """""" @@ -30,13 +35,16 @@ ENABLE FC instruction cache unit enable configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+======================================================+ + | 0|W |ENABLE|0x0 |Enable FC instruction cache: b0: disabled; b1: enabled| + +-----+---+------+-----+------------------------------------------------------+ -.. _fc_icache_ctrl_FLUSH: +.. _fc_icache_ctrl__FLUSH: FLUSH """"" @@ -44,13 +52,16 @@ FLUSH FC instruction cache unit flush command register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-----------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===============================================+ + | 0|W |FLUSH|0x0 |Write 1 to fully flush the FC instruction cache| + +-----+---+-----+-----+-----------------------------------------------+ -.. _fc_icache_ctrl_SEL_FLUSH: +.. _fc_icache_ctrl__SEL_FLUSH: SEL_FLUSH """"""""" @@ -58,13 +69,16 @@ SEL_FLUSH FC instruction cache unit selective flush command register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+---------+-----+----------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+========================================+ + |31:0 |W |SEL_FLUSH|0x0 |Write an address to selectively flush it| + +-----+---+---------+-----+----------------------------------------+ -.. _fc_icache_ctrl_STATUS: +.. _fc_icache_ctrl__STATUS: STATUS """""" @@ -72,8 +86,11 @@ STATUS FC instruction cache unit status register. .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------+-----+-------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=====================================================================================+ + | 0|R |STATUS|0x0 |Pending action status flag: b0: no pending caching action; b1: pending caching action| + +-----+---+------+-----+-------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/fc_itc.rst b/rtos/pulp/gap_archi/doc/ips/fc_itc.rst index 1d62c884f..7262429a8 100644 --- a/rtos/pulp/gap_archi/doc/ips/fc_itc.rst +++ b/rtos/pulp/gap_archi/doc/ips/fc_itc.rst @@ -8,168 +8,146 @@ Register map Overview """""""" -.. table:: - +----------------------------------------+------+-----+-------------------------------------+ - | Name |Offset|Width| Description | - +========================================+======+=====+=====================================+ - |:ref:`MASK` | 0| 32|FC_ITC Mask status register. | - +----------------------------------------+------+-----+-------------------------------------+ - |:ref:`MASK_SET` | 4| 32|FC_ITC Mask set register. | - +----------------------------------------+------+-----+-------------------------------------+ - |:ref:`MASK_CLEAR` | 8| 32|FC_ITC Mask clear register. | - +----------------------------------------+------+-----+-------------------------------------+ - |:ref:`STATUS` | 12| 32|FC_ITC interrupt status register. | - +----------------------------------------+------+-----+-------------------------------------+ - |:ref:`STATUS_SET` | 16| 32|FC_ITC interrupt enable register. | - +----------------------------------------+------+-----+-------------------------------------+ - |:ref:`STATUS_CLEAR`| 20| 32|FC_ITC interrupt clear register. | - +----------------------------------------+------+-----+-------------------------------------+ - |:ref:`ACK` | 24| 32|FC_ITC interrupt ack status register.| - +----------------------------------------+------+-----+-------------------------------------+ - |:ref:`ACK_SET` | 28| 32|FC_ITC interrupt ack set register. | - +----------------------------------------+------+-----+-------------------------------------+ - |:ref:`ACK_CLEAR` | 32| 32|FC_ITC interrupt ack clear register. | - +----------------------------------------+------+-----+-------------------------------------+ - |:ref:`FIFO` | 36| 32|FC_ITC event number fifo register. | - +----------------------------------------+------+-----+-------------------------------------+ - -.. _fc_itc_MASK: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-----------------------------------------+------+-----+-------------------------------+ + | Name |Offset|Width| Description | + +=========================================+======+=====+===============================+ + |:ref:`MASK` | 0| 32|Mask status register. | + +-----------------------------------------+------+-----+-------------------------------+ + |:ref:`MASK_SET` | 4| 32|Mask set register. | + +-----------------------------------------+------+-----+-------------------------------+ + |:ref:`MASK_CLEAR` | 8| 32|Mask clear register. | + +-----------------------------------------+------+-----+-------------------------------+ + |:ref:`STATUS` | 12| 32|Interrupt status register. | + +-----------------------------------------+------+-----+-------------------------------+ + |:ref:`STATUS_SET` | 16| 32|Interrupt enable register. | + +-----------------------------------------+------+-----+-------------------------------+ + |:ref:`STATUS_CLEAR`| 20| 32|Interrupt clear register. | + +-----------------------------------------+------+-----+-------------------------------+ + |:ref:`FIFO` | 36| 32|Read access to SoC events FIFO.| + +-----------------------------------------+------+-----+-------------------------------+ + +.. _fc_itc__MASK: MASK """" -FC_ITC Mask status register. +Mask status register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+----------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+====================================================+ + |31:0 |R/W|IT_MASK|0x0 |Interrupt mask: set bit i to 1 to enable interrupt i| + +-----+---+-------+-----+----------------------------------------------------+ -.. _fc_itc_MASK_SET: +.. _fc_itc__MASK_SET: MASK_SET """""""" -FC_ITC Mask set register. +Mask set register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----------+-----+----------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+==============================================+ + |31:0 |W |IT_MASK_SET|0x0 |Write 1 to bit i to set bit i of MASK register| + +-----+---+-----------+-----+----------------------------------------------+ -.. _fc_itc_MASK_CLEAR: +.. _fc_itc__MASK_CLEAR: MASK_CLEAR """""""""" -FC_ITC Mask clear register. +Mask clear register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------------+-----+------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+================================================+ + |31:0 |W |IT_MASK_CLEAR|0x0 |Write 1 to bit i to clear bit i of MASK register| + +-----+---+-------------+-----+------------------------------------------------+ -.. _fc_itc_STATUS: +.. _fc_itc__STATUS: STATUS """""" -FC_ITC interrupt status register. +Interrupt status register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+---------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=======================================================+ + |31:0 |R/W|IT_STATUS|0x0 |Interrupt status: bit i is 1 when interrupt i is active| + +-----+---+---------+-----+-------------------------------------------------------+ -.. _fc_itc_STATUS_SET: +.. _fc_itc__STATUS_SET: STATUS_SET """""""""" -FC_ITC interrupt enable register. +Interrupt enable register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------------+-----+------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+================================================+ + |31:0 |W |IT_STATUS_SET|0x0 |Write 1 to bit i to set bit i of STATUS register| + +-----+---+-------------+-----+------------------------------------------------+ -.. _fc_itc_STATUS_CLEAR: +.. _fc_itc__STATUS_CLEAR: STATUS_CLEAR """""""""""" -FC_ITC interrupt clear register. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_itc_ACK: - -ACK -""" - -FC_ITC interrupt ack status register. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_itc_ACK_SET: - -ACK_SET -""""""" - -FC_ITC interrupt ack set register. +Interrupt clear register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_itc_ACK_CLEAR: - -ACK_CLEAR -""""""""" + +-----+---+---------------+-----+--------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+==================================================+ + |31:0 |W |IT_STATUS_CLEAR|0x0 |Write 1 to bit i to clear bit i of STATUS register| + +-----+---+---------------+-----+--------------------------------------------------+ -FC_ITC interrupt ack clear register. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_itc_FIFO: +.. _fc_itc__FIFO: FIFO """" -FC_ITC event number fifo register. +Read access to SoC events FIFO. .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+-----------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=============================================================================+ + |31:0 |R |EVENT_NUM|0x0 |Reading this field pops an event from SoC event FIFO and returns the event ID| + +-----+---+---------+-----+-----------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/fc_mpu.rst b/rtos/pulp/gap_archi/doc/ips/fc_mpu.rst index d8ee55082..a0fc43d96 100644 --- a/rtos/pulp/gap_archi/doc/ips/fc_mpu.rst +++ b/rtos/pulp/gap_archi/doc/ips/fc_mpu.rst @@ -8,63 +8,68 @@ Register map Overview """""""" -.. table:: - +------------------------------------------+------+-----+-----------------------------------------------+ - | Name |Offset|Width| Description | - +==========================================+======+=====+===============================================+ - |:ref:`MPU_ENABLE` | 0| 32|MPU enable configuration register | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`FC_TCDM_RULE0`| 64| 32|FC address filter rule 0 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`FC_TCDM_RULE1`| 68| 32|FC address filter rule 1 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`FC_TCDM_RULE2`| 72| 32|FC address filter rule 2 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`FC_TCDM_RULE3`| 76| 32|FC address filter rule 3 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`FC_TCDM_RULE4`| 80| 32|FC address filter rule 4 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`FC_TCDM_RULE5`| 84| 32|FC address filter rule 5 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`FC_TCDM_RULE6`| 88| 32|FC address filter rule 6 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`FC_TCDM_RULE7`| 92| 32|FC address filter rule 7 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`L2_RULE0` | 128| 32|L2 address filter rule 0 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`L2_RULE1` | 132| 32|L2 address filter rule 1 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`L2_RULE2` | 136| 32|L2 address filter rule 2 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`L2_RULE3` | 140| 32|L2 address filter rule 3 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`L2_RULE4` | 144| 32|L2 address filter rule 4 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`L2_RULE5` | 148| 32|L2 address filter rule 5 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`L2_RULE6` | 152| 32|L2 address filter rule 6 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`L2_RULE7` | 156| 32|L2 address filter rule 7 | - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`APB_RULE0` | 192| 32|External peripheral (APB) address filter rule 0| - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`APB_RULE1` | 196| 32|External peripheral (APB) address filter rule 1| - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`APB_RULE2` | 200| 32|External peripheral (APB) address filter rule 2| - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`APB_RULE3` | 204| 32|External peripheral (APB) address filter rule 3| - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`APB_RULE4` | 208| 32|External peripheral (APB) address filter rule 4| - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`APB_RULE5` | 212| 32|External peripheral (APB) address filter rule 5| - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`APB_RULE6` | 216| 32|External peripheral (APB) address filter rule 6| - +------------------------------------------+------+-----+-----------------------------------------------+ - |:ref:`APB_RULE7` | 220| 32|External peripheral (APB) address filter rule 7| - +------------------------------------------+------+-----+-----------------------------------------------+ - -.. _fc_mpu_MPU_ENABLE: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-------------------------------------------+------+-----+-----------------------------------------------+ + | Name |Offset|Width| Description | + +===========================================+======+=====+===============================================+ + |:ref:`MPU_ENABLE` | 0| 32|MPU enable configuration register | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`FC_TCDM_RULE0`| 64| 32|FC address filter rule 0 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`FC_TCDM_RULE1`| 68| 32|FC address filter rule 1 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`FC_TCDM_RULE2`| 72| 32|FC address filter rule 2 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`FC_TCDM_RULE3`| 76| 32|FC address filter rule 3 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`FC_TCDM_RULE4`| 80| 32|FC address filter rule 4 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`FC_TCDM_RULE5`| 84| 32|FC address filter rule 5 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`FC_TCDM_RULE6`| 88| 32|FC address filter rule 6 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`FC_TCDM_RULE7`| 92| 32|FC address filter rule 7 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`L2_RULE0` | 128| 32|L2 address filter rule 0 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`L2_RULE1` | 132| 32|L2 address filter rule 1 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`L2_RULE2` | 136| 32|L2 address filter rule 2 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`L2_RULE3` | 140| 32|L2 address filter rule 3 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`L2_RULE4` | 144| 32|L2 address filter rule 4 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`L2_RULE5` | 148| 32|L2 address filter rule 5 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`L2_RULE6` | 152| 32|L2 address filter rule 6 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`L2_RULE7` | 156| 32|L2 address filter rule 7 | + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`APB_RULE0` | 192| 32|External peripheral (APB) address filter rule 0| + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`APB_RULE1` | 196| 32|External peripheral (APB) address filter rule 1| + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`APB_RULE2` | 200| 32|External peripheral (APB) address filter rule 2| + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`APB_RULE3` | 204| 32|External peripheral (APB) address filter rule 3| + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`APB_RULE4` | 208| 32|External peripheral (APB) address filter rule 4| + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`APB_RULE5` | 212| 32|External peripheral (APB) address filter rule 5| + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`APB_RULE6` | 216| 32|External peripheral (APB) address filter rule 6| + +-------------------------------------------+------+-----+-----------------------------------------------+ + |:ref:`APB_RULE7` | 220| 32|External peripheral (APB) address filter rule 7| + +-------------------------------------------+------+-----+-----------------------------------------------+ + +.. _fc_mpu__MPU_ENABLE: MPU_ENABLE """""""""" @@ -72,13 +77,16 @@ MPU_ENABLE MPU enable configuration register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+----------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+====================================================+ + | 0|R/W|ENABLE|0x0 |MPU enable status: b0: MPU disabled, b1: MPU enabled| + +-----+---+------+-----+----------------------------------------------------+ -.. _fc_mpu_FC_TCDM_RULE0: +.. _fc_mpu__FC_TCDM_RULE0: FC_TCDM_RULE0 """"""""""""" @@ -86,13 +94,22 @@ FC_TCDM_RULE0 FC address filter rule 0 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_FC_TCDM_RULE1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===================================================================================================================================================================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area (MSB indicates aliased memory area, LSB indicates L1 memory or peripheral memory): b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: L1 memory aliased (0x10000000); b11: Peripheral memory aliased (0x10200000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state: b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__FC_TCDM_RULE1: FC_TCDM_RULE1 """"""""""""" @@ -100,13 +117,22 @@ FC_TCDM_RULE1 FC address filter rule 1 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_FC_TCDM_RULE2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===================================================================================================================================================================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area (MSB indicates aliased memory area, LSB indicates L1 memory or peripheral memory): b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: L1 memory aliased (0x10000000); b11: Peripheral memory aliased (0x10200000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state: b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__FC_TCDM_RULE2: FC_TCDM_RULE2 """"""""""""" @@ -114,13 +140,22 @@ FC_TCDM_RULE2 FC address filter rule 2 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_FC_TCDM_RULE3: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===================================================================================================================================================================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area (MSB indicates aliased memory area, LSB indicates L1 memory or peripheral memory): b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: L1 memory aliased (0x10000000); b11: Peripheral memory aliased (0x10200000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state: b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__FC_TCDM_RULE3: FC_TCDM_RULE3 """"""""""""" @@ -128,13 +163,22 @@ FC_TCDM_RULE3 FC address filter rule 3 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_FC_TCDM_RULE4: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===================================================================================================================================================================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area (MSB indicates aliased memory area, LSB indicates L1 memory or peripheral memory): b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: L1 memory aliased (0x10000000); b11: Peripheral memory aliased (0x10200000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state: b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__FC_TCDM_RULE4: FC_TCDM_RULE4 """"""""""""" @@ -142,13 +186,22 @@ FC_TCDM_RULE4 FC address filter rule 4 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_FC_TCDM_RULE5: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===================================================================================================================================================================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area (MSB indicates aliased memory area, LSB indicates L1 memory or peripheral memory): b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: L1 memory aliased (0x10000000); b11: Peripheral memory aliased (0x10200000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state: b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__FC_TCDM_RULE5: FC_TCDM_RULE5 """"""""""""" @@ -156,13 +209,22 @@ FC_TCDM_RULE5 FC address filter rule 5 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_FC_TCDM_RULE6: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===================================================================================================================================================================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area (MSB indicates aliased memory area, LSB indicates L1 memory or peripheral memory): b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: L1 memory aliased (0x10000000); b11: Peripheral memory aliased (0x10200000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state: b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__FC_TCDM_RULE6: FC_TCDM_RULE6 """"""""""""" @@ -170,13 +232,22 @@ FC_TCDM_RULE6 FC address filter rule 6 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_FC_TCDM_RULE7: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===================================================================================================================================================================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area (MSB indicates aliased memory area, LSB indicates L1 memory or peripheral memory): b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: L1 memory aliased (0x10000000); b11: Peripheral memory aliased (0x10200000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state: b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__FC_TCDM_RULE7: FC_TCDM_RULE7 """"""""""""" @@ -184,13 +255,22 @@ FC_TCDM_RULE7 FC address filter rule 7 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_L2_RULE0: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===================================================================================================================================================================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area (MSB indicates aliased memory area, LSB indicates L1 memory or peripheral memory): b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: L1 memory aliased (0x10000000); b11: Peripheral memory aliased (0x10200000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state: b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__L2_RULE0: L2_RULE0 """""""" @@ -198,13 +278,22 @@ L2_RULE0 L2 address filter rule 0 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_L2_RULE1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+----------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================+ + |31:30|R/W|A |0x0 |Area: unused. Always uses 0x1C000000. | + +-----+---+----+-----+----------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+----------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+----------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled| + +-----+---+----+-----+----------------------------------------------+ + +.. _fc_mpu__L2_RULE1: L2_RULE1 """""""" @@ -212,13 +301,22 @@ L2_RULE1 L2 address filter rule 1 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_L2_RULE2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+----------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================+ + |31:30|R/W|A |0x0 |Area: unused. Always uses 0x1C000000. | + +-----+---+----+-----+----------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+----------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+----------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled| + +-----+---+----+-----+----------------------------------------------+ + +.. _fc_mpu__L2_RULE2: L2_RULE2 """""""" @@ -226,13 +324,22 @@ L2_RULE2 L2 address filter rule 2 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_L2_RULE3: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+----------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================+ + |31:30|R/W|A |0x0 |Area: unused. Always uses 0x1C000000. | + +-----+---+----+-----+----------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+----------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+----------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled| + +-----+---+----+-----+----------------------------------------------+ + +.. _fc_mpu__L2_RULE3: L2_RULE3 """""""" @@ -240,13 +347,22 @@ L2_RULE3 L2 address filter rule 3 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_L2_RULE4: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+----------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================+ + |31:30|R/W|A |0x0 |Area: unused. Always uses 0x1C000000. | + +-----+---+----+-----+----------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+----------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+----------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled| + +-----+---+----+-----+----------------------------------------------+ + +.. _fc_mpu__L2_RULE4: L2_RULE4 """""""" @@ -254,13 +370,22 @@ L2_RULE4 L2 address filter rule 4 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_L2_RULE5: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+----------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================+ + |31:30|R/W|A |0x0 |Area: unused. Always uses 0x1C000000. | + +-----+---+----+-----+----------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+----------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+----------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled| + +-----+---+----+-----+----------------------------------------------+ + +.. _fc_mpu__L2_RULE5: L2_RULE5 """""""" @@ -268,13 +393,22 @@ L2_RULE5 L2 address filter rule 5 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_L2_RULE6: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+----------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================+ + |31:30|R/W|A |0x0 |Area: unused. Always uses 0x1C000000. | + +-----+---+----+-----+----------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+----------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+----------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled| + +-----+---+----+-----+----------------------------------------------+ + +.. _fc_mpu__L2_RULE6: L2_RULE6 """""""" @@ -282,13 +416,22 @@ L2_RULE6 L2 address filter rule 6 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_L2_RULE7: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+----------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================+ + |31:30|R/W|A |0x0 |Area: unused. Always uses 0x1C000000. | + +-----+---+----+-----+----------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+----------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+----------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled| + +-----+---+----+-----+----------------------------------------------+ + +.. _fc_mpu__L2_RULE7: L2_RULE7 """""""" @@ -296,13 +439,22 @@ L2_RULE7 L2 address filter rule 7 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_APB_RULE0: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+----------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================+ + |31:30|R/W|A |0x0 |Area: unused. Always uses 0x1C000000. | + +-----+---+----+-----+----------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+----------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+----------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled| + +-----+---+----+-----+----------------------------------------------+ + +.. _fc_mpu__APB_RULE0: APB_RULE0 """"""""" @@ -310,13 +462,22 @@ APB_RULE0 External peripheral (APB) address filter rule 0 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_APB_RULE1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area: b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: APB memory (0x1A100000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__APB_RULE1: APB_RULE1 """"""""" @@ -324,13 +485,22 @@ APB_RULE1 External peripheral (APB) address filter rule 1 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_APB_RULE2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area: b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: APB memory (0x1A100000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__APB_RULE2: APB_RULE2 """"""""" @@ -338,13 +508,22 @@ APB_RULE2 External peripheral (APB) address filter rule 2 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_APB_RULE3: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area: b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: APB memory (0x1A100000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__APB_RULE3: APB_RULE3 """"""""" @@ -352,13 +531,22 @@ APB_RULE3 External peripheral (APB) address filter rule 3 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_APB_RULE4: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area: b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: APB memory (0x1A100000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__APB_RULE4: APB_RULE4 """"""""" @@ -366,13 +554,22 @@ APB_RULE4 External peripheral (APB) address filter rule 4 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_APB_RULE5: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area: b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: APB memory (0x1A100000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__APB_RULE5: APB_RULE5 """"""""" @@ -380,13 +577,22 @@ APB_RULE5 External peripheral (APB) address filter rule 5 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_APB_RULE6: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area: b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: APB memory (0x1A100000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__APB_RULE6: APB_RULE6 """"""""" @@ -394,13 +600,22 @@ APB_RULE6 External peripheral (APB) address filter rule 6 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _fc_mpu_APB_RULE7: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area: b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: APB memory (0x1A100000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fc_mpu__APB_RULE7: APB_RULE7 """"""""" @@ -408,8 +623,17 @@ APB_RULE7 External peripheral (APB) address filter rule 7 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================================================================================================================================+ + |31:30|R/W|A |0x0 |Area: b00: L1 memory (0x01B00000); b01: Peripheral memory (0x1B200000); b10: APB memory (0x1A100000). The unprotected area will start at the A base + 64K * base and will be 64K * size long.| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:15|R/W|BASE|0x0 |Area address base in 64kB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:1 |R/W|SIZE|0x0 |Area size in 64KB pages | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|ST |0x0 |Rule state b0: Rule disabled; b1: Rule enabled | + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/fll.rst b/rtos/pulp/gap_archi/doc/ips/fll.rst index e295e9f67..00b503e42 100644 --- a/rtos/pulp/gap_archi/doc/ips/fll.rst +++ b/rtos/pulp/gap_archi/doc/ips/fll.rst @@ -8,39 +8,44 @@ Register map Overview """""""" -.. table:: - +-----------------------+------+-----+------------------------------+ - | Name |Offset|Width| Description | - +=======================+======+=====+==============================+ - |:ref:`FSR` | 0| 32|FLL status register | - +-----------------------+------+-----+------------------------------+ - |:ref:`DRR` | 4| 32|DCO Range register | - +-----------------------+------+-----+------------------------------+ - |:ref:`TTR` | 8| 32|Temperature Tracking Register | - +-----------------------+------+-----+------------------------------+ - |:ref:`F0CR1`| 12| 32|FLL0 Configuration Register 1 | - +-----------------------+------+-----+------------------------------+ - |:ref:`F0CR2`| 16| 32|FLL0 Configuration Register 2 | - +-----------------------+------+-----+------------------------------+ - |:ref:`F1CR1`| 20| 32|FLL1 Configuration Register 1 | - +-----------------------+------+-----+------------------------------+ - |:ref:`F1CR2`| 24| 32|FLL1 Configuration Register 2 | - +-----------------------+------+-----+------------------------------+ - |:ref:`F2CR1`| 28| 32|FLL2 Configuration Register 1 | - +-----------------------+------+-----+------------------------------+ - |:ref:`F2CR2`| 32| 32|FLL2 Configuration Register 2 | - +-----------------------+------+-----+------------------------------+ - |:ref:`F3CR1`| 36| 32|FLL3 Configuration Register 1 | - +-----------------------+------+-----+------------------------------+ - |:ref:`F3CR2`| 40| 32|FLL3 Configuration Register 2 | - +-----------------------+------+-----+------------------------------+ - |:ref:`CCR1` | 44| 32|Clock Configuration register 1| - +-----------------------+------+-----+------------------------------+ - |:ref:`CCR2` | 48| 32|Clock Configuration register 2| - +-----------------------+------+-----+------------------------------+ - -.. _fll_FSR: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +------------------------+------+-----+------------------------------+ + | Name |Offset|Width| Description | + +========================+======+=====+==============================+ + |:ref:`FSR` | 0| 32|FLL status register | + +------------------------+------+-----+------------------------------+ + |:ref:`DRR` | 4| 32|DCO Range register | + +------------------------+------+-----+------------------------------+ + |:ref:`TTR` | 8| 32|Temperature Tracking Register | + +------------------------+------+-----+------------------------------+ + |:ref:`F0CR1`| 12| 32|FLL0 Configuration Register 1 | + +------------------------+------+-----+------------------------------+ + |:ref:`F0CR2`| 16| 32|FLL0 Configuration Register 2 | + +------------------------+------+-----+------------------------------+ + |:ref:`F1CR1`| 20| 32|FLL1 Configuration Register 1 | + +------------------------+------+-----+------------------------------+ + |:ref:`F1CR2`| 24| 32|FLL1 Configuration Register 2 | + +------------------------+------+-----+------------------------------+ + |:ref:`F2CR1`| 28| 32|FLL2 Configuration Register 1 | + +------------------------+------+-----+------------------------------+ + |:ref:`F2CR2`| 32| 32|FLL2 Configuration Register 2 | + +------------------------+------+-----+------------------------------+ + |:ref:`F3CR1`| 36| 32|FLL3 Configuration Register 1 | + +------------------------+------+-----+------------------------------+ + |:ref:`F3CR2`| 40| 32|FLL3 Configuration Register 2 | + +------------------------+------+-----+------------------------------+ + |:ref:`CCR1` | 44| 32|Clock Configuration register 1| + +------------------------+------+-----+------------------------------+ + |:ref:`CCR2` | 48| 32|Clock Configuration register 2| + +------------------------+------+-----+------------------------------+ + +.. _fll__FSR: FSR """ @@ -48,46 +53,48 @@ FSR FLL status register .. table:: - - +-----+---+------------+--------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+================================================================================+ - | 0|R |LOCK0 |LOCK0. Lock status for Feedback clock 0. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 1|R |CLMP_LO_ERR0|Clamp error low for FLL0. Set when new DCO value for FLL0 < DCO_MIN value. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 2|R |CLMP_HI_ERR0|Clamp error high for FLL0. Set when new DCO value for FLL0 > DCO_MAX value. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 3|R |FDC_SAT_ERR0|FDC saturation error for FLL0. Set when FDC counter of FLL0 overflows. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 4|R |LOCK1 |LOCK1. Lock status for Feedback clock 1. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 5|R |CLMP_LO_ERR1|Clamp error low for FLL1. Set when new DCO value for FLL1 < DCO_MIN value. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 6|R |CLMP_HI_ERR1|Clamp error high for FLL1. Set when new DCO value for FLL1 > DCO_MAX value. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 7|R |FDC_SAT_ERR1|FDC saturation error for FLL1. Set when FDC counter of FLL1 overflows. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 8|R |LOCK2 |LOCK2. Lock status for Feedback clock 3. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 9|R |CLMP_LO_ERR2|Clamp error low for FLL2. Set when new DCO value for FLL2 < DCO_MIN value. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 10|R |CLMP_HI_ERR2|Clamp error high for FLL2. Set when new DCO value for FLL2 > DCO_MAX value. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 11|R |FDC_SAT_ERR2|FDC saturation error for FLL2. Set when FDC counter of FLL2 overflows. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 12|R |LOCK3 |LOCK3. Lock status for Feedback clock 3. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 13|R |CLMP_LO_ERR3|Clamp error low for FLL3. Set when new DCO value for FLL3 < DCO_MIN value. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 14|R |CLMP_HI_ERR3|Clamp error high for FLL3. Set when new DCO value for FLL3 > DCO_MAX value. | - +-----+---+------------+--------------------------------------------------------------------------------+ - | 15|R |FDC_SAT_ERR3|FDC saturation error for FLL3. Set when FDC counter of FLL3 overflows. | - +-----+---+------------+--------------------------------------------------------------------------------+ - |24:16|R |DCOD |Current DCO input code of the selected FLL (see DCOD_SEL field of DRR register).| - +-----+---+------------+--------------------------------------------------------------------------------+ - -.. _fll_DRR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+================================================================================+ + | 0|R |LOCK0 |0x0 |LOCK0. Lock status for Feedback clock 0. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 1|R |CLMP_LO_ERR0|0x0 |Clamp error low for FLL0. Set when new DCO value for FLL0 < DCO_MIN value. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 2|R |CLMP_HI_ERR0|0x0 |Clamp error high for FLL0. Set when new DCO value for FLL0 > DCO_MAX value. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 3|R |FDC_SAT_ERR0|0x0 |FDC saturation error for FLL0. Set when FDC counter of FLL0 overflows. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 4|R |LOCK1 |0x0 |LOCK1. Lock status for Feedback clock 1. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 5|R |CLMP_LO_ERR1|0x0 |Clamp error low for FLL1. Set when new DCO value for FLL1 < DCO_MIN value. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 6|R |CLMP_HI_ERR1|0x0 |Clamp error high for FLL1. Set when new DCO value for FLL1 > DCO_MAX value. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 7|R |FDC_SAT_ERR1|0x0 |FDC saturation error for FLL1. Set when FDC counter of FLL1 overflows. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 8|R |LOCK2 |0x0 |LOCK2. Lock status for Feedback clock 3. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 9|R |CLMP_LO_ERR2|0x0 |Clamp error low for FLL2. Set when new DCO value for FLL2 < DCO_MIN value. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 10|R |CLMP_HI_ERR2|0x0 |Clamp error high for FLL2. Set when new DCO value for FLL2 > DCO_MAX value. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 11|R |FDC_SAT_ERR2|0x0 |FDC saturation error for FLL2. Set when FDC counter of FLL2 overflows. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 12|R |LOCK3 |0x0 |LOCK3. Lock status for Feedback clock 3. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 13|R |CLMP_LO_ERR3|0x0 |Clamp error low for FLL3. Set when new DCO value for FLL3 < DCO_MIN value. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 14|R |CLMP_HI_ERR3|0x0 |Clamp error high for FLL3. Set when new DCO value for FLL3 > DCO_MAX value. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + | 15|R |FDC_SAT_ERR3|0x0 |FDC saturation error for FLL3. Set when FDC counter of FLL3 overflows. | + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + |24:16|R |DCOD |0x00F|Current DCO input code of the selected FLL (see DCOD_SEL field of DRR register).| + +-----+---+------------+-----+--------------------------------------------------------------------------------+ + +.. _fll__DRR: DRR """ @@ -95,18 +102,20 @@ DRR DCO Range register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+-------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+=========================================================================================================================+ - |8:0 |R/W|DCOD_MIN|Minimum value allowed for DCO code. | - +-----+---+--------+-------------------------------------------------------------------------------------------------------------------------+ - |24:16|R/W|DCOD_MAX|Maximum value allowed for DCO code. | - +-----+---+--------+-------------------------------------------------------------------------------------------------------------------------+ - |29:28|R/W|DCOD_SEL|Selection of the FLL the DCO of which can be read back through FSR register (b00: FLLO, b01: FLL1, b10: FLL2, b11: FLL3).| - +-----+---+--------+-------------------------------------------------------------------------------------------------------------------------+ + +-----+---+--------+-----+-------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=========================================================================================================================+ + |8:0 |R/W|DCOD_MIN|0x000|Minimum value allowed for DCO code. | + +-----+---+--------+-----+-------------------------------------------------------------------------------------------------------------------------+ + |24:16|R/W|DCOD_MAX|0x086|Maximum value allowed for DCO code. | + +-----+---+--------+-----+-------------------------------------------------------------------------------------------------------------------------+ + |29:28|R/W|DCOD_SEL|0x0 |Selection of the FLL the DCO of which can be read back through FSR register (b00: FLLO, b01: FLL1, b10: FLL2, b11: FLL3).| + +-----+---+--------+-----+-------------------------------------------------------------------------------------------------------------------------+ -.. _fll_TTR: +.. _fll__TTR: TTR """ @@ -114,14 +123,16 @@ TTR Temperature Tracking Register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-----------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+===========================================================+ - |23:0 |R/W|REFRESH|Number of ref clock cycles between two integration periods.| - +-----+---+-------+-----------------------------------------------------------+ + +-----+---+-------+--------+-----------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+=======+========+===========================================================+ + |23:0 |R/W|REFRESH|0x000000|Number of ref clock cycles between two integration periods.| + +-----+---+-------+--------+-----------------------------------------------------------+ -.. _fll_F0CR1: +.. _fll__F0CR1: F0CR1 """"" @@ -129,28 +140,30 @@ F0CR1 FLL0 Configuration Register 1 .. table:: - - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+================================================================================================================================================================================================================================================================================================================+ - | 0|R/W|DCO_EN |DCO enable for FLL0 (active high). 0: DCO0 is disabled -- FBKCLK0 is inactive. 1: DCO0 is enabled -- FBKCLK0 is managed according to the FLL0 configuration (default state). | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|OP_MODE |FLL0 operating mode. 0: open loop mode (default state). 1: closed loop mode. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 2|R/W|TTM_EN |FLL0 temperature tracking mode enable. In open loop mode: do not care. In closed loop mode: 0: the frequency is always regulated (at each integration period). 1: the frequency is regulated at a rate controlled by REFRESH parameter of the TTR register. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 3|R/W|DITH_EN |FLL0 dithering enable. In open loop mode: do not care. In closed loop mode: when set, enable dithering pattern generator. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |7:4 |R/W|LOOP_GAIN|FLL0 loop gain setting. Default: 2\ :sup:-7 = 1 / 256. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15:8 |R/W|LOCK_TOL |FLL0 lock tolerance. Margin around the target multiplication factor per integration period (MFI) within which the output clock is considered stable (i.e. the clock is stable when target |MFI – N\ :sub:fdc| < LOCK_TOL). | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |25:16|R/W|ITG_PER |FLL0 integration period. Defines the duration of one integration period i.e. the number of REFCLK cycles during which the FDC counter is enabled. Integration period duration = (ITG_PER + 1) REFCLK cycles | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:26|R/W|STBL |FLL0 stable/unstable clock cycles before asserting/deasserting LOCK0. In closed loop mode, if LOCK0=0 (resp. 1): number of integration periods during which FBKCLK0 is stable (resp. unstable) before LOCK0 is asserted (resp. deasserted). In open loop mode, number of FBKCLK0 cycles until LOCK0 is asserted.| - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _fll_F0CR2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+================================================================================================================================================================================================================================================================================================================+ + | 0|R/W|DCO_EN |0x1 |DCO enable for FLL0 (active high). 0: DCO0 is disabled -- FBKCLK0 is inactive. 1: DCO0 is enabled -- FBKCLK0 is managed according to the FLL0 configuration (default state). | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|OP_MODE |0x0 |FLL0 operating mode. 0: open loop mode (default state). 1: closed loop mode. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 2|R/W|TTM_EN |0x0 |FLL0 temperature tracking mode enable. In open loop mode: do not care. In closed loop mode: 0: the frequency is always regulated (at each integration period). 1: the frequency is regulated at a rate controlled by REFRESH parameter of the TTR register. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 3|R/W|DITH_EN |0x0 |FLL0 dithering enable. In open loop mode: do not care. In closed loop mode: when set, enable dithering pattern generator. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:4 |R/W|LOOP_GAIN|0x7 |FLL0 loop gain setting. Default: :math:`2^{-7} = 1/256`. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R/W|LOCK_TOL |0x0A |FLL0 lock tolerance. Margin around the target multiplication factor per integration period (MFI) within which the output clock is considered stable (i.e. the clock is stable when target :math:`\|\mathrm{MFI} - N_\mathrm{FDC}\| < \mathrm{LOCK\_TOL}`. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |25:16|R/W|ITG_PER |0x003|FLL0 integration period. Defines the duration of one integration period i.e. the number of REFCLK cycles during which the FDC counter is enabled. Integration period duration = (ITG_PER + 1) REFCLK cycles | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:26|R/W|STBL |0x10 |FLL0 stable/unstable clock cycles before asserting/deasserting LOCK0. In closed loop mode, if LOCK0=0 (resp. 1): number of integration periods during which FBKCLK0 is stable (resp. unstable) before LOCK0 is asserted (resp. deasserted). In open loop mode, number of FBKCLK0 cycles until LOCK0 is asserted.| + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fll__F0CR2: F0CR2 """"" @@ -158,16 +171,18 @@ F0CR2 FLL0 Configuration Register 2 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+--------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+======================================================================================+ - |15:0 |R/W|MFI |Target clock multiplication factor per integration period for FLL0 (closed loop mode).| - +-----+---+--------+--------------------------------------------------------------------------------------+ - |24:16|R/W|DCOD_OLM|DCO input code for FLL0 (open loop mode). | - +-----+---+--------+--------------------------------------------------------------------------------------+ + +-----+---+--------+------+--------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+========+======+======================================================================================+ + |15:0 |R/W|MFI |0x0001|Target clock multiplication factor per integration period for FLL0 (closed loop mode).| + +-----+---+--------+------+--------------------------------------------------------------------------------------+ + |24:16|R/W|DCOD_OLM|0x00F |DCO input code for FLL0 (open loop mode). | + +-----+---+--------+------+--------------------------------------------------------------------------------------+ -.. _fll_F1CR1: +.. _fll__F1CR1: F1CR1 """"" @@ -175,28 +190,30 @@ F1CR1 FLL1 Configuration Register 1 .. table:: - - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+================================================================================================================================================================================================================================================================================================================+ - | 0|R/W|DCO_EN |DCO enable for FLL1 (active high). 0: DCO1 is disabled (default state) -- FBKCLK1 is inactive. 1: DCO1 is enabled -- FBKCLK1 is managed according to the FLL1 configuration. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|OP_MODE |FLL1 operating mode. 0: open loop mode (default state). 1: closed loop mode. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 2|R/W|TTM_EN |FLL1 temperature tracking mode enable. In open loop mode: do not care. In closed loop mode: 0: the frequency is always regulated (at each integration period). 1: the frequency is regulated at a rate controlled by REFRESH parameter of the TTR register. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 3|R/W|DITH_EN |FLL1 dithering enable. In open loop mode: do not care. In closed loop mode: when set, enable dithering pattern generator. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |7:4 |R/W|LOOP_GAIN|FLL1 loop gain setting. Default: 2\ :sup:-7 = 1 / 256. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15:8 |R/W|LOCK_TOL |FLL1 lock tolerance. Margin around the target multiplication factor per integration period (MFI) within which the output clock is considered stable (i.e. the clock is stable when target |MFI – N\ :sub:fdc| < LOCK_TOL). | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |25:16|R/W|ITG_PER |FLL1 integration period. Defines the duration of one integration period i.e. the number of REFCLK cycles during which the FDC counter is enabled. Integration period duration = (ITG_PER + 1) REFCLK cycles | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:26|R/W|STBL |FLL1 stable/unstable clock cycles before asserting/deasserting LOCK1. In closed loop mode, if LOCK1=0 (resp. 1): number of integration periods during which FBKCLK1 is stable (resp. unstable) before LOCK1 is asserted (resp. deasserted). In open loop mode, number of FBKCLK1 cycles until LOCK1 is asserted.| - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _fll_F1CR2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+================================================================================================================================================================================================================================================================================================================+ + | 0|R/W|DCO_EN |0x0 |DCO enable for FLL1 (active high). 0: DCO1 is disabled (default state) -- FBKCLK1 is inactive. 1: DCO1 is enabled -- FBKCLK1 is managed according to the FLL1 configuration. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|OP_MODE |0x0 |FLL1 operating mode. 0: open loop mode (default state). 1: closed loop mode. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 2|R/W|TTM_EN |0x0 |FLL1 temperature tracking mode enable. In open loop mode: do not care. In closed loop mode: 0: the frequency is always regulated (at each integration period). 1: the frequency is regulated at a rate controlled by REFRESH parameter of the TTR register. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 3|R/W|DITH_EN |0x0 |FLL1 dithering enable. In open loop mode: do not care. In closed loop mode: when set, enable dithering pattern generator. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:4 |R/W|LOOP_GAIN|0x7 |FLL1 loop gain setting. Default: :math:`2^{-7} = 1/256`. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R/W|LOCK_TOL |0x0A |FLL1 lock tolerance. Margin around the target multiplication factor per integration period (MFI) within which the output clock is considered stable (i.e. the clock is stable when target :math:`\|\mathrm{MFI} - N_\mathrm{FDC}\| < \mathrm{LOCK\_TOL}`. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |25:16|R/W|ITG_PER |0x003|FLL1 integration period. Defines the duration of one integration period i.e. the number of REFCLK cycles during which the FDC counter is enabled. Integration period duration = (ITG_PER + 1) REFCLK cycles | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:26|R/W|STBL |0x10 |FLL1 stable/unstable clock cycles before asserting/deasserting LOCK1. In closed loop mode, if LOCK1=0 (resp. 1): number of integration periods during which FBKCLK1 is stable (resp. unstable) before LOCK1 is asserted (resp. deasserted). In open loop mode, number of FBKCLK1 cycles until LOCK1 is asserted.| + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fll__F1CR2: F1CR2 """"" @@ -204,16 +221,18 @@ F1CR2 FLL1 Configuration Register 2 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+--------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+======================================================================================+ - |15:0 |R/W|MFI |Target clock multiplication factor per integration period for FLL1 (closed loop mode).| - +-----+---+--------+--------------------------------------------------------------------------------------+ - |24:16|R/W|DCOD_OLM|DCO input code for FLL1 (open loop mode). | - +-----+---+--------+--------------------------------------------------------------------------------------+ + +-----+---+--------+------+--------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+========+======+======================================================================================+ + |15:0 |R/W|MFI |0x0001|Target clock multiplication factor per integration period for FLL1 (closed loop mode).| + +-----+---+--------+------+--------------------------------------------------------------------------------------+ + |24:16|R/W|DCOD_OLM|0x00F |DCO input code for FLL1 (open loop mode). | + +-----+---+--------+------+--------------------------------------------------------------------------------------+ -.. _fll_F2CR1: +.. _fll__F2CR1: F2CR1 """"" @@ -221,28 +240,30 @@ F2CR1 FLL2 Configuration Register 1 .. table:: - - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+================================================================================================================================================================================================================================================================================================================+ - | 0|R/W|DCO_EN |DCO enable for FLL2 (active high). 0: DCO2 is disabled (default state) -- FBKCLK2 is inactive. 1: DCO2 is enabled -- FBKCLK2 is managed according to the FLL2 configuration. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|OP_MODE |FLL2 operating mode. 0: open loop mode (default state). 1: closed loop mode. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 2|R/W|TTM_EN |FLL2 temperature tracking mode enable. In open loop mode: do not care. In closed loop mode: 0: the frequency is always regulated (at each integration period). 1: the frequency is regulated at a rate controlled by REFRESH parameter of the TTR register. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 3|R/W|DITH_EN |FLL2 dithering enable. In open loop mode: do not care. In closed loop mode: when set, enable dithering pattern generator. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |7:4 |R/W|LOOP_GAIN|FLL2 loop gain setting. Default: 2\ :sup:-7 = 1 / 256. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15:8 |R/W|LOCK_TOL |FLL2 lock tolerance. Margin around the target multiplication factor per integration period (MFI) within which the output clock is considered stable (i.e. the clock is stable when target |MFI – N\ :sub:fdc| < LOCK_TOL). | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |25:16|R/W|ITG_PER |FLL2 integration period. Defines the duration of one integration period i.e. the number of REFCLK cycles during which the FDC counter is enabled. Integration period duration = (ITG_PER + 1) REFCLK cycles | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:26|R/W|STBL |FLL2 stable/unstable clock cycles before asserting/deasserting LOCK2. In closed loop mode, if LOCK2=0 (resp. 1): number of integration periods during which FBKCLK2 is stable (resp. unstable) before LOCK2 is asserted (resp. deasserted). In open loop mode, number of FBKCLK2 cycles until LOCK2 is asserted.| - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _fll_F2CR2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+================================================================================================================================================================================================================================================================================================================+ + | 0|R/W|DCO_EN |0x0 |DCO enable for FLL2 (active high). 0: DCO2 is disabled (default state) -- FBKCLK2 is inactive. 1: DCO2 is enabled -- FBKCLK2 is managed according to the FLL2 configuration. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|OP_MODE |0x0 |FLL2 operating mode. 0: open loop mode (default state). 1: closed loop mode. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 2|R/W|TTM_EN |0x0 |FLL2 temperature tracking mode enable. In open loop mode: do not care. In closed loop mode: 0: the frequency is always regulated (at each integration period). 1: the frequency is regulated at a rate controlled by REFRESH parameter of the TTR register. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 3|R/W|DITH_EN |0x0 |FLL2 dithering enable. In open loop mode: do not care. In closed loop mode: when set, enable dithering pattern generator. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:4 |R/W|LOOP_GAIN|0x7 |FLL2 loop gain setting. Default: :math:`2^{-7} = 1/256`. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R/W|LOCK_TOL |0x0A |FLL2 lock tolerance. Margin around the target multiplication factor per integration period (MFI) within which the output clock is considered stable (i.e. the clock is stable when target :math:`\|\mathrm{MFI} - N_\mathrm{FDC}\| < \mathrm{LOCK\_TOL}`. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |25:16|R/W|ITG_PER |0x003|FLL2 integration period. Defines the duration of one integration period i.e. the number of REFCLK cycles during which the FDC counter is enabled. Integration period duration = (ITG_PER + 1) REFCLK cycles | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:26|R/W|STBL |0x10 |FLL2 stable/unstable clock cycles before asserting/deasserting LOCK2. In closed loop mode, if LOCK2=0 (resp. 1): number of integration periods during which FBKCLK2 is stable (resp. unstable) before LOCK2 is asserted (resp. deasserted). In open loop mode, number of FBKCLK2 cycles until LOCK2 is asserted.| + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fll__F2CR2: F2CR2 """"" @@ -250,16 +271,18 @@ F2CR2 FLL2 Configuration Register 2 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+--------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+======================================================================================+ - |15:0 |R/W|MFI |Target clock multiplication factor per integration period for FLL2 (closed loop mode).| - +-----+---+--------+--------------------------------------------------------------------------------------+ - |24:16|R/W|DCOD_OLM|DCO input code for FLL2 (open loop mode). | - +-----+---+--------+--------------------------------------------------------------------------------------+ + +-----+---+--------+------+--------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+========+======+======================================================================================+ + |15:0 |R/W|MFI |0x0001|Target clock multiplication factor per integration period for FLL2 (closed loop mode).| + +-----+---+--------+------+--------------------------------------------------------------------------------------+ + |24:16|R/W|DCOD_OLM|0x00F |DCO input code for FLL2 (open loop mode). | + +-----+---+--------+------+--------------------------------------------------------------------------------------+ -.. _fll_F3CR1: +.. _fll__F3CR1: F3CR1 """"" @@ -267,28 +290,30 @@ F3CR1 FLL3 Configuration Register 1 .. table:: - - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+================================================================================================================================================================================================================================================================================================================+ - | 0|R/W|DCO_EN |DCO enable for FLL3 (active high). 0: DCO3 is disabled (default state) -- FBKCLK3 is inactive. 1: DCO3 is enabled -- FBKCLK3 is managed according to the FLL3 configuration. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|OP_MODE |FLL3 operating mode. 0: open loop mode (default state). 1: closed loop mode. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 2|R/W|TTM_EN |FLL3 temperature tracking mode enable. In open loop mode: do not care. In closed loop mode: 0: the frequency is always regulated (at each integration period). 1: the frequency is regulated at a rate controlled by REFRESH parameter of the TTR register. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 3|R/W|DITH_EN |FLL3 dithering enable. In open loop mode: do not care. In closed loop mode: when set, enable dithering pattern generator. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |7:4 |R/W|LOOP_GAIN|FLL3 loop gain setting. Default: 2\ :sup:-7 = 1 / 256. | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15:8 |R/W|LOCK_TOL |FLL3 lock tolerance. Margin around the target multiplication factor per integration period (MFI) within which the output clock is considered stable (i.e. the clock is stable when target |MFI – N\ :sub:fdc| < LOCK_TOL). | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |25:16|R/W|ITG_PER |FLL3 integration period. Defines the duration of one integration period i.e. the number of REFCLK cycles during which the FDC counter is enabled. Integration period duration = (ITG_PER + 1) REFCLK cycles | - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:26|R/W|STBL |FLL3 stable/unstable clock cycles before asserting/deasserting LOCK3. In closed loop mode, if LOCK3=0 (resp. 1): number of integration periods during which FBKCLK3 is stable (resp. unstable) before LOCK3 is asserted (resp. deasserted). In open loop mode, number of FBKCLK3 cycles until LOCK3 is asserted.| - +-----+---+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _fll_F3CR2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+================================================================================================================================================================================================================================================================================================================+ + | 0|R/W|DCO_EN |0x0 |DCO enable for FLL3 (active high). 0: DCO3 is disabled (default state) -- FBKCLK3 is inactive. 1: DCO3 is enabled -- FBKCLK3 is managed according to the FLL3 configuration. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|OP_MODE |0x0 |FLL3 operating mode. 0: open loop mode (default state). 1: closed loop mode. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 2|R/W|TTM_EN |0x0 |FLL3 temperature tracking mode enable. In open loop mode: do not care. In closed loop mode: 0: the frequency is always regulated (at each integration period). 1: the frequency is regulated at a rate controlled by REFRESH parameter of the TTR register. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 3|R/W|DITH_EN |0x0 |FLL3 dithering enable. In open loop mode: do not care. In closed loop mode: when set, enable dithering pattern generator. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:4 |R/W|LOOP_GAIN|0x7 |FLL2 loop gain setting. Default: :math:`2^{-7} = 1/256`. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R/W|LOCK_TOL |0x0A |FLL3 lock tolerance. Margin around the target multiplication factor per integration period (MFI) within which the output clock is considered stable (i.e. the clock is stable when target :math:`\|\mathrm{MFI} - N_\mathrm{FDC}\| < \mathrm{LOCK\_TOL}`. | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |25:16|R/W|ITG_PER |0x003|FLL3 integration period. Defines the duration of one integration period i.e. the number of REFCLK cycles during which the FDC counter is enabled. Integration period duration = (ITG_PER + 1) REFCLK cycles | + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:26|R/W|STBL |0x10 |FLL3 stable/unstable clock cycles before asserting/deasserting LOCK3. In closed loop mode, if LOCK3=0 (resp. 1): number of integration periods during which FBKCLK3 is stable (resp. unstable) before LOCK3 is asserted (resp. deasserted). In open loop mode, number of FBKCLK3 cycles until LOCK3 is asserted.| + +-----+---+---------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _fll__F3CR2: F3CR2 """"" @@ -296,16 +321,18 @@ F3CR2 FLL3 Configuration Register 2 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+--------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+======================================================================================+ - |15:0 |R/W|MFI |Target clock multiplication factor per integration period for FLL3 (closed loop mode).| - +-----+---+--------+--------------------------------------------------------------------------------------+ - |24:16|R/W|DCOD_OLM|DCO input code for FLL3 (open loop mode). | - +-----+---+--------+--------------------------------------------------------------------------------------+ + +-----+---+--------+------+--------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+========+======+======================================================================================+ + |15:0 |R/W|MFI |0x0001|Target clock multiplication factor per integration period for FLL3 (closed loop mode).| + +-----+---+--------+------+--------------------------------------------------------------------------------------+ + |24:16|R/W|DCOD_OLM|0x00F |DCO input code for FLL3 (open loop mode). | + +-----+---+--------+------+--------------------------------------------------------------------------------------+ -.. _fll_CCR1: +.. _fll__CCR1: CCR1 """" @@ -313,20 +340,22 @@ CCR1 Clock Configuration register 1 .. table:: - - +-----+---+--------+-------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+=============================================================================================================+ - |7:0 |R/W|CLK0_DIV|Clock divider setting for OUTCLK[0]: OUTCLK[0] = CLK0 / (CLK0_DIV); divider is bypassed if CLK0_DIV = 0 or 1.| - +-----+---+--------+-------------------------------------------------------------------------------------------------------------+ - |15:8 |R/W|CLK1_DIV|Clock divider setting for OUTCLK[1]: OUTCLK[1] = CLK1 / (CLK1_DIV); divider is bypassed if CLK1_DIV = 0 or 1.| - +-----+---+--------+-------------------------------------------------------------------------------------------------------------+ - |23:16|R/W|CLK2_DIV|Clock divider setting for OUTCLK[2]: OUTCLK[2] = CLK2 / (CLK2_DIV); divider is bypassed if CLK2_DIV = 0 or 1.| - +-----+---+--------+-------------------------------------------------------------------------------------------------------------+ - |31:24|R/W|CLK3_DIV|Clock divider setting for OUTCLK[3]: OUTCLK[3] = CLK3 / (CLK3_DIV); divider is bypassed if CLK3_DIV = 0 or 1.| - +-----+---+--------+-------------------------------------------------------------------------------------------------------------+ - -.. _fll_CCR2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+-----+---------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+===================================================================================================+ + |7:0 |R/W|CLK0_DIV|0x02 |Clock divider setting for output clock 0 (PERIPH clock); divider is bypassed if CLK0_DIV = 0 or 1. | + +-----+---+--------+-----+---------------------------------------------------------------------------------------------------+ + |15:8 |R/W|CLK1_DIV|0x02 |Clock divider setting for output clock 1 (SOC clock); divider is bypassed if CLK1_DIV = 0 or 1. | + +-----+---+--------+-----+---------------------------------------------------------------------------------------------------+ + |23:16|R/W|CLK2_DIV|0x00 |Clock divider setting for output clock 2 (CLUSTER clock); divider is bypassed if CLK2_DIV = 0 or 1.| + +-----+---+--------+-----+---------------------------------------------------------------------------------------------------+ + |31:24|R/W|CLK3_DIV|0x00 |Clock divider setting for output clock 3 (SFU clock); divider is bypassed if CLK3_DIV = 0 or 1. | + +-----+---+--------+-----+---------------------------------------------------------------------------------------------------+ + +.. _fll__CCR2: CCR2 """" @@ -334,23 +363,25 @@ CCR2 Clock Configuration register 2 .. table:: - - +-----+---+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+=======================================================================================================================================================+ - | 0|R/W|CLK0_SEL|Clock source selection for OUTCLK[0]: 0: Ref clock (default). 1: FBKCLK[0] clock. | - +-----+---+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |5:4 |R/W|CLK1_SEL|Clock source selection for OUTCLK[1]: 00: Ref clock. 01: FBKCLK[0] clock (default). 1x: FBKCLK[1] clock. | - +-----+---+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |9:8 |R/W|CLK2_SEL|Clock source selection for OUTCLK[2]: 00: Ref clock (default). 01: FBKCLK[0] clock. 10: FBKCLK[1] clock. 11: FBKCLK[2] clock. | - +-----+---+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |14:12|R/W|CLK3_SEL|Clock source selection for OUTCLK[3]: 000: Ref clock (default). 001: FBKCLK[0] clock. 010: FBKCLK[1] clock. 011: FBKCLK[2] clock. 1xx: FBKCLK[3] clock.| - +-----+---+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |16 |R/W|CKG0 |FBKCLK[0] clock gated. 0: FBKCLK[0] is not gated. 1: FBKCLK[0] is clock gated by LOCK0 signal. | - +-----+---+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |17 |R/W|CKG1 |FBKCLK[1] clock gated. 0: FBKCLK[1] is not gated. 1: FBKCLK[1] is clock gated by LOCK1 signal. | - +-----+---+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18 |R/W|CKG2 |FBKCLK[2] clock gated. 0: FBKCLK[2] is not gated. 1: FBKCLK[2] is clock gated by LOCK2 signal. | - +-----+---+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |19 |R/W|CKG3 |FBKCLK[3] clock gated. 0: FBKCLK[3] is not gated. 1: FBKCLK[3] is clock gated by LOCK3 signal. | - +-----+---+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+====================================================================================================================================================+ + | 0|R/W|CLK0_SEL|0x1 |Clock source selection for output clock 0 (PERIPH clock): 0: Ref clock (default). 1: FLL0 clock. | + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |5:4 |R/W|CLK1_SEL|0x1 |Clock source selection for output clock 1 (SOC clock): 00: Ref clock. 01: FLL0 clock (default). 1x: FLL1 clock. | + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |9:8 |R/W|CLK2_SEL|0x0 |Clock source selection for output clock 2 (CLUSTER clock): 00: Ref clock (default). 01: FLL0 clock. 10: FLL1 clock. 11: FLL2 clock. | + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |14:12|R/W|CLK3_SEL|0x0 |Clock source selection for output clock 3 (SFU clock): 000: Ref clock (default). 001: FLL0 clock. 010: FLL1 clock. 011: FLL2 clock. 1xx: FLL3 clock.| + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |16 |R/W|CKG0 |0x1 |FLL0 clock gated. 0: FLL0 is not gated. 1: FLL0 is clock gated by LOCK0 signal. | + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |17 |R/W|CKG1 |0x1 |FLL1 clock gated. 0: FLL1 is not gated. 1: FLL1 is clock gated by LOCK1 signal. | + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |18 |R/W|CKG2 |0x1 |FLL2 clock gated. 0: FLL2 is not gated. 1: FLL2 is clock gated by LOCK2 signal. | + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |19 |R/W|CKG3 |0x1 |FLL3 clock gated. 0: FLL3 is not gated. 1: FLL3 is clock gated by LOCK3 signal. | + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/gpio.rst b/rtos/pulp/gap_archi/doc/ips/gpio.rst index 927520d55..1ddf99efd 100644 --- a/rtos/pulp/gap_archi/doc/ips/gpio.rst +++ b/rtos/pulp/gap_archi/doc/ips/gpio.rst @@ -8,73 +8,78 @@ Register map Overview """""""" -.. table:: - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +============================================+======+=====+====================================================================+ - |:ref:`PADDIR_00_31` | 0| 32|GPIO pad direction configuration register for GPIOs 0 to 31. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`GPIOEN_00_31` | 4| 32|GPIO enable register for GPIOs 0 to 31. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`PADIN_00_31` | 8| 32|GPIO pad input value register for GPIOs 0 to 31. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`PADOUT_00_31` | 12| 32|GPIO pad output value register for GPIOs 0 to 31. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`PADOUTSET_00_31`| 16| 32|GPIO pad output set register for GPIOs 0 to 31. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`PADOUTCLR_00_31`| 20| 32|GPIO pad output clear register for GPIOs 0 to 31. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`INTEN_00_31` | 24| 32|GPIO pad interrupt enable configuration register for GPIOs 0 to 31. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`INTTYPE_00_15` | 28| 32|GPIO pad interrupt type for GPIOs 0 to 15. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`INTTYPE_16_31` | 32| 32|GPIO pad interrupt type for GPIOs 16 to 31. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`INTSTATUS_00_31`| 36| 32|GPIO pad interrupt status register for GPIOs 0 to 31. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`PADDIR_32_63` | 72| 32|GPIO pad direction configuration register for GPIOs 32 to 63. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`GPIOEN_32_63` | 76| 32|GPIO enable register for GPIOs 32 to 63. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`PADIN_32_63` | 80| 32|GPIO pad input value register for GPIOs 32 to 63. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`PADOUT_32_63` | 84| 32|GPIO pad output value register for GPIOs 32 to 63. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`PADOUTSET_32_63`| 88| 32|GPIO pad output set register for GPIOs 32 to 63. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`PADOUTCLR_32_63`| 92| 32|GPIO pad output clear register for GPIOs 32 to 63. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`INTEN_32_63` | 96| 32|GPIO pad interrupt enable configuration register for GPIOs 32 to 63.| - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`INTTYPE_32_47` | 100| 32|GPIO pad interrupt type for GPIOs 32 to 47. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`INTTYPE_48_63` | 104| 32|GPIO pad interrupt type for GPIOs 48 to 63. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`INTSTATUS_32_63`| 108| 32|GPIO pad interrupt status register for GPIOs 32 to 63. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`PADDIR_64_89` | 144| 32|GPIO pad direction configuration register for GPIO 64 to 89. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`GPIOEN_64_89` | 148| 32|GPIO enable register for GPIO 64 to 89. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`PADIN_64_89` | 152| 32|GPIO pad input value register for GPIO 64 to 89. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`PADOUT_64_89` | 156| 32|GPIO pad output value register for GPIO 64 to 89. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`PADOUTSET_64_89`| 160| 32|GPIO pad output set register for GPIO 64 to 89. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`PADOUTCLR_64_89`| 164| 32|GPIO pad output clear register for GPIO 64 to 89. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`INTEN_64_89` | 168| 32|GPIO pad interrupt enable configuration register for GPIO 64 to 89. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`INTTYPE_64_79` | 172| 32|GPIO pad interrupt type for GPIO 64 to 79. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`INTTYPE_80_89` | 176| 32|GPIO pad interrupt type for GPIO 80 to 89. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - |:ref:`INTSTATUS_64_89`| 180| 32|GPIO pad interrupt status register for GPIO 64 to 89. | - +--------------------------------------------+------+-----+--------------------------------------------------------------------+ - -.. _gpio_PADDIR_00_31: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +=============================================+======+=====+====================================================================+ + |:ref:`PADDIR_00_31` | 0| 32|GPIO pad direction configuration register for GPIOs 0 to 31. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`GPIOEN_00_31` | 4| 32|GPIO enable register for GPIOs 0 to 31. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`PADIN_00_31` | 8| 32|GPIO pad input value register for GPIOs 0 to 31. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`PADOUT_00_31` | 12| 32|GPIO pad output value register for GPIOs 0 to 31. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`PADOUTSET_00_31`| 16| 32|GPIO pad output set register for GPIOs 0 to 31. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`PADOUTCLR_00_31`| 20| 32|GPIO pad output clear register for GPIOs 0 to 31. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`INTEN_00_31` | 24| 32|GPIO pad interrupt enable configuration register for GPIOs 0 to 31. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`INTTYPE_00_15` | 28| 32|GPIO pad interrupt type for GPIOs 0 to 15. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`INTTYPE_16_31` | 32| 32|GPIO pad interrupt type for GPIOs 16 to 31. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`INTSTATUS_00_31`| 36| 32|GPIO pad interrupt status register for GPIOs 0 to 31. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`PADDIR_32_63` | 72| 32|GPIO pad direction configuration register for GPIOs 32 to 63. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`GPIOEN_32_63` | 76| 32|GPIO enable register for GPIOs 32 to 63. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`PADIN_32_63` | 80| 32|GPIO pad input value register for GPIOs 32 to 63. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`PADOUT_32_63` | 84| 32|GPIO pad output value register for GPIOs 32 to 63. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`PADOUTSET_32_63`| 88| 32|GPIO pad output set register for GPIOs 32 to 63. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`PADOUTCLR_32_63`| 92| 32|GPIO pad output clear register for GPIOs 32 to 63. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`INTEN_32_63` | 96| 32|GPIO pad interrupt enable configuration register for GPIOs 32 to 63.| + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`INTTYPE_32_47` | 100| 32|GPIO pad interrupt type for GPIOs 32 to 47. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`INTTYPE_48_63` | 104| 32|GPIO pad interrupt type for GPIOs 48 to 63. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`INTSTATUS_32_63`| 108| 32|GPIO pad interrupt status register for GPIOs 32 to 63. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`PADDIR_64_89` | 144| 32|GPIO pad direction configuration register for GPIO 64 to 89. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`GPIOEN_64_89` | 148| 32|GPIO enable register for GPIO 64 to 89. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`PADIN_64_89` | 152| 32|GPIO pad input value register for GPIO 64 to 89. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`PADOUT_64_89` | 156| 32|GPIO pad output value register for GPIO 64 to 89. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`PADOUTSET_64_89`| 160| 32|GPIO pad output set register for GPIO 64 to 89. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`PADOUTCLR_64_89`| 164| 32|GPIO pad output clear register for GPIO 64 to 89. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`INTEN_64_89` | 168| 32|GPIO pad interrupt enable configuration register for GPIO 64 to 89. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`INTTYPE_64_79` | 172| 32|GPIO pad interrupt type for GPIO 64 to 79. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`INTTYPE_80_89` | 176| 32|GPIO pad interrupt type for GPIO 80 to 89. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + |:ref:`INTSTATUS_64_89`| 180| 32|GPIO pad interrupt status register for GPIO 64 to 89. | + +---------------------------------------------+------+-----+--------------------------------------------------------------------+ + +.. _gpio__PADDIR_00_31: PADDIR_00_31 """""""""""" @@ -82,14 +87,16 @@ PADDIR_00_31 GPIO pad direction configuration register for GPIOs 0 to 31. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+==============================================================================+ - |31:0 |R/W|PADDIR|GPIO direction: bit i=0: GPIO i in input mode; bit i=1: GPIO i in output mode.| - +-----+---+------+------------------------------------------------------------------------------+ + +-----+---+------+-----+------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+==============================================================================+ + |31:0 |R/W|PADDIR|0x0 |GPIO direction: bit i=0: GPIO i in input mode; bit i=1: GPIO i in output mode.| + +-----+---+------+-----+------------------------------------------------------------------------------+ -.. _gpio_GPIOEN_00_31: +.. _gpio__GPIOEN_00_31: GPIOEN_00_31 """""""""""" @@ -97,14 +104,16 @@ GPIOEN_00_31 GPIO enable register for GPIOs 0 to 31. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+=======================================================================================================================================================================================================================================================+ - |31:0 |R/W|GPIOEN|GPIO clock enable: bit i=0: disable clock for GPIO i; bit i=1: enable clock for GPIO i. GPIOs are grouped by 4, the clock gating of one group is done only if all 4 GPIOs' clocks are disable. Clock must be enabled for a GPIO to be used as an input.| - +-----+---+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=======================================================================================================================================================================================================================================================+ + |31:0 |R/W|GPIOEN|0x0 |GPIO clock enable: bit i=0: disable clock for GPIO i; bit i=1: enable clock for GPIO i. GPIOs are grouped by 4, the clock gating of one group is done only if all 4 GPIOs' clocks are disable. Clock must be enabled for a GPIO to be used as an input.| + +-----+---+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _gpio_PADIN_00_31: +.. _gpio__PADIN_00_31: PADIN_00_31 """"""""""" @@ -112,14 +121,16 @@ PADIN_00_31 GPIO pad input value register for GPIOs 0 to 31. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-----------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+===========================================================+ - |31:0 |R |PADIN|GPIO input data: bit i corresponds to input data of GPIO i.| - +-----+---+-----+-----------------------------------------------------------+ + +-----+---+-----+-----+-----------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================================+ + |31:0 |R |PADIN|0x0 |GPIO input data: bit i corresponds to input data of GPIO i.| + +-----+---+-----+-----+-----------------------------------------------------------+ -.. _gpio_PADOUT_00_31: +.. _gpio__PADOUT_00_31: PADOUT_00_31 """""""""""" @@ -127,14 +138,16 @@ PADOUT_00_31 GPIO pad output value register for GPIOs 0 to 31. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+============================================================+ - |31:0 |R/W|PADOUT|GPIO output data: bit i corresponds to input data of GPIO i.| - +-----+---+------+------------------------------------------------------------+ + +-----+---+------+-----+------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+============================================================+ + |31:0 |R/W|PADOUT|0x0 |GPIO output data: bit i corresponds to input data of GPIO i.| + +-----+---+------+-----+------------------------------------------------------------+ -.. _gpio_PADOUTSET_00_31: +.. _gpio__PADOUTSET_00_31: PADOUTSET_00_31 """"""""""""""" @@ -142,14 +155,16 @@ PADOUTSET_00_31 GPIO pad output set register for GPIOs 0 to 31. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+---------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+=====================================================================+ - |31:0 |W |PADOUTSET|GPIO output set bitfield: writing 1 to bit i sets GPIO i output to 1.| - +-----+---+---------+---------------------------------------------------------------------+ + +-----+---+---------+-----+---------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=====================================================================+ + |31:0 |W |PADOUTSET|0x0 |GPIO output set bitfield: writing 1 to bit i sets GPIO i output to 1.| + +-----+---+---------+-----+---------------------------------------------------------------------+ -.. _gpio_PADOUTCLR_00_31: +.. _gpio__PADOUTCLR_00_31: PADOUTCLR_00_31 """"""""""""""" @@ -157,14 +172,16 @@ PADOUTCLR_00_31 GPIO pad output clear register for GPIOs 0 to 31. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+---------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+=====================================================================+ - |31:0 |W |PADOUTCLR|GPIO output set bitfield: writing 1 to bit i sets GPIO i output to 0.| - +-----+---+---------+---------------------------------------------------------------------+ + +-----+---+---------+-----+---------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=====================================================================+ + |31:0 |W |PADOUTCLR|0x0 |GPIO output set bitfield: writing 1 to bit i sets GPIO i output to 0.| + +-----+---+---------+-----+---------------------------------------------------------------------+ -.. _gpio_INTEN_00_31: +.. _gpio__INTEN_00_31: INTEN_00_31 """"""""""" @@ -172,14 +189,16 @@ INTEN_00_31 GPIO pad interrupt enable configuration register for GPIOs 0 to 31. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+---------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+===================================================================================================+ - |31:0 |R/W|INTEN|GPIO interrupt enable: bit i=0: disable interrupt for GPIO i; bit i=1: enable interrupt for GPIO i.| - +-----+---+-----+---------------------------------------------------------------------------------------------------+ + +-----+---+-----+-----+---------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===================================================================================================+ + |31:0 |R/W|INTEN|0x0 |GPIO interrupt enable: bit i=0: disable interrupt for GPIO i; bit i=1: enable interrupt for GPIO i.| + +-----+---+-----+-----+---------------------------------------------------------------------------------------------------+ -.. _gpio_INTTYPE_00_15: +.. _gpio__INTTYPE_00_15: INTTYPE_00_15 """"""""""""" @@ -187,14 +206,16 @@ INTTYPE_00_15 GPIO pad interrupt type for GPIOs 0 to 15. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+==========================================================================================================================================================================================================================+ - |31:0 |R/W|INTTYPE|GPIO interrupt type (2 bits per GPIO): for GPIO i, type is defined by bits (2xi+1, 2xi). If b00: interrupt on falling edge; if b01: interrupt on rising edge; if b10: interrupt on rising and falling edge; b11: Reserved.| - +-----+---+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==========================================================================================================================================================================================================================+ + |31:0 |R/W|INTTYPE|0x0 |GPIO interrupt type (2 bits per GPIO): for GPIO i, type is defined by bits (2xi+1, 2xi). If b00: interrupt on falling edge; if b01: interrupt on rising edge; if b10: interrupt on rising and falling edge; b11: Reserved.| + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _gpio_INTTYPE_16_31: +.. _gpio__INTTYPE_16_31: INTTYPE_16_31 """"""""""""" @@ -202,14 +223,16 @@ INTTYPE_16_31 GPIO pad interrupt type for GPIOs 16 to 31. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+===============================================================================================================================================================================================================================+ - |31:0 |R/W|INTTYPE|GPIO interrupt type (2 bits per GPIO): for GPIO (16+i), type is defined by bits (2xi+1, 2xi). If b00: interrupt on falling edge; if b01: interrupt on rising edge; if b10: interrupt on rising and falling edge; b11: Reserved.| - +-----+---+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===============================================================================================================================================================================================================================+ + |31:0 |R/W|INTTYPE|0x0 |GPIO interrupt type (2 bits per GPIO): for GPIO (16+i), type is defined by bits (2xi+1, 2xi). If b00: interrupt on falling edge; if b01: interrupt on rising edge; if b10: interrupt on rising and falling edge; b11: Reserved.| + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _gpio_INTSTATUS_00_31: +.. _gpio__INTSTATUS_00_31: INTSTATUS_00_31 """"""""""""""" @@ -217,14 +240,16 @@ INTSTATUS_00_31 GPIO pad interrupt status register for GPIOs 0 to 31. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+===================================================================================================================================================================+ - |31:0 |R |INTSTATUS|GPIO interrupt status flag. When read, bit i=1 signals that an interrupt has been received on GPIO i. Reading INTSTATUS clears its value and clears interrupt line.| - +-----+---+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+===================================================================================================================================================================+ + |31:0 |R |INTSTATUS|0x0 |GPIO interrupt status flag. When read, bit i=1 signals that an interrupt has been received on GPIO i. Reading INTSTATUS clears its value and clears interrupt line.| + +-----+---+---------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _gpio_PADDIR_32_63: +.. _gpio__PADDIR_32_63: PADDIR_32_63 """""""""""" @@ -232,14 +257,16 @@ PADDIR_32_63 GPIO pad direction configuration register for GPIOs 32 to 63. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+----------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+========================================================================================+ - |31:0 |R/W|PADDIR|GPIO direction: bit i=0: GPIO (32+i) in input mode; bit i=1: GPIO (32+i) in output mode.| - +-----+---+------+----------------------------------------------------------------------------------------+ + +-----+---+------+-----+----------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+========================================================================================+ + |31:0 |R/W|PADDIR|0x0 |GPIO direction: bit i=0: GPIO (32+i) in input mode; bit i=1: GPIO (32+i) in output mode.| + +-----+---+------+-----+----------------------------------------------------------------------------------------+ -.. _gpio_GPIOEN_32_63: +.. _gpio__GPIOEN_32_63: GPIOEN_32_63 """""""""""" @@ -247,14 +274,16 @@ GPIOEN_32_63 GPIO enable register for GPIOs 32 to 63. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+=================================================================================================================================================================================================================================================================+ - |31:0 |R/W|GPIOEN|GPIO clock enable: bit i=0: disable clock for GPIO (32+i); bit i=1: enable clock for GPIO (32+i). GPIOs are grouped by 4, the clock gating of one group is done only if all 4 GPIOs' clocks are disable. Clock must be enabled for a GPIO to be used as an input.| - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=================================================================================================================================================================================================================================================================+ + |31:0 |R/W|GPIOEN|0x0 |GPIO clock enable: bit i=0: disable clock for GPIO (32+i); bit i=1: enable clock for GPIO (32+i). GPIOs are grouped by 4, the clock gating of one group is done only if all 4 GPIOs' clocks are disable. Clock must be enabled for a GPIO to be used as an input.| + +-----+---+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _gpio_PADIN_32_63: +.. _gpio__PADIN_32_63: PADIN_32_63 """"""""""" @@ -262,14 +291,16 @@ PADIN_32_63 GPIO pad input value register for GPIOs 32 to 63. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+----------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+================================================================+ - |31:0 |R |PADIN|GPIO input data: bit i corresponds to input data of GPIO (32+i).| - +-----+---+-----+----------------------------------------------------------------+ + +-----+---+-----+-----+----------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+================================================================+ + |31:0 |R |PADIN|0x0 |GPIO input data: bit i corresponds to input data of GPIO (32+i).| + +-----+---+-----+-----+----------------------------------------------------------------+ -.. _gpio_PADOUT_32_63: +.. _gpio__PADOUT_32_63: PADOUT_32_63 """""""""""" @@ -277,14 +308,16 @@ PADOUT_32_63 GPIO pad output value register for GPIOs 32 to 63. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-----------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+=================================================================+ - |31:0 |R/W|PADOUT|GPIO output data: bit i corresponds to input data of GPIO (32+i).| - +-----+---+------+-----------------------------------------------------------------+ + +-----+---+------+-----+-----------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=================================================================+ + |31:0 |R/W|PADOUT|0x0 |GPIO output data: bit i corresponds to input data of GPIO (32+i).| + +-----+---+------+-----+-----------------------------------------------------------------+ -.. _gpio_PADOUTSET_32_63: +.. _gpio__PADOUTSET_32_63: PADOUTSET_32_63 """"""""""""""" @@ -292,14 +325,16 @@ PADOUTSET_32_63 GPIO pad output set register for GPIOs 32 to 63. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+--------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================================================+ - |31:0 |W |PADOUTSET|GPIO output set bitfield: writing 1 to bit i sets GPIO (32+i) output to 1.| - +-----+---+---------+--------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==========================================================================+ + |31:0 |W |PADOUTSET|0x0 |GPIO output set bitfield: writing 1 to bit i sets GPIO (32+i) output to 1.| + +-----+---+---------+-----+--------------------------------------------------------------------------+ -.. _gpio_PADOUTCLR_32_63: +.. _gpio__PADOUTCLR_32_63: PADOUTCLR_32_63 """"""""""""""" @@ -307,14 +342,16 @@ PADOUTCLR_32_63 GPIO pad output clear register for GPIOs 32 to 63. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+--------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================================================+ - |31:0 |W |PADOUTCLR|GPIO output set bitfield: writing 1 to bit i sets GPIO (32+i) output to 0.| - +-----+---+---------+--------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==========================================================================+ + |31:0 |W |PADOUTCLR|0x0 |GPIO output set bitfield: writing 1 to bit i sets GPIO (32+i) output to 0.| + +-----+---+---------+-----+--------------------------------------------------------------------------+ -.. _gpio_INTEN_32_63: +.. _gpio__INTEN_32_63: INTEN_32_63 """"""""""" @@ -322,14 +359,16 @@ INTEN_32_63 GPIO pad interrupt enable configuration register for GPIOs 32 to 63. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+=============================================================================================================+ - |31:0 |R/W|INTEN|GPIO interrupt enable: bit i=0: disable interrupt for GPIO (32+i); bit i=1: enable interrupt for GPIO (32+i).| - +-----+---+-----+-------------------------------------------------------------------------------------------------------------+ + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=============================================================================================================+ + |31:0 |R/W|INTEN|0x0 |GPIO interrupt enable: bit i=0: disable interrupt for GPIO (32+i); bit i=1: enable interrupt for GPIO (32+i).| + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------+ -.. _gpio_INTTYPE_32_47: +.. _gpio__INTTYPE_32_47: INTTYPE_32_47 """"""""""""" @@ -337,14 +376,16 @@ INTTYPE_32_47 GPIO pad interrupt type for GPIOs 32 to 47. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+===============================================================================================================================================================================================================================+ - |31:0 |R/W|INTTYPE|GPIO interrupt type (2 bits per GPIO): for GPIO (32+i), type is defined by bits (2xi+1, 2xi). If b00: interrupt on falling edge; if b01: interrupt on rising edge; if b10: interrupt on rising and falling edge; b11: Reserved.| - +-----+---+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===============================================================================================================================================================================================================================+ + |31:0 |R/W|INTTYPE|0x0 |GPIO interrupt type (2 bits per GPIO): for GPIO (32+i), type is defined by bits (2xi+1, 2xi). If b00: interrupt on falling edge; if b01: interrupt on rising edge; if b10: interrupt on rising and falling edge; b11: Reserved.| + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _gpio_INTTYPE_48_63: +.. _gpio__INTTYPE_48_63: INTTYPE_48_63 """"""""""""" @@ -352,14 +393,16 @@ INTTYPE_48_63 GPIO pad interrupt type for GPIOs 48 to 63. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+===============================================================================================================================================================================================================================+ - |31:0 |R/W|INTTYPE|GPIO interrupt type (2 bits per GPIO): for GPIO (48+i), type is defined by bits (2xi+1, 2xi). If b00: interrupt on falling edge; if b01: interrupt on rising edge; if b10: interrupt on rising and falling edge; b11: Reserved.| - +-----+---+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===============================================================================================================================================================================================================================+ + |31:0 |R/W|INTTYPE|0x0 |GPIO interrupt type (2 bits per GPIO): for GPIO (48+i), type is defined by bits (2xi+1, 2xi). If b00: interrupt on falling edge; if b01: interrupt on rising edge; if b10: interrupt on rising and falling edge; b11: Reserved.| + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _gpio_INTSTATUS_32_63: +.. _gpio__INTSTATUS_32_63: INTSTATUS_32_63 """"""""""""""" @@ -367,14 +410,16 @@ INTSTATUS_32_63 GPIO pad interrupt status register for GPIOs 32 to 63. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+========================================================================================================================================================================+ - |31:0 |R |INTSTATUS|GPIO interrupt status flag. When read, bit i=1 signals that an interrupt has been received on GPIO (32+i). Reading INTSTATUS clears its value and clears interrupt line.| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+========================================================================================================================================================================+ + |31:0 |R |INTSTATUS|0x0 |GPIO interrupt status flag. When read, bit i=1 signals that an interrupt has been received on GPIO (32+i). Reading INTSTATUS clears its value and clears interrupt line.| + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _gpio_PADDIR_64_89: +.. _gpio__PADDIR_64_89: PADDIR_64_89 """""""""""" @@ -382,14 +427,16 @@ PADDIR_64_89 GPIO pad direction configuration register for GPIO 64 to 89. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+----------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+========================================================================================+ - |25:0 |R/W|PADDIR|GPIO direction: bit i=0: GPIO (64+i) in input mode; bit i=1: GPIO (64+i) in output mode.| - +-----+---+------+----------------------------------------------------------------------------------------+ + +-----+---+------+-----+----------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+========================================================================================+ + |25:0 |R/W|PADDIR|0x0 |GPIO direction: bit i=0: GPIO (64+i) in input mode; bit i=1: GPIO (64+i) in output mode.| + +-----+---+------+-----+----------------------------------------------------------------------------------------+ -.. _gpio_GPIOEN_64_89: +.. _gpio__GPIOEN_64_89: GPIOEN_64_89 """""""""""" @@ -397,14 +444,16 @@ GPIOEN_64_89 GPIO enable register for GPIO 64 to 89. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+=================================================================================================================================================================================================================================================================+ - |25:0 |R/W|GPIOEN|GPIO clock enable: bit i=0: disable clock for GPIO (64+i); bit i=1: enable clock for GPIO (64+i). GPIOs are grouped by 4, the clock gating of one group is done only if all 4 GPIOs' clocks are disable. Clock must be enabled for a GPIO to be used as an input.| - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=================================================================================================================================================================================================================================================================+ + |25:0 |R/W|GPIOEN|0x0 |GPIO clock enable: bit i=0: disable clock for GPIO (64+i); bit i=1: enable clock for GPIO (64+i). GPIOs are grouped by 4, the clock gating of one group is done only if all 4 GPIOs' clocks are disable. Clock must be enabled for a GPIO to be used as an input.| + +-----+---+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _gpio_PADIN_64_89: +.. _gpio__PADIN_64_89: PADIN_64_89 """"""""""" @@ -412,14 +461,16 @@ PADIN_64_89 GPIO pad input value register for GPIO 64 to 89. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+----------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+================================================================+ - |25:0 |R |PADIN|GPIO input data: bit i corresponds to input data of GPIO (64+i).| - +-----+---+-----+----------------------------------------------------------------+ + +-----+---+-----+-----+----------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+================================================================+ + |25:0 |R |PADIN|0x0 |GPIO input data: bit i corresponds to input data of GPIO (64+i).| + +-----+---+-----+-----+----------------------------------------------------------------+ -.. _gpio_PADOUT_64_89: +.. _gpio__PADOUT_64_89: PADOUT_64_89 """""""""""" @@ -427,14 +478,16 @@ PADOUT_64_89 GPIO pad output value register for GPIO 64 to 89. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-----------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+=================================================================+ - |25:0 |R/W|PADOUT|GPIO output data: bit i corresponds to input data of GPIO (64+i).| - +-----+---+------+-----------------------------------------------------------------+ + +-----+---+------+-----+-----------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=================================================================+ + |25:0 |R/W|PADOUT|0x0 |GPIO output data: bit i corresponds to input data of GPIO (64+i).| + +-----+---+------+-----+-----------------------------------------------------------------+ -.. _gpio_PADOUTSET_64_89: +.. _gpio__PADOUTSET_64_89: PADOUTSET_64_89 """"""""""""""" @@ -442,14 +495,16 @@ PADOUTSET_64_89 GPIO pad output set register for GPIO 64 to 89. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+--------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================================================+ - |25:0 |W |PADOUTSET|GPIO output set bitfield: writing 1 to bit i sets GPIO (64+i) output to 1.| - +-----+---+---------+--------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==========================================================================+ + |25:0 |W |PADOUTSET|0x0 |GPIO output set bitfield: writing 1 to bit i sets GPIO (64+i) output to 1.| + +-----+---+---------+-----+--------------------------------------------------------------------------+ -.. _gpio_PADOUTCLR_64_89: +.. _gpio__PADOUTCLR_64_89: PADOUTCLR_64_89 """"""""""""""" @@ -457,14 +512,16 @@ PADOUTCLR_64_89 GPIO pad output clear register for GPIO 64 to 89. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+--------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================================================+ - |25:0 |W |PADOUTCLR|GPIO output set bitfield: writing 1 to bit i sets GPIO (64+i) output to 0.| - +-----+---+---------+--------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==========================================================================+ + |25:0 |W |PADOUTCLR|0x0 |GPIO output set bitfield: writing 1 to bit i sets GPIO (64+i) output to 0.| + +-----+---+---------+-----+--------------------------------------------------------------------------+ -.. _gpio_INTEN_64_89: +.. _gpio__INTEN_64_89: INTEN_64_89 """"""""""" @@ -472,14 +529,16 @@ INTEN_64_89 GPIO pad interrupt enable configuration register for GPIO 64 to 89. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+=============================================================================================================+ - |25:0 |R/W|INTEN|GPIO interrupt enable: bit i=0: disable interrupt for GPIO (64+i); bit i=1: enable interrupt for GPIO (64+i).| - +-----+---+-----+-------------------------------------------------------------------------------------------------------------+ + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=============================================================================================================+ + |25:0 |R/W|INTEN|0x0 |GPIO interrupt enable: bit i=0: disable interrupt for GPIO (64+i); bit i=1: enable interrupt for GPIO (64+i).| + +-----+---+-----+-----+-------------------------------------------------------------------------------------------------------------+ -.. _gpio_INTTYPE_64_79: +.. _gpio__INTTYPE_64_79: INTTYPE_64_79 """"""""""""" @@ -487,14 +546,16 @@ INTTYPE_64_79 GPIO pad interrupt type for GPIO 64 to 79. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+===============================================================================================================================================================================================================================+ - |31:0 |R/W|INTTYPE|GPIO interrupt type (2 bits per GPIO): for GPIO (64+i), type is defined by bits (2xi+1, 2xi). If b00: interrupt on falling edge; if b01: interrupt on rising edge; if b10: interrupt on rising and falling edge; b11: Reserved.| - +-----+---+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===============================================================================================================================================================================================================================+ + |31:0 |R/W|INTTYPE|0x0 |GPIO interrupt type (2 bits per GPIO): for GPIO (64+i), type is defined by bits (2xi+1, 2xi). If b00: interrupt on falling edge; if b01: interrupt on rising edge; if b10: interrupt on rising and falling edge; b11: Reserved.| + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _gpio_INTTYPE_80_89: +.. _gpio__INTTYPE_80_89: INTTYPE_80_89 """"""""""""" @@ -502,14 +563,16 @@ INTTYPE_80_89 GPIO pad interrupt type for GPIO 80 to 89. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+===============================================================================================================================================================================================================================+ - |19:0 |R/W|INTTYPE|GPIO interrupt type (2 bits per GPIO): for GPIO (80+i), type is defined by bits (2xi+1, 2xi). If b00: interrupt on falling edge; if b01: interrupt on rising edge; if b10: interrupt on rising and falling edge; b11: Reserved.| - +-----+---+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===============================================================================================================================================================================================================================+ + |19:0 |R/W|INTTYPE|0x0 |GPIO interrupt type (2 bits per GPIO): for GPIO (80+i), type is defined by bits (2xi+1, 2xi). If b00: interrupt on falling edge; if b01: interrupt on rising edge; if b10: interrupt on rising and falling edge; b11: Reserved.| + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _gpio_INTSTATUS_64_89: +.. _gpio__INTSTATUS_64_89: INTSTATUS_64_89 """"""""""""""" @@ -517,9 +580,11 @@ INTSTATUS_64_89 GPIO pad interrupt status register for GPIO 64 to 89. .. table:: - - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+========================================================================================================================================================================+ - |25:0 |R |INTSTATUS|GPIO interrupt status flag. When read, bit i=1 signals that an interrupt has been received on GPIO (64+i). Reading INTSTATUS clears its value and clears interrupt line.| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+========================================================================================================================================================================+ + |25:0 |R |INTSTATUS|0x0 |GPIO interrupt status flag. When read, bit i=1 signals that an interrupt has been received on GPIO (64+i). Reading INTSTATUS clears its value and clears interrupt line.| + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/i3c.rst b/rtos/pulp/gap_archi/doc/ips/i3c.rst index 914d0675f..559ee7898 100644 --- a/rtos/pulp/gap_archi/doc/ips/i3c.rst +++ b/rtos/pulp/gap_archi/doc/ips/i3c.rst @@ -8,191 +8,172 @@ Register map Overview """""""" -.. table:: - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +===============================================================+======+=====+=======================================================================================================================================================+ - |:ref:`Mst_Cntl_En_Reg` | 0| 32|I3C Master control. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_Tr_Req_Reg_1` | 4| 32|Data length or Data byte value to be sent along with the CCC or HDR command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_Tr_Req_Reg_2` | 8| 32|Command type, Transaction ID, CCC code and slave address. Writing to this register is considered as Doorbell for the master to initiate the transfer. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Resp_Reg` | 16| 32|Success or failure of the command, Transaction ID and the remaining data. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`IBI_Resp_Reg` | 20| 32|In-Band interrupt status, timestamping information present, dynamic address of the slave or Hot Join request. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`IBI_Data_Reg` | 24| 32|Data received from the slave during the IBI process. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Data_RX_FIFO_Reg` | 28| 32|Received data FIFO (Data_RX_FIFO). | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Data_TX_FIFO_Reg` | 32| 32|Sending data FIFO (Data_TX_FIFO). | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`IRQ_STATUS_Reg` | 48| 32|Status of the event happened during the transfer. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TCAS_TIMER_Reg` | 64| 32|Timing for Clock after Start condition (TCAS) is the time (in Number of Reference clocks) after the start condition after which the SCL pin can go low.| - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TLOW_OD_TIMER_Reg` | 68| 32|Low period of SCL pin in Open-Drain mode (in Number of Reference clock) after the SCL pin can go high. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`THIGH_OD_TIMER_Reg` | 72| 32|High period of SCL pin in Open-Drain mode (in Number of Reference clock) after the SCL pin can go low. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TLOW_PP_TIMER_Reg` | 76| 32|Low period of SCL pin in Push-Pull mode (in Number of Reference clock) after the SCL pin can go high. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`THIGH_PP_TIMER_Reg` | 80| 32|High period of SCL pin in Push-Pull mode (in Number of Reference clock) after the SCL pin can go low. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TDS_TIMER_Reg` | 84| 32|SDA data setup time during both Open-Drain/Push-Pull mode (in Number of Reference clock). | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`THD_PP_TIMER_Reg` | 88| 32|SDA data hold time during the Push-Pull mode (in Number of Reference clock). | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TCBP_TIMER_Reg` | 92| 32|Clock time before Stop condition. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TCBSR_TIMER_Reg` | 96| 32|Clock time before Repeated start condition. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`THD_DDR_TIMER_Reg` | 100| 32|SDA data hold time during the Push-Pull mode (in Number of Reference clock) in DDR Data rate. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`BUS_FREE_TIMER_Reg` | 104| 32|Bus free time between the Stop condition and the next start condition (in Number of Reference clock). | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`BUS_AVAIL_TIMER_Reg` | 108| 32|Time to keep the SDA and SCL pin to High (in Number of Reference clock). | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIDLE_TIMER_Reg` | 112| 32|Extended duration of the bus free condition after the Stop condition (in Number of Reference clock) to enable the device to drive the Hot Join request.| - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TSCO_TIMER_Reg` | 116| 32|Maximum time the slave needs to drive the bus during the ACK/read data after the clock change. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TSU_STA_TIMER_Reg` | 144| 32|SDA data setup time during both Open-Drain (in Number of Reference clock) for a Repeated Start. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`THD_STA_TIMER_Reg` | 148| 32|SDA data hold time during the Open Drain mode (in Number of Reference clock). | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TLOW_TIMER_Reg` | 152| 32|Low period of SCL pin in Open Drain mode during Legacy I2c Mode (in Number of Reference clock) after the timer reached the SCL pin can go high. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`THIGH_TIMER_Reg` | 156| 32|High period of SCL pin in Open Drain Mode for Legacy I2C (in Number of Reference clock) after this timer count reached the SCL pin can go low. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TVD_DATA_TIMER_Reg` | 160| 32|Data hold time in Open Drain Mode for Legacy I2C (in Number of Reference clock) after this timer count reached the SDA pin can change its value. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TSU_STOP_TIMER_Reg` | 168| 32|SDA data setup time during Open-Drain (in Number of Reference clock) for Stop condition. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Addr_Table_Reg0` | 256| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave0. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Addr_Table_Reg1` | 260| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave1. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Addr_Table_Reg2` | 264| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave2. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Addr_Table_Reg3` | 268| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave3. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Addr_Table_Reg4` | 272| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave4. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Addr_Table_Reg5` | 276| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave5. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Addr_Table_Reg6` | 280| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave6. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Addr_Table_Reg7` | 284| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave7. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Addr_Table_Reg8` | 288| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave8. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Addr_Table_Reg9` | 292| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave9. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Addr_Table_Reg10` | 296| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave10. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Addr_Table_Reg11` | 300| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave11. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg0_0` | 512| 32|BCR, DCR & PID Values of the slave0 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg1_0` | 516| 32|BCR, DCR & PID Values of the slave0 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg2_0` | 520| 32|BCR, DCR & PID Values of the slave0 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg3_0` | 524| 32|BCR, DCR & PID Values of the slave0 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg0_1` | 528| 32|BCR, DCR & PID Values of the slave1 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg1_1` | 532| 32|BCR, DCR & PID Values of the slave1 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg2_1` | 536| 32|BCR, DCR & PID Values of the slave1 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg3_1` | 540| 32|BCR, DCR & PID Values of the slave1 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg0_2` | 544| 32|BCR, DCR & PID Values of the slave2 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg1_2` | 548| 32|BCR, DCR & PID Values of the slave2 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg2_2` | 552| 32|BCR, DCR & PID Values of the slave2 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg3_2` | 556| 32|BCR, DCR & PID Values of the slave2 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg0_3` | 560| 32|BCR, DCR & PID Values of the slave3 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg1_3` | 564| 32|BCR, DCR & PID Values of the slave3 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg2_3` | 568| 32|BCR, DCR & PID Values of the slave3 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg3_3` | 572| 32|BCR, DCR & PID Values of the slave3 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg0_4` | 576| 32|BCR, DCR & PID Values of the slave4 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg1_4` | 580| 32|BCR, DCR & PID Values of the slave4 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg2_4` | 584| 32|BCR, DCR & PID Values of the slave4 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg3_4` | 588| 32|BCR, DCR & PID Values of the slave4 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg0_5` | 592| 32|BCR, DCR & PID Values of the slave5 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg1_5` | 596| 32|BCR, DCR & PID Values of the slave5 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg2_5` | 600| 32|BCR, DCR & PID Values of the slave5 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg3_5` | 604| 32|BCR, DCR & PID Values of the slave5 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg0_6` | 608| 32|BCR, DCR & PID Values of the slave6 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg1_6` | 612| 32|BCR, DCR & PID Values of the slave6 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg2_6` | 616| 32|BCR, DCR & PID Values of the slave6 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg3_6` | 620| 32|BCR, DCR & PID Values of the slave6 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg0_7` | 624| 32|BCR, DCR & PID Values of the slave7 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg1_7` | 628| 32|BCR, DCR & PID Values of the slave7 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg2_7` | 632| 32|BCR, DCR & PID Values of the slave7 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg3_7` | 636| 32|BCR, DCR & PID Values of the slave7 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg0_8` | 640| 32|BCR, DCR & PID Values of the slave8 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg1_8` | 644| 32|BCR, DCR & PID Values of the slave8 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg2_8` | 648| 32|BCR, DCR & PID Values of the slave8 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg3_8` | 652| 32|BCR, DCR & PID Values of the slave8 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg0_9` | 656| 32|BCR, DCR & PID Values of the slave9 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg1_9` | 660| 32|BCR, DCR & PID Values of the slave9 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg2_9` | 664| 32|BCR, DCR & PID Values of the slave9 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg3_9` | 668| 32|BCR, DCR & PID Values of the slave9 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg0_10`| 672| 32|BCR, DCR & PID Values of the slave10 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg1_10`| 676| 32|BCR, DCR & PID Values of the slave10 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg2_10`| 680| 32|BCR, DCR & PID Values of the slave10 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg3_10`| 684| 32|BCR, DCR & PID Values of the slave10 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg0_11`| 688| 32|BCR, DCR & PID Values of the slave11 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg1_11`| 692| 32|BCR, DCR & PID Values of the slave11 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg2_11`| 696| 32|BCR, DCR & PID Values of the slave11 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`Device_Char_Table_Reg3_11`| 700| 32|BCR, DCR & PID Values of the slave11 during the Dynamic address assignment command. | - +---------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _i3c_Mst_Cntl_En_Reg: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +================================================================+======+=====+=======================================================================================================================================================+ + |:ref:`Mst_Cntl_En_Reg` | 0| 32|I3C Master control. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_Tr_Req_Reg_1` | 4| 32|MSBs of command FIFO: data length, and data byte value to be sent along with the CCC or HDR command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_Tr_Req_Reg_2` | 8| 32|LSBs of command FIFO: command type, Transaction ID, CCC code and slave address. Writing to this register triggers command execution. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Resp_Fifo_Reg` | 16| 32|FIFO for received responses: success or failure of the command, transaction ID and the remaining data. Up to 32 outstanding responses can be stored. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`IBI_Resp_Reg` | 20| 32|In-Band interrupt status, timestamping information present, dynamic address of the slave or Hot Join request. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`IBI_Data_Reg` | 24| 32|Data received from the slave during the IBI process. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Data_RX_FIFO_Reg` | 28| 32|Received data FIFO (Data_RX_FIFO). | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Data_TX_FIFO_Reg` | 32| 32|Sending data FIFO (Data_TX_FIFO). | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`IRQ_STATUS_Reg` | 48| 32|Status of the event happened during the transfer. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TCAS_TIMER_Reg` | 64| 32|Timing for Clock after Start condition (TCAS) is the time (in Number of Reference clocks) after the start condition after which the SCL pin can go low.| + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TLOW_OD_TIMER_Reg` | 68| 32|Low period of SCL pin in Open-Drain mode (in Number of Reference clock) after the SCL pin can go high. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`THIGH_OD_TIMER_Reg` | 72| 32|High period of SCL pin in Open-Drain mode (in Number of Reference clock) after the SCL pin can go low. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TLOW_PP_TIMER_Reg` | 76| 32|Low period of SCL pin in Push-Pull mode (in Number of Reference clock) after the SCL pin can go high. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`THIGH_PP_TIMER_Reg` | 80| 32|High period of SCL pin in Push-Pull mode (in Number of Reference clock) after the SCL pin can go low. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TDS_TIMER_Reg` | 84| 32|SDA data setup time during both Open-Drain/Push-Pull mode (in Number of Reference clock). | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`THD_PP_TIMER_Reg` | 88| 32|SDA data hold time during the Push-Pull mode (in Number of Reference clock). | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TCBP_TIMER_Reg` | 92| 32|Clock time before Stop condition. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TCBSR_TIMER_Reg` | 96| 32|Clock time before Repeated start condition. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`THD_DDR_TIMER_Reg` | 100| 32|SDA data hold time during the Push-Pull mode (in Number of Reference clock) in DDR Data rate. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`BUS_FREE_TIMER_Reg` | 104| 32|Bus free time between the Stop condition and the next start condition (in Number of Reference clock). | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`BUS_AVAIL_TIMER_Reg` | 108| 32|Time to keep the SDA and SCL pin to High (in Number of Reference clock). | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIDLE_TIMER_Reg` | 112| 32|Extended duration of the bus free condition after the Stop condition (in Number of Reference clock) to enable the device to drive the Hot Join request.| + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TSCO_TIMER_Reg` | 116| 32|Maximum time the slave needs to drive the bus during the ACK/read data after the clock change. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TSU_STA_TIMER_Reg` | 144| 32|SDA data setup time during both Open-Drain (in Number of Reference clock) for a Repeated Start. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`THD_STA_TIMER_Reg` | 148| 32|SDA data hold time during the Open Drain mode (in Number of Reference clock). | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TLOW_TIMER_Reg` | 152| 32|Low period of SCL pin in Open Drain mode during Legacy I2c Mode (in Number of Reference clock) after the timer reached the SCL pin can go high. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`THIGH_TIMER_Reg` | 156| 32|High period of SCL pin in Open Drain Mode for Legacy I2C (in Number of Reference clock) after this timer count reached the SCL pin can go low. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TVD_DATA_TIMER_Reg` | 160| 32|Data hold time in Open Drain Mode for Legacy I2C (in Number of Reference clock) after this timer count reached the SDA pin can change its value. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TSU_STOP_TIMER_Reg` | 168| 32|SDA data setup time during Open-Drain (in Number of Reference clock) for Stop condition. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Addr_Table_Reg0` | 256| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave0. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Addr_Table_Reg1` | 260| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave1. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Addr_Table_Reg2` | 264| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave2. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Addr_Table_Reg3` | 268| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave3. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Addr_Table_Reg4` | 272| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave4. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Addr_Table_Reg5` | 276| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave5. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Addr_Table_Reg6` | 280| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave6. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Addr_Table_Reg7` | 284| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave7. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Addr_Table_Reg8` | 288| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave8. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Addr_Table_Reg9` | 292| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave9. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Addr_Table_Reg10` | 296| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave10. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Addr_Table_Reg11` | 300| 32|Device type, IBI handling and Dynamic address to be set and Static address of the slave11. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg0_0` | 512| 32|MSB of PID value of slave0 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg1_0` | 516| 32|LSB of PID value of slave0 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg2_0` | 520| 32|BCR, DCR and dynamic address of slave0 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg0_1` | 528| 32|MSB of PID value of slave1 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg1_1` | 532| 32|LSB of PID value of slave1 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg2_1` | 536| 32|BCR, DCR and dynamic address of slave1 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg0_2` | 544| 32|MSB of PID value of slave2 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg1_2` | 548| 32|LSB of PID value of slave2 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg2_2` | 552| 32|BCR, DCR and dynamic address of slave2 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg0_3` | 560| 32|MSB of PID value of slave3 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg1_3` | 564| 32|LSB of PID value of slave3 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg2_3` | 568| 32|BCR, DCR and dynamic address of slave3 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg0_4` | 576| 32|MSB of PID value of slave4 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg1_4` | 580| 32|LSB of PID value of slave4 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg2_4` | 584| 32|BCR, DCR and dynamic address of slave4 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg0_5` | 592| 32|MSB of PID value of slave5 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg1_5` | 596| 32|LSB of PID value of slave5 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg2_5` | 600| 32|BCR, DCR and dynamic address of slave5 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg0_6` | 608| 32|MSB of PID value of slave6 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg1_6` | 612| 32|LSB of PID value of slave6 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg2_6` | 616| 32|BCR, DCR and dynamic address of slave6 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg0_7` | 624| 32|MSB of PID value of slave7 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg1_7` | 628| 32|LSB of PID value of slave7 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg2_7` | 632| 32|BCR, DCR and dynamic address of slave7 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg0_8` | 640| 32|MSB of PID value of slave8 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg1_8` | 644| 32|LSB of PID value of slave8 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg2_8` | 648| 32|BCR, DCR and dynamic address of slave8 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg0_9` | 656| 32|MSB of PID value of slave9 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg1_9` | 660| 32|LSB of PID value of slave9 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg2_9` | 664| 32|BCR, DCR and dynamic address of slave9 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg0_10`| 672| 32|MSB of PID value of slave10 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg1_10`| 676| 32|LSB of PID value of slave10 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg2_10`| 680| 32|BCR, DCR and dynamic address of slave10 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg0_11`| 688| 32|MSB of PID value of slave11 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg1_11`| 692| 32|LSB of PID value of slave11 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`Device_Char_Table_Reg2_11`| 696| 32|BCR, DCR and dynamic address of slave11 during the dynamic address assignment command. | + +----------------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _i3c__Mst_Cntl_En_Reg: Mst_Cntl_En_Reg """"""""""""""" @@ -200,55 +181,73 @@ Mst_Cntl_En_Reg I3C Master control. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=================+=====+==============================================================================================================================================================+ + | 0|R/W|MASTER_CONTROL_EN|0x0 |Enable I3C master interface: b0: disabled; b1: enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|MASTER_RST_EN |0x0 |Enable master controller to issue soft reset during any transfer. Soft reset will be applied after the completion of ACK/NACK state. b0: disabled; b1: enabled| + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_CMD_Tr_Req_Reg_1: +.. _i3c__CMD_Tr_Req_Reg_1: CMD_Tr_Req_Reg_1 """""""""""""""" -Data length or Data byte value to be sent along with the CCC or HDR command. +MSBs of command FIFO: data length, and data byte value to be sent along with the CCC or HDR command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+--------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================================================================================+ + |31:0 |W |DATA|0x0 |Data length or data byte value, depending on the type of command being initiated. See description of commands.| + +-----+---+----+-----+--------------------------------------------------------------------------------------------------------------+ -.. _i3c_CMD_Tr_Req_Reg_2: +.. _i3c__CMD_Tr_Req_Reg_2: CMD_Tr_Req_Reg_2 """""""""""""""" -Command type, Transaction ID, CCC code and slave address. Writing to this register is considered as Doorbell for the master to initiate the transfer. +LSBs of command FIFO: command type, Transaction ID, CCC code and slave address. Writing to this register triggers command execution. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==========================================================================================================================================================================+ + |31:0 |W |CMD_REQ|0x0 |Command request, which contains information about the command type, transaction ID, slave address and the type of CCC or HDR to be initiated. See description of commands.| + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Resp_Reg: +.. _i3c__Resp_Fifo_Reg: -Resp_Reg -"""""""" +Resp_Fifo_Reg +""""""""""""" -Success or failure of the command, Transaction ID and the remaining data. +FIFO for received responses: success or failure of the command, transaction ID and the remaining data. Up to 32 outstanding responses can be stored. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+====================================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R |DATA_LEN |0x0 |Write transfer: remaining Data length (in bytes); Read transfer: number of read data received from the slave; Address command: remaining device count | + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |27:24|R |TID |0x0 |Command request Tag ID | + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:28|R |ERR_STATUS|0x0 |Type of error or success for the command transfer: 0x0: Success; 0x1: CRC Error; 0x2: Parity Error; 0x3-0x4: Reserved; 0x5: NACK error for Dynamic address, M0/M2 Error & HDR NACK error; 0x6: Overflow/underflow error; 0x7: Reserved; 0x8: Data success with Retry operation; 0x9-0xD: Reserved; 0xE: Overflow/underflow error with Retry operation; 0xF: Reserved| + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_IBI_Resp_Reg: +.. _i3c__IBI_Resp_Reg: IBI_Resp_Reg """""""""""" @@ -256,13 +255,24 @@ IBI_Resp_Reg In-Band interrupt status, timestamping information present, dynamic address of the slave or Hot Join request. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+-----+---------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+===========================================================================================================================+ + |7:0 |R |DATA_LEN |0x0 |IBI Data length. Number of bytes in the IBI requests received. | + +-----+---+----------+-----+---------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R |IBI_ID |0x0 |IBI received ID. Contains slave address for IBI. Contains Hot Join ID for the Hot-Join IBI | + +-----+---+----------+-----+---------------------------------------------------------------------------------------------------------------------------+ + |25 |R |TS_PRESENT|0x0 |IBI timestamp present for IBI: b1: IBI is timestamped; b0: IBI is not timestamped | + +-----+---+----------+-----+---------------------------------------------------------------------------------------------------------------------------+ + |30:26|R/W|RESERVED_5|0x0 |Reserved/Not used. | + +-----+---+----------+-----+---------------------------------------------------------------------------------------------------------------------------+ + |31 |R |IBI_STS |0x0 |IBI status. Indicates how the IBI is handled: b0: Indicates IBI is handled with ACK; b1: Indicates IBI is handled with NACK| + +-----+---+----------+-----+---------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_IBI_Data_Reg: +.. _i3c__IBI_Data_Reg: IBI_Data_Reg """""""""""" @@ -270,13 +280,16 @@ IBI_Data_Reg Data received from the slave during the IBI process. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+---------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=====================================================================================================================+ + |31:0 |R |IBI_DATA|0x0 |IBI data. Data received during the IBI process is stored in FIFO and is sent out to the software using this register.| + +-----+---+--------+-----+---------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Data_RX_FIFO_Reg: +.. _i3c__Data_RX_FIFO_Reg: Data_RX_FIFO_Reg """""""""""""""" @@ -284,13 +297,16 @@ Data_RX_FIFO_Reg Received data FIFO (Data_RX_FIFO). .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==============================================================================================================================+ + |31:0 |R |DATA_RX|0x0 |All the data received from the slave is stored in a FIFO. For each read of this register, a value are retrieved from the FIFO.| + +-----+---+-------+-----+------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Data_TX_FIFO_Reg: +.. _i3c__Data_TX_FIFO_Reg: Data_TX_FIFO_Reg """""""""""""""" @@ -298,13 +314,16 @@ Data_TX_FIFO_Reg Sending data FIFO (Data_TX_FIFO). .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+----------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+======================================================================================================================+ + |31:0 |W |DATA_TX|0x0 |Write data to be sent from the master to the slave. Software writes this register to send the write data to the slave.| + +-----+---+-------+-----+----------------------------------------------------------------------------------------------------------------------+ -.. _i3c_IRQ_STATUS_Reg: +.. _i3c__IRQ_STATUS_Reg: IRQ_STATUS_Reg """""""""""""" @@ -312,13 +331,32 @@ IRQ_STATUS_Reg Status of the event happened during the transfer. .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_TCAS_TIMER_Reg: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------------+-----+-------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+=================================================+ + | 0|R |RESP_DONE |0x0 |Indicate the response completion is done. | + +-----+---+---------------------+-----+-------------------------------------------------+ + | 1|R |DATA_TX_FIFO_FULL |0x0 |Indicate the data TX FIFO is full. | + +-----+---+---------------------+-----+-------------------------------------------------+ + | 2|R |DATA_TX_FIFO_EMPTY |0x0 |Indicate the data TX FIFO is empty. | + +-----+---+---------------------+-----+-------------------------------------------------+ + | 3|R |CMD_REQ_FIFO_FULL |0x0 |Indicate the command transfer request FIFO Full. | + +-----+---+---------------------+-----+-------------------------------------------------+ + | 4|R |DATA_RX_FIFO_FULL |0x0 |Indicate the data RX FIFO Full. | + +-----+---+---------------------+-----+-------------------------------------------------+ + | 5|R |RESP_COMPL |0x0 |Indicate the response completion FIFO is full. | + +-----+---+---------------------+-----+-------------------------------------------------+ + | 6|R |IBI_TRANSFER_DONE |0x0 |Indicate the IBI request is received from slave. | + +-----+---+---------------------+-----+-------------------------------------------------+ + | 7|R |IBI_DATA_RX_FIFO_FULL|0x0 |Indicate the IBI payload is full. | + +-----+---+---------------------+-----+-------------------------------------------------+ + | 8|R |RST_COMPLETION |0x0 |Indicate the Master controller issued soft reset.| + +-----+---+---------------------+-----+-------------------------------------------------+ + +.. _i3c__TCAS_TIMER_Reg: TCAS_TIMER_Reg """""""""""""" @@ -326,13 +364,16 @@ TCAS_TIMER_Reg Timing for Clock after Start condition (TCAS) is the time (in Number of Reference clocks) after the start condition after which the SCL pin can go low. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+=========================================================================================================================================================================================================================================+ + |31:0 |R/W|TCAS_TIMER|0x3 |Timing of the SCL pin to go low after the start condition (number of clock cycles). As per specification, min time value is 38.4ns. For example, with a 100MHz clock, 4 clock periods are required. So, the value of the register is 0x3.| + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_TLOW_OD_TIMER_Reg: +.. _i3c__TLOW_OD_TIMER_Reg: TLOW_OD_TIMER_Reg """"""""""""""""" @@ -340,13 +381,16 @@ TLOW_OD_TIMER_Reg Low period of SCL pin in Open-Drain mode (in Number of Reference clock) after the SCL pin can go high. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+==========================================================================================================================================================================================================================================+ + |4:0 |R/W|TLOW_OD_TIMER|0x23 |Low period of the SCL clock pin (number of clock cycles). As per specification, min time value is 200ns + fall time of SDA signal. For example, with a 100MHz clock, 24 clock periods are required. So, the value of the register is 0x23.| + +-----+---+-------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_THIGH_OD_TIMER_Reg: +.. _i3c__THIGH_OD_TIMER_Reg: THIGH_OD_TIMER_Reg """""""""""""""""" @@ -354,13 +398,16 @@ THIGH_OD_TIMER_Reg High period of SCL pin in Open-Drain mode (in Number of Reference clock) after the SCL pin can go low. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+====================================================================================================================================================================================================================+ + |4:0 |R/W|THIGH_OD_TIMER|0x2 |High period of the SCL clock pin (number of clock cycles). As per specification, max time value is 41ns. For example, with a 100MHz clock, max. of 2 clock periods is allowed. So, the value of the register is 0x2.| + +-----+---+--------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_TLOW_PP_TIMER_Reg: +.. _i3c__TLOW_PP_TIMER_Reg: TLOW_PP_TIMER_Reg """"""""""""""""" @@ -368,13 +415,16 @@ TLOW_PP_TIMER_Reg Low period of SCL pin in Push-Pull mode (in Number of Reference clock) after the SCL pin can go high. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+===============================================================================================================================================================================================================================+ + |4:0 |R/W|TLOW_PP_TIMER|0x3 |Low period of the SCL clock pin (number of clock cycles) in push-pull mode. As per specification, min time value is 24ns. For example, with a 100MHz clock, 3 clock periods are required. So, the value of the register is 0x3.| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_THIGH_PP_TIMER_Reg: +.. _i3c__THIGH_PP_TIMER_Reg: THIGH_PP_TIMER_Reg """""""""""""""""" @@ -382,13 +432,16 @@ THIGH_PP_TIMER_Reg High period of SCL pin in Push-Pull mode (in Number of Reference clock) after the SCL pin can go low. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+======================================================================================================================================================================================================================+ + |4:0 |R/W|THIGH_PP_TIMER|0x2 |High period of the SCL clock pin (number of clock cycles). As per specification, max time value is 41ns. For example, with a 100MHz clock, max. of 4 clock periods are required. So, the value of the register is 0x2.| + +-----+---+--------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_TDS_TIMER_Reg: +.. _i3c__TDS_TIMER_Reg: TDS_TIMER_Reg """"""""""""" @@ -396,13 +449,16 @@ TDS_TIMER_Reg SDA data setup time during both Open-Drain/Push-Pull mode (in Number of Reference clock). .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==========================================================================================================================================================================================+ + |2:0 |R/W|TDS_TIMER|0x1 |SDA Set up time (number of clock cycles). As per specification, min time value is 3ns. For example, with a 100MHz clock, 1 clock period is required. So, the value of the register is 0x1.| + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_THD_PP_TIMER_Reg: +.. _i3c__THD_PP_TIMER_Reg: THD_PP_TIMER_Reg """""""""""""""" @@ -410,13 +466,16 @@ THD_PP_TIMER_Reg SDA data hold time during the Push-Pull mode (in Number of Reference clock). .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+========================================================================================================================================================================================+ + |2:0 |R/W|THD_PP_TIMER|0x1 |SDA Hold time (number of clock cycles). As per specification, min time value is 6ns. For example, with a 100MHz clock, 1 clock period is required. So, the value of the register is 0x1.| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_TCBP_TIMER_Reg: +.. _i3c__TCBP_TIMER_Reg: TCBP_TIMER_Reg """""""""""""" @@ -424,13 +483,16 @@ TCBP_TIMER_Reg Clock time before Stop condition. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+====================================================================================================================================================================================================================================================================================+ + |4:0 |R/W|TCBP_TIMER|0x1 |To signal stop condition, the master should change the SDA pin after this time of SCL clock edge (number of clock cycles). As per specification, min time value is 19.2ns. For example, with a 100MHz ref clock, 2 clock periods are required. So, the value of the register is 0x1.| + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_TCBSR_TIMER_Reg: +.. _i3c__TCBSR_TIMER_Reg: TCBSR_TIMER_Reg """"""""""""""" @@ -438,13 +500,16 @@ TCBSR_TIMER_Reg Clock time before Repeated start condition. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+==============================================================================================================================================================================================================================================================================================+ + |2:0 |R/W|TCBSR_TIMER|0x1 |To signal repeated start condition, the master should change the SDA pin after this time of SCL clock edge (number of clock cycles). As per specification, min time value is 19.2ns. For example, with a 100MHz ref clock, 2 clock periods are required. So, the value of the register is 0x1.| + +-----+---+-----------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_THD_DDR_TIMER_Reg: +.. _i3c__THD_DDR_TIMER_Reg: THD_DDR_TIMER_Reg """"""""""""""""" @@ -452,13 +517,16 @@ THD_DDR_TIMER_Reg SDA data hold time during the Push-Pull mode (in Number of Reference clock) in DDR Data rate. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+============================================================================================================================================================================================+ + |2:0 |R/W|THD_DDR_TIMER|0x1 |SDA Hold time (number of clock cycles). As per specification, min time value is 6ns. For example, with a 100MHz ref clock, 1 clock period is required. So, the value of the register is 0x1.| + +-----+---+-------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_BUS_FREE_TIMER_Reg: +.. _i3c__BUS_FREE_TIMER_Reg: BUS_FREE_TIMER_Reg """""""""""""""""" @@ -466,13 +534,16 @@ BUS_FREE_TIMER_Reg Bus free time between the Stop condition and the next start condition (in Number of Reference clock). .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------------+-----+-----------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+=======================================================================================================================+ + |31:0 |R/W|BUS_FREE_TIMER|0xC8 |Bus free time after the stop condition and the start condition. As per specification, min. value of this period is 1us.| + +-----+---+--------------+-----+-----------------------------------------------------------------------------------------------------------------------+ -.. _i3c_BUS_AVAIL_TIMER_Reg: +.. _i3c__BUS_AVAIL_TIMER_Reg: BUS_AVAIL_TIMER_Reg """"""""""""""""""" @@ -480,13 +551,16 @@ BUS_AVAIL_TIMER_Reg Time to keep the SDA and SCL pin to High (in Number of Reference clock). .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+---------------+-----+------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+============================================================================================================+ + |31:0 |R/W|BUS_AVAIL_TIMER|0xC8 |Bus available time to drive SCL and SDA pin to high. As per specification, min. value of this period is 1us.| + +-----+---+---------------+-----+------------------------------------------------------------------------------------------------------------+ -.. _i3c_TIDLE_TIMER_Reg: +.. _i3c__TIDLE_TIMER_Reg: TIDLE_TIMER_Reg """"""""""""""" @@ -494,13 +568,16 @@ TIDLE_TIMER_Reg Extended duration of the bus free condition after the Stop condition (in Number of Reference clock) to enable the device to drive the Hot Join request. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+============================================================================================================+ + |31:0 |R/W|TIDLE_TIMER|0xC8 |Bus available time to drive SCL and SDA pin to high. As per specification, min. value of this period is 1ms.| + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------+ -.. _i3c_TSCO_TIMER_Reg: +.. _i3c__TSCO_TIMER_Reg: TSCO_TIMER_Reg """""""""""""" @@ -508,13 +585,16 @@ TSCO_TIMER_Reg Maximum time the slave needs to drive the bus during the ACK/read data after the clock change. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+===========================================================================================================+ + |2:0 |R/W|TSCO_TIMER|0x2 |Maximum time for the slave to release bus after the clock change. As per specification, max. value is 12ns.| + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------+ -.. _i3c_TSU_STA_TIMER_Reg: +.. _i3c__TSU_STA_TIMER_Reg: TSU_STA_TIMER_Reg """"""""""""""""" @@ -522,13 +602,16 @@ TSU_STA_TIMER_Reg SDA data setup time during both Open-Drain (in Number of Reference clock) for a Repeated Start. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+===========================================================================================================================================================================================================================================================================================================================================================+ + |8:0 |R/W|TSU_STA_TIMER|0x46 |SDA setup time (number of clock cycles) for a repeated start during legacy I2C mode. As per specification, min time value is 600ns for legacy FM mode, and 260ns for legacy FM+ mode. For example, with a 100MHz clock, 70 clock periods are required for FM mode, and the value of the register is 0x46. For FM+ mode, the value of this register is 0x1E.| + +-----+---+-------------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_THD_STA_TIMER_Reg: +.. _i3c__THD_STA_TIMER_Reg: THD_STA_TIMER_Reg """"""""""""""""" @@ -536,13 +619,16 @@ THD_STA_TIMER_Reg SDA data hold time during the Open Drain mode (in Number of Reference clock). .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================================================================================================================================================================================================================================================================================+ + |8:0 |R/W|THD_STA_TIMER|0x46 |SDA hold time (number of clock cycles) after start/repeated start. As per specification, min time value is 600ns for legacy FM mode, and 260ns for legacy FM+ mode. For example, with a 100MHz clock, 70 clock periods are required for FM mode, and the value of the register is 0x46. For FM+ mode, the value of this register is 0x1E.| + +-----+---+-------------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_TLOW_TIMER_Reg: +.. _i3c__TLOW_TIMER_Reg: TLOW_TIMER_Reg """""""""""""" @@ -550,13 +636,16 @@ TLOW_TIMER_Reg Low period of SCL pin in Open Drain mode during Legacy I2c Mode (in Number of Reference clock) after the timer reached the SCL pin can go high. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+=====================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|TLOW_TIMER|0x8C |Low period of the SCL clock pin (number of clock cycles) in legacy I2C mode. As per specification, min time value is 1300ns for legacy FM mode, and 500ns for legacy FM+ mode. For example, with a 100MHz clock, 130 clock periods are required for FM mode, and the value of the register is 0x8C. For FM+ mode, the value of this register is 0x3C.| + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_THIGH_TIMER_Reg: +.. _i3c__THIGH_TIMER_Reg: THIGH_TIMER_Reg """"""""""""""" @@ -564,13 +653,16 @@ THIGH_TIMER_Reg High period of SCL pin in Open Drain Mode for Legacy I2C (in Number of Reference clock) after this timer count reached the SCL pin can go low. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+====================================================================================================================================================================================================================================================================================================================================================+ + |15:0 |R/W|THIGH_TIMER|0x46 |High period of the SCL clock pin (number of clock cycles) in legacy I2C mode. As per specification, min time value is 600ns for legacy FM mode, and 260ns for legacy FM+ mode. For example, with a 100MHz clock, 70 clock periods are required for FM mode, and the value of the register is 0x46. For FM+ mode, the value of this register is 0x1E.| + +-----+---+-----------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_TVD_DATA_TIMER_Reg: +.. _i3c__TVD_DATA_TIMER_Reg: TVD_DATA_TIMER_Reg """""""""""""""""" @@ -578,13 +670,16 @@ TVD_DATA_TIMER_Reg Data hold time in Open Drain Mode for Legacy I2C (in Number of Reference clock) after this timer count reached the SDA pin can change its value. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+==============================================================================================================================================================================================================================================================================================================================================================================================================+ + |9:0 |R/W|TVD_DATA_TIMER|0x46 |Data hold time (number of clock cycles) in legacy I2C mode. As per specification, min data setup time value is 100ns for legacy FM mode (so hold time will be min 600ns), and 50ns for legacy FM+ mode (so hold time will be min 260ns). For example, with a 100MHz clock, 70 clock periods are required for FM mode, and the value of the register is 0x46. For FM+ Mode, the value of this register is 0x1E.| + +-----+---+--------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_TSU_STOP_TIMER_Reg: +.. _i3c__TSU_STOP_TIMER_Reg: TSU_STOP_TIMER_Reg """""""""""""""""" @@ -592,13 +687,16 @@ TSU_STOP_TIMER_Reg SDA data setup time during Open-Drain (in Number of Reference clock) for Stop condition. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+=========================================================================================================================================================================================================================================================================================================================================================+ + |8:0 |R/W|TSU_STOP_TIMER|0x46 |SDA setup time (number of clock cycles) for stop condition during legacy I2C mode. As per specification, min time value is 600ns for legacy FM mode, and 260ns for Legacy FM+ Mode. For example, with a 100MHz clock, 70 clock periods are required for FM mode, and the value of the register is 0x46. For FM+ Mode, the value of this register is 0x1E.| + +-----+---+--------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Addr_Table_Reg0: +.. _i3c__Device_Addr_Table_Reg0: Device_Addr_Table_Reg0 """""""""""""""""""""" @@ -606,13 +704,26 @@ Device_Addr_Table_Reg0 Device type, IBI handling and Dynamic address to be set and Static address of the slave0. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===============================================================================================================================================================================+ + |6:0 |R/W|Static_Addr |0x0 |Device I3C/I2C static address | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|IBI_Payload |0x0 |IBI payload. This bit reflects the information from the BCR regarding the IBI data present to be received by the master: b0: No IBI data payload; b1: IBI data contains payload| + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|In_Band_Req |0x0 |In-band interrupt enable. Controls the master to ACK/NACK the IBI requests from the particular slave. | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|Timestamp |0x0 |Device IBI timestamp. Enables or disables timestamping for a particular device: b0: Timestamp not required; b1: Timestamp enabled | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|Dynamic_Addr|0x0 |Device I3C dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |R/W|Device_Type |0x0 |Device type: b0: I3C Device; b1: I2C Device | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Addr_Table_Reg1: +.. _i3c__Device_Addr_Table_Reg1: Device_Addr_Table_Reg1 """""""""""""""""""""" @@ -620,13 +731,26 @@ Device_Addr_Table_Reg1 Device type, IBI handling and Dynamic address to be set and Static address of the slave1. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===============================================================================================================================================================================+ + |6:0 |R/W|Static_Addr |0x0 |Device I3C/I2C static address | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|IBI_Payload |0x0 |IBI payload. This bit reflects the information from the BCR regarding the IBI data present to be received by the master: b0: No IBI data payload; b1: IBI data contains payload| + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|In_Band_Req |0x0 |In-band interrupt enable. Controls the master to ACK/NACK the IBI requests from the particular slave. | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|Timestamp |0x0 |Device IBI timestamp. Enables or disables timestamping for a particular device: b0: Timestamp not required; b1: Timestamp enabled | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|Dynamic_Addr|0x0 |Device I3C dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |R/W|Device_Type |0x0 |Device type: b0: I3C Device; b1: I2C Device | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Addr_Table_Reg2: +.. _i3c__Device_Addr_Table_Reg2: Device_Addr_Table_Reg2 """""""""""""""""""""" @@ -634,13 +758,26 @@ Device_Addr_Table_Reg2 Device type, IBI handling and Dynamic address to be set and Static address of the slave2. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===============================================================================================================================================================================+ + |6:0 |R/W|Static_Addr |0x0 |Device I3C/I2C static address | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|IBI_Payload |0x0 |IBI payload. This bit reflects the information from the BCR regarding the IBI data present to be received by the master: b0: No IBI data payload; b1: IBI data contains payload| + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|In_Band_Req |0x0 |In-band interrupt enable. Controls the master to ACK/NACK the IBI requests from the particular slave. | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|Timestamp |0x0 |Device IBI timestamp. Enables or disables timestamping for a particular device: b0: Timestamp not required; b1: Timestamp enabled | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|Dynamic_Addr|0x0 |Device I3C dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |R/W|Device_Type |0x0 |Device type: b0: I3C Device; b1: I2C Device | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Addr_Table_Reg3: +.. _i3c__Device_Addr_Table_Reg3: Device_Addr_Table_Reg3 """""""""""""""""""""" @@ -648,13 +785,26 @@ Device_Addr_Table_Reg3 Device type, IBI handling and Dynamic address to be set and Static address of the slave3. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===============================================================================================================================================================================+ + |6:0 |R/W|Static_Addr |0x0 |Device I3C/I2C static address | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|IBI_Payload |0x0 |IBI payload. This bit reflects the information from the BCR regarding the IBI data present to be received by the master: b0: No IBI data payload; b1: IBI data contains payload| + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|In_Band_Req |0x0 |In-band interrupt enable. Controls the master to ACK/NACK the IBI requests from the particular slave. | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|Timestamp |0x0 |Device IBI timestamp. Enables or disables timestamping for a particular device: b0: Timestamp not required; b1: Timestamp enabled | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|Dynamic_Addr|0x0 |Device I3C dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |R/W|Device_Type |0x0 |Device type: b0: I3C Device; b1: I2C Device | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Addr_Table_Reg4: +.. _i3c__Device_Addr_Table_Reg4: Device_Addr_Table_Reg4 """""""""""""""""""""" @@ -662,13 +812,26 @@ Device_Addr_Table_Reg4 Device type, IBI handling and Dynamic address to be set and Static address of the slave4. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===============================================================================================================================================================================+ + |6:0 |R/W|Static_Addr |0x0 |Device I3C/I2C static address | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|IBI_Payload |0x0 |IBI payload. This bit reflects the information from the BCR regarding the IBI data present to be received by the master: b0: No IBI data payload; b1: IBI data contains payload| + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|In_Band_Req |0x0 |In-band interrupt enable. Controls the master to ACK/NACK the IBI requests from the particular slave. | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|Timestamp |0x0 |Device IBI timestamp. Enables or disables timestamping for a particular device: b0: Timestamp not required; b1: Timestamp enabled | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|Dynamic_Addr|0x0 |Device I3C dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |R/W|Device_Type |0x0 |Device type: b0: I3C Device; b1: I2C Device | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Addr_Table_Reg5: +.. _i3c__Device_Addr_Table_Reg5: Device_Addr_Table_Reg5 """""""""""""""""""""" @@ -676,13 +839,26 @@ Device_Addr_Table_Reg5 Device type, IBI handling and Dynamic address to be set and Static address of the slave5. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===============================================================================================================================================================================+ + |6:0 |R/W|Static_Addr |0x0 |Device I3C/I2C static address | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|IBI_Payload |0x0 |IBI payload. This bit reflects the information from the BCR regarding the IBI data present to be received by the master: b0: No IBI data payload; b1: IBI data contains payload| + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|In_Band_Req |0x0 |In-band interrupt enable. Controls the master to ACK/NACK the IBI requests from the particular slave. | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|Timestamp |0x0 |Device IBI timestamp. Enables or disables timestamping for a particular device: b0: Timestamp not required; b1: Timestamp enabled | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|Dynamic_Addr|0x0 |Device I3C dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |R/W|Device_Type |0x0 |Device type: b0: I3C Device; b1: I2C Device | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Addr_Table_Reg6: +.. _i3c__Device_Addr_Table_Reg6: Device_Addr_Table_Reg6 """""""""""""""""""""" @@ -690,13 +866,26 @@ Device_Addr_Table_Reg6 Device type, IBI handling and Dynamic address to be set and Static address of the slave6. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===============================================================================================================================================================================+ + |6:0 |R/W|Static_Addr |0x0 |Device I3C/I2C static address | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|IBI_Payload |0x0 |IBI payload. This bit reflects the information from the BCR regarding the IBI data present to be received by the master: b0: No IBI data payload; b1: IBI data contains payload| + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|In_Band_Req |0x0 |In-band interrupt enable. Controls the master to ACK/NACK the IBI requests from the particular slave. | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|Timestamp |0x0 |Device IBI timestamp. Enables or disables timestamping for a particular device: b0: Timestamp not required; b1: Timestamp enabled | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|Dynamic_Addr|0x0 |Device I3C dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |R/W|Device_Type |0x0 |Device type: b0: I3C Device; b1: I2C Device | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Addr_Table_Reg7: +.. _i3c__Device_Addr_Table_Reg7: Device_Addr_Table_Reg7 """""""""""""""""""""" @@ -704,13 +893,26 @@ Device_Addr_Table_Reg7 Device type, IBI handling and Dynamic address to be set and Static address of the slave7. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===============================================================================================================================================================================+ + |6:0 |R/W|Static_Addr |0x0 |Device I3C/I2C static address | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|IBI_Payload |0x0 |IBI payload. This bit reflects the information from the BCR regarding the IBI data present to be received by the master: b0: No IBI data payload; b1: IBI data contains payload| + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|In_Band_Req |0x0 |In-band interrupt enable. Controls the master to ACK/NACK the IBI requests from the particular slave. | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|Timestamp |0x0 |Device IBI timestamp. Enables or disables timestamping for a particular device: b0: Timestamp not required; b1: Timestamp enabled | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|Dynamic_Addr|0x0 |Device I3C dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |R/W|Device_Type |0x0 |Device type: b0: I3C Device; b1: I2C Device | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Addr_Table_Reg8: +.. _i3c__Device_Addr_Table_Reg8: Device_Addr_Table_Reg8 """""""""""""""""""""" @@ -718,13 +920,26 @@ Device_Addr_Table_Reg8 Device type, IBI handling and Dynamic address to be set and Static address of the slave8. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===============================================================================================================================================================================+ + |6:0 |R/W|Static_Addr |0x0 |Device I3C/I2C static address | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|IBI_Payload |0x0 |IBI payload. This bit reflects the information from the BCR regarding the IBI data present to be received by the master: b0: No IBI data payload; b1: IBI data contains payload| + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|In_Band_Req |0x0 |In-band interrupt enable. Controls the master to ACK/NACK the IBI requests from the particular slave. | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|Timestamp |0x0 |Device IBI timestamp. Enables or disables timestamping for a particular device: b0: Timestamp not required; b1: Timestamp enabled | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|Dynamic_Addr|0x0 |Device I3C dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |R/W|Device_Type |0x0 |Device type: b0: I3C Device; b1: I2C Device | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Addr_Table_Reg9: +.. _i3c__Device_Addr_Table_Reg9: Device_Addr_Table_Reg9 """""""""""""""""""""" @@ -732,13 +947,26 @@ Device_Addr_Table_Reg9 Device type, IBI handling and Dynamic address to be set and Static address of the slave9. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===============================================================================================================================================================================+ + |6:0 |R/W|Static_Addr |0x0 |Device I3C/I2C static address | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|IBI_Payload |0x0 |IBI payload. This bit reflects the information from the BCR regarding the IBI data present to be received by the master: b0: No IBI data payload; b1: IBI data contains payload| + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|In_Band_Req |0x0 |In-band interrupt enable. Controls the master to ACK/NACK the IBI requests from the particular slave. | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|Timestamp |0x0 |Device IBI timestamp. Enables or disables timestamping for a particular device: b0: Timestamp not required; b1: Timestamp enabled | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|Dynamic_Addr|0x0 |Device I3C dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |R/W|Device_Type |0x0 |Device type: b0: I3C Device; b1: I2C Device | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Addr_Table_Reg10: +.. _i3c__Device_Addr_Table_Reg10: Device_Addr_Table_Reg10 """"""""""""""""""""""" @@ -746,13 +974,26 @@ Device_Addr_Table_Reg10 Device type, IBI handling and Dynamic address to be set and Static address of the slave10. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===============================================================================================================================================================================+ + |6:0 |R/W|Static_Addr |0x0 |Device I3C/I2C static address | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|IBI_Payload |0x0 |IBI payload. This bit reflects the information from the BCR regarding the IBI data present to be received by the master: b0: No IBI data payload; b1: IBI data contains payload| + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|In_Band_Req |0x0 |In-band interrupt enable. Controls the master to ACK/NACK the IBI requests from the particular slave. | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|Timestamp |0x0 |Device IBI timestamp. Enables or disables timestamping for a particular device: b0: Timestamp not required; b1: Timestamp enabled | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|Dynamic_Addr|0x0 |Device I3C dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |R/W|Device_Type |0x0 |Device type: b0: I3C Device; b1: I2C Device | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Addr_Table_Reg11: +.. _i3c__Device_Addr_Table_Reg11: Device_Addr_Table_Reg11 """"""""""""""""""""""" @@ -760,680 +1001,805 @@ Device_Addr_Table_Reg11 Device type, IBI handling and Dynamic address to be set and Static address of the slave11. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===============================================================================================================================================================================+ + |6:0 |R/W|Static_Addr |0x0 |Device I3C/I2C static address | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|IBI_Payload |0x0 |IBI payload. This bit reflects the information from the BCR regarding the IBI data present to be received by the master: b0: No IBI data payload; b1: IBI data contains payload| + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|In_Band_Req |0x0 |In-band interrupt enable. Controls the master to ACK/NACK the IBI requests from the particular slave. | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|Timestamp |0x0 |Device IBI timestamp. Enables or disables timestamping for a particular device: b0: Timestamp not required; b1: Timestamp enabled | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|Dynamic_Addr|0x0 |Device I3C dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |R/W|Device_Type |0x0 |Device type: b0: I3C Device; b1: I2C Device | + +-----+---+------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg0_0: +.. _i3c__Device_Char_Table_Reg0_0: Device_Char_Table_Reg0_0 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave0 during the Dynamic address assignment command. +MSB of PID value of slave0 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============================================================+ + |31:0 |R |PID_HIGH|0x0 |Device provisional ID high: bits [48:16] of Device’s I3C PID.| + +-----+---+--------+-----+-------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg1_0: +.. _i3c__Device_Char_Table_Reg1_0: Device_Char_Table_Reg1_0 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave0 during the Dynamic address assignment command. +LSB of PID value of slave0 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===========================================================+ + |15:0 |R |PID_LOW|0x0 |Device provisional ID low: bits [15:0] of Device’s I3C PID.| + +-----+---+-------+-----+-----------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg2_0: +.. _i3c__Device_Char_Table_Reg2_0: Device_Char_Table_Reg2_0 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave0 during the Dynamic address assignment command. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg3_0: - -Device_Char_Table_Reg3_0 -"""""""""""""""""""""""" - -BCR, DCR & PID Values of the slave0 during the Dynamic address assignment command. +BCR, DCR and dynamic address of slave0 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+====================================================================================================================================================+ + |7:0 |R |DCR |0x0 |Device Characteristics Register(DCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R |BCR |0x0 |I3C Bus Characteristics Register(BCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R |Dynamic_Addr|0x0 |Device I3C Dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg0_1: +.. _i3c__Device_Char_Table_Reg0_1: Device_Char_Table_Reg0_1 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave1 during the Dynamic address assignment command. +MSB of PID value of slave1 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============================================================+ + |31:0 |R |PID_HIGH|0x0 |Device provisional ID high: bits [48:16] of Device’s I3C PID.| + +-----+---+--------+-----+-------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg1_1: +.. _i3c__Device_Char_Table_Reg1_1: Device_Char_Table_Reg1_1 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave1 during the Dynamic address assignment command. +LSB of PID value of slave1 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===========================================================+ + |15:0 |R |PID_LOW|0x0 |Device provisional ID low: bits [15:0] of Device’s I3C PID.| + +-----+---+-------+-----+-----------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg2_1: +.. _i3c__Device_Char_Table_Reg2_1: Device_Char_Table_Reg2_1 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave1 during the Dynamic address assignment command. +BCR, DCR and dynamic address of slave1 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+====================================================================================================================================================+ + |7:0 |R |DCR |0x0 |Device Characteristics Register(DCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R |BCR |0x0 |I3C Bus Characteristics Register(BCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R |Dynamic_Addr|0x0 |Device I3C Dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg3_1: - -Device_Char_Table_Reg3_1 -"""""""""""""""""""""""" - -BCR, DCR & PID Values of the slave1 during the Dynamic address assignment command. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg0_2: +.. _i3c__Device_Char_Table_Reg0_2: Device_Char_Table_Reg0_2 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave2 during the Dynamic address assignment command. +MSB of PID value of slave2 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============================================================+ + |31:0 |R |PID_HIGH|0x0 |Device provisional ID high: bits [48:16] of Device’s I3C PID.| + +-----+---+--------+-----+-------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg1_2: +.. _i3c__Device_Char_Table_Reg1_2: Device_Char_Table_Reg1_2 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave2 during the Dynamic address assignment command. +LSB of PID value of slave2 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===========================================================+ + |15:0 |R |PID_LOW|0x0 |Device provisional ID low: bits [15:0] of Device’s I3C PID.| + +-----+---+-------+-----+-----------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg2_2: +.. _i3c__Device_Char_Table_Reg2_2: Device_Char_Table_Reg2_2 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave2 during the Dynamic address assignment command. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg3_2: - -Device_Char_Table_Reg3_2 -"""""""""""""""""""""""" - -BCR, DCR & PID Values of the slave2 during the Dynamic address assignment command. +BCR, DCR and dynamic address of slave2 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+====================================================================================================================================================+ + |7:0 |R |DCR |0x0 |Device Characteristics Register(DCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R |BCR |0x0 |I3C Bus Characteristics Register(BCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R |Dynamic_Addr|0x0 |Device I3C Dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg0_3: +.. _i3c__Device_Char_Table_Reg0_3: Device_Char_Table_Reg0_3 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave3 during the Dynamic address assignment command. +MSB of PID value of slave3 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============================================================+ + |31:0 |R |PID_HIGH|0x0 |Device provisional ID high: bits [48:16] of Device’s I3C PID.| + +-----+---+--------+-----+-------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg1_3: +.. _i3c__Device_Char_Table_Reg1_3: Device_Char_Table_Reg1_3 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave3 during the Dynamic address assignment command. +LSB of PID value of slave3 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===========================================================+ + |15:0 |R |PID_LOW|0x0 |Device provisional ID low: bits [15:0] of Device’s I3C PID.| + +-----+---+-------+-----+-----------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg2_3: +.. _i3c__Device_Char_Table_Reg2_3: Device_Char_Table_Reg2_3 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave3 during the Dynamic address assignment command. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg3_3: - -Device_Char_Table_Reg3_3 -"""""""""""""""""""""""" - -BCR, DCR & PID Values of the slave3 during the Dynamic address assignment command. +BCR, DCR and dynamic address of slave3 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+====================================================================================================================================================+ + |7:0 |R |DCR |0x0 |Device Characteristics Register(DCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R |BCR |0x0 |I3C Bus Characteristics Register(BCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R |Dynamic_Addr|0x0 |Device I3C Dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg0_4: +.. _i3c__Device_Char_Table_Reg0_4: Device_Char_Table_Reg0_4 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave4 during the Dynamic address assignment command. +MSB of PID value of slave4 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============================================================+ + |31:0 |R |PID_HIGH|0x0 |Device provisional ID high: bits [48:16] of Device’s I3C PID.| + +-----+---+--------+-----+-------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg1_4: +.. _i3c__Device_Char_Table_Reg1_4: Device_Char_Table_Reg1_4 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave4 during the Dynamic address assignment command. +LSB of PID value of slave4 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===========================================================+ + |15:0 |R |PID_LOW|0x0 |Device provisional ID low: bits [15:0] of Device’s I3C PID.| + +-----+---+-------+-----+-----------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg2_4: +.. _i3c__Device_Char_Table_Reg2_4: Device_Char_Table_Reg2_4 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave4 during the Dynamic address assignment command. +BCR, DCR and dynamic address of slave4 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg3_4: + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+====================================================================================================================================================+ + |7:0 |R |DCR |0x0 |Device Characteristics Register(DCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R |BCR |0x0 |I3C Bus Characteristics Register(BCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R |Dynamic_Addr|0x0 |Device I3C Dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ -Device_Char_Table_Reg3_4 -"""""""""""""""""""""""" - -BCR, DCR & PID Values of the slave4 during the Dynamic address assignment command. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg0_5: +.. _i3c__Device_Char_Table_Reg0_5: Device_Char_Table_Reg0_5 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave5 during the Dynamic address assignment command. +MSB of PID value of slave5 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============================================================+ + |31:0 |R |PID_HIGH|0x0 |Device provisional ID high: bits [48:16] of Device’s I3C PID.| + +-----+---+--------+-----+-------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg1_5: +.. _i3c__Device_Char_Table_Reg1_5: Device_Char_Table_Reg1_5 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave5 during the Dynamic address assignment command. +LSB of PID value of slave5 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===========================================================+ + |15:0 |R |PID_LOW|0x0 |Device provisional ID low: bits [15:0] of Device’s I3C PID.| + +-----+---+-------+-----+-----------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg2_5: +.. _i3c__Device_Char_Table_Reg2_5: Device_Char_Table_Reg2_5 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave5 during the Dynamic address assignment command. +BCR, DCR and dynamic address of slave5 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg3_5: - -Device_Char_Table_Reg3_5 -"""""""""""""""""""""""" - -BCR, DCR & PID Values of the slave5 during the Dynamic address assignment command. - -.. table:: + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+====================================================================================================================================================+ + |7:0 |R |DCR |0x0 |Device Characteristics Register(DCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R |BCR |0x0 |I3C Bus Characteristics Register(BCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R |Dynamic_Addr|0x0 |Device I3C Dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg0_6: +.. _i3c__Device_Char_Table_Reg0_6: Device_Char_Table_Reg0_6 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave6 during the Dynamic address assignment command. +MSB of PID value of slave6 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============================================================+ + |31:0 |R |PID_HIGH|0x0 |Device provisional ID high: bits [48:16] of Device’s I3C PID.| + +-----+---+--------+-----+-------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg1_6: +.. _i3c__Device_Char_Table_Reg1_6: Device_Char_Table_Reg1_6 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave6 during the Dynamic address assignment command. +LSB of PID value of slave6 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===========================================================+ + |15:0 |R |PID_LOW|0x0 |Device provisional ID low: bits [15:0] of Device’s I3C PID.| + +-----+---+-------+-----+-----------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg2_6: +.. _i3c__Device_Char_Table_Reg2_6: Device_Char_Table_Reg2_6 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave6 during the Dynamic address assignment command. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg3_6: - -Device_Char_Table_Reg3_6 -"""""""""""""""""""""""" - -BCR, DCR & PID Values of the slave6 during the Dynamic address assignment command. +BCR, DCR and dynamic address of slave6 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+====================================================================================================================================================+ + |7:0 |R |DCR |0x0 |Device Characteristics Register(DCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R |BCR |0x0 |I3C Bus Characteristics Register(BCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R |Dynamic_Addr|0x0 |Device I3C Dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg0_7: +.. _i3c__Device_Char_Table_Reg0_7: Device_Char_Table_Reg0_7 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave7 during the Dynamic address assignment command. +MSB of PID value of slave7 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============================================================+ + |31:0 |R |PID_HIGH|0x0 |Device provisional ID high: bits [48:16] of Device’s I3C PID.| + +-----+---+--------+-----+-------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg1_7: +.. _i3c__Device_Char_Table_Reg1_7: Device_Char_Table_Reg1_7 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave7 during the Dynamic address assignment command. +LSB of PID value of slave7 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===========================================================+ + |15:0 |R |PID_LOW|0x0 |Device provisional ID low: bits [15:0] of Device’s I3C PID.| + +-----+---+-------+-----+-----------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg2_7: +.. _i3c__Device_Char_Table_Reg2_7: Device_Char_Table_Reg2_7 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave7 during the Dynamic address assignment command. +BCR, DCR and dynamic address of slave7 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg3_7: + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+====================================================================================================================================================+ + |7:0 |R |DCR |0x0 |Device Characteristics Register(DCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R |BCR |0x0 |I3C Bus Characteristics Register(BCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R |Dynamic_Addr|0x0 |Device I3C Dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ -Device_Char_Table_Reg3_7 -"""""""""""""""""""""""" - -BCR, DCR & PID Values of the slave7 during the Dynamic address assignment command. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg0_8: +.. _i3c__Device_Char_Table_Reg0_8: Device_Char_Table_Reg0_8 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave8 during the Dynamic address assignment command. +MSB of PID value of slave8 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============================================================+ + |31:0 |R |PID_HIGH|0x0 |Device provisional ID high: bits [48:16] of Device’s I3C PID.| + +-----+---+--------+-----+-------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg1_8: +.. _i3c__Device_Char_Table_Reg1_8: Device_Char_Table_Reg1_8 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave8 during the Dynamic address assignment command. +LSB of PID value of slave8 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===========================================================+ + |15:0 |R |PID_LOW|0x0 |Device provisional ID low: bits [15:0] of Device’s I3C PID.| + +-----+---+-------+-----+-----------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg2_8: +.. _i3c__Device_Char_Table_Reg2_8: Device_Char_Table_Reg2_8 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave8 during the Dynamic address assignment command. +BCR, DCR and dynamic address of slave8 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg3_8: - -Device_Char_Table_Reg3_8 -"""""""""""""""""""""""" + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+====================================================================================================================================================+ + |7:0 |R |DCR |0x0 |Device Characteristics Register(DCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R |BCR |0x0 |I3C Bus Characteristics Register(BCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R |Dynamic_Addr|0x0 |Device I3C Dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ -BCR, DCR & PID Values of the slave8 during the Dynamic address assignment command. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg0_9: +.. _i3c__Device_Char_Table_Reg0_9: Device_Char_Table_Reg0_9 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave9 during the Dynamic address assignment command. +MSB of PID value of slave9 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============================================================+ + |31:0 |R |PID_HIGH|0x0 |Device provisional ID high: bits [48:16] of Device’s I3C PID.| + +-----+---+--------+-----+-------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg1_9: +.. _i3c__Device_Char_Table_Reg1_9: Device_Char_Table_Reg1_9 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave9 during the Dynamic address assignment command. +LSB of PID value of slave9 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===========================================================+ + |15:0 |R |PID_LOW|0x0 |Device provisional ID low: bits [15:0] of Device’s I3C PID.| + +-----+---+-------+-----+-----------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg2_9: +.. _i3c__Device_Char_Table_Reg2_9: Device_Char_Table_Reg2_9 """""""""""""""""""""""" -BCR, DCR & PID Values of the slave9 during the Dynamic address assignment command. +BCR, DCR and dynamic address of slave9 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+====================================================================================================================================================+ + |7:0 |R |DCR |0x0 |Device Characteristics Register(DCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R |BCR |0x0 |I3C Bus Characteristics Register(BCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R |Dynamic_Addr|0x0 |Device I3C Dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg3_9: - -Device_Char_Table_Reg3_9 -"""""""""""""""""""""""" - -BCR, DCR & PID Values of the slave9 during the Dynamic address assignment command. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg0_10: +.. _i3c__Device_Char_Table_Reg0_10: Device_Char_Table_Reg0_10 """"""""""""""""""""""""" -BCR, DCR & PID Values of the slave10 during the Dynamic address assignment command. +MSB of PID value of slave10 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============================================================+ + |31:0 |R |PID_HIGH|0x0 |Device provisional ID high: bits [48:16] of Device’s I3C PID.| + +-----+---+--------+-----+-------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg1_10: +.. _i3c__Device_Char_Table_Reg1_10: Device_Char_Table_Reg1_10 """"""""""""""""""""""""" -BCR, DCR & PID Values of the slave10 during the Dynamic address assignment command. +LSB of PID value of slave10 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===========================================================+ + |15:0 |R |PID_LOW|0x0 |Device provisional ID low: bits [15:0] of Device’s I3C PID.| + +-----+---+-------+-----+-----------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg2_10: +.. _i3c__Device_Char_Table_Reg2_10: Device_Char_Table_Reg2_10 """"""""""""""""""""""""" -BCR, DCR & PID Values of the slave10 during the Dynamic address assignment command. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg3_10: - -Device_Char_Table_Reg3_10 -""""""""""""""""""""""""" - -BCR, DCR & PID Values of the slave10 during the Dynamic address assignment command. +BCR, DCR and dynamic address of slave10 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+====================================================================================================================================================+ + |7:0 |R |DCR |0x0 |Device Characteristics Register(DCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R |BCR |0x0 |I3C Bus Characteristics Register(BCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R |Dynamic_Addr|0x0 |Device I3C Dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg0_11: +.. _i3c__Device_Char_Table_Reg0_11: Device_Char_Table_Reg0_11 """"""""""""""""""""""""" -BCR, DCR & PID Values of the slave11 during the Dynamic address assignment command. +MSB of PID value of slave11 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============================================================+ + |31:0 |R |PID_HIGH|0x0 |Device provisional ID high: bits [48:16] of Device’s I3C PID.| + +-----+---+--------+-----+-------------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg1_11: +.. _i3c__Device_Char_Table_Reg1_11: Device_Char_Table_Reg1_11 """"""""""""""""""""""""" -BCR, DCR & PID Values of the slave11 during the Dynamic address assignment command. +LSB of PID value of slave11 during the dynamic address assignment command. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===========================================================+ + |15:0 |R |PID_LOW|0x0 |Device provisional ID low: bits [15:0] of Device’s I3C PID.| + +-----+---+-------+-----+-----------------------------------------------------------+ -.. _i3c_Device_Char_Table_Reg2_11: +.. _i3c__Device_Char_Table_Reg2_11: Device_Char_Table_Reg2_11 """"""""""""""""""""""""" -BCR, DCR & PID Values of the slave11 during the Dynamic address assignment command. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _i3c_Device_Char_Table_Reg3_11: - -Device_Char_Table_Reg3_11 -""""""""""""""""""""""""" - -BCR, DCR & PID Values of the slave11 during the Dynamic address assignment command. +BCR, DCR and dynamic address of slave11 during the dynamic address assignment command. + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+====================================================================================================================================================+ + |7:0 |R |DCR |0x0 |Device Characteristics Register(DCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R |BCR |0x0 |I3C Bus Characteristics Register(BCR) of the slave. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R |Dynamic_Addr|0x0 |Device I3C Dynamic address: bit 23 is the parity bit for the dynamic address calculated by software, bits 22:16 are the dynamic address of the slave| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + +I3C Interface Commands +^^^^^^^^^^^^^^^^^^^^^^ + +.. table:: + :align: center + :widths: 45 15 15 80 + + +---------------------------------------------------------+-----+------------+--------------------------+ + | Command name |Width|Command code| Description | + +=========================================================+=====+============+==========================+ + |:ref:`REGULAR_CMD` | 64|0x0 |Regular command | + +---------------------------------------------------------+-----+------------+--------------------------+ + |:ref:`IMM_TRANSFER`| 64|0x1 |Immediate transfer command| + +---------------------------------------------------------+-----+------------+--------------------------+ + |:ref:`ADDR_ASSIGN` | 64|0x2 |Address assignment command| + +---------------------------------------------------------+-----+------------+--------------------------+ + +.. _I3C Interface Commands__REGULAR_CMD: + +REGULAR_CMD +""""""""""" + +.. table:: + :align: center + :widths: 15 45 90 + + +-----+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #| Name | Description | + +=====+=========+===========================================================================================================================================================================================================================================================================================================================+ + |63:48|DATA_LEN |Indicates the number of bytes to be transferred | + +-----+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |TOC |Controls the bus condition when completing the data transfer: b0: Repeated start for next transfer; b1: Stop condition | + +-----+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |30 |ROC |Controls the response status after the completion of transfer: b0: Response status not required; b1: Response status required | + +-----+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |RnW |Transfer direction: b0: Write transfer; b1: Read transfer | + +-----+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:26|MODE |Mode and speed of the transfer using I3C or I2C bus. Values for I3C mode: h0: Standard speed mode (12.5MHZ); h1: 8MHz speed mode; h2: 6MHz speed mode; h3: 4MHz speed mode; h4: 2MHz speed mode; h5: Reserved; h6: HDR-DDR mode (25MHz speed); h7: Reserved. Values for I2C Mode: h0: I2C FM; h1: I2C FM+; h2-h7: Reserved.| + +-----+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |21 |BC_EN |Initiate the transfer after sending the Broadcast message (7’h7E): b0: No Broadcast message required; b1: Broadcast message required | + +-----+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |20:16|DEV_INDEX|Slave address to which the data transfer is required | + +-----+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |CP |Indicates if the command field is valid or not: b0: SDR transfer, no CCC command; b1: CCC or HDR command transfer | + +-----+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |14:7 |CMD |I3C command code: 8-bit for CCC, 7-bit for HDR | + +-----+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |6:3 |TID |Command request Tag ID. Maximum of 16 transfers can be initiated. | + +-----+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |2:0 |CMD_ATTR |Command code -- 0x0 for regular command type | + +-----+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _I3C Interface Commands__IMM_TRANSFER: + +IMM_TRANSFER +"""""""""""" .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + :align: center + :widths: 15 45 90 + + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #| Name | Description | + +=====+===========+===========================================================================================================================================================================================================================================================================================================================+ + |63:56|DATA_BYTE_4|Data byte 4 to be transferred. | + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |55:48|DATA_BYTE_3|Data byte 3 to be transferred. | + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |47:40|DATA_BYTE_2|Data byte 2 to be transferred. | + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |39:32|DATA_BYTE_1|Data byte 1 to be transferred. | + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |TOC |Controls the bus condition when completing the data transfer: b0: Repeated start for next transfer; b1: Stop condition | + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |30 |ROC |Controls the response status after the completion of transfer: b0: Response status not required; b1: Response status required | + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |RnW |Transfer direction: b0: Write transfer; b1: Read transfer | + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:26|MODE |Mode and speed of the transfer using I3C or I2C bus. Values for I3C mode: h0: Standard speed mode (12.5MHZ); h1: 8MHz speed mode; h2: 6MHz speed mode; h3: 4MHz speed mode; h4: 2MHz speed mode; h5: Reserved; h6: HDR-DDR mode (25MHz speed); h7: Reserved. Values for I2C Mode: h0: I2C FM; h1: I2C FM+; h2-h7: Reserved.| + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |25:23|BYTE_CNT |Number of valid data bytes: h0: No payload; h1 to h4: 1 to 4 bytes respectively; h5 to h7: Reserved. | + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |21 |BC_EN |Initiate the transfer after sending the Broadcast message (7’h7E): b0: No Broadcast message required; b1: Broadcast message required | + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |20:16|DEV_INDEX |Slave address to which the data transfer is required | + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |CP |Indicates if the command field is valid or not: b0: SDR transfer, no CCC command; b1: CCC or HDR command transfer | + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |14:7 |CMD |I3C command code: 8-bit for CCC, 7-bit for HDR | + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |6:3 |TID |Command request Tag ID. Maximum of 16 transfers can be initiated. | + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |2:0 |CMD_ATTR |Command code -- 0x1 for immediate transfer command type | + +-----+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _I3C Interface Commands__ADDR_ASSIGN: + +ADDR_ASSIGN +""""""""""" + +.. table:: + :align: center + :widths: 15 45 90 + + +-----+----------+------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #| Name | Description | + +=====+==========+====================================================================================================================================+ + | 31|TOC |Controls the bus condition when completing the data transfer: b0: Repeated start for next transfer; b1: Stop condition | + +-----+----------+------------------------------------------------------------------------------------------------------------------------------------+ + | 30|ROC |Controls the response status after the completion of transfer: b0: Response status not required; b1: Response status required | + +-----+----------+------------------------------------------------------------------------------------------------------------------------------------+ + |29:26|DEVICE_CNT|Device count. Master to perform the dynamic address assignment for the number of devices present. | + +-----+----------+------------------------------------------------------------------------------------------------------------------------------------+ + | 21|BC_EN |Initiate the transfer after sending the Broadcast message (7’h7E): b0: No Broadcast message required; b1: Broadcast message required| + +-----+----------+------------------------------------------------------------------------------------------------------------------------------------+ + |20:16|DEV_INDEX |Slave address to which the data transfer is required | + +-----+----------+------------------------------------------------------------------------------------------------------------------------------------+ + |14:7 |CMD |ENTDAA or SETDASA command code | + +-----+----------+------------------------------------------------------------------------------------------------------------------------------------+ + |6:3 |TID |Command request Tag ID. Maximum of 16 transfers can be initiated. | + +-----+----------+------------------------------------------------------------------------------------------------------------------------------------+ + |2:0 |CMD_ATTR |Command code -- 0x2 for address assignment command type | + +-----+----------+------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/ne16.rst b/rtos/pulp/gap_archi/doc/ips/ne16.rst index 3c464361b..20d129d9c 100644 --- a/rtos/pulp/gap_archi/doc/ips/ne16.rst +++ b/rtos/pulp/gap_archi/doc/ips/ne16.rst @@ -8,582 +8,616 @@ Register map Overview """""""" -.. table:: - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +================================================+======+=====+============================================================================================================================================+ - |:ref:`TRIGGER` | 0| 32|Write 0 to start execution, unlock controller. | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`ACQUIRE` | 4| 32|On read starts a job offload, locks controller. Returns job ID. | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FINISHED_JOBS` | 8| 32|Returns number of completed jobs. | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`STATUS` | 12| 32|Returns status of jobs in the queue (each byte is a different job). | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`RUNNING_JOB` | 16| 32|Returns ID of currently running job. | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`SOFT_CLEAR` | 20| 32|Soft-clears the NE16 at any write. | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`MICROCODE` | 24| 32|Reserved. | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`SW_SYNC` | 28| 32|Triggers a SW event inside NE16 (e.g. for DMA synchronization). | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WEIGHTS_PTR` | 32| 32|Pointer to Weights tensor in memory (d3=Ko, d2=KiMaj, d1=Qw, d0=FxFyKimin for 3x3 mode; d2=Ko, d1=KiMaj, d0=Qw*KiMin for 1x1 mode).| - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`INFEAT_PTR` | 36| 32|Pointer to InFeat tensor in memory (d2=Hi, d1=Wi, d0=Ki). | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`OUTFEAT_PTR` | 40| 32|Pointer to OutFeat tensor in memory (d2=Ho, d1=Wo, d0=Ko). | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`SCALE_PTR` | 44| 32|Pointer to Scale parameters in memory (d0=Ko). | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`SCALE_SHIFT_PTR` | 48| 32|Pointer to Scale parameters in memory (d0=Ko). | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`SCALE_BIAS_PTR` | 52| 32|Pointer to Scale parameters in memory (d0=Ko). | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`INFEAT_D0_STRIDE` | 56| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`INFEAT_D1_STRIDE` | 60| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`INFEAT_D2_STRIDE` | 64| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`OUTFEAT_D0_STRIDE`| 68| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`OUTFEAT_D1_STRIDE`| 72| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`OUTFEAT_D2_STRIDE`| 76| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WEIGHTS_D0_STRIDE`| 80| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WEIGHTS_D1_STRIDE`| 84| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WEIGHTS_D2_STRIDE`| 88| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`SUBTILE_REM0` | 92| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`SUBTILE_REM1` | 96| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`SUBTILE_REM2` | 100| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`SUBTILE_NB0` | 104| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`SUBTILE_NB1` | 108| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`PADDING` | 112| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WEIGHT_OFFSET` | 116| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FILTER_MASK` | 120| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CONFIG0` | 124| 32| | - +------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _ne16_TRIGGER: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-------------------------------------------------+------+-----+---------------------------------+ + | Name |Offset|Width| Description | + +=================================================+======+=====+=================================+ + |:ref:`TRIGGER` | 0| 32|Commit/trigger jobs | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`ACQUIRE` | 4| 32|Offload jobs | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`STATUS` | 12| 32|Status of jobs | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`RUNNING_JOB` | 16| 32|Running job ID | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`SOFT_CLEAR` | 20| 32|Soft reset of NE16 state | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`WEIGHTS_PTR` | 32| 32|Pointer to weights tensor | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`INFEAT_PTR` | 36| 32|Pointer to InFeat tensor | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`OUTFEAT_PTR` | 40| 32|Pointer to OutFeat tensor | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`SCALE_PTR` | 44| 32|Pointer to ScaleScaleN parameters| + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`SCALE_SHIFT_PTR` | 48| 32|Pointer to ScaleShift parameters | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`SCALE_BIAS_PTR` | 52| 32|Pointer to ScaleBias parameters | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`INFEAT_D0_STRIDE` | 56| 32|InFeat tensor d0 stride | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`INFEAT_D1_STRIDE` | 60| 32|InFeat tensor d1 stride | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`INFEAT_D2_STRIDE` | 64| 32|InFeat tensor d2 stride | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`OUTFEAT_D0_STRIDE`| 68| 32|OutFeat tensor d0 stride | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`OUTFEAT_D1_STRIDE`| 72| 32|OutFeat tensor d1 stride | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`OUTFEAT_D2_STRIDE`| 76| 32|OutFeat tensor d2 stride | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`WEIGHTS_D0_STRIDE`| 80| 32|Weights tensor d0 stride | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`WEIGHTS_D1_STRIDE`| 84| 32|Weights tensor d1 stride | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`WEIGHTS_D2_STRIDE`| 88| 32|Weights tensor d2 stride | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`SUBTILE_REM0` | 92| 32|Subtile remainders 0 | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`SUBTILE_REM1` | 96| 32|Subtile remainders 1 | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`SUBTILE_REM2` | 100| 32|Subtile remainders 2 | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`SUBTILE_NB0` | 104| 32|Subtile numbers 0 | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`SUBTILE_NB1` | 108| 32|Subtile numbers 1 | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`PADDING` | 112| 32|Padding | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`WEIGHT_OFFSET` | 116| 32|Weight offset | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`FILTER_MASK` | 120| 32|Filter masking | + +-------------------------------------------------+------+-----+---------------------------------+ + |:ref:`CONFIG0` | 124| 32|Main configuration register | + +-------------------------------------------------+------+-----+---------------------------------+ + +.. _ne16__TRIGGER: TRIGGER """"""" -Write 0 to start execution, unlock controller. +Commit/trigger jobs .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+===============================================================================================================================================================================================================================================================================================+ + |31:0 |W |TRIG_CMD|0x0 |Write 0 to commit a job, unlock controller and start execution. Write a non-0 value to commit a job and unlock controller without starting execution, which will be started when the next job is committed and triggered. Only the first job in a queue may be committed without triggering it.| + +-----+---+--------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _ne16_ACQUIRE: +.. _ne16__ACQUIRE: ACQUIRE """"""" -On read starts a job offload, locks controller. Returns job ID. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _ne16_FINISHED_JOBS: - -FINISHED_JOBS -""""""""""""" - -Returns number of completed jobs. +Offload jobs .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+----------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+================================================================+ + |31:0 |R |JOB_ID|0x0 |Read to start a job offload and lock controller. Returns job ID.| + +-----+---+------+-----+----------------------------------------------------------------+ -.. _ne16_STATUS: +.. _ne16__STATUS: STATUS """""" -Returns status of jobs in the queue (each byte is a different job). +Status of jobs .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+---------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===========================================================================+ + | 0|R |STATUS0|0x0 |Status of job 0: b1 if job 0 is currently enqueued or running, b0 otherwise| + +-----+---+-------+-----+---------------------------------------------------------------------------+ + | 8|R |STATUS1|0x0 |Status of job 1: b1 if job 1 is currently enqueued or running, b0 otherwise| + +-----+---+-------+-----+---------------------------------------------------------------------------+ -.. _ne16_RUNNING_JOB: +.. _ne16__RUNNING_JOB: RUNNING_JOB """"""""""" -Returns ID of currently running job. +Running job ID .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+-----------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+===============================================================================================+ + |31:0 |R |JOB_ID|0x0 |ID of currently running, if any job is running; otherwise, ID of the last job that has been run| + +-----+---+------+-----+-----------------------------------------------------------------------------------------------+ -.. _ne16_SOFT_CLEAR: +.. _ne16__SOFT_CLEAR: SOFT_CLEAR """""""""" -Soft-clears the NE16 at any write. +Soft reset of NE16 state .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _ne16_MICROCODE: + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+================================================================================================================================================================================+ + |31:0 |W |CLR_CMD|0x0 |Write 0 to clear the full status of the accelerator IP, including the register file; write a non-0 value to clear the status of the accelerator IP, except for the register file| + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -MICROCODE -""""""""" - -Reserved. - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _ne16_SW_SYNC: - -SW_SYNC -""""""" - -Triggers a SW event inside NE16 (e.g. for DMA synchronization). - -.. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _ne16_WEIGHTS_PTR: +.. _ne16__WEIGHTS_PTR: WEIGHTS_PTR """"""""""" -Pointer to Weights tensor in memory (d3=Ko, d2=KiMaj, d1=Qw, d0=FxFyKimin for 3x3 mode; d2=Ko, d1=KiMaj, d0=Qw*KiMin for 1x1 mode). +Pointer to weights tensor .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==========================================================================================================================================================================================================================================================================================+ + |31:0 |R/W|POINTER|0x0 |Pointer to weights tensor in memory (d3=Ko, d2=KiMaj, d1=Qw, d0=Fx\ :math:`\times`\ Fy\ :math:`\times`\ Kimin for 3\ :math:`\times`\ 3 modes; d2=Ko, d1=KiMaj, d0=Qw\ :math:`\times`\ KiMin for 1\ :math:`\times`\ 1 mode; d2=Ko, d1=Qw, d0=KiMaj\ :math:`\times`\ KiMin for linear mode).| + +-----+---+-------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _ne16_INFEAT_PTR: +.. _ne16__INFEAT_PTR: INFEAT_PTR """""""""" -Pointer to InFeat tensor in memory (d2=Hi, d1=Wi, d0=Ki). +Pointer to InFeat tensor .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+--------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+========================================================+ + |31:0 |R/W|POINTER|0x0 |Pointer to InFeat tensor in memory (d2=Hi, d1=Wi, d0=Ki)| + +-----+---+-------+-----+--------------------------------------------------------+ -.. _ne16_OUTFEAT_PTR: +.. _ne16__OUTFEAT_PTR: OUTFEAT_PTR """"""""""" -Pointer to OutFeat tensor in memory (d2=Ho, d1=Wo, d0=Ko). +Pointer to OutFeat tensor .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+---------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=========================================================+ + |31:0 |R/W|POINTER|0x0 |Pointer to OutFeat tensor in memory (d2=Ho, d1=Wo, d0=Ko)| + +-----+---+-------+-----+---------------------------------------------------------+ -.. _ne16_SCALE_PTR: +.. _ne16__SCALE_PTR: SCALE_PTR """"""""" -Pointer to Scale parameters in memory (d0=Ko). +Pointer to ScaleScaleN parameters .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+----------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+====================================================+ + |31:0 |R/W|POINTER|0x0 |Pointer to Scale/ScaleN parameters in memory (d0=Ko)| + +-----+---+-------+-----+----------------------------------------------------+ -.. _ne16_SCALE_SHIFT_PTR: +.. _ne16__SCALE_SHIFT_PTR: SCALE_SHIFT_PTR """"""""""""""" -Pointer to Scale parameters in memory (d0=Ko). +Pointer to ScaleShift parameters .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+--------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==================================================+ + |31:0 |R/W|POINTER|0x0 |Pointer to ScaleShift parameters in memory (d0=Ko)| + +-----+---+-------+-----+--------------------------------------------------+ -.. _ne16_SCALE_BIAS_PTR: +.. _ne16__SCALE_BIAS_PTR: SCALE_BIAS_PTR """""""""""""" -Pointer to Scale parameters in memory (d0=Ko). +Pointer to ScaleBias parameters .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=================================================+ + |31:0 |R/W|POINTER|0x0 |Pointer to ScaleBias parameters in memory (d0=Ko)| + +-----+---+-------+-----+-------------------------------------------------+ -.. _ne16_INFEAT_D0_STRIDE: +.. _ne16__INFEAT_D0_STRIDE: INFEAT_D0_STRIDE """""""""""""""" - +InFeat tensor d0 stride .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+------------+ + |Bit #|R/W| Name |Reset|Description | + +=====+===+======+=====+============+ + |31:0 |R/W|STRIDE|0x0 |Stride value| + +-----+---+------+-----+------------+ -.. _ne16_INFEAT_D1_STRIDE: +.. _ne16__INFEAT_D1_STRIDE: INFEAT_D1_STRIDE """""""""""""""" - +InFeat tensor d1 stride .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+------------+ + |Bit #|R/W| Name |Reset|Description | + +=====+===+======+=====+============+ + |31:0 |R/W|STRIDE|0x0 |Stride value| + +-----+---+------+-----+------------+ -.. _ne16_INFEAT_D2_STRIDE: +.. _ne16__INFEAT_D2_STRIDE: INFEAT_D2_STRIDE """""""""""""""" - +InFeat tensor d2 stride .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+------------+ + |Bit #|R/W| Name |Reset|Description | + +=====+===+======+=====+============+ + |31:0 |R/W|STRIDE|0x0 |Stride value| + +-----+---+------+-----+------------+ -.. _ne16_OUTFEAT_D0_STRIDE: +.. _ne16__OUTFEAT_D0_STRIDE: OUTFEAT_D0_STRIDE """"""""""""""""" - +OutFeat tensor d0 stride .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+------------+ + |Bit #|R/W| Name |Reset|Description | + +=====+===+======+=====+============+ + |31:0 |R/W|STRIDE|0x0 |Stride value| + +-----+---+------+-----+------------+ -.. _ne16_OUTFEAT_D1_STRIDE: +.. _ne16__OUTFEAT_D1_STRIDE: OUTFEAT_D1_STRIDE """"""""""""""""" - +OutFeat tensor d1 stride .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+------------+ + |Bit #|R/W| Name |Reset|Description | + +=====+===+======+=====+============+ + |31:0 |R/W|STRIDE|0x0 |Stride value| + +-----+---+------+-----+------------+ -.. _ne16_OUTFEAT_D2_STRIDE: +.. _ne16__OUTFEAT_D2_STRIDE: OUTFEAT_D2_STRIDE """"""""""""""""" - +OutFeat tensor d2 stride .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+------------+ + |Bit #|R/W| Name |Reset|Description | + +=====+===+======+=====+============+ + |31:0 |R/W|STRIDE|0x0 |Stride value| + +-----+---+------+-----+------------+ -.. _ne16_WEIGHTS_D0_STRIDE: +.. _ne16__WEIGHTS_D0_STRIDE: WEIGHTS_D0_STRIDE """"""""""""""""" - +Weights tensor d0 stride .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+------------+ + |Bit #|R/W| Name |Reset|Description | + +=====+===+======+=====+============+ + |31:0 |R/W|STRIDE|0x0 |Stride value| + +-----+---+------+-----+------------+ -.. _ne16_WEIGHTS_D1_STRIDE: +.. _ne16__WEIGHTS_D1_STRIDE: WEIGHTS_D1_STRIDE """"""""""""""""" - +Weights tensor d1 stride .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+------------+ + |Bit #|R/W| Name |Reset|Description | + +=====+===+======+=====+============+ + |31:0 |R/W|STRIDE|0x0 |Stride value| + +-----+---+------+-----+------------+ -.. _ne16_WEIGHTS_D2_STRIDE: +.. _ne16__WEIGHTS_D2_STRIDE: WEIGHTS_D2_STRIDE """"""""""""""""" - +Weights tensor d2 stride .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+------------+ + |Bit #|R/W| Name |Reset|Description | + +=====+===+======+=====+============+ + |31:0 |R/W|STRIDE|0x0 |Stride value| + +-----+---+------+-----+------------+ -.. _ne16_SUBTILE_REM0: +.. _ne16__SUBTILE_REM0: SUBTILE_REM0 """""""""""" - +Subtile remainders 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============+ - |15:0 |R/W|KI |Ki remainder.| - +-----+---+----+-------------+ - |31:16|R/W|KO |Ko remainder.| - +-----+---+----+-------------+ + +-----+---+----+-----+------------+ + |Bit #|R/W|Name|Reset|Description | + +=====+===+====+=====+============+ + |15:0 |R/W|KI |0x0 |Ki remainder| + +-----+---+----+-----+------------+ + |31:16|R/W|KO |0x0 |Ko remainder| + +-----+---+----+-----+------------+ -.. _ne16_SUBTILE_REM1: +.. _ne16__SUBTILE_REM1: SUBTILE_REM1 """""""""""" - +Subtile remainders 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============+ - |15:0 |R/W|WO |Wo remainder.| - +-----+---+----+-------------+ - |31:16|R/W|HO |Ho remainder.| - +-----+---+----+-------------+ + +-----+---+----+-----+------------+ + |Bit #|R/W|Name|Reset|Description | + +=====+===+====+=====+============+ + |15:0 |R/W|WO |0x0 |Wo remainder| + +-----+---+----+-----+------------+ + |31:16|R/W|HO |0x0 |Ho remainder| + +-----+---+----+-----+------------+ -.. _ne16_SUBTILE_REM2: +.. _ne16__SUBTILE_REM2: SUBTILE_REM2 """""""""""" - +Subtile remainders 2 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============+ - |15:0 |R/W|WI |Wi remainder.| - +-----+---+----+-------------+ - |31:16|R/W|HI |Hi remainder.| - +-----+---+----+-------------+ + +-----+---+----+-----+------------+ + |Bit #|R/W|Name|Reset|Description | + +=====+===+====+=====+============+ + |15:0 |R/W|WI |0x0 |Wi remainder| + +-----+---+----+-----+------------+ + |31:16|R/W|HI |0x0 |Hi remainder| + +-----+---+----+-----+------------+ -.. _ne16_SUBTILE_NB0: +.. _ne16__SUBTILE_NB0: SUBTILE_NB0 """"""""""" - +Subtile numbers 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============+ - |15:0 |R/W|KI |Ki remainder.| - +-----+---+----+-------------+ - |31:16|R/W|KO |Ko remainder.| - +-----+---+----+-------------+ + +-----+---+----+-----+------------+ + |Bit #|R/W|Name|Reset|Description | + +=====+===+====+=====+============+ + |15:0 |R/W|KI |0x0 |Ki remainder| + +-----+---+----+-----+------------+ + |31:16|R/W|KO |0x0 |Ko remainder| + +-----+---+----+-----+------------+ -.. _ne16_SUBTILE_NB1: +.. _ne16__SUBTILE_NB1: SUBTILE_NB1 """"""""""" - +Subtile numbers 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============+ - |15:0 |R/W|WO |Wo remainder.| - +-----+---+----+-------------+ - |31:16|R/W|HO |Ho remainder.| - +-----+---+----+-------------+ + +-----+---+----+-----+------------+ + |Bit #|R/W|Name|Reset|Description | + +=====+===+====+=====+============+ + |15:0 |R/W|WO |0x0 |Wo remainder| + +-----+---+----+-----+------------+ + |31:16|R/W|HO |0x0 |Ho remainder| + +-----+---+----+-----+------------+ -.. _ne16_PADDING: +.. _ne16__PADDING: PADDING """"""" - +Padding .. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------+-----+----------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+==============================================================================================+ + |15:0 |R/W|VALUE |0x0 |Padding value | + +-----+---+------+-----+----------------------------------------------------------------------------------------------+ + |19:16|R/W|LEFT |0x0 |Number of spatially padded pixels in the left subtile border | + +-----+---+------+-----+----------------------------------------------------------------------------------------------+ + |23:20|R/W|BOTTOM|0x0 |Number of spatially padded pixels in the bottom subtile border (counted from 5 pixels upward) | + +-----+---+------+-----+----------------------------------------------------------------------------------------------+ + |27:24|R/W|RIGHT |0x0 |Number of spatially padded pixels in the right subtile border (counted from 5 pixels leftward)| + +-----+---+------+-----+----------------------------------------------------------------------------------------------+ + |31:28|R/W|TOP |0x0 |Number of spatially padded pixels in the top subtile border | + +-----+---+------+-----+----------------------------------------------------------------------------------------------+ - +-----+---+------+------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+================================================================================================+ - |15:0 |R/W|VALUE |Padding value. | - +-----+---+------+------------------------------------------------------------------------------------------------+ - |19:16|R/W|LEFT |Number of spatially padded pixels in the LEFT subtile border. | - +-----+---+------+------------------------------------------------------------------------------------------------+ - |23:20|R/W|BOTTOM|Number of spatially padded pixels in the BOTTOM subtile border (counted from 5 pixels upward!). | - +-----+---+------+------------------------------------------------------------------------------------------------+ - |27:24|R/W|RIGHT |Number of spatially padded pixels in the RIGHT subtile border (counted from 5 pixels leftward!).| - +-----+---+------+------------------------------------------------------------------------------------------------+ - |31:28|R/W|TOP |Number of spatially padded pixels in the TOP subtile border. | - +-----+---+------+------------------------------------------------------------------------------------------------+ - -.. _ne16_WEIGHT_OFFSET: +.. _ne16__WEIGHT_OFFSET: WEIGHT_OFFSET """"""""""""" - +Weight offset .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-----------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=======================+ + |7:0 |R/W|VALUE|0x0 |Value of weights offset| + +-----+---+-----+-----+-----------------------+ -.. _ne16_FILTER_MASK: +.. _ne16__FILTER_MASK: FILTER_MASK """"""""""" - +Filter masking .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+------------+ - |Bit #|R/W| Name |Description | - +=====+===+======+============+ - |7:0 |R/W|LEFT |Left mask. | - +-----+---+------+------------+ - |15:8 |R/W|BOTTOM|Bottom mask.| - +-----+---+------+------------+ - |23:16|R/W|RIGHT |Right mask. | - +-----+---+------+------------+ - |31:24|R/W|TOP |Top mask. | - +-----+---+------+------------+ + +-----+---+------+-----+-----------+ + |Bit #|R/W| Name |Reset|Description| + +=====+===+======+=====+===========+ + |7:0 |R/W|LEFT |0x0 |Left mask | + +-----+---+------+-----+-----------+ + |15:8 |R/W|BOTTOM|0x0 |Bottom mask| + +-----+---+------+-----+-----------+ + |23:16|R/W|RIGHT |0x0 |Right mask | + +-----+---+------+-----+-----------+ + |31:24|R/W|TOP |0x0 |Top mask | + +-----+---+------+-----+-----------+ -.. _ne16_CONFIG0: +.. _ne16__CONFIG0: CONFIG0 """"""" - - - - -.. table:: - - +-----+---+-----------+--------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+================================================================================+ - |2:0 |R/W|QWM1 |Weight bits minus 1. | - +-----+---+-----------+--------------------------------------------------------------------------------+ - |3 |R/W|MODE16 |16-bit input data mode. | - +-----+---+-----------+--------------------------------------------------------------------------------+ - |4 |R/W|STREAMOUT |Streamout / quantization (1=quantization+streamout, 0=streamout only). | - +-----+---+-----------+--------------------------------------------------------------------------------+ - |6:5 |R/W|FILTER_MODE|Filter mode (11=reserved, 10=1x1, 01=3x3 depthwise, 00=3x3). | - +-----+---+-----------+--------------------------------------------------------------------------------+ - |7 |R/W|LINEAR |Linear mode (experimental). | - +-----+---+-----------+--------------------------------------------------------------------------------+ - |8 |R/W|STRIDED_2X2|2x2 strided mode (experimental). | - +-----+---+-----------+--------------------------------------------------------------------------------+ - |10:9 |R/W|RES1 |Reserved. | - +-----+---+-----------+--------------------------------------------------------------------------------+ - |11 |R/W|ROUND |Rounding mode (0=round, 1=do not round). | - +-----+---+-----------+--------------------------------------------------------------------------------+ - |13:12|R/W|NORM_BITS |Normalization bits (00=8b, 01=16b, 10=32b). | - +-----+---+-----------+--------------------------------------------------------------------------------+ - |14 |R/W|STREAMIN |Streamin mode (1=do streamin, 0=do not streamin). | - +-----+---+-----------+--------------------------------------------------------------------------------+ - |15 |R/W|WEIGHT_OFFS|Weight offset cfg (0=symmetric weights, 1=use layer-wise weight_offset). | - +-----+---+-----------+--------------------------------------------------------------------------------+ - |20:16|R/W|RIGHT_SHIFT|Quantization right shift. | - +-----+---+-----------+--------------------------------------------------------------------------------+ - |22:21|R/W|QUANT_BITS |Quantization bits (00=8b, 01=16b, 10=32b). | - +-----+---+-----------+--------------------------------------------------------------------------------+ - |23 |R/W|QUANT_RECT |Quantization rect(0=rectify, consider as unsigned; 1=do not rectify, keep sign).| - +-----+---+-----------+--------------------------------------------------------------------------------+ - |31:24|R/W|RES2 |Reserved. | - +-----+---+-----------+--------------------------------------------------------------------------------+ +Main configuration register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+==================================================================================================================+ + |2:0 |R/W|QWM1 |0x0 |Weight bits minus 1 | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |3 |R/W|MODE16 |0x0 |Enable mode16: b0: 8-bit mode; b1: 16-bit mode | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |4 |R/W|STREAMOUT |0x0 |Normalization/quantization before streamout: b0: streamout only; b1: quantization+streamout | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |6:5 |R/W|FILTER_MODE|0x0 |Filter mode: b00=3\ :math:`\times`\ 3; b01=3\ :math:`\times`\ 3 depthwise; b10=1\ :math:`\times`\ 1; b11: reserved| + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |7 |R/W|LINEAR |0x0 |Linear mode: b0: normal operation; b1: linear mode | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |8 |R/W|STRIDED_2X2|0x0 |Strided 2\ :math:`\times`\ 2 mode: b0: normal operation; b1: strided mode | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |13:12|R/W|NORM_BITS |0x0 |Normalization bits: b00: 8 bits; b01: 16 bits; b10: 32b; b11: reserved | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |14 |R/W|STREAMIN |0x0 |Streamin mode: b0: normal operation; b1: enable streamin | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|WEIGHT_OFFS|0x0 |Weight offset configuration: b0: symmetric weights; b1: use layer-wise weight offset | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |20:16|R/W|RIGHT_SHIFT|0x0 |Quantization right shift | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |22:21|R/W|QUANT_BITS |0x0 |Quantization bits: b00: 8 bits; b01: 16 bits; b10: 32b; b11: reserved | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |23 |R/W|QUANT_RECT |0x0 |Quantization recttify: b0: rectify, consider as unsigned; b1: do not rectify, keep sign | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |24 |R/W|NORM_SHIFT |0x0 |Norm option shift: b0: use quantization right shift; b1: load with norm | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |25 |R/W|NORM_BIAS |0x0 |Norm option bias: b0: do not load bias; b1: load bias | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/new_decompr.rst b/rtos/pulp/gap_archi/doc/ips/new_decompr.rst new file mode 100644 index 000000000..7e3a23969 --- /dev/null +++ b/rtos/pulp/gap_archi/doc/ips/new_decompr.rst @@ -0,0 +1,327 @@ +.. + Input file: fe/ips/mchan/doc/CL_DMA_reference.md + +Register map +^^^^^^^^^^^^ + + +Overview +"""""""" + + +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +==========================================================+======+=====+==========================================================================================================+ + |:ref:`TCDM_ADDR_REG` | 0| 32|Start address in TCDM (L1) | + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + |:ref:`L2_ADDR_REG` | 4| 32|Start address in L2 | + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + |:ref:`CONF_REG` | 8| 32|Setup of the different parameters to configure compression/decompression | + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + |:ref:`STATUS_REG` | 12| 32|Busy status for decompressor engines T1, T2 and T3, and compressor engine T1 | + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + |:ref:`LUT_WRITE_REG` | 16| 32|Write LUT content (for T2 and T3) | + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + |:ref:`SPECIAL_SYMBOL_REG`| 20| 32|For T3 decompression only, decompressed value of the special symbol compressed into a single '0' bit in L2| + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + |:ref:`BIT_READ_REG` | 24| 32|Number of bits read during the decompression/compression | + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + |:ref:`MODE_REG` | 28| 32|Transfer mode (linear or 2D) for source and destination | + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + |:ref:`SOFT_RESET_REG` | 32| 32|Reset of compression/decompression engines and FIFOs (configuration registers are preserved) | + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + |:ref:`CLOCK_ENABLE_REG` | 36| 32|Clock gating control: enable/disable the clock of the compressor/decompressor | + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + |:ref:`PUSH_CMD_REG` | 40| 32|Trigger TX or RX transaction according to CONF_REG configuration | + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + |:ref:`L2_COUNT_REG` | 48| 32|Number of items to decompress after each stride from L2 to TCDM (Used only for 2D decompression) | + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + |:ref:`L2_STRIDE_REG` | 52| 32|Number of items to jump for every L2_COUNT_REG in the L2 (Used only for 2D decompression) | + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + |:ref:`TCDM_COUNT_REG` | 56| 32|Number of items to decompress after each stride from TCDM to L2 (Used only for 2D decompression) | + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + |:ref:`TCDM_STRIDE_REG` | 60| 32|Number of items to jump for every TCDM_COUNT_REG in the L2 (Used only for 2D decompression) | + +----------------------------------------------------------+------+-----+----------------------------------------------------------------------------------------------------------+ + +.. _new_decompr__TCDM_ADDR_REG: + +TCDM_ADDR_REG +""""""""""""" + +Start address in TCDM (L1) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+----------+-------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+===============+==========+===========================================+ + |31:0 |R/W|TCDM_START_ADDR|0x00000000|Start address for TCDM transfers (TX or RX)| + +-----+---+---------------+----------+-------------------------------------------+ + +.. _new_decompr__L2_ADDR_REG: + +L2_ADDR_REG +""""""""""" + +Start address in L2 + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+----------+-----------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+=============+==========+=========================================+ + |31:0 |R/W|L2_START_ADDR|0x00000000|Start address for L2 transfers (TX or RX)| + +-----+---+-------------+----------+-----------------------------------------+ + +.. _new_decompr__CONF_REG: + +CONF_REG +"""""""" + +Setup of the different parameters to configure compression/decompression + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+=================+======+===============================================================================================================================================================================+ + |1:0 |R/W|decompr_mode |0x0 |Decompression Mode: b00: T1; b01: T2; b11:T3; b10: reserved. | + +-----+---+-----------------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|extension_type |0x3 |Extension Type: b00: 8-bit; b01: 16-bit; b11: 32-bit; b10: reserved. | + +-----+---+-----------------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |8:4 |R/W|item_bit_width |0x04 |Size of compressed data item in L2. Allowed sizes are 1 to 31 for T1, 1 to 15 for T2 and T3. Warning: An illegal configuration will be handled like a 1-bit width configuration| + +-----+---+-----------------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |9 |R/W|sign_extension |0x0 |Sign extension during decompression: 0: Unsigned; 1: Signed. | + +-----+---+-----------------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12:10|R/W|start_bit |0x0 |Bit offset (in the byte) for L2 start address during decompression or compression. | + +-----+---+-----------------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|decompr_direction|0x0 |Transfer direction: 0: TX (decompression); 1: RX (compression T1). | + +-----+---+-----------------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:14|R/W|start_byte |0x0 |Byte offset (in a 32-bit word) in L2 start address during decompression or compression. | + +-----+---+-----------------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:16|R/W|items_to_transfer|0x0000|Total items to compress/decompress during a transfer. | + +-----+---+-----------------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _new_decompr__STATUS_REG: + +STATUS_REG +"""""""""" + +Busy status for decompressor engines T1, T2 and T3, and compressor engine T1 + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+============================================================+ + | 0|R |T1_DECOMPR_BUSY|0x0 |Status of the T1 decompression engine: if 1, engine is busy.| + +-----+---+---------------+-----+------------------------------------------------------------+ + | 1|R |T2_DECOMPR_BUSY|0x0 |Status of the T2 decompression engine: if 1, engine is busy.| + +-----+---+---------------+-----+------------------------------------------------------------+ + | 2|R |T3_DECOMPR_BUSY|0x0 |Status of the T3 decompression engine: if 1, engine is busy.| + +-----+---+---------------+-----+------------------------------------------------------------+ + | 3|R |T1_COMPR_BUSY |0x0 |Status of the T1 compression engine: if 1, engine is busy. | + +-----+---+---------------+-----+------------------------------------------------------------+ + +.. _new_decompr__LUT_WRITE_REG: + +LUT_WRITE_REG +""""""""""""" + +Write LUT content (for T2 and T3) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+------+--------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+========+======+================================+ + |15:0 |W |LUT_DATA|0x0000|Data to write in the LUT | + +-----+---+--------+------+--------------------------------+ + |23:16|W |LUT_ADDR|0x00 |Address of the LUT to be written| + +-----+---+--------+------+--------------------------------+ + +.. _new_decompr__SPECIAL_SYMBOL_REG: + +SPECIAL_SYMBOL_REG +"""""""""""""""""" + +For T3 decompression only, decompressed value of the special symbol compressed into a single '0' bit in L2 + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+----------+------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==============+==========+==================================================================+ + |31:0 |R/W|SPECIAL_SYMBOL|0xABBAABBA|Special symbol compressed as a single '0' bit for T3 decompression| + +-----+---+--------------+----------+------------------------------------------------------------------+ + +.. _new_decompr__BIT_READ_REG: + +BIT_READ_REG +"""""""""""" + +Number of bits read during the decompression/compression + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+----------+-----------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+===============================================+ + |31:0 |R |BIT_READ|0x00000000|Number of bits read at the end of decompression| + +-----+---+--------+----------+-----------------------------------------------+ + +.. _new_decompr__MODE_REG: + +MODE_REG +"""""""" + +Transfer mode (linear or 2D) for source and destination + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+==========================================================================================================================================================+ + |1:0 |R/W|TRANSF_MODE|0x0 |Transfer mode: 0: linear L2/linear TCDM; 1: 2D L2/linear TCDM; 2: linear L2/2D TCDM; 3: reserved. Warning: Only T1 decompression supports a non-0 setting.| + +-----+---+-----------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _new_decompr__SOFT_RESET_REG: + +SOFT_RESET_REG +"""""""""""""" + +Reset of compression/decompression engines and FIFOs (configuration registers are preserved) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+----------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+==========================================================================================================+ + | 0|W |SOFT_RESET|0x0 |Writing any value generates a reset to clear all engines and FIFOs. Configuration registers are not reset.| + +-----+---+----------+-----+----------------------------------------------------------------------------------------------------------+ + +.. _new_decompr__CLOCK_ENABLE_REG: + +CLOCK_ENABLE_REG +"""""""""""""""" + +Clock gating control: enable/disable the clock of the compressor/decompressor + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+================================================================================================================================================+ + | 0|W |CLOCK_ENABLE|0x0 |Set to 1 to enable the clock for the compressor/decompressor block. Access to configuration registers remains active when the clock is disabled.| + +-----+---+------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _new_decompr__PUSH_CMD_REG: + +PUSH_CMD_REG +"""""""""""" + +Trigger TX or RX transaction according to CONF_REG configuration + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=========================================================================+ + | 0|W |TRIGGER|0x0 |Write 1 to trigger a TX or RX transfer, according to configured settings.| + +-----+---+-------+-----+-------------------------------------------------------------------------+ + +.. _new_decompr__L2_COUNT_REG: + +L2_COUNT_REG +"""""""""""" + +Number of items to decompress after each stride from L2 to TCDM (Used only for 2D decompression) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+------+----------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+===============+======+============================================================================================================================+ + |15:0 |R/W|L2_LINEAR_COUNT|0x0000|For L2 2D transfers, number of items for each linear part of the transfer, minus 1 (e.g. set to 7 for a 8-item linear part).| + +-----+---+---------------+------+----------------------------------------------------------------------------------------------------------------------------+ + +.. _new_decompr__L2_STRIDE_REG: + +L2_STRIDE_REG +""""""""""""" + +Number of items to jump for every L2_COUNT_REG in the L2 (Used only for 2D decompression) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+===============+======+=====================================================================================================================================================================================================================================+ + |15:0 |R/W|L2_STRIDE_COUNT|0x0000|For L2 2D transfers, number of items in a stride (i.e. from a linear chunck of data to the next), minus 1 (e.g if the first item of the next linear chunk of data is 16 items after the first item of current chunk, then set to 15).| + +-----+---+---------------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _new_decompr__TCDM_COUNT_REG: + +TCDM_COUNT_REG +"""""""""""""" + +Number of items to decompress after each stride from TCDM to L2 (Used only for 2D decompression) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------------+------+-------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+=================+======+=====================================================================================+ + |15:0 |R/W|TCDM_LINEAR_COUNT|0x0000|For TCDM 2D transfers, number of items for each linear part of the transfer, minus 1.| + +-----+---+-----------------+------+-------------------------------------------------------------------------------------+ + +.. _new_decompr__TCDM_STRIDE_REG: + +TCDM_STRIDE_REG +""""""""""""""" + +Number of items to jump for every TCDM_COUNT_REG in the L2 (Used only for 2D decompression) + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------------+------+------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset | Description | + +=====+===+=================+======+============================================================================================================+ + |15:0 |R/W|TCDM_STRIDE_COUNT|0x0000|For TCDM 2D transfers, number of items in a stride (i.e. from a linear chunck of data to the next), minus 1.| + +-----+---+-----------------+------+------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/non_secured_riscv_debug.rst b/rtos/pulp/gap_archi/doc/ips/non_secured_riscv_debug.rst index 1697b423e..cbf33b58b 100644 --- a/rtos/pulp/gap_archi/doc/ips/non_secured_riscv_debug.rst +++ b/rtos/pulp/gap_archi/doc/ips/non_secured_riscv_debug.rst @@ -8,121 +8,126 @@ Register map Overview """""""" -.. table:: - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +=======================================================+======+=====+===================================================================+ - |:ref:`CTRL` | 0| 32|Debug control configuration register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`HIT` | 4| 32|Debug hit status register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`IE` | 8| 32|Debug exception trap enable configuration register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CAUSE` | 12| 32|Debug trap cause status register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`NPC` | 8192| 32|Debug next program counter value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`PPC` | 8196| 32|Debug previous program counter value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR0` | 1024| 32|Core general purpose register 0 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR1` | 1028| 32|Core general purpose register 1 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR2` | 1032| 32|Core general purpose register 2 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR3` | 1036| 32|Core general purpose register 3 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR4` | 1040| 32|Core general purpose register 4 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR5` | 1044| 32|Core general purpose register 5 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR6` | 1048| 32|Core general purpose register 6 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR7` | 1052| 32|Core general purpose register 7 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR8` | 1056| 32|Core general purpose register 8 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR9` | 1060| 32|Core general purpose register 9 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR10` | 1064| 32|Core general purpose register 10 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR11` | 1068| 32|Core general purpose register 11 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR12` | 1072| 32|Core general purpose register 12 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR13` | 1076| 32|Core general purpose register 13 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR14` | 1080| 32|Core general purpose register 14 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR15` | 1084| 32|Core general purpose register 15 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR16` | 1088| 32|Core general purpose register 16 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR17` | 1092| 32|Core general purpose register 17 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR18` | 1096| 32|Core general purpose register 18 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR19` | 1100| 32|Core general purpose register 19 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR20` | 1104| 32|Core general purpose register 20 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR21` | 1108| 32|Core general purpose register 21 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR22` | 1112| 32|Core general purpose register 22 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR23` | 1116| 32|Core general purpose register 23 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR24` | 1120| 32|Core general purpose register 24 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR25` | 1124| 32|Core general purpose register 25 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR26` | 1128| 32|Core general purpose register 26 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR27` | 1132| 32|Core general purpose register 27 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR28` | 1136| 32|Core general purpose register 28 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR29` | 1140| 32|Core general purpose register 29 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR30` | 1144| 32|Core general purpose register 30 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR31` | 1148| 32|Core general purpose register 31 value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_MSTATUS`| 19456| 32|Core CSR machine status value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_MTVEC` | 19476| 32|Core CSR machine vector-trap base address value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_MEPC` | 19716| 32|Core CSR machine exception program counter value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_MCAUSE` | 19720| 32|Core CSR machine trap cause value register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_PCCR` | 24064| 32|Core CSR performance counter counter register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_PCER` | 24192| 32|Core CSR performance counter enable configuration register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_PCMR` | 24196| 32|Core CSR performance counter mode configuration register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_HWLP0S` | 24256| 32|Core CSR hardware loop 0 start configuration register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_HWLP0E` | 24260| 32|Core CSR hardware loop 0 end configuration register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_HWLP0C` | 24264| 32|Core CSR hardware loop 0 counter configuration register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_HWLP1S` | 24272| 32|Core CSR hardware loop 1 start configuration register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_HWLP1E` | 24276| 32|Core CSR hardware loop 1 end configuration register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_HWLP1C` | 24280| 32|Core CSR hardware loop 1 counter configuration register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_PRIVLV` | 28736| 32|Cose CSR privilege level status register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_UHARTID`| 16464| 32|Core CSR user privilege mode hardware thread ID status register. | - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_MHARTID`| 31824| 32|Core CSR machine privilege mode hardware thread ID status register.| - +-------------------------------------------------------+------+-----+-------------------------------------------------------------------+ - -.. _non_secured_riscv_debug_CTRL: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +========================================================+======+=====+===================================================================+ + |:ref:`CTRL` | 0| 32|Debug control configuration register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`HIT` | 4| 32|Debug hit status register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`IE` | 8| 32|Debug exception trap enable configuration register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CAUSE` | 12| 32|Debug trap cause status register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`NPC` | 8192| 32|Debug next program counter value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`PPC` | 8196| 32|Debug previous program counter value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR0` | 1024| 32|Core general purpose register 0 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR1` | 1028| 32|Core general purpose register 1 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR2` | 1032| 32|Core general purpose register 2 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR3` | 1036| 32|Core general purpose register 3 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR4` | 1040| 32|Core general purpose register 4 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR5` | 1044| 32|Core general purpose register 5 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR6` | 1048| 32|Core general purpose register 6 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR7` | 1052| 32|Core general purpose register 7 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR8` | 1056| 32|Core general purpose register 8 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR9` | 1060| 32|Core general purpose register 9 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR10` | 1064| 32|Core general purpose register 10 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR11` | 1068| 32|Core general purpose register 11 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR12` | 1072| 32|Core general purpose register 12 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR13` | 1076| 32|Core general purpose register 13 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR14` | 1080| 32|Core general purpose register 14 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR15` | 1084| 32|Core general purpose register 15 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR16` | 1088| 32|Core general purpose register 16 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR17` | 1092| 32|Core general purpose register 17 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR18` | 1096| 32|Core general purpose register 18 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR19` | 1100| 32|Core general purpose register 19 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR20` | 1104| 32|Core general purpose register 20 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR21` | 1108| 32|Core general purpose register 21 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR22` | 1112| 32|Core general purpose register 22 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR23` | 1116| 32|Core general purpose register 23 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR24` | 1120| 32|Core general purpose register 24 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR25` | 1124| 32|Core general purpose register 25 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR26` | 1128| 32|Core general purpose register 26 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR27` | 1132| 32|Core general purpose register 27 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR28` | 1136| 32|Core general purpose register 28 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR29` | 1140| 32|Core general purpose register 29 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR30` | 1144| 32|Core general purpose register 30 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR31` | 1148| 32|Core general purpose register 31 value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_MSTATUS`| 19456| 32|Core CSR machine status value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_MTVEC` | 19476| 32|Core CSR machine vector-trap base address value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_MEPC` | 19716| 32|Core CSR machine exception program counter value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_MCAUSE` | 19720| 32|Core CSR machine trap cause value register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_PCCR` | 24064| 32|Core CSR performance counter counter register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_PCER` | 24192| 32|Core CSR performance counter enable configuration register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_PCMR` | 24196| 32|Core CSR performance counter mode configuration register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_HWLP0S` | 24256| 32|Core CSR hardware loop 0 start configuration register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_HWLP0E` | 24260| 32|Core CSR hardware loop 0 end configuration register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_HWLP0C` | 24264| 32|Core CSR hardware loop 0 counter configuration register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_HWLP1S` | 24272| 32|Core CSR hardware loop 1 start configuration register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_HWLP1E` | 24276| 32|Core CSR hardware loop 1 end configuration register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_HWLP1C` | 24280| 32|Core CSR hardware loop 1 counter configuration register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_PRIVLV` | 28736| 32|Cose CSR privilege level status register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_UHARTID`| 16464| 32|Core CSR user privilege mode hardware thread ID status register. | + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_MHARTID`| 31824| 32|Core CSR machine privilege mode hardware thread ID status register.| + +--------------------------------------------------------+------+-----+-------------------------------------------------------------------+ + +.. _non_secured_riscv_debug__CTRL: CTRL """" @@ -130,13 +135,15 @@ CTRL Debug control configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_HIT: +.. _non_secured_riscv_debug__HIT: HIT """ @@ -144,13 +151,15 @@ HIT Debug hit status register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_IE: +.. _non_secured_riscv_debug__IE: IE "" @@ -158,13 +167,15 @@ IE Debug exception trap enable configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CAUSE: +.. _non_secured_riscv_debug__CAUSE: CAUSE """"" @@ -172,13 +183,15 @@ CAUSE Debug trap cause status register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_NPC: +.. _non_secured_riscv_debug__NPC: NPC """ @@ -186,13 +199,15 @@ NPC Debug next program counter value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_PPC: +.. _non_secured_riscv_debug__PPC: PPC """ @@ -200,13 +215,15 @@ PPC Debug previous program counter value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR0: +.. _non_secured_riscv_debug__GPR0: GPR0 """" @@ -214,13 +231,15 @@ GPR0 Core general purpose register 0 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR1: +.. _non_secured_riscv_debug__GPR1: GPR1 """" @@ -228,13 +247,15 @@ GPR1 Core general purpose register 1 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR2: +.. _non_secured_riscv_debug__GPR2: GPR2 """" @@ -242,13 +263,15 @@ GPR2 Core general purpose register 2 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR3: +.. _non_secured_riscv_debug__GPR3: GPR3 """" @@ -256,13 +279,15 @@ GPR3 Core general purpose register 3 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR4: +.. _non_secured_riscv_debug__GPR4: GPR4 """" @@ -270,13 +295,15 @@ GPR4 Core general purpose register 4 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR5: +.. _non_secured_riscv_debug__GPR5: GPR5 """" @@ -284,13 +311,15 @@ GPR5 Core general purpose register 5 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR6: +.. _non_secured_riscv_debug__GPR6: GPR6 """" @@ -298,13 +327,15 @@ GPR6 Core general purpose register 6 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR7: +.. _non_secured_riscv_debug__GPR7: GPR7 """" @@ -312,13 +343,15 @@ GPR7 Core general purpose register 7 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR8: +.. _non_secured_riscv_debug__GPR8: GPR8 """" @@ -326,13 +359,15 @@ GPR8 Core general purpose register 8 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR9: +.. _non_secured_riscv_debug__GPR9: GPR9 """" @@ -340,13 +375,15 @@ GPR9 Core general purpose register 9 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR10: +.. _non_secured_riscv_debug__GPR10: GPR10 """"" @@ -354,13 +391,15 @@ GPR10 Core general purpose register 10 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR11: +.. _non_secured_riscv_debug__GPR11: GPR11 """"" @@ -368,13 +407,15 @@ GPR11 Core general purpose register 11 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR12: +.. _non_secured_riscv_debug__GPR12: GPR12 """"" @@ -382,13 +423,15 @@ GPR12 Core general purpose register 12 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR13: +.. _non_secured_riscv_debug__GPR13: GPR13 """"" @@ -396,13 +439,15 @@ GPR13 Core general purpose register 13 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR14: +.. _non_secured_riscv_debug__GPR14: GPR14 """"" @@ -410,13 +455,15 @@ GPR14 Core general purpose register 14 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR15: +.. _non_secured_riscv_debug__GPR15: GPR15 """"" @@ -424,13 +471,15 @@ GPR15 Core general purpose register 15 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR16: +.. _non_secured_riscv_debug__GPR16: GPR16 """"" @@ -438,13 +487,15 @@ GPR16 Core general purpose register 16 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR17: +.. _non_secured_riscv_debug__GPR17: GPR17 """"" @@ -452,13 +503,15 @@ GPR17 Core general purpose register 17 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR18: +.. _non_secured_riscv_debug__GPR18: GPR18 """"" @@ -466,13 +519,15 @@ GPR18 Core general purpose register 18 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR19: +.. _non_secured_riscv_debug__GPR19: GPR19 """"" @@ -480,13 +535,15 @@ GPR19 Core general purpose register 19 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR20: +.. _non_secured_riscv_debug__GPR20: GPR20 """"" @@ -494,13 +551,15 @@ GPR20 Core general purpose register 20 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR21: +.. _non_secured_riscv_debug__GPR21: GPR21 """"" @@ -508,13 +567,15 @@ GPR21 Core general purpose register 21 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR22: +.. _non_secured_riscv_debug__GPR22: GPR22 """"" @@ -522,13 +583,15 @@ GPR22 Core general purpose register 22 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR23: +.. _non_secured_riscv_debug__GPR23: GPR23 """"" @@ -536,13 +599,15 @@ GPR23 Core general purpose register 23 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR24: +.. _non_secured_riscv_debug__GPR24: GPR24 """"" @@ -550,13 +615,15 @@ GPR24 Core general purpose register 24 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR25: +.. _non_secured_riscv_debug__GPR25: GPR25 """"" @@ -564,13 +631,15 @@ GPR25 Core general purpose register 25 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR26: +.. _non_secured_riscv_debug__GPR26: GPR26 """"" @@ -578,13 +647,15 @@ GPR26 Core general purpose register 26 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR27: +.. _non_secured_riscv_debug__GPR27: GPR27 """"" @@ -592,13 +663,15 @@ GPR27 Core general purpose register 27 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR28: +.. _non_secured_riscv_debug__GPR28: GPR28 """"" @@ -606,13 +679,15 @@ GPR28 Core general purpose register 28 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR29: +.. _non_secured_riscv_debug__GPR29: GPR29 """"" @@ -620,13 +695,15 @@ GPR29 Core general purpose register 29 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR30: +.. _non_secured_riscv_debug__GPR30: GPR30 """"" @@ -634,13 +711,15 @@ GPR30 Core general purpose register 30 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_GPR31: +.. _non_secured_riscv_debug__GPR31: GPR31 """"" @@ -648,13 +727,15 @@ GPR31 Core general purpose register 31 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_MSTATUS: +.. _non_secured_riscv_debug__CSR_MSTATUS: CSR_MSTATUS """"""""""" @@ -662,13 +743,15 @@ CSR_MSTATUS Core CSR machine status value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_MTVEC: +.. _non_secured_riscv_debug__CSR_MTVEC: CSR_MTVEC """"""""" @@ -676,13 +759,15 @@ CSR_MTVEC Core CSR machine vector-trap base address value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_MEPC: +.. _non_secured_riscv_debug__CSR_MEPC: CSR_MEPC """""""" @@ -690,13 +775,15 @@ CSR_MEPC Core CSR machine exception program counter value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_MCAUSE: +.. _non_secured_riscv_debug__CSR_MCAUSE: CSR_MCAUSE """""""""" @@ -704,13 +791,15 @@ CSR_MCAUSE Core CSR machine trap cause value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_PCCR: +.. _non_secured_riscv_debug__CSR_PCCR: CSR_PCCR """""""" @@ -718,13 +807,15 @@ CSR_PCCR Core CSR performance counter counter register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_PCER: +.. _non_secured_riscv_debug__CSR_PCER: CSR_PCER """""""" @@ -732,13 +823,15 @@ CSR_PCER Core CSR performance counter enable configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_PCMR: +.. _non_secured_riscv_debug__CSR_PCMR: CSR_PCMR """""""" @@ -746,13 +839,15 @@ CSR_PCMR Core CSR performance counter mode configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_HWLP0S: +.. _non_secured_riscv_debug__CSR_HWLP0S: CSR_HWLP0S """""""""" @@ -760,13 +855,15 @@ CSR_HWLP0S Core CSR hardware loop 0 start configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_HWLP0E: +.. _non_secured_riscv_debug__CSR_HWLP0E: CSR_HWLP0E """""""""" @@ -774,13 +871,15 @@ CSR_HWLP0E Core CSR hardware loop 0 end configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_HWLP0C: +.. _non_secured_riscv_debug__CSR_HWLP0C: CSR_HWLP0C """""""""" @@ -788,13 +887,15 @@ CSR_HWLP0C Core CSR hardware loop 0 counter configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_HWLP1S: +.. _non_secured_riscv_debug__CSR_HWLP1S: CSR_HWLP1S """""""""" @@ -802,13 +903,15 @@ CSR_HWLP1S Core CSR hardware loop 1 start configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_HWLP1E: +.. _non_secured_riscv_debug__CSR_HWLP1E: CSR_HWLP1E """""""""" @@ -816,13 +919,15 @@ CSR_HWLP1E Core CSR hardware loop 1 end configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_HWLP1C: +.. _non_secured_riscv_debug__CSR_HWLP1C: CSR_HWLP1C """""""""" @@ -830,13 +935,15 @@ CSR_HWLP1C Core CSR hardware loop 1 counter configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_PRIVLV: +.. _non_secured_riscv_debug__CSR_PRIVLV: CSR_PRIVLV """""""""" @@ -844,13 +951,15 @@ CSR_PRIVLV Cose CSR privilege level status register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_UHARTID: +.. _non_secured_riscv_debug__CSR_UHARTID: CSR_UHARTID """"""""""" @@ -858,13 +967,15 @@ CSR_UHARTID Core CSR user privilege mode hardware thread ID status register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _non_secured_riscv_debug_CSR_MHARTID: +.. _non_secured_riscv_debug__CSR_MHARTID: CSR_MHARTID """"""""""" @@ -872,8 +983,10 @@ CSR_MHARTID Core CSR machine privilege mode hardware thread ID status register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ diff --git a/rtos/pulp/gap_archi/doc/ips/power_manager.rst b/rtos/pulp/gap_archi/doc/ips/power_manager.rst index c000eb750..c04671f48 100644 --- a/rtos/pulp/gap_archi/doc/ips/power_manager.rst +++ b/rtos/pulp/gap_archi/doc/ips/power_manager.rst @@ -8,191 +8,214 @@ Register map Overview """""""" -.. table:: - +-------------------------------------------------+------+-----+--------------------------------------------+ - | Name |Offset|Width| Description | - +=================================================+======+=====+============================================+ - |:ref:`DLCPD_MSR` | 0| 32|Maestro Status Register. | - +-------------------------------------------------+------+-----+--------------------------------------------+ - |:ref:`DLCPD_MPACR` | 4| 32|Maestro PICL Access Control Register. | - +-------------------------------------------------+------+-----+--------------------------------------------+ - |:ref:`DLCPD_MPADR` | 8| 32|Maestro PICL Access Data Register. | - +-------------------------------------------------+------+-----+--------------------------------------------+ - |:ref:`DLCPD_IMR` | 12| 32|Maestro Interrupt Mask Register. | - +-------------------------------------------------+------+-----+--------------------------------------------+ - |:ref:`DLCPD_IFR` | 16| 32|Maestro Interrupt Flag Register. | - +-------------------------------------------------+------+-----+--------------------------------------------+ - |:ref:`DLCPD_IOK_IFR`| 20| 32|Maestro ICU_OK Interrupt Flag Register. | - +-------------------------------------------------+------+-----+--------------------------------------------+ - |:ref:`DLCPD_IDL_IFR`| 24| 32|Maestro ICU_DELAYED Interrupt Flag Register.| - +-------------------------------------------------+------+-----+--------------------------------------------+ - |:ref:`DLCPD_IDN_IFR`| 28| 32|Maestro ICU_DENIED Interrupt Flag Register. | - +-------------------------------------------------+------+-----+--------------------------------------------+ - |:ref:`DLCPD_IUP_IFR`| 32| 32|Maestro ICU_UPDATED Interrupt Flag Register.| - +-------------------------------------------------+------+-----+--------------------------------------------+ - -.. _power_manager_DLCPD_MSR: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +--------------------------------------------------+------+-----+-------------------------------------------+ + | Name |Offset|Width| Description | + +==================================================+======+=====+===========================================+ + |:ref:`DLCPD_MSR` | 0| 32|Maestro Status Register | + +--------------------------------------------------+------+-----+-------------------------------------------+ + |:ref:`DLCPD_MPACR` | 4| 32|Maestro PICL Access Control Register | + +--------------------------------------------------+------+-----+-------------------------------------------+ + |:ref:`DLCPD_MPADR` | 8| 32|Maestro PICL Access Data Register | + +--------------------------------------------------+------+-----+-------------------------------------------+ + |:ref:`DLCPD_IMR` | 12| 32|Maestro Interrupt Mask Register | + +--------------------------------------------------+------+-----+-------------------------------------------+ + |:ref:`DLCPD_IFR` | 16| 32|Maestro Interrupt Flag Register | + +--------------------------------------------------+------+-----+-------------------------------------------+ + |:ref:`DLCPD_IOK_IFR`| 20| 32|Maestro ICU_OK Interrupt Flag Register | + +--------------------------------------------------+------+-----+-------------------------------------------+ + |:ref:`DLCPD_IDL_IFR`| 24| 32|Maestro ICU_DELAYED Interrupt Flag Register| + +--------------------------------------------------+------+-----+-------------------------------------------+ + |:ref:`DLCPD_IDN_IFR`| 28| 32|Maestro ICU_DENIED Interrupt Flag Register | + +--------------------------------------------------+------+-----+-------------------------------------------+ + |:ref:`DLCPD_IUP_IFR`| 32| 32|Maestro ICU_UPDATED Interrupt Flag Register| + +--------------------------------------------------+------+-----+-------------------------------------------+ + +.. _power_manager__DLCPD_MSR: DLCPD_MSR """"""""" -Maestro Status Register. +Maestro Status Register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+-----------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+===========================================================================================================+ - | 0|W |PICL_BUSY|PICL busy status. Set when a transfer is on going on the PICL bus. Cleared at the end of the PICL transfer.| - +-----+---+---------+-----------------------------------------------------------------------------------------------------------+ - | 1|W |SCU_BUSY |SCU busy status. Set when a SCU sequence is on going. Cleared when a SCU sequence ends. | - +-----+---+---------+-----------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+-----------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+===========================================================================================================+ + | 0|W |PICL_BUSY| 0|PICL busy status. Set when a transfer is on going on the PICL bus. Cleared at the end of the PICL transfer.| + +-----+---+---------+-----+-----------------------------------------------------------------------------------------------------------+ + | 1|W |SCU_BUSY | 0|SCU busy status. Set when a SCU sequence is on going. Cleared when a SCU sequence ends. | + +-----+---+---------+-----+-----------------------------------------------------------------------------------------------------------+ -.. _power_manager_DLCPD_MPACR: +.. _power_manager__DLCPD_MPACR: DLCPD_MPACR """"""""""" -Maestro PICL Access Control Register. +Maestro PICL Access Control Register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+====================================================================================+ - |15:0 |R |PAADDR |PICL Access Address. | - +-----+---+-------+------------------------------------------------------------------------------------+ - |24 |R |PADIR |PICL Access Direction : - 1'b0: write - 1'b1: read. | - +-----+---+-------+------------------------------------------------------------------------------------+ - |28 |R |PASTART|PICL Access Start. This field is automatically cleared when PICL access is finished.| - +-----+---+-------+------------------------------------------------------------------------------------+ + +-----+---+-------+-----+------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+====================================================================================+ + |15:0 |R |PAADDR | 0|PICL Access Address. | + +-----+---+-------+-----+------------------------------------------------------------------------------------+ + |24 |R |PADIR | 0|PICL Access Direction: b0: write; b1: read. | + +-----+---+-------+-----+------------------------------------------------------------------------------------+ + |28 |R |PASTART| 0|PICL Access Start. This field is automatically cleared when PICL access is finished.| + +-----+---+-------+-----+------------------------------------------------------------------------------------+ -.. _power_manager_DLCPD_MPADR: +.. _power_manager__DLCPD_MPADR: DLCPD_MPADR """"""""""" -Maestro PICL Access Data Register. +Maestro PICL Access Data Register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-----------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+===============================================================================================+ - |15:0 |W |PRWDATA|PICL Read/Write Data. This field is automatically updated after a PICL read access is finished.| - +-----+---+-------+-----------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+-----------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===============================================================================================+ + |15:0 |W |PRWDATA| 0|PICL Read/Write Data. This field is automatically updated after a PICL read access is finished.| + +-----+---+-------+-----+-----------------------------------------------------------------------------------------------+ -.. _power_manager_DLCPD_IMR: +.. _power_manager__DLCPD_IMR: DLCPD_IMR """"""""" -Maestro Interrupt Mask Register. +Maestro Interrupt Mask Register .. table:: - - +-----+---+---------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==============================+ - | 0|W |ICU_OK_M |Mask of ICU_OK interrupt. | - +-----+---+---------+------------------------------+ - | 1|W |ICU_DLY_M|Mask of ICU_DELAYED interrupt.| - +-----+---+---------+------------------------------+ - | 2|W |ICU_DEN_M|Mask of ICU_DENIED interrupt. | - +-----+---+---------+------------------------------+ - | 3|W |ICU_UPD_M|Mask of ICU_UPDATED interrupt.| - +-----+---+---------+------------------------------+ - | 6|W |PICL_OK_M|Mask of PICL_OK interrupt. | - +-----+---+---------+------------------------------+ - | 7|W |SCU_OK_M |Mask of SCU_OK interrupt. | - +-----+---+---------+------------------------------+ - | 8|W |SCU_FL_M |Mask of SCU_FL interrupt. | - +-----+---+---------+------------------------------+ - -.. _power_manager_DLCPD_IFR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==============================+ + | 0|W |ICU_OK_M | 0|Mask of ICU_OK interrupt. | + +-----+---+---------+-----+------------------------------+ + | 1|W |ICU_DLY_M| 0|Mask of ICU_DELAYED interrupt.| + +-----+---+---------+-----+------------------------------+ + | 2|W |ICU_DEN_M| 0|Mask of ICU_DENIED interrupt. | + +-----+---+---------+-----+------------------------------+ + | 3|W |ICU_UPD_M| 0|Mask of ICU_UPDATED interrupt.| + +-----+---+---------+-----+------------------------------+ + | 6|W |PICL_OK_M| 0|Mask of PICL_OK interrupt. | + +-----+---+---------+-----+------------------------------+ + | 7|W |SCU_OK_M | 0|Mask of SCU_OK interrupt. | + +-----+---+---------+-----+------------------------------+ + | 8|W |SCU_FL_M | 0|Mask of SCU_FL interrupt. | + +-----+---+---------+-----+------------------------------+ + +.. _power_manager__DLCPD_IFR: DLCPD_IFR """"""""" -Maestro Interrupt Flag Register. +Maestro Interrupt Flag Register .. table:: - - +-----+---+---------+--------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+======================================================================================+ - | 0|W |ICU_OK_F |Set when at least one of the bit of the DLCPD_IOK_IFR register is set. | - +-----+---+---------+--------------------------------------------------------------------------------------+ - | 1|W |ICU_DLY_F|Set when at least one of the bit of the DLCPD_IDL_IFR register is set. | - +-----+---+---------+--------------------------------------------------------------------------------------+ - | 2|W |ICU_DEN_F|Set when at least one of the bit of the DLCPD_IDN_IFR register is set. | - +-----+---+---------+--------------------------------------------------------------------------------------+ - | 3|W |ICU_UPD_F|Set when at least one of the bit of the DLCPD_IUP_IFR register is set. | - +-----+---+---------+--------------------------------------------------------------------------------------+ - | 6|W |PICL_OK_F|Set when PICL transfer is finished. Cleared when writing 1 in this field. | - +-----+---+---------+--------------------------------------------------------------------------------------+ - | 7|W |SCU_OK_F |Set when SCU sequence is finished without error. Cleared when writing 1 in this field.| - +-----+---+---------+--------------------------------------------------------------------------------------+ - | 8|W |SCU_FL_F |Set when SCU sequence is finished with error. Cleared when writing 1 in this field. | - +-----+---+---------+--------------------------------------------------------------------------------------+ - -.. _power_manager_DLCPD_IOK_IFR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+--------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+======================================================================================+ + | 0|W |ICU_OK_F | 0|Set when at least one of the bit of the DLCPD_IOK_IFR register is set. | + +-----+---+---------+-----+--------------------------------------------------------------------------------------+ + | 1|W |ICU_DLY_F| 0|Set when at least one of the bit of the DLCPD_IDL_IFR register is set. | + +-----+---+---------+-----+--------------------------------------------------------------------------------------+ + | 2|W |ICU_DEN_F| 0|Set when at least one of the bit of the DLCPD_IDN_IFR register is set. | + +-----+---+---------+-----+--------------------------------------------------------------------------------------+ + | 3|W |ICU_UPD_F| 0|Set when at least one of the bit of the DLCPD_IUP_IFR register is set. | + +-----+---+---------+-----+--------------------------------------------------------------------------------------+ + | 6|W |PICL_OK_F| 0|Set when PICL transfer is finished. Cleared when writing 1 in this field. | + +-----+---+---------+-----+--------------------------------------------------------------------------------------+ + | 7|W |SCU_OK_F | 0|Set when SCU sequence is finished without error. Cleared when writing 1 in this field.| + +-----+---+---------+-----+--------------------------------------------------------------------------------------+ + | 8|W |SCU_FL_F | 0|Set when SCU sequence is finished with error. Cleared when writing 1 in this field. | + +-----+---+---------+-----+--------------------------------------------------------------------------------------+ + +.. _power_manager__DLCPD_IOK_IFR: DLCPD_IOK_IFR """"""""""""" -Maestro ICU_OK Interrupt Flag Register. +Maestro ICU_OK Interrupt Flag Register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+=========================================================================================================================================================================================+ - |31:0 |W |ICU_OK_FLAGS|Flags of the ICU_OK interrupts. Each bit is set if the requested mode change from the control interface on the corresponding ICU was performed. Each bit is cleared when writing it to 1.| - +-----+---+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+------------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+=========================================================================================================================================================================================+ + |31:0 |W |ICU_OK_FLAGS| 0|Flags of the ICU_OK interrupts. Each bit is set if the requested mode change from the control interface on the corresponding ICU was performed. Each bit is cleared when writing it to 1.| + +-----+---+------------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _power_manager_DLCPD_IDL_IFR: +.. _power_manager__DLCPD_IDL_IFR: DLCPD_IDL_IFR """"""""""""" -Maestro ICU_DELAYED Interrupt Flag Register. +Maestro ICU_DELAYED Interrupt Flag Register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+============================================================================================================================================================================================+ - |31:0 |W |ICU_DLY_FLAGS|Flags of the ICU_DELAYED interrupts. Each bit is set if the requested mode change from the control interface on the corresponding ICU was delayed. Each bit is cleared when writing it to 1.| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+============================================================================================================================================================================================+ + |31:0 |W |ICU_DLY_FLAGS| 0|Flags of the ICU_DELAYED interrupts. Each bit is set if the requested mode change from the control interface on the corresponding ICU was delayed. Each bit is cleared when writing it to 1.| + +-----+---+-------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _power_manager_DLCPD_IDN_IFR: +.. _power_manager__DLCPD_IDN_IFR: DLCPD_IDN_IFR """"""""""""" -Maestro ICU_DENIED Interrupt Flag Register. +Maestro ICU_DENIED Interrupt Flag Register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+==========================================================================================================================================================================================+ - |31:0 |W |ICU_DEN_FLAGS|Flags of the ICU_DENIED interrupts. Each bit is set if the requested mode change from the control interface on the corresponding ICU was denied. Each bit is cleared when writing it to 1.| - +-----+---+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+==========================================================================================================================================================================================+ + |31:0 |W |ICU_DEN_FLAGS| 0|Flags of the ICU_DENIED interrupts. Each bit is set if the requested mode change from the control interface on the corresponding ICU was denied. Each bit is cleared when writing it to 1.| + +-----+---+-------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _power_manager_DLCPD_IUP_IFR: +.. _power_manager__DLCPD_IUP_IFR: DLCPD_IUP_IFR """"""""""""" -Maestro ICU_UPDATED Interrupt Flag Register. +Maestro ICU_UPDATED Interrupt Flag Register .. table:: - - +-----+---+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+====================================================================================================================================================+ - |31:0 |W |ICU_UPD_FLAGS|Flags of the ICU_UPDATED interrupts. Each bit is set when the corresponding ICU changed its mode or order. Each bit is cleared when writing it to 1.| - +-----+---+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+====================================================================================================================================================+ + |31:0 |W |ICU_UPD_FLAGS| 0|Flags of the ICU_UPDATED interrupts. Each bit is set when the corresponding ICU changed its mode or order. Each bit is cleared when writing it to 1.| + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/quiddikey.rst b/rtos/pulp/gap_archi/doc/ips/quiddikey.rst index 325318d77..3c20833a0 100644 --- a/rtos/pulp/gap_archi/doc/ips/quiddikey.rst +++ b/rtos/pulp/gap_archi/doc/ips/quiddikey.rst @@ -1,4 +1,5 @@ -Input file: fe/ips/quiddikey/doc/quiddikey_reference.md +.. + Input file: fe/ips/quiddikey/doc/quiddikey_reference.md Register map ^^^^^^^^^^^^ @@ -7,1511 +8,56 @@ Register map Overview """""""" -.. table:: - - +-----------------------------------------+------+-----+-----------------------------------------+ - | Name |Offset|Width| Description | - +=========================================+======+=====+=========================================+ - |:ref:`CR` | 0| 32|Control register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`SR` | 8| 32|Status register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`AR` | 12| 32|Allow register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`IER` | 16| 32|Interrupt Enable register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`IMR` | 20| 32|Interrupt Mask register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`ISR` | 24| 32|Interrupt Status register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`DATA_DEST` | 32| 32|Destination Data register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`DIR` | 160| 32|Data Input register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`DOR` | 168| 32|Data Output register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`MISC` | 192| 32|Miscellaneous register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`IF_SR` | 208| 32|Interface Status register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`TEST` | 216| 32|Test register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`PSR` | 220| 32|PUF Score register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`HW_RUC0` | 224| 32|Hardware Restrict User Context 0 register| - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`HW_RUC1` | 228| 32|Hardware Restrict User Context 1 register| - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`HW_SETTINGS`| 240| 32|Hardware Settings register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`HW_INFO` | 244| 32|Hardware Information register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`HW_ID` | 248| 32|Hardware Identifier register | - +-----------------------------------------+------+-----+-----------------------------------------+ - |:ref:`HW_VER` | 252| 32|Hardware Version register | - +-----------------------------------------+------+-----+-----------------------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Control register - #define QUIDDIKEY_CR_OFFSET 0x0 - - // Status register - #define QUIDDIKEY_SR_OFFSET 0x8 - - // Allow register - #define QUIDDIKEY_AR_OFFSET 0xc - - // Interrupt Enable register - #define QUIDDIKEY_IER_OFFSET 0x10 - - // Interrupt Mask register - #define QUIDDIKEY_IMR_OFFSET 0x14 - - // Interrupt Status register - #define QUIDDIKEY_ISR_OFFSET 0x18 - - // Destination Data register - #define QUIDDIKEY_DATA_DEST_OFFSET 0x20 - - // Data Input register - #define QUIDDIKEY_DIR_OFFSET 0xa0 - - // Data Output register - #define QUIDDIKEY_DOR_OFFSET 0xa8 - - // Miscellaneous register - #define QUIDDIKEY_MISC_OFFSET 0xc0 - - // Interface Status register - #define QUIDDIKEY_IF_SR_OFFSET 0xd0 - - // Test register - #define QUIDDIKEY_TEST_OFFSET 0xd8 - - // PUF Score register - #define QUIDDIKEY_PSR_OFFSET 0xdc - - // Hardware Restrict User Context 0 register - #define QUIDDIKEY_HW_RUC0_OFFSET 0xe0 - - // Hardware Restrict User Context 1 register - #define QUIDDIKEY_HW_RUC1_OFFSET 0xe4 - - // Hardware Settings register - #define QUIDDIKEY_HW_SETTINGS_OFFSET 0xf0 - - // Hardware Information register - #define QUIDDIKEY_HW_INFO_OFFSET 0xf4 - - // Hardware Identifier register - #define QUIDDIKEY_HW_ID_OFFSET 0xf8 - - // Hardware Version register - #define QUIDDIKEY_HW_VER_OFFSET 0xfc - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_cr_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_cr_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_sr_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_sr_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_ar_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_ar_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_ier_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_ier_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_imr_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_imr_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_isr_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_isr_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_data_dest_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_data_dest_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_dir_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_dir_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_dor_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_dor_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_misc_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_misc_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_if_sr_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_if_sr_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_test_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_test_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_psr_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_psr_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_hw_ruc0_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_hw_ruc0_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_hw_ruc1_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_hw_ruc1_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_hw_settings_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_hw_settings_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_hw_info_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_hw_info_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_hw_id_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_hw_id_set(uint32_t base, uint32_t value); - - static inline __attribute__((always_inline)) uint32_t quiddikey_hw_ver_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_hw_ver_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - .. code-block:: c +Refer to :ref:`GAP9 address map` for the base address to be used. - - // Begin Zeroize operation (access: R/W) - #define QUIDDIKEY_CR_ZEROIZE_BIT 0 - #define QUIDDIKEY_CR_ZEROIZE_WIDTH 1 - #define QUIDDIKEY_CR_ZEROIZE_MASK 0x1 - #define QUIDDIKEY_CR_ZEROIZE_RESET 0x0 - - // Begin Enroll operation (access: R/W) - #define QUIDDIKEY_CR_ENROLL_BIT 1 - #define QUIDDIKEY_CR_ENROLL_WIDTH 1 - #define QUIDDIKEY_CR_ENROLL_MASK 0x2 - #define QUIDDIKEY_CR_ENROLL_RESET 0x0 - - // Begin Start operation (access: R/W) - #define QUIDDIKEY_CR_START_BIT 2 - #define QUIDDIKEY_CR_START_WIDTH 1 - #define QUIDDIKEY_CR_START_MASK 0x4 - #define QUIDDIKEY_CR_START_RESET 0x0 - - // Begin Stop operation (access: R/W) - #define QUIDDIKEY_CR_STOP_BIT 5 - #define QUIDDIKEY_CR_STOP_WIDTH 1 - #define QUIDDIKEY_CR_STOP_MASK 0x20 - #define QUIDDIKEY_CR_STOP_RESET 0x0 - - // Begin Get Key operation (access: R/W) - #define QUIDDIKEY_CR_GET_KEY_BIT 6 - #define QUIDDIKEY_CR_GET_KEY_WIDTH 1 - #define QUIDDIKEY_CR_GET_KEY_MASK 0x40 - #define QUIDDIKEY_CR_GET_KEY_RESET 0x0 - - // Begin Unwrap operation (access: R/W) - #define QUIDDIKEY_CR_UNWRAP_BIT 7 - #define QUIDDIKEY_CR_UNWRAP_WIDTH 1 - #define QUIDDIKEY_CR_UNWRAP_MASK 0x80 - #define QUIDDIKEY_CR_UNWRAP_RESET 0x0 - - // Begin Wrap Generation Random operation (access: R/W) - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM_BIT 8 - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM_WIDTH 1 - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM_MASK 0x100 - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM_RESET 0x0 - - // Begin Wrap operation (access: R/W) - #define QUIDDIKEY_CR_WRAP_BIT 9 - #define QUIDDIKEY_CR_WRAP_WIDTH 1 - #define QUIDDIKEY_CR_WRAP_MASK 0x200 - #define QUIDDIKEY_CR_WRAP_RESET 0x0 - - // Begin Generate Random operation (access: R/W) - #define QUIDDIKEY_CR_GENERATE_RANDOM_BIT 15 - #define QUIDDIKEY_CR_GENERATE_RANDOM_WIDTH 1 - #define QUIDDIKEY_CR_GENERATE_RANDOM_MASK 0x8000 - #define QUIDDIKEY_CR_GENERATE_RANDOM_RESET 0x0 - - // Begin Reseed operation (access: R/W) - #define QUIDDIKEY_CR_RESEED_BIT 16 - #define QUIDDIKEY_CR_RESEED_WIDTH 1 - #define QUIDDIKEY_CR_RESEED_MASK 0x10000 - #define QUIDDIKEY_CR_RESEED_RESET 0x0 - - // Begin Test PUF operation (access: R/W) - #define QUIDDIKEY_CR_TEST_PUF_BIT 31 - #define QUIDDIKEY_CR_TEST_PUF_WIDTH 1 - #define QUIDDIKEY_CR_TEST_PUF_MASK 0x80000000 - #define QUIDDIKEY_CR_TEST_PUF_RESET 0x0 - - // Operation is in progress (access: R/W) - #define QUIDDIKEY_SR_BUSY_BIT 0 - #define QUIDDIKEY_SR_BUSY_WIDTH 1 - #define QUIDDIKEY_SR_BUSY_MASK 0x1 - #define QUIDDIKEY_SR_BUSY_RESET 0x0 - - // Last operation was successful (access: R/W) - #define QUIDDIKEY_SR_OK_BIT 1 - #define QUIDDIKEY_SR_OK_WIDTH 1 - #define QUIDDIKEY_SR_OK_MASK 0x2 - #define QUIDDIKEY_SR_OK_RESET 0x0 - - // Last operation failed (access: R/W) - #define QUIDDIKEY_SR_ERROR_BIT 2 - #define QUIDDIKEY_SR_ERROR_WIDTH 1 - #define QUIDDIKEY_SR_ERROR_MASK 0x4 - #define QUIDDIKEY_SR_ERROR_RESET 0x0 - - // Quiddikey is in Zeroized or in Locked state (access: R/W) - #define QUIDDIKEY_SR_ZEROIZED_BIT 3 - #define QUIDDIKEY_SR_ZEROIZED_WIDTH 1 - #define QUIDDIKEY_SR_ZEROIZED_MASK 0x8 - #define QUIDDIKEY_SR_ZEROIZED_RESET 0x0 - - // Read: last command rejected, Write 1: Clear this bit (access: R/W) - #define QUIDDIKEY_SR_REJECTED_BIT 4 - #define QUIDDIKEY_SR_REJECTED_WIDTH 1 - #define QUIDDIKEY_SR_REJECTED_MASK 0x10 - #define QUIDDIKEY_SR_REJECTED_RESET 0x0 - - // Request for Data in transfer via DIR register (access: R/W) - #define QUIDDIKEY_SR_DI_REQUEST_BIT 5 - #define QUIDDIKEY_SR_DI_REQUEST_WIDTH 1 - #define QUIDDIKEY_SR_DI_REQUEST_MASK 0x20 - #define QUIDDIKEY_SR_DI_REQUEST_RESET 0x0 - - // Request for Data out transfer via DOR register (access: R/W) - #define QUIDDIKEY_SR_DO_REQUEST_BIT 6 - #define QUIDDIKEY_SR_DO_REQUEST_WIDTH 1 - #define QUIDDIKEY_SR_DO_REQUEST_MASK 0x40 - #define QUIDDIKEY_SR_DO_REQUEST_RESET 0x0 - - // Reseed warning (see ORR RESEED_WARNING) (access: R/W) - #define QUIDDIKEY_SR_RESEED_WARNING_BIT 29 - #define QUIDDIKEY_SR_RESEED_WARNING_WIDTH 1 - #define QUIDDIKEY_SR_RESEED_WARNING_MASK 0x20000000 - #define QUIDDIKEY_SR_RESEED_WARNING_RESET 0x0 - - // Reseed required (see ORR RESEED_REQUIRED) (access: R/W) - #define QUIDDIKEY_SR_RESEED_REQUIRED_BIT 30 - #define QUIDDIKEY_SR_RESEED_REQUIRED_WIDTH 1 - #define QUIDDIKEY_SR_RESEED_REQUIRED_MASK 0x40000000 - #define QUIDDIKEY_SR_RESEED_REQUIRED_RESET 0x0 - - // Quiddikey is in state Lab Test Mode (access: R/W) - #define QUIDDIKEY_SR_LAB_TEST_MODE_BIT 31 - #define QUIDDIKEY_SR_LAB_TEST_MODE_WIDTH 1 - #define QUIDDIKEY_SR_LAB_TEST_MODE_MASK 0x80000000 - #define QUIDDIKEY_SR_LAB_TEST_MODE_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_ENROLL_BIT 1 - #define QUIDDIKEY_AR_ALLOW_ENROLL_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_ENROLL_MASK 0x2 - #define QUIDDIKEY_AR_ALLOW_ENROLL_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_START_BIT 2 - #define QUIDDIKEY_AR_ALLOW_START_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_START_MASK 0x4 - #define QUIDDIKEY_AR_ALLOW_START_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_STOP_BIT 5 - #define QUIDDIKEY_AR_ALLOW_STOP_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_STOP_MASK 0x20 - #define QUIDDIKEY_AR_ALLOW_STOP_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_GET_KEY_BIT 6 - #define QUIDDIKEY_AR_ALLOW_GET_KEY_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_GET_KEY_MASK 0x40 - #define QUIDDIKEY_AR_ALLOW_GET_KEY_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_UNWRAP_BIT 7 - #define QUIDDIKEY_AR_ALLOW_UNWRAP_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_UNWRAP_MASK 0x80 - #define QUIDDIKEY_AR_ALLOW_UNWRAP_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND_BIT 8 - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND_MASK 0x100 - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_WRAP_BIT 9 - #define QUIDDIKEY_AR_ALLOW_WRAP_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_WRAP_MASK 0x200 - #define QUIDDIKEY_AR_ALLOW_WRAP_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_GEN_RND_BIT 15 - #define QUIDDIKEY_AR_ALLOW_GEN_RND_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_GEN_RND_MASK 0x8000 - #define QUIDDIKEY_AR_ALLOW_GEN_RND_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_RESEED_BIT 16 - #define QUIDDIKEY_AR_ALLOW_RESEED_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_RESEED_MASK 0x10000 - #define QUIDDIKEY_AR_ALLOW_RESEED_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_TEST_PUF_BIT 31 - #define QUIDDIKEY_AR_ALLOW_TEST_PUF_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_TEST_PUF_MASK 0x80000000 - #define QUIDDIKEY_AR_ALLOW_TEST_PUF_RESET 0x0 - - // Interrupt enable register (access: R/W) - #define QUIDDIKEY_IER_INT_EN_BIT 0 - #define QUIDDIKEY_IER_INT_EN_WIDTH 1 - #define QUIDDIKEY_IER_INT_EN_MASK 0x1 - #define QUIDDIKEY_IER_INT_EN_RESET 0x0 - - // Enable Busy interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_BUSY_BIT 0 - #define QUIDDIKEY_IMR_INT_EN_BUSY_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_BUSY_MASK 0x1 - #define QUIDDIKEY_IMR_INT_EN_BUSY_RESET 0x0 - - // Enable Ok interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_OK_BIT 1 - #define QUIDDIKEY_IMR_INT_EN_OK_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_OK_MASK 0x2 - #define QUIDDIKEY_IMR_INT_EN_OK_RESET 0x0 - - // Enable Error interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_ERROR_BIT 2 - #define QUIDDIKEY_IMR_INT_EN_ERROR_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_ERROR_MASK 0x4 - #define QUIDDIKEY_IMR_INT_EN_ERROR_RESET 0x0 - - // Enable Zeroized interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED_BIT 3 - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED_MASK 0x8 - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED_RESET 0x0 - - // Enable Rejected interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_REJECTED_BIT 4 - #define QUIDDIKEY_IMR_INT_EN_REJECTED_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_REJECTED_MASK 0x10 - #define QUIDDIKEY_IMR_INT_EN_REJECTED_RESET 0x0 - - // Enable Data In Request interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST_BIT 5 - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST_MASK 0x20 - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST_RESET 0x0 - - // Enable Data Out Request interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST_BIT 6 - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST_MASK 0x40 - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST_RESET 0x0 - - // Enable Reseed Warning interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING_BIT 29 - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING_MASK 0x20000000 - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING_RESET 0x0 - - // Enable Reseed Required interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED_BIT 30 - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED_MASK 0x40000000 - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED_RESET 0x0 - - // Enable Lab Test Mode interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE_BIT 31 - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE_MASK 0x80000000 - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE_RESET 0x0 - - // Busy interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_BUSY_BIT 0 - #define QUIDDIKEY_ISR_INT_BUSY_WIDTH 1 - #define QUIDDIKEY_ISR_INT_BUSY_MASK 0x1 - #define QUIDDIKEY_ISR_INT_BUSY_RESET 0x0 - - // Ok interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_OK_BIT 1 - #define QUIDDIKEY_ISR_INT_OK_WIDTH 1 - #define QUIDDIKEY_ISR_INT_OK_MASK 0x2 - #define QUIDDIKEY_ISR_INT_OK_RESET 0x0 - - // Error interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_ERROR_BIT 2 - #define QUIDDIKEY_ISR_INT_ERROR_WIDTH 1 - #define QUIDDIKEY_ISR_INT_ERROR_MASK 0x4 - #define QUIDDIKEY_ISR_INT_ERROR_RESET 0x0 - - // Zeroized interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_ZEROIZED_BIT 3 - #define QUIDDIKEY_ISR_INT_ZEROIZED_WIDTH 1 - #define QUIDDIKEY_ISR_INT_ZEROIZED_MASK 0x8 - #define QUIDDIKEY_ISR_INT_ZEROIZED_RESET 0x0 - - // Rejected interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_REJECTED_BIT 4 - #define QUIDDIKEY_ISR_INT_REJECTED_WIDTH 1 - #define QUIDDIKEY_ISR_INT_REJECTED_MASK 0x10 - #define QUIDDIKEY_ISR_INT_REJECTED_RESET 0x0 - - // Data In Request interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_DI_REQUEST_BIT 5 - #define QUIDDIKEY_ISR_INT_DI_REQUEST_WIDTH 1 - #define QUIDDIKEY_ISR_INT_DI_REQUEST_MASK 0x20 - #define QUIDDIKEY_ISR_INT_DI_REQUEST_RESET 0x0 - - // Data Out Request interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_DO_REQUEST_BIT 6 - #define QUIDDIKEY_ISR_INT_DO_REQUEST_WIDTH 1 - #define QUIDDIKEY_ISR_INT_DO_REQUEST_MASK 0x40 - #define QUIDDIKEY_ISR_INT_DO_REQUEST_RESET 0x0 - - // Reseed Warning interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_RESEED_WARNING_BIT 29 - #define QUIDDIKEY_ISR_INT_RESEED_WARNING_WIDTH 1 - #define QUIDDIKEY_ISR_INT_RESEED_WARNING_MASK 0x20000000 - #define QUIDDIKEY_ISR_INT_RESEED_WARNING_RESET 0x0 - - // Reseed Required interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED_BIT 30 - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED_WIDTH 1 - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED_MASK 0x40000000 - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED_RESET 0x0 - - // Lab Test Mode interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE_BIT 31 - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE_WIDTH 1 - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE_MASK 0x80000000 - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE_RESET 0x0 - - // Data out register destination (access: R/W) - #define QUIDDIKEY_DATA_DEST_DEST_DOR_BIT 0 - #define QUIDDIKEY_DATA_DEST_DEST_DOR_WIDTH 1 - #define QUIDDIKEY_DATA_DEST_DEST_DOR_MASK 0x1 - #define QUIDDIKEY_DATA_DEST_DEST_DOR_RESET 0x0 - - // Secure Output interface destination (access: R/W) - #define QUIDDIKEY_DATA_DEST_DEST_SO_BIT 1 - #define QUIDDIKEY_DATA_DEST_DEST_SO_WIDTH 1 - #define QUIDDIKEY_DATA_DEST_DEST_SO_MASK 0x2 - #define QUIDDIKEY_DATA_DEST_DEST_SO_RESET 0x0 - - // Data In field (access: R/W) - #define QUIDDIKEY_DIR_DI_BIT 0 - #define QUIDDIKEY_DIR_DI_WIDTH 32 - #define QUIDDIKEY_DIR_DI_MASK 0xffffffff - #define QUIDDIKEY_DIR_DI_RESET 0x0 - - // Data Out field (access: R) - #define QUIDDIKEY_DOR_DOR_BIT 0 - #define QUIDDIKEY_DOR_DOR_WIDTH 32 - #define QUIDDIKEY_DOR_DOR_MASK 0xffffffff - #define QUIDDIKEY_DOR_DOR_RESET 0x0 - - // Set endianness (access: R) - #define QUIDDIKEY_MISC_ENDIANNESS_BIT 0 - #define QUIDDIKEY_MISC_ENDIANNESS_WIDTH 32 - #define QUIDDIKEY_MISC_ENDIANNESS_MASK 0xffffffff - #define QUIDDIKEY_MISC_ENDIANNESS_RESET 0x0 - - // An APB error has occured (access: R/W) - #define QUIDDIKEY_IF_SR_APB_ERROR_BIT 0 - #define QUIDDIKEY_IF_SR_APB_ERROR_WIDTH 1 - #define QUIDDIKEY_IF_SR_APB_ERROR_MASK 0x1 - #define QUIDDIKEY_IF_SR_APB_ERROR_RESET 0x0 - - // Isolates Quiddikey and runs BIST (access: R/W) - #define QUIDDIKEY_TEST_BIST_ENABLE_BIT 0 - #define QUIDDIKEY_TEST_BIST_ENABLE_WIDTH 1 - #define QUIDDIKEY_TEST_BIST_ENABLE_MASK 0x1 - #define QUIDDIKEY_TEST_BIST_ENABLE_RESET 0x0 - - // BIST is in progress or finishing up (access: R/W) - #define QUIDDIKEY_TEST_BIST_RUNNING_BIT 4 - #define QUIDDIKEY_TEST_BIST_RUNNING_WIDTH 1 - #define QUIDDIKEY_TEST_BIST_RUNNING_MASK 0x10 - #define QUIDDIKEY_TEST_BIST_RUNNING_RESET 0x0 - - // BIST is in progress (access: R/W) - #define QUIDDIKEY_TEST_BIST_ACTIVE_BIT 5 - #define QUIDDIKEY_TEST_BIST_ACTIVE_WIDTH 1 - #define QUIDDIKEY_TEST_BIST_ACTIVE_MASK 0x20 - #define QUIDDIKEY_TEST_BIST_ACTIVE_RESET 0x0 - - // BIST has passed (access: R/W) - #define QUIDDIKEY_TEST_BIST_OK_BIT 6 - #define QUIDDIKEY_TEST_BIST_OK_WIDTH 1 - #define QUIDDIKEY_TEST_BIST_OK_MASK 0x40 - #define QUIDDIKEY_TEST_BIST_OK_RESET 0x0 - - // BIST has failed (access: R/W) - #define QUIDDIKEY_TEST_BIST_ERROR_BIT 7 - #define QUIDDIKEY_TEST_BIST_ERROR_WIDTH 1 - #define QUIDDIKEY_TEST_BIST_ERROR_MASK 0x80 - #define QUIDDIKEY_TEST_BIST_ERROR_RESET 0x0 - - // BIST is not allowed (access: R/W) - #define QUIDDIKEY_TEST_ALLOW_BIST_BIT 31 - #define QUIDDIKEY_TEST_ALLOW_BIST_WIDTH 1 - #define QUIDDIKEY_TEST_ALLOW_BIST_MASK 0x80000000 - #define QUIDDIKEY_TEST_ALLOW_BIST_RESET 0x0 - - // PUF Score field (access: R/W) - #define QUIDDIKEY_PSR_PUF_SCORE_BIT 0 - #define QUIDDIKEY_PSR_PUF_SCORE_WIDTH 4 - #define QUIDDIKEY_PSR_PUF_SCORE_MASK 0xf - #define QUIDDIKEY_PSR_PUF_SCORE_RESET 0x0 - - // Restrict User Context 0 field (access: R/W) - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0_BIT 0 - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0_WIDTH 32 - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0_MASK 0xffffffff - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0_RESET 0x0 - - // Restrict User Context 1 field (access: R/W) - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1_BIT 0 - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1_WIDTH 32 - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1_MASK 0xffffffff - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1_RESET 0x0 - - // Enroll settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL_BIT 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL_MASK 0x2 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL_RESET 0x0 - - // Start settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START_BIT 2 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START_MASK 0x4 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START_RESET 0x0 - - // Stop settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP_BIT 5 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP_MASK 0x20 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP_RESET 0x0 - - // Get Key settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY_BIT 6 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY_MASK 0x40 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY_RESET 0x0 - - // Unwrap settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP_BIT 7 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP_MASK 0x80 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP_RESET 0x0 - - // Wrap Generated Random settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND_BIT 8 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND_MASK 0x100 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND_RESET 0x0 - - // Wrap settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_BIT 9 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_MASK 0x200 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_RESET 0x0 - - // Generate Random settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND_BIT 15 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND_MASK 0x8000 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND_RESET 0x0 - - // Reseed settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED_BIT 16 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED_MASK 0x10000 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED_RESET 0x0 - - // Lab Test Mode settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE_BIT 24 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE_MASK 0x1000000 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE_RESET 0x0 - - // Lab Test Mode select field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE_BIT 25 - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE_MASK 0x2000000 - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE_RESET 0x0 - - // Reseed via DIR settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR_BIT 27 - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR_MASK 0x8000000 - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR_RESET 0x0 - - // Reseed via SI settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI_BIT 28 - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI_MASK 0x10000000 - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI_RESET 0x0 - - // Test PUF settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF_BIT 31 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF_MASK 0x80000000 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF_RESET 0x0 - - // 1: SP 800-90 is included, 0: not included (access: R/W) - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90_BIT 21 - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90_WIDTH 1 - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90_MASK 0x200000 - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90_RESET 0x0 - - // 1: BIST is included, 0: not included (access: R/W) - #define QUIDDIKEY_HW_INFO_CONFIG_BIST_BIT 22 - #define QUIDDIKEY_HW_INFO_CONFIG_BIST_WIDTH 1 - #define QUIDDIKEY_HW_INFO_CONFIG_BIST_MASK 0x400000 - #define QUIDDIKEY_HW_INFO_CONFIG_BIST_RESET 0x0 - - // 1: Safe, 0: Plus (access: R/W) - #define QUIDDIKEY_HW_INFO_RESERVED_BIT 23 - #define QUIDDIKEY_HW_INFO_RESERVED_WIDTH 1 - #define QUIDDIKEY_HW_INFO_RESERVED_MASK 0x800000 - #define QUIDDIKEY_HW_INFO_RESERVED_RESET 0x0 - - // 1: Wrap is included, 0: not included (access: R/W) - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP_BIT 24 - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP_WIDTH 1 - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP_MASK 0x1000000 - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP_RESET 0x0 - - // Quiddikey configuration (access: R/W) - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE_BIT 28 - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE_WIDTH 4 - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE_MASK 0xf0000000 - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE_RESET 0x0 - - // Hardware Identifier (access: R/W) - #define QUIDDIKEY_HW_ID_HW_ID_BIT 0 - #define QUIDDIKEY_HW_ID_HW_ID_WIDTH 32 - #define QUIDDIKEY_HW_ID_HW_ID_MASK 0xffffffff - #define QUIDDIKEY_HW_ID_HW_ID_RESET 0x0 - - // Hardware version, revision part (access: R/W) - #define QUIDDIKEY_HW_VER_HW_VER_REV_BIT 0 - #define QUIDDIKEY_HW_VER_HW_VER_REV_WIDTH 8 - #define QUIDDIKEY_HW_VER_HW_VER_REV_MASK 0xff - #define QUIDDIKEY_HW_VER_HW_VER_REV_RESET 0x0 - - // Hardware version, minor part (access: R/W) - #define QUIDDIKEY_HW_VER_HW_VER_MINOR_BIT 8 - #define QUIDDIKEY_HW_VER_HW_VER_MINOR_WIDTH 8 - #define QUIDDIKEY_HW_VER_HW_VER_MINOR_MASK 0xff00 - #define QUIDDIKEY_HW_VER_HW_VER_MINOR_RESET 0x0 - - // Hardware version, major part (access: R/W) - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR_BIT 16 - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR_WIDTH 8 - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR_MASK 0xff0000 - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_CR_ZEROIZE_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_CR_ZEROIZE_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_CR_ZEROIZE_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_CR_ZEROIZE(val) ((val) << 0) - - #define QUIDDIKEY_CR_ENROLL_GET(value) (GAP_BEXTRACTU((value),1,1)) - #define QUIDDIKEY_CR_ENROLL_GETS(value) (GAP_BEXTRACT((value),1,1)) - #define QUIDDIKEY_CR_ENROLL_SET(value,field) (GAP_BINSERT((value),(field),1,1)) - #define QUIDDIKEY_CR_ENROLL(val) ((val) << 1) - - #define QUIDDIKEY_CR_START_GET(value) (GAP_BEXTRACTU((value),1,2)) - #define QUIDDIKEY_CR_START_GETS(value) (GAP_BEXTRACT((value),1,2)) - #define QUIDDIKEY_CR_START_SET(value,field) (GAP_BINSERT((value),(field),1,2)) - #define QUIDDIKEY_CR_START(val) ((val) << 2) - - #define QUIDDIKEY_CR_STOP_GET(value) (GAP_BEXTRACTU((value),1,5)) - #define QUIDDIKEY_CR_STOP_GETS(value) (GAP_BEXTRACT((value),1,5)) - #define QUIDDIKEY_CR_STOP_SET(value,field) (GAP_BINSERT((value),(field),1,5)) - #define QUIDDIKEY_CR_STOP(val) ((val) << 5) - - #define QUIDDIKEY_CR_GET_KEY_GET(value) (GAP_BEXTRACTU((value),1,6)) - #define QUIDDIKEY_CR_GET_KEY_GETS(value) (GAP_BEXTRACT((value),1,6)) - #define QUIDDIKEY_CR_GET_KEY_SET(value,field) (GAP_BINSERT((value),(field),1,6)) - #define QUIDDIKEY_CR_GET_KEY(val) ((val) << 6) - - #define QUIDDIKEY_CR_UNWRAP_GET(value) (GAP_BEXTRACTU((value),1,7)) - #define QUIDDIKEY_CR_UNWRAP_GETS(value) (GAP_BEXTRACT((value),1,7)) - #define QUIDDIKEY_CR_UNWRAP_SET(value,field) (GAP_BINSERT((value),(field),1,7)) - #define QUIDDIKEY_CR_UNWRAP(val) ((val) << 7) - - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM_GET(value) (GAP_BEXTRACTU((value),1,8)) - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM_GETS(value) (GAP_BEXTRACT((value),1,8)) - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM_SET(value,field) (GAP_BINSERT((value),(field),1,8)) - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM(val) ((val) << 8) - - #define QUIDDIKEY_CR_WRAP_GET(value) (GAP_BEXTRACTU((value),1,9)) - #define QUIDDIKEY_CR_WRAP_GETS(value) (GAP_BEXTRACT((value),1,9)) - #define QUIDDIKEY_CR_WRAP_SET(value,field) (GAP_BINSERT((value),(field),1,9)) - #define QUIDDIKEY_CR_WRAP(val) ((val) << 9) - - #define QUIDDIKEY_CR_GENERATE_RANDOM_GET(value) (GAP_BEXTRACTU((value),1,15)) - #define QUIDDIKEY_CR_GENERATE_RANDOM_GETS(value) (GAP_BEXTRACT((value),1,15)) - #define QUIDDIKEY_CR_GENERATE_RANDOM_SET(value,field) (GAP_BINSERT((value),(field),1,15)) - #define QUIDDIKEY_CR_GENERATE_RANDOM(val) ((val) << 15) - - #define QUIDDIKEY_CR_RESEED_GET(value) (GAP_BEXTRACTU((value),1,16)) - #define QUIDDIKEY_CR_RESEED_GETS(value) (GAP_BEXTRACT((value),1,16)) - #define QUIDDIKEY_CR_RESEED_SET(value,field) (GAP_BINSERT((value),(field),1,16)) - #define QUIDDIKEY_CR_RESEED(val) ((val) << 16) - - #define QUIDDIKEY_CR_TEST_PUF_GET(value) (GAP_BEXTRACTU((value),1,31)) - #define QUIDDIKEY_CR_TEST_PUF_GETS(value) (GAP_BEXTRACT((value),1,31)) - #define QUIDDIKEY_CR_TEST_PUF_SET(value,field) (GAP_BINSERT((value),(field),1,31)) - #define QUIDDIKEY_CR_TEST_PUF(val) ((val) << 31) - - #define QUIDDIKEY_SR_BUSY_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_SR_BUSY_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_SR_BUSY_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_SR_BUSY(val) ((val) << 0) - - #define QUIDDIKEY_SR_OK_GET(value) (GAP_BEXTRACTU((value),1,1)) - #define QUIDDIKEY_SR_OK_GETS(value) (GAP_BEXTRACT((value),1,1)) - #define QUIDDIKEY_SR_OK_SET(value,field) (GAP_BINSERT((value),(field),1,1)) - #define QUIDDIKEY_SR_OK(val) ((val) << 1) - - #define QUIDDIKEY_SR_ERROR_GET(value) (GAP_BEXTRACTU((value),1,2)) - #define QUIDDIKEY_SR_ERROR_GETS(value) (GAP_BEXTRACT((value),1,2)) - #define QUIDDIKEY_SR_ERROR_SET(value,field) (GAP_BINSERT((value),(field),1,2)) - #define QUIDDIKEY_SR_ERROR(val) ((val) << 2) - - #define QUIDDIKEY_SR_ZEROIZED_GET(value) (GAP_BEXTRACTU((value),1,3)) - #define QUIDDIKEY_SR_ZEROIZED_GETS(value) (GAP_BEXTRACT((value),1,3)) - #define QUIDDIKEY_SR_ZEROIZED_SET(value,field) (GAP_BINSERT((value),(field),1,3)) - #define QUIDDIKEY_SR_ZEROIZED(val) ((val) << 3) - - #define QUIDDIKEY_SR_REJECTED_GET(value) (GAP_BEXTRACTU((value),1,4)) - #define QUIDDIKEY_SR_REJECTED_GETS(value) (GAP_BEXTRACT((value),1,4)) - #define QUIDDIKEY_SR_REJECTED_SET(value,field) (GAP_BINSERT((value),(field),1,4)) - #define QUIDDIKEY_SR_REJECTED(val) ((val) << 4) - - #define QUIDDIKEY_SR_DI_REQUEST_GET(value) (GAP_BEXTRACTU((value),1,5)) - #define QUIDDIKEY_SR_DI_REQUEST_GETS(value) (GAP_BEXTRACT((value),1,5)) - #define QUIDDIKEY_SR_DI_REQUEST_SET(value,field) (GAP_BINSERT((value),(field),1,5)) - #define QUIDDIKEY_SR_DI_REQUEST(val) ((val) << 5) - - #define QUIDDIKEY_SR_DO_REQUEST_GET(value) (GAP_BEXTRACTU((value),1,6)) - #define QUIDDIKEY_SR_DO_REQUEST_GETS(value) (GAP_BEXTRACT((value),1,6)) - #define QUIDDIKEY_SR_DO_REQUEST_SET(value,field) (GAP_BINSERT((value),(field),1,6)) - #define QUIDDIKEY_SR_DO_REQUEST(val) ((val) << 6) - - #define QUIDDIKEY_SR_RESEED_WARNING_GET(value) (GAP_BEXTRACTU((value),1,29)) - #define QUIDDIKEY_SR_RESEED_WARNING_GETS(value) (GAP_BEXTRACT((value),1,29)) - #define QUIDDIKEY_SR_RESEED_WARNING_SET(value,field) (GAP_BINSERT((value),(field),1,29)) - #define QUIDDIKEY_SR_RESEED_WARNING(val) ((val) << 29) - - #define QUIDDIKEY_SR_RESEED_REQUIRED_GET(value) (GAP_BEXTRACTU((value),1,30)) - #define QUIDDIKEY_SR_RESEED_REQUIRED_GETS(value) (GAP_BEXTRACT((value),1,30)) - #define QUIDDIKEY_SR_RESEED_REQUIRED_SET(value,field) (GAP_BINSERT((value),(field),1,30)) - #define QUIDDIKEY_SR_RESEED_REQUIRED(val) ((val) << 30) - - #define QUIDDIKEY_SR_LAB_TEST_MODE_GET(value) (GAP_BEXTRACTU((value),1,31)) - #define QUIDDIKEY_SR_LAB_TEST_MODE_GETS(value) (GAP_BEXTRACT((value),1,31)) - #define QUIDDIKEY_SR_LAB_TEST_MODE_SET(value,field) (GAP_BINSERT((value),(field),1,31)) - #define QUIDDIKEY_SR_LAB_TEST_MODE(val) ((val) << 31) - - #define QUIDDIKEY_AR_ALLOW_ENROLL_GET(value) (GAP_BEXTRACTU((value),1,1)) - #define QUIDDIKEY_AR_ALLOW_ENROLL_GETS(value) (GAP_BEXTRACT((value),1,1)) - #define QUIDDIKEY_AR_ALLOW_ENROLL_SET(value,field) (GAP_BINSERT((value),(field),1,1)) - #define QUIDDIKEY_AR_ALLOW_ENROLL(val) ((val) << 1) - - #define QUIDDIKEY_AR_ALLOW_START_GET(value) (GAP_BEXTRACTU((value),1,2)) - #define QUIDDIKEY_AR_ALLOW_START_GETS(value) (GAP_BEXTRACT((value),1,2)) - #define QUIDDIKEY_AR_ALLOW_START_SET(value,field) (GAP_BINSERT((value),(field),1,2)) - #define QUIDDIKEY_AR_ALLOW_START(val) ((val) << 2) - - #define QUIDDIKEY_AR_ALLOW_STOP_GET(value) (GAP_BEXTRACTU((value),1,5)) - #define QUIDDIKEY_AR_ALLOW_STOP_GETS(value) (GAP_BEXTRACT((value),1,5)) - #define QUIDDIKEY_AR_ALLOW_STOP_SET(value,field) (GAP_BINSERT((value),(field),1,5)) - #define QUIDDIKEY_AR_ALLOW_STOP(val) ((val) << 5) - - #define QUIDDIKEY_AR_ALLOW_GET_KEY_GET(value) (GAP_BEXTRACTU((value),1,6)) - #define QUIDDIKEY_AR_ALLOW_GET_KEY_GETS(value) (GAP_BEXTRACT((value),1,6)) - #define QUIDDIKEY_AR_ALLOW_GET_KEY_SET(value,field) (GAP_BINSERT((value),(field),1,6)) - #define QUIDDIKEY_AR_ALLOW_GET_KEY(val) ((val) << 6) - - #define QUIDDIKEY_AR_ALLOW_UNWRAP_GET(value) (GAP_BEXTRACTU((value),1,7)) - #define QUIDDIKEY_AR_ALLOW_UNWRAP_GETS(value) (GAP_BEXTRACT((value),1,7)) - #define QUIDDIKEY_AR_ALLOW_UNWRAP_SET(value,field) (GAP_BINSERT((value),(field),1,7)) - #define QUIDDIKEY_AR_ALLOW_UNWRAP(val) ((val) << 7) - - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND_GET(value) (GAP_BEXTRACTU((value),1,8)) - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND_GETS(value) (GAP_BEXTRACT((value),1,8)) - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND_SET(value,field) (GAP_BINSERT((value),(field),1,8)) - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND(val) ((val) << 8) - - #define QUIDDIKEY_AR_ALLOW_WRAP_GET(value) (GAP_BEXTRACTU((value),1,9)) - #define QUIDDIKEY_AR_ALLOW_WRAP_GETS(value) (GAP_BEXTRACT((value),1,9)) - #define QUIDDIKEY_AR_ALLOW_WRAP_SET(value,field) (GAP_BINSERT((value),(field),1,9)) - #define QUIDDIKEY_AR_ALLOW_WRAP(val) ((val) << 9) - - #define QUIDDIKEY_AR_ALLOW_GEN_RND_GET(value) (GAP_BEXTRACTU((value),1,15)) - #define QUIDDIKEY_AR_ALLOW_GEN_RND_GETS(value) (GAP_BEXTRACT((value),1,15)) - #define QUIDDIKEY_AR_ALLOW_GEN_RND_SET(value,field) (GAP_BINSERT((value),(field),1,15)) - #define QUIDDIKEY_AR_ALLOW_GEN_RND(val) ((val) << 15) - - #define QUIDDIKEY_AR_ALLOW_RESEED_GET(value) (GAP_BEXTRACTU((value),1,16)) - #define QUIDDIKEY_AR_ALLOW_RESEED_GETS(value) (GAP_BEXTRACT((value),1,16)) - #define QUIDDIKEY_AR_ALLOW_RESEED_SET(value,field) (GAP_BINSERT((value),(field),1,16)) - #define QUIDDIKEY_AR_ALLOW_RESEED(val) ((val) << 16) - - #define QUIDDIKEY_AR_ALLOW_TEST_PUF_GET(value) (GAP_BEXTRACTU((value),1,31)) - #define QUIDDIKEY_AR_ALLOW_TEST_PUF_GETS(value) (GAP_BEXTRACT((value),1,31)) - #define QUIDDIKEY_AR_ALLOW_TEST_PUF_SET(value,field) (GAP_BINSERT((value),(field),1,31)) - #define QUIDDIKEY_AR_ALLOW_TEST_PUF(val) ((val) << 31) - - #define QUIDDIKEY_IER_INT_EN_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_IER_INT_EN_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_IER_INT_EN_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_IER_INT_EN(val) ((val) << 0) - - #define QUIDDIKEY_IMR_INT_EN_BUSY_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_IMR_INT_EN_BUSY_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_IMR_INT_EN_BUSY_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_IMR_INT_EN_BUSY(val) ((val) << 0) - - #define QUIDDIKEY_IMR_INT_EN_OK_GET(value) (GAP_BEXTRACTU((value),1,1)) - #define QUIDDIKEY_IMR_INT_EN_OK_GETS(value) (GAP_BEXTRACT((value),1,1)) - #define QUIDDIKEY_IMR_INT_EN_OK_SET(value,field) (GAP_BINSERT((value),(field),1,1)) - #define QUIDDIKEY_IMR_INT_EN_OK(val) ((val) << 1) - - #define QUIDDIKEY_IMR_INT_EN_ERROR_GET(value) (GAP_BEXTRACTU((value),1,2)) - #define QUIDDIKEY_IMR_INT_EN_ERROR_GETS(value) (GAP_BEXTRACT((value),1,2)) - #define QUIDDIKEY_IMR_INT_EN_ERROR_SET(value,field) (GAP_BINSERT((value),(field),1,2)) - #define QUIDDIKEY_IMR_INT_EN_ERROR(val) ((val) << 2) - - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED_GET(value) (GAP_BEXTRACTU((value),1,3)) - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED_GETS(value) (GAP_BEXTRACT((value),1,3)) - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED_SET(value,field) (GAP_BINSERT((value),(field),1,3)) - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED(val) ((val) << 3) - - #define QUIDDIKEY_IMR_INT_EN_REJECTED_GET(value) (GAP_BEXTRACTU((value),1,4)) - #define QUIDDIKEY_IMR_INT_EN_REJECTED_GETS(value) (GAP_BEXTRACT((value),1,4)) - #define QUIDDIKEY_IMR_INT_EN_REJECTED_SET(value,field) (GAP_BINSERT((value),(field),1,4)) - #define QUIDDIKEY_IMR_INT_EN_REJECTED(val) ((val) << 4) - - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST_GET(value) (GAP_BEXTRACTU((value),1,5)) - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST_GETS(value) (GAP_BEXTRACT((value),1,5)) - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST_SET(value,field) (GAP_BINSERT((value),(field),1,5)) - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST(val) ((val) << 5) - - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST_GET(value) (GAP_BEXTRACTU((value),1,6)) - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST_GETS(value) (GAP_BEXTRACT((value),1,6)) - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST_SET(value,field) (GAP_BINSERT((value),(field),1,6)) - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST(val) ((val) << 6) - - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING_GET(value) (GAP_BEXTRACTU((value),1,29)) - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING_GETS(value) (GAP_BEXTRACT((value),1,29)) - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING_SET(value,field) (GAP_BINSERT((value),(field),1,29)) - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING(val) ((val) << 29) - - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED_GET(value) (GAP_BEXTRACTU((value),1,30)) - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED_GETS(value) (GAP_BEXTRACT((value),1,30)) - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED_SET(value,field) (GAP_BINSERT((value),(field),1,30)) - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED(val) ((val) << 30) - - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE_GET(value) (GAP_BEXTRACTU((value),1,31)) - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE_GETS(value) (GAP_BEXTRACT((value),1,31)) - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE_SET(value,field) (GAP_BINSERT((value),(field),1,31)) - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE(val) ((val) << 31) - - #define QUIDDIKEY_ISR_INT_BUSY_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_ISR_INT_BUSY_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_ISR_INT_BUSY_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_ISR_INT_BUSY(val) ((val) << 0) - - #define QUIDDIKEY_ISR_INT_OK_GET(value) (GAP_BEXTRACTU((value),1,1)) - #define QUIDDIKEY_ISR_INT_OK_GETS(value) (GAP_BEXTRACT((value),1,1)) - #define QUIDDIKEY_ISR_INT_OK_SET(value,field) (GAP_BINSERT((value),(field),1,1)) - #define QUIDDIKEY_ISR_INT_OK(val) ((val) << 1) - - #define QUIDDIKEY_ISR_INT_ERROR_GET(value) (GAP_BEXTRACTU((value),1,2)) - #define QUIDDIKEY_ISR_INT_ERROR_GETS(value) (GAP_BEXTRACT((value),1,2)) - #define QUIDDIKEY_ISR_INT_ERROR_SET(value,field) (GAP_BINSERT((value),(field),1,2)) - #define QUIDDIKEY_ISR_INT_ERROR(val) ((val) << 2) - - #define QUIDDIKEY_ISR_INT_ZEROIZED_GET(value) (GAP_BEXTRACTU((value),1,3)) - #define QUIDDIKEY_ISR_INT_ZEROIZED_GETS(value) (GAP_BEXTRACT((value),1,3)) - #define QUIDDIKEY_ISR_INT_ZEROIZED_SET(value,field) (GAP_BINSERT((value),(field),1,3)) - #define QUIDDIKEY_ISR_INT_ZEROIZED(val) ((val) << 3) - - #define QUIDDIKEY_ISR_INT_REJECTED_GET(value) (GAP_BEXTRACTU((value),1,4)) - #define QUIDDIKEY_ISR_INT_REJECTED_GETS(value) (GAP_BEXTRACT((value),1,4)) - #define QUIDDIKEY_ISR_INT_REJECTED_SET(value,field) (GAP_BINSERT((value),(field),1,4)) - #define QUIDDIKEY_ISR_INT_REJECTED(val) ((val) << 4) - - #define QUIDDIKEY_ISR_INT_DI_REQUEST_GET(value) (GAP_BEXTRACTU((value),1,5)) - #define QUIDDIKEY_ISR_INT_DI_REQUEST_GETS(value) (GAP_BEXTRACT((value),1,5)) - #define QUIDDIKEY_ISR_INT_DI_REQUEST_SET(value,field) (GAP_BINSERT((value),(field),1,5)) - #define QUIDDIKEY_ISR_INT_DI_REQUEST(val) ((val) << 5) - - #define QUIDDIKEY_ISR_INT_DO_REQUEST_GET(value) (GAP_BEXTRACTU((value),1,6)) - #define QUIDDIKEY_ISR_INT_DO_REQUEST_GETS(value) (GAP_BEXTRACT((value),1,6)) - #define QUIDDIKEY_ISR_INT_DO_REQUEST_SET(value,field) (GAP_BINSERT((value),(field),1,6)) - #define QUIDDIKEY_ISR_INT_DO_REQUEST(val) ((val) << 6) - - #define QUIDDIKEY_ISR_INT_RESEED_WARNING_GET(value) (GAP_BEXTRACTU((value),1,29)) - #define QUIDDIKEY_ISR_INT_RESEED_WARNING_GETS(value) (GAP_BEXTRACT((value),1,29)) - #define QUIDDIKEY_ISR_INT_RESEED_WARNING_SET(value,field) (GAP_BINSERT((value),(field),1,29)) - #define QUIDDIKEY_ISR_INT_RESEED_WARNING(val) ((val) << 29) - - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED_GET(value) (GAP_BEXTRACTU((value),1,30)) - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED_GETS(value) (GAP_BEXTRACT((value),1,30)) - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED_SET(value,field) (GAP_BINSERT((value),(field),1,30)) - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED(val) ((val) << 30) - - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE_GET(value) (GAP_BEXTRACTU((value),1,31)) - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE_GETS(value) (GAP_BEXTRACT((value),1,31)) - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE_SET(value,field) (GAP_BINSERT((value),(field),1,31)) - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE(val) ((val) << 31) - - #define QUIDDIKEY_DATA_DEST_DEST_DOR_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_DATA_DEST_DEST_DOR_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_DATA_DEST_DEST_DOR_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_DATA_DEST_DEST_DOR(val) ((val) << 0) - - #define QUIDDIKEY_DATA_DEST_DEST_SO_GET(value) (GAP_BEXTRACTU((value),1,1)) - #define QUIDDIKEY_DATA_DEST_DEST_SO_GETS(value) (GAP_BEXTRACT((value),1,1)) - #define QUIDDIKEY_DATA_DEST_DEST_SO_SET(value,field) (GAP_BINSERT((value),(field),1,1)) - #define QUIDDIKEY_DATA_DEST_DEST_SO(val) ((val) << 1) - - #define QUIDDIKEY_DIR_DI_GET(value) (value) - #define QUIDDIKEY_DIR_DI_GETS(value) (value) - #define QUIDDIKEY_DIR_DI_SET(value,field) (field) - #define QUIDDIKEY_DIR_DI(val) ((val) << 0) - - #define QUIDDIKEY_DOR_DOR_GET(value) (value) - #define QUIDDIKEY_DOR_DOR_GETS(value) (value) - #define QUIDDIKEY_DOR_DOR_SET(value,field) (field) - #define QUIDDIKEY_DOR_DOR(val) ((val) << 0) - - #define QUIDDIKEY_MISC_ENDIANNESS_GET(value) (value) - #define QUIDDIKEY_MISC_ENDIANNESS_GETS(value) (value) - #define QUIDDIKEY_MISC_ENDIANNESS_SET(value,field) (field) - #define QUIDDIKEY_MISC_ENDIANNESS(val) ((val) << 0) - - #define QUIDDIKEY_IF_SR_APB_ERROR_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_IF_SR_APB_ERROR_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_IF_SR_APB_ERROR_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_IF_SR_APB_ERROR(val) ((val) << 0) - - #define QUIDDIKEY_TEST_BIST_ENABLE_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_TEST_BIST_ENABLE_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_TEST_BIST_ENABLE_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_TEST_BIST_ENABLE(val) ((val) << 0) - - #define QUIDDIKEY_TEST_BIST_RUNNING_GET(value) (GAP_BEXTRACTU((value),1,4)) - #define QUIDDIKEY_TEST_BIST_RUNNING_GETS(value) (GAP_BEXTRACT((value),1,4)) - #define QUIDDIKEY_TEST_BIST_RUNNING_SET(value,field) (GAP_BINSERT((value),(field),1,4)) - #define QUIDDIKEY_TEST_BIST_RUNNING(val) ((val) << 4) - - #define QUIDDIKEY_TEST_BIST_ACTIVE_GET(value) (GAP_BEXTRACTU((value),1,5)) - #define QUIDDIKEY_TEST_BIST_ACTIVE_GETS(value) (GAP_BEXTRACT((value),1,5)) - #define QUIDDIKEY_TEST_BIST_ACTIVE_SET(value,field) (GAP_BINSERT((value),(field),1,5)) - #define QUIDDIKEY_TEST_BIST_ACTIVE(val) ((val) << 5) - - #define QUIDDIKEY_TEST_BIST_OK_GET(value) (GAP_BEXTRACTU((value),1,6)) - #define QUIDDIKEY_TEST_BIST_OK_GETS(value) (GAP_BEXTRACT((value),1,6)) - #define QUIDDIKEY_TEST_BIST_OK_SET(value,field) (GAP_BINSERT((value),(field),1,6)) - #define QUIDDIKEY_TEST_BIST_OK(val) ((val) << 6) - - #define QUIDDIKEY_TEST_BIST_ERROR_GET(value) (GAP_BEXTRACTU((value),1,7)) - #define QUIDDIKEY_TEST_BIST_ERROR_GETS(value) (GAP_BEXTRACT((value),1,7)) - #define QUIDDIKEY_TEST_BIST_ERROR_SET(value,field) (GAP_BINSERT((value),(field),1,7)) - #define QUIDDIKEY_TEST_BIST_ERROR(val) ((val) << 7) - - #define QUIDDIKEY_TEST_ALLOW_BIST_GET(value) (GAP_BEXTRACTU((value),1,31)) - #define QUIDDIKEY_TEST_ALLOW_BIST_GETS(value) (GAP_BEXTRACT((value),1,31)) - #define QUIDDIKEY_TEST_ALLOW_BIST_SET(value,field) (GAP_BINSERT((value),(field),1,31)) - #define QUIDDIKEY_TEST_ALLOW_BIST(val) ((val) << 31) - - #define QUIDDIKEY_PSR_PUF_SCORE_GET(value) (GAP_BEXTRACTU((value),4,0)) - #define QUIDDIKEY_PSR_PUF_SCORE_GETS(value) (GAP_BEXTRACT((value),4,0)) - #define QUIDDIKEY_PSR_PUF_SCORE_SET(value,field) (GAP_BINSERT((value),(field),4,0)) - #define QUIDDIKEY_PSR_PUF_SCORE(val) ((val) << 0) - - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0_GET(value) (value) - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0_GETS(value) (value) - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0_SET(value,field) (field) - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0(val) ((val) << 0) - - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1_GET(value) (value) - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1_GETS(value) (value) - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1_SET(value,field) (field) - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1(val) ((val) << 0) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL_GET(value) (GAP_BEXTRACTU((value),1,1)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL_GETS(value) (GAP_BEXTRACT((value),1,1)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL_SET(value,field) (GAP_BINSERT((value),(field),1,1)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL(val) ((val) << 1) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START_GET(value) (GAP_BEXTRACTU((value),1,2)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START_GETS(value) (GAP_BEXTRACT((value),1,2)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START_SET(value,field) (GAP_BINSERT((value),(field),1,2)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START(val) ((val) << 2) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP_GET(value) (GAP_BEXTRACTU((value),1,5)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP_GETS(value) (GAP_BEXTRACT((value),1,5)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP_SET(value,field) (GAP_BINSERT((value),(field),1,5)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP(val) ((val) << 5) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY_GET(value) (GAP_BEXTRACTU((value),1,6)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY_GETS(value) (GAP_BEXTRACT((value),1,6)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY_SET(value,field) (GAP_BINSERT((value),(field),1,6)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY(val) ((val) << 6) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP_GET(value) (GAP_BEXTRACTU((value),1,7)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP_GETS(value) (GAP_BEXTRACT((value),1,7)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP_SET(value,field) (GAP_BINSERT((value),(field),1,7)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP(val) ((val) << 7) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND_GET(value) (GAP_BEXTRACTU((value),1,8)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND_GETS(value) (GAP_BEXTRACT((value),1,8)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND_SET(value,field) (GAP_BINSERT((value),(field),1,8)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND(val) ((val) << 8) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GET(value) (GAP_BEXTRACTU((value),1,9)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GETS(value) (GAP_BEXTRACT((value),1,9)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_SET(value,field) (GAP_BINSERT((value),(field),1,9)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP(val) ((val) << 9) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND_GET(value) (GAP_BEXTRACTU((value),1,15)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND_GETS(value) (GAP_BEXTRACT((value),1,15)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND_SET(value,field) (GAP_BINSERT((value),(field),1,15)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND(val) ((val) << 15) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED_GET(value) (GAP_BEXTRACTU((value),1,16)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED_GETS(value) (GAP_BEXTRACT((value),1,16)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED_SET(value,field) (GAP_BINSERT((value),(field),1,16)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED(val) ((val) << 16) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE_GET(value) (GAP_BEXTRACTU((value),1,24)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE_GETS(value) (GAP_BEXTRACT((value),1,24)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE_SET(value,field) (GAP_BINSERT((value),(field),1,24)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE(val) ((val) << 24) - - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE_GET(value) (GAP_BEXTRACTU((value),1,25)) - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE_GETS(value) (GAP_BEXTRACT((value),1,25)) - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE_SET(value,field) (GAP_BINSERT((value),(field),1,25)) - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE(val) ((val) << 25) - - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR_GET(value) (GAP_BEXTRACTU((value),1,27)) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR_GETS(value) (GAP_BEXTRACT((value),1,27)) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR_SET(value,field) (GAP_BINSERT((value),(field),1,27)) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR(val) ((val) << 27) - - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI_GET(value) (GAP_BEXTRACTU((value),1,28)) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI_GETS(value) (GAP_BEXTRACT((value),1,28)) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI_SET(value,field) (GAP_BINSERT((value),(field),1,28)) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI(val) ((val) << 28) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF_GET(value) (GAP_BEXTRACTU((value),1,31)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF_GETS(value) (GAP_BEXTRACT((value),1,31)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF_SET(value,field) (GAP_BINSERT((value),(field),1,31)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF(val) ((val) << 31) - - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90_GET(value) (GAP_BEXTRACTU((value),1,21)) - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90_GETS(value) (GAP_BEXTRACT((value),1,21)) - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90_SET(value,field) (GAP_BINSERT((value),(field),1,21)) - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90(val) ((val) << 21) - - #define QUIDDIKEY_HW_INFO_CONFIG_BIST_GET(value) (GAP_BEXTRACTU((value),1,22)) - #define QUIDDIKEY_HW_INFO_CONFIG_BIST_GETS(value) (GAP_BEXTRACT((value),1,22)) - #define QUIDDIKEY_HW_INFO_CONFIG_BIST_SET(value,field) (GAP_BINSERT((value),(field),1,22)) - #define QUIDDIKEY_HW_INFO_CONFIG_BIST(val) ((val) << 22) - - #define QUIDDIKEY_HW_INFO_RESERVED_GET(value) (GAP_BEXTRACTU((value),1,23)) - #define QUIDDIKEY_HW_INFO_RESERVED_GETS(value) (GAP_BEXTRACT((value),1,23)) - #define QUIDDIKEY_HW_INFO_RESERVED_SET(value,field) (GAP_BINSERT((value),(field),1,23)) - #define QUIDDIKEY_HW_INFO_RESERVED(val) ((val) << 23) - - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP_GET(value) (GAP_BEXTRACTU((value),1,24)) - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP_GETS(value) (GAP_BEXTRACT((value),1,24)) - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP_SET(value,field) (GAP_BINSERT((value),(field),1,24)) - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP(val) ((val) << 24) - - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE_GET(value) (GAP_BEXTRACTU((value),4,28)) - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE_GETS(value) (GAP_BEXTRACT((value),4,28)) - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE_SET(value,field) (GAP_BINSERT((value),(field),4,28)) - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE(val) ((val) << 28) - - #define QUIDDIKEY_HW_ID_HW_ID_GET(value) (value) - #define QUIDDIKEY_HW_ID_HW_ID_GETS(value) (value) - #define QUIDDIKEY_HW_ID_HW_ID_SET(value,field) (field) - #define QUIDDIKEY_HW_ID_HW_ID(val) ((val) << 0) - - #define QUIDDIKEY_HW_VER_HW_VER_REV_GET(value) (GAP_BEXTRACTU((value),8,0)) - #define QUIDDIKEY_HW_VER_HW_VER_REV_GETS(value) (GAP_BEXTRACT((value),8,0)) - #define QUIDDIKEY_HW_VER_HW_VER_REV_SET(value,field) (GAP_BINSERT((value),(field),8,0)) - #define QUIDDIKEY_HW_VER_HW_VER_REV(val) ((val) << 0) - - #define QUIDDIKEY_HW_VER_HW_VER_MINOR_GET(value) (GAP_BEXTRACTU((value),8,8)) - #define QUIDDIKEY_HW_VER_HW_VER_MINOR_GETS(value) (GAP_BEXTRACT((value),8,8)) - #define QUIDDIKEY_HW_VER_HW_VER_MINOR_SET(value,field) (GAP_BINSERT((value),(field),8,8)) - #define QUIDDIKEY_HW_VER_HW_VER_MINOR(val) ((val) << 8) - - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR_GET(value) (GAP_BEXTRACTU((value),8,16)) - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR_GETS(value) (GAP_BEXTRACT((value),8,16)) - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR_SET(value,field) (GAP_BINSERT((value),(field),8,16)) - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR(val) ((val) << 16) - -.. toggle-header:: - :header: *Register map structure* - - .. code-block:: c - - /** QUIDDIKEY_Type Register Layout Typedef */ - typedef struct { - volatile uint32_t cr; // Control register - volatile uint32_t reserved_0[1]; // Reserved/Not used. - volatile uint32_t sr; // Status register - volatile uint32_t ar; // Allow register - volatile uint32_t ier; // Interrupt Enable register - volatile uint32_t imr; // Interrupt Mask register - volatile uint32_t isr; // Interrupt Status register - volatile uint32_t reserved_1[1]; // Reserved/Not used. - volatile uint32_t data_dest; // Destination Data register - volatile uint32_t reserved_2[31]; // Reserved/Not used. - volatile uint32_t dir; // Data Input register - volatile uint32_t reserved_3[1]; // Reserved/Not used. - volatile uint32_t dor; // Data Output register - volatile uint32_t reserved_4[5]; // Reserved/Not used. - volatile uint32_t misc; // Miscellaneous register - volatile uint32_t reserved_5[3]; // Reserved/Not used. - volatile uint32_t if_sr; // Interface Status register - volatile uint32_t reserved_6[1]; // Reserved/Not used. - volatile uint32_t test; // Test register - volatile uint32_t psr; // PUF Score register - volatile uint32_t hw_ruc0; // Hardware Restrict User Context 0 register - volatile uint32_t hw_ruc1; // Hardware Restrict User Context 1 register - volatile uint32_t reserved_7[2]; // Reserved/Not used. - volatile uint32_t hw_settings; // Hardware Settings register - volatile uint32_t hw_info; // Hardware Information register - volatile uint32_t hw_id; // Hardware Identifier register - volatile uint32_t hw_ver; // Hardware Version register - } __attribute__((packed)) quiddikey_t; - /** QUIDDIKEY_Type Register Layout Typedef */ - typedef struct { - volatile quiddikey_cr_t cr; // Control register - volatile uint32_t reserved_0[1]; // Reserved/Not used. - volatile quiddikey_sr_t sr; // Status register - volatile quiddikey_ar_t ar; // Allow register - volatile quiddikey_ier_t ier; // Interrupt Enable register - volatile quiddikey_imr_t imr; // Interrupt Mask register - volatile quiddikey_isr_t isr; // Interrupt Status register - volatile uint32_t reserved_1[1]; // Reserved/Not used. - volatile quiddikey_data_dest_t data_dest; // Destination Data register - volatile uint32_t reserved_2[31]; // Reserved/Not used. - volatile quiddikey_dir_t dir; // Data Input register - volatile uint32_t reserved_3[1]; // Reserved/Not used. - volatile quiddikey_dor_t dor; // Data Output register - volatile uint32_t reserved_4[5]; // Reserved/Not used. - volatile quiddikey_misc_t misc; // Miscellaneous register - volatile uint32_t reserved_5[3]; // Reserved/Not used. - volatile quiddikey_if_sr_t if_sr; // Interface Status register - volatile uint32_t reserved_6[1]; // Reserved/Not used. - volatile quiddikey_test_t test; // Test register - volatile quiddikey_psr_t psr; // PUF Score register - volatile quiddikey_hw_ruc0_t hw_ruc0; // Hardware Restrict User Context 0 register - volatile quiddikey_hw_ruc1_t hw_ruc1; // Hardware Restrict User Context 1 register - volatile uint32_t reserved_7[2]; // Reserved/Not used. - volatile quiddikey_hw_settings_t hw_settings; // Hardware Settings register - volatile quiddikey_hw_info_t hw_info; // Hardware Information register - volatile quiddikey_hw_id_t hw_id; // Hardware Identifier register - volatile quiddikey_hw_ver_t hw_ver; // Hardware Version register - } __attribute__((packed)) quiddikey_struct_t; - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int zeroize :1 ; // Begin Zeroize operation - unsigned int enroll :1 ; // Begin Enroll operation - unsigned int start :1 ; // Begin Start operation - unsigned int padding0:2 ; - unsigned int stop :1 ; // Begin Stop operation - unsigned int get_key :1 ; // Begin Get Key operation - unsigned int unwrap :1 ; // Begin Unwrap operation - unsigned int wrap_generated_random:1 ; // Begin Wrap Generation Random operation - unsigned int wrap :1 ; // Begin Wrap operation - unsigned int padding1:5 ; - unsigned int generate_random :1 ; // Begin Generate Random operation - unsigned int reseed :1 ; // Begin Reseed operation - unsigned int padding2:14; - unsigned int test_puf :1 ; // Begin Test PUF operation - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_cr_t; - - typedef union { - struct { - unsigned int busy :1 ; // Operation is in progress - unsigned int ok :1 ; // Last operation was successful - unsigned int error :1 ; // Last operation failed - unsigned int zeroized :1 ; // Quiddikey is in Zeroized or in Locked state - unsigned int rejected :1 ; // Read: last command rejected, Write 1: Clear this bit - unsigned int di_request :1 ; // Request for Data in transfer via DIR register - unsigned int do_request :1 ; // Request for Data out transfer via DOR register - unsigned int padding0:22; - unsigned int reseed_warning :1 ; // Reseed warning (see ORR RESEED_WARNING) - unsigned int reseed_required :1 ; // Reseed required (see ORR RESEED_REQUIRED) - unsigned int lab_test_mode :1 ; // Quiddikey is in state Lab Test Mode - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_sr_t; - - typedef union { - struct { - unsigned int padding0:1 ; - unsigned int allow_enroll :1 ; // Operation allowed status - unsigned int allow_start :1 ; // Operation allowed status - unsigned int padding1:2 ; - unsigned int allow_stop :1 ; // Operation allowed status - unsigned int allow_get_key :1 ; // Operation allowed status - unsigned int allow_unwrap :1 ; // Operation allowed status - unsigned int allow_wrap_gen_rnd:1 ; // Operation allowed status - unsigned int allow_wrap :1 ; // Operation allowed status - unsigned int padding2:5 ; - unsigned int allow_gen_rnd :1 ; // Operation allowed status - unsigned int allow_reseed :1 ; // Operation allowed status - unsigned int padding3:14; - unsigned int allow_test_puf :1 ; // Operation allowed status - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_ar_t; - - typedef union { - struct { - unsigned int int_en :1 ; // Interrupt enable register - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_ier_t; - - typedef union { - struct { - unsigned int int_en_busy :1 ; // Enable Busy interrupt - unsigned int int_en_ok :1 ; // Enable Ok interrupt - unsigned int int_en_error :1 ; // Enable Error interrupt - unsigned int int_en_zeroized :1 ; // Enable Zeroized interrupt - unsigned int int_en_rejected :1 ; // Enable Rejected interrupt - unsigned int int_en_di_request:1 ; // Enable Data In Request interrupt - unsigned int int_en_do_request:1 ; // Enable Data Out Request interrupt - unsigned int padding0:22; - unsigned int int_en_reseed_warning:1 ; // Enable Reseed Warning interrupt - unsigned int int_en_reseed_required:1 ; // Enable Reseed Required interrupt - unsigned int int_en_lab_test_mode:1 ; // Enable Lab Test Mode interrupt - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_imr_t; - - typedef union { - struct { - unsigned int int_busy :1 ; // Busy interrupt status register - unsigned int int_ok :1 ; // Ok interrupt status register - unsigned int int_error :1 ; // Error interrupt status register - unsigned int int_zeroized :1 ; // Zeroized interrupt status register - unsigned int int_rejected :1 ; // Rejected interrupt status register - unsigned int int_di_request :1 ; // Data In Request interrupt status register - unsigned int int_do_request :1 ; // Data Out Request interrupt status register - unsigned int padding0:22; - unsigned int int_reseed_warning:1 ; // Reseed Warning interrupt status register - unsigned int int_reseed_required:1 ; // Reseed Required interrupt status register - unsigned int int_lab_test_mode:1 ; // Lab Test Mode interrupt status register - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_isr_t; - - typedef union { - struct { - unsigned int dest_dor :1 ; // Data out register destination - unsigned int dest_so :1 ; // Secure Output interface destination - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_data_dest_t; - - typedef union { - struct { - unsigned int di :32; // Data In field - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_dir_t; - - typedef union { - struct { - unsigned int dor :32; // Data Out field - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_dor_t; - - typedef union { - struct { - unsigned int endianness :32; // Set endianness - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_misc_t; - - typedef union { - struct { - unsigned int apb_error :1 ; // An APB error has occured - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_if_sr_t; - - typedef union { - struct { - unsigned int bist_enable :1 ; // Isolates Quiddikey and runs BIST - unsigned int padding0:3 ; - unsigned int bist_running :1 ; // BIST is in progress or finishing up - unsigned int bist_active :1 ; // BIST is in progress - unsigned int bist_ok :1 ; // BIST has passed - unsigned int bist_error :1 ; // BIST has failed - unsigned int padding1:23; - unsigned int allow_bist :1 ; // BIST is not allowed - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_test_t; - - typedef union { - struct { - unsigned int puf_score :4 ; // PUF Score field - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_psr_t; - - typedef union { - struct { - unsigned int restrict_user_context_0:32; // Restrict User Context 0 field - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_hw_ruc0_t; - - typedef union { - struct { - unsigned int restrict_user_context_1:32; // Restrict User Context 1 field - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_hw_ruc1_t; - - typedef union { - struct { - unsigned int padding0:1 ; - unsigned int disable_enroll :1 ; // Enroll settings field - unsigned int disable_start :1 ; // Start settings field - unsigned int padding1:2 ; - unsigned int disable_stop :1 ; // Stop settings field - unsigned int disable_get_key :1 ; // Get Key settings field - unsigned int disable_unwrap :1 ; // Unwrap settings field - unsigned int disable_wrap_gen_rnd:1 ; // Wrap Generated Random settings field - unsigned int disable_wrap :1 ; // Wrap settings field - unsigned int padding2:5 ; - unsigned int disable_gen_rnd :1 ; // Generate Random settings field - unsigned int disable_reseed :1 ; // Reseed settings field - unsigned int padding3:7 ; - unsigned int disable_lab_test_mode:1 ; // Lab Test Mode settings field - unsigned int select_lab_test_mode:1 ; // Lab Test Mode select field - unsigned int padding4:1 ; - unsigned int require_reseed_src_via_dir:1 ; // Reseed via DIR settings field - unsigned int require_reseed_src_via_si:1 ; // Reseed via SI settings field - unsigned int padding5:2 ; - unsigned int disable_test_puf:1 ; // Test PUF settings field - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_hw_settings_t; - - typedef union { - struct { - unsigned int padding0:21; - unsigned int config_sp_800_90:1 ; // 1: SP 800-90 is included, 0: not included - unsigned int config_bist :1 ; // 1: BIST is included, 0: not included - unsigned int reserved :1 ; // 1: Safe, 0: Plus - unsigned int config_wrap :1 ; // 1: Wrap is included, 0: not included - unsigned int padding1:3 ; - unsigned int config_type :4 ; // Quiddikey configuration - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_hw_info_t; - - typedef union { - struct { - unsigned int hw_id :32; // Hardware Identifier - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_hw_id_t; - - typedef union { - struct { - unsigned int hw_ver_rev :8 ; // Hardware version, revision part - unsigned int hw_ver_minor :8 ; // Hardware version, minor part - unsigned int hw_ver_major :8 ; // Hardware version, major part - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_hw_ver_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_regmap_quiddikey : public vp::regmap - { - public: - vp_quiddikey_cr cr; - vp_quiddikey_sr sr; - vp_quiddikey_ar ar; - vp_quiddikey_ier ier; - vp_quiddikey_imr imr; - vp_quiddikey_isr isr; - vp_quiddikey_data_dest data_dest; - vp_quiddikey_dir dir; - vp_quiddikey_dor dor; - vp_quiddikey_misc misc; - vp_quiddikey_if_sr if_sr; - vp_quiddikey_test test; - vp_quiddikey_psr psr; - vp_quiddikey_hw_ruc0 hw_ruc0; - vp_quiddikey_hw_ruc1 hw_ruc1; - vp_quiddikey_hw_settings hw_settings; - vp_quiddikey_hw_info hw_info; - vp_quiddikey_hw_id hw_id; - vp_quiddikey_hw_ver hw_ver; - }; - -| - -.. _quiddikey_CR: +.. table:: + :align: center + :widths: 40 12 12 90 + + +------------------------------------------+------+-----+-----------------------------------------+ + | Name |Offset|Width| Description | + +==========================================+======+=====+=========================================+ + |:ref:`CR` | 0| 32|Control register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`SR` | 8| 32|Status register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`AR` | 12| 32|Allow register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`IER` | 16| 32|Interrupt Enable register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`IMR` | 20| 32|Interrupt Mask register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`ISR` | 24| 32|Interrupt Status register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`DATA_DEST` | 32| 32|Destination Data register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`DIR` | 160| 32|Data Input register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`DOR` | 168| 32|Data Output register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`MISC` | 192| 32|Miscellaneous register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`IF_SR` | 208| 32|Interface Status register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`TEST` | 216| 32|Test register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`PSR` | 220| 32|PUF Score register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`HW_RUC0` | 224| 32|Hardware Restrict User Context 0 register| + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`HW_RUC1` | 228| 32|Hardware Restrict User Context 1 register| + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`HW_SETTINGS`| 240| 32|Hardware Settings register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`HW_INFO` | 244| 32|Hardware Information register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`HW_ID` | 248| 32|Hardware Identifier register | + +------------------------------------------+------+-----+-----------------------------------------+ + |:ref:`HW_VER` | 252| 32|Hardware Version register | + +------------------------------------------+------+-----+-----------------------------------------+ + +.. _quiddikey__CR: CR "" @@ -1519,250 +65,36 @@ CR Control register .. table:: - - +-----+---+---------------------+--------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+======================================+ - | 0|R/W|ZEROIZE |Begin Zeroize operation | - +-----+---+---------------------+--------------------------------------+ - | 1|R/W|ENROLL |Begin Enroll operation | - +-----+---+---------------------+--------------------------------------+ - | 2|R/W|START |Begin Start operation | - +-----+---+---------------------+--------------------------------------+ - | 5|R/W|STOP |Begin Stop operation | - +-----+---+---------------------+--------------------------------------+ - | 6|R/W|GET_KEY |Begin Get Key operation | - +-----+---+---------------------+--------------------------------------+ - | 7|R/W|UNWRAP |Begin Unwrap operation | - +-----+---+---------------------+--------------------------------------+ - | 8|R/W|WRAP_GENERATED_RANDOM|Begin Wrap Generation Random operation| - +-----+---+---------------------+--------------------------------------+ - | 9|R/W|WRAP |Begin Wrap operation | - +-----+---+---------------------+--------------------------------------+ - | 15|R/W|GENERATE_RANDOM |Begin Generate Random operation | - +-----+---+---------------------+--------------------------------------+ - | 16|R/W|RESEED |Begin Reseed operation | - +-----+---+---------------------+--------------------------------------+ - | 31|R/W|TEST_PUF |Begin Test PUF operation | - +-----+---+---------------------+--------------------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Control register - #define QUIDDIKEY_CR_OFFSET 0x0 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_cr_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_cr_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Begin Zeroize operation (access: R/W) - #define QUIDDIKEY_CR_ZEROIZE_BIT 0 - #define QUIDDIKEY_CR_ZEROIZE_WIDTH 1 - #define QUIDDIKEY_CR_ZEROIZE_MASK 0x1 - #define QUIDDIKEY_CR_ZEROIZE_RESET 0x0 - - // Begin Enroll operation (access: R/W) - #define QUIDDIKEY_CR_ENROLL_BIT 1 - #define QUIDDIKEY_CR_ENROLL_WIDTH 1 - #define QUIDDIKEY_CR_ENROLL_MASK 0x2 - #define QUIDDIKEY_CR_ENROLL_RESET 0x0 - - // Begin Start operation (access: R/W) - #define QUIDDIKEY_CR_START_BIT 2 - #define QUIDDIKEY_CR_START_WIDTH 1 - #define QUIDDIKEY_CR_START_MASK 0x4 - #define QUIDDIKEY_CR_START_RESET 0x0 - - // Begin Stop operation (access: R/W) - #define QUIDDIKEY_CR_STOP_BIT 5 - #define QUIDDIKEY_CR_STOP_WIDTH 1 - #define QUIDDIKEY_CR_STOP_MASK 0x20 - #define QUIDDIKEY_CR_STOP_RESET 0x0 - - // Begin Get Key operation (access: R/W) - #define QUIDDIKEY_CR_GET_KEY_BIT 6 - #define QUIDDIKEY_CR_GET_KEY_WIDTH 1 - #define QUIDDIKEY_CR_GET_KEY_MASK 0x40 - #define QUIDDIKEY_CR_GET_KEY_RESET 0x0 - - // Begin Unwrap operation (access: R/W) - #define QUIDDIKEY_CR_UNWRAP_BIT 7 - #define QUIDDIKEY_CR_UNWRAP_WIDTH 1 - #define QUIDDIKEY_CR_UNWRAP_MASK 0x80 - #define QUIDDIKEY_CR_UNWRAP_RESET 0x0 - - // Begin Wrap Generation Random operation (access: R/W) - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM_BIT 8 - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM_WIDTH 1 - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM_MASK 0x100 - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM_RESET 0x0 - - // Begin Wrap operation (access: R/W) - #define QUIDDIKEY_CR_WRAP_BIT 9 - #define QUIDDIKEY_CR_WRAP_WIDTH 1 - #define QUIDDIKEY_CR_WRAP_MASK 0x200 - #define QUIDDIKEY_CR_WRAP_RESET 0x0 - - // Begin Generate Random operation (access: R/W) - #define QUIDDIKEY_CR_GENERATE_RANDOM_BIT 15 - #define QUIDDIKEY_CR_GENERATE_RANDOM_WIDTH 1 - #define QUIDDIKEY_CR_GENERATE_RANDOM_MASK 0x8000 - #define QUIDDIKEY_CR_GENERATE_RANDOM_RESET 0x0 - - // Begin Reseed operation (access: R/W) - #define QUIDDIKEY_CR_RESEED_BIT 16 - #define QUIDDIKEY_CR_RESEED_WIDTH 1 - #define QUIDDIKEY_CR_RESEED_MASK 0x10000 - #define QUIDDIKEY_CR_RESEED_RESET 0x0 - - // Begin Test PUF operation (access: R/W) - #define QUIDDIKEY_CR_TEST_PUF_BIT 31 - #define QUIDDIKEY_CR_TEST_PUF_WIDTH 1 - #define QUIDDIKEY_CR_TEST_PUF_MASK 0x80000000 - #define QUIDDIKEY_CR_TEST_PUF_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_CR_ZEROIZE_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_CR_ZEROIZE_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_CR_ZEROIZE_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_CR_ZEROIZE(val) ((val) << 0) - - #define QUIDDIKEY_CR_ENROLL_GET(value) (GAP_BEXTRACTU((value),1,1)) - #define QUIDDIKEY_CR_ENROLL_GETS(value) (GAP_BEXTRACT((value),1,1)) - #define QUIDDIKEY_CR_ENROLL_SET(value,field) (GAP_BINSERT((value),(field),1,1)) - #define QUIDDIKEY_CR_ENROLL(val) ((val) << 1) - - #define QUIDDIKEY_CR_START_GET(value) (GAP_BEXTRACTU((value),1,2)) - #define QUIDDIKEY_CR_START_GETS(value) (GAP_BEXTRACT((value),1,2)) - #define QUIDDIKEY_CR_START_SET(value,field) (GAP_BINSERT((value),(field),1,2)) - #define QUIDDIKEY_CR_START(val) ((val) << 2) - - #define QUIDDIKEY_CR_STOP_GET(value) (GAP_BEXTRACTU((value),1,5)) - #define QUIDDIKEY_CR_STOP_GETS(value) (GAP_BEXTRACT((value),1,5)) - #define QUIDDIKEY_CR_STOP_SET(value,field) (GAP_BINSERT((value),(field),1,5)) - #define QUIDDIKEY_CR_STOP(val) ((val) << 5) - - #define QUIDDIKEY_CR_GET_KEY_GET(value) (GAP_BEXTRACTU((value),1,6)) - #define QUIDDIKEY_CR_GET_KEY_GETS(value) (GAP_BEXTRACT((value),1,6)) - #define QUIDDIKEY_CR_GET_KEY_SET(value,field) (GAP_BINSERT((value),(field),1,6)) - #define QUIDDIKEY_CR_GET_KEY(val) ((val) << 6) - - #define QUIDDIKEY_CR_UNWRAP_GET(value) (GAP_BEXTRACTU((value),1,7)) - #define QUIDDIKEY_CR_UNWRAP_GETS(value) (GAP_BEXTRACT((value),1,7)) - #define QUIDDIKEY_CR_UNWRAP_SET(value,field) (GAP_BINSERT((value),(field),1,7)) - #define QUIDDIKEY_CR_UNWRAP(val) ((val) << 7) - - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM_GET(value) (GAP_BEXTRACTU((value),1,8)) - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM_GETS(value) (GAP_BEXTRACT((value),1,8)) - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM_SET(value,field) (GAP_BINSERT((value),(field),1,8)) - #define QUIDDIKEY_CR_WRAP_GENERATED_RANDOM(val) ((val) << 8) - - #define QUIDDIKEY_CR_WRAP_GET(value) (GAP_BEXTRACTU((value),1,9)) - #define QUIDDIKEY_CR_WRAP_GETS(value) (GAP_BEXTRACT((value),1,9)) - #define QUIDDIKEY_CR_WRAP_SET(value,field) (GAP_BINSERT((value),(field),1,9)) - #define QUIDDIKEY_CR_WRAP(val) ((val) << 9) - - #define QUIDDIKEY_CR_GENERATE_RANDOM_GET(value) (GAP_BEXTRACTU((value),1,15)) - #define QUIDDIKEY_CR_GENERATE_RANDOM_GETS(value) (GAP_BEXTRACT((value),1,15)) - #define QUIDDIKEY_CR_GENERATE_RANDOM_SET(value,field) (GAP_BINSERT((value),(field),1,15)) - #define QUIDDIKEY_CR_GENERATE_RANDOM(val) ((val) << 15) - - #define QUIDDIKEY_CR_RESEED_GET(value) (GAP_BEXTRACTU((value),1,16)) - #define QUIDDIKEY_CR_RESEED_GETS(value) (GAP_BEXTRACT((value),1,16)) - #define QUIDDIKEY_CR_RESEED_SET(value,field) (GAP_BINSERT((value),(field),1,16)) - #define QUIDDIKEY_CR_RESEED(val) ((val) << 16) - - #define QUIDDIKEY_CR_TEST_PUF_GET(value) (GAP_BEXTRACTU((value),1,31)) - #define QUIDDIKEY_CR_TEST_PUF_GETS(value) (GAP_BEXTRACT((value),1,31)) - #define QUIDDIKEY_CR_TEST_PUF_SET(value,field) (GAP_BINSERT((value),(field),1,31)) - #define QUIDDIKEY_CR_TEST_PUF(val) ((val) << 31) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int zeroize :1 ; // Begin Zeroize operation - unsigned int enroll :1 ; // Begin Enroll operation - unsigned int start :1 ; // Begin Start operation - unsigned int padding0:2 ; - unsigned int stop :1 ; // Begin Stop operation - unsigned int get_key :1 ; // Begin Get Key operation - unsigned int unwrap :1 ; // Begin Unwrap operation - unsigned int wrap_generated_random:1 ; // Begin Wrap Generation Random operation - unsigned int wrap :1 ; // Begin Wrap operation - unsigned int padding1:5 ; - unsigned int generate_random :1 ; // Begin Generate Random operation - unsigned int reseed :1 ; // Begin Reseed operation - unsigned int padding2:14; - unsigned int test_puf :1 ; // Begin Test PUF operation - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_cr_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_cr : public vp::reg_32 - { - public: - inline void zeroize_set(uint32_t value); - inline uint32_t zeroize_get(); - inline void enroll_set(uint32_t value); - inline uint32_t enroll_get(); - inline void start_set(uint32_t value); - inline uint32_t start_get(); - inline void stop_set(uint32_t value); - inline uint32_t stop_get(); - inline void get_key_set(uint32_t value); - inline uint32_t get_key_get(); - inline void unwrap_set(uint32_t value); - inline uint32_t unwrap_get(); - inline void wrap_generated_random_set(uint32_t value); - inline uint32_t wrap_generated_random_get(); - inline void wrap_set(uint32_t value); - inline uint32_t wrap_get(); - inline void generate_random_set(uint32_t value); - inline uint32_t generate_random_get(); - inline void reseed_set(uint32_t value); - inline uint32_t reseed_get(); - inline void test_puf_set(uint32_t value); - inline uint32_t test_puf_get(); - }; - -| - -.. _quiddikey_SR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------------+-----+--------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+======================================+ + | 0|R/W|ZEROIZE |0x00 |Begin Zeroize operation | + +-----+---+---------------------+-----+--------------------------------------+ + | 1|R/W|ENROLL |0x00 |Begin Enroll operation | + +-----+---+---------------------+-----+--------------------------------------+ + | 2|R/W|START |0x00 |Begin Start operation | + +-----+---+---------------------+-----+--------------------------------------+ + | 5|R/W|STOP |0x00 |Begin Stop operation | + +-----+---+---------------------+-----+--------------------------------------+ + | 6|R/W|GET_KEY |0x00 |Begin Get Key operation | + +-----+---+---------------------+-----+--------------------------------------+ + | 7|R/W|UNWRAP |0x00 |Begin Unwrap operation | + +-----+---+---------------------+-----+--------------------------------------+ + | 8|R/W|WRAP_GENERATED_RANDOM|0x00 |Begin Wrap Generation Random operation| + +-----+---+---------------------+-----+--------------------------------------+ + | 9|R/W|WRAP |0x00 |Begin Wrap operation | + +-----+---+---------------------+-----+--------------------------------------+ + | 15|R/W|GENERATE_RANDOM |0x00 |Begin Generate Random operation | + +-----+---+---------------------+-----+--------------------------------------+ + | 16|R/W|RESEED |0x00 |Begin Reseed operation | + +-----+---+---------------------+-----+--------------------------------------+ + | 31|R/W|TEST_PUF |0x00 |Begin Test PUF operation | + +-----+---+---------------------+-----+--------------------------------------+ + +.. _quiddikey__SR: SR "" @@ -1770,232 +102,34 @@ SR Status register .. table:: - - +-----+---+---------------+----------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+====================================================+ - | 0|R/W|BUSY |Operation is in progress | - +-----+---+---------------+----------------------------------------------------+ - | 1|R/W|OK |Last operation was successful | - +-----+---+---------------+----------------------------------------------------+ - | 2|R/W|ERROR |Last operation failed | - +-----+---+---------------+----------------------------------------------------+ - | 3|R/W|ZEROIZED |Quiddikey is in Zeroized or in Locked state | - +-----+---+---------------+----------------------------------------------------+ - | 4|R/W|REJECTED |Read: last command rejected, Write 1: Clear this bit| - +-----+---+---------------+----------------------------------------------------+ - | 5|R/W|DI_REQUEST |Request for Data in transfer via DIR register | - +-----+---+---------------+----------------------------------------------------+ - | 6|R/W|DO_REQUEST |Request for Data out transfer via DOR register | - +-----+---+---------------+----------------------------------------------------+ - | 29|R/W|RESEED_WARNING |Reseed warning (see ORR RESEED_WARNING) | - +-----+---+---------------+----------------------------------------------------+ - | 30|R/W|RESEED_REQUIRED|Reseed required (see ORR RESEED_REQUIRED) | - +-----+---+---------------+----------------------------------------------------+ - | 31|R/W|LAB_TEST_MODE |Quiddikey is in state Lab Test Mode | - +-----+---+---------------+----------------------------------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Status register - #define QUIDDIKEY_SR_OFFSET 0x8 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_sr_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_sr_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Operation is in progress (access: R/W) - #define QUIDDIKEY_SR_BUSY_BIT 0 - #define QUIDDIKEY_SR_BUSY_WIDTH 1 - #define QUIDDIKEY_SR_BUSY_MASK 0x1 - #define QUIDDIKEY_SR_BUSY_RESET 0x0 - - // Last operation was successful (access: R/W) - #define QUIDDIKEY_SR_OK_BIT 1 - #define QUIDDIKEY_SR_OK_WIDTH 1 - #define QUIDDIKEY_SR_OK_MASK 0x2 - #define QUIDDIKEY_SR_OK_RESET 0x0 - - // Last operation failed (access: R/W) - #define QUIDDIKEY_SR_ERROR_BIT 2 - #define QUIDDIKEY_SR_ERROR_WIDTH 1 - #define QUIDDIKEY_SR_ERROR_MASK 0x4 - #define QUIDDIKEY_SR_ERROR_RESET 0x0 - - // Quiddikey is in Zeroized or in Locked state (access: R/W) - #define QUIDDIKEY_SR_ZEROIZED_BIT 3 - #define QUIDDIKEY_SR_ZEROIZED_WIDTH 1 - #define QUIDDIKEY_SR_ZEROIZED_MASK 0x8 - #define QUIDDIKEY_SR_ZEROIZED_RESET 0x0 - - // Read: last command rejected, Write 1: Clear this bit (access: R/W) - #define QUIDDIKEY_SR_REJECTED_BIT 4 - #define QUIDDIKEY_SR_REJECTED_WIDTH 1 - #define QUIDDIKEY_SR_REJECTED_MASK 0x10 - #define QUIDDIKEY_SR_REJECTED_RESET 0x0 - - // Request for Data in transfer via DIR register (access: R/W) - #define QUIDDIKEY_SR_DI_REQUEST_BIT 5 - #define QUIDDIKEY_SR_DI_REQUEST_WIDTH 1 - #define QUIDDIKEY_SR_DI_REQUEST_MASK 0x20 - #define QUIDDIKEY_SR_DI_REQUEST_RESET 0x0 - - // Request for Data out transfer via DOR register (access: R/W) - #define QUIDDIKEY_SR_DO_REQUEST_BIT 6 - #define QUIDDIKEY_SR_DO_REQUEST_WIDTH 1 - #define QUIDDIKEY_SR_DO_REQUEST_MASK 0x40 - #define QUIDDIKEY_SR_DO_REQUEST_RESET 0x0 - - // Reseed warning (see ORR RESEED_WARNING) (access: R/W) - #define QUIDDIKEY_SR_RESEED_WARNING_BIT 29 - #define QUIDDIKEY_SR_RESEED_WARNING_WIDTH 1 - #define QUIDDIKEY_SR_RESEED_WARNING_MASK 0x20000000 - #define QUIDDIKEY_SR_RESEED_WARNING_RESET 0x0 - - // Reseed required (see ORR RESEED_REQUIRED) (access: R/W) - #define QUIDDIKEY_SR_RESEED_REQUIRED_BIT 30 - #define QUIDDIKEY_SR_RESEED_REQUIRED_WIDTH 1 - #define QUIDDIKEY_SR_RESEED_REQUIRED_MASK 0x40000000 - #define QUIDDIKEY_SR_RESEED_REQUIRED_RESET 0x0 - - // Quiddikey is in state Lab Test Mode (access: R/W) - #define QUIDDIKEY_SR_LAB_TEST_MODE_BIT 31 - #define QUIDDIKEY_SR_LAB_TEST_MODE_WIDTH 1 - #define QUIDDIKEY_SR_LAB_TEST_MODE_MASK 0x80000000 - #define QUIDDIKEY_SR_LAB_TEST_MODE_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_SR_BUSY_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_SR_BUSY_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_SR_BUSY_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_SR_BUSY(val) ((val) << 0) - - #define QUIDDIKEY_SR_OK_GET(value) (GAP_BEXTRACTU((value),1,1)) - #define QUIDDIKEY_SR_OK_GETS(value) (GAP_BEXTRACT((value),1,1)) - #define QUIDDIKEY_SR_OK_SET(value,field) (GAP_BINSERT((value),(field),1,1)) - #define QUIDDIKEY_SR_OK(val) ((val) << 1) - - #define QUIDDIKEY_SR_ERROR_GET(value) (GAP_BEXTRACTU((value),1,2)) - #define QUIDDIKEY_SR_ERROR_GETS(value) (GAP_BEXTRACT((value),1,2)) - #define QUIDDIKEY_SR_ERROR_SET(value,field) (GAP_BINSERT((value),(field),1,2)) - #define QUIDDIKEY_SR_ERROR(val) ((val) << 2) - - #define QUIDDIKEY_SR_ZEROIZED_GET(value) (GAP_BEXTRACTU((value),1,3)) - #define QUIDDIKEY_SR_ZEROIZED_GETS(value) (GAP_BEXTRACT((value),1,3)) - #define QUIDDIKEY_SR_ZEROIZED_SET(value,field) (GAP_BINSERT((value),(field),1,3)) - #define QUIDDIKEY_SR_ZEROIZED(val) ((val) << 3) - - #define QUIDDIKEY_SR_REJECTED_GET(value) (GAP_BEXTRACTU((value),1,4)) - #define QUIDDIKEY_SR_REJECTED_GETS(value) (GAP_BEXTRACT((value),1,4)) - #define QUIDDIKEY_SR_REJECTED_SET(value,field) (GAP_BINSERT((value),(field),1,4)) - #define QUIDDIKEY_SR_REJECTED(val) ((val) << 4) - - #define QUIDDIKEY_SR_DI_REQUEST_GET(value) (GAP_BEXTRACTU((value),1,5)) - #define QUIDDIKEY_SR_DI_REQUEST_GETS(value) (GAP_BEXTRACT((value),1,5)) - #define QUIDDIKEY_SR_DI_REQUEST_SET(value,field) (GAP_BINSERT((value),(field),1,5)) - #define QUIDDIKEY_SR_DI_REQUEST(val) ((val) << 5) - - #define QUIDDIKEY_SR_DO_REQUEST_GET(value) (GAP_BEXTRACTU((value),1,6)) - #define QUIDDIKEY_SR_DO_REQUEST_GETS(value) (GAP_BEXTRACT((value),1,6)) - #define QUIDDIKEY_SR_DO_REQUEST_SET(value,field) (GAP_BINSERT((value),(field),1,6)) - #define QUIDDIKEY_SR_DO_REQUEST(val) ((val) << 6) - - #define QUIDDIKEY_SR_RESEED_WARNING_GET(value) (GAP_BEXTRACTU((value),1,29)) - #define QUIDDIKEY_SR_RESEED_WARNING_GETS(value) (GAP_BEXTRACT((value),1,29)) - #define QUIDDIKEY_SR_RESEED_WARNING_SET(value,field) (GAP_BINSERT((value),(field),1,29)) - #define QUIDDIKEY_SR_RESEED_WARNING(val) ((val) << 29) - - #define QUIDDIKEY_SR_RESEED_REQUIRED_GET(value) (GAP_BEXTRACTU((value),1,30)) - #define QUIDDIKEY_SR_RESEED_REQUIRED_GETS(value) (GAP_BEXTRACT((value),1,30)) - #define QUIDDIKEY_SR_RESEED_REQUIRED_SET(value,field) (GAP_BINSERT((value),(field),1,30)) - #define QUIDDIKEY_SR_RESEED_REQUIRED(val) ((val) << 30) - - #define QUIDDIKEY_SR_LAB_TEST_MODE_GET(value) (GAP_BEXTRACTU((value),1,31)) - #define QUIDDIKEY_SR_LAB_TEST_MODE_GETS(value) (GAP_BEXTRACT((value),1,31)) - #define QUIDDIKEY_SR_LAB_TEST_MODE_SET(value,field) (GAP_BINSERT((value),(field),1,31)) - #define QUIDDIKEY_SR_LAB_TEST_MODE(val) ((val) << 31) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int busy :1 ; // Operation is in progress - unsigned int ok :1 ; // Last operation was successful - unsigned int error :1 ; // Last operation failed - unsigned int zeroized :1 ; // Quiddikey is in Zeroized or in Locked state - unsigned int rejected :1 ; // Read: last command rejected, Write 1: Clear this bit - unsigned int di_request :1 ; // Request for Data in transfer via DIR register - unsigned int do_request :1 ; // Request for Data out transfer via DOR register - unsigned int padding0:22; - unsigned int reseed_warning :1 ; // Reseed warning (see ORR RESEED_WARNING) - unsigned int reseed_required :1 ; // Reseed required (see ORR RESEED_REQUIRED) - unsigned int lab_test_mode :1 ; // Quiddikey is in state Lab Test Mode - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_sr_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_sr : public vp::reg_32 - { - public: - inline void busy_set(uint32_t value); - inline uint32_t busy_get(); - inline void ok_set(uint32_t value); - inline uint32_t ok_get(); - inline void error_set(uint32_t value); - inline uint32_t error_get(); - inline void zeroized_set(uint32_t value); - inline uint32_t zeroized_get(); - inline void rejected_set(uint32_t value); - inline uint32_t rejected_get(); - inline void di_request_set(uint32_t value); - inline uint32_t di_request_get(); - inline void do_request_set(uint32_t value); - inline uint32_t do_request_get(); - inline void reseed_warning_set(uint32_t value); - inline uint32_t reseed_warning_get(); - inline void reseed_required_set(uint32_t value); - inline uint32_t reseed_required_get(); - inline void lab_test_mode_set(uint32_t value); - inline uint32_t lab_test_mode_get(); - }; - -| - -.. _quiddikey_AR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+----------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+====================================================+ + | 0|R/W|BUSY |0x00 |Operation is in progress | + +-----+---+---------------+-----+----------------------------------------------------+ + | 1|R/W|OK |0x00 |Last operation was successful | + +-----+---+---------------+-----+----------------------------------------------------+ + | 2|R/W|ERROR |0x00 |Last operation failed | + +-----+---+---------------+-----+----------------------------------------------------+ + | 3|R/W|ZEROIZED |0x00 |Quiddikey is in Zeroized or in Locked state | + +-----+---+---------------+-----+----------------------------------------------------+ + | 4|R/W|REJECTED |0x00 |Read: last command rejected, Write 1: Clear this bit| + +-----+---+---------------+-----+----------------------------------------------------+ + | 5|R/W|DI_REQUEST |0x00 |Request for Data in transfer via DIR register | + +-----+---+---------------+-----+----------------------------------------------------+ + | 6|R/W|DO_REQUEST |0x00 |Request for Data out transfer via DOR register | + +-----+---+---------------+-----+----------------------------------------------------+ + | 29|R/W|RESEED_WARNING |0x00 |Reseed warning (see ORR RESEED_WARNING) | + +-----+---+---------------+-----+----------------------------------------------------+ + | 30|R/W|RESEED_REQUIRED|0x00 |Reseed required (see ORR RESEED_REQUIRED) | + +-----+---+---------------+-----+----------------------------------------------------+ + | 31|R/W|LAB_TEST_MODE |0x00 |Quiddikey is in state Lab Test Mode | + +-----+---+---------------+-----+----------------------------------------------------+ + +.. _quiddikey__AR: AR "" @@ -2003,235 +137,34 @@ AR Allow register .. table:: - - +-----+---+------------------+------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================+ - | 1|R/W|ALLOW_ENROLL |Operation allowed status| - +-----+---+------------------+------------------------+ - | 2|R/W|ALLOW_START |Operation allowed status| - +-----+---+------------------+------------------------+ - | 5|R/W|ALLOW_STOP |Operation allowed status| - +-----+---+------------------+------------------------+ - | 6|R/W|ALLOW_GET_KEY |Operation allowed status| - +-----+---+------------------+------------------------+ - | 7|R/W|ALLOW_UNWRAP |Operation allowed status| - +-----+---+------------------+------------------------+ - | 8|R/W|ALLOW_WRAP_GEN_RND|Operation allowed status| - +-----+---+------------------+------------------------+ - | 9|R/W|ALLOW_WRAP |Operation allowed status| - +-----+---+------------------+------------------------+ - | 15|R/W|ALLOW_GEN_RND |Operation allowed status| - +-----+---+------------------+------------------------+ - | 16|R/W|ALLOW_RESEED |Operation allowed status| - +-----+---+------------------+------------------------+ - | 31|R/W|ALLOW_TEST_PUF |Operation allowed status| - +-----+---+------------------+------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Allow register - #define QUIDDIKEY_AR_OFFSET 0xc - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_ar_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_ar_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_ENROLL_BIT 1 - #define QUIDDIKEY_AR_ALLOW_ENROLL_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_ENROLL_MASK 0x2 - #define QUIDDIKEY_AR_ALLOW_ENROLL_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_START_BIT 2 - #define QUIDDIKEY_AR_ALLOW_START_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_START_MASK 0x4 - #define QUIDDIKEY_AR_ALLOW_START_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_STOP_BIT 5 - #define QUIDDIKEY_AR_ALLOW_STOP_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_STOP_MASK 0x20 - #define QUIDDIKEY_AR_ALLOW_STOP_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_GET_KEY_BIT 6 - #define QUIDDIKEY_AR_ALLOW_GET_KEY_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_GET_KEY_MASK 0x40 - #define QUIDDIKEY_AR_ALLOW_GET_KEY_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_UNWRAP_BIT 7 - #define QUIDDIKEY_AR_ALLOW_UNWRAP_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_UNWRAP_MASK 0x80 - #define QUIDDIKEY_AR_ALLOW_UNWRAP_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND_BIT 8 - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND_MASK 0x100 - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_WRAP_BIT 9 - #define QUIDDIKEY_AR_ALLOW_WRAP_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_WRAP_MASK 0x200 - #define QUIDDIKEY_AR_ALLOW_WRAP_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_GEN_RND_BIT 15 - #define QUIDDIKEY_AR_ALLOW_GEN_RND_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_GEN_RND_MASK 0x8000 - #define QUIDDIKEY_AR_ALLOW_GEN_RND_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_RESEED_BIT 16 - #define QUIDDIKEY_AR_ALLOW_RESEED_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_RESEED_MASK 0x10000 - #define QUIDDIKEY_AR_ALLOW_RESEED_RESET 0x0 - - // Operation allowed status (access: R/W) - #define QUIDDIKEY_AR_ALLOW_TEST_PUF_BIT 31 - #define QUIDDIKEY_AR_ALLOW_TEST_PUF_WIDTH 1 - #define QUIDDIKEY_AR_ALLOW_TEST_PUF_MASK 0x80000000 - #define QUIDDIKEY_AR_ALLOW_TEST_PUF_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_AR_ALLOW_ENROLL_GET(value) (GAP_BEXTRACTU((value),1,1)) - #define QUIDDIKEY_AR_ALLOW_ENROLL_GETS(value) (GAP_BEXTRACT((value),1,1)) - #define QUIDDIKEY_AR_ALLOW_ENROLL_SET(value,field) (GAP_BINSERT((value),(field),1,1)) - #define QUIDDIKEY_AR_ALLOW_ENROLL(val) ((val) << 1) - - #define QUIDDIKEY_AR_ALLOW_START_GET(value) (GAP_BEXTRACTU((value),1,2)) - #define QUIDDIKEY_AR_ALLOW_START_GETS(value) (GAP_BEXTRACT((value),1,2)) - #define QUIDDIKEY_AR_ALLOW_START_SET(value,field) (GAP_BINSERT((value),(field),1,2)) - #define QUIDDIKEY_AR_ALLOW_START(val) ((val) << 2) - - #define QUIDDIKEY_AR_ALLOW_STOP_GET(value) (GAP_BEXTRACTU((value),1,5)) - #define QUIDDIKEY_AR_ALLOW_STOP_GETS(value) (GAP_BEXTRACT((value),1,5)) - #define QUIDDIKEY_AR_ALLOW_STOP_SET(value,field) (GAP_BINSERT((value),(field),1,5)) - #define QUIDDIKEY_AR_ALLOW_STOP(val) ((val) << 5) - - #define QUIDDIKEY_AR_ALLOW_GET_KEY_GET(value) (GAP_BEXTRACTU((value),1,6)) - #define QUIDDIKEY_AR_ALLOW_GET_KEY_GETS(value) (GAP_BEXTRACT((value),1,6)) - #define QUIDDIKEY_AR_ALLOW_GET_KEY_SET(value,field) (GAP_BINSERT((value),(field),1,6)) - #define QUIDDIKEY_AR_ALLOW_GET_KEY(val) ((val) << 6) - - #define QUIDDIKEY_AR_ALLOW_UNWRAP_GET(value) (GAP_BEXTRACTU((value),1,7)) - #define QUIDDIKEY_AR_ALLOW_UNWRAP_GETS(value) (GAP_BEXTRACT((value),1,7)) - #define QUIDDIKEY_AR_ALLOW_UNWRAP_SET(value,field) (GAP_BINSERT((value),(field),1,7)) - #define QUIDDIKEY_AR_ALLOW_UNWRAP(val) ((val) << 7) - - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND_GET(value) (GAP_BEXTRACTU((value),1,8)) - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND_GETS(value) (GAP_BEXTRACT((value),1,8)) - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND_SET(value,field) (GAP_BINSERT((value),(field),1,8)) - #define QUIDDIKEY_AR_ALLOW_WRAP_GEN_RND(val) ((val) << 8) - - #define QUIDDIKEY_AR_ALLOW_WRAP_GET(value) (GAP_BEXTRACTU((value),1,9)) - #define QUIDDIKEY_AR_ALLOW_WRAP_GETS(value) (GAP_BEXTRACT((value),1,9)) - #define QUIDDIKEY_AR_ALLOW_WRAP_SET(value,field) (GAP_BINSERT((value),(field),1,9)) - #define QUIDDIKEY_AR_ALLOW_WRAP(val) ((val) << 9) - - #define QUIDDIKEY_AR_ALLOW_GEN_RND_GET(value) (GAP_BEXTRACTU((value),1,15)) - #define QUIDDIKEY_AR_ALLOW_GEN_RND_GETS(value) (GAP_BEXTRACT((value),1,15)) - #define QUIDDIKEY_AR_ALLOW_GEN_RND_SET(value,field) (GAP_BINSERT((value),(field),1,15)) - #define QUIDDIKEY_AR_ALLOW_GEN_RND(val) ((val) << 15) - - #define QUIDDIKEY_AR_ALLOW_RESEED_GET(value) (GAP_BEXTRACTU((value),1,16)) - #define QUIDDIKEY_AR_ALLOW_RESEED_GETS(value) (GAP_BEXTRACT((value),1,16)) - #define QUIDDIKEY_AR_ALLOW_RESEED_SET(value,field) (GAP_BINSERT((value),(field),1,16)) - #define QUIDDIKEY_AR_ALLOW_RESEED(val) ((val) << 16) - - #define QUIDDIKEY_AR_ALLOW_TEST_PUF_GET(value) (GAP_BEXTRACTU((value),1,31)) - #define QUIDDIKEY_AR_ALLOW_TEST_PUF_GETS(value) (GAP_BEXTRACT((value),1,31)) - #define QUIDDIKEY_AR_ALLOW_TEST_PUF_SET(value,field) (GAP_BINSERT((value),(field),1,31)) - #define QUIDDIKEY_AR_ALLOW_TEST_PUF(val) ((val) << 31) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int padding0:1 ; - unsigned int allow_enroll :1 ; // Operation allowed status - unsigned int allow_start :1 ; // Operation allowed status - unsigned int padding1:2 ; - unsigned int allow_stop :1 ; // Operation allowed status - unsigned int allow_get_key :1 ; // Operation allowed status - unsigned int allow_unwrap :1 ; // Operation allowed status - unsigned int allow_wrap_gen_rnd:1 ; // Operation allowed status - unsigned int allow_wrap :1 ; // Operation allowed status - unsigned int padding2:5 ; - unsigned int allow_gen_rnd :1 ; // Operation allowed status - unsigned int allow_reseed :1 ; // Operation allowed status - unsigned int padding3:14; - unsigned int allow_test_puf :1 ; // Operation allowed status - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_ar_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_ar : public vp::reg_32 - { - public: - inline void allow_enroll_set(uint32_t value); - inline uint32_t allow_enroll_get(); - inline void allow_start_set(uint32_t value); - inline uint32_t allow_start_get(); - inline void allow_stop_set(uint32_t value); - inline uint32_t allow_stop_get(); - inline void allow_get_key_set(uint32_t value); - inline uint32_t allow_get_key_get(); - inline void allow_unwrap_set(uint32_t value); - inline uint32_t allow_unwrap_get(); - inline void allow_wrap_gen_rnd_set(uint32_t value); - inline uint32_t allow_wrap_gen_rnd_get(); - inline void allow_wrap_set(uint32_t value); - inline uint32_t allow_wrap_get(); - inline void allow_gen_rnd_set(uint32_t value); - inline uint32_t allow_gen_rnd_get(); - inline void allow_reseed_set(uint32_t value); - inline uint32_t allow_reseed_get(); - inline void allow_test_puf_set(uint32_t value); - inline uint32_t allow_test_puf_get(); - }; - -| - -.. _quiddikey_IER: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------------+-----+------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+========================+ + | 1|R/W|ALLOW_ENROLL |0x00 |Operation allowed status| + +-----+---+------------------+-----+------------------------+ + | 2|R/W|ALLOW_START |0x00 |Operation allowed status| + +-----+---+------------------+-----+------------------------+ + | 5|R/W|ALLOW_STOP |0x00 |Operation allowed status| + +-----+---+------------------+-----+------------------------+ + | 6|R/W|ALLOW_GET_KEY |0x00 |Operation allowed status| + +-----+---+------------------+-----+------------------------+ + | 7|R/W|ALLOW_UNWRAP |0x00 |Operation allowed status| + +-----+---+------------------+-----+------------------------+ + | 8|R/W|ALLOW_WRAP_GEN_RND|0x00 |Operation allowed status| + +-----+---+------------------+-----+------------------------+ + | 9|R/W|ALLOW_WRAP |0x00 |Operation allowed status| + +-----+---+------------------+-----+------------------------+ + | 15|R/W|ALLOW_GEN_RND |0x00 |Operation allowed status| + +-----+---+------------------+-----+------------------------+ + | 16|R/W|ALLOW_RESEED |0x00 |Operation allowed status| + +-----+---+------------------+-----+------------------------+ + | 31|R/W|ALLOW_TEST_PUF |0x00 |Operation allowed status| + +-----+---+------------------+-----+------------------------+ + +.. _quiddikey__IER: IER """ @@ -2239,87 +172,16 @@ IER Interrupt Enable register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+=========================+ - | 0|R/W|INT_EN|Interrupt enable register| - +-----+---+------+-------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* + +-----+---+------+-----+-------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=========================+ + | 0|R/W|INT_EN|0x00 |Interrupt enable register| + +-----+---+------+-----+-------------------------+ - .. code-block:: c - - - // Interrupt Enable register - #define QUIDDIKEY_IER_OFFSET 0x10 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_ier_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_ier_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Interrupt enable register (access: R/W) - #define QUIDDIKEY_IER_INT_EN_BIT 0 - #define QUIDDIKEY_IER_INT_EN_WIDTH 1 - #define QUIDDIKEY_IER_INT_EN_MASK 0x1 - #define QUIDDIKEY_IER_INT_EN_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_IER_INT_EN_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_IER_INT_EN_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_IER_INT_EN_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_IER_INT_EN(val) ((val) << 0) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int int_en :1 ; // Interrupt enable register - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_ier_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_ier : public vp::reg_32 - { - public: - inline void int_en_set(uint32_t value); - inline uint32_t int_en_get(); - }; - -| - -.. _quiddikey_IMR: +.. _quiddikey__IMR: IMR """ @@ -2327,232 +189,34 @@ IMR Interrupt Mask register .. table:: - - +-----+---+----------------------+---------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======================+=================================+ - | 0|R/W|INT_EN_BUSY |Enable Busy interrupt | - +-----+---+----------------------+---------------------------------+ - | 1|R/W|INT_EN_OK |Enable Ok interrupt | - +-----+---+----------------------+---------------------------------+ - | 2|R/W|INT_EN_ERROR |Enable Error interrupt | - +-----+---+----------------------+---------------------------------+ - | 3|R/W|INT_EN_ZEROIZED |Enable Zeroized interrupt | - +-----+---+----------------------+---------------------------------+ - | 4|R/W|INT_EN_REJECTED |Enable Rejected interrupt | - +-----+---+----------------------+---------------------------------+ - | 5|R/W|INT_EN_DI_REQUEST |Enable Data In Request interrupt | - +-----+---+----------------------+---------------------------------+ - | 6|R/W|INT_EN_DO_REQUEST |Enable Data Out Request interrupt| - +-----+---+----------------------+---------------------------------+ - | 29|R/W|INT_EN_RESEED_WARNING |Enable Reseed Warning interrupt | - +-----+---+----------------------+---------------------------------+ - | 30|R/W|INT_EN_RESEED_REQUIRED|Enable Reseed Required interrupt | - +-----+---+----------------------+---------------------------------+ - | 31|R/W|INT_EN_LAB_TEST_MODE |Enable Lab Test Mode interrupt | - +-----+---+----------------------+---------------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Interrupt Mask register - #define QUIDDIKEY_IMR_OFFSET 0x14 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_imr_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_imr_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Enable Busy interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_BUSY_BIT 0 - #define QUIDDIKEY_IMR_INT_EN_BUSY_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_BUSY_MASK 0x1 - #define QUIDDIKEY_IMR_INT_EN_BUSY_RESET 0x0 - - // Enable Ok interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_OK_BIT 1 - #define QUIDDIKEY_IMR_INT_EN_OK_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_OK_MASK 0x2 - #define QUIDDIKEY_IMR_INT_EN_OK_RESET 0x0 - - // Enable Error interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_ERROR_BIT 2 - #define QUIDDIKEY_IMR_INT_EN_ERROR_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_ERROR_MASK 0x4 - #define QUIDDIKEY_IMR_INT_EN_ERROR_RESET 0x0 - - // Enable Zeroized interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED_BIT 3 - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED_MASK 0x8 - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED_RESET 0x0 - - // Enable Rejected interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_REJECTED_BIT 4 - #define QUIDDIKEY_IMR_INT_EN_REJECTED_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_REJECTED_MASK 0x10 - #define QUIDDIKEY_IMR_INT_EN_REJECTED_RESET 0x0 - - // Enable Data In Request interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST_BIT 5 - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST_MASK 0x20 - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST_RESET 0x0 - - // Enable Data Out Request interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST_BIT 6 - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST_MASK 0x40 - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST_RESET 0x0 - - // Enable Reseed Warning interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING_BIT 29 - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING_MASK 0x20000000 - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING_RESET 0x0 - - // Enable Reseed Required interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED_BIT 30 - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED_MASK 0x40000000 - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED_RESET 0x0 - - // Enable Lab Test Mode interrupt (access: R/W) - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE_BIT 31 - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE_WIDTH 1 - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE_MASK 0x80000000 - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_IMR_INT_EN_BUSY_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_IMR_INT_EN_BUSY_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_IMR_INT_EN_BUSY_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_IMR_INT_EN_BUSY(val) ((val) << 0) - - #define QUIDDIKEY_IMR_INT_EN_OK_GET(value) (GAP_BEXTRACTU((value),1,1)) - #define QUIDDIKEY_IMR_INT_EN_OK_GETS(value) (GAP_BEXTRACT((value),1,1)) - #define QUIDDIKEY_IMR_INT_EN_OK_SET(value,field) (GAP_BINSERT((value),(field),1,1)) - #define QUIDDIKEY_IMR_INT_EN_OK(val) ((val) << 1) - - #define QUIDDIKEY_IMR_INT_EN_ERROR_GET(value) (GAP_BEXTRACTU((value),1,2)) - #define QUIDDIKEY_IMR_INT_EN_ERROR_GETS(value) (GAP_BEXTRACT((value),1,2)) - #define QUIDDIKEY_IMR_INT_EN_ERROR_SET(value,field) (GAP_BINSERT((value),(field),1,2)) - #define QUIDDIKEY_IMR_INT_EN_ERROR(val) ((val) << 2) - - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED_GET(value) (GAP_BEXTRACTU((value),1,3)) - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED_GETS(value) (GAP_BEXTRACT((value),1,3)) - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED_SET(value,field) (GAP_BINSERT((value),(field),1,3)) - #define QUIDDIKEY_IMR_INT_EN_ZEROIZED(val) ((val) << 3) - - #define QUIDDIKEY_IMR_INT_EN_REJECTED_GET(value) (GAP_BEXTRACTU((value),1,4)) - #define QUIDDIKEY_IMR_INT_EN_REJECTED_GETS(value) (GAP_BEXTRACT((value),1,4)) - #define QUIDDIKEY_IMR_INT_EN_REJECTED_SET(value,field) (GAP_BINSERT((value),(field),1,4)) - #define QUIDDIKEY_IMR_INT_EN_REJECTED(val) ((val) << 4) - - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST_GET(value) (GAP_BEXTRACTU((value),1,5)) - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST_GETS(value) (GAP_BEXTRACT((value),1,5)) - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST_SET(value,field) (GAP_BINSERT((value),(field),1,5)) - #define QUIDDIKEY_IMR_INT_EN_DI_REQUEST(val) ((val) << 5) - - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST_GET(value) (GAP_BEXTRACTU((value),1,6)) - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST_GETS(value) (GAP_BEXTRACT((value),1,6)) - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST_SET(value,field) (GAP_BINSERT((value),(field),1,6)) - #define QUIDDIKEY_IMR_INT_EN_DO_REQUEST(val) ((val) << 6) - - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING_GET(value) (GAP_BEXTRACTU((value),1,29)) - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING_GETS(value) (GAP_BEXTRACT((value),1,29)) - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING_SET(value,field) (GAP_BINSERT((value),(field),1,29)) - #define QUIDDIKEY_IMR_INT_EN_RESEED_WARNING(val) ((val) << 29) - - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED_GET(value) (GAP_BEXTRACTU((value),1,30)) - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED_GETS(value) (GAP_BEXTRACT((value),1,30)) - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED_SET(value,field) (GAP_BINSERT((value),(field),1,30)) - #define QUIDDIKEY_IMR_INT_EN_RESEED_REQUIRED(val) ((val) << 30) - - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE_GET(value) (GAP_BEXTRACTU((value),1,31)) - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE_GETS(value) (GAP_BEXTRACT((value),1,31)) - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE_SET(value,field) (GAP_BINSERT((value),(field),1,31)) - #define QUIDDIKEY_IMR_INT_EN_LAB_TEST_MODE(val) ((val) << 31) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int int_en_busy :1 ; // Enable Busy interrupt - unsigned int int_en_ok :1 ; // Enable Ok interrupt - unsigned int int_en_error :1 ; // Enable Error interrupt - unsigned int int_en_zeroized :1 ; // Enable Zeroized interrupt - unsigned int int_en_rejected :1 ; // Enable Rejected interrupt - unsigned int int_en_di_request:1 ; // Enable Data In Request interrupt - unsigned int int_en_do_request:1 ; // Enable Data Out Request interrupt - unsigned int padding0:22; - unsigned int int_en_reseed_warning:1 ; // Enable Reseed Warning interrupt - unsigned int int_en_reseed_required:1 ; // Enable Reseed Required interrupt - unsigned int int_en_lab_test_mode:1 ; // Enable Lab Test Mode interrupt - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_imr_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_imr : public vp::reg_32 - { - public: - inline void int_en_busy_set(uint32_t value); - inline uint32_t int_en_busy_get(); - inline void int_en_ok_set(uint32_t value); - inline uint32_t int_en_ok_get(); - inline void int_en_error_set(uint32_t value); - inline uint32_t int_en_error_get(); - inline void int_en_zeroized_set(uint32_t value); - inline uint32_t int_en_zeroized_get(); - inline void int_en_rejected_set(uint32_t value); - inline uint32_t int_en_rejected_get(); - inline void int_en_di_request_set(uint32_t value); - inline uint32_t int_en_di_request_get(); - inline void int_en_do_request_set(uint32_t value); - inline uint32_t int_en_do_request_get(); - inline void int_en_reseed_warning_set(uint32_t value); - inline uint32_t int_en_reseed_warning_get(); - inline void int_en_reseed_required_set(uint32_t value); - inline uint32_t int_en_reseed_required_get(); - inline void int_en_lab_test_mode_set(uint32_t value); - inline uint32_t int_en_lab_test_mode_get(); - }; - -| - -.. _quiddikey_ISR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------+-----+---------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======================+=====+=================================+ + | 0|R/W|INT_EN_BUSY |0x00 |Enable Busy interrupt | + +-----+---+----------------------+-----+---------------------------------+ + | 1|R/W|INT_EN_OK |0x00 |Enable Ok interrupt | + +-----+---+----------------------+-----+---------------------------------+ + | 2|R/W|INT_EN_ERROR |0x00 |Enable Error interrupt | + +-----+---+----------------------+-----+---------------------------------+ + | 3|R/W|INT_EN_ZEROIZED |0x00 |Enable Zeroized interrupt | + +-----+---+----------------------+-----+---------------------------------+ + | 4|R/W|INT_EN_REJECTED |0x00 |Enable Rejected interrupt | + +-----+---+----------------------+-----+---------------------------------+ + | 5|R/W|INT_EN_DI_REQUEST |0x00 |Enable Data In Request interrupt | + +-----+---+----------------------+-----+---------------------------------+ + | 6|R/W|INT_EN_DO_REQUEST |0x00 |Enable Data Out Request interrupt| + +-----+---+----------------------+-----+---------------------------------+ + | 29|R/W|INT_EN_RESEED_WARNING |0x00 |Enable Reseed Warning interrupt | + +-----+---+----------------------+-----+---------------------------------+ + | 30|R/W|INT_EN_RESEED_REQUIRED|0x00 |Enable Reseed Required interrupt | + +-----+---+----------------------+-----+---------------------------------+ + | 31|R/W|INT_EN_LAB_TEST_MODE |0x00 |Enable Lab Test Mode interrupt | + +-----+---+----------------------+-----+---------------------------------+ + +.. _quiddikey__ISR: ISR """ @@ -2560,232 +224,34 @@ ISR Interrupt Status register .. table:: - - +-----+---+-------------------+------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===================+==========================================+ - | 0|R/W|INT_BUSY |Busy interrupt status register | - +-----+---+-------------------+------------------------------------------+ - | 1|R/W|INT_OK |Ok interrupt status register | - +-----+---+-------------------+------------------------------------------+ - | 2|R/W|INT_ERROR |Error interrupt status register | - +-----+---+-------------------+------------------------------------------+ - | 3|R/W|INT_ZEROIZED |Zeroized interrupt status register | - +-----+---+-------------------+------------------------------------------+ - | 4|R/W|INT_REJECTED |Rejected interrupt status register | - +-----+---+-------------------+------------------------------------------+ - | 5|R/W|INT_DI_REQUEST |Data In Request interrupt status register | - +-----+---+-------------------+------------------------------------------+ - | 6|R/W|INT_DO_REQUEST |Data Out Request interrupt status register| - +-----+---+-------------------+------------------------------------------+ - | 29|R/W|INT_RESEED_WARNING |Reseed Warning interrupt status register | - +-----+---+-------------------+------------------------------------------+ - | 30|R/W|INT_RESEED_REQUIRED|Reseed Required interrupt status register | - +-----+---+-------------------+------------------------------------------+ - | 31|R/W|INT_LAB_TEST_MODE |Lab Test Mode interrupt status register | - +-----+---+-------------------+------------------------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Interrupt Status register - #define QUIDDIKEY_ISR_OFFSET 0x18 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_isr_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_isr_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Busy interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_BUSY_BIT 0 - #define QUIDDIKEY_ISR_INT_BUSY_WIDTH 1 - #define QUIDDIKEY_ISR_INT_BUSY_MASK 0x1 - #define QUIDDIKEY_ISR_INT_BUSY_RESET 0x0 - - // Ok interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_OK_BIT 1 - #define QUIDDIKEY_ISR_INT_OK_WIDTH 1 - #define QUIDDIKEY_ISR_INT_OK_MASK 0x2 - #define QUIDDIKEY_ISR_INT_OK_RESET 0x0 - - // Error interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_ERROR_BIT 2 - #define QUIDDIKEY_ISR_INT_ERROR_WIDTH 1 - #define QUIDDIKEY_ISR_INT_ERROR_MASK 0x4 - #define QUIDDIKEY_ISR_INT_ERROR_RESET 0x0 - - // Zeroized interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_ZEROIZED_BIT 3 - #define QUIDDIKEY_ISR_INT_ZEROIZED_WIDTH 1 - #define QUIDDIKEY_ISR_INT_ZEROIZED_MASK 0x8 - #define QUIDDIKEY_ISR_INT_ZEROIZED_RESET 0x0 - - // Rejected interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_REJECTED_BIT 4 - #define QUIDDIKEY_ISR_INT_REJECTED_WIDTH 1 - #define QUIDDIKEY_ISR_INT_REJECTED_MASK 0x10 - #define QUIDDIKEY_ISR_INT_REJECTED_RESET 0x0 - - // Data In Request interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_DI_REQUEST_BIT 5 - #define QUIDDIKEY_ISR_INT_DI_REQUEST_WIDTH 1 - #define QUIDDIKEY_ISR_INT_DI_REQUEST_MASK 0x20 - #define QUIDDIKEY_ISR_INT_DI_REQUEST_RESET 0x0 - - // Data Out Request interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_DO_REQUEST_BIT 6 - #define QUIDDIKEY_ISR_INT_DO_REQUEST_WIDTH 1 - #define QUIDDIKEY_ISR_INT_DO_REQUEST_MASK 0x40 - #define QUIDDIKEY_ISR_INT_DO_REQUEST_RESET 0x0 - - // Reseed Warning interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_RESEED_WARNING_BIT 29 - #define QUIDDIKEY_ISR_INT_RESEED_WARNING_WIDTH 1 - #define QUIDDIKEY_ISR_INT_RESEED_WARNING_MASK 0x20000000 - #define QUIDDIKEY_ISR_INT_RESEED_WARNING_RESET 0x0 - - // Reseed Required interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED_BIT 30 - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED_WIDTH 1 - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED_MASK 0x40000000 - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED_RESET 0x0 - - // Lab Test Mode interrupt status register (access: R/W) - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE_BIT 31 - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE_WIDTH 1 - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE_MASK 0x80000000 - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_ISR_INT_BUSY_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_ISR_INT_BUSY_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_ISR_INT_BUSY_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_ISR_INT_BUSY(val) ((val) << 0) - - #define QUIDDIKEY_ISR_INT_OK_GET(value) (GAP_BEXTRACTU((value),1,1)) - #define QUIDDIKEY_ISR_INT_OK_GETS(value) (GAP_BEXTRACT((value),1,1)) - #define QUIDDIKEY_ISR_INT_OK_SET(value,field) (GAP_BINSERT((value),(field),1,1)) - #define QUIDDIKEY_ISR_INT_OK(val) ((val) << 1) - - #define QUIDDIKEY_ISR_INT_ERROR_GET(value) (GAP_BEXTRACTU((value),1,2)) - #define QUIDDIKEY_ISR_INT_ERROR_GETS(value) (GAP_BEXTRACT((value),1,2)) - #define QUIDDIKEY_ISR_INT_ERROR_SET(value,field) (GAP_BINSERT((value),(field),1,2)) - #define QUIDDIKEY_ISR_INT_ERROR(val) ((val) << 2) - - #define QUIDDIKEY_ISR_INT_ZEROIZED_GET(value) (GAP_BEXTRACTU((value),1,3)) - #define QUIDDIKEY_ISR_INT_ZEROIZED_GETS(value) (GAP_BEXTRACT((value),1,3)) - #define QUIDDIKEY_ISR_INT_ZEROIZED_SET(value,field) (GAP_BINSERT((value),(field),1,3)) - #define QUIDDIKEY_ISR_INT_ZEROIZED(val) ((val) << 3) - - #define QUIDDIKEY_ISR_INT_REJECTED_GET(value) (GAP_BEXTRACTU((value),1,4)) - #define QUIDDIKEY_ISR_INT_REJECTED_GETS(value) (GAP_BEXTRACT((value),1,4)) - #define QUIDDIKEY_ISR_INT_REJECTED_SET(value,field) (GAP_BINSERT((value),(field),1,4)) - #define QUIDDIKEY_ISR_INT_REJECTED(val) ((val) << 4) - - #define QUIDDIKEY_ISR_INT_DI_REQUEST_GET(value) (GAP_BEXTRACTU((value),1,5)) - #define QUIDDIKEY_ISR_INT_DI_REQUEST_GETS(value) (GAP_BEXTRACT((value),1,5)) - #define QUIDDIKEY_ISR_INT_DI_REQUEST_SET(value,field) (GAP_BINSERT((value),(field),1,5)) - #define QUIDDIKEY_ISR_INT_DI_REQUEST(val) ((val) << 5) - - #define QUIDDIKEY_ISR_INT_DO_REQUEST_GET(value) (GAP_BEXTRACTU((value),1,6)) - #define QUIDDIKEY_ISR_INT_DO_REQUEST_GETS(value) (GAP_BEXTRACT((value),1,6)) - #define QUIDDIKEY_ISR_INT_DO_REQUEST_SET(value,field) (GAP_BINSERT((value),(field),1,6)) - #define QUIDDIKEY_ISR_INT_DO_REQUEST(val) ((val) << 6) - - #define QUIDDIKEY_ISR_INT_RESEED_WARNING_GET(value) (GAP_BEXTRACTU((value),1,29)) - #define QUIDDIKEY_ISR_INT_RESEED_WARNING_GETS(value) (GAP_BEXTRACT((value),1,29)) - #define QUIDDIKEY_ISR_INT_RESEED_WARNING_SET(value,field) (GAP_BINSERT((value),(field),1,29)) - #define QUIDDIKEY_ISR_INT_RESEED_WARNING(val) ((val) << 29) - - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED_GET(value) (GAP_BEXTRACTU((value),1,30)) - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED_GETS(value) (GAP_BEXTRACT((value),1,30)) - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED_SET(value,field) (GAP_BINSERT((value),(field),1,30)) - #define QUIDDIKEY_ISR_INT_RESEED_REQUIRED(val) ((val) << 30) - - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE_GET(value) (GAP_BEXTRACTU((value),1,31)) - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE_GETS(value) (GAP_BEXTRACT((value),1,31)) - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE_SET(value,field) (GAP_BINSERT((value),(field),1,31)) - #define QUIDDIKEY_ISR_INT_LAB_TEST_MODE(val) ((val) << 31) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int int_busy :1 ; // Busy interrupt status register - unsigned int int_ok :1 ; // Ok interrupt status register - unsigned int int_error :1 ; // Error interrupt status register - unsigned int int_zeroized :1 ; // Zeroized interrupt status register - unsigned int int_rejected :1 ; // Rejected interrupt status register - unsigned int int_di_request :1 ; // Data In Request interrupt status register - unsigned int int_do_request :1 ; // Data Out Request interrupt status register - unsigned int padding0:22; - unsigned int int_reseed_warning:1 ; // Reseed Warning interrupt status register - unsigned int int_reseed_required:1 ; // Reseed Required interrupt status register - unsigned int int_lab_test_mode:1 ; // Lab Test Mode interrupt status register - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_isr_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_isr : public vp::reg_32 - { - public: - inline void int_busy_set(uint32_t value); - inline uint32_t int_busy_get(); - inline void int_ok_set(uint32_t value); - inline uint32_t int_ok_get(); - inline void int_error_set(uint32_t value); - inline uint32_t int_error_get(); - inline void int_zeroized_set(uint32_t value); - inline uint32_t int_zeroized_get(); - inline void int_rejected_set(uint32_t value); - inline uint32_t int_rejected_get(); - inline void int_di_request_set(uint32_t value); - inline uint32_t int_di_request_get(); - inline void int_do_request_set(uint32_t value); - inline uint32_t int_do_request_get(); - inline void int_reseed_warning_set(uint32_t value); - inline uint32_t int_reseed_warning_get(); - inline void int_reseed_required_set(uint32_t value); - inline uint32_t int_reseed_required_get(); - inline void int_lab_test_mode_set(uint32_t value); - inline uint32_t int_lab_test_mode_get(); - }; - -| - -.. _quiddikey_DATA_DEST: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------------+-----+------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===================+=====+==========================================+ + | 0|R/W|INT_BUSY |0x00 |Busy interrupt status register | + +-----+---+-------------------+-----+------------------------------------------+ + | 1|R/W|INT_OK |0x00 |Ok interrupt status register | + +-----+---+-------------------+-----+------------------------------------------+ + | 2|R/W|INT_ERROR |0x00 |Error interrupt status register | + +-----+---+-------------------+-----+------------------------------------------+ + | 3|R/W|INT_ZEROIZED |0x00 |Zeroized interrupt status register | + +-----+---+-------------------+-----+------------------------------------------+ + | 4|R/W|INT_REJECTED |0x00 |Rejected interrupt status register | + +-----+---+-------------------+-----+------------------------------------------+ + | 5|R/W|INT_DI_REQUEST |0x00 |Data In Request interrupt status register | + +-----+---+-------------------+-----+------------------------------------------+ + | 6|R/W|INT_DO_REQUEST |0x00 |Data Out Request interrupt status register| + +-----+---+-------------------+-----+------------------------------------------+ + | 29|R/W|INT_RESEED_WARNING |0x00 |Reseed Warning interrupt status register | + +-----+---+-------------------+-----+------------------------------------------+ + | 30|R/W|INT_RESEED_REQUIRED|0x00 |Reseed Required interrupt status register | + +-----+---+-------------------+-----+------------------------------------------+ + | 31|R/W|INT_LAB_TEST_MODE |0x00 |Lab Test Mode interrupt status register | + +-----+---+-------------------+-----+------------------------------------------+ + +.. _quiddikey__DATA_DEST: DATA_DEST """"""""" @@ -2793,103 +259,18 @@ DATA_DEST Destination Data register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+===================================+ - | 0|R/W|DEST_DOR|Data out register destination | - +-----+---+--------+-----------------------------------+ - | 1|R/W|DEST_SO |Secure Output interface destination| - +-----+---+--------+-----------------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Destination Data register - #define QUIDDIKEY_DATA_DEST_OFFSET 0x20 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - + +-----+---+--------+-----+-----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+===================================+ + | 0|R/W|DEST_DOR|0x00 |Data out register destination | + +-----+---+--------+-----+-----------------------------------+ + | 1|R/W|DEST_SO |0x00 |Secure Output interface destination| + +-----+---+--------+-----+-----------------------------------+ - static inline __attribute__((always_inline)) uint32_t quiddikey_data_dest_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_data_dest_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Data out register destination (access: R/W) - #define QUIDDIKEY_DATA_DEST_DEST_DOR_BIT 0 - #define QUIDDIKEY_DATA_DEST_DEST_DOR_WIDTH 1 - #define QUIDDIKEY_DATA_DEST_DEST_DOR_MASK 0x1 - #define QUIDDIKEY_DATA_DEST_DEST_DOR_RESET 0x0 - - // Secure Output interface destination (access: R/W) - #define QUIDDIKEY_DATA_DEST_DEST_SO_BIT 1 - #define QUIDDIKEY_DATA_DEST_DEST_SO_WIDTH 1 - #define QUIDDIKEY_DATA_DEST_DEST_SO_MASK 0x2 - #define QUIDDIKEY_DATA_DEST_DEST_SO_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_DATA_DEST_DEST_DOR_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_DATA_DEST_DEST_DOR_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_DATA_DEST_DEST_DOR_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_DATA_DEST_DEST_DOR(val) ((val) << 0) - - #define QUIDDIKEY_DATA_DEST_DEST_SO_GET(value) (GAP_BEXTRACTU((value),1,1)) - #define QUIDDIKEY_DATA_DEST_DEST_SO_GETS(value) (GAP_BEXTRACT((value),1,1)) - #define QUIDDIKEY_DATA_DEST_DEST_SO_SET(value,field) (GAP_BINSERT((value),(field),1,1)) - #define QUIDDIKEY_DATA_DEST_DEST_SO(val) ((val) << 1) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int dest_dor :1 ; // Data out register destination - unsigned int dest_so :1 ; // Secure Output interface destination - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_data_dest_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_data_dest : public vp::reg_32 - { - public: - inline void dest_dor_set(uint32_t value); - inline uint32_t dest_dor_get(); - inline void dest_so_set(uint32_t value); - inline uint32_t dest_so_get(); - }; - -| - -.. _quiddikey_DIR: +.. _quiddikey__DIR: DIR """ @@ -2897,87 +278,16 @@ DIR Data Input register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============+ - |31:0 |R/W|DI |Data In field| - +-----+---+----+-------------+ - -Generated headers -""""""""""""""""" + +-----+---+----+-----+-------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============+ + |31:0 |R/W|DI |0x00 |Data In field| + +-----+---+----+-----+-------------+ - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Data Input register - #define QUIDDIKEY_DIR_OFFSET 0xa0 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_dir_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_dir_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Data In field (access: R/W) - #define QUIDDIKEY_DIR_DI_BIT 0 - #define QUIDDIKEY_DIR_DI_WIDTH 32 - #define QUIDDIKEY_DIR_DI_MASK 0xffffffff - #define QUIDDIKEY_DIR_DI_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_DIR_DI_GET(value) (value) - #define QUIDDIKEY_DIR_DI_GETS(value) (value) - #define QUIDDIKEY_DIR_DI_SET(value,field) (field) - #define QUIDDIKEY_DIR_DI(val) ((val) << 0) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int di :32; // Data In field - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_dir_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_dir : public vp::reg_32 - { - public: - inline void di_set(uint32_t value); - inline uint32_t di_get(); - }; - -| - -.. _quiddikey_DOR: +.. _quiddikey__DOR: DOR """ @@ -2985,87 +295,16 @@ DOR Data Output register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+--------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==============+ - |31:0 |R |DOR |Data Out field| - +-----+---+----+--------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Data Output register - #define QUIDDIKEY_DOR_OFFSET 0xa8 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_dor_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_dor_set(uint32_t base, uint32_t value); + +-----+---+----+-----+--------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============+ + |31:0 |R |DOR |0x00 |Data Out field| + +-----+---+----+-----+--------------+ -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Data Out field (access: R) - #define QUIDDIKEY_DOR_DOR_BIT 0 - #define QUIDDIKEY_DOR_DOR_WIDTH 32 - #define QUIDDIKEY_DOR_DOR_MASK 0xffffffff - #define QUIDDIKEY_DOR_DOR_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_DOR_DOR_GET(value) (value) - #define QUIDDIKEY_DOR_DOR_GETS(value) (value) - #define QUIDDIKEY_DOR_DOR_SET(value,field) (field) - #define QUIDDIKEY_DOR_DOR(val) ((val) << 0) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int dor :32; // Data Out field - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_dor_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_dor : public vp::reg_32 - { - public: - inline void dor_set(uint32_t value); - inline uint32_t dor_get(); - }; - -| - -.. _quiddikey_MISC: +.. _quiddikey__MISC: MISC """" @@ -3073,87 +312,16 @@ MISC Miscellaneous register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------+--------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+==============+ - |31:0 |R |ENDIANNESS|Set endianness| - +-----+---+----------+--------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Miscellaneous register - #define QUIDDIKEY_MISC_OFFSET 0xc0 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_misc_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_misc_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Set endianness (access: R) - #define QUIDDIKEY_MISC_ENDIANNESS_BIT 0 - #define QUIDDIKEY_MISC_ENDIANNESS_WIDTH 32 - #define QUIDDIKEY_MISC_ENDIANNESS_MASK 0xffffffff - #define QUIDDIKEY_MISC_ENDIANNESS_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_MISC_ENDIANNESS_GET(value) (value) - #define QUIDDIKEY_MISC_ENDIANNESS_GETS(value) (value) - #define QUIDDIKEY_MISC_ENDIANNESS_SET(value,field) (field) - #define QUIDDIKEY_MISC_ENDIANNESS(val) ((val) << 0) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c + +-----+---+----------+-----+--------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+==============+ + |31:0 |R |ENDIANNESS|0x00 |Set endianness| + +-----+---+----------+-----+--------------+ - - typedef union { - struct { - unsigned int endianness :32; // Set endianness - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_misc_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_misc : public vp::reg_32 - { - public: - inline void endianness_set(uint32_t value); - inline uint32_t endianness_get(); - }; - -| - -.. _quiddikey_IF_SR: +.. _quiddikey__IF_SR: IF_SR """"" @@ -3161,87 +329,16 @@ IF_SR Interface Status register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+========================+ - | 0|R/W|APB_ERROR|An APB error has occured| - +-----+---+---------+------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Interface Status register - #define QUIDDIKEY_IF_SR_OFFSET 0xd0 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_if_sr_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_if_sr_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* + +-----+---+---------+-----+------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+========================+ + | 0|R/W|APB_ERROR|0x00 |An APB error has occured| + +-----+---+---------+-----+------------------------+ - .. code-block:: c - - - // An APB error has occured (access: R/W) - #define QUIDDIKEY_IF_SR_APB_ERROR_BIT 0 - #define QUIDDIKEY_IF_SR_APB_ERROR_WIDTH 1 - #define QUIDDIKEY_IF_SR_APB_ERROR_MASK 0x1 - #define QUIDDIKEY_IF_SR_APB_ERROR_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_IF_SR_APB_ERROR_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_IF_SR_APB_ERROR_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_IF_SR_APB_ERROR_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_IF_SR_APB_ERROR(val) ((val) << 0) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int apb_error :1 ; // An APB error has occured - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_if_sr_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_if_sr : public vp::reg_32 - { - public: - inline void apb_error_set(uint32_t value); - inline uint32_t apb_error_get(); - }; - -| - -.. _quiddikey_TEST: +.. _quiddikey__TEST: TEST """" @@ -3249,169 +346,26 @@ TEST Test register .. table:: - - +-----+---+------------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+===================================+ - | 0|R/W|BIST_ENABLE |Isolates Quiddikey and runs BIST | - +-----+---+------------+-----------------------------------+ - | 4|R/W|BIST_RUNNING|BIST is in progress or finishing up| - +-----+---+------------+-----------------------------------+ - | 5|R/W|BIST_ACTIVE |BIST is in progress | - +-----+---+------------+-----------------------------------+ - | 6|R/W|BIST_OK |BIST has passed | - +-----+---+------------+-----------------------------------+ - | 7|R/W|BIST_ERROR |BIST has failed | - +-----+---+------------+-----------------------------------+ - | 31|R/W|ALLOW_BIST |BIST is not allowed | - +-----+---+------------+-----------------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Test register - #define QUIDDIKEY_TEST_OFFSET 0xd8 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_test_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_test_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Isolates Quiddikey and runs BIST (access: R/W) - #define QUIDDIKEY_TEST_BIST_ENABLE_BIT 0 - #define QUIDDIKEY_TEST_BIST_ENABLE_WIDTH 1 - #define QUIDDIKEY_TEST_BIST_ENABLE_MASK 0x1 - #define QUIDDIKEY_TEST_BIST_ENABLE_RESET 0x0 - - // BIST is in progress or finishing up (access: R/W) - #define QUIDDIKEY_TEST_BIST_RUNNING_BIT 4 - #define QUIDDIKEY_TEST_BIST_RUNNING_WIDTH 1 - #define QUIDDIKEY_TEST_BIST_RUNNING_MASK 0x10 - #define QUIDDIKEY_TEST_BIST_RUNNING_RESET 0x0 - - // BIST is in progress (access: R/W) - #define QUIDDIKEY_TEST_BIST_ACTIVE_BIT 5 - #define QUIDDIKEY_TEST_BIST_ACTIVE_WIDTH 1 - #define QUIDDIKEY_TEST_BIST_ACTIVE_MASK 0x20 - #define QUIDDIKEY_TEST_BIST_ACTIVE_RESET 0x0 - - // BIST has passed (access: R/W) - #define QUIDDIKEY_TEST_BIST_OK_BIT 6 - #define QUIDDIKEY_TEST_BIST_OK_WIDTH 1 - #define QUIDDIKEY_TEST_BIST_OK_MASK 0x40 - #define QUIDDIKEY_TEST_BIST_OK_RESET 0x0 - - // BIST has failed (access: R/W) - #define QUIDDIKEY_TEST_BIST_ERROR_BIT 7 - #define QUIDDIKEY_TEST_BIST_ERROR_WIDTH 1 - #define QUIDDIKEY_TEST_BIST_ERROR_MASK 0x80 - #define QUIDDIKEY_TEST_BIST_ERROR_RESET 0x0 - - // BIST is not allowed (access: R/W) - #define QUIDDIKEY_TEST_ALLOW_BIST_BIT 31 - #define QUIDDIKEY_TEST_ALLOW_BIST_WIDTH 1 - #define QUIDDIKEY_TEST_ALLOW_BIST_MASK 0x80000000 - #define QUIDDIKEY_TEST_ALLOW_BIST_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_TEST_BIST_ENABLE_GET(value) (GAP_BEXTRACTU((value),1,0)) - #define QUIDDIKEY_TEST_BIST_ENABLE_GETS(value) (GAP_BEXTRACT((value),1,0)) - #define QUIDDIKEY_TEST_BIST_ENABLE_SET(value,field) (GAP_BINSERT((value),(field),1,0)) - #define QUIDDIKEY_TEST_BIST_ENABLE(val) ((val) << 0) - - #define QUIDDIKEY_TEST_BIST_RUNNING_GET(value) (GAP_BEXTRACTU((value),1,4)) - #define QUIDDIKEY_TEST_BIST_RUNNING_GETS(value) (GAP_BEXTRACT((value),1,4)) - #define QUIDDIKEY_TEST_BIST_RUNNING_SET(value,field) (GAP_BINSERT((value),(field),1,4)) - #define QUIDDIKEY_TEST_BIST_RUNNING(val) ((val) << 4) - - #define QUIDDIKEY_TEST_BIST_ACTIVE_GET(value) (GAP_BEXTRACTU((value),1,5)) - #define QUIDDIKEY_TEST_BIST_ACTIVE_GETS(value) (GAP_BEXTRACT((value),1,5)) - #define QUIDDIKEY_TEST_BIST_ACTIVE_SET(value,field) (GAP_BINSERT((value),(field),1,5)) - #define QUIDDIKEY_TEST_BIST_ACTIVE(val) ((val) << 5) - - #define QUIDDIKEY_TEST_BIST_OK_GET(value) (GAP_BEXTRACTU((value),1,6)) - #define QUIDDIKEY_TEST_BIST_OK_GETS(value) (GAP_BEXTRACT((value),1,6)) - #define QUIDDIKEY_TEST_BIST_OK_SET(value,field) (GAP_BINSERT((value),(field),1,6)) - #define QUIDDIKEY_TEST_BIST_OK(val) ((val) << 6) - - #define QUIDDIKEY_TEST_BIST_ERROR_GET(value) (GAP_BEXTRACTU((value),1,7)) - #define QUIDDIKEY_TEST_BIST_ERROR_GETS(value) (GAP_BEXTRACT((value),1,7)) - #define QUIDDIKEY_TEST_BIST_ERROR_SET(value,field) (GAP_BINSERT((value),(field),1,7)) - #define QUIDDIKEY_TEST_BIST_ERROR(val) ((val) << 7) - - #define QUIDDIKEY_TEST_ALLOW_BIST_GET(value) (GAP_BEXTRACTU((value),1,31)) - #define QUIDDIKEY_TEST_ALLOW_BIST_GETS(value) (GAP_BEXTRACT((value),1,31)) - #define QUIDDIKEY_TEST_ALLOW_BIST_SET(value,field) (GAP_BINSERT((value),(field),1,31)) - #define QUIDDIKEY_TEST_ALLOW_BIST(val) ((val) << 31) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int bist_enable :1 ; // Isolates Quiddikey and runs BIST - unsigned int padding0:3 ; - unsigned int bist_running :1 ; // BIST is in progress or finishing up - unsigned int bist_active :1 ; // BIST is in progress - unsigned int bist_ok :1 ; // BIST has passed - unsigned int bist_error :1 ; // BIST has failed - unsigned int padding1:23; - unsigned int allow_bist :1 ; // BIST is not allowed - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_test_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_test : public vp::reg_32 - { - public: - inline void bist_enable_set(uint32_t value); - inline uint32_t bist_enable_get(); - inline void bist_running_set(uint32_t value); - inline uint32_t bist_running_get(); - inline void bist_active_set(uint32_t value); - inline uint32_t bist_active_get(); - inline void bist_ok_set(uint32_t value); - inline uint32_t bist_ok_get(); - inline void bist_error_set(uint32_t value); - inline uint32_t bist_error_get(); - inline void allow_bist_set(uint32_t value); - inline uint32_t allow_bist_get(); - }; - -| - -.. _quiddikey_PSR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------+-----+-----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===================================+ + | 0|R/W|BIST_ENABLE |0x00 |Isolates Quiddikey and runs BIST | + +-----+---+------------+-----+-----------------------------------+ + | 4|R/W|BIST_RUNNING|0x00 |BIST is in progress or finishing up| + +-----+---+------------+-----+-----------------------------------+ + | 5|R/W|BIST_ACTIVE |0x00 |BIST is in progress | + +-----+---+------------+-----+-----------------------------------+ + | 6|R/W|BIST_OK |0x00 |BIST has passed | + +-----+---+------------+-----+-----------------------------------+ + | 7|R/W|BIST_ERROR |0x00 |BIST has failed | + +-----+---+------------+-----+-----------------------------------+ + | 31|R/W|ALLOW_BIST |0x00 |BIST is not allowed | + +-----+---+------------+-----+-----------------------------------+ + +.. _quiddikey__PSR: PSR """ @@ -3419,87 +373,16 @@ PSR PUF Score register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+---------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+===============+ - |3:0 |R/W|PUF_SCORE|PUF Score field| - +-----+---+---------+---------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // PUF Score register - #define QUIDDIKEY_PSR_OFFSET 0xdc - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_psr_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_psr_set(uint32_t base, uint32_t value); + +-----+---+---------+-----+---------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+===============+ + |3:0 |R/W|PUF_SCORE|0x00 |PUF Score field| + +-----+---+---------+-----+---------------+ -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // PUF Score field (access: R/W) - #define QUIDDIKEY_PSR_PUF_SCORE_BIT 0 - #define QUIDDIKEY_PSR_PUF_SCORE_WIDTH 4 - #define QUIDDIKEY_PSR_PUF_SCORE_MASK 0xf - #define QUIDDIKEY_PSR_PUF_SCORE_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_PSR_PUF_SCORE_GET(value) (GAP_BEXTRACTU((value),4,0)) - #define QUIDDIKEY_PSR_PUF_SCORE_GETS(value) (GAP_BEXTRACT((value),4,0)) - #define QUIDDIKEY_PSR_PUF_SCORE_SET(value,field) (GAP_BINSERT((value),(field),4,0)) - #define QUIDDIKEY_PSR_PUF_SCORE(val) ((val) << 0) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int puf_score :4 ; // PUF Score field - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_psr_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_psr : public vp::reg_32 - { - public: - inline void puf_score_set(uint32_t value); - inline uint32_t puf_score_get(); - }; - -| - -.. _quiddikey_HW_RUC0: +.. _quiddikey__HW_RUC0: HW_RUC0 """"""" @@ -3507,87 +390,16 @@ HW_RUC0 Hardware Restrict User Context 0 register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------------------+-----------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======================+=============================+ - |31:0 |R/W|RESTRICT_USER_CONTEXT_0|Restrict User Context 0 field| - +-----+---+-----------------------+-----------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Hardware Restrict User Context 0 register - #define QUIDDIKEY_HW_RUC0_OFFSET 0xe0 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_hw_ruc0_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_hw_ruc0_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Restrict User Context 0 field (access: R/W) - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0_BIT 0 - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0_WIDTH 32 - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0_MASK 0xffffffff - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0_GET(value) (value) - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0_GETS(value) (value) - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0_SET(value,field) (field) - #define QUIDDIKEY_HW_RUC0_RESTRICT_USER_CONTEXT_0(val) ((val) << 0) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c + +-----+---+-----------------------+-----+-----------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======================+=====+=============================+ + |31:0 |R/W|RESTRICT_USER_CONTEXT_0|0x00 |Restrict User Context 0 field| + +-----+---+-----------------------+-----+-----------------------------+ - - typedef union { - struct { - unsigned int restrict_user_context_0:32; // Restrict User Context 0 field - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_hw_ruc0_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_hw_ruc0 : public vp::reg_32 - { - public: - inline void restrict_user_context_0_set(uint32_t value); - inline uint32_t restrict_user_context_0_get(); - }; - -| - -.. _quiddikey_HW_RUC1: +.. _quiddikey__HW_RUC1: HW_RUC1 """"""" @@ -3595,87 +407,16 @@ HW_RUC1 Hardware Restrict User Context 1 register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------------------+-----------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======================+=============================+ - |31:0 |R/W|RESTRICT_USER_CONTEXT_1|Restrict User Context 1 field| - +-----+---+-----------------------+-----------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Hardware Restrict User Context 1 register - #define QUIDDIKEY_HW_RUC1_OFFSET 0xe4 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_hw_ruc1_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_hw_ruc1_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* + +-----+---+-----------------------+-----+-----------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======================+=====+=============================+ + |31:0 |R/W|RESTRICT_USER_CONTEXT_1|0x00 |Restrict User Context 1 field| + +-----+---+-----------------------+-----+-----------------------------+ - .. code-block:: c - - - // Restrict User Context 1 field (access: R/W) - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1_BIT 0 - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1_WIDTH 32 - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1_MASK 0xffffffff - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1_GET(value) (value) - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1_GETS(value) (value) - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1_SET(value,field) (field) - #define QUIDDIKEY_HW_RUC1_RESTRICT_USER_CONTEXT_1(val) ((val) << 0) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int restrict_user_context_1:32; // Restrict User Context 1 field - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_hw_ruc1_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_hw_ruc1 : public vp::reg_32 - { - public: - inline void restrict_user_context_1_set(uint32_t value); - inline uint32_t restrict_user_context_1_get(); - }; - -| - -.. _quiddikey_HW_SETTINGS: +.. _quiddikey__HW_SETTINGS: HW_SETTINGS """"""""""" @@ -3683,301 +424,42 @@ HW_SETTINGS Hardware Settings register .. table:: - - +-----+---+--------------------------+------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========================+====================================+ - | 1|R/W|DISABLE_ENROLL |Enroll settings field | - +-----+---+--------------------------+------------------------------------+ - | 2|R/W|DISABLE_START |Start settings field | - +-----+---+--------------------------+------------------------------------+ - | 5|R/W|DISABLE_STOP |Stop settings field | - +-----+---+--------------------------+------------------------------------+ - | 6|R/W|DISABLE_GET_KEY |Get Key settings field | - +-----+---+--------------------------+------------------------------------+ - | 7|R/W|DISABLE_UNWRAP |Unwrap settings field | - +-----+---+--------------------------+------------------------------------+ - | 8|R/W|DISABLE_WRAP_GEN_RND |Wrap Generated Random settings field| - +-----+---+--------------------------+------------------------------------+ - | 9|R/W|DISABLE_WRAP |Wrap settings field | - +-----+---+--------------------------+------------------------------------+ - | 15|R/W|DISABLE_GEN_RND |Generate Random settings field | - +-----+---+--------------------------+------------------------------------+ - | 16|R/W|DISABLE_RESEED |Reseed settings field | - +-----+---+--------------------------+------------------------------------+ - | 24|R/W|DISABLE_LAB_TEST_MODE |Lab Test Mode settings field | - +-----+---+--------------------------+------------------------------------+ - | 25|R/W|SELECT_LAB_TEST_MODE |Lab Test Mode select field | - +-----+---+--------------------------+------------------------------------+ - | 27|R/W|REQUIRE_RESEED_SRC_VIA_DIR|Reseed via DIR settings field | - +-----+---+--------------------------+------------------------------------+ - | 28|R/W|REQUIRE_RESEED_SRC_VIA_SI |Reseed via SI settings field | - +-----+---+--------------------------+------------------------------------+ - | 31|R/W|DISABLE_TEST_PUF |Test PUF settings field | - +-----+---+--------------------------+------------------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Hardware Settings register - #define QUIDDIKEY_HW_SETTINGS_OFFSET 0xf0 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_hw_settings_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_hw_settings_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Enroll settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL_BIT 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL_MASK 0x2 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL_RESET 0x0 - - // Start settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START_BIT 2 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START_MASK 0x4 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START_RESET 0x0 - - // Stop settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP_BIT 5 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP_MASK 0x20 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP_RESET 0x0 - - // Get Key settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY_BIT 6 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY_MASK 0x40 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY_RESET 0x0 - - // Unwrap settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP_BIT 7 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP_MASK 0x80 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP_RESET 0x0 - - // Wrap Generated Random settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND_BIT 8 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND_MASK 0x100 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND_RESET 0x0 - - // Wrap settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_BIT 9 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_MASK 0x200 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_RESET 0x0 - - // Generate Random settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND_BIT 15 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND_MASK 0x8000 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND_RESET 0x0 - - // Reseed settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED_BIT 16 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED_MASK 0x10000 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED_RESET 0x0 - - // Lab Test Mode settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE_BIT 24 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE_MASK 0x1000000 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE_RESET 0x0 - - // Lab Test Mode select field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE_BIT 25 - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE_MASK 0x2000000 - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE_RESET 0x0 - - // Reseed via DIR settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR_BIT 27 - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR_MASK 0x8000000 - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR_RESET 0x0 - - // Reseed via SI settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI_BIT 28 - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI_MASK 0x10000000 - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI_RESET 0x0 - - // Test PUF settings field (access: R/W) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF_BIT 31 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF_WIDTH 1 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF_MASK 0x80000000 - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL_GET(value) (GAP_BEXTRACTU((value),1,1)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL_GETS(value) (GAP_BEXTRACT((value),1,1)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL_SET(value,field) (GAP_BINSERT((value),(field),1,1)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_ENROLL(val) ((val) << 1) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START_GET(value) (GAP_BEXTRACTU((value),1,2)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START_GETS(value) (GAP_BEXTRACT((value),1,2)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START_SET(value,field) (GAP_BINSERT((value),(field),1,2)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_START(val) ((val) << 2) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP_GET(value) (GAP_BEXTRACTU((value),1,5)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP_GETS(value) (GAP_BEXTRACT((value),1,5)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP_SET(value,field) (GAP_BINSERT((value),(field),1,5)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_STOP(val) ((val) << 5) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY_GET(value) (GAP_BEXTRACTU((value),1,6)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY_GETS(value) (GAP_BEXTRACT((value),1,6)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY_SET(value,field) (GAP_BINSERT((value),(field),1,6)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GET_KEY(val) ((val) << 6) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP_GET(value) (GAP_BEXTRACTU((value),1,7)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP_GETS(value) (GAP_BEXTRACT((value),1,7)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP_SET(value,field) (GAP_BINSERT((value),(field),1,7)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_UNWRAP(val) ((val) << 7) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND_GET(value) (GAP_BEXTRACTU((value),1,8)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND_GETS(value) (GAP_BEXTRACT((value),1,8)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND_SET(value,field) (GAP_BINSERT((value),(field),1,8)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GEN_RND(val) ((val) << 8) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GET(value) (GAP_BEXTRACTU((value),1,9)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_GETS(value) (GAP_BEXTRACT((value),1,9)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP_SET(value,field) (GAP_BINSERT((value),(field),1,9)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_WRAP(val) ((val) << 9) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND_GET(value) (GAP_BEXTRACTU((value),1,15)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND_GETS(value) (GAP_BEXTRACT((value),1,15)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND_SET(value,field) (GAP_BINSERT((value),(field),1,15)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_GEN_RND(val) ((val) << 15) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED_GET(value) (GAP_BEXTRACTU((value),1,16)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED_GETS(value) (GAP_BEXTRACT((value),1,16)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED_SET(value,field) (GAP_BINSERT((value),(field),1,16)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_RESEED(val) ((val) << 16) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE_GET(value) (GAP_BEXTRACTU((value),1,24)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE_GETS(value) (GAP_BEXTRACT((value),1,24)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE_SET(value,field) (GAP_BINSERT((value),(field),1,24)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_LAB_TEST_MODE(val) ((val) << 24) - - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE_GET(value) (GAP_BEXTRACTU((value),1,25)) - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE_GETS(value) (GAP_BEXTRACT((value),1,25)) - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE_SET(value,field) (GAP_BINSERT((value),(field),1,25)) - #define QUIDDIKEY_HW_SETTINGS_SELECT_LAB_TEST_MODE(val) ((val) << 25) - - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR_GET(value) (GAP_BEXTRACTU((value),1,27)) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR_GETS(value) (GAP_BEXTRACT((value),1,27)) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR_SET(value,field) (GAP_BINSERT((value),(field),1,27)) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_DIR(val) ((val) << 27) - - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI_GET(value) (GAP_BEXTRACTU((value),1,28)) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI_GETS(value) (GAP_BEXTRACT((value),1,28)) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI_SET(value,field) (GAP_BINSERT((value),(field),1,28)) - #define QUIDDIKEY_HW_SETTINGS_REQUIRE_RESEED_SRC_VIA_SI(val) ((val) << 28) - - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF_GET(value) (GAP_BEXTRACTU((value),1,31)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF_GETS(value) (GAP_BEXTRACT((value),1,31)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF_SET(value,field) (GAP_BINSERT((value),(field),1,31)) - #define QUIDDIKEY_HW_SETTINGS_DISABLE_TEST_PUF(val) ((val) << 31) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int padding0:1 ; - unsigned int disable_enroll :1 ; // Enroll settings field - unsigned int disable_start :1 ; // Start settings field - unsigned int padding1:2 ; - unsigned int disable_stop :1 ; // Stop settings field - unsigned int disable_get_key :1 ; // Get Key settings field - unsigned int disable_unwrap :1 ; // Unwrap settings field - unsigned int disable_wrap_gen_rnd:1 ; // Wrap Generated Random settings field - unsigned int disable_wrap :1 ; // Wrap settings field - unsigned int padding2:5 ; - unsigned int disable_gen_rnd :1 ; // Generate Random settings field - unsigned int disable_reseed :1 ; // Reseed settings field - unsigned int padding3:7 ; - unsigned int disable_lab_test_mode:1 ; // Lab Test Mode settings field - unsigned int select_lab_test_mode:1 ; // Lab Test Mode select field - unsigned int padding4:1 ; - unsigned int require_reseed_src_via_dir:1 ; // Reseed via DIR settings field - unsigned int require_reseed_src_via_si:1 ; // Reseed via SI settings field - unsigned int padding5:2 ; - unsigned int disable_test_puf:1 ; // Test PUF settings field - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_hw_settings_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_hw_settings : public vp::reg_32 - { - public: - inline void disable_enroll_set(uint32_t value); - inline uint32_t disable_enroll_get(); - inline void disable_start_set(uint32_t value); - inline uint32_t disable_start_get(); - inline void disable_stop_set(uint32_t value); - inline uint32_t disable_stop_get(); - inline void disable_get_key_set(uint32_t value); - inline uint32_t disable_get_key_get(); - inline void disable_unwrap_set(uint32_t value); - inline uint32_t disable_unwrap_get(); - inline void disable_wrap_gen_rnd_set(uint32_t value); - inline uint32_t disable_wrap_gen_rnd_get(); - inline void disable_wrap_set(uint32_t value); - inline uint32_t disable_wrap_get(); - inline void disable_gen_rnd_set(uint32_t value); - inline uint32_t disable_gen_rnd_get(); - inline void disable_reseed_set(uint32_t value); - inline uint32_t disable_reseed_get(); - inline void disable_lab_test_mode_set(uint32_t value); - inline uint32_t disable_lab_test_mode_get(); - inline void select_lab_test_mode_set(uint32_t value); - inline uint32_t select_lab_test_mode_get(); - inline void require_reseed_src_via_dir_set(uint32_t value); - inline uint32_t require_reseed_src_via_dir_get(); - inline void require_reseed_src_via_si_set(uint32_t value); - inline uint32_t require_reseed_src_via_si_get(); - inline void disable_test_puf_set(uint32_t value); - inline uint32_t disable_test_puf_get(); - }; - -| - -.. _quiddikey_HW_INFO: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------------------+-----+------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========================+=====+====================================+ + | 1|R/W|DISABLE_ENROLL |0x00 |Enroll settings field | + +-----+---+--------------------------+-----+------------------------------------+ + | 2|R/W|DISABLE_START |0x00 |Start settings field | + +-----+---+--------------------------+-----+------------------------------------+ + | 5|R/W|DISABLE_STOP |0x00 |Stop settings field | + +-----+---+--------------------------+-----+------------------------------------+ + | 6|R/W|DISABLE_GET_KEY |0x00 |Get Key settings field | + +-----+---+--------------------------+-----+------------------------------------+ + | 7|R/W|DISABLE_UNWRAP |0x00 |Unwrap settings field | + +-----+---+--------------------------+-----+------------------------------------+ + | 8|R/W|DISABLE_WRAP_GEN_RND |0x00 |Wrap Generated Random settings field| + +-----+---+--------------------------+-----+------------------------------------+ + | 9|R/W|DISABLE_WRAP |0x00 |Wrap settings field | + +-----+---+--------------------------+-----+------------------------------------+ + | 15|R/W|DISABLE_GEN_RND |0x00 |Generate Random settings field | + +-----+---+--------------------------+-----+------------------------------------+ + | 16|R/W|DISABLE_RESEED |0x00 |Reseed settings field | + +-----+---+--------------------------+-----+------------------------------------+ + | 24|R/W|DISABLE_LAB_TEST_MODE |0x00 |Lab Test Mode settings field | + +-----+---+--------------------------+-----+------------------------------------+ + | 25|R/W|SELECT_LAB_TEST_MODE |0x00 |Lab Test Mode select field | + +-----+---+--------------------------+-----+------------------------------------+ + | 27|R/W|REQUIRE_RESEED_SRC_VIA_DIR|0x00 |Reseed via DIR settings field | + +-----+---+--------------------------+-----+------------------------------------+ + | 28|R/W|REQUIRE_RESEED_SRC_VIA_SI |0x00 |Reseed via SI settings field | + +-----+---+--------------------------+-----+------------------------------------+ + | 31|R/W|DISABLE_TEST_PUF |0x00 |Test PUF settings field | + +-----+---+--------------------------+-----+------------------------------------+ + +.. _quiddikey__HW_INFO: HW_INFO """"""" @@ -3985,153 +467,24 @@ HW_INFO Hardware Information register .. table:: - - +-----+---+----------------+-----------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+================+=========================================+ - | 21|R/W|CONFIG_SP_800_90|1: SP 800-90 is included, 0: not included| - +-----+---+----------------+-----------------------------------------+ - | 22|R/W|CONFIG_BIST |1: BIST is included, 0: not included | - +-----+---+----------------+-----------------------------------------+ - | 23|R/W|RESERVED |1: Safe, 0: Plus | - +-----+---+----------------+-----------------------------------------+ - | 24|R/W|CONFIG_WRAP |1: Wrap is included, 0: not included | - +-----+---+----------------+-----------------------------------------+ - |31:28|R/W|CONFIG_TYPE |Quiddikey configuration | - +-----+---+----------------+-----------------------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Hardware Information register - #define QUIDDIKEY_HW_INFO_OFFSET 0xf4 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_hw_info_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_hw_info_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // 1: SP 800-90 is included, 0: not included (access: R/W) - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90_BIT 21 - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90_WIDTH 1 - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90_MASK 0x200000 - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90_RESET 0x0 - - // 1: BIST is included, 0: not included (access: R/W) - #define QUIDDIKEY_HW_INFO_CONFIG_BIST_BIT 22 - #define QUIDDIKEY_HW_INFO_CONFIG_BIST_WIDTH 1 - #define QUIDDIKEY_HW_INFO_CONFIG_BIST_MASK 0x400000 - #define QUIDDIKEY_HW_INFO_CONFIG_BIST_RESET 0x0 - - // 1: Safe, 0: Plus (access: R/W) - #define QUIDDIKEY_HW_INFO_RESERVED_BIT 23 - #define QUIDDIKEY_HW_INFO_RESERVED_WIDTH 1 - #define QUIDDIKEY_HW_INFO_RESERVED_MASK 0x800000 - #define QUIDDIKEY_HW_INFO_RESERVED_RESET 0x0 - - // 1: Wrap is included, 0: not included (access: R/W) - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP_BIT 24 - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP_WIDTH 1 - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP_MASK 0x1000000 - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP_RESET 0x0 - - // Quiddikey configuration (access: R/W) - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE_BIT 28 - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE_WIDTH 4 - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE_MASK 0xf0000000 - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90_GET(value) (GAP_BEXTRACTU((value),1,21)) - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90_GETS(value) (GAP_BEXTRACT((value),1,21)) - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90_SET(value,field) (GAP_BINSERT((value),(field),1,21)) - #define QUIDDIKEY_HW_INFO_CONFIG_SP_800_90(val) ((val) << 21) - - #define QUIDDIKEY_HW_INFO_CONFIG_BIST_GET(value) (GAP_BEXTRACTU((value),1,22)) - #define QUIDDIKEY_HW_INFO_CONFIG_BIST_GETS(value) (GAP_BEXTRACT((value),1,22)) - #define QUIDDIKEY_HW_INFO_CONFIG_BIST_SET(value,field) (GAP_BINSERT((value),(field),1,22)) - #define QUIDDIKEY_HW_INFO_CONFIG_BIST(val) ((val) << 22) - - #define QUIDDIKEY_HW_INFO_RESERVED_GET(value) (GAP_BEXTRACTU((value),1,23)) - #define QUIDDIKEY_HW_INFO_RESERVED_GETS(value) (GAP_BEXTRACT((value),1,23)) - #define QUIDDIKEY_HW_INFO_RESERVED_SET(value,field) (GAP_BINSERT((value),(field),1,23)) - #define QUIDDIKEY_HW_INFO_RESERVED(val) ((val) << 23) - - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP_GET(value) (GAP_BEXTRACTU((value),1,24)) - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP_GETS(value) (GAP_BEXTRACT((value),1,24)) - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP_SET(value,field) (GAP_BINSERT((value),(field),1,24)) - #define QUIDDIKEY_HW_INFO_CONFIG_WRAP(val) ((val) << 24) - - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE_GET(value) (GAP_BEXTRACTU((value),4,28)) - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE_GETS(value) (GAP_BEXTRACT((value),4,28)) - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE_SET(value,field) (GAP_BINSERT((value),(field),4,28)) - #define QUIDDIKEY_HW_INFO_CONFIG_TYPE(val) ((val) << 28) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int padding0:21; - unsigned int config_sp_800_90:1 ; // 1: SP 800-90 is included, 0: not included - unsigned int config_bist :1 ; // 1: BIST is included, 0: not included - unsigned int reserved :1 ; // 1: Safe, 0: Plus - unsigned int config_wrap :1 ; // 1: Wrap is included, 0: not included - unsigned int padding1:3 ; - unsigned int config_type :4 ; // Quiddikey configuration - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_hw_info_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_hw_info : public vp::reg_32 - { - public: - inline void config_sp_800_90_set(uint32_t value); - inline uint32_t config_sp_800_90_get(); - inline void config_bist_set(uint32_t value); - inline uint32_t config_bist_get(); - inline void reserved_set(uint32_t value); - inline uint32_t reserved_get(); - inline void config_wrap_set(uint32_t value); - inline uint32_t config_wrap_get(); - inline void config_type_set(uint32_t value); - inline uint32_t config_type_get(); - }; - -| - -.. _quiddikey_HW_ID: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------+-----+-----------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+================+=====+=========================================+ + | 21|R/W|CONFIG_SP_800_90|0x00 |1: SP 800-90 is included, 0: not included| + +-----+---+----------------+-----+-----------------------------------------+ + | 22|R/W|CONFIG_BIST |0x00 |1: BIST is included, 0: not included | + +-----+---+----------------+-----+-----------------------------------------+ + | 23|R/W|RESERVED |0x00 |1: Safe, 0: Plus | + +-----+---+----------------+-----+-----------------------------------------+ + | 24|R/W|CONFIG_WRAP |0x00 |1: Wrap is included, 0: not included | + +-----+---+----------------+-----+-----------------------------------------+ + |31:28|R/W|CONFIG_TYPE |0x00 |Quiddikey configuration | + +-----+---+----------------+-----+-----------------------------------------+ + +.. _quiddikey__HW_ID: HW_ID """"" @@ -4139,87 +492,16 @@ HW_ID Hardware Identifier register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+===================+ - |31:0 |R/W|HW_ID|Hardware Identifier| - +-----+---+-----+-------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Hardware Identifier register - #define QUIDDIKEY_HW_ID_OFFSET 0xf8 - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_hw_id_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_hw_id_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Hardware Identifier (access: R/W) - #define QUIDDIKEY_HW_ID_HW_ID_BIT 0 - #define QUIDDIKEY_HW_ID_HW_ID_WIDTH 32 - #define QUIDDIKEY_HW_ID_HW_ID_MASK 0xffffffff - #define QUIDDIKEY_HW_ID_HW_ID_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_HW_ID_HW_ID_GET(value) (value) - #define QUIDDIKEY_HW_ID_HW_ID_GETS(value) (value) - #define QUIDDIKEY_HW_ID_HW_ID_SET(value,field) (field) - #define QUIDDIKEY_HW_ID_HW_ID(val) ((val) << 0) + +-----+---+-----+-----+-------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===================+ + |31:0 |R/W|HW_ID|0x00 |Hardware Identifier| + +-----+---+-----+-----+-------------------+ -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int hw_id :32; // Hardware Identifier - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_hw_id_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_hw_id : public vp::reg_32 - { - public: - inline void hw_id_set(uint32_t value); - inline uint32_t hw_id_get(); - }; - -| - -.. _quiddikey_HW_VER: +.. _quiddikey__HW_VER: HW_VER """""" @@ -4227,114 +509,15 @@ HW_VER Hardware Version register .. table:: - - +-----+---+------------+-------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+===============================+ - |7:0 |R/W|HW_VER_REV |Hardware version, revision part| - +-----+---+------------+-------------------------------+ - |15:8 |R/W|HW_VER_MINOR|Hardware version, minor part | - +-----+---+------------+-------------------------------+ - |23:16|R/W|HW_VER_MAJOR|Hardware version, major part | - +-----+---+------------+-------------------------------+ - -Generated headers -""""""""""""""""" - - -.. toggle-header:: - :header: *Register map C offsets* - - .. code-block:: c - - - // Hardware Version register - #define QUIDDIKEY_HW_VER_OFFSET 0xfc - -.. toggle-header:: - :header: *Register accessors* - - .. code-block:: c - - - static inline __attribute__((always_inline)) uint32_t quiddikey_hw_ver_get(uint32_t base); - static inline __attribute__((always_inline)) void quiddikey_hw_ver_set(uint32_t base, uint32_t value); - -.. toggle-header:: - :header: *Register fields defines* - - .. code-block:: c - - - // Hardware version, revision part (access: R/W) - #define QUIDDIKEY_HW_VER_HW_VER_REV_BIT 0 - #define QUIDDIKEY_HW_VER_HW_VER_REV_WIDTH 8 - #define QUIDDIKEY_HW_VER_HW_VER_REV_MASK 0xff - #define QUIDDIKEY_HW_VER_HW_VER_REV_RESET 0x0 - - // Hardware version, minor part (access: R/W) - #define QUIDDIKEY_HW_VER_HW_VER_MINOR_BIT 8 - #define QUIDDIKEY_HW_VER_HW_VER_MINOR_WIDTH 8 - #define QUIDDIKEY_HW_VER_HW_VER_MINOR_MASK 0xff00 - #define QUIDDIKEY_HW_VER_HW_VER_MINOR_RESET 0x0 - - // Hardware version, major part (access: R/W) - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR_BIT 16 - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR_WIDTH 8 - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR_MASK 0xff0000 - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR_RESET 0x0 - -.. toggle-header:: - :header: *Register fields macros* - - .. code-block:: c - - - #define QUIDDIKEY_HW_VER_HW_VER_REV_GET(value) (GAP_BEXTRACTU((value),8,0)) - #define QUIDDIKEY_HW_VER_HW_VER_REV_GETS(value) (GAP_BEXTRACT((value),8,0)) - #define QUIDDIKEY_HW_VER_HW_VER_REV_SET(value,field) (GAP_BINSERT((value),(field),8,0)) - #define QUIDDIKEY_HW_VER_HW_VER_REV(val) ((val) << 0) - - #define QUIDDIKEY_HW_VER_HW_VER_MINOR_GET(value) (GAP_BEXTRACTU((value),8,8)) - #define QUIDDIKEY_HW_VER_HW_VER_MINOR_GETS(value) (GAP_BEXTRACT((value),8,8)) - #define QUIDDIKEY_HW_VER_HW_VER_MINOR_SET(value,field) (GAP_BINSERT((value),(field),8,8)) - #define QUIDDIKEY_HW_VER_HW_VER_MINOR(val) ((val) << 8) - - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR_GET(value) (GAP_BEXTRACTU((value),8,16)) - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR_GETS(value) (GAP_BEXTRACT((value),8,16)) - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR_SET(value,field) (GAP_BINSERT((value),(field),8,16)) - #define QUIDDIKEY_HW_VER_HW_VER_MAJOR(val) ((val) << 16) - -.. toggle-header:: - :header: *Register fields structures* - - .. code-block:: c - - - typedef union { - struct { - unsigned int hw_ver_rev :8 ; // Hardware version, revision part - unsigned int hw_ver_minor :8 ; // Hardware version, minor part - unsigned int hw_ver_major :8 ; // Hardware version, major part - }; - unsigned int raw; - } __attribute__((packed)) quiddikey_hw_ver_t; - -.. toggle-header:: - :header: *GVSOC registers* - - .. code-block:: c - - - class vp_quiddikey_hw_ver : public vp::reg_32 - { - public: - inline void hw_ver_rev_set(uint32_t value); - inline uint32_t hw_ver_rev_get(); - inline void hw_ver_minor_set(uint32_t value); - inline uint32_t hw_ver_minor_get(); - inline void hw_ver_major_set(uint32_t value); - inline uint32_t hw_ver_major_get(); - }; - -| + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+===============================+ + |7:0 |R/W|HW_VER_REV |0x00 |Hardware version, revision part| + +-----+---+------------+-----+-------------------------------+ + |15:8 |R/W|HW_VER_MINOR|0x00 |Hardware version, minor part | + +-----+---+------------+-----+-------------------------------+ + |23:16|R/W|HW_VER_MAJOR|0x00 |Hardware version, major part | + +-----+---+------------+-----+-------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/riscv_dbg_dm.rst b/rtos/pulp/gap_archi/doc/ips/riscv_dbg_dm.rst index 20dacf5da..ed3d7ff4e 100644 --- a/rtos/pulp/gap_archi/doc/ips/riscv_dbg_dm.rst +++ b/rtos/pulp/gap_archi/doc/ips/riscv_dbg_dm.rst @@ -8,51 +8,56 @@ Register map Overview """""""" -.. table:: - +------------------------------------------+------+-----+------------------------------------+ - | Name |Offset|Width| Description | - +==========================================+======+=====+====================================+ - |:ref:`data0` | 4| 32|Abstract Data 0 | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`data1` | 5| 32|Abstract Data 1 | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`dmcontrol` | 16| 32|Debug Module Control | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`dmstatus` | 17| 32|Debug Module Status | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`hartinfo` | 18| 32|Hart Info | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`abstractcs`| 22| 32|Abstract Control and Status | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`command` | 23| 32|Abstract Command | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`sbcs` | 56| 32|System Bus Access Control and Status| - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`progbuf0` | 32| 32|Program Buffer 0 | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`progbuf1` | 33| 32|Program Buffer 1 | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`progbuf2` | 34| 32|Program Buffer 2 | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`progbuf3` | 35| 32|Program Buffer 3 | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`progbuf4` | 36| 32|Program Buffer 4 | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`progbuf5` | 37| 32|Program Buffer 5 | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`progbuf6` | 38| 32|Program Buffer 6 | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`progbuf7` | 39| 32|Program Buffer 7 | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`sbaddress0`| 57| 32|System Bus Address 31:0 | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`dmcs2` | 50| 32|Debug Module Control and Status 2 | - +------------------------------------------+------+-----+------------------------------------+ - |:ref:`sbdata0` | 60| 32|System Bus data 31:0 | - +------------------------------------------+------+-----+------------------------------------+ - -.. _riscv_dbg_dm_data0: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-------------------------------------------+------+-----+------------------------------------+ + | Name |Offset|Width| Description | + +===========================================+======+=====+====================================+ + |:ref:`data0` | 4| 32|Abstract Data 0 | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`data1` | 5| 32|Abstract Data 1 | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`dmcontrol` | 16| 32|Debug Module Control | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`dmstatus` | 17| 32|Debug Module Status | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`hartinfo` | 18| 32|Hart Info | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`abstractcs`| 22| 32|Abstract Control and Status | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`command` | 23| 32|Abstract Command | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`sbcs` | 56| 32|System Bus Access Control and Status| + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`progbuf0` | 32| 32|Program Buffer 0 | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`progbuf1` | 33| 32|Program Buffer 1 | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`progbuf2` | 34| 32|Program Buffer 2 | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`progbuf3` | 35| 32|Program Buffer 3 | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`progbuf4` | 36| 32|Program Buffer 4 | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`progbuf5` | 37| 32|Program Buffer 5 | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`progbuf6` | 38| 32|Program Buffer 6 | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`progbuf7` | 39| 32|Program Buffer 7 | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`sbaddress0`| 57| 32|System Bus Address 31:0 | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`dmcs2` | 50| 32|Debug Module Control and Status 2 | + +-------------------------------------------+------+-----+------------------------------------+ + |:ref:`sbdata0` | 60| 32|System Bus data 31:0 | + +-------------------------------------------+------+-----+------------------------------------+ + +.. _riscv_dbg_dm__data0: data0 """"" @@ -60,14 +65,16 @@ data0 Abstract Data 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - |31:0 |R/W|data|Data value | - +-----+---+----+-----------+ + +-----+---+----+-----+-----------+ + |Bit #|R/W|Name|Reset|Description| + +=====+===+====+=====+===========+ + |31:0 |R/W|data|-- |Data value | + +-----+---+----+-----+-----------+ -.. _riscv_dbg_dm_data1: +.. _riscv_dbg_dm__data1: data1 """"" @@ -75,14 +82,16 @@ data1 Abstract Data 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - |31:0 |R/W|data|Data value | - +-----+---+----+-----------+ + +-----+---+----+-----+-----------+ + |Bit #|R/W|Name|Reset|Description| + +=====+===+====+=====+===========+ + |31:0 |R/W|data|-- |Data value | + +-----+---+----+-----+-----------+ -.. _riscv_dbg_dm_dmcontrol: +.. _riscv_dbg_dm__dmcontrol: dmcontrol """"""""" @@ -90,34 +99,36 @@ dmcontrol Debug Module Control .. table:: - - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+=======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================+ - | 0|R/W|dmactive |This bit serves as a reset signal for the DebugModule itself.0: The module’s state, including authenticationmechanism, takes its reset values (thedmactivebitis the only bit which can be written to somethingother than its reset value).1: The module functions normally.No other mechanism should exist that may resultin resetting the Debug Module after power up,with the possible (but not recommended) excep-tion of a global reset signal that resets the entireplatform.A debugger may pulse this bit low to get the De-bug Module into a known state.Implementations may pay attention to this bit tofurther aid debugging, for example by preventingthe Debug Module from being power gated whiledebugging is active.| - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|ndmreset |This bit controls the reset signal from the DM tothe rest of the system. The signal should resetevery part of the system, including every hart,except for the DM and any logic required to accessthe DM. To perform a system reset the debuggerwrites 1, and then writes 0 to deassert the reset. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 2|R/W|clrresethaltreq|This optional field clears the halt-on-reset requestbit for all currently selected harts.Writes apply to the new value ofhartselandhasel. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 3|R/W|setresethaltreq|This optional field writes the halt-on-reset re-quest bit for all currently selected harts, unlessclrresethaltreqis simultaneously set to 1. Whenset to 1, each selected hart will halt upon the nextdeassertion of its reset. The halt-on-reset requestbit is not automatically cleared. The debuggermust write toclrresethaltreqto clear it.Writes apply to the new value ofhartselandhasel.Ifhasresethaltreqis 0, this field is not imple-mented. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15:6 |R/W|hartselhi |The high 10 bits ofhartsel: the DM-specific indexof the hart to select. This hart is always part ofthe currently selected harts. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |25:16|R/W|hartsello |The low 10 bits ofhartsel: the DM-specific indexof the hart to select. This hart is always part ofthe currently selected harts. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 26|R/W|hasel |Selects the definition of currently selected harts.0: There is a single currently selected hart, thatis selected byhartsel.1: There may be multiple currently selected harts– the hart selected byhartsel, plus those selectedby the hart array mask register.An implementation which does not implement thehart array mask register must tie this field to 0.A debugger which wishes to use the hart arraymask register feature should set this bit and readback to see if the functionality is supported. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 28|R/W|ackhavereset |0: No effect.1: Clearshaveresetfor any selected harts.Writes apply to the new value ofhartselandhasel. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 29|R/W|hartreset |This optional field writes the reset bit for all thecurrently selected harts. To perform a reset thedebugger writes 1, and then writes 0 to deassertthe reset signal.While this bit is 1, the debugger must not changewhich harts are selected.If this feature is not implemented, the bit alwaysstays 0, so after writing 1 the debugger can readthe register back to see if the feature is supported.Writes apply to the new value ofhartselandhasel. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 30|R/W|resumereq |Writing 1 causes the currently selected harts toresume once, if they are halted when the writeoccurs. It also clears the resume ack bit for thoseharts.resumereqis ignored ifhaltreqis set.Writes apply to the new value ofhartselandhasel. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 31|R/W|haltreq |Writing 0 clears the halt request bit for all cur-rently selected harts. This may cancel outstand-ing halt requests for those harts.Writing 1 sets the halt request bit for all currentlyselected harts. Running harts will halt whenevertheir halt request bit is set.Writes apply to the new value ofhartselandhasel. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _riscv_dbg_dm_dmstatus: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+=======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================+ + | 0|R/W|dmactive |-- |This bit serves as a reset signal for the DebugModule itself.0: The module’s state, including authenticationmechanism, takes its reset values (thedmactivebitis the only bit which can be written to somethingother than its reset value).1: The module functions normally.No other mechanism should exist that may resultin resetting the Debug Module after power up,with the possible (but not recommended) excep-tion of a global reset signal that resets the entireplatform.A debugger may pulse this bit low to get the De-bug Module into a known state.Implementations may pay attention to this bit tofurther aid debugging, for example by preventingthe Debug Module from being power gated whiledebugging is active.| + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|ndmreset |-- |This bit controls the reset signal from the DM tothe rest of the system. The signal should resetevery part of the system, including every hart,except for the DM and any logic required to accessthe DM. To perform a system reset the debuggerwrites 1, and then writes 0 to deassert the reset. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 2|R/W|clrresethaltreq|-- |This optional field clears the halt-on-reset requestbit for all currently selected harts.Writes apply to the new value ofhartselandhasel. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 3|R/W|setresethaltreq|-- |This optional field writes the halt-on-reset re-quest bit for all currently selected harts, unlessclrresethaltreqis simultaneously set to 1. Whenset to 1, each selected hart will halt upon the nextdeassertion of its reset. The halt-on-reset requestbit is not automatically cleared. The debuggermust write toclrresethaltreqto clear it.Writes apply to the new value ofhartselandhasel.Ifhasresethaltreqis 0, this field is not imple-mented. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:6 |R/W|hartselhi |-- |The high 10 bits ofhartsel: the DM-specific indexof the hart to select. This hart is always part ofthe currently selected harts. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |25:16|R/W|hartsello |-- |The low 10 bits ofhartsel: the DM-specific indexof the hart to select. This hart is always part ofthe currently selected harts. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 26|R/W|hasel |-- |Selects the definition of currently selected harts.0: There is a single currently selected hart, thatis selected byhartsel.1: There may be multiple currently selected harts– the hart selected byhartsel, plus those selectedby the hart array mask register.An implementation which does not implement thehart array mask register must tie this field to 0.A debugger which wishes to use the hart arraymask register feature should set this bit and readback to see if the functionality is supported. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 28|R/W|ackhavereset |-- |0: No effect.1: Clearshaveresetfor any selected harts.Writes apply to the new value ofhartselandhasel. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 29|R/W|hartreset |-- |This optional field writes the reset bit for all thecurrently selected harts. To perform a reset thedebugger writes 1, and then writes 0 to deassertthe reset signal.While this bit is 1, the debugger must not changewhich harts are selected.If this feature is not implemented, the bit alwaysstays 0, so after writing 1 the debugger can readthe register back to see if the feature is supported.Writes apply to the new value ofhartselandhasel. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 30|R/W|resumereq |-- |Writing 1 causes the currently selected harts toresume once, if they are halted when the writeoccurs. It also clears the resume ack bit for thoseharts.resumereqis ignored ifhaltreqis set.Writes apply to the new value ofhartselandhasel. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 31|R/W|haltreq |-- |Writing 0 clears the halt request bit for all cur-rently selected harts. This may cancel outstand-ing halt requests for those harts.Writing 1 sets the halt request bit for all currentlyselected harts. Running harts will halt whenevertheir halt request bit is set.Writes apply to the new value ofhartselandhasel. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _riscv_dbg_dm__dmstatus: dmstatus """""""" @@ -125,48 +136,50 @@ dmstatus Debug Module Status .. table:: - - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+===================================================================================================================================================================================================================================================================================================+ - |3:0 |R |version |0: There is no Debug Module present.1: There is a Debug Module and it conforms toversion 0.11 of this specification.2: There is a Debug Module and it conforms toversion 0.13 of this specification.15: There is a Debug Module but it does not con-form to any available version of this spec.| - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |4 |R |confstrptrvalid|0:confstrptr0–confstrptr3hold informationwhich is not relevant to the configuration string.1:confstrptr0–confstrptr3hold the addressof the configuration string. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |5 |R |hasresethaltreq|1 if this Debug Module supports halt-on-resetfunctionality controllable by thesetresethaltreqandclrresethaltreqbits. 0 otherwise. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |6 |R |authbusy |0: The authentication module is ready to processthe next read/write toauthdata.1: The authentication module is busy. Accessingauthdataresults in unspecified behavior.authbusyonly becomes set in immediate responseto an access toauthdata. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |7 |R |authenticated |0: Authentication is required before using theDM.1: The authentication check has passed.On components that don’t implement authentica-tion, this bit must be preset as 1. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |8 |R |anyhalted |This field is 1 when any currently selected hart ishalted. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |9 |R |allhalted |This field is 1 when all currently selected hartsare halted. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10 |R |anyrunning |This field is 1 when any currently selected hart isrunning. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |11 |R |allrunning |This field is 1 when all currently selected hartsare running. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |12 |R |anyunavail |This field is 1 when any currently selected hart isunavailable. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |13 |R |allunavail |This field is 1 when all currently selected hartsare unavailable. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |14 |R |anynonexistent |This field is 1 when any currently selected hartdoes not exist in this platform. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15 |R |allnonexistent |This field is 1 when all currently selected harts donot exist in this platform. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |16 |R |anyresumeack |This field is 1 when any currently selected harthas acknowledged its last resume request. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |17 |R |allresumeack |This field is 1 when all currently selected hartshave acknowledged their last resume request. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18 |R |anyhavereset |This field is 1 when at least one currently selectedhart has been reset and reset has not been ac-knowledged for that hart. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |19 |R |allhavereset |This field is 1 when all currently selected hartshave been reset and reset has not been acknowl-edged for any of them. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |22 |R |impebreak |If 1, then there is an implicitebreakinstructionat the non-existent word immediately after theProgram Buffer. This saves the debugger fromhaving to write theebreakitself, and allows theProgram Buffer to be one word smaller.This must be 1 whenprogbufsizeis 1. | - +-----+---+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _riscv_dbg_dm_hartinfo: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+===================================================================================================================================================================================================================================================================================================+ + |3:0 |R |version |-- |0: There is no Debug Module present.1: There is a Debug Module and it conforms toversion 0.11 of this specification.2: There is a Debug Module and it conforms toversion 0.13 of this specification.15: There is a Debug Module but it does not con-form to any available version of this spec.| + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |4 |R |confstrptrvalid|-- |0:confstrptr0–confstrptr3hold informationwhich is not relevant to the configuration string.1:confstrptr0–confstrptr3hold the addressof the configuration string. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |5 |R |hasresethaltreq|-- |1 if this Debug Module supports halt-on-resetfunctionality controllable by thesetresethaltreqandclrresethaltreqbits. 0 otherwise. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |6 |R |authbusy |-- |0: The authentication module is ready to processthe next read/write toauthdata.1: The authentication module is busy. Accessingauthdataresults in unspecified behavior.authbusyonly becomes set in immediate responseto an access toauthdata. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |authenticated |-- |0: Authentication is required before using theDM.1: The authentication check has passed.On components that don’t implement authentica-tion, this bit must be preset as 1. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |8 |R |anyhalted |-- |This field is 1 when any currently selected hart ishalted. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |9 |R |allhalted |-- |This field is 1 when all currently selected hartsare halted. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10 |R |anyrunning |-- |This field is 1 when any currently selected hart isrunning. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |11 |R |allrunning |-- |This field is 1 when all currently selected hartsare running. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R |anyunavail |-- |This field is 1 when any currently selected hart isunavailable. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R |allunavail |-- |This field is 1 when all currently selected hartsare unavailable. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |14 |R |anynonexistent |-- |This field is 1 when any currently selected hartdoes not exist in this platform. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R |allnonexistent |-- |This field is 1 when all currently selected harts donot exist in this platform. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |16 |R |anyresumeack |-- |This field is 1 when any currently selected harthas acknowledged its last resume request. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |17 |R |allresumeack |-- |This field is 1 when all currently selected hartshave acknowledged their last resume request. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18 |R |anyhavereset |-- |This field is 1 when at least one currently selectedhart has been reset and reset has not been ac-knowledged for that hart. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |19 |R |allhavereset |-- |This field is 1 when all currently selected hartshave been reset and reset has not been acknowl-edged for any of them. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |22 |R |impebreak |-- |If 1, then there is an implicitebreakinstructionat the non-existent word immediately after theProgram Buffer. This saves the debugger fromhaving to write theebreakitself, and allows theProgram Buffer to be one word smaller.This must be 1 whenprogbufsizeis 1. | + +-----+---+---------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _riscv_dbg_dm__hartinfo: hartinfo """""""" @@ -174,20 +187,22 @@ hartinfo Hart Info .. table:: - - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+================================================================================================================================================================================================================================================================================+ - |11:0 |R |dataaddr |Ifdataaccessis 0: The number of the first CSRdedicated to shadowing thedataregisters.Ifdataaccessis 1: Signed address of RAM wherethedataregisters are shadowed, to be used toaccess relative tozero. | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15:12|R |datasize |Ifdataaccessis 0: Number of CSRs dedicated toshadowing thedataregisters.Ifdataaccessis 1: Number of 32-bit words in thememory map dedicated to shadowing thedataregisters.Since there are at most 12dataregisters, thevalue in this register must be 12 or smaller.| - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |16 |R |dataaccess|0: Thedataregisters are shadowed in the hartby CSRs. Each CSR is DXLEN bits in size, andcorresponds to a single argument, per Table 3.1.1: Thedataregisters are shadowed in the hart’smemory map. Each register takes up 4 bytes inthe memory map. | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |23:20|R |nscratch |Number ofdscratchregisters available for thedebugger to use during program buffer execution,starting fromdscratch0. The debugger can makeno assumptions about the contents of these regis-ters between commands. | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _riscv_dbg_dm_abstractcs: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+================================================================================================================================================================================================================================================================================+ + |11:0 |R |dataaddr |-- |Ifdataaccessis 0: The number of the first CSRdedicated to shadowing thedataregisters.Ifdataaccessis 1: Signed address of RAM wherethedataregisters are shadowed, to be used toaccess relative tozero. | + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:12|R |datasize |-- |Ifdataaccessis 0: Number of CSRs dedicated toshadowing thedataregisters.Ifdataaccessis 1: Number of 32-bit words in thememory map dedicated to shadowing thedataregisters.Since there are at most 12dataregisters, thevalue in this register must be 12 or smaller.| + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |16 |R |dataaccess|-- |0: Thedataregisters are shadowed in the hartby CSRs. Each CSR is DXLEN bits in size, andcorresponds to a single argument, per Table 3.1.1: Thedataregisters are shadowed in the hart’smemory map. Each register takes up 4 bytes inthe memory map. | + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:20|R |nscratch |-- |Number ofdscratchregisters available for thedebugger to use during program buffer execution,starting fromdscratch0. The debugger can makeno assumptions about the contents of these regis-ters between commands. | + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _riscv_dbg_dm__abstractcs: abstractcs """""""""" @@ -195,20 +210,22 @@ abstractcs Abstract Control and Status .. table:: - - +-----+---+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================+ - |3:0 |R |datacount |Number ofdataregisters that are implementedas part of the abstract command interface. Validsizes are 1 – 12. | - +-----+---+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10:8 |R/W|cmderr |Gets set if an abstract command fails. The bits inthis field remain set until they are cleared by writ-ing 1 to them. No abstract command is starteduntil the value is reset to 0.This field only contains a valid value ifbusyis 0.0 (none): No error.1 (busy): An abstract command was executingwhilecommand,abstractcs, orabstractautowas written, or when one of thedataorprogbufregisters was read or written. This status is onlywritten ifcmderrcontains 0.2 (not supported): The requested command is notsupported, regardless of whether the hart is run-ning or not.3 (exception): An exception occurred while ex-ecuting the command (e.g. while executing theProgram Buffer).4 (halt/resume): The abstract command couldn’texecute because the hart wasn’t in the requiredstate (running/halted), or unavailable.5 (bus): The abstract command failed due to abus error (e.g. alignment, access size, or timeout).7 (other): The command failed for another rea-son.| - +-----+---+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |12 |R |busy |1: An abstract command is currently being exe-cuted.This bit is set as soon ascommandis written, andis not cleared until that command has completed. | - +-----+---+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |28:24|R |progbufsize|Size of the Program Buffer, in 32-bit words. Validsizes are 0 - 16. | - +-----+---+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _riscv_dbg_dm_command: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================+ + |3:0 |R |datacount |-- |Number ofdataregisters that are implementedas part of the abstract command interface. Validsizes are 1 – 12. | + +-----+---+-----------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10:8 |R/W|cmderr |-- |Gets set if an abstract command fails. The bits inthis field remain set until they are cleared by writ-ing 1 to them. No abstract command is starteduntil the value is reset to 0.This field only contains a valid value ifbusyis 0.0 (none): No error.1 (busy): An abstract command was executingwhilecommand,abstractcs, orabstractautowas written, or when one of thedataorprogbufregisters was read or written. This status is onlywritten ifcmderrcontains 0.2 (not supported): The requested command is notsupported, regardless of whether the hart is run-ning or not.3 (exception): An exception occurred while ex-ecuting the command (e.g. while executing theProgram Buffer).4 (halt/resume): The abstract command couldn’texecute because the hart wasn’t in the requiredstate (running/halted), or unavailable.5 (bus): The abstract command failed due to abus error (e.g. alignment, access size, or timeout).7 (other): The command failed for another rea-son.| + +-----+---+-----------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R |busy |-- |1: An abstract command is currently being exe-cuted.This bit is set as soon ascommandis written, andis not cleared until that command has completed. | + +-----+---+-----------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |28:24|R |progbufsize|-- |Size of the Program Buffer, in 32-bit words. Validsizes are 0 - 16. | + +-----+---+-----------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _riscv_dbg_dm__command: command """"""" @@ -216,16 +233,18 @@ command Abstract Command .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+=================================================================================================+ - |23:0 |R/W|control|This field is interpreted in a command-specificmanner, described for each abstract command.| - +-----+---+-------+-------------------------------------------------------------------------------------------------+ - |31:24|R/W|cmdtype|The type determines the overall functionality ofthis abstract command. | - +-----+---+-------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=================================================================================================+ + |23:0 |R/W|control|-- |This field is interpreted in a command-specificmanner, described for each abstract command.| + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------+ + |31:24|R/W|cmdtype|-- |The type determines the overall functionality ofthis abstract command. | + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------+ -.. _riscv_dbg_dm_sbcs: +.. _riscv_dbg_dm__sbcs: sbcs """" @@ -233,40 +252,42 @@ sbcs System Bus Access Control and Status .. table:: - - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+===============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================+ - | 0|R |sbaccess8 |1 when 8-bit system bus accesses are supported. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R |sbaccess16 |1 when 16-bit system bus accesses are supported. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 2|R |sbaccess32 |1 when 32-bit system bus accesses are supported. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 3|R |sbaccess64 |1 when 64-bit system bus accesses are supported. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 4|R |sbaccess128 |1 when 128-bit system bus accesses are supported. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |11:5 |R |sbasize |Width of system bus addresses in bits. (0 indi-cates there is no bus access support.) | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |14:12|R/W|sberror |When the Debug Module’s system bus master en-counters an error, this field gets set. The bits inthis field remain set until they are cleared by writ-ing 1 to them. While this field is non-zero, nomore system bus accesses can be initiated by theDebug Module.An implementation may report “Other” (7) forany error condition.0: There was no bus error.1: There was a timeout.2: A bad address was accessed.3: There was an alignment error.4: An access of unsupported size was requested.7: Other.| - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 15|R/W|sbreadondata |When 1, every read fromsbdata0automaticallytriggers a system bus read at the (possibly auto-incremented) address. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 16|R/W|sbautoincrement|When 1,sbaddressis incremented by the accesssize (in bytes) selected insbaccessafter every sys-tem bus access. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |19:17|R/W|sbaccess |Select the access size to use for system bus ac-cesses.0: 8-bit1: 16-bit2: 32-bit3: 64-bit4: 128-bitIfsbaccesshas an unsupported value when theDM starts a bus access, the access is not per-formed andsberroris set to 4. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 20|R/W|sbreadonaddr |When 1, every write tosbaddress0automaticallytriggers a system bus read at the new address. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 21|R |sbbusy |When 1, indicates the system bus master is busy.(Whether the system bus itself is busy is related,but not the same thing.) This bit goes high im-mediately when a read or write is requested forany reason, and does not go low until the accessis fully completed.Writes tosbcswhilesbbusyis high result in un-defined behavior. A debugger must not write tosbcsuntil it readssbbusyas 0. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |27:22|R/W|sbbusyerror |Set when the debugger attempts to read datawhile a read is in progress, or when the debug-ger initiates a new access while one is already inprogress (whilesbbusyis set). It remains set untilit’s explicitly cleared by the debugger.While this field is set, no more system bus accessescan be initiated by the Debug Module. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:29|R |sbversion |0: The System Bus interface conforms to mainlinedrafts of this spec older than 1 January, 2018.1: The System Bus interface conforms to this ver-sion of the spec.Other values are reserved for future versions. | - +-----+---+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _riscv_dbg_dm_progbuf0: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+===============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================+ + | 0|R |sbaccess8 |-- |1 when 8-bit system bus accesses are supported. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R |sbaccess16 |-- |1 when 16-bit system bus accesses are supported. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 2|R |sbaccess32 |-- |1 when 32-bit system bus accesses are supported. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 3|R |sbaccess64 |-- |1 when 64-bit system bus accesses are supported. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 4|R |sbaccess128 |-- |1 when 128-bit system bus accesses are supported. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |11:5 |R |sbasize |-- |Width of system bus addresses in bits. (0 indi-cates there is no bus access support.) | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |14:12|R/W|sberror |-- |When the Debug Module’s system bus master en-counters an error, this field gets set. The bits inthis field remain set until they are cleared by writ-ing 1 to them. While this field is non-zero, nomore system bus accesses can be initiated by theDebug Module.An implementation may report “Other” (7) forany error condition.0: There was no bus error.1: There was a timeout.2: A bad address was accessed.3: There was an alignment error.4: An access of unsupported size was requested.7: Other.| + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 15|R/W|sbreadondata |-- |When 1, every read fromsbdata0automaticallytriggers a system bus read at the (possibly auto-incremented) address. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 16|R/W|sbautoincrement|-- |When 1,sbaddressis incremented by the accesssize (in bytes) selected insbaccessafter every sys-tem bus access. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |19:17|R/W|sbaccess |-- |Select the access size to use for system bus ac-cesses.0: 8-bit1: 16-bit2: 32-bit3: 64-bit4: 128-bitIfsbaccesshas an unsupported value when theDM starts a bus access, the access is not per-formed andsberroris set to 4. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 20|R/W|sbreadonaddr |-- |When 1, every write tosbaddress0automaticallytriggers a system bus read at the new address. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 21|R |sbbusy |-- |When 1, indicates the system bus master is busy.(Whether the system bus itself is busy is related,but not the same thing.) This bit goes high im-mediately when a read or write is requested forany reason, and does not go low until the accessis fully completed.Writes tosbcswhilesbbusyis high result in un-defined behavior. A debugger must not write tosbcsuntil it readssbbusyas 0. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |27:22|R/W|sbbusyerror |-- |Set when the debugger attempts to read datawhile a read is in progress, or when the debug-ger initiates a new access while one is already inprogress (whilesbbusyis set). It remains set untilit’s explicitly cleared by the debugger.While this field is set, no more system bus accessescan be initiated by the Debug Module. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:29|R |sbversion |-- |0: The System Bus interface conforms to mainlinedrafts of this spec older than 1 January, 2018.1: The System Bus interface conforms to this ver-sion of the spec.Other values are reserved for future versions. | + +-----+---+---------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _riscv_dbg_dm__progbuf0: progbuf0 """""""" @@ -274,14 +295,16 @@ progbuf0 Program Buffer 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - |31:0 |R/W|data|Data value | - +-----+---+----+-----------+ + +-----+---+----+-----+-----------+ + |Bit #|R/W|Name|Reset|Description| + +=====+===+====+=====+===========+ + |31:0 |R/W|data|-- |Data value | + +-----+---+----+-----+-----------+ -.. _riscv_dbg_dm_progbuf1: +.. _riscv_dbg_dm__progbuf1: progbuf1 """""""" @@ -289,14 +312,16 @@ progbuf1 Program Buffer 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - |31:0 |R/W|data|Data value | - +-----+---+----+-----------+ + +-----+---+----+-----+-----------+ + |Bit #|R/W|Name|Reset|Description| + +=====+===+====+=====+===========+ + |31:0 |R/W|data|-- |Data value | + +-----+---+----+-----+-----------+ -.. _riscv_dbg_dm_progbuf2: +.. _riscv_dbg_dm__progbuf2: progbuf2 """""""" @@ -304,14 +329,16 @@ progbuf2 Program Buffer 2 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - |31:0 |R/W|data|Data value | - +-----+---+----+-----------+ + +-----+---+----+-----+-----------+ + |Bit #|R/W|Name|Reset|Description| + +=====+===+====+=====+===========+ + |31:0 |R/W|data|-- |Data value | + +-----+---+----+-----+-----------+ -.. _riscv_dbg_dm_progbuf3: +.. _riscv_dbg_dm__progbuf3: progbuf3 """""""" @@ -319,14 +346,16 @@ progbuf3 Program Buffer 3 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - |31:0 |R/W|data|Data value | - +-----+---+----+-----------+ + +-----+---+----+-----+-----------+ + |Bit #|R/W|Name|Reset|Description| + +=====+===+====+=====+===========+ + |31:0 |R/W|data|-- |Data value | + +-----+---+----+-----+-----------+ -.. _riscv_dbg_dm_progbuf4: +.. _riscv_dbg_dm__progbuf4: progbuf4 """""""" @@ -334,14 +363,16 @@ progbuf4 Program Buffer 4 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - |31:0 |R/W|data|Data value | - +-----+---+----+-----------+ + +-----+---+----+-----+-----------+ + |Bit #|R/W|Name|Reset|Description| + +=====+===+====+=====+===========+ + |31:0 |R/W|data|-- |Data value | + +-----+---+----+-----+-----------+ -.. _riscv_dbg_dm_progbuf5: +.. _riscv_dbg_dm__progbuf5: progbuf5 """""""" @@ -349,14 +380,16 @@ progbuf5 Program Buffer 5 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - |31:0 |R/W|data|Data value | - +-----+---+----+-----------+ + +-----+---+----+-----+-----------+ + |Bit #|R/W|Name|Reset|Description| + +=====+===+====+=====+===========+ + |31:0 |R/W|data|-- |Data value | + +-----+---+----+-----+-----------+ -.. _riscv_dbg_dm_progbuf6: +.. _riscv_dbg_dm__progbuf6: progbuf6 """""""" @@ -364,14 +397,16 @@ progbuf6 Program Buffer 6 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - |31:0 |R/W|data|Data value | - +-----+---+----+-----------+ + +-----+---+----+-----+-----------+ + |Bit #|R/W|Name|Reset|Description| + +=====+===+====+=====+===========+ + |31:0 |R/W|data|-- |Data value | + +-----+---+----+-----+-----------+ -.. _riscv_dbg_dm_progbuf7: +.. _riscv_dbg_dm__progbuf7: progbuf7 """""""" @@ -379,14 +414,16 @@ progbuf7 Program Buffer 7 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - |31:0 |R/W|data|Data value | - +-----+---+----+-----------+ + +-----+---+----+-----+-----------+ + |Bit #|R/W|Name|Reset|Description| + +=====+===+====+=====+===========+ + |31:0 |R/W|data|-- |Data value | + +-----+---+----+-----+-----------+ -.. _riscv_dbg_dm_sbaddress0: +.. _riscv_dbg_dm__sbaddress0: sbaddress0 """""""""" @@ -394,14 +431,16 @@ sbaddress0 System Bus Address 31:0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-----------+ - |Bit #|R/W| Name |Description| - +=====+===+=======+===========+ - |31:0 |R/W|address|Address | - +-----+---+-------+-----------+ + +-----+---+-------+-----+-----------+ + |Bit #|R/W| Name |Reset|Description| + +=====+===+=======+=====+===========+ + |31:0 |R/W|address|-- |Address | + +-----+---+-------+-----+-----------+ -.. _riscv_dbg_dm_dmcs2: +.. _riscv_dbg_dm__dmcs2: dmcs2 """"" @@ -409,22 +448,24 @@ dmcs2 Debug Module Control and Status 2 .. table:: - - +-----+---+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+==========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================+ - | 0|R/W|hgselect |0: Operate on harts.1: Operate on DM external triggers.If there are no DM external triggers, this fieldmust be tied to 0. | - +-----+---+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|hgwrite |Whenhgselectis 0, writing 1 changes the groupof all selected harts to the value written togroup.When 1 is written andhgselectis 0, for every se-lected hart the DM will change its group to thevalue written togroup, if the hardware supportsthat group for that hart.When 1 is written andhgselectis 1, the DMwill change the group of the DM external trig-ger selected bydmexttriggerto the value writtentogroup, if the hardware supports that group forthat trigger.Writing 0 has no effect. | - +-----+---+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |6:2 |R/W|group |Whenhgselectis 0, contains the group of the hartspecified byhartsel.Whenhgselectis 1, contains the group of the DMexternal trigger selected bydmexttrigger.Writes only have an effect ifhgwriteis also written1.Group numbers are contiguous starting at 0,with the highest number being implementation-dependent, and possibly different between differ-ent group types. Debuggers should read back thisfield after writing to confirm they are using a hartgroup that is supported.If groups aren’t implemented, then this entire fieldis 0.| - +-----+---+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10:7 |R/W|dmexttrigger|This field contains the currently selected DM ex-ternal trigger.If a non-existent trigger value is written here, thehardware will change it to a valid one or 0 if noDM external triggers exist. | - +-----+---+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 11|R/W|grouptype |0: The remaining fields in this register configurehalt groups.1: The remaining fields in this register configureresume groups. | - +-----+---+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _riscv_dbg_dm_sbdata0: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+==========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================+ + | 0|R/W|hgselect |-- |0: Operate on harts.1: Operate on DM external triggers.If there are no DM external triggers, this fieldmust be tied to 0. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|hgwrite |-- |Whenhgselectis 0, writing 1 changes the groupof all selected harts to the value written togroup.When 1 is written andhgselectis 0, for every se-lected hart the DM will change its group to thevalue written togroup, if the hardware supportsthat group for that hart.When 1 is written andhgselectis 1, the DMwill change the group of the DM external trig-ger selected bydmexttriggerto the value writtentogroup, if the hardware supports that group forthat trigger.Writing 0 has no effect. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |6:2 |R/W|group |-- |Whenhgselectis 0, contains the group of the hartspecified byhartsel.Whenhgselectis 1, contains the group of the DMexternal trigger selected bydmexttrigger.Writes only have an effect ifhgwriteis also written1.Group numbers are contiguous starting at 0,with the highest number being implementation-dependent, and possibly different between differ-ent group types. Debuggers should read back thisfield after writing to confirm they are using a hartgroup that is supported.If groups aren’t implemented, then this entire fieldis 0.| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10:7 |R/W|dmexttrigger|-- |This field contains the currently selected DM ex-ternal trigger.If a non-existent trigger value is written here, thehardware will change it to a valid one or 0 if noDM external triggers exist. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 11|R/W|grouptype |-- |0: The remaining fields in this register configurehalt groups.1: The remaining fields in this register configureresume groups. | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _riscv_dbg_dm__sbdata0: sbdata0 """"""" @@ -432,9 +473,11 @@ sbdata0 System Bus data 31:0 .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - |31:0 |R/W|data|Data value | - +-----+---+----+-----------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+-----------+ + |Bit #|R/W|Name|Reset|Description| + +=====+===+====+=====+===========+ + |31:0 |R/W|data|-- |Data value | + +-----+---+----+-----+-----------+ diff --git a/rtos/pulp/gap_archi/doc/ips/rom.rst b/rtos/pulp/gap_archi/doc/ips/rom.rst index aa287a35e..912bcc2a0 100644 --- a/rtos/pulp/gap_archi/doc/ips/rom.rst +++ b/rtos/pulp/gap_archi/doc/ips/rom.rst @@ -1,1124 +1,1304 @@ .. Input file: docs/IP_REFERENCES/GAP9_ROM.md -Register map -^^^^^^^^^^^^ +Register map for reserved eFuses +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Overview """""""" -.. table:: - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +=========================================================================+======+=====+==========================================================================================================================================================================================================================+ - |:ref:`INFO_1` | 0| 32|Information register 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`INFO_2` | 1| 32|Information register 2. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`INFO_3` | 2| 32|Information register 3. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLL_DRR` | 3| 32|FLL DRR value. This is only set when FLL_GLOBAL_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLL_CCR1_PRE_LOCK` | 4| 32|FLL CCR1 value set before locking the FLL. This is only set when FLL_GLOBAL_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLL_CCR1_POST_LOCK` | 5| 32|FLL CCR1 value set after locking the FLL. This is only set when FLL_GLOBAL_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLL_CCR2` | 6| 32|FLL CCR2 value. This is only set when FLL_GLOBAL_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLL_F0CR1` | 7| 32|FLL F0CR1 value. This is only set when FLL_DCO0_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLL_F0CR2` | 8| 32|FLL F0CR2 value. This is only set when FLL_DCO0_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`PADFUN0` | 9| 32|PADFUN0 value. This is only set PADFUN0_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`PADFUN1` | 10| 32|PADFUN1 value. This is only set PADFUN1_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`PADFUN2` | 11| 32|PADFUN2 value. This is only set PADFUN2_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`PADFUN3` | 12| 32|PADFUN3 value. This is only set PADFUN3_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`PADFUN4` | 13| 32|PADFUN4 value. This is only set PADFUN4_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`PADFUN5` | 14| 32|PADFUN5 value. This is only set PADFUN5_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FEATURE_DISABLE` | 15| 32|Specify list of features which must be deactivated by the ROM. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`SECURE_BOOT` | 16| 32|Specify AES configuration. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`AES_KEY0` | 17| 32|Word 0 of AES key. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`AES_KEY1` | 18| 32|Word 1 of AES key. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`AES_KEY2` | 19| 32|Word 2 of AES key. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`AES_KEY3` | 20| 32|Word 3 of AES key. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`AES_KEY4` | 21| 32|Word 4 of AES key. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`AES_KEY5` | 22| 32|Word 5 of AES key. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`AES_KEY6` | 23| 32|Word 6 of AES key. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`AES_KEY7` | 24| 32|Word 7 of AES key. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FEATURE_DISABLE_QK` | 25| 32|Specify list of qk features which must disabled. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WAIT_XTAL_PERIOD` | 32| 32|When WAIT_XTAL is 1, this gives the timer period at which the oscillator is checked. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WAIT_XTAL_DELTA` | 33| 32|When WAIT_XTAL is 1, this gives the delta under which the oscillator is considered stable. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WAIT_XTAL_MIN` | 34| 32|When WAIT_XTAL is 1, this gives the number of stable checks after which the wait is considered successfull . | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WAIT_XTAL_MAX` | 35| 32|When WAIT_XTAL is 1, this gives the number of unstable checks after which the wait is considered failing and is aborted. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`REF_CLK_WAIT_CYCLES` | 36| 32|When REF_CLK_WAIT is 1, this gives the number of clock cycles after which the ROM can start accessing the pads after cold boot. Used clock is selected by the TIMER_SOURCE field of INFO_1 register. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`REF_CLK_WAIT_CYCLES_DEEP_SLEEP`| 37| 32|When REF_CLK_WAIT_DEEP_SLEEP is 1, this gives the number of clock cycles after which the ROM can start accessing the pads after non-retentive wakeup. Used clock is selected by the TIMER_SOURCE field of INFO_1 register.| - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FAST_CLK_DIV_POW2` | 38| 32|When FAST_CLK_DIV_POW2_SETUP is 1, the ROM will setup the fast clock divider with this value. The final divider is the power of two of this value. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WAKEUP_FLL_DRR` | 39| 32|Wakeup FLL DRR value. This is only set when FLL_GLOBAL_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WAKEUP_FLL_CCR1_PRE_LOCK` | 40| 32|Wakeup FLL CCR1 value set before locking the FLL. This is only set when FLL_GLOBAL_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WAKEUP_FLL_CCR1_POST_LOCK` | 41| 32|Wakeup FLL CCR1 value set after locking the FLL. This is only set when FLL_GLOBAL_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WAKEUP_FLL_CCR2` | 42| 32|Wakeup FLL CCR2 value. This is only set when FLL_GLOBAL_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WAKEUP_FLL_F0CR1` | 43| 32|Wakeup FLL F0CR1 value. This is only set when FLL_DCO0_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WAKEUP_FLL_F0CR2` | 44| 32|Wakeup FLL F0CR2 value. This is only set when FLL_DCO0_SETUP is 1. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WAKE_FAST_CLK_DIV_POW2` | 45| 32|When WAKE_FAST_CLK_DIV_POW2_SETUP is 1, the ROM will setup the fast clock divider with this value after non-retentive deep sleep. The final divider is the power of two of this value. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`MRAM_RESET_WAIT_CYCLES` | 46| 32|Number of cycles to wait after mram has been reset. This is a number of cycles for the timer, whatever the timer source is. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`WAKE_MRAM_RESET_WAIT_CYCLES` | 47| 32|Number of cycles to wait after mram has been reset after a non-retentive wakeup. This is a number of cycles for the timer, whatever the timer source is. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`SPI_CONF_WAIT_CYCLES` | 48| 32|Number of cycles to wait after the spiflash has been configured. This is a number of cycles for the timer, whatever the timer source is. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLASH_OFFSET` | 49| 32|Flash offset. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLL_WAIT_CYCLES` | 50| 32|Number of cycles to wait before the FLL is configured. This is a number of cycles for the timer, whatever the timer source is. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLL_WAKE_WAIT_CYCLES` | 51| 32|Number of cycles to wait before the FLL is configured after non-retentive wakeup. This is a number of cycles for the timer, whatever the timer source is. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLASH_RESET_WAIT` | 53| 32|Wait loop after flash reset. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLASH_CMD_1` | 54| 32|First additionnal custom command. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLASH_CMD_2` | 55| 32|Second additionnal custom command. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLASH_CMD_3` | 56| 32|Third additionnal custom command. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLASH_CMD_4` | 57| 32|Fourth additionnal custom command. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLASH_WAIT` | 58| 32|Apply a wait loop before using the flash. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLASH_WAKEUP_WAIT` | 59| 32|Wait loop when waiting for flash wakup. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLASH_STATUS` | 60| 32|Flash status register value. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLASH_COMMANDS` | 61| 32|Flash commands. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`INFO_4` | 62| 32|Information register 4. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FLASH_GPIO_PULSE_WAIT` | 63| 32|Number of cycles the ROM should wait after it has set the GPIO to active. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`NEVA_CFG` | 64| 32|Number of cycles the ROM should wait after it has set the GPIO to active. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`MRAM_TRIM_SIZE` | 65| 32|When MRAM_TRIM is 1, this gives the size of the MRAM trim config. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`MRAM_TRIM_START` | 66| 32|When MTAM_TRIM is 1, this is the first efuse storing the MRAM trim configuration. | - +-------------------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _rom_INFO_1: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +==========================================================================+======+=====+=======================================================================================================================================================================================================================+ + |:ref:`INFO_1` | 0| 32|Information eFuse 1 | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`INFO_2` | 1| 32|Information eFuse 2 | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`INFO_3` | 2| 32|Information eFuse 3 | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLL_DRR` | 3| 32|FLL DRR value (only used when FLL_GLOBAL_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLL_CCR1_PRE_LOCK` | 4| 32|FLL CCR1 value set before locking the FLL (only used when FLL_GLOBAL_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLL_CCR1_POST_LOCK` | 5| 32|FLL CCR1 value set after locking the FLL (only used when FLL_GLOBAL_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLL_CCR2` | 6| 32|FLL CCR2 value (only used when FLL_GLOBAL_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLL_F0CR1` | 7| 32|FLL F0CR1 value (only used when FLL_GLOBAL_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLL_F0CR2` | 8| 32|FLL F0CR2 value (only used when FLL_GLOBAL_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`PADFUN0` | 9| 32|PADFUN0 value (only used when PADFUN0_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`PADFUN1` | 10| 32|PADFUN1 value (only used when PADFUN1_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`PADFUN2` | 11| 32|PADFUN2 value (only used when PADFUN2_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`PADFUN3` | 12| 32|PADFUN3 value (only used when PADFUN3_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`PADFUN4` | 13| 32|PADFUN4 value (only used when PADFUN4_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`PADFUN5` | 14| 32|PADFUN5 value (only used when PADFUN5_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FEATURE_DISABLE` | 15| 32|Specify the list of features which must be deactivated by the ROM boot | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`SECURE_BOOT` | 16| 32|Specify AES configuration | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`AES_KEY0` | 17| 32|Word 0 of AES key | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`AES_KEY1` | 18| 32|Word 1 of AES key | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`AES_KEY2` | 19| 32|Word 2 of AES key | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`AES_KEY3` | 20| 32|Word 3 of AES key | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`AES_KEY4` | 21| 32|Word 4 of AES key | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`AES_KEY5` | 22| 32|Word 5 of AES key | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`AES_KEY6` | 23| 32|Word 6 of AES key | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`AES_KEY7` | 24| 32|Word 7 of AES key | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FEATURE_DISABLE_QK` | 25| 32|Specify list of QuiddiKey features which must be disabled by the ROM boot | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`WAIT_XTAL_PERIOD` | 32| 32|When WAIT_XTAL is 1, this gives the timer period at which the oscillator is checked | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`WAIT_XTAL_DELTA` | 33| 32|When WAIT_XTAL is 1, this gives the delta under which the oscillator is considered stable | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`WAIT_XTAL_MIN` | 34| 32|When WAIT_XTAL is 1, this gives the number of stable checks after which the wait is considered successful | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`WAIT_XTAL_MAX` | 35| 32|When WAIT_XTAL is 1, this gives the number of unstable checks after which the wait is considered failing and is aborted | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`REF_CLK_WAIT_CYCLES` | 36| 32|When REF_CLK_WAIT is 1, this gives the number of clock cycles after which the ROM can start accessing the pads after cold boot (used clock is selected by the TIMER_SOURCE field of INFO_1 eFuse) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`REF_CLK_WAIT_CYCLES_DEEP_SLEEP`| 37| 32|When REF_CLK_WAIT_DEEP_SLEEP is 1, this gives the number of clock cycles after which the ROM can start accessing the pads after non-retentive wakeup (used clock is selected by the TIMER_SOURCE field of INFO_1 eFuse)| + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FAST_CLK_DIV_POW2` | 38| 32|When FAST_CLK_DIV_POW2_SETUP is 1, the ROM will setup the fast clock divider with this value (the real division factor is the power of two of this value) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`WAKEUP_FLL_DRR` | 39| 32|Wakeup FLL DRR value (only used when FLL_GLOBAL_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`WAKEUP_FLL_CCR1_PRE_LOCK` | 40| 32|Wakeup FLL CCR1 value set before locking the FLL (only used when FLL_GLOBAL_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`WAKEUP_FLL_CCR1_POST_LOCK` | 41| 32|Wakeup FLL CCR1 value set after locking the FLL (only used when FLL_GLOBAL_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`WAKEUP_FLL_CCR2` | 42| 32|Wakeup FLL CCR2 value (only used when FLL_GLOBAL_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`WAKEUP_FLL_F0CR1` | 43| 32|Wakeup FLL F0CR1 value (only used when FLL_DCO0_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`WAKEUP_FLL_F0CR2` | 44| 32|Wakeup FLL F0CR2 value (only used when FLL_DCO0_SETUP is 1) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`WAKE_FAST_CLK_DIV_POW2` | 45| 32|When WAKE_FAST_CLK_DIV_POW2_SETUP is 1, the ROM will setup the fast clock divider with this value after non-retentive deep sleep (the real division factor is the power of two of this value) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`MRAM_RESET_WAIT_CYCLES` | 46| 32|Number of cycles to wait after MRAM has been reset (this is a number of cycles for the timer, whatever the timer source is) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`WAKE_MRAM_RESET_WAIT_CYCLES` | 47| 32|Number of cycles to wait after MRAM has been reset after a non-retentive wakeup (this is a number of cycles for the timer, whatever the timer source is) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`SPI_CONF_WAIT_CYCLES` | 48| 32|Number of cycles to wait after the spiflash has been configured (this is a number of cycles for the timer, whatever the timer source is) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLASH_OFFSET` | 49| 32|Flash offset | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLL_WAIT_CYCLES` | 50| 32|Number of cycles to wait before the FLL is configured (this is a number of cycles for the timer, whatever the timer source is) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLL_WAKE_WAIT_CYCLES` | 51| 32|Number of cycles to wait before the FLL is configured after non-retentive wakeup (this is a number of cycles for the timer, whatever the timer source is) | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLASH_RESET_WAIT` | 53| 32|Wait loop after flash reset | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLASH_CMD_1` | 54| 32|First additionnal custom command | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLASH_CMD_2` | 55| 32|Second additionnal custom command | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLASH_CMD_3` | 56| 32|Third additionnal custom command | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLASH_CMD_4` | 57| 32|Fourth additionnal custom command | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLASH_WAIT` | 58| 32|Apply a wait loop before using the flash | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLASH_WAKEUP_WAIT` | 59| 32|Wait loop when waiting for flash wakup | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLASH_STATUS` | 60| 32|Flash status register value | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLASH_COMMANDS` | 61| 32|Flash commands | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`INFO_4` | 62| 32|Information eFuse 4 | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FLASH_GPIO_PULSE_WAIT` | 63| 32|Number of cycles the ROM should wait after it has set the GPIO to active | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`NEVA_CFG` | 64| 32|Number of cycles the ROM should wait after it has set the GPIO to active | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`MRAM_TRIM_SIZE` | 65| 32|When MRAM_TRIM is 1, this gives the size of the MRAM trim config | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`MRAM_TRIM_START` | 66| 32|When MRAM_TRIM is 1, this is the first eFuse storing the MRAM trim configuration | + +--------------------------------------------------------------------------+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _rom__INFO_1: INFO_1 """""" -Information register 1. +Information eFuse 1 .. table:: - - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======================+=====================================================================================================================================================================================================================+ - |2:0 |R/W|PLATFORM |Platform on which the execution is being done. This is only used for test purpose on simulation platform and should be kept to 0 on real platform. Possible values: 0: Undefined, 1: FPGA, 2: RTL, 3: GVSOC, 4: BOARD| - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10:3 |R/W|BOOTMODE |Bootmode that the ROM should follow (see bootmode section for more details). Possible values: 0: JTAG stop, 1: Hyperflash boot, 2: SPI flash boot, 3: MRAM boot, 4: SPI slave boot | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |11 |R/W|ENCRYPTED |1 if the binary to be loaded from flash is encrypted. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |12 |R/W|WAIT_XTAL |1 if the ROM should wait for stabilization of the oscillator. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |13 |R/W|ICACHE_ENABLED |1 if the ROM should activate FC icache. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |14 |R/W|FLL_GLOBAL_SETUP |1 if the ROM should configure FLL global registers (drr, ccr1 and ccr2). | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15 |R/W|FLL_DCO0_SETUP |1 if the ROM should configure DCO 0. (f0cr1 and f0cr2) | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |16 |R/W|PADFUN0_SETUP |1 if the ROM should configure PADFUN0. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |17 |R/W|PADFUN1_SETUP |1 if the ROM should configure PADFUN1. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |18 |R/W|PADFUN2_SETUP |1 if the ROM should configure PADFUN2. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |19 |R/W|PADFUN3_SETUP |1 if the ROM should configure PADFUN3. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |20 |R/W|PADFUN4_SETUP |1 if the ROM should configure PADFUN4. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |21 |R/W|PADFUN5_SETUP |1 if the ROM should configure PADFUN5. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |22 |R/W|PMU_WAIT_RESET_SKIP |1 if the ROM should not wait for end of reset sequence. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |24:23|R/W|TIMER_SOURCE |Clock source for the timer used for generating wait loops: 0: FLL, 1: 32kHz reference clock, 2: divided fast clock. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |25 |R/W|FAST_CLK_DIV_POW2_SETUP|1 if the ROM should setup the fast clock divider with the content of FAST_CLK_DIV_POW2. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |26 |R/W|OSC_CTRL_SETUP |1 if the ROM should setup the oscillator control register with the content of OSC_CTRL. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |29:27|R/W|OSC_CTRL |Content of oscillator control register when it is setup. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |30 |R/W|FEATURE_DISABLE_SET |Set feature disable register from what is specified in FEATURE_DISABLE. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31 |R/W|MRAM_RESET_WAIT |Set number of cycles to wait after the mram has been reset. The number of cycles is taken from MRAM_RESET_WAIT_CYCLES. | - +-----+---+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _rom_INFO_2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======================+=====+=====================================================================================================================================================================================================================+ + |2:0 |R/W|PLATFORM |0x0 |Platform on which the execution is being done. This is only used for test purpose on simulation platform and should be kept to 0 on real platform. Possible values: 0: Undefined, 1: FPGA, 2: RTL, 3: GVSOC, 4: BOARD| + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10:3 |R/W|BOOTMODE |0x0 |Bootmode that the ROM should follow (see bootmode section for more details). Possible values: 0: JTAG stop, 1: Hyperflash boot, 2: SPI flash boot, 3: MRAM boot, 4: SPI slave boot | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |11 |R/W|ENCRYPTED |0x0 |1 if the binary to be loaded from flash is encrypted. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|WAIT_XTAL |0x0 |1 if the ROM should wait for stabilization of the oscillator. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|ICACHE_ENABLED |0x0 |1 if the ROM should activate FC icache. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |14 |R/W|FLL_GLOBAL_SETUP |0x0 |1 if the ROM should configure FLL global registers (drr, ccr1 and ccr2). | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|FLL_DCO0_SETUP |0x0 |1 if the ROM should configure DCO 0. (f0cr1 and f0cr2) | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |16 |R/W|PADFUN0_SETUP |0x0 |1 if the ROM should configure PADFUN0. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |17 |R/W|PADFUN1_SETUP |0x0 |1 if the ROM should configure PADFUN1. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |18 |R/W|PADFUN2_SETUP |0x0 |1 if the ROM should configure PADFUN2. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |19 |R/W|PADFUN3_SETUP |0x0 |1 if the ROM should configure PADFUN3. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |20 |R/W|PADFUN4_SETUP |0x0 |1 if the ROM should configure PADFUN4. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |21 |R/W|PADFUN5_SETUP |0x0 |1 if the ROM should configure PADFUN5. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |22 |R/W|PMU_WAIT_RESET_SKIP |0x0 |1 if the ROM should not wait for end of reset sequence. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |24:23|R/W|TIMER_SOURCE |0x0 |Clock source for the timer used for generating wait loops: 0: FLL, 1: 32kHz reference clock, 2: divided fast clock. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |25 |R/W|FAST_CLK_DIV_POW2_SETUP|0x0 |1 if the ROM should setup the fast clock divider with the content of FAST_CLK_DIV_POW2. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |26 |R/W|OSC_CTRL_SETUP |0x0 |1 if the ROM should setup the oscillator control register with the content of OSC_CTRL. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |29:27|R/W|OSC_CTRL |0x0 |Content of oscillator control register when it is setup. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |30 |R/W|FEATURE_DISABLE_SET |0x0 |Set feature disable register from what is specified in FEATURE_DISABLE. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31 |R/W|MRAM_RESET_WAIT |0x0 |Set number of cycles to wait after the MRAM has been reset. The number of cycles is taken from MRAM_RESET_WAIT_CYCLES. | + +-----+---+-----------------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _rom__INFO_2: INFO_2 """""" -Information register 2. +Information eFuse 2 .. table:: - - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============================+============================================================================================================================================================================================+ - | 0|R/W|CLKDIV_SETUP |1 if the ROM should take the peripheral divider from field CLKDIV of efuse INFO_2. If it is 0, a default divider of 0 is taken for Hyper flash and SPI flash, and a divider of 2 for MRAM. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |5:1 |R/W|CLKDIV |Peripheral divider. 0 or 1 do not divide, other values divide by the specified value. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 6|R/W|JTAG_LOCK |1 if the ROM should not authorize JTAG accesses. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 7|R/W|REF_CLK_WAIT |1 if the ROM should wait before accessing the pads. The duration of the wait is the number of ref clock cycles described in efuse REF_CLK_WAIT_CYCLES. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 8|R/W|REF_CLK_WAIT_DEEP_SLEEP |1 if the ROM should wait before accessing the pads after non-retentive wakeup. The duration of the wait is the number of ref clock cycles described in efuse REF_CLK_WAIT_CYCLES_DEEP_SLEEP.| - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 9|R/W|BOOTMODE0_NOCHECK |1 if the ROM should not use bootsel pad 0 for choosing boot mode. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 10|R/W|BOOTMODE1_NOCHECK |1 if the ROM should not use bootsel pad 1 for choosing boot mode. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 11|R/W|MRAM_TRIM |1 if the ROM should configure MRAM trim before using the MRAM. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 12|R/W|WAKE_FAST_CLK_DIV_POW2_SETUP|1 if the ROM should setup the fast clock divider with the content of WAKE_FAST_CLK_DIV_POW2 after non-retentive deep sleep. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 13|R/W|WAKE_OSC_CTRL_SETUP |1 if the ROM should setup the oscillator control register with the content of WAKE_OSC_CTRL after non-retentive deep sleep. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15:14|R/W|WAKE_OSC_CTRL |Content of oscillator control register when it is setup after non-retentive deep sleep. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 16|R/W|SPI_CONF_WAIT |Set number of cycles to wait after the spiflash has been configured. The number of cycles is taken from SPI_CONF_WAIT_CYCLES. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 17|R/W|WAKE_WAIT_XTAL |1 if the ROM should wait for stabilization of the oscillator after non-retentive wakeup. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 18|R/W|FLL_WAIT |1 if the ROM should wait before configuring the FLL. The number of cycles is taken from FLL_WAIT_CYCLES. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 19|R/W|FLL_WAKE_WAIT |1 if the ROM should wait before configuring the FLL. The number of cycles is taken from FLL_WAKE_WAIT_CYCLES. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |22:21|R/W|FLASH_STATUS_SET |0 if the ROM should set the flash status register to a default value, 1, if it should do nothing or 2 if it should apply the status found in FLASH_STATUS. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 23|R/W|FLASH_COMMANDS_SET |1 if the ROM should take flash commands from FLASH_COMMANDS. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 24|R/W|FLASH_LATENCY_SET |1 if the ROM should take flash latency from FLASH_LATENCY_VALUE. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |29:25|R/W|FLASH_LATENCY_VALUE |Flash latency. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 30|R/W|WAKE_MRAM_RESET_WAIT |Set number of cycles to wait after the mram has been reset after non-retentive wakeup. The number of cycles is taken from WAKE_MRAM_RESET_WAITC_CYCLES. | - +-----+---+----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _rom_INFO_3: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============================+=====+============================================================================================================================================================================================+ + | 0|R/W|CLKDIV_SETUP |0x0 |1 if the ROM should take the peripheral divider from field CLKDIV of eFuse INFO_2. If it is 0, a default divider of 0 is taken for Hyper flash and SPI flash, and a divider of 2 for MRAM. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |5:1 |R/W|CLKDIV |0x0 |Peripheral divider. 0 or 1 do not divide, other values divide by the specified value. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 6|R/W|JTAG_LOCK |0x0 |1 if the ROM should not authorize JTAG accesses. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 7|R/W|REF_CLK_WAIT |0x0 |1 if the ROM should wait before accessing the pads. The duration of the wait is the number of ref clock cycles described in eFuse REF_CLK_WAIT_CYCLES. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 8|R/W|REF_CLK_WAIT_DEEP_SLEEP |0x0 |1 if the ROM should wait before accessing the pads after non-retentive wakeup. The duration of the wait is the number of ref clock cycles described in eFuse REF_CLK_WAIT_CYCLES_DEEP_SLEEP.| + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 9|R/W|BOOTMODE0_NOCHECK |0x0 |1 if the ROM should not use bootsel pad 0 for choosing boot mode. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 10|R/W|BOOTMODE1_NOCHECK |0x0 |1 if the ROM should not use bootsel pad 1 for choosing boot mode. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 11|R/W|MRAM_TRIM |0x0 |1 if the ROM should configure MRAM trim before using the MRAM. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 12|R/W|WAKE_FAST_CLK_DIV_POW2_SETUP|0x0 |1 if the ROM should setup the fast clock divider with the content of WAKE_FAST_CLK_DIV_POW2 after non-retentive deep sleep. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 13|R/W|WAKE_OSC_CTRL_SETUP |0x0 |1 if the ROM should setup the oscillator control register with the content of WAKE_OSC_CTRL after non-retentive deep sleep. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:14|R/W|WAKE_OSC_CTRL |0x0 |Content of oscillator control register when it is setup after non-retentive deep sleep. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 16|R/W|SPI_CONF_WAIT |0x0 |Set number of cycles to wait after the spiflash has been configured. The number of cycles is taken from SPI_CONF_WAIT_CYCLES. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 17|R/W|WAKE_WAIT_XTAL |0x0 |1 if the ROM should wait for stabilization of the oscillator after non-retentive wakeup. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 18|R/W|FLL_WAIT |0x0 |1 if the ROM should wait before configuring the FLL. The number of cycles is taken from FLL_WAIT_CYCLES. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 19|R/W|FLL_WAKE_WAIT |0x0 |1 if the ROM should wait before configuring the FLL. The number of cycles is taken from FLL_WAKE_WAIT_CYCLES. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |22:21|R/W|FLASH_STATUS_SET |0x0 |0 if the ROM should set the flash status register to a default value, 1, if it should do nothing or 2 if it should apply the status found in FLASH_STATUS. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 23|R/W|FLASH_COMMANDS_SET |0x0 |1 if the ROM should take flash commands from FLASH_COMMANDS. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 24|R/W|FLASH_LATENCY_SET |0x0 |1 if the ROM should take flash latency from FLASH_LATENCY_VALUE. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |29:25|R/W|FLASH_LATENCY_VALUE |0x0 |Flash latency. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 30|R/W|WAKE_MRAM_RESET_WAIT |0x0 |Set number of cycles to wait after the MRAM has been reset after non-retentive wakeup. The number of cycles is taken from WAKE_MRAM_RESET_WAITC_CYCLES. | + +-----+---+----------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _rom__INFO_3: INFO_3 """""" -Information register 3. +Information eFuse 3 .. table:: - - +-----+---+-------------------+-----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===================+=======================================================================+ - | 0|R/W|FLASH_CS_SETUP |Setup Chip Select of the flash to be used for the binary loading. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 1|R/W|FLASH_CS |Chip Select of the flash to be used for the binary loading. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 2|R/W|FLASH_ITF_SETUP |Setup interface ID where the flash is connected for the binary loading.| - +-----+---+-------------------+-----------------------------------------------------------------------+ - |4:3 |R/W|FLASH_ITF |Interface ID where the flash is connected for the binary loading. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 5|R/W|FLASH_OFFSET_SETUP |Set the offset of the flash. Offset is given in FLASH_OFFSET. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 6|R/W|HYPER_DELAY_SETUP |Set Hyperbus delay. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - |9:7 |R/W|HYPER_DELAY |Hyperbus delay. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 10|R/W|HYPER_LATENCY_SETUP|Set Hyperbus latency. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - |15:11|R/W|HYPER_LATENCY |Hyperbus latency. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 16|R/W|HYPER_CS_POLARITY |Hyperbus Chip select polarity. 0 means normal polarity (CS active low).| - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 17|R/W|FLASH_WAKEUP |Wakeup the flash after non-retentive deep sleep wakeup. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 18|R/W|FLASH_RESET |Reset the flash before using it. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 19|R/W|FLASH_INIT |Init the flash before using it. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 20|R/W|FLASH_WAIT |Apply a wait loop before using the flash. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 21|R/W|FLASH_CMD_1 |First additionnal custom command. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 22|R/W|FLASH_CMD_2 |Second additionnal custom command. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 23|R/W|FLASH_CMD_3 |Third additionnal custom command. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 24|R/W|FLASH_CMD_4 |Fourth additionnal custom command. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 25|R/W|FLASH_CMD_1_DS |First additionnal custom command after non-retentive wakeup. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 26|R/W|FLASH_CMD_2_DS |Second additionnal custom command after non-retentive wakeup. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 27|R/W|FLASH_CMD_3_DS |Third additionnal custom command after non-retentive wakeup. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 28|R/W|FLASH_CMD_4_DS |Fourth additionnal custom command after non-retentive wakeup. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 29|R/W|FLASH_RESET_WAIT |Wait loop after flash reset. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - | 30|R/W|FLASH_WAKEUP_WAIT |Wait loop when waiting for flas wakeup. | - +-----+---+-------------------+-----------------------------------------------------------------------+ - -.. _rom_FLL_DRR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===================+=====+=======================================================================+ + | 0|R/W|FLASH_CS_SETUP |0x0 |Setup Chip Select of the flash to be used for the binary loading. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 1|R/W|FLASH_CS |0x0 |Chip Select of the flash to be used for the binary loading. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 2|R/W|FLASH_ITF_SETUP |0x0 |Setup interface ID where the flash is connected for the binary loading.| + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + |4:3 |R/W|FLASH_ITF |0x0 |Interface ID where the flash is connected for the binary loading. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 5|R/W|FLASH_OFFSET_SETUP |0x0 |Set the offset of the flash. Offset is given in FLASH_OFFSET. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 6|R/W|HYPER_DELAY_SETUP |0x0 |Set Hyperbus delay. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + |9:7 |R/W|HYPER_DELAY |0x0 |Hyperbus delay. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 10|R/W|HYPER_LATENCY_SETUP|0x0 |Set Hyperbus latency. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + |15:11|R/W|HYPER_LATENCY |0x0 |Hyperbus latency. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 16|R/W|HYPER_CS_POLARITY |0x0 |Hyperbus Chip select polarity. 0 means normal polarity (CS active low).| + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 17|R/W|FLASH_WAKEUP |0x0 |Wakeup the flash after non-retentive deep sleep wakeup. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 18|R/W|FLASH_RESET |0x0 |Reset the flash before using it. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 19|R/W|FLASH_INIT |0x0 |Init the flash before using it. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 20|R/W|FLASH_WAIT |0x0 |Apply a wait loop before using the flash. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 21|R/W|FLASH_CMD_1 |0x0 |First additionnal custom command. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 22|R/W|FLASH_CMD_2 |0x0 |Second additionnal custom command. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 23|R/W|FLASH_CMD_3 |0x0 |Third additionnal custom command. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 24|R/W|FLASH_CMD_4 |0x0 |Fourth additionnal custom command. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 25|R/W|FLASH_CMD_1_DS |0x0 |First additionnal custom command after non-retentive wakeup. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 26|R/W|FLASH_CMD_2_DS |0x0 |Second additionnal custom command after non-retentive wakeup. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 27|R/W|FLASH_CMD_3_DS |0x0 |Third additionnal custom command after non-retentive wakeup. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 28|R/W|FLASH_CMD_4_DS |0x0 |Fourth additionnal custom command after non-retentive wakeup. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 29|R/W|FLASH_RESET_WAIT |0x0 |Wait loop after flash reset. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + | 30|R/W|FLASH_WAKEUP_WAIT |0x0 |Wait loop when waiting for flas wakeup. | + +-----+---+-------------------+-----+-----------------------------------------------------------------------+ + +.. _rom__FLL_DRR: FLL_DRR """"""" -FLL DRR value. This is only set when FLL_GLOBAL_SETUP is 1. +FLL DRR value (only used when FLL_GLOBAL_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_FLL_CCR1_PRE_LOCK: +.. _rom__FLL_CCR1_PRE_LOCK: FLL_CCR1_PRE_LOCK """"""""""""""""" -FLL CCR1 value set before locking the FLL. This is only set when FLL_GLOBAL_SETUP is 1. +FLL CCR1 value set before locking the FLL (only used when FLL_GLOBAL_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_FLL_CCR1_POST_LOCK: +.. _rom__FLL_CCR1_POST_LOCK: FLL_CCR1_POST_LOCK """""""""""""""""" -FLL CCR1 value set after locking the FLL. This is only set when FLL_GLOBAL_SETUP is 1. +FLL CCR1 value set after locking the FLL (only used when FLL_GLOBAL_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_FLL_CCR2: +.. _rom__FLL_CCR2: FLL_CCR2 """""""" -FLL CCR2 value. This is only set when FLL_GLOBAL_SETUP is 1. +FLL CCR2 value (only used when FLL_GLOBAL_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_FLL_F0CR1: +.. _rom__FLL_F0CR1: FLL_F0CR1 """"""""" -FLL F0CR1 value. This is only set when FLL_DCO0_SETUP is 1. +FLL F0CR1 value (only used when FLL_GLOBAL_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_FLL_F0CR2: +.. _rom__FLL_F0CR2: FLL_F0CR2 """"""""" -FLL F0CR2 value. This is only set when FLL_DCO0_SETUP is 1. +FLL F0CR2 value (only used when FLL_GLOBAL_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_PADFUN0: +.. _rom__PADFUN0: PADFUN0 """"""" -PADFUN0 value. This is only set PADFUN0_SETUP is 1. +PADFUN0 value (only used when PADFUN0_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_PADFUN1: +.. _rom__PADFUN1: PADFUN1 """"""" -PADFUN1 value. This is only set PADFUN1_SETUP is 1. +PADFUN1 value (only used when PADFUN1_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_PADFUN2: +.. _rom__PADFUN2: PADFUN2 """"""" -PADFUN2 value. This is only set PADFUN2_SETUP is 1. +PADFUN2 value (only used when PADFUN2_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_PADFUN3: +.. _rom__PADFUN3: PADFUN3 """"""" -PADFUN3 value. This is only set PADFUN3_SETUP is 1. +PADFUN3 value (only used when PADFUN3_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_PADFUN4: +.. _rom__PADFUN4: PADFUN4 """"""" -PADFUN4 value. This is only set PADFUN4_SETUP is 1. +PADFUN4 value (only used when PADFUN4_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_PADFUN5: +.. _rom__PADFUN5: PADFUN5 """"""" -PADFUN5 value. This is only set PADFUN5_SETUP is 1. +PADFUN5 value (only used when PADFUN5_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_FEATURE_DISABLE: +.. _rom__FEATURE_DISABLE: FEATURE_DISABLE """"""""""""""" -Specify list of features which must be deactivated by the ROM. +Specify the list of features which must be deactivated by the ROM boot .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_SECURE_BOOT: +.. _rom__SECURE_BOOT: SECURE_BOOT """"""""""" -Specify AES configuration. +Specify AES configuration .. table:: - - +-----+---+-----------------+-------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=================+===========================================+ - | 0|R/W|SECURE_ONLY |Only allow secure boot. | - +-----+---+-----------------+-------------------------------------------+ - | 1|R/W|AES_QK |Use QK as key source. | - +-----+---+-----------------+-------------------------------------------+ - | 2|R/W|AES_USER |Use efuse as key source. | - +-----+---+-----------------+-------------------------------------------+ - | 3|R/W|AES_USER_KEY_SIZE|Key size for "user" security (256=1,128=0).| - +-----+---+-----------------+-------------------------------------------+ - | 4|R/W|CRC_EN |Enable crc check. | - +-----+---+-----------------+-------------------------------------------+ - | 5|R/W|KEY_LOCK |Lock AES key in efuse. | - +-----+---+-----------------+-------------------------------------------+ - | 6|R/W|SIGN_ONLY |Sign only mode, no encryption. | - +-----+---+-----------------+-------------------------------------------+ - | 7|R/W|QK_LOCK |Lock QK features. | - +-----+---+-----------------+-------------------------------------------+ - -.. _rom_AES_KEY0: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------------+-----+-------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=================+=====+===========================================+ + | 0|R/W|SECURE_ONLY |0x0 |Only allow secure boot. | + +-----+---+-----------------+-----+-------------------------------------------+ + | 1|R/W|AES_QK |0x0 |Use QK as key source. | + +-----+---+-----------------+-----+-------------------------------------------+ + | 2|R/W|AES_USER |0x0 |Use eFuse as key source. | + +-----+---+-----------------+-----+-------------------------------------------+ + | 3|R/W|AES_USER_KEY_SIZE|0x0 |Key size for "user" security (256=1,128=0).| + +-----+---+-----------------+-----+-------------------------------------------+ + | 4|R/W|CRC_EN |0x0 |Enable crc check. | + +-----+---+-----------------+-----+-------------------------------------------+ + | 5|R/W|KEY_LOCK |0x0 |Lock AES key in eFuse. | + +-----+---+-----------------+-----+-------------------------------------------+ + | 6|R/W|SIGN_ONLY |0x0 |Sign only mode, no encryption. | + +-----+---+-----------------+-----+-------------------------------------------+ + | 7|R/W|QK_LOCK |0x0 |Lock QK features. | + +-----+---+-----------------+-----+-------------------------------------------+ + +.. _rom__AES_KEY0: AES_KEY0 """""""" -Word 0 of AES key. +Word 0 of AES key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_AES_KEY1: +.. _rom__AES_KEY1: AES_KEY1 """""""" -Word 1 of AES key. +Word 1 of AES key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_AES_KEY2: +.. _rom__AES_KEY2: AES_KEY2 """""""" -Word 2 of AES key. +Word 2 of AES key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_AES_KEY3: +.. _rom__AES_KEY3: AES_KEY3 """""""" -Word 3 of AES key. +Word 3 of AES key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_AES_KEY4: +.. _rom__AES_KEY4: AES_KEY4 """""""" -Word 4 of AES key. +Word 4 of AES key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_AES_KEY5: +.. _rom__AES_KEY5: AES_KEY5 """""""" -Word 5 of AES key. +Word 5 of AES key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_AES_KEY6: +.. _rom__AES_KEY6: AES_KEY6 """""""" -Word 6 of AES key. +Word 6 of AES key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_AES_KEY7: +.. _rom__AES_KEY7: AES_KEY7 """""""" -Word 7 of AES key. +Word 7 of AES key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_FEATURE_DISABLE_QK: +.. _rom__FEATURE_DISABLE_QK: FEATURE_DISABLE_QK """""""""""""""""" -Specify list of qk features which must disabled. +Specify list of QuiddiKey features which must be disabled by the ROM boot .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_WAIT_XTAL_PERIOD: +.. _rom__WAIT_XTAL_PERIOD: WAIT_XTAL_PERIOD """""""""""""""" -When WAIT_XTAL is 1, this gives the timer period at which the oscillator is checked. +When WAIT_XTAL is 1, this gives the timer period at which the oscillator is checked .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_WAIT_XTAL_DELTA: +.. _rom__WAIT_XTAL_DELTA: WAIT_XTAL_DELTA """"""""""""""" -When WAIT_XTAL is 1, this gives the delta under which the oscillator is considered stable. +When WAIT_XTAL is 1, this gives the delta under which the oscillator is considered stable .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_WAIT_XTAL_MIN: +.. _rom__WAIT_XTAL_MIN: WAIT_XTAL_MIN """"""""""""" -When WAIT_XTAL is 1, this gives the number of stable checks after which the wait is considered successfull . +When WAIT_XTAL is 1, this gives the number of stable checks after which the wait is considered successful .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_WAIT_XTAL_MAX: +.. _rom__WAIT_XTAL_MAX: WAIT_XTAL_MAX """"""""""""" -When WAIT_XTAL is 1, this gives the number of unstable checks after which the wait is considered failing and is aborted. +When WAIT_XTAL is 1, this gives the number of unstable checks after which the wait is considered failing and is aborted .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_REF_CLK_WAIT_CYCLES: +.. _rom__REF_CLK_WAIT_CYCLES: REF_CLK_WAIT_CYCLES """"""""""""""""""" -When REF_CLK_WAIT is 1, this gives the number of clock cycles after which the ROM can start accessing the pads after cold boot. Used clock is selected by the TIMER_SOURCE field of INFO_1 register. +When REF_CLK_WAIT is 1, this gives the number of clock cycles after which the ROM can start accessing the pads after cold boot (used clock is selected by the TIMER_SOURCE field of INFO_1 eFuse) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_REF_CLK_WAIT_CYCLES_DEEP_SLEEP: +.. _rom__REF_CLK_WAIT_CYCLES_DEEP_SLEEP: REF_CLK_WAIT_CYCLES_DEEP_SLEEP """""""""""""""""""""""""""""" -When REF_CLK_WAIT_DEEP_SLEEP is 1, this gives the number of clock cycles after which the ROM can start accessing the pads after non-retentive wakeup. Used clock is selected by the TIMER_SOURCE field of INFO_1 register. +When REF_CLK_WAIT_DEEP_SLEEP is 1, this gives the number of clock cycles after which the ROM can start accessing the pads after non-retentive wakeup (used clock is selected by the TIMER_SOURCE field of INFO_1 eFuse) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_FAST_CLK_DIV_POW2: +.. _rom__FAST_CLK_DIV_POW2: FAST_CLK_DIV_POW2 """"""""""""""""" -When FAST_CLK_DIV_POW2_SETUP is 1, the ROM will setup the fast clock divider with this value. The final divider is the power of two of this value. +When FAST_CLK_DIV_POW2_SETUP is 1, the ROM will setup the fast clock divider with this value (the real division factor is the power of two of this value) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_WAKEUP_FLL_DRR: +.. _rom__WAKEUP_FLL_DRR: WAKEUP_FLL_DRR """""""""""""" -Wakeup FLL DRR value. This is only set when FLL_GLOBAL_SETUP is 1. +Wakeup FLL DRR value (only used when FLL_GLOBAL_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_WAKEUP_FLL_CCR1_PRE_LOCK: +.. _rom__WAKEUP_FLL_CCR1_PRE_LOCK: WAKEUP_FLL_CCR1_PRE_LOCK """""""""""""""""""""""" -Wakeup FLL CCR1 value set before locking the FLL. This is only set when FLL_GLOBAL_SETUP is 1. +Wakeup FLL CCR1 value set before locking the FLL (only used when FLL_GLOBAL_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_WAKEUP_FLL_CCR1_POST_LOCK: +.. _rom__WAKEUP_FLL_CCR1_POST_LOCK: WAKEUP_FLL_CCR1_POST_LOCK """"""""""""""""""""""""" -Wakeup FLL CCR1 value set after locking the FLL. This is only set when FLL_GLOBAL_SETUP is 1. +Wakeup FLL CCR1 value set after locking the FLL (only used when FLL_GLOBAL_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_WAKEUP_FLL_CCR2: +.. _rom__WAKEUP_FLL_CCR2: WAKEUP_FLL_CCR2 """"""""""""""" -Wakeup FLL CCR2 value. This is only set when FLL_GLOBAL_SETUP is 1. +Wakeup FLL CCR2 value (only used when FLL_GLOBAL_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_WAKEUP_FLL_F0CR1: +.. _rom__WAKEUP_FLL_F0CR1: WAKEUP_FLL_F0CR1 """""""""""""""" -Wakeup FLL F0CR1 value. This is only set when FLL_DCO0_SETUP is 1. +Wakeup FLL F0CR1 value (only used when FLL_DCO0_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_WAKEUP_FLL_F0CR2: +.. _rom__WAKEUP_FLL_F0CR2: WAKEUP_FLL_F0CR2 """""""""""""""" -Wakeup FLL F0CR2 value. This is only set when FLL_DCO0_SETUP is 1. +Wakeup FLL F0CR2 value (only used when FLL_DCO0_SETUP is 1) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_WAKE_FAST_CLK_DIV_POW2: +.. _rom__WAKE_FAST_CLK_DIV_POW2: WAKE_FAST_CLK_DIV_POW2 """""""""""""""""""""" -When WAKE_FAST_CLK_DIV_POW2_SETUP is 1, the ROM will setup the fast clock divider with this value after non-retentive deep sleep. The final divider is the power of two of this value. +When WAKE_FAST_CLK_DIV_POW2_SETUP is 1, the ROM will setup the fast clock divider with this value after non-retentive deep sleep (the real division factor is the power of two of this value) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_MRAM_RESET_WAIT_CYCLES: +.. _rom__MRAM_RESET_WAIT_CYCLES: MRAM_RESET_WAIT_CYCLES """""""""""""""""""""" -Number of cycles to wait after mram has been reset. This is a number of cycles for the timer, whatever the timer source is. +Number of cycles to wait after MRAM has been reset (this is a number of cycles for the timer, whatever the timer source is) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_WAKE_MRAM_RESET_WAIT_CYCLES: +.. _rom__WAKE_MRAM_RESET_WAIT_CYCLES: WAKE_MRAM_RESET_WAIT_CYCLES """"""""""""""""""""""""""" -Number of cycles to wait after mram has been reset after a non-retentive wakeup. This is a number of cycles for the timer, whatever the timer source is. +Number of cycles to wait after MRAM has been reset after a non-retentive wakeup (this is a number of cycles for the timer, whatever the timer source is) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_SPI_CONF_WAIT_CYCLES: +.. _rom__SPI_CONF_WAIT_CYCLES: SPI_CONF_WAIT_CYCLES """""""""""""""""""" -Number of cycles to wait after the spiflash has been configured. This is a number of cycles for the timer, whatever the timer source is. +Number of cycles to wait after the spiflash has been configured (this is a number of cycles for the timer, whatever the timer source is) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_FLASH_OFFSET: +.. _rom__FLASH_OFFSET: FLASH_OFFSET """""""""""" -Flash offset. +Flash offset .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_FLL_WAIT_CYCLES: +.. _rom__FLL_WAIT_CYCLES: FLL_WAIT_CYCLES """"""""""""""" -Number of cycles to wait before the FLL is configured. This is a number of cycles for the timer, whatever the timer source is. +Number of cycles to wait before the FLL is configured (this is a number of cycles for the timer, whatever the timer source is) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_FLL_WAKE_WAIT_CYCLES: +.. _rom__FLL_WAKE_WAIT_CYCLES: FLL_WAKE_WAIT_CYCLES """""""""""""""""""" -Number of cycles to wait before the FLL is configured after non-retentive wakeup. This is a number of cycles for the timer, whatever the timer source is. +Number of cycles to wait before the FLL is configured after non-retentive wakeup (this is a number of cycles for the timer, whatever the timer source is) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_FLASH_RESET_WAIT: +.. _rom__FLASH_RESET_WAIT: FLASH_RESET_WAIT """""""""""""""" -Wait loop after flash reset. +Wait loop after flash reset .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_FLASH_CMD_1: +.. _rom__FLASH_CMD_1: FLASH_CMD_1 """"""""""" -First additionnal custom command. +First additionnal custom command .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_FLASH_CMD_2: +.. _rom__FLASH_CMD_2: FLASH_CMD_2 """"""""""" -Second additionnal custom command. +Second additionnal custom command .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_FLASH_CMD_3: +.. _rom__FLASH_CMD_3: FLASH_CMD_3 """"""""""" -Third additionnal custom command. +Third additionnal custom command .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_FLASH_CMD_4: +.. _rom__FLASH_CMD_4: FLASH_CMD_4 """"""""""" -Fourth additionnal custom command. +Fourth additionnal custom command .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_FLASH_WAIT: +.. _rom__FLASH_WAIT: FLASH_WAIT """""""""" -Apply a wait loop before using the flash. +Apply a wait loop before using the flash .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_FLASH_WAKEUP_WAIT: +.. _rom__FLASH_WAKEUP_WAIT: FLASH_WAKEUP_WAIT """"""""""""""""" -Wait loop when waiting for flash wakup. +Wait loop when waiting for flash wakup .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_FLASH_STATUS: +.. _rom__FLASH_STATUS: FLASH_STATUS """""""""""" -Flash status register value. +Flash status register value .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_FLASH_COMMANDS: +.. _rom__FLASH_COMMANDS: FLASH_COMMANDS """""""""""""" -Flash commands. +Flash commands .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_INFO_4: +.. _rom__INFO_4: INFO_4 """""" -Information register 4. +Information eFuse 4 .. table:: - - +-----+---+---------------------+-------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+=============================================================+ - | 0|R/W|FLASH_GPIO_PULSE_GEN |Generate a pulse on a GPIO before using the flash. | - +-----+---+---------------------+-------------------------------------------------------------+ - | 1|R/W|FLASH_GPIO_PULSE_WAIT|1 if the ROM should wait after it has set the GPIO to active.| - +-----+---+---------------------+-------------------------------------------------------------+ - | 2|R/W|FLASH_GPIO_PULSE_POL |1 if the pulse should be active high. | - +-----+---+---------------------+-------------------------------------------------------------+ - |9:3 |R/W|FLASH_GPIO_PULSE_ID |GPIO pulse ID. | - +-----+---+---------------------+-------------------------------------------------------------+ - | 10|R/W|NEVA_CFG |Set the NEVA configuration from NEVA_CFG. | - +-----+---+---------------------+-------------------------------------------------------------+ - -.. _rom_FLASH_GPIO_PULSE_WAIT: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+=============================================================+ + | 0|R/W|FLASH_GPIO_PULSE_GEN |0x0 |Generate a pulse on a GPIO before using the flash. | + +-----+---+---------------------+-----+-------------------------------------------------------------+ + | 1|R/W|FLASH_GPIO_PULSE_WAIT|0x0 |1 if the ROM should wait after it has set the GPIO to active.| + +-----+---+---------------------+-----+-------------------------------------------------------------+ + | 2|R/W|FLASH_GPIO_PULSE_POL |0x0 |1 if the pulse should be active high. | + +-----+---+---------------------+-----+-------------------------------------------------------------+ + |9:3 |R/W|FLASH_GPIO_PULSE_ID |0x0 |GPIO pulse ID. | + +-----+---+---------------------+-----+-------------------------------------------------------------+ + | 10|R/W|NEVA_CFG |0x0 |Set the NEVA configuration from NEVA_CFG. | + +-----+---+---------------------+-----+-------------------------------------------------------------+ + +.. _rom__FLASH_GPIO_PULSE_WAIT: FLASH_GPIO_PULSE_WAIT """"""""""""""""""""" -Number of cycles the ROM should wait after it has set the GPIO to active. +Number of cycles the ROM should wait after it has set the GPIO to active .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_NEVA_CFG: +.. _rom__NEVA_CFG: NEVA_CFG """""""" -Number of cycles the ROM should wait after it has set the GPIO to active. +Number of cycles the ROM should wait after it has set the GPIO to active .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |31:0 |R/W|VALUE|0x0 |Value to copy to register| + +-----+---+-----+-----+-------------------------+ -.. _rom_MRAM_TRIM_SIZE: +.. _rom__MRAM_TRIM_SIZE: MRAM_TRIM_SIZE """""""""""""" -When MRAM_TRIM is 1, this gives the size of the MRAM trim config. +When MRAM_TRIM is 1, this gives the size of the MRAM trim config .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ -.. _rom_MRAM_TRIM_START: +.. _rom__MRAM_TRIM_START: MRAM_TRIM_START """"""""""""""" -When MTAM_TRIM is 1, this is the first efuse storing the MRAM trim configuration. +When MRAM_TRIM is 1, this is the first eFuse storing the MRAM trim configuration .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+-------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===========================================+ + |31:0 |R/W|VALUE|0x0 |Configuration value to be used by boot code| + +-----+---+-----+-----+-------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/rtc_v1.rst b/rtos/pulp/gap_archi/doc/ips/rtc_v1.rst index 72556fbfa..63666b8f6 100644 --- a/rtos/pulp/gap_archi/doc/ips/rtc_v1.rst +++ b/rtos/pulp/gap_archi/doc/ips/rtc_v1.rst @@ -8,128 +8,133 @@ Register map Overview """""""" -.. table:: - +---------------------------+------+-----+--------------------------------------+ - | Name |Offset|Width| Description | - +===========================+======+=====+======================================+ - |:ref:`APB_SR` | 0| 32|RTC APB status register. | - +---------------------------+------+-----+--------------------------------------+ - |:ref:`APB_CR` | 4| 32|RTC APB control register. | - +---------------------------+------+-----+--------------------------------------+ - |:ref:`APB_DR` | 8| 32|RTC APB data register. | - +---------------------------+------+-----+--------------------------------------+ - |:ref:`APB_ICR`| 16| 32|RTC APB interruption control register.| - +---------------------------+------+-----+--------------------------------------+ - |:ref:`APB_IMR`| 20| 32|RTC APB interruption mask register. | - +---------------------------+------+-----+--------------------------------------+ - |:ref:`APB_IFR`| 24| 32|RTC APB interruption flag register. | - +---------------------------+------+-----+--------------------------------------+ - -.. _rtc_APB_SR: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +----------------------------+------+-----+-------------------------------------+ + | Name |Offset|Width| Description | + +============================+======+=====+=====================================+ + |:ref:`APB_SR` | 0| 32|RTC APB status register | + +----------------------------+------+-----+-------------------------------------+ + |:ref:`APB_CR` | 4| 32|RTC APB control register | + +----------------------------+------+-----+-------------------------------------+ + |:ref:`APB_DR` | 8| 32|RTC APB data register | + +----------------------------+------+-----+-------------------------------------+ + |:ref:`APB_ICR`| 16| 32|RTC APB interruption control register| + +----------------------------+------+-----+-------------------------------------+ + |:ref:`APB_IMR`| 20| 32|RTC APB interruption mask register | + +----------------------------+------+-----+-------------------------------------+ + |:ref:`APB_IFR`| 24| 32|RTC APB interruption flag register | + +----------------------------+------+-----+-------------------------------------+ + +.. _rtc__APB_SR: APB_SR """""" -RTC APB status register. +RTC APB status register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------+---------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+=========================================================================================================+ - |1:0 |R |APB_INT |APB interrupt status bitfield : - 1'b0: No interruption has been requested - 1'b1: Interruption requested| - +-----+---+----------+---------------------------------------------------------------------------------------------------------+ - |31:2 |R/W|RESERVED_0|Reserved/Not used. | - +-----+---+----------+---------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=================================================================================================+ + |1:0 |R |APB_INT|0x0 |APB interrupt status bitfield: b0: no interruption has been requested; b1: interruption requested| + +-----+---+-------+-----+-------------------------------------------------------------------------------------------------+ -.. _rtc_APB_CR: +.. _rtc__APB_CR: APB_CR """""" -RTC APB control register. +RTC APB control register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------+---------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+=========================================================================================================+ - |5:0 |R/W|APB_ADDR |Indirect access address configuration. | - +-----+---+----------+---------------------------------------------------------------------------------------------------------+ - |15:6 |R/W|RESERVED_0|Reserved/Not used. | - +-----+---+----------+---------------------------------------------------------------------------------------------------------+ - |16 |R/W|APB_OP |Indirect access operation configuration bitfield : - 1'b0: APB read operation - 1'b1: APB write operation| - +-----+---+----------+---------------------------------------------------------------------------------------------------------+ - |31:17|R/W|RESERVED_1|Reserved/Not used. | - +-----+---+----------+---------------------------------------------------------------------------------------------------------+ + +-----+---+--------+-----+--------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+==========================================================================+ + |5:0 |R/W|APB_ADDR|0x0 |Indirect access address | + +-----+---+--------+-----+--------------------------------------------------------------------------+ + |16 |R/W|APB_OP |0x0 |Indirect access operation: b0: APB read operation; b1: APB write operation| + +-----+---+--------+-----+--------------------------------------------------------------------------+ -.. _rtc_APB_DR: +.. _rtc__APB_DR: APB_DR """""" -RTC APB data register. +RTC APB data register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+==============================+ - |31:0 |R/W|APB_DATA|Indirect access data register.| - +-----+---+--------+------------------------------+ + +-----+---+--------+-----+--------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+====================+ + |31:0 |R/W|APB_DATA|0x0 |Indirect access data| + +-----+---+--------+-----+--------------------+ -.. _rtc_APB_ICR: +.. _rtc__APB_ICR: APB_ICR """"""" -RTC APB interruption control register. +RTC APB interruption control register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+============================================================================================================================================================================================================================================================================+ - |1:0 |R/W|MODE |APB interrupt signal mode configuration bitfield : - 2'b00: APB interrupt is a high level signal - 2'b01: APB interrupt is a low level signal - 2'b10: APB interrupt is a high level pulse of 1 PCLK duration - 2'b11: APB interrupt is a low level pulse of 1 PCLK duration| - +-----+---+----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:2 |R/W|RESERVED_0|Reserved/Not used. | - +-----+---+----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=====================================================================================================================================================================================================================================================================+ + |1:0 |R/W|MODE|0x0 |APB interrupt signal mode configuration: b00: APB interrupt is a high level signal; b01: APB interrupt is a low level signal; b10: APB interrupt is a high level pulse of 1 REF SLOW clock period; b11: APB interrupt is a low level pulse of 1 REF SLOW clock period| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _rtc_APB_IMR: +.. _rtc__APB_IMR: APB_IMR """"""" -RTC APB interruption mask register. +RTC APB interruption mask register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------+---------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+=================================================================================+ - | 0|R/W|READ_MASK |APB read operation interruption mask bitfield : - 1'b0: enabled - 1'b1: disabled | - +-----+---+----------+---------------------------------------------------------------------------------+ - | 1|R/W|WRITE_MASK|APB write operation interruption mask bitfield : - 1'b0: enabled - 1'b1: disabled| - +-----+---+----------+---------------------------------------------------------------------------------+ - |31:2 |R/W|RESERVED_0|Reserved/Not used. | - +-----+---+----------+---------------------------------------------------------------------------------+ + +-----+---+----------+-----+----------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+================================================================+ + | 0|R/W|READ_MASK |0x0 |APB read operation interruption mask: b0: enabled; b1: disabled | + +-----+---+----------+-----+----------------------------------------------------------------+ + | 1|R/W|WRITE_MASK|0x0 |APB write operation interruption mask: b0: enabled; b1: disabled| + +-----+---+----------+-----+----------------------------------------------------------------+ -.. _rtc_APB_IFR: +.. _rtc__APB_IFR: APB_IFR """"""" -RTC APB interruption flag register. +RTC APB interruption flag register .. table:: - - +-----+---+----------+------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+==============================================================================================================================+ - | 0|R/W|READ_FLAG |APB read operation status flag bitfield : - 1'b0: nothing - 1'b1: read operation done and requested indirect data is available| - +-----+---+----------+------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|WRITE_FLAG|APB write operation status flag bitfield : - 1'b0: nothing - 1'b1: write operation done | - +-----+---+----------+------------------------------------------------------------------------------------------------------------------------------+ - |31:2 |R/W|RESERVED_0|Reserved/Not used. | - +-----+---+----------+------------------------------------------------------------------------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+-------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+=============================================================================================================+ + | 0|R/W|READ_FLAG |0x0 |APB read operation status flag: b0: nothing; b1: read operation done and requested indirect data is available| + +-----+---+----------+-----+-------------------------------------------------------------------------------------------------------------+ + | 1|R/W|WRITE_FLAG|0x0 |APB write operation status flag: b0: nothing; b1: write operation done | + +-----+---+----------+-----+-------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/rtc_v1_internals.rst b/rtos/pulp/gap_archi/doc/ips/rtc_v1_internals.rst new file mode 100644 index 000000000..6929623c7 --- /dev/null +++ b/rtos/pulp/gap_archi/doc/ips/rtc_v1_internals.rst @@ -0,0 +1,401 @@ +.. + Input file: fe/ips/rtc_dolphin/docs/RTC_reference_internals.md + +Register map for indirectly accessed registers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + +Overview +"""""""" + + +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +----------------------------------------------------------+------+-----+------------------------------------------+ + | Name |Offset|Width| Description | + +==========================================================+======+=====+==========================================+ + |:ref:`RTC_SR` | 0| 32|RTC status register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`RTC_CR` | 1| 32|RTC control register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`RTC_ICR` | 8| 32|RTC interrupt control register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`RTC_IMR` | 9| 32|RTC interrupt mask register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`RTC_IFR` | 10| 32|RTC interrupt flag register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`CALENDAR_CONTROL` | 16| 32|RTC calendar control register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`CALENDAR_TIME` | 18| 32|RTC calendar time register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`CALENDAR_DATE` | 19| 32|RTC calendar date register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`ALARM_CONTROL` | 24| 32|RTC alarm control register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`ALARM1_TIME` | 26| 32|RTC alarm 1 time register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`ALARM1_DATE` | 27| 32|RTC alarm 1 date register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`COUNTDOWN_CONTROL`| 32| 32|RTC countdown control register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`COUNTDOWN1_INIT` | 33| 32|RTC countdown 1 initialisation register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`COUNTDOWN1_TIMER` | 34| 32|RTC countdown 1 timer register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`CKIN_DIV1` | 40| 32|RTC clock divider 1 register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`CKREF_CONF` | 42| 32|RTC reference clock configuration register| + +----------------------------------------------------------+------+-----+------------------------------------------+ + |:ref:`RTC_TEST_REG_A` | 48| 32|RTC test register | + +----------------------------------------------------------+------+-----+------------------------------------------+ + +.. _rtc_internals__RTC_SR: + +RTC_SR +"""""" + +RTC status register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+----------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+========================================================================================+ + | 0|R |INT |0x0 |RTC interrupt status: b0: no interruption has been requested; b1: interruption requested| + +-----+---+----+-----+----------------------------------------------------------------------------------------+ + +.. _rtc_internals__RTC_CR: + +RTC_CR +"""""" + +RTC control register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+-----+-------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+===========================================================================================================================================+ + | 0|R/W|SB |0x0 |RTC standby configuration: b0: RTC is in active mode; b1: RTC is in standby mode | + +-----+---+--------+-----+-------------------------------------------------------------------------------------------------------------------------------------------+ + | 4|R/W|CAL_EN |0x0 |Calibration process activation (unused, must remain b0) | + +-----+---+--------+-----+-------------------------------------------------------------------------------------------------------------------------------------------+ + | 8|R/W|SOFT_RST|0x0 |Soft reset command: b0: no reset; b1: reset the calendar, alarm, countdown and clock generation features and associated registers (CALENDAR| + +-----+---+--------+-----+-------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _rtc_internals__RTC_ICR: + +RTC_ICR +""""""" + +RTC interrupt control register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=====================================================================================================================================================================================================================================================================+ + |1:0 |R/W|MODE|0x0 |RTC interrupt signal mode configuration: b00: RTC interrupt is a high level signal; b01: RTC interrupt is a low level signal; b10: RTC interrupt is a high level pulse of 1 REF SLOW clock period; b11: RTC interrupt is a low level pulse of 1 REF SLOW clock period| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _rtc_internals__RTC_IMR: + +RTC_IMR +""""""" + +RTC interrupt mask register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+---------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+=======================================================================================+ + | 0|R/W|ALARM_MASK|0x1 |Alarm 1 interrupt mask configuration: b0: interrupt enabled; b1: interrupt disabled | + +-----+---+----------+-----+---------------------------------------------------------------------------------------+ + | 4|R/W|TIMER_MASK|0x1 |Timer 1 interrupt mask configuration: b0: interrupt enabled; b1: interrupt disabled | + +-----+---+----------+-----+---------------------------------------------------------------------------------------+ + | 12|R/W|CAL_MASK |0x1 |Calibration interrupt mask configuration: b0: interrupt enabled; b1: interrupt disabled| + +-----+---+----------+-----+---------------------------------------------------------------------------------------+ + +.. _rtc_internals__RTC_IFR: + +RTC_IFR +""""""" + +RTC interrupt flag register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+=====================================================================================================+ + | 0|R |ALARM_FLAG|0x0 |Alarm 1 interrupt status flag: b0: nothing; b1: calendar has reached the date and time set in alarm 1| + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------+ + | 4|R |TIMER_FLAG|0x0 |Timer 1 interrupt status flag: b0: nothing; b1: countdown timer 1 has reached value 0 | + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------+ + | 12|R |CAL_FLAG |0x0 |Calibration interrupt status flag (unused): b0: nothing; b1: calibration process has ended | + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------+ + +.. _rtc_internals__CALENDAR_CONTROL: + +CALENDAR_CONTROL +"""""""""""""""" + +RTC calendar control register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+--------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+================================================================================+ + | 0|R/W|SB |0x0 |Calendar standby configuration: b0: calendar is active; b1: calendar is disabled| + +-----+---+----+-----+--------------------------------------------------------------------------------+ + +.. _rtc_internals__CALENDAR_TIME: + +CALENDAR_TIME +""""""""""""" + +RTC calendar time register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================+ + |3:0 |R/W|SEC0|0x0 |Calendar time: seconds digit 0| + +-----+---+----+-----+------------------------------+ + |7:4 |R/W|SEC1|0x0 |Calendar time: seconds digit 1| + +-----+---+----+-----+------------------------------+ + |11:8 |R/W|MIN0|0x0 |Calendar time: minutes digit 0| + +-----+---+----+-----+------------------------------+ + |15:12|R/W|MIN1|0x0 |Calendar time: minutes digit 1| + +-----+---+----+-----+------------------------------+ + |19:16|R/W|HOU0|0x0 |Calendar time: hours digit 0 | + +-----+---+----+-----+------------------------------+ + |23:20|R/W|HOU1|0x0 |Calendar time: hours digit 1 | + +-----+---+----+-----+------------------------------+ + +.. _rtc_internals__CALENDAR_DATE: + +CALENDAR_DATE +""""""""""""" + +RTC calendar date register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+----------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+============================+ + |3:0 |R/W|DAY0|0x1 |Calendar date: day digit 0 | + +-----+---+----+-----+----------------------------+ + |7:4 |R/W|DAY1|0x0 |Calendar date: day digit 1 | + +-----+---+----+-----+----------------------------+ + |11:8 |R/W|MON0|0x1 |Calendar date: month digit 0| + +-----+---+----+-----+----------------------------+ + |15:12|R/W|MON1|0x0 |Calendar date: month digit 1| + +-----+---+----+-----+----------------------------+ + |19:16|R/W|YEA0|0x0 |Calendar date: year digit 0 | + +-----+---+----+-----+----------------------------+ + |23:20|R/W|YEA1|0x0 |Calendar date: year digit 1 | + +-----+---+----+-----+----------------------------+ + +.. _rtc_internals__ALARM_CONTROL: + +ALARM_CONTROL +""""""""""""" + +RTC alarm control register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================================================================================================================================+ + | 0|R/W|SB |0x1 |Alarm 1 standby configuration: b0: alarm is active; b1: alarm is inactive. In single mode, this bitfield is automatically updated to b1 after the event occurs| + +-----+---+----+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 4|R/W|MODE|0x0 |Alarm 1 mode configuration: b0: single; b1: repeat | + +-----+---+----+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |19:16|R/W|CFG |0x6 |Alarm 1 repeat configuration: b0011: every second; b0100: every minute; b0101: every hour; b0110: every day; b0111: every month; b1000: every year | + +-----+---+----+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _rtc_internals__ALARM1_TIME: + +ALARM1_TIME +""""""""""" + +RTC alarm 1 time register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+-----------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================+ + |3:0 |R/W|SEC0|0x0 |Alarm 1 time: seconds digit 0| + +-----+---+----+-----+-----------------------------+ + |7:4 |R/W|SEC1|0x0 |Alarm 1 time: seconds digit 1| + +-----+---+----+-----+-----------------------------+ + |11:8 |R/W|MIN0|0x0 |Alarm 1 time: minutes digit 0| + +-----+---+----+-----+-----------------------------+ + |15:12|R/W|MIN1|0x0 |Alarm 1 time: minutes digit 1| + +-----+---+----+-----+-----------------------------+ + |19:16|R/W|HOU0|0x0 |Alarm 1 time: hours digit 0 | + +-----+---+----+-----+-----------------------------+ + |23:20|R/W|HOU1|0x0 |Alarm 1 time: hours digit 1 | + +-----+---+----+-----+-----------------------------+ + +.. _rtc_internals__ALARM1_DATE: + +ALARM1_DATE +""""""""""" + +RTC alarm 1 date register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+---------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================+ + |3:0 |R/W|DAY0|0x0 |Alarm 1 date: day digit 0 | + +-----+---+----+-----+---------------------------+ + |7:4 |R/W|DAY1|0x0 |Alarm 1 date: day digit 1 | + +-----+---+----+-----+---------------------------+ + |11:8 |R/W|MON0|0x0 |Alarm 1 date: month digit 0| + +-----+---+----+-----+---------------------------+ + |15:12|R/W|MON1|0x0 |Alarm 1 date: month digit 1| + +-----+---+----+-----+---------------------------+ + |19:16|R/W|YEA0|0x0 |Alarm 1 date: year digit 0 | + +-----+---+----+-----+---------------------------+ + |23:20|R/W|YEA1|0x0 |Alarm 1 date: year digit 1 | + +-----+---+----+-----+---------------------------+ + +.. _rtc_internals__COUNTDOWN_CONTROL: + +COUNTDOWN_CONTROL +""""""""""""""""" + +RTC countdown control register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+============================================================================================================================================================================================+ + | 0|R/W|SB |0x1 |Countdown timer 1 standby configuration: b0: countdown timer is active; b1: countdown timer is inactive. In single mode, this bitfield is automatically updated to b1 after the event occurs| + +-----+---+----+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 4|R/W|MODE|0x0 |Countdown timer 1 mode configuration: b0: single; b1: repeat | + +-----+---+----+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _rtc_internals__COUNTDOWN1_INIT: + +COUNTDOWN1_INIT +""""""""""""""" + +RTC countdown 1 initialisation register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+----------+-------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+===============================+ + |31:0 |R/W|VAL |0xFFFFFFFF|Countdown timer 1 initial value| + +-----+---+----+----------+-------------------------------+ + +.. _rtc_internals__COUNTDOWN1_TIMER: + +COUNTDOWN1_TIMER +"""""""""""""""" + +RTC countdown 1 timer register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+----------+-------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+===============================+ + |31:0 |R |VAL |0x00000000|Countdown timer 1 current value| + +-----+---+----+----------+-------------------------------+ + +.. _rtc_internals__CKIN_DIV1: + +CKIN_DIV1 +""""""""" + +RTC clock divider 1 register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+------+-------------------------------------+ + |Bit #|R/W|Name|Reset | Description | + +=====+===+====+======+=====================================+ + |15:0 |R/W|VAL |0x8000|Countdown timer 1 clock divider value| + +-----+---+----+------+-------------------------------------+ + +.. _rtc_internals__CKREF_CONF: + +CKREF_CONF +"""""""""" + +RTC reference clock configuration register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+--------+-----------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+========+=========================================+ + |21:0 |R/W|VAL |0x0F4240|Countdown 1 reference clock configuration| + +-----+---+----+--------+-----------------------------------------+ + +.. _rtc_internals__RTC_TEST_REG_A: + +RTC_TEST_REG_A +"""""""""""""" + +RTC test register + +.. table:: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+----------+-----------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================+ + |21:0 |R/W|RESERVED|0x00001E3D|Reserved for test| + +-----+---+--------+----------+-----------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/secured_riscv_debug.rst b/rtos/pulp/gap_archi/doc/ips/secured_riscv_debug.rst index ab040da38..5d9f57a3f 100644 --- a/rtos/pulp/gap_archi/doc/ips/secured_riscv_debug.rst +++ b/rtos/pulp/gap_archi/doc/ips/secured_riscv_debug.rst @@ -8,129 +8,134 @@ Register map Overview """""""" -.. table:: - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +===================================================+======+=====+===================================================================+ - |:ref:`CTRL` | 0| 32|Debug control configuration register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`HIT` | 4| 32|Debug hit status register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`IE` | 8| 32|Debug exception trap enable configuration register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CAUSE` | 12| 32|Debug trap cause status register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`NPC` | 8192| 32|Debug next program counter value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`PPC` | 8196| 32|Debug previous program counter value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR0` | 1024| 32|Core general purpose register 0 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR1` | 1028| 32|Core general purpose register 1 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR2` | 1032| 32|Core general purpose register 2 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR3` | 1036| 32|Core general purpose register 3 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR4` | 1040| 32|Core general purpose register 4 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR5` | 1044| 32|Core general purpose register 5 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR6` | 1048| 32|Core general purpose register 6 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR7` | 1052| 32|Core general purpose register 7 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR8` | 1056| 32|Core general purpose register 8 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR9` | 1060| 32|Core general purpose register 9 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR10` | 1064| 32|Core general purpose register 10 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR11` | 1068| 32|Core general purpose register 11 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR12` | 1072| 32|Core general purpose register 12 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR13` | 1076| 32|Core general purpose register 13 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR14` | 1080| 32|Core general purpose register 14 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR15` | 1084| 32|Core general purpose register 15 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR16` | 1088| 32|Core general purpose register 16 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR17` | 1092| 32|Core general purpose register 17 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR18` | 1096| 32|Core general purpose register 18 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR19` | 1100| 32|Core general purpose register 19 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR20` | 1104| 32|Core general purpose register 20 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR21` | 1108| 32|Core general purpose register 21 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR22` | 1112| 32|Core general purpose register 22 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR23` | 1116| 32|Core general purpose register 23 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR24` | 1120| 32|Core general purpose register 24 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR25` | 1124| 32|Core general purpose register 25 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR26` | 1128| 32|Core general purpose register 26 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR27` | 1132| 32|Core general purpose register 27 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR28` | 1136| 32|Core general purpose register 28 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR29` | 1140| 32|Core general purpose register 29 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR30` | 1144| 32|Core general purpose register 30 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`GPR31` | 1148| 32|Core general purpose register 31 value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_MSTATUS`| 19456| 32|Core CSR machine status value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_MTVEC` | 19476| 32|Core CSR machine vector-trap base address value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_MEPC` | 19716| 32|Core CSR machine exception program counter value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_MCAUSE` | 19720| 32|Core CSR machine trap cause value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_PCCR` | 24064| 32|Core CSR performance counter counter register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_PCER` | 24192| 32|Core CSR performance counter enable configuration register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_PCMR` | 24196| 32|Core CSR performance counter mode configuration register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_HWLP0S` | 24256| 32|Core CSR hardware loop 0 start configuration register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_HWLP0E` | 24260| 32|Core CSR hardware loop 0 end configuration register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_HWLP0C` | 24264| 32|Core CSR hardware loop 0 counter configuration register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_HWLP1S` | 24272| 32|Core CSR hardware loop 1 start configuration register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_HWLP1E` | 24276| 32|Core CSR hardware loop 1 end configuration register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_HWLP1C` | 24280| 32|Core CSR hardware loop 1 counter configuration register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_PRIVLV` | 28736| 32|Cose CSR current privilege level status register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_UHARTID`| 16464| 32|Core CSR user privilege mode hardware thread ID status register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_MHARTID`| 31824| 32|Core CSR machine privilege mode hardware thread ID status register.| - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_USTATUS`| 16404| 32|Core CSR user status value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_UTVEC` | 16464| 32|Core CSR user vector-trap base address value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_UEPC` | 16644| 32|Core CSR user exception program counter value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - |:ref:`CSR_UCAUSE` | 16648| 32|Core CSR user trap cause value register. | - +---------------------------------------------------+------+-----+-------------------------------------------------------------------+ - -.. _secured_riscv_debug_CTRL: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +====================================================+======+=====+===================================================================+ + |:ref:`CTRL` | 0| 32|Debug control configuration register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`HIT` | 4| 32|Debug hit status register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`IE` | 8| 32|Debug exception trap enable configuration register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CAUSE` | 12| 32|Debug trap cause status register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`NPC` | 8192| 32|Debug next program counter value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`PPC` | 8196| 32|Debug previous program counter value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR0` | 1024| 32|Core general purpose register 0 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR1` | 1028| 32|Core general purpose register 1 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR2` | 1032| 32|Core general purpose register 2 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR3` | 1036| 32|Core general purpose register 3 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR4` | 1040| 32|Core general purpose register 4 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR5` | 1044| 32|Core general purpose register 5 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR6` | 1048| 32|Core general purpose register 6 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR7` | 1052| 32|Core general purpose register 7 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR8` | 1056| 32|Core general purpose register 8 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR9` | 1060| 32|Core general purpose register 9 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR10` | 1064| 32|Core general purpose register 10 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR11` | 1068| 32|Core general purpose register 11 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR12` | 1072| 32|Core general purpose register 12 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR13` | 1076| 32|Core general purpose register 13 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR14` | 1080| 32|Core general purpose register 14 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR15` | 1084| 32|Core general purpose register 15 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR16` | 1088| 32|Core general purpose register 16 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR17` | 1092| 32|Core general purpose register 17 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR18` | 1096| 32|Core general purpose register 18 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR19` | 1100| 32|Core general purpose register 19 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR20` | 1104| 32|Core general purpose register 20 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR21` | 1108| 32|Core general purpose register 21 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR22` | 1112| 32|Core general purpose register 22 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR23` | 1116| 32|Core general purpose register 23 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR24` | 1120| 32|Core general purpose register 24 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR25` | 1124| 32|Core general purpose register 25 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR26` | 1128| 32|Core general purpose register 26 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR27` | 1132| 32|Core general purpose register 27 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR28` | 1136| 32|Core general purpose register 28 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR29` | 1140| 32|Core general purpose register 29 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR30` | 1144| 32|Core general purpose register 30 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`GPR31` | 1148| 32|Core general purpose register 31 value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_MSTATUS`| 19456| 32|Core CSR machine status value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_MTVEC` | 19476| 32|Core CSR machine vector-trap base address value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_MEPC` | 19716| 32|Core CSR machine exception program counter value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_MCAUSE` | 19720| 32|Core CSR machine trap cause value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_PCCR` | 24064| 32|Core CSR performance counter counter register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_PCER` | 24192| 32|Core CSR performance counter enable configuration register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_PCMR` | 24196| 32|Core CSR performance counter mode configuration register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_HWLP0S` | 24256| 32|Core CSR hardware loop 0 start configuration register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_HWLP0E` | 24260| 32|Core CSR hardware loop 0 end configuration register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_HWLP0C` | 24264| 32|Core CSR hardware loop 0 counter configuration register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_HWLP1S` | 24272| 32|Core CSR hardware loop 1 start configuration register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_HWLP1E` | 24276| 32|Core CSR hardware loop 1 end configuration register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_HWLP1C` | 24280| 32|Core CSR hardware loop 1 counter configuration register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_PRIVLV` | 28736| 32|Cose CSR current privilege level status register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_UHARTID`| 16464| 32|Core CSR user privilege mode hardware thread ID status register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_MHARTID`| 31824| 32|Core CSR machine privilege mode hardware thread ID status register.| + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_USTATUS`| 16404| 32|Core CSR user status value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_UTVEC` | 16464| 32|Core CSR user vector-trap base address value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_UEPC` | 16644| 32|Core CSR user exception program counter value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + |:ref:`CSR_UCAUSE` | 16648| 32|Core CSR user trap cause value register. | + +----------------------------------------------------+------+-----+-------------------------------------------------------------------+ + +.. _secured_riscv_debug__CTRL: CTRL """" @@ -138,13 +143,15 @@ CTRL Debug control configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_HIT: +.. _secured_riscv_debug__HIT: HIT """ @@ -152,13 +159,15 @@ HIT Debug hit status register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_IE: +.. _secured_riscv_debug__IE: IE "" @@ -166,13 +175,15 @@ IE Debug exception trap enable configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CAUSE: +.. _secured_riscv_debug__CAUSE: CAUSE """"" @@ -180,13 +191,15 @@ CAUSE Debug trap cause status register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_NPC: +.. _secured_riscv_debug__NPC: NPC """ @@ -194,13 +207,15 @@ NPC Debug next program counter value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_PPC: +.. _secured_riscv_debug__PPC: PPC """ @@ -208,13 +223,15 @@ PPC Debug previous program counter value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR0: +.. _secured_riscv_debug__GPR0: GPR0 """" @@ -222,13 +239,15 @@ GPR0 Core general purpose register 0 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR1: +.. _secured_riscv_debug__GPR1: GPR1 """" @@ -236,13 +255,15 @@ GPR1 Core general purpose register 1 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR2: +.. _secured_riscv_debug__GPR2: GPR2 """" @@ -250,13 +271,15 @@ GPR2 Core general purpose register 2 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR3: +.. _secured_riscv_debug__GPR3: GPR3 """" @@ -264,13 +287,15 @@ GPR3 Core general purpose register 3 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR4: +.. _secured_riscv_debug__GPR4: GPR4 """" @@ -278,13 +303,15 @@ GPR4 Core general purpose register 4 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR5: +.. _secured_riscv_debug__GPR5: GPR5 """" @@ -292,13 +319,15 @@ GPR5 Core general purpose register 5 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR6: +.. _secured_riscv_debug__GPR6: GPR6 """" @@ -306,13 +335,15 @@ GPR6 Core general purpose register 6 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR7: +.. _secured_riscv_debug__GPR7: GPR7 """" @@ -320,13 +351,15 @@ GPR7 Core general purpose register 7 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR8: +.. _secured_riscv_debug__GPR8: GPR8 """" @@ -334,13 +367,15 @@ GPR8 Core general purpose register 8 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR9: +.. _secured_riscv_debug__GPR9: GPR9 """" @@ -348,13 +383,15 @@ GPR9 Core general purpose register 9 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR10: +.. _secured_riscv_debug__GPR10: GPR10 """"" @@ -362,13 +399,15 @@ GPR10 Core general purpose register 10 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR11: +.. _secured_riscv_debug__GPR11: GPR11 """"" @@ -376,13 +415,15 @@ GPR11 Core general purpose register 11 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR12: +.. _secured_riscv_debug__GPR12: GPR12 """"" @@ -390,13 +431,15 @@ GPR12 Core general purpose register 12 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR13: +.. _secured_riscv_debug__GPR13: GPR13 """"" @@ -404,13 +447,15 @@ GPR13 Core general purpose register 13 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR14: +.. _secured_riscv_debug__GPR14: GPR14 """"" @@ -418,13 +463,15 @@ GPR14 Core general purpose register 14 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR15: +.. _secured_riscv_debug__GPR15: GPR15 """"" @@ -432,13 +479,15 @@ GPR15 Core general purpose register 15 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR16: +.. _secured_riscv_debug__GPR16: GPR16 """"" @@ -446,13 +495,15 @@ GPR16 Core general purpose register 16 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR17: +.. _secured_riscv_debug__GPR17: GPR17 """"" @@ -460,13 +511,15 @@ GPR17 Core general purpose register 17 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR18: +.. _secured_riscv_debug__GPR18: GPR18 """"" @@ -474,13 +527,15 @@ GPR18 Core general purpose register 18 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR19: +.. _secured_riscv_debug__GPR19: GPR19 """"" @@ -488,13 +543,15 @@ GPR19 Core general purpose register 19 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR20: +.. _secured_riscv_debug__GPR20: GPR20 """"" @@ -502,13 +559,15 @@ GPR20 Core general purpose register 20 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR21: +.. _secured_riscv_debug__GPR21: GPR21 """"" @@ -516,13 +575,15 @@ GPR21 Core general purpose register 21 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR22: +.. _secured_riscv_debug__GPR22: GPR22 """"" @@ -530,13 +591,15 @@ GPR22 Core general purpose register 22 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR23: +.. _secured_riscv_debug__GPR23: GPR23 """"" @@ -544,13 +607,15 @@ GPR23 Core general purpose register 23 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR24: +.. _secured_riscv_debug__GPR24: GPR24 """"" @@ -558,13 +623,15 @@ GPR24 Core general purpose register 24 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR25: +.. _secured_riscv_debug__GPR25: GPR25 """"" @@ -572,13 +639,15 @@ GPR25 Core general purpose register 25 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR26: +.. _secured_riscv_debug__GPR26: GPR26 """"" @@ -586,13 +655,15 @@ GPR26 Core general purpose register 26 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR27: +.. _secured_riscv_debug__GPR27: GPR27 """"" @@ -600,13 +671,15 @@ GPR27 Core general purpose register 27 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR28: +.. _secured_riscv_debug__GPR28: GPR28 """"" @@ -614,13 +687,15 @@ GPR28 Core general purpose register 28 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR29: +.. _secured_riscv_debug__GPR29: GPR29 """"" @@ -628,13 +703,15 @@ GPR29 Core general purpose register 29 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR30: +.. _secured_riscv_debug__GPR30: GPR30 """"" @@ -642,13 +719,15 @@ GPR30 Core general purpose register 30 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_GPR31: +.. _secured_riscv_debug__GPR31: GPR31 """"" @@ -656,13 +735,15 @@ GPR31 Core general purpose register 31 value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_MSTATUS: +.. _secured_riscv_debug__CSR_MSTATUS: CSR_MSTATUS """"""""""" @@ -670,13 +751,15 @@ CSR_MSTATUS Core CSR machine status value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_MTVEC: +.. _secured_riscv_debug__CSR_MTVEC: CSR_MTVEC """"""""" @@ -684,13 +767,15 @@ CSR_MTVEC Core CSR machine vector-trap base address value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_MEPC: +.. _secured_riscv_debug__CSR_MEPC: CSR_MEPC """""""" @@ -698,13 +783,15 @@ CSR_MEPC Core CSR machine exception program counter value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_MCAUSE: +.. _secured_riscv_debug__CSR_MCAUSE: CSR_MCAUSE """""""""" @@ -712,13 +799,15 @@ CSR_MCAUSE Core CSR machine trap cause value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_PCCR: +.. _secured_riscv_debug__CSR_PCCR: CSR_PCCR """""""" @@ -726,13 +815,15 @@ CSR_PCCR Core CSR performance counter counter register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_PCER: +.. _secured_riscv_debug__CSR_PCER: CSR_PCER """""""" @@ -740,13 +831,15 @@ CSR_PCER Core CSR performance counter enable configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_PCMR: +.. _secured_riscv_debug__CSR_PCMR: CSR_PCMR """""""" @@ -754,13 +847,15 @@ CSR_PCMR Core CSR performance counter mode configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_HWLP0S: +.. _secured_riscv_debug__CSR_HWLP0S: CSR_HWLP0S """""""""" @@ -768,13 +863,15 @@ CSR_HWLP0S Core CSR hardware loop 0 start configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_HWLP0E: +.. _secured_riscv_debug__CSR_HWLP0E: CSR_HWLP0E """""""""" @@ -782,13 +879,15 @@ CSR_HWLP0E Core CSR hardware loop 0 end configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_HWLP0C: +.. _secured_riscv_debug__CSR_HWLP0C: CSR_HWLP0C """""""""" @@ -796,13 +895,15 @@ CSR_HWLP0C Core CSR hardware loop 0 counter configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_HWLP1S: +.. _secured_riscv_debug__CSR_HWLP1S: CSR_HWLP1S """""""""" @@ -810,13 +911,15 @@ CSR_HWLP1S Core CSR hardware loop 1 start configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_HWLP1E: +.. _secured_riscv_debug__CSR_HWLP1E: CSR_HWLP1E """""""""" @@ -824,13 +927,15 @@ CSR_HWLP1E Core CSR hardware loop 1 end configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_HWLP1C: +.. _secured_riscv_debug__CSR_HWLP1C: CSR_HWLP1C """""""""" @@ -838,13 +943,15 @@ CSR_HWLP1C Core CSR hardware loop 1 counter configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_PRIVLV: +.. _secured_riscv_debug__CSR_PRIVLV: CSR_PRIVLV """""""""" @@ -852,13 +959,15 @@ CSR_PRIVLV Cose CSR current privilege level status register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_UHARTID: +.. _secured_riscv_debug__CSR_UHARTID: CSR_UHARTID """"""""""" @@ -866,13 +975,15 @@ CSR_UHARTID Core CSR user privilege mode hardware thread ID status register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_MHARTID: +.. _secured_riscv_debug__CSR_MHARTID: CSR_MHARTID """"""""""" @@ -880,13 +991,15 @@ CSR_MHARTID Core CSR machine privilege mode hardware thread ID status register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_USTATUS: +.. _secured_riscv_debug__CSR_USTATUS: CSR_USTATUS """"""""""" @@ -894,13 +1007,15 @@ CSR_USTATUS Core CSR user status value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_UTVEC: +.. _secured_riscv_debug__CSR_UTVEC: CSR_UTVEC """"""""" @@ -908,13 +1023,15 @@ CSR_UTVEC Core CSR user vector-trap base address value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_UEPC: +.. _secured_riscv_debug__CSR_UEPC: CSR_UEPC """""""" @@ -922,13 +1039,15 @@ CSR_UEPC Core CSR user exception program counter value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ -.. _secured_riscv_debug_CSR_UCAUSE: +.. _secured_riscv_debug__CSR_UCAUSE: CSR_UCAUSE """""""""" @@ -936,8 +1055,10 @@ CSR_UCAUSE Core CSR user trap cause value register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +----+---+----+-----+-----------+ + |Bit#|R/W|Name|Reset|Description| + +====+===+====+=====+===========+ + +----+---+----+-----+-----------+ diff --git a/rtos/pulp/gap_archi/doc/ips/sfu.rst b/rtos/pulp/gap_archi/doc/ips/sfu.rst index 820d873e8..f83121cb4 100644 --- a/rtos/pulp/gap_archi/doc/ips/sfu.rst +++ b/rtos/pulp/gap_archi/doc/ips/sfu.rst @@ -8,135 +8,150 @@ Register map Overview """""""" -.. table:: - +-------------------------------------------+------+-----+-----------------------------------+ - | Name |Offset|Width| Description | - +===========================================+======+=====+===================================+ - |:ref:`GRAPH_PTR` | 0| 32|Pointer to GRAPH configuration | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`GRAPH_CMD` | 4| 32|GRAPH command register | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`CLOCK_PTR` | 8| 32|Pointer to CLOCK configuration | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`CLOCK_CMD` | 12| 32|CLOCK command register | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`SFU_STATUS` | 16| 32|Status of graph and clocks commands| - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`MEM_IN_STATUS` | 20| 32|Status of memory IN interfaces | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`LIMITER_MUTE` | 24| 32|Limiter mute/unmute control | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`VOLUME_INDEX` | 28| 32|Control of Mute/Unmute | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`VOLUME_VALUE` | 32| 32|Control of linear Volume | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`CLK_MONITOR_0` | 36| 32|Control of clock monitors 0..3 | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`CLK_MONITOR_1` | 40| 32|Control of clock monitors 4..7 | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`OUT_MUTE` | 44| 32|Mutes corresponding output channel | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`AUDIO_CLK_CFG_0`| 48| 32|Control Audio clock generator 0 | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`AUDIO_CLK_CFG_1`| 52| 32|Control Audio clock generator 1 | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`AUDIO_CLK_CFG_2`| 56| 32|Control Audio clock generator 2 | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`AUDIO_CLK_CFG_3`| 60| 32|Control Audio clock generator 3 | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`ASRC_RATIO_0` | 64| 32|ASRC0 conversion ratio | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`ASRC_RATIO_1` | 68| 32|ASRC1 conversion ratio | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`ASRC_RATIO_2` | 72| 32|ASRC2 conversion ratio | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`MEM_IN_0_CNT` | 88| 32|Memory input counter | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`MEM_IN_1_CNT` | 92| 32|Memory input counter | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`MEM_IN_2_CNT` | 96| 32|Memory input counter | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`MEM_IN_3_CNT` | 100| 32|Memory input counter | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`MEM_IN_4_CNT` | 104| 32|Memory input counter | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`MEM_IN_5_CNT` | 108| 32|Memory input counter | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`MEM_IN_6_CNT` | 112| 32|Memory input counter | - +-------------------------------------------+------+-----+-----------------------------------+ - |:ref:`MEM_IN_7_CNT` | 116| 32|Memory input counter | - +-------------------------------------------+------+-----+-----------------------------------+ - -.. _sfu_GRAPH_PTR: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +--------------------------------------------+------+-----+-----------------------------------+ + | Name |Offset|Width| Description | + +============================================+======+=====+===================================+ + |:ref:`GRAPH_PTR` | 0| 32|Pointer to graph configuration | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`GRAPH_CMD` | 4| 32|Graph command register | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`CLOCK_PTR` | 8| 32|Pointer to clock configuration | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`CLOCK_CMD` | 12| 32|Clock command register | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`SFU_STATUS` | 16| 32|Status of graph and clocks commands| + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`MEM_IN_STATUS` | 20| 32|Status of memory IN interfaces | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`LIMITER_MUTE` | 24| 32|Limiter mute/unmute control | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`VOLUME_INDEX` | 28| 32|Control of mute/unmute | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`VOLUME_VALUE` | 32| 32|Control of linear volume | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`CLK_MONITOR_0` | 36| 32|Control of clock monitors 0 to 3 | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`CLK_MONITOR_1` | 40| 32|Control of clock monitors 4 to 7 | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`OUT_MUTE` | 44| 32|Control of output channel mute | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`AUDIO_CLK_CFG_0`| 48| 32|Control audio clock generator 0 | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`AUDIO_CLK_CFG_1`| 52| 32|Control audio clock generator 1 | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`AUDIO_CLK_CFG_2`| 56| 32|Control audio clock generator 2 | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`AUDIO_CLK_CFG_3`| 60| 32|Control audio clock generator 3 | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`ASRC_RATIO_0` | 64| 32|ASRC0 conversion ratio | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`ASRC_RATIO_1` | 68| 32|ASRC1 conversion ratio | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`ASRC_RATIO_2` | 72| 32|ASRC2 conversion ratio | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`MEM_IN_0_CNT` | 88| 32|Memory input counter 0 | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`MEM_IN_1_CNT` | 92| 32|Memory input counter 1 | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`MEM_IN_2_CNT` | 96| 32|Memory input counter 2 | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`MEM_IN_3_CNT` | 100| 32|Memory input counter 3 | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`MEM_IN_4_CNT` | 104| 32|Memory input counter 4 | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`MEM_IN_5_CNT` | 108| 32|Memory input counter 5 | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`MEM_IN_6_CNT` | 112| 32|Memory input counter 6 | + +--------------------------------------------+------+-----+-----------------------------------+ + |:ref:`MEM_IN_7_CNT` | 116| 32|Memory input counter 7 | + +--------------------------------------------+------+-----+-----------------------------------+ + +.. _sfu__GRAPH_PTR: GRAPH_PTR """"""""" -Pointer to GRAPH configuration +Pointer to graph configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+----------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+========================================+ + |31:0 |R/W|ADDRESS|0x0 |Address of graph configuration in memory| + +-----+---+-------+-----+----------------------------------------+ -.. _sfu_GRAPH_CMD: +.. _sfu__GRAPH_CMD: GRAPH_CMD """"""""" -GRAPH command register +Graph command register .. table:: - - +-----+---+-----------+--------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+============================================+ - | 0|W |LOAD |Starts GRAPH load | - +-----+---+-----------+--------------------------------------------+ - | 1|W |RECONF |Starts GRAPH reconf | - +-----+---+-----------+--------------------------------------------+ - | 2|W |UNLOAD |Starts GRAPH unload | - +-----+---+-----------+--------------------------------------------+ - | 3|W |SAVE |Starts GRAPH save | - +-----+---+-----------+--------------------------------------------+ - | 4|W |SET_CURRENT|Sets the current graph(used for status read)| - +-----+---+-----------+--------------------------------------------+ - -.. _sfu_CLOCK_PTR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------+-----+---------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+=============================================+ + | 0|W |LOAD |0x0 |Write b1 to start graph load | + +-----+---+-----------+-----+---------------------------------------------+ + | 1|W |RECONF |0x0 |Write b1 to start graph reconfiguration | + +-----+---+-----------+-----+---------------------------------------------+ + | 2|W |UNLOAD |0x0 |Write b1 to start graph unload | + +-----+---+-----------+-----+---------------------------------------------+ + | 3|W |SAVE |0x0 |Write b1 to start graph save | + +-----+---+-----------+-----+---------------------------------------------+ + | 4|W |SET_CURRENT|0x0 |Sets the current graph (used for status read)| + +-----+---+-----------+-----+---------------------------------------------+ + +.. _sfu__CLOCK_PTR: CLOCK_PTR """"""""" -Pointer to CLOCK configuration +Pointer to clock configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+----------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+========================================+ + |31:0 |R/W|ADDRESS|0x0 |Address of clock configuration in memory| + +-----+---+-------+-----+----------------------------------------+ -.. _sfu_CLOCK_CMD: +.. _sfu__CLOCK_CMD: CLOCK_CMD """"""""" -CLOCK command register +Clock command register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+===================+ - | 0|W |LOAD |Starts CLOCK load | - +-----+---+------+-------------------+ - | 1|W |UNLOAD|Starts CLOCK unload| - +-----+---+------+-------------------+ + +-----+---+------+-----+------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+==============================+ + | 0|W |LOAD |0x0 |Write b1 to start clock load | + +-----+---+------+-----+------------------------------+ + | 1|W |UNLOAD|0x0 |Write b1 to start clock unload| + +-----+---+------+-----+------------------------------+ -.. _sfu_SFU_STATUS: +.. _sfu__SFU_STATUS: SFU_STATUS """""""""" @@ -144,28 +159,30 @@ SFU_STATUS Status of graph and clocks commands .. table:: - - +-----+---+-------------+-----------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=========================================+ - | 0|R |CLOCK_LOAD |When set load is ongoing | - +-----+---+-------------+-----------------------------------------+ - | 1|R |GRAPH_LOAD |When set graph load is ongoing | - +-----+---+-------------+-----------------------------------------+ - | 2|R |GRAPH_UNLOAD |When set graph unload is ongoing | - +-----+---+-------------+-----------------------------------------+ - | 3|R |GRAPH_RECONF |When set graph reconfiguration is ongoing| - +-----+---+-------------+-----------------------------------------+ - | 4|R |GRAPH_SAVE |When set graph save is ongoing | - +-----+---+-------------+-----------------------------------------+ - | 5|R |GRAPH_SET_CUR|When set graph set current is ongoing | - +-----+---+-------------+-----------------------------------------+ - |8:6 |R |ASRC_LOCK |Lock status of the 3 ASRCs | - +-----+---+-------------+-----------------------------------------+ - | 9|R |GRAPH_BUSY |When high current graph is busy | - +-----+---+-------------+-----------------------------------------+ - -.. _sfu_MEM_IN_STATUS: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+==============================================================================================+ + | 0|R |CLOCK_LOAD |0x0 |Bit is set to 1 when clock load is ongoing | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------+ + | 1|R |GRAPH_LOAD |0x0 |Bit is set to 1 when graph load is ongoing | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------+ + | 2|R |GRAPH_UNLOAD |0x0 |Bit is set to 1 when graph unload is ongoing | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------+ + | 3|R |GRAPH_RECONF |0x0 |Bit is set to 1 when graph reconfiguration is ongoing | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------+ + | 4|R |GRAPH_SAVE |0x0 |Bit is set to 1 when graph save is ongoing | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------+ + | 5|R |GRAPH_SET_CUR|0x0 |Bit is set to 1 when current graph is being set | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------+ + |8:6 |R |ASRC_LOCK |0x0 |Lock status of the 3 ASRCs: bit *i* is set to 1 when frequency tracking of ASRC\ *i* is locked| + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------+ + | 9|R |GRAPH_BUSY |0x0 |Bit is set to 1 when current graph is busy | + +-----+---+-------------+-----+----------------------------------------------------------------------------------------------+ + +.. _sfu__MEM_IN_STATUS: MEM_IN_STATUS """"""""""""" @@ -173,14 +190,16 @@ MEM_IN_STATUS Status of memory IN interfaces .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+---------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+===========================================================================================================================+ - |7:0 |R/W|STATUS|When reading 1:b0 mem_in ok 1:b1 buffer is ended. When writing 1'b1: restart the mem in interface(ex. after buffer restart)| - +-----+---+------+---------------------------------------------------------------------------------------------------------------------------+ + +-----+---+------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+========================================================================================================================================================================================+ + |7:0 |R/W|STATUS|0x0 |When reading, bit *i* give the status of MemIn interface *i*: b0: interface OK; b1: buffer has ended. Writing b1 to bit *i* restarts the MemIn interface *i* (e.g. after buffer restart)| + +-----+---+------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _sfu_LIMITER_MUTE: +.. _sfu__LIMITER_MUTE: LIMITER_MUTE """""""""""" @@ -188,201 +207,221 @@ LIMITER_MUTE Limiter mute/unmute control .. table:: - - +-----+---+----------+--------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+======================================+ - | 0|R/W|MUTE_LIM_0|1'b1: Enables Mute 1'b0: Disables Mute| - +-----+---+----------+--------------------------------------+ - | 1|R/W|MUTE_LIM_1|1'b1: Enables Mute 1'b0: Disables Mute| - +-----+---+----------+--------------------------------------+ - | 2|R/W|MUTE_LIM_2|1'b1: Enables Mute 1'b0: Disables Mute| - +-----+---+----------+--------------------------------------+ - | 3|R/W|MUTE_LIM_3|1'b1: Enables Mute 1'b0: Disables Mute| - +-----+---+----------+--------------------------------------+ - | 4|R/W|MUTE_LIM_4|1'b1: Enables Mute 1'b0: Disables Mute| - +-----+---+----------+--------------------------------------+ - | 5|R/W|MUTE_LIM_5|1'b1: Enables Mute 1'b0: Disables Mute| - +-----+---+----------+--------------------------------------+ - -.. _sfu_VOLUME_INDEX: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+--------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+==================================================+ + | 0|R/W|MUTE_LIM_0|0x0 |Enable mute 0: b0: mute disabled; b1: mute enabled| + +-----+---+----------+-----+--------------------------------------------------+ + | 1|R/W|MUTE_LIM_1|0x0 |Enable mute 1: b0: mute disabled; b1: mute enabled| + +-----+---+----------+-----+--------------------------------------------------+ + | 2|R/W|MUTE_LIM_2|0x0 |Enable mute 2: b0: mute disabled; b1: mute enabled| + +-----+---+----------+-----+--------------------------------------------------+ + | 3|R/W|MUTE_LIM_3|0x0 |Enable mute 3: b0: mute disabled; b1: mute enabled| + +-----+---+----------+-----+--------------------------------------------------+ + | 4|R/W|MUTE_LIM_4|0x0 |Enable mute 4: b0: mute disabled; b1: mute enabled| + +-----+---+----------+-----+--------------------------------------------------+ + | 5|R/W|MUTE_LIM_5|0x0 |Enable mute 5: b0: mute disabled; b1: mute enabled| + +-----+---+----------+-----+--------------------------------------------------+ + +.. _sfu__VOLUME_INDEX: VOLUME_INDEX """""""""""" -Control of Mute/Unmute +Control of mute/unmute .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+=================================================+ - |4:0 |R/W|INDEX|index of volume accessed by VOLUME_VALUE register| - +-----+---+-----+-------------------------------------------------+ + +-----+---+-----+-----+---------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================================================+ + |4:0 |R/W|INDEX|0x0 |Index of volume setting accessed by VOLUME_VALUE register| + +-----+---+-----+-----+---------------------------------------------------------+ -.. _sfu_VOLUME_VALUE: +.. _sfu__VOLUME_VALUE: VOLUME_VALUE """""""""""" -Control of linear Volume +Control of linear volume .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+======================================================+ - |25:0 |R/W|VOLUME |Value of volume(linear) | - +-----+---+---------+------------------------------------------------------+ - |31:26|R/W|SCALING_V|Value in bits for the scaling (bit 5 is the direction)| - +-----+---+---------+------------------------------------------------------+ + +-----+---+---------+-----+------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+======================================================+ + |25:0 |R/W|VOLUME |0x0 |Value of volume (linear) | + +-----+---+---------+-----+------------------------------------------------------+ + |31:26|R/W|SCALING_V|0x0 |Value in bits for the scaling (bit 5 is the direction)| + +-----+---+---------+-----+------------------------------------------------------+ -.. _sfu_CLK_MONITOR_0: +.. _sfu__CLK_MONITOR_0: CLK_MONITOR_0 """"""""""""" -Control of clock monitors 0..3 +Control of clock monitors 0 to 3 .. table:: - - +-----+---+----+------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+========================+ - |4:0 |R/W|SEL0|Monitored clock selector| - +-----+---+----+------------------------+ - |7 |R/W|EN0 |Enable monitor | - +-----+---+----+------------------------+ - |12:8 |R/W|SEL1|Monitored clock selector| - +-----+---+----+------------------------+ - |15 |R/W|EN1 |Enable monitor | - +-----+---+----+------------------------+ - |20:16|R/W|SEL2|Monitored clock selector| - +-----+---+----+------------------------+ - |23 |R/W|EN2 |Enable moniotor | - +-----+---+----+------------------------+ - |28:24|R/W|SEL3|Monitored clock selector| - +-----+---+----+------------------------+ - |31 |R/W|EN3 |Enable monitor | - +-----+---+----+------------------------+ - -.. _sfu_CLK_MONITOR_1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+-------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=======================================================+ + |4:0 |R/W|SEL0|0x0 |Monitored clock selector (see Clock select table below)| + +-----+---+----+-----+-------------------------------------------------------+ + |7 |R/W|EN0 |0x0 |Set to b1 to enable monitoring | + +-----+---+----+-----+-------------------------------------------------------+ + |12:8 |R/W|SEL1|0x0 |Monitored clock selector (see Clock select table below | + +-----+---+----+-----+-------------------------------------------------------+ + |15 |R/W|EN1 |0x0 |Set to b1 to enable monitoring | + +-----+---+----+-----+-------------------------------------------------------+ + |20:16|R/W|SEL2|0x0 |Monitored clock selector (see Clock select table below | + +-----+---+----+-----+-------------------------------------------------------+ + |23 |R/W|EN2 |0x0 |Set to b1 to enable monitoring | + +-----+---+----+-----+-------------------------------------------------------+ + |28:24|R/W|SEL3|0x0 |Monitored clock selector (see Clock select table below | + +-----+---+----+-----+-------------------------------------------------------+ + |31 |R/W|EN3 |0x0 |Set to b1 to enable monitoring | + +-----+---+----+-----+-------------------------------------------------------+ + +.. _sfu__CLK_MONITOR_1: CLK_MONITOR_1 """"""""""""" -Control of clock monitors 4..7 +Control of clock monitors 4 to 7 .. table:: - - +-----+---+----+------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+========================+ - |4:0 |R/W|SEL0|Monitored clock selector| - +-----+---+----+------------------------+ - |7 |R/W|EN0 |Enable monitor | - +-----+---+----+------------------------+ - |12:8 |R/W|SEL1|Monitored clock selector| - +-----+---+----+------------------------+ - |15 |R/W|EN1 |Enable monitor | - +-----+---+----+------------------------+ - |20:16|R/W|SEL2|Monitored clock selector| - +-----+---+----+------------------------+ - |23 |R/W|EN2 |Enable moniotor | - +-----+---+----+------------------------+ - |28:24|R/W|SEL3|Monitored clock selector| - +-----+---+----+------------------------+ - |31 |R/W|EN3 |Enable monitor | - +-----+---+----+------------------------+ - -.. _sfu_OUT_MUTE: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+-------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=======================================================+ + |4:0 |R/W|SEL0|0x0 |Monitored clock selector (see Clock select table below)| + +-----+---+----+-----+-------------------------------------------------------+ + |7 |R/W|EN0 |0x0 |Set to b1 to enable monitoring | + +-----+---+----+-----+-------------------------------------------------------+ + |12:8 |R/W|SEL1|0x0 |Monitored clock selector (see Clock select table below | + +-----+---+----+-----+-------------------------------------------------------+ + |15 |R/W|EN1 |0x0 |Set to b1 to enable monitoring | + +-----+---+----+-----+-------------------------------------------------------+ + |20:16|R/W|SEL2|0x0 |Monitored clock selector (see Clock select table below | + +-----+---+----+-----+-------------------------------------------------------+ + |23 |R/W|EN2 |0x0 |Set to b1 to enable monitoring | + +-----+---+----+-----+-------------------------------------------------------+ + |28:24|R/W|SEL3|0x0 |Monitored clock selector (see Clock select table below | + +-----+---+----+-----+-------------------------------------------------------+ + |31 |R/W|EN3 |0x0 |Set to b1 to enable monitoring | + +-----+---+----+-----+-------------------------------------------------------+ + +.. _sfu__OUT_MUTE: OUT_MUTE """""""" -Mutes corresponding output channel +Control of output channel mute .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------+--------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+======================================+ - |7:0 |R/W|MEM_OUT |Mutes corresponding MEM_OUT channel | - +-----+---+----------+--------------------------------------+ - |15:8 |R/W|STREAM_OUT|Mutes corresponding STREAM_OUT channel| - +-----+---+----------+--------------------------------------+ - |18:16|R/W|PDM_OUT |Mutes corresponding PDM_OUT channel | - +-----+---+----------+--------------------------------------+ + +-----+---+----------+-----+-------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+=====================================+ + |7:0 |R/W|MEM_OUT |0x0 |Mutes corresponding MemOut channel | + +-----+---+----------+-----+-------------------------------------+ + |15:8 |R/W|STREAM_OUT|0x0 |Mutes corresponding StreamOut channel| + +-----+---+----------+-----+-------------------------------------+ + |18:16|R/W|PDM_OUT |0x0 |Mutes corresponding PDMOut channel | + +-----+---+----------+-----+-------------------------------------+ -.. _sfu_AUDIO_CLK_CFG_0: +.. _sfu__AUDIO_CLK_CFG_0: AUDIO_CLK_CFG_0 """"""""""""""" -Control Audio clock generator 0 +Control audio clock generator 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===============================+ - |15:0 |R/W|DIV |DIVision factor for audio clock| - +-----+---+----+-------------------------------+ - |16 |R/W|EN |Enable audio clock | - +-----+---+----+-------------------------------+ + +-----+---+----+-----+---------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=========================================================+ + |15:0 |R/W|DIV |0x0 |Division factor for audio clock | + +-----+---+----+-----+---------------------------------------------------------+ + |16 |R/W|EN |0x0 |Enable: b0: audio clock disabled; b1: audio clock enabled| + +-----+---+----+-----+---------------------------------------------------------+ -.. _sfu_AUDIO_CLK_CFG_1: +.. _sfu__AUDIO_CLK_CFG_1: AUDIO_CLK_CFG_1 """"""""""""""" -Control Audio clock generator 1 +Control audio clock generator 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===============================+ - |15:0 |R/W|DIV |DIVision factor for audio clock| - +-----+---+----+-------------------------------+ - |16 |R/W|EN |Enable audio clock | - +-----+---+----+-------------------------------+ + +-----+---+----+-----+---------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=========================================================+ + |15:0 |R/W|DIV |0x0 |Division factor for audio clock | + +-----+---+----+-----+---------------------------------------------------------+ + |16 |R/W|EN |0x0 |Enable: b0: audio clock disabled; b1: audio clock enabled| + +-----+---+----+-----+---------------------------------------------------------+ -.. _sfu_AUDIO_CLK_CFG_2: +.. _sfu__AUDIO_CLK_CFG_2: AUDIO_CLK_CFG_2 """"""""""""""" -Control Audio clock generator 2 +Control audio clock generator 2 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===============================+ - |15:0 |R/W|DIV |DIVision factor for audio clock| - +-----+---+----+-------------------------------+ - |16 |R/W|EN |Enable audio clock | - +-----+---+----+-------------------------------+ + +-----+---+----+-----+---------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=========================================================+ + |15:0 |R/W|DIV |0x0 |Division factor for audio clock | + +-----+---+----+-----+---------------------------------------------------------+ + |16 |R/W|EN |0x0 |Enable: b0: audio clock disabled; b1: audio clock enabled| + +-----+---+----+-----+---------------------------------------------------------+ -.. _sfu_AUDIO_CLK_CFG_3: +.. _sfu__AUDIO_CLK_CFG_3: AUDIO_CLK_CFG_3 """"""""""""""" -Control Audio clock generator 3 +Control audio clock generator 3 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===============================+ - |15:0 |R/W|DIV |DIVision factor for audio clock| - +-----+---+----+-------------------------------+ - |16 |R/W|EN |Enable audio clock | - +-----+---+----+-------------------------------+ + +-----+---+----+-----+---------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=========================================================+ + |15:0 |R/W|DIV |0x0 |Division factor for audio clock | + +-----+---+----+-----+---------------------------------------------------------+ + |16 |R/W|EN |0x0 |Enable: b0: audio clock disabled; b1: audio clock enabled| + +-----+---+----+-----+---------------------------------------------------------+ -.. _sfu_ASRC_RATIO_0: +.. _sfu__ASRC_RATIO_0: ASRC_RATIO_0 """""""""""" @@ -390,14 +429,16 @@ ASRC_RATIO_0 ASRC0 conversion ratio .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+----------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+================+ - |25:0 |R/W|RATIO|Conversion RATIO| - +-----+---+-----+----------------+ + +-----+---+-----+-----+----------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+================+ + |25:0 |R/W|RATIO|0x0 |Conversion ratio| + +-----+---+-----+-----+----------------+ -.. _sfu_ASRC_RATIO_1: +.. _sfu__ASRC_RATIO_1: ASRC_RATIO_1 """""""""""" @@ -405,14 +446,16 @@ ASRC_RATIO_1 ASRC1 conversion ratio .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+----------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+================+ - |25:0 |R/W|RATIO|Conversion RATIO| - +-----+---+-----+----------------+ + +-----+---+-----+-----+----------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+================+ + |25:0 |R/W|RATIO|0x0 |Conversion ratio| + +-----+---+-----+-----+----------------+ -.. _sfu_ASRC_RATIO_2: +.. _sfu__ASRC_RATIO_2: ASRC_RATIO_2 """""""""""" @@ -420,129 +463,147 @@ ASRC_RATIO_2 ASRC2 conversion ratio .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+----------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+================+ - |25:0 |R/W|RATIO|Conversion RATIO| - +-----+---+-----+----------------+ + +-----+---+-----+-----+----------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+================+ + |25:0 |R/W|RATIO|0x0 |Conversion ratio| + +-----+---+-----+-----+----------------+ -.. _sfu_MEM_IN_0_CNT: +.. _sfu__MEM_IN_0_CNT: MEM_IN_0_CNT """""""""""" -Memory input counter +Memory input counter 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+----------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+====================================================+ - |20:0 |R |CNT |Reports how many samples have been pushed to the SFU| - +-----+---+----+----------------------------------------------------+ + +-----+---+----+-----+------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================================================+ + |20:0 |R |CNT |0x0 |Reports how many samples have been pushed to the SFU from this MemIn interface| + +-----+---+----+-----+------------------------------------------------------------------------------+ -.. _sfu_MEM_IN_1_CNT: +.. _sfu__MEM_IN_1_CNT: MEM_IN_1_CNT """""""""""" -Memory input counter +Memory input counter 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+----------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+====================================================+ - |20:0 |R |CNT |Reports how many samples have been pushed to the SFU| - +-----+---+----+----------------------------------------------------+ + +-----+---+----+-----+------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================================================+ + |20:0 |R |CNT |0x0 |Reports how many samples have been pushed to the SFU from this MemIn interface| + +-----+---+----+-----+------------------------------------------------------------------------------+ -.. _sfu_MEM_IN_2_CNT: +.. _sfu__MEM_IN_2_CNT: MEM_IN_2_CNT """""""""""" -Memory input counter +Memory input counter 2 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+----------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+====================================================+ - |20:0 |R |CNT |Reports how many samples have been pushed to the SFU| - +-----+---+----+----------------------------------------------------+ + +-----+---+----+-----+------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================================================+ + |20:0 |R |CNT |0x0 |Reports how many samples have been pushed to the SFU from this MemIn interface| + +-----+---+----+-----+------------------------------------------------------------------------------+ -.. _sfu_MEM_IN_3_CNT: +.. _sfu__MEM_IN_3_CNT: MEM_IN_3_CNT """""""""""" -Memory input counter +Memory input counter 3 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+----------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+====================================================+ - |20:0 |R |CNT |Reports how many samples have been pushed to the SFU| - +-----+---+----+----------------------------------------------------+ + +-----+---+----+-----+------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================================================+ + |20:0 |R |CNT |0x0 |Reports how many samples have been pushed to the SFU from this MemIn interface| + +-----+---+----+-----+------------------------------------------------------------------------------+ -.. _sfu_MEM_IN_4_CNT: +.. _sfu__MEM_IN_4_CNT: MEM_IN_4_CNT """""""""""" -Memory input counter +Memory input counter 4 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+----------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+====================================================+ - |20:0 |R |CNT |Reports how many samples have been pushed to the SFU| - +-----+---+----+----------------------------------------------------+ + +-----+---+----+-----+------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================================================+ + |20:0 |R |CNT |0x0 |Reports how many samples have been pushed to the SFU from this MemIn interface| + +-----+---+----+-----+------------------------------------------------------------------------------+ -.. _sfu_MEM_IN_5_CNT: +.. _sfu__MEM_IN_5_CNT: MEM_IN_5_CNT """""""""""" -Memory input counter +Memory input counter 5 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+----------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+====================================================+ - |20:0 |R |CNT |Reports how many samples have been pushed to the SFU| - +-----+---+----+----------------------------------------------------+ + +-----+---+----+-----+------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================================================+ + |20:0 |R |CNT |0x0 |Reports how many samples have been pushed to the SFU from this MemIn interface| + +-----+---+----+-----+------------------------------------------------------------------------------+ -.. _sfu_MEM_IN_6_CNT: +.. _sfu__MEM_IN_6_CNT: MEM_IN_6_CNT """""""""""" -Memory input counter +Memory input counter 6 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+----------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+====================================================+ - |20:0 |R |CNT |Reports how many samples have been pushed to the SFU| - +-----+---+----+----------------------------------------------------+ + +-----+---+----+-----+------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================================================+ + |20:0 |R |CNT |0x0 |Reports how many samples have been pushed to the SFU from this MemIn interface| + +-----+---+----+-----+------------------------------------------------------------------------------+ -.. _sfu_MEM_IN_7_CNT: +.. _sfu__MEM_IN_7_CNT: MEM_IN_7_CNT """""""""""" -Memory input counter +Memory input counter 7 .. table:: - - +-----+---+----+----------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+====================================================+ - |20:0 |R |CNT |Reports how many samples have been pushed to the SFU| - +-----+---+----+----------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================================================+ + |20:0 |R |CNT |0x0 |Reports how many samples have been pushed to the SFU from this MemIn interface| + +-----+---+----+-----+------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/soc_eu.rst b/rtos/pulp/gap_archi/doc/ips/soc_eu.rst index 5043f8d95..dff5b16c8 100644 --- a/rtos/pulp/gap_archi/doc/ips/soc_eu.rst +++ b/rtos/pulp/gap_archi/doc/ips/soc_eu.rst @@ -8,677 +8,762 @@ Register map Overview """""""" -.. table:: - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +==========================================+======+=====+===============================================================================+ - |:ref:`SW_EVENT` | 0| |SoC software events trigger command register. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`FC_MASK_0` | 4| |FC event unit event dispatch mask configuration register for events 0 to 31. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`FC_MASK_1` | 8| |FC event unit event dispatch mask configuration register for events 32 to 63. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`FC_MASK_2` | 12| |FC event unit event dispatch mask configuration register for events 64 to 95. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`FC_MASK_3` | 16| |FC event unit event dispatch mask configuration register for events 96 to 127. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`FC_MASK_4` | 20| |FC event unit event dispatch mask configuration register for events 128 to 159.| - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`FC_MASK_5` | 24| |FC event unit event dispatch mask configuration register for events 160 to 191.| - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`FC_MASK_6` | 28| |FC event unit event dispatch mask configuration register for events 192 to 223.| - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`FC_MASK_7` | 32| |FC event unit event dispatch mask configuration register for events 224 to 255.| - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`CL_MASK_0` | 36| |Cluster event dispatch mask configuration register for events 0 to 31. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`CL_MASK_1` | 40| |Cluster event dispatch mask configuration register for events 32 to 63. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`CL_MASK_2` | 44| |Cluster event dispatch mask configuration register for events 64 to 95. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`CL_MASK_3` | 48| |Cluster event dispatch mask configuration register for events 96 to 127. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`CL_MASK_4` | 52| |Cluster event dispatch mask configuration register for events 128 to 159. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`CL_MASK_5` | 56| |Cluster event dispatch mask configuration register for events 160 to 191. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`CL_MASK_6` | 60| |Cluster event dispatch mask configuration register for events 192 to 223. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`CL_MASK_7` | 64| |Cluster event dispatch mask configuration register for events 224 to 255. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`PR_MASK_0` | 68| |uDMA event dispatch mask configuration registerfor events 0 to 31. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`PR_MASK_1` | 72| |uDMA event dispatch mask configuration registerfor events 32 to 63. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`PR_MASK_2` | 76| |uDMA event dispatch mask configuration registerfor events 64 to 95. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`PR_MASK_3` | 80| |uDMA event dispatch mask configuration registerfor events 96 to 127. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`PR_MASK_4` | 84| |uDMA event dispatch mask configuration registerfor events 128 to 159. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`PR_MASK_5` | 88| |uDMA event dispatch mask configuration registerfor events 160 to 191. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`PR_MASK_6` | 92| |uDMA event dispatch mask configuration registerfor events 192 to 223. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`PR_MASK_7` | 96| |uDMA event dispatch mask configuration registerfor events 224 to 255. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`ERR_0` | 100| |Event queue overflow status register for events 0 to 31. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`ERR_1` | 104| |Event queue overflow status register for events 32 to 63. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`ERR_2` | 108| |Event queue overflow status register for events 64 to 95. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`ERR_3` | 112| |Event queue overflow status register for events 96 to 127. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`ERR_4` | 116| |Event queue overflow status register for events 128 to 159. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`ERR_5` | 120| |Event queue overflow status register for events 160 to 191. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`ERR_6` | 124| |Event queue overflow status register for events 192 to 223. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`ERR_7` | 128| |Event queue overflow status register for events 224 to 255. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`TIMER1_SEL_HI`| 132| |FC High Timer1 source event configuration register. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`TIMER1_SEL_LO`| 136| |FC Low Timer1 source event configuration register. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`TIMER2_SEL_HI`| 140| |FC High Timer2 source event configuration register. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`TIMER2_SEL_LO`| 144| |FC Low Timer2 source event configuration register. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`FC_MASK_SET` | 148| |Set the the FC mask of the specified event to 1. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - |:ref:`FC_MASK_CLR` | 152| |Set the the FC mask of the specified event to 0. | - +------------------------------------------+------+-----+-------------------------------------------------------------------------------+ - -.. _soc_eu_SW_EVENT: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +===========================================+======+=====+==============================================================================+ + |:ref:`SW_EVENT` | 0| 32|SoC software events trigger command register | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`FC_MASK_0` | 4| 32|FC event unit event dispatch mask configuration register for events 0 to 31 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`FC_MASK_1` | 8| 32|FC event unit event dispatch mask configuration register for events 32 to 63 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`FC_MASK_2` | 12| 32|FC event unit event dispatch mask configuration register for events 64 to 95 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`FC_MASK_3` | 16| 32|FC event unit event dispatch mask configuration register for events 96 to 127 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`FC_MASK_4` | 20| 32|FC event unit event dispatch mask configuration register for events 128 to 159| + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`FC_MASK_5` | 24| 32|FC event unit event dispatch mask configuration register for events 160 to 191| + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`FC_MASK_6` | 28| 32|FC event unit event dispatch mask configuration register for events 192 to 223| + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`FC_MASK_7` | 32| 32|FC event unit event dispatch mask configuration register for events 224 to 255| + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`CL_MASK_0` | 36| 32|Cluster event dispatch mask configuration register for events 0 to 31 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`CL_MASK_1` | 40| 32|Cluster event dispatch mask configuration register for events 32 to 63 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`CL_MASK_2` | 44| 32|Cluster event dispatch mask configuration register for events 64 to 95 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`CL_MASK_3` | 48| 32|Cluster event dispatch mask configuration register for events 96 to 127 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`CL_MASK_4` | 52| 32|Cluster event dispatch mask configuration register for events 128 to 159 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`CL_MASK_5` | 56| 32|Cluster event dispatch mask configuration register for events 160 to 191 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`CL_MASK_6` | 60| 32|Cluster event dispatch mask configuration register for events 192 to 223 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`CL_MASK_7` | 64| 32|Cluster event dispatch mask configuration register for events 224 to 255 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`PR_MASK_0` | 68| 32|uDMA event dispatch mask configuration register for events 0 to 31 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`PR_MASK_1` | 72| 32|uDMA event dispatch mask configuration register for events 32 to 63 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`PR_MASK_2` | 76| 32|uDMA event dispatch mask configuration register for events 64 to 95 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`PR_MASK_3` | 80| 32|uDMA event dispatch mask configuration register for events 96 to 127 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`PR_MASK_4` | 84| 32|uDMA event dispatch mask configuration register for events 128 to 159 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`PR_MASK_5` | 88| 32|uDMA event dispatch mask configuration register for events 160 to 191 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`PR_MASK_6` | 92| 32|uDMA event dispatch mask configuration register for events 192 to 223 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`PR_MASK_7` | 96| 32|uDMA event dispatch mask configuration register for events 224 to 255 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`ERR_0` | 100| 32|Event queue overflow status register for events 0 to 31 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`ERR_1` | 104| 32|Event queue overflow status register for events 32 to 63 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`ERR_2` | 108| 32|Event queue overflow status register for events 64 to 95 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`ERR_3` | 112| 32|Event queue overflow status register for events 96 to 127 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`ERR_4` | 116| 32|Event queue overflow status register for events 128 to 159 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`ERR_5` | 120| 32|Event queue overflow status register for events 160 to 191 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`ERR_6` | 124| 32|Event queue overflow status register for events 192 to 223 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`ERR_7` | 128| 32|Event queue overflow status register for events 224 to 255 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`TIMER1_SEL_HI`| 132| 32|FC High Timer1 source event configuration register | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`TIMER1_SEL_LO`| 136| 32|FC Low Timer1 source event configuration register | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`TIMER2_SEL_HI`| 140| 32|FC High Timer2 source event configuration register | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`TIMER2_SEL_LO`| 144| 32|FC Low Timer2 source event configuration register | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`FC_MASK_SET` | 148| 32|Set the the FC mask of the specified event to 1 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + |:ref:`FC_MASK_CLR` | 152| 32|Set the the FC mask of the specified event to 0 | + +-------------------------------------------+------+-----+------------------------------------------------------------------------------+ + +.. _soc_eu__SW_EVENT: SW_EVENT """""""" -SoC software events trigger command register. +SoC software events trigger command register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+----------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+==========================================================================================================+ - |7:0 |W |EVENT|Writing a one-hot value into EVENT bitfield triggers SoC software event i. 8 software events are provided.| - +-----+---+-----+----------------------------------------------------------------------------------------------------------+ + +-----+---+-----+-----+-----------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=======================================================================================================================+ + |7:0 |W |EVENT|0x0 |Writing a one-hot value (bit *i*=1) into EVENT bitfield triggers SoC software event *i*. 8 software events are provided| + +-----+---+-----+-----+-----------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_FC_MASK_0: +.. _soc_eu__FC_MASK_0: FC_MASK_0 """"""""" -FC event unit event dispatch mask configuration register for events 0 to 31. +FC event unit event dispatch mask configuration register for events 0 to 31 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to FC event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to FC event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to FC event unit.| - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+===========================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to FC event unit: setting bit *i* to 1 disables dispatching corresponding event to FC event unit; setting bit *i* to 0 enables dispatching corresponding event to FC event unit| + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_FC_MASK_1: +.. _soc_eu__FC_MASK_1: FC_MASK_1 """"""""" -FC event unit event dispatch mask configuration register for events 32 to 63. +FC event unit event dispatch mask configuration register for events 32 to 63 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to FC event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to FC event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to FC event unit.| - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+===========================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to FC event unit: setting bit *i* to 1 disables dispatching corresponding event to FC event unit; setting bit *i* to 0 enables dispatching corresponding event to FC event unit| + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_FC_MASK_2: +.. _soc_eu__FC_MASK_2: FC_MASK_2 """"""""" -FC event unit event dispatch mask configuration register for events 64 to 95. +FC event unit event dispatch mask configuration register for events 64 to 95 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to FC event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to FC event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to FC event unit.| - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+===========================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to FC event unit: setting bit *i* to 1 disables dispatching corresponding event to FC event unit; setting bit *i* to 0 enables dispatching corresponding event to FC event unit| + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_FC_MASK_3: +.. _soc_eu__FC_MASK_3: FC_MASK_3 """"""""" -FC event unit event dispatch mask configuration register for events 96 to 127. +FC event unit event dispatch mask configuration register for events 96 to 127 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to FC event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to FC event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to FC event unit.| - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+===========================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to FC event unit: setting bit *i* to 1 disables dispatching corresponding event to FC event unit; setting bit *i* to 0 enables dispatching corresponding event to FC event unit| + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_FC_MASK_4: +.. _soc_eu__FC_MASK_4: FC_MASK_4 """"""""" -FC event unit event dispatch mask configuration register for events 128 to 159. +FC event unit event dispatch mask configuration register for events 128 to 159 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to FC event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to FC event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to FC event unit.| - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+===========================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to FC event unit: setting bit *i* to 1 disables dispatching corresponding event to FC event unit; setting bit *i* to 0 enables dispatching corresponding event to FC event unit| + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_FC_MASK_5: +.. _soc_eu__FC_MASK_5: FC_MASK_5 """"""""" -FC event unit event dispatch mask configuration register for events 160 to 191. +FC event unit event dispatch mask configuration register for events 160 to 191 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to FC event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to FC event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to FC event unit.| - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+===========================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to FC event unit: setting bit *i* to 1 disables dispatching corresponding event to FC event unit; setting bit *i* to 0 enables dispatching corresponding event to FC event unit| + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_FC_MASK_6: +.. _soc_eu__FC_MASK_6: FC_MASK_6 """"""""" -FC event unit event dispatch mask configuration register for events 192 to 223. +FC event unit event dispatch mask configuration register for events 192 to 223 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to FC event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to FC event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to FC event unit.| - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+===========================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to FC event unit: setting bit *i* to 1 disables dispatching corresponding event to FC event unit; setting bit *i* to 0 enables dispatching corresponding event to FC event unit| + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_FC_MASK_7: +.. _soc_eu__FC_MASK_7: FC_MASK_7 """"""""" -FC event unit event dispatch mask configuration register for events 224 to 255. +FC event unit event dispatch mask configuration register for events 224 to 255 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to FC event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to FC event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to FC event unit.| - +-----+---+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+===========================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to FC event unit: setting bit *i* to 1 disables dispatching corresponding event to FC event unit; setting bit *i* to 0 enables dispatching corresponding event to FC event unit| + +-----+---+----+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_CL_MASK_0: +.. _soc_eu__CL_MASK_0: CL_MASK_0 """"""""" -Cluster event dispatch mask configuration register for events 0 to 31. +Cluster event dispatch mask configuration register for events 0 to 31 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=================================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to Cluster event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to Cluster event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to Cluster event unit.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+==========================================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to Cluster event unit: setting bit *i* to 1 disables dispatching corresponding event to Cluster event unit; setting bit *i* to 0 enables dispatching corresponding event to Cluster event unit| + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_CL_MASK_1: +.. _soc_eu__CL_MASK_1: CL_MASK_1 """"""""" -Cluster event dispatch mask configuration register for events 32 to 63. +Cluster event dispatch mask configuration register for events 32 to 63 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=================================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to Cluster event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to Cluster event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to Cluster event unit.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+==========================================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to Cluster event unit: setting bit *i* to 1 disables dispatching corresponding event to Cluster event unit; setting bit *i* to 0 enables dispatching corresponding event to Cluster event unit| + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_CL_MASK_2: +.. _soc_eu__CL_MASK_2: CL_MASK_2 """"""""" -Cluster event dispatch mask configuration register for events 64 to 95. +Cluster event dispatch mask configuration register for events 64 to 95 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=================================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to Cluster event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to Cluster event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to Cluster event unit.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+==========================================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to Cluster event unit: setting bit *i* to 1 disables dispatching corresponding event to Cluster event unit; setting bit *i* to 0 enables dispatching corresponding event to Cluster event unit| + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_CL_MASK_3: +.. _soc_eu__CL_MASK_3: CL_MASK_3 """"""""" -Cluster event dispatch mask configuration register for events 96 to 127. +Cluster event dispatch mask configuration register for events 96 to 127 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=================================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to Cluster event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to Cluster event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to Cluster event unit.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+==========================================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to Cluster event unit: setting bit *i* to 1 disables dispatching corresponding event to Cluster event unit; setting bit *i* to 0 enables dispatching corresponding event to Cluster event unit| + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_CL_MASK_4: +.. _soc_eu__CL_MASK_4: CL_MASK_4 """"""""" -Cluster event dispatch mask configuration register for events 128 to 159. +Cluster event dispatch mask configuration register for events 128 to 159 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=================================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to Cluster event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to Cluster event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to Cluster event unit.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+==========================================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to Cluster event unit: setting bit *i* to 1 disables dispatching corresponding event to Cluster event unit; setting bit *i* to 0 enables dispatching corresponding event to Cluster event unit| + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_CL_MASK_5: +.. _soc_eu__CL_MASK_5: CL_MASK_5 """"""""" -Cluster event dispatch mask configuration register for events 160 to 191. +Cluster event dispatch mask configuration register for events 160 to 191 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=================================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to Cluster event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to Cluster event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to Cluster event unit.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+==========================================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to Cluster event unit: setting bit *i* to 1 disables dispatching corresponding event to Cluster event unit; setting bit *i* to 0 enables dispatching corresponding event to Cluster event unit| + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_CL_MASK_6: +.. _soc_eu__CL_MASK_6: CL_MASK_6 """"""""" -Cluster event dispatch mask configuration register for events 192 to 223. +Cluster event dispatch mask configuration register for events 192 to 223 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=================================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to Cluster event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to Cluster event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to Cluster event unit.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+==========================================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to Cluster event unit: setting bit *i* to 1 disables dispatching corresponding event to Cluster event unit; setting bit *i* to 0 enables dispatching corresponding event to Cluster event unit| + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_CL_MASK_7: +.. _soc_eu__CL_MASK_7: CL_MASK_7 """"""""" -Cluster event dispatch mask configuration register for events 224 to 255. +Cluster event dispatch mask configuration register for events 224 to 255 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=================================================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to Cluster event unit. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to Cluster event unit. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to Cluster event unit.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+==========================================================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to Cluster event unit: setting bit *i* to 1 disables dispatching corresponding event to Cluster event unit; setting bit *i* to 0 enables dispatching corresponding event to Cluster event unit| + +-----+---+----+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_PR_MASK_0: +.. _soc_eu__PR_MASK_0: PR_MASK_0 """"""""" -uDMA event dispatch mask configuration registerfor events 0 to 31. +uDMA event dispatch mask configuration register for events 0 to 31 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to UDMA peripherals. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to uDMA. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to uDMA.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+=============================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to uDMA peripherals: setting bit *i* to 1 disables dispatching corresponding event to uDMA; setting bit *i* to 0 enables dispatching corresponding event to uDMA| + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_PR_MASK_1: +.. _soc_eu__PR_MASK_1: PR_MASK_1 """"""""" -uDMA event dispatch mask configuration registerfor events 32 to 63. +uDMA event dispatch mask configuration register for events 32 to 63 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to UDMA peripherals. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to uDMA. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to uDMA.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+=============================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to uDMA peripherals: setting bit *i* to 1 disables dispatching corresponding event to uDMA; setting bit *i* to 0 enables dispatching corresponding event to uDMA| + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_PR_MASK_2: +.. _soc_eu__PR_MASK_2: PR_MASK_2 """"""""" -uDMA event dispatch mask configuration registerfor events 64 to 95. +uDMA event dispatch mask configuration register for events 64 to 95 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to UDMA peripherals. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to uDMA. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to uDMA.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+=============================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to uDMA peripherals: setting bit *i* to 1 disables dispatching corresponding event to uDMA; setting bit *i* to 0 enables dispatching corresponding event to uDMA| + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_PR_MASK_3: +.. _soc_eu__PR_MASK_3: PR_MASK_3 """"""""" -uDMA event dispatch mask configuration registerfor events 96 to 127. +uDMA event dispatch mask configuration register for events 96 to 127 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to UDMA peripherals. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to uDMA. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to uDMA.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+=============================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to uDMA peripherals: setting bit *i* to 1 disables dispatching corresponding event to uDMA; setting bit *i* to 0 enables dispatching corresponding event to uDMA| + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_PR_MASK_4: +.. _soc_eu__PR_MASK_4: PR_MASK_4 """"""""" -uDMA event dispatch mask configuration registerfor events 128 to 159. +uDMA event dispatch mask configuration register for events 128 to 159 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to UDMA peripherals. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to uDMA. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to uDMA.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+=============================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to uDMA peripherals: setting bit *i* to 1 disables dispatching corresponding event to uDMA; setting bit *i* to 0 enables dispatching corresponding event to uDMA| + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_PR_MASK_5: +.. _soc_eu__PR_MASK_5: PR_MASK_5 """"""""" -uDMA event dispatch mask configuration registerfor events 160 to 191. +uDMA event dispatch mask configuration register for events 160 to 191 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to UDMA peripherals. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to uDMA. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to uDMA.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+=============================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to uDMA peripherals: setting bit *i* to 1 disables dispatching corresponding event to uDMA; setting bit *i* to 0 enables dispatching corresponding event to uDMA| + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_PR_MASK_6: +.. _soc_eu__PR_MASK_6: PR_MASK_6 """"""""" -uDMA event dispatch mask configuration registerfor events 192 to 223. +uDMA event dispatch mask configuration register for events 192 to 223 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to UDMA peripherals. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to uDMA. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to uDMA.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+=============================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to uDMA peripherals: setting bit *i* to 1 disables dispatching corresponding event to uDMA; setting bit *i* to 0 enables dispatching corresponding event to uDMA| + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_PR_MASK_7: +.. _soc_eu__PR_MASK_7: PR_MASK_7 """"""""" -uDMA event dispatch mask configuration registerfor events 224 to 255. +uDMA event dispatch mask configuration register for events 224 to 255 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===================================================================================================================================================================================================+ - |31:0 |R/W|MASK|Event mask to enable/disable event dispatch to UDMA peripherals. - Setting bit[i] to 1'b1 disable dispatching event[32+i] to uDMA. - Setting bit[i] to 1'b0 enable dispatching event[32+i] to uDMA.| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name| Reset | Description | + +=====+===+====+==========+=============================================================================================================================================================================================================+ + |31:0 |R/W|MASK|0xFFFFFFFF|Event mask to enable/disable event dispatch to uDMA peripherals: setting bit *i* to 1 disables dispatching corresponding event to uDMA; setting bit *i* to 0 enables dispatching corresponding event to uDMA| + +-----+---+----+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_ERR_0: +.. _soc_eu__ERR_0: ERR_0 """"" -Event queue overflow status register for events 0 to 31. +Event queue overflow status register for events 0 to 31 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+============================================================================================================================================+ - |31:0 |R/W|MASK|Report MSB queue overflows. Cleared after read. Reading a 1'b1 at ERR_MSB[i] means that an overflow occurred for SoC event[32+i] FIFO queue.| - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==============================================================================================================================================================+ + |31:0 |R/W|ERR_VAL|0x0 |Report event queues overflows: reading 1 on bit *i* means that an overflow occurred on the queue for corresponding SoC event. This field is cleared after read| + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_ERR_1: +.. _soc_eu__ERR_1: ERR_1 """"" -Event queue overflow status register for events 32 to 63. +Event queue overflow status register for events 32 to 63 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+============================================================================================================================================+ - |31:0 |R/W|MASK|Report MSB queue overflows. Cleared after read. Reading a 1'b1 at ERR_MSB[i] means that an overflow occurred for SoC event[32+i] FIFO queue.| - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==============================================================================================================================================================+ + |31:0 |R/W|ERR_VAL|0x0 |Report event queues overflows: reading 1 on bit *i* means that an overflow occurred on the queue for corresponding SoC event. This field is cleared after read| + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_ERR_2: +.. _soc_eu__ERR_2: ERR_2 """"" -Event queue overflow status register for events 64 to 95. +Event queue overflow status register for events 64 to 95 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+============================================================================================================================================+ - |31:0 |R/W|MASK|Report MSB queue overflows. Cleared after read. Reading a 1'b1 at ERR_MSB[i] means that an overflow occurred for SoC event[32+i] FIFO queue.| - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==============================================================================================================================================================+ + |31:0 |R/W|ERR_VAL|0x0 |Report event queues overflows: reading 1 on bit *i* means that an overflow occurred on the queue for corresponding SoC event. This field is cleared after read| + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_ERR_3: +.. _soc_eu__ERR_3: ERR_3 """"" -Event queue overflow status register for events 96 to 127. +Event queue overflow status register for events 96 to 127 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+============================================================================================================================================+ - |31:0 |R/W|MASK|Report MSB queue overflows. Cleared after read. Reading a 1'b1 at ERR_MSB[i] means that an overflow occurred for SoC event[32+i] FIFO queue.| - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==============================================================================================================================================================+ + |31:0 |R/W|ERR_VAL|0x0 |Report event queues overflows: reading 1 on bit *i* means that an overflow occurred on the queue for corresponding SoC event. This field is cleared after read| + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_ERR_4: +.. _soc_eu__ERR_4: ERR_4 """"" -Event queue overflow status register for events 128 to 159. +Event queue overflow status register for events 128 to 159 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+============================================================================================================================================+ - |31:0 |R/W|MASK|Report MSB queue overflows. Cleared after read. Reading a 1'b1 at ERR_MSB[i] means that an overflow occurred for SoC event[32+i] FIFO queue.| - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==============================================================================================================================================================+ + |31:0 |R/W|ERR_VAL|0x0 |Report event queues overflows: reading 1 on bit *i* means that an overflow occurred on the queue for corresponding SoC event. This field is cleared after read| + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_ERR_5: +.. _soc_eu__ERR_5: ERR_5 """"" -Event queue overflow status register for events 160 to 191. +Event queue overflow status register for events 160 to 191 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+============================================================================================================================================+ - |31:0 |R/W|MASK|Report MSB queue overflows. Cleared after read. Reading a 1'b1 at ERR_MSB[i] means that an overflow occurred for SoC event[32+i] FIFO queue.| - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==============================================================================================================================================================+ + |31:0 |R/W|ERR_VAL|0x0 |Report event queues overflows: reading 1 on bit *i* means that an overflow occurred on the queue for corresponding SoC event. This field is cleared after read| + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_ERR_6: +.. _soc_eu__ERR_6: ERR_6 """"" -Event queue overflow status register for events 192 to 223. +Event queue overflow status register for events 192 to 223 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+============================================================================================================================================+ - |31:0 |R/W|MASK|Report MSB queue overflows. Cleared after read. Reading a 1'b1 at ERR_MSB[i] means that an overflow occurred for SoC event[32+i] FIFO queue.| - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==============================================================================================================================================================+ + |31:0 |R/W|ERR_VAL|0x0 |Report event queues overflows: reading 1 on bit *i* means that an overflow occurred on the queue for corresponding SoC event. This field is cleared after read| + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_ERR_7: +.. _soc_eu__ERR_7: ERR_7 """"" -Event queue overflow status register for events 224 to 255. +Event queue overflow status register for events 224 to 255 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+============================================================================================================================================+ - |31:0 |R/W|MASK|Report MSB queue overflows. Cleared after read. Reading a 1'b1 at ERR_MSB[i] means that an overflow occurred for SoC event[32+i] FIFO queue.| - +-----+---+----+--------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==============================================================================================================================================================+ + |31:0 |R/W|ERR_VAL|0x0 |Report event queues overflows: reading 1 on bit *i* means that an overflow occurred on the queue for corresponding SoC event. This field is cleared after read| + +-----+---+-------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _soc_eu_TIMER1_SEL_HI: +.. _soc_eu__TIMER1_SEL_HI: TIMER1_SEL_HI """"""""""""" -FC High Timer1 source event configuration register. +FC High Timer1 source event configuration register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===================================================================================================+ - |7:0 |R/W|EVT |Configure which SoC event generator input event is propagated to FC Timer High trigger event input.| - +-----+---+----+---------------------------------------------------------------------------------------------------+ - |31 |R/W|ENA |Enable SoC event generator event propagation to FC Timer High trigger event input. | - +-----+---+----+---------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==================================================================================================+ + |7:0 |R/W|EVT |0x0 |Configure which SoC event generator input event is propagated to FC Timer High trigger event input| + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ + |31 |R/W|ENA |0x0 |Write 1 to enable SoC event generator event propagation to FC Timer High trigger event input | + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ -.. _soc_eu_TIMER1_SEL_LO: +.. _soc_eu__TIMER1_SEL_LO: TIMER1_SEL_LO """"""""""""" -FC Low Timer1 source event configuration register. +FC Low Timer1 source event configuration register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===================================================================================================+ - |7:0 |R/W|EVT |Configure which SoC event generator input event is propagated to FC Timer High trigger event input.| - +-----+---+----+---------------------------------------------------------------------------------------------------+ - |31 |R/W|ENA |Enable SoC event generator event propagation to FC Timer High trigger event input. | - +-----+---+----+---------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==================================================================================================+ + |7:0 |R/W|EVT |0x0 |Configure which SoC event generator input event is propagated to FC Timer High trigger event input| + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ + |31 |R/W|ENA |0x0 |Write 1 to enable SoC event generator event propagation to FC Timer High trigger event input | + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ -.. _soc_eu_TIMER2_SEL_HI: +.. _soc_eu__TIMER2_SEL_HI: TIMER2_SEL_HI """"""""""""" -FC High Timer2 source event configuration register. +FC High Timer2 source event configuration register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===================================================================================================+ - |7:0 |R/W|EVT |Configure which SoC event generator input event is propagated to FC Timer High trigger event input.| - +-----+---+----+---------------------------------------------------------------------------------------------------+ - |31 |R/W|ENA |Enable SoC event generator event propagation to FC Timer High trigger event input. | - +-----+---+----+---------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==================================================================================================+ + |7:0 |R/W|EVT |0x0 |Configure which SoC event generator input event is propagated to FC Timer High trigger event input| + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ + |31 |R/W|ENA |0x0 |Write 1 to enable SoC event generator event propagation to FC Timer High trigger event input | + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ -.. _soc_eu_TIMER2_SEL_LO: +.. _soc_eu__TIMER2_SEL_LO: TIMER2_SEL_LO """"""""""""" -FC Low Timer2 source event configuration register. +FC Low Timer2 source event configuration register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===================================================================================================+ - |7:0 |R/W|EVT |Configure which SoC event generator input event is propagated to FC Timer High trigger event input.| - +-----+---+----+---------------------------------------------------------------------------------------------------+ - |31 |R/W|ENA |Enable SoC event generator event propagation to FC Timer High trigger event input. | - +-----+---+----+---------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==================================================================================================+ + |7:0 |R/W|EVT |0x0 |Configure which SoC event generator input event is propagated to FC Timer High trigger event input| + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ + |31 |R/W|ENA |0x0 |Write 1 to enable SoC event generator event propagation to FC Timer High trigger event input | + +-----+---+----+-----+--------------------------------------------------------------------------------------------------+ -.. _soc_eu_FC_MASK_SET: +.. _soc_eu__FC_MASK_SET: FC_MASK_SET """"""""""" -Set the the FC mask of the specified event to 1. +Set the the FC mask of the specified event to 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-----------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================================+ + |7:0 |W |EVENT|0x0 |Write an event ID to set its FC mask to 1| + +-----+---+-----+-----+-----------------------------------------+ -.. _soc_eu_FC_MASK_CLR: +.. _soc_eu__FC_MASK_CLR: FC_MASK_CLR """"""""""" -Set the the FC mask of the specified event to 0. +Set the the FC mask of the specified event to 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-----------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================================+ + |7:0 |W |EVENT|0x0 |Write an event ID to set its FC mask to 0| + +-----+---+-----+-----+-----------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/timer_unit.rst b/rtos/pulp/gap_archi/doc/ips/timer_unit.rst index 5a9ce738c..b014e4557 100644 --- a/rtos/pulp/gap_archi/doc/ips/timer_unit.rst +++ b/rtos/pulp/gap_archi/doc/ips/timer_unit.rst @@ -8,212 +8,235 @@ Register map Overview """""""" -.. table:: - +------------------------------------+------+-----+-------------------------------------+ - | Name |Offset|Width| Description | - +====================================+======+=====+=====================================+ - |:ref:`CFG_LO` | 0| |Timer Low Configuration register. | - +------------------------------------+------+-----+-------------------------------------+ - |:ref:`CFG_HI` | 4| |Timer High Configuration register. | - +------------------------------------+------+-----+-------------------------------------+ - |:ref:`CNT_LO` | 8| |Timer Low counter value register. | - +------------------------------------+------+-----+-------------------------------------+ - |:ref:`CNT_HI` | 12| |Timer High counter value register. | - +------------------------------------+------+-----+-------------------------------------+ - |:ref:`CMP_LO` | 16| |Timer Low comparator value register. | - +------------------------------------+------+-----+-------------------------------------+ - |:ref:`CMP_HI` | 20| |Timer High comparator value register.| - +------------------------------------+------+-----+-------------------------------------+ - |:ref:`START_LO`| 24| |Start Timer Low counting register. | - +------------------------------------+------+-----+-------------------------------------+ - |:ref:`START_HI`| 28| |Start Timer High counting register. | - +------------------------------------+------+-----+-------------------------------------+ - |:ref:`RESET_LO`| 32| |Reset Timer Low counter register. | - +------------------------------------+------+-----+-------------------------------------+ - |:ref:`RESET_HI`| 36| |Reset Timer High counter register. | - +------------------------------------+------+-----+-------------------------------------+ - -.. _timer_unit_CFG_LO: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-------------------------------------+------+-----+------------------------------------+ + | Name |Offset|Width| Description | + +=====================================+======+=====+====================================+ + |:ref:`CFG_LO` | 0| |Timer Low Configuration register | + +-------------------------------------+------+-----+------------------------------------+ + |:ref:`CFG_HI` | 4| |Timer High Configuration register | + +-------------------------------------+------+-----+------------------------------------+ + |:ref:`CNT_LO` | 8| |Timer Low counter value register | + +-------------------------------------+------+-----+------------------------------------+ + |:ref:`CNT_HI` | 12| |Timer High counter value register | + +-------------------------------------+------+-----+------------------------------------+ + |:ref:`CMP_LO` | 16| |Timer Low comparator value register | + +-------------------------------------+------+-----+------------------------------------+ + |:ref:`CMP_HI` | 20| |Timer High comparator value register| + +-------------------------------------+------+-----+------------------------------------+ + |:ref:`START_LO`| 24| |Start Timer Low counting register | + +-------------------------------------+------+-----+------------------------------------+ + |:ref:`START_HI`| 28| |Start Timer High counting register | + +-------------------------------------+------+-----+------------------------------------+ + |:ref:`RESET_LO`| 32| |Reset Timer Low counter register | + +-------------------------------------+------+-----+------------------------------------+ + |:ref:`RESET_HI`| 36| |Reset Timer High counter register | + +-------------------------------------+------+-----+------------------------------------+ + +.. _timer_unit__CFG_LO: CFG_LO """""" -Timer Low Configuration register. +Timer Low Configuration register .. table:: - - +-----+---+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+============================================================================================================================================================================================================================================+ - | 0|R/W|ENABLE|Timer low enable configuration bitfield: - 1'b0: disabled - 1'b1: enabled | - +-----+---+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|RESET |Timer low counter reset command bitfield. Cleared after Timer Low reset execution. | - +-----+---+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 2|R/W|IRQEN |Timer low compare match interrupt enable configuration bitfield: - 1'b0: disabled - 1'b1: enabled | - +-----+---+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 3|R/W|IEM |Timer low input event mask configuration bitfield: - 1'b0: disabled - 1'b1: enabled | - +-----+---+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 4|R/W|MODE |Timer low continuous mode configuration bitfield: - 1'b0: Continue mode - continue incrementing Timer low counter when compare match with CMP_LO occurs. - 1'b1: Cycle mode - reset Timer low counter when compare match with CMP_LO occurs.| - +-----+---+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 5|R/W|ONE_S |Timer low one shot configuration bitfield: - 1'b0: let Timer low enabled counting when compare match with CMP_LO occurs. - 1'b1: disable Timer low when compare match with CMP_LO occurs. | - +-----+---+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 6|R/W|PEN |Timer low prescaler enable configuration bitfield:- 1'b0: disabled - 1'b1: enabled | - +-----+---+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 7|R/W|CLKCFG|Timer low clock source configuration bitfield: - 1'b0: FLL or FLL+Prescaler - 1'b1: Reference clock at 32kHz | - +-----+---+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15:8 |R/W|PVAL |Timer low prescaler value bitfield. Ftimer = Fclk / (1 + PRESC_VAL) | - +-----+---+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 31|R/W|CASC |Timer low + Timer high 64bit cascaded mode configuration bitfield. | - +-----+---+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _timer_unit_CFG_HI: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=========================================================================================================================================================================+ + | 0|R/W|ENABLE|0x0 |Timer Low enable: b0: disabled; b1: enabled | + +-----+---+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|RESET |0x0 |Write b1 to reset Timer Low counter. This fiels is cleared after reset execution | + +-----+---+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 2|R/W|IRQEN |0x0 |Timer Low compare interrupt enable: b0: disabled; b1: enabled | + +-----+---+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 3|R/W|IEM |0x0 |Timer Low input event mask: b0: disabled; b1: enabled | + +-----+---+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 4|R/W|MODE |0x0 |Timer Low continuous mode configuration: b0: Timer Low counter continues incrementing when value matches CMP_LO; b1: Timer low counter is reset when value matches CMP_LO| + +-----+---+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 5|R/W|ONE_S |0x0 |Timer Low one shot configuration: b0: Timer Low remains enabled when value matches CMP_LO; b1: disable Timer Low when value matches CMP_LO | + +-----+---+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 6|R/W|PEN |0x0 |Timer Low prescaler enable: b0: disabled; b1: enabled | + +-----+---+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 7|R/W|CCFG |0x0 |Timer Low clock source configuration: b0: FLL or FLL+Prescaler; b1: slow reference clock | + +-----+---+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R/W|PVAL |0x0 |Timer Low prescaler value. Ftimer = Fclk / (1 + PVAL) | + +-----+---+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 31|R/W|CASC |0x0 |Timer Low + Timer High 64bit cascaded mode: b0: disabled; b1: enabled | + +-----+---+------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _timer_unit__CFG_HI: CFG_HI """""" -Timer High Configuration register. +Timer High Configuration register .. table:: - - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+===============================================================================================================================================================================================================================================+ - | 0|R/W|ENABLE|Timer high enable configuration bitfield: - 1'b0: disabled - 1'b1: enabled | - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|W |RESET |Timer high counter reset command bitfield. Cleared after Timer high reset execution. | - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 2|R/W|IRQEN |Timer high compare match interrupt enable configuration bitfield: - 1'b0: disabled - 1'b1: enabled | - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 3|R/W|IEM |Timer high input event mask configuration bitfield: - 1'b0: disabled - 1'b1: enabled | - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 4|R/W|MODE |Timer high continuous mode configuration bitfield: - 1'b0: Continue mode - continue incrementing Timer high counter when compare match with CMP_LO occurs. - 1'b1: Cycle mode - reset Timer high counter when compare match with CMP_HI occurs.| - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 5|R/W|ONE_S |Timer high one shot configuration bitfield: - 1'b0: let Timer high enabled counting when compare match with CMP_HI occurs. - 1'b1: disable Timer high when compare match with CMP_HI occurs. | - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 6|R/W|PEN |Timer high prescaler enable configuration bitfield: - 1'b0: disabled - 1'b1: enabled | - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 7|R/W|CLKCFG|Timer high clock source configuration bitfield: - 1'b0: FLL or FLL+Prescaler - 1'b1: Reference clock at 32kHz | - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15:8 |R/W|PVAL |Timer high prescaler value bitfield. Ftimer = Fclk / (1 + PRESC_VAL) | - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _timer_unit_CNT_LO: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+==========================================================================================================================================================================+ + | 0|R/W|ENABLE|0x0 |Timer High enable: b0: disabled; b1: enabled | + +-----+---+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|W |RESET |0x0 |Write b1 to reset Timer High counter. This fiels is cleared after reset execution | + +-----+---+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 2|R/W|IRQEN |0x0 |Timer High compare interrupt enable: b0: disabled; b1: enabled | + +-----+---+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 3|R/W|IEM |0x0 |Timer High input event mask: b0: disabled; b1: enabled | + +-----+---+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 4|R/W|MODE |0x0 |Timer High continuous mode configuration: b0: Timer Low counter continues incrementing when value matches CMP_HI; b1: Timer low counter is reset when value matches CMP_HI| + +-----+---+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 5|R/W|ONE_S |0x0 |Timer High one shot configuration: b0: Timer Low remains enabled when value matches CMP_HI; b1: disable Timer Low when value matches CMP_HI | + +-----+---+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 6|R/W|PEN |0x0 |Timer High prescaler enable: b0: disabled; b1: enabled | + +-----+---+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 7|R/W|CLKCFG|0x0 |Timer High clock source configuration: b0: FLL or FLL+Prescaler; b1: slow reference clock | + +-----+---+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _timer_unit__CNT_LO: CNT_LO """""" -Timer Low counter value register. +Timer Low counter value register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+---------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+=================================+ - |31:0 |R/W|CNT_LO|Timer Low counter value bitfield.| - +-----+---+------+---------------------------------+ + +-----+---+------+-----+-----------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=======================+ + |31:0 |R/W|CNT_LO|0x0 |Timer Low counter value| + +-----+---+------+-----+-----------------------+ -.. _timer_unit_CNT_HI: +.. _timer_unit__CNT_HI: CNT_HI """""" -Timer High counter value register. +Timer High counter value register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+==================================+ - |31:0 |R/W|CNT_HI|Timer High counter value bitfield.| - +-----+---+------+----------------------------------+ + +-----+---+------+-----+------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+========================+ + |31:0 |R/W|CNT_HI|0x0 |Timer High counter value| + +-----+---+------+-----+------------------------+ -.. _timer_unit_CMP_LO: +.. _timer_unit__CMP_LO: CMP_LO """""" -Timer Low comparator value register. +Timer Low comparator value register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+====================================+ - |31:0 |R/W|CMP_LO|Timer Low comparator value bitfield.| - +-----+---+------+------------------------------------+ + +-----+---+------+-----+--------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+==========================+ + |31:0 |R/W|CMP_LO|0x0 |Timer Low comparator value| + +-----+---+------+-----+--------------------------+ -.. _timer_unit_CMP_HI: +.. _timer_unit__CMP_HI: CMP_HI """""" -Timer High comparator value register. +Timer High comparator value register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+=====================================+ - |31:0 |R/W|CMP_HI|Timer High comparator value bitfield.| - +-----+---+------+-------------------------------------+ + +-----+---+------+-----+---------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+===========================+ + |31:0 |R/W|CMP_HI|0x0 |Timer High comparator value| + +-----+---+------+-----+---------------------------+ -.. _timer_unit_START_LO: +.. _timer_unit__START_LO: START_LO """""""" -Start Timer Low counting register. +Start Timer Low counting register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+======================================================================+ - | 0|W |STRT_LO|Timer Low start command bitfield. When executed, CFG_LO.ENABLE is set.| - +-----+---+-------+----------------------------------------------------------------------+ + +-----+---+-------+-----+------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==================================================================+ + | 0|W |STRT_LO|0x0 |Timer Low start command. When executed, CFG_LO ENABLE field is set| + +-----+---+-------+-----+------------------------------------------------------------------+ -.. _timer_unit_START_HI: +.. _timer_unit__START_HI: START_HI """""""" -Start Timer High counting register. +Start Timer High counting register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+=======================================================================+ - | 0|W |STRT_HI|Timer High start command bitfield. When executed, CFG_HI.ENABLE is set.| - +-----+---+-------+-----------------------------------------------------------------------+ + +-----+---+-------+-----+-------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===================================================================+ + | 0|W |STRT_HI|0x0 |Timer High start command. When executed, CFG_HI ENABLE field is set| + +-----+---+-------+-----+-------------------------------------------------------------------+ -.. _timer_unit_RESET_LO: +.. _timer_unit__RESET_LO: RESET_LO """""""" -Reset Timer Low counter register. +Reset Timer Low counter register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-----------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+=============================================================================+ - | 0|W |RST_LO|Timer Low counter reset command bitfield. When executed, CFG_LO.RESET is set.| - +-----+---+------+-----------------------------------------------------------------------------+ + +-----+---+------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=========================================================================+ + | 0|W |RST_LO|0x0 |Timer Low counter reset command. When executed, CFG_LO RESET field is set| + +-----+---+------+-----+-------------------------------------------------------------------------+ -.. _timer_unit_RESET_HI: +.. _timer_unit__RESET_HI: RESET_HI """""""" -Reset Timer High counter register. +Reset Timer High counter register .. table:: - - +-----+---+------+------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+==============================================================================+ - | 0|W |RST_HI|Timer High counter reset command bitfield. When executed, CFG_HI.RESET is set.| - +-----+---+------+------------------------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------+-----+--------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+==========================================================================+ + | 0|W |RST_HI|0x0 |Timer High counter reset command. When executed, CFG_HI RESET field is set| + +-----+---+------+-----+--------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_aes.rst b/rtos/pulp/gap_archi/doc/ips/udma_aes.rst index f4ebce71c..9629d16f7 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_aes.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_aes.rst @@ -8,257 +8,300 @@ Register map Overview """""""" -.. table:: - +------------------------------+------+-----+---------------------------+ - | Name |Offset|Width| Description | - +==============================+======+=====+===========================+ - |:ref:`KEY0_0`| 0| 32|core 0 key 0 | - +------------------------------+------+-----+---------------------------+ - |:ref:`KEY0_1`| 4| 32|core 0 key 1 | - +------------------------------+------+-----+---------------------------+ - |:ref:`KEY0_2`| 8| 32|core 0 key 2 | - +------------------------------+------+-----+---------------------------+ - |:ref:`KEY0_3`| 12| 32|core 0 key 3 | - +------------------------------+------+-----+---------------------------+ - |:ref:`KEY0_4`| 16| 32|core 0 key 4 | - +------------------------------+------+-----+---------------------------+ - |:ref:`KEY0_5`| 20| 32|core 0 key 5 | - +------------------------------+------+-----+---------------------------+ - |:ref:`KEY0_6`| 24| 32|core 0 key 6 | - +------------------------------+------+-----+---------------------------+ - |:ref:`KEY0_7`| 28| 32|core 0 key 7 | - +------------------------------+------+-----+---------------------------+ - |:ref:`IV0_0` | 32| 32|core 0 IV 0 | - +------------------------------+------+-----+---------------------------+ - |:ref:`IV0_1` | 36| 32|core 0 IV 1 | - +------------------------------+------+-----+---------------------------+ - |:ref:`IV0_2` | 40| 32|core 0 IV 2 | - +------------------------------+------+-----+---------------------------+ - |:ref:`IV0_3` | 44| 32|core 0 IV 3 | - +------------------------------+------+-----+---------------------------+ - |:ref:`DEST` | 48| 32|RX TX destination channel | - +------------------------------+------+-----+---------------------------+ - |:ref:`SETUP` | 52| 32|core setup | - +------------------------------+------+-----+---------------------------+ - |:ref:`CFG` | 56| 32|AES data flow configuration| - +------------------------------+------+-----+---------------------------+ - -.. _udma_aes_KEY0_0: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-------------------------------+------+-----+---------------------------------------+ + | Name |Offset|Width| Description | + +===============================+======+=====+=======================================+ + |:ref:`KEY0_0`| 0| 32|Word 0 of encryption key | + +-------------------------------+------+-----+---------------------------------------+ + |:ref:`KEY0_1`| 4| 32|Word 1 of encryption key | + +-------------------------------+------+-----+---------------------------------------+ + |:ref:`KEY0_2`| 8| 32|Word 2 of encryption key | + +-------------------------------+------+-----+---------------------------------------+ + |:ref:`KEY0_3`| 12| 32|Word 3 of encryption key | + +-------------------------------+------+-----+---------------------------------------+ + |:ref:`KEY0_4`| 16| 32|Word 4 of encryption key | + +-------------------------------+------+-----+---------------------------------------+ + |:ref:`KEY0_5`| 20| 32|Word 5 of encryption key | + +-------------------------------+------+-----+---------------------------------------+ + |:ref:`KEY0_6`| 24| 32|Word 6 of encryption key | + +-------------------------------+------+-----+---------------------------------------+ + |:ref:`KEY0_7`| 28| 32|Word 7 of encryption key | + +-------------------------------+------+-----+---------------------------------------+ + |:ref:`IV0_0` | 32| 32|Word 0 of encrypted block initial value| + +-------------------------------+------+-----+---------------------------------------+ + |:ref:`IV0_1` | 36| 32|Word 1 of encrypted block initial value| + +-------------------------------+------+-----+---------------------------------------+ + |:ref:`IV0_2` | 40| 32|Word 2 of encrypted block initial value| + +-------------------------------+------+-----+---------------------------------------+ + |:ref:`IV0_3` | 44| 32|Word 3 of encrypted block initial value| + +-------------------------------+------+-----+---------------------------------------+ + |:ref:`DEST` | 48| 32|RX and TX destination channels | + +-------------------------------+------+-----+---------------------------------------+ + |:ref:`SETUP` | 52| 32|Core setup | + +-------------------------------+------+-----+---------------------------------------+ + |:ref:`CFG` | 56| 32|AES data flow configuration | + +-------------------------------+------+-----+---------------------------------------+ + +.. _udma_aes__KEY0_0: KEY0_0 """""" -core 0 key 0 +Word 0 of encryption key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_KEY0_1: +.. _udma_aes__KEY0_1: KEY0_1 """""" -core 0 key 1 +Word 1 of encryption key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_KEY0_2: +.. _udma_aes__KEY0_2: KEY0_2 """""" -core 0 key 2 +Word 2 of encryption key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_KEY0_3: +.. _udma_aes__KEY0_3: KEY0_3 """""" -core 0 key 3 +Word 3 of encryption key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_KEY0_4: +.. _udma_aes__KEY0_4: KEY0_4 """""" -core 0 key 4 +Word 4 of encryption key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_KEY0_5: +.. _udma_aes__KEY0_5: KEY0_5 """""" -core 0 key 5 +Word 5 of encryption key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_KEY0_6: +.. _udma_aes__KEY0_6: KEY0_6 """""" -core 0 key 6 +Word 6 of encryption key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_KEY0_7: +.. _udma_aes__KEY0_7: KEY0_7 """""" -core 0 key 7 +Word 7 of encryption key .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_IV0_0: +.. _udma_aes__IV0_0: IV0_0 """"" -core 0 IV 0 +Word 0 of encrypted block initial value .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+----------+--------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==============================================================+ + |31:0 |W |BLOCK_WORD|0x00000000|Value of the corresponding word of the initial encrypted block| + +-----+---+----------+----------+--------------------------------------------------------------+ -.. _udma_aes_IV0_1: +.. _udma_aes__IV0_1: IV0_1 """"" -core 0 IV 1 +Word 1 of encrypted block initial value .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+----------+--------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==============================================================+ + |31:0 |W |BLOCK_WORD|0x00000000|Value of the corresponding word of the initial encrypted block| + +-----+---+----------+----------+--------------------------------------------------------------+ -.. _udma_aes_IV0_2: +.. _udma_aes__IV0_2: IV0_2 """"" -core 0 IV 2 +Word 2 of encrypted block initial value .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+----------+--------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==============================================================+ + |31:0 |W |BLOCK_WORD|0x00000000|Value of the corresponding word of the initial encrypted block| + +-----+---+----------+----------+--------------------------------------------------------------+ -.. _udma_aes_IV0_3: +.. _udma_aes__IV0_3: IV0_3 """"" -core 0 IV 3 +Word 3 of encrypted block initial value .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+----------+--------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==============================================================+ + |31:0 |W |BLOCK_WORD|0x00000000|Value of the corresponding word of the initial encrypted block| + +-----+---+----------+----------+--------------------------------------------------------------+ -.. _udma_aes_DEST: +.. _udma_aes__DEST: DEST """" -RX TX destination channel +RX and TX destination channels .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+--------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+====================================================================+ - |7:0 |R/W|RX_DEST|Stream ID for the RX uDMA channel. Default is 0xFF(channel disabled)| - +-----+---+-------+--------------------------------------------------------------------+ - |15:8 |R/W|TX_DEST|Stream ID for the TX uDMA channel. Default is 0xFF(channel disabled)| - +-----+---+-------+--------------------------------------------------------------------+ + +-----+---+-------+-----+---------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=====================================================================+ + |7:0 |R/W|RX_DEST|0xFF |Stream ID for the RX uDMA channel. Default is 0xFF (channel disabled)| + +-----+---+-------+-----+---------------------------------------------------------------------+ + |15:8 |R/W|TX_DEST|0xFF |Stream ID for the TX uDMA channel. Default is 0xFF (channel disabled)| + +-----+---+-------+-----+---------------------------------------------------------------------+ -.. _udma_aes_SETUP: +.. _udma_aes__SETUP: SETUP """"" -core setup +Core setup .. table:: - - +-----+---+---------+------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================+ - | 0|R |KEY_INIT |Indicate the key configuration is finished| - +-----+---+---------+------------------------------------------+ - | 1|R/W|KEY_TYPE |KEY type, 0 for 128B, 1 for 256B | - +-----+---+---------+------------------------------------------+ - | 2|R/W|ENC_DEC |Operation type, 0 for DEC, 1 for ENC | - +-----+---+---------+------------------------------------------+ - | 3|R/W|ECB_CBC |Enc_type, 0 for ECB, 1 for CBC | - +-----+---+---------+------------------------------------------+ - | 4|W |BLOCK_RST|Block reset | - +-----+---+---------+------------------------------------------+ - | 5|R/W|QK_KEY_EN|Use quiddikey key generation | - +-----+---+---------+------------------------------------------+ - |7:6 |- |RESERVED | | - +-----+---+---------+------------------------------------------+ - | 8|W |FIFO_CLR |Clean the fifo | - +-----+---+---------+------------------------------------------+ - -.. _udma_aes_CFG: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+--------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==================================================+ + | 0|R |KEY_INIT |0x0 |Is set to 1 when the key configuration is finished| + +-----+---+---------+-----+--------------------------------------------------+ + | 1|R/W|KEY_TYPE |0x0 |Key type: b0: 128 bits; b1: 256 bits | + +-----+---+---------+-----+--------------------------------------------------+ + | 2|R/W|ENC_DEC |0x0 |Operation type: b0: decryption; b1: encryption | + +-----+---+---------+-----+--------------------------------------------------+ + | 3|R/W|ECB_CBC |0x0 |Encryption type: b0: ECB; b1: CBC | + +-----+---+---------+-----+--------------------------------------------------+ + | 4|W |BLOCK_RST|0x0 |Write b1 to reset AES core | + +-----+---+---------+-----+--------------------------------------------------+ + | 5|R/W|QK_KEY_EN|0x0 |Use quiddikey key generation | + +-----+---+---------+-----+--------------------------------------------------+ + | 8|W |FIFO_CLR |0x0 |Write b1 to clear data FIFO | + +-----+---+---------+-----+--------------------------------------------------+ + +.. _udma_aes__CFG: CFG """ @@ -266,9 +309,11 @@ CFG AES data flow configuration .. table:: - - +-----+---+----+---------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================+ - |1:0 |R/W|MODE|Transfer MODE 2'b00: memory 2 memory 2'b01: Stream 2 memory 2'b10: Memory 2 Stream 2'b11: Stream 2 Stream| - +-----+---+----+---------------------------------------------------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=========================================================================================================+ + |1:0 |R/W|MODE|0x0 |Transfer mode: b00: memory to memory; b01: stream to memory; b10: memory to stream; b11: stream to stream| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_aes_dual_core.rst b/rtos/pulp/gap_archi/doc/ips/udma_aes_dual_core.rst index 9d2499654..bd3e3a629 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_aes_dual_core.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_aes_dual_core.rst @@ -8,480 +8,559 @@ Register map Overview """""""" -.. table:: - +----------------------------------------+------+-----+---------------------------+ - | Name |Offset|Width| Description | - +========================================+======+=====+===========================+ - |:ref:`KEY0_0`| 0| 32|core 0 key 0 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY0_1`| 4| 32|core 0 key 1 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY0_2`| 8| 32|core 0 key 2 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY0_3`| 12| 32|core 0 key 3 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY0_4`| 16| 32|core 0 key 4 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY0_5`| 20| 32|core 0 key 5 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY0_6`| 24| 32|core 0 key 6 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY0_7`| 28| 32|core 0 key 7 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`IV0_0` | 32| 32|core 0 IV 0 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`IV0_1` | 36| 32|core 0 IV 1 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`IV0_2` | 40| 32|core 0 IV 2 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`IV0_3` | 44| 32|core 0 IV 3 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY1_0`| 48| 32|core 1 key 0 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY1_1`| 52| 32|core 1 key 1 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY1_2`| 56| 32|core 1 key 2 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY1_3`| 60| 32|core 1 key 3 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY1_4`| 64| 32|core 1 key 4 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY1_5`| 68| 32|core 1 key 5 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY1_6`| 72| 32|core 1 key 6 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`KEY1_7`| 76| 32|core 1 key 7 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`IV1_0` | 80| 32|core 1 IV 0 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`IV1_1` | 84| 32|core 1 IV 1 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`IV1_2` | 88| 32|core 1 IV 2 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`IV1_3` | 92| 32|core 1 IV 3 | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`DEST` | 96| 32|RX TX destination channel | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`SETUP0`| 100| 32|core 0 setup | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`SETUP1`| 104| 32|core 1 setup | - +----------------------------------------+------+-----+---------------------------+ - |:ref:`CFG` | 108| 32|AES data flow configuration| - +----------------------------------------+------+-----+---------------------------+ - -.. _udma_aes_dual_core_KEY0_0: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-----------------------------------------+------+-----+--------------------------------------------------+ + | Name |Offset|Width| Description | + +=========================================+======+=====+==================================================+ + |:ref:`KEY0_0`| 0| 32|Word 0 of encryption key for core 0 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY0_1`| 4| 32|Word 1 of encryption key for core 0 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY0_2`| 8| 32|Word 2 of encryption key for core 0 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY0_3`| 12| 32|Word 3 of encryption key for core 0 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY0_4`| 16| 32|Word 4 of encryption key for core 0 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY0_5`| 20| 32|Word 5 of encryption key for core 0 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY0_6`| 24| 32|Word 6 of encryption key for core 0 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY0_7`| 28| 32|Word 7 of encryption key for core 0 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`IV0_0` | 32| 32|Word 0 of encrypted block initial value for core 0| + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`IV0_1` | 36| 32|Word 1 of encrypted block initial value for core 0| + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`IV0_2` | 40| 32|Word 2 of encrypted block initial value for core 0| + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`IV0_3` | 44| 32|Word 3 of encrypted block initial value for core 0| + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY1_0`| 48| 32|Word 0 of encryption key for core 1 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY1_1`| 52| 32|Word 1 of encryption key for core 1 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY1_2`| 56| 32|Word 2 of encryption key for core 1 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY1_3`| 60| 32|Word 3 of encryption key for core 1 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY1_4`| 64| 32|Word 4 of encryption key for core 1 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY1_5`| 68| 32|Word 5 of encryption key for core 1 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY1_6`| 72| 32|Word 6 of encryption key for core 1 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`KEY1_7`| 76| 32|Word 7 of encryption key for core 1 | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`IV1_0` | 80| 32|Word 0 of encrypted block initial value for core 1| + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`IV1_1` | 84| 32|Word 1 of encrypted block initial value for core 1| + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`IV1_2` | 88| 32|Word 2 of encrypted block initial value for core 1| + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`IV1_3` | 92| 32|Word 3 of encrypted block initial value for core 1| + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`DEST` | 96| 32|RX and TX destination channels | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`SETUP0`| 100| 32|Core 0 setup | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`SETUP1`| 104| 32|Core 1 setup | + +-----------------------------------------+------+-----+--------------------------------------------------+ + |:ref:`CFG` | 108| 32|AES data flow configuration | + +-----------------------------------------+------+-----+--------------------------------------------------+ + +.. _udma_aes_dual_core__KEY0_0: KEY0_0 """""" -core 0 key 0 +Word 0 of encryption key for core 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_KEY0_1: +.. _udma_aes_dual_core__KEY0_1: KEY0_1 """""" -core 0 key 1 +Word 1 of encryption key for core 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_KEY0_2: +.. _udma_aes_dual_core__KEY0_2: KEY0_2 """""" -core 0 key 2 +Word 2 of encryption key for core 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_KEY0_3: +.. _udma_aes_dual_core__KEY0_3: KEY0_3 """""" -core 0 key 3 +Word 3 of encryption key for core 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_KEY0_4: +.. _udma_aes_dual_core__KEY0_4: KEY0_4 """""" -core 0 key 4 +Word 4 of encryption key for core 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_KEY0_5: +.. _udma_aes_dual_core__KEY0_5: KEY0_5 """""" -core 0 key 5 +Word 5 of encryption key for core 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_KEY0_6: +.. _udma_aes_dual_core__KEY0_6: KEY0_6 """""" -core 0 key 6 +Word 6 of encryption key for core 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_KEY0_7: +.. _udma_aes_dual_core__KEY0_7: KEY0_7 """""" -core 0 key 7 +Word 7 of encryption key for core 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_IV0_0: +.. _udma_aes_dual_core__IV0_0: IV0_0 """"" -core 0 IV 0 +Word 0 of encrypted block initial value for core 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+----------+--------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==============================================================+ + |31:0 |W |BLOCK_WORD|0x00000000|Value of the corresponding word of the initial encrypted block| + +-----+---+----------+----------+--------------------------------------------------------------+ -.. _udma_aes_dual_core_IV0_1: +.. _udma_aes_dual_core__IV0_1: IV0_1 """"" -core 0 IV 1 +Word 1 of encrypted block initial value for core 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+----------+--------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==============================================================+ + |31:0 |W |BLOCK_WORD|0x00000000|Value of the corresponding word of the initial encrypted block| + +-----+---+----------+----------+--------------------------------------------------------------+ -.. _udma_aes_dual_core_IV0_2: +.. _udma_aes_dual_core__IV0_2: IV0_2 """"" -core 0 IV 2 +Word 2 of encrypted block initial value for core 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+----------+--------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==============================================================+ + |31:0 |W |BLOCK_WORD|0x00000000|Value of the corresponding word of the initial encrypted block| + +-----+---+----------+----------+--------------------------------------------------------------+ -.. _udma_aes_dual_core_IV0_3: +.. _udma_aes_dual_core__IV0_3: IV0_3 """"" -core 0 IV 3 +Word 3 of encrypted block initial value for core 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+----------+--------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==============================================================+ + |31:0 |W |BLOCK_WORD|0x00000000|Value of the corresponding word of the initial encrypted block| + +-----+---+----------+----------+--------------------------------------------------------------+ -.. _udma_aes_dual_core_KEY1_0: +.. _udma_aes_dual_core__KEY1_0: KEY1_0 """""" -core 1 key 0 +Word 0 of encryption key for core 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_KEY1_1: +.. _udma_aes_dual_core__KEY1_1: KEY1_1 """""" -core 1 key 1 +Word 1 of encryption key for core 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_KEY1_2: +.. _udma_aes_dual_core__KEY1_2: KEY1_2 """""" -core 1 key 2 +Word 2 of encryption key for core 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_KEY1_3: +.. _udma_aes_dual_core__KEY1_3: KEY1_3 """""" -core 1 key 3 +Word 3 of encryption key for core 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_KEY1_4: +.. _udma_aes_dual_core__KEY1_4: KEY1_4 """""" -core 1 key 4 +Word 4 of encryption key for core 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_KEY1_5: +.. _udma_aes_dual_core__KEY1_5: KEY1_5 """""" -core 1 key 5 +Word 5 of encryption key for core 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_KEY1_6: +.. _udma_aes_dual_core__KEY1_6: KEY1_6 """""" -core 1 key 6 +Word 6 of encryption key for core 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_KEY1_7: +.. _udma_aes_dual_core__KEY1_7: KEY1_7 """""" -core 1 key 7 +Word 7 of encryption key for core 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+--------+----------+-------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+========+==========+=================================================+ + |31:0 |W |KEY_WORD|0x00000000|Value of the corresponding word of encryption key| + +-----+---+--------+----------+-------------------------------------------------+ -.. _udma_aes_dual_core_IV1_0: +.. _udma_aes_dual_core__IV1_0: IV1_0 """"" -core 1 IV 0 +Word 0 of encrypted block initial value for core 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+----------+--------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==============================================================+ + |31:0 |W |BLOCK_WORD|0x00000000|Value of the corresponding word of the initial encrypted block| + +-----+---+----------+----------+--------------------------------------------------------------+ -.. _udma_aes_dual_core_IV1_1: +.. _udma_aes_dual_core__IV1_1: IV1_1 """"" -core 1 IV 1 +Word 1 of encrypted block initial value for core 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+----------+--------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==============================================================+ + |31:0 |W |BLOCK_WORD|0x00000000|Value of the corresponding word of the initial encrypted block| + +-----+---+----------+----------+--------------------------------------------------------------+ -.. _udma_aes_dual_core_IV1_2: +.. _udma_aes_dual_core__IV1_2: IV1_2 """"" -core 1 IV 2 +Word 2 of encrypted block initial value for core 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+----------+--------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==============================================================+ + |31:0 |W |BLOCK_WORD|0x00000000|Value of the corresponding word of the initial encrypted block| + +-----+---+----------+----------+--------------------------------------------------------------+ -.. _udma_aes_dual_core_IV1_3: +.. _udma_aes_dual_core__IV1_3: IV1_3 """"" -core 1 IV 3 +Word 3 of encrypted block initial value for core 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----------+----------+--------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+==========+==========+==============================================================+ + |31:0 |W |BLOCK_WORD|0x00000000|Value of the corresponding word of the initial encrypted block| + +-----+---+----------+----------+--------------------------------------------------------------+ -.. _udma_aes_dual_core_DEST: +.. _udma_aes_dual_core__DEST: DEST """" -RX TX destination channel +RX and TX destination channels .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+--------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+====================================================================+ - |7:0 |R/W|RX_DEST|Stream ID for the RX uDMA channel. Default is 0xFF(channel disabled)| - +-----+---+-------+--------------------------------------------------------------------+ - |15:8 |R/W|TX_DEST|Stream ID for the TX uDMA channel. Default is 0xFF(channel disabled)| - +-----+---+-------+--------------------------------------------------------------------+ + +-----+---+-------+-----+---------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=====================================================================+ + |7:0 |R/W|RX_DEST|0xFF |Stream ID for the RX uDMA channel. Default is 0xFF (channel disabled)| + +-----+---+-------+-----+---------------------------------------------------------------------+ + |15:8 |R/W|TX_DEST|0xFF |Stream ID for the TX uDMA channel. Default is 0xFF (channel disabled)| + +-----+---+-------+-----+---------------------------------------------------------------------+ -.. _udma_aes_dual_core_SETUP0: +.. _udma_aes_dual_core__SETUP0: SETUP0 """""" -core 0 setup +Core 0 setup .. table:: - - +-----+---+---------+------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================+ - | 0|R |KEY_INIT |Indicate the key configuration is finished| - +-----+---+---------+------------------------------------------+ - | 1|R/W|KEY_TYPE |KEY type, 0 for 128B, 1 for 256B | - +-----+---+---------+------------------------------------------+ - | 2|R/W|ENC_DEC |Operation type, 0 for DEC, 1 for ENC | - +-----+---+---------+------------------------------------------+ - | 3|R/W|ECB_CBC |Enc_type, 0 for ECB, 1 for CBC | - +-----+---+---------+------------------------------------------+ - | 4|W |BLOCK_RST|Block reset | - +-----+---+---------+------------------------------------------+ - | 5|R/W|QK_KEY_EN|Use quiddikey key generation | - +-----+---+---------+------------------------------------------+ - |7:6 |- |RESERVED | | - +-----+---+---------+------------------------------------------+ - | 8|W |FIFO_CLR |Clean the fifo | - +-----+---+---------+------------------------------------------+ - -.. _udma_aes_dual_core_SETUP1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+--------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==================================================+ + | 0|R |KEY_INIT |0x0 |Is set to 1 when the key configuration is finished| + +-----+---+---------+-----+--------------------------------------------------+ + | 1|R/W|KEY_TYPE |0x0 |Key type: b0: 128 bits; b1: 256 bits | + +-----+---+---------+-----+--------------------------------------------------+ + | 2|R/W|ENC_DEC |0x0 |Operation type: b0: decryption; b1: encryption | + +-----+---+---------+-----+--------------------------------------------------+ + | 3|R/W|ECB_CBC |0x0 |Encryption type: b0: ECB; b1: CBC | + +-----+---+---------+-----+--------------------------------------------------+ + | 4|W |BLOCK_RST|0x0 |Write b1 to reset AES core 0 | + +-----+---+---------+-----+--------------------------------------------------+ + | 5|R/W|QK_KEY_EN|0x0 |Use quiddikey key generation | + +-----+---+---------+-----+--------------------------------------------------+ + | 8|W |FIFO_CLR |0x0 |Write b1 to clear data FIFO | + +-----+---+---------+-----+--------------------------------------------------+ + +.. _udma_aes_dual_core__SETUP1: SETUP1 """""" -core 1 setup +Core 1 setup .. table:: - - +-----+---+---------+------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================+ - | 0|R |KEY_INIT |Indicate the key configuration is finished| - +-----+---+---------+------------------------------------------+ - | 1|R/W|KEY_TYPE |KEY type, 0 for 128B, 1 for 256B | - +-----+---+---------+------------------------------------------+ - | 2|R/W|ENC_DEC |Operation type, 0 for DEC, 1 for ENC | - +-----+---+---------+------------------------------------------+ - | 3|R/W|ECB_CBC |Enc_type, 0 for ECB, 1 for CBC | - +-----+---+---------+------------------------------------------+ - | 4|W |BLOCK_RST|Block reset | - +-----+---+---------+------------------------------------------+ - | 5|R/W|QK_KEY_EN|Use quiddikey key generation | - +-----+---+---------+------------------------------------------+ - |7:6 |- |RESERVED | | - +-----+---+---------+------------------------------------------+ - | 8|W |FIFO_CLR |Clean the fifo | - +-----+---+---------+------------------------------------------+ - -.. _udma_aes_dual_core_CFG: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+--------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==================================================+ + | 0|R |KEY_INIT |0x0 |Is set to 1 when the key configuration is finished| + +-----+---+---------+-----+--------------------------------------------------+ + | 1|R/W|KEY_TYPE |0x0 |Key type: b0: 128 bits; b1: 256 bits | + +-----+---+---------+-----+--------------------------------------------------+ + | 2|R/W|ENC_DEC |0x0 |Operation type: b0: decryption; b1: encryption | + +-----+---+---------+-----+--------------------------------------------------+ + | 3|R/W|ECB_CBC |0x0 |Encryption type: b0: ECB; b1: CBC | + +-----+---+---------+-----+--------------------------------------------------+ + | 4|W |BLOCK_RST|0x0 |Write b1 to reset AES core 1 | + +-----+---+---------+-----+--------------------------------------------------+ + | 5|R/W|QK_KEY_EN|0x0 |Use quiddikey key generation | + +-----+---+---------+-----+--------------------------------------------------+ + | 8|W |FIFO_CLR |0x0 |Write b1 to clear data FIFO | + +-----+---+---------+-----+--------------------------------------------------+ + +.. _udma_aes_dual_core__CFG: CFG """ @@ -489,9 +568,11 @@ CFG AES data flow configuration .. table:: - - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=================================================================================================================================================================================================================================+ - |1:0 |R/W|MODE|Transfer MODE for AES core0 2'b00: memory 2 memory 2'b01: Stream 2 memory 2'b10: Memory 2 Stream 2'b11: Stream 2 Stream, for AES core1 inverse. When in HYPER mode, only can be 2'b10, for core0 MISO (enc), for core1 SIMO (dec)| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==========================================================================================================================================================================================================================================================================================================+ + |1:0 |R/W|MODE|0x0 |Transfer mode for core 0: b00: memory to memory; b01: stream to memory; b10: memory to stream; b11: stream to stream --- reverse configuration is used for core 1. When used with memory controller, must be set to b10 (core 0: memory to stream for encryption; core 1: stream to memory for decryption)| + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_core_2d.rst b/rtos/pulp/gap_archi/doc/ips/udma_core_2d.rst index 76a3bd93a..a7685de7c 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_core_2d.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_core_2d.rst @@ -8,43 +8,51 @@ Register map Overview """""""" -.. table:: - +--------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +==================================================+======+=====+=====================================================================================+ - |:ref:`CFG_SA_BUF0` | 0| 32|Start address of 1st buffer used in legacy mode and continuous mode(hw double buffer)| - +--------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - |:ref:`CFG_SA_BUF1` | 4| 32|Start address of 2nd buffer used in continuous mode | - +--------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - |:ref:`CFG_SIZE` | 8| 32|Sets the size of the buffer | - +--------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - |:ref:`CFG_STRIDE` | 12| 32|Distance in byte between the end of a row and the beginning of the following | - +--------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - |:ref:`CFG_ROW_LEN` | 16| 32|Length of the row in bytes | - +--------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - |:ref:`CFG_CURR_ADDR` | 20| 32|Current Address | - +--------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - |:ref:`CFG_BYTES_LEFT`| 24| 32|Number of bytes left | - +--------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - |:ref:`CFG_CTRL` | 28| 32|uDMA peripherals reset configuration. At RESET all periphs under reset. | - +--------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - -.. _udma_core_2d_CFG_SA_BUF0: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +---------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +===================================================+======+=====+======================================================================================+ + |:ref:`CFG_SA_BUF0` | 0| 32|Start address of 1st buffer used in legacy mode and continuous mode (HW double buffer)| + +---------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + |:ref:`CFG_SA_BUF1` | 4| 32|Start address of 2nd buffer used in continuous mode | + +---------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + |:ref:`CFG_SIZE` | 8| 32|Sets the size of the buffers | + +---------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + |:ref:`CFG_STRIDE` | 12| 32|Distance in byte between the end of a row and the beginning of the following | + +---------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + |:ref:`CFG_ROW_LEN` | 16| 32|Length of the row in bytes | + +---------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + |:ref:`CFG_CURR_ADDR` | 20| 32|Current address | + +---------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + |:ref:`CFG_BYTES_LEFT`| 24| 32|Number of bytes left | + +---------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + |:ref:`CFG_CTRL` | 28| 32|2D generator control | + +---------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + +.. _udma_core_2d__CFG_SA_BUF0: CFG_SA_BUF0 """"""""""" -Start address of 1st buffer used in legacy mode and continuous mode(hw double buffer) +Start address of 1st buffer used in legacy mode and continuous mode (HW double buffer) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+---------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=====================================================================+ + |31:0 |R/W|ADDRESS|0x0 |Start address of the 1st buffer (the 8 upper bits are forced to 0x1C)| + +-----+---+-------+-----+---------------------------------------------------------------------+ -.. _udma_core_2d_CFG_SA_BUF1: +.. _udma_core_2d__CFG_SA_BUF1: CFG_SA_BUF1 """"""""""" @@ -52,27 +60,33 @@ CFG_SA_BUF1 Start address of 2nd buffer used in continuous mode .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+----------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==============================================================================================+ + |31:0 |R/W|ADDRESS|0x0 |Start address of the 2nd buffer, when in continuous mode (the 8 upper bits are forced to 0x1C)| + +-----+---+-------+-----+----------------------------------------------------------------------------------------------+ -.. _udma_core_2d_CFG_SIZE: +.. _udma_core_2d__CFG_SIZE: CFG_SIZE """""""" -Sets the size of the buffer +Sets the size of the buffers .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+----------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+======================+ + |19:0 |R/W|SIZE|0x0 |Transfer size in bytes| + +-----+---+----+-----+----------------------+ -.. _udma_core_2d_CFG_STRIDE: +.. _udma_core_2d__CFG_STRIDE: CFG_STRIDE """""""""" @@ -80,13 +94,16 @@ CFG_STRIDE Distance in byte between the end of a row and the beginning of the following .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+----------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+======================+ + |19:0 |R/W|STRIDE|0x0 |Stride length in bytes| + +-----+---+------+-----+----------------------+ -.. _udma_core_2d_CFG_ROW_LEN: +.. _udma_core_2d__CFG_ROW_LEN: CFG_ROW_LEN """"""""""" @@ -94,27 +111,33 @@ CFG_ROW_LEN Length of the row in bytes .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+----------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+======================+ + |19:0 |R/W|ROW_LEN|0x0 |Stride length in bytes| + +-----+---+-------+-----+----------------------+ -.. _udma_core_2d_CFG_CURR_ADDR: +.. _udma_core_2d__CFG_CURR_ADDR: CFG_CURR_ADDR """"""""""""" -Current Address +Current address .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=========================================================================+ + |31:0 |R |ADDRESS|0x0 |Value of current address in the buffer (the 8 upper bits are always 0x1C)| + +-----+---+-------+-----+-------------------------------------------------------------------------+ -.. _udma_core_2d_CFG_BYTES_LEFT: +.. _udma_core_2d__CFG_BYTES_LEFT: CFG_BYTES_LEFT """""""""""""" @@ -122,27 +145,32 @@ CFG_BYTES_LEFT Number of bytes left .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+---------+-----+-------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=====================================+ + |20:0 |R |NUM_BYTES|0x0 |Number of remaining bytes to transfer| + +-----+---+---------+-----+-------------------------------------+ -.. _udma_core_2d_CFG_CTRL: +.. _udma_core_2d__CFG_CTRL: CFG_CTRL """""""" -uDMA peripherals reset configuration. At RESET all periphs under reset. +2D generator control .. table:: - - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================+ - | 0|R/W|CONT|Enable hardware double buffer support - 1’b1 : HW Doble Buffer -1'b0 Legacy mode | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|EN |Transfer enable - 1’b1 : Starts the transfer or enque a new transfer is a transfer is allready running. On read -1'b1 transfer on going -1'b0 no transfer| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 4|W |STOP|When set stops the current transfer and resets the address generator | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+========================================================================================================================================+ + | 0|R/W|CONT|0x0 |Enable hardware double buffer support (continuous mode): b0: legacy mode; b1: continuous mode | + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|EN |0x0 |Write b1 to start a transfer or enqueue a new transfer if one is already running. On read: b0: no ongoing transfer; b1: ongoing transfer| + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------+ + | 4|W |STOP|0x0 |Write b1 to stop the current transfer and reset the address generator | + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_core_fifo.rst b/rtos/pulp/gap_archi/doc/ips/udma_core_fifo.rst index 18e7a771a..e3590e1ae 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_core_fifo.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_core_fifo.rst @@ -8,23 +8,28 @@ Register map Overview """""""" -.. table:: - +--------------------------------------------------+------+-----+-----------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +==================================================+======+=====+=======================================================================+ - |:ref:`CFG_SA_BUFFER`| 0| 32|Start address for the FIFO | - +--------------------------------------------------+------+-----+-----------------------------------------------------------------------+ - |:ref:`CFG_SIZE` | 8| 32|Sets the size of the FIFO (minimum size is 16bytes 0x10) | - +--------------------------------------------------+------+-----+-----------------------------------------------------------------------+ - |:ref:`CFG_EVT` | 12| 32|Controls event generation | - +--------------------------------------------------+------+-----+-----------------------------------------------------------------------+ - |:ref:`CFG_FIFO_FILL`| 24| 32|FILL status of the FIFO | - +--------------------------------------------------+------+-----+-----------------------------------------------------------------------+ - |:ref:`CFG_CTRL` | 28| 32|uDMA peripherals reset configuration. At RESET all periphs under reset.| - +--------------------------------------------------+------+-----+-----------------------------------------------------------------------+ - -.. _udma_core_fifo_CFG_SA_BUFFER: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +---------------------------------------------------+------+-----+--------------------------+ + | Name |Offset|Width| Description | + +===================================================+======+=====+==========================+ + |:ref:`CFG_SA_BUFFER`| 0| 32|Start address for the FIFO| + +---------------------------------------------------+------+-----+--------------------------+ + |:ref:`CFG_SIZE` | 8| 32|Sets the size of the FIFO | + +---------------------------------------------------+------+-----+--------------------------+ + |:ref:`CFG_EVT` | 12| 32|Controls event generation | + +---------------------------------------------------+------+-----+--------------------------+ + |:ref:`CFG_FIFO_FILL`| 24| 32|Filling status of the FIFO| + +---------------------------------------------------+------+-----+--------------------------+ + |:ref:`CFG_CTRL` | 28| 32|FIFO control | + +---------------------------------------------------+------+-----+--------------------------+ + +.. _udma_core_fifo__CFG_SA_BUFFER: CFG_SA_BUFFER """"""""""""" @@ -32,27 +37,33 @@ CFG_SA_BUFFER Start address for the FIFO .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+----------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+================================================================+ + |31:0 |R/W|ADDRESS|0x0 |Start address for the FIFO (the 8 upper bits are forced to 0x1C)| + +-----+---+-------+-----+----------------------------------------------------------------+ -.. _udma_core_fifo_CFG_SIZE: +.. _udma_core_fifo__CFG_SIZE: CFG_SIZE """""""" -Sets the size of the FIFO (minimum size is 16bytes 0x10) +Sets the size of the FIFO .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+---------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================+ + |19:0 |R/W|SIZE|0x10 |FIFO size in bytes (minimum is 16, i.e. 0x10)| + +-----+---+----+-----+---------------------------------------------+ -.. _udma_core_fifo_CFG_EVT: +.. _udma_core_fifo__CFG_EVT: CFG_EVT """"""" @@ -60,44 +71,51 @@ CFG_EVT Controls event generation .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+--------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+============================================+ - |20:0 |R/W|NUM_BYTES|Number of bytes received that trigger event.| - +-----+---+---------+--------------------------------------------+ - |31 |R/W|EN |Enables event generation | - +-----+---+---------+--------------------------------------------+ + +-----+---+---------+-----+---------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+===================================================+ + |20:0 |R/W|NUM_BYTES|0x0 |Number of bytes to be received to trigger an event | + +-----+---+---------+-----+---------------------------------------------------+ + |31 |R/W|EN |0x0 |Enables event generation: b0: disabled; b1: enabled| + +-----+---+---------+-----+---------------------------------------------------+ -.. _udma_core_fifo_CFG_FIFO_FILL: +.. _udma_core_fifo__CFG_FIFO_FILL: CFG_FIFO_FILL """"""""""""" -FILL status of the FIFO +Filling status of the FIFO .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+---------+-----+---------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+===========================+ + |20:0 |R |NUM_BYTES|0x0 |Number of bytes in the FIFO| + +-----+---+---------+-----+---------------------------+ -.. _udma_core_fifo_CFG_CTRL: +.. _udma_core_fifo__CFG_CTRL: CFG_CTRL """""""" -uDMA peripherals reset configuration. At RESET all periphs under reset. +FIFO control .. table:: - - +-----+---+-----------+-----------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+===================================================================================+ - | 1|R/W|EN |FIFO enable - 1’b1 : Starts the FIFO on read -1'b1 FIFO enabled -1'b0 FIFO disabled| - +-----+---+-----------+-----------------------------------------------------------------------------------+ - | 4|W |STOP |FIFO disable - 1’b1 : Stops the FIFO | - +-----+---+-----------+-----------------------------------------------------------------------------------+ - | 8|R/W|TIMEOUT_MON|Selects the port to monitor - 1'b0 : Monitor RX port -1’b1 : Monitor TX port | - +-----+---+-----------+-----------------------------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------+-----+---------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+===========================================================================+ + | 1|R/W|EN |0x0 |Enable FIFO: b0: disabled; b1: enabled. If enabled, starts the FIFO on read| + +-----+---+-----------+-----+---------------------------------------------------------------------------+ + | 4|W |STOP |0x0 |Disable FIFO: write b1 to stop the FIFO | + +-----+---+-----------+-----+---------------------------------------------------------------------------+ + | 8|R/W|TIMEOUT_MON|0x0 |Select the port to monitor: b0: monitor RX port; b1: Monitor TX port | + +-----+---+-----------+-----+---------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_core_lin.rst b/rtos/pulp/gap_archi/doc/ips/udma_core_lin.rst index 748fe487e..2854a58b8 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_core_lin.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_core_lin.rst @@ -8,39 +8,47 @@ Register map Overview """""""" -.. table:: - +-----------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +===========================================================+======+=====+=====================================================================================+ - |:ref:`CFG_SA_BUF0` | 0| 32|Start address of 1st buffer used in legacy mode and continuous mode(hw double buffer)| - +-----------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - |:ref:`CFG_SA_BUF1` | 4| 32|Start address of 2nd buffer used in continuous mode | - +-----------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - |:ref:`CFG_SIZE` | 8| 32|Sets the size of the buffer | - +-----------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - |:ref:`CFG_CURR_ADDR` | 20| 32|Current Address | - +-----------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - |:ref:`CFG_BYTES_LEFT`| 24| 32|Number of bytes left | - +-----------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - |:ref:`CFG_CTRL` | 28| 32|uDMA peripherals reset configuration. At RESET all periphs under reset. | - +-----------------------------------------------------------+------+-----+-------------------------------------------------------------------------------------+ - -.. _udma_core_lin_addrgen_CFG_SA_BUF0: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +============================================================+======+=====+======================================================================================+ + |:ref:`CFG_SA_BUF0` | 0| 32|Start address of 1st buffer used in legacy mode and continuous mode (HW double buffer)| + +------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + |:ref:`CFG_SA_BUF1` | 4| 32|Start address of 2nd buffer used in continuous mode | + +------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + |:ref:`CFG_SIZE` | 8| 32|Sets the size of the buffers | + +------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + |:ref:`CFG_CURR_ADDR` | 20| 32|Current address | + +------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + |:ref:`CFG_BYTES_LEFT`| 24| 32|Number of bytes left | + +------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + |:ref:`CFG_CTRL` | 28| 32|Linear generator control | + +------------------------------------------------------------+------+-----+--------------------------------------------------------------------------------------+ + +.. _udma_core_lin_addrgen__CFG_SA_BUF0: CFG_SA_BUF0 """"""""""" -Start address of 1st buffer used in legacy mode and continuous mode(hw double buffer) +Start address of 1st buffer used in legacy mode and continuous mode (HW double buffer) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+---------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=====================================================================+ + |31:0 |R/W|ADDRESS|0x0 |Start address of the 1st buffer (the 8 upper bits are forced to 0x1C)| + +-----+---+-------+-----+---------------------------------------------------------------------+ -.. _udma_core_lin_addrgen_CFG_SA_BUF1: +.. _udma_core_lin_addrgen__CFG_SA_BUF1: CFG_SA_BUF1 """"""""""" @@ -48,41 +56,50 @@ CFG_SA_BUF1 Start address of 2nd buffer used in continuous mode .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+----------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==============================================================================================+ + |31:0 |R/W|ADDRESS|0x0 |Start address of the 2nd buffer, when in continuous mode (the 8 upper bits are forced to 0x1C)| + +-----+---+-------+-----+----------------------------------------------------------------------------------------------+ -.. _udma_core_lin_addrgen_CFG_SIZE: +.. _udma_core_lin_addrgen__CFG_SIZE: CFG_SIZE """""""" -Sets the size of the buffer +Sets the size of the buffers .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-----------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=========================================+ + |19:0 |R/W|SIZE|0x0 |Buffer size (i.e. transfer size) in bytes| + +-----+---+----+-----+-----------------------------------------+ -.. _udma_core_lin_addrgen_CFG_CURR_ADDR: +.. _udma_core_lin_addrgen__CFG_CURR_ADDR: CFG_CURR_ADDR """"""""""""" -Current Address +Current address .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=========================================================================+ + |31:0 |R |ADDRESS|0x0 |Value of current address in the buffer (the 8 upper bits are always 0x1C)| + +-----+---+-------+-----+-------------------------------------------------------------------------+ -.. _udma_core_lin_addrgen_CFG_BYTES_LEFT: +.. _udma_core_lin_addrgen__CFG_BYTES_LEFT: CFG_BYTES_LEFT """""""""""""" @@ -90,27 +107,32 @@ CFG_BYTES_LEFT Number of bytes left .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+---------+-----+-------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=====================================+ + |20:0 |R |NUM_BYTES|0x0 |Number of remaining bytes to transfer| + +-----+---+---------+-----+-------------------------------------+ -.. _udma_core_lin_addrgen_CFG_CTRL: +.. _udma_core_lin_addrgen__CFG_CTRL: CFG_CTRL """""""" -uDMA peripherals reset configuration. At RESET all periphs under reset. +Linear generator control .. table:: - - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================================================================================================================================+ - | 0|R/W|CONT|Enable hardware double buffer support - 1’b1 : HW Doble Buffer -1'b0 Legacy mode | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|EN |Transfer enable - 1’b1 : Starts the transfer or enque a new transfer is a transfer is allready running. On read -1'b1 transfer on going -1'b0 no transfer| - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 4|W |STOP|When set stops the current transfer and resets the address generator | - +-----+---+----+---------------------------------------------------------------------------------------------------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+========================================================================================================================================+ + | 0|R/W|CONT|0x0 |Enable hardware double buffer support (continuous mode): b0: legacy mode; b1: continuous mode | + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|EN |0x0 |Write b1 to start a transfer or enqueue a new transfer if one is already running. On read: b0: no ongoing transfer; b1: ongoing transfer| + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------+ + | 4|W |STOP|0x0 |Write b1 to stop the current transfer and reset the address generator | + +-----+---+----+-----+----------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_cpi.rst b/rtos/pulp/gap_archi/doc/ips/udma_cpi.rst index 66f966ea5..4a23b8193 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_cpi.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_cpi.rst @@ -8,29 +8,34 @@ Register map Overview """""""" -.. table:: - +------------------------------------------------------+------+-----+--------------------------------------------------------+ - | Name |Offset|Width| Description | - +======================================================+======+=====+========================================================+ - |:ref:`CAM_RX_DEST` | 0| 32|Stream ID for the uDMA channel | - +------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`CAM_RX_DATASIZE` | 4| 32|Transfer datasize 00: 8bit 01: 16bit 10: 24bit 11: 32bit| - +------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`CAM_CFG_GLOB` | 32| 32|Global configuration register | - +------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`CAM_CFG_LL` | 36| 32|Lower Left corner configuration register | - +------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`CAM_CFG_UR` | 40| 32|Upper Right corner configuration register | - +------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`CAM_CFG_SIZE` | 44| 32|Horizontal Resolution configuration register | - +------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`CAM_CFG_RGB` | 48| 32|RGB coefficients configuration register | - +------------------------------------------------------+------+-----+--------------------------------------------------------+ - |:ref:`CAM_VSYNC_POLARITY`| 52| 32|VSYNC Polarity register | - +------------------------------------------------------+------+-----+--------------------------------------------------------+ - -.. _udma_cpi_CAM_RX_DEST: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-------------------------------------------------------+------+-----+--------------------------------------------+ + | Name |Offset|Width| Description | + +=======================================================+======+=====+============================================+ + |:ref:`CAM_RX_DEST` | 0| 32|Stream ID for the uDMA channel | + +-------------------------------------------------------+------+-----+--------------------------------------------+ + |:ref:`CAM_RX_DATASIZE` | 4| 32|Data size | + +-------------------------------------------------------+------+-----+--------------------------------------------+ + |:ref:`CAM_CFG_GLOB` | 32| 32|Global configuration register | + +-------------------------------------------------------+------+-----+--------------------------------------------+ + |:ref:`CAM_CFG_LL` | 36| 32|Lower Left corner configuration register | + +-------------------------------------------------------+------+-----+--------------------------------------------+ + |:ref:`CAM_CFG_UR` | 40| 32|Upper Right corner configuration register | + +-------------------------------------------------------+------+-----+--------------------------------------------+ + |:ref:`CAM_CFG_SIZE` | 44| 32|Horizontal Resolution configuration register| + +-------------------------------------------------------+------+-----+--------------------------------------------+ + |:ref:`CAM_CFG_RGB` | 48| 32|RGB coefficients configuration register | + +-------------------------------------------------------+------+-----+--------------------------------------------+ + |:ref:`CAM_VSYNC_POLARITY`| 52| 32|VSYNC Polarity register | + +-------------------------------------------------------+------+-----+--------------------------------------------+ + +.. _udma_cpi__CAM_RX_DEST: CAM_RX_DEST """"""""""" @@ -38,29 +43,33 @@ CAM_RX_DEST Stream ID for the uDMA channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-----------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+=================================================================+ - |6:0 |R/W|RX_DEST|Stream ID for the uDMA channel. Default is 0x7F(channel disabled)| - +-----+---+-------+-----------------------------------------------------------------+ + +-----+---+-------+-----+-------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===================================================================+ + |6:0 |R/W|RX_DEST|0x7F |Stream ID for the uDMA channel. Default is 0x7F (channel disabled).| + +-----+---+-------+-----+-------------------------------------------------------------------+ -.. _udma_cpi_CAM_RX_DATASIZE: +.. _udma_cpi__CAM_RX_DATASIZE: CAM_RX_DATASIZE """"""""""""""" -Transfer datasize 00: 8bit 01: 16bit 10: 24bit 11: 32bit +Data size .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------+--------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+========================================================+ - |1:0 |R/W|RX_DATASIZE|Transfer datasize 00: 8bit 01: 16bit 10: 24bit 11: 32bit| - +-----+---+-----------+--------------------------------------------------------+ + +-----+---+-----------+-----+----------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+================================================================+ + |1:0 |R/W|RX_DATASIZE|0x0 |Transfer datasize: b00: 8bit; b01: 16bit; b10: 24bit; b11: 32bit| + +-----+---+-----------+-----+----------------------------------------------------------------+ -.. _udma_cpi_CAM_CFG_GLOB: +.. _udma_cpi__CAM_CFG_GLOB: CAM_CFG_GLOB """""""""""" @@ -68,22 +77,24 @@ CAM_CFG_GLOB Global configuration register .. table:: - - +-----+---+-------------+---------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=======================================================================================================================================+ - | 0|R/W|FRAMEDROP_EN |Frame dropping: - 1'b0: disable - 1'b1: enable | - +-----+---+-------------+---------------------------------------------------------------------------------------------------------------------------------------+ - |6:1 |R/W|FRAMEDROP_VAL|Sets how many frames should be dropped after each received. | - +-----+---+-------------+---------------------------------------------------------------------------------------------------------------------------------------+ - | 7|R/W|FRAMESLICE_EN|Input frame slicing: - 1'b0: disable - 1'b1: enable | - +-----+---+-------------+---------------------------------------------------------------------------------------------------------------------------------------+ - |10:8 |R/W|FORMAT |Input frame format: - 3'b000: RGB565 - 3'b001: RGB555 - 3'b010: RGB444 - 3'b011: RGB888 - 3'b100: BYPASS_LITEND - 3'b101: BYPASS_BIGEND| - +-----+---+-------------+---------------------------------------------------------------------------------------------------------------------------------------+ - | 31|R/W|EN |Enable data rx from camera interface. The enable/disable happens only at the start of a frame. - 1'b0: disable - 1'b1: enable | - +-----+---+-------------+---------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_cpi_CAM_CFG_LL: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+========================================================================================================================+ + | 0|R/W|FRAMEDROP_EN |0x0 |Frame dropping: b0: disabled; b1: enabled | + +-----+---+-------------+-----+------------------------------------------------------------------------------------------------------------------------+ + |6:1 |R/W|FRAMEDROP_VAL|0x0 |Set how many frames should be dropped after each received | + +-----+---+-------------+-----+------------------------------------------------------------------------------------------------------------------------+ + | 7|R/W|FRAMESLICE_EN|0x0 |Input frame slicing: b0: disabled; b1: enabled | + +-----+---+-------------+-----+------------------------------------------------------------------------------------------------------------------------+ + |10:8 |R/W|FORMAT |0x0 |Input frame format: b000: RGB565; b001: RGB555; b010: RGB444; b011: RGB888; b100: BYPASS_LITEND; b101: BYPASS_BIGEND | + +-----+---+-------------+-----+------------------------------------------------------------------------------------------------------------------------+ + | 31|R/W|EN |0x0 |Enable data rx from camera interface. The enable/disable happens only at the start of a frame. b0: disabled; b1: enabled| + +-----+---+-------------+-----+------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_cpi__CAM_CFG_LL: CAM_CFG_LL """""""""" @@ -91,16 +102,18 @@ CAM_CFG_LL Lower Left corner configuration register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------------+------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+==========================================+ - |15:0 |R/W|FRAMESLICE_LLX|X coordinate of lower left corner of slice| - +-----+---+--------------+------------------------------------------+ - |31:16|R/W|FRAMESLICE_LLY|Y coordinate of lower left corner of slice| - +-----+---+--------------+------------------------------------------+ + +-----+---+--------------+-----+------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+==========================================+ + |15:0 |R/W|FRAMESLICE_LLX|0x0 |X coordinate of lower left corner of slice| + +-----+---+--------------+-----+------------------------------------------+ + |31:16|R/W|FRAMESLICE_LLY|0x0 |Y coordinate of lower left corner of slice| + +-----+---+--------------+-----+------------------------------------------+ -.. _udma_cpi_CAM_CFG_UR: +.. _udma_cpi__CAM_CFG_UR: CAM_CFG_UR """""""""" @@ -108,16 +121,18 @@ CAM_CFG_UR Upper Right corner configuration register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------------+-------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===========================================+ - |15:0 |R/W|FRAMESLICE_URX|X coordinate of upper right corner of slice| - +-----+---+--------------+-------------------------------------------+ - |31:16|R/W|FRAMESLICE_URY|Y coordinate of upper right corner of slice| - +-----+---+--------------+-------------------------------------------+ + +-----+---+--------------+-----+-------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===========================================+ + |15:0 |R/W|FRAMESLICE_URX|0x0 |X coordinate of upper right corner of slice| + +-----+---+--------------+-----+-------------------------------------------+ + |31:16|R/W|FRAMESLICE_URY|0x0 |Y coordinate of upper right corner of slice| + +-----+---+--------------+-----+-------------------------------------------+ -.. _udma_cpi_CAM_CFG_SIZE: +.. _udma_cpi__CAM_CFG_SIZE: CAM_CFG_SIZE """""""""""" @@ -125,14 +140,16 @@ CAM_CFG_SIZE Horizontal Resolution configuration register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+----------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+==========================================================================================================+ - |15:0 |R/W|ROWLEN|Horizontal Resolution. It is used for slice mode. Value set into the bitfield must be equal to (rowlen-1).| - +-----+---+------+----------------------------------------------------------------------------------------------------------+ + +-----+---+------+-----+----------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+==========================================================================================================+ + |15:0 |R/W|ROWLEN|0x0 |Horizontal Resolution. It is used for slice mode. Value set into the bitfield must be equal to (rowlen-1).| + +-----+---+------+-----+----------------------------------------------------------------------------------------------------------+ -.. _udma_cpi_CAM_CFG_RGB: +.. _udma_cpi__CAM_CFG_RGB: CAM_CFG_RGB """"""""""" @@ -140,14 +157,16 @@ CAM_CFG_RGB RGB coefficients configuration register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+---------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+=======================================================================================+ - |2:0 |R/W|FORMAT|3'h0 - RGB, 3'h1 - RBG, 3'h2 - GRB, 3'h3 - GBR, 3'h4 - BRG, 3'h5 - BGR, 3'h6 3'h7 - RGB| - +-----+---+------+---------------------------------------------------------------------------------------+ + +-----+---+------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=================================================================================================+ + |2:0 |R/W|FORMAT|0x0 |Order of RGB coefficients: h0: RGB; h1: RBG; h2: GRB; h3: GBR; h4: BRG; h5: BGR; h6: RGB; h7: RGB| + +-----+---+------+-----+-------------------------------------------------------------------------------------------------+ -.. _udma_cpi_CAM_VSYNC_POLARITY: +.. _udma_cpi__CAM_VSYNC_POLARITY: CAM_VSYNC_POLARITY """""""""""""""""" @@ -155,11 +174,13 @@ CAM_VSYNC_POLARITY VSYNC Polarity register .. table:: - - +-----+---+--------------+------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+============================================================+ - | 0|R/W|VSYNC_POLARITY|Set vsync polarity of CPI. - 1'b0: Active 0 - 1'b1: Active 1| - +-----+---+--------------+------------------------------------------------------------+ - | 1|R/W|HSYNC_POLARITY|Set hsync polarity of CPI. - 1'b0: Active 1 - 1'b1: Active 0| - +-----+---+--------------+------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+-----+----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+==========================================================+ + | 0|R/W|VSYNC_POLARITY|0x0 |Set vsync polarity of CPI: b0: active low; b1: active high| + +-----+---+--------------+-----+----------------------------------------------------------+ + | 1|R/W|HSYNC_POLARITY|0x0 |Set hsync polarity of CPI: b0: active high; b1: active low| + +-----+---+--------------+-----+----------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_csi2.rst b/rtos/pulp/gap_archi/doc/ips/udma_csi2.rst index 78215826b..1cecc6d90 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_csi2.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_csi2.rst @@ -8,33 +8,38 @@ Register map for CSI2 UDMA interface Overview """""""" -.. table:: - +-------------------------------------------+------+-----+----------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +===========================================+======+=====+======================================================================+ - |:ref:`RX_CH0_DEST` | 0| 32|Stream ID for the uDMA channel 0 | - +-------------------------------------------+------+-----+----------------------------------------------------------------------+ - |:ref:`RX_CH1_DEST` | 4| 32|Stream ID for the uDMA channel 1 | - +-------------------------------------------+------+-----+----------------------------------------------------------------------+ - |:ref:`RX_ENABLE` | 32| 32|Enable receiving | - +-------------------------------------------+------+-----+----------------------------------------------------------------------+ - |:ref:`CLK_SETUP` | 36| 32|Configure clock divider | - +-------------------------------------------+------+-----+----------------------------------------------------------------------+ - |:ref:`SLICE_ENABLE`| 40| 32|Enable slice mode | - +-------------------------------------------+------+-----+----------------------------------------------------------------------+ - |:ref:`SLICE_ROWLEN`| 44| 32|Configure image row length when in slice mode | - +-------------------------------------------+------+-----+----------------------------------------------------------------------+ - |:ref:`SLICE0_ULXY` | 48| 32|Configure upper left pixel position when in slice mode for channel 0 | - +-------------------------------------------+------+-----+----------------------------------------------------------------------+ - |:ref:`SLICE0_BRXY` | 52| 32|Configure bottom right pixel position when in slice mode for channel 0| - +-------------------------------------------+------+-----+----------------------------------------------------------------------+ - |:ref:`SLICE1_ULXY` | 56| 32|Configure upper left pixel position when in slice mode for channel 1 | - +-------------------------------------------+------+-----+----------------------------------------------------------------------+ - |:ref:`SLICE1_BRXY` | 60| 32|Configure bottom right pixel position when in slice mode for channel 1| - +-------------------------------------------+------+-----+----------------------------------------------------------------------+ - -.. _udma_csi2_RX_CH0_DEST: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +--------------------------------------------+------+-----+----------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +============================================+======+=====+======================================================================+ + |:ref:`RX_CH0_DEST` | 0| 32|Stream ID for the uDMA channel 0 | + +--------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`RX_CH1_DEST` | 4| 32|Stream ID for the uDMA channel 1 | + +--------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`RX_ENABLE` | 32| 32|Enable receiving | + +--------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`CLK_SETUP` | 36| 32|Configure clock divider | + +--------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`SLICE_ENABLE`| 40| 32|Enable slice mode | + +--------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`SLICE_ROWLEN`| 44| 32|Configure image row length when in slice mode | + +--------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`SLICE0_ULXY` | 48| 32|Configure upper left pixel position when in slice mode for channel 0 | + +--------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`SLICE0_BRXY` | 52| 32|Configure bottom right pixel position when in slice mode for channel 0| + +--------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`SLICE1_ULXY` | 56| 32|Configure upper left pixel position when in slice mode for channel 1 | + +--------------------------------------------+------+-----+----------------------------------------------------------------------+ + |:ref:`SLICE1_BRXY` | 60| 32|Configure bottom right pixel position when in slice mode for channel 1| + +--------------------------------------------+------+-----+----------------------------------------------------------------------+ + +.. _udma_csi2__RX_CH0_DEST: RX_CH0_DEST """"""""""" @@ -42,14 +47,16 @@ RX_CH0_DEST Stream ID for the uDMA channel 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+========================================================================+ - |7:0 |R/W|DEST|Stream ID for the CMD uDMA channel 0. Default is 0xFF (channel disabled)| - +-----+---+----+------------------------------------------------------------------------+ + +-----+---+----+-----+------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+========================================================================+ + |7:0 |R/W|DEST|0xFF |Stream ID for the CMD uDMA channel 0. Default is 0xFF (channel disabled)| + +-----+---+----+-----+------------------------------------------------------------------------+ -.. _udma_csi2_RX_CH1_DEST: +.. _udma_csi2__RX_CH1_DEST: RX_CH1_DEST """"""""""" @@ -57,14 +64,16 @@ RX_CH1_DEST Stream ID for the uDMA channel 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+========================================================================+ - |7:0 |R/W|DEST|Stream ID for the CMD uDMA channel 1. Default is 0xFF (channel disabled)| - +-----+---+----+------------------------------------------------------------------------+ + +-----+---+----+-----+------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+========================================================================+ + |7:0 |R/W|DEST|0xFF |Stream ID for the CMD uDMA channel 1. Default is 0xFF (channel disabled)| + +-----+---+----+-----+------------------------------------------------------------------------+ -.. _udma_csi2_RX_ENABLE: +.. _udma_csi2__RX_ENABLE: RX_ENABLE """"""""" @@ -72,16 +81,18 @@ RX_ENABLE Enable receiving .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+--------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==============================================================+ - | 0|R/W|EN0 |Enable channel 0 pixel stream receiving: 0: Disable, 1: Enable| - +-----+---+----+--------------------------------------------------------------+ - | 1|R/W|EN1 |Enable channel 1 pixel stream receiving: 0: Disable, 1: Enable| - +-----+---+----+--------------------------------------------------------------+ + +-----+---+----+-----+--------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================================+ + | 0|R/W|EN0 |0x0 |Enable channel 0 pixel stream receiving: 0: Disable, 1: Enable| + +-----+---+----+-----+--------------------------------------------------------------+ + | 1|R/W|EN1 |0x0 |Enable channel 1 pixel stream receiving: 0: Disable, 1: Enable| + +-----+---+----+-----+--------------------------------------------------------------+ -.. _udma_csi2_CLK_SETUP: +.. _udma_csi2__CLK_SETUP: CLK_SETUP """"""""" @@ -89,18 +100,20 @@ CLK_SETUP Configure clock divider .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+---------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+===========================+ - |7:0 |R/W|CCI_CLK_DIV |Clock diver for CCI clock | - +-----+---+-------------+---------------------------+ - |15:8 |R/W|PIXEL_CLK_DIV|Clock diver for pixel clock| - +-----+---+-------------+---------------------------+ - |23:16|R/W|APB_CLK_DIV |Clock diver for APB clock | - +-----+---+-------------+---------------------------+ + +-----+---+-------------+-----+---------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+===========================+ + |7:0 |R/W|CCI_CLK_DIV |0x0 |Clock diver for CCI clock | + +-----+---+-------------+-----+---------------------------+ + |15:8 |R/W|PIXEL_CLK_DIV|0x0 |Clock diver for pixel clock| + +-----+---+-------------+-----+---------------------------+ + |23:16|R/W|APB_CLK_DIV |0x0 |Clock diver for APB clock | + +-----+---+-------------+-----+---------------------------+ -.. _udma_csi2_SLICE_ENABLE: +.. _udma_csi2__SLICE_ENABLE: SLICE_ENABLE """""""""""" @@ -108,16 +121,18 @@ SLICE_ENABLE Enable slice mode .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============================================================================+ - | 0|R/W|EN0 |Enable channel 0 slice mode for pixel stream receiving: 0: Disable, 1: Enable| - +-----+---+----+-----------------------------------------------------------------------------+ - | 1|R/W|EN1 |Enable channel 1 slice mode for pixel stream receiving: 0: Disable, 1: Enable| - +-----+---+----+-----------------------------------------------------------------------------+ + +-----+---+----+-----+-----------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================================+ + | 0|R/W|EN0 |0x0 |Enable channel 0 slice mode for pixel stream receiving: 0: Disable, 1: Enable| + +-----+---+----+-----+-----------------------------------------------------------------------------+ + | 1|R/W|EN1 |0x0 |Enable channel 1 slice mode for pixel stream receiving: 0: Disable, 1: Enable| + +-----+---+----+-----+-----------------------------------------------------------------------------+ -.. _udma_csi2_SLICE_ROWLEN: +.. _udma_csi2__SLICE_ROWLEN: SLICE_ROWLEN """""""""""" @@ -125,16 +140,18 @@ SLICE_ROWLEN Configure image row length when in slice mode .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-----------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+=========================================+ - |15:0 |R/W|ROWLEN0|Slice mode image row length for channel 0| - +-----+---+-------+-----------------------------------------+ - |31:16|R/W|ROWLEN1|Slice mode image row length for channel 1| - +-----+---+-------+-----------------------------------------+ + +-----+---+-------+-----+-----------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=========================================+ + |15:0 |R/W|ROWLEN0|0x0 |Slice mode image row length for channel 0| + +-----+---+-------+-----+-----------------------------------------+ + |31:16|R/W|ROWLEN1|0x0 |Slice mode image row length for channel 1| + +-----+---+-------+-----+-----------------------------------------+ -.. _udma_csi2_SLICE0_ULXY: +.. _udma_csi2__SLICE0_ULXY: SLICE0_ULXY """"""""""" @@ -142,16 +159,18 @@ SLICE0_ULXY Configure upper left pixel position when in slice mode for channel 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================+ - |15:0 |R/W|ULY |Upper left pixel position Y for channel 0| - +-----+---+----+-----------------------------------------+ - |31:16|R/W|ULX |Upper left pixel position X for channel 0| - +-----+---+----+-----------------------------------------+ + +-----+---+----+-----+-----------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=========================================+ + |15:0 |R/W|ULY |0x0 |Upper left pixel position Y for channel 0| + +-----+---+----+-----+-----------------------------------------+ + |31:16|R/W|ULX |0x0 |Upper left pixel position X for channel 0| + +-----+---+----+-----+-----------------------------------------+ -.. _udma_csi2_SLICE0_BRXY: +.. _udma_csi2__SLICE0_BRXY: SLICE0_BRXY """"""""""" @@ -159,16 +178,18 @@ SLICE0_BRXY Configure bottom right pixel position when in slice mode for channel 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===========================================+ - |15:0 |R/W|BRY |Bottom right pixel position Y for channel 0| - +-----+---+----+-------------------------------------------+ - |31:16|R/W|BRX |Bottom right pixel position X for channel 0| - +-----+---+----+-------------------------------------------+ + +-----+---+----+-----+-------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================================+ + |15:0 |R/W|BRY |0x0 |Bottom right pixel position Y for channel 0| + +-----+---+----+-----+-------------------------------------------+ + |31:16|R/W|BRX |0x0 |Bottom right pixel position X for channel 0| + +-----+---+----+-----+-------------------------------------------+ -.. _udma_csi2_SLICE1_ULXY: +.. _udma_csi2__SLICE1_ULXY: SLICE1_ULXY """"""""""" @@ -176,16 +197,18 @@ SLICE1_ULXY Configure upper left pixel position when in slice mode for channel 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=========================================+ - |15:0 |R/W|ULY |Upper left pixel position Y for channel 1| - +-----+---+----+-----------------------------------------+ - |31:16|R/W|ULX |Upper left pixel position X for channel 1| - +-----+---+----+-----------------------------------------+ + +-----+---+----+-----+-----------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=========================================+ + |15:0 |R/W|ULY |0x0 |Upper left pixel position Y for channel 1| + +-----+---+----+-----+-----------------------------------------+ + |31:16|R/W|ULX |0x0 |Upper left pixel position X for channel 1| + +-----+---+----+-----+-----------------------------------------+ -.. _udma_csi2_SLICE1_BRXY: +.. _udma_csi2__SLICE1_BRXY: SLICE1_BRXY """"""""""" @@ -193,11 +216,13 @@ SLICE1_BRXY Configure bottom right pixel position when in slice mode for channel 1 .. table:: - - +-----+---+----+-------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===========================================+ - |15:0 |R/W|BRY |Bottom right pixel position Y for channel 1| - +-----+---+----+-------------------------------------------+ - |31:16|R/W|BRX |Bottom right pixel position X for channel 1| - +-----+---+----+-------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+-------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================================+ + |15:0 |R/W|BRY |0x0 |Bottom right pixel position Y for channel 1| + +-----+---+----+-----+-------------------------------------------+ + |31:16|R/W|BRX |0x0 |Bottom right pixel position X for channel 1| + +-----+---+----+-----+-------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_ctrl.rst b/rtos/pulp/gap_archi/doc/ips/udma_ctrl.rst index c183d8a18..bb4facc6a 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_ctrl.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_ctrl.rst @@ -8,77 +8,82 @@ Register map Overview """""""" -.. table:: - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +=================================================+======+=====+==================================================================================================================================================================================================================================================+ - |:ref:`CFG_CG` | 0| 32|uDMA peripherals clock gate configuration. This controls the individual clock-gating of each uDMA peripheral. There is one bit per peripheral, and the clock-gating is active low, i.e the peripheral is inactive when its corresponding bit is 0.| - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_CG_SET` | 4| 32|Each bit set to 1 sets the corresponding bit in the CFG_CG register | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_CG_CLR` | 8| 32|Each bit set to 1 clears the corresponding bit in the CFG_CG register | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_RSTN` | 12| 32|uDMA peripherals reset configuration (active low). At chip reset all periphs are under reset. | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_RSTN_SET` | 16| 32|Each bit set to 1 sets the corresponding bit in the CFG_RSTN register | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_RSTN_CLR` | 20| 32|Each bit set to 1 sets the corresponding bit in the CFG_RSTN register | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_EVENT` | 24| 32|uDMA peripherals external event configuration | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FIFO_CFG` | 28| 32|Set FIFO ID for push and pop | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FIFO_PUSHPOP_8` | 32| 32|Pushe (write) and pop (read) 8bit to/from the FIFO | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FIFO_PUSHPOP_16`| 36| 32|Pushe (write) and pop (read) 16bit to/from the FIFO | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FIFO_PUSHPOP_24`| 40| 32|Pushe (write) and pop (read) 24bit to/from the FIFO | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`FIFO_PUSHPOP_32`| 44| 32|Pushe (write) and pop (read) 32bit to/from the FIFO | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`DATAMOVE_CFG` | 48| 32|Configure data movement | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`DATAMOVE0_SIZE` | 52| 32|Control of mover channel 0 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`DATAMOVE1_SIZE` | 56| 32|Control of mover channel 1 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`STREAM_CFG` | 60| 32|Configure blocking behavior of streams | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_PRE0` | 64| 32|Configuration of the frequency prescaler for timeout ch0 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_CH0` | 68| 32|Configuration for timeout ch0 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_PRE1` | 72| 32|Configuration of the frequency prescaler for timeout ch1 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_CH1` | 76| 32|Configuration for timeout ch1 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_PRE2` | 80| 32|Configuration of the frequency prescaler for timeout ch2 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_CH2` | 84| 32|Configuration for timeout ch2 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_PRE3` | 88| 32|Configuration of the frequency prescaler for timeout ch3 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_CH3` | 92| 32|Configuration for timeout ch3 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_PRE4` | 96| 32|Configuration of the frequency prescaler for timeout ch4 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_CH4` | 100| 32|Configuration for timeout ch4 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_PRE5` | 104| 32|Configuration of the frequency prescaler for timeout ch5 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_CH5` | 108| 32|Configuration for timeout ch5 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_PRE6` | 112| 32|Configuration of the frequency prescaler for timeout ch6 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_CH6` | 116| 32|Configuration for timeout ch6 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_PRE7` | 120| 32|Configuration of the frequency prescaler for timeout ch7 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`TIMEOUT_CH7` | 124| 32|Configuration for timeout ch7 | - +-------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_ctrl_CFG_CG: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | Name |Offset|Width| Description | + +==================================================+======+=====+==================================================================================================================================================================================================================================================+ + |:ref:`CFG_CG` | 0| 32|uDMA peripherals clock gate configuration. This controls the individual clock-gating of each uDMA peripheral. There is one bit per peripheral, and the clock-gating is active low, i.e the peripheral is inactive when its corresponding bit is 0.| + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CFG_CG_SET` | 4| 32|Each bit set to 1 sets the corresponding bit in the CFG_CG register | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CFG_CG_CLR` | 8| 32|Each bit set to 1 clears the corresponding bit in the CFG_CG register | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CFG_RSTN` | 12| 32|uDMA peripherals reset configuration (active low). At chip reset all periphs are under reset. | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CFG_RSTN_SET` | 16| 32|Each bit set to 1 sets the corresponding bit in the CFG_RSTN register | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CFG_RSTN_CLR` | 20| 32|Each bit set to 1 sets the corresponding bit in the CFG_RSTN register | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CFG_EVENT` | 24| 32|uDMA peripherals external event configuration | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FIFO_CFG` | 28| 32|Set FIFO ID for push and pop | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FIFO_PUSHPOP_8` | 32| 32|Push (write) and pop (read) 8-bit word to/from the FIFO | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FIFO_PUSHPOP_16`| 36| 32|Push (write) and pop (read) 16-bit word to/from the FIFO | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FIFO_PUSHPOP_24`| 40| 32|Push (write) and pop (read) 24-bit word to/from the FIFO | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`FIFO_PUSHPOP_32`| 44| 32|Push (write) and pop (read) 32-bit word to/from the FIFO | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`DATAMOVE_CFG` | 48| 32|Configure data movement | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`DATAMOVE0_SIZE` | 52| 32|Control of mover channel 0 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`DATAMOVE1_SIZE` | 56| 32|Control of mover channel 1 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`STREAM_CFG` | 60| 32|Configure blocking behavior of streams | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_PRE0` | 64| 32|Configuration of the frequency prescaler for timeout ch0 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_CH0` | 68| 32|Configuration for timeout ch0 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_PRE1` | 72| 32|Configuration of the frequency prescaler for timeout ch1 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_CH1` | 76| 32|Configuration for timeout ch1 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_PRE2` | 80| 32|Configuration of the frequency prescaler for timeout ch2 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_CH2` | 84| 32|Configuration for timeout ch2 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_PRE3` | 88| 32|Configuration of the frequency prescaler for timeout ch3 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_CH3` | 92| 32|Configuration for timeout ch3 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_PRE4` | 96| 32|Configuration of the frequency prescaler for timeout ch4 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_CH4` | 100| 32|Configuration for timeout ch4 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_PRE5` | 104| 32|Configuration of the frequency prescaler for timeout ch5 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_CH5` | 108| 32|Configuration for timeout ch5 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_PRE6` | 112| 32|Configuration of the frequency prescaler for timeout ch6 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_CH6` | 116| 32|Configuration for timeout ch6 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_PRE7` | 120| 32|Configuration of the frequency prescaler for timeout ch7 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`TIMEOUT_CH7` | 124| 32|Configuration for timeout ch7 | + +--------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_ctrl__CFG_CG: CFG_CG """""" @@ -86,74 +91,76 @@ CFG_CG uDMA peripherals clock gate configuration. This controls the individual clock-gating of each uDMA peripheral. There is one bit per peripheral, and the clock-gating is active low, i.e the peripheral is inactive when its corresponding bit is 0. .. table:: - - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=================+============================================================================================+ - | 0|R/W|CK_GATE_SPI0 |Control internal clock of SPI0: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 1|R/W|CK_GATE_SPI1 |Control internal clock of SPI1: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 2|R/W|CK_GATE_SPI2 |Control internal clock of SPI2: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 3|R/W|CK_GATE_SPI3 |Control internal clock of SPI3: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 4|R/W|CK_GATE_UART0 |Control internal clock of UART0: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 5|R/W|CK_GATE_UART1 |Control internal clock of UART1: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 6|R/W|CK_GATE_UART2 |Control internal clock of UART2: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 7|R/W|CK_GATE_UART3 |Control internal clock of UART3: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 8|R/W|CK_GATE_UART4 |Control internal clock of UART4: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 9|R/W|CK_GATE_I2C0 |Control internal clock of I2C0: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 10|R/W|CK_GATE_I2C1 |Control internal clock of I2C1: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 11|R/W|CK_GATE_I2C2 |Control internal clock of I2C2: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 12|R/W|CK_GATE_I2C3 |Control internal clock of I2C3: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 13|R/W|CK_GATE_HYPER0 |Control internal clock of memory interface 0: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 14|R/W|CK_GATE_HYPER1 |Control internal clock of memory interface 1: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 15|R/W|CK_GATE_JTAG |Control internal clock of JTAG data transfers: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 16|R/W|CK_GATE_SAI0 |Control internal clock of I2S/SAI0: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 17|R/W|CK_GATE_SAI1 |Control internal clock of I2S/SAI1: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 18|R/W|CK_GATE_SAI2 |Control internal clock of I2S/SAI2: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 19|R/W|CK_GATE_CPI |Control internal clock of camera parallel interface: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 20|R/W|CK_GATE_CSI2 |Control internal clock of CSI2 interface: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 21|R/W|CK_GATE_MRAM |Control internal clock of MRAM interface: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 22|R/W|CK_GATE_FILTER |Control internal clock of filter unit: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 23|R/W|CK_GATE_TIMESTAMP|Control internal clock of timestamp unit: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 24|R/W|CK_GATE_AES0 |Control internal clock of AES0: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 25|R/W|CK_GATE_AES1 |Control internal clock of AES1: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 26|R/W|CK_GATE_SFU |Control internal clock of SFU interface: 0: clock gated, 1: clock enabled | - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 27|R/W|CK_GATE_FFC0 |Control internal clock of fixed/floating point converter 0: 0: clock gated, 1: clock enabled| - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 28|R/W|CK_GATE_FFC1 |Control internal clock of fixed/floating point converter 1: 0: clock gated, 1: clock enabled| - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 29|R/W|CK_GATE_FFC2 |Control internal clock of fixed/floating point converter 2: 0: clock gated, 1: clock enabled| - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - | 30|R/W|CK_GATE_FFC3 |Control internal clock of fixed/floating point converter 3: 0: clock gated, 1: clock enabled| - +-----+---+-----------------+--------------------------------------------------------------------------------------------+ - -.. _udma_ctrl_CFG_CG_SET: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=================+=====+============================================================================================+ + | 0|R/W|CK_GATE_SPI0 |0x0 |Control internal clock of SPI0: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 1|R/W|CK_GATE_SPI1 |0x0 |Control internal clock of SPI1: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 2|R/W|CK_GATE_SPI2 |0x0 |Control internal clock of SPI2: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 3|R/W|CK_GATE_SPI3 |0x0 |Control internal clock of SPI3: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 4|R/W|CK_GATE_UART0 |0x0 |Control internal clock of UART0: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 5|R/W|CK_GATE_UART1 |0x0 |Control internal clock of UART1: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 6|R/W|CK_GATE_UART2 |0x0 |Control internal clock of UART2: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 7|R/W|CK_GATE_UART3 |0x0 |Control internal clock of UART3: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 8|R/W|CK_GATE_UART4 |0x0 |Control internal clock of UART4: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 9|R/W|CK_GATE_I2C0 |0x0 |Control internal clock of I2C0: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 10|R/W|CK_GATE_I2C1 |0x0 |Control internal clock of I2C1: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 11|R/W|CK_GATE_I2C2 |0x0 |Control internal clock of I2C2: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 12|R/W|CK_GATE_I2C3 |0x0 |Control internal clock of I2C3: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 13|R/W|CK_GATE_HYPER0 |0x0 |Control internal clock of memory interface 0: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 14|R/W|CK_GATE_HYPER1 |0x0 |Control internal clock of memory interface 1: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 15|R/W|CK_GATE_JTAG |0x0 |Control internal clock of JTAG data transfers: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 16|R/W|CK_GATE_SAI0 |0x0 |Control internal clock of I2S/SAI0: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 17|R/W|CK_GATE_SAI1 |0x0 |Control internal clock of I2S/SAI1: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 18|R/W|CK_GATE_SAI2 |0x0 |Control internal clock of I2S/SAI2: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 19|R/W|CK_GATE_CPI |0x0 |Control internal clock of camera parallel interface: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 20|R/W|CK_GATE_CSI2 |0x0 |Control internal clock of CSI2 interface: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 21|R/W|CK_GATE_MRAM |0x0 |Control internal clock of MRAM interface: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 22|R/W|CK_GATE_FILTER |0x0 |Control internal clock of filter unit: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 23|R/W|CK_GATE_TIMESTAMP|0x0 |Control internal clock of timestamp unit: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 24|R/W|CK_GATE_AES0 |0x0 |Control internal clock of AES0: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 25|R/W|CK_GATE_AES1 |0x0 |Control internal clock of AES1: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 26|R/W|CK_GATE_SFU |0x0 |Control internal clock of SFU interface: 0: clock gated, 1: clock enabled | + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 27|R/W|CK_GATE_FFC0 |0x0 |Control internal clock of fixed/floating point converter 0: 0: clock gated, 1: clock enabled| + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 28|R/W|CK_GATE_FFC1 |0x0 |Control internal clock of fixed/floating point converter 1: 0: clock gated, 1: clock enabled| + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 29|R/W|CK_GATE_FFC2 |0x0 |Control internal clock of fixed/floating point converter 2: 0: clock gated, 1: clock enabled| + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + | 30|R/W|CK_GATE_FFC3 |0x0 |Control internal clock of fixed/floating point converter 3: 0: clock gated, 1: clock enabled| + +-----+---+-----------------+-----+--------------------------------------------------------------------------------------------+ + +.. _udma_ctrl__CFG_CG_SET: CFG_CG_SET """""""""" @@ -161,74 +168,76 @@ CFG_CG_SET Each bit set to 1 sets the corresponding bit in the CFG_CG register .. table:: - - +-----+---+---------------------+-----------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+===========================================================+ - | 0|W |CK_GATE_SPI0_SET |Write 1 to enable clock of SPI0 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 1|W |CK_GATE_SPI1_SET |Write 1 to enable clock of SPI1 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 2|W |CK_GATE_SPI2_SET |Write 1 to enable clock of SPI2 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 3|W |CK_GATE_SPI3_SET |Write 1 to enable clock of SPI3 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 4|W |CK_GATE_UART0_SET |Write 1 to enable clock of UART0 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 5|W |CK_GATE_UART1_SET |Write 1 to enable clock of UART1 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 6|W |CK_GATE_UART2_SET |Write 1 to enable clock of UART2 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 7|W |CK_GATE_UART3_SET |Write 1 to enable clock of UART3 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 8|W |CK_GATE_UART4_SET |Write 1 to enable clock of UART4 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 9|W |CK_GATE_I2C0_SET |Write 1 to enable clock of I2C0 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 10|W |CK_GATE_I2C1_SET |Write 1 to enable clock of I2C1 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 11|W |CK_GATE_I2C2_SET |Write 1 to enable clock of I2C2 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 12|W |CK_GATE_I2C3_SET |Write 1 to enable clock of I2C3 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 13|W |CK_GATE_HYPER0_SET |Write 1 to enable clock of memory interface 0 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 14|W |CK_GATE_HYPER1_SET |Write 1 to enable clock of memory interface 1 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 15|W |CK_GATE_JTAG_SET |Write 1 to enable clock of JTAG data transfers | - +-----+---+---------------------+-----------------------------------------------------------+ - | 16|W |CK_GATE_SAI0_SET |Write 1 to enable clock of I2S/SAI0 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 17|W |CK_GATE_SAI1_SET |Write 1 to enable clock of I2S/SAI1 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 18|W |CK_GATE_SAI2_SET |Write 1 to enable clock of I2S/SAI2 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 19|W |CK_GATE_CPI_SET |Write 1 to enable clock of camera parallel interface | - +-----+---+---------------------+-----------------------------------------------------------+ - | 20|W |CK_GATE_CSI2_SET |Write 1 to enable clock of CSI2 interface | - +-----+---+---------------------+-----------------------------------------------------------+ - | 21|W |CK_GATE_MRAM_SET |Write 1 to enable clock of MRAM interface | - +-----+---+---------------------+-----------------------------------------------------------+ - | 22|W |CK_GATE_FILTER_SET |Write 1 to enable clock of filter unit | - +-----+---+---------------------+-----------------------------------------------------------+ - | 23|W |CK_GATE_TIMESTAMP_SET|Write 1 to enable clock of timestamp unit | - +-----+---+---------------------+-----------------------------------------------------------+ - | 24|W |CK_GATE_AES0_SET |Write 1 to enable clock of AES0 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 25|W |CK_GATE_AES1_SET |Write 1 to enable clock of AES1 | - +-----+---+---------------------+-----------------------------------------------------------+ - | 26|W |CK_GATE_SFU_SET |Write 1 to enable clock of SFU interface | - +-----+---+---------------------+-----------------------------------------------------------+ - | 27|W |CK_GATE_FFC0_SET |Write 1 to enable clock of fixed/floating point converter 0| - +-----+---+---------------------+-----------------------------------------------------------+ - | 28|W |CK_GATE_FFC1_SET |Write 1 to enable clock of fixed/floating point converter 1| - +-----+---+---------------------+-----------------------------------------------------------+ - | 29|W |CK_GATE_FFC2_SET |Write 1 to enable clock of fixed/floating point converter 2| - +-----+---+---------------------+-----------------------------------------------------------+ - | 30|W |CK_GATE_FFC3_SET |Write 1 to enable clock of fixed/floating point converter 3| - +-----+---+---------------------+-----------------------------------------------------------+ - -.. _udma_ctrl_CFG_CG_CLR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+===========================================================+ + | 0|W |CK_GATE_SPI0_SET |0x0 |Write 1 to enable clock of SPI0 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 1|W |CK_GATE_SPI1_SET |0x0 |Write 1 to enable clock of SPI1 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 2|W |CK_GATE_SPI2_SET |0x0 |Write 1 to enable clock of SPI2 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 3|W |CK_GATE_SPI3_SET |0x0 |Write 1 to enable clock of SPI3 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 4|W |CK_GATE_UART0_SET |0x0 |Write 1 to enable clock of UART0 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 5|W |CK_GATE_UART1_SET |0x0 |Write 1 to enable clock of UART1 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 6|W |CK_GATE_UART2_SET |0x0 |Write 1 to enable clock of UART2 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 7|W |CK_GATE_UART3_SET |0x0 |Write 1 to enable clock of UART3 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 8|W |CK_GATE_UART4_SET |0x0 |Write 1 to enable clock of UART4 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 9|W |CK_GATE_I2C0_SET |0x0 |Write 1 to enable clock of I2C0 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 10|W |CK_GATE_I2C1_SET |0x0 |Write 1 to enable clock of I2C1 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 11|W |CK_GATE_I2C2_SET |0x0 |Write 1 to enable clock of I2C2 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 12|W |CK_GATE_I2C3_SET |0x0 |Write 1 to enable clock of I2C3 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 13|W |CK_GATE_HYPER0_SET |0x0 |Write 1 to enable clock of memory interface 0 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 14|W |CK_GATE_HYPER1_SET |0x0 |Write 1 to enable clock of memory interface 1 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 15|W |CK_GATE_JTAG_SET |0x0 |Write 1 to enable clock of JTAG data transfers | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 16|W |CK_GATE_SAI0_SET |0x0 |Write 1 to enable clock of I2S/SAI0 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 17|W |CK_GATE_SAI1_SET |0x0 |Write 1 to enable clock of I2S/SAI1 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 18|W |CK_GATE_SAI2_SET |0x0 |Write 1 to enable clock of I2S/SAI2 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 19|W |CK_GATE_CPI_SET |0x0 |Write 1 to enable clock of camera parallel interface | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 20|W |CK_GATE_CSI2_SET |0x0 |Write 1 to enable clock of CSI2 interface | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 21|W |CK_GATE_MRAM_SET |0x0 |Write 1 to enable clock of MRAM interface | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 22|W |CK_GATE_FILTER_SET |0x0 |Write 1 to enable clock of filter unit | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 23|W |CK_GATE_TIMESTAMP_SET|0x0 |Write 1 to enable clock of timestamp unit | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 24|W |CK_GATE_AES0_SET |0x0 |Write 1 to enable clock of AES0 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 25|W |CK_GATE_AES1_SET |0x0 |Write 1 to enable clock of AES1 | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 26|W |CK_GATE_SFU_SET |0x0 |Write 1 to enable clock of SFU interface | + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 27|W |CK_GATE_FFC0_SET |0x0 |Write 1 to enable clock of fixed/floating point converter 0| + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 28|W |CK_GATE_FFC1_SET |0x0 |Write 1 to enable clock of fixed/floating point converter 1| + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 29|W |CK_GATE_FFC2_SET |0x0 |Write 1 to enable clock of fixed/floating point converter 2| + +-----+---+---------------------+-----+-----------------------------------------------------------+ + | 30|W |CK_GATE_FFC3_SET |0x0 |Write 1 to enable clock of fixed/floating point converter 3| + +-----+---+---------------------+-----+-----------------------------------------------------------+ + +.. _udma_ctrl__CFG_CG_CLR: CFG_CG_CLR """""""""" @@ -236,74 +245,76 @@ CFG_CG_CLR Each bit set to 1 clears the corresponding bit in the CFG_CG register .. table:: - - +-----+---+---------------------+---------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+=========================================================+ - | 0|W |CK_GATE_SPI0_CLR |Write 1 to gate clock of SPI0 | - +-----+---+---------------------+---------------------------------------------------------+ - | 1|W |CK_GATE_SPI1_CLR |Write 1 to gate clock of SPI1 | - +-----+---+---------------------+---------------------------------------------------------+ - | 2|W |CK_GATE_SPI2_CLR |Write 1 to gate clock of SPI2 | - +-----+---+---------------------+---------------------------------------------------------+ - | 3|W |CK_GATE_SPI3_CLR |Write 1 to gate clock of SPI3 | - +-----+---+---------------------+---------------------------------------------------------+ - | 4|W |CK_GATE_UART0_CLR |Write 1 to gate clock of UART0 | - +-----+---+---------------------+---------------------------------------------------------+ - | 5|W |CK_GATE_UART1_CLR |Write 1 to gate clock of UART1 | - +-----+---+---------------------+---------------------------------------------------------+ - | 6|W |CK_GATE_UART2_CLR |Write 1 to gate clock of UART2 | - +-----+---+---------------------+---------------------------------------------------------+ - | 7|W |CK_GATE_UART3_CLR |Write 1 to gate clock of UART3 | - +-----+---+---------------------+---------------------------------------------------------+ - | 8|W |CK_GATE_UART4_CLR |Write 1 to gate clock of UART4 | - +-----+---+---------------------+---------------------------------------------------------+ - | 9|W |CK_GATE_I2C0_CLR |Write 1 to gate clock of I2C0 | - +-----+---+---------------------+---------------------------------------------------------+ - | 10|W |CK_GATE_I2C1_CLR |Write 1 to gate clock of I2C1 | - +-----+---+---------------------+---------------------------------------------------------+ - | 11|W |CK_GATE_I2C2_CLR |Write 1 to gate clock of I2C2 | - +-----+---+---------------------+---------------------------------------------------------+ - | 12|W |CK_GATE_I2C3_CLR |Write 1 to gate clock of I2C3 | - +-----+---+---------------------+---------------------------------------------------------+ - | 13|W |CK_GATE_HYPER0_CLR |Write 1 to gate clock of memory interface 0 | - +-----+---+---------------------+---------------------------------------------------------+ - | 14|W |CK_GATE_HYPER1_CLR |Write 1 to gate clock of memory interface 1 | - +-----+---+---------------------+---------------------------------------------------------+ - | 15|W |CK_GATE_JTAG_CLR |Write 1 to gate clock of JTAG data transfers | - +-----+---+---------------------+---------------------------------------------------------+ - | 16|W |CK_GATE_SAI0_CLR |Write 1 to gate clock of I2S/SAI0 | - +-----+---+---------------------+---------------------------------------------------------+ - | 17|W |CK_GATE_SAI1_CLR |Write 1 to gate clock of I2S/SAI1 | - +-----+---+---------------------+---------------------------------------------------------+ - | 18|W |CK_GATE_SAI2_CLR |Write 1 to gate clock of I2S/SAI2 | - +-----+---+---------------------+---------------------------------------------------------+ - | 19|W |CK_GATE_CPI_CLR |Write 1 to gate clock of camera parallel interface | - +-----+---+---------------------+---------------------------------------------------------+ - | 20|W |CK_GATE_CSI2_CLR |Write 1 to gate clock of CSI2 interface | - +-----+---+---------------------+---------------------------------------------------------+ - | 21|W |CK_GATE_MRAM_CLR |Write 1 to gate clock of MRAM interface | - +-----+---+---------------------+---------------------------------------------------------+ - | 22|W |CK_GATE_FILTER_CLR |Write 1 to gate clock of filter unit | - +-----+---+---------------------+---------------------------------------------------------+ - | 23|W |CK_GATE_TIMESTAMP_CLR|Write 1 to gate clock of timestamp unit | - +-----+---+---------------------+---------------------------------------------------------+ - | 24|W |CK_GATE_AES0_CLR |Write 1 to gate clock of AES0 | - +-----+---+---------------------+---------------------------------------------------------+ - | 25|W |CK_GATE_AES1_CLR |Write 1 to gate clock of AES1 | - +-----+---+---------------------+---------------------------------------------------------+ - | 26|W |CK_GATE_SFU_CLR |Write 1 to gate clock of SFU interface | - +-----+---+---------------------+---------------------------------------------------------+ - | 27|W |CK_GATE_FFC0_CLR |Write 1 to gate clock of fixed/floating point converter 0| - +-----+---+---------------------+---------------------------------------------------------+ - | 28|W |CK_GATE_FFC1_CLR |Write 1 to gate clock of fixed/floating point converter 1| - +-----+---+---------------------+---------------------------------------------------------+ - | 29|W |CK_GATE_FFC2_CLR |Write 1 to gate clock of fixed/floating point converter 2| - +-----+---+---------------------+---------------------------------------------------------+ - | 30|W |CK_GATE_FFC3_CLR |Write 1 to gate clock of fixed/floating point converter 3| - +-----+---+---------------------+---------------------------------------------------------+ - -.. _udma_ctrl_CFG_RSTN: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------------+-----+---------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+=========================================================+ + | 0|W |CK_GATE_SPI0_CLR |0x0 |Write 1 to gate clock of SPI0 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 1|W |CK_GATE_SPI1_CLR |0x0 |Write 1 to gate clock of SPI1 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 2|W |CK_GATE_SPI2_CLR |0x0 |Write 1 to gate clock of SPI2 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 3|W |CK_GATE_SPI3_CLR |0x0 |Write 1 to gate clock of SPI3 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 4|W |CK_GATE_UART0_CLR |0x0 |Write 1 to gate clock of UART0 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 5|W |CK_GATE_UART1_CLR |0x0 |Write 1 to gate clock of UART1 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 6|W |CK_GATE_UART2_CLR |0x0 |Write 1 to gate clock of UART2 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 7|W |CK_GATE_UART3_CLR |0x0 |Write 1 to gate clock of UART3 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 8|W |CK_GATE_UART4_CLR |0x0 |Write 1 to gate clock of UART4 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 9|W |CK_GATE_I2C0_CLR |0x0 |Write 1 to gate clock of I2C0 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 10|W |CK_GATE_I2C1_CLR |0x0 |Write 1 to gate clock of I2C1 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 11|W |CK_GATE_I2C2_CLR |0x0 |Write 1 to gate clock of I2C2 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 12|W |CK_GATE_I2C3_CLR |0x0 |Write 1 to gate clock of I2C3 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 13|W |CK_GATE_HYPER0_CLR |0x0 |Write 1 to gate clock of memory interface 0 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 14|W |CK_GATE_HYPER1_CLR |0x0 |Write 1 to gate clock of memory interface 1 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 15|W |CK_GATE_JTAG_CLR |0x0 |Write 1 to gate clock of JTAG data transfers | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 16|W |CK_GATE_SAI0_CLR |0x0 |Write 1 to gate clock of I2S/SAI0 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 17|W |CK_GATE_SAI1_CLR |0x0 |Write 1 to gate clock of I2S/SAI1 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 18|W |CK_GATE_SAI2_CLR |0x0 |Write 1 to gate clock of I2S/SAI2 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 19|W |CK_GATE_CPI_CLR |0x0 |Write 1 to gate clock of camera parallel interface | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 20|W |CK_GATE_CSI2_CLR |0x0 |Write 1 to gate clock of CSI2 interface | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 21|W |CK_GATE_MRAM_CLR |0x0 |Write 1 to gate clock of MRAM interface | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 22|W |CK_GATE_FILTER_CLR |0x0 |Write 1 to gate clock of filter unit | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 23|W |CK_GATE_TIMESTAMP_CLR|0x0 |Write 1 to gate clock of timestamp unit | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 24|W |CK_GATE_AES0_CLR |0x0 |Write 1 to gate clock of AES0 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 25|W |CK_GATE_AES1_CLR |0x0 |Write 1 to gate clock of AES1 | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 26|W |CK_GATE_SFU_CLR |0x0 |Write 1 to gate clock of SFU interface | + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 27|W |CK_GATE_FFC0_CLR |0x0 |Write 1 to gate clock of fixed/floating point converter 0| + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 28|W |CK_GATE_FFC1_CLR |0x0 |Write 1 to gate clock of fixed/floating point converter 1| + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 29|W |CK_GATE_FFC2_CLR |0x0 |Write 1 to gate clock of fixed/floating point converter 2| + +-----+---+---------------------+-----+---------------------------------------------------------+ + | 30|W |CK_GATE_FFC3_CLR |0x0 |Write 1 to gate clock of fixed/floating point converter 3| + +-----+---+---------------------+-----+---------------------------------------------------------+ + +.. _udma_ctrl__CFG_RSTN: CFG_RSTN """""""" @@ -311,74 +322,76 @@ CFG_RSTN uDMA peripherals reset configuration (active low). At chip reset all periphs are under reset. .. table:: - - +-----+---+--------------+-------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===============================================================================+ - | 0|R/W|RSTN_SPI0 |Control reset of SPI0: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 1|R/W|RSTN_SPI1 |Control reset of SPI1: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 2|R/W|RSTN_SPI2 |Control reset of SPI2: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 3|R/W|RSTN_SPI3 |Control reset of SPI3: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 4|R/W|RSTN_UART0 |Control reset of UART0: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 5|R/W|RSTN_UART1 |Control reset of UART1: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 6|R/W|RSTN_UART2 |Control reset of UART2: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 7|R/W|RSTN_UART3 |Control reset of UART3: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 8|R/W|RSTN_UART4 |Control reset of UART4: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 9|R/W|RSTN_I2C0 |Control reset of I2C0: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 10|R/W|RSTN_I2C1 |Control reset of I2C1: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 11|R/W|RSTN_I2C2 |Control reset of I2C2: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 12|R/W|RSTN_I2C3 |Control reset of I2C3: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 13|R/W|RSTN_HYPER0 |Control reset of memory interface 0: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 14|R/W|RSTN_HYPER1 |Control reset of memory interface 1: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 15|R/W|RSTN_JTAG |Control reset of JTAG data transfers: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 16|R/W|RSTN_SAI0 |Control reset of I2S/SAI0: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 17|R/W|RSTN_SAI1 |Control reset of I2S/SAI1: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 18|R/W|RSTN_SAI2 |Control reset of I2S/SAI2: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 19|R/W|RSTN_CPI |Control reset of camera parallel interface: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 20|R/W|RSTN_CSI2 |Control reset of CSI2 interface: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 21|R/W|RSTN_MRAM |Control reset of MRAM interface: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 22|R/W|RSTN_FILTER |Control reset of filter unit: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 23|R/W|RSTN_TIMESTAMP|Control reset of timestamp unit: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 24|R/W|RSTN_AES0 |Control reset of AES0: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 25|R/W|RSTN_AES1 |Control reset of AES1: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 26|R/W|RSTN_SFU |Control reset of SFU interface: 0: periph reset, 1: no reset | - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 27|R/W|RSTN_FFC0 |Control reset of fixed/floating point converter 0: 0: periph reset, 1: no reset| - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 28|R/W|RSTN_FFC1 |Control reset of fixed/floating point converter 1: 0: periph reset, 1: no reset| - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 29|R/W|RSTN_FFC2 |Control reset of fixed/floating point converter 2: 0: periph reset, 1: no reset| - +-----+---+--------------+-------------------------------------------------------------------------------+ - | 30|R/W|RSTN_FFC3 |Control reset of fixed/floating point converter 3: 0: periph reset, 1: no reset| - +-----+---+--------------+-------------------------------------------------------------------------------+ - -.. _udma_ctrl_CFG_RSTN_SET: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===============================================================================+ + | 0|R/W|RSTN_SPI0 |0x0 |Control reset of SPI0: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 1|R/W|RSTN_SPI1 |0x0 |Control reset of SPI1: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 2|R/W|RSTN_SPI2 |0x0 |Control reset of SPI2: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 3|R/W|RSTN_SPI3 |0x0 |Control reset of SPI3: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 4|R/W|RSTN_UART0 |0x0 |Control reset of UART0: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 5|R/W|RSTN_UART1 |0x0 |Control reset of UART1: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 6|R/W|RSTN_UART2 |0x0 |Control reset of UART2: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 7|R/W|RSTN_UART3 |0x0 |Control reset of UART3: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 8|R/W|RSTN_UART4 |0x0 |Control reset of UART4: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 9|R/W|RSTN_I2C0 |0x0 |Control reset of I2C0: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 10|R/W|RSTN_I2C1 |0x0 |Control reset of I2C1: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 11|R/W|RSTN_I2C2 |0x0 |Control reset of I2C2: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 12|R/W|RSTN_I2C3 |0x0 |Control reset of I2C3: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 13|R/W|RSTN_HYPER0 |0x0 |Control reset of memory interface 0: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 14|R/W|RSTN_HYPER1 |0x0 |Control reset of memory interface 1: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 15|R/W|RSTN_JTAG |0x0 |Control reset of JTAG data transfers: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 16|R/W|RSTN_SAI0 |0x0 |Control reset of I2S/SAI0: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 17|R/W|RSTN_SAI1 |0x0 |Control reset of I2S/SAI1: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 18|R/W|RSTN_SAI2 |0x0 |Control reset of I2S/SAI2: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 19|R/W|RSTN_CPI |0x0 |Control reset of camera parallel interface: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 20|R/W|RSTN_CSI2 |0x0 |Control reset of CSI2 interface: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 21|R/W|RSTN_MRAM |0x0 |Control reset of MRAM interface: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 22|R/W|RSTN_FILTER |0x0 |Control reset of filter unit: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 23|R/W|RSTN_TIMESTAMP|0x0 |Control reset of timestamp unit: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 24|R/W|RSTN_AES0 |0x0 |Control reset of AES0: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 25|R/W|RSTN_AES1 |0x0 |Control reset of AES1: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 26|R/W|RSTN_SFU |0x0 |Control reset of SFU interface: 0: periph reset, 1: no reset | + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 27|R/W|RSTN_FFC0 |0x0 |Control reset of fixed/floating point converter 0: 0: periph reset, 1: no reset| + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 28|R/W|RSTN_FFC1 |0x0 |Control reset of fixed/floating point converter 1: 0: periph reset, 1: no reset| + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 29|R/W|RSTN_FFC2 |0x0 |Control reset of fixed/floating point converter 2: 0: periph reset, 1: no reset| + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + | 30|R/W|RSTN_FFC3 |0x0 |Control reset of fixed/floating point converter 3: 0: periph reset, 1: no reset| + +-----+---+--------------+-----+-------------------------------------------------------------------------------+ + +.. _udma_ctrl__CFG_RSTN_SET: CFG_RSTN_SET """""""""""" @@ -386,74 +399,76 @@ CFG_RSTN_SET Each bit set to 1 sets the corresponding bit in the CFG_RSTN register .. table:: - - +-----+---+------------------+------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+============================================================+ - | 0|W |RSTN_SPI0_SET |Write 1 to disable reset of SPI0 | - +-----+---+------------------+------------------------------------------------------------+ - | 1|W |RSTN_SPI1_SET |Write 1 to disable reset of SPI1 | - +-----+---+------------------+------------------------------------------------------------+ - | 2|W |RSTN_SPI2_SET |Write 1 to disable reset of SPI2 | - +-----+---+------------------+------------------------------------------------------------+ - | 3|W |RSTN_SPI3_SET |Write 1 to disable reset of SPI3 | - +-----+---+------------------+------------------------------------------------------------+ - | 4|W |RSTN_UART0_SET |Write 1 to disable reset of UART0 | - +-----+---+------------------+------------------------------------------------------------+ - | 5|W |RSTN_UART1_SET |Write 1 to disable reset of UART1 | - +-----+---+------------------+------------------------------------------------------------+ - | 6|W |RSTN_UART2_SET |Write 1 to disable reset of UART2 | - +-----+---+------------------+------------------------------------------------------------+ - | 7|W |RSTN_UART3_SET |Write 1 to disable reset of UART3 | - +-----+---+------------------+------------------------------------------------------------+ - | 8|W |RSTN_UART4_SET |Write 1 to disable reset of UART4 | - +-----+---+------------------+------------------------------------------------------------+ - | 9|W |RSTN_I2C0_SET |Write 1 to disable reset of I2C0 | - +-----+---+------------------+------------------------------------------------------------+ - | 10|W |RSTN_I2C1_SET |Write 1 to disable reset of I2C1 | - +-----+---+------------------+------------------------------------------------------------+ - | 11|W |RSTN_I2C2_SET |Write 1 to disable reset of I2C2 | - +-----+---+------------------+------------------------------------------------------------+ - | 12|W |RSTN_I2C3_SET |Write 1 to disable reset of I2C3 | - +-----+---+------------------+------------------------------------------------------------+ - | 13|W |RSTN_HYPER0_SET |Write 1 to disable reset of memory interface 0 | - +-----+---+------------------+------------------------------------------------------------+ - | 14|W |RSTN_HYPER1_SET |Write 1 to disable reset of memory interface 1 | - +-----+---+------------------+------------------------------------------------------------+ - | 15|W |RSTN_JTAG_SET |Write 1 to disable reset of JTAG data transfers | - +-----+---+------------------+------------------------------------------------------------+ - | 16|W |RSTN_SAI0_SET |Write 1 to disable reset of I2S/SAI0 | - +-----+---+------------------+------------------------------------------------------------+ - | 17|W |RSTN_SAI1_SET |Write 1 to disable reset of I2S/SAI1 | - +-----+---+------------------+------------------------------------------------------------+ - | 18|W |RSTN_SAI2_SET |Write 1 to disable reset of I2S/SAI2 | - +-----+---+------------------+------------------------------------------------------------+ - | 19|W |RSTN_CPI_SET |Write 1 to disable reset of camera parallel interface | - +-----+---+------------------+------------------------------------------------------------+ - | 20|W |RSTN_CSI2_SET |Write 1 to disable reset of CSI2 interface | - +-----+---+------------------+------------------------------------------------------------+ - | 21|W |RSTN_MRAM_SET |Write 1 to disable reset of MRAM interface | - +-----+---+------------------+------------------------------------------------------------+ - | 22|W |RSTN_FILTER_SET |Write 1 to disable reset of filter unit | - +-----+---+------------------+------------------------------------------------------------+ - | 23|W |RSTN_TIMESTAMP_SET|Write 1 to disable reset of timestamp unit | - +-----+---+------------------+------------------------------------------------------------+ - | 24|W |RSTN_AES0_SET |Write 1 to disable reset of AES0 | - +-----+---+------------------+------------------------------------------------------------+ - | 25|W |RSTN_AES1_SET |Write 1 to disable reset of AES1 | - +-----+---+------------------+------------------------------------------------------------+ - | 26|W |RSTN_SFU_SET |Write 1 to disable reset of SFU interface | - +-----+---+------------------+------------------------------------------------------------+ - | 27|W |RSTN_FFC0_SET |Write 1 to disable reset of fixed/floating point converter 0| - +-----+---+------------------+------------------------------------------------------------+ - | 28|W |RSTN_FFC1_SET |Write 1 to disable reset of fixed/floating point converter 1| - +-----+---+------------------+------------------------------------------------------------+ - | 29|W |RSTN_FFC2_SET |Write 1 to disable reset of fixed/floating point converter 2| - +-----+---+------------------+------------------------------------------------------------+ - | 30|W |RSTN_FFC3_SET |Write 1 to disable reset of fixed/floating point converter 3| - +-----+---+------------------+------------------------------------------------------------+ - -.. _udma_ctrl_CFG_RSTN_CLR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------------+-----+------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+============================================================+ + | 0|W |RSTN_SPI0_SET |0x0 |Write 1 to disable reset of SPI0 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 1|W |RSTN_SPI1_SET |0x0 |Write 1 to disable reset of SPI1 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 2|W |RSTN_SPI2_SET |0x0 |Write 1 to disable reset of SPI2 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 3|W |RSTN_SPI3_SET |0x0 |Write 1 to disable reset of SPI3 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 4|W |RSTN_UART0_SET |0x0 |Write 1 to disable reset of UART0 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 5|W |RSTN_UART1_SET |0x0 |Write 1 to disable reset of UART1 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 6|W |RSTN_UART2_SET |0x0 |Write 1 to disable reset of UART2 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 7|W |RSTN_UART3_SET |0x0 |Write 1 to disable reset of UART3 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 8|W |RSTN_UART4_SET |0x0 |Write 1 to disable reset of UART4 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 9|W |RSTN_I2C0_SET |0x0 |Write 1 to disable reset of I2C0 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 10|W |RSTN_I2C1_SET |0x0 |Write 1 to disable reset of I2C1 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 11|W |RSTN_I2C2_SET |0x0 |Write 1 to disable reset of I2C2 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 12|W |RSTN_I2C3_SET |0x0 |Write 1 to disable reset of I2C3 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 13|W |RSTN_HYPER0_SET |0x0 |Write 1 to disable reset of memory interface 0 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 14|W |RSTN_HYPER1_SET |0x0 |Write 1 to disable reset of memory interface 1 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 15|W |RSTN_JTAG_SET |0x0 |Write 1 to disable reset of JTAG data transfers | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 16|W |RSTN_SAI0_SET |0x0 |Write 1 to disable reset of I2S/SAI0 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 17|W |RSTN_SAI1_SET |0x0 |Write 1 to disable reset of I2S/SAI1 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 18|W |RSTN_SAI2_SET |0x0 |Write 1 to disable reset of I2S/SAI2 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 19|W |RSTN_CPI_SET |0x0 |Write 1 to disable reset of camera parallel interface | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 20|W |RSTN_CSI2_SET |0x0 |Write 1 to disable reset of CSI2 interface | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 21|W |RSTN_MRAM_SET |0x0 |Write 1 to disable reset of MRAM interface | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 22|W |RSTN_FILTER_SET |0x0 |Write 1 to disable reset of filter unit | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 23|W |RSTN_TIMESTAMP_SET|0x0 |Write 1 to disable reset of timestamp unit | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 24|W |RSTN_AES0_SET |0x0 |Write 1 to disable reset of AES0 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 25|W |RSTN_AES1_SET |0x0 |Write 1 to disable reset of AES1 | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 26|W |RSTN_SFU_SET |0x0 |Write 1 to disable reset of SFU interface | + +-----+---+------------------+-----+------------------------------------------------------------+ + | 27|W |RSTN_FFC0_SET |0x0 |Write 1 to disable reset of fixed/floating point converter 0| + +-----+---+------------------+-----+------------------------------------------------------------+ + | 28|W |RSTN_FFC1_SET |0x0 |Write 1 to disable reset of fixed/floating point converter 1| + +-----+---+------------------+-----+------------------------------------------------------------+ + | 29|W |RSTN_FFC2_SET |0x0 |Write 1 to disable reset of fixed/floating point converter 2| + +-----+---+------------------+-----+------------------------------------------------------------+ + | 30|W |RSTN_FFC3_SET |0x0 |Write 1 to disable reset of fixed/floating point converter 3| + +-----+---+------------------+-----+------------------------------------------------------------+ + +.. _udma_ctrl__CFG_RSTN_CLR: CFG_RSTN_CLR """""""""""" @@ -461,74 +476,76 @@ CFG_RSTN_CLR Each bit set to 1 sets the corresponding bit in the CFG_RSTN register .. table:: - - +-----+---+------------------+-------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+=================================================+ - | 0|W |RSTN_SPI0_CLR |Write 1 to reset SPI0 | - +-----+---+------------------+-------------------------------------------------+ - | 1|W |RSTN_SPI1_CLR |Write 1 to reset SPI1 | - +-----+---+------------------+-------------------------------------------------+ - | 2|W |RSTN_SPI2_CLR |Write 1 to reset SPI2 | - +-----+---+------------------+-------------------------------------------------+ - | 3|W |RSTN_SPI3_CLR |Write 1 to reset SPI3 | - +-----+---+------------------+-------------------------------------------------+ - | 4|W |RSTN_UART0_CLR |Write 1 to reset UART0 | - +-----+---+------------------+-------------------------------------------------+ - | 5|W |RSTN_UART1_CLR |Write 1 to reset UART1 | - +-----+---+------------------+-------------------------------------------------+ - | 6|W |RSTN_UART2_CLR |Write 1 to reset UART2 | - +-----+---+------------------+-------------------------------------------------+ - | 7|W |RSTN_UART3_CLR |Write 1 to reset UART3 | - +-----+---+------------------+-------------------------------------------------+ - | 8|W |RSTN_UART4_CLR |Write 1 to reset UART4 | - +-----+---+------------------+-------------------------------------------------+ - | 9|W |RSTN_I2C0_CLR |Write 1 to reset I2C0 | - +-----+---+------------------+-------------------------------------------------+ - | 10|W |RSTN_I2C1_CLR |Write 1 to reset I2C1 | - +-----+---+------------------+-------------------------------------------------+ - | 11|W |RSTN_I2C2_CLR |Write 1 to reset I2C2 | - +-----+---+------------------+-------------------------------------------------+ - | 12|W |RSTN_I2C3_CLR |Write 1 to reset I2C3 | - +-----+---+------------------+-------------------------------------------------+ - | 13|W |RSTN_HYPER0_CLR |Write 1 to reset memory interface 0 | - +-----+---+------------------+-------------------------------------------------+ - | 14|W |RSTN_HYPER1_CLR |Write 1 to reset memory interface 1 | - +-----+---+------------------+-------------------------------------------------+ - | 15|W |RSTN_JTAG_CLR |Write 1 to reset JTAG data transfers | - +-----+---+------------------+-------------------------------------------------+ - | 16|W |RSTN_SAI0_CLR |Write 1 to reset I2S/SAI0 | - +-----+---+------------------+-------------------------------------------------+ - | 17|W |RSTN_SAI1_CLR |Write 1 to reset I2S/SAI1 | - +-----+---+------------------+-------------------------------------------------+ - | 18|W |RSTN_SAI2_CLR |Write 1 to reset I2S/SAI2 | - +-----+---+------------------+-------------------------------------------------+ - | 19|W |RSTN_CPI_CLR |Write 1 to reset camera parallel interface | - +-----+---+------------------+-------------------------------------------------+ - | 20|W |RSTN_CSI2_CLR |Write 1 to reset CSI2 interface | - +-----+---+------------------+-------------------------------------------------+ - | 21|W |RSTN_MRAM_CLR |Write 1 to reset MRAM interface | - +-----+---+------------------+-------------------------------------------------+ - | 22|W |RSTN_FILTER_CLR |Write 1 to reset filter unit | - +-----+---+------------------+-------------------------------------------------+ - | 23|W |RSTN_TIMESTAMP_CLR|Write 1 to reset timestamp unit | - +-----+---+------------------+-------------------------------------------------+ - | 24|W |RSTN_AES0_CLR |Write 1 to reset AES0 | - +-----+---+------------------+-------------------------------------------------+ - | 25|W |RSTN_AES1_CLR |Write 1 to reset AES1 | - +-----+---+------------------+-------------------------------------------------+ - | 26|W |RSTN_SFU_CLR |Write 1 to reset SFU interface | - +-----+---+------------------+-------------------------------------------------+ - | 27|W |RSTN_FFC0_CLR |Write 1 to reset fixed/floating point converter 0| - +-----+---+------------------+-------------------------------------------------+ - | 28|W |RSTN_FFC1_CLR |Write 1 to reset fixed/floating point converter 1| - +-----+---+------------------+-------------------------------------------------+ - | 29|W |RSTN_FFC2_CLR |Write 1 to reset fixed/floating point converter 2| - +-----+---+------------------+-------------------------------------------------+ - | 30|W |RSTN_FFC3_CLR |Write 1 to reset fixed/floating point converter 3| - +-----+---+------------------+-------------------------------------------------+ - -.. _udma_ctrl_CFG_EVENT: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------------+-----+-------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+=================================================+ + | 0|W |RSTN_SPI0_CLR |0x0 |Write 1 to reset SPI0 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 1|W |RSTN_SPI1_CLR |0x0 |Write 1 to reset SPI1 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 2|W |RSTN_SPI2_CLR |0x0 |Write 1 to reset SPI2 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 3|W |RSTN_SPI3_CLR |0x0 |Write 1 to reset SPI3 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 4|W |RSTN_UART0_CLR |0x0 |Write 1 to reset UART0 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 5|W |RSTN_UART1_CLR |0x0 |Write 1 to reset UART1 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 6|W |RSTN_UART2_CLR |0x0 |Write 1 to reset UART2 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 7|W |RSTN_UART3_CLR |0x0 |Write 1 to reset UART3 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 8|W |RSTN_UART4_CLR |0x0 |Write 1 to reset UART4 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 9|W |RSTN_I2C0_CLR |0x0 |Write 1 to reset I2C0 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 10|W |RSTN_I2C1_CLR |0x0 |Write 1 to reset I2C1 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 11|W |RSTN_I2C2_CLR |0x0 |Write 1 to reset I2C2 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 12|W |RSTN_I2C3_CLR |0x0 |Write 1 to reset I2C3 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 13|W |RSTN_HYPER0_CLR |0x0 |Write 1 to reset memory interface 0 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 14|W |RSTN_HYPER1_CLR |0x0 |Write 1 to reset memory interface 1 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 15|W |RSTN_JTAG_CLR |0x0 |Write 1 to reset JTAG data transfers | + +-----+---+------------------+-----+-------------------------------------------------+ + | 16|W |RSTN_SAI0_CLR |0x0 |Write 1 to reset I2S/SAI0 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 17|W |RSTN_SAI1_CLR |0x0 |Write 1 to reset I2S/SAI1 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 18|W |RSTN_SAI2_CLR |0x0 |Write 1 to reset I2S/SAI2 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 19|W |RSTN_CPI_CLR |0x0 |Write 1 to reset camera parallel interface | + +-----+---+------------------+-----+-------------------------------------------------+ + | 20|W |RSTN_CSI2_CLR |0x0 |Write 1 to reset CSI2 interface | + +-----+---+------------------+-----+-------------------------------------------------+ + | 21|W |RSTN_MRAM_CLR |0x0 |Write 1 to reset MRAM interface | + +-----+---+------------------+-----+-------------------------------------------------+ + | 22|W |RSTN_FILTER_CLR |0x0 |Write 1 to reset filter unit | + +-----+---+------------------+-----+-------------------------------------------------+ + | 23|W |RSTN_TIMESTAMP_CLR|0x0 |Write 1 to reset timestamp unit | + +-----+---+------------------+-----+-------------------------------------------------+ + | 24|W |RSTN_AES0_CLR |0x0 |Write 1 to reset AES0 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 25|W |RSTN_AES1_CLR |0x0 |Write 1 to reset AES1 | + +-----+---+------------------+-----+-------------------------------------------------+ + | 26|W |RSTN_SFU_CLR |0x0 |Write 1 to reset SFU interface | + +-----+---+------------------+-----+-------------------------------------------------+ + | 27|W |RSTN_FFC0_CLR |0x0 |Write 1 to reset fixed/floating point converter 0| + +-----+---+------------------+-----+-------------------------------------------------+ + | 28|W |RSTN_FFC1_CLR |0x0 |Write 1 to reset fixed/floating point converter 1| + +-----+---+------------------+-----+-------------------------------------------------+ + | 29|W |RSTN_FFC2_CLR |0x0 |Write 1 to reset fixed/floating point converter 2| + +-----+---+------------------+-----+-------------------------------------------------+ + | 30|W |RSTN_FFC3_CLR |0x0 |Write 1 to reset fixed/floating point converter 3| + +-----+---+------------------+-----+-------------------------------------------------+ + +.. _udma_ctrl__CFG_EVENT: CFG_EVENT """"""""" @@ -536,20 +553,22 @@ CFG_EVENT uDMA peripherals external event configuration .. table:: - - +-----+---+--------+-------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+=============+ - |7:0 |R/W|CMP_EVT0|Compare event| - +-----+---+--------+-------------+ - |15:8 |R/W|CMP_EVT1|Compare event| - +-----+---+--------+-------------+ - |23:16|R/W|CMP_EVT2|Compare event| - +-----+---+--------+-------------+ - |31:24|R/W|CMP_EVT3|Compare event| - +-----+---+--------+-------------+ - -.. _udma_ctrl_FIFO_CFG: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------+-----+-------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=============+ + |7:0 |R/W|CMP_EVT0|0x0 |Compare event| + +-----+---+--------+-----+-------------+ + |15:8 |R/W|CMP_EVT1|0x0 |Compare event| + +-----+---+--------+-----+-------------+ + |23:16|R/W|CMP_EVT2|0x0 |Compare event| + +-----+---+--------+-----+-------------+ + |31:24|R/W|CMP_EVT3|0x0 |Compare event| + +-----+---+--------+-----+-------------+ + +.. _udma_ctrl__FIFO_CFG: FIFO_CFG """""""" @@ -557,76 +576,86 @@ FIFO_CFG Set FIFO ID for push and pop .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+---------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+=================================+ - |7:0 |R/W|PUSH_ID|Sets the FIFO ID used for pushing| - +-----+---+-------+---------------------------------+ - |15:8 |R/W|POP_ID |Sets the FIFO ID used for popping| - +-----+---+-------+---------------------------------+ + +-----+---+-------+-----+---------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=================================+ + |7:0 |R/W|PUSH_ID|0xFF |Sets the FIFO ID used for pushing| + +-----+---+-------+-----+---------------------------------+ + |15:8 |R/W|POP_ID |0xFF |Sets the FIFO ID used for popping| + +-----+---+-------+-----+---------------------------------+ -.. _udma_ctrl_FIFO_PUSHPOP_8: +.. _udma_ctrl__FIFO_PUSHPOP_8: FIFO_PUSHPOP_8 """""""""""""" -Pushe (write) and pop (read) 8bit to/from the FIFO +Push (write) and pop (read) 8-bit word to/from the FIFO .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=================================================================================+ - |7:0 |R/W|DATA|A write pushes an 8-bit data to the FIFO, a read pops an 8-bit data from the FIFO| - +-----+---+----+---------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=================================================================================+ + |7:0 |R/W|DATA|0x00 |A write pushes an 8-bit data to the FIFO, a read pops an 8-bit data from the FIFO| + +-----+---+----+-----+---------------------------------------------------------------------------------+ -.. _udma_ctrl_FIFO_PUSHPOP_16: +.. _udma_ctrl__FIFO_PUSHPOP_16: FIFO_PUSHPOP_16 """"""""""""""" -Pushe (write) and pop (read) 16bit to/from the FIFO +Push (write) and pop (read) 16-bit word to/from the FIFO .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=================================================================================+ - |15:0 |R/W|DATA|A write pushes a 16-bit data to the FIFO, a read pops a 16-bit data from the FIFO| - +-----+---+----+---------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=================================================================================+ + |15:0 |R/W|DATA|0x00 |A write pushes a 16-bit data to the FIFO, a read pops a 16-bit data from the FIFO| + +-----+---+----+-----+---------------------------------------------------------------------------------+ -.. _udma_ctrl_FIFO_PUSHPOP_24: +.. _udma_ctrl__FIFO_PUSHPOP_24: FIFO_PUSHPOP_24 """"""""""""""" -Pushe (write) and pop (read) 24bit to/from the FIFO +Push (write) and pop (read) 24-bit word to/from the FIFO .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=================================================================================+ - |23:0 |R/W|DATA|A write pushes a 24-bit data to the FIFO, a read pops a 24-bit data from the FIFO| - +-----+---+----+---------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=================================================================================+ + |23:0 |R/W|DATA|0x00 |A write pushes a 24-bit data to the FIFO, a read pops a 24-bit data from the FIFO| + +-----+---+----+-----+---------------------------------------------------------------------------------+ -.. _udma_ctrl_FIFO_PUSHPOP_32: +.. _udma_ctrl__FIFO_PUSHPOP_32: FIFO_PUSHPOP_32 """"""""""""""" -Pushe (write) and pop (read) 32bit to/from the FIFO +Push (write) and pop (read) 32-bit word to/from the FIFO .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=================================================================================+ - |31:0 |R/W|DATA|A write pushes a 32-bit data to the FIFO, a read pops a 32-bit data from the FIFO| - +-----+---+----+---------------------------------------------------------------------------------+ + +-----+---+----+-----+---------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=================================================================================+ + |31:0 |R/W|DATA|0x00 |A write pushes a 32-bit data to the FIFO, a read pops a 32-bit data from the FIFO| + +-----+---+----+-----+---------------------------------------------------------------------------------+ -.. _udma_ctrl_DATAMOVE_CFG: +.. _udma_ctrl__DATAMOVE_CFG: DATAMOVE_CFG """""""""""" @@ -634,20 +663,22 @@ DATAMOVE_CFG Configure data movement .. table:: - - +-----+---+-----------+----------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+==============================================+ - |7:0 |R/W|SOURCE_ID_0|Sets the source ID used by the data mover | - +-----+---+-----------+----------------------------------------------+ - |15:8 |R/W|DEST_ID_0 |Sets the destination ID used by the data mover| - +-----+---+-----------+----------------------------------------------+ - |23:16|R/W|SOURCE_ID_1|Sets the source ID used by the data mover | - +-----+---+-----------+----------------------------------------------+ - |31:24|R/W|DEST_ID_1 |Sets the destination ID used by the data mover| - +-----+---+-----------+----------------------------------------------+ - -.. _udma_ctrl_DATAMOVE0_SIZE: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------+-----+----------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+==============================================+ + |7:0 |R/W|SOURCE_ID_0|0xFF |Sets the source ID used by the data mover | + +-----+---+-----------+-----+----------------------------------------------+ + |15:8 |R/W|DEST_ID_0 |0xFF |Sets the destination ID used by the data mover| + +-----+---+-----------+-----+----------------------------------------------+ + |23:16|R/W|SOURCE_ID_1|0xFF |Sets the source ID used by the data mover | + +-----+---+-----------+-----+----------------------------------------------+ + |31:24|R/W|DEST_ID_1 |0xFF |Sets the destination ID used by the data mover| + +-----+---+-----------+-----+----------------------------------------------+ + +.. _udma_ctrl__DATAMOVE0_SIZE: DATAMOVE0_SIZE """""""""""""" @@ -655,18 +686,20 @@ DATAMOVE0_SIZE Control of mover channel 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+----------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==============================================================================================+ - |20:0 |R/W|SIZE|Write sets the number of bytes to be moved. Read returns the number of bytes remaining | - +-----+---+----+----------------------------------------------------------------------------------------------+ - |30 |R/W|STOP|When written to 1 stops the data mover. When read return the enable status of the data mover | - +-----+---+----+----------------------------------------------------------------------------------------------+ - |31 |R/W|EN |When written to 1 enables the data mover. When read return the enable status of the data mover| - +-----+---+----+----------------------------------------------------------------------------------------------+ + +-----+---+----+-----+----------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================================================================+ + |20:0 |R/W|SIZE|0x0 |Write sets the number of bytes to be moved. Read returns the number of bytes remaining | + +-----+---+----+-----+----------------------------------------------------------------------------------------------+ + |30 |R/W|STOP|0x0 |When written to 1 stops the data mover. When read return the enable status of the data mover | + +-----+---+----+-----+----------------------------------------------------------------------------------------------+ + |31 |R/W|EN |0x0 |When written to 1 enables the data mover. When read return the enable status of the data mover| + +-----+---+----+-----+----------------------------------------------------------------------------------------------+ -.. _udma_ctrl_DATAMOVE1_SIZE: +.. _udma_ctrl__DATAMOVE1_SIZE: DATAMOVE1_SIZE """""""""""""" @@ -674,18 +707,20 @@ DATAMOVE1_SIZE Control of mover channel 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+----------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==============================================================================================+ - |20:0 |R/W|SIZE|Write sets the number of bytes to be moved. Read returns the number of bytes remaining | - +-----+---+----+----------------------------------------------------------------------------------------------+ - |30 |R/W|STOP|When written to 1 stops the data mover. When read return the enable status of the data mover | - +-----+---+----+----------------------------------------------------------------------------------------------+ - |31 |R/W|EN |When written to 1 enables the data mover. When read return the enable status of the data mover| - +-----+---+----+----------------------------------------------------------------------------------------------+ + +-----+---+----+-----+----------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================================================================+ + |20:0 |R/W|SIZE|0x0 |Write sets the number of bytes to be moved. Read returns the number of bytes remaining | + +-----+---+----+-----+----------------------------------------------------------------------------------------------+ + |30 |R/W|STOP|0x0 |When written to 1 stops the data mover. When read return the enable status of the data mover | + +-----+---+----+-----+----------------------------------------------------------------------------------------------+ + |31 |R/W|EN |0x0 |When written to 1 enables the data mover. When read return the enable status of the data mover| + +-----+---+----+-----+----------------------------------------------------------------------------------------------+ -.. _udma_ctrl_STREAM_CFG: +.. _udma_ctrl__STREAM_CFG: STREAM_CFG """""""""" @@ -693,44 +728,46 @@ STREAM_CFG Configure blocking behavior of streams .. table:: - - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+==========================================================================================================+ - | 0|R/W|BLK_STREAM0 |Blocking state for stream 0: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM1 |Blocking state for stream 1: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM2 |Blocking state for stream 2: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM3 |Blocking state for stream 3: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM4 |Blocking state for stream 4: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM5 |Blocking state for stream 5: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM6 |Blocking state for stream 6: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM7 |Blocking state for stream 7: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM8 |Blocking state for stream 8: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM9 |Blocking state for stream 9: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM10|Blocking state for stream 10: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available| - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM11|Blocking state for stream 11: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available| - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM12|Blocking state for stream 12: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available| - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM13|Blocking state for stream 13: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available| - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM14|Blocking state for stream 14: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available| - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - | 0|R/W|BLK_STREAM15|Blocking state for stream 15: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available| - +-----+---+------------+----------------------------------------------------------------------------------------------------------+ - -.. _udma_ctrl_TIMEOUT_PRE0: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+==========================================================================================================+ + | 0|R/W|BLK_STREAM0 |0x0 |Blocking state for stream 0: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM1 |0x0 |Blocking state for stream 1: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM2 |0x0 |Blocking state for stream 2: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM3 |0x0 |Blocking state for stream 3: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM4 |0x0 |Blocking state for stream 4: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM5 |0x0 |Blocking state for stream 5: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM6 |0x0 |Blocking state for stream 6: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM7 |0x0 |Blocking state for stream 7: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM8 |0x0 |Blocking state for stream 8: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM9 |0x0 |Blocking state for stream 9: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available | + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM10|0x0 |Blocking state for stream 10: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM11|0x0 |Blocking state for stream 11: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM12|0x0 |Blocking state for stream 12: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM13|0x0 |Blocking state for stream 13: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM14|0x0 |Blocking state for stream 14: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + | 0|R/W|BLK_STREAM15|0x0 |Blocking state for stream 15: 0: non blocking, 1: blocking, i.e. "ready" asserted only when data available| + +-----+---+------------+-----+----------------------------------------------------------------------------------------------------------+ + +.. _udma_ctrl__TIMEOUT_PRE0: TIMEOUT_PRE0 """""""""""" @@ -738,18 +775,20 @@ TIMEOUT_PRE0 Configuration of the frequency prescaler for timeout ch0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============================================================+ - |15:0 |R/W|CNT |Set the target for the timeout counter | - +-----+---+----+-------------------------------------------------------------+ - |16 |R/W|EN |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| - +-----+---+----+-------------------------------------------------------------+ - |17 |W |CLR |Reset the timeout prescaler to 0 | - +-----+---+----+-------------------------------------------------------------+ + +-----+---+----+-----+-------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================+ + |15:0 |R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+----+-----+-------------------------------------------------------------+ + |16 |R/W|EN |0x0 |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| + +-----+---+----+-----+-------------------------------------------------------------+ + |17 |W |CLR |0x0 |Reset the timeout prescaler to 0 | + +-----+---+----+-----+-------------------------------------------------------------+ -.. _udma_ctrl_TIMEOUT_CH0: +.. _udma_ctrl__TIMEOUT_CH0: TIMEOUT_CH0 """"""""""" @@ -757,20 +796,22 @@ TIMEOUT_CH0 Configuration for timeout ch0 .. table:: - - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================================================================================================================================================+ - |7:0 |R/W|SOURCE_ID|Set the uDMA source ID used by the timeout | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |9:8 |R/W|MODE |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10 |R/W|EN |Enable/disable the timeout: 0: disabled, 1: enabled | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:16|R/W|CNT |Set the target for the timeout counter | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_ctrl_TIMEOUT_PRE1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==========================================================================================================================================================================+ + |7:0 |R/W|SOURCE_ID|0x0 |Set the uDMA source ID used by the timeout | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |9:8 |R/W|MODE |0x0 |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10 |R/W|EN |0x0 |Enable/disable the timeout: 0: disabled, 1: enabled | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:16|R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_ctrl__TIMEOUT_PRE1: TIMEOUT_PRE1 """""""""""" @@ -778,18 +819,20 @@ TIMEOUT_PRE1 Configuration of the frequency prescaler for timeout ch1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============================================================+ - |15:0 |R/W|CNT |Set the target for the timeout counter | - +-----+---+----+-------------------------------------------------------------+ - |16 |R/W|EN |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| - +-----+---+----+-------------------------------------------------------------+ - |17 |W |CLR |Reset the timeout prescaler to 0 | - +-----+---+----+-------------------------------------------------------------+ + +-----+---+----+-----+-------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================+ + |15:0 |R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+----+-----+-------------------------------------------------------------+ + |16 |R/W|EN |0x0 |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| + +-----+---+----+-----+-------------------------------------------------------------+ + |17 |W |CLR |0x0 |Reset the timeout prescaler to 0 | + +-----+---+----+-----+-------------------------------------------------------------+ -.. _udma_ctrl_TIMEOUT_CH1: +.. _udma_ctrl__TIMEOUT_CH1: TIMEOUT_CH1 """"""""""" @@ -797,20 +840,22 @@ TIMEOUT_CH1 Configuration for timeout ch1 .. table:: - - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================================================================================================================================================+ - |7:0 |R/W|SOURCE_ID|Set the uDMA source ID used by the timeout | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |9:8 |R/W|MODE |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10 |R/W|EN |Enable/disable the timeout: 0: disabled, 1: enabled | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:16|R/W|CNT |Set the target for the timeout counter | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_ctrl_TIMEOUT_PRE2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==========================================================================================================================================================================+ + |7:0 |R/W|SOURCE_ID|0x0 |Set the uDMA source ID used by the timeout | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |9:8 |R/W|MODE |0x0 |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10 |R/W|EN |0x0 |Enable/disable the timeout: 0: disabled, 1: enabled | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:16|R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_ctrl__TIMEOUT_PRE2: TIMEOUT_PRE2 """""""""""" @@ -818,18 +863,20 @@ TIMEOUT_PRE2 Configuration of the frequency prescaler for timeout ch2 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============================================================+ - |15:0 |R/W|CNT |Set the target for the timeout counter | - +-----+---+----+-------------------------------------------------------------+ - |16 |R/W|EN |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| - +-----+---+----+-------------------------------------------------------------+ - |17 |W |CLR |Reset the timeout prescaler to 0 | - +-----+---+----+-------------------------------------------------------------+ + +-----+---+----+-----+-------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================+ + |15:0 |R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+----+-----+-------------------------------------------------------------+ + |16 |R/W|EN |0x0 |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| + +-----+---+----+-----+-------------------------------------------------------------+ + |17 |W |CLR |0x0 |Reset the timeout prescaler to 0 | + +-----+---+----+-----+-------------------------------------------------------------+ -.. _udma_ctrl_TIMEOUT_CH2: +.. _udma_ctrl__TIMEOUT_CH2: TIMEOUT_CH2 """"""""""" @@ -837,20 +884,22 @@ TIMEOUT_CH2 Configuration for timeout ch2 .. table:: - - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================================================================================================================================================+ - |7:0 |R/W|SOURCE_ID|Set the uDMA source ID used by the timeout | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |9:8 |R/W|MODE |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10 |R/W|EN |Enable/disable the timeout: 0: disabled, 1: enabled | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:16|R/W|CNT |Set the target for the timeout counter | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_ctrl_TIMEOUT_PRE3: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==========================================================================================================================================================================+ + |7:0 |R/W|SOURCE_ID|0x0 |Set the uDMA source ID used by the timeout | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |9:8 |R/W|MODE |0x0 |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10 |R/W|EN |0x0 |Enable/disable the timeout: 0: disabled, 1: enabled | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:16|R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_ctrl__TIMEOUT_PRE3: TIMEOUT_PRE3 """""""""""" @@ -858,18 +907,20 @@ TIMEOUT_PRE3 Configuration of the frequency prescaler for timeout ch3 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============================================================+ - |15:0 |R/W|CNT |Set the target for the timeout counter | - +-----+---+----+-------------------------------------------------------------+ - |16 |R/W|EN |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| - +-----+---+----+-------------------------------------------------------------+ - |17 |W |CLR |Reset the timeout prescaler to 0 | - +-----+---+----+-------------------------------------------------------------+ + +-----+---+----+-----+-------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================+ + |15:0 |R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+----+-----+-------------------------------------------------------------+ + |16 |R/W|EN |0x0 |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| + +-----+---+----+-----+-------------------------------------------------------------+ + |17 |W |CLR |0x0 |Reset the timeout prescaler to 0 | + +-----+---+----+-----+-------------------------------------------------------------+ -.. _udma_ctrl_TIMEOUT_CH3: +.. _udma_ctrl__TIMEOUT_CH3: TIMEOUT_CH3 """"""""""" @@ -877,20 +928,22 @@ TIMEOUT_CH3 Configuration for timeout ch3 .. table:: - - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================================================================================================================================================+ - |7:0 |R/W|SOURCE_ID|Set the uDMA source ID used by the timeout | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |9:8 |R/W|MODE |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10 |R/W|EN |Enable/disable the timeout: 0: disabled, 1: enabled | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:16|R/W|CNT |Set the target for the timeout counter | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_ctrl_TIMEOUT_PRE4: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==========================================================================================================================================================================+ + |7:0 |R/W|SOURCE_ID|0x0 |Set the uDMA source ID used by the timeout | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |9:8 |R/W|MODE |0x0 |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10 |R/W|EN |0x0 |Enable/disable the timeout: 0: disabled, 1: enabled | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:16|R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_ctrl__TIMEOUT_PRE4: TIMEOUT_PRE4 """""""""""" @@ -898,18 +951,20 @@ TIMEOUT_PRE4 Configuration of the frequency prescaler for timeout ch4 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============================================================+ - |15:0 |R/W|CNT |Set the target for the timeout counter | - +-----+---+----+-------------------------------------------------------------+ - |16 |R/W|EN |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| - +-----+---+----+-------------------------------------------------------------+ - |17 |W |CLR |Reset the timeout prescaler to 0 | - +-----+---+----+-------------------------------------------------------------+ + +-----+---+----+-----+-------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================+ + |15:0 |R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+----+-----+-------------------------------------------------------------+ + |16 |R/W|EN |0x0 |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| + +-----+---+----+-----+-------------------------------------------------------------+ + |17 |W |CLR |0x0 |Reset the timeout prescaler to 0 | + +-----+---+----+-----+-------------------------------------------------------------+ -.. _udma_ctrl_TIMEOUT_CH4: +.. _udma_ctrl__TIMEOUT_CH4: TIMEOUT_CH4 """"""""""" @@ -917,20 +972,22 @@ TIMEOUT_CH4 Configuration for timeout ch4 .. table:: - - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================================================================================================================================================+ - |7:0 |R/W|SOURCE_ID|Set the uDMA source ID used by the timeout | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |9:8 |R/W|MODE |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10 |R/W|EN |Enable/disable the timeout: 0: disabled, 1: enabled | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:16|R/W|CNT |Set the target for the timeout counter | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_ctrl_TIMEOUT_PRE5: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==========================================================================================================================================================================+ + |7:0 |R/W|SOURCE_ID|0x0 |Set the uDMA source ID used by the timeout | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |9:8 |R/W|MODE |0x0 |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10 |R/W|EN |0x0 |Enable/disable the timeout: 0: disabled, 1: enabled | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:16|R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_ctrl__TIMEOUT_PRE5: TIMEOUT_PRE5 """""""""""" @@ -938,18 +995,20 @@ TIMEOUT_PRE5 Configuration of the frequency prescaler for timeout ch5 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============================================================+ - |15:0 |R/W|CNT |Set the target for the timeout counter | - +-----+---+----+-------------------------------------------------------------+ - |16 |R/W|EN |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| - +-----+---+----+-------------------------------------------------------------+ - |17 |W |CLR |Reset the timeout prescaler to 0 | - +-----+---+----+-------------------------------------------------------------+ + +-----+---+----+-----+-------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================+ + |15:0 |R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+----+-----+-------------------------------------------------------------+ + |16 |R/W|EN |0x0 |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| + +-----+---+----+-----+-------------------------------------------------------------+ + |17 |W |CLR |0x0 |Reset the timeout prescaler to 0 | + +-----+---+----+-----+-------------------------------------------------------------+ -.. _udma_ctrl_TIMEOUT_CH5: +.. _udma_ctrl__TIMEOUT_CH5: TIMEOUT_CH5 """"""""""" @@ -957,20 +1016,22 @@ TIMEOUT_CH5 Configuration for timeout ch5 .. table:: - - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================================================================================================================================================+ - |7:0 |R/W|SOURCE_ID|Set the uDMA source ID used by the timeout | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |9:8 |R/W|MODE |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10 |R/W|EN |Enable/disable the timeout: 0: disabled, 1: enabled | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:16|R/W|CNT |Set the target for the timeout counter | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_ctrl_TIMEOUT_PRE6: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==========================================================================================================================================================================+ + |7:0 |R/W|SOURCE_ID|0x0 |Set the uDMA source ID used by the timeout | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |9:8 |R/W|MODE |0x0 |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10 |R/W|EN |0x0 |Enable/disable the timeout: 0: disabled, 1: enabled | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:16|R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_ctrl__TIMEOUT_PRE6: TIMEOUT_PRE6 """""""""""" @@ -978,18 +1039,20 @@ TIMEOUT_PRE6 Configuration of the frequency prescaler for timeout ch6 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============================================================+ - |15:0 |R/W|CNT |Set the target for the timeout counter | - +-----+---+----+-------------------------------------------------------------+ - |16 |R/W|EN |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| - +-----+---+----+-------------------------------------------------------------+ - |17 |W |CLR |Reset the timeout prescaler to 0 | - +-----+---+----+-------------------------------------------------------------+ + +-----+---+----+-----+-------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================+ + |15:0 |R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+----+-----+-------------------------------------------------------------+ + |16 |R/W|EN |0x0 |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| + +-----+---+----+-----+-------------------------------------------------------------+ + |17 |W |CLR |0x0 |Reset the timeout prescaler to 0 | + +-----+---+----+-----+-------------------------------------------------------------+ -.. _udma_ctrl_TIMEOUT_CH6: +.. _udma_ctrl__TIMEOUT_CH6: TIMEOUT_CH6 """"""""""" @@ -997,20 +1060,22 @@ TIMEOUT_CH6 Configuration for timeout ch6 .. table:: - - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================================================================================================================================================+ - |7:0 |R/W|SOURCE_ID|Set the uDMA source ID used by the timeout | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |9:8 |R/W|MODE |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10 |R/W|EN |Enable/disable the timeout: 0: disabled, 1: enabled | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:16|R/W|CNT |Set the target for the timeout counter | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_ctrl_TIMEOUT_PRE7: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==========================================================================================================================================================================+ + |7:0 |R/W|SOURCE_ID|0x0 |Set the uDMA source ID used by the timeout | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |9:8 |R/W|MODE |0x0 |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10 |R/W|EN |0x0 |Enable/disable the timeout: 0: disabled, 1: enabled | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:16|R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_ctrl__TIMEOUT_PRE7: TIMEOUT_PRE7 """""""""""" @@ -1018,18 +1083,20 @@ TIMEOUT_PRE7 Configuration of the frequency prescaler for timeout ch7 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============================================================+ - |15:0 |R/W|CNT |Set the target for the timeout counter | - +-----+---+----+-------------------------------------------------------------+ - |16 |R/W|EN |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| - +-----+---+----+-------------------------------------------------------------+ - |17 |W |CLR |Reset the timeout prescaler to 0 | - +-----+---+----+-------------------------------------------------------------+ + +-----+---+----+-----+-------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============================================================+ + |15:0 |R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+----+-----+-------------------------------------------------------------+ + |16 |R/W|EN |0x0 |Enable/disable the timeout prescaler: 0: disabled, 1: enabled| + +-----+---+----+-----+-------------------------------------------------------------+ + |17 |W |CLR |0x0 |Reset the timeout prescaler to 0 | + +-----+---+----+-----+-------------------------------------------------------------+ -.. _udma_ctrl_TIMEOUT_CH7: +.. _udma_ctrl__TIMEOUT_CH7: TIMEOUT_CH7 """"""""""" @@ -1037,15 +1104,17 @@ TIMEOUT_CH7 Configuration for timeout ch7 .. table:: - - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==========================================================================================================================================================================+ - |7:0 |R/W|SOURCE_ID|Set the uDMA source ID used by the timeout | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |9:8 |R/W|MODE |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |10 |R/W|EN |Enable/disable the timeout: 0: disabled, 1: enabled | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:16|R/W|CNT |Set the target for the timeout counter | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==========================================================================================================================================================================+ + |7:0 |R/W|SOURCE_ID|0x0 |Set the uDMA source ID used by the timeout | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |9:8 |R/W|MODE |0x0 |Set the mode to start/stop the timeout: b00: software triggered, b01: started by start of transfer and stopped by end of transfer, b10: counter cleared at each data RX/TX| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |10 |R/W|EN |0x0 |Enable/disable the timeout: 0: disabled, 1: enabled | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:16|R/W|CNT |0x0 |Set the target for the timeout counter | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_ffc.rst b/rtos/pulp/gap_archi/doc/ips/udma_ffc.rst index ee7ea3527..b906b774d 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_ffc.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_ffc.rst @@ -1,4 +1,5 @@ -Input file: fe/ips/udma/udma_ffc/README.md +.. + Input file: fe/ips/udma/udma_ffc/README.md Register map ^^^^^^^^^^^^ @@ -7,198 +8,235 @@ Register map Overview """""""" -.. table:: - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +==========================================+======+=====+==================================================================================+ - |:ref:`RX_DEST` | 0| 32|Stream ID for the uDMA channel | - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - |:ref:`TX_DEST` | 4| 32|Stream ID for the uDMA channel | - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - |:ref:`FL_FORMAT` | 8| 32|Floating point format - 2'b00 : FP16 - 2'b01 : BFP16- 2'b10, 2'b11 : FP32 | - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - |:ref:`FP_FORMAT` | 12| 32|Fix point format - 2'b00 : 8bits - 2'b01 :16bits - 2'b10 : 24bits - 2'b11 : 32bits| - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - |:ref:`FP_PREC` | 16| 32|Fix point precision, must less than fix point size | - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - |:ref:`FP_SCALE` | 20| 32|Fix point scale, signed number, FL * 2^scale | - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - |:ref:`MODE` | 24| 32|Direction and IO mode configuration | - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - |:ref:`TRANS_MODE` | 28| 32|Use auto tranfer or not | - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - |:ref:`CONV_NUM` | 32| 32|Convertion data number | - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - |:ref:`CONV_TX_ADDR`| 36| 32|Only use when auto mode is set, convertion data tx channel read from l2 address | - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - |:ref:`CONV_RX_ADDR`| 40| 32|Only use when auto mode is set, convertion data tx channel read from l2 address | - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - |:ref:`IRQ_EN` | 44| 32|Enable or disable transfer interrupt | - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - |:ref:`STATUS` | 48| 32|Show if the transfer is finished or not | - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - |:ref:`START` | 52| 32|Start transition | - +------------------------------------------+------+-----+----------------------------------------------------------------------------------+ - -.. _udma_ffc_RX_DEST: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-------------------------------------------+------+-----+----------------------------------------------+ + | Name |Offset|Width| Description | + +===========================================+======+=====+==============================================+ + |:ref:`RX_DEST` | 0| 32|Stream ID for the uDMA RX channel | + +-------------------------------------------+------+-----+----------------------------------------------+ + |:ref:`TX_DEST` | 4| 32|Stream ID for the uDMA TX channel | + +-------------------------------------------+------+-----+----------------------------------------------+ + |:ref:`FL_FORMAT` | 8| 32|Floating point format | + +-------------------------------------------+------+-----+----------------------------------------------+ + |:ref:`FP_FORMAT` | 12| 32|Fixed point format | + +-------------------------------------------+------+-----+----------------------------------------------+ + |:ref:`FP_PREC` | 16| 32|Fixed point precision | + +-------------------------------------------+------+-----+----------------------------------------------+ + |:ref:`FP_SCALE` | 20| 32|Fixed point scale | + +-------------------------------------------+------+-----+----------------------------------------------+ + |:ref:`MODE` | 24| 32|Direction and I/O mode configuration | + +-------------------------------------------+------+-----+----------------------------------------------+ + |:ref:`TRANS_MODE` | 28| 32|Use auto transfer or not | + +-------------------------------------------+------+-----+----------------------------------------------+ + |:ref:`CONV_NUM` | 32| 32|Number of conversions to be done | + +-------------------------------------------+------+-----+----------------------------------------------+ + |:ref:`CONV_TX_ADDR`| 36| 32|TX channel address in L2 when auto mode is set| + +-------------------------------------------+------+-----+----------------------------------------------+ + |:ref:`CONV_RX_ADDR`| 40| 32|RX channel address in L2 when auto mode is set| + +-------------------------------------------+------+-----+----------------------------------------------+ + |:ref:`IRQ_EN` | 44| 32|Enable or disable transfer interrupt | + +-------------------------------------------+------+-----+----------------------------------------------+ + |:ref:`STATUS` | 48| 32|Show if the transfer is finished or not | + +-------------------------------------------+------+-----+----------------------------------------------+ + |:ref:`START` | 52| 32|Start processing | + +-------------------------------------------+------+-----+----------------------------------------------+ + +.. _udma_ffc__RX_DEST: RX_DEST """"""" -Stream ID for the uDMA channel +Stream ID for the uDMA RX channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-----------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=============================+ + |7:0 |R/W|ID_RX|0xFF |UDMA stream ID for RX channel| + +-----+---+-----+-----+-----------------------------+ -.. _udma_ffc_TX_DEST: +.. _udma_ffc__TX_DEST: TX_DEST """"""" -Stream ID for the uDMA channel +Stream ID for the uDMA TX channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-----------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=============================+ + |7:0 |R/W|ID_TX|0xFF |UDMA stream ID for TX channel| + +-----+---+-----+-----+-----------------------------+ -.. _udma_ffc_FL_FORMAT: +.. _udma_ffc__FL_FORMAT: FL_FORMAT """"""""" -Floating point format - 2'b00 : FP16 - 2'b01 : BFP16- 2'b10, 2'b11 : FP32 +Floating point format .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+-----------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+===========================================================+ + |1:0 |R/W|FORMAT|0x0 |Floating point format: b00: FP16; b01: BFP16; b10-b11: FP32| + +-----+---+------+-----+-----------------------------------------------------------+ -.. _udma_ffc_FP_FORMAT: +.. _udma_ffc__FP_FORMAT: FP_FORMAT """"""""" -Fix point format - 2'b00 : 8bits - 2'b01 :16bits - 2'b10 : 24bits - 2'b11 : 32bits +Fixed point format .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+========================================================================+ + |1:0 |R/W|FORMAT|0x0 |Fixed point format: b00: 8 bits; b01: 16 bits; b10: 24 bits; b11: 32bits| + +-----+---+------+-----+------------------------------------------------------------------------+ -.. _udma_ffc_FP_PREC: +.. _udma_ffc__FP_PREC: FP_PREC """"""" -Fix point precision, must less than fix point size +Fixed point precision .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+---------+-----+----------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+================================================================+ + |4:0 |R/W|PRECISION|0x0 |Precision of fixed point format (cannot exceed fixed point size)| + +-----+---+---------+-----+----------------------------------------------------------------+ -.. _udma_ffc_FP_SCALE: +.. _udma_ffc__FP_SCALE: FP_SCALE """""""" -Fix point scale, signed number, FL * 2^scale +Fixed point scale .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+--------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+========================================================================================================+ + |15:0 |R/W|SCALE|0x0 |Fixed point scale (signed number): data are multiplied by :math:`2^{scale}̀` to compute their real value| + +-----+---+-----+-----+--------------------------------------------------------------------------------------------------------+ -.. _udma_ffc_MODE: +.. _udma_ffc__MODE: MODE """" -Direction and IO mode configuration +Direction and I/O mode configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+--------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================+ - | 0|R/W|DIRECTION|0: Float to fix, 1:Fix to float | - +-----+---+---------+--------------------------------------------------+ - |2:1 |R/W|IO_MODE |2'b00: MIMO, 2'b01: SIMO, 2'b10: MISO, 2'b11: SISO| - +-----+---+---------+--------------------------------------------------+ + +-----+---+---------+-----+------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==================================================================+ + | 0|R/W|DIRECTION|0x0 |0: Floating point to fixed point; 1: Fixed point to floating point| + +-----+---+---------+-----+------------------------------------------------------------------+ + |2:1 |R/W|IO_MODE |0x0 |b00: MIMO; b01: SIMO; b10: MISO; b11: SISO | + +-----+---+---------+-----+------------------------------------------------------------------+ -.. _udma_ffc_TRANS_MODE: +.. _udma_ffc__TRANS_MODE: TRANS_MODE """""""""" -Use auto tranfer or not +Use auto transfer or not .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+--------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+================================+ + | 0|R/W|AUTO_EN|0x0 |Set to 1 to enable auto transfer| + +-----+---+-------+-----+--------------------------------+ -.. _udma_ffc_CONV_NUM: +.. _udma_ffc__CONV_NUM: CONV_NUM """""""" -Convertion data number +Number of conversions to be done .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+--------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+================================+ + |31:0 |R/W|NUM |0x0 |Number of conversions to be done| + +-----+---+----+-----+--------------------------------+ -.. _udma_ffc_CONV_TX_ADDR: +.. _udma_ffc__CONV_TX_ADDR: CONV_TX_ADDR """""""""""" -Only use when auto mode is set, convertion data tx channel read from l2 address +TX channel address in L2 when auto mode is set .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+----------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+====================================================+ + |31:0 |R/W|ADDRESS|0x0 |In auto mode, gives the address in L2 for TX channel| + +-----+---+-------+-----+----------------------------------------------------+ -.. _udma_ffc_CONV_RX_ADDR: +.. _udma_ffc__CONV_RX_ADDR: CONV_RX_ADDR """""""""""" -Only use when auto mode is set, convertion data tx channel read from l2 address +RX channel address in L2 when auto mode is set .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+-----+----------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+====================================================+ + |31:0 |R/W|ADDRESS|0x0 |In auto mode, gives the address in L2 for RX channel| + +-----+---+-------+-----+----------------------------------------------------+ -.. _udma_ffc_IRQ_EN: +.. _udma_ffc__IRQ_EN: IRQ_EN """""" @@ -206,13 +244,16 @@ IRQ_EN Enable or disable transfer interrupt .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+-----+-------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=====================================+ + | 0|R/W|ENABLE|0x0 |Set to 1 to enable transfer interrupt| + +-----+---+------+-----+-------------------------------------+ -.. _udma_ffc_STATUS: +.. _udma_ffc__STATUS: STATUS """""" @@ -220,22 +261,30 @@ STATUS Show if the transfer is finished or not .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=========================================================================+ + | 0|R |DONE|0x0 |Is set to 1 when the configured number of conversions have been completed| + +-----+---+----+-----+-------------------------------------------------------------------------+ + | 1|R |BUSY|0x0 |Is set to 1 while conversions are ongoing | + +-----+---+----+-----+-------------------------------------------------------------------------+ -.. _udma_ffc_START: +.. _udma_ffc__START: START """"" -Start transition +Start processing .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----+-----+---------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=================================================================================+ + | 0|W |START|0x0 |Write any value to start the processing of conversions according to configuration| + +-----+---+-----+-----+---------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_filter.rst b/rtos/pulp/gap_archi/doc/ips/udma_filter.rst index 884aa9619..3f8cd1f45 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_filter.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_filter.rst @@ -8,408 +8,502 @@ Register map Overview """""""" -.. table:: - +---------------------------------------------------+------+-----+---------------------------------------------+ - | Name |Offset|Width| Description | - +===================================================+======+=====+=============================================+ - |:ref:`REG_TX_CH0_ADD` | 0| 32|FILTER tx channel 0 address register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_TX_CH0_CFG` | 4| 32|FILTER tx channel 0 configuration register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_TX_CH0_LEN0`| 8| 32|FILTER tx channel 0 length0 register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_TX_CH0_LEN1`| 12| 32|FILTER tx channel 0 length1 register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_TX_CH0_LEN2`| 16| 32|FILTER tx channel 0 length2 register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_TX_CH1_ADD` | 20| 32|FILTER tx channel 1 address register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_TX_CH1_CFG` | 24| 32|FILTER tx channel 1 configuration register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_TX_CH1_LEN0`| 28| 32|FILTER tx channel 1 length0 register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_TX_CH1_LEN1`| 32| 32|FILTER tx channel 1 length1 register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_TX_CH1_LEN2`| 36| 32|FILTER tx channel 1 length2 register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_RX_CH_ADD` | 40| 32|FILTER RX channel address register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_RX_CH_CFG` | 44| 32|FILTER RX channel configuration register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_RX_CH_LEN0` | 48| 32|FILTER RX channel length0 register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_RX_CH_LEN1` | 52| 32|FILTER RX channel length1 register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_RX_CH_LEN2` | 56| 32|FILTER RX channel length2 register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_AU_CFG` | 60| 32|FILTER arithmetic unit configuration register| - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_AU_REG0` | 64| 32|FILTER arithmetic unit 0 register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_AU_REG1` | 68| 32|FILTER arithmetic unit 1 register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_BINCU_TH` | 72| 32|FILTER binarization threshold register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_BINCU_CNT` | 76| 32|FILTER binarization count register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_BINCU_SETUP`| 80| 32|FILTER binarization datasize format register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_BINCU_VAL` | 84| 32|FILTER binarization result count register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_FILT` | 88| 32|FILTER control mode register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_FILT_CMD` | 92| 32|FILTER start register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - |:ref:`REG_STATUS` | 96| 32|FILTER status register | - +---------------------------------------------------+------+-----+---------------------------------------------+ - -.. _udma_filter_REG_TX_CH0_ADD: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +----------------------------------------------------+------+-----+---------------------------------------------+ + | Name |Offset|Width| Description | + +====================================================+======+=====+=============================================+ + |:ref:`REG_TX_CH0_ADD` | 0| 32|Filter TX channel 0 address register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_TX_CH0_CFG` | 4| 32|Filter TX channel 0 configuration register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_TX_CH0_LEN0`| 8| 32|Filter TX channel 0 length0 register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_TX_CH0_LEN1`| 12| 32|Filter TX channel 0 length1 register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_TX_CH0_LEN2`| 16| 32|Filter TX channel 0 length2 register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_TX_CH1_ADD` | 20| 32|Filter TX channel 1 address register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_TX_CH1_CFG` | 24| 32|Filter TX channel 1 configuration register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_TX_CH1_LEN0`| 28| 32|Filter TX channel 1 length0 register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_TX_CH1_LEN1`| 32| 32|Filter TX channel 1 length1 register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_TX_CH1_LEN2`| 36| 32|Filter TX channel 1 length2 register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_RX_CH_ADD` | 40| 32|Filter RX channel address register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_RX_CH_CFG` | 44| 32|Filter RX channel configuration register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_RX_CH_LEN0` | 48| 32|Filter RX channel length0 register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_RX_CH_LEN1` | 52| 32|Filter RX channel length1 register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_RX_CH_LEN2` | 56| 32|Filter RX channel length2 register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_AU_CFG` | 60| 32|Filter arithmetic unit configuration register| + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_AU_REG0` | 64| 32|Filter arithmetic unit 0 register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_AU_REG1` | 68| 32|Filter arithmetic unit 1 register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_BINCU_TH` | 72| 32|Filter binarization threshold register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_BINCU_CNT` | 76| 32|Filter binarization count register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_BINCU_SETUP`| 80| 32|Filter binarization datasize format register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_BINCU_VAL` | 84| 32|Filter binarization result count register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_FILT` | 88| 32|Filter control mode register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_FILT_CMD` | 92| 32|Filter start register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_STATUS` | 96| 32|Filter status register | + +----------------------------------------------------+------+-----+---------------------------------------------+ + +.. _udma_filter__REG_TX_CH0_ADD: REG_TX_CH0_ADD """""""""""""" -FILTER tx channel 0 address register +Filter TX channel 0 address register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+----------+--------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+=======+==========+==============+ + |31:0 |R/W|ADDRESS|0x00000000|Target address| + +-----+---+-------+----------+--------------+ -.. _udma_filter_REG_TX_CH0_CFG: +.. _udma_filter__REG_TX_CH0_CFG: REG_TX_CH0_CFG """""""""""""" -FILTER tx channel 0 configuration register +Filter TX channel 0 configuration register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+----------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+================================================================+ + |1:0 |R/W|SIZE|0x0 |Data format: b00: 8-bit; b01: 16-bit; b10: 24-bit; b11: 32-bit | + +-----+---+----+-----+----------------------------------------------------------------+ + |9:8 |R/W|MODE|0x0 |Transfer mode: b00: linear; b01: sliding; b10: circular; b11: 2D| + +-----+---+----+-----+----------------------------------------------------------------+ -.. _udma_filter_REG_TX_CH0_LEN0: +.. _udma_filter__REG_TX_CH0_LEN0: REG_TX_CH0_LEN0 """"""""""""""" -FILTER tx channel 0 length0 register +Filter TX channel 0 length0 register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+----------+---------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+======+==========+=========================================================+ + |31:0 |R/W|LENGTH|0x00000000|Length0 parameter: length of the linear part of transfers| + +-----+---+------+----------+---------------------------------------------------------+ -.. _udma_filter_REG_TX_CH0_LEN1: +.. _udma_filter__REG_TX_CH0_LEN1: REG_TX_CH0_LEN1 """"""""""""""" -FILTER tx channel 0 length1 register +Filter TX channel 0 length1 register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+----------+---------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+======+==========+=========================================================+ + |31:0 |R/W|LENGTH|0x00000000|Length1 parameter: number of linear parts in the transfer| + +-----+---+------+----------+---------------------------------------------------------+ -.. _udma_filter_REG_TX_CH0_LEN2: +.. _udma_filter__REG_TX_CH0_LEN2: REG_TX_CH0_LEN2 """"""""""""""" -FILTER tx channel 0 length2 register +Filter TX channel 0 length2 register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+----------+---------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+======+==========+=================================================================================+ + |31:0 |R/W|LENGTH|0x00000000|Length2 parameter: length of the stride between linear transfers for 2D transfers| + +-----+---+------+----------+---------------------------------------------------------------------------------+ -.. _udma_filter_REG_TX_CH1_ADD: +.. _udma_filter__REG_TX_CH1_ADD: REG_TX_CH1_ADD """""""""""""" -FILTER tx channel 1 address register +Filter TX channel 1 address register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+----------+--------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+=======+==========+==============+ + |31:0 |R/W|ADDRESS|0x00000000|Target address| + +-----+---+-------+----------+--------------+ -.. _udma_filter_REG_TX_CH1_CFG: +.. _udma_filter__REG_TX_CH1_CFG: REG_TX_CH1_CFG """""""""""""" -FILTER tx channel 1 configuration register +Filter TX channel 1 configuration register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+----------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+================================================================+ + |1:0 |R/W|SIZE|0x0 |Data format: b00: 8-bit; b01: 16-bit; b10: 24-bit; b11: 32-bit | + +-----+---+----+-----+----------------------------------------------------------------+ + |9:8 |R/W|MODE|0x0 |Transfer mode: b00: linear; b01: sliding; b10: circular; b11: 2D| + +-----+---+----+-----+----------------------------------------------------------------+ -.. _udma_filter_REG_TX_CH1_LEN0: +.. _udma_filter__REG_TX_CH1_LEN0: REG_TX_CH1_LEN0 """"""""""""""" -FILTER tx channel 1 length0 register +Filter TX channel 1 length0 register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+----------+---------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+======+==========+=========================================================+ + |31:0 |R/W|LENGTH|0x00000000|Length0 parameter: length of the linear part of transfers| + +-----+---+------+----------+---------------------------------------------------------+ -.. _udma_filter_REG_TX_CH1_LEN1: +.. _udma_filter__REG_TX_CH1_LEN1: REG_TX_CH1_LEN1 """"""""""""""" -FILTER tx channel 1 length1 register +Filter TX channel 1 length1 register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+----------+---------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+======+==========+=========================================================+ + |31:0 |R/W|LENGTH|0x00000000|Length1 parameter: number of linear parts in the transfer| + +-----+---+------+----------+---------------------------------------------------------+ -.. _udma_filter_REG_TX_CH1_LEN2: +.. _udma_filter__REG_TX_CH1_LEN2: REG_TX_CH1_LEN2 """"""""""""""" -FILTER tx channel 1 length2 register +Filter TX channel 1 length2 register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+----------+---------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+======+==========+=================================================================================+ + |31:0 |R/W|LENGTH|0x00000000|Length2 parameter: length of the stride between linear transfers for 2D transfers| + +-----+---+------+----------+---------------------------------------------------------------------------------+ -.. _udma_filter_REG_RX_CH_ADD: +.. _udma_filter__REG_RX_CH_ADD: REG_RX_CH_ADD """"""""""""" -FILTER RX channel address register +Filter RX channel address register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-------+----------+--------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+=======+==========+==============+ + |31:0 |R/W|ADDRESS|0x00000000|Target address| + +-----+---+-------+----------+--------------+ -.. _udma_filter_REG_RX_CH_CFG: +.. _udma_filter__REG_RX_CH_CFG: REG_RX_CH_CFG """"""""""""" -FILTER RX channel configuration register +Filter RX channel configuration register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+----------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+================================================================+ + |1:0 |R/W|SIZE|0x0 |Data format: b00: 8-bit; b01: 16-bit; b10: 24-bit; b11: 32-bit | + +-----+---+----+-----+----------------------------------------------------------------+ + |9:8 |R/W|MODE|0x0 |Transfer mode: b00: linear; b01: sliding; b10: circular; b11: 2D| + +-----+---+----+-----+----------------------------------------------------------------+ -.. _udma_filter_REG_RX_CH_LEN0: +.. _udma_filter__REG_RX_CH_LEN0: REG_RX_CH_LEN0 """""""""""""" -FILTER RX channel length0 register +Filter RX channel length0 register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+----------+---------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+======+==========+=========================================================+ + |31:0 |R/W|LENGTH|0x00000000|Length0 parameter: length of the linear part of transfers| + +-----+---+------+----------+---------------------------------------------------------+ -.. _udma_filter_REG_RX_CH_LEN1: +.. _udma_filter__REG_RX_CH_LEN1: REG_RX_CH_LEN1 """""""""""""" -FILTER RX channel length1 register +Filter RX channel length1 register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+----------+---------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+======+==========+=========================================================+ + |31:0 |R/W|LENGTH|0x00000000|Length1 parameter: number of linear parts in the transfer| + +-----+---+------+----------+---------------------------------------------------------+ -.. _udma_filter_REG_RX_CH_LEN2: +.. _udma_filter__REG_RX_CH_LEN2: REG_RX_CH_LEN2 """""""""""""" -FILTER RX channel length2 register +Filter RX channel length2 register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+------+----------+---------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+======+==========+=================================================================================+ + |31:0 |R/W|LENGTH|0x00000000|Length2 parameter: length of the stride between linear transfers for 2D transfers| + +-----+---+------+----------+---------------------------------------------------------------------------------+ -.. _udma_filter_REG_AU_CFG: +.. _udma_filter__REG_AU_CFG: REG_AU_CFG """""""""" -FILTER arithmetic unit configuration register +Filter arithmetic unit configuration register .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ - -.. _udma_filter_REG_AU_REG0: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+========================================================================================================================================================================================================================================================================================================================+ + | 0|R/W|SIGNED|0x0 |Arithmetic unit result signed or not: b0: not signed; b1: signed | + +-----+---+------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|BYPASS|0x0 |Arithmetic unit bypass or not: b0: not bypassed; b1: bypassed | + +-----+---+------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |11:8 |R/W|MODE |0x0 |Arithmetic unit operation: b0000: AxB; b0001: AxB+REG0; b0010: AxB with accumulation; b0011: AxA; b0100: AxA+B; b0101: AxA-B; b0110: AxA with accumulation; b0111: AxA+REG0; b1000: AxREG1; b1001: AxREG1+B; b1010: AxREG1-B; b1011: AxREG1+REG0; b1100: AxREG1 with accumulation; b1101: A+B; b1110: A-B; b1111: A+REG0| + +-----+---+------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |20:16|R/W|SHIFT |0x0 |Output right shift (0--31) | + +-----+---+------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_filter__REG_AU_REG0: REG_AU_REG0 """"""""""" -FILTER arithmetic unit 0 register +Filter arithmetic unit 0 register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+----------+-------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+=========================+ + |31:0 |R/W|VALUE|0x00000000|Register configured value| + +-----+---+-----+----------+-------------------------+ -.. _udma_filter_REG_AU_REG1: +.. _udma_filter__REG_AU_REG1: REG_AU_REG1 """"""""""" -FILTER arithmetic unit 1 register +Filter arithmetic unit 1 register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+----------+-------------------------+ + |Bit #|R/W|Name | Reset | Description | + +=====+===+=====+==========+=========================+ + |31:0 |R/W|VALUE|0x00000000|Register configured value| + +-----+---+-----+----------+-------------------------+ -.. _udma_filter_REG_BINCU_TH: +.. _udma_filter__REG_BINCU_TH: REG_BINCU_TH """""""""""" -FILTER binarization threshold register +Filter binarization threshold register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+---------+----------+------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+=========+==========+========================================================================+ + |31:0 |R/W|THRESHOLD|0x00000000|Threshold value: value > THRESHOLD is binarized to all bits at 1, else 0| + +-----+---+---------+----------+------------------------------------------------------------------------+ -.. _udma_filter_REG_BINCU_CNT: +.. _udma_filter__REG_BINCU_CNT: REG_BINCU_CNT """"""""""""" -FILTER binarization count register +Filter binarization count register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+--------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+====================================================================+ + |19:0 |R/W|COUNT|0x0 |Number of values above threshold to count before triggering an event| + +-----+---+-----+-----+--------------------------------------------------------------------+ + |31 |R/W|EN |0x0 |Binarization and counting unit enable: b0: not enabled; b1: enabled | + +-----+---+-----+-----+--------------------------------------------------------------------+ -.. _udma_filter_REG_BINCU_SETUP: +.. _udma_filter__REG_BINCU_SETUP: REG_BINCU_SETUP """"""""""""""" -FILTER binarization datasize format register +Filter binarization datasize format register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-----------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=====================================================+ + |1:0 |R/W|SIZE|0x0 |Data format: b00: 8-bit; b01: 16-bit; b10-b11: 32-bit| + +-----+---+----+-----+-----------------------------------------------------+ -.. _udma_filter_REG_BINCU_VAL: +.. _udma_filter__REG_BINCU_VAL: REG_BINCU_VAL """"""""""""" -FILTER binarization result count register +Filter binarization result count register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+--------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+============================================+ + |19:0 |R |COUNT|0x0 |Number of encountered values above threshold| + +-----+---+-----+-----+--------------------------------------------+ -.. _udma_filter_REG_FILT: +.. _udma_filter__REG_FILT: REG_FILT """""""" -FILTER control mode register +Filter control mode register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+----+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=========================================================================================================================================================================================================================+ + |3:0 |R/W|MODE|0x0 |Filter control mode: b0000: A, B and output; b0001: A and output; b0010: A, B and binarization; b0011: A and binarization; b0100: A, B, output and binarization; b0101: A, output and binarization; b0110-b1111: reserved| + +-----+---+----+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _udma_filter_REG_FILT_CMD: +.. _udma_filter__REG_FILT_CMD: REG_FILT_CMD """""""""""" -FILTER start register +Filter start register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-----------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================================+ + | 0|W |START|0x0 |Filter start: write 1 to start the filter| + +-----+---+-----+-----+-----------------------------------------+ -.. _udma_filter_REG_STATUS: +.. _udma_filter__REG_STATUS: REG_STATUS """""""""" -FILTER status register +Filter status register .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===============================================================================================================+ + | 0|R/W|DONE|0x0 |Filter done flag: b0: ongoing filter processing; b1: filter has completed processing. Write 1 to clear the flag| + +-----+---+----+-----+---------------------------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_hyper.rst b/rtos/pulp/gap_archi/doc/ips/udma_hyper.rst index f6e5311e8..fe6fba1df 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_hyper.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_hyper.rst @@ -8,77 +8,82 @@ Register map Overview """""""" -.. table:: - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - | Name |Offset|Width| Description | - +====================================================+======+=====+===========================================================+ - |:ref:`RX_DEST` | 0| 32|Stream ID for the uDMA channel | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`TX_DEST` | 4| 32|Stream ID for the uDMA channel | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`TRANS_MODE` | 8| 32|Configure transaction mode | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`TRANS_ADDR` | 12| 32|Configure each transaction addr | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`TRANS_SIZE` | 16| 32|Configure each transaction size | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`TRANS_CFG` | 20| 32|Start each transaction rx/tx | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`OSPI_CMD_XIP` | 24| 32|OSPI XIP command and psram command config | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`OSPI_CFG_XIP` | 28| 32|OSPI XIP configuration | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`EXT_ADDR` | 32| 32|Memory access address register. | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`TIMING_CFG` | 36| 32|HYPERBUS and Octo SPI Memory Timing configuration register.| - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`MBA0` | 40| 32|Device start address register. | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`MBA1` | 44| 32|Device start address register. | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`DEVICE` | 48| 32|Device type register(RAM or FLASH). | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`OSPI_CMD` | 52| 32|OSPI command and psram command config | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`OSPI_ALTER` | 56| 32|OSPI alternative 2 bytes | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`OSPI_CFG` | 60| 32|OSPI configuration | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`OSPI_CSN` | 64| 32|OSPI chip select configuration | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`OSPI_JEDEC_RESET`| 68| 32|OSPI JEDEC Hardware Reset, user can control sdo0 manually | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`OSPI_RAM_OPT` | 72| 32|OSPI RAM DATA transfer optimisation, only in auto mode | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`OSPI_ALTER_XIP` | 76| 32|OSPI XIP alternative 2 bytes | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`OSPI_REG_XIP` | 80| 32|OSPI XIP other configuration | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`LINE_2D` | 84| 32|OSPI 2D line. | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`STRIDE_2D` | 88| 32|OSPI 2D stride. | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`BURST_ENABLE` | 92| 32|OSPI burst mode/2D mode enable. | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`IRQ_EN` | 96| 32|OSPI interrupt enable register | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CLK_DIV` | 100| 32|Clock divide. | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`STATUS` | 104| 32|Transfer status for error. | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SDIO_CMD_ARG` | 108| 32|SDIO command argument. | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SDIO_RSP0` | 112| 32|SDIO response 0. | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SDIO_RSP1` | 116| 32|SDIO response 1. | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SDIO_RSP2` | 120| 32|SDIO response 2. | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SDIO_RSP3` | 124| 32|SDIO response 3. | - +----------------------------------------------------+------+-----+-----------------------------------------------------------+ - -.. _udma_hyper_RX_DEST: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + | Name |Offset|Width| Description | + +=====================================================+======+=====+===========================================================+ + |:ref:`RX_DEST` | 0| 32|Stream ID for the uDMA channel | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`TX_DEST` | 4| 32|Stream ID for the uDMA channel | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`TRANS_MODE` | 8| 32|Configure transaction mode | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`TRANS_ADDR` | 12| 32|Configure each transaction addr | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`TRANS_SIZE` | 16| 32|Configure each transaction size | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`TRANS_CFG` | 20| 32|Start each transaction rx/tx | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`OSPI_CMD_XIP` | 24| 32|OSPI XIP command and psram command config | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`OSPI_CFG_XIP` | 28| 32|OSPI XIP configuration | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`EXT_ADDR` | 32| 32|Memory access address register. | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`TIMING_CFG` | 36| 32|HYPERBUS and Octo SPI Memory Timing configuration register.| + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`MBA0` | 40| 32|Device start address register. | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`MBA1` | 44| 32|Device start address register. | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`DEVICE` | 48| 32|Device type register(RAM or FLASH). | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`OSPI_CMD` | 52| 32|OSPI command and psram command config | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`OSPI_ALTER` | 56| 32|OSPI alternative 2 bytes | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`OSPI_CFG` | 60| 32|OSPI configuration | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`OSPI_CSN` | 64| 32|OSPI chip select configuration | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`OSPI_JEDEC_RESET`| 68| 32|OSPI JEDEC Hardware Reset, user can control sdo0 manually | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`OSPI_RAM_OPT` | 72| 32|OSPI RAM DATA transfer optimisation, only in auto mode | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`OSPI_ALTER_XIP` | 76| 32|OSPI XIP alternative 2 bytes | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`OSPI_REG_XIP` | 80| 32|OSPI XIP other configuration | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`LINE_2D` | 84| 32|OSPI 2D line. | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`STRIDE_2D` | 88| 32|OSPI 2D stride. | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`BURST_ENABLE` | 92| 32|OSPI burst mode/2D mode enable. | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`IRQ_EN` | 96| 32|OSPI interrupt enable register | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CLK_DIV` | 100| 32|Clock divide. | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`STATUS` | 104| 32|Transfer status for error. | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SDIO_CMD_ARG` | 108| 32|SDIO command argument. | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SDIO_RSP0` | 112| 32|SDIO response 0. | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SDIO_RSP1` | 116| 32|SDIO response 1. | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SDIO_RSP2` | 120| 32|SDIO response 2. | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SDIO_RSP3` | 124| 32|SDIO response 3. | + +-----------------------------------------------------+------+-----+-----------------------------------------------------------+ + +.. _udma_hyper__RX_DEST: RX_DEST """"""" @@ -86,16 +91,18 @@ RX_DEST Stream ID for the uDMA channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------+---------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+===========================================================================+ - |7:0 |R/W|DEST |Stream ID for the RX 1D/2D uDMA channel. Default is 0xFF(channel disabled) | - +-----+---+-----------+---------------------------------------------------------------------------+ - |15:8 |R/W|DEST_STREAM|Stream ID for the RX STREAM uDMA channel. Default is 0xFF(channel disabled)| - +-----+---+-----------+---------------------------------------------------------------------------+ + +-----+---+-----------+-----+---------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+===========================================================================+ + |7:0 |R/W|DEST |0xFF |Stream ID for the RX 1D/2D uDMA channel. Default is 0xFF(channel disabled) | + +-----+---+-----------+-----+---------------------------------------------------------------------------+ + |15:8 |R/W|DEST_STREAM|0xFF |Stream ID for the RX STREAM uDMA channel. Default is 0xFF(channel disabled)| + +-----+---+-----------+-----+---------------------------------------------------------------------------+ -.. _udma_hyper_TX_DEST: +.. _udma_hyper__TX_DEST: TX_DEST """"""" @@ -103,16 +110,18 @@ TX_DEST Stream ID for the uDMA channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------+---------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+===========================================================================+ - |7:0 |R/W|DEST |Stream ID for the TX 1D/2D uDMA channel. Default is 0xFF(channel disabled) | - +-----+---+-----------+---------------------------------------------------------------------------+ - |15:8 |R/W|DEST_STREAM|Stream ID for the TX STREAM uDMA channel. Default is 0xFF(channel disabled)| - +-----+---+-----------+---------------------------------------------------------------------------+ + +-----+---+-----------+-----+---------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+===========================================================================+ + |7:0 |R/W|DEST |0xFF |Stream ID for the TX 1D/2D uDMA channel. Default is 0xFF(channel disabled) | + +-----+---+-----------+-----+---------------------------------------------------------------------------+ + |15:8 |R/W|DEST_STREAM|0xFF |Stream ID for the TX STREAM uDMA channel. Default is 0xFF(channel disabled)| + +-----+---+-----------+-----+---------------------------------------------------------------------------+ -.. _udma_hyper_TRANS_MODE: +.. _udma_hyper__TRANS_MODE: TRANS_MODE """""""""" @@ -120,32 +129,34 @@ TRANS_MODE Configure transaction mode .. table:: - - +-----+---+-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=================+===================================================================================================================================================================================+ - | 0|R/W|AUTO_ENA |Transfer mode in AUTO, IP will configure the UDMA transfer automatically using register parameters instead using SW configuration in UDMA - 1'b0: AUTO_DIS - 1'b1: AUTO_EN | - +-----+---+-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|XIP_EN |Transfer mode in XIP, IP will configure the UDMA transfer automatically using XIP parameters instead using SW configuration in UDMA - 1'b0: XIP_DIS - 1'b1: XIP_EN | - +-----+---+-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |3:2 |R |RESERVED0 |- | - +-----+---+-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 4|R/W|STREAM_EN |Transfer mode in noraml mode use STREAM or not, IP will configure the STREAM UDMA transfer automatically to read / write data from / to memory - 1'b0: STREAM_DIS - 1'b1: STREAM_EN| - +-----+---+-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 5|R/W|AES_STREAM_EN |Transfer mode in noraml mode use AES STREAM or not, to avoid Read synchronous issue when in AUTO mode - 1'b0: AES_STREAM_DIS - 1'b1: AES_STREAM_EN | - +-----+---+-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |7:6 |R |RESERVED1 |- | - +-----+---+-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 8|R/W|XIP_STREAM_EN |Transfer mode in noraml mode use STREAM or not, IP will configure the STREAM UDMA transfer automatically to read / write data from / to memory - 1'b0: STREAM_DIS - 1'b1: STREAM_EN| - +-----+---+-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 9|R/W|XIP_AES_STREAM_EN|Transfer mode in noraml mode use AES STREAM or not, to avoid Read synchronous issue when in AUTO mode - 1'b0: AES_STREAM_DIS - 1'b1: AES_STREAM_EN | - +-----+---+-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |11:10|R |RESERVED2 |- | - +-----+---+-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 12|R/W|XIP_HALTED |Halted XIP refill when in XIP, XIP refill will wait SW unlock this bit. - 1'b0: XIP_RUNNING - 1'b1: XIP_HALTED | - +-----+---+-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_hyper_TRANS_ADDR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=================+=====+=========================================================================================================================================================================+ + | 0|R/W|AUTO_ENA |0x0 |Transfer mode in AUTO, IP will configure the UDMA transfer automatically using register parameters instead using SW configuration in UDMA: b0: AUTO_DIS; b1: AUTO_EN | + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|XIP_EN |0x0 |Transfer mode in XIP, IP will configure the UDMA transfer automatically using XIP parameters instead using SW configuration in UDMA: b0: XIP_DIS; b1: XIP_EN | + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R |RESERVED0 |0x0 |-- | + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 4|R/W|STREAM_EN |0x0 |Transfer mode in noraml mode use STREAM or not, IP will configure the STREAM UDMA transfer automatically to read/write data from/to memory: b0: STREAM_DIS; b1: STREAM_EN| + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 5|R/W|AES_STREAM_EN |0x0 |Transfer mode in noraml mode use AES STREAM or not, to avoid Read synchronous issue when in AUTO mode: b0: AES_STREAM_DIS; b1: AES_STREAM_EN | + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:6 |R |RESERVED1 |0x0 |-- | + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 8|R/W|XIP_STREAM_EN |0x0 |Transfer mode in noraml mode use STREAM or not, IP will configure the STREAM UDMA transfer automatically to read/write data from/to memory: b0: STREAM_DIS; b1: STREAM_EN| + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 9|R/W|XIP_AES_STREAM_EN|0x0 |Transfer mode in noraml mode use AES STREAM or not, to avoid Read synchronous issue when in AUTO mode: b0: AES_STREAM_DIS; b1: AES_STREAM_EN | + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |11:10|R |RESERVED2 |0x0 |-- | + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 12|R/W|XIP_HALTED |0x0 |Halted XIP refill when in XIP, XIP refill will wait SW unlock this bit: b0: XIP_RUNNING; b1: XIP_HALTED | + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_hyper__TRANS_ADDR: TRANS_ADDR """""""""" @@ -153,14 +164,16 @@ TRANS_ADDR Configure each transaction addr .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+----------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+========================================+ - |31:0 |R/W|ADDR|Transfer addr, only when MODE is in AUTO| - +-----+---+----+----------------------------------------+ + +-----+---+----+-----+----------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+========================================+ + |31:0 |R/W|ADDR|0x0 |Transfer addr, only when MODE is in AUTO| + +-----+---+----+-----+----------------------------------------+ -.. _udma_hyper_TRANS_SIZE: +.. _udma_hyper__TRANS_SIZE: TRANS_SIZE """""""""" @@ -168,14 +181,16 @@ TRANS_SIZE Configure each transaction size .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============+ - |20:0 |R/W|SIZE|Transfer Size| - +-----+---+----+-------------+ + +-----+---+----+-----+-------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============+ + |20:0 |R/W|SIZE|0x0 |Transfer Size| + +-----+---+----+-----+-------------+ -.. _udma_hyper_TRANS_CFG: +.. _udma_hyper__TRANS_CFG: TRANS_CFG """"""""" @@ -183,16 +198,18 @@ TRANS_CFG Start each transaction rx/tx .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+---------------------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+===========================================================================+ - | 0|R/W|RXTX |Transfer type - 1'b0: TX - 1'b1: RX | - +-----+---+-----+---------------------------------------------------------------------------+ - | 1|W |VALID|Transfer valid to start, always read 0 - 1'b0: clear transfer - 1'b1: Start| - +-----+---+-----+---------------------------------------------------------------------------+ + +-----+---+-----+-----+---------------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=======================================================================================+ + | 0|R/W|RXTX |0x0 |Transfer type: b0: TX; b1: RX | + +-----+---+-----+-----+---------------------------------------------------------------------------------------+ + | 1|W |VALID|0x0 |Transfer valid to start: b0: clear transfer; b1: Start transfer. Read always returns O.| + +-----+---+-----+-----+---------------------------------------------------------------------------------------+ -.. _udma_hyper_OSPI_CMD_XIP: +.. _udma_hyper__OSPI_CMD_XIP: OSPI_CMD_XIP """""""""""" @@ -200,18 +217,20 @@ OSPI_CMD_XIP OSPI XIP command and psram command config .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------------+-----------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=================+=======================+ - |15:0 |R/W|CMD |2 Bytes SPI command | - +-----+---+-----------------+-----------------------+ - |22:20|R/W|SDIO_CMD_RSP_TYPE|SDIO CMD response type | - +-----+---+-----------------+-----------------------+ - |29:24|R/W|SDIO_CMD_OP |SDIO CMD operation code| - +-----+---+-----------------+-----------------------+ + +-----+---+-----------------+-----+-----------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=================+=====+=======================+ + |15:0 |R/W|CMD |0x0 |2 Bytes SPI command | + +-----+---+-----------------+-----+-----------------------+ + |22:20|R/W|SDIO_CMD_RSP_TYPE|0x0 |SDIO CMD response type | + +-----+---+-----------------+-----+-----------------------+ + |29:24|R/W|SDIO_CMD_OP |0x0 |SDIO CMD operation code| + +-----+---+-----------------+-----+-----------------------+ -.. _udma_hyper_OSPI_CFG_XIP: +.. _udma_hyper__OSPI_CFG_XIP: OSPI_CFG_XIP """""""""""" @@ -219,26 +238,28 @@ OSPI_CFG_XIP OSPI XIP configuration .. table:: - - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+===============================================================================================================================================================================+ - |1:0 |R/W|CMD_SIZE |Octo SPI command size : - 2’b0: 0 byte - 2'b1: 1 byte - 2'b2: 2 byte | - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |6:4 |R/W|ADDR_SIZE |Octo SPI address size : - 3'b000: 0 byte (Jump ADDRESS stage) - 3'b001: 1 byte - 3'b010: 2 byte - 3'b011: 3 byte - 3'b100: 4 byte | - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |9:8 |R/W|LINE |Octo SPI line number for Single SPI or Octo SPI: - 2'b00: 8 line for Octo SPI - 2'b01: 4 line for QUAD SPI (sdio{3:0]) - 2'b10: 1 line for Single SPI (SI : dq[0] SO: dq[1])| - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |12 |R/W|CMD_DTR_STR |Octo SPI command ddr mode or single mode : - 1'b0: DTR mode - 1'b1: STR mode | - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |13 |R/W|ADDR_DTR_STR|Octo SPI address ddr mode or single mode : - 1'b0: DTR mode - 1'b1: STR mode | - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |14 |R/W|DATA_DTR_STR|Octo SPI data ddr mode or single mode : - 1'b0: DTR mode - 1'b1: STR mode | - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15 |R/W|DATA_DTR_MSB|Octo SPI data ddr mode data MSB: - 1'b0: LSB - 1'b1: MSB | - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_hyper_EXT_ADDR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+=============================================================================================================================================+ + |1:0 |R/W|CMD_SIZE |0x0 |Octo SPI command size (number of bytes, from 0 to 2) | + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + |6:4 |R/W|ADDR_SIZE |0x0 |Octo SPI address size (number of bytes, from 0 to 4). If 0, jump ADDRESS stage | + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + |9:8 |R/W|LINE |0x0 |Octo SPI number of lines: b00: 8 lines for Octo SPI; b01: 4 lines for QUAD SPI (sdio{3:0]); b10: 1 line for Single SPI (SI: dq[0]; SO: dq[1])| + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|CMD_DTR_STR |0x0 |Octo SPI command DDR mode or single mode: b0: DTR mode; b1: STR mode | + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|ADDR_DTR_STR|0x0 |Octo SPI address DDR mode or single mode: b0: DTR mode; b1: STR mode | + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + |14 |R/W|DATA_DTR_STR|0x0 |Octo SPI data DDR mode or single mode: b0: DTR mode; b1: STR mode | + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|DATA_DTR_MSB|0x0 |Octo SPI data DDR mode data MSB: b0: LSB; b1: MSB | + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_hyper__EXT_ADDR: EXT_ADDR """""""" @@ -246,16 +267,18 @@ EXT_ADDR Memory access address register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----------+-------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+===============================+ - |30:0 |R/W|SADDR |Memory access address bitfield.| - +-----+---+----------+-------------------------------+ - |31 |R/W|REG_ACCESS|Register access flag bitfield. | - +-----+---+----------+-------------------------------+ + +-----+---+----------+-----+----------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+======================+ + |30:0 |R/W|SADDR |0x0 |Memory access address.| + +-----+---+----------+-----+----------------------+ + |31 |R/W|REG_ACCESS|0x0 |Register access flag. | + +-----+---+----------+-----+----------------------+ -.. _udma_hyper_TIMING_CFG: +.. _udma_hyper__TIMING_CFG: TIMING_CFG """""""""" @@ -263,24 +286,26 @@ TIMING_CFG HYPERBUS and Octo SPI Memory Timing configuration register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============================+========================================================================================================================================================================================================================================================================================================================================================================================================+ - |4:0 |R/W|LATENCY0 |Latency Cycle value for both HyperRAM and HyperFLASH for chip select 0. When using HyperRAM memory, this bit should be set to the same value as the read latency in configuration register of HyperRAM memory the read latency in configuration register of HyperRAM memory. For SPI, is the dummy cycle after ADDRESS stage : - 5'b00000: 0 CK - 5'b00001: 1 CK - 5'b000001: 2 CK ... - 5'b11111: 31 CK| - +-----+---+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |9:5 |R/W|LATENCY1 |Latency Cycle value for both HyperRAM and HyperFLASH for chip select 1. When using HyperRAM memory, this bit should be set to the same value as the read latency in configuration register of HyperRAM memory the read latency in configuration register of HyperRAM memory. For SPI, is the dummy cycle after ADDRESS stage : - 5'b00000: 0 CK - 5'b00001: 1 CK - 5'b000001: 2 CK ... - 5'b11111: 31 CK| - +-----+---+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |13:10|R/W|RW_RECOVERY |Some HyperBus devices may require a minimum time between the end of a prior transaction and the start of a new access. This time is referred to as Read-Write-Recovery time (tRWR). The master interface must start driving CS# Low only at a time when the CA1 transfer will complete after tRWR is satisfied. - 5'b00000: 0 CK - 5'b00001: 1 CK - 5'b000001: 2 CK ... - 5'b11111: 31 CK | - +-----+---+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |16:14|R/W|RWDS_DELAY |Delay of RWDS for center aligned read: - 3'b000: 0 logic delay - 3'b001: 1 logic delay - 3'b010: 2 logic delay … - 3'b111: 7 logic delay | - +-----+---+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |17 |R/W|ADDITIONAL_LATENCY_AUTOCHECK_EN|Auto check for RWDS high or low for additional latency : - 1'b0: additional latency no autocheck - 1'b1: additional latency autocheck | - +-----+---+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |31:18|R/W|CS_MAX |Maximum chip select low time for self-refresh HYPERRAM to valid the data transfer : - 14'h0000: 1 CK - 14'h0001: 2 CK - 14'h0011: 3 CK - … - 14'h3FFF: 16383 CK | - +-----+---+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-------------------------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============================+=====+====================================================================================================================================================================================================================================================================================================+ + |4:0 |R/W|LATENCY0 |0x0 |Latency Cycle value for both HyperRAM and HyperFLASH for chip select 0. When using HyperRAM memory, this bit should be set to the same value as the read latency in configuration register of HyperRAM memory. For SPI, it is the number of dummy cycles after ADDRESS stage. | + +-----+---+-------------------------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |9:5 |R/W|LATENCY1 |0x0 |Latency Cycle value for both HyperRAM and HyperFLASH for chip select 1. When using HyperRAM memory, this bit should be set to the same value as the read latency in configuration register of HyperRAM memory. For SPI, it is the number of dummy cycles after ADDRESS stage. | + +-----+---+-------------------------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:10|R/W|RW_RECOVERY |0x0 |Number of clock cycles for Read-Write-Recovery time (tRWR): some HyperBus devices may require a minimum time between the end of a prior transaction and the start of a new access. The master interface waits this number of cycles before driving CS# low after the completion of the CA1 transfer.| + +-----+---+-------------------------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |16:14|R/W|RWDS_DELAY |0x0 |Delay (number of clock cycles) of RWDS for center aligned read. | + +-----+---+-------------------------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |17 |R/W|ADDITIONAL_LATENCY_AUTOCHECK_EN|0x0 |Autocheck for RWDS high or low for additional latency: b0: no autocheck; b1: autocheck enabled | + +-----+---+-------------------------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |31:18|R/W|CS_MAX |0x100|Maximum chip select low time for self-refresh HYPERRAM to valid the data transfer (number of clock cycles) | + +-----+---+-------------------------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _udma_hyper_MBA0: +.. _udma_hyper__MBA0: MBA0 """" @@ -288,16 +313,18 @@ MBA0 Device start address register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+============================================================================================================================================================================================================================================================================================================================================================================================================================================================+ - |23:0 |R |reserved|- | - +-----+---+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |30:24|R/W|MBA0 |Memory Base Address 0 for both RAM and FLASH bitfield. The base address of addressable region to each memory is set up. Since register can be set in 16M bytes boundary, lower 24 bit is fixed to 0. MBA0 can be greater than MBA1, the chip select which decided by the relationship among MBA0, MBA1, and EXT_ADDR. - MBA0 < MBA1, if (MBA1 <= EXT_ADDR) CS1 = 0; else CS0 = 0; - MBA0 > MBA1, if (MBA0 <= EXT_ADDR) CS0 = 0; else CS1 = 0;| - +-----+---+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+--------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=================================================================================================================================================================================================================================================================================================================================================================================================================================================+ + |23:0 |R |reserved|0x0 |-- | + +-----+---+--------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |30:24|R/W|MBA0 |0x0 |Memory Base Address 0 for both RAM and FLASH bitfield. The base address of addressable region to each memory is set up. Since register can be set in 16M bytes boundary, lower 24 bits are fixed to 0. MBA0 can be greater than MBA1. Used chip select depends on the relationship between MBA0, MBA1 and EXT_ADDR: if MBA0 < MBA1, if MBA1 <= EXT_ADDR then CS1 = 0 else CS0 = 0; if MBA0 > MBA1, if MBA0 <= EXT_ADDR then CS0 = 0 else CS1 = 0.| + +-----+---+--------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _udma_hyper_MBA1: +.. _udma_hyper__MBA1: MBA1 """" @@ -305,16 +332,18 @@ MBA1 Device start address register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+===============================================================================================================================================================================================================================================================================================================================================================================================================================================================+ - |23:0 |R |reserved|- | - +-----+---+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |30:24|R/W|MBA1 |Memory Base Address for both RAM and FLASH bitfield. The base address of addressable region to each memory is set up. Since register can be set in 16M bytes boundary, lower 24 bit is fixed to 0. MBA0 can be greater than MBA1, the chip select which decided by the relationship among MBA0, MBA1, and EXT_ADDR. - MBA0 < MBA1, if (MBA1 <= EXT_ADDR) CSn1 = 0; else CSn0 = 0; - MBA0 > MBA1, if (MBA0 <= EXT_ADDR) CSn0 = 0; else CSn1 = 0;| - +-----+---+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+====================================================================================================================================================================================================================================================================================================================================================================================================================================================+ + |23:0 |R |reserved|0x0 |-- | + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |30:24|R/W|MBA1 |0x0 |Memory Base Address for both RAM and FLASH bitfield. The base address of addressable region to each memory is set up. Since register can be set in 16M bytes boundary, lower 24 bits are fixed to 0. MBA0 can be greater than MBA1. Used chip select depends on the relationship between MBA0, MBA1 and EXT_ADDR: if MBA0 < MBA1, if MBA1 <= EXT_ADDR then CSn1 = 0 else CSn0 = 0; if MBA0 > MBA1, if MBA0 <= EXT_ADDR then CSn0 = 0 else CSn1 = 0.| + +-----+---+--------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _udma_hyper_DEVICE: +.. _udma_hyper__DEVICE: DEVICE """""" @@ -322,20 +351,22 @@ DEVICE Device type register(RAM or FLASH). .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+============================================================+ - | 0|R/W|TYPE|Device type : - 1'b00: Octo/ Single SPI - 1'b01: HYPERBUS | - +-----+---+----+------------------------------------------------------------+ - | 1|R/W|DT0 |When in HYPERBUS mode : - 1'b0: HYPERRAM - 1'b1: HYPERLASH| - +-----+---+----+------------------------------------------------------------+ - | 2|R/W|DT1 |When in HYPERBUS mode : - 1'b0: HYPERRAM - 1'b1: HYPERLASH| - +-----+---+----+------------------------------------------------------------+ - | 3|R/W|SDIO|SDIO mode | - +-----+---+----+------------------------------------------------------------+ + +-----+---+----+-----+--------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==================================================+ + | 0|R/W|TYPE|0x0 |Device type: b0: Octo/Single SPI; b1: HYPERBUS | + +-----+---+----+-----+--------------------------------------------------+ + | 1|R/W|DT0 |0x0 |When in HYPERBUS mode: b0: HYPERRAM; b1: HYPERLASH| + +-----+---+----+-----+--------------------------------------------------+ + | 2|R/W|DT1 |0x0 |When in HYPERBUS mode: b0: HYPERRAM; b1: HYPERLASH| + +-----+---+----+-----+--------------------------------------------------+ + | 3|R/W|SDIO|0x0 |SDIO mode | + +-----+---+----+-----+--------------------------------------------------+ -.. _udma_hyper_OSPI_CMD: +.. _udma_hyper__OSPI_CMD: OSPI_CMD """""""" @@ -343,18 +374,20 @@ OSPI_CMD OSPI command and psram command config .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----------------+-----------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=================+=======================+ - |15:0 |R/W|CMD |2 Bytes SPI command | - +-----+---+-----------------+-----------------------+ - |22:20|R/W|SDIO_CMD_RSP_TYPE|SDIO CMD response type | - +-----+---+-----------------+-----------------------+ - |29:24|R/W|SDIO_CMD_OP |SDIO CMD operation code| - +-----+---+-----------------+-----------------------+ + +-----+---+-----------------+-----+-----------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=================+=====+=======================+ + |15:0 |R/W|CMD |0x0 |2 Bytes SPI command | + +-----+---+-----------------+-----+-----------------------+ + |22:20|R/W|SDIO_CMD_RSP_TYPE|0x0 |SDIO CMD response type | + +-----+---+-----------------+-----+-----------------------+ + |29:24|R/W|SDIO_CMD_OP |0x0 |SDIO CMD operation code| + +-----+---+-----------------+-----+-----------------------+ -.. _udma_hyper_OSPI_ALTER: +.. _udma_hyper__OSPI_ALTER: OSPI_ALTER """""""""" @@ -362,16 +395,18 @@ OSPI_ALTER OSPI alternative 2 bytes .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-----------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+=======================+ - |15:0 |R/W|MODE0|2 Bytes SPI alternative| - +-----+---+-----+-----------------------+ - |31:16|R/W|MODE1|2 Bytes SPI alternative| - +-----+---+-----+-----------------------+ + +-----+---+-----+-----+-----------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=======================+ + |15:0 |R/W|MODE0|0x0 |2 Bytes SPI alternative| + +-----+---+-----+-----+-----------------------+ + |31:16|R/W|MODE1|0x0 |2 Bytes SPI alternative| + +-----+---+-----+-----+-----------------------+ -.. _udma_hyper_OSPI_CFG: +.. _udma_hyper__OSPI_CFG: OSPI_CFG """""""" @@ -379,26 +414,28 @@ OSPI_CFG OSPI configuration .. table:: - - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+===============================================================================================================================================================================+ - |1:0 |R/W|CMD_SIZE |Octo SPI command size : - 2’b0: 0 byte - 2'b1: 1 byte - 2'b2: 2 byte | - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |6:4 |R/W|ADDR_SIZE |Octo SPI address size : - 3'b000: 0 byte (Jump ADDRESS stage) - 3'b001: 1 byte - 3'b010: 2 byte - 3'b011: 3 byte - 3'b100: 4 byte | - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |9:8 |R/W|LINE |Octo SPI line number for Single SPI or Octo SPI: - 2'b00: 8 line for Octo SPI - 2'b01: 4 line for QUAD SPI (sdio{3:0]) - 2'b10: 1 line for Single SPI (SI : dq[0] SO: dq[1])| - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |12 |R/W|CMD_DTR_STR |Octo SPI command ddr mode or single mode : - 1'b0: DTR mode - 1'b1: STR mode | - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |13 |R/W|ADDR_DTR_STR|Octo SPI address ddr mode or single mode : - 1'b0: DTR mode - 1'b1: STR mode | - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |14 |R/W|DATA_DTR_STR|Octo SPI data ddr mode or single mode : - 1'b0: DTR mode - 1'b1: STR mode | - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15 |R/W|DATA_DTR_MSB|Octo SPI data ddr mode data MSB: - 1'b0: LSB - 1'b1: MSB | - +-----+---+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_hyper_OSPI_CSN: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+=============================================================================================================================================+ + |1:0 |R/W|CMD_SIZE |0x0 |Octo SPI command size (number of bytes, from 0 to 2) | + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + |6:4 |R/W|ADDR_SIZE |0x0 |Octo SPI address size (number of bytes, from 0 to 4). If 0, jump ADDRESS stage | + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + |9:8 |R/W|LINE |0x0 |Octo SPI number of lines: b00: 8 lines for Octo SPI; b01: 4 lines for QUAD SPI (sdio{3:0]); b10: 1 line for Single SPI (SI: dq[0]; SO: dq[1])| + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + |12 |R/W|CMD_DTR_STR |0x0 |Octo SPI command DDR mode or single mode: b0: DTR mode; b1: STR mode | + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + |13 |R/W|ADDR_DTR_STR|0x0 |Octo SPI address DDR mode or single mode: b0: DTR mode; b1: STR mode | + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + |14 |R/W|DATA_DTR_STR|0x0 |Octo SPI data DDR mode or single mode: b0: DTR mode; b1: STR mode | + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |R/W|DATA_DTR_MSB|0x0 |Octo SPI data DDR mode data MSB: b0: LSB; b1: MSB | + +-----+---+------------+-----+---------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_hyper__OSPI_CSN: OSPI_CSN """""""" @@ -406,34 +443,36 @@ OSPI_CSN OSPI chip select configuration .. table:: - - +-----+---+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+====================================================================================================================================================================+ - | 0|R/W|INDEX |Octo SPI chip select index controlled by user : - 1'b0: CSN0 - 1'b1: CSN1 | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|AUTO_EN |Octo SPI chip select controlled by IP automatically : - 1'b0: IP control CSN according to index - 1'b1: : IP control CSN according to address range automatically| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 2|R |SET_CSN_VALID |- | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 3|R/W|POLARITY |Octo SPI chip select polarity : 0 - csn is active low, 1 - csn is active high | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 4|R/W|DIRECT_CTRL |Octo SPI chip select controlled by user enable GPIO mode : - 1'b0: IP control CSN according to index - 1'b1: USER control CSN in GPIO mode | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 5|R/W|VALUE |Octo SPI chip select value controlled by user : - 1'b0: HIGH - 1'b1: : Low | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 6|R/W|SDIO_DATA_QUAD |SDIO data quad enable : - 1'b0: Disable - 1'b1: : Enable | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 7|R/W|SDIO_DATA_QUAD_DDR|SDIO data quad ddr enable : - 1'b0: Disable - 1'b1: : Enable | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15:8 |R/W|SDIO_BLOCK_NUM |SDIO data block number | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |25:16|R/W|SDIO_BLOCK_SIZE |SDIO data block size | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 26|R/W|SDIO_AUTO_STOP |SDIO enable HW auto stop after multiple read and write : - 1'b0: Disable - 1'b1: : Enable | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_hyper_OSPI_JEDEC_RESET: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+=======================================================================================================================================================+ + | 0|R/W|INDEX |0x0 |Octo SPI chip select index controlled by user: b0: CSN0; b1: CSN1 | + +-----+---+------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|AUTO_EN |0x0 |Octo SPI chip select controlled by IP automatically: b0: IP control CSN according to index; b1: IP control CSN according to address range automatically| + +-----+---+------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 2|R |SET_CSN_VALID |0x0 |-- | + +-----+---+------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 3|R/W|POLARITY |0x0 |Octo SPI chip select polarity: b0: csn is active low; b1: csn is active high | + +-----+---+------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 4|R/W|DIRECT_CTRL |0x0 |Octo SPI chip select controlled by user enable GPIO mode: b0: IP control CSN according to index; b1: USER control CSN in GPIO mode | + +-----+---+------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 5|R/W|VALUE |0x0 |Octo SPI chip select value controlled by user: b0: high; b1: low | + +-----+---+------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 6|R/W|SDIO_DATA_QUAD |0x0 |SDIO data quad enable: b0: Disable; b1: Enable | + +-----+---+------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 7|R/W|SDIO_DATA_QUAD_DDR|0x0 |SDIO data quad DDR enable: b0: Disable; b1: Enable | + +-----+---+------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R/W|SDIO_BLOCK_NUM |0x0 |SDIO data block number | + +-----+---+------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + |25:16|R/W|SDIO_BLOCK_SIZE |0x0 |SDIO data block size | + +-----+---+------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 26|R/W|SDIO_AUTO_STOP |0x1 |SDIO enable HW auto stop after multiple read and write: b0: Disable; b1: Enable | + +-----+---+------------------+-----+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_hyper__OSPI_JEDEC_RESET: OSPI_JEDEC_RESET """""""""""""""" @@ -441,16 +480,18 @@ OSPI_JEDEC_RESET OSPI JEDEC Hardware Reset, user can control sdo0 manually .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------------------+--------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+====================+==================================================================================================+ - | 0|R/W|USER_CTRL_SDO0_EN |Octo SPI chip in JEDEC reset mode enable : - 1'b0: JEDEC reset disable - 1'b1: USER control sdo0| - +-----+---+--------------------+--------------------------------------------------------------------------------------------------+ - | 1|R/W|USER_CTRL_SDO0_VALUE|Octo SPI chip in JEDEC reset mode, sdo0 value | - +-----+---+--------------------+--------------------------------------------------------------------------------------------------+ + +-----+---+--------------------+-----+----------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+====================+=====+========================================================================================+ + | 0|R/W|USER_CTRL_SDO0_EN |0x0 |Octo SPI chip in JEDEC reset mode enable: b0: JEDEC reset disable; b1: USER control sdo0| + +-----+---+--------------------+-----+----------------------------------------------------------------------------------------+ + | 1|R/W|USER_CTRL_SDO0_VALUE|0x0 |Octo SPI chip in JEDEC reset mode, sdo0 value | + +-----+---+--------------------+-----+----------------------------------------------------------------------------------------+ -.. _udma_hyper_OSPI_RAM_OPT: +.. _udma_hyper__OSPI_RAM_OPT: OSPI_RAM_OPT """""""""""" @@ -458,30 +499,32 @@ OSPI_RAM_OPT OSPI RAM DATA transfer optimisation, only in auto mode .. table:: - - +-----+---+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========================+==================================================================================================================================================================================================================================+ - |1:0 |R/W|OPT_READ_EN_CS |Octo SPI RAM optimisation read enable for CS 0, special when no accross boundary rwds latency for each channel : - 1'b0: disable - 1'b1: enable | - +-----+---+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|REAL_ADDR_EN |Octo SPI or single SPI which use real address instead of address/2 for each channel : - 1'b0: disable - 1'b1: enable | - +-----+---+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |5:4 |R/W|PSRAM_READ_BIT |PSRAM CMD automatically reform - CMD bit[47] R/W# - Read is 1 or 0 for each channel | - +-----+---+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |7:6 |R/W|PSRAM_CMD_EN |PSRAM CMD automatically reform enable for each channel | - +-----+---+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |9:8 |R/W|PSRAM_ADDR_EVEN |PSRAM even address reform for each channel | - +-----+---+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |11:10|R/W|PSRAM_CROSS_BOUNDARY_EN0 |PSRAM cross boundary access (CBD) optimisation R/W enable for channle CS0 : 2'b00: Both read write can CBD - 2'b01: read can not CBD, write can CBD - 2'b10: read can CBD, write can not CBD - 2'b11: Both read write can not CBD| - +-----+---+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |13:12|R/W|PSRAM_CROSS_BOUNDARY_EN1 |PSRAM cross boundary access (CBD) optimisation R/W enable for channle CS0 : 2'b00: Both read write can CBD - 2'b01: read can not CBD, write can CBD - 2'b10: read can CBD, write can not CBD - 2'b11: Both read write can not CBD| - +-----+---+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15:14|R/W|PSRAM_CROSS_BOUNDARY_PAGE0|PSRAM cross boundary access optimisation page for channle CS0 : - 2'b00: 256B - 2'b01: 512B - 2'b10: 1KB - 2'b11: 2KB | - +-----+---+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |17:16|R/W|PSRAM_CROSS_BOUNDARY_PAGE1|PSRAM cross boundary access optimisation page for channle CS1 : - 2'b00: 256B - 2'b01: 512B - 2'b10: 1KB - 2'b11: 2KB | - +-----+---+--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_hyper_OSPI_ALTER_XIP: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========================+=====+==================================================================================================================================================================================================================+ + |1:0 |R/W|OPT_READ_EN_CS |0x0 |Octo SPI RAM optimisation read enable for CS0, special when no accross boundary rwds latency for each channel: b0: disable; b1: enable | + +-----+---+--------------------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|REAL_ADDR_EN |0x0 |Octo SPI or single SPI which use real address instead of address/2 for each channel: b0: disable; b1: enable | + +-----+---+--------------------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |5:4 |R/W|PSRAM_READ_BIT |0x0 |PSRAM CMD automatically reform -- CMD bit[47] R/W# -- Read is 1 or 0 for each channel | + +-----+---+--------------------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:6 |R/W|PSRAM_CMD_EN |0x0 |PSRAM CMD automatically reform enable for each channel | + +-----+---+--------------------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |9:8 |R/W|PSRAM_ADDR_EVEN |0x0 |PSRAM even address reform for each channel | + +-----+---+--------------------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |11:10|R/W|PSRAM_CROSS_BOUNDARY_EN0 |0x0 |PSRAM cross boundary access (CBD) optimisation R/W enable for channle CS0: b00: Both read write can CBD. b01: read cannot CBD, write can CBD; b10: read can CBD, write cannot CBD; b11: Both read write ca not CBD| + +-----+---+--------------------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |13:12|R/W|PSRAM_CROSS_BOUNDARY_EN1 |0x0 |PSRAM cross boundary access (CBD) optimisation R/W enable for channle CS0: b00: Both read write can CBD; b01: read cannot CBD, write can CBD; b10: read can CBD, write cannot CBD; b11: Both read write cannot CBD| + +-----+---+--------------------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:14|R/W|PSRAM_CROSS_BOUNDARY_PAGE0|0x0 |PSRAM cross boundary access optimisation page for channle CS0: b00: 256B; b01: 512B; b10: 1KB; b11: 2KB | + +-----+---+--------------------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |17:16|R/W|PSRAM_CROSS_BOUNDARY_PAGE1|0x0 |PSRAM cross boundary access optimisation page for channle CS1: b00: 256B; b01: 512B; b10: 1KB; b11: 2KB | + +-----+---+--------------------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_hyper__OSPI_ALTER_XIP: OSPI_ALTER_XIP """""""""""""" @@ -489,16 +532,18 @@ OSPI_ALTER_XIP OSPI XIP alternative 2 bytes .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-----------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+=======================+ - |15:0 |R/W|MODE0|2 Bytes SPI alternative| - +-----+---+-----+-----------------------+ - |31:16|R/W|MODE1|2 Bytes SPI alternative| - +-----+---+-----+-----------------------+ + +-----+---+-----+-----+-----------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=======================+ + |15:0 |R/W|MODE0|0x0 |2 Bytes SPI alternative| + +-----+---+-----+-----+-----------------------+ + |31:16|R/W|MODE1|0x0 |2 Bytes SPI alternative| + +-----+---+-----+-----+-----------------------+ -.. _udma_hyper_OSPI_REG_XIP: +.. _udma_hyper__OSPI_REG_XIP: OSPI_REG_XIP """""""""""" @@ -506,16 +551,18 @@ OSPI_REG_XIP OSPI XIP other configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------+--------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+====================+ - |4:0 |R/W|XIP_LATENCY0|XIP latency0 for cs0| - +-----+---+------------+--------------------+ - |9:5 |R/W|XIP_LATENCY1|XIP latency1 for cs1| - +-----+---+------------+--------------------+ + +-----+---+------------+-----+--------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+====================+ + |4:0 |R/W|XIP_LATENCY0|0x0 |XIP latency0 for cs0| + +-----+---+------------+-----+--------------------+ + |9:5 |R/W|XIP_LATENCY1|0x0 |XIP latency1 for cs1| + +-----+---+------------+-----+--------------------+ -.. _udma_hyper_LINE_2D: +.. _udma_hyper__LINE_2D: LINE_2D """"""" @@ -523,14 +570,16 @@ LINE_2D OSPI 2D line. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+--------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==============================================================================================================+ - |20:0 |R/W|LINE|OSPI 2D line with 2D mode. For example, ADDR = START_ADDR + i * BURST_STRIDE. Normally, LINE >= BURST_SIZE.| - +-----+---+----+--------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================================================================================================+ + |20:0 |R/W|LINE|0x0 |OSPI 2D line with 2D mode. For example, ADDR = START_ADDR + i * BURST_STRIDE. Normally, LINE >= BURST_SIZE.| + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------+ -.. _udma_hyper_STRIDE_2D: +.. _udma_hyper__STRIDE_2D: STRIDE_2D """"""""" @@ -538,14 +587,16 @@ STRIDE_2D OSPI 2D stride. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+==================================================================================================================+ - |20:0 |R/W|STRIDE|OSPI 2D stride with 2D mode. For example, ADDR = START_ADDR + i * BURST_STRIDE. Normally, STRIDE >= BURST_SIZE.| - +-----+---+------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+------+-----+---------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+===============================================================================================================+ + |20:0 |R/W|STRIDE|0x0 |OSPI 2D stride with 2D mode. For example, ADDR = START_ADDR + i * BURST_STRIDE. Normally, STRIDE >= BURST_SIZE.| + +-----+---+------+-----+---------------------------------------------------------------------------------------------------------------+ -.. _udma_hyper_BURST_ENABLE: +.. _udma_hyper__BURST_ENABLE: BURST_ENABLE """""""""""" @@ -553,24 +604,26 @@ BURST_ENABLE OSPI burst mode/2D mode enable. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========================+=======================================================================================================================================================+ - | 0|R/W|CS0_AUTO_BURST_ENABLE |Automatically control Maximum chip select low time for self-refresh HYPERRAM to valid the data transfer for channel 0 : - 1'b0 disable - 1'b1 Enable| - +-----+---+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|CS1_AUTO_BURST_ENABLE |Automatically control Maximum chip select low time for self-refresh HYPERRAM to valid the data transfer for channel 1 : - 1'b0 disable - 1'b1 Enable| - +-----+---+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 2|R/W|CS0_MAXIMUM_CHECK_ENABLE|Enable Maximum chip select low time for self-refresh HYPERRAM for channel 0: - 1'b0: disable - 1'b1: enable | - +-----+---+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 3|R/W|CS1_MAXIMUM_CHECK_ENABLE|Enable Maximum chip select low time for self-refresh HYPERRAM for channel 1 : - 1'b0: disable - 1'b1: enable | - +-----+---+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |5:4 |R/W|QSPI_2D_ENABLE |OSPI burst 2D mode enable for normal mode and XIP : - 1'b0: BURST 2D mode disable - 1'b1: BURST 2D mode disable | - +-----+---+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ - |7:6 |R/W|L2_2D_MODE |2D tansfer mode from L2 to external memory config : - 2'b00: 1D_TO_1D - 2'b01: 1D_TO_2D - 2'b10: 2D_TO_1D - 2'b11: 2D_TO_2D | - +-----+---+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========================+=====+============================================================================================================================================+ + | 0|R/W|CS0_AUTO_BURST_ENABLE |0x0 |Automatically control Maximum chip select low time for self-refresh HYPERRAM to valid the data transfer for channel 0: b0 disable; b1 enable| + +-----+---+------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|CS1_AUTO_BURST_ENABLE |0x0 |Automatically control Maximum chip select low time for self-refresh HYPERRAM to valid the data transfer for channel 1: b0 disable; b1 enable| + +-----+---+------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + | 2|R/W|CS0_MAXIMUM_CHECK_ENABLE|0x0 |Enable Maximum chip select low time for self-refresh HYPERRAM for channel 0: b0: disable; b1: enable | + +-----+---+------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + | 3|R/W|CS1_MAXIMUM_CHECK_ENABLE|0x0 |Enable Maximum chip select low time for self-refresh HYPERRAM for channel 1: b0: disable; b1: enable | + +-----+---+------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |5:4 |R/W|QSPI_2D_ENABLE |0x0 |OSPI burst 2D mode enable for normal mode and XIP: b0: disable; b1: enable | + +-----+---+------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |7:6 |R/W|L2_2D_MODE |0x0 |2D tansfer mode from L2 to external memory config: b00: 1D_TO_1D; b01: 1D_TO_2D; b10: 2D_TO_1D; b11: 2D_TO_2D | + +-----+---+------------------------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _udma_hyper_IRQ_EN: +.. _udma_hyper__IRQ_EN: IRQ_EN """""" @@ -578,16 +631,18 @@ IRQ_EN OSPI interrupt enable register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+================================================================================================+ - | 0|R/W|EN |Octo SPI interrupt enable control : - 1'b0: interrupt disable - 1'b1: Interrupt enable | - +-----+---+------+------------------------------------------------------------------------------------------------+ - | 1|R/W|XIP_EN|Octo SPI interrupt enable control for XIP : - 1'b0: interrupt disable - 1'b1: Interrupt enable| - +-----+---+------+------------------------------------------------------------------------------------------------+ + +-----+---+------+-----+--------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+======================================================================================+ + | 0|R/W|EN |0x0 |Octo SPI interrupt enable control: b0: interrupt disable; b1: Interrupt enable | + +-----+---+------+-----+--------------------------------------------------------------------------------------+ + | 1|R/W|XIP_EN|0x0 |Octo SPI interrupt enable control for XIP: b0: interrupt disable; b1: Interrupt enable| + +-----+---+------+-----+--------------------------------------------------------------------------------------+ -.. _udma_hyper_CLK_DIV: +.. _udma_hyper__CLK_DIV: CLK_DIV """"""" @@ -595,16 +650,18 @@ CLK_DIV Clock divide. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+=====================================================================================================================================================+ - |7:0 |R/W|DATA |Clock divide data, form 0 – 255, frequency divide table is : -8’h0 – IO_FREQUENCY / 1 -8’h1 – IO_FREQUENCY / 2 -8’h2 – IO_FREQUENCY / 4 … | - +-----+---+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------+ - |8 |W |VALID|Clock divide valid, user can not control. Every time there is clock divide write access, set 1 by default, then when clock divide is finished, set 0.| - +-----+---+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+-----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=====================================================================================================================================================+ + |7:0 |R/W|DATA |0x0 |Clock divider ratio (0-255): PERIPH clock frequency is divided by pow2(DATA) | + +-----+---+-----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------+ + |8 |W |VALID|0x0 |Clock divider valid, user cannot control. Every time there is clock divide write access, set 1 by default, then when clock divide is finished, set 0.| + +-----+---+-----+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _udma_hyper_STATUS: +.. _udma_hyper__STATUS: STATUS """""" @@ -612,26 +669,28 @@ STATUS Transfer status for error. .. table:: - - +-----+---+-----------------+---------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=================+===================================================================================================+ - | 0|R |TX_ERROR |TX transfer error because of tcsm, write 1 to clear: - 1'b0: no error - 1'b1: error | - +-----+---+-----------------+---------------------------------------------------------------------------------------------------+ - | 1|R |RX_ERROR |RX transfer error because of tcsm, write 1 to clear: - 1'b0: no error - 1'b1: error | - +-----+---+-----------------+---------------------------------------------------------------------------------------------------+ - | 2|R |RX_TX_END |RX TX transfer end flag, can be polling by user, write 1 to clear: - 1'b0: not end - 1'b1: end | - +-----+---+-----------------+---------------------------------------------------------------------------------------------------+ - | 3|R |SDIO_RX_TX_ERROR |SDIO RX TX transfer error because of tcsm, write 1 to clear: - 1'b0: no error - 1'b1: error | - +-----+---+-----------------+---------------------------------------------------------------------------------------------------+ - | 4|R |SDIO_RX_TX_END |SDIO RX TX transfer end flag, can be polling by user, write 1 to clear: - 1'b0: not end - 1'b1: end| - +-----+---+-----------------+---------------------------------------------------------------------------------------------------+ - |15:5 |R |reserved |- | - +-----+---+-----------------+---------------------------------------------------------------------------------------------------+ - |31:16|R |SDIO_ERROR_STATUS|SDIO error status flag, indicate the error type | - +-----+---+-----------------+---------------------------------------------------------------------------------------------------+ - -.. _udma_hyper_SDIO_CMD_ARG: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=================+=====+===========================================================================================+ + | 0|R |TX_ERROR |0x0 |TX transfer error because of tcsm, write 1 to clear: b0: no error; b1: error | + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------+ + | 1|R |RX_ERROR |0x0 |RX transfer error because of tcsm, write 1 to clear: b0: no error; b1: error | + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------+ + | 2|R |RX_TX_END |0x0 |RX TX transfer end flag, can be polled by user, write 1 to clear: b0: not end; b1: end | + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------+ + | 3|R |SDIO_RX_TX_ERROR |0x0 |SDIO RX TX transfer error because of tcsm, write 1 to clear: b0: no error; b1: error | + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------+ + | 4|R |SDIO_RX_TX_END |0x0 |SDIO RX TX transfer end flag, can be polled by user, write 1 to clear: b0: not end; b1: end| + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------+ + |15:5 |R |reserved |0x0 |-- | + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------+ + |31:16|R |SDIO_ERROR_STATUS|0x0 |SDIO error status flag, indicate the error type | + +-----+---+-----------------+-----+-------------------------------------------------------------------------------------------+ + +.. _udma_hyper__SDIO_CMD_ARG: SDIO_CMD_ARG """""""""""" @@ -639,14 +698,16 @@ SDIO_CMD_ARG SDIO command argument. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=====================+ - |31:0 |R/W|ARG |SDIO command argument| - +-----+---+----+---------------------+ + +-----+---+----+-----+---------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=====================+ + |31:0 |R/W|ARG |0x0 |SDIO command argument| + +-----+---+----+-----+---------------------+ -.. _udma_hyper_SDIO_RSP0: +.. _udma_hyper__SDIO_RSP0: SDIO_RSP0 """"""""" @@ -654,14 +715,16 @@ SDIO_RSP0 SDIO response 0. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===============+ - |31:0 |R |RSP0|SDIO response 0| - +-----+---+----+---------------+ + +-----+---+----+-----+---------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===============+ + |31:0 |R |RSP0|0x0 |SDIO response 0| + +-----+---+----+-----+---------------+ -.. _udma_hyper_SDIO_RSP1: +.. _udma_hyper__SDIO_RSP1: SDIO_RSP1 """"""""" @@ -669,14 +732,16 @@ SDIO_RSP1 SDIO response 1. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===============+ - |31:0 |R |RSP1|SDIO response 1| - +-----+---+----+---------------+ + +-----+---+----+-----+---------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===============+ + |31:0 |R |RSP1|0x0 |SDIO response 1| + +-----+---+----+-----+---------------+ -.. _udma_hyper_SDIO_RSP2: +.. _udma_hyper__SDIO_RSP2: SDIO_RSP2 """"""""" @@ -684,14 +749,16 @@ SDIO_RSP2 SDIO response 2. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===============+ - |31:0 |R |RSP2|SDIO response 2| - +-----+---+----+---------------+ + +-----+---+----+-----+---------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===============+ + |31:0 |R |RSP2|0x0 |SDIO response 2| + +-----+---+----+-----+---------------+ -.. _udma_hyper_SDIO_RSP3: +.. _udma_hyper__SDIO_RSP3: SDIO_RSP3 """"""""" @@ -699,9 +766,11 @@ SDIO_RSP3 SDIO response 3. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===============+ - |31:0 |R |RSP3|SDIO response 3| - +-----+---+----+---------------+ + +-----+---+----+-----+---------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===============+ + |31:0 |R |RSP3|0x0 |SDIO response 3| + +-----+---+----+-----+---------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_i2c.rst b/rtos/pulp/gap_archi/doc/ips/udma_i2c.rst index b31590dc9..73cbeee78 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_i2c.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_i2c.rst @@ -8,25 +8,30 @@ Register map Overview """""""" -.. table:: - +--------------------------------------------------------------------+------+-----+--------------------------------+ - | Name |Offset|Width| Description | - +====================================================================+======+=====+================================+ - |:ref:`FOLL_UDMA_RX_DEST_REG_IDX`| 0| 32|I2c follower RX uDMA channel | - +--------------------------------------------------------------------+------+-----+--------------------------------+ - |:ref:`FOLL_UDMA_TX_DEST_REG_IDX`| 4| 32|I2c follower TX uDMA channel | - +--------------------------------------------------------------------+------+-----+--------------------------------+ - |:ref:`UDMA_CMD_DEST_REG_IDX` | 8| 32|Command TX uDMA channel | - +--------------------------------------------------------------------+------+-----+--------------------------------+ - |:ref:`LEAD_UDMA_RX_DEST_REG_IDX`| 12| 32|I2c leader RX uDMA channel | - +--------------------------------------------------------------------+------+-----+--------------------------------+ - |:ref:`LEAD_UDMA_TX_DEST_REG_IDX`| 16| 32|I2c leader TX uDMA channel | - +--------------------------------------------------------------------+------+-----+--------------------------------+ - |:ref:`STATUS_REG_IDX` | 20| 32|Incoming event flag / emit event| - +--------------------------------------------------------------------+------+-----+--------------------------------+ - -.. _udma_i2c_FOLL_UDMA_RX_DEST_REG_IDX: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +---------------------------------------------------------------------+------+-----+--------------------------------+ + | Name |Offset|Width| Description | + +=====================================================================+======+=====+================================+ + |:ref:`FOLL_UDMA_RX_DEST_REG_IDX`| 0| 32|I2c follower RX uDMA channel | + +---------------------------------------------------------------------+------+-----+--------------------------------+ + |:ref:`FOLL_UDMA_TX_DEST_REG_IDX`| 4| 32|I2c follower TX uDMA channel | + +---------------------------------------------------------------------+------+-----+--------------------------------+ + |:ref:`UDMA_CMD_DEST_REG_IDX` | 8| 32|Command TX uDMA channel | + +---------------------------------------------------------------------+------+-----+--------------------------------+ + |:ref:`LEAD_UDMA_RX_DEST_REG_IDX`| 12| 32|I2c leader RX uDMA channel | + +---------------------------------------------------------------------+------+-----+--------------------------------+ + |:ref:`LEAD_UDMA_TX_DEST_REG_IDX`| 16| 32|I2c leader TX uDMA channel | + +---------------------------------------------------------------------+------+-----+--------------------------------+ + |:ref:`STATUS_REG_IDX` | 20| 32|Incoming event flag / emit event| + +---------------------------------------------------------------------+------+-----+--------------------------------+ + +.. _udma_i2c__FOLL_UDMA_RX_DEST_REG_IDX: FOLL_UDMA_RX_DEST_REG_IDX """"""""""""""""""""""""" @@ -34,14 +39,16 @@ FOLL_UDMA_RX_DEST_REG_IDX I2c follower RX uDMA channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------------+-------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===============================+ - |7:0 |R/W|UDMA_STREAM_ID|UDMA channel ID (0xFF=disabled)| - +-----+---+--------------+-------------------------------+ + +-----+---+--------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===============================+ + |7:0 |R/W|UDMA_STREAM_ID|0xFF |UDMA channel ID (0xFF=disabled)| + +-----+---+--------------+-----+-------------------------------+ -.. _udma_i2c_FOLL_UDMA_TX_DEST_REG_IDX: +.. _udma_i2c__FOLL_UDMA_TX_DEST_REG_IDX: FOLL_UDMA_TX_DEST_REG_IDX """"""""""""""""""""""""" @@ -49,14 +56,16 @@ FOLL_UDMA_TX_DEST_REG_IDX I2c follower TX uDMA channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------------+-------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===============================+ - |7:0 |R/W|UDMA_STREAM_ID|UDMA channel ID (0xFF=disabled)| - +-----+---+--------------+-------------------------------+ + +-----+---+--------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===============================+ + |7:0 |R/W|UDMA_STREAM_ID|0xFF |UDMA channel ID (0xFF=disabled)| + +-----+---+--------------+-----+-------------------------------+ -.. _udma_i2c_UDMA_CMD_DEST_REG_IDX: +.. _udma_i2c__UDMA_CMD_DEST_REG_IDX: UDMA_CMD_DEST_REG_IDX """"""""""""""""""""" @@ -64,14 +73,16 @@ UDMA_CMD_DEST_REG_IDX Command TX uDMA channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------------+-------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===============================+ - |7:0 |R/W|UDMA_STREAM_ID|UDMA channel ID (0xFF=disabled)| - +-----+---+--------------+-------------------------------+ + +-----+---+--------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===============================+ + |7:0 |R/W|UDMA_STREAM_ID|0xFF |UDMA channel ID (0xFF=disabled)| + +-----+---+--------------+-----+-------------------------------+ -.. _udma_i2c_LEAD_UDMA_RX_DEST_REG_IDX: +.. _udma_i2c__LEAD_UDMA_RX_DEST_REG_IDX: LEAD_UDMA_RX_DEST_REG_IDX """"""""""""""""""""""""" @@ -79,14 +90,16 @@ LEAD_UDMA_RX_DEST_REG_IDX I2c leader RX uDMA channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------------+-------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===============================+ - |7:0 |R/W|UDMA_STREAM_ID|UDMA channel ID (0xFF=disabled)| - +-----+---+--------------+-------------------------------+ + +-----+---+--------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===============================+ + |7:0 |R/W|UDMA_STREAM_ID|0xFF |UDMA channel ID (0xFF=disabled)| + +-----+---+--------------+-----+-------------------------------+ -.. _udma_i2c_LEAD_UDMA_TX_DEST_REG_IDX: +.. _udma_i2c__LEAD_UDMA_TX_DEST_REG_IDX: LEAD_UDMA_TX_DEST_REG_IDX """"""""""""""""""""""""" @@ -94,14 +107,16 @@ LEAD_UDMA_TX_DEST_REG_IDX I2c leader TX uDMA channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------------+-------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===============================+ - |7:0 |R/W|UDMA_STREAM_ID|UDMA channel ID (0xFF=disabled)| - +-----+---+--------------+-------------------------------+ + +-----+---+--------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===============================+ + |7:0 |R/W|UDMA_STREAM_ID|0xFF |UDMA channel ID (0xFF=disabled)| + +-----+---+--------------+-----+-------------------------------+ -.. _udma_i2c_STATUS_REG_IDX: +.. _udma_i2c__STATUS_REG_IDX: STATUS_REG_IDX """""""""""""" @@ -109,92 +124,98 @@ STATUS_REG_IDX Incoming event flag / emit event .. table:: - - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========================================+=========================================================================+ - | 0|R/W|STATUS_FOLL_SOF_RCV_EVENT_I_IDX |Follower is addressed by a read. Write 1 to clear. | - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 1|R/W|STATUS_FOLL_SOF_SND_EVENT_I_IDX |Follower is addressed by a write. Write 1 to clear. | - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 2|R/W|STATUS_FOLL_EOF_RCV_EVENT_I_IDX |Follower is addressed by a read which closes transfer. Write 1 to clear. | - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 3|R/W|STATUS_FOLL_EOF_SND_EVENT_I_IDX |Follower is addressed by a write which closes transfer. Write 1 to clear.| - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 4|R/W|STATUS_FOLL_ERROR_ARLO_EVENT_I_IDX |Follower is addressed and received an arbitration loss. Write 1 to clear.| - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 5|R/W|STATUS_FOLL_ERROR_FRAMING_EVENT_I_IDX |Follower is addressed and noticed incorrect framing. Write 1 to clear. | - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 14|W |STATUS_FOLL_UNLOCK_EVENT_O_IDX |Write 1 to unlock follower TX RX channels after a SOF/EOF/ERROR event | - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 15|W |STATUS_FOLL_PURGE_EVENT_O_IDX |Write 1 to purge TX RX channels FIFOs of any remaining data | - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 16|R/W|STATUS_LEAD_ERROR_NACK_EVENT_I_IDX |Leader encountered an unexpected NACK. Write 1 to clear. | - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 17|R/W|STATUS_LEAD_ERROR_ARLO_EVENT_I_IDX |Leader encountered an arbitration loss. Write 1 to clear. | - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 18|R/W|STATUS_LEAD_ERROR_FRAMING_EVENT_I_IDX |Leader encountered an incorrect framing. Write 1 to clear. | - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 19|R/W|STATUS_LEAD_COMMAND_EVENT_I_IDX |Leader emitted a command event. Does not lock. Write 1 to clear. | - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 22|W |STATUS_LEAD_UNLOCK_EVENT_O_IDX |Write 1 to unlock leader TX RX channels after a SOF/EOF/ERROR event | - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 23|W |STATUS_LEAD_PURGE_EVENT_O_IDX |Write 1 to purge cmd TX RX leader FIFOs of any remaining data | - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 24|W |STATUS_I2C_SOFT_RESET_EVENT_O_IDX |Write 1 to soft reset i2c, if it is deadlocked due to bus error | - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ - | 25|W |STATUS_I2C_PRESCALER_SET_DIV10_EVENT_O_IDX|Write 1 to set prescaler to divide by 10 instead of 100 by default | - +-----+---+------------------------------------------+-------------------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========================================+=====+=========================================================================+ + | 0|R/W|STATUS_FOLL_SOF_RCV_EVENT_I_IDX | 0|Follower is addressed by a read. Write 1 to clear. | + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 1|R/W|STATUS_FOLL_SOF_SND_EVENT_I_IDX | 0|Follower is addressed by a write. Write 1 to clear. | + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 2|R/W|STATUS_FOLL_EOF_RCV_EVENT_I_IDX | 0|Follower is addressed by a read which closes transfer. Write 1 to clear. | + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 3|R/W|STATUS_FOLL_EOF_SND_EVENT_I_IDX | 0|Follower is addressed by a write which closes transfer. Write 1 to clear.| + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 4|R/W|STATUS_FOLL_ERROR_ARLO_EVENT_I_IDX | 0|Follower is addressed and received an arbitration loss. Write 1 to clear.| + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 5|R/W|STATUS_FOLL_ERROR_FRAMING_EVENT_I_IDX | 0|Follower is addressed and noticed incorrect framing. Write 1 to clear. | + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 14|W |STATUS_FOLL_UNLOCK_EVENT_O_IDX | 0|Write 1 to unlock follower TX RX channels after a SOF/EOF/ERROR event | + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 15|W |STATUS_FOLL_PURGE_EVENT_O_IDX | 0|Write 1 to purge TX RX channels FIFOs of any remaining data | + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 16|R/W|STATUS_LEAD_ERROR_NACK_EVENT_I_IDX | 0|Leader encountered an unexpected NACK. Write 1 to clear. | + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 17|R/W|STATUS_LEAD_ERROR_ARLO_EVENT_I_IDX | 0|Leader encountered an arbitration loss. Write 1 to clear. | + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 18|R/W|STATUS_LEAD_ERROR_FRAMING_EVENT_I_IDX | 0|Leader encountered an incorrect framing. Write 1 to clear. | + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 19|R/W|STATUS_LEAD_COMMAND_EVENT_I_IDX | 0|Leader emitted a command event. Does not lock. Write 1 to clear. | + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 22|W |STATUS_LEAD_UNLOCK_EVENT_O_IDX | 0|Write 1 to unlock leader TX RX channels after a SOF/EOF/ERROR event | + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 23|W |STATUS_LEAD_PURGE_EVENT_O_IDX | 0|Write 1 to purge cmd TX RX leader FIFOs of any remaining data | + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 24|W |STATUS_I2C_SOFT_RESET_EVENT_O_IDX | 0|Write 1 to soft reset i2c, if it is deadlocked due to bus error | + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ + | 25|W |STATUS_I2C_PRESCALER_SET_DIV10_EVENT_O_IDX| 0|Write 1 to set prescaler to divide by 10 instead of 100 by default | + +-----+---+------------------------------------------+-----+-------------------------------------------------------------------------+ I2C micro-code ^^^^^^^^^^^^^^ .. table:: - - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - | Command name |Width|Command code| Description | - +================================================================================+=====+============+=====================================================================================================================================+ - |:ref:`CMD_MISC_NOP` | 32|0x00 |Does nothing | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_MISC_WAIT` | 32|0x01 |Wait one i2c clock cycle (repeated if REPEAT_CNT > 1) | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_MISC_REPEAT` | 32|0x02 |Reload the 16-bit repeat downcounter | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_MISC_WAIT_I2C_PERIOD_END`| 32|0x03 |Wait one i2c scl period cycle -- see CMD_TIMING (repeated if REPEAT_CNT > 1) | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_TIMING` | 32|0x10 |Setup i2c_clock period and i2c scl low/high delays | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_FOLL_ADDR` | 32|0x20 |Setup follower adressing & events | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_LEAD_START` | 32|0x30 |Send a (re)start condition | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_LEAD_SEND` | 32|0x31 |Send a byte from TX stream, check ACK (repeated if REPEAT_CNT > 1) | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_LEAD_SEND_IMM` | 32|0x32 |Send a byte from the command, check ACK | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_LEAD_SEND_IMM_ADDR` | 32|0x37 |Send an addr7 or addr10, check ACK | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_LEAD_RECV` | 32|0x33 |Receives a byte that is not the last byte, send ACK (repeated if REPEAT_CNT > 1) | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_LEAD_RECV_LAST` | 32|0x34 |Receives a byte that is the last byte, send NACK (repeated if REPEAT_CNT > 1, in this case the first REPEAT_CNT-1 bytes are ACKed)| - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_LEAD_STOP` | 32|0x36 |Generates a stop condition | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_EVENT_RECV` | 32|0x40 |Wait for an external event of a given index (repeated if REPEAT_CNT > 1) | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_EVENT_SEND` | 32|0x41 |Triggers an internal 'command event' | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_UDMA_TX_CHAN_CFG` | 32|0x50 |Send a configuration command to uDMA TX channel (the register value is given in the following word) | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CMD_UDMA_RX_CHAN_CFG` | 32|0x51 |Send a configuration command to uDMA RX channel (the register value is given in the following word) | - +--------------------------------------------------------------------------------+-----+------------+-------------------------------------------------------------------------------------------------------------------------------------+ - -.. _I2C micro-code_CMD_MISC_NOP: + :align: center + :widths: 45 15 15 80 + + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + | Command name |Width|Command code| Description | + +=================================================================================+=====+============+==================================================================================================================================+ + |:ref:`CMD_MISC_NOP` | 32|0x00 |Does nothing | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_MISC_WAIT` | 32|0x01 |Wait one i2c clock cycle (repeated if REPEAT_CNT > 1) | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_MISC_REPEAT` | 32|0x02 |Reload the 16-bit repeat downcounter | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_MISC_WAIT_I2C_PERIOD_END`| 32|0x03 |Wait one i2c scl period cycle -- see CMD_TIMING (repeated if REPEAT_CNT > 1) | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_TIMING` | 32|0x10 |Setup i2c_clock period and i2c scl low/high delays | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_FOLL_ADDR` | 32|0x20 |Setup follower adressing & events | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_LEAD_START` | 32|0x30 |Send a (re)start condition | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_LEAD_SEND` | 32|0x31 |Send a byte from TX stream, check ACK (repeated if REPEAT_CNT > 1) | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_LEAD_SEND_IMM` | 32|0x32 |Send a byte from the command, check ACK | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_LEAD_SEND_IMM_ADDR` | 32|0x37 |Send an addr7 or addr10, check ACK | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_LEAD_RECV` | 32|0x33 |Receives a byte that is not the last byte, send ACK (repeated if REPEAT_CNT > 1) | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_LEAD_RECV_LAST` | 32|0x34 |Receives a byte that is the last byte, send NACK (repeated if REPEAT_CNT > 1, in this case the first REPEAT_CNT-1 bytes are ACKed)| + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_LEAD_STOP` | 32|0x36 |Generates a stop condition | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_EVENT_RECV` | 32|0x40 |Wait for an external event of a given index (repeated if REPEAT_CNT > 1) | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_EVENT_SEND` | 32|0x41 |Triggers an internal 'command event' | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_UDMA_TX_CHAN_CFG` | 32|0x50 |Send a configuration command to uDMA TX channel (the register value is given in the following word) | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + |:ref:`CMD_UDMA_RX_CHAN_CFG` | 32|0x51 |Send a configuration command to uDMA RX channel (the register value is given in the following word) | + +---------------------------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------------------------------------------+ + +.. _I2C micro-code__CMD_MISC_NOP: CMD_MISC_NOP """""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------+------------------------------------+ |Bit #| Name | Description | @@ -202,12 +223,14 @@ CMD_MISC_NOP |31:24|I2C_CMD|Command code -- here “MISC_NOP”=0x00| +-----+-------+------------------------------------+ -.. _I2C micro-code_CMD_MISC_WAIT: +.. _I2C micro-code__CMD_MISC_WAIT: CMD_MISC_WAIT """"""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------+-------------------------------------+ |Bit #| Name | Description | @@ -215,12 +238,14 @@ CMD_MISC_WAIT |31:24|I2C_CMD|Command code -- here “MISC_WAIT”=0x01| +-----+-------+-------------------------------------+ -.. _I2C micro-code_CMD_MISC_REPEAT: +.. _I2C micro-code__CMD_MISC_REPEAT: CMD_MISC_REPEAT """"""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+--------------+-------------------------------------------------------------------------------------------------------------------------------+ |Bit #| Name | Description | @@ -230,12 +255,14 @@ CMD_MISC_REPEAT |31:24|I2C_CMD |Command code -- here “MISC_REPEAT”=0x02 | +-----+--------------+-------------------------------------------------------------------------------------------------------------------------------+ -.. _I2C micro-code_CMD_MISC_WAIT_I2C_PERIOD_END: +.. _I2C micro-code__CMD_MISC_WAIT_I2C_PERIOD_END: CMD_MISC_WAIT_I2C_PERIOD_END """""""""""""""""""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------+----------------------------------------------------+ |Bit #| Name | Description | @@ -243,31 +270,35 @@ CMD_MISC_WAIT_I2C_PERIOD_END |31:24|I2C_CMD|Command code -- here “MISC_WAIT_I2C_PERIOD_END”=0x03| +-----+-------+----------------------------------------------------+ -.. _I2C micro-code_CMD_TIMING: +.. _I2C micro-code__CMD_TIMING: CMD_TIMING """""""""" .. table:: - - +-----+-------+--------------------------------------------------------------------------------------------------------------+ - |Bit #| Name | Description | - +=====+=======+==============================================================================================================+ - |3:0 |DL |Setup scl low duration: T_low=i2c_period x (DL + 4) | - +-----+-------+--------------------------------------------------------------------------------------------------------------+ - |7:4 |DH |Setup scl high duration: T_high=i2c_period x (DL + 4) | - +-----+-------+--------------------------------------------------------------------------------------------------------------+ - |11:8 |DP |Division factor between PERIPH clock and i2c clock, minus 1. Must be ≥ 1. DP=99 at reset (i.e. divide by 100).| - +-----+-------+--------------------------------------------------------------------------------------------------------------+ - |31:24|I2C_CMD|Command code -- here “TIMING”=0x10 | - +-----+-------+--------------------------------------------------------------------------------------------------------------+ - -.. _I2C micro-code_CMD_FOLL_ADDR: + :align: center + :widths: 15 45 90 + + +-----+-------+-------------------------------------------------------------------------------------------------------------------------+ + |Bit #| Name | Description | + +=====+=======+=========================================================================================================================+ + |3:0 |DL |Setup scl low duration: T_low=i2c_period :math:`\times` (DL + 4) | + +-----+-------+-------------------------------------------------------------------------------------------------------------------------+ + |7:4 |DH |Setup scl high duration: T_high=i2c_period :math:`\times` (DL + 4) | + +-----+-------+-------------------------------------------------------------------------------------------------------------------------+ + |11:8 |DP |Division factor between PERIPH clock and i2c clock, minus 1. Must be :math:`\geq` 1. DP=99 at reset (i.e. divide by 100).| + +-----+-------+-------------------------------------------------------------------------------------------------------------------------+ + |31:24|I2C_CMD|Command code -- here “TIMING”=0x10 | + +-----+-------+-------------------------------------------------------------------------------------------------------------------------+ + +.. _I2C micro-code__CMD_FOLL_ADDR: CMD_FOLL_ADDR """"""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-----------------+------------------------------------------------------------------------+ |Bit #| Name | Description | @@ -295,12 +326,14 @@ CMD_FOLL_ADDR |31:24|I2C_CMD |Command code -- here “FOLL_ADDR”=0x20 | +-----+-----------------+------------------------------------------------------------------------+ -.. _I2C micro-code_CMD_LEAD_START: +.. _I2C micro-code__CMD_LEAD_START: CMD_LEAD_START """""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------+--------------------------------------+ |Bit #| Name | Description | @@ -308,12 +341,14 @@ CMD_LEAD_START |31:24|I2C_CMD|Command code -- here “LEAD_START”=0x30| +-----+-------+--------------------------------------+ -.. _I2C micro-code_CMD_LEAD_SEND: +.. _I2C micro-code__CMD_LEAD_SEND: CMD_LEAD_SEND """"""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+------------------+----------------------------------------------------------------+ |Bit #| Name | Description | @@ -325,12 +360,14 @@ CMD_LEAD_SEND |31:24|I2C_CMD |Command code -- here “LEAD_SEND”=0x31 | +-----+------------------+----------------------------------------------------------------+ -.. _I2C micro-code_CMD_LEAD_SEND_IMM: +.. _I2C micro-code__CMD_LEAD_SEND_IMM: CMD_LEAD_SEND_IMM """"""""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+------------------+----------------------------------------------------------------+ |Bit #| Name | Description | @@ -344,25 +381,39 @@ CMD_LEAD_SEND_IMM |31:24|I2C_CMD |Command code -- here “LEAD_SEND_IMM”=0x32 | +-----+------------------+----------------------------------------------------------------+ -.. _I2C micro-code_CMD_LEAD_SEND_IMM_ADDR: +.. _I2C micro-code__CMD_LEAD_SEND_IMM_ADDR: CMD_LEAD_SEND_IMM_ADDR """""""""""""""""""""" .. table:: - - +-----+----------------------+-----------+ - |Bit #| Name |Description| - +=====+======================+===========+ - |31:0 |CMD_LEAD_SEND_IMM_ADDR| | - +-----+----------------------+-----------+ - -.. _I2C micro-code_CMD_LEAD_RECV: + :align: center + :widths: 15 45 90 + + +-----+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #| Name | Description | + +=====+==================+===============================================================================================================================================+ + |7:0 |ADDR8 |Address LSBs: in 7-bit addressing, it is made of the 7 address bits + direction bit; in 10-bit adressing, it is the 8 LSBs of the address. | + +-----+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |ADDR16 |Address MSBs in 10-bit addressing: b11110 + address bits 9 and 8 + direction bit. | + +-----+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ + |15 |ADDRESS_MODE |If 0, send 7-bit address (i.e. send ADDR8 byte only); if 1, send 10-bit address (i.e. ADDR16 as the first byte, then ADDR8 as the second byte).| + +-----+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ + |22 |TWEAK_IGNORE_NACK |If 1, ignore NACK error: it will not trigger an event nor a lock | + +-----+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ + |23 |TWEAK_STOP_ON_NACK|If 1, on NACK automatically send a stop | + +-----+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ + |31:24|I2C_CMD |Command code -- here “LEAD_SEND_IMM_ADDR”=0x37 | + +-----+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _I2C micro-code__CMD_LEAD_RECV: CMD_LEAD_RECV """"""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------+-------------------------------------+ |Bit #| Name | Description | @@ -370,12 +421,14 @@ CMD_LEAD_RECV |31:24|I2C_CMD|Command code -- here “LEAD_RECV”=0x33| +-----+-------+-------------------------------------+ -.. _I2C micro-code_CMD_LEAD_RECV_LAST: +.. _I2C micro-code__CMD_LEAD_RECV_LAST: CMD_LEAD_RECV_LAST """""""""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------+------------------------------------------+ |Bit #| Name | Description | @@ -383,12 +436,14 @@ CMD_LEAD_RECV_LAST |31:24|I2C_CMD|Command code -- here “LEAD_RECV_LAST”=0x34| +-----+-------+------------------------------------------+ -.. _I2C micro-code_CMD_LEAD_STOP: +.. _I2C micro-code__CMD_LEAD_STOP: CMD_LEAD_STOP """"""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------+-------------------------------------+ |Bit #| Name | Description | @@ -396,12 +451,14 @@ CMD_LEAD_STOP |31:24|I2C_CMD|Command code -- here “LEAD_STOP”=0x36| +-----+-------+-------------------------------------+ -.. _I2C micro-code_CMD_EVENT_RECV: +.. _I2C micro-code__CMD_EVENT_RECV: CMD_EVENT_RECV """""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+---------+--------------------------------------+ |Bit #| Name | Description | @@ -411,12 +468,14 @@ CMD_EVENT_RECV |31:24|I2C_CMD |Command code -- here “EVENT_RECV”=0x40| +-----+---------+--------------------------------------+ -.. _I2C micro-code_CMD_EVENT_SEND: +.. _I2C micro-code__CMD_EVENT_SEND: CMD_EVENT_SEND """""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------+--------------------------------------+ |Bit #| Name | Description | @@ -424,12 +483,14 @@ CMD_EVENT_SEND |31:24|I2C_CMD|Command code -- here “EVENT_SEND”=0x41| +-----+-------+--------------------------------------+ -.. _I2C micro-code_CMD_UDMA_TX_CHAN_CFG: +.. _I2C micro-code__CMD_UDMA_TX_CHAN_CFG: CMD_UDMA_TX_CHAN_CFG """""""""""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------------+------------------------------------------------------------------------------+ |Bit #| Name | Description | @@ -439,12 +500,14 @@ CMD_UDMA_TX_CHAN_CFG |31:24|I2C_CMD |Command code -- here “UDMA_TX_CHAN_CFG”=0x50 | +-----+-------------+------------------------------------------------------------------------------+ -.. _I2C micro-code_CMD_UDMA_RX_CHAN_CFG: +.. _I2C micro-code__CMD_UDMA_RX_CHAN_CFG: CMD_UDMA_RX_CHAN_CFG """""""""""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------------+------------------------------------------------------------------------------+ |Bit #| Name | Description | diff --git a/rtos/pulp/gap_archi/doc/ips/udma_i2s.rst b/rtos/pulp/gap_archi/doc/ips/udma_i2s.rst index 26fbe3f20..70e8ee006 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_i2s.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_i2s.rst @@ -8,71 +8,76 @@ Register map Overview """""""" -.. table:: - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - | Name |Offset|Width| Description | - +================================================+======+=====+===========================================================+ - |:ref:`SLOT_CFG_0` | 0| 32|Configuration for slot 0 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_1` | 4| 32|Configuration for slot 1 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_2` | 8| 32|Configuration for slot 2 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_3` | 12| 32|Configuration for slot 3 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_4` | 16| 32|Configuration for slot 4 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_5` | 20| 32|Configuration for slot 5 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_6` | 24| 32|Configuration for slot 6 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_7` | 28| 32|Configuration for slot 7 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_8` | 32| 32|Configuration for slot 8 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_9` | 36| 32|Configuration for slot 9 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_10` | 40| 32|Configuration for slot 10 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_11` | 44| 32|Configuration for slot 11 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_12` | 48| 32|Configuration for slot 12 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_13` | 52| 32|Configuration for slot 13 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_14` | 56| 32|Configuration for slot 14 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_CFG_15` | 60| 32|Configuration for slot 15 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`WORD_SIZE_0_1` | 64| 32|Defines word size for RX and TX channels for slot 0 and 1 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`WORD_SIZE_2_3` | 68| 32|Defines word size for RX and TX channels for slot 2 and 3 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`WORD_SIZE_4_5` | 72| 32|Defines word size for RX and TX channels for slot 4 and 5 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`WORD_SIZE_6_7` | 76| 32|Defines word size for RX and TX channels for slot 6 and 7 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`WORD_SIZE_8_9` | 80| 32|Defines word size for RX and TX channels for slot 8 and 9 | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`WORD_SIZE_10_11`| 84| 32|Defines word size for RX and TX channels for slot 10 and 11| - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`WORD_SIZE_12_13`| 88| 32|Defines word size for RX and TX channels for slot 12 and 13| - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`WORD_SIZE_14_15`| 92| 32|Defines word size for RX and TX channels for slot 14 and 15| - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`SLOT_EN` | 96| 32|Slot Enable | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CLKCFG_SETUP` | 100| 32|Clock configuration for both master, slave and pdm | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`GLB_SETUP` | 104| 32|Configuration of the global parameters | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`CLK_FAST` | 108| 32|Configuration to use reference fast clock | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - |:ref:`ERR_STATUS` | 112| 32|Error status for all slots 0-15 RX slots 16-31 TX slots | - +------------------------------------------------+------+-----+-----------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_0: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + | Name |Offset|Width| Description | + +=================================================+======+=====+===========================================================+ + |:ref:`SLOT_CFG_0` | 0| 32|Configuration for slot 0 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_1` | 4| 32|Configuration for slot 1 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_2` | 8| 32|Configuration for slot 2 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_3` | 12| 32|Configuration for slot 3 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_4` | 16| 32|Configuration for slot 4 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_5` | 20| 32|Configuration for slot 5 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_6` | 24| 32|Configuration for slot 6 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_7` | 28| 32|Configuration for slot 7 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_8` | 32| 32|Configuration for slot 8 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_9` | 36| 32|Configuration for slot 9 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_10` | 40| 32|Configuration for slot 10 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_11` | 44| 32|Configuration for slot 11 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_12` | 48| 32|Configuration for slot 12 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_13` | 52| 32|Configuration for slot 13 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_14` | 56| 32|Configuration for slot 14 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_CFG_15` | 60| 32|Configuration for slot 15 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`WORD_SIZE_0_1` | 64| 32|Defines word size for RX and TX channels for slot 0 and 1 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`WORD_SIZE_2_3` | 68| 32|Defines word size for RX and TX channels for slot 2 and 3 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`WORD_SIZE_4_5` | 72| 32|Defines word size for RX and TX channels for slot 4 and 5 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`WORD_SIZE_6_7` | 76| 32|Defines word size for RX and TX channels for slot 6 and 7 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`WORD_SIZE_8_9` | 80| 32|Defines word size for RX and TX channels for slot 8 and 9 | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`WORD_SIZE_10_11`| 84| 32|Defines word size for RX and TX channels for slot 10 and 11| + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`WORD_SIZE_12_13`| 88| 32|Defines word size for RX and TX channels for slot 12 and 13| + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`WORD_SIZE_14_15`| 92| 32|Defines word size for RX and TX channels for slot 14 and 15| + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`SLOT_EN` | 96| 32|Slot Enable | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CLKCFG_SETUP` | 100| 32|Clock configuration for both master, slave and PDM | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`GLB_SETUP` | 104| 32|Configuration of the global parameters | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CLK_FAST` | 108| 32|Configuration to use reference fast clock | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`ERR_STATUS` | 112| 32|Error status for all slots 0-15 RX slots 16-31 TX slots | + +-------------------------------------------------+------+-----+-----------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_0: SLOT_CFG_0 """""""""" @@ -80,38 +85,40 @@ SLOT_CFG_0 Configuration for slot 0 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_1: SLOT_CFG_1 """""""""" @@ -119,38 +126,40 @@ SLOT_CFG_1 Configuration for slot 1 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_2: SLOT_CFG_2 """""""""" @@ -158,38 +167,40 @@ SLOT_CFG_2 Configuration for slot 2 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_3: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_3: SLOT_CFG_3 """""""""" @@ -197,38 +208,40 @@ SLOT_CFG_3 Configuration for slot 3 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_4: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_4: SLOT_CFG_4 """""""""" @@ -236,38 +249,40 @@ SLOT_CFG_4 Configuration for slot 4 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_5: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_5: SLOT_CFG_5 """""""""" @@ -275,38 +290,40 @@ SLOT_CFG_5 Configuration for slot 5 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_6: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_6: SLOT_CFG_6 """""""""" @@ -314,38 +331,40 @@ SLOT_CFG_6 Configuration for slot 6 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_7: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_7: SLOT_CFG_7 """""""""" @@ -353,38 +372,40 @@ SLOT_CFG_7 Configuration for slot 7 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_8: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_8: SLOT_CFG_8 """""""""" @@ -392,38 +413,40 @@ SLOT_CFG_8 Configuration for slot 8 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_9: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_9: SLOT_CFG_9 """""""""" @@ -431,38 +454,40 @@ SLOT_CFG_9 Configuration for slot 9 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_10: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_10: SLOT_CFG_10 """"""""""" @@ -470,38 +495,40 @@ SLOT_CFG_10 Configuration for slot 10 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_11: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_11: SLOT_CFG_11 """"""""""" @@ -509,38 +536,40 @@ SLOT_CFG_11 Configuration for slot 11 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_12: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_12: SLOT_CFG_12 """"""""""" @@ -548,38 +577,40 @@ SLOT_CFG_12 Configuration for slot 12 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_13: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_13: SLOT_CFG_13 """"""""""" @@ -587,38 +618,40 @@ SLOT_CFG_13 Configuration for slot 13 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_14: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_14: SLOT_CFG_14 """"""""""" @@ -626,38 +659,40 @@ SLOT_CFG_14 Configuration for slot 14 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_SLOT_CFG_15: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__SLOT_CFG_15: SLOT_CFG_15 """"""""""" @@ -665,38 +700,40 @@ SLOT_CFG_15 Configuration for slot 15 .. table:: - - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+========================================================================================================+ - |7:0 |R/W|ID_RX |uDMA Stream ID for RX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |8 |R/W|RX_EN |Enable RX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |9 |R/W|RX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |10 |R/W|RX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |13:12|R/W|RX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |14 |R/W|RX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |23:16|R/W|TX_ID |uDMA Stream ID for TX channel | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |24 |R/W|TX_EN |Enable TX for the slot | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |25 |R/W|TX_MSB_FIRST |Configuration of the MSB or LSB first: - 1’b0 : LSB - 1’b1 : MSB | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |26 |R/W|TX_LEFT_ALIGN|Justification to the left or to the right: - 1’b0 : right - 1’b1 : left | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |29:28|R/W|TX_DSIZE |uDMA transfer size: - 2’b00 : 1 byte - 2’b01 : 2 bytes - 2’b10 : 3 bytes - 2’b11 : 4 bytes| - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |30 |R/W|TX_SIGN |Enables sign extension on RX data | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - |31 |R/W|BYP |Enables INput to OUTput Bypass | - +-----+---+-------------+--------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_WORD_SIZE_0_1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=========================================================================+ + |7:0 |r/w|id_rx |0x7f |udma Stream ID for RX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |8 |R/W|RX_EN |0x0 |Enable RX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |9 |R/W|RX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |10 |R/W|RX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right ; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |13:12|R/W|RX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |14 |R/W|RX_SIGN |0x0 |Enables sign extension on RX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |23:16|R/W|TX_ID |0x7F |UDMA stream ID for TX channel | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |24 |R/W|TX_EN |0x0 |Enable TX for the slot | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |25 |R/W|TX_MSB_FIRST |0x0 |Configuration of the MSB or LSB first: b0: LSB; b1: MSB | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |26 |R/W|TX_LEFT_ALIGN|0x0 |Justification to the left or to the right: b0: right; b1: left | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |29:28|R/W|TX_DSIZE |0x0 |UDMA transfer size: b00: 1 byte; b01: 2 bytes; b10: 3 bytes; b11: 4 bytes| + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |30 |R/W|TX_SIGN |0x0 |Enables sign extension on TX data | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + |31 |R/W|BYP |0x0 |Enables input-to-output bypass | + +-----+---+-------------+-----+-------------------------------------------------------------------------+ + +.. _udma_i2s__WORD_SIZE_0_1: WORD_SIZE_0_1 """"""""""""" @@ -704,20 +741,22 @@ WORD_SIZE_0_1 Defines word size for RX and TX channels for slot 0 and 1 .. table:: - - +-----+---+--------------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===================================+ - |4:0 |R/W|WORD_SIZE_RX_0|Word size for RX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |12:8 |R/W|WORD_SIZE_TX_0|Word size for TX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |20:16|R/W|WORD_SIZE_RX_1|Word size for RX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - |28:24|R/W|WORD_SIZE_TX_1|Word size for TX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - -.. _udma_i2s_WORD_SIZE_2_3: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+-----+-----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===================================+ + |4:0 |R/W|WORD_SIZE_RX_0|0x0 |Word size for RX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |12:8 |R/W|WORD_SIZE_TX_0|0x0 |Word size for TX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |20:16|R/W|WORD_SIZE_RX_1|0x0 |Word size for RX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + |28:24|R/W|WORD_SIZE_TX_1|0x0 |Word size for TX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + +.. _udma_i2s__WORD_SIZE_2_3: WORD_SIZE_2_3 """"""""""""" @@ -725,20 +764,22 @@ WORD_SIZE_2_3 Defines word size for RX and TX channels for slot 2 and 3 .. table:: - - +-----+---+--------------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===================================+ - |4:0 |R/W|WORD_SIZE_RX_0|Word size for RX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |12:8 |R/W|WORD_SIZE_TX_0|Word size for TX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |20:16|R/W|WORD_SIZE_RX_1|Word size for RX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - |28:24|R/W|WORD_SIZE_TX_1|Word size for TX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - -.. _udma_i2s_WORD_SIZE_4_5: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+-----+-----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===================================+ + |4:0 |R/W|WORD_SIZE_RX_0|0x0 |Word size for RX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |12:8 |R/W|WORD_SIZE_TX_0|0x0 |Word size for TX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |20:16|R/W|WORD_SIZE_RX_1|0x0 |Word size for RX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + |28:24|R/W|WORD_SIZE_TX_1|0x0 |Word size for TX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + +.. _udma_i2s__WORD_SIZE_4_5: WORD_SIZE_4_5 """"""""""""" @@ -746,20 +787,22 @@ WORD_SIZE_4_5 Defines word size for RX and TX channels for slot 4 and 5 .. table:: - - +-----+---+--------------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===================================+ - |4:0 |R/W|WORD_SIZE_RX_0|Word size for RX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |12:8 |R/W|WORD_SIZE_TX_0|Word size for TX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |20:16|R/W|WORD_SIZE_RX_1|Word size for RX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - |28:24|R/W|WORD_SIZE_TX_1|Word size for TX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - -.. _udma_i2s_WORD_SIZE_6_7: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+-----+-----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===================================+ + |4:0 |R/W|WORD_SIZE_RX_0|0x0 |Word size for RX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |12:8 |R/W|WORD_SIZE_TX_0|0x0 |Word size for TX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |20:16|R/W|WORD_SIZE_RX_1|0x0 |Word size for RX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + |28:24|R/W|WORD_SIZE_TX_1|0x0 |Word size for TX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + +.. _udma_i2s__WORD_SIZE_6_7: WORD_SIZE_6_7 """"""""""""" @@ -767,20 +810,22 @@ WORD_SIZE_6_7 Defines word size for RX and TX channels for slot 6 and 7 .. table:: - - +-----+---+--------------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===================================+ - |4:0 |R/W|WORD_SIZE_RX_0|Word size for RX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |12:8 |R/W|WORD_SIZE_TX_0|Word size for TX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |20:16|R/W|WORD_SIZE_RX_1|Word size for RX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - |28:24|R/W|WORD_SIZE_TX_1|Word size for TX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - -.. _udma_i2s_WORD_SIZE_8_9: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+-----+-----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===================================+ + |4:0 |R/W|WORD_SIZE_RX_0|0x0 |Word size for RX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |12:8 |R/W|WORD_SIZE_TX_0|0x0 |Word size for TX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |20:16|R/W|WORD_SIZE_RX_1|0x0 |Word size for RX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + |28:24|R/W|WORD_SIZE_TX_1|0x0 |Word size for TX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + +.. _udma_i2s__WORD_SIZE_8_9: WORD_SIZE_8_9 """"""""""""" @@ -788,20 +833,22 @@ WORD_SIZE_8_9 Defines word size for RX and TX channels for slot 8 and 9 .. table:: - - +-----+---+--------------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===================================+ - |4:0 |R/W|WORD_SIZE_RX_0|Word size for RX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |12:8 |R/W|WORD_SIZE_TX_0|Word size for TX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |20:16|R/W|WORD_SIZE_RX_1|Word size for RX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - |28:24|R/W|WORD_SIZE_TX_1|Word size for TX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - -.. _udma_i2s_WORD_SIZE_10_11: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+-----+-----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===================================+ + |4:0 |R/W|WORD_SIZE_RX_0|0x0 |Word size for RX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |12:8 |R/W|WORD_SIZE_TX_0|0x0 |Word size for TX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |20:16|R/W|WORD_SIZE_RX_1|0x0 |Word size for RX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + |28:24|R/W|WORD_SIZE_TX_1|0x0 |Word size for TX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + +.. _udma_i2s__WORD_SIZE_10_11: WORD_SIZE_10_11 """"""""""""""" @@ -809,20 +856,22 @@ WORD_SIZE_10_11 Defines word size for RX and TX channels for slot 10 and 11 .. table:: - - +-----+---+--------------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===================================+ - |4:0 |R/W|WORD_SIZE_RX_0|Word size for RX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |12:8 |R/W|WORD_SIZE_TX_0|Word size for TX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |20:16|R/W|WORD_SIZE_RX_1|Word size for RX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - |28:24|R/W|WORD_SIZE_TX_1|Word size for TX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - -.. _udma_i2s_WORD_SIZE_12_13: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+-----+-----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===================================+ + |4:0 |R/W|WORD_SIZE_RX_0|0x0 |Word size for RX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |12:8 |R/W|WORD_SIZE_TX_0|0x0 |Word size for TX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |20:16|R/W|WORD_SIZE_RX_1|0x0 |Word size for RX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + |28:24|R/W|WORD_SIZE_TX_1|0x0 |Word size for TX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + +.. _udma_i2s__WORD_SIZE_12_13: WORD_SIZE_12_13 """"""""""""""" @@ -830,20 +879,22 @@ WORD_SIZE_12_13 Defines word size for RX and TX channels for slot 12 and 13 .. table:: - - +-----+---+--------------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===================================+ - |4:0 |R/W|WORD_SIZE_RX_0|Word size for RX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |12:8 |R/W|WORD_SIZE_TX_0|Word size for TX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |20:16|R/W|WORD_SIZE_RX_1|Word size for RX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - |28:24|R/W|WORD_SIZE_TX_1|Word size for TX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - -.. _udma_i2s_WORD_SIZE_14_15: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+-----+-----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===================================+ + |4:0 |R/W|WORD_SIZE_RX_0|0x0 |Word size for RX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |12:8 |R/W|WORD_SIZE_TX_0|0x0 |Word size for TX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |20:16|R/W|WORD_SIZE_RX_1|0x0 |Word size for RX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + |28:24|R/W|WORD_SIZE_TX_1|0x0 |Word size for TX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + +.. _udma_i2s__WORD_SIZE_14_15: WORD_SIZE_14_15 """"""""""""""" @@ -851,20 +902,22 @@ WORD_SIZE_14_15 Defines word size for RX and TX channels for slot 14 and 15 .. table:: - - +-----+---+--------------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===================================+ - |4:0 |R/W|WORD_SIZE_RX_0|Word size for RX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |12:8 |R/W|WORD_SIZE_TX_0|Word size for TX channel of slots 0| - +-----+---+--------------+-----------------------------------+ - |20:16|R/W|WORD_SIZE_RX_1|Word size for RX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - |28:24|R/W|WORD_SIZE_TX_1|Word size for TX channel of slots 1| - +-----+---+--------------+-----------------------------------+ - -.. _udma_i2s_SLOT_EN: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+-----+-----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+===================================+ + |4:0 |R/W|WORD_SIZE_RX_0|0x0 |Word size for RX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |12:8 |R/W|WORD_SIZE_TX_0|0x0 |Word size for TX channel of slots 0| + +-----+---+--------------+-----+-----------------------------------+ + |20:16|R/W|WORD_SIZE_RX_1|0x0 |Word size for RX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + |28:24|R/W|WORD_SIZE_TX_1|0x0 |Word size for TX channel of slots 1| + +-----+---+--------------+-----+-----------------------------------+ + +.. _udma_i2s__SLOT_EN: SLOT_EN """"""" @@ -872,75 +925,79 @@ SLOT_EN Slot Enable .. table:: - - +-----+---+----------+------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+==================+ - | 0|R/W|SLOT_EN_0 |Enable for slot 0 | - +-----+---+----------+------------------+ - | 1|R/W|SLOT_EN_1 |Enable for slot 1 | - +-----+---+----------+------------------+ - | 2|R/W|SLOT_EN_2 |Enable for slot 2 | - +-----+---+----------+------------------+ - | 3|R/W|SLOT_EN_3 |Enable for slot 3 | - +-----+---+----------+------------------+ - | 4|R/W|SLOT_EN_4 |Enable for slot 4 | - +-----+---+----------+------------------+ - | 5|R/W|SLOT_EN_5 |Enable for slot 5 | - +-----+---+----------+------------------+ - | 6|R/W|SLOT_EN_6 |Enable for slot 6 | - +-----+---+----------+------------------+ - | 7|R/W|SLOT_EN_7 |Enable for slot 7 | - +-----+---+----------+------------------+ - | 8|R/W|SLOT_EN_8 |Enable for slot 8 | - +-----+---+----------+------------------+ - | 9|R/W|SLOT_EN_9 |Enable for slot 9 | - +-----+---+----------+------------------+ - | 10|R/W|SLOT_EN_10|Enable for slot 10| - +-----+---+----------+------------------+ - | 11|R/W|SLOT_EN_11|Enable for slot 11| - +-----+---+----------+------------------+ - | 12|R/W|SLOT_EN_12|Enable for slot 12| - +-----+---+----------+------------------+ - | 13|R/W|SLOT_EN_13|Enable for slot 13| - +-----+---+----------+------------------+ - | 14|R/W|SLOT_EN_14|Enable for slot 14| - +-----+---+----------+------------------+ - | 15|R/W|SLOT_EN_15|Enable for slot 15| - +-----+---+----------+------------------+ - -.. _udma_i2s_CLKCFG_SETUP: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+==================+ + | 0|R/W|SLOT_EN_0 |0x0 |Enable for slot 0 | + +-----+---+----------+-----+------------------+ + | 1|R/W|SLOT_EN_1 |0x0 |Enable for slot 1 | + +-----+---+----------+-----+------------------+ + | 2|R/W|SLOT_EN_2 |0x0 |Enable for slot 2 | + +-----+---+----------+-----+------------------+ + | 3|R/W|SLOT_EN_3 |0x0 |Enable for slot 3 | + +-----+---+----------+-----+------------------+ + | 4|R/W|SLOT_EN_4 |0x0 |Enable for slot 4 | + +-----+---+----------+-----+------------------+ + | 5|R/W|SLOT_EN_5 |0x0 |Enable for slot 5 | + +-----+---+----------+-----+------------------+ + | 6|R/W|SLOT_EN_6 |0x0 |Enable for slot 6 | + +-----+---+----------+-----+------------------+ + | 7|R/W|SLOT_EN_7 |0x0 |Enable for slot 7 | + +-----+---+----------+-----+------------------+ + | 8|R/W|SLOT_EN_8 |0x0 |Enable for slot 8 | + +-----+---+----------+-----+------------------+ + | 9|R/W|SLOT_EN_9 |0x0 |Enable for slot 9 | + +-----+---+----------+-----+------------------+ + | 10|R/W|SLOT_EN_10|0x0 |Enable for slot 10| + +-----+---+----------+-----+------------------+ + | 11|R/W|SLOT_EN_11|0x0 |Enable for slot 11| + +-----+---+----------+-----+------------------+ + | 12|R/W|SLOT_EN_12|0x0 |Enable for slot 12| + +-----+---+----------+-----+------------------+ + | 13|R/W|SLOT_EN_13|0x0 |Enable for slot 13| + +-----+---+----------+-----+------------------+ + | 14|R/W|SLOT_EN_14|0x0 |Enable for slot 14| + +-----+---+----------+-----+------------------+ + | 15|R/W|SLOT_EN_15|0x0 |Enable for slot 15| + +-----+---+----------+-----+------------------+ + +.. _udma_i2s__CLKCFG_SETUP: CLKCFG_SETUP """""""""""" -Clock configuration for both master, slave and pdm +Clock configuration for both master, slave and PDM .. table:: - - +-----+---+-----------+-------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===========+=====================================================================================+ - |15:0 |R/W|CLK_DIV |Clock Divider | - +-----+---+-----------+-------------------------------------------------------------------------------------+ - |16 |R/W|CLK_EN |Enables Clock Generator | - +-----+---+-----------+-------------------------------------------------------------------------------------+ - |17 |R/W|CLK_SRC |Clock internal or external - 1’b0 : internal - 1’b1 : external | - +-----+---+-----------+-------------------------------------------------------------------------------------+ - |18 |R/W|CLK_EXT_SRC|Clock External Source - 1’b0 : pad - 1’b1 : internally routed | - +-----+---+-----------+-------------------------------------------------------------------------------------+ - |19 |R/W|CLK_EDGE |Clock polarity - 1’b0 : rising edge - 1’b1 : falling edge | - +-----+---+-----------+-------------------------------------------------------------------------------------+ - |20 |R/W|WS_SRC |WS internal or external - 1’b0 : internal - 1’b1 : external | - +-----+---+-----------+-------------------------------------------------------------------------------------+ - |21 |R/W|WS_EXT_SRC |WS External Source - 1’b0 : pad - 1’b1 : internally routed | - +-----+---+-----------+-------------------------------------------------------------------------------------+ - |22 |R/W|WS_EDGE |WS Polarity - 1’b0 : rising edge - 1’b1 : falling edge | - +-----+---+-----------+-------------------------------------------------------------------------------------+ - |24:23|R/W|WS_TYPE |WS Type: - 2’b00 : pulse - 2’b01 : state - 2’b10 : N/2 frame - 1’b11 : don’t care| - +-----+---+-----------+-------------------------------------------------------------------------------------+ - -.. _udma_i2s_GLB_SETUP: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+==================================================================================================================+ + |15:0 |R/W|CLK_DIV |0x0 |Clock divider | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |16 |R/W|CLK_EN |0x0 |Enables clock generator | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |17 |R/W|CLK_SRC |0x0 |Clock internal or external: b0: internal; b1: external | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |18 |R/W|CLK_EXT_SRC|0x0 |Clock external source: b0: pad; b1: internally routed (from SAI0) | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |19 |R/W|CLK_EDGE |0x0 |Clock polarity: b0: rising edge; b1: falling edge | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |20 |R/W|WS_SRC |0x0 |WS internal or external: b0: internal; b1: external | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |21 |R/W|WS_EXT_SRC |0x0 |WS external source: b0: pad; b1: internally routed (from SAI0) | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |22 |R/W|WS_EDGE |0x0 |WS polarity: b0: rising edge; b1: falling edge | + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + |24:23|R/W|WS_TYPE |0x0 |WS type (duration): b00: pulse (first bit of first slot); b01: first slot; b10: half frame (N/2 slots); b11: pulse| + +-----+---+-----------+-----+------------------------------------------------------------------------------------------------------------------+ + +.. _udma_i2s__GLB_SETUP: GLB_SETUP """"""""" @@ -948,30 +1005,32 @@ GLB_SETUP Configuration of the global parameters .. table:: - - +-----+---+--------------+--------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+==============================================================================================================+ - | 0|R/W|GLOBAL_EN |Enables the I2s interface | - +-----+---+--------------+--------------------------------------------------------------------------------------------------------------+ - |4:1 |R/W|FRAME_LENGTH |Sets how many slots for each frame(1-16) | - +-----+---+--------------+--------------------------------------------------------------------------------------------------------------+ - |9:5 |R/W|SLOT_WIDTH |Sets the slot width in bits(1-32) | - +-----+---+--------------+--------------------------------------------------------------------------------------------------------------+ - |12:10|R/W|WS_DELAY |Sets the distance in i2s cycles from the WS rising edge to the first bit of the frame | - +-----+---+--------------+--------------------------------------------------------------------------------------------------------------+ - |13 |R/W|FULL_DUPLEX_EN|Enables Full Duplex mode(SDI and SDO) | - +-----+---+--------------+--------------------------------------------------------------------------------------------------------------+ - |14 |R/W|PDM_EN |switch to PDM mode on sdi (bit0) and sdo (bit1) (2 pdm lanes, 2 slave channels or 1 master channels per lane )| - +-----+---+--------------+--------------------------------------------------------------------------------------------------------------+ - |16:15|R/W|PDM_POL |set lane polarity (0: slave, 1:master) for sdi (bit0) and sdo (bit1) | - +-----+---+--------------+--------------------------------------------------------------------------------------------------------------+ - |18:17|R/W|PDM_DIFF |in master mode only: set differential mode on pairs, bit0: (sdi,ws), bit1: (sdo,sck) | - +-----+---+--------------+--------------------------------------------------------------------------------------------------------------+ - |21:19|R/W|BLOCK_COMMIT |Used for synchronization of the 3 instantiated I2S | - +-----+---+--------------+--------------------------------------------------------------------------------------------------------------+ - -.. _udma_i2s_CLK_FAST: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+-----+------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+============================================================================================================+ + | 0|R/W|GLOBAL_EN |0x0 |Enables the I2S interface | + +-----+---+--------------+-----+------------------------------------------------------------------------------------------------------------+ + |4:1 |R/W|FRAME_LENGTH |0x0 |Sets how many slots for each frame (1-16) | + +-----+---+--------------+-----+------------------------------------------------------------------------------------------------------------+ + |9:5 |R/W|SLOT_WIDTH |0x0 |Sets the slot width in bits (1-32) | + +-----+---+--------------+-----+------------------------------------------------------------------------------------------------------------+ + |12:10|R/W|WS_DELAY |0x0 |Sets the distance in I2S cycles from the WS rising edge to the first bit of the frame | + +-----+---+--------------+-----+------------------------------------------------------------------------------------------------------------+ + |13 |R/W|FULL_DUPLEX_EN|0x0 |Enables full duplex mode (SDI and SDO) | + +-----+---+--------------+-----+------------------------------------------------------------------------------------------------------------+ + |14 |R/W|PDM_EN |0x0 |Switch to PDM mode on SDI (bit0) and SDO (bit1) (2 PDM lanes, 2 slave channels or 1 master channel per lane)| + +-----+---+--------------+-----+------------------------------------------------------------------------------------------------------------+ + |16:15|R/W|PDM_POL |0x0 |Set lane polarity (0: slave, 1: master) for SDI (bit0) and SDO (bit1) | + +-----+---+--------------+-----+------------------------------------------------------------------------------------------------------------+ + |18:17|R/W|PDM_DIFF |0x0 |In master mode only: set differential mode on pairs, bit0: (SDI,WS), bit1: (SDO,SCK) | + +-----+---+--------------+-----+------------------------------------------------------------------------------------------------------------+ + |21:19|R/W|BLOCK_COMMIT |0x0 |Used for synchronization of the 3 instantiated I2S | + +-----+---+--------------+-----+------------------------------------------------------------------------------------------------------------+ + +.. _udma_i2s__CLK_FAST: CLK_FAST """""""" @@ -979,14 +1038,16 @@ CLK_FAST Configuration to use reference fast clock .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+===================================+ - | 0|R/W|FAST_EN|Enables to use reference fast clock| - +-----+---+-------+-----------------------------------+ + +-----+---+-------+-----+-----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+===================================+ + | 0|R/W|FAST_EN|0x0 |Enables to use reference fast clock| + +-----+---+-------+-----+-----------------------------------+ -.. _udma_i2s_ERR_STATUS: +.. _udma_i2s__ERR_STATUS: ERR_STATUS """""""""" @@ -994,8 +1055,13 @@ ERR_STATUS Error status for all slots 0-15 RX slots 16-31 TX slots .. table:: - - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-----------+-----+---------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===========+=====+===========================================================================+ + |15:0 |R/W|RX_ERR_FLAG|0x0 |Error status flag for RX slots: bit *i*\ =1 signals an error on RX slot *i*| + +-----+---+-----------+-----+---------------------------------------------------------------------------+ + |31:16|R/W|TX_ERR_FLAG|0x0 |Error status flag for TX slots: bit *i*\ =1 signals an error on TX slot *i*| + +-----+---+-----------+-----+---------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_mram.rst b/rtos/pulp/gap_archi/doc/ips/udma_mram.rst index 712d0cb04..25988e596 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_mram.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_mram.rst @@ -8,49 +8,54 @@ Register map Overview """""""" -.. table:: - +---------------------------------------+------+-----+-------------------------------+ - | Name |Offset|Width| Description | - +=======================================+======+=====+===============================+ - |:ref:`RX_DEST` | 0| 32|Stream ID for the uDMA channel | - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`TX_DEST` | 4| 32|Stream ID for the uDMA channel | - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`TRANS_MODE`| 8| 32|Configure transaction mode | - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`TRANS_ADDR`| 12| 32|Configure each transaction addr| - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`TRANS_SIZE`| 16| 32|Configure each transaction size| - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`TRANS_CFG` | 20| 32|Start each transaction rx/tx | - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`EXT_ADDR` | 24| 32|Memory access address register.| - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`STATUS` | 28| 32|MRAM status register. | - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`MODE` | 32| 32|MRAM mode configure register. | - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`ERASE_ADDR`| 36| 32|Erase address register. | - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`ERASE_SIZE`| 40| 32|Erase size register. | - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`CLK_DIV` | 44| 32|Clock divide. | - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`ISR` | 48| 32|IRQ status register. | - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`IER` | 52| 32|IRQ enable register. | - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`LINE_2D` | 60| 32|OSPI 2D line. | - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`STRIDE_2D` | 64| 32|OSPI 2D stride. | - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`ENABLE_2D` | 68| 32|2D mode enable. | - +---------------------------------------+------+-----+-------------------------------+ - |:ref:`TIMING_CFG`| 72| 32|Timing configuration. | - +---------------------------------------+------+-----+-------------------------------+ - -.. _udma_mram_RX_DEST: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +----------------------------------------+------+-----+-------------------------------+ + | Name |Offset|Width| Description | + +========================================+======+=====+===============================+ + |:ref:`RX_DEST` | 0| 32|Stream ID for the uDMA channel | + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`TX_DEST` | 4| 32|Stream ID for the uDMA channel | + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`TRANS_MODE`| 8| 32|Configure transaction mode | + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`TRANS_ADDR`| 12| 32|Configure each transaction addr| + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`TRANS_SIZE`| 16| 32|Configure each transaction size| + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`TRANS_CFG` | 20| 32|Start each transaction rx/tx | + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`EXT_ADDR` | 24| 32|Memory access address register.| + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`STATUS` | 28| 32|MRAM status register. | + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`MODE` | 32| 32|MRAM mode configure register. | + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`ERASE_ADDR`| 36| 32|Erase address register. | + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`ERASE_SIZE`| 40| 32|Erase size register. | + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`CLK_DIV` | 44| 32|Clock divide. | + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`ISR` | 48| 32|IRQ status register. | + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`IER` | 52| 32|IRQ enable register. | + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`LINE_2D` | 60| 32|OSPI 2D line. | + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`STRIDE_2D` | 64| 32|OSPI 2D stride. | + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`ENABLE_2D` | 68| 32|2D mode enable. | + +----------------------------------------+------+-----+-------------------------------+ + |:ref:`TIMING_CFG`| 72| 32|Timing configuration. | + +----------------------------------------+------+-----+-------------------------------+ + +.. _udma_mram__RX_DEST: RX_DEST """"""" @@ -58,14 +63,16 @@ RX_DEST Stream ID for the uDMA channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===========================================================================+ - |7:0 |R/W|DEST|Stream ID for the RX and TX uDMA channel. Default is 0xFF(channel disabled)| - +-----+---+----+---------------------------------------------------------------------------+ + +-----+---+----+-----+--------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+====================================================================+ + |7:0 |R/W|DEST|0xFF |Stream ID for the RX and TX uDMA channel. Default is 0xFF disabled)| + +-----+---+----+-----+--------------------------------------------------------------------+ -.. _udma_mram_TX_DEST: +.. _udma_mram__TX_DEST: TX_DEST """"""" @@ -73,14 +80,16 @@ TX_DEST Stream ID for the uDMA channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+---------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=====================================================================+ - |7:0 |R/W|DEST|Stream ID for the CMD uDMA channel. Default is 0xFF(channel disabled)| - +-----+---+----+---------------------------------------------------------------------+ + +-----+---+----+-----+--------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+==============================================================+ + |7:0 |R/W|DEST|0xFF |Stream ID for the CMD uDMA channel. Default is 0xFF (disabled)| + +-----+---+----+-----+--------------------------------------------------------------+ -.. _udma_mram_TRANS_MODE: +.. _udma_mram__TRANS_MODE: TRANS_MODE """""""""" @@ -88,22 +97,24 @@ TRANS_MODE Configure transaction mode .. table:: - - +-----+---+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+==========================================================================================================================================================================+ - | 0|R/W|AUTO_ENA |Transfer mode in AUTO, IP will configure the UDMA transfer automatically using register parameters instead using SW configuration in UDMA - 1'b0: AUTO_DIS - 1'b1: AUTO_EN| - +-----+---+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|XIP_EN |Transfer mode in XIP, IP will configure the UDMA transfer automatically using XIP parameters instead using SW configuration in UDMA - 1'b0: XIP_DIS - 1'b1: XIP_EN | - +-----+---+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |3:2 |R |RESERVED |Reserved | - +-----+---+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 4|R/W|XIP_HALTED |Halted XIP refill when in XIP, XIP refill will wait SW unlock this bit. - 1'b0: XIP_RUNNING - 1'b1: XIP_HALTED | - +-----+---+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 5|R/W|XIP_AUTO_HALTED|XIP refills will be automatically blocked when an erase operation is on-going. - 1'b0: Disabled - 1'b1: enabled | - +-----+---+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_mram_TRANS_ADDR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+=========================================================================================================================================================================================+ + | 0|R/W|AUTO_ENA |0x0 |Set transfer mode in AUTO, in which MRAM interface configures the UDMA transfer automatically using register parameters instead using SW configuration of UDMA: b0: disabled; b1: enabled| + +-----+---+---------------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|XIP_EN |0x0 |Transfer mode in XIP, IP will configure the UDMA transfer automatically using XIP parameters instead using SW configuration in UDMA: b0: XIP_DIS; b1: XIP_EN | + +-----+---+---------------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R |RESERVED |0x0 |-- | + +-----+---+---------------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 4|R/W|XIP_HALTED |0x0 |Halted XIP refill when in XIP, XIP refill will wait until SW unlocks this bit: b0: XIP_RUNNING; b1: XIP_HALTED | + +-----+---+---------------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 5|R/W|XIP_AUTO_HALTED|0x0 |XIP refills will be automatically blocked when an erase operation is on-going: b0: disabled; b1: enabled | + +-----+---+---------------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_mram__TRANS_ADDR: TRANS_ADDR """""""""" @@ -111,14 +122,16 @@ TRANS_ADDR Configure each transaction addr .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+----------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+========================================+ - |31:0 |R/W|ADDR|Transfer addr, only when MODE is in AUTO| - +-----+---+----+----------------------------------------+ + +-----+---+----+-----+----------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+========================================+ + |31:0 |R/W|ADDR|0x0 |Transfer addr, only when MODE is in AUTO| + +-----+---+----+-----+----------------------------------------+ -.. _udma_mram_TRANS_SIZE: +.. _udma_mram__TRANS_SIZE: TRANS_SIZE """""""""" @@ -126,14 +139,16 @@ TRANS_SIZE Configure each transaction size .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+=============+ - |20:0 |R/W|SIZE|Transfer Size| - +-----+---+----+-------------+ + +-----+---+----+-----+-------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+=============+ + |20:0 |R/W|SIZE|0x0 |Transfer Size| + +-----+---+----+-----+-------------+ -.. _udma_mram_TRANS_CFG: +.. _udma_mram__TRANS_CFG: TRANS_CFG """"""""" @@ -141,16 +156,18 @@ TRANS_CFG Start each transaction rx/tx .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+---------------------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+===========================================================================+ - | 0|R/W|RXTX |Transfer type - 1'b0: TX - 1'b1: RX | - +-----+---+-----+---------------------------------------------------------------------------+ - | 1|R/W|VALID|Transfer valid to start, always read 0 - 1'b0: clear transfer - 1'b1: Start| - +-----+---+-----+---------------------------------------------------------------------------+ + +-----+---+-----+-----+---------------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=======================================================================================+ + | 0|R/W|RXTX |0x0 |Transfer type: b0: TX; b1: RX | + +-----+---+-----+-----+---------------------------------------------------------------------------------------+ + | 1|R/W|VALID|0x0 |Transfer valid to start: b0: clear transfer; b1: Start transfer. Read always returns O.| + +-----+---+-----+-----+---------------------------------------------------------------------------------------+ -.. _udma_mram_EXT_ADDR: +.. _udma_mram__EXT_ADDR: EXT_ADDR """""""" @@ -158,14 +175,16 @@ EXT_ADDR Memory access address register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+===============================+ - |31:0 |R/W|ADDR|Memory access address bitfield.| - +-----+---+----+-------------------------------+ + +-----+---+----+-----+-------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===============================+ + |31:0 |R/W|ADDR|0x0 |Memory access address bitfield.| + +-----+---+----+-----+-------------------------------+ -.. _udma_mram_STATUS: +.. _udma_mram__STATUS: STATUS """""" @@ -173,24 +192,26 @@ STATUS MRAM status register. .. table:: - - +-----+---+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+===================================================================================================================================================================+ - | 0|R |ERASE_BUSY|Erase busy: - 1'b0: no busy - 1'b1: busy | - +-----+---+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R |TX_BUSY |TX busy: - 1'b0: no busy - 1'b1: busy | - +-----+---+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 2|R |RX_BUSY |RX busy: - 1'b0: no busy - 1'b1: busy | - +-----+---+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 3|R |RESERVED |- | - +-----+---+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 4|R |UE_ERR |Unrecoverable Error, High indicates unrecoverable errors detected. Not 100% accurate for 3 or more bit errors. In the case of 3-bit errors,correct detection is 84%| - +-----+---+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 5|R |EC_ERR |ECC Error Correction, Low indicates no ECC error detected. High indicates 1 or 2 bit errors corrected. | - +-----+---+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_mram_MODE: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+====================================================================================================================================================================+ + | 0|R |ERASE_BUSY|0x0 |Erase busy: b0: not busy; b1: busy | + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R |TX_BUSY |0x0 |TX busy: b0: not busy; b1: busy | + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 2|R |RX_BUSY |0x0 |RX busy: b0: not busy; b1: busy | + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 3|R |RESERVED |0x0 |-- | + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 4|R |UE_ERR |0x0 |Unrecoverable Error, High indicates unrecoverable errors detected. Not 100% accurate for 3 or more bit errors. In the case of 3-bit errors, correct detection is 84%| + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 5|R |EC_ERR |0x0 |ECC Error Correction, Low indicates no ECC error detected. High indicates 1- or 2-bit errors corrected. | + +-----+---+----------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_mram__MODE: MODE """" @@ -198,28 +219,30 @@ MODE MRAM mode configure register. .. table:: - - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+====================================================================================================================================================================+ - | 0|R/W|ECCBYPS |Signal ECC bypass | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 1|R/W|DPD |Signal Deep power down | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 3|R/W|TMEN |Signal TMEN | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 4|R/W|NVR |Signal NVR | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 5|R/W|RSTb |Signal RSTb | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 6|R/W|RETb |Signal RETb | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | 7|R/W|PORb |Signal PORb | - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |15:8 |R/W|OPERATION|MRAM operation configure, -8'h00 power up -8'h01 trim configure -8'h02 program -8'h04 chip erase -8'h08 sector erase -8'h10 word erase -8'h20 power down -8'h40 read| - +-----+---+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_mram_ERASE_ADDR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+==============================================================================================================================================================+ + | 0|R/W|ECCBYPS |0x0 |Signal ECC bypass | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 1|R/W|DPD |0x0 |Signal Deep power down | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 3|R/W|TMEN |0x0 |Signal TMEN | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 4|R/W|NVR |0x0 |Signal NVR | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 5|R/W|RSTb |0x0 |Signal RSTb | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 6|R/W|RETb |0x0 |Signal RETb | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | 7|R/W|PORb |0x0 |Signal PORb | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + |15:8 |R/W|OPERATION|0x0 |Configure MRAM operation: h00: power up; h01: configure trimming; h02: program; h04: chip erase; h08: sector erase; h10 word erase; h20: power down; h40: read| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_mram__ERASE_ADDR: ERASE_ADDR """""""""" @@ -227,16 +250,18 @@ ERASE_ADDR Erase address register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+----------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+==================================+ - |3:0 |R/W|ADDR_LSB|Erase addr, lower 4 bit is useless| - +-----+---+--------+----------------------------------+ - |20:4 |R/W|ADDR_MSB|Erase addr | - +-----+---+--------+----------------------------------+ + +-----+---+--------+-----+----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+==================================+ + |3:0 |R/W|ADDR_LSB|0x0 |Erase addr, lower 4 bit is useless| + +-----+---+--------+-----+----------------------------------+ + |20:4 |R/W|ADDR_MSB|0x0 |Erase addr | + +-----+---+--------+-----+----------------------------------+ -.. _udma_mram_ERASE_SIZE: +.. _udma_mram__ERASE_SIZE: ERASE_SIZE """""""""" @@ -244,14 +269,16 @@ ERASE_SIZE Erase size register. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - |6:0 |R/W|SIZE|Erase Size | - +-----+---+----+-----------+ + +-----+---+----+-----+-----------+ + |Bit #|R/W|Name|Reset|Description| + +=====+===+====+=====+===========+ + |6:0 |R/W|SIZE|0x0 |Erase Size | + +-----+---+----+-----+-----------+ -.. _udma_mram_CLK_DIV: +.. _udma_mram__CLK_DIV: CLK_DIV """"""" @@ -259,18 +286,20 @@ CLK_DIV Clock divide. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+=====================================================================================================================================================+ - |7:0 |R/W|DATA |Clock divide data, form 0 – 255, frequency divide table is : -8’h0 – IO_FREQUENCY / 1 -8’h1 – IO_FREQUENCY / 2 -8’h2 – IO_FREQUENCY / 4 … | - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------+ - |8 |W |VALID |Clock divide valid, user can not control. Every time there is clock divide write access, set 1 by default, then when clock divide is finished, set 0.| - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------+ - |9 |W |ENABLE|MRAM Clock enable. | - +-----+---+------+-----------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=====================================================================================================================================================+ + |7:0 |R/W|DATA |0x0 |Clock divider ratio (0-255): PERIPH clock frequency is divided by pow2(DATA) | + +-----+---+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------+ + |8 |W |VALID |0x0 |Clock divider valid, user cannot control. Every time there is clock divide write access, set 1 by default, then when clock divide is finished, set 0.| + +-----+---+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------+ + |9 |W |ENABLE|0x0 |MRAM Clock enable. | + +-----+---+------+-----+-----------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _udma_mram_ISR: +.. _udma_mram__ISR: ISR """ @@ -278,20 +307,22 @@ ISR IRQ status register. .. table:: - - +-----+---+----------------+-----------------------+ - |Bit #|R/W| Name | Description | - +=====+===+================+=======================+ - | 0|R |erase_done |MRAM erase finish | - +-----+---+----------------+-----------------------+ - | 1|R |program_done |MRAM program finish | - +-----+---+----------------+-----------------------+ - | 2|R |trim_config_done|MRAM trim config finish| - +-----+---+----------------+-----------------------+ - | 3|R |rx_done |MRAM read finish. | - +-----+---+----------------+-----------------------+ - -.. _udma_mram_IER: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------------+-----+-----------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+================+=====+=======================+ + | 0|R |erase_done |0x0 |MRAM erase finish | + +-----+---+----------------+-----+-----------------------+ + | 1|R |program_done |0x0 |MRAM program finish | + +-----+---+----------------+-----+-----------------------+ + | 2|R |trim_config_done|0x0 |MRAM trim config finish| + +-----+---+----------------+-----+-----------------------+ + | 3|R |rx_done |0x0 |MRAM read finish. | + +-----+---+----------------+-----+-----------------------+ + +.. _udma_mram__IER: IER """ @@ -299,28 +330,30 @@ IER IRQ enable register. .. table:: - - +-----+---+------------------+-------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+===============================+ - | 0|R/W|erase_en |MRAM erase IRQ enable | - +-----+---+------------------+-------------------------------+ - | 1|R/W|program_en |MRAM program IRQ enable | - +-----+---+------------------+-------------------------------+ - | 2|R/W|trim_config_en |MRAM trim config IRQ enable | - +-----+---+------------------+-------------------------------+ - | 3|R/W|rx_done_en |MRAM read IRQ enable. | - +-----+---+------------------+-------------------------------+ - | 4|R/W|xip_erase_en |MRAM xip erase IRQ enable | - +-----+---+------------------+-------------------------------+ - | 5|R/W|xip_program_en |MRAM xip program IRQ enable | - +-----+---+------------------+-------------------------------+ - | 6|R/W|xip_trim_config_en|MRAM xip trim config IRQ enable| - +-----+---+------------------+-------------------------------+ - | 7|R/W|rx_xip_done_en |MRAM xip read IRQ enable. | - +-----+---+------------------+-------------------------------+ - -.. _udma_mram_LINE_2D: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------------+-----+-------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===============================+ + | 0|R/W|erase_en |0x0 |MRAM erase IRQ enable | + +-----+---+------------------+-----+-------------------------------+ + | 1|R/W|program_en |0x0 |MRAM program IRQ enable | + +-----+---+------------------+-----+-------------------------------+ + | 2|R/W|trim_config_en |0x0 |MRAM trim config IRQ enable | + +-----+---+------------------+-----+-------------------------------+ + | 3|R/W|rx_done_en |0x0 |MRAM read IRQ enable. | + +-----+---+------------------+-----+-------------------------------+ + | 4|R/W|xip_erase_en |0x0 |MRAM XIP erase IRQ enable | + +-----+---+------------------+-----+-------------------------------+ + | 5|R/W|xip_program_en |0x0 |MRAM XIP program IRQ enable | + +-----+---+------------------+-----+-------------------------------+ + | 6|R/W|xip_trim_config_en|0x0 |MRAM XIP trim config IRQ enable| + +-----+---+------------------+-----+-------------------------------+ + | 7|R/W|rx_xip_done_en |0x0 |MRAM XIP read IRQ enable. | + +-----+---+------------------+-----+-------------------------------+ + +.. _udma_mram__LINE_2D: LINE_2D """"""" @@ -328,14 +361,16 @@ LINE_2D OSPI 2D line. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+--------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W|Name| Description | - +=====+===+====+==============================================================================================================+ - |31:0 |R/W|LINE|OSPI 2D line with 2D mode. For example, ADDR = START_ADDR + i * BURST_STRIDE. Normally, LINE >= BURST_SIZE.| - +-----+---+----+--------------------------------------------------------------------------------------------------------------+ + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------+ + |Bit #|R/W|Name|Reset| Description | + +=====+===+====+=====+===========================================================================================================+ + |31:0 |R/W|LINE|0x0 |OSPI 2D line with 2D mode. For example, ADDR = START_ADDR + i * BURST_STRIDE. Normally, LINE >= BURST_SIZE.| + +-----+---+----+-----+-----------------------------------------------------------------------------------------------------------+ -.. _udma_mram_STRIDE_2D: +.. _udma_mram__STRIDE_2D: STRIDE_2D """"""""" @@ -343,14 +378,16 @@ STRIDE_2D OSPI 2D stride. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+==================================================================================================================+ - |31:0 |R/W|STRIDE|OSPI 2D stride with 2D mode. For example, ADDR = START_ADDR + i * BURST_STRIDE. Normally, STRIDE >= BURST_SIZE.| - +-----+---+------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+------+-----+---------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+===============================================================================================================+ + |31:0 |R/W|STRIDE|0x0 |OSPI 2D stride with 2D mode. For example, ADDR = START_ADDR + i * BURST_STRIDE. Normally, STRIDE >= BURST_SIZE.| + +-----+---+------+-----+---------------------------------------------------------------------------------------------------------------+ -.. _udma_mram_ENABLE_2D: +.. _udma_mram__ENABLE_2D: ENABLE_2D """"""""" @@ -358,14 +395,16 @@ ENABLE_2D 2D mode enable. .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------+-----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+======+=======================================================================+ - | 0|R/W|ENABLE|MRAM 2D mode enable : - 1'b0: 2D mode disable - 1'b1: 2D mode disable| - +-----+---+------+-----------------------------------------------------------------------+ + +-----+---+------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+======+=====+=============================================================+ + | 0|R/W|ENABLE|0x0 |MRAM 2D mode enable: b0: 2D mode disable; b1: 2D mode disable| + +-----+---+------+-----+-------------------------------------------------------------+ -.. _udma_mram_TIMING_CFG: +.. _udma_mram__TIMING_CFG: TIMING_CFG """""""""" @@ -373,21 +412,23 @@ TIMING_CFG Timing configuration. .. table:: - - +-----+---+---------------+----------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+===============+========================================+ - |2:0 |R/W|STROBE_TIME_CNT|Strobe timing couner | - +-----+---+---------------+----------------------------------------+ - |5:3 |R/W|GO_SUP_TIME_CNT|Power Supply timing couner | - +-----+---+---------------+----------------------------------------+ - |8:6 |R/W|MEN_TIME_CNT |MRAM EN timing couner | - +-----+---+---------------+----------------------------------------+ - |15:9 |R/W|RW_TIME_CNT |Latency from write to read timing couner| - +-----+---+---------------+----------------------------------------+ - |18:16|R/W|ADS_TIME_CNT |Address setup time couner | - +-----+---+---------------+----------------------------------------+ - |28:19|R/W|PGS_TIME_CNT |Program Setup time couner | - +-----+---+---------------+----------------------------------------+ - |31:29|R/W|PROG_TIME_CNT |Program Min Pulse Width timing couner | - +-----+---+---------------+----------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------+-----+----------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+===============+=====+========================================+ + |2:0 |R/W|STROBE_TIME_CNT|0x2 |Strobe timing couner | + +-----+---+---------------+-----+----------------------------------------+ + |5:3 |R/W|GO_SUP_TIME_CNT|0x4 |Power Supply timing couner | + +-----+---+---------------+-----+----------------------------------------+ + |8:6 |R/W|MEN_TIME_CNT |0x4 |MRAM EN timing couner | + +-----+---+---------------+-----+----------------------------------------+ + |15:9 |R/W|RW_TIME_CNT |0x78 |Latency from write to read timing couner| + +-----+---+---------------+-----+----------------------------------------+ + |18:16|R/W|ADS_TIME_CNT |0x4 |Address setup time couner | + +-----+---+---------------+-----+----------------------------------------+ + |28:19|R/W|PGS_TIME_CNT |0x320|Program Setup time couner | + +-----+---+---------------+-----+----------------------------------------+ + |31:29|R/W|PROG_TIME_CNT |0x8 |Program Min Pulse Width timing couner | + +-----+---+---------------+-----+----------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_spim.rst b/rtos/pulp/gap_archi/doc/ips/udma_spim.rst index 0532436bf..0a4c4867c 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_spim.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_spim.rst @@ -8,23 +8,28 @@ Register map Overview """""""" -.. table:: - +-----------------------------------+------+-----+----------------------------------+ - | Name |Offset|Width| Description | - +===================================+======+=====+==================================+ - |:ref:`RX_DEST` | 0| 32|Stream ID for the RX uDMA channel | - +-----------------------------------+------+-----+----------------------------------+ - |:ref:`TX_DEST` | 4| 32|Stream ID for the TX uDMA channel | - +-----------------------------------+------+-----+----------------------------------+ - |:ref:`CMD_DEST`| 8| 32|Stream ID for the CMD uDMA channel| - +-----------------------------------+------+-----+----------------------------------+ - |:ref:`STATUS` | 48| 32|Status register | - +-----------------------------------+------+-----+----------------------------------+ - |:ref:`CONFIG` | 52| 32|Configuration register | - +-----------------------------------+------+-----+----------------------------------+ - -.. _udma_spim_RX_DEST: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +------------------------------------+------+-----+----------------------------------+ + | Name |Offset|Width| Description | + +====================================+======+=====+==================================+ + |:ref:`RX_DEST` | 0| 32|Stream ID for the RX uDMA channel | + +------------------------------------+------+-----+----------------------------------+ + |:ref:`TX_DEST` | 4| 32|Stream ID for the TX uDMA channel | + +------------------------------------+------+-----+----------------------------------+ + |:ref:`CMD_DEST`| 8| 32|Stream ID for the CMD uDMA channel| + +------------------------------------+------+-----+----------------------------------+ + |:ref:`STATUS` | 48| 32|Status register | + +------------------------------------+------+-----+----------------------------------+ + |:ref:`CONFIG` | 52| 32|Configuration register | + +------------------------------------+------+-----+----------------------------------+ + +.. _udma_spim__RX_DEST: RX_DEST """"""" @@ -32,14 +37,16 @@ RX_DEST Stream ID for the RX uDMA channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+======================================================================+ - |7:0 |R/W|RX_DEST|Stream ID for the RX uDMA channel. Default is 0xFF (channel disabled).| - +-----+---+-------+----------------------------------------------------------------------+ + +-----+---+-------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+======================================================================+ + |7:0 |R/W|RX_DEST|0xFF |Stream ID for the RX uDMA channel. Default is 0xFF (channel disabled).| + +-----+---+-------+-----+----------------------------------------------------------------------+ -.. _udma_spim_TX_DEST: +.. _udma_spim__TX_DEST: TX_DEST """"""" @@ -47,14 +54,16 @@ TX_DEST Stream ID for the TX uDMA channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+======================================================================+ - |7:0 |R/W|TX_DEST|Stream ID for the TX uDMA channel. Default is 0xFF (channel disabled).| - +-----+---+-------+----------------------------------------------------------------------+ + +-----+---+-------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+======================================================================+ + |7:0 |R/W|TX_DEST|0xFF |Stream ID for the TX uDMA channel. Default is 0xFF (channel disabled).| + +-----+---+-------+-----+----------------------------------------------------------------------+ -.. _udma_spim_CMD_DEST: +.. _udma_spim__CMD_DEST: CMD_DEST """""""" @@ -62,14 +71,16 @@ CMD_DEST Stream ID for the CMD uDMA channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+-----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+=======================================================================+ - |7:0 |R/W|CMD_DEST|Stream ID for the CMD uDMA channel. Default is 0xFF (channel disabled).| - +-----+---+--------+-----------------------------------------------------------------------+ + +-----+---+--------+-----+-----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=======================================================================+ + |7:0 |R/W|CMD_DEST|0xFF |Stream ID for the CMD uDMA channel. Default is 0xFF (channel disabled).| + +-----+---+--------+-----+-----------------------------------------------------------------------+ -.. _udma_spim_STATUS: +.. _udma_spim__STATUS: STATUS """""" @@ -77,20 +88,22 @@ STATUS Status register .. table:: - - +-----+---+------------------+----------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+======================================================================+ - |3:0 |R/W|STATUS |Misc status | - +-----+---+------------------+----------------------------------------------------------------------+ - |4 |R/W|CMD_EVENT |Is set to 1 upon transmission of a command; write register to clear | - +-----+---+------------------+----------------------------------------------------------------------+ - |5 |R/W|RX_OVERFLOW_EVENT |(slave only) Set to 1 in case of RX overflow; write register to clear | - +-----+---+------------------+----------------------------------------------------------------------+ - |6 |R/W|TX_UNDERFLOW_EVENT|(slave only) Set to 1 in case of TX underflow; write register to clear| - +-----+---+------------------+----------------------------------------------------------------------+ - -.. _udma_spim_CONFIG: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+------------------+-----+----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+======================================================================+ + |3:0 |R/W|STATUS | 0|Misc status | + +-----+---+------------------+-----+----------------------------------------------------------------------+ + |4 |R/W|CMD_EVENT | 0|Is set to 1 upon transmission of a command; write register to clear | + +-----+---+------------------+-----+----------------------------------------------------------------------+ + |5 |R/W|RX_OVERFLOW_EVENT | 0|(slave only) Set to 1 in case of RX overflow; write register to clear | + +-----+---+------------------+-----+----------------------------------------------------------------------+ + |6 |R/W|TX_UNDERFLOW_EVENT| 0|(slave only) Set to 1 in case of TX underflow; write register to clear| + +-----+---+------------------+-----+----------------------------------------------------------------------+ + +.. _udma_spim__CONFIG: CONFIG """""" @@ -98,58 +111,64 @@ CONFIG Configuration register .. table:: - - +-----+---+--------------+-------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+=========================+ - | 0|R/W|SPI_SLAVE_MODE|Enable SPI slave mode | - +-----+---+--------------+-------------------------+ - | 1|R/W|RX_OVRFLW_EN |Enable RX overflow event | - +-----+---+--------------+-------------------------+ - | 2|R/W|TX_UNDRFLW_EN |Enable TX underflow event| - +-----+---+--------------+-------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+-----+-------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+=========================+ + | 0|R/W|SPI_SLAVE_MODE| 1|Enable SPI slave mode | + +-----+---+--------------+-----+-------------------------+ + | 1|R/W|RX_OVRFLW_EN | 1|Enable RX overflow event | + +-----+---+--------------+-----+-------------------------+ + | 2|R/W|TX_UNDRFLW_EN | 1|Enable TX underflow event| + +-----+---+--------------+-----+-------------------------+ SPI micro-code ^^^^^^^^^^^^^^ .. table:: - - +--------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ - | Command name |Width|Command code| Description | - +==============================================================+=====+============+==============================================================================================+ - |:ref:`SPI_CMD_CFG` | 32|0x0 |(Master only) Set the configuration for the SPI Master IP | - +--------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ - |:ref:`SPI_CMD_SOT` | 32|0x1 |(Master only) Select the Chip Select (CS) | - +--------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ - |:ref:`SPI_CMD_SEND_CMD` | 32|0x2 |(Master only) Transmit up to 16 bits of data in the command word | - +--------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ - |:ref:`SPI_CMD_DUMMY` | 32|0x4 |(Master only) Receive a number of dummy bits (not sent to the RX interface) | - +--------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ - |:ref:`SPI_CMD_WAIT` | 32|0x5 |(Master only) Wait for an external event to move to the next instruction | - +--------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ - |:ref:`SPI_CMD_TX_DATA` | 32|0x6 |Transfer from master to slave (Master: send data; slave: receive data) -- max 64 kwords | - +--------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ - |:ref:`SPI_CMD_RX_DATA` | 32|0x7 |Transfer from slave to master (Master: receive data; slave: send data) -- max 64 kwords | - +--------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ - |:ref:`SPI_CMD_RPT` | 32|0x8 |(Master only) Repeat the commands from here to SPI_CMD_RPT_END command a given number of times| - +--------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ - |:ref:`SPI_CMD_EOT` | 32|0x9 |Clear the Chip Select (CS) after transfer | - +--------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ - |:ref:`SPI_CMD_RPT_END` | 32|0xA |(Master only) End of the repeated command section | - +--------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ - |:ref:`SPI_CMD_RX_CHECK` | 32|0xB |(Master only) Check up to 16 bits of data against an expected value | - +--------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ - |:ref:`SPI_CMD_FULL_DUPLEX`| 32|0xC |Transfer in full duplex mode (send and receive data) -- max 64 kwords | - +--------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ - |:ref:`SPI_CMD_SETUP_AG` | 32|0xD |Setup a register of the address generator (the register value is given in the following word) | - +--------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ - -.. _SPI micro-code_SPI_CMD_CFG: + :align: center + :widths: 45 15 15 80 + + +---------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ + | Command name |Width|Command code| Description | + +===============================================================+=====+============+==============================================================================================+ + |:ref:`SPI_CMD_CFG` | 32|0x0 |(Master only) Set the configuration for the SPI Master IP | + +---------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ + |:ref:`SPI_CMD_SOT` | 32|0x1 |(Master only) Select the Chip Select (CS) | + +---------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ + |:ref:`SPI_CMD_SEND_CMD` | 32|0x2 |(Master only) Transmit up to 16 bits of data in the command word | + +---------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ + |:ref:`SPI_CMD_DUMMY` | 32|0x4 |(Master only) Receive a number of dummy bits (not sent to the RX interface) | + +---------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ + |:ref:`SPI_CMD_WAIT` | 32|0x5 |(Master only) Wait for an external event to move to the next instruction | + +---------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ + |:ref:`SPI_CMD_TX_DATA` | 32|0x6 |Transfer from master to slave (Master: send data; slave: receive data) -- max 64 kwords | + +---------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ + |:ref:`SPI_CMD_RX_DATA` | 32|0x7 |Transfer from slave to master (Master: receive data; slave: send data) -- max 64 kwords | + +---------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ + |:ref:`SPI_CMD_RPT` | 32|0x8 |(Master only) Repeat the commands from here to SPI_CMD_RPT_END command a given number of times| + +---------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ + |:ref:`SPI_CMD_EOT` | 32|0x9 |Clear the Chip Select (CS) after transfer | + +---------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ + |:ref:`SPI_CMD_RPT_END` | 32|0xA |(Master only) End of the repeated command section | + +---------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ + |:ref:`SPI_CMD_RX_CHECK` | 32|0xB |(Master only) Check up to 16 bits of data against an expected value | + +---------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ + |:ref:`SPI_CMD_FULL_DUPLEX`| 32|0xC |Transfer in full duplex mode (send and receive data) -- max 64 kwords | + +---------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ + |:ref:`SPI_CMD_SETUP_AG` | 32|0xD |Setup a register of the address generator (the register value is given in the following word) | + +---------------------------------------------------------------+-----+------------+----------------------------------------------------------------------------------------------+ + +.. _SPI micro-code__SPI_CMD_CFG: SPI_CMD_CFG """"""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------+------------------------------+ |Bit #| Name | Description | @@ -163,12 +182,14 @@ SPI_CMD_CFG |31:28|SPI_CMD|Command code -- here “CFG”=0x0| +-----+-------+------------------------------+ -.. _SPI micro-code_SPI_CMD_SOT: +.. _SPI micro-code__SPI_CMD_SOT: SPI_CMD_SOT """"""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------+-----------------------------------------------------------------------+ |Bit #| Name | Description | @@ -178,12 +199,14 @@ SPI_CMD_SOT |31:28|SPI_CMD|Command code -- here “SOT”=0x1 | +-----+-------+-----------------------------------------------------------------------+ -.. _SPI micro-code_SPI_CMD_SEND_CMD: +.. _SPI micro-code__SPI_CMD_SEND_CMD: SPI_CMD_SEND_CMD """""""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+----------+------------------------------------------------------------------------------------------------------------+ |Bit #| Name | Description | @@ -197,12 +220,14 @@ SPI_CMD_SEND_CMD |31:28|SPI_CMD |Command code -- here “SEND_CMD”=0x2 | +-----+----------+------------------------------------------------------------------------------------------------------------+ -.. _SPI micro-code_SPI_CMD_DUMMY: +.. _SPI micro-code__SPI_CMD_DUMMY: SPI_CMD_DUMMY """"""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-----------+---------------------------------+ |Bit #| Name | Description | @@ -214,12 +239,14 @@ SPI_CMD_DUMMY |31:28|SPI_CMD |Command code -- here “DUMMY”=0x4 | +-----+-----------+---------------------------------+ -.. _SPI micro-code_SPI_CMD_WAIT: +.. _SPI micro-code__SPI_CMD_WAIT: SPI_CMD_WAIT """""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+--------------------+-----------------------------------------------------------------------------------------------------------------------------+ |Bit #| Name | Description | @@ -231,12 +258,14 @@ SPI_CMD_WAIT |31:28|SPI_CMD |Command code -- here “WAIT”=0x5 | +-----+--------------------+-----------------------------------------------------------------------------------------------------------------------------+ -.. _SPI micro-code_SPI_CMD_TX_DATA: +.. _SPI micro-code__SPI_CMD_TX_DATA: SPI_CMD_TX_DATA """"""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ |Bit #| Name | Description | @@ -256,12 +285,14 @@ SPI_CMD_TX_DATA |31:28|SPI_CMD |Command code -- here “TX_DATA”=0x6 | +-----+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _SPI micro-code_SPI_CMD_RX_DATA: +.. _SPI micro-code__SPI_CMD_RX_DATA: SPI_CMD_RX_DATA """"""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ |Bit #| Name | Description | @@ -281,12 +312,14 @@ SPI_CMD_RX_DATA |31:28|SPI_CMD |Command code -- here “RX_DATA”=0x7 | +-----+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _SPI micro-code_SPI_CMD_RPT: +.. _SPI micro-code__SPI_CMD_RPT: SPI_CMD_RPT """"""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------+-------------------------------------+ |Bit #| Name | Description | @@ -296,12 +329,14 @@ SPI_CMD_RPT |31:28|SPI_CMD|Command code -- here “RPT”=0x8 | +-----+-------+-------------------------------------+ -.. _SPI micro-code_SPI_CMD_EOT: +.. _SPI micro-code__SPI_CMD_EOT: SPI_CMD_EOT """"""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+---------+---------------------------------------------------------------------------------------------------------------------------------------+ |Bit #| Name | Description | @@ -313,12 +348,14 @@ SPI_CMD_EOT |31:28|SPI_CMD |Command code -- here “EOT”=0x9 | +-----+---------+---------------------------------------------------------------------------------------------------------------------------------------+ -.. _SPI micro-code_SPI_CMD_RPT_END: +.. _SPI micro-code__SPI_CMD_RPT_END: SPI_CMD_RPT_END """"""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------+----------------------------------+ |Bit #| Name | Description | @@ -326,12 +363,14 @@ SPI_CMD_RPT_END |31:28|SPI_CMD|Command code -- here “RPT_END”=0xA| +-----+-------+----------------------------------+ -.. _SPI micro-code_SPI_CMD_RX_CHECK: +.. _SPI micro-code__SPI_CMD_RX_CHECK: SPI_CMD_RX_CHECK """""""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-----------+----------------------------------------------------------------------------------------------------+ |Bit #| Name | Description | @@ -349,12 +388,14 @@ SPI_CMD_RX_CHECK |31:28|SPI_CMD |Command code -- here “RX_CHECK”=0xB | +-----+-----------+----------------------------------------------------------------------------------------------------+ -.. _SPI micro-code_SPI_CMD_FULL_DUPLEX: +.. _SPI micro-code__SPI_CMD_FULL_DUPLEX: SPI_CMD_FULL_DUPLEX """"""""""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ |Bit #| Name | Description | @@ -372,12 +413,14 @@ SPI_CMD_FULL_DUPLEX |31:28|SPI_CMD |Command code -- here “FULL_DUPLEX”=0xC | +-----+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. _SPI micro-code_SPI_CMD_SETUP_AG: +.. _SPI micro-code__SPI_CMD_SETUP_AG: SPI_CMD_SETUP_AG """""""""""""""" .. table:: + :align: center + :widths: 15 45 90 +-----+-------------+--------------------------------------------------------------------------------------------------------------+ |Bit #| Name | Description | diff --git a/rtos/pulp/gap_archi/doc/ips/udma_timestamp.rst b/rtos/pulp/gap_archi/doc/ips/udma_timestamp.rst index 34af9a7ef..d2eea29a2 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_timestamp.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_timestamp.rst @@ -8,282 +8,309 @@ Register map Overview """""""" -.. table:: - +--------------------------------------------------+------+-----+------------------------------------------------------------+ - | Name |Offset|Width| Description | - +==================================================+======+=====+============================================================+ - |:ref:`REG_CMD` | 0| 32|Counter start/stop/reset register | - +--------------------------------------------------+------+-----+------------------------------------------------------------+ - |:ref:`REG_SETUP_CNT`| 4| 32|CFG register for counter if counter start is linked to GPIOs| - +--------------------------------------------------+------+-----+------------------------------------------------------------+ - |:ref:`REG_SETUP_CH0`| 8| 32|CFG register for channel 0 (linked to GPIOs) | - +--------------------------------------------------+------+-----+------------------------------------------------------------+ - |:ref:`REG_SETUP_CH1`| 12| 32|CFG register for channel 1 (linked to GPIOs) | - +--------------------------------------------------+------+-----+------------------------------------------------------------+ - |:ref:`REG_SETUP_CH2`| 16| 32|CFG register for channel 2 (linked to GPIOs) | - +--------------------------------------------------+------+-----+------------------------------------------------------------+ - |:ref:`REG_SETUP_CH3`| 20| 32|CFG register for channel 3 (linked to GPIOs) | - +--------------------------------------------------+------+-----+------------------------------------------------------------+ - |:ref:`REG_SETUP_CH4`| 24| 32|CFG register for channel 4 (linked to GPIOs) | - +--------------------------------------------------+------+-----+------------------------------------------------------------+ - |:ref:`REG_SETUP_CH5`| 28| 32|CFG register for channel 5 (linked to GPIOs) | - +--------------------------------------------------+------+-----+------------------------------------------------------------+ - |:ref:`REG_SETUP_CH6`| 32| 32|CFG register for channel 6 (linked to GPIOs) | - +--------------------------------------------------+------+-----+------------------------------------------------------------+ - |:ref:`REG_SETUP_CH7`| 36| 32|CFG register for channel 7 (linked to GPIOs) | - +--------------------------------------------------+------+-----+------------------------------------------------------------+ - |:ref:`REG_EVENT` | 40| 32| | - +--------------------------------------------------+------+-----+------------------------------------------------------------+ - |:ref:`REG_CLK_CFG` | 44| 32|CFG register for clock prescaler and mux | - +--------------------------------------------------+------+-----+------------------------------------------------------------+ - -.. _udma_timestamp_REG_CMD: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +---------------------------------------------------+------+-----+---------------------------------------------+ + | Name |Offset|Width| Description | + +===================================================+======+=====+=============================================+ + |:ref:`REG_CMD` | 0| 32|Counter start/stop/reset | + +---------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_SETUP_CNT`| 4| 32|Configuration of counter start through GPIO | + +---------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_SETUP_CH0`| 8| 32|Channel 0 configuration (AUX or GPIOs events)| + +---------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_SETUP_CH1`| 12| 32|Channel 1 configuration (AUX or GPIOs events)| + +---------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_SETUP_CH2`| 16| 32|Channel 2 configuration (AUX or GPIOs events)| + +---------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_SETUP_CH3`| 20| 32|Channel 3 configuration (AUX or GPIOs events)| + +---------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_SETUP_CH4`| 24| 32|Channel 4 configuration (AUX or GPIOs events)| + +---------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_SETUP_CH5`| 28| 32|Channel 5 configuration (AUX or GPIOs events)| + +---------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_SETUP_CH6`| 32| 32|Channel 6 configuration (AUX or GPIOs events)| + +---------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_SETUP_CH7`| 36| 32|Channel 7 configuration (AUX or GPIOs events)| + +---------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_EVENT` | 40| 32|SOC events timestamp configuration | + +---------------------------------------------------+------+-----+---------------------------------------------+ + |:ref:`REG_CLK_CFG` | 44| 32|Counting clock configuration | + +---------------------------------------------------+------+-----+---------------------------------------------+ + +.. _udma_timestamp__REG_CMD: REG_CMD """"""" -Counter start/stop/reset register +Counter start/stop/reset .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+---------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+=============================================+ - | 0|W |CNT_CLR |Reset the counter to 0 and starts/restarts it| - +-----+---+--------+---------------------------------------------+ - | 1|W |CNT_STOP|Reset the counter to 0 and stops it | - +-----+---+--------+---------------------------------------------+ + +-----+---+--------+-----+------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+======================================================+ + | 0|W |CNT_CLR |0x0 |Write 1 to reset the counter to 0 and start/restart it| + +-----+---+--------+-----+------------------------------------------------------+ + | 1|W |CNT_STOP|0x0 |Write 1 to reset the counter to 0 and stop it | + +-----+---+--------+-----+------------------------------------------------------+ -.. _udma_timestamp_REG_SETUP_CNT: +.. _udma_timestamp__REG_SETUP_CNT: REG_SETUP_CNT """"""""""""" -CFG register for counter if counter start is linked to GPIOs +Configuration of counter start through GPIO .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+====================================================================================================================================================================================+ - |5:0 |R/W|EXT_SEL |Select the GPIO bit among the 64 available used for making the udma_timestamp_counter starting | - +-----+---+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |7:6 |R/W|EXT_TYPE|Mode of interpreting the GPIO selected signal, udma_timestamp_counter starts counting (or is reset) if we are in => 0 (rising edge), 1 (falling edge), 2 (both edges), 3 (never)| - +-----+---+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - |8 |R/W|EXT_EN |Enable the start/reset of udma_timestamp_counter linked to GPIOs signals | - +-----+---+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-----+---+--------+-----+---------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=========================================================================================================+ + |5:0 |R/W|EXT_SEL |0x00 |ID of the GPIO used to start/restart the counter | + +-----+---+--------+-----+---------------------------------------------------------------------------------------------------------+ + |7:6 |R/W|EXT_TYPE|0x0 |GPIO condition to trigger counter start/restart: 0: rising edge; 1: falling edge; 2: both edges; 3: never| + +-----+---+--------+-----+---------------------------------------------------------------------------------------------------------+ + |8 |R/W|EXT_EN |0x0 |If 1, GPIO-controlled start/restart of the counter is activated | + +-----+---+--------+-----+---------------------------------------------------------------------------------------------------------+ -.. _udma_timestamp_REG_SETUP_CH0: +.. _udma_timestamp__REG_SETUP_CH0: REG_SETUP_CH0 """"""""""""" -CFG register for channel 0 (linked to GPIOs) +Channel 0 configuration (AUX or GPIOs events) .. table:: - - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+==========================================================================================================================+ - |5:0 |R/W|INPUT_SEL |Select the GPIO bit among the 64 available linked to CHANNEL 0(when source 0,1,2) or SFU(0..7), SAI0(8), SAI1(9), SAI2(10)| - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |7:6 |R/W|INPUT_TYPE|Event source for CHANNEL ( GPIO rising edge), 1 (GPIO falling edge), 2 (GPIO both edges), 3 (AUX: SFU or SAI) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |8 |R/W|INPUT_EN |Enable the CHANNEL requests (linked to specific GPIOs or AUX signals) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |23:16|R/W|DEST_ID |uDMA destination ID | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_timestamp_REG_SETUP_CH1: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+================================================================================================================================================+ + |5:0 |R/W|INPUT_SEL |0x00 |Select event input index for channel 0, depending on INPUT_TYPE: 0 to 63 for GPIOs, 0 to 7 for SFU events, 8 to 10 for WS signal of SAI0 to SAI2| + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:6 |R/W|INPUT_TYPE|0x0 |Event source for channel 0: 0: GPIO rising edge; 1: GPIO falling edge; 2: GPIO both edges; 3: AUX event (SFU or SAI WS) | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |8 |R/W|INPUT_EN |0x0 |Enable timestamping for channel 0 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|DEST_ID |0x00 |UDMA destination ID for channel 0 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_timestamp__REG_SETUP_CH1: REG_SETUP_CH1 """"""""""""" -CFG register for channel 1 (linked to GPIOs) +Channel 1 configuration (AUX or GPIOs events) .. table:: - - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+==========================================================================================================================+ - |5:0 |R/W|INPUT_SEL |Select the GPIO bit among the 64 available linked to CHANNEL 0(when source 0,1,2) or SFU(0..7), SAI0(8), SAI1(9), SAI2(10)| - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |7:6 |R/W|INPUT_TYPE|Event source for CHANNEL ( GPIO rising edge), 1 (GPIO falling edge), 2 (GPIO both edges), 3 (AUX: SFU or SAI) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |8 |R/W|INPUT_EN |Enable the CHANNEL requests (linked to specific GPIOs or AUX signals) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |23:16|R/W|DEST_ID |uDMA destination ID | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_timestamp_REG_SETUP_CH2: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+================================================================================================================================================+ + |5:0 |R/W|INPUT_SEL |0x00 |Select event input index for channel 1, depending on INPUT_TYPE: 0 to 63 for GPIOs, 0 to 7 for SFU events, 8 to 10 for WS signal of SAI0 to SAI2| + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:6 |R/W|INPUT_TYPE|0x0 |Event source for channel 1: 0: GPIO rising edge; 1: GPIO falling edge; 2: GPIO both edges; 3: AUX event (SFU or SAI WS) | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |8 |R/W|INPUT_EN |0x0 |Enable timestamping for channel 1 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|DEST_ID |0x00 |UDMA destination ID for channel 1 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_timestamp__REG_SETUP_CH2: REG_SETUP_CH2 """"""""""""" -CFG register for channel 2 (linked to GPIOs) +Channel 2 configuration (AUX or GPIOs events) .. table:: - - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+==========================================================================================================================+ - |5:0 |R/W|INPUT_SEL |Select the GPIO bit among the 64 available linked to CHANNEL 0(when source 0,1,2) or SFU(0..7), SAI0(8), SAI1(9), SAI2(10)| - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |7:6 |R/W|INPUT_TYPE|Event source for CHANNEL ( GPIO rising edge), 1 (GPIO falling edge), 2 (GPIO both edges), 3 (AUX: SFU or SAI) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |8 |R/W|INPUT_EN |Enable the CHANNEL requests (linked to specific GPIOs or AUX signals) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |23:16|R/W|DEST_ID |uDMA destination ID | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_timestamp_REG_SETUP_CH3: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+================================================================================================================================================+ + |5:0 |R/W|INPUT_SEL |0x00 |Select event input index for channel 2, depending on INPUT_TYPE: 0 to 63 for GPIOs, 0 to 7 for SFU events, 8 to 10 for WS signal of SAI0 to SAI2| + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:6 |R/W|INPUT_TYPE|0x0 |Event source for channel 2: 0: GPIO rising edge; 1: GPIO falling edge; 2: GPIO both edges; 3: AUX event (SFU or SAI WS) | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |8 |R/W|INPUT_EN |0x0 |Enable timestamping for channel 2 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|DEST_ID |0x00 |UDMA destination ID for channel 2 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_timestamp__REG_SETUP_CH3: REG_SETUP_CH3 """"""""""""" -CFG register for channel 3 (linked to GPIOs) +Channel 3 configuration (AUX or GPIOs events) .. table:: - - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+==========================================================================================================================+ - |5:0 |R/W|INPUT_SEL |Select the GPIO bit among the 64 available linked to CHANNEL 0(when source 0,1,2) or SFU(0..7), SAI0(8), SAI1(9), SAI2(10)| - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |7:6 |R/W|INPUT_TYPE|Event source for CHANNEL ( GPIO rising edge), 1 (GPIO falling edge), 2 (GPIO both edges), 3 (AUX: SFU or SAI) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |8 |R/W|INPUT_EN |Enable the CHANNEL requests (linked to specific GPIOs or AUX signals) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |23:16|R/W|DEST_ID |uDMA destination ID | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_timestamp_REG_SETUP_CH4: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+================================================================================================================================================+ + |5:0 |R/W|INPUT_SEL |0x00 |Select event input index for channel 3, depending on INPUT_TYPE: 0 to 63 for GPIOs, 0 to 7 for SFU events, 8 to 10 for WS signal of SAI0 to SAI2| + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:6 |R/W|INPUT_TYPE|0x0 |Event source for channel 3: 0: GPIO rising edge; 1: GPIO falling edge; 2: GPIO both edges; 3: AUX event (SFU or SAI WS) | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |8 |R/W|INPUT_EN |0x0 |Enable timestamping for channel 3 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|DEST_ID |0x00 |UDMA destination ID for channel 3 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_timestamp__REG_SETUP_CH4: REG_SETUP_CH4 """"""""""""" -CFG register for channel 4 (linked to GPIOs) +Channel 4 configuration (AUX or GPIOs events) .. table:: - - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+==========================================================================================================================+ - |5:0 |R/W|INPUT_SEL |Select the GPIO bit among the 64 available linked to CHANNEL 0(when source 0,1,2) or SFU(0..7), SAI0(8), SAI1(9), SAI2(10)| - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |7:6 |R/W|INPUT_TYPE|Event source for CHANNEL ( GPIO rising edge), 1 (GPIO falling edge), 2 (GPIO both edges), 3 (AUX: SFU or SAI) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |8 |R/W|INPUT_EN |Enable the CHANNEL requests (linked to specific GPIOs or AUX signals) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |23:16|R/W|DEST_ID |uDMA destination ID | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_timestamp_REG_SETUP_CH5: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+================================================================================================================================================+ + |5:0 |R/W|INPUT_SEL |0x00 |Select event input index for channel 4, depending on INPUT_TYPE: 0 to 63 for GPIOs, 0 to 7 for SFU events, 8 to 10 for WS signal of SAI0 to SAI2| + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:6 |R/W|INPUT_TYPE|0x0 |Event source for channel 4: 0: GPIO rising edge; 1: GPIO falling edge; 2: GPIO both edges; 3: AUX event (SFU or SAI WS) | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |8 |R/W|INPUT_EN |0x0 |Enable timestamping for channel 4 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|DEST_ID |0x00 |UDMA destination ID for channel 4 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_timestamp__REG_SETUP_CH5: REG_SETUP_CH5 """"""""""""" -CFG register for channel 5 (linked to GPIOs) +Channel 5 configuration (AUX or GPIOs events) .. table:: - - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+==========================================================================================================================+ - |5:0 |R/W|INPUT_SEL |Select the GPIO bit among the 64 available linked to CHANNEL 0(when source 0,1,2) or SFU(0..7), SAI0(8), SAI1(9), SAI2(10)| - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |7:6 |R/W|INPUT_TYPE|Event source for CHANNEL ( GPIO rising edge), 1 (GPIO falling edge), 2 (GPIO both edges), 3 (AUX: SFU or SAI) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |8 |R/W|INPUT_EN |Enable the CHANNEL requests (linked to specific GPIOs or AUX signals) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |23:16|R/W|DEST_ID |uDMA destination ID | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_timestamp_REG_SETUP_CH6: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+================================================================================================================================================+ + |5:0 |R/W|INPUT_SEL |0x00 |Select event input index for channel 5, depending on INPUT_TYPE: 0 to 63 for GPIOs, 0 to 7 for SFU events, 8 to 10 for WS signal of SAI0 to SAI2| + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:6 |R/W|INPUT_TYPE|0x0 |Event source for channel 5: 0: GPIO rising edge; 1: GPIO falling edge; 2: GPIO both edges; 3: AUX event (SFU or SAI WS) | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |8 |R/W|INPUT_EN |0x0 |Enable timestamping for channel 5 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|DEST_ID |0x00 |UDMA destination ID for channel 5 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_timestamp__REG_SETUP_CH6: REG_SETUP_CH6 """"""""""""" -CFG register for channel 6 (linked to GPIOs) +Channel 6 configuration (AUX or GPIOs events) .. table:: - - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+==========================================================================================================================+ - |5:0 |R/W|INPUT_SEL |Select the GPIO bit among the 64 available linked to CHANNEL 0(when source 0,1,2) or SFU(0..7), SAI0(8), SAI1(9), SAI2(10)| - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |7:6 |R/W|INPUT_TYPE|Event source for CHANNEL ( GPIO rising edge), 1 (GPIO falling edge), 2 (GPIO both edges), 3 (AUX: SFU or SAI) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |8 |R/W|INPUT_EN |Enable the CHANNEL requests (linked to specific GPIOs or AUX signals) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |23:16|R/W|DEST_ID |uDMA destination ID | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_timestamp_REG_SETUP_CH7: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+================================================================================================================================================+ + |5:0 |R/W|INPUT_SEL |0x00 |Select event input index for channel 6, depending on INPUT_TYPE: 0 to 63 for GPIOs, 0 to 7 for SFU events, 8 to 10 for WS signal of SAI0 to SAI2| + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:6 |R/W|INPUT_TYPE|0x0 |Event source for channel 6: 0: GPIO rising edge; 1: GPIO falling edge; 2: GPIO both edges; 3: AUX event (SFU or SAI WS) | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |8 |R/W|INPUT_EN |0x0 |Enable timestamping for channel 6 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|DEST_ID |0x00 |UDMA destination ID for channel 6 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_timestamp__REG_SETUP_CH7: REG_SETUP_CH7 """"""""""""" -CFG register for channel 7 (linked to GPIOs) +Channel 7 configuration (AUX or GPIOs events) .. table:: - - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+==========================================================================================================================+ - |5:0 |R/W|INPUT_SEL |Select the GPIO bit among the 64 available linked to CHANNEL 0(when source 0,1,2) or SFU(0..7), SAI0(8), SAI1(9), SAI2(10)| - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |7:6 |R/W|INPUT_TYPE|Event source for CHANNEL ( GPIO rising edge), 1 (GPIO falling edge), 2 (GPIO both edges), 3 (AUX: SFU or SAI) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |8 |R/W|INPUT_EN |Enable the CHANNEL requests (linked to specific GPIOs or AUX signals) | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - |23:16|R/W|DEST_ID |uDMA destination ID | - +-----+---+----------+--------------------------------------------------------------------------------------------------------------------------+ - -.. _udma_timestamp_REG_EVENT: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+================================================================================================================================================+ + |5:0 |R/W|INPUT_SEL |0x00 |Select event input index for channel 7, depending on INPUT_TYPE: 0 to 63 for GPIOs, 0 to 7 for SFU events, 8 to 10 for WS signal of SAI0 to SAI2| + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |7:6 |R/W|INPUT_TYPE|0x0 |Event source for channel 7: 0: GPIO rising edge; 1: GPIO falling edge; 2: GPIO both edges; 3: AUX event (SFU or SAI WS) | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |8 |R/W|INPUT_EN |0x0 |Enable timestamping for channel 7 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + |23:16|R/W|DEST_ID |0x00 |UDMA destination ID for channel 7 | + +-----+---+----------+-----+------------------------------------------------------------------------------------------------------------------------------------------------+ + +.. _udma_timestamp__REG_EVENT: REG_EVENT """"""""" - - - +SOC events timestamp configuration .. table:: - - +-----+---+-------------+--------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+==========================+ - |7:0 |R/W|DEST_ID_EVT_0|uDMA destination ID Event0| - +-----+---+-------------+--------------------------+ - |15:8 |R/W|DEST_ID_EVT_1|uDMA destination ID Event0| - +-----+---+-------------+--------------------------+ - |23:16|R/W|DEST_ID_EVT_2|uDMA destination ID Event0| - +-----+---+-------------+--------------------------+ - |31:24|R/W|DEST_ID_EVT_3|uDMA destination ID Event0| - +-----+---+-------------+--------------------------+ - -.. _udma_timestamp_REG_CLK_CFG: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+-------------+-----+-----------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+===================================+ + |7:0 |R/W|DEST_ID_EVT_0|0xFF |UDMA destination ID for SOC event 0| + +-----+---+-------------+-----+-----------------------------------+ + |15:8 |R/W|DEST_ID_EVT_1|0xFF |UDMA destination ID for SOC event 1| + +-----+---+-------------+-----+-----------------------------------+ + |23:16|R/W|DEST_ID_EVT_2|0xFF |UDMA destination ID for SOC event 2| + +-----+---+-------------+-----+-----------------------------------+ + |31:24|R/W|DEST_ID_EVT_3|0xFF |UDMA destination ID for SOC event 3| + +-----+---+-------------+-----+-----------------------------------+ + +.. _udma_timestamp__REG_CLK_CFG: REG_CLK_CFG """"""""""" -CFG register for clock prescaler and mux +Counting clock configuration .. table:: - - +-----+---+----------+-----------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+===========================================================+ - |1:0 |R/W|CLK_MUX |Select clock src : 00 - PWM, 01 - GPIO, 10 - Ref clock fast| - +-----+---+----------+-----------------------------------------------------------+ - |2 |R/W|CLK_MUX_EN|Enable the clk mux, otherwise, use internal soc clk | - +-----+---+----------+-----------------------------------------------------------+ - |6:4 |R/W|PWM_SEL |Select among 8 pwm to be clock source for counter | - +-----+---+----------+-----------------------------------------------------------+ - |13:8 |R/W|GPIO_SEL |Select among 64 gpio to be clock source for counter | - +-----+---+----------+-----------------------------------------------------------+ - |23:16|R/W|PRESCALER |Clock counter prescaler | - +-----+---+----------+-----------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+-------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+=============================================================+ + |1:0 |R/W|CLK_MUX |0x0 |Select clock source: b00: PWM; b01: GPIO; b10: REF FAST clock| + +-----+---+----------+-----+-------------------------------------------------------------+ + |2 |R/W|CLK_MUX_EN|0x0 |Enable the clock mux: if b0, internal SOC clock is used | + +-----+---+----------+-----+-------------------------------------------------------------+ + |6:4 |R/W|PWM_SEL |0x0 |Select PWM clock source among the 8 possible PWM | + +-----+---+----------+-----+-------------------------------------------------------------+ + |13:8 |R/W|GPIO_SEL |0x0 |Select GPIO clock source among the 64 possible GPIOs | + +-----+---+----------+-----+-------------------------------------------------------------+ + |23:16|R/W|PRESCALER |0x0 |Clock counter prescaler | + +-----+---+----------+-----+-------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/udma_uart.rst b/rtos/pulp/gap_archi/doc/ips/udma_uart.rst index b92c50af8..afbe07193 100644 --- a/rtos/pulp/gap_archi/doc/ips/udma_uart.rst +++ b/rtos/pulp/gap_archi/doc/ips/udma_uart.rst @@ -8,29 +8,34 @@ Register map Overview """""""" -.. table:: - +---------------------------------+------+-----+----------------------------------+ - | Name |Offset|Width| Description | - +=================================+======+=====+==================================+ - |:ref:`RX_DEST`| 0| 32|Stream ID for the uDMA RX channel | - +---------------------------------+------+-----+----------------------------------+ - |:ref:`TX_DEST`| 4| 32|Stream ID for the uDMA TX channel | - +---------------------------------+------+-----+----------------------------------+ - |:ref:`MISC` | 16| 32|Send events | - +---------------------------------+------+-----+----------------------------------+ - |:ref:`STATUS` | 32| 32|Status register | - +---------------------------------+------+-----+----------------------------------+ - |:ref:`SETUP` | 36| 32|Configuration register | - +---------------------------------+------+-----+----------------------------------+ - |:ref:`ERROR` | 40| 32|Error register, cleared on reading| - +---------------------------------+------+-----+----------------------------------+ - |:ref:`IRQ_EN` | 44| 32|Enable/disable events | - +---------------------------------+------+-----+----------------------------------+ - |:ref:`SETUP_2`| 56| 32|Configuration register 2 | - +---------------------------------+------+-----+----------------------------------+ - -.. _udma_uart_RX_DEST: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +----------------------------------+------+-----+----------------------------------+ + | Name |Offset|Width| Description | + +==================================+======+=====+==================================+ + |:ref:`RX_DEST`| 0| 32|Stream ID for the uDMA RX channel | + +----------------------------------+------+-----+----------------------------------+ + |:ref:`TX_DEST`| 4| 32|Stream ID for the uDMA TX channel | + +----------------------------------+------+-----+----------------------------------+ + |:ref:`MISC` | 16| 32|Send events | + +----------------------------------+------+-----+----------------------------------+ + |:ref:`STATUS` | 32| 32|Status register | + +----------------------------------+------+-----+----------------------------------+ + |:ref:`SETUP` | 36| 32|Configuration register | + +----------------------------------+------+-----+----------------------------------+ + |:ref:`ERROR` | 40| 32|Error register, cleared on reading| + +----------------------------------+------+-----+----------------------------------+ + |:ref:`IRQ_EN` | 44| 32|Enable/disable events | + +----------------------------------+------+-----+----------------------------------+ + |:ref:`SETUP_2`| 56| 32|Configuration register 2 | + +----------------------------------+------+-----+----------------------------------+ + +.. _udma_uart__RX_DEST: RX_DEST """"""" @@ -38,14 +43,16 @@ RX_DEST Stream ID for the uDMA RX channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+---------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+=====================================================================+ - |7:0 |RW |RX_DEST|Stream ID for the RX uDMA channel. Default is 0xFF (channel disabled)| - +-----+---+-------+---------------------------------------------------------------------+ + +-----+---+-------+-----+---------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=====================================================================+ + |7:0 |RW |RX_DEST|0xFF |Stream ID for the RX uDMA channel. Default is 0xFF (channel disabled)| + +-----+---+-------+-----+---------------------------------------------------------------------+ -.. _udma_uart_TX_DEST: +.. _udma_uart__TX_DEST: TX_DEST """"""" @@ -53,14 +60,16 @@ TX_DEST Stream ID for the uDMA TX channel .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+---------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+=====================================================================+ - |7:0 |RW |TX_DEST|Stream ID for the TX uDMA channel. Default is 0xFF (channel disabled)| - +-----+---+-------+---------------------------------------------------------------------+ + +-----+---+-------+-----+---------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=====================================================================+ + |7:0 |RW |TX_DEST|0xFF |Stream ID for the TX uDMA channel. Default is 0xFF (channel disabled)| + +-----+---+-------+-----+---------------------------------------------------------------------+ -.. _udma_uart_MISC: +.. _udma_uart__MISC: MISC """" @@ -68,20 +77,22 @@ MISC Send events .. table:: - - +-----+---+---------------------+---------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=====================+===========================+ - | 0|W |TX_FIFO_CLEAR_EVENT_O|Send event to clear TX FIFO| - +-----+---+---------------------+---------------------------+ - | 1|W |RX_FIFO_CLEAR_EVENT_O|Send event to clear RX FIFO| - +-----+---+---------------------+---------------------------+ - | 2|W |TX_FSM_RESET_EVENT_O |Send event to reset TX FSM | - +-----+---+---------------------+---------------------------+ - | 3|W |RX_FSM_RESET_EVENT_O |Send event to reset RX FSM | - +-----+---+---------------------+---------------------------+ - -.. _udma_uart_STATUS: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+---------------------+-----+---------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=====================+=====+===========================+ + | 0|W |TX_FIFO_CLEAR_EVENT_O| 0|Send event to clear TX FIFO| + +-----+---+---------------------+-----+---------------------------+ + | 1|W |RX_FIFO_CLEAR_EVENT_O| 0|Send event to clear RX FIFO| + +-----+---+---------------------+-----+---------------------------+ + | 2|W |TX_FSM_RESET_EVENT_O | 0|Send event to reset TX FSM | + +-----+---+---------------------+-----+---------------------------+ + | 3|W |RX_FSM_RESET_EVENT_O | 0|Send event to reset RX FSM | + +-----+---+---------------------+-----+---------------------------+ + +.. _udma_uart__STATUS: STATUS """""" @@ -89,16 +100,18 @@ STATUS Status register .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+==============================+ - | 0|R |TX_BUSY|Transmitter is sending a frame| - +-----+---+-------+------------------------------+ - | 1|R |RX_BUSY|Receiver is receiving a frame | - +-----+---+-------+------------------------------+ + +-----+---+-------+-----+------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+==============================+ + | 0|R |TX_BUSY| 0|Transmitter is sending a frame| + +-----+---+-------+-----+------------------------------+ + | 1|R |RX_BUSY| 0|Receiver is receiving a frame | + +-----+---+-------+-----+------------------------------+ -.. _udma_uart_SETUP: +.. _udma_uart__SETUP: SETUP """"" @@ -106,34 +119,36 @@ SETUP Configuration register .. table:: - - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==========+=================================================================================================================+ - | 0|RW |PARITY_ENA|Enable parity bit for TX and RX blocks | - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------+ - |2:1 |RW |BIT_LENGTH|RX/TX word width (see encoding below) | - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------+ - | 3|RW |STOP_BITS |Stop bits count (see encoding below) | - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------+ - | 8|RW |TX_ENA |Enable transmitter | - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------+ - | 9|RW |RX_ENA |Enable receiver | - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------+ - | 10|RW |CTS_EN |Flow control: enable Clear To Send input pin. Transmitter will send next word if UART CTS input is 0. | - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------+ - | 11|RW |RTS_EN |Flow control: enable Ready To Send output pin. UART RTS output is set to 0 if the receiver can receive next word.| - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------+ - | 12|RW |TX_CLK_EN |Enable synchronous master mode | - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------+ - | 13|RW |TX_CLK_POL|Configure TX clock polarity (see encoding below) | - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------+ - | 14|RW |TX_CLK_PHA|Configure TX clock phase (see encoding below) | - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------+ - |31:16|RW |CLKDIV |Baudrate divider applied to selected internal clock. Baudrate = Clk_freq / (CLKDIV + 1) | - +-----+---+----------+-----------------------------------------------------------------------------------------------------------------+ - -.. _udma_uart_ERROR: + :align: center + :widths: 13 12 45 24 85 + + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==========+=====+=================================================================================================================+ + | 0|RW |PARITY_ENA| 0|Enable parity bit for TX and RX blocks | + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------+ + |2:1 |RW |BIT_LENGTH| 0|RX/TX word width (see encoding below) | + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------+ + | 3|RW |STOP_BITS | 0|Stop bits count (see encoding below) | + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------+ + | 8|RW |TX_ENA | 0|Enable transmitter | + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------+ + | 9|RW |RX_ENA | 0|Enable receiver | + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------+ + | 10|RW |CTS_EN | 0|Flow control: enable Clear To Send input pin. Transmitter will send next word if UART CTS input is 0. | + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------+ + | 11|RW |RTS_EN | 0|Flow control: enable Ready To Send output pin. UART RTS output is set to 0 if the receiver can receive next word.| + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------+ + | 12|RW |TX_CLK_EN | 0|Enable synchronous master mode | + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------+ + | 13|RW |TX_CLK_POL| 0|Configure TX clock polarity (see encoding below) | + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------+ + | 14|RW |TX_CLK_PHA| 0|Configure TX clock phase (see encoding below) | + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------+ + |31:16|RW |CLKDIV | 0|Baudrate divider applied to selected internal clock. Baudrate = Clk_freq / (CLKDIV + 1) | + +-----+---+----------+-----+-----------------------------------------------------------------------------------------------------------------+ + +.. _udma_uart__ERROR: ERROR """"" @@ -141,16 +156,18 @@ ERROR Error register, cleared on reading .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------+--------------------+ - |Bit #|R/W| Name | Description | - +=====+===+============+====================+ - | 0|R |ERR_OVERFLOW|RX overflow flag | - +-----+---+------------+--------------------+ - | 1|R |ERR_PARITY |RX parity error flag| - +-----+---+------------+--------------------+ + +-----+---+------------+-----+--------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+============+=====+====================+ + | 0|R |ERR_OVERFLOW| 0|RX overflow flag | + +-----+---+------------+-----+--------------------+ + | 1|R |ERR_PARITY | 0|RX parity error flag| + +-----+---+------------+-----+--------------------+ -.. _udma_uart_IRQ_EN: +.. _udma_uart__IRQ_EN: IRQ_EN """""" @@ -158,18 +175,20 @@ IRQ_EN Enable/disable events .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------+-----------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=======+=================================================================+ - | 0|R/W|RX_IRQ |Emit event if RX received a word | - +-----+---+-------+-----------------------------------------------------------------+ - | 1|R/W|ERR_IRQ|Emit event on an error (see ERROR register) | - +-----+---+-------+-----------------------------------------------------------------+ - | 2|R/W|TX_IRQ |Emit event after a byte is sent, after stop symbol is transmitted| - +-----+---+-------+-----------------------------------------------------------------+ + +-----+---+-------+-----+-----------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=======+=====+=================================================================+ + | 0|R/W|RX_IRQ | 0|Emit event if RX received a word | + +-----+---+-------+-----+-----------------------------------------------------------------+ + | 1|R/W|ERR_IRQ| 0|Emit event on an error (see ERROR register) | + +-----+---+-------+-----+-----------------------------------------------------------------+ + | 2|R/W|TX_IRQ | 0|Emit event after a byte is sent, after stop symbol is transmitted| + +-----+---+-------+-----+-----------------------------------------------------------------+ -.. _udma_uart_SETUP_2: +.. _udma_uart__SETUP_2: SETUP_2 """"""" @@ -177,9 +196,11 @@ SETUP_2 Configuration register 2 .. table:: - - +-----+---+--------------+-----------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==============+===================================================================================+ - |3:0 |R/W|RTS_HIGH_LIMIT|Deassert UART RTS when number of data in the FIFO ≥ RTS_HIGH_LIMIT. FIFO size is 8.| - +-----+---+--------------+-----------------------------------------------------------------------------------+ + :align: center + :widths: 13 12 45 24 85 + + +-----+---+--------------+-----+----------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==============+=====+==============================================================================================+ + |3:0 |R/W|RTS_HIGH_LIMIT| 4|Deassert UART RTS when number of data in the FIFO :math:`\geq` RTS_HIGH_LIMIT. FIFO size is 8.| + +-----+---+--------------+-----+----------------------------------------------------------------------------------------------+ diff --git a/rtos/pulp/gap_archi/doc/ips/xip.rst b/rtos/pulp/gap_archi/doc/ips/xip.rst index 804f8979d..f1f52ecae 100644 --- a/rtos/pulp/gap_archi/doc/ips/xip.rst +++ b/rtos/pulp/gap_archi/doc/ips/xip.rst @@ -8,1329 +8,1432 @@ Register map Overview """""""" -.. table:: - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - | Name |Offset|Width| Description | - +=====================================================+======+=====+================================================================================================================================+ - |:ref:`CFG_XIP` | 0| 32|Main config register for XIP (tlb mode) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_SOFT_RESET` | 4| 32|Flush mask register for pages, allow keeping page synced with EXT | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CLUSTER_ERR_PAGE` | 8| 32|page address for first detected cluster error | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`ERR_PAGE` | 12| 32|page address for first detected FC insn error + one hot for if/where ro violation | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_VIRT_ADDR0` | 16| 32|Base virtual address for hyper0 | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_VIRT_ADDR1` | 20| 32|Base virtual address for hyper1 | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_VIRT_ADDR2` | 24| 32|Base virtual address for mram | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_EXT_ADDR0` | 28| 32|Base external address for hyper0 | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_EXT_ADDR1` | 32| 32|Base external address for hyper1 | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_EXT_ADDR2` | 36| 32|Base external address for mram | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_MNT_SIZE0` | 40| 32|Virt memory size for hyper0 (pages) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_MNT_SIZE1` | 44| 32|Virt memory size for hyper1 (pages) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_MNT_SIZE2` | 48| 32|Virt memory size for mram (pages) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE_SIZE0` | 52| 32|Page size for hyper0 (512B - 64KB, power of two) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE_SIZE1` | 56| 32|Page size for hyper1 (512B - 64KB, power of two) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE_SIZE2` | 60| 32|Page size for mram (512B - 64KB, power of two) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE0` | 64| 32|page0 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE1` | 68| 32|page1 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE2` | 72| 32|page2 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE3` | 76| 32|page3 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE4` | 80| 32|page4 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE5` | 84| 32|page5 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE6` | 88| 32|page6 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE7` | 92| 32|page7 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE8` | 96| 32|page8 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE9` | 100| 32|page9 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE10` | 104| 32|page10 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE11` | 108| 32|page11 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE12` | 112| 32|page12 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE13` | 116| 32|page13 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE14` | 120| 32|page14 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_PAGE15` | 124| 32|page15 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_0` | 128| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_1` | 132| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_2` | 136| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_3` | 140| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_4` | 144| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_5` | 148| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_6` | 152| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_7` | 156| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_8` | 160| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_9` | 164| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_10`| 168| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_11`| 172| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_12`| 176| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_13`| 180| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_14`| 184| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_VIRT_PAGE_15`| 188| 32|TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable)| - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_0` | 192| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_1` | 196| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_2` | 200| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_3` | 204| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_4` | 208| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_5` | 212| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_6` | 216| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_7` | 220| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_8` | 224| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_9` | 228| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_10`| 232| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_11`| 236| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_12`| 240| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_13`| 244| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_14`| 248| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_TLB_PHYS_PAGE_15`| 252| 32|TLB physical page configuration (bit [31:0]: physical address) | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - |:ref:`CFG_XIP_LRU` | 256| 32|TLB current LRU entry | - +-----------------------------------------------------+------+-----+--------------------------------------------------------------------------------------------------------------------------------+ - -.. _xip_CFG_XIP: +Refer to :ref:`GAP9 address map` for the base address to be used. + +.. table:: + :align: center + :widths: 40 12 12 90 + + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + | Name |Offset|Width| Description | + +======================================================+======+=====+===========================================================+ + |:ref:`CFG_XIP` | 0| 32|Main config register for XIP (TLB mode) | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_SOFT_RESET` | 4| 32|Flush register for pages | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CLUSTER_ERR_PAGE` | 8| 32|Page address for first detected cluster error | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`ERR_PAGE` | 12| 32|Page address for first detected FC instruction error | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_VIRT_ADDR0` | 16| 32|Base virtual address for memory interface 0 | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_VIRT_ADDR1` | 20| 32|Base virtual address for memory interface 1 | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_VIRT_ADDR2` | 24| 32|Base virtual address for MRAM | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_EXT_ADDR0` | 28| 32|Base external address for memory interface 0 | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_EXT_ADDR1` | 32| 32|Base external address for memory interface 1 | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_EXT_ADDR2` | 36| 32|Base external address for MRAM | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_MNT_SIZE0` | 40| 32|Virtual memory size for memory interface 0 (pages) | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_MNT_SIZE1` | 44| 32|Virtual memory size for memory interface 1 (pages) | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_MNT_SIZE2` | 48| 32|Virtual memory size for MRAM (pages) | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE_SIZE0` | 52| 32|Page size for memory interface 0 (512B--64KB, power of two)| + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE_SIZE1` | 56| 32|Page size for memory interface 1 (512B--64KB, power of two)| + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE_SIZE2` | 60| 32|Page size for MRAM (512B--64KB, power of two) | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE0` | 64| 32|Page 0 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE1` | 68| 32|Page 1 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE2` | 72| 32|Page 2 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE3` | 76| 32|Page 3 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE4` | 80| 32|Page 4 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE5` | 84| 32|Page 5 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE6` | 88| 32|Page 6 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE7` | 92| 32|Page 7 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE8` | 96| 32|Page 8 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE9` | 100| 32|Page 9 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE10` | 104| 32|Page 10 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE11` | 108| 32|Page 11 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE12` | 112| 32|Page 12 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE13` | 116| 32|Page 13 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE14` | 120| 32|Page 14 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_PAGE15` | 124| 32|Page 15 configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_0` | 128| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_1` | 132| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_2` | 136| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_3` | 140| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_4` | 144| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_5` | 148| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_6` | 152| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_7` | 156| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_8` | 160| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_9` | 164| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_10`| 168| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_11`| 172| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_12`| 176| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_13`| 180| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_14`| 184| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_VIRT_PAGE_15`| 188| 32|TLB virtual page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_0` | 192| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_1` | 196| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_2` | 200| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_3` | 204| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_4` | 208| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_5` | 212| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_6` | 216| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_7` | 220| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_8` | 224| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_9` | 228| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_10`| 232| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_11`| 236| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_12`| 240| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_13`| 244| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_14`| 248| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_TLB_PHYS_PAGE_15`| 252| 32|TLB physical page configuration | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + |:ref:`CFG_XIP_LRU` | 256| 32|TLB current LRU entry | + +------------------------------------------------------+------+-----+-----------------------------------------------------------+ + +.. _xip__CFG_XIP: CFG_XIP """"""" -Main config register for XIP (tlb mode) +Main config register for XIP (TLB mode) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+-------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+=====================================+ - | 0|R/W|TLB_EN |Enable or Disable TLB mode | - +-----+---+---------+-------------------------------------+ - |3:1 |R/W|DEVICE_RO|Flag to check whether device is RO | - +-----+---+---------+-------------------------------------+ - | 16|R/W|POWER_ON |Inform XIP that cluster is powered on| - +-----+---+---------+-------------------------------------+ + +-----+---+---------+-----+-------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+=====================================+ + | 0|R/W|TLB_EN |0x0 |Enable or Disable TLB mode | + +-----+---+---------+-----+-------------------------------------+ + |3:1 |R/W|DEVICE_RO|0x0 |Flag to check whether device is RO | + +-----+---+---------+-----+-------------------------------------+ + | 16|R/W|POWER_ON |0x0 |Inform XIP that cluster is powered on| + +-----+---+---------+-----+-------------------------------------+ -.. _xip_CFG_SOFT_RESET: +.. _xip__CFG_SOFT_RESET: CFG_SOFT_RESET """""""""""""" -Flush mask register for pages, allow keeping page synced with EXT +Flush register for pages .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-----+-----------------------------------------------------------------------------------+ - |Bit #|R/W|Name | Description | - +=====+===+=====+===================================================================================+ - | 0|R/W|RESET|Flush dirty pages, and reset logic to enable reconfiguration. Falls to 0 when done.| - +-----+---+-----+-----------------------------------------------------------------------------------+ + +-----+---+-----+-----+-----------------------------------------------------------------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+===================================================================================+ + | 0|R/W|RESET|0x0 |Flush dirty pages, and reset logic to enable reconfiguration. Falls to 0 when done.| + +-----+---+-----+-----+-----------------------------------------------------------------------------------+ -.. _xip_CLUSTER_ERR_PAGE: +.. _xip__CLUSTER_ERR_PAGE: CLUSTER_ERR_PAGE """""""""""""""" -page address for first detected cluster error +Page address for first detected cluster error .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+---------+----------+----------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+=========+==========+================================================================+ + |31:0 |R/W|VIRT_ADDR|0x20000000|Virtual address (must be in the [0x2000_0000-0x2FFF_FFFF] range)| + +-----+---+---------+----------+----------------------------------------------------------------+ -.. _xip_ERR_PAGE: +.. _xip__ERR_PAGE: ERR_PAGE """""""" -page address for first detected FC insn error + one hot for if/where ro violation +Page address for first detected FC instruction error .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+---------+----------+----------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+=========+==========+================================================================+ + |31:0 |R/W|VIRT_ADDR|0x20000000|Virtual address (must be in the [0x2000_0000-0x2FFF_FFFF] range)| + +-----+---+---------+----------+----------------------------------------------------------------+ -.. _xip_CFG_VIRT_ADDR0: +.. _xip__CFG_VIRT_ADDR0: CFG_VIRT_ADDR0 """""""""""""" -Base virtual address for hyper0 +Base virtual address for memory interface 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+================================================================================================+ - |31:0 |R/W|VIRT_ADDR|Start of Virtual Address for external peripheral 0 Must be in the range[0x2000_0000-0x2FFF_FFFF]| - +-----+---+---------+------------------------------------------------------------------------------------------------+ + +-----+---+---------+----------+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+=========+==========+=================================================================================================+ + |31:0 |R/W|VIRT_ADDR|0x20000000|Start of virtual address for external peripheral (must be in the [0x2000_0000-0x2FFF_FFFF] range)| + +-----+---+---------+----------+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_VIRT_ADDR1: +.. _xip__CFG_VIRT_ADDR1: CFG_VIRT_ADDR1 """""""""""""" -Base virtual address for hyper1 +Base virtual address for memory interface 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+================================================================================================+ - |31:0 |R/W|VIRT_ADDR|Start of Virtual Address for external peripheral 0 Must be in the range[0x2000_0000-0x2FFF_FFFF]| - +-----+---+---------+------------------------------------------------------------------------------------------------+ + +-----+---+---------+----------+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+=========+==========+=================================================================================================+ + |31:0 |R/W|VIRT_ADDR|0x20000000|Start of virtual address for external peripheral (must be in the [0x2000_0000-0x2FFF_FFFF] range)| + +-----+---+---------+----------+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_VIRT_ADDR2: +.. _xip__CFG_VIRT_ADDR2: CFG_VIRT_ADDR2 """""""""""""" -Base virtual address for mram +Base virtual address for MRAM .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+================================================================================================+ - |31:0 |R/W|VIRT_ADDR|Start of Virtual Address for external peripheral 0 Must be in the range[0x2000_0000-0x2FFF_FFFF]| - +-----+---+---------+------------------------------------------------------------------------------------------------+ + +-----+---+---------+----------+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name | Reset | Description | + +=====+===+=========+==========+=================================================================================================+ + |31:0 |R/W|VIRT_ADDR|0x20000000|Start of virtual address for external peripheral (must be in the [0x2000_0000-0x2FFF_FFFF] range)| + +-----+---+---------+----------+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_EXT_ADDR0: +.. _xip__CFG_EXT_ADDR0: CFG_EXT_ADDR0 """"""""""""" -Base external address for hyper0 +Base external address for memory interface 0 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+---------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+===================================================+ - |31:0 |R/W|EXT_ADDR|Start of External Address for external peripheral 0| - +-----+---+--------+---------------------------------------------------+ + +-----+---+--------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=======================================================+ + |31:0 |R/W|EXT_ADDR|0x0 |Start of external address space for external peripheral| + +-----+---+--------+-----+-------------------------------------------------------+ -.. _xip_CFG_EXT_ADDR1: +.. _xip__CFG_EXT_ADDR1: CFG_EXT_ADDR1 """"""""""""" -Base external address for hyper1 +Base external address for memory interface 1 .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+---------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+===================================================+ - |31:0 |R/W|EXT_ADDR|Start of External Address for external peripheral 0| - +-----+---+--------+---------------------------------------------------+ + +-----+---+--------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=======================================================+ + |31:0 |R/W|EXT_ADDR|0x0 |Start of external address space for external peripheral| + +-----+---+--------+-----+-------------------------------------------------------+ -.. _xip_CFG_EXT_ADDR2: +.. _xip__CFG_EXT_ADDR2: CFG_EXT_ADDR2 """"""""""""" -Base external address for mram +Base external address for MRAM .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+---------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+===================================================+ - |31:0 |R/W|EXT_ADDR|Start of External Address for external peripheral 0| - +-----+---+--------+---------------------------------------------------+ + +-----+---+--------+-----+-------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=======================================================+ + |31:0 |R/W|EXT_ADDR|0x0 |Start of external address space for external peripheral| + +-----+---+--------+-----+-------------------------------------------------------+ -.. _xip_CFG_MNT_SIZE0: +.. _xip__CFG_MNT_SIZE0: CFG_MNT_SIZE0 """"""""""""" -Virt memory size for hyper0 (pages) +Virtual memory size for memory interface 0 (pages) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+================================================================================================+ - |15:0 |R/W|MNT_SIZE|Size of the mounted region in pages for peripheral 0 (total size of region = this reg*page size)| - +-----+---+--------+------------------------------------------------------------------------------------------------+ + +-----+---+--------+-----+-----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=======================================================================+ + |15:0 |R/W|MNT_SIZE|0x0 |Size of the mounted region for external peripheral (in number of pages)| + +-----+---+--------+-----+-----------------------------------------------------------------------+ -.. _xip_CFG_MNT_SIZE1: +.. _xip__CFG_MNT_SIZE1: CFG_MNT_SIZE1 """"""""""""" -Virt memory size for hyper1 (pages) +Virtual memory size for memory interface 1 (pages) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+================================================================================================+ - |15:0 |R/W|MNT_SIZE|Size of the mounted region in pages for peripheral 0 (total size of region = this reg*page size)| - +-----+---+--------+------------------------------------------------------------------------------------------------+ + +-----+---+--------+-----+-----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=======================================================================+ + |15:0 |R/W|MNT_SIZE|0x0 |Size of the mounted region for external peripheral (in number of pages)| + +-----+---+--------+-----+-----------------------------------------------------------------------+ -.. _xip_CFG_MNT_SIZE2: +.. _xip__CFG_MNT_SIZE2: CFG_MNT_SIZE2 """"""""""""" -Virt memory size for mram (pages) +Virtual memory size for MRAM (pages) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+--------+------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+========+================================================================================================+ - |15:0 |R/W|MNT_SIZE|Size of the mounted region in pages for peripheral 0 (total size of region = this reg*page size)| - +-----+---+--------+------------------------------------------------------------------------------------------------+ + +-----+---+--------+-----+-----------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+========+=====+=======================================================================+ + |15:0 |R/W|MNT_SIZE|0x0 |Size of the mounted region for external peripheral (in number of pages)| + +-----+---+--------+-----+-----------------------------------------------------------------------+ -.. _xip_CFG_PAGE_SIZE0: +.. _xip__CFG_PAGE_SIZE0: CFG_PAGE_SIZE0 """""""""""""" -Page size for hyper0 (512B - 64KB, power of two) +Page size for memory interface 0 (512B--64KB, power of two) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+--------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+============================================================================================+ - |2:0 |R/W|PAGE_SIZE|Size of pages for peripheral 0 0: 512Bytes 1: 1KBytes 2: 2KBytes 3: 4KBytes ... 7: 64KBytes| - +-----+---+---------+--------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================+ + |2:0 |R/W|PAGE_SIZE|0x0 |Size of pages for external peripheral: 0: 512 Bytes; 1: 1 KByte; 2: 2 KBytes; 3: 4 KBytes; ...; 7: 64 KBytes| + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE_SIZE1: +.. _xip__CFG_PAGE_SIZE1: CFG_PAGE_SIZE1 """""""""""""" -Page size for hyper1 (512B - 64KB, power of two) +Page size for memory interface 1 (512B--64KB, power of two) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+--------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+============================================================================================+ - |2:0 |R/W|PAGE_SIZE|Size of pages for peripheral 0 0: 512Bytes 1: 1KBytes 2: 2KBytes 3: 4KBytes ... 7: 64KBytes| - +-----+---+---------+--------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================+ + |2:0 |R/W|PAGE_SIZE|0x0 |Size of pages for external peripheral: 0: 512 Bytes; 1: 1 KByte; 2: 2 KBytes; 3: 4 KBytes; ...; 7: 64 KBytes| + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE_SIZE2: +.. _xip__CFG_PAGE_SIZE2: CFG_PAGE_SIZE2 """""""""""""" -Page size for mram (512B - 64KB, power of two) +Page size for MRAM (512B--64KB, power of two) .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+--------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+============================================================================================+ - |2:0 |R/W|PAGE_SIZE|Size of pages for peripheral 0 0: 512Bytes 1: 1KBytes 2: 2KBytes 3: 4KBytes ... 7: 64KBytes| - +-----+---+---------+--------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================+ + |2:0 |R/W|PAGE_SIZE|0x0 |Size of pages for external peripheral: 0: 512 Bytes; 1: 1 KByte; 2: 2 KBytes; 3: 4 KBytes; ...; 7: 64 KBytes| + +-----+---+---------+-----+------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE0: +.. _xip__CFG_PAGE0: CFG_PAGE0 """"""""" -page0 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 0 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE1: +.. _xip__CFG_PAGE1: CFG_PAGE1 """"""""" -page1 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 1 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE2: +.. _xip__CFG_PAGE2: CFG_PAGE2 """"""""" -page2 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 2 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE3: +.. _xip__CFG_PAGE3: CFG_PAGE3 """"""""" -page3 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 3 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE4: +.. _xip__CFG_PAGE4: CFG_PAGE4 """"""""" -page4 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 4 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE5: +.. _xip__CFG_PAGE5: CFG_PAGE5 """"""""" -page5 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 5 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE6: +.. _xip__CFG_PAGE6: CFG_PAGE6 """"""""" -page6 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 6 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE7: +.. _xip__CFG_PAGE7: CFG_PAGE7 """"""""" -page7 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 7 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE8: +.. _xip__CFG_PAGE8: CFG_PAGE8 """"""""" -page8 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 8 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE9: +.. _xip__CFG_PAGE9: CFG_PAGE9 """"""""" -page9 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 9 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE10: +.. _xip__CFG_PAGE10: CFG_PAGE10 """""""""" -page10 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 10 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE11: +.. _xip__CFG_PAGE11: CFG_PAGE11 """""""""" -page11 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 11 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE12: +.. _xip__CFG_PAGE12: CFG_PAGE12 """""""""" -page12 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 12 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE13: +.. _xip__CFG_PAGE13: CFG_PAGE13 """""""""" -page13 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 13 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE14: +.. _xip__CFG_PAGE14: CFG_PAGE14 """""""""" -page14 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 14 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_PAGE15: +.. _xip__CFG_PAGE15: CFG_PAGE15 """""""""" -page15 configuration (bit [31:30]: device id, [29]: active bit, [20:0]: l2 offset) +Page 15 configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=========+==================================================================================================================+ - |20:0 |R/W|INT_ADDR |21 LSB of L2 Address of the page | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |28 |R/W|CACHEABLE|Make icache aware of this page or not Shared with TLB_VIRT_PAGE.CACHEABLE | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |29 |R/W|ACTIVE |Make page "active" or "ignored | - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ - |31:30|R/W|PER_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with TLB_VIRT_PAGE.TLB_PAGE_ID| - +-----+---+---------+------------------------------------------------------------------------------------------------------------------+ + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=========+=====+============================================================================================================================================+ + |20:0 |R/W|INT_ADDR |0x0 |21 LSB of L2 address of the page | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |28 |R/W|CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_TLB_VIRT_PAGE | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |29 |R/W|ACTIVE |0x0 |Activate page: b0: page is ignored; b1: page is active | + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ + |31:30|R/W|PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_TLB_VIRT_PAGE| + +-----+---+---------+-----+--------------------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_0: +.. _xip__CFG_TLB_VIRT_PAGE_0: CFG_TLB_VIRT_PAGE_0 """"""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_1: +.. _xip__CFG_TLB_VIRT_PAGE_1: CFG_TLB_VIRT_PAGE_1 """"""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_2: +.. _xip__CFG_TLB_VIRT_PAGE_2: CFG_TLB_VIRT_PAGE_2 """"""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_3: +.. _xip__CFG_TLB_VIRT_PAGE_3: CFG_TLB_VIRT_PAGE_3 """"""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_4: +.. _xip__CFG_TLB_VIRT_PAGE_4: CFG_TLB_VIRT_PAGE_4 """"""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_5: +.. _xip__CFG_TLB_VIRT_PAGE_5: CFG_TLB_VIRT_PAGE_5 """"""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_6: +.. _xip__CFG_TLB_VIRT_PAGE_6: CFG_TLB_VIRT_PAGE_6 """"""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_7: +.. _xip__CFG_TLB_VIRT_PAGE_7: CFG_TLB_VIRT_PAGE_7 """"""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_8: +.. _xip__CFG_TLB_VIRT_PAGE_8: CFG_TLB_VIRT_PAGE_8 """"""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_9: +.. _xip__CFG_TLB_VIRT_PAGE_9: CFG_TLB_VIRT_PAGE_9 """"""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_10: +.. _xip__CFG_TLB_VIRT_PAGE_10: CFG_TLB_VIRT_PAGE_10 """""""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_11: +.. _xip__CFG_TLB_VIRT_PAGE_11: CFG_TLB_VIRT_PAGE_11 """""""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_12: +.. _xip__CFG_TLB_VIRT_PAGE_12: CFG_TLB_VIRT_PAGE_12 """""""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_13: +.. _xip__CFG_TLB_VIRT_PAGE_13: CFG_TLB_VIRT_PAGE_13 """""""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_14: +.. _xip__CFG_TLB_VIRT_PAGE_14: CFG_TLB_VIRT_PAGE_14 """""""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_VIRT_PAGE_15: +.. _xip__CFG_TLB_VIRT_PAGE_15: CFG_TLB_VIRT_PAGE_15 """""""""""""""""""" -TLB virtual page configuration (bit [31:8]: virtual address, [6:4]: page size, [3:2] page_id, [1]: reserved, [0] page_cacheable) +TLB virtual page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+==================+========================================================================================================+ - |27:9 |R/W|TLB_VIRT_ADDR |Virtual address TAG entry that is compared against the virtual address seeking for access | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |7 |R |TLB_VALID_DATA |When system boots the data are invalid. When any register is written the data become valid | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |3:2 |R/W|TLB_PAGE_ID |Peripheral ID (0: Hyper0, 1: Hyper1, 2: MRAM, 3 is invalid and can't be set) Shared with CFG_PAGE.PER_ID| - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |1 |R/W|RESERVED |Reserved for future use | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ - |0 |R/W|TLB_PAGE_CACHEABLE|Make icache aware of this page or not (shared with CFG_PAGEN) Shared with CFG_PAGE.CACHEABLE | - +-----+---+------------------+--------------------------------------------------------------------------------------------------------+ + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+==================+=====+===================================================================================================================================+ + |27:9 |R/W|TLB_VIRT_ADDR |0x0 |Virtual address tag entry that is compared against the virtual address seeking for access | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |7 |R |TLB_VALID_DATA |0x0 |When system boots the data are invalid; when any register is written the data become valid | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |3:2 |R/W|TLB_PER_ID |0x0 |Peripheral ID: b00: memory interface 0; b01: memory interface 1; b10: MRAM; b11: reserved (field shared with corresponding CFG_PAGE| + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ + |0 |R/W|TLB_PAGE_CACHEABLE|0x0 |Make I-cache aware (b1) of this page or not (b0) (field shared with corresponding CFG_PAGE | + +-----+---+------------------+-----+-----------------------------------------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_0: +.. _xip__CFG_TLB_PHYS_PAGE_0: CFG_TLB_PHYS_PAGE_0 """"""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_1: +.. _xip__CFG_TLB_PHYS_PAGE_1: CFG_TLB_PHYS_PAGE_1 """"""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_2: +.. _xip__CFG_TLB_PHYS_PAGE_2: CFG_TLB_PHYS_PAGE_2 """"""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_3: +.. _xip__CFG_TLB_PHYS_PAGE_3: CFG_TLB_PHYS_PAGE_3 """"""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_4: +.. _xip__CFG_TLB_PHYS_PAGE_4: CFG_TLB_PHYS_PAGE_4 """"""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_5: +.. _xip__CFG_TLB_PHYS_PAGE_5: CFG_TLB_PHYS_PAGE_5 """"""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_6: +.. _xip__CFG_TLB_PHYS_PAGE_6: CFG_TLB_PHYS_PAGE_6 """"""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_7: +.. _xip__CFG_TLB_PHYS_PAGE_7: CFG_TLB_PHYS_PAGE_7 """"""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_8: +.. _xip__CFG_TLB_PHYS_PAGE_8: CFG_TLB_PHYS_PAGE_8 """"""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_9: +.. _xip__CFG_TLB_PHYS_PAGE_9: CFG_TLB_PHYS_PAGE_9 """"""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_10: +.. _xip__CFG_TLB_PHYS_PAGE_10: CFG_TLB_PHYS_PAGE_10 """""""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_11: +.. _xip__CFG_TLB_PHYS_PAGE_11: CFG_TLB_PHYS_PAGE_11 """""""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_12: +.. _xip__CFG_TLB_PHYS_PAGE_12: CFG_TLB_PHYS_PAGE_12 """""""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_13: +.. _xip__CFG_TLB_PHYS_PAGE_13: CFG_TLB_PHYS_PAGE_13 """""""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_14: +.. _xip__CFG_TLB_PHYS_PAGE_14: CFG_TLB_PHYS_PAGE_14 """""""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_TLB_PHYS_PAGE_15: +.. _xip__CFG_TLB_PHYS_PAGE_15: CFG_TLB_PHYS_PAGE_15 """""""""""""""""""" -TLB physical page configuration (bit [31:0]: physical address) +TLB physical page configuration .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ - |Bit #|R/W| Name | Description | - +=====+===+=============+=================================================================================================+ - |31:0 |R/W|TLB_PHYS_ADDR|Physical address used along the virtual address in TLB to form the refill address in case of miss| - +-----+---+-------------+-------------------------------------------------------------------------------------------------+ + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ + |Bit #|R/W| Name |Reset| Description | + +=====+===+=============+=====+=================================================================================================+ + |31:0 |R/W|TLB_PHYS_ADDR|0x0 |Physical address used along the virtual address in TLB to form the refill address in case of miss| + +-----+---+-------------+-----+-------------------------------------------------------------------------------------------------+ -.. _xip_CFG_XIP_LRU: +.. _xip__CFG_XIP_LRU: CFG_XIP_LRU """"""""""" @@ -1338,8 +1441,11 @@ CFG_XIP_LRU TLB current LRU entry .. table:: + :align: center + :widths: 13 12 45 24 85 - +-----+---+----+-----------+ - |Bit #|R/W|Name|Description| - +=====+===+====+===========+ - +-----+---+----+-----------+ + +-----+---+-----+-----+-------------------------+ + |Bit #|R/W|Name |Reset| Description | + +=====+===+=====+=====+=========================+ + |3:0 |R |RESET|0x0 |Least recently used entry| + +-----+---+-----+-----+-------------------------+ diff --git a/rtos/pulp/gap_archi/regmap/bin/regmap b/rtos/pulp/gap_archi/regmap/bin/regmap index 8d03c10c0..8b2f4ecb4 100755 --- a/rtos/pulp/gap_archi/regmap/bin/regmap +++ b/rtos/pulp/gap_archi/regmap/bin/regmap @@ -18,6 +18,11 @@ parser.add_argument( help="Specify input XLS file" ) +parser.add_argument( + "--input-md-mistune", dest="input_md_mistune", default=None, + help="Specify input Markdown file" +) + parser.add_argument( "--input-md", dest="input_md", default=None, help="Specify input Markdown file" @@ -74,6 +79,7 @@ args = parser.parse_args() import collections import regmap as rmap import regmap_xls +import regmap_md_mistune import regmap_md import regmap_json import regmap_c_header @@ -88,6 +94,9 @@ if args.input: if args.input_xls is not None: regmap_xls.import_xls(regmap, args.input_xls) +if args.input_md_mistune is not None: + regmap_md_mistune.import_md(regmap, args.input_md_mistune, registers=args.registers) + if args.input_md is not None: regmap_md.import_md(regmap, args.input_md, registers=args.registers) diff --git a/rtos/pulp/gap_archi/regmap/bin/regmap_md.py b/rtos/pulp/gap_archi/regmap/bin/regmap_md.py index 57e25677e..f400aa37f 100644 --- a/rtos/pulp/gap_archi/regmap/bin/regmap_md.py +++ b/rtos/pulp/gap_archi/regmap/bin/regmap_md.py @@ -3,367 +3,310 @@ # import regmap as rmap -import mistune as mt -from bs4 import BeautifulSoup -import bs4 -import html2text as htt +import marko +from marko import Markdown +from marko.ext.gfm import gfm, GFM +from marko.ast_renderer import ASTRenderer -# def get_name(field): - # if field[0].isdigit(): - # field = '_' + field - # return field.replace(' ', '_') -# -# def get_description(field): - # return field.replace('\n', ' ').replace('\r', ' ') +class Node(object): -def is_header(n): return n.name[0] == 'h' + def __init__(self, is_table=False): + self.children = [] + self.level = None + self.is_table = is_table + self.tables = [] -def header_name(level): return 'h' + str(level) + def get_table(self, index=0): + if index >= len(self.tables): + return None -def header_node_level(hn): - assert hn.name[0] == 'h' - return int(hn.name[1]) + return self.tables[index] -def build_header_hierarchy(node, hier = []): - pass + def add_header(self, node): + self.children.append(node) -def get_description(node): - description_header_level = header_node_level(node) - description_nodes = [] - for i in node.find_next_siblings(): - if is_header(i): break - else: - description_nodes.append(i) + def add_children(self, node): + self.children.append(node) - description_html = "".join(map(str, description_nodes)) - description_text = htt.html2text(description_html) - return description_text + if node.is_table: + self.tables.append(node) + def is_header(self): + return self.level is not None -def get_register_node(current_node, reg_name): - for register_header in current_node.find_next_siblings(header_name(header_node_level(current_node)+1)): - name = register_header.decode_contents() + def get_level(self): + return self.level - if name == reg_name: - return register_header + def set_header(self, level, title): + self.level = level + self.title = title - return None + def dump(self, indent=''): + if self.is_header(): + print (indent + self.title) -def get_register_field_table(current_node): - for i in current_node.find_next_siblings('table'): - headrow = i.thead.tr - if headrow.th: - s = headrow.th.decode_contents().lower() - if 'field name' in s: - # looks like a valid register table - return i + for child in self.children: + child.dump(' ' + indent) - return None + def get(self, name): + if self.is_header() and self.title == name: + return self + + for child in self.children: + ast = child.get(name) + if ast is not None: + return ast -def get_table_index(table, name=None, names=[]): + return None - search_names = [] - search_names += names +class Document(Node): - if name is not None: - search_names.append(name) + def __init__(self, md): + super(Document, self).__init__() - for name in search_names: - headrow = table.thead.tr - r = [] + last_headers = [self] + [None] * 6 + last_header = None - for field_el in headrow('th'): - r.append(field_el.decode_contents().lower()) + for child in md.children: + node = parse_md(child) - if not name.lower() in r: - continue - return r.index(name.lower()) + if node is not None: + if node.is_header(): + if last_headers[node.get_level() - 1] is not None: + last_headers[node.get_level() - 1].add_header(node) - return -1 + last_headers[node.get_level()] = node + last_header = node -def get_register_field_node(current_node, field_name): - for register_header in current_node.find_next_siblings(header_name(header_node_level(current_node)+2)): - name = register_header.decode_contents() + else: + if last_header is not None: + last_header.add_children(node) - if name == field_name: - return register_header - return None +class Heading(Node): -def get_top_node(bs, current_node, name): - for i in bs(header_name(header_node_level(current_node) +1)): - if name in i.decode_contents().lower(): - return i + def __init__(self, md): + super(Heading, self).__init__() - return None + self.set_header(md.level, md.children[0].children) -def get_nodes(current_node, level=1): - return current_node.find_next_siblings(header_name(header_node_level(current_node)+level)) -def get_node(current_node, name, level=1): - for node in get_nodes(current_node, level): - if node.decode_contents() == name: - return node - return None +class Table(Node): -def get_table(table_node): - table = [] - for row in table_node.tbody('tr'): - r = [] - for el in row('td'): - r.append(el.decode_contents()) - table.append(r) - - return table - -def get_table_node(current_node, name): - for i in current_node.find_next_siblings('table'): - headrow = i.thead.tr - if headrow.th: - s = headrow.th.decode_contents().lower() - if name.lower() in s: - return i - - return None + def __init__(self, md): + super(Table, self).__init__(is_table=True) -def import_md(regmap, path, registers=[]): - with open(path, "rt") as fh: - raw_text = fh.read() - html_text = mt.markdown(raw_text) - with open(path+'.html', 'wt') as fh2: fh2.write(html_text) - bs = BeautifulSoup(html_text, "html.parser") - - block = {} - - most_headers_names = ['h'+str(i) for i in range(1, 10)] - - # get block name, first header - name_header_node = bs(most_headers_names)[0] - if name_header_node: - block['name'] = name_header_node.decode_contents() - else: - raise RuntimeError("Cannot find block name header") - - # get block description - # first header with 'description' in it - description_header_node = None - for i in bs(header_name(header_node_level(name_header_node) +1)): - if 'description' in i.decode_contents().lower(): - description_header_node = i - break - - if not description_header_node: - raise RuntimeError("Cannot find a description header") - - # description nodes - # between description header and next header of another hierarchy - block['description'] = get_description(description_header_node) - - # register table - # find an header named register - # with the same hierarchy than description - register_header_node = None - for i in bs(header_name(header_node_level(name_header_node) +1)): - if 'register' in i.decode_contents().lower(): - register_header_node = i - break - - if not register_header_node: - raise RuntimeError("Cannot find a register header") - - # find the register table, should be just after this header - register_table = None - for i in register_header_node.find_next_siblings('table'): - headrow = i.thead.tr - if headrow.th: - s = headrow.th.decode_contents().lower() - if 'register name' in s: - # looks like a valid register table - register_table = i - break - - for reg_name in registers: - reg = regmap.add_register( - rmap.Register( - name=reg_name - ) - ) - - - # parse registers - for register_row in register_table.tbody('tr'): - r = [] - for register_el in register_row('td'): - r.append(register_el.decode_contents()) - - reg = regmap.add_register( - rmap.Register( - name=r[0], - offset=int(r[1], 0) - ) - ) - - try: - default_index = get_table_index(register_table, 'Properties') - if default_index != -1: - for prop in r[default_index].split(): - key, value = prop.split('=') - if key == 'template': - reg.template = value - - default_index = get_table_index(register_table, 'Size') - if default_index != -1: - # Too many IPs has wrong register width, hard-code it to 32 bits - reg.width = 32 # int(r[default_index], 0) - - default_index = get_table_index(register_table, names=['Default', 'Reset Value']) - if default_index != -1: - reg.reset = int(r[default_index], 0) - - desc_index = get_table_index(register_table, 'Description') - if desc_index == -1: - desc_index = get_table_index(register_table, 'Short description') - - if desc_index != -1: - if len(r) > desc_index: - reg.desc = r[desc_index] - - do_reset_index = get_table_index(register_table, 'Reset') - if do_reset_index != -1: - reg.do_reset = int(r[do_reset_index]) - - except: - print ('Caught error while parsing register (name: %s)' % r[0]) - raise - - - # Now for each register parse the field table - for register in regmap.get_registers(): - node = get_register_node(register_header_node, register.get_field_template()) + nb_cols = md._num_of_cols - if node is not None and register.desc is None: - description = get_description(node) - register.desc = description + self.table = [] - if node is not None: - fields_table = get_register_field_table(node) - - if fields_table is not None: - for field_row in fields_table.tbody('tr'): - r = [] - for field_el in field_row('td'): - r.append(field_el.decode_contents()) - - name_index = get_table_index(fields_table, names=['Field Name']) - bit_index = get_table_index(fields_table, names=['Offset', 'Bit', 'Bit Position']) - width_index = get_table_index(fields_table, names=['Size', 'Width']) - access_index = get_table_index(fields_table, names=['Host Access Type', 'Access Type']) - reset_index = get_table_index(fields_table, names=['Default', 'Reset Value']) - - regfield = register.add_regfield( - rmap.Regfield( - name=r[name_index], - width=int(r[width_index], 0), - bit=int(r[bit_index], 0), - access=r[access_index] - ) - ) - - desc_index = get_table_index(fields_table, 'Description') - if desc_index == -1: - desc_index = get_table_index(fields_table, 'Short description') - - if desc_index != -1: - register.get_regfield(r[0]).desc = r[desc_index] + for md_row in md.children: - if reset_index != -1: - regfield.reset = int(r[reset_index], 0) + row = [None]*nb_cols - for field in register.get_fields(): - field_node = get_register_field_node(node, field.name) + index = 0 + for cell in md_row.children: + if len(cell.children) > 0: + row[index] = cell.children[0].children + else: + row[index] = '' + index += 1 - if field_node is not None and field.desc is None: - description = get_description(field_node) - field.desc = description + self.table.append(row) - commands_top_node = get_top_node(bs, name_header_node, 'commands') + self.names = [] - if commands_top_node is not None: - for command_node in get_nodes(commands_top_node, 1): - cmdmap = rmap.Cmdmap(name=command_node.decode_contents()) - regmap.add_cmdmap(cmdmap) + for name in self.table[0]: + self.names.append(name.lower()) - table_node = get_table_node(command_node, 'Command Name') + def get_index(self, names): + for name in names: + if name.lower() in self.names: + return self.names.index(name.lower()) - if table_node is not None: + return -1 - size_index = get_table_index(table_node, 'Size') - id_index = get_table_index(table_node, 'Command field') - if id_index == -1: - id_index = get_table_index(table_node, 'id') + def get_elem(self, row, index): + if index is None: + return None - for row in get_table(table_node): + return self.table[row+1][index] - if size_index != -1: - size = int(row[size_index], 0) - else: - size = 32 + def get_elem_int(self, row, index): + elem = self.get_elem(row, index) + if elem is not None: + return int(elem, 0) + return None + + def get_size(self): + return len(self.table) - 1 - cmdmap.add_cmd( - rmap.Cmd( - name=row[0], - code=row[id_index], - width=size - ) - ) - desc_index = get_table_index(get_table_node(command_node, 'Command Name'), 'Description') - if desc_index == -1: - desc_index = get_table_index(get_table_node(command_node, 'Command Name'), 'Short description') - if desc_index != -1 and len(row) >= desc_index + 1: - cmdmap.get_cmd(row[0]).desc = row[desc_index] +def parse_md(md): + if type(md) == marko.block.Document: + return Document(md) - for cmd in cmdmap.get_cmds(): - node = get_node(command_node, cmd.name) + elif type(md) == marko.block.Heading: + return Heading(md) - if node is not None: - if cmd.desc is None: - cmd.desc = get_description(node) + elif type(md) == marko.ext.gfm.elements.Table: + return Table(md) - table = get_table_node(node, 'Field Name') + #print (type(md)) - if node is not None and table is not None: - for row in get_table(table): - cmd.add_cmdfield( - rmap.Cmdfield( - name=row[0], - width=int(row[2], 0), - offset=int(row[1], 0), - value=row[3] - ) - ) + return None - desc_index = get_table_index(get_table_node(node, 'Field Name'), 'Description') - if desc_index == -1: - desc_index = get_table_index(get_table_node(node, 'Field Name'), 'Short description') - if desc_index != -1 and len(row) >= desc_index + 1: - cmd.get_cmdfield(row[0]).desc = row[desc_index] - if cmd.get_cmdfield(row[0]).desc is None: - desc_node = get_node(node, row[0], 2) - if desc_node is not None: - cmd.get_cmdfield(row[0]).desc = get_description(desc_node) +def import_md(regmap, path, registers=[]): + + with open(path, "rt") as fh: + ast = parse_md(gfm.parse(fh.read())) + + registers_ast = ast.get('Registers') + if registers_ast is None: + raise RuntimeError("Didn't find section 'Registers'") + + table = registers_ast.get_table() + if table is None: + raise RuntimeError("Didn't find table in section 'Registers'") + + for reg_name in registers: + reg = regmap.add_register(rmap.Register(name=reg_name)) + + name_index = table.get_index(names=['Register Name', 'Name']) + offset_index = table.get_index(names=['Offset', 'Address']) + width_index = table.get_index(names=['Size']) + properties_index = table.get_index(names=['Properties']) + reset_index = table.get_index(names=['Default', 'Reset Value']) + description_index = table.get_index(names=['Description', 'Short description']) + do_reset_index = table.get_index(names=['Reset']) + + for index in range(0, table.get_size()): + reg = regmap.add_register(rmap.Register( + name=table.get_elem(index, name_index), + offset=table.get_elem_int(index, offset_index) + )) + + if properties_index != -1: + for prop in table.get_elem(index, properties_index).split(): + key, value = prop.split('=') + if key == 'template': + reg.template = value + + if width_index != -1: + # Too many IPs has wrong register width, hard-code it to 32 bits + reg.width = 32 #table.get_elem_int(index, width_index) + if reset_index != -1: + reg.reset = table.get_elem_int(index, reset_index) + + if description_index != -1: + reg.desc = table.get_elem(index, description_index) + + if do_reset_index != -1: + reg.do_reset = table.get_elem_int(index, do_reset_index) + + + for register in regmap.get_registers(): + reg_name = register.get_field_template() + register_ast = ast.get(reg_name) + if register_ast is None: + print ("WARNING: Didn't find section for register %s" % reg_name) + + else: + fields_ast = register_ast.get('Fields') + if fields_ast is not None: + table = fields_ast.get_table() + else: + table = register_ast.get_table() + + if table is None: + print ("WARNING: Didn't find table in section %s" % reg_name) + else: + name_index = table.get_index(names=['Field Name']) + bit_index = table.get_index(names=['Offset', 'Bit', 'Bit Position']) + width_index = table.get_index(names=['Size', 'Width']) + access_index = table.get_index(names=['Host Access Type', 'Access Type']) + reset_index = table.get_index(names=['Default', 'Reset Value']) + description_index = table.get_index(names=['Description', 'Short description']) + + for index in range(0, table.get_size()): + regfield = register.add_regfield(rmap.Regfield( + name=table.get_elem(index, name_index), + width=table.get_elem_int(index, width_index), + bit=table.get_elem_int(index, bit_index), + access=table.get_elem(index, access_index) + )) + + if reset_index != -1: + regfield.reset = table.get_elem_int(index, reset_index) + regfield.reset_txt = table.get_elem(index, reset_index) else: - cmd.add_cmdfield( - rmap.Cmdfield( - value=cmd.code, - width=cmd.width, - name=cmd.name, - offset=0 - ) - ) + regfield.reset_txt = "--" + + if description_index != -1: + regfield.desc = table.get_elem(index, description_index) + + commands_ast = ast.get('Commands') + if commands_ast is not None: + for command_ast in commands_ast.children: + cmdmap = rmap.Cmdmap(name=command_ast.title) + regmap.add_cmdmap(cmdmap) + + table = command_ast.get_table(); + if table is None: + raise RuntimeError("Didn't find table in section 'Commands'") + + name_index = table.get_index(names=['Command Name']) + size_index = table.get_index(names=['Size']) + id_index = table.get_index(names=['Command field', 'id']) + description_index = table.get_index(names=['Description', 'Short description']) + + for index in range(0, table.get_size()): + if size_index != -1: + size = table.get_elem_int(index, size_index) + else: + size = 32 + + cmdmap.add_cmd(rmap.Cmd( + name=table.get_elem(index, name_index), + code=table.get_elem(index, id_index), + width=size, + desc=table.get_elem(index, description_index) + )) + + for cmd in cmdmap.get_cmds(): + cmd_name = cmd.name + cmd_ast = ast.get(cmd_name) + if cmd_ast is None: + print ("WARNING: Didn't find section for command %s" % cmd_name) + + else: + fields_ast = cmd_ast.get('Fields') + + if fields_ast is not None: + table = fields_ast.get_table() + else: + table = cmd_ast.get_table() + + if table is None: + print ("WARNING: Didn't find table in section %s" % cmd_name) + else: + name_index = table.get_index(names=['Field Name']) + bit_index = table.get_index(names=['Offset', 'Bit', 'Bit Position']) + width_index = table.get_index(names=['Size', 'Width']) + value_index = table.get_index(names=['Value']) + description_index = table.get_index(names=['Description', 'Short description']) + + for index in range(0, table.get_size()): + cmd.add_cmdfield(rmap.Cmdfield( + name=table.get_elem(index, name_index), + width=table.get_elem_int(index, width_index), + offset=table.get_elem_int(index, bit_index), + value=table.get_elem(index, value_index), + desc=table.get_elem(index, description_index) + )) diff --git a/rtos/pulp/gap_archi/regmap/bin/regmap_md_mistune.py b/rtos/pulp/gap_archi/regmap/bin/regmap_md_mistune.py new file mode 100644 index 000000000..57e25677e --- /dev/null +++ b/rtos/pulp/gap_archi/regmap/bin/regmap_md_mistune.py @@ -0,0 +1,369 @@ +# +# Copyright (C) 2019 GreenWaves Technologies +# + +import regmap as rmap +import mistune as mt +from bs4 import BeautifulSoup +import bs4 +import html2text as htt + +# def get_name(field): + # if field[0].isdigit(): + # field = '_' + field + # return field.replace(' ', '_') +# +# def get_description(field): + # return field.replace('\n', ' ').replace('\r', ' ') + +def is_header(n): return n.name[0] == 'h' + +def header_name(level): return 'h' + str(level) + +def header_node_level(hn): + assert hn.name[0] == 'h' + return int(hn.name[1]) + +def build_header_hierarchy(node, hier = []): + pass + +def get_description(node): + description_header_level = header_node_level(node) + description_nodes = [] + for i in node.find_next_siblings(): + if is_header(i): break + else: + description_nodes.append(i) + + description_html = "".join(map(str, description_nodes)) + description_text = htt.html2text(description_html) + return description_text + + +def get_register_node(current_node, reg_name): + for register_header in current_node.find_next_siblings(header_name(header_node_level(current_node)+1)): + name = register_header.decode_contents() + + if name == reg_name: + return register_header + + return None + +def get_register_field_table(current_node): + for i in current_node.find_next_siblings('table'): + headrow = i.thead.tr + if headrow.th: + s = headrow.th.decode_contents().lower() + if 'field name' in s: + # looks like a valid register table + return i + + return None + +def get_table_index(table, name=None, names=[]): + + search_names = [] + + search_names += names + + if name is not None: + search_names.append(name) + + for name in search_names: + headrow = table.thead.tr + r = [] + + for field_el in headrow('th'): + r.append(field_el.decode_contents().lower()) + + if not name.lower() in r: + continue + return r.index(name.lower()) + + return -1 + +def get_register_field_node(current_node, field_name): + for register_header in current_node.find_next_siblings(header_name(header_node_level(current_node)+2)): + name = register_header.decode_contents() + + if name == field_name: + return register_header + + return None + +def get_top_node(bs, current_node, name): + for i in bs(header_name(header_node_level(current_node) +1)): + if name in i.decode_contents().lower(): + return i + + return None + +def get_nodes(current_node, level=1): + return current_node.find_next_siblings(header_name(header_node_level(current_node)+level)) + +def get_node(current_node, name, level=1): + for node in get_nodes(current_node, level): + if node.decode_contents() == name: + return node + return None + +def get_table(table_node): + table = [] + for row in table_node.tbody('tr'): + r = [] + for el in row('td'): + r.append(el.decode_contents()) + table.append(r) + + return table + +def get_table_node(current_node, name): + for i in current_node.find_next_siblings('table'): + headrow = i.thead.tr + if headrow.th: + s = headrow.th.decode_contents().lower() + if name.lower() in s: + return i + + return None + +def import_md(regmap, path, registers=[]): + with open(path, "rt") as fh: + raw_text = fh.read() + html_text = mt.markdown(raw_text) + with open(path+'.html', 'wt') as fh2: fh2.write(html_text) + bs = BeautifulSoup(html_text, "html.parser") + + block = {} + + most_headers_names = ['h'+str(i) for i in range(1, 10)] + + # get block name, first header + name_header_node = bs(most_headers_names)[0] + if name_header_node: + block['name'] = name_header_node.decode_contents() + else: + raise RuntimeError("Cannot find block name header") + + # get block description + # first header with 'description' in it + description_header_node = None + for i in bs(header_name(header_node_level(name_header_node) +1)): + if 'description' in i.decode_contents().lower(): + description_header_node = i + break + + if not description_header_node: + raise RuntimeError("Cannot find a description header") + + # description nodes + # between description header and next header of another hierarchy + block['description'] = get_description(description_header_node) + + # register table + # find an header named register + # with the same hierarchy than description + register_header_node = None + for i in bs(header_name(header_node_level(name_header_node) +1)): + if 'register' in i.decode_contents().lower(): + register_header_node = i + break + + if not register_header_node: + raise RuntimeError("Cannot find a register header") + + # find the register table, should be just after this header + register_table = None + for i in register_header_node.find_next_siblings('table'): + headrow = i.thead.tr + if headrow.th: + s = headrow.th.decode_contents().lower() + if 'register name' in s: + # looks like a valid register table + register_table = i + break + + for reg_name in registers: + reg = regmap.add_register( + rmap.Register( + name=reg_name + ) + ) + + + # parse registers + for register_row in register_table.tbody('tr'): + r = [] + for register_el in register_row('td'): + r.append(register_el.decode_contents()) + + reg = regmap.add_register( + rmap.Register( + name=r[0], + offset=int(r[1], 0) + ) + ) + + try: + default_index = get_table_index(register_table, 'Properties') + if default_index != -1: + for prop in r[default_index].split(): + key, value = prop.split('=') + if key == 'template': + reg.template = value + + default_index = get_table_index(register_table, 'Size') + if default_index != -1: + # Too many IPs has wrong register width, hard-code it to 32 bits + reg.width = 32 # int(r[default_index], 0) + + default_index = get_table_index(register_table, names=['Default', 'Reset Value']) + if default_index != -1: + reg.reset = int(r[default_index], 0) + + desc_index = get_table_index(register_table, 'Description') + if desc_index == -1: + desc_index = get_table_index(register_table, 'Short description') + + if desc_index != -1: + if len(r) > desc_index: + reg.desc = r[desc_index] + + do_reset_index = get_table_index(register_table, 'Reset') + if do_reset_index != -1: + reg.do_reset = int(r[do_reset_index]) + + except: + print ('Caught error while parsing register (name: %s)' % r[0]) + raise + + + # Now for each register parse the field table + for register in regmap.get_registers(): + node = get_register_node(register_header_node, register.get_field_template()) + + if node is not None and register.desc is None: + description = get_description(node) + register.desc = description + + if node is not None: + fields_table = get_register_field_table(node) + + if fields_table is not None: + for field_row in fields_table.tbody('tr'): + r = [] + for field_el in field_row('td'): + r.append(field_el.decode_contents()) + + name_index = get_table_index(fields_table, names=['Field Name']) + bit_index = get_table_index(fields_table, names=['Offset', 'Bit', 'Bit Position']) + width_index = get_table_index(fields_table, names=['Size', 'Width']) + access_index = get_table_index(fields_table, names=['Host Access Type', 'Access Type']) + reset_index = get_table_index(fields_table, names=['Default', 'Reset Value']) + + regfield = register.add_regfield( + rmap.Regfield( + name=r[name_index], + width=int(r[width_index], 0), + bit=int(r[bit_index], 0), + access=r[access_index] + ) + ) + + desc_index = get_table_index(fields_table, 'Description') + if desc_index == -1: + desc_index = get_table_index(fields_table, 'Short description') + + if desc_index != -1: + register.get_regfield(r[0]).desc = r[desc_index] + + if reset_index != -1: + regfield.reset = int(r[reset_index], 0) + + for field in register.get_fields(): + field_node = get_register_field_node(node, field.name) + + if field_node is not None and field.desc is None: + description = get_description(field_node) + field.desc = description + + commands_top_node = get_top_node(bs, name_header_node, 'commands') + + if commands_top_node is not None: + for command_node in get_nodes(commands_top_node, 1): + cmdmap = rmap.Cmdmap(name=command_node.decode_contents()) + regmap.add_cmdmap(cmdmap) + + table_node = get_table_node(command_node, 'Command Name') + + if table_node is not None: + + size_index = get_table_index(table_node, 'Size') + id_index = get_table_index(table_node, 'Command field') + if id_index == -1: + id_index = get_table_index(table_node, 'id') + + for row in get_table(table_node): + + if size_index != -1: + size = int(row[size_index], 0) + else: + size = 32 + + cmdmap.add_cmd( + rmap.Cmd( + name=row[0], + code=row[id_index], + width=size + ) + ) + + desc_index = get_table_index(get_table_node(command_node, 'Command Name'), 'Description') + if desc_index == -1: + desc_index = get_table_index(get_table_node(command_node, 'Command Name'), 'Short description') + + if desc_index != -1 and len(row) >= desc_index + 1: + cmdmap.get_cmd(row[0]).desc = row[desc_index] + + for cmd in cmdmap.get_cmds(): + node = get_node(command_node, cmd.name) + + if node is not None: + if cmd.desc is None: + cmd.desc = get_description(node) + + table = get_table_node(node, 'Field Name') + + if node is not None and table is not None: + + for row in get_table(table): + cmd.add_cmdfield( + rmap.Cmdfield( + name=row[0], + width=int(row[2], 0), + offset=int(row[1], 0), + value=row[3] + ) + ) + + desc_index = get_table_index(get_table_node(node, 'Field Name'), 'Description') + if desc_index == -1: + desc_index = get_table_index(get_table_node(node, 'Field Name'), 'Short description') + + if desc_index != -1 and len(row) >= desc_index + 1: + cmd.get_cmdfield(row[0]).desc = row[desc_index] + + if cmd.get_cmdfield(row[0]).desc is None: + desc_node = get_node(node, row[0], 2) + if desc_node is not None: + cmd.get_cmdfield(row[0]).desc = get_description(desc_node) + + else: + cmd.add_cmdfield( + rmap.Cmdfield( + value=cmd.code, + width=cmd.width, + name=cmd.name, + offset=0 + ) + ) diff --git a/rtos/pulp/gap_archi/regmap/bin/regmap_rst.py b/rtos/pulp/gap_archi/regmap/bin/regmap_rst.py index 3c0a3005a..339ab49b7 100644 --- a/rtos/pulp/gap_archi/regmap/bin/regmap_rst.py +++ b/rtos/pulp/gap_archi/regmap/bin/regmap_rst.py @@ -56,10 +56,11 @@ def dump_to_rst(self, rst): class Cmd(object): def dump_to_cmdlist_rst(self, cmdmap, table): - table.append([':ref:`%s<%s_%s>`' % (self.name, cmdmap.name, self.name), self.width, self.code, self.desc]) + table.append([':ref:`%s<%s__%s>`' % (self.name, cmdmap.name, self.name), self.width, self.code, self.desc]) def dump_to_rst(self, rst): writer = pytablewriter.RstGridTableWriter() + writer.table_name = '\n%s:align: center\n%s:widths: 15 45 90' % (writer.indent_string, writer.indent_string) writer.header_list = ['Bit #', 'Name', 'Description'] table = [] @@ -76,6 +77,7 @@ class Cmdmap(object): def dump_to_cmdlist_rst(self, rst, writer): writer = pytablewriter.RstGridTableWriter() + writer.table_name = '\n%s:align: center\n%s:widths: 45 15 15 80' % (writer.indent_string, writer.indent_string) writer.header_list = ['Command name', 'Width', 'Command code', 'Description'] table = [] @@ -88,7 +90,7 @@ def dump_to_cmdlist_rst(self, rst, writer): writer.write_table() for name, cmd in self.commands.items(): - rst.dump_title(cmd.name, 6, link='%s_%s' % (self.name, cmd.name)) + rst.dump_title(cmd.name, 6, link='%s__%s' % (self.name, cmd.name)) cmd.dump_to_rst(rst) @@ -101,7 +103,7 @@ def get_row(self): else: bit = '%d:%d' % (self.bit + self.width - 1, self.bit) - return [bit, self.access, self.name, self.desc] + return [bit, self.access, self.name, self.reset_txt, self.desc] def dump_to_rst(self, rst): rst.append(self.get_row()) @@ -117,7 +119,8 @@ def dump_to_rst(self, rst): rst.file.write('\n') writer = pytablewriter.RstGridTableWriter() - writer.header_list = ['Bit #', 'R/W', 'Name', 'Description'] + writer.table_name = '\n%s:align: center\n%s:widths: 13 12 45 24 85' % (writer.indent_string, writer.indent_string) + writer.header_list = ['Bit #', 'R/W', 'Name', 'Reset', 'Description'] table = [] for name, field in self.fields.items(): @@ -136,7 +139,7 @@ def dump_to_rst(self, rst): rst.file.write('|\n') def dump_to_reglist_rst(self, regmap, table): - table.append([':ref:`%s<%s_%s>`' % (self.name, regmap.name, self.name), self.offset, self.width, self.desc]) + table.append([':ref:`%s<%s__%s>`' % (self.name, regmap.name, self.name), self.offset, self.width, self.desc]) class Regmap(object): @@ -154,7 +157,10 @@ def dump_to_rst(self, rst, pretty_name): rst.dump_title('Overview', 6) + rst.file.write('\nRefer to :ref:`GAP9 address map` for the base address to be used.\n\n') + writer = pytablewriter.RstGridTableWriter() + writer.table_name = '\n%s:align: center\n%s:widths: 40 12 12 90' % (writer.indent_string, writer.indent_string) writer.header_list = ['Name', 'Offset', 'Width', 'Description'] table = [] @@ -176,7 +182,7 @@ def dump_to_rst(self, rst, pretty_name): for name, register in self.registers.items(): - rst.dump_title(register.name, 6, link='%s_%s' % (self.name, register.name)) + rst.dump_title(register.name, 6, link='%s__%s' % (self.name, register.name)) register.dump_to_rst(rst) if len(self.cmdmaps) != 0: diff --git a/rtos/pulp/pulpos-2/include/pos/data/cluster.h b/rtos/pulp/pulpos-2/include/pos/data/cluster.h index 4c351318c..7abe70e42 100644 --- a/rtos/pulp/pulpos-2/include/pos/data/cluster.h +++ b/rtos/pulp/pulpos-2/include/pos/data/cluster.h @@ -26,16 +26,20 @@ typedef struct { struct pi_cluster_task *first_call_fc_for_cl; - pi_cluster_pe_task_t *first_call_from_pe; - pi_cluster_pe_task_t *last_call_from_pe; - pi_cluster_pe_task_t *first_pe_task; - pi_cluster_pe_task_t *last_pe_task; + struct pi_cluster_task *first_tasklet_fc_for_cl; + pi_cl_workitem_t *first_call_from_pe; + pi_cl_workitem_t *last_call_from_pe; + pi_cl_workitem_t *first_pe_task; + pi_cl_workitem_t *last_pe_task; + uint32_t trig_addr; } pos_cluster_call_pool_t; typedef struct pos_cluster_t { struct pi_cluster_task *last_call_fc; + struct pi_cluster_task *last_tasklet_fc; pos_cluster_call_pool_t *pool; + void *cc_stack; void *stacks; int stacks_size; unsigned int trig_addr; @@ -47,26 +51,32 @@ typedef struct pos_cluster_t { } pos_cluster_t; +extern PI_CL_L1_TINY int pos_pending_task; extern PI_CL_L1_TINY pos_cluster_call_pool_t pos_cluster_pool; #endif #define POS_CLUSTER_CALL_POOL_T_FIRST_CALL_FC_FOR_CL (0*4) -#define POS_CLUSTER_CALL_POOL_T_FIRST_CALL_FROM_PE (1*4) -#define POS_CLUSTER_CALL_POOL_T_LAST_CALL_FROM_PE (2*4) -#define POS_CLUSTER_CALL_POOL_T_FIRST_PE_TASK (3*4) -#define POS_CLUSTER_CALL_POOL_T_LAST_PE_TASK (4*4) +#define POS_CLUSTER_CALL_POOL_T_FIRST_TASKLET_FC_FOR_CL (1*4) +#define POS_CLUSTER_CALL_POOL_T_FIRST_CALL_FROM_PE (2*4) +#define POS_CLUSTER_CALL_POOL_T_LAST_CALL_FROM_PE (3*4) +#define POS_CLUSTER_CALL_POOL_T_FIRST_PE_TASK (4*4) +#define POS_CLUSTER_CALL_POOL_T_LAST_PE_TASK (5*4) +#define POS_CLUSTER_CALL_POOL_T_TRIG_ADDR (6*4) -#define POS_CLUSTER_T_SIZEOF (11*4) +#define POS_CLUSTER_T_SIZEOF (10*4) #define POS_CLUSTER_T_LAST_CALL_FC 0 -#define POS_CLUSTER_T_POOL 4 -#define POS_CLUSTER_T_STACKS 8 -#define POS_CLUSTER_T_STACKS_SIZE 12 -#define POS_CLUSTER_T_TRIG_ADDR 16 -#define POS_CLUSTER_T_CL_TASKS 20 -#define POS_CLUSTER_T_TASK_TRIG_ADDR 24 -#define POS_CLUSTER_T_CID 25 -#define POS_CLUSTER_T_CLUSTER_EXEC_MODE 26 +#define POS_CLUSTER_T_LAST_TASKLET_FC 4 +#define POS_CLUSTER_T_POOL 8 +#define POS_CLUSTER_T_CC_STACK 12 +#define POS_CLUSTER_T_STACKS 16 +#define POS_CLUSTER_T_STACKS_SIZE 20 +#define POS_CLUSTER_T_TRIG_ADDR 24 +#define POS_CLUSTER_T_CL_TASKS 28 +#define POS_CLUSTER_T_TASK_TRIG_ADDR 32 +#define POS_CLUSTER_T_CID 36 +#define POS_CLUSTER_T_CLUSTER_EXEC_MODE 37 +#define POS_CLUSTER_T_CLUSTER_STACK_SET 38 #endif \ No newline at end of file diff --git a/rtos/pulp/pulpos-2/include/pos/data/data.h b/rtos/pulp/pulpos-2/include/pos/data/data.h index 0250d1701..5c84f3b64 100644 --- a/rtos/pulp/pulpos-2/include/pos/data/data.h +++ b/rtos/pulp/pulpos-2/include/pos/data/data.h @@ -83,7 +83,7 @@ struct pi_task_implem #define CLUSTER_TASK_CUSTOM 1 -struct pi_cluster_task { +typedef struct pi_cluster_task { // entry function and its argument(s) void (*entry)(void*); void *arg; @@ -100,7 +100,8 @@ struct pi_cluster_task { struct pi_cluster_task *next; int core_mask; -}; + uint8_t event_based; +} pi_cluster_task_t; #define CLUSTER_TASK_IMPLEM struct pos_cluster_task_implem implem @@ -111,26 +112,25 @@ struct pi_cluster_task { typedef struct pi_task{ // Warning, might be accessed inline in asm, and thus can not be moved struct pi_task *next; - uintptr_t arg[2]; + uintptr_t arg[4]; uint32_t data[PI_TASK_IMPLEM_NB_DATA]; PI_TASK_IMPLEM; } pi_task_t; -typedef struct pi_cluster_pe_task_s +typedef struct pi_cl_workitem_s { - void (*entry)(struct pi_cluster_pe_task_s *task, int id); - struct pi_cluster_pe_task_s *next; - void *stacks; + void (*entry)(struct pi_cl_workitem_s *task, int id); + struct pi_cl_workitem_s *next; void (*callback_entry)(void *arg); void *callback_arg; - struct pi_cluster_pe_task_s *piped_task; + struct pi_cl_workitem_s *piped_task; uint32_t args[4]; uint8_t nb_cores; uint8_t nb_cores_popped; uint8_t nb_done_cores; -} pi_cluster_pe_task_t; +} pi_cl_workitem_t; struct pi_mem_slab { @@ -156,14 +156,13 @@ struct pi_mem_slab { #define PI_CLUSTER_PE_TASK_T_ENTRY (0*4) #define PI_CLUSTER_PE_TASK_T_NEXT (1*4) -#define PI_CLUSTER_PE_TASK_T_STACKS (2*4) -#define PI_CLUSTER_PE_TASK_T_CALLBACK_ENTRY (3*4) -#define PI_CLUSTER_PE_TASK_T_CALLBACK_ARG (4*4) -#define PI_CLUSTER_PE_TASK_T_PIPED_TASK (5*4) -#define PI_CLUSTER_PE_TASK_T_ARGS (6*4) -#define PI_CLUSTER_PE_TASK_T_NB_CORES (10*4) -#define PI_CLUSTER_PE_TASK_T_NB_CORES_POPPED (10*4 + 1) -#define PI_CLUSTER_PE_TASK_T_NB_DONE_CORES (10*4 + 2) +#define PI_CLUSTER_PE_TASK_T_CALLBACK_ENTRY (2*4) +#define PI_CLUSTER_PE_TASK_T_CALLBACK_ARG (3*4) +#define PI_CLUSTER_PE_TASK_T_PIPED_TASK (4*4) +#define PI_CLUSTER_PE_TASK_T_ARGS (5*4) +#define PI_CLUSTER_PE_TASK_T_NB_CORES (9*4) +#define PI_CLUSTER_PE_TASK_T_NB_CORES_POPPED (9*4 + 1) +#define PI_CLUSTER_PE_TASK_T_NB_DONE_CORES (9*4 + 2) #define PI_CALLBACK_T_NEXT (0*4) #define PI_CALLBACK_T_ENTRY (1*4) @@ -172,14 +171,16 @@ struct pi_mem_slab { #define PI_TASK_T_NEXT (0*4) #define PI_TASK_T_ARG_0 (1*4) #define PI_TASK_T_ARG_1 (2*4) -#define PI_TASK_T_DATA_0 (3*4) -#define PI_TASK_T_DATA_1 (4*4) -#define PI_TASK_T_DATA_2 (5*4) -#define PI_TASK_T_DATA_3 (6*4) -#define PI_TASK_T_DATA_4 (7*4) -#define PI_TASK_T_DATA_5 (8*4) -#define PI_TASK_T_DATA_6 (9*4) -#define PI_TASK_T_DATA_7 (10*4) +#define PI_TASK_T_ARG_2 (3*4) +#define PI_TASK_T_ARG_3 (4*4) +#define PI_TASK_T_DATA_0 (5*4) +#define PI_TASK_T_DATA_1 (6*4) +#define PI_TASK_T_DATA_2 (7*4) +#define PI_TASK_T_DATA_3 (8*4) +#define PI_TASK_T_DATA_4 (9*4) +#define PI_TASK_T_DATA_5 (10*4) +#define PI_TASK_T_DATA_6 (11*4) +#define PI_TASK_T_DATA_7 (12*4) #define PI_CLUSTER_TASK_ENTRY (0*4) @@ -192,6 +193,7 @@ struct pi_mem_slab { #define PI_CLUSTER_TASK_STACK_ALLOCATED (7*4) #define PI_CLUSTER_TASK_NEXT (8*4) #define PI_CLUSTER_TASK_CORE_MASK (9*4) +#define PI_CLUSTER_TASK_EVENT_BASED (10*4) diff --git a/rtos/pulp/pulpos-2/include/pos/implem/alloc_pool.h b/rtos/pulp/pulpos-2/include/pos/implem/alloc_pool.h index 908619d3e..15da3df46 100644 --- a/rtos/pulp/pulpos-2/include/pos/implem/alloc_pool.h +++ b/rtos/pulp/pulpos-2/include/pos/implem/alloc_pool.h @@ -23,6 +23,6 @@ void pos_allocs_init(); -void pos_alloc_init_l1(int cid); +void pos_alloc_init_l1(int cid, void *base, uint32_t size); #endif \ No newline at end of file diff --git a/rtos/pulp/pulpos-2/include/pos/implem/cluster.h b/rtos/pulp/pulpos-2/include/pos/implem/cluster.h index 4c3d49537..c14574957 100644 --- a/rtos/pulp/pulpos-2/include/pos/implem/cluster.h +++ b/rtos/pulp/pulpos-2/include/pos/implem/cluster.h @@ -21,6 +21,21 @@ #ifndef __POS_IMPLEM_CLUSTER_H__ #define __POS_IMPLEM_CLUSTER_H__ +extern PI_CL_L1_TINY int pos_cluster_nb_active_pe; + +static inline int pi_cluster_get_task_nb_cores() +{ + return pos_cluster_nb_active_pe; +} + +static inline int pi_cluster_send_workgroup(pi_device_t *device, pi_cluster_task_t *cluster_task) +{ + pi_task_t task; + pi_task_block(&task); + int error = pi_cluster_send_workgroup_async(device, cluster_task, &task); + pi_task_wait_on(&task); + return error; +} void pos_cluster_push_fc_event(pi_task_t *event); @@ -53,6 +68,7 @@ static inline struct pi_cluster_task *pi_cluster_task(struct pi_cluster_task *ta task->stack_size = 0; task->slave_stack_size = 0; task->nb_cores = pi_cl_cluster_nb_cores(); + task->event_based = 0; return task; } diff --git a/rtos/pulp/pulpos-2/include/pos/implem/implem.h b/rtos/pulp/pulpos-2/include/pos/implem/implem.h index ab0701ede..143f62c43 100644 --- a/rtos/pulp/pulpos-2/include/pos/implem/implem.h +++ b/rtos/pulp/pulpos-2/include/pos/implem/implem.h @@ -49,13 +49,23 @@ static inline uint32_t pi_cluster_id() return hal_cluster_id(); } +static inline int pi_cl_cluster_nb_cores_with_cc() +{ +#if !defined(ARCHI_CORE_HAS_PULPV2) || defined(PLP_NO_BUILTIN) + return ((pulp_read32(ARCHI_APB_SOC_CTRL_ADDR)>>16)) + 1; +#else + return __builtin_pulp_CoreCount() + 1; +#endif +} + + static inline int pi_cl_cluster_nb_cores() { #ifdef ARCHI_HAS_CC #if !defined(ARCHI_CORE_HAS_PULPV2) || defined(PLP_NO_BUILTIN) - return ((pulp_read32(ARCHI_APB_SOC_CTRL_ADDR)>>16) + 1); + return ((pulp_read32(ARCHI_APB_SOC_CTRL_ADDR)>>16)); #else - return __builtin_pulp_CoreCount() + 1; + return __builtin_pulp_CoreCount(); #endif #else #if !defined(ARCHI_CORE_HAS_PULPV2) || defined(PLP_NO_BUILTIN) @@ -112,6 +122,10 @@ static inline void pmsis_exit(int err) #include "task.h" +#include "alloc.h" +#include "irq.h" +#include "link.h" +#include "soc_event.h" #if defined(UDMA_VERSION) && UDMA_VERSION == 2 #include "pos/implem/udma-v2.h" #endif @@ -122,10 +136,6 @@ static inline void pmsis_exit(int err) #include "pos/implem/udma-v4.h" #endif #include "alloc.h" -#include "irq.h" -#include "link.h" -#include "soc_event.h" -#include "alloc.h" #include "alloc_pool.h" #include "trace.h" #include "soc.h" @@ -141,7 +151,7 @@ static inline void pmsis_exit(int err) #if defined(__GAP9__) #include "pos/implem/hyperbus-v2.h" #include "pos/implem/octospi-v2.h" -#include "pos/implem/i2s-v3.h" +#include "chips/gap9/drivers/i2s/i2s.h" #endif #endif diff --git a/rtos/pulp/pulpos-2/include/pos/implem/pe.h b/rtos/pulp/pulpos-2/include/pos/implem/pe.h index f1a3e8b45..bc0828c7f 100644 --- a/rtos/pulp/pulpos-2/include/pos/implem/pe.h +++ b/rtos/pulp/pulpos-2/include/pos/implem/pe.h @@ -21,21 +21,19 @@ #ifndef __POS_IMPLEM_PE_H__ #define __POS_IMPLEM_PE_H__ +static inline void pi_cl_team_barrier(); static inline void pos_team_cc_barrier() { -#ifdef ARCHI_CC_CORE_ID - eu_bar_trig_wait_clr(eu_bar_addr(1)); -#else eu_bar_trig_wait_clr(eu_bar_addr(0)); -#endif } static inline void pos_team_config_offload(int nb_cores) { unsigned int core_mask = ((1<entry = entry; task->nb_cores = 1; - task->stacks = NULL; - task->callback_entry = NULL; + task->callback_entry = pi_cl_workitem_empty_callback; task->piped_task = NULL; } -static inline void pi_cluster_pe_task_nb_cores(pi_cluster_pe_task_t *task, unsigned int nb_cores) +static inline void pi_cl_workitem_set_nb_tasks(pi_cl_workitem_t *task, unsigned int nb_cores) { task->nb_cores = nb_cores; } -static inline void pi_cluster_pe_task_callback(pi_cluster_pe_task_t *task, void (*callback)(void *arg), void *arg) +static inline void pi_cl_workitem_set_callback(pi_cl_workitem_t *task, void (*callback)(void *arg), void *arg) { task->callback_entry = callback; task->callback_arg = arg; } -static inline void pi_cluster_pe_task_arg(pi_cluster_pe_task_t *task, int index, uint32_t value) +static inline void pi_cl_workitem_set_arg(pi_cl_workitem_t *task, int index, uint32_t value) { task->args[index] = value; } -static inline void pi_cluster_pe_task_push(pi_cluster_pe_task_t *task) +static inline uint32_t pi_cl_workitem_get_arg(pi_cl_workitem_t *task, int index) +{ + return task->args[index]; +} + +static inline void pi_cl_workitem_push(pi_cl_workitem_t *task) { task->next = NULL; task->nb_done_cores = task->nb_cores; task->nb_cores_popped = 0; eu_mutex_lock_from_id(0); + pos_pending_task++; if (pos_cluster_pool.first_pe_task) { pos_cluster_pool.last_pe_task->next = task; @@ -119,7 +124,7 @@ static inline void pi_cluster_pe_task_push(pi_cluster_pe_task_t *task) } -static inline void pi_cluster_pe_task_wait(pi_cluster_pe_task_t *task) +static inline void pi_cl_workitem_wait(pi_cl_workitem_t *task) { while(*(volatile int8_t *)&task->nb_done_cores != 0) { @@ -128,7 +133,7 @@ static inline void pi_cluster_pe_task_wait(pi_cluster_pe_task_t *task) } -static inline void pi_cluster_pe_piped_task_push(pi_cluster_pe_task_t *task, pi_cluster_pe_task_t *piped_task) +static inline void pi_cluster_pe_piped_task_push(pi_cl_workitem_t *task, pi_cl_workitem_t *piped_task) { piped_task->next = NULL; piped_task->nb_done_cores = piped_task->nb_cores; @@ -173,9 +178,7 @@ static inline void pi_cl_team_preset_fork(void (*entry)(void *), void *arg) { pos_team_offload_preset(entry, arg); -#ifndef ARCHI_CC_CORE_ID entry(arg); -#endif pos_team_offload_wait(); } @@ -184,23 +187,52 @@ static inline void pi_cl_team_fork(int nb_cores, void (*entry)(void *), void *ar { pos_team_offload(nb_cores, entry, arg); -#ifndef ARCHI_CC_CORE_ID entry(arg); -#endif pos_team_offload_wait(); } +static inline void pi_cl_team_fork_pe_entry(pi_cl_workitem_t *task, int id) +{ + void (*entry)(void *) = (void (*)(void *))pi_cl_workitem_get_arg(task, 0); + void *arg = (void *)pi_cl_workitem_get_arg(task, 1); + entry(arg); +} static inline void pi_cl_team_fork_cc(int nb_cores, void (*entry)(void *), void *arg) { - pos_team_offload(nb_cores, entry, arg); + pi_cl_workitem_t workitem; + + if (nb_cores == 0) + { + nb_cores = pi_cl_team_nb_cores(); + } + if ((unsigned int)nb_cores == pi_cl_cluster_nb_pe_cores()+1) + { + nb_cores = pi_cl_cluster_nb_pe_cores(); + } + + uint32_t core_mask = ((1<arg[3]; +} + +static inline void pi_task_status_set(pi_task_t *task, int32_t status) +{ + task->arg[3] = status; +} + + static inline void pi_task_wait_on(struct pi_task *task) { int irq = hal_irq_disable(); @@ -124,6 +135,10 @@ static inline void __attribute__((always_inline)) pos_task_push_locked(pi_task_t } } +static inline void __attribute__((always_inline)) pi_task_push_irq_safe(pi_task_t *task) +{ + pos_task_push_locked(task); +} static inline void __attribute__((always_inline)) pi_task_push(pi_task_t *task) { diff --git a/rtos/pulp/pulpos-2/kernel/alloc_pool.c b/rtos/pulp/pulpos-2/kernel/alloc_pool.c index 91fbd5746..fb14681c7 100644 --- a/rtos/pulp/pulpos-2/kernel/alloc_pool.c +++ b/rtos/pulp/pulpos-2/kernel/alloc_pool.c @@ -50,11 +50,11 @@ static inline pos_alloc_t *get_fc_alloc() { return &pos_alloc_l2[0]; } #ifdef ARCHI_HAS_L1 -void pos_alloc_init_l1(int cid) +void pos_alloc_init_l1(int cid, void *base, uint32_t size) { - INIT_INF("Initializing L1 allocator (cluster: %d, base: 0x%8x, size: 0x%8x)\n", cid, (int)pos_l1_base(cid), pos_l1_size(cid)); + INIT_INF("Initializing L1 allocator (cluster: %d, base: 0x%8x, size: 0x%8x)\n", cid, (int)base, size); - pos_alloc_init(&pos_alloc_l1[cid], pos_l1_base(cid), pos_l1_size(cid)); + pos_alloc_init(&pos_alloc_l1[cid], base, size); } #endif diff --git a/rtos/pulp/pulpos-2/kernel/crt0.S b/rtos/pulp/pulpos-2/kernel/crt0.S index 46056df4f..cc88eb7e7 100644 --- a/rtos/pulp/pulpos-2/kernel/crt0.S +++ b/rtos/pulp/pulpos-2/kernel/crt0.S @@ -34,15 +34,8 @@ pos_init_entry: # Cluster PEs will also starts here to avoid aligning another entry point # Just re-route them to the right entry csrr a0, 0xF14 -#ifndef CONFIG_NO_CLUSTER_ID - andi a1, a0, 0x1f - srli a0, a0, 5 - li a2, ARCHI_FC_CID - bne a0, a2, pos_pe_start -#else li a2, ARCHI_FC_COREID - bne a0, a2, pos_pe_start -#endif + bne a0, a2, pi_cl_entry_stub #endif @@ -61,6 +54,10 @@ pos_init_entry: pos_init_end: j pos_init_end +pi_cl_entry_stub: + la t0, pi_cl_entry + jr t0 + .section .vectors, "ax" .option norvc; diff --git a/rtos/pulp/pulpos-2/kernel/init.c b/rtos/pulp/pulpos-2/kernel/init.c index 09c8e544b..310ede378 100644 --- a/rtos/pulp/pulpos-2/kernel/init.c +++ b/rtos/pulp/pulpos-2/kernel/init.c @@ -72,6 +72,11 @@ static void pos_init_bss() } +void __attribute__((weak)) pi_bsp_init() +{ +} + + void pos_init_start() { INIT_INF("Starting runtime initialization\n"); @@ -106,6 +111,8 @@ void pos_init_start() // Now now the minimal init are done, we can activate interruptions hal_irq_enable(); + pi_bsp_init(); + int retval = main(); exit(retval); diff --git a/rtos/pulp/pulpos-2/rules/pulpos/default_rules.mk b/rtos/pulp/pulpos-2/rules/pulpos/default_rules.mk index a5edf1b22..061e65c1e 100644 --- a/rtos/pulp/pulpos-2/rules/pulpos/default_rules.mk +++ b/rtos/pulp/pulpos-2/rules/pulpos/default_rules.mk @@ -309,6 +309,8 @@ build: $(TARGETS) image: gapy $(GAPY_TARGET_OPT) --platform=$(platform) --work-dir=$(TARGET_BUILD_DIR) $(config_args) $(gapy_args) run --image --binary=$(TARGETS) $(runner_args) +flash_noforce: flash + flash: gapy $(GAPY_TARGET_OPT) --platform=$(platform) --work-dir=$(TARGET_BUILD_DIR) $(config_args) $(gapy_args) run --flash --binary=$(TARGETS) $(runner_args) @@ -354,4 +356,4 @@ install-lib: build-lib # @echo " CONFIG_TRACE_LEVEL= Activate traces for the specified level (0=none, 1=fatal, 2=error, 3=warning, 4=info, 5=debug, 6=trace)." # @echo " CONFIG_TRACE_ALL=1 Activate all traces. Other traces can be individually activated with CONFIG_TRACE_." -.PHONY: image flash exec run dis size help clean all conf build-lib install-lib +.PHONY: image flash flash_noforce exec run dis size help clean all conf build-lib install-lib diff --git a/rtos/pulp/pulpos-2/rules/pulpos/src.mk b/rtos/pulp/pulpos-2/rules/pulpos/src.mk index 3726fe2f0..43feacbed 100644 --- a/rtos/pulp/pulpos-2/rules/pulpos/src.mk +++ b/rtos/pulp/pulpos-2/rules/pulpos/src.mk @@ -30,7 +30,7 @@ endif # HYPER ifeq '$(CONFIG_HYPER)' '1' -ifneq '$(udma/version)' '' +ifneq '$(udma/hyper/version)' '' ifeq '$(TARGET_CHIP_FAMILY)' 'GAP9' HYPER_HAS_ASM = 1 HYPER_HAS_OCTOSPI = 1 @@ -124,12 +124,9 @@ endif # Cluster ifeq '$(CONFIG_CLUSTER)' '1' -ifneq '$(cluster/version)' '' +ifeq '$(cluster/version)' '3' PULP_SRCS += drivers/cluster/cluster.c PULP_ASM_SRCS += drivers/cluster/pe-eu-v$(event_unit/version).S -ifneq '$(event_unit/version)' '3' -PULP_ASM_SRCS += drivers/cluster/pe-eu-v$(event_unit/version)_task.S -endif endif endif diff --git a/tools/autotiler_v3/Autotiler/AutoTilerLibTypes.h b/tools/autotiler_v3/Autotiler/AutoTilerLibTypes.h index b5bdac14e..4f4395b0d 100644 --- a/tools/autotiler_v3/Autotiler/AutoTilerLibTypes.h +++ b/tools/autotiler_v3/Autotiler/AutoTilerLibTypes.h @@ -49,6 +49,7 @@ typedef enum { KOP_DP_REDUCT_NOSCALE, KOP_DP_REDUCT_CHW2HWC, KOP_DP_REDUCT_IO, + KOP_DP_REDUCT_IO_NOSCALE, KOP_DP_REDUCT_MULBIAS, KOP_DP_REDUCT_IO_MULBIAS, KOP_DP_REDUCT_MULBIAS_SCALAR, @@ -916,6 +917,7 @@ typedef struct { uint64_t PaddedSize; /* Total size in bytes or bits of this kernel argument, byte aligned, forced padding taken into account */ uint64_t BitSize; /* Total size in bits of this kernel argument (unaligned) */ uint64_t PaddedBitSize; /* Total size in bits of this kernel argument (unaligned), forced padding taken into account */ + uint64_t Overflow; /* Amount of read overflow in bytes, it can happen on TILED arg when right or bottom padding is greater than the size of the last tile */ KernelArgOneDimDescrT **DimDescr; /* A vector of dimension description outer to inner */ KernelArgOneDimDescrT **IterOrderDimDescr; /* Reordered DimDescr according to Kernel Iteration Order */ int *KerIterDimDescr; /* Indexed by kernel's IterOrder, if in DimDescr then position in IterOrderDimDescr otherwise -1 */ @@ -1429,6 +1431,7 @@ typedef struct AGraphNodeList_T { ArgBindingDescr_T *Binding; /* The bindings from which this edge is originating */ GraphEdgeWeb_T *Web; /* Which symbol */ unsigned int Size; /* Size of this symbol as seen in the related kernel argument */ + unsigned int Guard; /* Extra space above size in case related arg can read overflow */ int Offset; /* Offset applied to the base of this symbol in case binding Oper is + or - */ int Channel; /* To which channel this symbol belongs to */ int ChannelDepth; /* Channel depth */ @@ -1457,6 +1460,7 @@ typedef struct { AT_MemLocation_T MemType; unsigned int Address; unsigned int Size; + unsigned int Guard; int LiveFirst; int LiveLast; BoxType_T AllocType; @@ -1484,6 +1488,7 @@ typedef struct AGraphEdgeWeb_T { CKernel_Arg_T *Edge; /* The symbol, CArgs or Locals in the current graph */ unsigned int Index; /* Index of this Symbol */ unsigned int Size; /* Size of this symbol */ + unsigned int Guard; /* Guard on top of Size for this symbol in case of read overflow */ int LiveFirst; /* Graph node index of start life for this symbol */ int LiveLast; /* Graph node index of start stop for this symbol */ Kernel_Arg_T *KerArg; /* This symbol is bounded to this Kernel argument */ diff --git a/tools/autotiler_v3/Autotiler/TilingGenCode.h b/tools/autotiler_v3/Autotiler/TilingGenCode.h index 53f9bc350..b036d5d5a 100644 --- a/tools/autotiler_v3/Autotiler/TilingGenCode.h +++ b/tools/autotiler_v3/Autotiler/TilingGenCode.h @@ -22,6 +22,7 @@ extern void LogicalTileNAddressAndSizeOrig(Kernel_T *Ker, Kernel_Arg_T *Arg, uin extern char *BindOpImage(ArgBindingOper Op); extern char *KernelArgImage(Kernel_T *Ker, Kernel_Arg_T *Arg, CKernel_Arg_T *ArgVal, KernelArgSelect_T ArgSel, KernelIteratorT ArgSpace, KernelIteratorT ItSpace, int *IsInvar); +extern int EvalArgOverflow(Kernel_T *Ker, Kernel_Arg_T *Arg, Object_T *Obj); #endif diff --git a/tools/autotiler_v3/CNN_Generators/CNN_Copy_Generators.c b/tools/autotiler_v3/CNN_Generators/CNN_Copy_Generators.c index a6030494d..0f69bba89 100644 --- a/tools/autotiler_v3/CNN_Generators/CNN_Copy_Generators.c +++ b/tools/autotiler_v3/CNN_Generators/CNN_Copy_Generators.c @@ -721,6 +721,8 @@ static int CNN_MatTranspose_Internal( add_kernel_arg_func_t AddKArgDimFunc = AddKernelArgDim; cnn_kernel_arg_datatype_func_t CNN_ArgDtype = CNN_ArgDataType; + if (Size < 0) CNN_ArgDtype = CNN_ArgDataTypeUns; + if (Ctrl) { if (Ctrl->TileOrientation != -1) TileOrientation = (Ctrl->TileOrientation==0)?TILE_HOR:TILE_VER; if (Ctrl->ParallelFeatures != -1) ParFeat = Ctrl->ParallelFeatures; @@ -731,6 +733,7 @@ static int CNN_MatTranspose_Internal( if (HWC) { return CNN_3DTensorPermute(Name, Ctrl, Feat, Size, Width, Height, KOP_MATPERM_HWC2WHC); } + if (Size < 0) Size = -Size; unsigned long long int LayerOp = Width*Height*Feat*Size; unsigned long long int LayerBandwidth = 0; @@ -890,6 +893,11 @@ int CNN_3DTensorPermute( add_kernel_arg_func_t AddKArgDimFunc = AddKernelArgDim; cnn_kernel_arg_datatype_func_t CNN_ArgDtype = CNN_ArgDataType; + if (Size < 0) { + CNN_ArgDtype = CNN_ArgDataTypeUns; + Size = -Size; + } + if (Ctrl) { if (Ctrl->HWC != -1) HWC = Ctrl->HWC; if (Ctrl->FloatDump != -1&&Ctrl->FloatDump) AddKArgDimFunc = AddKernelFloatArgDim; diff --git a/tools/autotiler_v3/CNN_Generators_NE16/CNN_Generators_NE16.c b/tools/autotiler_v3/CNN_Generators_NE16/CNN_Generators_NE16.c index f4a50abbf..0edf74202 100644 --- a/tools/autotiler_v3/CNN_Generators_NE16/CNN_Generators_NE16.c +++ b/tools/autotiler_v3/CNN_Generators_NE16/CNN_Generators_NE16.c @@ -23,6 +23,7 @@ #include "CNN_Generator_Util.h" #include "Gap.h" #include "hal_ne16.h" +#include "../CNN_Libraries_SQ8/CNN_Infos_SQ8.h" #define D0 KER_ITER_D0 #define D1 KER_ITER_D1 @@ -32,11 +33,6 @@ #define T1 KER_ITER_TILE1 #define T2 KER_ITER_TILE2 -#define AT_INF_NE16_PADVAL 10 -#define AT_INF_NE16_WOFFSET 12 - -#define AT_INF_NE16_DIM 16 - unsigned int NE16_DefaultConfig(unsigned char Qw, unsigned char Mode16, unsigned char StreamoutMode, @@ -320,8 +316,6 @@ Kernel_T *CNN_MM_ConvolutionNE16( char *ConvKerName=0, *PoolKerName=0, *ActKerName=0, *SetBiasKerName=0, *DPReductionKerName=0; int NeedFcx, NeedFcy, NeedDcx, NeedDcy, NeedScx, NeedScy, NeedFpx, NeedFpy, NeedDpx, NeedDpy, NeedSpx, NeedSpy; int UsedWidth, UsedHeight, UsedWc, UsedHc; - - unsigned int InTileCons = 16; int OutTileCons = 32; int StandAloneAct = (ActOper!=KOP_NONE); unsigned long long int LayerOp = 0; @@ -335,11 +329,18 @@ Kernel_T *CNN_MM_ConvolutionNE16( if (!(ActOper == KOP_NONE || ActOper == KOP_RELU || ActOper == KOP_RELUN || ActOper == KOP_RELUM || ActOper == KOP_HSIGMOID || ActOper == KOP_HSWISH || ActOper == KOP_LEAKYRELU || ActOper == KOP_SIGMOID || ActOper == KOP_TANH)) GenTilingError("CNN_MM_ConvolutionNE16 Kernel: %s, ActOper, expecting KOP_NONE, KOP_RELU, KOP_RELUN, KOP_RELUM, KOP_HSIGMOID, KOP_HSWISH, KOP_LEAKYRELU, KOP_SIGMOID or KOP_TANH", Name); - Wa |= O_NE16_LIN | O_LINEAR; + Wa |= O_NE16_LIN | O_LINEAR; + int Mode16 = (Abs(In_DataSize) == 2); + if (Mode16) { + Wa |= O_NE16_MODE16; + } + + unsigned int InTileCons = Mode16?8:16; + int NeedSetBias = Mode16; /* When there is a special activation (not supported by the accelerator itself), you need to streamout 32bits and do the act in the cluster but the ((*S) >> N) is done in the accelerator (KOP_DP_REDUCT_NOSCALE) */ int NeedReductNoScale = !(ActOper == KOP_RELU || ActOper == KOP_NONE); /* Also when in/out are 16bits you need to streamout 32bits but here the reduction step will be done in the cluster (KOP_DP_REDUCT) */ - int NeedReductScale = Abs(In_DataSize) == 2; + int NeedReductScale = Mode16; int NeedReduct = NeedReductNoScale || NeedReductScale; CNN_LayerOutputDim(Width, Height, ConvOper, Fcx, Fcy, Dcx, Dcy, Scx, Scy, ConvPad, PoolOper, Fpx, Fpy, Dpx, Dpy, Spx, Spy, PoolPad, @@ -380,26 +381,38 @@ Kernel_T *CNN_MM_ConvolutionNE16( ConvKerName = CNN_FindMatchingKernelAttr(KOP_MM_CONV, KOP_NONE, ParFeat, CALL_NE16_KER, Abs(In_DataSize), Abs(Out_DataSize), Bias_DataSize, 0, 4, Fcx, Fcy, Dcx, Dcy, Scx, Scy, &NeedFcx, &NeedFcy, &NeedDcx, &NeedDcy, &NeedScx, &NeedScy, 0); - if (ConvKerName==0) GenTilingError("CNN_MM_ConvolutionNE16 Kernel: %s, Can't find a matching Convolution basic kernel", Name); - if (PoolOper==KOP_MAXPOOL) { - PoolKerName = CNN_FindMatchingKernelAttr(PoolOper, KOP_NONE, 1, CALL_HWC_KER, In_DataSize, 0, 0, 0, Out_DataSize, Fpx, Fpy, Dpx, Dpy, Spx, Spy, + if (ConvKerName==0) GenTilingError("CNN_ConvolutionPoolAct_NE16 Kernel: %s, Can't find a matching Convolution basic kernel", Name); + + if (PoolOper==KOP_MAXPOOL || PoolOper==KOP_AVGPOOL) { + PoolKerName = CNN_FindMatchingKernelAttr(PoolOper, NeedReduct?KOP_NONE:ActOper, 1, CALL_HWC_KER, In_DataSize, 0, 0, 0, Out_DataSize, Fpx, Fpy, Dpx, Dpy, Spx, Spy, &NeedFpx, &NeedFpy, &NeedDpx, &NeedDpy, &NeedSpx, &NeedSpy, 0); - if (PoolKerName==0) GenTilingError("CNN_MM_ConvolutionNE16 Kernel: %s, Can't find a matching Pooling basic kernel", Name); + if (PoolKerName==0) GenTilingError("CNN_ConvolutionPoolAct_NE16 Kernel: %s, Can't find a matching Pooling basic kernel", Name); + if (NeedReduct) { + DPReductionKerName = CNN_FindMatchingKernelAttr(NeedReductScale?KOP_DP_REDUCT_IO:KOP_DP_REDUCT_IO_NOSCALE, ActOper, 1, CALL_HWC_KER, + 4, 0, 0, 0, Out_DataSize, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + if (DPReductionKerName==0) GenTilingError("CNN_ConvolutionPoolAct_NE16 Kernel: %s, Can't find a matching Reduction basic kernel %d %s", Name, Out_DataSize, NeedReductNoScale?"NoScale":"Scale"); + } + + } else if (NeedReduct) { + DPReductionKerName = CNN_FindMatchingKernelAttr(NeedReductScale?KOP_DP_REDUCT:KOP_DP_REDUCT_NOSCALE, ActOper, 1, CALL_HWC_KER, + 4, 0, 0, 0, Out_DataSize, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + if (DPReductionKerName==0) GenTilingError("CNN_ConvolutionPoolAct_NE16 Kernel: %s, Can't find a matching Reduction basic kernel %d %s", Name, Out_DataSize, NeedReductNoScale?"NoScale":"Scale"); } - if (NeedReduct) { - DPReductionKerName = CNN_FindMatchingKernelAttr(NeedReductNoScale?KOP_DP_REDUCT_NOSCALE:KOP_DP_REDUCT, ActOper, 1, CALL_HWC_KER, 4, 0, 0, 0, Out_DataSize, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - if (DPReductionKerName==0) GenTilingError("CNN_MM_ConvolutionNE16 Kernel: %s, Can't find a matching Reduction basic kernel %d", Name, Out_DataSize); + if (NeedSetBias) { + SetBiasKerName = CNN_FindMatchingKernelAttr(KOP_SETBIAS, KOP_NONE, ParFeat, CALL_HWC_KER, Bias_DataSize,0,0,0,4, 0,0,0,0,0,0, 0,0,0,0,0,0, 0); + if (SetBiasKerName==0) GenTilingError("CNN_ConvolutionPoolAct_NE16 Kernel: %s, Can't find a matching SetBias basic kernel", Name); } + // If pooling you need an extra buffer for convout but reduction can be done in the accelerator - int NeedConvout = NeedReduct || PoolKerName; + int NeedConvout = NeedReduct || NeedSetBias || PoolKerName; unsigned int Cos = NeedConvout?4:1; if (Log) { printf("InFeat: %d%s, OutFeat: %d, InFeatCons: %d\n", InFeat, " Im2Col", OutFeat, InTileCons); printf("Conv => W: %4d, Pad:[%d,%d] PadT:[%d,%d] => Wc: %d, Filter:[%d,%d]x%d Bits\n", Width, PadInc[0], PadInc[1], PadIncT[0], PadIncT[1], Wc, Fcx, Fcy, Filter_DataSizeBits); printf(" => H: %4d, Pad:[%d,%d] PadT:[%d,%d] => Hc: %d\n", Height, PadInc[2], PadInc[3], PadIncT[2], PadIncT[3], Hc); - printf(" ConvOut_DataSize: %d\n", Cos); - printf("Pool => Wc: %4d, Pad:[%d,%d] => Wo: %d, Filter:[%d,%d]\n", UsedWc, PadInp[0], PadInp[1], Wo, Fpx, Fpy); + printf("%s -- >ConvOut_DataSize: %d\n", NeedConvout?"NeedConvOut":"NoConvOut", Cos); + printf("Pool => Wc: %4d, Pad:[%d,%d] => Wo: %d, Filter:[%d,%d] %d\n", UsedWc, PadInp[0], PadInp[1], Wo, Fpx, Fpy, Mode16); printf(" => Hc: %4d, Pad:[%d,%d] => Ho: %d\n", UsedHc, PadInp[2], PadInp[3], Ho); printf("OverlapC: %d\n", OverlapC); printf("OverlapP: %d\n", OverlapP); @@ -410,15 +423,14 @@ Kernel_T *CNN_MM_ConvolutionNE16( if (DPReductionKerName) printf("%20s: %s\n", "DPReductionKerName", DPReductionKerName); if (PoolKerName) printf("%20s: %s\n", "PoolKerName", PoolKerName); printf("Nb Oper : %lld\n", LayerOp); - printf("NeedConvout: %d\n", NeedConvout); + } /* User kernel C arguments */ CKernel_Arg_T **KCArgs = AllocateCArgs(7); Kernel_T *Kernel; - int StreamoutMode = 1; // Streamout = apply *Scale >> ScaleN - int Mode16 = (Abs(In_DataSize) == 2); - int Streamin = 0; // Streamin initialized at 0, set to 1 in the basic kernel if multiple chin tile + int StreamoutMode = !Mode16; // Streamout = apply *Scale >> ScaleN + int Streamin = Mode16; // Streamin initialized at 0, set to 1 in the basic kernel if multiple chin tile int FilterMode = 3; int LinearMode = 1; int StridedMode = 0; @@ -426,9 +438,9 @@ Kernel_T *CNN_MM_ConvolutionNE16( int WOffsetCfg = 1; int QuantRightShift = 0; int QuantBits = (NeedReduct)?2:(Abs(Out_DataSize)==2?1:0); // 00: 8bit, 01: 16bit, 10: 32bit --> If tiling the channel input dimension you need to streamin (need 32 bits output) - int QuantNoRect = (Out_DataSize>0)?1:0; + int QuantNoRect = (NeedReduct || (Out_DataSize>0))?1:0; int NormShift = 1; - int NormBias = 1; + int NormBias = !Mode16; unsigned int DEFAULT_NE16_JOB_CFG = NE16_DefaultConfig(Filter_DataSizeBits, Mode16, StreamoutMode, FilterMode, LinearMode, StridedMode, NormBits, Streamin, \ WOffsetCfg, QuantRightShift, QuantBits, QuantNoRect, NormShift, NormBias); @@ -444,9 +456,19 @@ Kernel_T *CNN_MM_ConvolutionNE16( TCArg(CNN_ArgDataType(1, 1,1), "ScaleN"), TCArg(CNN_ArgDataType(1, 1,1), "Infos") ), - Calls(6, + Calls(7, Call("NE16_Enable", LOC_D1_PROLOG, Bindings(0)), Call("NE16_SoftReset", LOC_D0, Bindings(0)), + SetBiasKerName?Call(SetBiasKerName, LOC_D0, + Bindings(6, + K_Arg("ConvOut", KER_ARG_TILE), /* SetBias output tile */ + K_Arg("ConvOut", KER_ARG_TILE_W), /* SetBias output tile width */ + K_Arg("ConvOut", KER_ARG_TILE_H), /* SetBias output tile height */ + ParFeat?K_ArgPar("ConvOut", KER_ARG_PARTILE_SIZE, D1):Imm(1), /* Number of output features in this tile */ + K_Arg("Bias", KER_ARG_TILE), /* SetBias Bias tile */ + K_TileOper("Infos", "char *", '@', AT_INF_BIASN) /* Bias Norm */ + ) + ):AT_NO_CALL, Call(ConvKerName, LOC_D0, Bindings(28, K_Arg("In", KER_ARG_TILE), /* Conv input tile */ @@ -456,11 +478,11 @@ Kernel_T *CNN_MM_ConvolutionNE16( K_Arg(NeedConvout?"ConvOut":"Out", KER_ARG_TILE), /* Conv output */ K_Arg("Scale", KER_ARG_TILE), /* Per channel scale tile */ K_Arg("ScaleN", KER_ARG_TILE), /* Per channel scale normalization tile */ - K_ArgPar("In", KER_ARG_PARTILE_SIZE, D0), /* Number of input features in this tile */ - K_ArgPar("In", KER_ARG_LOADEDPARTILE_SIZE, D0), /* Total Number of loaded input features in case of promotion */ + K_ArgPar("In", KER_ARG_PARTILE_SIZE, D0), /* Number of input features in this tile */ + K_ArgPar("In", KER_ARG_LOADEDPARTILE_SIZE, D0), /* Total Number of loaded input features in case of promotion */ K_Arg("In", KER_ARG_TILE_H), /* Conv input tile height */ K_Arg("In", KER_ARG_TILE_W), /* Conv input tile width */ - K_ArgPar(NeedConvout?"ConvOut":"Out", KER_ARG_PARTILE_SIZE, D1), /* Number of output features in this tile */ + K_ArgPar(NeedConvout?"ConvOut":"Out", KER_ARG_PARTILE_SIZE, D1), /* Number of output features in this tile */ K_Arg(NeedConvout?"ConvOut":"Out", KER_ARG_TILE_H), K_Arg(NeedConvout?"ConvOut":"Out", KER_ARG_TILE_W), Imm(PadValue), @@ -494,7 +516,7 @@ Kernel_T *CNN_MM_ConvolutionNE16( ), (PoolKerName==0)?AT_NO_CALL: Call(PoolKerName, LOC_D0_EPILOG, - Bindings(13, + Bindings(14, K_Arg("ConvOut", KER_ARG_TILE), K_Arg("ConvOut", KER_ARG_TILE_W), K_Arg("ConvOut", KER_ARG_TILE_H), @@ -507,22 +529,23 @@ Kernel_T *CNN_MM_ConvolutionNE16( K_Arg("Out", KER_ARG_TILE), /* Pooling output tile */ K_ArgPar("ConvOut", KER_ARG_PARTILE_SIZE, D1), /* In Features */ K_Arg("Out", KER_ARG_TILE_W), /* Output tile width */ - K_Arg("Out", KER_ARG_TILE_H) /* Output tile height */ + K_Arg("Out", KER_ARG_TILE_H), /* Output tile height */ + K_Arg("Infos", KER_ARG_TILE) /* Infos */ ) ), Call("NE16_Disable", LOC_D1_EPILOG, Bindings(0)) ), KerArgs(9, - KerArgPV("In", KerArgSpace(2,T0,D0), O_IN|O_DB|O_HWC, Width, Height, UsedWidth, UsedHeight, PadIncT, PadInc, PadValue, Abs(In_DataSize), OverlapC, 0, 0, "In"), - KerArg ("ColBuff",KerArgSpace(1,T0), O_BUFF|O_NTILED, BuffS, 1, 1, 0, 0, 0, 0), - KerArg ("Bias", KerArgSpace(1,D1), O_IN|O_DB|O_CONST, 1, 1, Bs, 0, 0, 0, "Bias"), - KerArg ("Scale", KerArgSpace(1,D1), O_IN|O_DB|O_CONST, 1, 1, 1, 0, 0, 0, "Scale"), - KerArg ("ScaleN", KerArgSpace(1,D1), O_IN|O_DB|O_CONST, 1, 1, 1, 0, 0, 0, "ScaleN"), - KerArg ("Filter", KerArgSpace(1,D1), O_IN|O_DB|O_CONST|Wa, 1, WBuffSize, Ws, 0, 0, 0, "Filter"), + KerArgPV("In", KerArgSpace(2,T0,D0), O_IN|O_DB|O_HWC, Width, Height, UsedWidth, UsedHeight, PadIncT, PadInc, PadValue, Abs(In_DataSize), OverlapC, 0, 0, "In"), + KerArg ("ColBuff",KerArgSpace(1,T0), O_BUFF|O_NTILED, BuffS, 1, 1, 0, 0, 0, 0), + KerArg ("Bias", KerArgSpace(1,D1), O_IN|O_DB|O_CONST, 1, 1, Bs, 0, 0, 0, "Bias"), + KerArg ("Scale", KerArgSpace(1,D1), O_IN|O_DB|O_CONST, 1, 1, 1, 0, 0, 0, "Scale"), + KerArg ("ScaleN", KerArgSpace(1,D1), O_IN|O_DB|O_CONST, 1, 1, 1, 0, 0, 0, "ScaleN"), + KerArg ("Filter", KerArgSpace(1,D1), O_IN|O_DB|O_CONST|Wa, 1, WBuffSize, Ws, 0, 0, 0, "Filter"), NeedConvout? - KerArgP("ConvOut",KerArgSpace(2,T0,D1), O_BUFF|O_ONETILE|O_HWC,Wc, Hc, UsedWc, UsedHc, PadInp, PadInp, Cos, OverlapP, 0, 0, ""):AT_NO_KER_ARG, - KerArg ("Out", KerArgSpace(2,T0,D1), O_OUT|O_DB|O_HWC, Wo, Ho, Abs(Out_DataSize), 0, 0, 0, "Out"), - KerArg ("Infos", KerArgSpace(1,T0), O_IN|O_BUFF|O_NTILED|O_CONST, AT_INF_NE16_DIM, 1, 1, 0, 0, 0, "Infos") + KerArgP("ConvOut",KerArgSpace(2,T0,D1), O_BUFF|O_ONETILE|O_HWC,Wc, Hc, UsedWc, UsedHc, PadInp, PadInp, Cos, OverlapP, 0, 0, ""):AT_NO_KER_ARG, + KerArg ("Out", KerArgSpace(2,T0,D1), O_OUT|O_DB|O_HWC, Wo, Ho, Abs(Out_DataSize), 0, 0, 0, "Out"), + KerArg ("Infos", KerArgSpace(1,T0), O_IN|O_BUFF|O_NTILED|O_CONST, AT_INF_NE16_DIM,1, 1, 0, 0, 0, "Infos") ) ); if (Kernel) { @@ -680,18 +703,22 @@ static Kernel_T *CNN_ConvolutionNE16_Internal( LayerBandwidth += (Fcx*Fcy*Filter_DataSizeBits*InFeat*(DWConv?1:OutFeat)+7)/8; LayerBandwidth += Bias_DataSize*OutFeat; - if (ConvOper == KOP_CONV && Height == 1 && Fcy == 1) ConvOper = KOP_CONV1D; + if (ConvOper == KOP_CONV && Height == 1 && Fcy == 1 && Fcx > 1) ConvOper = KOP_CONV1D; ConvKerName = CNN_FindMatchingKernelAttr(ConvOper, KOP_NONE, ParFeat, CALL_NE16_KER, Abs(In_DataSize), Abs(Out_DataSize), Bias_DataSize, 0, 4, Fcx, Fcy, Dcx, Dcy, Scx, Scy, &NeedFcx, &NeedFcy, &NeedDcx, &NeedDcy, &NeedScx, &NeedScy, 0); if (ConvKerName==0) GenTilingError("CNN_ConvolutionPoolAct_NE16 Kernel: %s, Can't find a matching Convolution basic kernel", Name); - int BasicNE16Mode = 0; - // if ((Fcx==1 && Fcy==1) || (Fcx==3 && Fcy==3 && Scx==1 && Scy==1)) {BasicNE16Mode = 1; printf("BASIC MODE\n");} + if (PoolOper==KOP_MAXPOOL || PoolOper==KOP_AVGPOOL) { - PoolKerName = CNN_FindMatchingKernelAttr(PoolOper, KOP_NONE, 1, CALL_HWC_KER, In_DataSize, 0, 0, 0, Out_DataSize, Fpx, Fpy, Dpx, Dpy, Spx, Spy, + PoolKerName = CNN_FindMatchingKernelAttr(PoolOper, NeedReduct?KOP_NONE:ActOper, 1, CALL_HWC_KER, In_DataSize, 0, 0, 0, Out_DataSize, Fpx, Fpy, Dpx, Dpy, Spx, Spy, &NeedFpx, &NeedFpy, &NeedDpx, &NeedDpy, &NeedSpx, &NeedSpy, 0); if (PoolKerName==0) GenTilingError("CNN_ConvolutionPoolAct_NE16 Kernel: %s, Can't find a matching Pooling basic kernel", Name); - } - if (NeedReduct) { + if (NeedReduct) { + DPReductionKerName = CNN_FindMatchingKernelAttr(NeedReductScale?KOP_DP_REDUCT_IO:KOP_DP_REDUCT_IO_NOSCALE, ActOper, 1, CALL_HWC_KER, + 4, 0, 0, 0, Out_DataSize, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + if (DPReductionKerName==0) GenTilingError("CNN_ConvolutionPoolAct_NE16 Kernel: %s, Can't find a matching Reduction basic kernel %d %s", Name, Out_DataSize, NeedReductNoScale?"NoScale":"Scale"); + } + + } else if (NeedReduct) { DPReductionKerName = CNN_FindMatchingKernelAttr(NeedReductScale?KOP_DP_REDUCT:KOP_DP_REDUCT_NOSCALE, ActOper, 1, CALL_HWC_KER, 4, 0, 0, 0, Out_DataSize, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); if (DPReductionKerName==0) GenTilingError("CNN_ConvolutionPoolAct_NE16 Kernel: %s, Can't find a matching Reduction basic kernel %d %s", Name, Out_DataSize, NeedReductNoScale?"NoScale":"Scale"); @@ -702,7 +729,7 @@ static Kernel_T *CNN_ConvolutionNE16_Internal( } // If pooling you need an extra buffer for convout but reduction can be done in the accelerator - int NeedConvout = NeedReduct || PoolKerName || NeedSetBias; + int NeedConvout = NeedReduct || NeedSetBias || PoolKerName; unsigned int Cos = NeedConvout?4:1; if (Log) { @@ -738,7 +765,7 @@ static Kernel_T *CNN_ConvolutionNE16_Internal( int WOffsetCfg = 1; int QuantRightShift = 0; int QuantBits = (NeedReduct)?2:(Abs(Out_DataSize)==2?1:0); // 00: 8bit, 01: 16bit, 10: 32bit --> If tiling the channel input dimension you need to streamin (need 32 bits output) - int QuantNoRect = (Out_DataSize>0 || Mode16)?1:0; + int QuantNoRect = (NeedReduct || (Out_DataSize>0))?1:0; int NormShift = 1; int NormBias = !Mode16; unsigned int DEFAULT_NE16_JOB_CFG = NE16_DefaultConfig(Filter_DataSizeBits, Mode16, StreamoutMode, FilterMode, LinearMode, StridedMode, NormBits, Streamin, \ @@ -754,7 +781,7 @@ static Kernel_T *CNN_ConvolutionNE16_Internal( KCArgs[Ca++] = TCArg(CNN_ArgDataType(1, 1,1), "Infos"); /* User kernel kernel arguments */ - Object_T **KArgs = AllocateKerArgs(NeedConvout?(PoolKerName?9:8):7); + Object_T **KArgs = AllocateKerArgs(NeedConvout?8:7); int Ka=0; KArgs[Ka++] = KerArgPV("In", KerArgSpace(2,T0,D0), O_IN|O_DB|O_HWC, Width, Height, UsedWidth, UsedHeight, PadIncT, PadInc, PadValue, Abs(In_DataSize), OverlapC, 0, TileCons, "In"); if (MinTileDim && (MinTileDim > TileCons)) SetKerArgMinTileSize(KArgs[Ka-1], MinTileDim); @@ -768,8 +795,6 @@ static Kernel_T *CNN_ConvolutionNE16_Internal( } if (NeedConvout) KArgs[Ka++] = KerArgP("ConvOut",KerArgSpace(2,T0,Os), O_BUFF|O_ONETILE|O_HWC, Wc, Hc, UsedWc, UsedHc, PadInp, PadInp, Cos, OverlapP, 0, 0, ""); - if (NeedConvout && PoolKerName) - KArgs[Ka++] = KerArgP("ActOut", KerArgSpace(2,T0,Os), O_BUFF|O_ONETILE|O_HWC, Wc, Hc, UsedWc, UsedHc, PadInp, PadInp, 1, OverlapP, 0, 0, ""); KArgs[Ka++] = KerArg ("Out", KerArgSpace(2,T0,Os), O_OUT|O_DB|O_HWC, Wo, Ho, Abs(Out_DataSize),0,0, 0, "Out"); KArgs[Ka++] = KerArg ("Infos", KerArgSpace(1,T0), O_IN|O_BUFF|O_NTILED|O_CONST, AT_INF_NE16_DIM, 1, 1, 0, 0, 0, "Infos"); @@ -780,34 +805,9 @@ static Kernel_T *CNN_ConvolutionNE16_Internal( KernelIterSpace(3, IterParSpace(D1, OutFeat, OutTileCons), IterTiledSpace(T0), IterParSpace(D0|InFeatProp, InFeat, InTileCons))), TileOrientation|TILE_HWC, KCArgs, - Calls(10, + Calls(8, Call("NE16_Enable", DWConv?LOC_D0_PROLOG:LOC_D1_PROLOG, Bindings(0)), - BasicNE16Mode?Call("NE16_SoftReset", DWConv?LOC_D0_PROLOG:LOC_D1_PROLOG, Bindings(0)):AT_NO_CALL, - BasicNE16Mode?Call("NE16_PrepareJob", DWConv?LOC_D0_PROLOG:LOC_D1_PROLOG, - Bindings(21, - K_Arg("In", KER_ARG_FIRST_TILE), - K_Arg("In", KER_ARG_FIRST_TILE_W), - K_Arg("In", KER_ARG_FIRST_TILE_H), - K_Arg("In", KER_ARG_FIRST_TILE_PAD), - K_Arg("Filter", KER_ARG_FIRST_TILE), - K_Arg("Bias", KER_ARG_FIRST_TILE), - K_Arg("Out", KER_ARG_FIRST_TILE), - K_Arg("Scale", KER_ARG_FIRST_TILE), - K_Arg("ScaleN", KER_ARG_FIRST_TILE), - K_Arg("Out", KER_ARG_FIRST_TILE_W), - K_Arg("Out", KER_ARG_FIRST_TILE_H), - K_ArgPar("In", KER_ARG_PARTILE_SIZE, D0), - K_ArgPar(NeedConvout?"ConvOut":"Out", KER_ARG_FIRST_PARTILE_SIZE, Os), - Imm(Filter_DataSizeBits), - Imm(DEFAULT_NE16_JOB_CFG), - K_TileOper("Infos", "int *", '@', AT_INF_NE16_WOFFSET/4), - Imm(PadValue), - Imm(1), - K_ArgParOper("In", KER_ARG_PARTILE_DIM, D0, '=', 1), - Imm(0), - Imm(0) - ) - ):AT_NO_CALL, + Call("NE16_SoftReset", DWConv?LOC_D0_PROLOG:LOC_D1_PROLOG, Bindings(0)), SetBiasKerName?Call(SetBiasKerName, DWConv?LOC_LOOP:LOC_D0, Bindings(6, K_Arg("ConvOut", KER_ARG_TILE), /* SetBias output tile */ @@ -819,8 +819,8 @@ static Kernel_T *CNN_ConvolutionNE16_Internal( ) ):AT_NO_CALL, Call("NE16_SoftReset", DWConv?LOC_LOOP:LOC_D0, Bindings(0)), - Call(BasicNE16Mode?"NE16_FireJob":ConvKerName, DWConv?LOC_LOOP:LOC_D0, - Bindings(BasicNE16Mode?0:26, + Call(ConvKerName, DWConv?LOC_LOOP:LOC_D0, + Bindings(26, K_Arg("In", KER_ARG_TILE), /* Conv input tile */ K_Arg("Filter", KER_ARG_TILE), /* Conv filter */ K_Arg("Bias", KER_ARG_TILE), /* Conv Bias when depth wise conv*/ @@ -831,7 +831,7 @@ static Kernel_T *CNN_ConvolutionNE16_Internal( K_ArgPar("Filter", KER_ARG_LOADEDPARTILE_SIZE, D0), /* Total Number of loaded input features in case of promotion */ K_Arg("In", KER_ARG_TILE_H), /* Conv input tile height */ K_Arg("In", KER_ARG_TILE_W), /* Conv input tile width */ - K_ArgPar(NeedConvout?"ConvOut":"Out", KER_ARG_PARTILE_SIZE, Os), /* Number of output features in this tile */ + K_ArgPar(NeedConvout?"ConvOut":"Out", KER_ARG_PARTILE_SIZE, Os), /* Number of output features in this tile */ K_Arg(NeedConvout?"ConvOut":"Out", KER_ARG_TILE_H), K_Arg(NeedConvout?"ConvOut":"Out", KER_ARG_TILE_W), Imm(PadValue), @@ -849,36 +849,11 @@ static Kernel_T *CNN_ConvolutionNE16_Internal( NeedDcy?Imm(Dcy):AT_IGNORE_ARG_BINDING /* Pooling Dy */ ) ), - BasicNE16Mode?Call("NE16_PrepareJob", DWConv?LOC_LOOP:LOC_D0, - Bindings(21, - K_Arg("In", KER_ARG_NEXT_TILE), - K_Arg("In", KER_ARG_NEXT_TILE_W), - K_Arg("In", KER_ARG_NEXT_TILE_H), - K_Arg("In", KER_ARG_NEXT_TILE_PAD), - K_Arg("Filter", KER_ARG_NEXT_TILE), - K_Arg("Bias", KER_ARG_NEXT_TILE), - K_Arg("Out", KER_ARG_NEXT_TILE), - K_Arg("Scale", KER_ARG_NEXT_TILE), - K_Arg("ScaleN", KER_ARG_NEXT_TILE), - K_Arg("Out", KER_ARG_NEXT_TILE_W), - K_Arg("Out", KER_ARG_NEXT_TILE_H), - K_ArgPar("In", KER_ARG_NEXT_PARTILE_SIZE, D0), - K_ArgPar(NeedConvout?"ConvOut":"Out", KER_ARG_NEXT_PARTILE_SIZE, Os), - Imm(Filter_DataSizeBits), - Imm(DEFAULT_NE16_JOB_CFG), - K_TileOper("Infos", "int *", '@', AT_INF_NE16_WOFFSET/4), - Imm(PadValue), - K_ArgPred("In", KER_ARG_TILEFIRST, D0), - K_ArgPred("In", KER_ARG_NEXT_TILELAST, D0), - K_ArgPred("In", KER_ARG_NEXT_TILELAST, T0), - Imm(0) - ) - ):AT_NO_CALL, (NeedReduct==0)?AT_NO_CALL: - Call(DPReductionKerName, DWConv?LOC_LOOP_EPILOG:LOC_D0_EPILOG, /* DP Reduction also take care of optional activation */ + Call(DPReductionKerName, DWConv?LOC_LOOP_EPILOG:LOC_D0_EPILOG, /* DPReduction also take care of optional activation */ Bindings(8, K_Arg("ConvOut", KER_ARG_TILE), /* Double precision input tile */ - K_Arg(PoolOper?"ActOut":"Out", KER_ARG_TILE), /* Single precision output tile, warning use IO kernel when In=Out */ + K_Arg(PoolOper?"ConvOut":"Out", KER_ARG_TILE), /* Single precision output tile, warning use IO kernel when In=Out */ ParFeat?K_ArgPar("ConvOut", KER_ARG_PARTILE_SIZE, Os):Imm(1), /* Input tile Number of features */ K_Arg("ConvOut", KER_ARG_TILE_W), /* Input tile width */ K_Arg("ConvOut", KER_ARG_TILE_H), /* Input tile height */ @@ -889,20 +864,21 @@ static Kernel_T *CNN_ConvolutionNE16_Internal( ), (PoolKerName==0)?AT_NO_CALL: Call(PoolKerName, DWConv?LOC_LOOP:LOC_D0_EPILOG, - Bindings(13, - K_Arg(NeedReduct?"ActOut":"ConvOut", KER_ARG_TILE), - K_Arg(NeedReduct?"ActOut":"ConvOut", KER_ARG_TILE_W), - K_Arg(NeedReduct?"ActOut":"ConvOut", KER_ARG_TILE_H), + Bindings(14, + K_Arg("ConvOut", KER_ARG_TILE), + K_Arg("ConvOut", KER_ARG_TILE_W), + K_Arg("ConvOut", KER_ARG_TILE_H), NeedFpx?Imm(Fpx):AT_IGNORE_ARG_BINDING, /* Pool Fx */ NeedFpy?Imm(Fpy):AT_IGNORE_ARG_BINDING, /* Pool Fy */ NeedSpx?Imm(Spx):AT_IGNORE_ARG_BINDING, /* Pool Stridex */ NeedSpy?Imm(Spy):AT_IGNORE_ARG_BINDING, /* Pool Stridey */ - K_ArgPred(NeedReduct?"ActOut":"ConvOut", KER_ARG_TILEFIRST, T0), /* First Tile */ - K_Arg(NeedReduct?"ActOut":"ConvOut", KER_ARG_TILE_PAD), /* Pool Padding */ + K_ArgPred("ConvOut", KER_ARG_TILEFIRST, T0), /* First Tile */ + K_Arg("ConvOut", KER_ARG_TILE_PAD), /* Pool Padding */ K_Arg("Out", KER_ARG_TILE), /* Pooling output tile */ - K_ArgPar(NeedReduct?"ActOut":"ConvOut", KER_ARG_PARTILE_SIZE, D1), /* In Features */ + K_ArgPar("ConvOut", KER_ARG_PARTILE_SIZE, D1), /* In Features */ K_Arg("Out", KER_ARG_TILE_W), /* Output tile width */ - K_Arg("Out", KER_ARG_TILE_H) /* Output tile height */ + K_Arg("Out", KER_ARG_TILE_H), /* Output tile height */ + K_Arg("Infos", KER_ARG_TILE) /* Infos */ ) ), Call("NE16_Disable", DWConv?LOC_D0_EPILOG:LOC_D1_EPILOG, Bindings(0)) @@ -970,11 +946,15 @@ int CNN_ConvolutionNE16( ) { - if (Fcx==1 && Fcy==1 && Scx==1 && Scy==1 && Dcx==1 && Dcy==1 && Height==1 && Width==1) { + if (Fcx==1 && Fcy==1 && Height==1 && Width==1) { printf("This is a pointwise on 1x1 input --> Mapping to CNN_Linear_NE16\n"); CNN_LinearAct_NE16(Name, Ctrl, In_DataSize, Out_DataSize, Bias_DataSize, Scale_DataSize, Filter_DataSizeBits, InFeat, OutFeat, KOP_LINEAR, ActOper); return 1; } + int HWC = 0; + if (Ctrl) { + if (Ctrl->HWC != -1) HWC = Ctrl->HWC; + } unsigned int MinTile; unsigned int InTileCons; if (PoolOper==KOP_NONE) { @@ -991,6 +971,14 @@ int CNN_ConvolutionNE16( unsigned int Sol1TileCons = TileCons, Sol2TileCons = TileCons; AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_OFF); + if (HWC) { + printf("---------------------------------------------------------- CNN_ConvolutionNE16 MM ---------------------------------------------------------------------------\n"); + Ker = CNN_MM_ConvolutionNE16(Name, Ctrl, + In_DataSize, Out_DataSize, Bias_DataSize, Scale_DataSize, Filter_DataSizeBits, InFeat, OutFeat, Width, Height, + ConvOper, Fcx, Fcy, Dcx, Dcy, Scx, Scy, ConvPad, PadValue, PoolOper, Fpx, Fpy, Dpx, Dpy, Spx, Spy, PoolPad, ActOper); + if (Ker) return 1; + else printf("---------------------------------------------------------- MM NO SOLUTION FOUND ---------------------------------------------------------------------------\n"); + } printf("----------------------------------------------------------CNN_ConvolutionNE16------------------------------------------------------------------------------\n"); Ker = CNN_ConvolutionNE16_Internal(Name, Ctrl, In_DataSize, Out_DataSize, Bias_DataSize, Scale_DataSize, Filter_DataSizeBits, InFeat, OutFeat, Width, Height, @@ -1067,7 +1055,7 @@ int CNN_ConvolutionNE16( OutDim: Number of outputs LinearOper KOP_LINEAR - ActOper Optional activation function: KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU + ActOper Optional activation function: KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID, KOP_TANH Signature: Name(In, Filter, Bias, Out, Scale, ScaleN, Infos) @@ -1123,7 +1111,7 @@ static Kernel_T *CNN_LinearAct_NE16_Internal( LinearKerName = CNN_FindMatchingKernelAttr(LinearOper, KOP_NONE, 0, CALL_NE16_KER, Abs(In_DataSize), 0, Bias_DataSize, 0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 0); if (LinearKerName==0) GenTilingError("CNN_LinearAct_NE16 Kernel: %s, Can't find a matching Linear basic kernel: %d %d", Name, Abs(In_DataSize), Bias_DataSize); if (!(ActOper == KOP_NONE || ActOper == KOP_RELU || ActOper == KOP_RELUN || ActOper == KOP_RELUM || ActOper == KOP_HSIGMOID || ActOper == KOP_SIGMOID || ActOper == KOP_HSWISH || ActOper == KOP_LEAKYRELU || ActOper == KOP_TANH)) - GenTilingError("CNN_ConvolutionPoolAct_NE16 Kernel: %s, ActOper, expecting KOP_NONE, KOP_RELU, KOP_RELUN, KOP_RELUM, KOP_HSIGMOID, KOP_HSWISH or KOP_LEAKYRELU", Name); + GenTilingError("CNN_ConvolutionPoolAct_NE16 Kernel: %s, ActOper, expecting KOP_NONE, KOP_RELU, KOP_RELUN, KOP_RELUM, KOP_HSIGMOID, KOP_HSWISH, KOP_LEAKYRELU, KOP_SIGMOID or KOP_TANH", Name); /* Also when in/out are 16bits you need to streamout 32bits but here the reduction step will be done in the cluster (KOP_DP_REDUCT) */ int NeedReductScale = Mode16; //Abs(Out_DataSize) == 2; @@ -1159,7 +1147,7 @@ static Kernel_T *CNN_LinearAct_NE16_Internal( int WOffsetCfg = 1; int QuantRightShift = 0; int QuantBits = NeedLinOut?2:((Abs(Out_DataSize)==1)?0:1); // 00: 8bit, 01: 16bit, 10: 32bit - int QuantNoRect = (Out_DataSize>0 || Mode16)?1:0; + int QuantNoRect = (NeedReduct || (Out_DataSize>0))?1:0; int NormBias = !Mode16; int NormShift = 1; unsigned int DEFAULT_NE16_JOB_CFG = NE16_DefaultConfig(Filter_DataSizeBits, Mode16, StreamoutMode, FilterMode, LinearMode, StridedMode, NormBits, Streamin, \ diff --git a/tools/autotiler_v3/CNN_Generators_NE16/RNN_Generators_NE16.c b/tools/autotiler_v3/CNN_Generators_NE16/RNN_Generators_NE16.c index 61db23112..fb4b4693b 100644 --- a/tools/autotiler_v3/CNN_Generators_NE16/RNN_Generators_NE16.c +++ b/tools/autotiler_v3/CNN_Generators_NE16/RNN_Generators_NE16.c @@ -651,7 +651,7 @@ int RNN_Stack_NE16( if (Log) printf("Mapped sequence tile based with %d output size constraint\n", DoConstraint); } else { if (Log) printf("Failed to map sequence tile based with %d output size constraint, relaxing constraint\n", DoConstraint); - DoConstraint = (DoConstraint>16)?DoConstraint/2:0; + DoConstraint = (DoConstraint>16)?DoConstraint/2:1; } } else { if (Ok) { @@ -1128,7 +1128,7 @@ int LSTM_Stack_NE16( if (Log) printf("Mapped sequence tile based with %d output size constraint\n", DoConstraint); } else { if (Log) printf("Failed to map sequence tile based with %d output size constraint, relaxing constraint\n", DoConstraint); - DoConstraint = (DoConstraint>16)?DoConstraint-8:0; + DoConstraint = (DoConstraint>16)?DoConstraint-8:1; } } else { if (Ok) { @@ -1664,7 +1664,7 @@ int GRU_Stack_NE16( if (Log) printf("Mapped sequence tile based with %d output size constraint\n", DoConstraint); } else { if (Log) printf("Failed to map sequence tile based with %d output size constraint, relaxing constraint\n", DoConstraint); - DoConstraint = (DoConstraint>16)?DoConstraint-8:0; + DoConstraint = (DoConstraint>16)?DoConstraint-8:1; } } else { if (Ok) { diff --git a/tools/autotiler_v3/CNN_Generators_SQ8/CNN_Generators_SQ8.c b/tools/autotiler_v3/CNN_Generators_SQ8/CNN_Generators_SQ8.c index 99d97952d..2298074f7 100644 --- a/tools/autotiler_v3/CNN_Generators_SQ8/CNN_Generators_SQ8.c +++ b/tools/autotiler_v3/CNN_Generators_SQ8/CNN_Generators_SQ8.c @@ -21,6 +21,8 @@ #include "CNN_Generator_Util.h" #include "CNN_Copy_Generators.h" #include "Gap.h" +#include "../CNN_Libraries_SQ8/CNN_Infos_SQ8.h" + #define MaxS(a, b) (((int)(a)>(int)(b))?(a):(b)) #define Max(a, b) (((a)>(b))?(a):(b)) @@ -35,32 +37,6 @@ #define T1 KER_ITER_TILE1 #define T2 KER_ITER_TILE2 -#define AT_INF_BIASL_SM 0 -#define AT_INF_ACTSCALE 0 -#define AT_INF_ACTSCALEN 1 -#define AT_INF_A0 2 -#define AT_INF_B0 3 -#define AT_INF_C0 4 - -#define AT_INF_BIASN 5 -#define AT_INF_IN1SCALE 5 -#define AT_INF_SCALEN 5 -#define AT_INF_GLOBAL_SUM_SCALE 5 - -#define AT_INF_IN1SCALEN 6 -#define AT_INF_GLOBAL_SUM_SCALEN 6 - -#define AT_INF_OUTSCALE 7 -#define AT_INF_OUTSCALEN 8 - -#define AT_INF_DIM 9 - -#define AT_INF_PRENORM 9 -#define AT_INF_SQ16_DIM 10 - -#define AT_INF_ADD_BIAS 9 -#define AT_INF_ASYM_ADD_DIM 11 - void LoadCNN_SQ8_Library() @@ -128,7 +104,7 @@ void LoadCNN_SQ8_Library() ); LibKernelTemplate("Ker_MM_Pool_SQ8_T", - CArgs(13, + CArgs(14, TCArg("signed char * __restrict__", "In"), TCArg("unsigned short int", "W"), TCArg("unsigned short int", "H"), @@ -141,11 +117,12 @@ void LoadCNN_SQ8_Library() TCArg("signed char * __restrict__", "Out"), TCArg("unsigned short int", "Feat"), TCArg("unsigned short int", "Wo"), - TCArg("unsigned short int", "Ho") + TCArg("unsigned short int", "Ho"), + TCArg("signed char * __restrict__", "Infos") ) ); LibKernelTemplate("Ker_MM_Pool_USQ8_T", - CArgs(13, + CArgs(14, TCArg("unsigned char * __restrict__", "In"), TCArg("unsigned short int", "W"), TCArg("unsigned short int", "H"), @@ -158,7 +135,8 @@ void LoadCNN_SQ8_Library() TCArg("unsigned char * __restrict__", "Out"), TCArg("unsigned short int", "Feat"), TCArg("unsigned short int", "Wo"), - TCArg("unsigned short int", "Ho") + TCArg("unsigned short int", "Ho"), + TCArg("signed char * __restrict__", "Infos") ) ); LibKernelTemplate("KerConvLinReduct_SQ8_T", @@ -472,17 +450,38 @@ void LoadCNN_SQ8_Library() LibKernel("KerParLinearLayer_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), 0, 1, CNN_Type(1,1,0,0,4), 0,0,0,0,0,0)); /* Linear layer, 8b output with bias and scaling/activation (ReLU, ReLUN) done in a single shot */ - LibKernel("KerParLinearLayerFullFeatB8_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,0,0)); - LibKernel("KerParLinearLayerFullFeatB8_ReLU_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,0,0)); - LibKernel("KerParLinearLayerFullFeatB8_ReLUN_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,0,0)); - - LibKernel("KerParLinearLayerFullFeatB16_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,0,0)); - LibKernel("KerParLinearLayerFullFeatB16_ReLU_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,0,0)); - LibKernel("KerParLinearLayerFullFeatB16_ReLUN_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T",CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,0,0)); - - LibKernel("KerParLinearLayerFullFeatB32_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,0,0)); - LibKernel("KerParLinearLayerFullFeatB32_ReLU_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,0,0)); - LibKernel("KerParLinearLayerFullFeatB32_ReLUN_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T",CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB8_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB8_ReLU_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB8_ReLUN_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB8_ReLUM_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB8_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB8_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB8_HSwish_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB8_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB8_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB8_Tanh_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,0,0)); + + LibKernel("KerParLinearLayerFullFeatB16_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB16_ReLU_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB16_ReLUN_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB16_ReLUM_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB16_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB16_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB16_HSwish_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB16_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB16_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB16_Tanh_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,0,0)); + + LibKernel("KerParLinearLayerFullFeatB32_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB32_ReLU_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB32_ReLUN_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB32_ReLUM_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB32_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB32_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB32_HSwish_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB32_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB32_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,0,0)); + LibKernel("KerParLinearLayerFullFeatB32_Tanh_SQ8", CALL_PARALLEL, 0, "KerLinear_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LINEAR), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,0,0)); /* Convolution or Linear output reduction with per channel scaling and optional activation. Out != In and In Place (IO) */ LibKernel("KerParReduct_CC_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_NONE), 1, @@ -561,12 +560,49 @@ void LoadCNN_SQ8_Library() LibKernel("KerParPoolNxMStrideSxSy_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerPool_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MAXPOOL, KOP_AVGPOOL), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); - LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", - CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_NONE), 1, - CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); - LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", - CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_NONE), 1, - CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_ReLU_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_ReLUN_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_ReLUM_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_ReLUMN_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_LeakyReLU_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_HSwish_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_HSigmoid_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_Sigmoid_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_Tanh_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_ReLU_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_ReLUN_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_ReLUM_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_ReLUMN_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_LeakyReLU_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_HSwish_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_HSigmoid_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_Sigmoid_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_Tanh_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); + + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_ReLU_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_ReLUN_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_ReLUM_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_ReLUMN_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_LeakyReLU_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_HSwish_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_HSigmoid_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_Sigmoid_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_Tanh_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_MAXPOOL), CNN_OperList(1, KOP_TANH), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_ReLU_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_ReLUN_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_ReLUM_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_ReLUMN_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_LeakyReLU_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_HSwish_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_HSigmoid_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_Sigmoid_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); + LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_Tanh_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", CNN_Match(CNN_OperList(1, KOP_AVGPOOL), CNN_OperList(1, KOP_TANH), 1, CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); /* Global Pooling (Max or Avg) with tensor centric scaling and optional ReLU or ReLUN activation */ LibKernel("KerParGlobalMaxPoolFullFeat_SQ8", CALL_PARALLEL, 0, "KerGlobalPool_SQ8_T", CNN_Match(CNN_OperList(1, KOP_GLOBAL_MAXPOOL), CNN_OperList(1, KOP_NONE), 1, @@ -659,123 +695,281 @@ void LoadCNN_SQ8_Library() /* Matrix Multiplication for 1x1 convolutions with channel scaling and optional ReLU or ReLUN activation */ /* 8b Bias */ - LibKernel("KerParMatMulB8_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulB8_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulB8_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_ReLUM_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_HSwish_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_Tanh_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + + LibKernel("KerParMatMulSxSyB8_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB8_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB8_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB8_ReLUM_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB8_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB8_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB8_HSwish_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB8_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB8_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB8_Tanh_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,-1,-1)); - LibKernel("KerParMatMulSxSyB8_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,-1,-1)); - LibKernel("KerParMatMulSxSyB8_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,-1,-1)); - LibKernel("KerParMatMulSxSyB8_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,-1,-1)); /* 16b Bias */ - LibKernel("KerParMatMulB16_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulB16_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulB16_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); - - LibKernel("KerParMatMulSxSyB16_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,-1,-1)); - LibKernel("KerParMatMulSxSyB16_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,-1,-1)); - LibKernel("KerParMatMulSxSyB16_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,-1,-1)); - - /* 32b Bias */ - LibKernel("KerParMatMulB32_2x4_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulB32_2x4_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulB32_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - - LibKernel("KerParMatMulTransposedB32_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_TRANSPOSED), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulTransposedB32_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_TRANSPOSED), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulTransposedB32_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_TRANSPOSED), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - - LibKernel("KerParMatMulTransposedNoBias_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_NOBIAS_TRANSPOSED), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,0,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulTransposedNoBias_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_NOBIAS_TRANSPOSED), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,0,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulTransposedNoBias_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T",CNN_Match(CNN_OperList(1, KOP_MATMUL_NOBIAS_TRANSPOSED), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,0,0,1), 0,0,0,0,1,1)); - - LibKernel("KerParMatMulB32_2x4_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SCALE_SCALAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulB32_2x4_ReLU_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SCALE_SCALAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulB32_2x4_ReLUN_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SCALE_SCALAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - - LibKernel("KerParMatMulNoBias_2x4_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_NOBIAS_SCALE_SCALAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,0,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulNoBias_2x4_ReLU_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_NOBIAS_SCALE_SCALAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,0,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulNoBias_2x4_ReLUN_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T",CNN_Match(CNN_OperList(1, KOP_MATMUL_NOBIAS_SCALE_SCALAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,0,0,1), 0,0,0,0,1,1)); - - LibKernel("KerParMatMulTransposedB32_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulTransposedB32_ReLU_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulTransposedB32_ReLUN_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - - LibKernel("KerParMatMulTransposedNoBias_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,0,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulTransposedNoBias_ReLU_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,0,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulTransposedNoBias_ReLUN_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,0,0,1), 0,0,0,0,1,1)); - - LibKernel("KerParMatMulSxSyB32_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,-1,-1)); - LibKernel("KerParMatMulSxSyB32_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,-1,-1)); - LibKernel("KerParMatMulSxSyB32_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulB16_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_ReLUM_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_HSwish_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_Tanh_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + + LibKernel("KerParMatMulSxSyB16_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB16_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB16_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB16_ReLUM_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB16_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB16_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB16_HSwish_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB16_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB16_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB16_Tanh_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,-1,-1)); + + /* 32b Bias or No Bias at all */ + LibKernel("KerParMatMulB32_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_ReLUM_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_HSwish_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_Tanh_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + + LibKernel("KerParMatMulTransposedB32_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_TRANSPOSED, KOP_MATMUL_NOBIAS_TRANSPOSED), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_TRANSPOSED, KOP_MATMUL_NOBIAS_TRANSPOSED), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_TRANSPOSED, KOP_MATMUL_NOBIAS_TRANSPOSED), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_ReLUM_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_TRANSPOSED, KOP_MATMUL_NOBIAS_TRANSPOSED), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_TRANSPOSED, KOP_MATMUL_NOBIAS_TRANSPOSED), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_TRANSPOSED, KOP_MATMUL_NOBIAS_TRANSPOSED), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_HSwish_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_TRANSPOSED, KOP_MATMUL_NOBIAS_TRANSPOSED), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_TRANSPOSED, KOP_MATMUL_NOBIAS_TRANSPOSED), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_TRANSPOSED, KOP_MATMUL_NOBIAS_TRANSPOSED), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_Tanh_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_TRANSPOSED, KOP_MATMUL_NOBIAS_TRANSPOSED), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + + LibKernel("KerParMatMulB32_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR, KOP_MATMUL_NOBIAS_SCALE_SCALAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_ReLU_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR, KOP_MATMUL_NOBIAS_SCALE_SCALAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_ReLUN_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR, KOP_MATMUL_NOBIAS_SCALE_SCALAR), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_ReLUM_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR, KOP_MATMUL_NOBIAS_SCALE_SCALAR), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_ReLUMN_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR, KOP_MATMUL_NOBIAS_SCALE_SCALAR), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_LeakyReLU_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR, KOP_MATMUL_NOBIAS_SCALE_SCALAR), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_HSwish_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR, KOP_MATMUL_NOBIAS_SCALE_SCALAR), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_HSigmoid_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR, KOP_MATMUL_NOBIAS_SCALE_SCALAR), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_Sigmoid_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR, KOP_MATMUL_NOBIAS_SCALE_SCALAR), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_Tanh_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR, KOP_MATMUL_NOBIAS_SCALE_SCALAR), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + + LibKernel("KerParMatMulTransposedB32_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR_TRANSPOSED, KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_ReLU_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR_TRANSPOSED, KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_ReLUN_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR_TRANSPOSED, KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_ReLUM_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR_TRANSPOSED, KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_ReLUMN_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR_TRANSPOSED, KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_LeakyReLU_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR_TRANSPOSED, KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_HSwish_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR_TRANSPOSED, KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_HSigmoid_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR_TRANSPOSED, KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_Sigmoid_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR_TRANSPOSED, KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulTransposedB32_Tanh_PL_SQ8", CALL_PARALLEL, 0, "KerMatMul_PL_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL_SCALE_SCALAR_TRANSPOSED, KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + + LibKernel("KerParMatMulSxSyB32_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB32_ReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB32_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB32_ReLUM_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB32_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB32_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB32_HSwish_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB32_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB32_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,-1,-1)); + LibKernel("KerParMatMulSxSyB32_Tanh_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MATMUL, KOP_MATMUL_NOBIAS), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,-1,-1)); /* Mat Mul based convolutions */ /* CHW In and Out tensors, [OutFeat,InFeat,Fy,Fx] weights */ - LibKernel("KerPar_MM_Conv1D_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); - LibKernel("KerPar_MM_Conv1D_ReLU_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); - LibKernel("KerPar_MM_Conv1D_ReLUN_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); - LibKernel("KerPar_MM_Conv1D_LeakyReLU_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T",CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); - - LibKernel("KerPar_MM_Conv1D_DxDy_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); - LibKernel("KerPar_MM_Conv1D_DxDy_ReLU_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T",CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); - - LibKernel("KerPar_MM_Conv2D_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); - LibKernel("KerPar_MM_Conv2D_DxDy_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); - LibKernel("KerPar_MM_Conv2D_DxDy_ReLU_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T",CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); - + LibKernel("KerPar_MM_Conv1D_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_ReLU_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_ReLUN_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_ReLUM_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_ReLUMN_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_LeakyReLU_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_HSwish_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_HSigmoid_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_Sigmoid_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_Tanh_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + + LibKernel("KerPar_MM_Conv1D_DxDy_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_ReLU_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_ReLUN_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_ReLUM_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_ReLUMN_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_LeakyReLU_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_HSwish_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_HSigmoid_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_Sigmoid_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_Tanh_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + + LibKernel("KerPar_MM_Conv2D_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_ReLU_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_ReLUN_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_ReLUM_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_ReLUMN_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_LeakyReLU_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_HSwish_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_HSigmoid_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_Sigmoid_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_Tanh_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + + LibKernel("KerPar_MM_Conv2D_DxDy_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_ReLU_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_ReLUN_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_ReLUM_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_ReLUMN_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_LeakyReLU_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_HSwish_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_HSigmoid_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_Sigmoid_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_Tanh_SQ8", CALL_PARALLEL, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); /* HWC In and Out tensors, [OutFeat,Fy,Fx,InFeat] weights */ - LibKernel("KerPar_MM_Conv1x1_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", - CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); - LibKernel("KerPar_MM_Conv1x1_ReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", - CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); - LibKernel("Ker_MM_Conv1x1_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", - CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 0, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); - LibKernel("Ker_MM_Conv1x1_ReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", - CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 0, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); - LibKernel("KerPar_MM_Conv1D_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", - CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); - LibKernel("KerPar_MM_Conv1D_DxDy_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", - CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); - LibKernel("KerPar_MM_Conv2D_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", - CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); - LibKernel("KerPar_MM_Conv2D_ReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", - CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); - LibKernel("KerPar_MM_Conv2D_DxDy_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", - CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); - LibKernel("KerPar_MM_ConvDW2D_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", - CNN_Match(CNN_OperList(1, KOP_MM_CONV_DW), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); - LibKernel("Ker_MM_Conv2D_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", - CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 0, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); - LibKernel("Ker_MM_Conv2D_ReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", - CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 0, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1x1_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1x1_ReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1x1_ReLUN_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1x1_ReLUM_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1x1_ReLUMN_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1x1_LeakyReLU_HWC_SQ8",CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1x1_HSwish_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1x1_HSigmoid_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1x1_Sigmoid_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1x1_Tanh_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + + LibKernel("Ker_MM_Conv1x1_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 0, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv1x1_ReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 0, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv1x1_ReLUN_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUN), 0, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv1x1_ReLUM_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUM), 0, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv1x1_ReLUMN_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUMN), 0, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv1x1_LeakyReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_LEAKYRELU), 0, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv1x1_HSwish_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSWISH), 0, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv1x1_HSigmoid_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSIGMOID), 0, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv1x1_Sigmoid_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_SIGMOID), 0, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv1x1_Tanh_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_TANH), 0, CNN_Type(1,1,4,0,1), 1,1,1,1,-1,-1)); + + LibKernel("KerPar_MM_Conv1D_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_ReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_ReLUN_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_ReLUM_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_ReLUMN_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_LeakyReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_HSwish_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_HSigmoid_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_Sigmoid_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_Tanh_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), -1,1,1,1,-1,-1)); + + LibKernel("KerPar_MM_Conv1D_DxDy_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_ReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_ReLUN_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_ReLUM_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_ReLUMN_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_LeakyReLU_HWC_SQ8",CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_HSwish_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_HSigmoid_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_Sigmoid_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv1D_DxDy_Tanh_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), -1,1,-1,-1,-1,-1)); + + LibKernel("KerPar_MM_Conv2D_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_ReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_ReLUN_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_ReLUM_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_ReLUMN_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_LeakyReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_HSwish_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_HSigmoid_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_Sigmoid_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_Tanh_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + + LibKernel("KerPar_MM_Conv2D_DxDy_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_ReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_ReLUN_HWC_SQ8",CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_ReLUM_HWC_SQ8",CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_ReLUMN_HWC_SQ8",CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_LeakyReLU_HWC_SQ8",CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_HSwish_HWC_SQ8",CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_HSigmoid_HWC_SQ8",CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_Sigmoid_HWC_SQ8",CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + LibKernel("KerPar_MM_Conv2D_DxDy_Tanh_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), -1,-1,-1,-1,-1,-1)); + + LibKernel("Ker_MM_Conv2D_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_NONE), 0, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv2D_ReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELU), 0, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv2D_ReLUN_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUN), 0, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv2D_ReLUM_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUM), 0, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv2D_ReLUMN_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_RELUMN), 0, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv2D_LeakyReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_LEAKYRELU), 0, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv2D_HSwish_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSWISH), 0, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv2D_HSigmoid_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_HSIGMOID), 0, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv2D_Sigmoid_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_SIGMOID), 0, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); + LibKernel("Ker_MM_Conv2D_Tanh_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Conv_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MM_CONV), CNN_OperList(1, KOP_TANH), 0, CNN_Type(1,1,4,0,1), -1,-1,1,1,-1,-1)); /* Matrix Multiplication for 1x1 convolutions with channel scaling and optional ReLU or ReLUN activation, optimized form when In1 fits entirely into shared L1 */ /* 8b Bias */ - LibKernel("KerParMatMulB8_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulB8_ReLU_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulB8_ReLUN_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_ReLU_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_ReLUN_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_ReLUM_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_ReLUMN_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_LeakyReLU_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_HSwish_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_HSigmoid_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_Sigmoid_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB8_Tanh_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); /* 16b Bias */ - LibKernel("KerParMatMulB16_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulB16_ReLU_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulB16_ReLUN_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_ReLU_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_ReLUN_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_ReLUM_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_ReLUMN_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_LeakyReLU_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_HSwish_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_HSigmoid_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_Sigmoid_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB16_Tanh_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,2,0,1), 0,0,0,0,1,1)); /* 32b Bias */ - LibKernel("KerParMatMulB32_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - //LibKernel("KerParMatMulB32_ReLU_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulB32_2x4_ReLU_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatMulB32_ReLUN_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); - + LibKernel("KerParMatMulB32_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_ReLU_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_ReLUN_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_ReLUM_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_ReLUMN_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_LeakyReLU_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_HSwish_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_HSigmoid_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_Sigmoid_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatMulB32_Tanh_SF_SQ8", CALL_PARALLEL, 0, "KerMatMul_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATMUL_SM1), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,4,0,1), 0,0,0,0,1,1)); /* Matrix by vector multiplication with tensor centric scaling and optional activation */ - LibKernel("KerParMatVectMul_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatVectMul_ReLU_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatVectMul_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatVectMul_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatVectMul_HSwish_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); - LibKernel("KerParMatVectMul_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatVectMul_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_NONE), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatVectMul_ReLU_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_RELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatVectMul_ReLUN_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatVectMul_ReLUM_SF_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatVectMul_ReLUMN_SF_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatVectMul_LeakyReLU_SF_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatVectMul_HSwish_SF_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatVectMul_HSigmoid_SF_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatVectMul_Sigmoid_SF_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); + LibKernel("KerParMatVectMul_Tanh_SF_SQ8", CALL_PARALLEL, 0, "KerMat3_SQ8_T", CNN_Match(CNN_OperList(1, KOP_MATVECTMUL), CNN_OperList(1, KOP_TANH), 1, CNN_Type(1,1,1,0,1), 0,0,0,0,1,1)); /* SoftMax, pre scaling */ LibKernel("KerParSoftMax_SQ8", CALL_PARALLEL, 0, "KerSoftMax_SQ8_T", CNN_Match(CNN_OperList(1, KOP_SOFTMAX), 0, -1, CNN_Type(1,0,0,0,2), 0,0,0,0,0,0)); @@ -921,47 +1115,38 @@ void LoadCNN_SQ8_Library() LibKernel("KerConvDWNxMDxDyStrideSxSyB32_SQ8", CALL_PARALLEL, 0, "KerConv_SQ8_T",CNN_Match(CNN_OperList(1, KOP_CONV_DW), 0, 0, CNN_Type(1,1,4,0,4), -1,-1,-1,-1,-1,-1)); /* Convolution, Linear output reduction with per channel scaling and optional activation. Out != In and In Place (IO) */ - LibKernel("KerReduct_CC_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_NONE), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_ReLU_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_RELU), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_ReLUN_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_RELUN), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_ReLUM_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_RELUM), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_RELUMN), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T",CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_HSIGMOID), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_HSwish_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T",CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_HSWISH), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T",CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_LEAKYRELU), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T",CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_SIGMOID), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_Tanh_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T",CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_TANH), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - - LibKernel("KerReductIO_CC_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_NONE), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReductIO_CC_ReLU_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T",CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_RELU), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReductIO_CC_ReLUN_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T",CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_RELUN), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReductIO_CC_ReLUM_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T",CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_RELUM), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReductIO_CC_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T",CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_RELUMN), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReductIO_CC_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T",CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_HSIGMOID), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReductIO_CC_HSwish_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T",CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_HSWISH), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReductIO_CC_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T",CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_LEAKYRELU), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReductIO_CC_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T",CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_SIGMOID), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("KerReductIO_CC_Tanh_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T",CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_TANH), 0, - CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_NONE), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_ReLU_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_RELU), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_ReLUN_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_RELUN), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_ReLUM_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_RELUM), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_RELUMN), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_HSIGMOID), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_HSwish_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_HSWISH), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_LEAKYRELU), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_SIGMOID), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_Tanh_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_TANH), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + + LibKernel("KerReductIO_CC_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_NONE), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_ReLU_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_RELU), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_ReLUN_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_RELUN), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_ReLUM_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_RELUM), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_ReLUMN_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_RELUMN), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_HSigmoid_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_HSIGMOID), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_HSwish_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_HSWISH), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_LeakyReLU_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_LEAKYRELU), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_SIGMOID), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_Tanh_SQ8", CALL_PARALLEL, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_TANH), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + + LibKernel("KerReductIO_CC_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_NONE), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_HWC_ReLU_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_RELU), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_HWC_ReLUN_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_RELUN), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_HWC_ReLUM_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_RELUM), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_HWC_ReLUMN_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_RELUMN), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_HWC_HSigmoid_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_HSIGMOID), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_HWC_HSwish_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_HSWISH), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_HWC_LeakyReLU_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_LEAKYRELU), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_HWC_Sigmoid_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_SIGMOID), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_HWC_Tanh_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO), CNN_OperList(1, KOP_TANH), 0, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); /* Activation and reduct for CHW input and HWC output Layer Layout */ LibKernel("KerParReduct_CC_CHW2HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_CHW2HWC), CNN_OperList(1, KOP_NONE), 1, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); @@ -986,7 +1171,18 @@ void LoadCNN_SQ8_Library() LibKernel("KerParReduct_CC_LeakyReLU_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); LibKernel("KerParReduct_CC_Sigmoid_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); LibKernel("KerParReduct_CC_Tanh_HWC_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_TANH), 1, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); - + + LibKernel("KerParReduct_CC_HWC_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_NONE), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerParReduct_CC_ReLU_HWC_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_RELU), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerParReduct_CC_ReLUN_HWC_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerParReduct_CC_ReLUM_HWC_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerParReduct_CC_ReLUMN_HWC_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerParReduct_CC_HSigmoid_HWC_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerParReduct_CC_HSwish_HWC_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerParReduct_CC_LeakyReLU_HWC_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerParReduct_CC_Sigmoid_HWC_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerParReduct_CC_Tanh_HWC_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_TANH), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerParReduct_CC_HWC_SQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_NONE), 1, CNN_Type(4,0,0,0,2), 0,0,0,0,0,0)); LibKernel("KerParReduct_CC_ReLU_HWC_SQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_RELU), 1, CNN_Type(4,0,0,0,2), 0,0,0,0,0,0)); LibKernel("KerParReduct_CC_ReLUN_HWC_SQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(4,0,0,0,2), 0,0,0,0,0,0)); @@ -1033,20 +1229,77 @@ void LoadCNN_SQ8_Library() LibKernel("KerReduct_CC_NoScale_Tanh_SQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_TANH), 1, CNN_Type(4,0,0,0,2), 0,0,0,0,0,0)); /* Unsigned */ - LibKernel("KerReduct_CC_NoScale_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE),CNN_OperList(1, KOP_NONE), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_NoScale_ReLU_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE),CNN_OperList(1, KOP_RELU), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_NoScale_ReLUN_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE),CNN_OperList(1, KOP_RELUN), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_NoScale_ReLUM_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE),CNN_OperList(1, KOP_RELUM), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_NoScale_ReLUMN_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE),CNN_OperList(1, KOP_RELUMN),1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); - - LibKernel("KerReduct_CC_NoScale_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE),CNN_OperList(1, KOP_NONE), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_NoScale_ReLU_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE),CNN_OperList(1, KOP_RELU), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_NoScale_ReLUN_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE),CNN_OperList(1, KOP_RELUN), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_NoScale_ReLUM_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE),CNN_OperList(1, KOP_RELUM), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); - LibKernel("KerReduct_CC_NoScale_ReLUMN_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE),CNN_OperList(1, KOP_RELUMN),1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_NONE), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_ReLU_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_RELU), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_ReLUN_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_ReLUM_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_ReLUMN_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_HSigmoid_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_HSwish_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_LeakyReLU_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_Sigmoid_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_Tanh_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_TANH), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + + LibKernel("KerReduct_CC_NoScale_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_NONE), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_ReLU_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_RELU), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_ReLUN_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_ReLUM_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_ReLUMN_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_HSigmoid_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_HSwish_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_LeakyReLU_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_Sigmoid_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReduct_CC_NoScale_Tanh_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_NOSCALE), CNN_OperList(1, KOP_TANH), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + + + /* Activation and Reduct without PerChannel Scaling */ + LibKernel("KerReductIO_CC_NoScale_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_NONE), 1, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLU_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELU), 1, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLUN_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLUM_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLUMN_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_HSigmoid_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_HSwish_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_LeakyReLU_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_Sigmoid_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_Tanh_SQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_TANH), 1, CNN_Type(4,0,0,0,1), 0,0,0,0,0,0)); + + LibKernel("KerReductIO_CC_NoScale_SQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_NONE), 1, CNN_Type(4,0,0,0,2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLU_SQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELU), 1, CNN_Type(4,0,0,0,2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLUN_SQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(4,0,0,0,2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLUM_SQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(4,0,0,0,2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLUMN_SQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(4,0,0,0,2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_HSigmoid_SQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(4,0,0,0,2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_HSwish_SQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(4,0,0,0,2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_LeakyReLU_SQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(4,0,0,0,2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_Sigmoid_SQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(4,0,0,0,2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_Tanh_SQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_TANH), 1, CNN_Type(4,0,0,0,2), 0,0,0,0,0,0)); + + /* Unsigned */ + LibKernel("KerReductIO_CC_NoScale_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_NONE), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLU_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELU), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLUN_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLUM_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLUMN_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_HSigmoid_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_HSwish_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_LeakyReLU_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_Sigmoid_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_Tanh_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_TANH), 1, CNN_Type(4,0,0,0,-1), 0,0,0,0,0,0)); + + LibKernel("KerReductIO_CC_NoScale_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_NONE), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLU_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELU), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLUN_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELUN), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLUM_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELUM), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_ReLUMN_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_RELUMN), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_HSigmoid_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_HSIGMOID), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_HSwish_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_HSWISH), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_LeakyReLU_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_LEAKYRELU), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_Sigmoid_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_SIGMOID), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + LibKernel("KerReductIO_CC_NoScale_Tanh_USQ16", CALL_PARALLEL|CALL_HWC_KER, 0, "KerConvLinReduct_SQ8_T", CNN_Match(CNN_OperList(1, KOP_DP_REDUCT_IO_NOSCALE), CNN_OperList(1, KOP_TANH), 1, CNN_Type(4,0,0,0,-2), 0,0,0,0,0,0)); + /* Activations with tensor centric scaling */ - LibKernel("Ker_Scale_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_SCALE), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); LibKernel("Ker_ActNone_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_ACT_NONE), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); LibKernel("Ker_ReLU_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_RELU), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); LibKernel("Ker_ReLUN_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_RELUN), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); @@ -1058,17 +1311,6 @@ void LoadCNN_SQ8_Library() LibKernel("Ker_Sigmoid_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_SIGMOID), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); LibKernel("Ker_Tanh_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_TANH), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("Ker_ActNone_ScaleIn_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_ACT_NONE_IN_SCALE), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("Ker_ReLU_ScaleIn_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_RELU_IN_SCALE), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("Ker_ReLUN_ScaleIn_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_RELUN_IN_SCALE), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("Ker_ReLUM_ScaleIn_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_RELUM_IN_SCALE), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("Ker_ReLUMN_ScaleIn_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_RELUMN_IN_SCALE), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("Ker_HSigmoid_ScaleIn_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_HSIGMOID_IN_SCALE), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("Ker_HSwish_ScaleIn_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_HSWISH_IN_SCALE), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("Ker_LeakyReLU_ScaleIn_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_LEAKYRELU_IN_SCALE),0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("Ker_Sigmoid_ScaleIn_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_SIGMOID_IN_SCALE), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); - LibKernel("Ker_Tanh_ScaleIn_SQ8", CALL_PARALLEL, 0, "KerActivation_SQ8_T", CNN_Match(CNN_OperList(1, KOP_TANH_IN_SCALE), 0, 0, CNN_Type(1,0,0,0,1), 0,0,0,0,0,0)); - /* Pooling (Max or Avg) with tensor centric scaling and optional ReLU or ReLUN activation */ LibKernel("KerPool2x2Stride2_SQ8", CALL_PARALLEL, 0, "KerPool_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MAXPOOL, KOP_AVGPOOL), CNN_OperList(1, KOP_NONE), 0, CNN_Type(1,0,0,0,1), 2,2,1,1,2,2)); @@ -1091,13 +1333,6 @@ void LoadCNN_SQ8_Library() LibKernel("KerPoolNxMStrideSxSy_ReLUN_SQ8", CALL_PARALLEL, 0, "KerPool_SQ8_T", CNN_Match(CNN_OperList(2, KOP_MAXPOOL, KOP_AVGPOOL), CNN_OperList(1, KOP_RELUN), 0, CNN_Type(1,0,0,0,1), -1,-1,1,1,-1,-1)); - /* Unsigned int8 input/output functions for NE16 */ - LibKernel("KerParMaxPoolNxMStrideSxSy_HWC_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", - CNN_Match(CNN_OperList(1, KOP_MAXPOOL), 0, 1, - CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); - LibKernel("KerParAvgPoolNxMStrideSxSy_HWC_USQ8", CALL_PARALLEL|CALL_HWC_KER, 0, "Ker_MM_Pool_USQ8_T", - CNN_Match(CNN_OperList(1, KOP_AVGPOOL), 0, 1, - CNN_Type(-1,0,0,0,-1), -1,-1,1,1,-1,-1)); LoadCNN_Copy_Library(); } @@ -1136,7 +1371,7 @@ void LoadCNN_SQ8_Library() Spy: Pooling filter stride y dimension PoolPad: 0: No padding, 1: Zero padding - ActOper: Optional activation function: KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU + ActOper: Optional activation function: KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID, KOP_TANH Signature: Name(In, Filter, Bias, Out, Scale, ScaleN, Infos) @@ -1203,7 +1438,7 @@ static Kernel_T *CNN_MM_ConvolutionPoolAct_SQ8_Internal( } if (HWC && Fcy==1 && Fcx==1 && Scy==1 && Scx==1 && Dcy==1 && Dcx==1) - return CNN_MatMulAct_SQ8_Internal(Name, Ctrl, Bias_DataSize, Scale_DataSize, InFeat, Height*Width, OutFeat, InFeat, 0,0,0,0, KOP_MATMUL_TRANSPOSED, ActOper, 0); + return CNN_MatMulAct_SQ8_Internal(Name, Ctrl, Bias_DataSize, Scale_DataSize, 1, InFeat, Height*Width, OutFeat, InFeat, 0,0,0,0, KOP_MATMUL_TRANSPOSED, ActOper, 0); if (ParFeatConv == 2 && HWC && Fcy>1 && (InFeat < 8)) ParFeatConv = 0; @@ -1230,7 +1465,7 @@ static Kernel_T *CNN_MM_ConvolutionPoolAct_SQ8_Internal( GenTilingError("CNN_MM_ConvolutionPoolAct_SQ8 Kernel: %s, ConvOper, expecting KOP_CONV, KOP_CONV_DW", Name); if (!(PoolOper == KOP_NONE || PoolOper == KOP_MAXPOOL || PoolOper == KOP_AVGPOOL)) GenTilingError("CNN_MM_ConvolutionPoolAct_SQ8 Kernel: %s, PoolOper, expecting KOP_NONE, KOP_MAXPOOL or KOP_AVGPOOL", Name); - if (!(ActOper == KOP_NONE || ActOper == KOP_RELU || ActOper == KOP_RELUN || ActOper == KOP_RELUM || ActOper == KOP_RELUMN || ActOper == KOP_HSIGMOID || ActOper == KOP_HSWISH || ActOper == KOP_LEAKYRELU)) + if (!(ActOper == KOP_NONE || ActOper == KOP_RELU || ActOper == KOP_RELUN || ActOper == KOP_RELUM || ActOper == KOP_RELUMN || ActOper == KOP_HSIGMOID || ActOper == KOP_HSWISH || ActOper == KOP_LEAKYRELU || ActOper == KOP_SIGMOID || ActOper == KOP_TANH)) GenTilingError("CNN_MM_ConvolutionPoolAct_SQ8 Kernel: %s, ActOper, expecting KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSIGMOID, KOP_TANH, KOP_HSWISH or KOP_LEAKYRELU", Name); if (DWConv && (InFeat != OutFeat)) GenTilingError("CNN_ConvolutionPoolAct_NE16 Kernel: %s, Depth wise convolution requested with InFeat:%d != OutFeat:%d", Name, InFeat, OutFeat); @@ -1291,7 +1526,7 @@ static Kernel_T *CNN_MM_ConvolutionPoolAct_SQ8_Internal( &NeedFpx, &NeedFpy, &NeedDpx, &NeedDpy, &NeedSpx, &NeedSpy, 0); else if (ActOper) StandAloneAct = 0; else if (PoolOper==KOP_AVGPOOL && ActOper==KOP_NONE && HWC) { - StandAloneAct = 1; ActOper = KOP_SCALE; + StandAloneAct = 1; ActOper = KOP_ACT_NONE; } if (PoolKerName==0) GenTilingError("CNN_MM_ConvolutionPoolAct_SQ8 Kernel: %s, Can't find a matching Pooling %s basic kernel", Name, ActOper?"with linear rectification":""); } @@ -1385,7 +1620,7 @@ static Kernel_T *CNN_MM_ConvolutionPoolAct_SQ8_Internal( Imm((ActOper==KOP_NONE)), /* Scaling when no activation */ K_Arg("Infos", KER_ARG_TILE) /* Infos */ ): - Bindings(13, + Bindings(14, K_Arg("ConvOut", KER_ARG_TILE), /* Input tile */ K_Arg("ConvOut", KER_ARG_TILE_W), /* Input tile width */ K_Arg("ConvOut", KER_ARG_TILE_H), /* Input tile height */ @@ -1398,7 +1633,8 @@ static Kernel_T *CNN_MM_ConvolutionPoolAct_SQ8_Internal( K_Arg("Out", KER_ARG_TILE), /* Pooling output tile */ K_ArgPar("ConvOut", KER_ARG_PARTILE_SIZE, Os), /* In Features */ K_Arg("Out", KER_ARG_TILE_W), /* Output tile width */ - K_Arg("Out", KER_ARG_TILE_H) /* Output tile height */ + K_Arg("Out", KER_ARG_TILE_H), /* Output tile height */ + K_Arg("Infos", KER_ARG_TILE) /* Infos */ ) ), (ActKerName==0)?AT_NO_CALL: @@ -1695,7 +1931,7 @@ static Kernel_T *CNN_HWC_DWConvolutionPoolAct_SQ8_Internal( ), (PoolKerName==0)?AT_NO_CALL: Call(PoolKerName, LOC_D0, - Bindings(13, + Bindings(14, K_Arg("ConvOut", KER_ARG_TILE), /* Input tile */ K_Arg("ConvOut", KER_ARG_TILE_W), /* Input tile width */ K_Arg("ConvOut", KER_ARG_TILE_H), /* Input tile height */ @@ -1708,7 +1944,8 @@ static Kernel_T *CNN_HWC_DWConvolutionPoolAct_SQ8_Internal( K_Arg("Out", KER_ARG_TILE), /* Pooling output tile */ K_ArgPar("ConvOut", KER_ARG_PARTILE_SIZE, D0), /* In Features */ K_Arg("Out", KER_ARG_TILE_W), /* Output tile width */ - K_Arg("Out", KER_ARG_TILE_H) /* Output tile height */ + K_Arg("Out", KER_ARG_TILE_H), /* Output tile height */ + K_Arg("Infos", KER_ARG_TILE) /* Infos */ ) ), (ActKerName==0)?AT_NO_CALL: @@ -1790,7 +2027,7 @@ static Kernel_T *CNN_HWC_DWConvolutionPoolAct_SQ8_Internal( Spy: Pooling filter stride y dimension PoolPad: 0: No padding, 1: Zero padding - ActOper: Optional activation function: KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID + ActOper: Optional activation function: KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID, KOP_TANH Signature: Name(In, Filter, Bias, Out, Scale, ScaleN, Infos) @@ -1880,10 +2117,6 @@ Kernel_T *CNN_ConvolutionPoolAct_SQ8_Internal( if (Ok!=0) return Ok; if (Log) printf("No solution found for im2col scheme, reverting to standard implementation\n"); } - if (Fcx==1 && Fcy==1 && Scx==1 && Scy==1 && Dcx==1 && Dcy==1 && Height==1 && Width==1) { - printf("This is a pointwise on 1x1 input --> Mapping to CNN_Linear_NE16\n"); - return CNN_LinearAct_SQ8_Internal(Name, Ctrl, Bias_DataSize, Scale_DataSize, InFeat, OutFeat, KOP_LINEAR, ActOper); - } if (PoolOper==KOP_NONE) { Fpx=1; Dpx=1; Spx=1; Fpy=1; Dpy=1; Spy=1; @@ -2010,7 +2243,7 @@ Kernel_T *CNN_ConvolutionPoolAct_SQ8_Internal( if (Ok) return Ok; } if (Log) printf("Mapping this convolution to matrix multiplication\n"); - Kernel_T *Ok = CNN_MatMulAct_SQ8_Internal(Name, 0, Bias_DataSize, Scale_DataSize, InFeat, OutFeat, Width*Height, InFeat, Width, Height, Scx, Scy, KOP_MATMUL, ActOper, 1); + Kernel_T *Ok = CNN_MatMulAct_SQ8_Internal(Name, 0, Bias_DataSize, Scale_DataSize, 1, InFeat, OutFeat, Width*Height, InFeat, Width, Height, Scx, Scy, KOP_MATMUL, ActOper, 1); AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_ON); if (Ok) return Ok; if (Log) printf("Mapping this convolution to matrix multiplication FAILED, reverting to standard implementation\n"); @@ -2208,7 +2441,7 @@ Kernel_T *CNN_ConvolutionPoolAct_SQ8_Internal( Spy: Pooling filter stride y dimension PoolPad: 0: No padding, 1: Zero padding - ActOper: Optional activation function: KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID + ActOper: Optional activation function: KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID, KOP_TANH Signature: Name(In, Filter, Bias, Out, Scale, ScaleN, Infos) @@ -2263,7 +2496,7 @@ int CNN_GroupedConvolutionPoolAct_SQ8( GenTilingError("CNN_GroupedConvolutionPoolAct_SQ8: Kernel: %s, ConvOper, expecting KOP_NONE, KOP_CONV or KOP_CONV_DW", Name); if (!(PoolOper == KOP_NONE || PoolOper == KOP_MAXPOOL || PoolOper == KOP_AVGPOOL)) GenTilingError("CNN_GroupedConvolutionPoolAct_SQ8: Kernel: %s, PoolOper, expecting KOP_NONE, KOP_MAXPOOL or KOP_AVGPOOL", Name); - if (!(ActOper == KOP_NONE || ActOper == KOP_RELU || ActOper == KOP_RELUN || ActOper == KOP_RELUM || ActOper == KOP_RELUMN || ActOper == KOP_HSIGMOID || ActOper == KOP_HSWISH || ActOper == KOP_LEAKYRELU)) + if (!(ActOper == KOP_NONE || ActOper == KOP_RELU || ActOper == KOP_RELUN || ActOper == KOP_RELUM || ActOper == KOP_RELUMN || ActOper == KOP_HSIGMOID || ActOper == KOP_HSWISH || ActOper == KOP_LEAKYRELU || ActOper == KOP_SIGMOID || ActOper == KOP_TANH)) GenTilingError("CNN_GroupedConvolutionPoolAct_SQ8: Kernel: %s, ActOper, expecting KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSIGMOID, KOP_TANH, KOP_HSWISH or KOP_LEAKYRELU", Name); CNN_LayerOutputDim(Width, Height, ConvOper, Fcx, Fcy, Dcx, Dcy, Scx, Scy, ConvPad, PoolOper, Fpx, Fpy, Dpx, Dpy, Spx, Spy, PoolPad, &Wc, &Hc, &Wo, &Ho, 0, 0, 0, 0); @@ -2345,7 +2578,7 @@ int CNN_GroupedConvolutionPoolAct_SQ8( Spx: Pooling stride, x dimension Spy: Pooling stride, y dimension - ActOper: Optional activation function: KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID + ActOper: Optional activation function: KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID, KOP_TANH Signature: Name(In, Out, Infos) @@ -2403,7 +2636,7 @@ Kernel_T * CNN_PoolAct_SQ8_Internal( if (!(PoolOper == KOP_MAXPOOL || PoolOper == KOP_AVGPOOL)) GenTilingError("CNN_Pool_SQ8 Kernel: %s, PoolOper, expecting KOP_MAXPOOL or KOP_AVGPOOL", Name); - if (!(ActOper == KOP_NONE || ActOper == KOP_RELU || ActOper == KOP_RELUN || ActOper == KOP_RELUM || ActOper == KOP_RELUMN || ActOper == KOP_HSIGMOID || ActOper == KOP_HSWISH || ActOper == KOP_LEAKYRELU)) + if (!(ActOper == KOP_NONE || ActOper == KOP_RELU || ActOper == KOP_RELUN || ActOper == KOP_RELUM || ActOper == KOP_RELUMN || ActOper == KOP_HSIGMOID || ActOper == KOP_HSWISH || ActOper == KOP_LEAKYRELU || ActOper == KOP_SIGMOID || ActOper == KOP_TANH)) GenTilingError("CNN_Pool_SQ8 Kernel: %s, ActOper, expecting KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSIGMOID, KOP_TANH, KOP_HSWISH or KOP_LEAKYRELU", Name); /* Set Kernel characteristics */ @@ -2491,7 +2724,7 @@ Kernel_T * CNN_PoolAct_SQ8_Internal( Imm((ActOper==KOP_NONE)), /* Scaling when no activation */ K_Arg("Infos", KER_ARG_TILE) /* Infos */ ): - Bindings(13, + Bindings(14, K_Arg("In", KER_ARG_TILE), /* Input tile */ K_Arg("In", KER_ARG_TILE_W), /* Input tile width */ K_Arg("In", KER_ARG_TILE_H), /* Input tile height */ @@ -2504,7 +2737,8 @@ Kernel_T * CNN_PoolAct_SQ8_Internal( K_Arg("Out", KER_ARG_TILE), /* Pooling output tile */ ParFeat?K_ArgPar("In", KER_ARG_PARTILE_SIZE, D0):Imm(1), /* In Features */ K_Arg("Out", KER_ARG_TILE_W), /* Output tile width */ - K_Arg("Out", KER_ARG_TILE_H) /* Output tile height */ + K_Arg("Out", KER_ARG_TILE_H), /* Output tile height */ + K_Arg("Infos", KER_ARG_TILE) /* Infos */ ) ), @@ -2550,7 +2784,6 @@ Kernel_T * CNN_PoolAct_SQ8_Internal( Height: Number of lines of a given feature map ActOper: KOP_ACT_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID - KOP_ACT_NONE_IN_SCALE, KOP_RELU_IN_SCALE, KOP_RELUN_IN_SCALE, KOP_HSIGMOID_IN_SCALE, KOP_HSWISH_IN_SCALE, KOP_LEAKYRELU_IN_SCALE, KOP_SIGMOID_IN_SCALE Signature: Name(In, Out, Infos) @@ -2580,9 +2813,8 @@ Kernel_T * CNN_Act_SQ8_Internal( int StandAloneAct = (ActOper!=KOP_NONE); int Log=1; - if (!(ActOper == KOP_ACT_NONE || ActOper == KOP_RELU || ActOper == KOP_RELUN || ActOper == KOP_RELUM || ActOper == KOP_RELUMN || ActOper == KOP_HSIGMOID || ActOper == KOP_HSWISH || ActOper == KOP_LEAKYRELU || ActOper == KOP_SIGMOID || ActOper == KOP_TANH || - ActOper == KOP_ACT_NONE_IN_SCALE || ActOper == KOP_RELU_IN_SCALE || ActOper == KOP_RELUN_IN_SCALE || ActOper == KOP_RELUM_IN_SCALE || ActOper == KOP_RELUMN_IN_SCALE || ActOper == KOP_HSIGMOID_IN_SCALE || ActOper == KOP_HSWISH_IN_SCALE || ActOper == KOP_LEAKYRELU_IN_SCALE || ActOper == KOP_SIGMOID_IN_SCALE || ActOper == KOP_TANH_IN_SCALE)) - GenTilingError("CNN_Act_SQ8 Kernel: %s, ActOper, expecting KOP_ACT_NONE, KOP_RELU, KOP_RELUN, KOP_RELUM, KOP_RELUMN, KOP_HSIGMOID, KOP_TANH, KOP_HSWISH or KOP_LEAKYRELU", Name); + if (!(ActOper == KOP_ACT_NONE || ActOper == KOP_RELU || ActOper == KOP_RELUN || ActOper == KOP_RELUM || ActOper == KOP_RELUMN || ActOper == KOP_HSIGMOID || ActOper == KOP_HSWISH || ActOper == KOP_LEAKYRELU || ActOper == KOP_SIGMOID || ActOper == KOP_TANH)) + GenTilingError("CNN_Act_SQ8 Kernel: %s, ActOper, expecting KOP_ACT_NONE, KOP_RELU, KOP_RELUN, KOP_RELUM, KOP_RELUMN, KOP_HSIGMOID, KOP_TANH, KOP_HSWISH, KOP_SIGMOID or KOP_LEAKYRELU", Name); ActKerName = CNN_FindMatchingKernel(ActOper, KOP_NONE, 0, 1, 0, 0, 0, 1, 0,0,0,0,0,0, 0,0,0,0,0,0, 0); if (ActKerName==0) GenTilingError("CNN_Act_SQ8 Kernel: %s, Can't find a matching Activation basic kernel", Name); @@ -2653,7 +2885,7 @@ Kernel_T * CNN_Act_SQ8_Internal( PoolOper: KOP_GLOBAL_MAXPOOL or KOP_GLOBAL_AVGPOOL - ActOper: Optional activation function: KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID + ActOper: Optional activation function: KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID, KOP_TANH Signature: Name(In, Out, Infos) @@ -2692,7 +2924,7 @@ static Kernel_T *CNN_GlobalPoolAct_SQ8_Interal( if (!(PoolOper == KOP_GLOBAL_MAXPOOL || PoolOper == KOP_GLOBAL_AVGPOOL || PoolOper == KOP_GLOBAL_SUMPOOL)) GenTilingError("CNN_GlobalPoolAct_SQ8 Kernel: %s, PoolOper should be KOP_GLOBAL_MAXPOOL or KOP_GLOBAL_AVGPOOL or KOP_GLOBAL_SUMPOOL", Name); - if (!(ActOper == KOP_NONE || ActOper == KOP_RELU || ActOper == KOP_RELUN || ActOper == KOP_RELUM || ActOper == KOP_RELUMN || ActOper == KOP_HSIGMOID || ActOper == KOP_HSWISH || ActOper == KOP_LEAKYRELU)) + if (!(ActOper == KOP_NONE || ActOper == KOP_RELU || ActOper == KOP_RELUN || ActOper == KOP_RELUM || ActOper == KOP_RELUMN || ActOper == KOP_HSIGMOID || ActOper == KOP_HSWISH || ActOper == KOP_LEAKYRELU || ActOper == KOP_SIGMOID || ActOper == KOP_TANH)) GenTilingError("CNN_GlobalPoolAct_SQ8 Kernel: %s, ActOper, expecting KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSIGMOID, KOP_TANH, KOP_HSWISH or KOP_LEAKYRELU", Name); PoolKerName = CNN_FindMatchingKernelAttr(PoolOper, ActOper, ParFeat, KerLayout, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); @@ -2871,7 +3103,7 @@ static Kernel_T *CNN_GlobalPoolAct_SQ8_Interal( OutDim: Number of outputs LinearOper KOP_LINEAR - ActOper Optional activation function: KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID + ActOper Optional activation function: KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID, KOP_TANH Signature: Name(In, Filter, Bias, Out, Scale, ScaleN, Infos) @@ -3220,13 +3452,13 @@ static Kernel_T * CNN_SoftMax2D_SQ8_Internal( ), (HWC==0)? KerArgs(3, - KerArg("In", KerArgSpace(2,D0,T0), OBJ_BUFFER_IN, 1, Dim, 1, 0, 0, 8, "In"), - KerArg("Out", KerArgSpace(2,D0,T0), OBJ_BUFFER_OUT, 1, Dim, OutBytes, 0, 0, 0, "Out"), + KerArg("In", KerArgSpace(2,D0,T0), OBJ_IN_DB, 1, Dim, 1, 0, 0, 8, "In"), + KerArg("Out", KerArgSpace(2,D0,T0), OBJ_OUT_DB, 1, Dim, OutBytes, 0, 0, 0, "Out"), KerArg("Infos", KerArgSpace(1,T0), O_IN|O_BUFF|O_NTILED|O_CONST, AT_INF_DIM, 1, 1, 0, 0, 0, "Infos") ): KerArgs(3, - KerArg("In", KerArgSpace(2,T0,D0), OBJ_BUFFER_IN, 1, Dim, 1, 0, 0, 8, "In"), - KerArg("Out", KerArgSpace(2,T0,D0), OBJ_BUFFER_OUT, 1, Dim, OutBytes, 0, 0, 0, "Out"), + KerArg("In", KerArgSpace(2,T0,D0), OBJ_IN_DB, 1, Dim, 1, 0, 0, 8, "In"), + KerArg("Out", KerArgSpace(2,T0,D0), OBJ_OUT_DB, 1, Dim, OutBytes, 0, 0, 0, "Out"), KerArg("Infos", KerArgSpace(1,T0), O_IN|O_BUFF|O_NTILED|O_CONST, AT_INF_DIM, 1, 1, 0, 0, 0, "Infos") ) ); @@ -3416,24 +3648,11 @@ int CNN_MatAddPaddedAct_SQ8( char *TopName = NULL, *BotName = NULL, *BodyName = NULL; Ok = Ok && CNN_MatAddAct_SQ8(BodyName = AppendNames(Name, "Body"), Ctrl, FeatBody, Width, Height, AddMatOper, ActOper); - KernelOper_T PadActOper; - switch (ActOper) { - case KOP_NONE: PadActOper = KOP_ACT_NONE_IN_SCALE; break; - case KOP_RELU: PadActOper = KOP_RELU_IN_SCALE; break; - case KOP_RELUN: PadActOper = KOP_RELUN_IN_SCALE; break; - case KOP_RELUM: PadActOper = KOP_RELUM_IN_SCALE; break; - case KOP_RELUMN: PadActOper = KOP_RELUMN_IN_SCALE; break; - case KOP_HSIGMOID: PadActOper = KOP_HSIGMOID_IN_SCALE; break; - case KOP_HSWISH: PadActOper = KOP_HSWISH_IN_SCALE; break; - case KOP_LEAKYRELU: PadActOper = KOP_LEAKYRELU_IN_SCALE; break; - case KOP_SIGMOID: PadActOper = KOP_SIGMOID_IN_SCALE; break; - case KOP_TANH: PadActOper = KOP_TANH_IN_SCALE; break; - } if (PadTop) { - Ok = Ok && CNN_Act_SQ8(TopName = AppendNames(Name, "PadTop"), Ctrl, PadTop, Width, Height, PadActOper); + Ok = Ok && CNN_Act_SQ8(TopName = AppendNames(Name, "PadTop"), Ctrl, PadTop, Width, Height, ActOper); } if (PadBot) { - Ok = Ok && CNN_Act_SQ8(BotName = AppendNames(Name, "PadBot"), Ctrl, PadBot, Width, Height, PadActOper); + Ok = Ok && CNN_Act_SQ8(BotName = AppendNames(Name, "PadBot"), Ctrl, PadBot, Width, Height, ActOper); } CloseKernelGroupNoMerge(); if (Ok==0) return 0; @@ -3518,7 +3737,7 @@ int CNN_MatAddPaddedAct_SQ8( Height: Height of a In1 MatOper: KOP_MATVECTMUL - ActOper: Optional activation function: KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID + ActOper: Optional activation function: KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSWISH, KOP_HSIGMOID, KOP_LEAKYRELU, KOP_SIGMOID, KOP_TANH Signature: Name(In1, In2, Out, Infos) @@ -3728,6 +3947,7 @@ Kernel_T *CNN_MatMulAct_SQ8_Internal( int Bias_DataSize, int Scale_DataSize, + int NBatches, int ColM1, int LineM1, int ColM2, @@ -3755,15 +3975,19 @@ Kernel_T *CNN_MatMulAct_SQ8_Internal( int ColFirst = ((LineM1*ColM1)<(LineM2*ColM2)); char *MatMulKerName=0, *ActKerName=0; int StandAloneAct = (ActOper!=KOP_NONE); - Bias_DataSize = (MatMulOper == KOP_MATMUL_NOBIAS_SCALE_SCALAR || MatMulOper == KOP_MATMUL_NOBIAS_TRANSPOSED)?0:Bias_DataSize; + + /* NoBias Basic Kernels have 32bits bias not used */ + int NoBias = (MatMulOper == KOP_MATMUL_NOBIAS_SCALE_SCALAR) || (MatMulOper == KOP_MATMUL_NOBIAS) || (MatMulOper == KOP_MATMUL_NOBIAS_TRANSPOSED) || (MatMulOper == KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED); + Bias_DataSize = NoBias?4:Bias_DataSize; + int ScaleScalar = (MatMulOper == KOP_MATMUL_SCALE_SCALAR) || (MatMulOper == KOP_MATMUL_SCALE_SCALAR_TRANSPOSED) || (MatMulOper == KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED) || (MatMulOper == KOP_MATMUL_NOBIAS_SCALE_SCALAR); int Transposed = (MatMulOper == KOP_MATMUL_TRANSPOSED) || (MatMulOper == KOP_MATMUL_NOBIAS_TRANSPOSED) || (MatMulOper == KOP_MATMUL_SCALE_SCALAR_TRANSPOSED) || (MatMulOper == KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED); int SAxis = (MatMulOper == KOP_MATMUL)?LineO:ColO; int TA = (MatMulOper == KOP_MATMUL)?T0:T1; int TB = (MatMulOper == KOP_MATMUL)?T1:T0; - if (!(MatMulOper == KOP_MATMUL) && !(MatMulOper == KOP_MATMUL_NOBIAS_SCALE_SCALAR) && !(MatMulOper == KOP_MATMUL_SCALE_SCALAR_TRANSPOSED) && !(MatMulOper == KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED) && !(MatMulOper == KOP_MATMUL_SCALE_SCALAR) && !(MatMulOper == KOP_MATMUL_TRANSPOSED) && !(MatMulOper == KOP_MATMUL_NOBIAS_TRANSPOSED)) - GenTilingError("CNN_MatMulAct_SQ8 Kernel: %s, MatMulOper should be KOP_MATMUL or KOP_MATMUL_NOBIAS_SCALE_SCALAR or KOP_MATMUL_SCALE_SCALAR_TRANSPOSED or KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED or KOP_MATMUL_SCALE_SCALAR or KOP_MATMUL_TRANSPOSED or KOP_MATMUL_NOBIAS_TRANSPOSED", Name); + if (!(MatMulOper == KOP_MATMUL) && !(MatMulOper == KOP_MATMUL_NOBIAS) && !(MatMulOper == KOP_MATMUL_NOBIAS_SCALE_SCALAR) && !(MatMulOper == KOP_MATMUL_SCALE_SCALAR_TRANSPOSED) && !(MatMulOper == KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED) && !(MatMulOper == KOP_MATMUL_SCALE_SCALAR) && !(MatMulOper == KOP_MATMUL_TRANSPOSED) && !(MatMulOper == KOP_MATMUL_NOBIAS_TRANSPOSED)) + GenTilingError("CNN_MatMulAct_SQ8 Kernel: %s, MatMulOper should be KOP_MATMUL or KOP_MATMUL_NOBIAS or KOP_MATMUL_NOBIAS_SCALE_SCALAR or KOP_MATMUL_SCALE_SCALAR_TRANSPOSED or KOP_MATMUL_NOBIAS_SCALE_SCALAR_TRANSPOSED or KOP_MATMUL_SCALE_SCALAR or KOP_MATMUL_TRANSPOSED or KOP_MATMUL_NOBIAS_TRANSPOSED", Name); if (!(ActOper == KOP_NONE || ActOper == KOP_RELU || ActOper == KOP_RELUN || ActOper == KOP_RELUM || ActOper == KOP_RELUMN || ActOper == KOP_HSIGMOID || ActOper == KOP_HSWISH || ActOper == KOP_LEAKYRELU || ActOper == KOP_SIGMOID || ActOper == KOP_TANH)) GenTilingError("CNN_MatMulAct_SQ8 Kernel: %s, ActOper, expecting KOP_NONE, KOP_RELU, KOP_RELUN, KOP_HSIGMOID, KOP_TANH, KOP_HSWISH or KOP_LEAKYRELU", Name); @@ -3786,9 +4010,9 @@ Kernel_T *CNN_MatMulAct_SQ8_Internal( } ColO = ((Width+Scx-1)/Scx) * ((Height+Scy-1)/Scy); - LayerOp += (int64_t) ColM1*ColO*LineM1; - LayerBandwidth += (int64_t) LineM1*(ColM1*ColM2*(1+1)); - LayerBandwidth += (int64_t) LineM1*ColM2*1; + LayerOp += (int64_t) NBatches*ColM1*ColO*LineM1; + LayerBandwidth += (int64_t) NBatches*LineM1*(ColM1*ColM2*(1+1)); + LayerBandwidth += (int64_t) NBatches*LineM1*ColM2*1; LayerBandwidth += (int64_t) LineM1*Bias_DataSize; if (Scy!=1) ConsT0 = Width*Scy; else ConsT0 = 4; @@ -3811,12 +4035,14 @@ Kernel_T *CNN_MatMulAct_SQ8_Internal( } /* First try buffering small objects */ Kernel = UserKernel(Name, + (NBatches>1)? + KernelIterSpace(3, IterFixedSpace(D0, NBatches), IterTiledSpace(T1), IterTiledSpace(T0)): KernelIterSpace(2, IterTiledSpace(T1), IterTiledSpace(T0)), TILE_HOR, CArgs(7, TCArg(CNN_ArgDataType(1,1,1), InvertInputs?"In2":"In1"), TCArg(CNN_ArgDataType(1,1,1), InvertInputs?"In1":"In2"), - Bias_DataSize?TCArg(CNN_ArgDataType(Bias_DataSize,1,1), "Bias"):AT_NO_C_ARG, + !NoBias?TCArg(CNN_ArgDataType(Bias_DataSize,1,1), "Bias"):AT_NO_C_ARG, TCArg(CNN_ArgDataType(1,1,1), "Out"), !ScaleScalar?TCArg(CNN_ArgDataTypeUns(1,1,1),"Scale"):AT_NO_C_ARG, !ScaleScalar?TCArg(CNN_ArgDataType(1,1,1),"ScaleN"):AT_NO_C_ARG, @@ -3827,12 +4053,12 @@ Kernel_T *CNN_MatMulAct_SQ8_Internal( Bindings(19, K_Arg("In1", KER_ARG_TILE), K_Arg("In1", KER_ARG_TILE_W), K_Arg("In1", KER_ARG_TILE_H), K_Arg("In2", KER_ARG_TILE), Transposed?K_Arg("In2", KER_ARG_TILE_H):K_Arg("In2", KER_ARG_TILE_W), - Bias_DataSize?K_Arg("Bias", KER_ARG_TILE):AT_IGNORE_ARG_BINDING, + !NoBias?K_Arg("Bias", KER_ARG_TILE):Imm(0), !ScaleScalar?K_Arg("Scale", KER_ARG_TILE):AT_IGNORE_ARG_BINDING, !ScaleScalar?K_Arg("ScaleN", KER_ARG_TILE):AT_IGNORE_ARG_BINDING, K_Arg("Out", KER_ARG_TILE), K_Arg("Out", KER_ARG_TILE_W), K_Arg(ColFirst?"In1":"In2", KER_ARG_TILE_BASE), !Transposed?K_Arg("KerBuff", KER_ARG_TILE):AT_IGNORE_ARG_BINDING, - Bias_DataSize?K_TileOper("Infos", "char *", '@', AT_INF_BIASN):AT_IGNORE_ARG_BINDING, + !NoBias?K_TileOper("Infos", "char *", '@', AT_INF_BIASN):AT_IGNORE_ARG_BINDING, Imm(ColFirst), NeedScx?Imm(Scx):AT_IGNORE_ARG_BINDING, NeedScy?Imm(Scy):AT_IGNORE_ARG_BINDING, @@ -3858,7 +4084,7 @@ Kernel_T *CNN_MatMulAct_SQ8_Internal( !Transposed?KerArg("KerBuff",KerArgSpace(1, T1), O_BUFF|O_NTILED, Nbuff*ColM1, 1, 1, 0, 0, 0, 0):AT_NO_KER_ARG, KerArg("In1", KerArgSpace(1, T0), O_IN|O_DB|O_CONST, ColM1, LineM1, 1, 0, OBJ_CONSTRAINTS_PAD_REM, 8, "In1"), KerArg("In2", KerArgSpace(1, T1), O_IN|O_DB, ColM2, LineM2, 1, 0, ObjCons|OBJ_CONSTRAINTS_PAD_REM, ConsT0, "In2"), - Bias_DataSize?KerArg("Bias", KerArgSpace(1, TA), O_BUFF|O_IN|O_CONST, 1, SAxis, Bias_DataSize, 0, OBJ_CONSTRAINTS_PAD_REM, 0, "Bias"):AT_NO_KER_ARG, + !NoBias?KerArg("Bias", KerArgSpace(1, TA), O_BUFF|O_IN|O_CONST, 1, SAxis, Bias_DataSize, 0, OBJ_CONSTRAINTS_PAD_REM, 0, "Bias"):AT_NO_KER_ARG, KerArg("Out", KerArgSpace(1, T1), O_OUT|O_DB, ColO, LineO, 1, 0, OBJ_CONSTRAINTS_TILE_VER|OBJ_CONSTRAINTS_PAD_REM, 0, "Out"), !ScaleScalar?KerArg("Scale", KerArgSpace(1, TA), O_BUFF|O_IN|O_CONST, 1, SAxis, 1, 0, 0, 0, "Scale"):AT_NO_KER_ARG, !ScaleScalar?KerArg("ScaleN", KerArgSpace(1, TA), O_BUFF|O_IN|O_CONST, 1, SAxis, 1, 0, 0, 0, "ScaleN"):AT_NO_KER_ARG, @@ -3868,7 +4094,7 @@ Kernel_T *CNN_MatMulAct_SQ8_Internal( !Transposed?KerArg("KerBuff",KerArgSpace(1, T0), O_BUFF|O_NTILED, Nbuff*ColM1, 1, 1, 0, 0, 0, 0):AT_NO_KER_ARG, KerArg("In1", KerArgSpace(1, T1), O_IN|O_DB|O_CONST, ColM1, LineM1, 1, 0, OBJ_CONSTRAINTS_PAD_REM, 8, "In1"), KerArg("In2", KerArgSpace(1, T0), O_IN|O_DB, ColM2, LineM2, 1, 0, ObjCons|OBJ_CONSTRAINTS_PAD_REM, ConsT0, "In2"), - Bias_DataSize?KerArg("Bias", KerArgSpace(1, TB), O_BUFF|O_IN|O_CONST, 1, SAxis, Bias_DataSize, 0, OBJ_CONSTRAINTS_PAD_REM, 0, "Bias"):AT_NO_KER_ARG, + !NoBias?KerArg("Bias", KerArgSpace(1, TB), O_BUFF|O_IN|O_CONST, 1, SAxis, Bias_DataSize, 0, OBJ_CONSTRAINTS_PAD_REM, 0, "Bias"):AT_NO_KER_ARG, KerArg("Out", KerArgSpace(1, T1), O_OUT|O_DB, ColO, LineO, 1, 0, OBJ_CONSTRAINTS_PAD_REM, 0, "Out"), !ScaleScalar?KerArg("Scale", KerArgSpace(1, TB), O_BUFF|O_IN|O_CONST, 1, SAxis, 1, 0, 0, 0, "Scale"):AT_NO_KER_ARG, !ScaleScalar?KerArg("ScaleN", KerArgSpace(1, TB), O_BUFF|O_IN|O_CONST, 1, SAxis, 1, 0, 0, 0, "ScaleN"):AT_NO_KER_ARG, @@ -3881,7 +4107,7 @@ Kernel_T *CNN_MatMulAct_SQ8_Internal( AddKernelArgDim(Name, "In1", 3, LineM1, ColM1, 1); AddKernelArgDim(Name, "In2", 4, LineM2, Height, Width, 1); - if (Bias_DataSize) AddKernelArgDim(Name, "Bias", 2, SAxis, Bias_DataSize); + if (!NoBias) AddKernelArgDim(Name, "Bias", 2, SAxis, Bias_DataSize); AddKernelArgDim(Name, "Out", 3, LineO, ColO, 1); if (!ScaleScalar) AddKernelArgDim(Name, "Scale", 2, SAxis, 1); if (!ScaleScalar) AddKernelArgDim(Name, "ScaleN", 2, SAxis, 1); @@ -4295,6 +4521,10 @@ int CNN_ConvolutionPoolAct_SQ8( KernelOper_T ActOper ) { + if (Fcx==1 && Fcy==1 && Height==1 && Width==1) { + printf("This is a pointwise on 1x1 input --> Mapping to CNN_Linear_NE16\n"); + return CNN_LinearAct_SQ8(Name, Ctrl, Bias_DataSize, Scale_DataSize, InFeat, OutFeat, KOP_LINEAR, ActOper); + } Kernel_T *Ker = 0, *Sol1 = 0, *Sol2 = 0; float K = 0.9; Tile_Orientation_T TileOrientation = TILE_HOR; @@ -4372,7 +4602,11 @@ int CNN_MatAddAct_SQ8(char *Name, CNN_GenControl_T *Ctrl, int Feat, int Width, i } int CNN_MatMulAct_SQ8(char *Name, CNN_GenControl_T *Ctrl, int Bias_DataSize, int Scale_DataSize, int ColM1, int LineM1, int ColM2, int LineM2, int Width, int Height, int Scx, int Scy, KernelOper_T MatMulOper, KernelOper_T ActOper) { - return (CNN_MatMulAct_SQ8_Internal(Name, Ctrl, Bias_DataSize, Scale_DataSize, ColM1, LineM1, ColM2, LineM2, Width, Height, Scx, Scy, MatMulOper, ActOper, 1)!=0); + return (CNN_MatMulAct_SQ8_Internal(Name, Ctrl, Bias_DataSize, Scale_DataSize, 1, ColM1, LineM1, ColM2, LineM2, Width, Height, Scx, Scy, MatMulOper, ActOper, 1)!=0); +} + +int CNN_BatchedMatMulAct_SQ8(char *Name, CNN_GenControl_T *Ctrl, int Bias_DataSize, int Scale_DataSize, int NBatches, int ColM1, int LineM1, int ColM2, int LineM2, int Width, int Height, int Scx, int Scy, KernelOper_T MatMulOper, KernelOper_T ActOper) { + return (CNN_MatMulAct_SQ8_Internal(Name, Ctrl, Bias_DataSize, Scale_DataSize, NBatches, ColM1, LineM1, ColM2, LineM2, Width, Height, Scx, Scy, MatMulOper, ActOper, 1)!=0); } int CNN_MatMulSmallM1Act_SQ8(char *Name, CNN_GenControl_T *Ctrl, int Bias_DataSize, int Scale_DataSize, int ColM1, int LineM1, int ColM2, int LineM2, int Width, int Height, int Scx, int Scy, KernelOper_T MatMulOper, KernelOper_T ActOper) { diff --git a/tools/autotiler_v3/CNN_Generators_SQ8/CNN_Generators_SQ8.h b/tools/autotiler_v3/CNN_Generators_SQ8/CNN_Generators_SQ8.h index ba223b55d..ab919a417 100644 --- a/tools/autotiler_v3/CNN_Generators_SQ8/CNN_Generators_SQ8.h +++ b/tools/autotiler_v3/CNN_Generators_SQ8/CNN_Generators_SQ8.h @@ -698,6 +698,29 @@ int CNN_MatMulAct_SQ8( KernelOper_T ActOper ); +int CNN_BatchedMatMulAct_SQ8( + char *Name, + + CNN_GenControl_T *Ctrl, + + int Bias_DataSize, + int Scale_DataSize, + + int NBatches, + int ColM1, + int LineM1, + int ColM2, + int LineM2, + + int Width, + int Height, + int Scx, + int Scy, + + KernelOper_T MatMulOper, + KernelOper_T ActOper + ); + Kernel_T *CNN_MatMulAct_SQ8_Internal( char *Name, @@ -706,6 +729,7 @@ Kernel_T *CNN_MatMulAct_SQ8_Internal( int Bias_DataSize, int Scale_DataSize, + int NBatches, int ColM1, int LineM1, int ColM2, diff --git a/tools/autotiler_v3/CNN_Generators_SQ8/RNN_Generators_SQ8.c b/tools/autotiler_v3/CNN_Generators_SQ8/RNN_Generators_SQ8.c index ca31fbf57..527c10588 100644 --- a/tools/autotiler_v3/CNN_Generators_SQ8/RNN_Generators_SQ8.c +++ b/tools/autotiler_v3/CNN_Generators_SQ8/RNN_Generators_SQ8.c @@ -132,7 +132,7 @@ int RNN_Sequence(int Nc, int K0, int K1, int *n1, int *n2, int *n3, int *n2_io) return ((N1!=0) + (N2!=0) + (N3!=0)); } -static Kernel_T *RNN_Stack_Seq_SQ8( +static Kernel_T *RNN_Stack_Seq_SQ8_Internal( char *Name, CNN_GenControl_T *Ctrl, char *RNNKerName, @@ -257,6 +257,45 @@ static Kernel_T *RNN_Stack_Seq_SQ8( return Kernel; } +static Kernel_T *RNN_Stack_Seq_SQ8( + char *Name, + CNN_GenControl_T *Ctrl, + char *RNNKerName, + + int BiasDataSize, + int FeatDataSize, + + int AlwaysReset, + int NCells, + int DimState, + int DimIn, + int UseIn, + int ExposeSequence, + int Buffer, + int FirstSeq, + int LastSeq, + int Revert, + int Dynamic + ) +{ + Kernel_T *Ker = 0; + + AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_OFF); + Ker = RNN_Stack_Seq_SQ8_Internal(Name, Ctrl, RNNKerName, BiasDataSize, FeatDataSize, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, Buffer, FirstSeq, LastSeq, Revert, Dynamic); + if (Ker) return Ker; + AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_ON); + + printf("\n\n=============================== Solution not found for %s: Trying PARALLELFEATURES=0 ===============================\n\n", Name); + /* If solution not found try with ParallelFeature = 0 */ + CNN_GenControl_T InternalCtrl; + if (!Ctrl) CNN_InitGenCtrl(&InternalCtrl); + else InternalCtrl = *Ctrl; + CNN_SetGenCtrl(&InternalCtrl, "PARALLELFEATURES", AT_OPT_VAL(0)); + Ker = RNN_Stack_Seq_SQ8_Internal(Name, &InternalCtrl, RNNKerName, BiasDataSize, FeatDataSize, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, Buffer, FirstSeq, LastSeq, Revert, Dynamic); + return Ker; +} + + int RNN_Stack_SQ8( char *Name, CNN_GenControl_T *Ctrl, @@ -485,7 +524,7 @@ int RNN_Stack_SQ8( } -static int LSTM_Stack_Seq_SQ8( +static int LSTM_Stack_Seq_SQ8_Internal( char *Name, CNN_GenControl_T *Ctrl, char *LSTMKerName, @@ -660,6 +699,44 @@ static int LSTM_Stack_Seq_SQ8( return (Kernel!=0); } +static int LSTM_Stack_Seq_SQ8( + char *Name, + CNN_GenControl_T *Ctrl, + char *LSTMKerName, + + int BiasDataSize, + int FeatDataSize, + + int AlwaysReset, + int NCells, + int DimState, + int DimIn, + int UseIn, + int ExposeSequence, + int FirstSeq, + int LastSeq, + int Revert, + int Dynamic + ) +{ + int Ker = 0; + + AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_OFF); + Ker = LSTM_Stack_Seq_SQ8_Internal(Name, Ctrl, LSTMKerName, BiasDataSize, FeatDataSize, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, FirstSeq, LastSeq, Revert, Dynamic); + if (Ker) return 1; + AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_ON); + + printf("\n\n=============================== Solution not found for %s: Trying PARALLELFEATURES=0 ===============================\n\n", Name); + /* If solution not found try with ParallelFeature = 0 */ + CNN_GenControl_T InternalCtrl; + if (!Ctrl) CNN_InitGenCtrl(&InternalCtrl); + else InternalCtrl = *Ctrl; + CNN_SetGenCtrl(&InternalCtrl, "PARALLELFEATURES", AT_OPT_VAL(0)); + Ker = LSTM_Stack_Seq_SQ8_Internal(Name, &InternalCtrl, LSTMKerName, BiasDataSize, FeatDataSize, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, FirstSeq, LastSeq, Revert, Dynamic); + return Ker; +} + + int LSTM_Stack_SQ8( char *Name, CNN_GenControl_T *Ctrl, @@ -904,7 +981,7 @@ int LSTM_Stack_SQ8( } -static int GRU_Stack_Seq_SQ8( +static int GRU_Stack_Seq_SQ8_Internal( char *Name, CNN_GenControl_T *Ctrl, char *GRUKerName, @@ -1064,6 +1141,43 @@ static int GRU_Stack_Seq_SQ8( return (Kernel!=0); } +static int GRU_Stack_Seq_SQ8( + char *Name, + CNN_GenControl_T *Ctrl, + char *GRUKerName, + + int BiasDataSize, + int FeatDataSize, + + int AlwaysReset, + int NCells, + int DimState, + int DimIn, + int UseIn, + int ExposeSequence, + int FirstSeq, + int LastSeq, + int Revert, + int Dynamic + ) +{ + int Ker = 0; + + AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_OFF); + Ker = GRU_Stack_Seq_SQ8_Internal(Name, Ctrl, GRUKerName, BiasDataSize, FeatDataSize, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, FirstSeq, LastSeq, Revert, Dynamic); + if (Ker) return 1; + AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_ON); + + printf("\n\n=============================== Solution not found for %s: Trying PARALLELFEATURES=0 ===============================\n\n", Name); + /* If solution not found try with ParallelFeature = 0 */ + CNN_GenControl_T InternalCtrl; + if (!Ctrl) CNN_InitGenCtrl(&InternalCtrl); + else InternalCtrl = *Ctrl; + CNN_SetGenCtrl(&InternalCtrl, "PARALLELFEATURES", AT_OPT_VAL(0)); + Ker = GRU_Stack_Seq_SQ8_Internal(Name, &InternalCtrl, GRUKerName, BiasDataSize, FeatDataSize, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, FirstSeq, LastSeq, Revert, Dynamic); + return Ker; +} + int GRU_Stack_SQ8( char *Name, CNN_GenControl_T *Ctrl, diff --git a/tools/autotiler_v3/CNN_Generators_fp16/CNN_Generators_fp16.c b/tools/autotiler_v3/CNN_Generators_fp16/CNN_Generators_fp16.c index 659e2e34e..9f912d010 100644 --- a/tools/autotiler_v3/CNN_Generators_fp16/CNN_Generators_fp16.c +++ b/tools/autotiler_v3/CNN_Generators_fp16/CNN_Generators_fp16.c @@ -1279,7 +1279,7 @@ Kernel_T *CNN_ConvolutionPoolAct_fp16_Internal( if (Ok!=0) return Ok; if (Log) printf("Mapping this convolution to im2col scheme failed, reverting to standard implementation\n"); } - if (Fcx==1 && Fcy==1 && Scx==1 && Scy==1 && Dcx==1 && Dcy==1 && Height==1 && Width==1) { + if (Fcx==1 && Fcy==1 && Height==1 && Width==1) { printf("This is a pointwise on 1x1 input --> Mapping to CNN_Linear_NE16\n"); return CNN_LinearAct_fp16_Internal(Name, Ctrl, InFeat, OutFeat, KOP_LINEAR, ActOper); } diff --git a/tools/autotiler_v3/CNN_Generators_fp16/RNN_Generators_fp16.c b/tools/autotiler_v3/CNN_Generators_fp16/RNN_Generators_fp16.c index 5a6ca45dc..435e965e6 100644 --- a/tools/autotiler_v3/CNN_Generators_fp16/RNN_Generators_fp16.c +++ b/tools/autotiler_v3/CNN_Generators_fp16/RNN_Generators_fp16.c @@ -106,7 +106,7 @@ int RNN_Sequence_fp16(int Nc, int K0, int K1, int *n1, int *n2, int *n3, int *n2 return ((N1!=0) + (N2!=0) + (N3!=0)); } -static int RNN_Stack_Seq_fp16( +static int RNN_Stack_Seq_fp16_Internal( char *Name, CNN_GenControl_T *Ctrl, char *RNNKerName, @@ -222,6 +222,40 @@ static int RNN_Stack_Seq_fp16( return (Kernel!=0); } +static int RNN_Stack_Seq_fp16( + char *Name, + CNN_GenControl_T *Ctrl, + char *RNNKerName, + + int AlwaysReset, + int NCells, + int DimState, + int DimIn, + int UseIn, + int ExposeSequence, + int Buffer, + int FirstSeq, + int LastSeq, + int Revert, + int Dynamic) +{ + int Ker = 0; + + AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_OFF); + Ker = RNN_Stack_Seq_fp16_Internal(Name, Ctrl, RNNKerName, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, Buffer, FirstSeq, LastSeq, Revert, Dynamic); + if (Ker) return 1; + AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_ON); + + printf("\n\n=============================== Solution not found for %s: Trying PARALLELFEATURES=0 ===============================\n\n", Name); + /* If solution not found try with ParallelFeature = 0 */ + CNN_GenControl_T InternalCtrl; + if (!Ctrl) CNN_InitGenCtrl(&InternalCtrl); + else InternalCtrl = *Ctrl; + CNN_SetGenCtrl(&InternalCtrl, "PARALLELFEATURES", AT_OPT_VAL(0)); + Ker = RNN_Stack_Seq_fp16_Internal(Name, &InternalCtrl, RNNKerName, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, Buffer, FirstSeq, LastSeq, Revert, Dynamic); + return Ker; +} + int RNN_Stack_fp16( char *Name, CNN_GenControl_T *Ctrl, @@ -400,7 +434,7 @@ int RNN_Stack_fp16( } -static int LSTM_Stack_Seq_fp16( +static int LSTM_Stack_Seq_fp16_Internal( char *Name, CNN_GenControl_T *Ctrl, char *LSTMKerName, @@ -568,6 +602,39 @@ static int LSTM_Stack_Seq_fp16( return (Kernel!=0); } +static int LSTM_Stack_Seq_fp16( + char *Name, + CNN_GenControl_T *Ctrl, + char *LSTMKerName, + + int AlwaysReset, + int NCells, + int DimState, + int DimIn, + int UseIn, + int ExposeSequence, + int FirstSeq, + int LastSeq, + int Revert, + int Dynamic) +{ + int Ker = 0; + + AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_OFF); + Ker = LSTM_Stack_Seq_fp16_Internal(Name, Ctrl, LSTMKerName, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, FirstSeq, LastSeq, Revert, Dynamic); + if (Ker) return 1; + AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_ON); + + printf("\n\n=============================== Solution not found for %s: Trying PARALLELFEATURES=0 ===============================\n\n", Name); + /* If solution not found try with ParallelFeature = 0 */ + CNN_GenControl_T InternalCtrl; + if (!Ctrl) CNN_InitGenCtrl(&InternalCtrl); + else InternalCtrl = *Ctrl; + CNN_SetGenCtrl(&InternalCtrl, "PARALLELFEATURES", AT_OPT_VAL(0)); + Ker = LSTM_Stack_Seq_fp16_Internal(Name, &InternalCtrl, LSTMKerName, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, FirstSeq, LastSeq, Revert, Dynamic); + return Ker; +} + int LSTM_Stack_fp16( char *Name, CNN_GenControl_T *Ctrl, @@ -791,7 +858,7 @@ int LSTM_Stack_fp16( } -static int GRU_Stack_Seq_fp16( +static int GRU_Stack_Seq_fp16_Internal( char *Name, CNN_GenControl_T *Ctrl, char *GRUKerName, @@ -943,6 +1010,40 @@ static int GRU_Stack_Seq_fp16( return (Kernel!=0); } +static int GRU_Stack_Seq_fp16( + char *Name, + CNN_GenControl_T *Ctrl, + char *GRUKerName, + + int AlwaysReset, + int NCells, + int DimState, + int DimIn, + int UseIn, + int ExposeSequence, + int FirstSeq, + int LastSeq, + int Revert, + int Dynamic) +{ + int Ker = 0; + + AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_OFF); + Ker = GRU_Stack_Seq_fp16_Internal(Name, Ctrl, GRUKerName, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, FirstSeq, LastSeq, Revert, Dynamic); + if (Ker) return 1; + AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_ON); + + printf("\n\n=============================== Solution not found for %s: Trying PARALLELFEATURES=0 ===============================\n\n", Name); + /* If solution not found try with ParallelFeature = 0 */ + CNN_GenControl_T InternalCtrl; + if (!Ctrl) CNN_InitGenCtrl(&InternalCtrl); + else InternalCtrl = *Ctrl; + CNN_SetGenCtrl(&InternalCtrl, "PARALLELFEATURES", AT_OPT_VAL(0)); + Ker = GRU_Stack_Seq_fp16_Internal(Name, &InternalCtrl, GRUKerName, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, FirstSeq, LastSeq, Revert, Dynamic); + return Ker; +} + + int GRU_Stack_fp16( char *Name, CNN_GenControl_T *Ctrl, diff --git a/tools/autotiler_v3/CNN_Libraries/SSD_BasicKernels.c b/tools/autotiler_v3/CNN_Libraries/SSD_BasicKernels.c index cdce41f3b..09e5e814f 100644 --- a/tools/autotiler_v3/CNN_Libraries/SSD_BasicKernels.c +++ b/tools/autotiler_v3/CNN_Libraries/SSD_BasicKernels.c @@ -1,7 +1,3 @@ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wextra" -#pragma GCC diagnostic ignored "-Wpointer-sign" -#pragma GCC diagnostic ignored "-Wsign-compare" /* * Copyright (C) 2020 GreenWaves Technologies * All rights reserved. @@ -10,18 +6,14 @@ * of the BSD license. See the LICENSE file for details. * */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-compare" + #include #include "Gap.h" #include "CNN_BasicKernels.h" #include "SSD_BasicKernels.h" -#ifndef __EMUL__ - #define CL_CRITICAL_ENTER() pi_cl_team_critical_enter() - #define CL_CRITICAL_EXIT() pi_cl_team_critical_exit() -#else - #define CL_CRITICAL_ENTER() - #define CL_CRITICAL_EXIT() -#endif // optimize the division to find the chunk size // equivalent to ceil(KerArg0->W/rt_nb_pe()) inline static unsigned int __attribute__((always_inline)) ChunkSize(unsigned int X) @@ -137,14 +129,14 @@ void Ker_SSD_Decoder(Ker_SSD_Decoder_ArgT *KerArg0 ) boxes_idx = i*num_coords; for (unsigned int j=1; j score_th){ - CL_CRITICAL_ENTER(); + gap_cl_critical_enter(); bbn = KerArg0->bbox_idx[0]++; // printf("Core: %d\tbbox_idx:%d\n", CoreId, KerArg0->bbox_idx[0]); if(bbn > n_max_bb){ // check if we reched n_max_bb - CL_CRITICAL_EXIT(); + gap_cl_critical_exit(); goto exit_double_for; } - CL_CRITICAL_EXIT(); + gap_cl_critical_exit(); // Valid BBOX --> alive bbox[bbn].alive = 1; //Save score always as a Q7 diff --git a/tools/autotiler_v3/CNN_Libraries_NE16/CNN_BasicKernels_NE16.c b/tools/autotiler_v3/CNN_Libraries_NE16/CNN_BasicKernels_NE16.c index 1c302417a..e0bd7445e 100644 --- a/tools/autotiler_v3/CNN_Libraries_NE16/CNN_BasicKernels_NE16.c +++ b/tools/autotiler_v3/CNN_Libraries_NE16/CNN_BasicKernels_NE16.c @@ -1275,7 +1275,7 @@ void KerConvDW3x3Stride2_NE16(KerConv_NE16_T *Arg) SetNE16_ScaleNPointer (ScaleN); SetNE16_Strides (Tile_InFeat, Tile_InFeat * Tile_InW, 0, // In_D0, In_D1, In_D2 - unused Out_Stride0, OutBytes * Tile_OutFeat / 2, OutBytes * Tile_OutFeat * Tile_OutW / 2, // Out_D0, Out_D1, Out_D2 div 2 to take into account strideness - 2*3*3, 2*3*3*Arg->Qw*Nb_KI, 0); // Weights_D0, Weights_D1, Weights_D2 + 2*3*3, 0, 0); // Weights_D0, Weights_D1, Weights_D2 SetNE16_Dim (Nb_KI, Nb_KO, Nb_WO, Nb_HO); // Assume first subtile no need for right/bottom pad SetNE16_ConfigPad ((v4s) {PadL, IsLastSubtileW?PadR:0, PadT, IsLastSubtileH?PadB:0}, Arg->Pad_Val); @@ -1343,7 +1343,7 @@ void KerConvDW3x3Stride2_NE16(KerConv_NE16_T *Arg) SetNE16_ScaleNPointer (ScaleN); SetNE16_Strides (Tile_InFeat, Tile_InFeat * Tile_InW, 0, // In_D0, In_D1, In_D2 - unused Out_Stride0, OutBytes * Tile_OutFeat / 2, OutBytes * Tile_OutFeat * Tile_OutW / 2, // Out_D0, Out_D1, Out_D2 div 2 to take into account strideness - 2*3*3, 2*3*3*Arg->Qw*Nb_KI, 0); // Weights_D0, Weights_D1, Weights_D2 + 2*3*3, 0, 0); // Weights_D0, Weights_D1, Weights_D2 SetNE16_Dim (Nb_KI, Nb_KO, Nb_WO, Nb_HO); // Moving to next spatial subtile means consider less padding (2 because of the stride) PadL = Max(0, TilePadL-2*subtile_j_major); diff --git a/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_AT_Misc.c b/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_AT_Misc.c index 187fd3ab3..dd82478c9 100644 --- a/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_AT_Misc.c +++ b/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_AT_Misc.c @@ -25,6 +25,7 @@ #include "CNN_AT_Misc.h" + #ifdef __pulp__ #define Abs(a) __builtin_pulp_abs((a)) #define Min(a, b) __builtin_pulp_minsi((a), (b)) diff --git a/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_Activation_HWC_SQ8.c b/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_Activation_HWC_SQ8.c index 91c6be453..5c5a14412 100644 --- a/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_Activation_HWC_SQ8.c +++ b/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_Activation_HWC_SQ8.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#if 0 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wextra" @@ -908,17 +909,17 @@ void KerParReduct_CC_HSigmoid_HWC_USQ16(KerConvLinReduct_SQ8_T *Arg) unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; int Prenorm = Infos[AT_INF_PRENORM]; - + // Output is asymmetric with zeropoint at 0 for (int i=First; i> 8, ActScale, ActScaleN), 16); + int Acc0 = gap_clip(AT_SCALE(AT_NORM(In[i*Feat + Feat-1], Prenorm), Scale[Feat-1], ScaleN[Feat-1]), 15); + Out[i*Feat + Feat-1] = gap_clipu(AT_SCALE(SigmoidU(Acc0), ActScale, ActScaleN), 16); } } gap_waitbarrier(0); @@ -1049,12 +1050,12 @@ void KerParReduct_CC_Tanh_HWC_USQ16(KerConvLinReduct_SQ8_T *Arg) int Acc0 = gap_clip(AT_SCALE(AT_NORM(In[i*Feat + 2*c+0], Prenorm), Scale[2*c ], ScaleN[2*c ]), 15); int Acc1 = gap_clip(AT_SCALE(AT_NORM(In[i*Feat + 2*c+1], Prenorm), Scale[2*c+1], ScaleN[2*c+1]), 15); - Out[i*Feat + 2*c ] = gap_clip(AT_SCALE(Tanh(Acc0 << 8), ActScale, ActScaleN), 15); - Out[i*Feat + 2*c+1] = gap_clip(AT_SCALE(Tanh(Acc1 << 8), ActScale, ActScaleN), 15); + Out[i*Feat + 2*c ] = (unsigned short) (gap_clip(AT_SCALE(Tanh(Acc0), ActScale, ActScaleN), 15) + 32768); + Out[i*Feat + 2*c+1] = (unsigned short) (gap_clip(AT_SCALE(Tanh(Acc1), ActScale, ActScaleN), 15) + 32768); } if (Feat&0x1) { int Acc0 = gap_clip(AT_SCALE(AT_NORM(In[i*Feat + Feat-1], Prenorm), Scale[Feat-1], ScaleN[Feat-1]), 15); - Out[i*Feat + Feat-1] = gap_clip(AT_SCALE(Tanh(Acc0 << 8) >> 8, ActScale, ActScaleN), 15); + Out[i*Feat + Feat-1] = (unsigned short) (gap_clip(AT_SCALE(Tanh(Acc0), ActScale, ActScaleN), 15) + 32768); } } gap_waitbarrier(0); @@ -1372,8 +1373,6 @@ void KerParPool_PoolNxMStrideSxSyBody__HWC_USQ8( -#define AT_INF_NE16_PADVAL 10 - void KerParPool_MaxPoolNxMStrideSxSy__HWC_USQ8(KerPool_HWC_USQ8_T *Arg) { unsigned int FSx=Arg->FS, Sx=Arg->S; @@ -1399,4 +1398,5 @@ void KerParPool_MaxPoolNxMStrideSxSy__HWC_USQ8(KerPool_HWC_USQ8_T *Arg) gap_waitbarrier(0); } +#endif #pragma GCC diagnostic pop diff --git a/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_Activation_SQ8.c b/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_Activation_SQ8.c index 241bcbbff..233b637bc 100644 --- a/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_Activation_SQ8.c +++ b/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_Activation_SQ8.c @@ -14,6 +14,9 @@ * limitations under the License. */ +#include "Gap.h" +#include "CNN_BasicKernels_SQ8.h" + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wextra" #pragma GCC diagnostic ignored "-Wpointer-sign" @@ -21,9 +24,6 @@ #pragma GCC diagnostic ignored "-Wswitch" #pragma GCC diagnostic ignored "-Wstrict-aliasing" -#include "Gap.h" -#include "CNN_BasicKernels_SQ8.h" - static int CoreCountDynamic = 1; static int ActiveCore = gap_ncore(); @@ -53,9 +53,7 @@ unsigned short int SIGMOID_LUT_uint16[256] = { 65533, 65533, 65533, 65534, 65534, 65534, 65534, 65534, 65534, 65534, 65534, 65534, 65534, 65535}; -static inline unsigned int __attribute__((always_inline)) ChunkSize(unsigned int X) - -{ +static inline unsigned int __attribute__((always_inline)) ChunkSize(unsigned int X) { unsigned int NCore; unsigned int Log2Core; unsigned int Chunk; @@ -67,7 +65,7 @@ static inline unsigned int __attribute__((always_inline)) ChunkSize(unsigned int } #define NEAREST //Use nearest LUT element instead of linearly interpolate -int SigmoidTable(int x, unsigned short int * table){ +static inline int __attribute__((always_inline)) SigmoidTableInt(int x, unsigned short int * table){ /* Input x: Q12 [-8:8] range Output y = sig(x) -> Q15 @@ -96,10 +94,18 @@ int SigmoidTable(int x, unsigned short int * table){ } if (x>0) result = result; else result = (1<<16) - result; - return result >> 1; + return result; #endif } +int SigmoidTable(int x, unsigned short int * table){ + return SigmoidTableInt(x, table) >> 1; +} + +int SigmoidTableUnsigned(int x, unsigned short int * table){ + return SigmoidTableInt(x, table); +} + int TanhTable(int x, unsigned short * table){ #ifndef NEAREST int result, ua, ub, ut; @@ -129,1063 +135,245 @@ int TanhTable(int x, unsigned short * table){ #endif } - -/* - * Standalone activation -*/ -static void Ker_Activation_SQ8( - signed char * __restrict__ In, - signed char * __restrict__ Out, - unsigned int N, - CNN_ActivationOper_T Activation, - unsigned int ActScale, unsigned int ActScaleN, int A0, int B0, int C0 - ) - -{ - for (unsigned int i=0; i Sin/Sq12 = 2**(-4) / 2**(-12) = 2**(8) --> << 8 - // y in Q15 is then shifted to fit int8 Q7 data --> >> 8 and scaled to the output scale with ActScale - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Sigmoid(Acc0N) >> 8), ActScale, ActScaleN); - int Acc1N = Acc1 << 8; - Acc1 = AT_SCALE((Sigmoid(Acc1N) >> 8), ActScale, ActScaleN); - } - break; - case ACT_TANH: - { - // Assumes input (Acc) in Sq[-8:8] = 16 / 256 = 2**(-4) - // y = Sigmoid(x) expects x in Q12 --> Sin/Sq12 = 2**(-4) / 2**(-12) = 2**(8) --> << 8 - // y in Q15 is then shifted to fit int8 Q7 data --> >> 8 and scaled to the output scale with ActScale - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Tanh(Acc0N) >> 8), ActScale, ActScaleN); - int Acc1N = Acc1 << 8; - Acc1 = AT_SCALE((Tanh(Acc1N) >> 8), ActScale, ActScaleN); - } - break; - } - Out[2*i] = gap_clip(Acc0, 7), Out[2*i+1] = gap_clip(Acc1, 7); - } - if (N&0x1) { - unsigned int i=N-1; - int Acc0 = In[i]; - switch (Activation) { - case ACT_NONE: Acc0 = AT_SCALE(Acc0, ActScale, ActScaleN); break; - case ACT_RELU: Acc0 = AT_SCALE(Max(0, Acc0), ActScale, ActScaleN); break; - case ACT_RELUM: Acc0 = AT_SCALE(Max(A0, Acc0), ActScale, ActScaleN); break; - case ACT_RELUMN: Acc0 = AT_SCALE(Min(B0, Max(A0, Acc0)), ActScale, ActScaleN); break; - case ACT_RELUN: Acc0 = AT_SCALE(AT_CLIP_POS(Acc0, A0), ActScale, ActScaleN); break; - case ACT_HSIGMOID: Acc0 = AT_SCALE(AT_CLIP_POS(Acc0 + B0, A0) * C0, ActScale, ActScaleN); break; - case ACT_HSWISH: Acc0 = AT_SCALE(AT_CLIP_POS(Acc0 + B0, A0) * C0 * Acc0, ActScale, ActScaleN); break; - case ACT_LEAKYRELU: - { - int Neg0 = gap_bitextractu(Acc0, 1, 31), Pos0 = !Neg0; - int Acc0N = AT_NORM(Acc0 * A0, 7); - Acc0 = AT_SCALE((Neg0*Acc0N+Pos0*Acc0), ActScale, ActScaleN); - // Acc0 = AT_SCALE(((Acc0<0) ? AT_NORM((Acc0 * A0), 7):Acc0), ActScale, ActScaleN); - } - break; - case ACT_SIGMOID: - { - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Sigmoid(Acc0N) >> 8), ActScale, ActScaleN); - } - break; - case ACT_TANH: - { - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Tanh(Acc0N) >> 8), ActScale, ActScaleN); - } - break; - } - Out[i] = gap_clip(Acc0, 7); - } -} - -/* - * Standalone activation variant with Scale = 1.0 -*/ -static void Ker_ActivationScale1_SQ8( - signed char * __restrict__ In, - signed char * __restrict__ Out, - unsigned int N, - CNN_ActivationOper_T Activation, - int A0, - int B0 - ) - -{ - for (unsigned int i=0; i Sin/Sq12 = 2**(-4) / 2**(-12) = 2**(8) --> << 8 - // y in Q15 is then shifted to fit int8 Q7 data --> >> 8 and scaled to the output scale with ActScale - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Sigmoid(Acc0N) >> 8), ActScale, ActScaleN); - int Acc1N = Acc1 << 8; - Acc1 = AT_SCALE((Sigmoid(Acc1N) >> 8), ActScale, ActScaleN); - } - break; - case ACT_TANH: - { - // Assumes input (Acc) in Sq[-8:8] = 16 / 256 = 2**(-4) - // y = Sigmoid(x) expects x in Q12 --> Sin/Sq12 = 2**(-4) / 2**(-12) = 2**(8) --> << 8 - // y in Q15 is then shifted to fit int8 Q7 data --> >> 8 and scaled to the output scale with ActScale - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Tanh(Acc0N) >> 8), ActScale, ActScaleN); - int Acc1N = Acc1 << 8; - Acc1 = AT_SCALE((Tanh(Acc1N) >> 8), ActScale, ActScaleN); - } - break; - } - Out[2*i] = gap_clip(Acc0, 7), Out[2*i+1] = gap_clip(Acc1, 7); - } - if (N&0x1) { - unsigned int i=N-1; - int Acc0 = gap_clip(AT_SCALE(In[i], Scale, ScaleN), 7); - switch (Activation) { - case ACT_NONE: Acc0 = AT_SCALE(Acc0, ActScale, ActScaleN); break; - case ACT_RELU: Acc0 = AT_SCALE(Max(0, Acc0), ActScale, ActScaleN); break; - case ACT_RELUN: Acc0 = AT_SCALE(AT_CLIP_POS(Acc0, A0), ActScale, ActScaleN); break; - case ACT_RELUM: Acc0 = AT_SCALE(Max(A0, Acc0), ActScale, ActScaleN); break; - case ACT_RELUMN: Acc0 = AT_SCALE(Min(B0, Max(A0, Acc0)), ActScale, ActScaleN); break; - case ACT_HSIGMOID: Acc0 = AT_SCALE(AT_CLIP_POS(Acc0 + B0, A0) * C0, ActScale, ActScaleN); break; - case ACT_HSWISH: Acc0 = AT_SCALE(AT_CLIP_POS(Acc0 + B0, A0) * C0 * Acc0, ActScale, ActScaleN); break; - case ACT_LEAKYRELU: - { - int Neg0 = gap_bitextractu(Acc0, 1, 31), Pos0 = !Neg0; - int Acc0N = AT_NORM(Acc0 * A0, 7); - Acc0 = AT_SCALE((Neg0*Acc0N+Pos0*Acc0), ActScale, ActScaleN); - // Acc0 = AT_SCALE(((Acc0<0) ? AT_NORM((Acc0 * A0), 7):Acc0), ActScale, ActScaleN); - } - break; - case ACT_SIGMOID: - { - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Sigmoid(Acc0N) >> 8), ActScale, ActScaleN); - } - break; - case ACT_TANH: - { - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Tanh(Acc0N) >> 8), ActScale, ActScaleN); - } - break; - } - Out[i] = gap_clip(Acc0, 7); - } -} - -/* - * Standalone activation variant with Scale = 1.0 -*/ -static void Ker_ActivationScale1_ScaleIn_SQ8( - signed char * __restrict__ In, - signed char * __restrict__ Out, - unsigned int Scale, - unsigned int ScaleN, - unsigned int N, - CNN_ActivationOper_T Activation, - int A0, - int B0 - ) - -{ - for (unsigned int i=0; i> 8), ActScale, ActScaleN); - } - break; - case ACT_TANH: - { - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Tanh(Acc0N) >> 8), ActScale, ActScaleN); - } - break; - } - Out[i] = gap_clip(Acc0, 7); - } -} - -/* - * Conv/Linear DP scaling followed by an optional activation, Out buffer is different from In Buffer -*/ -/*static void KerReduct_Activation_SQ8( - int * __restrict__ In, - signed char * __restrict__ Out, - unsigned int N, - unsigned int Scale, - unsigned int ScaleN, - CNN_ActivationOper_T Activation, - unsigned int ActScale, unsigned int ActScaleN, int A0, int B0, int C0 - ) - -{ - for (unsigned int i=0; i> 8), ActScale, ActScaleN); - } - break; - case ACT_TANH: - { - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Tanh(Acc0N) >> 8), ActScale, ActScaleN); - } - break; - } - Out[i*Feat] = gap_clip(Acc0, 7); - } -} - -/* - * Conv/Linear DP scaling followed by an optional activation, variant for ScaleAct=1.0, Out buffer is different from In Buffer -*/ -static void KerReduct_ActivationScale1_SQ8( - int * __restrict__ In, - signed char * __restrict__ Out, - unsigned int N, - unsigned int Scale, - unsigned int ScaleN, - CNN_ActivationOper_T Activation, - int A0, int B0, int C0 - ) - -{ - for (unsigned int i=0; i Sin/Sq12 = 2**(-4) / 2**(-12) = 2**(8) --> << 8 - // y in Q15 is then shifted to fit int8 Q7 data --> >> 8 and scaled to the output scale with ActScale - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Sigmoid(Acc0N) >> 8), ActScale, ActScaleN); - } - break; - case ACT_TANH: - { - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Tanh(Acc0N) >> 8), ActScale, ActScaleN); - } - break; - } - Out[i] = gap_clip(Acc0, 7); - } -} - -/* - * Conv/Linear DP scaling followed by an optional activation, variant for ActScale=1.0, In place version - * Input is 32b int output is 8b -*/ -static void KerReductIO_ActivationScale1_SQ8( - signed char *__restrict__ Out, - int *__restrict__ In, - unsigned int N, - unsigned int Scale, - unsigned int ScaleN, - CNN_ActivationOper_T Activation, - int A0, int B0, int C0 - ) - -{ - for (unsigned int i=0; i Sin/Sq12 = 2**(-4) / 2**(-12) = 2**(8) --> << 8 - // y in Q15 is then shifted to fit int8 Q7 data --> >> 8 and scaled to the output scale with ActScale - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Sigmoid(Acc0N) >> 8), ActScale, ActScaleN); - int Acc1N = Acc1 << 8; - Acc1 = AT_SCALE((Sigmoid(Acc1N) >> 8), ActScale, ActScaleN); - } - break; - case ACT_TANH: - { - // Assumes input (Acc) in Sq[-8:8] = 16 / 256 = 2**(-4) - // y = Sigmoid(x) expects x in Q12 --> Sin/Sq12 = 2**(-4) / 2**(-12) = 2**(8) --> << 8 - // y in Q15 is then shifted to fit int8 Q7 data --> >> 8 and scaled to the output scale with ActScale - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Tanh(Acc0N) >> 8), ActScale, ActScaleN); - int Acc1N = Acc1 << 8; - Acc1 = AT_SCALE((Tanh(Acc1N) >> 8), ActScale, ActScaleN); - } - break; - } - Out[2*i] = gap_clip(Acc0, 7); Out[2*i+1] = gap_clip(Acc1, 7); - } - if (N&0x1) { - int Acc0 = gap_clip(AT_SCALE(In[N-1], Scale, ScaleN), 7); - switch (Activation) { - case ACT_NONE: - break; - case ACT_RELU: - Acc0 = AT_SCALE(Max(0, Acc0), ActScale, ActScaleN); - break; - case ACT_RELUN: - Acc0 = AT_SCALE(AT_CLIP_POS(Acc0, A0), ActScale, ActScaleN); - break; - case ACT_RELUM: - Acc0 = AT_SCALE(Max(A0, Acc0), ActScale, ActScaleN); - break; - case ACT_RELUMN: - Acc0 = AT_SCALE(Min(B0, Max(A0, Acc0)), ActScale, ActScaleN); - break; - case ACT_HSIGMOID: - Acc0 = AT_SCALE(AT_CLIP_POS(Acc0 + B0, A0) * C0, ActScale, ActScaleN); - break; - case ACT_HSWISH: - Acc0 = AT_SCALE(AT_CLIP_POS(Acc0 + B0, A0) * C0 * Acc0, ActScale, ActScaleN); - break; - case ACT_LEAKYRELU: - { - int Neg0 = gap_bitextractu(Acc0, 1, 31), Pos0 = !Neg0; - int Acc0N = AT_NORM(Acc0 * A0, 7); - Acc0 = AT_SCALE((Neg0*Acc0N+Pos0*Acc0), ActScale, ActScaleN); - - // Acc0 = AT_SCALE(((Acc0<0) ? AT_NORM(Acc0 * A0, 7):Acc0), ActScale, ActScaleN); - } - break; - case ACT_SIGMOID: - { - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Sigmoid(Acc0N) >> 8), ActScale, ActScaleN); - } - break; - case ACT_TANH: - { - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Tanh(Acc0N) >> 8), ActScale, ActScaleN); - } - break; - } - Out[N-1] = gap_clip(Acc0, 7); - } -} - -/* - * Conv/Linear DP scaling followed by an optional activation, variant for ActScale=1.0, Out buffer is different from In Buffer - * Partial unroll to avoid load use penalty -*/ -static void _KerReduct_ActivationScale1_SQ8( - int * __restrict__ In, - signed char * __restrict__ Out, - unsigned int N, - unsigned int Scale, - unsigned int ScaleN, - CNN_ActivationOper_T Activation, - int A0, int B0, int C0 - ) - -{ - for (unsigned int i=0; i<(N/2); i++) { - int Acc0 = gap_clip(AT_SCALE(In[2*i+0], Scale, ScaleN), 7); - int Acc1 = gap_clip(AT_SCALE(In[2*i+1], Scale, ScaleN), 7); - - switch (Activation) { - case ACT_NONE: - break; - case ACT_RELU: - Acc0 = Max(0, Acc0); - Acc1 = Max(0, Acc1); - break; - case ACT_RELUN: - Acc0 = AT_CLIP_POS(Acc0, A0); - Acc1 = AT_CLIP_POS(Acc1, A0); - break; - case ACT_RELUM: - Acc0 = Max(A0, Acc0); - Acc1 = Max(A0, Acc1); - break; - case ACT_RELUMN: - Acc0 = Min(B0, Max(A0, Acc0)); - Acc1 = Min(B0, Max(A0, Acc1)); - break; - } - Out[2*i] = Acc0; Out[2*i+1] = Acc1; - } - if (N&0x1) { - int Acc0 = gap_clip(AT_SCALE(In[N-1], Scale, ScaleN), 7); - switch (Activation) { - case ACT_NONE: - break; - case ACT_RELU: - Acc0 = Max(0, Acc0); - break; - case ACT_RELUN: - Acc0 = AT_CLIP_POS(Acc0, A0); - break; - case ACT_RELUM: - Acc0 = Max(A0, Acc0); - break; - case ACT_RELUMN: - Acc0 = Min(B0, Max(A0, Acc0)); - break; - } - Out[N-1] = Acc0; - } -} - -/* - * Conv/Linear DP scaling followed by an optional activation, In place version - * Input is 32b int output is 8b - * Partially unrolled version to avoid load use penalty -*/ -static void _KerReductIO_Activation_SQ8( - signed char * __restrict__ Out, - int *__restrict__ In, - unsigned int N, - unsigned int Scale, - unsigned int ScaleN, - CNN_ActivationOper_T Activation, - unsigned int ActScale, unsigned int ActScaleN, int A0, int B0, int C0 - ) - -{ - for (unsigned int i=0; i<(N/2); i++) { - int Acc0 = gap_clip(AT_SCALE(In[2*i+0], Scale, ScaleN), 7); - int Acc1 = gap_clip(AT_SCALE(In[2*i+1], Scale, ScaleN), 7); - switch (Activation) { - case ACT_NONE: - break; - case ACT_RELU: - Acc0 = AT_SCALE(Max(0, Acc0), ActScale, ActScaleN); - Acc1 = AT_SCALE(Max(0, Acc1), ActScale, ActScaleN); - break; - case ACT_RELUN: - Acc0 = AT_SCALE(AT_CLIP_POS(Acc0, A0), ActScale, ActScaleN); - Acc1 = AT_SCALE(AT_CLIP_POS(Acc1, A0), ActScale, ActScaleN); - break; - case ACT_RELUM: - Acc0 = AT_SCALE(Max(A0, Acc0), ActScale, ActScaleN); - Acc1 = AT_SCALE(Max(A0, Acc1), ActScale, ActScaleN); - break; - case ACT_RELUMN: - Acc0 = AT_SCALE(Min(B0, Max(A0, Acc0)), ActScale, ActScaleN); - Acc1 = AT_SCALE(Min(B0, Max(A0, Acc1)), ActScale, ActScaleN); - break; - case ACT_HSIGMOID: - Acc0 = AT_SCALE(AT_CLIP_POS(Acc0 + B0, A0) * C0, ActScale, ActScaleN); - Acc1 = AT_SCALE(AT_CLIP_POS(Acc1 + B0, A0) * C0, ActScale, ActScaleN); - break; - case ACT_HSWISH: - Acc0 = AT_SCALE(AT_CLIP_POS(Acc0 + B0, A0) * C0 * Acc0, ActScale, ActScaleN); - Acc1 = AT_SCALE(AT_CLIP_POS(Acc1 + B0, A0) * C0 * Acc1, ActScale, ActScaleN); - break; - case ACT_LEAKYRELU: - { - int Neg0 = gap_bitextractu(Acc0, 1, 31), Pos0 = !Neg0; - int Neg1 = gap_bitextractu(Acc1, 1, 31), Pos1 = !Neg1; - int Acc0N = AT_NORM(Acc0 * A0, 7); - int Acc1N = AT_NORM(Acc1 * A0, 7); - Acc0 = AT_SCALE((Neg0*Acc0N+Pos0*Acc0), ActScale, ActScaleN); - Acc1 = AT_SCALE((Neg1*Acc1N+Pos1*Acc1), ActScale, ActScaleN); - - // Acc0 = AT_SCALE(((Acc0<0) ? AT_NORM(Acc0 * A0, 7):Acc0), ActScale, ActScaleN); - // Acc1 = AT_SCALE(((Acc1<0) ? AT_NORM(Acc1 * A0, 7):Acc1), ActScale, ActScaleN); - } - break; - case ACT_SIGMOID: - { - // Assumes input (Acc) in Sq[-8:8] = 16 / 256 = 2**(-4) - // y = Sigmoid(x) expects x in Q12 --> Sin/Sq12 = 2**(-4) / 2**(-12) = 2**(8) --> << 8 - // y in Q15 is then shifted to fit int8 Q7 data --> >> 8 and scaled to the output scale with ActScale - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Sigmoid(Acc0N) >> 8), ActScale, ActScaleN); - int Acc1N = Acc1 << 8; - Acc1 = AT_SCALE((Sigmoid(Acc1N) >> 8), ActScale, ActScaleN); - } - break; - case ACT_TANH: - { - // Assumes input (Acc) in Sq[-8:8] = 16 / 256 = 2**(-4) - // y = Sigmoid(x) expects x in Q12 --> Sin/Sq12 = 2**(-4) / 2**(-12) = 2**(8) --> << 8 - // y in Q15 is then shifted to fit int8 Q7 data --> >> 8 and scaled to the output scale with ActScale - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Tanh(Acc0N) >> 8), ActScale, ActScaleN); - int Acc1N = Acc1 << 8; - Acc1 = AT_SCALE((Tanh(Acc1N) >> 8), ActScale, ActScaleN); - } - break; - } - Out[2*i] = gap_clip(Acc0, 7); Out[2*i+1] = gap_clip(Acc1, 7); - } - if (N&0x1) { - int Acc0 = gap_clip(AT_SCALE(In[N-1], Scale, ScaleN), 7); - switch (Activation) { - case ACT_NONE: - break; - case ACT_RELU: - Acc0 = AT_SCALE(Max(0, Acc0), ActScale, ActScaleN); - break; - case ACT_RELUN: - Acc0 = AT_SCALE(AT_CLIP_POS(Acc0, A0), ActScale, ActScaleN); - break; - case ACT_RELUM: - Acc0 = AT_SCALE(Max(A0, Acc0), ActScale, ActScaleN); - break; - case ACT_RELUMN: - Acc0 = AT_SCALE(Min(B0, Max(A0, Acc0)), ActScale, ActScaleN); - break; - case ACT_HSIGMOID: - Acc0 = AT_SCALE(AT_CLIP_POS(Acc0 + B0, A0) * C0, ActScale, ActScaleN); - break; - case ACT_HSWISH: - Acc0 = AT_SCALE(AT_CLIP_POS(Acc0 + B0, A0) * C0 * Acc0, ActScale, ActScaleN); - break; - case ACT_LEAKYRELU: - { - int Neg0 = gap_bitextractu(Acc0, 1, 31), Pos0 = !Neg0; - int Acc0N = AT_NORM(Acc0 * A0, 7); - Acc0 = AT_SCALE((Neg0*Acc0N+Pos0*Acc0), ActScale, ActScaleN); - - // Acc0 = AT_SCALE(((Acc0<0) ? AT_NORM(Acc0 * A0, 7):Acc0), ActScale, ActScaleN); - } - break; - case ACT_SIGMOID: - { - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Sigmoid(Acc0N) >> 8), ActScale, ActScaleN); - } - break; - case ACT_TANH: - { - int Acc0N = Acc0 << 8; - Acc0 = AT_SCALE((Tanh(Acc0N) >> 8), ActScale, ActScaleN); - } - break; - } - Out[N-1] = gap_clip(Acc0, 7); - } -} - -/* - * Conv/Linear DP scaling followed by an optional activation, Variant for ActScale=1.0, In place version - * Input is 32b int output is 8b - * Partially unrolled version to avoid load use penalty -*/ -static void _KerReductIO_ActivationScale1_SQ8( - signed char *__restrict__ Out, - int *__restrict__ In, - unsigned int N, - unsigned int Scale, - unsigned int ScaleN, - CNN_ActivationOper_T Activation, - int A0, int B0, int C0 - ) - -{ - for (unsigned int i=0; i<(N/2); i++) { - int Acc0 = gap_clip(AT_SCALE(In[2*i+0], Scale, ScaleN), 7); - int Acc1 = gap_clip(AT_SCALE(In[2*i+1], Scale, ScaleN), 7); - switch (Activation) { - case ACT_NONE: - break; - case ACT_RELU: - Acc0 = Max(0, Acc0); - Acc1 = Max(0, Acc1); - break; - case ACT_RELUN: - Acc0 = AT_CLIP_POS(Acc0, A0); - Acc1 = AT_CLIP_POS(Acc1, A0); - break; - case ACT_RELUM: - Acc0 = Max(A0, Acc0); - Acc1 = Max(A0, Acc1); - break; - case ACT_RELUMN: - Acc0 = Min(B0, Max(A0, Acc0)); - Acc1 = Min(B0, Max(A0, Acc1)); - break; - } - Out[2*i] = Acc0; Out[2*i+1] = Acc1; - } - if (N&0x1) { - int Acc0 = gap_clip(AT_SCALE(In[N-1], Scale, ScaleN), 7); - switch (Activation) { - case ACT_NONE: - break; - case ACT_RELU: - Acc0 = Max(0, Acc0); - break; - case ACT_RELUN: - Acc0 = AT_CLIP_POS(Acc0, A0); - break; - case ACT_RELUM: - Acc0 = Max(A0, Acc0); - break; - case ACT_RELUMN: - Acc0 = Min(B0, Max(A0, Acc0)); - break; - } - Out[N-1] = Acc0; - } -} - -/* - * Buffer compaction, scattered by chunk size groups of 8b moved to a contiguous representation through a parallel reduction tree -*/ -static void __attribute__ ((noinline)) KerReductIO_Compact_SQ8(int *__restrict__ In, unsigned int Size, unsigned int CoreId, unsigned int ChunkCell) - -{ - unsigned int U = gap_ncore()/2, Log2Core = gap_fl1(gap_ncore()), A = 2, B = 1; - for (int k=0; kW*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); \ + decl(in_d_type * __restrict__, In) = decl((in_d_type *__restrict__), Arg->In); \ + decl(out_d_type * __restrict__, Out) = decl((out_d_type *__restrict__), Arg->Out); \ + signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; \ + unsigned int Size = Max(0, Last-First); \ + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; \ + int A0 = arr_at_as(Infos, AT_INF_A0, p_type); int B0 = arr_at_as(Infos, AT_INF_B0, p_type); int C0 = arr_at_as(Infos, AT_INF_C0, p_type); \ +\ + for (unsigned int i=First; iW*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); \ + int * __restrict__ InOut = (int *__restrict__) Arg->In; \ + signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; \ + unsigned int Size = Max(0, Last-First); \ + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; \ + int A0 = arr_at_as(Infos, AT_INF_A0, p_type); int B0 = arr_at_as(Infos, AT_INF_B0, p_type); int C0 = arr_at_as(Infos, AT_INF_C0, p_type); \ +\ + for (unsigned int i=0; iFeat; \ + unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); \ + int * __restrict__ In = (int *__restrict__) Arg->In; \ + unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; \ + unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; \ + decl(d_type * __restrict__, Out) = decl((d_type *__restrict__), Arg->Out); \ + signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; \ + unsigned int Size = Arg->W*Arg->H; \ + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; \ + int A0 = arr_at_as(Infos, AT_INF_A0, p_type); int B0 = arr_at_as(Infos, AT_INF_B0, p_type); int C0 = arr_at_as(Infos, AT_INF_C0, p_type); \ + int Prenorm = arr_at_as(Infos, AT_INF_PRENORM, p_type); \ +\ + for (unsigned int c=First; cFeat; \ + unsigned S = Arg->W*Arg->H; \ + unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); \ + int * __restrict__ In = (int *__restrict__) Arg->In; \ + unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; \ + unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; \ + decl(d_type * __restrict__, Out) = decl((d_type *__restrict__), Arg->Out); \ + signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; \ + unsigned int Size = Max(0, Last-First); \ + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; \ + int A0 = arr_at_as(Infos, AT_INF_A0, p_type); int B0 = arr_at_as(Infos, AT_INF_B0, p_type); int C0 = arr_at_as(Infos, AT_INF_C0, p_type); \ + int Prenorm = arr_at_as(Infos, AT_INF_PRENORM, p_type); \ +\ + for (unsigned int c=0; cFeat; \ + unsigned int Size = Arg->W*Arg->H; \ + unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); \ + int * __restrict__ In = (int *__restrict__) Arg->In; \ + unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; \ + unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; \ + signed char *__restrict__ Out = (signed char *__restrict__)(In+First*Size); \ + signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; \ + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; \ + int A0 = arr_at_as(Infos, AT_INF_A0, p_type); int B0 = arr_at_as(Infos, AT_INF_B0, p_type); int C0 = arr_at_as(Infos, AT_INF_C0, p_type); \ + int Prenorm = arr_at_as(Infos, AT_INF_PRENORM, p_type); \ +\ + for (unsigned int c=First; cFeat); \ +} while(0); + +#define KER_REDUCT_IO_ACT_CHW(Activation, d_type, p_type, in_n_bits, out_n_bits, is_unsigned) \ +do { \ + unsigned int Feat = Arg->Feat; \ + unsigned int S = Arg->W*Arg->H; \ + unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); \ + int * __restrict__ InOut = (int *__restrict__) Arg->In; \ + unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; \ + unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; \ + signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; \ + unsigned int Size = Max(0, Last-First); \ + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; \ + int A0 = arr_at_as(Infos, AT_INF_A0, p_type); int B0 = arr_at_as(Infos, AT_INF_B0, p_type); int C0 = arr_at_as(Infos, AT_INF_C0, p_type); \ + int Prenorm = arr_at_as(Infos, AT_INF_PRENORM, p_type); \ + \ + for (unsigned int c=0; cFeat; \ + unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat); \ + int * __restrict__ In = (int *__restrict__) Arg->In; \ + unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; \ + unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; \ + decl(d_type * __restrict__, Out) = decl((d_type *__restrict__), Arg->Out); \ + signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; \ + unsigned int Size = Arg->W*Arg->H; \ + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; \ + int A0 = arr_at_as(Infos, AT_INF_A0, p_type); int B0 = arr_at_as(Infos, AT_INF_B0, p_type); int C0 = arr_at_as(Infos, AT_INF_C0, p_type); \ + int Prenorm = arr_at_as(Infos, AT_INF_PRENORM, p_type); \ +\ + for (unsigned int c=First; cFeat; \ + unsigned S = Arg->W*Arg->H; \ + unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); \ + int * __restrict__ In = (int *__restrict__) Arg->In; \ + unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; \ + unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; \ + decl(d_type * __restrict__, Out) = decl((d_type *__restrict__), Arg->Out); \ + signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; \ + unsigned int Size = Max(0, Last-First); \ + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; \ + int A0 = arr_at_as(Infos, AT_INF_A0, p_type); int B0 = arr_at_as(Infos, AT_INF_B0, p_type); int C0 = arr_at_as(Infos, AT_INF_C0, p_type); \ + int Prenorm = arr_at_as(Infos, AT_INF_PRENORM, p_type); \ +\ + for (unsigned int c=0; cFeat; \ + unsigned S = Arg->W*Arg->H; \ + unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); \ + int * __restrict__ In = (int *__restrict__) Arg->In; \ + unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; \ + unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; \ + decl(d_type * __restrict__, Out) = decl((d_type *__restrict__), Arg->Out); \ + signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; \ + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; \ + int A0 = arr_at_as(Infos, AT_INF_A0, p_type); int B0 = arr_at_as(Infos, AT_INF_B0, p_type); int C0 = arr_at_as(Infos, AT_INF_C0, p_type); \ + int Prenorm = arr_at_as(Infos, AT_INF_PRENORM, p_type); \ +\ + for (unsigned int i=First; iFeat; \ + unsigned S = Arg->W*Arg->H; \ + unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); \ + int * __restrict__ In = (int *__restrict__) Arg->In; \ + unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; \ + unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; \ + decl(d_type * __restrict__, Out) = decl((d_type *__restrict__), Arg->Out); \ + signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; \ + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; \ + int A0 = arr_at_as(Infos, AT_INF_A0, p_type); int B0 = arr_at_as(Infos, AT_INF_B0, p_type); int C0 = arr_at_as(Infos, AT_INF_C0, p_type); \ + int Prenorm = arr_at_as(Infos, AT_INF_PRENORM, p_type); \ +\ + for (unsigned int i=First; iFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Arg->W*Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Arg->W*Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Arg->W*Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Arg->W*Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Arg->W*Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Arg->W*Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Arg->W*Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Arg->W*Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Arg->W*Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Arg->W*Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int W = Arg->W, H = Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int W = Arg->W, H = Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int W = Arg->W, H = Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int W = Arg->W, H = Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int W = Arg->W, H = Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int W = Arg->W, H = Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int W = Arg->W, H = Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int W = Arg->W, H = Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int W = Arg->W, H = Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int W = Arg->W, H = Arg->H; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=First; cFeat; - unsigned int Size = Arg->W*Arg->H; - unsigned int W = Arg->W, H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char *__restrict__ Out = (signed char *__restrict__)(In+First*Size); - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - S = Size*Max(0, Last-First); - for (int c=First; cFeat); -} - -void KerParReductIO_CC_ReLU_SQ8(KerConvLinReduct_SQ8_T *Arg) - -{ - unsigned int S = Arg->Feat; - unsigned int Size = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char *__restrict__ Out = (signed char *__restrict__)(In+First*Size); - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - S = Size*Max(0, Last-First); - for (int c=First; cFeat); -} - -void KerParReductIO_CC_ReLUN_SQ8(KerConvLinReduct_SQ8_T *Arg) - -{ - unsigned int S = Arg->Feat; - unsigned int Size = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char *__restrict__ Out = (signed char *__restrict__)(In+First*Size); - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - S = Size*Max(0, Last-First); - for (int c=First; cFeat); -} - -void KerParReductIO_CC_ReLUM_SQ8(KerConvLinReduct_SQ8_T *Arg) - -{ - unsigned int S = Arg->Feat; - unsigned int Size = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char *__restrict__ Out = (signed char *__restrict__)(In+First*Size); - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - S = Size*Max(0, Last-First); - for (int c=First; cFeat); -} - -void KerParReductIO_CC_ReLUMN_SQ8(KerConvLinReduct_SQ8_T *Arg) - -{ - unsigned int S = Arg->Feat; - unsigned int Size = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char *__restrict__ Out = (signed char *__restrict__)(In+First*Size); - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - S = Size*Max(0, Last-First); - for (int c=First; cFeat); -} - -void KerParReductIO_CC_HSigmoid_SQ8(KerConvLinReduct_SQ8_T *Arg) - -{ - unsigned int S = Arg->Feat; - unsigned int Size = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char *__restrict__ Out = (signed char *__restrict__)(In+First*Size); - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - S = Size*Max(0, Last-First); - for (int c=First; cFeat); -} - -void KerParReductIO_CC_HSwish_SQ8(KerConvLinReduct_SQ8_T *Arg) - -{ - unsigned int S = Arg->Feat; - unsigned int Size = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char *__restrict__ Out = (signed char *__restrict__)(In+First*Size); - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - S = Size*Max(0, Last-First); - for (int c=First; cFeat); -} - -void KerParReductIO_CC_LeakyReLU_SQ8(KerConvLinReduct_SQ8_T *Arg) - -{ - unsigned int S = Arg->Feat; - unsigned int Size = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char *__restrict__ Out = (signed char *__restrict__)(In+First*Size); - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - S = Size*Max(0, Last-First); - for (int c=First; cFeat); -} - -void KerParReductIO_CC_Sigmoid_SQ8(KerConvLinReduct_SQ8_T *Arg) - -{ - unsigned int S = Arg->Feat; - unsigned int Size = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char *__restrict__ Out = (signed char *__restrict__)(In+First*Size); - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - S = Size*Max(0, Last-First); - for (int c=First; cFeat); -} - -void KerParReductIO_CC_Tanh_SQ8(KerConvLinReduct_SQ8_T *Arg) - -{ - unsigned int S = Arg->Feat; - unsigned int Size = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char *__restrict__ Out = (signed char *__restrict__)(In+First*Size); - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - S = Size*Max(0, Last-First); - for (int c=First; cFeat); -} - -/* Input Scaling and reduction to 8b then channel centric activation, Out location != In location. Features are evaluated one after the other in parallel */ -void KerReduct_CC_SQ8(KerConvLinReduct_SQ8_T *Arg) - -{ - unsigned int Feat = Arg->Feat; - unsigned S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned int S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ InOut = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned int S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ InOut = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerParReduct_CC_CHW2HWC_HSigmoid_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_ACT_CHW2HWC(ACT_HSIGMOID, signed char, unsigned char, 32, 8, 0); +} - for (int c=0; cFeat; - unsigned int S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ InOut = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned int S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ InOut = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned int S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ InOut = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned int S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ InOut = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned int S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ InOut = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned int S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ InOut = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned int S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ InOut = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cFeat; - unsigned int S = Arg->W*Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - int * __restrict__ InOut = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int c=0; cW*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; +void KerParReduct_CC_CHW2HWC_Tanh_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_ACT_CHW2HWC(ACT_TANH, signed char, unsigned char, 32, 8, 0); +} +/* + * Input Scaling and reduction to 8b then channel centric activation, Out location = In location. Features are evaluated in parallel +*/ +void KerParReductIO_CC_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_IO_ACT_CHW(ACT_NONE, signed char, unsigned char, 32, 8, 0); +} - Ker_Activation_SQ8(In+First, Out+First, Size, ACT_NONE, ActScale, ActScaleN, 0, 0, 0); - gap_waitbarrier(0); +void KerParReductIO_CC_ReLU_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_IO_ACT_CHW(ACT_RELU, signed char, unsigned char, 32, 8, 0); } -void Ker_Scale_SQ8(KerActivation_SQ8_T *Arg) +void KerParReductIO_CC_ReLUN_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_IO_ACT_CHW(ACT_RELUN, signed char, unsigned char, 32, 8, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; +void KerParReductIO_CC_ReLUM_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_IO_ACT_CHW(ACT_RELUM, signed char, unsigned char, 32, 8, 0); +} +void KerParReductIO_CC_ReLUMN_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_IO_ACT_CHW(ACT_RELUMN, signed char, unsigned char, 32, 8, 0); +} - Ker_Activation_SQ8(In+First, Out+First, Size, ACT_NONE, ActScale, ActScaleN, 0, 0, 0); - gap_waitbarrier(0); +void KerParReductIO_CC_HSigmoid_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_IO_ACT_CHW(ACT_HSIGMOID, signed char, unsigned char, 32, 8, 0); } -void Ker_ReLU_SQ8(KerActivation_SQ8_T *Arg) +void KerParReductIO_CC_HSwish_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_IO_ACT_CHW(ACT_HSWISH, signed char, unsigned char, 32, 8, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerParReductIO_CC_LeakyReLU_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_IO_ACT_CHW(ACT_LEAKYRELU, signed char, unsigned char, 32, 8, 0); +} +void KerParReductIO_CC_Sigmoid_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_IO_ACT_CHW(ACT_SIGMOID, signed char, unsigned char, 32, 8, 0); +} - if (ActScale) Ker_Activation_SQ8(In+First, Out+First, Size, ACT_RELU, ActScale, ActScaleN, A0, B0, C0); - else Ker_ActivationScale1_SQ8(In+First, Out+First, Size, ACT_RELU, A0, B0); - gap_waitbarrier(0); +void KerParReductIO_CC_Tanh_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_IO_ACT_CHW(ACT_TANH, signed char, unsigned char, 32, 8, 0); } -void Ker_ReLUN_SQ8(KerActivation_SQ8_T *Arg) -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +/* + * Input Scaling and reduction to 8b then channel centric activation, Out location != In location. Features are evaluated one after the other in parallel +*/ +void KerReduct_CC_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_ACT_CHW(ACT_NONE, signed char, unsigned char, 32, 8, 0); +} +void KerReduct_CC_ReLU_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_ACT_CHW(ACT_RELU, signed char, unsigned char, 32, 8, 0); +} - if (ActScale) Ker_Activation_SQ8(In+First, Out+First, Size, ACT_RELUN, ActScale, ActScaleN, A0, B0, C0); - else Ker_ActivationScale1_SQ8(In+First, Out+First, Size, ACT_RELUN, A0, B0); - gap_waitbarrier(0); +void KerReduct_CC_ReLUN_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_ACT_CHW(ACT_RELUN, signed char, unsigned char, 32, 8, 0); } -void Ker_ReLUM_SQ8(KerActivation_SQ8_T *Arg) +void KerReduct_CC_ReLUM_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_ACT_CHW(ACT_RELUM, signed char, unsigned char, 32, 8, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReduct_CC_ReLUMN_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_ACT_CHW(ACT_RELUMN, signed char, unsigned char, 32, 8, 0); +} +void KerReduct_CC_HSigmoid_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_ACT_CHW(ACT_HSIGMOID, signed char, unsigned char, 32, 8, 0); +} - if (ActScale) Ker_Activation_SQ8(In+First, Out+First, Size, ACT_RELUM, ActScale, ActScaleN, A0, B0, C0); - else Ker_ActivationScale1_SQ8(In+First, Out+First, Size, ACT_RELUM, A0, B0); - gap_waitbarrier(0); +void KerReduct_CC_HSwish_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_ACT_CHW(ACT_HSWISH, signed char, unsigned char, 32, 8, 0); } -void Ker_ReLUMN_SQ8(KerActivation_SQ8_T *Arg) +void KerReduct_CC_LeakyReLU_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_ACT_CHW(ACT_LEAKYRELU, signed char, unsigned char, 32, 8, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReduct_CC_Sigmoid_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_ACT_CHW(ACT_SIGMOID, signed char, unsigned char, 32, 8, 0); +} +void KerReduct_CC_Tanh_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_ACT_CHW(ACT_TANH, signed char, unsigned char, 32, 8, 0); +} - if (ActScale) Ker_Activation_SQ8(In+First, Out+First, Size, ACT_RELUMN, ActScale, ActScaleN, A0, B0, C0); - else Ker_ActivationScale1_SQ8(In+First, Out+First, Size, ACT_RELUMN, A0, B0); - gap_waitbarrier(0); +/* + * Input Scaling and reduction to 8b then channel centric activation, Out location = In location. Features are evaluated one after the other in parallel +*/ +void KerReductIO_CC_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_IO_ACT_CHW(ACT_NONE, signed char, unsigned char, 32, 8, 0); } -void Ker_HSigmoid_SQ8(KerActivation_SQ8_T *Arg) +void KerReductIO_CC_ReLU_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_IO_ACT_CHW(ACT_RELU, signed char, unsigned char, 32, 8, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReductIO_CC_ReLUN_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_IO_ACT_CHW(ACT_RELUN, signed char, unsigned char, 32, 8, 0); +} +void KerReductIO_CC_ReLUM_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_IO_ACT_CHW(ACT_RELUM, signed char, unsigned char, 32, 8, 0); +} - Ker_Activation_SQ8(In+First, Out+First, Size, ACT_HSIGMOID, ActScale, ActScaleN, A0, B0, C0); - gap_waitbarrier(0); +void KerReductIO_CC_ReLUMN_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_IO_ACT_CHW(ACT_RELUMN, signed char, unsigned char, 32, 8, 0); } -void Ker_HSwish_SQ8(KerActivation_SQ8_T *Arg) +void KerReductIO_CC_HSigmoid_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_IO_ACT_CHW(ACT_HSIGMOID, signed char, unsigned char, 32, 8, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReductIO_CC_HSwish_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_IO_ACT_CHW(ACT_HSWISH, signed char, unsigned char, 32, 8, 0); +} +void KerReductIO_CC_LeakyReLU_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_IO_ACT_CHW(ACT_LEAKYRELU, signed char, unsigned char, 32, 8, 0); +} - Ker_Activation_SQ8(In+First, Out+First, Size, ACT_HSWISH, ActScale, ActScaleN, A0, B0, C0); - gap_waitbarrier(0); +void KerReductIO_CC_Sigmoid_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_IO_ACT_CHW(ACT_SIGMOID, signed char, unsigned char, 32, 8, 0); } -void Ker_LeakyReLU_SQ8(KerActivation_SQ8_T *Arg) +void KerReductIO_CC_Tanh_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_REDUCT_IO_ACT_CHW(ACT_TANH, signed char, unsigned char, 32, 8, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +/* + * Standalone Scaled Activation, No reduction with Scale[c] ScaleN[c] - All the elements can be evaluated in parallel +*/ +void Ker_ActNone_SQ8(KerActivation_SQ8_T *Arg) { + KER_ACT(ACT_NONE, signed char, signed char, unsigned char, 8, 8, 0); +} - Ker_Activation_SQ8(In+First, Out+First, Size, ACT_LEAKYRELU, ActScale, ActScaleN, A0, B0, C0); - gap_waitbarrier(0); +void Ker_ReLU_SQ8(KerActivation_SQ8_T *Arg) { + KER_ACT(ACT_RELU, signed char, signed char, unsigned char, 8, 8, 0); } -void Ker_Sigmoid_SQ8(KerActivation_SQ8_T *Arg) +void Ker_ReLUN_SQ8(KerActivation_SQ8_T *Arg) { + KER_ACT(ACT_RELUN, signed char, signed char, unsigned char, 8, 8, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void Ker_ReLUM_SQ8(KerActivation_SQ8_T *Arg) { + KER_ACT(ACT_RELUM, signed char, signed char, unsigned char, 8, 8, 0); +} +void Ker_ReLUMN_SQ8(KerActivation_SQ8_T *Arg) { + KER_ACT(ACT_RELUMN, signed char, signed char, unsigned char, 8, 8, 0); +} - Ker_Activation_SQ8(In+First, Out+First, Size, ACT_SIGMOID, ActScale, ActScaleN, A0, B0, C0); - gap_waitbarrier(0); +void Ker_HSigmoid_SQ8(KerActivation_SQ8_T *Arg) { + KER_ACT(ACT_HSIGMOID, signed char, signed char, unsigned char, 8, 8, 0); } -void Ker_Tanh_SQ8(KerActivation_SQ8_T *Arg) +void Ker_HSwish_SQ8(KerActivation_SQ8_T *Arg) { + KER_ACT(ACT_HSWISH, signed char, signed char, unsigned char, 8, 8, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void Ker_LeakyReLU_SQ8(KerActivation_SQ8_T *Arg) { + KER_ACT(ACT_LEAKYRELU, signed char, signed char, unsigned char, 8, 8, 0); +} +void Ker_Sigmoid_SQ8(KerActivation_SQ8_T *Arg) { + KER_ACT(ACT_SIGMOID, signed char, signed char, unsigned char, 8, 8, 0); +} - Ker_Activation_SQ8(In+First, Out+First, Size, ACT_TANH, ActScale, ActScaleN, A0, B0, C0); - gap_waitbarrier(0); +void Ker_Tanh_SQ8(KerActivation_SQ8_T *Arg) { + KER_ACT(ACT_TANH, signed char, signed char, unsigned char, 8, 8, 0); } -/* - * Standalone Scaled Activation with Extra Scale before activation, Features are evaluated one after the other in parallel +/* + * from int32 to 8/16bits + optional Activation - Reduction with Scale[c] ScaleN[c] - All the elements can be evaluated in parallel */ -void Ker_ActNone_ScaleIn_SQ8(KerActivation_SQ8_T *Arg) - -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - unsigned int In1Scale = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALE], In1ScaleN = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - +/* ------------------------------------------------------ Signed 8 bits ------------------------------------------------------ */ +void KerReduct_CC_NoScale_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_NONE, int, signed char, unsigned char, 32, 8, 0); +} - if (ActScale) Ker_Activation_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_NONE, ActScale, ActScaleN, A0, B0, C0); - else Ker_ActivationScale1_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_NONE, A0, B0); - gap_waitbarrier(0); +void KerReduct_CC_NoScale_ReLU_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_RELU, int, signed char, unsigned char, 32, 8, 0); } -void Ker_ReLU_ScaleIn_SQ8(KerActivation_SQ8_T *Arg) +void KerReduct_CC_NoScale_ReLUN_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_RELUN, int, signed char, unsigned char, 32, 8, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - unsigned int In1Scale = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALE], In1ScaleN = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReduct_CC_NoScale_ReLUM_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_RELUM, int, signed char, unsigned char, 32, 8, 0); +} +void KerReduct_CC_NoScale_ReLUMN_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_RELUMN, int, signed char, unsigned char, 32, 8, 0); +} - if (ActScale) Ker_Activation_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_RELU, ActScale, ActScaleN, A0, B0, C0); - else Ker_ActivationScale1_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_RELU, A0, B0); - gap_waitbarrier(0); +void KerReduct_CC_NoScale_HSigmoid_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_HSIGMOID, int, signed char, unsigned char, 32, 8, 0); } -void Ker_ReLUN_ScaleIn_SQ8(KerActivation_SQ8_T *Arg) +void KerReduct_CC_NoScale_HSwish_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_HSWISH, int, signed char, unsigned char, 32, 8, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - unsigned int In1Scale = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALE], In1ScaleN = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReduct_CC_NoScale_LeakyReLU_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_LEAKYRELU, int, signed char, unsigned char, 32, 8, 0); +} +void KerReduct_CC_NoScale_Sigmoid_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_SIGMOID, int, signed char, unsigned char, 32, 8, 0); +} - if (ActScale) Ker_Activation_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_RELUN, ActScale, ActScaleN, A0, B0, C0); - else Ker_ActivationScale1_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_RELUN, A0, B0); - gap_waitbarrier(0); +void KerReduct_CC_NoScale_Tanh_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_TANH, int, signed char, unsigned char, 32, 8, 0); } -void Ker_ReLUM_ScaleIn_SQ8(KerActivation_SQ8_T *Arg) +void KerReductIO_CC_NoScale_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_NONE, int, signed char, unsigned char, 32, 8, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - unsigned int In1Scale = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALE], In1ScaleN = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReductIO_CC_NoScale_ReLU_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_RELU, int, signed char, unsigned char, 32, 8, 0); +} +void KerReductIO_CC_NoScale_ReLUN_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_RELUN, int, signed char, unsigned char, 32, 8, 0); +} - if (ActScale) Ker_Activation_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_RELUM, ActScale, ActScaleN, A0, B0, C0); - else Ker_ActivationScale1_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_RELUM, A0, B0); - gap_waitbarrier(0); +void KerReductIO_CC_NoScale_ReLUM_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_RELUM, int, signed char, unsigned char, 32, 8, 0); } -void Ker_ReLUMN_ScaleIn_SQ8(KerActivation_SQ8_T *Arg) +void KerReductIO_CC_NoScale_ReLUMN_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_RELUMN, int, signed char, unsigned char, 32, 8, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - unsigned int In1Scale = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALE], In1ScaleN = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReductIO_CC_NoScale_HSigmoid_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_HSIGMOID, int, signed char, unsigned char, 32, 8, 0); +} +void KerReductIO_CC_NoScale_HSwish_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_HSWISH, int, signed char, unsigned char, 32, 8, 0); +} - if (ActScale) Ker_Activation_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_RELUMN, ActScale, ActScaleN, A0, B0, C0); - else Ker_ActivationScale1_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_RELUMN, A0, B0); - gap_waitbarrier(0); +void KerReductIO_CC_NoScale_LeakyReLU_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_LEAKYRELU, int, signed char, unsigned char, 32, 8, 0); } -void Ker_HSigmoid_ScaleIn_SQ8(KerActivation_SQ8_T *Arg) +void KerReductIO_CC_NoScale_Sigmoid_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_SIGMOID, int, signed char, unsigned char, 32, 8, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - unsigned int In1Scale = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALE], In1ScaleN = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReductIO_CC_NoScale_Tanh_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_TANH, int, signed char, unsigned char, 32, 8, 0); +} - Ker_Activation_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_HSIGMOID, ActScale, ActScaleN, A0, B0, C0); - gap_waitbarrier(0); +/* ------------------------------------------------------ Signed 16 bits ------------------------------------------------------ */ +void KerReduct_CC_NoScale_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_NONE, int, signed short, unsigned short, 32, 16, 0); } -void Ker_HSwish_ScaleIn_SQ8(KerActivation_SQ8_T *Arg) - -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - unsigned int In1Scale = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALE], In1ScaleN = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReduct_CC_NoScale_ReLU_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_RELU, int, signed short, unsigned short, 32, 16, 0); +} +void KerReduct_CC_NoScale_ReLUN_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_RELUN, int, signed short, unsigned short, 32, 16, 0); +} - Ker_Activation_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_HSWISH, ActScale, ActScaleN, A0, B0, C0); - gap_waitbarrier(0); +void KerReduct_CC_NoScale_ReLUM_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_RELUM, int, signed short, unsigned short, 32, 16, 0); } -void Ker_LeakyReLU_ScaleIn_SQ8(KerActivation_SQ8_T *Arg) +void KerReduct_CC_NoScale_ReLUMN_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_RELUMN, int, signed short, unsigned short, 32, 16, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - unsigned int In1Scale = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALE], In1ScaleN = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReduct_CC_NoScale_HSigmoid_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_HSIGMOID, int, signed short, unsigned short, 32, 16, 0); +} +void KerReduct_CC_NoScale_HSwish_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_HSWISH, int, signed short, unsigned short, 32, 16, 0); +} - Ker_Activation_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_LEAKYRELU, ActScale, ActScaleN, A0, B0, C0); - gap_waitbarrier(0); +void KerReduct_CC_NoScale_LeakyReLU_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_LEAKYRELU, int, signed short, unsigned short, 32, 16, 0); } -void Ker_Sigmoid_ScaleIn_SQ8(KerActivation_SQ8_T *Arg) +void KerReduct_CC_NoScale_Sigmoid_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_SIGMOID, int, signed short, unsigned short, 32, 16, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - unsigned int In1Scale = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALE], In1ScaleN = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReduct_CC_NoScale_Tanh_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_TANH, int, signed short, unsigned short, 32, 16, 0); +} +void KerReductIO_CC_NoScale_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_NONE, int, signed short, unsigned short, 32, 16, 0); +} - Ker_Activation_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_SIGMOID, ActScale, ActScaleN, A0, B0, C0); - gap_waitbarrier(0); +void KerReductIO_CC_NoScale_ReLU_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_RELU, int, signed short, unsigned short, 32, 16, 0); } -void Ker_Tanh_ScaleIn_SQ8(KerActivation_SQ8_T *Arg) +void KerReductIO_CC_NoScale_ReLUN_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_RELUN, int, signed short, unsigned short, 32, 16, 0); +} -{ - unsigned int S = Arg->W*Arg->H*Arg->Feat, CoreId = gap_coreid(), ChunkCell = ChunkSize(S), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, S); - signed char * __restrict__ In = (signed char *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int Size = Max(0, Last-First); - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - unsigned int In1Scale = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALE], In1ScaleN = ((unsigned char *)Arg->Infos)[AT_INF_IN1SCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReductIO_CC_NoScale_ReLUM_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_RELUM, int, signed short, unsigned short, 32, 16, 0); +} +void KerReductIO_CC_NoScale_ReLUMN_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_RELUMN, int, signed short, unsigned short, 32, 16, 0); +} - Ker_Activation_ScaleIn_SQ8(In+First, Out+First, In1Scale, In1ScaleN, Size, ACT_TANH, ActScale, ActScaleN, A0, B0, C0); - gap_waitbarrier(0); +void KerReductIO_CC_NoScale_HSigmoid_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_HSIGMOID, int, signed short, unsigned short, 32, 16, 0); } +void KerReductIO_CC_NoScale_HSwish_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_HSWISH, int, signed short, unsigned short, 32, 16, 0); +} -/* - * Input Scaling and reduction to 8b then channel cnetric activation, Out location != In location. Features are evaluated in parallel -*/ -void KerReduct_CC_NoScale_SQ8(KerConvLinReduct_SQ8_T *Arg) - -{ - int Feat = Arg->Feat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReductIO_CC_NoScale_Tanh_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_TANH, int, signed short, unsigned short, 32, 16, 0); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReduct_CC_NoScale_ReLUN_USQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_RELUN, int, unsigned char, unsigned char, 32, 8, 1); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReduct_CC_NoScale_HSwish_USQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_HSWISH, int, unsigned char, unsigned char, 32, 8, 1); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReductIO_CC_NoScale_USQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_NONE, int, unsigned char, unsigned char, 32, 8, 1); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReductIO_CC_NoScale_ReLUMN_USQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_RELUMN, int, unsigned char, unsigned char, 32, 8, 1); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReductIO_CC_NoScale_LeakyReLU_USQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_LEAKYRELU, int, unsigned char, unsigned char, 32, 8, 1); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +/* ---------------------------------------------------- UnSigned 16 bits ----------------------------------------------------- */ +void KerReduct_CC_NoScale_USQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_NONE, int, unsigned short, unsigned short, 32, 16, 1); +} - for (int i=First; i> 8), ActScale, ActScaleN), 7); - } - gap_waitbarrier(0); +void KerReduct_CC_NoScale_ReLU_USQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_RELU, int, unsigned short, unsigned short, 32, 16, 1); } -void KerReduct_CC_NoScale_Tanh_SQ8(KerConvLinReduct_SQ8_T *Arg) +void KerReduct_CC_NoScale_ReLUN_USQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_RELUN, int, unsigned short, unsigned short, 32, 16, 1); +} -{ - int Feat = Arg->Feat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed char * __restrict__ Out = (signed char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReduct_CC_NoScale_ReLUM_USQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_RELUM, int, unsigned short, unsigned short, 32, 16, 1); +} - for (int i=First; i> 8), ActScale, ActScaleN), 7); - } - gap_waitbarrier(0); +void KerReduct_CC_NoScale_ReLUMN_USQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_RELUMN, int, unsigned short, unsigned short, 32, 16, 1); } +void KerReduct_CC_NoScale_HSigmoid_USQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_HSIGMOID, int, unsigned short, unsigned short, 32, 16, 1); +} -/* - * Input Scaling and reduction to 8b then channel cnetric activation, Out location != In location. Features are evaluated in parallel -*/ -void KerReduct_CC_NoScale_SQ16(KerConvLinReduct_SQ8_T *Arg) - -{ - int Feat = Arg->Feat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed short * __restrict__ Out = (signed short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed short * __restrict__ Out = (signed short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReduct_CC_NoScale_Sigmoid_USQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT(ACT_SIGMOID, int, unsigned short, unsigned short, 32, 16, 1); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed short * __restrict__ Out = (signed short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReductIO_CC_NoScale_ReLU_USQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_RELU, int, unsigned short, unsigned short, 32, 16, 1); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed short * __restrict__ Out = (signed short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReductIO_CC_NoScale_HSigmoid_USQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_HSIGMOID, int, unsigned short, unsigned short, 32, 16, 1); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - signed short * __restrict__ Out = (signed short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerReductIO_CC_NoScale_Tanh_USQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_ACT_IO(ACT_TANH, int, unsigned short, unsigned short, 32, 16, 1); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed short * __restrict__ Out = (signed short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerParReduct_CC_ReLU_HWC_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_ACT_HWC(ACT_RELU, signed char, unsigned char, 32, 8, 0); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed short * __restrict__ Out = (signed short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerParReduct_CC_ReLUMN_HWC_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_ACT_HWC(ACT_RELUMN, signed char, unsigned char, 32, 8, 0); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed short * __restrict__ Out = (signed short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed short * __restrict__ Out = (signed short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerParReduct_CC_LeakyReLU_HWC_SQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_ACT_HWC(ACT_LEAKYRELU, signed char, unsigned char, 32, 8, 0); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - signed short * __restrict__ Out = (signed short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +/* ----------------------------------------------------- UnSigned 8 bits ----------------------------------------------------- */ +void KerParReduct_CC_HWC_USQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_ACT_HWC(ACT_NONE, unsigned char, unsigned char, 32, 8, 1); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Out = (unsigned char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Out = (unsigned char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerParReduct_CC_LeakyReLU_HWC_USQ8(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_ACT_HWC(ACT_LEAKYRELU, unsigned char, unsigned char, 32, 8, 1); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Scale = (unsigned char *__restrict__) Arg->Scale; - unsigned char * __restrict__ ScaleN = (unsigned char *__restrict__) Arg->ScaleN; - unsigned char * __restrict__ Out = (unsigned char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Out = (unsigned char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +/* ----------------------------------------------------- Signed 16 bits ---------------------------------------------------- */ +void KerParReduct_CC_HWC_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_ACT_HWC(ACT_NONE, signed short, unsigned short, 32, 16, 0); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned char * __restrict__ Out = (unsigned char *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerParReduct_CC_ReLUMN_HWC_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_ACT_HWC(ACT_RELUMN, signed short, unsigned short, 32, 16, 0); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned short * __restrict__ Out = (unsigned short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerParReduct_CC_Sigmoid_HWC_SQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_ACT_HWC(ACT_SIGMOID, signed short, unsigned short, 32, 16, 0); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned short * __restrict__ Out = (unsigned short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +/* ----------------------------------------------------- UnSigned 16 bits ---------------------------------------------------- */ +void KerParReduct_CC_HWC_USQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_ACT_HWC(ACT_NONE, unsigned short, unsigned short, 32, 16, 1); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned short * __restrict__ Out = (unsigned short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerParReduct_CC_ReLUM_HWC_USQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_ACT_HWC(ACT_RELUM, unsigned short, unsigned short, 32, 16, 1); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned short * __restrict__ Out = (unsigned short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; +void KerParReduct_CC_HSwish_HWC_USQ16(KerConvLinReduct_SQ8_T *Arg) { + KER_PAR_REDUCT_ACT_HWC(ACT_HSWISH, unsigned short, unsigned short, 32, 16, 1); +} - for (int i=First; iFeat; - int W = Arg->W; - int H = Arg->H; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H*W*Feat), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Feat*H*W); - int * __restrict__ In = (int *__restrict__) Arg->In; - unsigned short * __restrict__ Out = (unsigned short *__restrict__) Arg->Out; - signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; - unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; - int A0 = Infos[AT_INF_A0], B0 = Infos[AT_INF_B0], C0 = Infos[AT_INF_C0]; - for (int i=First; iIn; @@ -330,6 +334,9 @@ void KerParLinearLayerFullFeatB8_SQ8(KerLinear_SQ8_T *Arg) unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(OutDim), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, OutDim); v4s * __restrict__ VectIn = (v4s *) In; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); for (int i=First; iIn; - unsigned int InDim = Arg->InDim, OutDim = Arg->OutDim; - const signed char * __restrict__ Weights = Arg->Weights; - const signed char * __restrict__ Bias = Arg->Bias; - unsigned int NormBias = ((unsigned char *)Arg->Infos)[AT_INF_BIASN]; - unsigned char *Scale = Arg->Scale; - unsigned char *ScaleN = Arg->ScaleN; - signed char * __restrict__ Out = (signed char * __restrict__) Arg->Out; +void KerParLinearLayerFullFeatB8_ReLU_SQ8(KerLinear_SQ8_T *Arg) { + KerParLinearLayerFullFeatB8_SQ8_act(Arg, ACT_RELU); +} - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(OutDim), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, OutDim); - v4s * __restrict__ VectIn = (v4s *) In; +void KerParLinearLayerFullFeatB8_ReLUN_SQ8(KerLinear_SQ8_T *Arg) { + KerParLinearLayerFullFeatB8_SQ8_act(Arg, ACT_RELUN); +} - for (int i=First; iIn; - unsigned int InDim = Arg->InDim, OutDim = Arg->OutDim; - const signed char * __restrict__ Weights = Arg->Weights; - const signed char * __restrict__ Bias = Arg->Bias; - unsigned int NormBias = ((unsigned char *)Arg->Infos)[AT_INF_BIASN]; - unsigned char *Scale = Arg->Scale; - unsigned char *ScaleN = Arg->ScaleN; - int A0 = Arg->Infos[AT_INF_A0]; - signed char * __restrict__ Out = (signed char * __restrict__) Arg->Out; +void KerParLinearLayerFullFeatB8_LeakyReLU_SQ8(KerLinear_SQ8_T *Arg) { + KerParLinearLayerFullFeatB8_SQ8_act(Arg, ACT_LEAKYRELU); +} - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(OutDim), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, OutDim); - v4s * __restrict__ VectIn = (v4s *) In; +void KerParLinearLayerFullFeatB8_HSigmoid_SQ8(KerLinear_SQ8_T *Arg) { + KerParLinearLayerFullFeatB8_SQ8_act(Arg, ACT_HSIGMOID); +} - for (int i=First; iIn; unsigned int InDim = Arg->InDim, OutDim = Arg->OutDim; @@ -423,6 +413,9 @@ void KerParLinearLayerFullFeatB16_SQ8(KerLinear_SQ8_T *Arg) unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(OutDim), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, OutDim); v4s * __restrict__ VectIn = (v4s *) In; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); for (int i=First; iIn; - unsigned int InDim = Arg->InDim, OutDim = Arg->OutDim; - const signed char * __restrict__ Weights = Arg->Weights; - const short int * __restrict__ Bias = Arg->Bias; - unsigned int NormBias = ((unsigned char *)Arg->Infos)[AT_INF_BIASN]; - unsigned char *Scale = Arg->Scale; - unsigned char *ScaleN = Arg->ScaleN; - signed char * __restrict__ Out = (signed char * __restrict__) Arg->Out; +void KerParLinearLayerFullFeatB16_ReLU_SQ8(KerLinear_SQ8_T *Arg) { + KerParLinearLayerFullFeatB16_SQ8_act(Arg, ACT_RELU); +} - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(OutDim), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, OutDim); - v4s * __restrict__ VectIn = (v4s *) In; +void KerParLinearLayerFullFeatB16_ReLUN_SQ8(KerLinear_SQ8_T *Arg) { + KerParLinearLayerFullFeatB16_SQ8_act(Arg, ACT_RELUN); +} - for (int i=First; iIn; - unsigned int InDim = Arg->InDim, OutDim = Arg->OutDim; - const signed char * __restrict__ Weights = Arg->Weights; - const short int * __restrict__ Bias = Arg->Bias; - unsigned int NormBias = ((unsigned char *)Arg->Infos)[AT_INF_BIASN]; - unsigned char *Scale = Arg->Scale; - unsigned char *ScaleN = Arg->ScaleN; - int A0 = Arg->Infos[AT_INF_A0]; - signed char * __restrict__ Out = (signed char * __restrict__) Arg->Out; +void KerParLinearLayerFullFeatB16_LeakyReLU_SQ8(KerLinear_SQ8_T *Arg) { + KerParLinearLayerFullFeatB16_SQ8_act(Arg, ACT_LEAKYRELU); +} - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(OutDim), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, OutDim); - v4s * __restrict__ VectIn = (v4s *) In; +void KerParLinearLayerFullFeatB16_HSigmoid_SQ8(KerLinear_SQ8_T *Arg) { + KerParLinearLayerFullFeatB16_SQ8_act(Arg, ACT_HSIGMOID); +} - for (int i=First; iIn; unsigned int InDim = Arg->InDim, OutDim = Arg->OutDim; @@ -513,6 +488,9 @@ void KerParLinearLayerFullFeatB32_SQ8(KerLinear_SQ8_T *Arg) unsigned char *Scale = Arg->Scale; unsigned char *ScaleN = Arg->ScaleN; signed char * __restrict__ Out = (signed char * __restrict__) Arg->Out; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(OutDim), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, OutDim); v4s * __restrict__ VectIn = (v4s *) In; @@ -527,70 +505,102 @@ void KerParLinearLayerFullFeatB32_SQ8(KerLinear_SQ8_T *Arg) } if (InDim&0x4) Acc = gap_sumdotp4(VectIn[InDim/4-1], W[InDim/4-1], Acc); for (int j=4*(InDim/4); jIn; - unsigned int InDim = Arg->InDim, OutDim = Arg->OutDim; - const signed char * __restrict__ Weights = Arg->Weights; - const int * __restrict__ Bias = Arg->Bias; - unsigned int NormBias = ((unsigned char *)Arg->Infos)[AT_INF_BIASN]; - unsigned char *Scale = Arg->Scale; - unsigned char *ScaleN = Arg->ScaleN; - signed char * __restrict__ Out = (signed char * __restrict__) Arg->Out; - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(OutDim), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, OutDim); +/* unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(OutDim), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, OutDim); + int Iter = Last-First; v4s * __restrict__ VectIn = (v4s *) In; - for (int i=First; iIn; - unsigned int InDim = Arg->InDim, OutDim = Arg->OutDim; - const signed char * __restrict__ Weights = Arg->Weights; - const int * __restrict__ Bias = Arg->Bias; - unsigned int NormBias = ((unsigned char *)Arg->Infos)[AT_INF_BIASN]; - unsigned char *Scale = Arg->Scale; - unsigned char *ScaleN = Arg->ScaleN; - int A0 = Arg->Infos[AT_INF_A0]; - signed char * __restrict__ Out = (signed char * __restrict__) Arg->Out; +void KerParLinearLayerFullFeatB32_ReLUN_SQ8(KerLinear_SQ8_T *Arg) { + KerParLinearLayerFullFeatB32_SQ8_act(Arg, ACT_RELUN); +} - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(OutDim), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, OutDim); - v4s * __restrict__ VectIn = (v4s *) In; +void KerParLinearLayerFullFeatB32_ReLUM_SQ8(KerLinear_SQ8_T *Arg) { + KerParLinearLayerFullFeatB32_SQ8_act(Arg, ACT_RELUM); +} - for (int i=First; iTotalInFeatures, InFeatures = Arg->InFeatures, OutFeatures = Arg->OutFeatures; - for (unsigned int of=0; of +#include "CNN_BasicKernels_SQ8.h" + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wextra" #pragma GCC diagnostic ignored "-Wpointer-sign" #pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" -#include -#include "CNN_BasicKernels_SQ8.h" static int CoreCountDynamic = 1; static int ActiveCore = gap_ncore(); @@ -638,7 +639,9 @@ void KerMatAdd_ReLUMN_USQ8(KerMat3_SQ8_T *Arg) *************************************************************************************************************************************************/ /* Byte Bias */ -void KerParMatMulB8_SQ8(KerMatMul_SQ8_T *Arg) +static inline void __attribute__((always_inline)) KerParMatMulB8_SQ8_act( + KerMatMul_SQ8_T *Arg, + CNN_ActivationOper_T Activation) { /* @@ -658,6 +661,9 @@ void KerParMatMulB8_SQ8(KerMatMul_SQ8_T *Arg) unsigned int OutFirstCol = Arg->OutFirstCol; signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; int ColFirst = Arg->ColFirst; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); unsigned int H_In2 = W_In1; unsigned int H_Out = H_In1; @@ -702,7 +708,11 @@ void KerParMatMulB8_SQ8(KerMatMul_SQ8_T *Arg) S3 += V0 * BufferColIn2[i+3*H_In2]; } unsigned int Sc = Scale[Line], ScN = ScaleN[Line]; - v4s R = gap_pack4(gap_clip(AT_SCALE(S0, Sc, ScN), 7), gap_clip(AT_SCALE(S1, Sc, ScN), 7), gap_clip(AT_SCALE(S2, Sc, ScN), 7), gap_clip(AT_SCALE(S3, Sc, ScN), 7)); + S0 = AT_SCALE(S0, Sc, ScN); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S1 = AT_SCALE(S1, Sc, ScN); ACT_SWITCH(S1, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S2 = AT_SCALE(S2, Sc, ScN); ACT_SWITCH(S2, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S3 = AT_SCALE(S3, Sc, ScN); ACT_SWITCH(S3, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + v4s R = gap_pack4(gap_clip(S0, 7), gap_clip(S1, 7), gap_clip(S2, 7), gap_clip(S3, 7)); *((v4s *) (Out+(Line+OffLine)*W_Out+4*Col+0+OffCol)) = R; } gap_waitbarrier(0); @@ -730,8 +740,10 @@ void KerParMatMulB8_SQ8(KerMatMul_SQ8_T *Arg) S1 += V0 * BufferColIn2[i+1*H_In2]; } unsigned int Sc = Scale[Line], ScN = ScaleN[Line]; - Out[(Line+OffLine)*W_Out+2*Col+0+OffCol] = gap_clip(AT_SCALE(S0, Sc, ScN), 7); - Out[(Line+OffLine)*W_Out+2*Col+1+OffCol] = gap_clip(AT_SCALE(S1, Sc, ScN), 7); + S0 = AT_SCALE(S0, Sc, ScN); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S1 = AT_SCALE(S1, Sc, ScN); ACT_SWITCH(S1, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + Out[(Line+OffLine)*W_Out+2*Col+0+OffCol] = gap_clip(S0, 7); + Out[(Line+OffLine)*W_Out+2*Col+1+OffCol] = gap_clip(S1, 7); } gap_waitbarrier(0); } @@ -754,136 +766,172 @@ void KerParMatMulB8_SQ8(KerMatMul_SQ8_T *Arg) S0 += V0 * BufferColIn2[i]; } unsigned int Sc = Scale[Line], ScN = ScaleN[Line]; - Out[(Line+OffLine)*W_Out+1*Col+0+OffCol] = gap_clip(AT_SCALE(S0, Sc, ScN), 7); + S0 = AT_SCALE(S0, Sc, ScN); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + Out[(Line+OffLine)*W_Out+1*Col+0+OffCol] = gap_clip(S0, 7); } gap_waitbarrier(0); } } -void KerParMatMulB8_ReLU_SQ8(KerMatMul_SQ8_T *Arg) +void KerParMatMulB8_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB8_SQ8_act(Arg, ACT_NONE); +} + +void KerParMatMulB8_ReLU_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB8_SQ8_act(Arg, ACT_RELU); +} + +void KerParMatMulB8_ReLUN_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB8_SQ8_act(Arg, ACT_RELUN); +} + +void KerParMatMulB8_ReLUM_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB8_SQ8_act(Arg, ACT_RELUM); +} + +void KerParMatMulB8_ReLUMN_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB8_SQ8_act(Arg, ACT_RELUMN); +} + +void KerParMatMulB8_LeakyReLU_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB8_SQ8_act(Arg, ACT_LEAKYRELU); +} + +void KerParMatMulB8_HSwish_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB8_SQ8_act(Arg, ACT_HSWISH); +} + +void KerParMatMulB8_HSigmoid_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB8_SQ8_act(Arg, ACT_HSIGMOID); +} + +void KerParMatMulB8_Sigmoid_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB8_SQ8_act(Arg, ACT_SIGMOID); +} + +void KerParMatMulB8_Tanh_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB8_SQ8_act(Arg, ACT_TANH); +} + +static inline void __attribute__((always_inline)) KerParMatMulSxSyB8_SQ8_act( + KerMatMul_SQ8_T *Arg, + CNN_ActivationOper_T Activation) { - /* - Column buffer has to be sized in order to be able to accomodate up to 4 columns of size H_In2 - */ - signed char * __restrict__ In1 = Arg->In1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - signed char * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; +/* + In1 is usually the Conv1x1 filter set, e,g In1 is [OutFeat][InFeat] + In2 is [InFeat][Width*Height] + + When we receive tiles In2 and if StrideY is != 1 tile is always [OutFeat][K*(Width*Scy)] +*/ + signed char * __restrict__ In1 = Arg->In1; + unsigned int W_In1 = Arg->W_In1; + unsigned int H_In1 = Arg->H_In1; + signed char * __restrict__ In2 = Arg->In2; + unsigned int W_In2 = Arg->W_In2; + signed char * __restrict__ Bias = Arg->Bias; + signed char * __restrict__ Out = Arg->Out; + unsigned int W_Out = Arg->W_Out; + int Pi = Arg->OutFirstCol; + signed char *BufferColIn2 = Arg->BufferColIn2; + unsigned int NormBias = Arg->NormBias; + int Wi = Arg->W, Hi = Arg->H; + int Sx = Arg->Sx, Sy = Arg->Sy; + int ColFirst = Arg->ColFirst; unsigned char * __restrict__ Scale = Arg->Scale; unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int OutFirstCol = Arg->OutFirstCol; - signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; - int ColFirst = Arg->ColFirst; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; - v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); - v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); - v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); + unsigned int H_In2 = W_In1; + unsigned int H_Out = H_In1; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); - int OffLine = 0, OffCol = 0; + int Wo = (Wi+Sx-1)/Sx, Ho = (Hi+Sy-1)/Sy; + int Oo, OffLine; + int At, F=0, L = W_In2; - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - for (Col=0; Col0) { + for (i=Fi;iH_In1; signed char * __restrict__ In2 = Arg->In2; unsigned int W_In2 = Arg->W_In2; - signed char * __restrict__ Bias = Arg->Bias; + short int * __restrict__ Bias = Arg->Bias; signed char * __restrict__ Out = Arg->Out; unsigned int W_Out = Arg->W_Out; unsigned char * __restrict__ Scale = Arg->Scale; @@ -903,7 +951,9 @@ void KerParMatMulB8_ReLUN_SQ8(KerMatMul_SQ8_T *Arg) unsigned int OutFirstCol = Arg->OutFirstCol; signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; int ColFirst = Arg->ColFirst; - int A0 = Arg->Infos[AT_INF_A0]; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); unsigned int H_In2 = W_In1; unsigned int H_Out = H_In1; @@ -948,8 +998,11 @@ void KerParMatMulB8_ReLUN_SQ8(KerMatMul_SQ8_T *Arg) S3 += V0 * BufferColIn2[i+3*H_In2]; } unsigned int Sc = Scale[Line], ScN = ScaleN[Line]; - v4s R = gap_pack4(gap_clip(AT_CLIP_POS(AT_SCALE(S0, Sc, ScN), A0), 7), gap_clip(AT_CLIP_POS(AT_SCALE(S1, Sc, ScN), A0), 7), - gap_clip(AT_CLIP_POS(AT_SCALE(S2, Sc, ScN), A0), 7), gap_clip(AT_CLIP_POS(AT_SCALE(S3, Sc, ScN), A0), 7)); + S0 = AT_SCALE(S0, Sc, ScN); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S1 = AT_SCALE(S1, Sc, ScN); ACT_SWITCH(S1, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S2 = AT_SCALE(S2, Sc, ScN); ACT_SWITCH(S2, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S3 = AT_SCALE(S3, Sc, ScN); ACT_SWITCH(S3, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + v4s R = gap_pack4(gap_clip(S0, 7), gap_clip(S1, 7), gap_clip(S2, 7), gap_clip(S3, 7)); *((v4s *) (Out+(Line+OffLine)*W_Out+4*Col+0+OffCol)) = R; } gap_waitbarrier(0); @@ -977,8 +1030,10 @@ void KerParMatMulB8_ReLUN_SQ8(KerMatMul_SQ8_T *Arg) S1 += V0 * BufferColIn2[i+1*H_In2]; } unsigned int Sc = Scale[Line], ScN = ScaleN[Line]; - Out[(Line+OffLine)*W_Out+2*Col+0+OffCol] = gap_clip(AT_CLIP_POS(AT_SCALE(S0, Sc, ScN), A0), 7); - Out[(Line+OffLine)*W_Out+2*Col+1+OffCol] = gap_clip(AT_CLIP_POS(AT_SCALE(S1, Sc, ScN), A0), 7); + S0 = AT_SCALE(S0, Sc, ScN); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S1 = AT_SCALE(S1, Sc, ScN); ACT_SWITCH(S1, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + Out[(Line+OffLine)*W_Out+2*Col+0+OffCol] = gap_clip(S0, 7); + Out[(Line+OffLine)*W_Out+2*Col+1+OffCol] = gap_clip(S1, 7); } gap_waitbarrier(0); } @@ -1001,13 +1056,57 @@ void KerParMatMulB8_ReLUN_SQ8(KerMatMul_SQ8_T *Arg) S0 += V0 * BufferColIn2[i]; } unsigned int Sc = Scale[Line], ScN = ScaleN[Line]; - Out[(Line+OffLine)*W_Out+1*Col+0+OffCol] = gap_clip(AT_CLIP_POS(AT_SCALE(S0, Sc, ScN), A0), 7); + S0 = AT_SCALE(S0, Sc, ScN); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + Out[(Line+OffLine)*W_Out+1*Col+0+OffCol] = gap_clip(S0, 7); } gap_waitbarrier(0); } } -void KerParMatMulSxSyB8_SQ8(KerMatMul_SQ8_T *Arg) +void KerParMatMulB16_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB16_SQ8_act(Arg, ACT_NONE); +} + +void KerParMatMulB16_ReLU_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB16_SQ8_act(Arg, ACT_RELU); +} + +void KerParMatMulB16_ReLUN_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB16_SQ8_act(Arg, ACT_RELUN); +} + +void KerParMatMulB16_ReLUM_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB16_SQ8_act(Arg, ACT_RELUM); +} + +void KerParMatMulB16_ReLUMN_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB16_SQ8_act(Arg, ACT_RELUMN); +} + +void KerParMatMulB16_LeakyReLU_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB16_SQ8_act(Arg, ACT_LEAKYRELU); +} + +void KerParMatMulB16_HSwish_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB16_SQ8_act(Arg, ACT_HSWISH); +} + +void KerParMatMulB16_HSigmoid_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB16_SQ8_act(Arg, ACT_HSIGMOID); +} + +void KerParMatMulB16_Sigmoid_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB16_SQ8_act(Arg, ACT_SIGMOID); +} + +void KerParMatMulB16_Tanh_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB16_SQ8_act(Arg, ACT_TANH); +} + + +static inline void __attribute__((always_inline)) KerParMatMulSxSyB16_SQ8_act( + KerMatMul_SQ8_T *Arg, + CNN_ActivationOper_T Activation) { /* @@ -1021,7 +1120,7 @@ void KerParMatMulSxSyB8_SQ8(KerMatMul_SQ8_T *Arg) unsigned int H_In1 = Arg->H_In1; signed char * __restrict__ In2 = Arg->In2; unsigned int W_In2 = Arg->W_In2; - signed char * __restrict__ Bias = Arg->Bias; + short int * __restrict__ Bias = Arg->Bias; signed char * __restrict__ Out = Arg->Out; unsigned int W_Out = Arg->W_Out; int Pi = Arg->OutFirstCol; @@ -1032,6 +1131,9 @@ void KerParMatMulSxSyB8_SQ8(KerMatMul_SQ8_T *Arg) int ColFirst = Arg->ColFirst; unsigned char * __restrict__ Scale = Arg->Scale; unsigned char * __restrict__ ScaleN = Arg->ScaleN; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); unsigned int H_In2 = W_In1; unsigned int H_Out = H_In1; @@ -1062,7 +1164,8 @@ void KerParMatMulSxSyB8_SQ8(KerMatMul_SQ8_T *Arg) if (W_In1&0x4) S = gap_sumdotp4(VIn1[W_In1/4-1], VBuff[W_In1/4-1], S); for (i=(W_In1/4)*4; iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - signed char * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - int Pi = Arg->OutFirstCol; - signed char *BufferColIn2 = Arg->BufferColIn2; - unsigned int NormBias = Arg->NormBias; - int Wi = Arg->W, Hi = Arg->H; - int Sx = Arg->Sx, Sy = Arg->Sy; - int ColFirst = Arg->ColFirst; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; +void KerParMatMulSxSyB16_ReLUN_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulSxSyB16_SQ8_act(Arg, ACT_RELUN); +} - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - - int Wo = (Wi+Sx-1)/Sx, Ho = (Hi+Sy-1)/Sy; - int Oo, OffLine; - int At, F=0, L = W_In2; - - unsigned int Line, Col, i; - v4s *VBuff = (v4s *) BufferColIn2; - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Ci = ChunkSize(H_In2), Fi = CoreId*Ci, Li = Min(H_In2, Fi+Ci); - - At = 0; OffLine = 0; Oo = 0; - if (ColFirst) OffLine = Pi; else Oo = Pi; - - while (L>0) { - for (i=Fi;iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - signed char * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - int Pi = Arg->OutFirstCol; - signed char *BufferColIn2 = Arg->BufferColIn2; - unsigned int NormBias = Arg->NormBias; - int Wi = Arg->W, Hi = Arg->H; - int Sx = Arg->Sx, Sy = Arg->Sy; - int ColFirst = Arg->ColFirst; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - int A0 = Arg->Infos[AT_INF_A0]; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; +void KerParMatMulSxSyB16_ReLUMN_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulSxSyB16_SQ8_act(Arg, ACT_RELUMN); +} - int Wo = (Wi+Sx-1)/Sx, Ho = (Hi+Sy-1)/Sy; - int Oo, OffLine; - int At, F=0, L = W_In2; +void KerParMatMulSxSyB16_LeakyReLU_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulSxSyB16_SQ8_act(Arg, ACT_LEAKYRELU); +} - unsigned int Line, Col, i; - v4s *VBuff = (v4s *) BufferColIn2; +void KerParMatMulSxSyB16_HSwish_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulSxSyB16_SQ8_act(Arg, ACT_HSWISH); +} - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Ci = ChunkSize(H_In2), Fi = CoreId*Ci, Li = Min(H_In2, Fi+Ci); +void KerParMatMulSxSyB16_HSigmoid_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulSxSyB16_SQ8_act(Arg, ACT_HSIGMOID); +} - At = 0; OffLine = 0; Oo = 0; - if (ColFirst) OffLine = Pi; else Oo = Pi; +void KerParMatMulSxSyB16_Sigmoid_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulSxSyB16_SQ8_act(Arg, ACT_SIGMOID); +} - while (L>0) { - for (i=Fi;iH_In1; signed char * __restrict__ In2 = Arg->In2; unsigned int W_In2 = Arg->W_In2; - short int * __restrict__ Bias = Arg->Bias; + int * __restrict__ Bias = Arg->Bias; signed char * __restrict__ Out = Arg->Out; unsigned int W_Out = Arg->W_Out; unsigned char * __restrict__ Scale = Arg->Scale; @@ -1233,6 +1243,9 @@ void KerParMatMulB16_SQ8(KerMatMul_SQ8_T *Arg) unsigned int OutFirstCol = Arg->OutFirstCol; signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; int ColFirst = Arg->ColFirst; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); unsigned int H_In2 = W_In1; unsigned int H_Out = H_In1; @@ -1243,6 +1256,7 @@ void KerParMatMulB16_SQ8(KerMatMul_SQ8_T *Arg) v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); + unsigned int Iter = (Last>First)?(Last-First):0; unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); int OffLine = 0, OffCol = 0; @@ -1259,27 +1273,87 @@ void KerParMatMulB16_SQ8(KerMatMul_SQ8_T *Arg) BufferColIn2[i+3*H_In2] = X3; // In2[i*W_In2+4*Col+3]; } gap_waitbarrier(0); - for (Line=First; LineIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - short int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; +/* + In1 is usually the Conv1x1 filter set, e,g In1 is [OutFeat][InFeat] + In2 is [InFeat][Width*Height] + + When we receive tiles In2 and if StrideY is != 1 tile is always [OutFeat][K*(Width*Scy)] +*/ + signed char * __restrict__ In1 = Arg->In1; + unsigned int W_In1 = Arg->W_In1; + unsigned int H_In1 = Arg->H_In1; + signed char * __restrict__ In2 = Arg->In2; + unsigned int W_In2 = Arg->W_In2; + int * __restrict__ Bias = Arg->Bias; + signed char * __restrict__ Out = Arg->Out; + unsigned int W_Out = Arg->W_Out; + int Pi = Arg->OutFirstCol; + signed char *BufferColIn2 = Arg->BufferColIn2; + unsigned int NormBias = Arg->NormBias; + int Wi = Arg->W, Hi = Arg->H; + int Sx = Arg->Sx, Sy = Arg->Sy; + int ColFirst = Arg->ColFirst; unsigned char * __restrict__ Scale = Arg->Scale; unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int OutFirstCol = Arg->OutFirstCol; - signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; - int ColFirst = Arg->ColFirst; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; - v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); - v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); - v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); + unsigned int H_In2 = W_In1; + unsigned int H_Out = H_In1; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - for (Col=0; ColIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - short int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int OutFirstCol = Arg->OutFirstCol; - signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; - int ColFirst = Arg->ColFirst; - int A0 = Arg->Infos[AT_INF_A0]; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; - v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); - v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); - v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - for (Col=0; ColIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - short int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - int Pi = Arg->OutFirstCol; - signed char *BufferColIn2 = Arg->BufferColIn2; - unsigned int NormBias = Arg->NormBias; - int Wi = Arg->W, Hi = Arg->H; - int Sx = Arg->Sx, Sy = Arg->Sy; - int ColFirst = Arg->ColFirst; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - - int Wo = (Wi+Sx-1)/Sx, Ho = (Hi+Sy-1)/Sy; - int Oo, OffLine; - int At, F=0, L = W_In2; + int Wo = (Wi+Sx-1)/Sx, Ho = (Hi+Sy-1)/Sy; + int Oo, OffLine; + int At, F=0, L = W_In2; unsigned int Line, Col, i; v4s *VBuff = (v4s *) BufferColIn2; @@ -1629,7 +1510,7 @@ void KerParMatMulSxSyB16_SQ8(KerMatMul_SQ8_T *Arg) gap_waitbarrier(0); for (Line=First; LineIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - short int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - int Pi = Arg->OutFirstCol; - signed char *BufferColIn2 = Arg->BufferColIn2; - unsigned int NormBias = Arg->NormBias; - int Wi = Arg->W, Hi = Arg->H; - int Sx = Arg->Sx, Sy = Arg->Sy; - int ColFirst = Arg->ColFirst; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; +void KerParMatMulSxSyB32_ReLUN_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulSxSyB32_SQ8_act(Arg, ACT_RELUN); +} - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; +void KerParMatMulSxSyB32_ReLUM_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulSxSyB32_SQ8_act(Arg, ACT_RELUM); +} - int Wo = (Wi+Sx-1)/Sx, Ho = (Hi+Sy-1)/Sy; - int Oo, OffLine; - int At, F=0, L = W_In2; +void KerParMatMulSxSyB32_ReLUMN_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulSxSyB32_SQ8_act(Arg, ACT_RELUMN); +} - unsigned int Line, Col, i; - v4s *VBuff = (v4s *) BufferColIn2; +void KerParMatMulSxSyB32_LeakyReLU_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulSxSyB32_SQ8_act(Arg, ACT_LEAKYRELU); +} - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Ci = ChunkSize(H_In2), Fi = CoreId*Ci, Li = Min(H_In2, Fi+Ci); +void KerParMatMulSxSyB32_HSwish_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulSxSyB32_SQ8_act(Arg, ACT_HSWISH); +} - At = 0; OffLine = 0; Oo = 0; - if (ColFirst) OffLine = Pi; else Oo = Pi; +void KerParMatMulSxSyB32_HSigmoid_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulSxSyB32_SQ8_act(Arg, ACT_HSIGMOID); +} - while (L>0) { - for (i=Fi;iIn1; unsigned int W_In1 = Arg->W_In1; unsigned int H_In1 = Arg->H_In1; signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - short int * __restrict__ Bias = Arg->Bias; + unsigned int H_In2 = Arg->W_In2; + unsigned int W_In2 = W_In1; + signed char * __restrict__ Bias = Arg->Bias; signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - int Pi = Arg->OutFirstCol; - signed char *BufferColIn2 = Arg->BufferColIn2; - unsigned int NormBias = Arg->NormBias; - int Wi = Arg->W, Hi = Arg->H; - int Sx = Arg->Sx, Sy = Arg->Sy; - int ColFirst = Arg->ColFirst; unsigned char * __restrict__ Scale = Arg->Scale; unsigned char * __restrict__ ScaleN = Arg->ScaleN; - int A0 = Arg->Infos[AT_INF_A0]; + unsigned int NormBias = Arg->NormBias; + unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H_In2), First = Chunk*CoreId, Last = Min(First+Chunk, H_In2); + unsigned int Iter = (Last>First)?(Last-First):0; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; + for (int i=0; i0) { - for (i=Fi;iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; + signed char * __restrict__ In1 = Arg->In1; + unsigned int W_In1 = Arg->W_In1; + unsigned int H_In1 = Arg->H_In1; + signed char * __restrict__ In2 = Arg->In2; + unsigned int H_In2 = Arg->W_In2; + unsigned int W_In2 = W_In1; + short int * __restrict__ Bias = Arg->Bias; + signed char * __restrict__ Out = Arg->Out; unsigned char * __restrict__ Scale = Arg->Scale; unsigned char * __restrict__ ScaleN = Arg->ScaleN; unsigned int NormBias = Arg->NormBias; - unsigned int OutFirstCol = Arg->OutFirstCol; - signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; - int ColFirst = Arg->ColFirst; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; - v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); - v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); - v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); - int OffLine = 0, OffCol = 0; + unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H_In2), First = Chunk*CoreId, Last = Min(First+Chunk, H_In2); + unsigned int Iter = (Last>First)?(Last-First):0; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - for (Col=0; ColIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; + signed char * __restrict__ In1 = Arg->In1; + unsigned int W_In1 = Arg->W_In1; + unsigned int H_In1 = Arg->H_In1; + signed char * __restrict__ In2 = Arg->In2; + unsigned int H_In2 = Arg->W_In2; + unsigned int W_In2 = W_In1; + int * __restrict__ Bias = Arg->Bias; + signed char * __restrict__ Out = Arg->Out; unsigned char * __restrict__ Scale = Arg->Scale; unsigned char * __restrict__ ScaleN = Arg->ScaleN; unsigned int NormBias = Arg->NormBias; - unsigned int OutFirstCol = Arg->OutFirstCol; - signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; - int ColFirst = Arg->ColFirst; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; - v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); - v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); - v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); - int OffLine = 0, OffCol = 0; + unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H_In2), First = Chunk*CoreId, Last = Min(First+Chunk, H_In2); + unsigned int Iter = (Last>First)?(Last-First):0; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - for (Col=0; ColIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int OutFirstCol = Arg->OutFirstCol; - signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; - int ColFirst = Arg->ColFirst; +void KerParMatMulB32_ReLU_SF_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB32_SF_SQ8_act(Arg, ACT_RELU); +} - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; - v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); - v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); - v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); +void KerParMatMulB32_ReLUN_SF_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB32_SF_SQ8_act(Arg, ACT_RELUN); +} - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); - int OffLine = 0, OffCol = 0; +void KerParMatMulB32_ReLUM_SF_SQ8(KerMatMul_SQ8_T *Arg) { + KerParMatMulB32_SF_SQ8_act(Arg, ACT_RELUM); +} - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - for (Col=0; ColIn1; + signed char * __restrict__ In2 = Arg->In2; + signed char * __restrict__ Out = Arg->Out; + int W = Arg->W; + int H = Arg->H; + unsigned int Scale = ((unsigned char *)(Arg->Infos))[AT_INF_SCALE]; + unsigned int ScaleN = ((unsigned char *)(Arg->Infos))[AT_INF_SCALEN]; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); + + unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Arg->Feat), First = Chunk*CoreId, Last = Min(First+Chunk, Arg->Feat); + + if (Scale) + for (int i=First; iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int OutFirstCol = Arg->OutFirstCol; - signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; - int ColFirst = Arg->ColFirst; +void KerParMatVectMul_ReLU_SQ8(KerMat3_SQ8_T *Arg) { + KerParMatVectMul_SQ8_act(Arg, ACT_RELU); +} - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; - v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); - v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); - v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); +void KerParMatVectMul_ReLUN_SQ8(KerMat3_SQ8_T *Arg) { + KerParMatVectMul_SQ8_act(Arg, ACT_RELUN); +} - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); - int OffLine = 0, OffCol = 0; +void KerParMatVectMul_ReLUM_SQ8(KerMat3_SQ8_T *Arg) { + KerParMatVectMul_SQ8_act(Arg, ACT_RELUM); +} - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - for (Col=0; ColIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int OutFirstCol = Arg->OutFirstCol; - signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; - int ColFirst = Arg->ColFirst; - int A0 = Arg->Infos[AT_INF_A0]; +void KerParMatVectMul_HSwish_SQ8(KerMat3_SQ8_T *Arg) { + KerParMatVectMul_SQ8_act(Arg, ACT_HSWISH); +} - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; - v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); - v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); - v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); +void KerParMatVectMul_HSigmoid_SQ8(KerMat3_SQ8_T *Arg) { + KerParMatVectMul_SQ8_act(Arg, ACT_HSIGMOID); +} - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); - int OffLine = 0, OffCol = 0; +void KerParMatVectMul_Sigmoid_SQ8(KerMat3_SQ8_T *Arg) { + KerParMatVectMul_SQ8_act(Arg, ACT_SIGMOID); +} - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - for (Col=0; ColIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - int Pi = Arg->OutFirstCol; - signed char *BufferColIn2 = Arg->BufferColIn2; - unsigned int NormBias = Arg->NormBias; - int Wi = Arg->W, Hi = Arg->H; - int Sx = Arg->Sx, Sy = Arg->Sy; - int ColFirst = Arg->ColFirst; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - - int Wo = (Wi+Sx-1)/Sx, Ho = (Hi+Sy-1)/Sy; - int Oo, OffLine; - int At, F=0, L = W_In2; - - unsigned int Line, Col, i; - v4s *VBuff = (v4s *) BufferColIn2; - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Ci = ChunkSize(H_In2), Fi = CoreId*Ci, Li = Min(H_In2, Fi+Ci); - - At = 0; OffLine = 0; Oo = 0; - if (ColFirst) OffLine = Pi; else Oo = Pi; - - while (L>0) { - for (i=Fi;iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - int Pi = Arg->OutFirstCol; - signed char *BufferColIn2 = Arg->BufferColIn2; - unsigned int NormBias = Arg->NormBias; - int Wi = Arg->W, Hi = Arg->H; - int Sx = Arg->Sx, Sy = Arg->Sy; - int ColFirst = Arg->ColFirst; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - - int Wo = (Wi+Sx-1)/Sx, Ho = (Hi+Sy-1)/Sy; - int Oo, OffLine; - int At, F=0, L = W_In2; - - unsigned int Line, Col, i; - v4s *VBuff = (v4s *) BufferColIn2; - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Ci = ChunkSize(H_In2), Fi = CoreId*Ci, Li = Min(H_In2, Fi+Ci); - - At = 0; OffLine = 0; Oo = 0; - if (ColFirst) OffLine = Pi; else Oo = Pi; - - while (L>0) { - for (i=Fi;iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - int Pi = Arg->OutFirstCol; - signed char *BufferColIn2 = Arg->BufferColIn2; - unsigned int NormBias = Arg->NormBias; - int Wi = Arg->W, Hi = Arg->H; - int Sx = Arg->Sx, Sy = Arg->Sy; - int ColFirst = Arg->ColFirst; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - int A0 = Arg->Infos[AT_INF_A0]; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - - int Wo = (Wi+Sx-1)/Sx, Ho = (Hi+Sy-1)/Sy; - int Oo, OffLine; - int At, F=0, L = W_In2; - - unsigned int Line, Col, i; - v4s *VBuff = (v4s *) BufferColIn2; - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Ci = ChunkSize(H_In2), Fi = CoreId*Ci, Li = Min(H_In2, Fi+Ci); - - At = 0; OffLine = 0; Oo = 0; - if (ColFirst) OffLine = Pi; else Oo = Pi; - - while (L>0) { - for (i=Fi;iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int H_In2 = Arg->W_In2; - unsigned int W_In2 = W_In1; - signed char * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H_In2), First = Chunk*CoreId, Last = Min(First+Chunk, H_In2); - unsigned int Iter = (Last>First)?(Last-First):0; - - for (int i=0; iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int H_In2 = Arg->W_In2; - unsigned int W_In2 = W_In1; - signed char * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H_In2), First = Chunk*CoreId, Last = Min(First+Chunk, H_In2); - unsigned int Iter = (Last>First)?(Last-First):0; - - for (int i=0; iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int H_In2 = Arg->W_In2; - unsigned int W_In2 = W_In1; - signed char * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H_In2), First = Chunk*CoreId, Last = Min(First+Chunk, H_In2); - unsigned int Iter = (Last>First)?(Last-First):0; - int A0 = Arg->Infos[AT_INF_A0]; - - for (int i=0; iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int H_In2 = Arg->W_In2; - unsigned int W_In2 = W_In1; - short int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H_In2), First = Chunk*CoreId, Last = Min(First+Chunk, H_In2); - unsigned int Iter = (Last>First)?(Last-First):0; - - for (int i=0; iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int H_In2 = Arg->W_In2; - unsigned int W_In2 = W_In1; - short int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H_In2), First = Chunk*CoreId, Last = Min(First+Chunk, H_In2); - unsigned int Iter = (Last>First)?(Last-First):0; - - for (int i=0; iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int H_In2 = Arg->W_In2; - unsigned int W_In2 = W_In1; - short int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H_In2), First = Chunk*CoreId, Last = Min(First+Chunk, H_In2); - unsigned int Iter = (Last>First)?(Last-First):0; - int A0 = Arg->Infos[AT_INF_A0]; - - for (int i=0; iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int H_In2 = Arg->W_In2; - unsigned int W_In2 = W_In1; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H_In2), First = Chunk*CoreId, Last = Min(First+Chunk, H_In2); - unsigned int Iter = (Last>First)?(Last-First):0; - - for (int i=0; iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int H_In2 = Arg->W_In2; - unsigned int W_In2 = W_In1; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H_In2), First = Chunk*CoreId, Last = Min(First+Chunk, H_In2); - unsigned int Iter = (Last>First)?(Last-First):0; - - for (int i=0; iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int H_In2 = Arg->W_In2; - unsigned int W_In2 = W_In1; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H_In2), First = Chunk*CoreId, Last = Min(First+Chunk, H_In2); - unsigned int Iter = (Last>First)?(Last-First):0; - - for (int i=0; iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int H_In2 = Arg->W_In2; - unsigned int W_In2 = W_In1; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H_In2), First = Chunk*CoreId, Last = Min(First+Chunk, H_In2); - unsigned int Iter = (Last>First)?(Last-First):0; - int A0 = Arg->Infos[AT_INF_A0]; - - for (int i=0; iIn1; - signed char * __restrict__ In2 = Arg->In2; - signed char * __restrict__ Out = Arg->Out; - int W = Arg->W; - int H = Arg->H; - unsigned int Scale = ((unsigned char *)(Arg->Infos))[AT_INF_SCALE]; - unsigned int ScaleN = ((unsigned char *)(Arg->Infos))[AT_INF_SCALEN]; - - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Arg->Feat), First = Chunk*CoreId, Last = Min(First+Chunk, Arg->Feat); - - if (Scale) - for (int i=First; iIn1; - signed char * __restrict__ In2 = Arg->In2; - signed char * __restrict__ Out = Arg->Out; - int W = Arg->W; - int H = Arg->H; - int Feat = Arg->Feat; - unsigned int Scale = ((unsigned char *)(Arg->Infos))[AT_INF_SCALE]; - unsigned int ScaleN = ((unsigned char *)(Arg->Infos))[AT_INF_SCALEN]; - int S = W*H; - - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Feat), First = Chunk*CoreId, Last = Min(First+Chunk, Feat); - - if (Scale) - for (int i=First; iIn1; - signed char * __restrict__ In2 = Arg->In2; - signed char * __restrict__ Out = Arg->Out; - int W = Arg->W; - int H = Arg->H; - unsigned int Scale = ((unsigned char *)(Arg->Infos))[AT_INF_SCALE]; - unsigned int ScaleN = ((unsigned char *)(Arg->Infos))[AT_INF_SCALEN]; - - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Arg->Feat), First = Chunk*CoreId, Last = Min(First+Chunk, Arg->Feat); - - if (Scale) - for (int i=First; iIn1; - signed char * __restrict__ In2 = Arg->In2; - signed char * __restrict__ Out = Arg->Out; - int W = Arg->W; - int H = Arg->H; - int A0 = Arg->Infos[AT_INF_A0]; - unsigned int Scale = ((unsigned char *)(Arg->Infos))[AT_INF_SCALE]; - unsigned int ScaleN = ((unsigned char *)(Arg->Infos))[AT_INF_SCALEN]; - - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Arg->Feat), First = Chunk*CoreId, Last = Min(First+Chunk, Arg->Feat); - - if (Scale) - for (int i=First; iIn1; - signed char * __restrict__ In2 = Arg->In2; - signed char * __restrict__ Out = Arg->Out; - int W = Arg->W; - int H = Arg->H; - unsigned int ActScale = ((unsigned char *)(Arg->Infos))[AT_INF_ACTSCALE]; - unsigned int ActScaleN = ((unsigned char *)(Arg->Infos))[AT_INF_ACTSCALEN]; - int A0 = Arg->Infos[AT_INF_A0]; - int B0 = Arg->Infos[AT_INF_B0]; - int C0 = Arg->Infos[AT_INF_C0]; - unsigned int Scale = ((unsigned char *)(Arg->Infos))[AT_INF_SCALE]; - unsigned int ScaleN = ((unsigned char *)(Arg->Infos))[AT_INF_SCALEN]; - - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Arg->Feat), First = Chunk*CoreId, Last = Min(First+Chunk, Arg->Feat); - - if (Scale) - for (int i=First; iIn1; - signed char * __restrict__ In2 = Arg->In2; - signed char * __restrict__ Out = Arg->Out; - int W = Arg->W; - int H = Arg->H; - unsigned int ActScale = ((unsigned char *)(Arg->Infos))[AT_INF_ACTSCALE]; - unsigned int ActScaleN = ((unsigned char *)(Arg->Infos))[AT_INF_ACTSCALEN]; - int A0 = Arg->Infos[AT_INF_A0]; - int B0 = Arg->Infos[AT_INF_B0]; - int C0 = Arg->Infos[AT_INF_C0]; - unsigned int Scale = ((unsigned char *)(Arg->Infos))[AT_INF_SCALE]; - unsigned int ScaleN = ((unsigned char *)(Arg->Infos))[AT_INF_SCALEN]; - - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Arg->Feat), First = Chunk*CoreId, Last = Min(First+Chunk, Arg->Feat); - - if (Scale) - for (int i=First; iIn1; - signed char * __restrict__ In2 = Arg->In2; - signed char * __restrict__ Out = Arg->Out; - int W = Arg->W; - int H = Arg->H; - unsigned int ActScale = ((unsigned char *)(Arg->Infos))[AT_INF_ACTSCALE]; - unsigned int ActScaleN = ((unsigned char *)(Arg->Infos))[AT_INF_ACTSCALEN]; - int A0 = Arg->Infos[AT_INF_A0]; - int B0 = Arg->Infos[AT_INF_B0]; - int C0 = Arg->Infos[AT_INF_C0]; - unsigned int Scale = ((unsigned char *)(Arg->Infos))[AT_INF_SCALE]; - unsigned int ScaleN = ((unsigned char *)(Arg->Infos))[AT_INF_SCALEN]; - - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Arg->Feat), First = Chunk*CoreId, Last = Min(First+Chunk, Arg->Feat); - - if (Scale) - for (int i=First; iIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned char Scale = (unsigned char) Arg->Infos[AT_INF_OUTSCALE]; - unsigned char ScaleN = (unsigned char) Arg->Infos[AT_INF_OUTSCALEN]; - unsigned int OutFirstCol = Arg->OutFirstCol; - signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; - int ColFirst = Arg->ColFirst; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; - v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); - v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); - v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - for (Col=0; ColIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned int OutFirstCol = Arg->OutFirstCol; - signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; - int ColFirst = Arg->ColFirst; - unsigned char Scale = (unsigned char) Arg->Infos[AT_INF_OUTSCALE]; - unsigned char ScaleN = (unsigned char) Arg->Infos[AT_INF_OUTSCALEN]; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; - v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); - v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); - v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - for (Col=0; ColIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned int OutFirstCol = Arg->OutFirstCol; - signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; - int ColFirst = Arg->ColFirst; - int A0 = Arg->Infos[AT_INF_A0]; - unsigned char Scale = (unsigned char) Arg->Infos[AT_INF_OUTSCALE]; - unsigned char ScaleN = (unsigned char) Arg->Infos[AT_INF_OUTSCALEN]; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; - v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); - v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); - v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - for (Col=0; ColIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - signed char * __restrict__ Out = Arg->Out; - int * __restrict__ Bias = Arg->Bias; - unsigned int NormBias = Arg->NormBias; - unsigned int W_Out = Arg->W_Out; - unsigned char Scale = (unsigned char) Arg->Infos[AT_INF_OUTSCALE]; - unsigned char ScaleN = (unsigned char) Arg->Infos[AT_INF_OUTSCALEN]; - unsigned int OutFirstCol = Arg->OutFirstCol; - signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; - int ColFirst = Arg->ColFirst; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; - v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); - v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); - v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - for (Col=0; ColIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - signed char * __restrict__ Out = Arg->Out; - int * __restrict__ Bias = Arg->Bias; - unsigned int NormBias = Arg->NormBias; - unsigned int W_Out = Arg->W_Out; - unsigned int OutFirstCol = Arg->OutFirstCol; - signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; - int ColFirst = Arg->ColFirst; - unsigned char Scale = (unsigned char) Arg->Infos[AT_INF_OUTSCALE]; - unsigned char ScaleN = (unsigned char) Arg->Infos[AT_INF_OUTSCALEN]; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; - v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); - v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); - v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - for (Col=0; ColIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - signed char * __restrict__ Out = Arg->Out; - int * __restrict__ Bias = Arg->Bias; - unsigned int NormBias = Arg->NormBias; - unsigned int W_Out = Arg->W_Out; - unsigned int OutFirstCol = Arg->OutFirstCol; - signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; - int ColFirst = Arg->ColFirst; - int A0 = Arg->Infos[AT_INF_A0]; - unsigned char Scale = (unsigned char) Arg->Infos[AT_INF_OUTSCALE]; - unsigned char ScaleN = (unsigned char) Arg->Infos[AT_INF_OUTSCALEN]; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; - v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); - v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); - v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - for (Col=0; ColIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int OutFirstCol = Arg->OutFirstCol; - int ColFirst = Arg->ColFirst; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - signed char *pOut = Out + W_Out*OffLine + OffCol; - for (Line=0; LineIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int OutFirstCol = Arg->OutFirstCol; - int ColFirst = Arg->ColFirst; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - signed char *pOut = Out + W_Out*OffLine + OffCol; - for (Line=0; LineIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int NormBias = Arg->NormBias; - unsigned int OutFirstCol = Arg->OutFirstCol; - int ColFirst = Arg->ColFirst; - int A0 = Arg->Infos[AT_INF_A0]; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - signed char *pOut = Out + W_Out*OffLine + OffCol; - for (Line=0; LineIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int OutFirstCol = Arg->OutFirstCol; - int ColFirst = Arg->ColFirst; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - signed char *pOut = Out + W_Out*OffLine + OffCol; - for (Line=0; LineIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int OutFirstCol = Arg->OutFirstCol; - int ColFirst = Arg->ColFirst; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - signed char *pOut = Out + W_Out*OffLine + OffCol; - for (Line=0; LineIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - unsigned int OutFirstCol = Arg->OutFirstCol; - int ColFirst = Arg->ColFirst; - int A0 = Arg->Infos[AT_INF_A0]; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - signed char *pOut = Out + W_Out*OffLine + OffCol; - for (Line=0; LineIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned char Scale = (unsigned char) Arg->Infos[AT_INF_OUTSCALE]; - unsigned char ScaleN = (unsigned char) Arg->Infos[AT_INF_OUTSCALEN]; - unsigned int NormBias = Arg->NormBias; - unsigned int OutFirstCol = Arg->OutFirstCol; - int ColFirst = Arg->ColFirst; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - signed char *pOut = Out + W_Out*OffLine + OffCol; - for (Line=0; LineIn1; - unsigned int W_In1 = Arg->W_In1; - unsigned int H_In1 = Arg->H_In1; - signed char * __restrict__ In2 = Arg->In2; - unsigned int W_In2 = Arg->W_In2; - int * __restrict__ Bias = Arg->Bias; - signed char * __restrict__ Out = Arg->Out; - unsigned int W_Out = Arg->W_Out; - unsigned char Scale = (unsigned char) Arg->Infos[AT_INF_OUTSCALE]; - unsigned char ScaleN = (unsigned char) Arg->Infos[AT_INF_OUTSCALEN]; - unsigned int NormBias = Arg->NormBias; - unsigned int OutFirstCol = Arg->OutFirstCol; - int ColFirst = Arg->ColFirst; - - unsigned int H_In2 = W_In1; - unsigned int H_Out = H_In1; - unsigned int Line, Col, i; - - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); - unsigned int Iter = (Last>First)?(Last-First):0; - int OffLine = 0, OffCol = 0; - - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - signed char *pOut = Out + W_Out*OffLine + OffCol; - for (Line=0; LineIn1; + signed char * __restrict__ In2 = Arg->In2; + signed char * __restrict__ Out = Arg->Out; + int W = Arg->W; + int H = Arg->H; + int Feat = Arg->Feat; + unsigned int Scale = ((unsigned char *)(Arg->Infos))[AT_INF_SCALE]; + unsigned int ScaleN = ((unsigned char *)(Arg->Infos))[AT_INF_SCALEN]; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); + int S = W*H; + + unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Feat), First = Chunk*CoreId, Last = Min(First+Chunk, Feat); + + if (Scale) + for (int i=First; iH_In1; signed char * __restrict__ In2 = Arg->In2; unsigned int W_In2 = Arg->W_In2; - int * __restrict__ Bias = Arg->Bias; signed char * __restrict__ Out = Arg->Out; unsigned int W_Out = Arg->W_Out; unsigned char Scale = (unsigned char) Arg->Infos[AT_INF_OUTSCALE]; unsigned char ScaleN = (unsigned char) Arg->Infos[AT_INF_OUTSCALEN]; - unsigned int NormBias = Arg->NormBias; unsigned int OutFirstCol = Arg->OutFirstCol; + signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; int ColFirst = Arg->ColFirst; - int A0 = Arg->Infos[AT_INF_A0]; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); unsigned int H_In2 = W_In1; unsigned int H_Out = H_In1; unsigned int Line, Col, i; + v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; + v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); + v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); + v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); unsigned int Iter = (Last>First)?(Last-First):0; + unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); int OffLine = 0, OffCol = 0; if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - signed char *pOut = Out + W_Out*OffLine + OffCol; - for (Line=0; LineIn2; unsigned int W_In2 = Arg->W_In2; signed char * __restrict__ Out = Arg->Out; + int * __restrict__ Bias = Arg->Bias; + unsigned int NormBias = Arg->NormBias; unsigned int W_Out = Arg->W_Out; unsigned char Scale = (unsigned char) Arg->Infos[AT_INF_OUTSCALE]; unsigned char ScaleN = (unsigned char) Arg->Infos[AT_INF_OUTSCALEN]; unsigned int OutFirstCol = Arg->OutFirstCol; + signed char * __restrict__ BufferColIn2 = Arg->BufferColIn2; int ColFirst = Arg->ColFirst; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); unsigned int H_In2 = W_In1; unsigned int H_Out = H_In1; unsigned int Line, Col, i; + v4s * __restrict__ VBuff0 = (v4s *) BufferColIn2; + v4s * __restrict__ VBuff1 = (v4s *) (BufferColIn2+H_In2); + v4s * __restrict__ VBuff2 = (v4s *) (BufferColIn2+2*H_In2); + v4s * __restrict__ VBuff3 = (v4s *) (BufferColIn2+3*H_In2); unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(H_In1), First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); unsigned int Iter = (Last>First)?(Last-First):0; + unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); int OffLine = 0, OffCol = 0; - if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; - signed char *pOut = Out + W_Out*OffLine + OffCol; - for (Line=0; LineH_In1; signed char * __restrict__ In2 = Arg->In2; unsigned int W_In2 = Arg->W_In2; + int * __restrict__ Bias = Arg->Bias; signed char * __restrict__ Out = Arg->Out; unsigned int W_Out = Arg->W_Out; - unsigned char Scale = (unsigned char) Arg->Infos[AT_INF_OUTSCALE]; - unsigned char ScaleN = (unsigned char) Arg->Infos[AT_INF_OUTSCALEN]; + unsigned char * __restrict__ Scale = Arg->Scale; + unsigned char * __restrict__ ScaleN = Arg->ScaleN; + unsigned int NormBias = Arg->NormBias; unsigned int OutFirstCol = Arg->OutFirstCol; int ColFirst = Arg->ColFirst; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); unsigned int H_In2 = W_In1; unsigned int H_Out = H_In1; @@ -6532,10 +2695,13 @@ void KerParMatMulTransposedNoBias_ReLU_PL_SQ8(KerMatMul_PL_SQ8_T *Arg) v4s * __restrict__ VBuff1 = (v4s *) (pIn2+H_In2); v4s * __restrict__ VBuff2 = (v4s *) (pIn2+2*H_In2); v4s * __restrict__ VBuff3 = (v4s *) (pIn2+3*H_In2); - int S0 = 0, S4=S0; - int S1 = 0, S5=S1; - int S2 = 0, S6=S2; - int S3 = 0, S7=S3; + int S0=0, S1=0, S2=0, S3=0, S4=0, S5=0, S6=0, S7=0; + if (Bias) { + S0 = (Bias[4*Col]<H_In1; signed char * __restrict__ In2 = Arg->In2; unsigned int W_In2 = Arg->W_In2; + int * __restrict__ Bias = Arg->Bias; signed char * __restrict__ Out = Arg->Out; unsigned int W_Out = Arg->W_Out; unsigned char Scale = (unsigned char) Arg->Infos[AT_INF_OUTSCALE]; unsigned char ScaleN = (unsigned char) Arg->Infos[AT_INF_OUTSCALEN]; + unsigned int NormBias = Arg->NormBias; unsigned int OutFirstCol = Arg->OutFirstCol; int ColFirst = Arg->ColFirst; - int A0 = Arg->Infos[AT_INF_A0]; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); unsigned int H_In2 = W_In1; unsigned int H_Out = H_In1; @@ -6687,10 +2921,13 @@ void KerParMatMulTransposedNoBias_ReLUN_PL_SQ8(KerMatMul_PL_SQ8_T *Arg) v4s * __restrict__ VBuff1 = (v4s *) (pIn2+H_In2); v4s * __restrict__ VBuff2 = (v4s *) (pIn2+2*H_In2); v4s * __restrict__ VBuff3 = (v4s *) (pIn2+3*H_In2); - int S0 = 0, S4=S0; - int S1 = 0, S5=S1; - int S2 = 0, S6=S2; - int S3 = 0, S7=S3; + int S0=0, S1=0, S2=0, S3=0, S4=0, S5=0, S6=0, S7=0; + if (Bias) { + S0 = (Bias[4*Col]< #include "CNN_BasicKernels_SQ8.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wswitch" +#pragma GCC diagnostic ignored "-Wpointer-sign" + static int CoreCountDynamic = 1; static int ActiveCore = gap_ncore(); @@ -53,8 +55,14 @@ static int LastDefinedOutput(int DimIn, int F, int PadL, int Stride, int D) } // #define OLD -void KerPar_MM_Conv1D_SQ8( - Ker_MM_Conv_SQ8_T *Arg + +/* + * 1D Convolutional Kernels kernels based on MatMul (im2col: ColBuff) with CHW inout tensor order + * Optional Activation fused applied to the 32bits accumulator -> ACT_SWITCH defined in CNN_BasicKernels_SQ8.h + */ +static inline void __attribute__((always_inline)) KerPar_MM_Conv1D_SQ8_act( + Ker_MM_Conv_SQ8_T *Arg, + CNN_ActivationOper_T Activation ) { @@ -73,6 +81,9 @@ void KerPar_MM_Conv1D_SQ8( signed char * __restrict__ ColBuff = Arg->ColBuff; int Wo = Arg->Wo, Ho = Arg->Ho; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ v4s * __restrict__ VBuff = (v4s *) ColBuff; @@ -149,7 +160,8 @@ void KerPar_MM_Conv1D_SQ8( S0 = gap_sumdotp4(V1, C1, S0); } unsigned int Sc = Scale[Line], ScN = ScaleN[Line]; - Out[Line*Wo*Ho + l*Wo + c] = gap_clip(AT_SCALE(S0, Sc, ScN), 7); + S0 = AT_SCALE(S0, Sc, ScN); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + Out[Line*Wo*Ho + l*Wo + c] = gap_clip(S0, 7); } gap_waitbarrier(0); } @@ -157,81 +169,54 @@ void KerPar_MM_Conv1D_SQ8( } } -static void __attribute__ ((noinline)) MatMul2Out( - signed char *__restrict__ pI, - signed char *__restrict__ pC, - int *__restrict__ pBias, - unsigned char *__restrict__ pSc, - unsigned char *__restrict__ pScN, - signed char *__restrict__ pOut0, - signed char *__restrict__ pOut1, - unsigned int InFeat, - unsigned int IterOut, - unsigned int NormBias - ) +void KerPar_MM_Conv1D_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_SQ8_act(Arg, ACT_NONE); +} -{ - for (int i=0; i<(IterOut/4); i++) { - signed char *pIn0 = pI, *pIn1 = pIn0 + InFeat, - *pC0 = pC, *pC1 = pC0+InFeat, *pC2 = pC1+InFeat, *pC3 = pC2+InFeat; - pC+=4; - int S00 = (*pBias)< ACT_SWITCH defined in CNN_BasicKernels_SQ8.h + */ +static inline void __attribute__((always_inline)) KerPar_MM_Conv1x1_HWC_SQ8_act( + Ker_MM_Conv_SQ8_T *Arg, + CNN_ActivationOper_T Activation ) { @@ -251,6 +236,9 @@ void KerPar_MM_Conv1x1_HWC_SQ8( unsigned char * __restrict__ ScaleN = Arg->ScaleN; int Wo = Arg->Wo, Ho = Arg->Ho; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); unsigned int CoreId = gap_coreid(); unsigned int ChunkCell = ChunkSize(OutFeat), First = CoreId*ChunkCell, Last = Min(OutFeat, First+ChunkCell); @@ -294,17 +282,25 @@ void KerPar_MM_Conv1x1_HWC_SQ8( } unsigned int Sc, ScN; Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = gap_clip(AT_SCALE(S00, Sc, ScN), 7); pOut0++; - *pOut1 = gap_clip(AT_SCALE(S01, Sc, ScN), 7); pOut1++; - Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = gap_clip(AT_SCALE(S10, Sc, ScN), 7); pOut0++; - *pOut1 = gap_clip(AT_SCALE(S11, Sc, ScN), 7); pOut1++; - Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = gap_clip(AT_SCALE(S20, Sc, ScN), 7); pOut0++; - *pOut1 = gap_clip(AT_SCALE(S21, Sc, ScN), 7); pOut1++; - Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = gap_clip(AT_SCALE(S30, Sc, ScN), 7); pOut0++; - *pOut1 = gap_clip(AT_SCALE(S31, Sc, ScN), 7); pOut1++; + S00 = AT_SCALE(S00, Sc, ScN); ACT_SWITCH(S00, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S01 = AT_SCALE(S01, Sc, ScN); ACT_SWITCH(S01, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S00, 7); pOut0++; + *pOut1 = gap_clip(S01, 7); pOut1++; + Sc = *pSc; ScN = *pScN; pSc++; pScN++; + S10 = AT_SCALE(S10, Sc, ScN); ACT_SWITCH(S10, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S11 = AT_SCALE(S11, Sc, ScN); ACT_SWITCH(S11, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S10, 7); pOut0++; + *pOut1 = gap_clip(S11, 7); pOut1++; + Sc = *pSc; ScN = *pScN; pSc++; pScN++; + S20 = AT_SCALE(S20, Sc, ScN); ACT_SWITCH(S20, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S21 = AT_SCALE(S21, Sc, ScN); ACT_SWITCH(S21, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S20, 7); pOut0++; + *pOut1 = gap_clip(S21, 7); pOut1++; + Sc = *pSc; ScN = *pScN; pSc++; pScN++; + S30 = AT_SCALE(S30, Sc, ScN); ACT_SWITCH(S30, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S31 = AT_SCALE(S31, Sc, ScN); ACT_SWITCH(S31, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S30, 7); pOut0++; + *pOut1 = gap_clip(S31, 7); pOut1++; } for (int i=4*(IterOut/4); iIn; - int W = Arg->W, H = Arg->H; - signed char *__restrict__ Filter = Arg->Filter; - int Sx = Arg->Sx, Sy = Arg->Sy; - unsigned int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; +void KerPar_MM_Conv1x1_ReLUN_HWC_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1x1_HWC_SQ8_act(Arg, ACT_RELUN); +} - int * __restrict__ Bias = Arg->Bias; - int NormBias = Arg->Infos[AT_INF_BIASN]; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; +void KerPar_MM_Conv1x1_ReLUM_HWC_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1x1_HWC_SQ8_act(Arg, ACT_RELUM); +} - int Wo = Arg->Wo, Ho = Arg->Ho; +void KerPar_MM_Conv1x1_ReLUMN_HWC_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1x1_HWC_SQ8_act(Arg, ACT_RELUMN); +} - unsigned int CoreId = gap_coreid(); - unsigned int ChunkCell = ChunkSize(OutFeat), First = CoreId*ChunkCell, Last = Min(OutFeat, First+ChunkCell); - int IterOut = Last - First; +void KerPar_MM_Conv1x1_LeakyReLU_HWC_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1x1_HWC_SQ8_act(Arg, ACT_LEAKYRELU); +} - int PosL = 0; - for (int l=0; l ACT_SWITCH defined in CNN_BasicKernels_SQ8.h + */ +static inline void __attribute__((always_inline)) Ker_MM_Conv1x1_HWC_SQ8_act( + Ker_MM_Conv_SQ8_T *Arg, + CNN_ActivationOper_T Activation ) { @@ -576,6 +463,9 @@ void Ker_MM_Conv1x1_HWC_SQ8( unsigned char * __restrict__ ScaleN = Arg->ScaleN; int Wo = Arg->Wo, Ho = Arg->Ho; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); unsigned int CoreId = gap_coreid(); unsigned int ChunkCell = ChunkSize(Ho), First = Min(Ho, CoreId*ChunkCell), Last = Min(Ho, First+ChunkCell); @@ -618,17 +508,25 @@ void Ker_MM_Conv1x1_HWC_SQ8( } unsigned int Sc, ScN; Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = gap_clip(AT_SCALE(S00, Sc, ScN), 7); pOut0++; - *pOut1 = gap_clip(AT_SCALE(S01, Sc, ScN), 7); pOut1++; - Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = gap_clip(AT_SCALE(S10, Sc, ScN), 7); pOut0++; - *pOut1 = gap_clip(AT_SCALE(S11, Sc, ScN), 7); pOut1++; - Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = gap_clip(AT_SCALE(S20, Sc, ScN), 7); pOut0++; - *pOut1 = gap_clip(AT_SCALE(S21, Sc, ScN), 7); pOut1++; - Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = gap_clip(AT_SCALE(S30, Sc, ScN), 7); pOut0++; - *pOut1 = gap_clip(AT_SCALE(S31, Sc, ScN), 7); pOut1++; + S00 = AT_SCALE(S00, Sc, ScN); ACT_SWITCH(S00, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S01 = AT_SCALE(S01, Sc, ScN); ACT_SWITCH(S01, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S00, 7); pOut0++; + *pOut1 = gap_clip(S01, 7); pOut1++; + Sc = *pSc; ScN = *pScN; pSc++; pScN++; + S10 = AT_SCALE(S10, Sc, ScN); ACT_SWITCH(S10, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S11 = AT_SCALE(S11, Sc, ScN); ACT_SWITCH(S11, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S10, 7); pOut0++; + *pOut1 = gap_clip(S11, 7); pOut1++; + Sc = *pSc; ScN = *pScN; pSc++; pScN++; + S20 = AT_SCALE(S20, Sc, ScN); ACT_SWITCH(S20, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S21 = AT_SCALE(S21, Sc, ScN); ACT_SWITCH(S21, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S20, 7); pOut0++; + *pOut1 = gap_clip(S21, 7); pOut1++; + Sc = *pSc; ScN = *pScN; pSc++; pScN++; + S30 = AT_SCALE(S30, Sc, ScN); ACT_SWITCH(S30, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S31 = AT_SCALE(S31, Sc, ScN); ACT_SWITCH(S31, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S30, 7); pOut0++; + *pOut1 = gap_clip(S31, 7); pOut1++; } for (int i=4*(OutFeat/4); i ACT_SWITCH defined in CNN_BasicKernels_SQ8.h + */ +static inline void __attribute__((always_inline)) KerPar_MM_Conv1D_HWC_SQ8_act( + Ker_MM_Conv_SQ8_T *Arg, + CNN_ActivationOper_T Activation ) { @@ -726,184 +676,27 @@ void Ker_MM_Conv1x1_ReLU_HWC_SQ8( signed char *__restrict__ In = Arg->In; int W = Arg->W, H = Arg->H; signed char *__restrict__ Filter = Arg->Filter; - int Sx = Arg->Sx, Sy = Arg->Sy; - unsigned int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; + int Fx = Arg->Fx, Sx = Arg->Sx, Sy = Arg->Sy; + int PadL = Arg->Pad[0]; + int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; int * __restrict__ Bias = Arg->Bias; int NormBias = Arg->Infos[AT_INF_BIASN]; signed char * __restrict__ Out = Arg->Out; unsigned char * __restrict__ Scale = Arg->Scale; unsigned char * __restrict__ ScaleN = Arg->ScaleN; + signed char * __restrict__ ColBuff = Arg->ColBuff; int Wo = Arg->Wo, Ho = Arg->Ho; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); - unsigned int CoreId = gap_coreid(); - unsigned int ChunkCell = ChunkSize(Ho), First = Min(Ho, CoreId*ChunkCell), Last = Min(Ho, First+ChunkCell); - int IterOut = Last - First; - - for (int l=First; lIn; - int W = Arg->W, H = Arg->H; - signed char *__restrict__ Filter = Arg->Filter; - int Fx = Arg->Fx, Sx = Arg->Sx, Sy = Arg->Sy; - int PadL = Arg->Pad[0]; - int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; - - int * __restrict__ Bias = Arg->Bias; - int NormBias = Arg->Infos[AT_INF_BIASN]; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - signed char * __restrict__ ColBuff = Arg->ColBuff; - - int Wo = Arg->Wo, Ho = Arg->Ho; - - /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ - v4s * __restrict__ VBuff = (v4s *) ColBuff; - unsigned int W_In1 = InFeat*Fx; - unsigned int CoreId = gap_coreid(), C = ChunkSize(InFeat), F = Min(CoreId*C, InFeat), L = Min(InFeat, F+C); - unsigned int ChunkCell = ChunkSize(OutFeat), First = CoreId*ChunkCell, Last = Min(OutFeat, First+ChunkCell); + /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ + v4s * __restrict__ VBuff = (v4s *) ColBuff; + unsigned int W_In1 = InFeat*Fx; + unsigned int CoreId = gap_coreid(), C = ChunkSize(InFeat), F = Min(CoreId*C, InFeat), L = Min(InFeat, F+C); + unsigned int ChunkCell = ChunkSize(OutFeat), First = CoreId*ChunkCell, Last = Min(OutFeat, First+ChunkCell); int Tail = 2*((W_In1+7)/8); signed char * __restrict__ ColBuff1 = ColBuff + 4*Tail; @@ -992,10 +785,16 @@ void KerPar_MM_Conv1D_HWC_SQ8( S3 += V0*C3; S7 += V1*C3; pIn++; pIn1++; pC0++; pC1++; pC2++; pC3++; } - v4s R1 = gap_pack4(gap_clip(AT_SCALE(S0, pSc[4*Line ], pScN[4*Line ]), 7), gap_clip(AT_SCALE(S1, pSc[4*Line+1], pScN[4*Line+1]), 7), - gap_clip(AT_SCALE(S2, pSc[4*Line+2], pScN[4*Line+2]), 7), gap_clip(AT_SCALE(S3, pSc[4*Line+3], pScN[4*Line+3]), 7)); - v4s R2 = gap_pack4(gap_clip(AT_SCALE(S4, pSc[4*Line ], pScN[4*Line ]), 7), gap_clip(AT_SCALE(S5, pSc[4*Line+1], pScN[4*Line+1]), 7), - gap_clip(AT_SCALE(S6, pSc[4*Line+2], pScN[4*Line+2]), 7), gap_clip(AT_SCALE(S7, pSc[4*Line+3], pScN[4*Line+3]), 7)); + S0 = AT_SCALE(S0, pSc[4*Line ], pScN[4*Line ]); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S1 = AT_SCALE(S1, pSc[4*Line+1], pScN[4*Line+1]); ACT_SWITCH(S1, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S2 = AT_SCALE(S2, pSc[4*Line+2], pScN[4*Line+2]); ACT_SWITCH(S2, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S3 = AT_SCALE(S3, pSc[4*Line+3], pScN[4*Line+3]); ACT_SWITCH(S3, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S4 = AT_SCALE(S4, pSc[4*Line ], pScN[4*Line ]); ACT_SWITCH(S4, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S5 = AT_SCALE(S5, pSc[4*Line+1], pScN[4*Line+1]); ACT_SWITCH(S5, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S6 = AT_SCALE(S6, pSc[4*Line+2], pScN[4*Line+2]); ACT_SWITCH(S6, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S7 = AT_SCALE(S7, pSc[4*Line+3], pScN[4*Line+3]); ACT_SWITCH(S7, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + v4s R1 = gap_pack4(gap_clip(S0, 7), gap_clip(S1, 7), gap_clip(S2, 7), gap_clip(S3, 7)); + v4s R2 = gap_pack4(gap_clip(S4, 7), gap_clip(S5, 7), gap_clip(S6, 7), gap_clip(S7, 7)); *((v4s *) (pOut0+4*Line)) = R1; *((v4s *) (pOut1+4*Line)) = R2; } @@ -1013,8 +812,10 @@ void KerPar_MM_Conv1D_HWC_SQ8( S0 += V0*C0; S4 += V1*C0; pIn++; pIn1++; pC++; } - *(pOut0+i) = gap_clip(AT_SCALE(S0, pSc[i], pScN[i]), 7); - *(pOut1+i) = gap_clip(AT_SCALE(S4, pSc[i], pScN[i]), 7); + S0 = AT_SCALE(S0, pSc[i], pScN[i]); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S4 = AT_SCALE(S4, pSc[i], pScN[i]); ACT_SWITCH(S4, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *(pOut0+i) = gap_clip(S0, 7); + *(pOut1+i) = gap_clip(S4, 7); } gap_waitbarrier(0); } @@ -1068,8 +869,11 @@ void KerPar_MM_Conv1D_HWC_SQ8( S3 += V0*C3; pIn++; pC0++; pC1++; pC2++; pC3++; } - v4s R1 = gap_pack4(gap_clip(AT_SCALE(S0, pSc[4*Line ], pScN[4*Line ]), 7), gap_clip(AT_SCALE(S1, pSc[4*Line+1], pScN[4*Line+1]), 7), - gap_clip(AT_SCALE(S2, pSc[4*Line+2], pScN[4*Line+2]), 7), gap_clip(AT_SCALE(S3, pSc[4*Line+3], pScN[4*Line+3]), 7)); + S0 = AT_SCALE(S0, pSc[4*Line ], pScN[4*Line ]); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S1 = AT_SCALE(S1, pSc[4*Line+1], pScN[4*Line+1]); ACT_SWITCH(S1, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S2 = AT_SCALE(S2, pSc[4*Line+2], pScN[4*Line+2]); ACT_SWITCH(S2, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S3 = AT_SCALE(S3, pSc[4*Line+3], pScN[4*Line+3]); ACT_SWITCH(S3, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + v4s R1 = gap_pack4(gap_clip(S0, 7), gap_clip(S1, 7), gap_clip(S2, 7), gap_clip(S3, 7)); *((v4s *) (pOut0+4*Line)) = R1; } for (int i=4*(IterOut/4); i ACT_SWITCH defined in CNN_BasicKernels_SQ8.h + */ +static inline void __attribute__((always_inline)) KerPar_MM_Conv1D_DxDy_SQ8_act( + Ker_MM_Conv_SQ8_T *Arg, + CNN_ActivationOper_T Activation ) { @@ -1113,6 +964,9 @@ void KerPar_MM_Conv1D_DxDy_SQ8( signed char * __restrict__ ColBuff = Arg->ColBuff; int Wo = Arg->Wo, Ho = Arg->Ho; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ v4s * __restrict__ VBuff = (v4s *) ColBuff; @@ -1157,7 +1011,8 @@ void KerPar_MM_Conv1D_DxDy_SQ8( S0 = gap_sumdotp4(V1, C1, S0); } unsigned int Sc = Scale[Line], ScN = ScaleN[Line]; - Out[Line*Wo*Ho + l*Wo + c] = gap_clip(AT_SCALE(S0, Sc, ScN), 7); + S0 = AT_SCALE(S0, Sc, ScN); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + Out[Line*Wo*Ho + l*Wo + c] = gap_clip(S0, 7); } gap_waitbarrier(0); } @@ -1165,8 +1020,54 @@ void KerPar_MM_Conv1D_DxDy_SQ8( } } -void KerPar_MM_Conv1D_DxDy_HWC_SQ8( - Ker_MM_Conv_SQ8_T *Arg +void KerPar_MM_Conv1D_DxDy_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_DxDy_SQ8_act(Arg, ACT_NONE); +} + +void KerPar_MM_Conv1D_DxDy_ReLU_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_DxDy_SQ8_act(Arg, ACT_RELU); +} + +void KerPar_MM_Conv1D_DxDy_ReLUN_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_DxDy_SQ8_act(Arg, ACT_RELUN); +} + +void KerPar_MM_Conv1D_DxDy_ReLUM_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_DxDy_SQ8_act(Arg, ACT_RELUM); +} + +void KerPar_MM_Conv1D_DxDy_ReLUMN_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_DxDy_SQ8_act(Arg, ACT_RELUMN); +} + +void KerPar_MM_Conv1D_DxDy_LeakyReLU_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_DxDy_SQ8_act(Arg, ACT_LEAKYRELU); +} + +void KerPar_MM_Conv1D_DxDy_HSwish_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_DxDy_SQ8_act(Arg, ACT_HSWISH); +} + +void KerPar_MM_Conv1D_DxDy_HSigmoid_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_DxDy_SQ8_act(Arg, ACT_HSIGMOID); +} + +void KerPar_MM_Conv1D_DxDy_Sigmoid_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_DxDy_SQ8_act(Arg, ACT_SIGMOID); +} + +void KerPar_MM_Conv1D_DxDy_Tanh_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_DxDy_SQ8_act(Arg, ACT_TANH); +} + + +/* + * 1D Convolutional Kernels with Dilation kernels based on MatMul (im2col: ColBuff) with HWC inout tensor order + * Optional Activation fused applied to the 32bits accumulator -> ACT_SWITCH defined in CNN_BasicKernels_SQ8.h + */ +static inline void __attribute__((always_inline)) KerPar_MM_Conv1D_DxDy_HWC_SQ8_act( + Ker_MM_Conv_SQ8_T *Arg, + CNN_ActivationOper_T Activation ) { @@ -1189,6 +1090,10 @@ void KerPar_MM_Conv1D_DxDy_HWC_SQ8( int Wo = Arg->Wo, Ho = Arg->Ho; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); + /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ v4s * __restrict__ VBuff = (v4s *) ColBuff; unsigned int W_In1 = InFeat*Fx; @@ -1306,10 +1211,16 @@ void KerPar_MM_Conv1D_DxDy_HWC_SQ8( S3 += V0*C3; S7 += V1*C3; pIn++; pIn1++; pC0++; pC1++; pC2++; pC3++; } - v4s R1 = gap_pack4(gap_clip(AT_SCALE(S0, pSc[4*Line ], pScN[4*Line ]), 7), gap_clip(AT_SCALE(S1, pSc[4*Line+1], pScN[4*Line+1]), 7), - gap_clip(AT_SCALE(S2, pSc[4*Line+2], pScN[4*Line+2]), 7), gap_clip(AT_SCALE(S3, pSc[4*Line+3], pScN[4*Line+3]), 7)); - v4s R2 = gap_pack4(gap_clip(AT_SCALE(S4, pSc[4*Line ], pScN[4*Line ]), 7), gap_clip(AT_SCALE(S5, pSc[4*Line+1], pScN[4*Line+1]), 7), - gap_clip(AT_SCALE(S6, pSc[4*Line+2], pScN[4*Line+2]), 7), gap_clip(AT_SCALE(S7, pSc[4*Line+3], pScN[4*Line+3]), 7)); + S0 = AT_SCALE(S0, pSc[4*Line ], pScN[4*Line ]); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S1 = AT_SCALE(S1, pSc[4*Line+1], pScN[4*Line+1]); ACT_SWITCH(S1, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S2 = AT_SCALE(S2, pSc[4*Line+2], pScN[4*Line+2]); ACT_SWITCH(S2, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S3 = AT_SCALE(S3, pSc[4*Line+3], pScN[4*Line+3]); ACT_SWITCH(S3, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S4 = AT_SCALE(S4, pSc[4*Line ], pScN[4*Line ]); ACT_SWITCH(S4, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S5 = AT_SCALE(S5, pSc[4*Line+1], pScN[4*Line+1]); ACT_SWITCH(S5, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S6 = AT_SCALE(S6, pSc[4*Line+2], pScN[4*Line+2]); ACT_SWITCH(S6, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S7 = AT_SCALE(S7, pSc[4*Line+3], pScN[4*Line+3]); ACT_SWITCH(S7, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + v4s R1 = gap_pack4(gap_clip(S0, 7), gap_clip(S1, 7), gap_clip(S2, 7), gap_clip(S3, 7)); + v4s R2 = gap_pack4(gap_clip(S4, 7), gap_clip(S5, 7), gap_clip(S6, 7), gap_clip(S7, 7)); *((v4s *) (pOut0+4*Line)) = R1; *((v4s *) (pOut1+4*Line)) = R2; } @@ -1327,8 +1238,10 @@ void KerPar_MM_Conv1D_DxDy_HWC_SQ8( S0 += V0*C0; S4 += V1*C0; pIn++; pIn1++; pC++; } - *(pOut0+i) = gap_clip(AT_SCALE(S0, pSc[i], pScN[i]), 7); - *(pOut1+i) = gap_clip(AT_SCALE(S4, pSc[i], pScN[i]), 7); + S0 = AT_SCALE(S0, pSc[i], pScN[i]); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S4 = AT_SCALE(S4, pSc[i], pScN[i]); ACT_SWITCH(S4, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *(pOut0+i) = gap_clip(S0, 7); + *(pOut1+i) = gap_clip(S4, 7); } gap_waitbarrier(0); } @@ -1393,8 +1306,11 @@ void KerPar_MM_Conv1D_DxDy_HWC_SQ8( S3 += V0*C3; pIn++; pC0++; pC1++; pC2++; pC3++; } - v4s R1 = gap_pack4(gap_clip(AT_SCALE(S0, pSc[4*Line ], pScN[4*Line ]), 7), gap_clip(AT_SCALE(S1, pSc[4*Line+1], pScN[4*Line+1]), 7), - gap_clip(AT_SCALE(S2, pSc[4*Line+2], pScN[4*Line+2]), 7), gap_clip(AT_SCALE(S3, pSc[4*Line+3], pScN[4*Line+3]), 7)); + S0 = AT_SCALE(S0, pSc[4*Line ], pScN[4*Line ]); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S1 = AT_SCALE(S1, pSc[4*Line+1], pScN[4*Line+1]); ACT_SWITCH(S1, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S2 = AT_SCALE(S2, pSc[4*Line+2], pScN[4*Line+2]); ACT_SWITCH(S2, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S3 = AT_SCALE(S3, pSc[4*Line+3], pScN[4*Line+3]); ACT_SWITCH(S3, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + v4s R1 = gap_pack4(gap_clip(S0, 7), gap_clip(S1, 7), gap_clip(S2, 7), gap_clip(S3, 7)); *((v4s *) (pOut0+4*Line)) = R1; } for (int i=4*(IterOut/4); iIn; - int W = Arg->W, H = Arg->H; - signed char *__restrict__ Filter = Arg->Filter; - int Fx = Arg->Fx, Sx = Arg->Sx, Sy = Arg->Sy, Dx = Arg->Dx; - int PadL = Arg->Pad[0]; - int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; +void KerPar_MM_Conv1D_DxDy_ReLU_HWC_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_DxDy_HWC_SQ8_act(Arg, ACT_RELU); +} - int * __restrict__ Bias = Arg->Bias; - int NormBias = Arg->Infos[AT_INF_BIASN]; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - signed char * __restrict__ ColBuff = Arg->ColBuff; +void KerPar_MM_Conv1D_DxDy_ReLUN_HWC_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_DxDy_HWC_SQ8_act(Arg, ACT_RELUN); +} - int Wo = Arg->Wo, Ho = Arg->Ho; +void KerPar_MM_Conv1D_DxDy_ReLUM_HWC_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_DxDy_HWC_SQ8_act(Arg, ACT_RELUM); +} - /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ - v4s * __restrict__ VBuff = (v4s *) ColBuff; - unsigned int W_In1 = InFeat*Fx; - unsigned int CoreId = gap_coreid(), C = ChunkSize(InFeat), F = Min(CoreId*C, InFeat), L = Min(InFeat, F+C); - unsigned int ChunkCell = ChunkSize(OutFeat), First = CoreId*ChunkCell, Last = Min(OutFeat, First+ChunkCell); +void KerPar_MM_Conv1D_DxDy_ReLUMN_HWC_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv1D_DxDy_HWC_SQ8_act(Arg, ACT_RELUMN); +} - int Tail = 2*((W_In1+7)/8); - ((int *)ColBuff)[Tail-1] = 0; ((int *)ColBuff)[Tail-2] = 0; - - int DFx = Dx*(Fx-1)+1; - // int Prec=10; - int InvDx = ((1< ACT_SWITCH defined in CNN_BasicKernels_SQ8.h + */ +static inline void __attribute__((always_inline)) KerPar_MM_Conv2D_SQ8_act( + Ker_MM_Conv_SQ8_T *Arg, + CNN_ActivationOper_T Activation ) { signed char *__restrict__ In = Arg->In; int W = Arg->W, H = Arg->H; signed char *__restrict__ Filter = Arg->Filter; - int Fx = Arg->Fx, Sx = Arg->Sx, Sy = Arg->Sy; - int PadL = Arg->Pad[0]; + int Fx = Arg->Fx, Sx = Arg->Sx; + int Fy = Arg->Fy, Sy = Arg->Sy; + int PadL = Arg->Pad[0], PadT = Arg->Pad[2]; int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; int * __restrict__ Bias = Arg->Bias; int NormBias = Arg->Infos[AT_INF_BIASN]; @@ -1503,67 +1398,105 @@ void KerPar_MM_Conv1D_ReLU_SQ8( signed char * __restrict__ ColBuff = Arg->ColBuff; int Wo = Arg->Wo, Ho = Arg->Ho; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); + /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ v4s * __restrict__ VBuff = (v4s *) ColBuff; - unsigned int W_In1 = InFeat*Fx; + unsigned int W_In1 = InFeat*Fx*Fy; unsigned int CoreId = gap_coreid(), C = ChunkSize(InFeat), F = Min(CoreId*C, InFeat), L = Min(InFeat, F+C); unsigned int ChunkCell = ChunkSize(OutFeat), First = CoreId*ChunkCell, Last = Min(OutFeat, First+ChunkCell); + int FS = Fx*Fy; int Tail = 2*((W_In1+7)/8); ((int *)ColBuff)[Tail-1] = 0; ((int *)ColBuff)[Tail-2] = 0; - int PosL = 0; + int PosL = Arg->FirstTile?(-PadT):0; int Iter = L-F; - int Iter1 = Iter*Fx; + int Iter1 = Iter*FS; + + // printf("If: %3d, Of: %3d, W: %3d, H: %3d, Wo: %3d, Ho: %3d, PosL: %d\n", InFeat, OutFeat, W, H, Wo, Ho, PosL); for (int l=0; l4) { if (Size&0x2) { if (Size&0x1) { for (int f=F; f=2) { if (Size&0x4) { for (int f=F; f> %d = %d\n", Line, l, c, S0, Sc, ScN, gap_clip(AT_SCALE(S0, Sc, ScN), 7)); + S0 = AT_SCALE(S0, Sc, ScN); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + Out[Line*Wo*Ho + l*Wo + c] = gap_clip(S0, 7); } gap_waitbarrier(0); } PosL += Sy; } + gap_waitbarrier(0); } -void KerPar_MM_Conv1D_ReLUN_SQ8( - Ker_MM_Conv_SQ8_T *Arg - ) +void KerPar_MM_Conv2D_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_SQ8_act(Arg, ACT_NONE); +} -{ - signed char *__restrict__ In = Arg->In; - int W = Arg->W, H = Arg->H; - signed char *__restrict__ Filter = Arg->Filter; - int Fx = Arg->Fx, Sx = Arg->Sx, Sy = Arg->Sy; - int PadL = Arg->Pad[0]; - int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; - int * __restrict__ Bias = Arg->Bias; - int NormBias = Arg->Infos[AT_INF_BIASN]; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - signed char * __restrict__ ColBuff = Arg->ColBuff; - int Wo = Arg->Wo, Ho = Arg->Ho; - int A0 = Arg->Infos[AT_INF_A0]; +void KerPar_MM_Conv2D_ReLU_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_SQ8_act(Arg, ACT_RELU); +} - /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ - v4s * __restrict__ VBuff = (v4s *) ColBuff; - unsigned int W_In1 = InFeat*Fx; - unsigned int CoreId = gap_coreid(), C = ChunkSize(InFeat), F = Min(CoreId*C, InFeat), L = Min(InFeat, F+C); - unsigned int ChunkCell = ChunkSize(OutFeat), First = CoreId*ChunkCell, Last = Min(OutFeat, First+ChunkCell); +void KerPar_MM_Conv2D_ReLUN_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_SQ8_act(Arg, ACT_RELUN); +} - int Tail = 2*((W_In1+7)/8); - ((int *)ColBuff)[Tail-1] = 0; ((int *)ColBuff)[Tail-2] = 0; - int PosL = 0; - int Iter = L-F; - int Iter1 = Iter*Fx; - for (int l=0; l4) { - if (Size&0x2) { - if (Size&0x1) { - for (int f=F; f=2) { - if (Size&0x4) { - for (int f=F; f ACT_SWITCH defined in CNN_BasicKernels_SQ8.h + */ +static inline void __attribute__((always_inline)) KerPar_MM_Conv2D_HWC_SQ8_act( + Ker_MM_Conv_SQ8_T *Arg, + CNN_ActivationOper_T Activation) { + /* + For HWC weights (4D Tensor) are expected to be organized as [OutFeat x Fy x Fx x InFeat] + */ signed char *__restrict__ In = Arg->In; int W = Arg->W, H = Arg->H; signed char *__restrict__ Filter = Arg->Filter; - int Fx = Arg->Fx, Sx = Arg->Sx, Sy = Arg->Sy; - int PadL = Arg->Pad[0]; + int Fx = Arg->Fx, Sx = Arg->Sx; + int Fy = Arg->Fy, Sy = Arg->Sy; + int PadL = Arg->Pad[0], PadT = Arg->Pad[2]; int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; int * __restrict__ Bias = Arg->Bias; int NormBias = Arg->Infos[AT_INF_BIASN]; @@ -1693,1023 +1581,307 @@ void KerPar_MM_Conv1D_LeakyReLU_SQ8( unsigned char * __restrict__ ScaleN = Arg->ScaleN; signed char * __restrict__ ColBuff = Arg->ColBuff; int Wo = Arg->Wo, Ho = Arg->Ho; - int A0 = Arg->Infos[AT_INF_A0]; - unsigned int ActScale = ((unsigned char *)Arg->Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Arg->Infos)[AT_INF_ACTSCALEN]; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ v4s * __restrict__ VBuff = (v4s *) ColBuff; - unsigned int W_In1 = InFeat*Fx; - unsigned int CoreId = gap_coreid(), C = ChunkSize(InFeat), F = Min(CoreId*C, InFeat), L = Min(InFeat, F+C); - unsigned int ChunkCell = ChunkSize(OutFeat), First = CoreId*ChunkCell, Last = Min(OutFeat, First+ChunkCell); - - int Tail = 2*((W_In1+7)/8); - ((int *)ColBuff)[Tail-1] = 0; ((int *)ColBuff)[Tail-2] = 0; - int PosL = 0; - int Iter = L-F; - int Iter1 = Iter*Fx; - for (int l=0; l4) { - if (Size&0x2) { - if (Size&0x1) { - for (int f=F; f=2) { - if (Size&0x4) { - for (int f=F; fIn; - int W = Arg->W, H = Arg->H; - signed char *__restrict__ Filter = Arg->Filter; - int Fx = Arg->Fx, Sx = Arg->Sx; - int Fy = Arg->Fy, Sy = Arg->Sy; - int PadL = Arg->Pad[0], PadT = Arg->Pad[2]; - int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; - int * __restrict__ Bias = Arg->Bias; - int NormBias = Arg->Infos[AT_INF_BIASN]; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - signed char * __restrict__ ColBuff = Arg->ColBuff; - int Wo = Arg->Wo, Ho = Arg->Ho; - int A0 = Arg->Infos[AT_INF_A0]; - - /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ - v4s * __restrict__ VBuff = (v4s *) ColBuff; - unsigned int W_In1 = InFeat*Fx*Fy; - unsigned int CoreId = gap_coreid(), C = ChunkSize(InFeat), F = Min(CoreId*C, InFeat), L = Min(InFeat, F+C); - unsigned int ChunkCell = ChunkSize(OutFeat), First = CoreId*ChunkCell, Last = Min(OutFeat, First+ChunkCell); - - int FS = Fx*Fy; - int Tail = 2*((W_In1+7)/8); - ((int *)ColBuff)[Tail-1] = 0; ((int *)ColBuff)[Tail-2] = 0; - int PosL = Arg->FirstTile?(-PadT):0; - int Iter = L-F; - int Iter1 = Iter*FS; - - // printf("If: %3d, Of: %3d, W: %3d, H: %3d, Wo: %3d, Ho: %3d, PosL: %d\n", InFeat, OutFeat, W, H, Wo, Ho, PosL); - for (int l=0; l4) { - if (Size&0x2) { - if (Size&0x1) { - for (int f=F; f=2) { - if (Size&0x4) { - for (int f=F; f> %d = %d\n", Line, l, c, S0, Sc, ScN, gap_clip(AT_SCALE(S0, Sc, ScN), 7)); - Out[Line*Wo*Ho + l*Wo + c] = gap_clip(AT_SCALE(S0, Sc, ScN), 7); - } - gap_waitbarrier(0); - } - PosL += Sy; - } - gap_waitbarrier(0); -} - -void KerPar_MM_Conv2D_HWC_SQ8( - Ker_MM_Conv_SQ8_T *Arg - ) - -{ - /* - For HWC weights (4D Tensor) are expected to be organized as [OutFeat x Fy x Fx x InFeat] - */ - signed char *__restrict__ In = Arg->In; - int W = Arg->W, H = Arg->H; - signed char *__restrict__ Filter = Arg->Filter; - int Fx = Arg->Fx, Sx = Arg->Sx; - int Fy = Arg->Fy, Sy = Arg->Sy; - int PadL = Arg->Pad[0], PadT = Arg->Pad[2]; - int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; - int * __restrict__ Bias = Arg->Bias; - int NormBias = Arg->Infos[AT_INF_BIASN]; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - signed char * __restrict__ ColBuff = Arg->ColBuff; - int Wo = Arg->Wo, Ho = Arg->Ho; - int A0 = Arg->Infos[AT_INF_A0]; - - /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ - v4s * __restrict__ VBuff = (v4s *) ColBuff; - unsigned int W_In1 = InFeat*Fx*Fy; - unsigned int CoreId = gap_coreid(), C = ChunkSize(InFeat), F = Min(CoreId*C, InFeat), L = Min(InFeat, F+C); - unsigned int ChunkCell = ChunkSize(OutFeat), First = CoreId*ChunkCell, Last = Min(OutFeat, First+ChunkCell); - - int FS = Fx*Fy; - int Tail = 2*((W_In1+7)/8); - - signed char * __restrict__ ColBuff1 = ColBuff + 4*Tail; - ((int *)ColBuff)[Tail-1] = 0; ((int *)ColBuff)[Tail-2] = 0; - ((int *)ColBuff1)[Tail-1] = 0; ((int *)ColBuff1)[Tail-2] = 0; - int PosL = Arg->FirstTile?(-PadT):0; - - int Iter = L-F; - int Iter1 = Iter*FS; - int IterOut = Max(0, Last - First); - for (int l=0; l=4) { - for (int f=0; f<(Iter/4); f++) - for (int j=Tb; j=2) { - if (Iter&0x2) - for (int j=Tb; j0) { - for (int j=Tb; j=4) { - for (int f=0; f<(Iter/4); f++) - for (int j=Tb; j=2) { - if (Iter&0x2) - for (int j=Tb; j0) - for (int j=Tb; jIn; - int W = Arg->W, H = Arg->H; - signed char *__restrict__ Filter = Arg->Filter; - int Fx = Arg->Fx, Sx = Arg->Sx; - int Fy = Arg->Fy, Sy = Arg->Sy; - int PadL = Arg->Pad[0], PadT = Arg->Pad[2]; - int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; - int * __restrict__ Bias = Arg->Bias; - int NormBias = Arg->Infos[AT_INF_BIASN]; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - signed char * __restrict__ ColBuff = Arg->ColBuff; - int Wo = Arg->Wo, Ho = Arg->Ho; - int A0 = Arg->Infos[AT_INF_A0]; - - /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ - v4s * __restrict__ VBuff = (v4s *) ColBuff; - unsigned int W_In1 = InFeat*Fx*Fy; - unsigned int CoreId = gap_coreid(), C = ChunkSize(InFeat), F = Min(CoreId*C, InFeat), L = Min(InFeat, F+C); - unsigned int ChunkCell = ChunkSize(OutFeat), First = CoreId*ChunkCell, Last = Min(OutFeat, First+ChunkCell); - - int FS = Fx*Fy; - int Tail = 2*((W_In1+7)/8); - - signed char * __restrict__ ColBuff1 = ColBuff + 4*Tail; - ((int *)ColBuff)[Tail-1] = 0; ((int *)ColBuff)[Tail-2] = 0; - ((int *)ColBuff1)[Tail-1] = 0; ((int *)ColBuff1)[Tail-2] = 0; - int PosL = Arg->FirstTile?(-PadT):0; - - int Iter = L-F; - int Iter1 = Iter*FS; - int IterOut = Max(0, Last - First); - for (int l=0; l=4) { - for (int f=0; f<(Iter/4); f++) - for (int j=Tb; j=2) { - if (Iter&0x2) - for (int j=Tb; j0) { - for (int j=Tb; j=4) { - for (int f=0; f<(Iter/4); f++) - for (int j=Tb; j=2) { - if (Iter&0x2) - for (int j=Tb; j0) - for (int j=Tb; jIn; - int W = Arg->W, H = Arg->H; - signed char *__restrict__ Filter = Arg->Filter; - int Fx = Arg->Fx, Sx = Arg->Sx; - int Fy = Arg->Fy, Sy = Arg->Sy; - int PadL = Arg->Pad[0], PadT = Arg->Pad[2]; - int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; - int * __restrict__ Bias = Arg->Bias; - int NormBias = Arg->Infos[AT_INF_BIASN]; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - signed char * __restrict__ ColBuff = Arg->ColBuff; - signed char * __restrict__ ColBuff1; - int Wo = Arg->Wo, Ho = Arg->Ho; - int A0 = Arg->Infos[AT_INF_A0]; - - unsigned int W_In1 = InFeat*Fx*Fy; - unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(Wo), First = CoreId*ChunkCell, Last = Min(Wo, First+ChunkCell); + unsigned int CoreId = gap_coreid(), C = ChunkSize(InFeat), F = Min(CoreId*C, InFeat), L = Min(InFeat, F+C); + unsigned int ChunkCell = ChunkSize(OutFeat), First = CoreId*ChunkCell, Last = Min(OutFeat, First+ChunkCell); int FS = Fx*Fy; + int Tail = 2*((W_In1+7)/8); + + signed char * __restrict__ ColBuff1 = ColBuff + 4*Tail; + ((int *)ColBuff)[Tail-1] = 0; ((int *)ColBuff)[Tail-2] = 0; + ((int *)ColBuff1)[Tail-1] = 0; ((int *)ColBuff1)[Tail-2] = 0; int PosL = Arg->FirstTile?(-PadT):0; - int Iter = InFeat; + int Iter = L-F; int Iter1 = Iter*FS; - int IterOut = OutFeat; - int IterW = Max(0, Last-First); - ColBuff += 2*CoreId*InFeat*FS; - ColBuff1 = ColBuff + InFeat*FS; + int IterOut = Max(0, Last - First); for (int l=0; l=4) { for (int f=0; f<(Iter/4); f++) for (int j=Tb; j=2) { if (Iter&0x2) for (int j=Tb; j0) { for (int j=Tb; j=4) { for (int f=0; f<(Iter/4); f++) - for (int j=Tb; j=2) { if (Iter&0x2) - for (int j=Tb; j0) { - for (int j=Tb; j0) + for (int j=Tb; j Each Core has 2 im2col buffer + * Optional Activation fused applied to the 32bits accumulator -> ACT_SWITCH defined in CNN_BasicKernels_SQ8.h + */ +static inline void __attribute__((always_inline)) Ker_MM_Conv2D_HWC_SQ8_act( + Ker_MM_Conv_SQ8_T *Arg, + CNN_ActivationOper_T Activation ) { @@ -2731,7 +1903,9 @@ void Ker_MM_Conv2D_ReLU_HWC_SQ8( signed char * __restrict__ ColBuff = Arg->ColBuff; signed char * __restrict__ ColBuff1; int Wo = Arg->Wo, Ho = Arg->Ho; - int A0 = Arg->Infos[AT_INF_A0]; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); unsigned int W_In1 = InFeat*Fx*Fy; @@ -2848,17 +2022,25 @@ void Ker_MM_Conv2D_ReLU_HWC_SQ8( } unsigned int Sc, ScN; Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = AT_CLIP_POS_IMM(AT_SCALE(S00, Sc, ScN), 7); pOut0++; - *pOut1 = AT_CLIP_POS_IMM(AT_SCALE(S01, Sc, ScN), 7); pOut1++; - Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = AT_CLIP_POS_IMM(AT_SCALE(S10, Sc, ScN), 7); pOut0++; - *pOut1 = AT_CLIP_POS_IMM(AT_SCALE(S11, Sc, ScN), 7); pOut1++; - Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = AT_CLIP_POS_IMM(AT_SCALE(S20, Sc, ScN), 7); pOut0++; - *pOut1 = AT_CLIP_POS_IMM(AT_SCALE(S21, Sc, ScN), 7); pOut1++; - Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = AT_CLIP_POS_IMM(AT_SCALE(S30, Sc, ScN), 7); pOut0++; - *pOut1 = AT_CLIP_POS_IMM(AT_SCALE(S31, Sc, ScN), 7); pOut1++; + S00 = AT_SCALE(S00, Sc, ScN); ACT_SWITCH(S00, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S01 = AT_SCALE(S01, Sc, ScN); ACT_SWITCH(S01, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S00, 7); pOut0++; + *pOut1 = gap_clip(S01, 7); pOut1++; + Sc = *pSc; ScN = *pScN; pSc++; pScN++; + S10 = AT_SCALE(S10, Sc, ScN); ACT_SWITCH(S10, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S11 = AT_SCALE(S11, Sc, ScN); ACT_SWITCH(S11, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S10, 7); pOut0++; + *pOut1 = gap_clip(S11, 7); pOut1++; + Sc = *pSc; ScN = *pScN; pSc++; pScN++; + S20 = AT_SCALE(S20, Sc, ScN); ACT_SWITCH(S20, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S21 = AT_SCALE(S21, Sc, ScN); ACT_SWITCH(S21, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S20, 7); pOut0++; + *pOut1 = gap_clip(S21, 7); pOut1++; + Sc = *pSc; ScN = *pScN; pSc++; pScN++; + S30 = AT_SCALE(S30, Sc, ScN); ACT_SWITCH(S30, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S31 = AT_SCALE(S31, Sc, ScN); ACT_SWITCH(S31, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S30, 7); pOut0++; + *pOut1 = gap_clip(S31, 7); pOut1++; } for (int Line=4*(IterOut/4); Line ACT_SWITCH defined in CNN_BasicKernels_SQ8.h + */ +static inline void __attribute__((always_inline)) KerPar_MM_Conv2D_DxDy_SQ8_act( + Ker_MM_Conv_SQ8_T *Arg, + CNN_ActivationOper_T Activation ) { @@ -3005,7 +2239,9 @@ void KerPar_MM_Conv2D_DxDy_SQ8( unsigned char * __restrict__ ScaleN = Arg->ScaleN; signed char * __restrict__ ColBuff = Arg->ColBuff; int Wo = Arg->Wo, Ho = Arg->Ho; - int A0 = Arg->Infos[AT_INF_A0]; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ v4s * __restrict__ VBuff = (v4s *) ColBuff; @@ -3057,7 +2293,8 @@ void KerPar_MM_Conv2D_DxDy_SQ8( S0 = gap_sumdotp4(V1, C1, S0); } unsigned int Sc = Scale[Line], ScN = ScaleN[Line]; - Out[Line*Wo*Ho + l*Wo + c] = gap_clip(AT_SCALE(S0, Sc, ScN), 7); + S0 = AT_SCALE(S0, Sc, ScN); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + Out[Line*Wo*Ho + l*Wo + c] = gap_clip(S0, 7); } gap_waitbarrier(0); } @@ -3066,8 +2303,54 @@ void KerPar_MM_Conv2D_DxDy_SQ8( gap_waitbarrier(0); } -void KerPar_MM_Conv2D_DxDy_HWC_SQ8( - Ker_MM_Conv_SQ8_T *Arg +void KerPar_MM_Conv2D_DxDy_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_SQ8_act(Arg, ACT_NONE); +} + +void KerPar_MM_Conv2D_DxDy_ReLU_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_SQ8_act(Arg, ACT_RELU); +} + +void KerPar_MM_Conv2D_DxDy_ReLUN_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_SQ8_act(Arg, ACT_RELUN); +} + +void KerPar_MM_Conv2D_DxDy_ReLUM_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_SQ8_act(Arg, ACT_RELUM); +} + +void KerPar_MM_Conv2D_DxDy_ReLUMN_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_SQ8_act(Arg, ACT_RELUMN); +} + +void KerPar_MM_Conv2D_DxDy_LeakyReLU_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_SQ8_act(Arg, ACT_LEAKYRELU); +} + +void KerPar_MM_Conv2D_DxDy_HSwish_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_SQ8_act(Arg, ACT_HSWISH); +} + +void KerPar_MM_Conv2D_DxDy_HSigmoid_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_SQ8_act(Arg, ACT_HSIGMOID); +} + +void KerPar_MM_Conv2D_DxDy_Sigmoid_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_SQ8_act(Arg, ACT_SIGMOID); +} + +void KerPar_MM_Conv2D_DxDy_Tanh_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_SQ8_act(Arg, ACT_TANH); +} + + +/* + * 2D Convolutional Kernels with Dilation kernels based on MatMul (im2col: ColBuff) with HWC inout tensor order + * Optional Activation fused applied to the 32bits accumulator -> ACT_SWITCH defined in CNN_BasicKernels_SQ8.h + */ +static inline void __attribute__((always_inline)) KerPar_MM_Conv2D_DxDy_HWC_SQ8_act( + Ker_MM_Conv_SQ8_T *Arg, + CNN_ActivationOper_T Activation ) { @@ -3088,7 +2371,9 @@ void KerPar_MM_Conv2D_DxDy_HWC_SQ8( unsigned char * __restrict__ ScaleN = Arg->ScaleN; signed char * __restrict__ ColBuff = Arg->ColBuff; int Wo = Arg->Wo, Ho = Arg->Ho; - int A0 = Arg->Infos[AT_INF_A0]; + unsigned char * Infos = (unsigned char *) Arg->Infos; + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; + int A0 = *((unsigned char *) &Infos[AT_INF_A0]); int B0 = *((unsigned char *) &Infos[AT_INF_B0]); int C0 = *((unsigned char *) &Infos[AT_INF_C0]); /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ v4s * __restrict__ VBuff = (v4s *) ColBuff; @@ -3206,10 +2491,16 @@ This part is more efficient but NOT WORKING ???? TOCHECK S3 += V0*C3; S7 += V1*C3; pIn++; pIn1++; pC0++; pC1++; pC2++; pC3++; } - v4s R1 = gap_pack4(gap_clip(AT_SCALE(S0, pSc[4*Line ], pScN[4*Line ]), 7), gap_clip(AT_SCALE(S1, pSc[4*Line+1], pScN[4*Line+1]), 7), - gap_clip(AT_SCALE(S2, pSc[4*Line+2], pScN[4*Line+2]), 7), gap_clip(AT_SCALE(S3, pSc[4*Line+3], pScN[4*Line+3]), 7)); - v4s R2 = gap_pack4(gap_clip(AT_SCALE(S4, pSc[4*Line ], pScN[4*Line ]), 7), gap_clip(AT_SCALE(S5, pSc[4*Line+1], pScN[4*Line+1]), 7), - gap_clip(AT_SCALE(S6, pSc[4*Line+2], pScN[4*Line+2]), 7), gap_clip(AT_SCALE(S7, pSc[4*Line+3], pScN[4*Line+3]), 7)); + S0 = AT_SCALE(S0, pSc[4*Line ], pScN[4*Line ]); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S1 = AT_SCALE(S1, pSc[4*Line+1], pScN[4*Line+1]); ACT_SWITCH(S1, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S2 = AT_SCALE(S2, pSc[4*Line+2], pScN[4*Line+2]); ACT_SWITCH(S2, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S3 = AT_SCALE(S3, pSc[4*Line+3], pScN[4*Line+3]); ACT_SWITCH(S3, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S4 = AT_SCALE(S4, pSc[4*Line ], pScN[4*Line ]); ACT_SWITCH(S4, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S5 = AT_SCALE(S5, pSc[4*Line+1], pScN[4*Line+1]); ACT_SWITCH(S5, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S6 = AT_SCALE(S6, pSc[4*Line+2], pScN[4*Line+2]); ACT_SWITCH(S6, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S7 = AT_SCALE(S7, pSc[4*Line+3], pScN[4*Line+3]); ACT_SWITCH(S7, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + v4s R1 = gap_pack4(gap_clip(S0, 7), gap_clip(S1, 7), gap_clip(S2, 7), gap_clip(S3, 7)); + v4s R2 = gap_pack4(gap_clip(S4, 7), gap_clip(S5, 7), gap_clip(S6, 7), gap_clip(S7, 7)); *((v4s *) (pOut0+4*Line)) = R1; *((v4s *) (pOut1+4*Line)) = R2; } @@ -3227,8 +2518,10 @@ This part is more efficient but NOT WORKING ???? TOCHECK S0 += V0*C0; S4 += V1*C0; pIn++; pIn1++; pC++; } - *(pOut0+i) = gap_clip(AT_SCALE(S0, pSc[i], pScN[i]), 7); - *(pOut1+i) = gap_clip(AT_SCALE(S4, pSc[i], pScN[i]), 7); + S0 = AT_SCALE(S0, pSc[i], pScN[i]); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + S4 = AT_SCALE(S4, pSc[i], pScN[i]); ACT_SWITCH(S4, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *(pOut0+i) = gap_clip(S0, 7); + *(pOut1+i) = gap_clip(S4, 7); } gap_waitbarrier(0); } @@ -3278,13 +2571,17 @@ This part is more efficient but NOT WORKING ???? TOCHECK } unsigned int Sc, ScN; Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = gap_clip(AT_SCALE(S0, Sc, ScN), 7); pOut0++; + S0 = AT_SCALE(S0, Sc, ScN); ACT_SWITCH(S0, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S0, 7); pOut0++; Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = gap_clip(AT_SCALE(S1, Sc, ScN), 7); pOut0++; + S1 = AT_SCALE(S1, Sc, ScN); ACT_SWITCH(S1, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S1, 7); pOut0++; Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = gap_clip(AT_SCALE(S2, Sc, ScN), 7); pOut0++; + S2 = AT_SCALE(S2, Sc, ScN); ACT_SWITCH(S2, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S2, 7); pOut0++; Sc = *pSc; ScN = *pScN; pSc++; pScN++; - *pOut0 = gap_clip(AT_SCALE(S3, Sc, ScN), 7); pOut0++; + S3 = AT_SCALE(S3, Sc, ScN); ACT_SWITCH(S3, Activation, ActScale, ActScaleN, A0, B0, C0, 0, 0); + *pOut0 = gap_clip(S3, 7); pOut0++; } for (int i=4*(IterOut/4); iIn; - int W = Arg->W, H = Arg->H; - signed char *__restrict__ Filter = Arg->Filter; - int Fx = Arg->Fx, Sx = Arg->Sx, Dx = Arg->Dx; - int Fy = Arg->Fy, Sy = Arg->Sy, Dy = Arg->Dy; - int PadL = Arg->Pad[0], PadT = Arg->Pad[2]; - int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; - int * __restrict__ Bias = Arg->Bias; - int NormBias = Arg->Infos[AT_INF_BIASN]; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - signed char * __restrict__ ColBuff = Arg->ColBuff; - int Wo = Arg->Wo, Ho = Arg->Ho; - int A0 = Arg->Infos[AT_INF_A0]; - - /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ - v4s * __restrict__ VBuff = (v4s *) ColBuff; - unsigned int W_In1 = InFeat*Fx*Fy; - unsigned int CoreId = gap_coreid(), C = ChunkSize(InFeat), F = Min(CoreId*C, InFeat), L = Min(InFeat, F+C); - unsigned int ChunkCell = ChunkSize(OutFeat), First = CoreId*ChunkCell, Last = Min(OutFeat, First+ChunkCell); - - int FS = Fx*Fy; - int Tail = 2*((W_In1+7)/8); - ((int *)ColBuff)[Tail-1] = 0; ((int *)ColBuff)[Tail-2] = 0; - int PosL = Arg->FirstTile?(-PadT):0; - int DFx = Dx*(Fx-1)+1, DFy = Dy*(Fy-1)+1; - // int Prec=10; - int InvDx = ((1<In; - int W = Arg->W, H = Arg->H; - signed char *__restrict__ Filter = Arg->Filter; - int Fx = Arg->Fx, Sx = Arg->Sx, Sy = Arg->Sy; - int PadL = Arg->Pad[0]; - int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; - - int * __restrict__ Bias = Arg->Bias; - int NormBias = Arg->Infos[AT_INF_BIASN]; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - signed char * __restrict__ ColBuff = Arg->ColBuff; - - int Wo = Arg->Wo, Ho = Arg->Ho; +void KerPar_MM_Conv2D_DxDy_ReLU_HWC_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_HWC_SQ8_act(Arg, ACT_RELU); +} - /* ColBuff must be large enough to accomodate ((((InFeat/NCores)+3)/4)*4)*8 elements */ - v4s * __restrict__ VBuff = (v4s *) ColBuff; - unsigned int CoreId = gap_coreid(), C = ChunkSize(InFeat), F = Min(CoreId*C, InFeat), L = Min(InFeat, F+C); - v4s M0 = (v4s){-1,0,0,0}, M1 = (v4s){0,-1,0,0}, M2 = (v4s){0,0,-1,0}, M3 = (v4s){0,0,0,-1}; +void KerPar_MM_Conv2D_DxDy_ReLUN_HWC_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_HWC_SQ8_act(Arg, ACT_RELUN); +} - int PosL = 0; - int Iter = L-F; - for (int l=0; l=4) { - for (int f=0; f<(Iter/4); f++) - for (int i=Lb; i=2) { - if (Iter&0x2) for (int i=Lb; i0) - for (int i=Lb; i fx*Infeat + f */ - for (int f=0; f<(Iter/4); f++) { - v4s B = ((v4s *)(Bias + F))[f]; - int S0 = B[0], S1 = B[1], S2 = B[2], S3 = B[3]; - for (int i=0; iIn; - int W = Arg->W, H = Arg->H; - signed char *__restrict__ Filter = Arg->Filter; - int Fx = Arg->Fx, Sx = Arg->Sx; - int Fy = Arg->Fy, Sy = Arg->Sy; - int PadL = Arg->Pad[0], PadT = Arg->Pad[2]; - int InFeat = Arg->InFeat, OutFeat = Arg->OutFeat; - int * __restrict__ Bias = Arg->Bias; - int NormBias = Arg->Infos[AT_INF_BIASN]; - signed char * __restrict__ Out = Arg->Out; - unsigned char * __restrict__ Scale = Arg->Scale; - unsigned char * __restrict__ ScaleN = Arg->ScaleN; - signed char * __restrict__ ColBuff = Arg->ColBuff; - int Wo = Arg->Wo, Ho = Arg->Ho; - int A0 = Arg->Infos[AT_INF_A0]; +void KerPar_MM_Conv2D_DxDy_LeakyReLU_HWC_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_HWC_SQ8_act(Arg, ACT_LEAKYRELU); +} - /* ColBuff must be large enough to accomodate Align(Fx*InFeat, 8) elements */ - v4s * __restrict__ VBuff = (v4s *) ColBuff; - unsigned int W_In1 = InFeat*Fx*Fy; - unsigned int CoreId = gap_coreid(), C = ChunkSize(InFeat), F = Min(CoreId*C, InFeat), L = Min(InFeat, F+C); - //unsigned int ChunkCell = ChunkSize(OutFeat), First = CoreId*ChunkCell, Last = Min(OutFeat, First+ChunkCell); +void KerPar_MM_Conv2D_DxDy_HSwish_HWC_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_HWC_SQ8_act(Arg, ACT_HSWISH); +} - int FS = Fx*Fy; - int PosL = Arg->FirstTile?(-PadT):0; +void KerPar_MM_Conv2D_DxDy_HSigmoid_HWC_SQ8(Ker_MM_Conv_SQ8_T *Arg) { + KerPar_MM_Conv2D_DxDy_HWC_SQ8_act(Arg, ACT_HSIGMOID); +} - for (int l=0; l CxHW: InFeatxFyxFx - for (int c=F; c +#include "Gap.h" +#include "CNN_BasicKernels_SQ8.h" + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wextra" #pragma GCC diagnostic ignored "-Wpointer-sign" @@ -21,10 +25,6 @@ #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #pragma GCC diagnostic ignored "-Wswitch" -#include -#include "Gap.h" -#include "CNN_BasicKernels_SQ8.h" - static int CoreCountDynamic = 1; static int ActiveCore = gap_ncore(); @@ -3209,11 +3209,28 @@ void KerPoolNxMStrideSxSy_ReLUMN_SQ8(KerPool_SQ8_T *Arg) } +/* HWC Version */ +#define KER_POOL_ACT(Activation, p_type, n_bits, is_unsigned) \ +do { \ + int Size = Wo*Ho*Feat; \ + int CoreId = gap_coreid(), ChunkCell = ChunkSize(Size), First = CoreId*ChunkCell, Last = Min(First+ChunkCell, Size); \ + signed char * __restrict__ Infos = (signed char *__restrict__) Arg->Infos; \ + unsigned int ActScale = ((unsigned char *)Infos)[AT_INF_ACTSCALE], ActScaleN = ((unsigned char *)Infos)[AT_INF_ACTSCALEN]; \ + int A0 = arr_at_as(Infos, AT_INF_A0, p_type); int B0 = arr_at_as(Infos, AT_INF_B0, p_type); int C0 = arr_at_as(Infos, AT_INF_C0, p_type); \ +\ + for (int i=First; iIn; @@ -3262,11 +3279,55 @@ void KerParMaxPoolNxMStrideSxSy_HWC_SQ8(Ker_MM_Pool_SQ8_T *Arg) PosL += Sy; } gap_waitbarrier(0); - // KerParPoolActivation(Out, Wo, Ho, First, Last, Infos, Arg->Activation); - // gap_waitbarrier(0); + if (Activation != ACT_NONE) { + KER_POOL_ACT(Activation, unsigned char, 8, 0); + } +} + +void KerParMaxPoolNxMStrideSxSy_HWC_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_NONE); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_ReLU_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_RELU); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_ReLUN_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_RELUN); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_ReLUM_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_RELUM); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_ReLUMN_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_RELUMN); } -void KerParMaxPoolNxMStrideSxSy_HWC_USQ8(Ker_MM_Pool_USQ8_T *Arg) +void KerParMaxPoolNxMStrideSxSy_HWC_HSigmoid_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_HSIGMOID); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_HSwish_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_HSWISH); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_LeakyReLU_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_LEAKYRELU); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_Sigmoid_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_SIGMOID); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_Tanh_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_TANH); +} + +static inline void __attribute__((always_inline)) KerParMaxPoolNxMStrideSxSy_HWC_USQ8_act( + Ker_MM_Pool_USQ8_T *Arg, + CNN_ActivationOper_T Activation +) { unsigned char *__restrict__ In = Arg->In; @@ -3282,7 +3343,7 @@ void KerParMaxPoolNxMStrideSxSy_HWC_USQ8(Ker_MM_Pool_USQ8_T *Arg) unsigned int CoreId = gap_coreid(), ChunkCell = ChunkSize(Feat), First = CoreId*ChunkCell, Last = Min(Feat, First+ChunkCell); int PosL = Arg->FirstTile?(-PadT):0; - int Iter = Last-First; + int Iter = Max(0, Last-First); for (int l=0; lActivation); - // gap_waitbarrier(0); + if (Activation != ACT_NONE) { + KER_POOL_ACT(Activation, unsigned char, 8, 1); + } +} + +void KerParMaxPoolNxMStrideSxSy_HWC_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_NONE); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_ReLU_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_RELU); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_ReLUN_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_RELUN); } -void KerParAvgPoolNxMStrideSxSy_HWC_SQ8(Ker_MM_Pool_SQ8_T *Arg) +void KerParMaxPoolNxMStrideSxSy_HWC_ReLUM_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_RELUM); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_ReLUMN_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_RELUMN); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_HSigmoid_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_HSIGMOID); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_HSwish_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_HSWISH); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_LeakyReLU_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_LEAKYRELU); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_Sigmoid_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_SIGMOID); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_Tanh_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_TANH); +} + +static inline void __attribute__((always_inline)) KerParAvgPoolNxMStrideSxSy_HWC_SQ8_act( + Ker_MM_Pool_SQ8_T *Arg, + CNN_ActivationOper_T Activation +) { signed char *__restrict__ In = Arg->In; @@ -3388,11 +3493,55 @@ void KerParAvgPoolNxMStrideSxSy_HWC_SQ8(Ker_MM_Pool_SQ8_T *Arg) PosL += Sy; } gap_waitbarrier(0); - // KerParPoolActivation(Out, Wo, Ho, First, Last, Infos, Arg->Activation); - // gap_waitbarrier(0); + if (Activation != ACT_NONE) { + KER_POOL_ACT(Activation, unsigned char, 8, 0); + } +} + +void KerParAvgPoolNxMStrideSxSy_HWC_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_NONE); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_ReLU_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_RELU); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_ReLUN_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_RELUN); } -void KerParAvgPoolNxMStrideSxSy_HWC_USQ8(Ker_MM_Pool_USQ8_T *Arg) +void KerParAvgPoolNxMStrideSxSy_HWC_ReLUM_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_RELUM); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_ReLUMN_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_RELUMN); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_HSigmoid_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_HSIGMOID); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_HSwish_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_HSWISH); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_LeakyReLU_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_LEAKYRELU); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_Sigmoid_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_SIGMOID); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_Tanh_SQ8(Ker_MM_Pool_SQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ8_act(Arg, ACT_TANH); +} + +static inline void __attribute__((always_inline)) KerParAvgPoolNxMStrideSxSy_HWC_USQ8_act( + Ker_MM_Pool_USQ8_T *Arg, + CNN_ActivationOper_T Activation +) { unsigned char *__restrict__ In = Arg->In; @@ -3461,14 +3610,56 @@ void KerParAvgPoolNxMStrideSxSy_HWC_USQ8(Ker_MM_Pool_USQ8_T *Arg) PosL += Sy; } gap_waitbarrier(0); - // KerParPoolActivation(Out, Wo, Ho, First, Last, Infos, Arg->Activation); - // gap_waitbarrier(0); + if (Activation != ACT_NONE) { + KER_POOL_ACT(Activation, unsigned char, 8, 1); + } } +void KerParAvgPoolNxMStrideSxSy_HWC_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_NONE); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_ReLU_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_RELU); +} +void KerParAvgPoolNxMStrideSxSy_HWC_ReLUN_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_RELUN); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_ReLUM_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_RELUM); +} -void KerParMaxPoolNxMStrideSxSy_HWC_SQ16(Ker_MM_Pool_SQ16_T *Arg) +void KerParAvgPoolNxMStrideSxSy_HWC_ReLUMN_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_RELUMN); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_HSigmoid_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_HSIGMOID); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_HSwish_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_HSWISH); +} +void KerParAvgPoolNxMStrideSxSy_HWC_LeakyReLU_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_LEAKYRELU); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_Sigmoid_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_SIGMOID); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_Tanh_USQ8(Ker_MM_Pool_USQ8_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ8_act(Arg, ACT_TANH); +} + + +static inline void __attribute__((always_inline)) KerParMaxPoolNxMStrideSxSy_HWC_SQ16_act( + Ker_MM_Pool_SQ16_T *Arg, + CNN_ActivationOper_T Activation +) { short int *__restrict__ In = Arg->In; int W = Arg->W, H = Arg->H; @@ -3509,21 +3700,64 @@ void KerParMaxPoolNxMStrideSxSy_HWC_SQ16(Ker_MM_Pool_SQ16_T *Arg) PosL += Sy; } gap_waitbarrier(0); - // KerParPoolActivation(Out, Wo, Ho, First, Last, Infos, Arg->Activation); - // gap_waitbarrier(0); + if (Activation != ACT_NONE) { + KER_POOL_ACT(Activation, unsigned char, 8, 1); + } +} + +void KerParMaxPoolNxMStrideSxSy_HWC_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_NONE); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_ReLU_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_RELU); } +void KerParMaxPoolNxMStrideSxSy_HWC_ReLUN_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_RELUN); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_ReLUM_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_RELUM); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_ReLUMN_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_RELUMN); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_HSigmoid_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_HSIGMOID); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_HSwish_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_HSWISH); +} -void KerParMaxPoolNxMStrideSxSy_HWC_USQ16(Ker_MM_Pool_SQ16_T *Arg) +void KerParMaxPoolNxMStrideSxSy_HWC_LeakyReLU_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_LEAKYRELU); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_Sigmoid_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_SIGMOID); +} +void KerParMaxPoolNxMStrideSxSy_HWC_Tanh_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_TANH); +} + + +static inline void __attribute__((always_inline)) KerParMaxPoolNxMStrideSxSy_HWC_USQ16_act( + Ker_MM_Pool_USQ16_T *Arg, + CNN_ActivationOper_T Activation +) { - short int *__restrict__ In = Arg->In; + unsigned short int *__restrict__ In = Arg->In; int W = Arg->W, H = Arg->H; int Fx = Arg->Fx, Sx = Arg->Sx; int Fy = Arg->Fy, Sy = Arg->Sy; int PadL = Arg->Pad[0], PadT = Arg->Pad[2]; int Feat = Arg->Feat; - short int * __restrict__ Out = Arg->Out; + unsigned short int * __restrict__ Out = Arg->Out; int Wo = Arg->Wo, Ho = Arg->Ho; v2u M_Init = (v2u) {-32767,-32767}; @@ -3556,13 +3790,56 @@ void KerParMaxPoolNxMStrideSxSy_HWC_USQ16(Ker_MM_Pool_SQ16_T *Arg) PosL += Sy; } gap_waitbarrier(0); - // KerParPoolActivation(Out, Wo, Ho, First, Last, Infos, Arg->Activation); - // gap_waitbarrier(0); + if (Activation != ACT_NONE) { + KER_POOL_ACT(Activation, unsigned char, 8, 1); + } } +void KerParMaxPoolNxMStrideSxSy_HWC_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_NONE); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_ReLU_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_RELU); +} -void KerParAvgPoolNxMStrideSxSy_HWC_SQ16(Ker_MM_Pool_SQ16_T *Arg) +void KerParMaxPoolNxMStrideSxSy_HWC_ReLUN_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_RELUN); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_ReLUM_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_RELUM); +} +void KerParMaxPoolNxMStrideSxSy_HWC_ReLUMN_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_RELUMN); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_HSigmoid_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_HSIGMOID); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_HSwish_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_HSWISH); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_LeakyReLU_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_LEAKYRELU); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_Sigmoid_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_SIGMOID); +} + +void KerParMaxPoolNxMStrideSxSy_HWC_Tanh_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParMaxPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_TANH); +} + + +static inline void __attribute__((always_inline)) KerParAvgPoolNxMStrideSxSy_HWC_SQ16_act( + Ker_MM_Pool_SQ16_T *Arg, + CNN_ActivationOper_T Activation +) { signed short *__restrict__ In = Arg->In; int W = Arg->W, H = Arg->H; @@ -3611,12 +3888,56 @@ void KerParAvgPoolNxMStrideSxSy_HWC_SQ16(Ker_MM_Pool_SQ16_T *Arg) PosL += Sy; } gap_waitbarrier(0); - // KerParPoolActivation(Out, Wo, Ho, First, Last, Infos, Arg->Activation); - // gap_waitbarrier(0); + if (Activation != ACT_NONE) { + KER_POOL_ACT(Activation, unsigned char, 8, 1); + } +} + +void KerParAvgPoolNxMStrideSxSy_HWC_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_NONE); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_ReLU_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_RELU); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_ReLUN_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_RELUN); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_ReLUM_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_RELUM); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_ReLUMN_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_RELUMN); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_HSigmoid_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_HSIGMOID); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_HSwish_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_HSWISH); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_LeakyReLU_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_LEAKYRELU); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_Sigmoid_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_SIGMOID); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_Tanh_SQ16(Ker_MM_Pool_SQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_SQ16_act(Arg, ACT_TANH); } -void KerParAvgPoolNxMStrideSxSy_HWC_USQ16(Ker_MM_Pool_SQ16_T *Arg) +static inline void __attribute__((always_inline)) KerParAvgPoolNxMStrideSxSy_HWC_USQ16_act( + Ker_MM_Pool_USQ16_T *Arg, + CNN_ActivationOper_T Activation +) { unsigned short *__restrict__ In = Arg->In; int W = Arg->W, H = Arg->H; @@ -3665,6 +3986,49 @@ void KerParAvgPoolNxMStrideSxSy_HWC_USQ16(Ker_MM_Pool_SQ16_T *Arg) PosL += Sy; } gap_waitbarrier(0); - // KerParPoolActivation(Out, Wo, Ho, First, Last, Infos, Arg->Activation); - // gap_waitbarrier(0); -} \ No newline at end of file + if (Activation != ACT_NONE) { + KER_POOL_ACT(Activation, unsigned char, 8, 1); + } +} + +void KerParAvgPoolNxMStrideSxSy_HWC_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_NONE); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_ReLU_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_RELU); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_ReLUN_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_RELUN); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_ReLUM_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_RELUM); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_ReLUMN_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_RELUMN); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_HSigmoid_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_HSIGMOID); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_HSwish_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_HSWISH); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_LeakyReLU_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_LEAKYRELU); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_Sigmoid_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_SIGMOID); +} + +void KerParAvgPoolNxMStrideSxSy_HWC_Tanh_USQ16(Ker_MM_Pool_USQ16_T *Arg) { + KerParAvgPoolNxMStrideSxSy_HWC_USQ16_act(Arg, ACT_TANH); +} + +#pragma GCC diagnostic pop diff --git a/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_SoftMax_SQ8.c b/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_SoftMax_SQ8.c index 889d7cfd4..51ae1a98b 100644 --- a/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_SoftMax_SQ8.c +++ b/tools/autotiler_v3/CNN_Libraries_SQ8/CNN_SoftMax_SQ8.c @@ -14,13 +14,14 @@ * limitations under the License. */ +#include +#include +#include "CNN_BasicKernels_SQ8.h" + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wextra" #pragma GCC diagnostic ignored "-Wpointer-sign" #pragma GCC diagnostic ignored "-Wsign-compare" -#include -#include -#include "CNN_BasicKernels_SQ8.h" static int CoreCountDynamic = 1; static int ActiveCore = gap_ncore(); diff --git a/tools/autotiler_v3/CNN_Libraries_SQ8/RNN_SQ8.c b/tools/autotiler_v3/CNN_Libraries_SQ8/RNN_SQ8.c index 72a17aa83..5c134b67b 100644 --- a/tools/autotiler_v3/CNN_Libraries_SQ8/RNN_SQ8.c +++ b/tools/autotiler_v3/CNN_Libraries_SQ8/RNN_SQ8.c @@ -14,13 +14,15 @@ * limitations under the License. */ + +#include +#include +#include "CNN_BasicKernels_SQ8.h" + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wextra" #pragma GCC diagnostic ignored "-Wpointer-sign" #pragma GCC diagnostic ignored "-Wsign-compare" -#include -#include -#include "CNN_BasicKernels_SQ8.h" static int CoreCountDynamic = 1; static int ActiveCore = gap_ncore(); diff --git a/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Bias_Linear_Activation_fp16.c b/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Bias_Linear_Activation_fp16.c index 7992ebbfe..30a622ee2 100644 --- a/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Bias_Linear_Activation_fp16.c +++ b/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Bias_Linear_Activation_fp16.c @@ -14,6 +14,12 @@ * limitations under the License. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wpointer-sign" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + #include "Gap.h" #include "CNN_BasicKernels_fp16.h" #include "CNN_Defines_fp16.h" @@ -679,3 +685,4 @@ void KerParLinearLayerLeakyReLU_fp16(KerLinear_fp16_T *Arg) gap_waitbarrier(0); } +#pragma GCC diagnostic pop diff --git a/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Conv_BasicKernels_fp16.c b/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Conv_BasicKernels_fp16.c index 09a8faf29..86d55c0ea 100644 --- a/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Conv_BasicKernels_fp16.c +++ b/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Conv_BasicKernels_fp16.c @@ -14,6 +14,12 @@ * limitations under the License. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wpointer-sign" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + #include "Gap.h" #include "CNN_BasicKernels_fp16.h" @@ -4024,3 +4030,5 @@ void KerConvNxMDxDyStrideSxSy_fp16(KerConv_fp16_T *Arg) } gap_waitbarrier(0); } + +#pragma GCC diagnostic pop diff --git a/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Conv_DW_BasicKernels_fp16.c b/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Conv_DW_BasicKernels_fp16.c index 681de86d8..5d7d4a3b4 100644 --- a/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Conv_DW_BasicKernels_fp16.c +++ b/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Conv_DW_BasicKernels_fp16.c @@ -14,6 +14,12 @@ * limitations under the License. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wpointer-sign" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + #include "Gap.h" #include "CNN_BasicKernels_fp16.h" @@ -4151,3 +4157,5 @@ void KerConvDWNxMDxDyStrideSxSy_fp16(KerConv_fp16_T *Arg) gap_waitbarrier(0); } + +#pragma GCC diagnostic pop \ No newline at end of file diff --git a/tools/autotiler_v3/CNN_Libraries_fp16/CNN_MatAlgebra_fp16.c b/tools/autotiler_v3/CNN_Libraries_fp16/CNN_MatAlgebra_fp16.c index ece4f10f6..401728fab 100644 --- a/tools/autotiler_v3/CNN_Libraries_fp16/CNN_MatAlgebra_fp16.c +++ b/tools/autotiler_v3/CNN_Libraries_fp16/CNN_MatAlgebra_fp16.c @@ -14,6 +14,12 @@ * limitations under the License. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wpointer-sign" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + #include #include #include "CNN_BasicKernels_fp16.h" @@ -7038,3 +7044,5 @@ void KerParMatMulSmallFeatLeakyrelu_fp16(KerMatMul_fp16_T *Arg) } gap_waitbarrier(0); } + +#pragma GCC diagnostic pop diff --git a/tools/autotiler_v3/CNN_Libraries_fp16/CNN_MatMul_Conv_fp16.c b/tools/autotiler_v3/CNN_Libraries_fp16/CNN_MatMul_Conv_fp16.c index 5af1deb3a..29730226e 100644 --- a/tools/autotiler_v3/CNN_Libraries_fp16/CNN_MatMul_Conv_fp16.c +++ b/tools/autotiler_v3/CNN_Libraries_fp16/CNN_MatMul_Conv_fp16.c @@ -1,3 +1,10 @@ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wpointer-sign" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + #include #include "CNN_BasicKernels_fp16.h" @@ -1387,3 +1394,5 @@ void KerPar_MM_Conv2D_DxDy_ReLU_fp16( } gap_waitbarrier(0); } + +#pragma GCC diagnostic pop diff --git a/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Pooling_BasicKernels_fp16.c b/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Pooling_BasicKernels_fp16.c index c04650d15..0884c78e3 100644 --- a/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Pooling_BasicKernels_fp16.c +++ b/tools/autotiler_v3/CNN_Libraries_fp16/CNN_Pooling_BasicKernels_fp16.c @@ -14,6 +14,12 @@ * limitations under the License. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wpointer-sign" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + #include #include "Gap.h" #include "CNN_BasicKernels_fp16.h" @@ -1524,3 +1530,5 @@ void KerParAvgPoolNxMStrideSxSy_HWC_fp16(Ker_MM_Pool_fp16_T *Arg) } gap_waitbarrier(0); } + +#pragma GCC diagnostic pop diff --git a/tools/autotiler_v3/CNN_Libraries_fp16/RNN_fp16.c b/tools/autotiler_v3/CNN_Libraries_fp16/RNN_fp16.c index 08f52e1a8..f72da190f 100644 --- a/tools/autotiler_v3/CNN_Libraries_fp16/RNN_fp16.c +++ b/tools/autotiler_v3/CNN_Libraries_fp16/RNN_fp16.c @@ -14,6 +14,12 @@ * limitations under the License. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wpointer-sign" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + #include #include "CNN_BasicKernels_fp16.h" @@ -485,4 +491,6 @@ void GRU_ParKer_fp16(KerGRU_fp16_T *Arg) } gap_waitbarrier(0); } -#endif \ No newline at end of file +#endif + +#pragma GCC diagnostic pop diff --git a/tools/autotiler_v3/CNN_Libraries_fp16/SSD_BasicKernels_fp16.c b/tools/autotiler_v3/CNN_Libraries_fp16/SSD_BasicKernels_fp16.c index 1703742f3..03fa3d2af 100644 --- a/tools/autotiler_v3/CNN_Libraries_fp16/SSD_BasicKernels_fp16.c +++ b/tools/autotiler_v3/CNN_Libraries_fp16/SSD_BasicKernels_fp16.c @@ -61,12 +61,12 @@ void Ker_SSD_Init_f16(Ker_SSD_Init_Arg_f16_T *KerArg0) } // The actual code that does the tile addition -void Ker_SSD_Decoder_fp16(Ker_SSD_Decoder_Arg_fp16_T *KerArg0 ) +void Ker_SSD_Decoder_f16(Ker_SSD_Decoder_Arg_f16_T *KerArg0 ) { unsigned int CoreId = gap_coreid(); - unsigned int Chunk = ChunkSize(KerArg0->H); + unsigned int Chunk = ChunkSize(KerArg0->N_Anchors); unsigned int First = CoreId*Chunk; - unsigned int Last = (First+Chunk > KerArg0->H) ? (KerArg0->H) : (First+Chunk); + unsigned int Last = (First+Chunk > KerArg0->N_Anchors) ? (KerArg0->N_Anchors) : (First+Chunk); bbox_f16_t * bbox = KerArg0->bbox_buf; F16 * scores = KerArg0->classes_in; int num_classes = KerArg0->N_Classes; @@ -152,7 +152,7 @@ static int16_t KerIoverU(F16 a_x, F16 a_y, F16 a_w, F16 a_h, } -static void KerNonMaxSuppress(bbox_t * boundbxs, float iouThres, int nnbb){ +static void KerNonMaxSuppress(bbox_f16_t * boundbxs, float iouThres, int nnbb){ //BBOX value are in Q14 and non_max_threshold in Q14 int idx, idx_int; //Non-max supression @@ -175,7 +175,7 @@ static void KerNonMaxSuppress(bbox_t * boundbxs, float iouThres, int nnbb){ } } -void Ker_SSD_NMS(Ker_SSD_NMS_ArgT *KerArg0 ) +void Ker_SSD_NMS_f16(Ker_SSD_NMS_Arg_f16_T *KerArg0 ) { short int bbox_idx_max = *(KerArg0->bbox_idx); diff --git a/tools/autotiler_v3/CNN_Libraries_fp16/SSD_BasicKernels_fp16.h b/tools/autotiler_v3/CNN_Libraries_fp16/SSD_BasicKernels_fp16.h index 3bb8ca9cd..513581a17 100644 --- a/tools/autotiler_v3/CNN_Libraries_fp16/SSD_BasicKernels_fp16.h +++ b/tools/autotiler_v3/CNN_Libraries_fp16/SSD_BasicKernels_fp16.h @@ -72,9 +72,9 @@ typedef struct { F16 NMSThr; short int n_max_bb; short int *bbox_idx; -} Ker_SSD_NMS_ArgT; +} Ker_SSD_NMS_Arg_f16_T; -void Ker_SSD_NMS(Ker_SSD_NMS_ArgT *Arg); +void Ker_SSD_NMS_f16(Ker_SSD_NMS_Arg_f16_T *Arg); diff --git a/tools/autotiler_v3/DSP_Generators/DSP_Generators.c b/tools/autotiler_v3/DSP_Generators/DSP_Generators.c index 5d53db35e..df0f64605 100644 --- a/tools/autotiler_v3/DSP_Generators/DSP_Generators.c +++ b/tools/autotiler_v3/DSP_Generators/DSP_Generators.c @@ -234,6 +234,21 @@ void LoadMFCCLibrary() ) ); + LibKernelTemplate("MatMul_DSP_T", + CArgs(10, + TCArg("void * __restrict__", "In1"), + TCArg("void * __restrict__", "In2"), + TCArg("void * __restrict__", "Out"), + TCArg("void *", "BufferColIn2"), + TCArg("unsigned int", "W_In1"), + TCArg("unsigned int", "H_In1"), + TCArg("unsigned int", "W_In2"), + TCArg("unsigned int", "W_Out"), + TCArg("unsigned int", "OutFirstCol"), + TCArg("int", "ColFirst") + ) + ); + /* FFT Basic Kernels */ LibKernel("Radix2FFT_DIF_Par_Fix16", CALL_PARALLEL, 0, "FFT_Arg_T", NULL); LibKernel("Radix2FFT_DIF_Par_Fix32", CALL_PARALLEL, 0, "FFT_Arg_T", NULL); @@ -332,6 +347,11 @@ void LoadMFCCLibrary() LibKernel("Conjugate_Fix32_Par", CALL_PARALLEL, CArgs(2, TCArg("int * __restrict__", "Data"), TCArg("int", "Ni")), "SwapSamples_Arg_T", NULL); LibKernel("Conjugate_Float16_Par", CALL_PARALLEL, CArgs(2, TCArg("F16V_DSP * __restrict__", "Data"), TCArg("int", "Ni")), "SwapSamples_Arg_T", NULL); LibKernel("Conjugate_Float32_Par", CALL_PARALLEL, CArgs(2, TCArg("float * __restrict__", "Data"), TCArg("int", "Ni")), "SwapSamples_Arg_T", NULL); + + LibKernel("KerParMatMulDSP_fp16", CALL_PARALLEL, 0, "MatMul_DSP_T", NULL); + LibKernel("KerParMatMulDSPT_fp16", CALL_PARALLEL, 0, "MatMul_DSP_T", NULL); + LibKernel("KerParMatMulDSP_fp32", CALL_PARALLEL, 0, "MatMul_DSP_T", NULL); + LibKernel("KerParMatMulDSPT_fp32", CALL_PARALLEL, 0, "MatMul_DSP_T", NULL); } void PieceWiseGenerator(char *Name, CNN_GenControl_T *Ctrl, char *FunName, int Dim, int DataType, int Inplace) @@ -738,6 +758,11 @@ int MFCC_Generator( printf("MfccKernel: %25s\n", MfccKernel?MfccKernel:""); printf("LogKernel: %25s\n", LogKernel?LogKernel:""); printf("DCTKernel: %25s\n", DCTKernel?DCTKernel:""); + printf("\tN Frames: %d\n", NFrames); + printf("\tFrame Size: %d\n", FrameSize); + printf("\tFrame Stride: %d\n", FrameStride); + printf("\tIn Data Size: %d\n", InItemSize); + printf("\tTot Input Size: %d\n", FrameStride * (NFrames-1) + FrameSize); printf("\tNb Oper: %d\n", LayerOp); printf("\tBandwidth: %d\n", LayerBandwidth); // printf("MFCC_COEF_DYN = %d\nFFT_BITS = %d\nUSE_DB = %d\nDATA_TYPE = %dLOG OFFSET %f\n", MFCC_Coeff_Dyn, Log2Nfft, UseDB, DataType, MfccLogOffset); @@ -916,6 +941,104 @@ int MFCC_Generator( return (Kernel!=0); } +int IMel_Generator( + char *Name, + CNN_GenControl_T *Ctrl, + int NFrames, + int Nfft, + int NMelBanks, + int SizeMelCoeff, + int DataType + ) +{ + if (__builtin_popcount(Nfft) != 1) GenTilingError("%s, Incorrect FFTDim: %d, it has to be a a power of 2", Name, Nfft); + if (DataType==FIX32 || DataType==FIX16) GenTilingError("Not supported FIX_32"); + + int MFCC_Coeff_Dyn = 15; + char *PreEmpKernel=0, *InverseMelKer=0, *UserKernType=0, *UserKernPointer=0, InItemSize=2, OutItemSize=2, LUTItemSize=2; + + switch (DataType){ + case FIX16: + InverseMelKer = "MelFilterBank_Fix32"; + UserKernType = "short int"; + UserKernPointer = "short int * __restrict__"; + InItemSize=2; OutItemSize=2, LUTItemSize=2; + break; + case FLOAT16: + InverseMelKer = "MelFilterBank_f16"; + UserKernType = "F16_DSP"; + UserKernPointer = "F16_DSP * __restrict__"; + InItemSize=F16_SIZE; OutItemSize=F16_SIZE, LUTItemSize=F16_SIZE; + break; + case FLOAT32: + InverseMelKer = "MelFilterBank_f32"; + UserKernType = "float"; + UserKernPointer = "float * __restrict__"; + InItemSize=4; OutItemSize=4, LUTItemSize=4; + break; + default: + GenTilingError("Data Type %d not known", DataType); + return 0; + } + unsigned int LayerOp = 0; + unsigned int LayerBandwidth = 0; + printf("Inverse Mel:\n"); + printf("\tNb Oper: %d\n", LayerOp); + printf("\tBandwidth: %d\n", LayerBandwidth); + + Kernel_T *Kernel = UserKernel(Name, + NFrames<0? + KernelIterSpace(2, IterFixedSpaceDynBound(D0, -NFrames, "NFrames"), IterTiledSpace(T0)): + KernelIterSpace(2, IterFixedSpace(D0, NFrames), IterTiledSpace(T0)), + TILE_HOR, + CArgs(5, + TCArg(UserKernPointer, "In"), + TCArg(UserKernPointer, "Out"), + TCArg("fbank_type_t *","IMel_FilterBank"), + TCArg(UserKernPointer, "IMel_Coeffs"), + (NFrames<0)? + TCArg("short int", "NFrames"):AT_NO_C_ARG + ), + Calls(1, + Call(InverseMelKer, LOC_LOOP, + Bindings(9, + K_Arg("In", KER_ARG_TILE), + K_Arg("Out" , KER_ARG_TILE), + K_Arg("IMel_Coeffs" , KER_ARG_TILE), + K_Arg("IMel_FilterBank", KER_ARG_TILE), + Imm(NMelBanks), + Imm(MFCC_Coeff_Dyn), + AT_IGNORE_ARG_BINDING, + (DataType==FIX16)?K_Arg("shift_buff", KER_ARG_TILE):AT_IGNORE_ARG_BINDING, + AT_IGNORE_ARG_BINDING + ) + ) + ), + KerArgs(4, + KerArg("In", KerArgSpace(1,D0), OBJ_IN_DB, 1, NMelBanks, InItemSize, 0, 0, 0, "In"), + KerArg("Out", KerArgSpace(1,D0), OBJ_OUT_DB, 1, Nfft*2, OutItemSize, 0, 0, 0, "Out"), + KerArg("IMel_FilterBank", KerArgSpace(1,T0), O_IN|O_BUFF|O_CONST, 1, NMelBanks, 6, /* size of filterbank type */ 0, 0, 0, "IMel_FilterBank"), + KerArg("IMel_Coeffs", KerArgSpace(1,T0), O_IN|O_BUFF|O_CONST, 1, SizeMelCoeff, LUTItemSize, 0, 0, 0, "IMel_Coeffs") + ) + ); + if (Kernel) { + AddKernelInfos(Name, AT_KERINFO_OPER, LayerOp, 0); + AddKernelInfos(Name, AT_KERINFO_BANDWIDTH, LayerBandwidth, 0); + + if (DataType==FIX32 || DataType==FIX16) { + AddKernelArgDim(Name, "In", 3, Abs(NFrames), NMelBanks, InItemSize); + AddKernelArgDim(Name, "Out", 3, Abs(NFrames), 2*Nfft, OutItemSize); + AddKernelArgDim(Name, "IMel_Coeffs", 2, SizeMelCoeff, LUTItemSize); + } else { + AddKernelFloatArgDim(Name, "In", 3, Abs(NFrames), NMelBanks, InItemSize); + AddKernelFloatArgDim(Name, "Out", 3, Abs(NFrames), 2*Nfft, OutItemSize); + AddKernelFloatArgDim(Name, "IMel_Coeffs", 2, SizeMelCoeff, LUTItemSize); + } + AddKernelArgDim(Name, "IMel_FilterBank", 3, NMelBanks, 3, 2); + } + return (Kernel!=0); +} + int RFFT_2D_Generator( char *Name, CNN_GenControl_T *Ctrl, @@ -1533,3 +1656,126 @@ void STFT_Generator( ) ); } + +int DSP_MatMul_Generator( + char *Name, + + CNN_GenControl_T *Ctrl, + + int ColM1, + int LineM1, + int ColM2, + int LineM2, + + int TransposedIn2, + int DataType +) + +{ + int Log = 1; + Tile_Orientation_T TileOrientation = TILE_HOR; + int F = 0; + unsigned long long int LayerOp = 0; + unsigned long long int LayerBandwidth = 0; + int LineO = LineM1, ColO = ColM2; + int Nbuff, ItemSize; + + if (ColM1 != LineM2) GenTilingError("DSP_MatMul_Generator: %s, Incorrect input matrices dimensions for a matrix multiplication: [%d x %d]*[%d x %d]", Name, LineM1, ColM1, LineM2, ColM2); + + char *MatMulKerName=0, *UserKernType=0, *UserKernPointer=0; + switch (DataType){ + case FIX16: + GenTilingError("DSP_MatMul_Generator Not yet implemented in FIX16"); + UserKernType = "short int"; UserKernPointer = "short int * __restrict__"; + ItemSize=2; + break; + case FIX32: + GenTilingError("DSP_MatMul_Generator Not yet implemented in FIX16"); + UserKernType = "int"; UserKernPointer = "int * __restrict__"; + ItemSize=2; + break; + case FLOAT16: + MatMulKerName = TransposedIn2?"KerParMatMulDSPT_fp16":"KerParMatMulDSP_fp16"; + UserKernType = "F16_DSP"; UserKernPointer = "F16_DSP * __restrict__"; + ItemSize=F16_SIZE; F = O_FLOAT; + break; + case FLOAT32: + MatMulKerName = TransposedIn2?"KerParMatMulDSPT_fp32":"KerParMatMulDSP_fp32"; + UserKernType = "float"; UserKernPointer = "float * __restrict__"; + ItemSize=4; F = O_FLOAT; + break; + default: + GenTilingError("Data Type %d not known", DataType); + } + + + int ColFirst = ((LineM1*ColM1)<(LineM2*ColM2)); + Nbuff = 4; + LayerOp += ColM1*ColM2*LineM1; + LayerBandwidth += LineM1*(ColM1*ColM2*(2+2)); + LayerBandwidth += LineM1*ColM2*2; + LayerBandwidth += LineM1*2; + + if (Log) { + printf("CNN_MatMulAct_fp16: %s\n", Name); + printf("In1 => W: %4d, H: %4d\n", ColM1, LineM1); + printf("In2 => W: %4d, H: %4d\n", ColM2, LineM2); + printf("Out => W: %4d, H: %4d => %s\n", ColO, LineO, ColFirst?"Column first":"Line First"); + printf("Total Op: %lld\n", LayerOp); + if (MatMulKerName) printf("%20s: %s\n", "MatMulKerName", MatMulKerName); + } + + int ObjCons = (!TransposedIn2)?OBJ_CONSTRAINTS_TILE_VER:0; + if (TransposedIn2) { + LineM2 = ColM2; ColM2 = ColM1; + } + Kernel_T *Kernel = UserKernel(Name, + KernelIterSpace(2, IterTiledSpace(T1), IterTiledSpace(T0)), + TILE_HOR, + CArgs(3, + TCArg(UserKernPointer, "In1"), + TCArg(UserKernPointer, "In2"), + TCArg(UserKernPointer, "Out") + ), + Calls(1, + Call(MatMulKerName, LOC_LOOP, + Bindings(10, + K_Arg("In1", KER_ARG_TILE), + K_Arg("In2", KER_ARG_TILE), + K_Arg("Out", KER_ARG_TILE), + (!TransposedIn2)?K_Arg("KerBuff", KER_ARG_TILE):AT_IGNORE_ARG_BINDING, + K_Arg("In1", KER_ARG_TILE_W), + K_Arg("In1", KER_ARG_TILE_H), + TransposedIn2?K_Arg("In2", KER_ARG_TILE_H):K_Arg("In2", KER_ARG_TILE_W), + K_Arg("Out", KER_ARG_TILE_W), + K_Arg(ColFirst?"In1":"In2", KER_ARG_TILE_BASE), + Imm(ColFirst) + ) + ) + ), + ColFirst? + KerArgs(4, + (!TransposedIn2)? + KerArg("KerBuff",KerArgSpace(1,T1), F|O_BUFF|O_NTILED, Nbuff*ColM1, 1, ItemSize, 0, 0, 0, 0):AT_NO_KER_ARG, + KerArg("In1", KerArgSpace(1,T0), F|O_IN|O_DB|O_CONST, ColM1, LineM1, ItemSize, 0, OBJ_CONSTRAINTS_PAD_REM, 8, "In1"), + KerArg("In2", KerArgSpace(1,T1), F|O_IN|O_DB, ColM2, LineM2, ItemSize, 0, ObjCons|OBJ_CONSTRAINTS_PAD_REM, 2, "In2"), + KerArg("Out", KerArgSpace(1,T1), F|O_OUT|O_DB, ColO, LineO, ItemSize, 0, OBJ_CONSTRAINTS_TILE_VER|OBJ_CONSTRAINTS_PAD_REM, 0, "Out") + ): + KerArgs(4, + (!TransposedIn2)? + KerArg("KerBuff",KerArgSpace(1,T0), F|O_BUFF|O_NTILED, Nbuff*ColM1, 1, ItemSize, 0, 0, 0, 0):AT_NO_KER_ARG, + KerArg("In1", KerArgSpace(1,T1), F|O_IN|O_DB|O_CONST, ColM1, LineM1, ItemSize, 0, OBJ_CONSTRAINTS_PAD_REM, 8, "In1"), + KerArg("In2", KerArgSpace(1,T0), F|O_IN|O_DB, ColM2, LineM2, ItemSize, 0, ObjCons|OBJ_CONSTRAINTS_PAD_REM, 2, "In2"), + KerArg("Out", KerArgSpace(1,T1), F|O_OUT|O_DB, ColO, LineO, ItemSize, 0, OBJ_CONSTRAINTS_PAD_REM, 0, "Out") + ) + ); + if (Kernel) { + AddKernelInfos(Name, AT_KERINFO_OPER, LayerOp, 0); + AddKernelInfos(Name, AT_KERINFO_BANDWIDTH, LayerBandwidth, 0); + + AddKernelFloatArgDim(Name, "In1", 3, LineM1, ColM1, ItemSize); + AddKernelFloatArgDim(Name, "In2", 3, LineM2, ColM2, ItemSize); + AddKernelFloatArgDim(Name, "Out", 3, LineO, ColO, ItemSize); + } + return (Kernel!=0); +} diff --git a/tools/autotiler_v3/DSP_Generators/DSP_Generators.h b/tools/autotiler_v3/DSP_Generators/DSP_Generators.h index e6ff452ac..74938f019 100644 --- a/tools/autotiler_v3/DSP_Generators/DSP_Generators.h +++ b/tools/autotiler_v3/DSP_Generators/DSP_Generators.h @@ -29,6 +29,30 @@ int MFCC_Generator( int OutFFT /* If output FFT beside mel spect */ ); +int DSP_MatMul_Generator( + char *Name, + + CNN_GenControl_T *Ctrl, + + int ColM1, + int LineM1, + int ColM2, + int LineM2, + + int TransposedIn2, + int DataType +); + +int IMel_Generator( + char *Name, + CNN_GenControl_T *Ctrl, + int NFrames, + int Nfft, + int NMelBanks, + int SizeMelCoeff, + int DataType + ); + int RFFT_2D_Generator( char *Name, CNN_GenControl_T *Ctrl, diff --git a/tools/autotiler_v3/DSP_Libraries/DSP_Lib.h b/tools/autotiler_v3/DSP_Libraries/DSP_Lib.h index c1f642364..292a84998 100644 --- a/tools/autotiler_v3/DSP_Libraries/DSP_Lib.h +++ b/tools/autotiler_v3/DSP_Libraries/DSP_Lib.h @@ -121,9 +121,9 @@ typedef struct { } FFT_InstallArg_T; typedef struct fbank_type_ { - short int Start; - short int Items; - short int Base; + unsigned short int Start; + unsigned short int Items; + unsigned short int Base; } fbank_type_t; typedef struct { @@ -231,6 +231,19 @@ typedef struct { int FFT_Dim; } Windowing_T; +typedef struct { + void * __restrict__ In1; + void * __restrict__ In2; + void * __restrict__ Out; + void *BufferColIn2; + unsigned int W_In1; + unsigned int H_In1; + unsigned int W_In2; + unsigned int W_Out; + unsigned int OutFirstCol; + int ColFirst; +} MatMul_DSP_T; + /********************************************************************************************************************************************************************/ /****************** FFT Library ************************************************************************************************************************************/ /********************************************************************************************************************************************************************/ @@ -353,4 +366,9 @@ extern void WindowingReal2Cmplx_PadCenter_f16(Windowing_T *Arg); extern void WindowingReal2Real_f16(Windowing_T *Arg); extern void WindowingReal2Real_PadCenter_f16(Windowing_T *Arg); +extern void KerParMatMulDSP_fp16(MatMul_DSP_T *Arg); +extern void KerParMatMulDSPT_fp16(MatMul_DSP_T *Arg); +extern void KerParMatMulDSP_fp32(MatMul_DSP_T *Arg); +extern void KerParMatMulDSPT_fp32(MatMul_DSP_T *Arg); + #endif //DSP_LIB_H \ No newline at end of file diff --git a/tools/autotiler_v3/DSP_Libraries/FFT_Library.c b/tools/autotiler_v3/DSP_Libraries/FFT_Library.c index 99d5d95f3..cef2cb0f9 100644 --- a/tools/autotiler_v3/DSP_Libraries/FFT_Library.c +++ b/tools/autotiler_v3/DSP_Libraries/FFT_Library.c @@ -29,8 +29,8 @@ void FFT_InstallTwiddlesAndSwapLUT(FFT_InstallArg_T *Arg, int format) LUTSize = Arg->Nfft*sizeof(short); - AT_L2_COPY(0, (AT_L2_EXT_ADDR_TYPE) Arg->SwapLUT, (AT_L2_INT_ADDR_TYPE) Arg->L1_SwapLUT, LUTSize, 0, &DmaR_Evt2); - AT_L2_COPY(0, (AT_L2_EXT_ADDR_TYPE) Arg->Twiddles, (AT_L2_INT_ADDR_TYPE)Arg->L1_Twiddles, TwidSize, 0, &DmaR_Evt1); + AT_L2_COPY(0, (AT_L2_EXT_ADDR_TYPE) Arg->SwapLUT, (AT_L2_INT_ADDR_TYPE) Arg->L1_SwapLUT, LUTSize, 0, &DmaR_Evt1); + AT_L2_COPY(0, (AT_L2_EXT_ADDR_TYPE) Arg->Twiddles, (AT_L2_INT_ADDR_TYPE) Arg->L1_Twiddles, TwidSize, 0, &DmaR_Evt2); AT_L2_WAIT(0, &DmaR_Evt1); AT_L2_WAIT(0, &DmaR_Evt2); @@ -42,8 +42,8 @@ void RFFT_InstallTwiddlesAndSwapLUT(FFT_InstallArg_T *Arg, int format) AT_L2_EVENT DmaR_Evt1, DmaR_Evt2, DmaR_Evt3; int TwidSize, RTwidSize, LUTSize; - if (Arg->Radix == 2) TwidSize = Arg->Nfft * sizeof(short); - else TwidSize = 3 * Arg->Nfft * (sizeof(short)/2); + if (Arg->Radix == 2) TwidSize = (Arg->Nfft>>1) * sizeof(short); + else TwidSize = 3 * (Arg->Nfft>>1) * (sizeof(short)/2); // when floating 32, size is double if (format==1) TwidSize *=2; @@ -52,10 +52,9 @@ void RFFT_InstallTwiddlesAndSwapLUT(FFT_InstallArg_T *Arg, int format) if (format==1) RTwidSize = Arg->Nfft * sizeof(float); else RTwidSize = Arg->Nfft * sizeof(short); - - AT_L2_COPY(0, (AT_L2_EXT_ADDR_TYPE) Arg->SwapLUT, (AT_L2_INT_ADDR_TYPE) Arg->L1_SwapLUT, LUTSize, 0, &DmaR_Evt1); - AT_L2_COPY(0, (AT_L2_EXT_ADDR_TYPE) Arg->Twiddles, (AT_L2_INT_ADDR_TYPE)Arg->L1_Twiddles, TwidSize, 0, &DmaR_Evt2); - AT_L2_COPY(0, (AT_L2_EXT_ADDR_TYPE) Arg->RTwiddles, (AT_L2_INT_ADDR_TYPE)Arg->L1_RTwiddles, RTwidSize, 0, &DmaR_Evt3); + AT_L2_COPY(0, (AT_L2_EXT_ADDR_TYPE) Arg->SwapLUT, (AT_L2_INT_ADDR_TYPE) Arg->L1_SwapLUT, LUTSize, 0, &DmaR_Evt1); + AT_L2_COPY(0, (AT_L2_EXT_ADDR_TYPE) Arg->Twiddles, (AT_L2_INT_ADDR_TYPE) Arg->L1_Twiddles, TwidSize, 0, &DmaR_Evt2); + AT_L2_COPY(0, (AT_L2_EXT_ADDR_TYPE) Arg->RTwiddles, (AT_L2_INT_ADDR_TYPE) Arg->L1_RTwiddles, RTwidSize, 0, &DmaR_Evt3); AT_L2_WAIT(0, &DmaR_Evt1); AT_L2_WAIT(0, &DmaR_Evt2); @@ -492,7 +491,7 @@ void Radix4FFT_DIF_Par_Fix16(FFT_Arg_T *Arg) int iCnt1, iCnt2, iCnt3, iL, iM, iQ, iA, iB, iC, iD; - unsigned int iLog4N = (gap_fl1(N_fft))>>1; + int iLog4N = (gap_fl1(N_fft))>>1; v2s *DataV = (v2s *) Data; v2s *CoeffV = (v2s *) Twiddles; unsigned int CoreId; @@ -580,7 +579,7 @@ void Radix4FFT_DIF_Par_Fix32(FFT_Arg_T *Arg) int iCnt1, iCnt2, iCnt3, iL, iM, iQ, iA, iB, iC, iD; - unsigned int iLog4N = (gap_fl1(N_fft))>>1; + int iLog4N = (gap_fl1(N_fft))>>1; unsigned int CoreId; int First, Last, Chunk; @@ -656,7 +655,7 @@ void Radix4FFT_DIF_Par_f16(FFT_Arg_T *Arg) int iCnt1, iCnt2, iCnt3, iL, iM, iQ, iA, iB, iC, iD; - unsigned int iLog4N = (gap_fl1(N_fft))>>1; + int iLog4N = (gap_fl1(N_fft))>>1; F16V_DSP *DataV = (F16V_DSP *) Data; F16V_DSP *CoeffV = (F16V_DSP *) Twiddles; unsigned int CoreId; @@ -746,7 +745,7 @@ void Radix4FFT_DIF_Par_f32(FFT_Arg_T *Arg) int iCnt1, iCnt2, iCnt3, iL, iM, iQ, iA, iB, iC, iD; - unsigned int iLog4N = (gap_fl1(N_fft))>>1; + int iLog4N = (gap_fl1(N_fft))>>1; unsigned int CoreId; int First, Last, Chunk; @@ -1428,7 +1427,7 @@ void Radix2FFT_DIF_Par_Fix32_Scal(FFT_scal_Arg_T *Arg) // reset the shift table Chunk = N_fft/nbcore; First = CoreId*Chunk; Last = Min( First+Chunk,N_fft); - for (int i = First; i < Last; i++) shift_fft[i]=0; + for (unsigned int i = First; i < Last; i++) shift_fft[i]=0; gap_waitbarrier(0); // compute fft @@ -1656,14 +1655,17 @@ void RFFT_DIF_Par_Fix16(RFFT_Arg_T *Arg){ if (CoreId == 0){ xBR = pB[0][0]; xBI = pB[0][1]; - xAR = pA[0][0]; - xAI = pA[0][1]; // real(tw * (xB - xA)) = twR * (xBR - xAR) - twI * (xBI - xAI); // imag(tw * (xB - xA)) = twI * (xBR - xAR) + twR * (xBI - xAI); - RFFT_Out[0][0] = ( xBR + xAR + xBI + xAI ) >> 2; - RFFT_Out[0][1] = ( xAI - xBI + xBR - xAR ) >> 2; // XA(1) = 1/2*( U1 - imag(U2) + i*( U1 +imag(U2) )); + RFFT_Out[0][0] = ( xBR + xBI ) >> 1; + RFFT_Out[0][1] = 0; + + // Gr(N) = Gr(0) - Gi(0) + // Gi(N) = 0 + RFFT_Out[k+1][0] = ( xBR - xBI ); + RFFT_Out[k+1][1] = 0; } gap_waitbarrier(0); @@ -1698,16 +1700,6 @@ void RFFT_DIF_Par_Fix16(RFFT_Arg_T *Arg){ t2 = gap_add2div4( xA, gap_cplxconj(xB)); RFFT_Out[i] = gap_cplxmuls(tw, t1) + t2; } - if (CoreId == 0){ - xBR = pB[-(k-1)][0]; - xBI = pB[-(k-1)][1]; - xAR = pA[ (k-1)][0]; - xAI = pA[ (k-1)][1]; - RFFT_Out[k][0] = ( xBR + xAR - xBI - xAI ) >> 2; - // TODO - CHECK - // RFFT_Out[k][1] = ( xAI - xBI - xBR + xAR ) >> 2; - RFFT_Out[k][1] = 0; - } gap_waitbarrier(0); #ifdef PRINTDEB if (CoreId==0){ @@ -1854,14 +1846,14 @@ void RFFT_DIF_Par_f16(RFFT_Arg_T *Arg){ if (CoreId == 0){ xBR = pB[0][0]; xBI = pB[0][1]; - xAR = pA[0][0]; - xAI = pA[0][1]; // real(tw * (xB - xA)) = twR * (xBR - xAR) - twI * (xBI - xAI); // imag(tw * (xB - xA)) = twI * (xBR - xAR) + twR * (xBI - xAI); - RFFT_Out[0][0] = 0.5f * ( xBR + xAR + xBI + xAI ); - RFFT_Out[0][1] = 0.5f * ( xAI - xBI + xBR - xAR ); + RFFT_Out[0][0] = xBR + xBI; + RFFT_Out[0][1] = 0.0f; // XA(1) = 1/2*( U1 - imag(U2) + i*( U1 +imag(U2) )); + RFFT_Out[k+1][0] = xBR - xBI; + RFFT_Out[k+1][1] = 0.0f; } gap_waitbarrier(0); @@ -1897,15 +1889,6 @@ void RFFT_DIF_Par_f16(RFFT_Arg_T *Arg){ t2 = t2 + xA; RFFT_Out[i] = (CplxMult_f16(tw, t1) + t2) * (F16V_DSP) {0.5f, 0.5f}; } - if (CoreId == 0){ - xBR = pB[-(k-1)][0]; - xBI = pB[-(k-1)][1]; - xAR = pA[(k-1)][0]; - xAI = pA[(k-1)][1]; - RFFT_Out[k][0] = 0.5f * ( xBR + xAR - xBI - xAI ); - // RFFT_Out[k][1] = 0.5f * ( xAI - xBI - xBR + xAR ); - RFFT_Out[k][1] = 0.0f; - } gap_waitbarrier(0); #ifdef PRINTDEB if (CoreId==0){ @@ -1947,10 +1930,10 @@ void RFFT_DIF_Par_f32(RFFT_Arg_T *Arg){ if (CoreId == 0){ xBR = pB[0]; xBI = pB[1]; - xAR = pA[0]; - xAI = pA[1]; - RFFT_Out[0] = 0.5f * ( xBR + xAR + xBI + xAI ); - RFFT_Out[1] = 0.5f * ( xAI - xBI + xBR - xAR ); + RFFT_Out[0] = xBR + xBI; + RFFT_Out[1] = 0.0f; + RFFT_Out[2*(k+1)] = xBR - xBI; + RFFT_Out[2*(k+1)+1] = 0.0f; } gap_waitbarrier(0); @@ -1998,16 +1981,6 @@ void RFFT_DIF_Par_f32(RFFT_Arg_T *Arg){ RFFT_Out[2*i] = 0.5f * (xAR + xBR + p0 + p3 ); //xAR RFFT_Out[2*i+1] = 0.5f * (xAI - xBI + p1 - p2 ); //xAI - // printf("%d %f %f\n", i, RFFT_Out[2*i] ,RFFT_Out[2*i+1] ); - } - if (CoreId == 0){ - xBR = pB[-2*(k-1)]; - xBI = pB[-2*(k-1)+1]; - xAR = pA[2*(k-1)]; - xAI = pA[2*(k-1)+1]; - RFFT_Out[2*k] = 0.5f * ( xBR + xAR - xBI - xAI ); - RFFT_Out[2*k+1] = 0.0f; - // RFFT_Out[2*k+1] = 0.5f * ( xAI - xBI - xBR + xAR ); } gap_waitbarrier(0); #ifdef PRINTDEB @@ -2040,9 +2013,10 @@ void IRFFT_DIF_Par_Fix16(RFFT_Arg_T *Arg){ if (CoreId == 0){ xAR = pA[0][0]; xAI = pA[0][1]; + xBR = pA[k+1][0]; - RFFT_Out[0][0] = (xAR + xAI) >> 1; - RFFT_Out[0][1] = (xAR - xAI) >> 1; + RFFT_Out[0][0] = (xAR + xAI + xBR) >> 1; + RFFT_Out[0][1] = (xAR + xAI - xBR) >> 1; } Chunk = ChunkSize(k); First = CoreId*Chunk; Last = Min(First+Chunk, k); @@ -2111,9 +2085,10 @@ void IRFFT_DIF_Par_f16(RFFT_Arg_T *Arg){ if (CoreId == 0){ xAR = pA[0][0]; xAI = pA[0][1]; + xBR = pA[k+1][0]; - RFFT_Out[0][0] = 0.5f * ( xAR + xAI ); - RFFT_Out[0][1] = 0.5f * ( xAR - xAI ); + RFFT_Out[0][0] = 0.5f * ( xAR + xAI + xBR); + RFFT_Out[0][1] = 0.5f * ( xAR + xAI - xBR); } Chunk = ChunkSize(k); First = CoreId*Chunk; Last = Min(First+Chunk, k); @@ -2185,9 +2160,10 @@ void IRFFT_DIF_Par_f32(RFFT_Arg_T *Arg){ if (CoreId == 0){ xAR = pA[0]; xAI = pA[1]; + xBR = pA[2*(k+1)]; - RFFT_Out[0] = 0.5f * ( xAR + xAI ); - RFFT_Out[1] = 0.5f * ( xAR - xAI ); + RFFT_Out[0] = 0.5f * ( xAR + xAI + xBR ); + RFFT_Out[1] = 0.5f * ( xAR + xAI - xBR ); } Chunk = ChunkSize(k); First = CoreId*Chunk; Last = Min(First+Chunk, k); diff --git a/tools/autotiler_v3/DSP_Libraries/LUT_Tables/gen_scripts/GenMFCCLUT.py b/tools/autotiler_v3/DSP_Libraries/LUT_Tables/gen_scripts/GenMFCCLUT.py index 947e2d625..5cea41772 100644 --- a/tools/autotiler_v3/DSP_Libraries/LUT_Tables/gen_scripts/GenMFCCLUT.py +++ b/tools/autotiler_v3/DSP_Libraries/LUT_Tables/gen_scripts/GenMFCCLUT.py @@ -26,7 +26,9 @@ def create_parser(): parser.add_argument('--fft_lut_file', required="--params_json" not in sys.argv, help="path to fft lut file") parser.add_argument('--mfcc_bf_lut_file', default=None, - help="path to fft lut file") + help="path to mfcc lut file") + parser.add_argument('--imel_lut_file', default=None, + help="path to inverse mel lut file") parser.add_argument('--sample_rate', default=16000, type=int) parser.add_argument('--name_suffix', default="", type=str) parser.add_argument('--frame_size', required="--params_json" not in sys.argv, type=int, @@ -81,6 +83,7 @@ def main(): fft_lut_file = args.fft_lut_file if not "fft_lut_file" in models_params else models_params["fft_lut_file"] mfcc_bf_lut_file = args.mfcc_bf_lut_file if not "mfcc_bf_lut_file" in models_params else models_params["mfcc_bf_lut_file"] + imel_lut_file = args.imel_lut_file if not "imel_lut_file" in models_params else models_params["imel_lut_file"] use_tf_mfcc = args.use_tf_mfcc if not "use_tf_mfcc" in models_params else models_params["use_tf_mfcc"] use_librosa = args.use_librosa if not "use_librosa" in models_params else models_params["use_librosa"] sample_rate = args.sample_rate if not "sample_rate" in models_params else models_params["sample_rate"] @@ -218,10 +221,19 @@ def main(): from SetupLUT import GenMFCC_FB filters = GenMFCC_FB(n_fft, mfcc_bank_cnt, Fmin=fmin, Fmax=fmax, sample_rate=sample_rate, dtype=lut_dtype) - MfccLUT, HeadCoeff = GenMelFilterBanksCode(filters, mfcc_bank_cnt, fmin, fmax, lut_dtype, data_type, name_suffix) + MelLUT, NCoeffMEL = GenMelFilterBanksCode(filters, mfcc_bank_cnt, fmin, fmax, lut_dtype, data_type, name_suffix) with open(mfcc_bf_lut_file, "w") as f: - f.write(MfccLUT) + f.write(MelLUT) + + if imel_lut_file: + # Inverse matrix of filterbank generated with least squares algorithm + # A.T*b = A.T*A*x^ + # x^ = (A.T*A)^-1 * A.T * b + inverse_mel_fb = np.matmul(np.linalg.inv(np.matmul(filters, filters.T)), filters) + ImelLUT = array_to_def_c_file(inverse_mel_fb.flatten(), f"ImelLUT{name_suffix}", data_type, inverse_mel_fb.size, elem_in_rows=inverse_mel_fb.size) + with open(imel_lut_file, "w") as f: + f.write(ImelLUT) if args.save_params_header: with open(args.save_params_header, "w") as f: @@ -230,11 +242,11 @@ def main(): f.write("#define\t{:21}{:>10}\n".format("FRAME_STEP", frame_step)) f.write("#define\t{:21}{:>10}\n".format("N_FFT", n_fft)) f.write("#define\t{:21}{:>10}\n".format("DATA_TYPE", 2 if dtype=="float16" else (3 if dtype=="float32" else (1 if dtype=="fix32_scal" else 0)))) - if mfcc_bf_lut_file: + if mfcc_bf_lut_file or imel_lut_file: f.write("#define\t{:21}{:>10}\n".format("MFCC_BANK_CNT", mfcc_bank_cnt)) f.write("#define\t{:21}{:>10}\n".format("FMIN", fmin)) f.write("#define\t{:21}{:>10}\n".format("FMAX", fmax)) - f.write("#define\t{:21}{:>10}\n".format("MFCC_COEFF_CNT", HeadCoeff+1)) + f.write("#define\t{:21}{:>10}\n".format("MFCC_COEFF_CNT", NCoeffMEL+1)) f.write("#define\t{:21}{:>10}\n".format("N_DCT", n_dct)) diff --git a/tools/autotiler_v3/DSP_Libraries/LUT_Tables/gen_scripts/SetupLUT.py b/tools/autotiler_v3/DSP_Libraries/LUT_Tables/gen_scripts/SetupLUT.py index 671c7d190..5460da336 100644 --- a/tools/autotiler_v3/DSP_Libraries/LUT_Tables/gen_scripts/SetupLUT.py +++ b/tools/autotiler_v3/DSP_Libraries/LUT_Tables/gen_scripts/SetupLUT.py @@ -117,7 +117,14 @@ def SetupLiftCoeff(L, N, dtype="int"): def GenMelFilterBanksCode(filters, mfcc_bank_cnt, fmin, fmax, dtype, data_type, name_suffix): HeadCoeff = 0 MFCC_Coeff = [] - for i, filt in enumerate(filters): + if dtype == "int": + quant_filters = FP2FIX(filters, MFCC_COEFF_DYN) + elif dtype == "float16": + quant_filters = filters.astype(np.float16) + else: + quant_filters = filters.astype(np.float32) + + for i, filt in enumerate(quant_filters): if np.all(filt == 0): Start = 0 Stop = 0 @@ -130,22 +137,17 @@ def GenMelFilterBanksCode(filters, mfcc_bank_cnt, fmin, fmax, dtype, data_type, Items = Stop - Start + 1 print("Filter {}: Start: {} Stop: {} Base: {} Items: {}".format(i, Start, Stop, Base, Items)) for j in range(Items): - if dtype == "int": - MFCC_Coeff.append(FP2FIX(filt[Start+j], MFCC_COEFF_DYN)) - elif dtype == "float16": - MFCC_Coeff.append(filt[Start+j].astype(np.float16)) - else: - MFCC_Coeff.append(filt[Start+j]) + MFCC_Coeff.append(filt[Start+j]) HeadCoeff += Items - Out_str = "#define MFCC_COEFF_CNT\t{}\n\n".format(HeadCoeff+1) - Out_str += "/* Filter Bank bands:\n\n" + #Out_str = "#define MFCC_COEFF_CNT\t{}\n\n".format(HeadCoeff+1) + Out_str = "/* Filter Bank bands:\n\n" Out_str += "\tMinimum Frequency: {} Hz\n".format(fmin) Out_str += "\tMaximum Frequency: {} Hz*/\n\n".format(fmax) Out_str += "PI_L2 fbank_type_t MFCC_FilterBank{}[{}] = {{\n".format(name_suffix, mfcc_bank_cnt) HeadCoeff = 0 - for i, filt in enumerate(filters): + for i, filt in enumerate(quant_filters): if np.all(filt == 0): Start = 0 Stop = 0 diff --git a/tools/autotiler_v3/DSP_Libraries/MatMulDSP.c b/tools/autotiler_v3/DSP_Libraries/MatMulDSP.c new file mode 100644 index 000000000..94aa3cea5 --- /dev/null +++ b/tools/autotiler_v3/DSP_Libraries/MatMulDSP.c @@ -0,0 +1,514 @@ +#include +#include "FastFloatApprox16.h" +#include "DSP_Lib.h" + +static int CoreCountDynamic = 1; +static int ActiveCore = gap_ncore(); +static inline unsigned int __attribute__((always_inline)) ChunkSize(unsigned int X) + +{ + unsigned int NCore; + unsigned int Log2Core; + unsigned int Chunk; + + if (CoreCountDynamic) NCore = ActiveCore; else NCore = gap_ncore(); + Log2Core = gap_fl1(NCore); + Chunk = (X>>Log2Core) + ((X&(NCore-1))!=0); + return Chunk; +} + +void KerParMatMulDSP_fp16(MatMul_DSP_T *Arg) + +{ + F16_DSP * __restrict__ In1 = (F16_DSP * __restrict__) Arg->In1; + F16_DSP * __restrict__ In2 = (F16_DSP * __restrict__) Arg->In2; + F16_DSP * __restrict__ Out = (F16_DSP * __restrict__) Arg->Out; + F16_DSP *BufferColIn2 = (F16_DSP *) Arg->BufferColIn2; + unsigned int W_In1 = Arg->W_In1; + unsigned int H_In1 = Arg->H_In1; + unsigned int W_In2 = Arg->W_In2; /* H_In2 = W_In1 by construction */ + unsigned int W_Out = Arg->W_Out; + unsigned int OutFirstCol = Arg->OutFirstCol; + int ColFirst = Arg->ColFirst; + + unsigned int H_In2 = W_In1; + unsigned int H_Out = H_In1; + unsigned int Line, Col, i; + F16V_DSP *VBuff1 = (F16V_DSP *) (&BufferColIn2[0]); + F16V_DSP *VBuff2 = (F16V_DSP *) (&BufferColIn2[1*H_In2]); + F16V_DSP *VBuff3 = (F16V_DSP *) (&BufferColIn2[2*H_In2]); + F16V_DSP *VBuff4 = (F16V_DSP *) (&BufferColIn2[3*H_In2]); + + unsigned int CoreId = gap_coreid(); + unsigned int ChunkCell = ChunkSize(H_In1); + unsigned int First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); + unsigned int Iter = (Last>First)?(Last-First):0; + unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); + int OffLine = 0, OffCol = 0; + + if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; + for (Col=0; ColIn1; + F16_DSP * __restrict__ In2 = (F16_DSP * __restrict__) Arg->In2; + F16_DSP * __restrict__ Out = (F16_DSP * __restrict__) Arg->Out; + unsigned int W_In1 = Arg->W_In1; + unsigned int H_In1 = Arg->H_In1; + unsigned int W_In2 = Arg->W_In2; /* H_In2 = W_In1 by construction */ + unsigned int W_Out = Arg->W_Out; + unsigned int OutFirstCol = Arg->OutFirstCol; + int ColFirst = Arg->ColFirst; + + unsigned int H_In2 = W_In1; + unsigned int H_Out = H_In1; + unsigned int Line, Col, i; + + unsigned int CoreId = gap_coreid(); + unsigned int ChunkCell = ChunkSize(H_In1); + unsigned int First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); + unsigned int Iter = (Last>First)?(Last-First):0; + int OffLine = 0, OffCol = 0; + + if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; + F16_DSP * pOut = Out + (OffLine+First)*W_Out + OffCol; + for (Line=0; LineIn1; + float * __restrict__ In2 = (float *__restrict__) Arg->In2; + float * __restrict__ Out = (float *__restrict__) Arg->Out; + float *BufferColIn2 = (float *) Arg->BufferColIn2; + unsigned int W_In1 = Arg->W_In1; + unsigned int H_In1 = Arg->H_In1; + unsigned int W_In2 = Arg->W_In2; /* H_In2 = W_In1 by construction */ + unsigned int W_Out = Arg->W_Out; + unsigned int OutFirstCol = Arg->OutFirstCol; + int ColFirst = Arg->ColFirst; + + unsigned int H_In2 = W_In1; + unsigned int H_Out = H_In1; + unsigned int Line, Col, i; + + unsigned int CoreId = gap_coreid(); + unsigned int ChunkCell = ChunkSize(H_In1); + unsigned int First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); + unsigned int Iter = (Last>First)?(Last-First):0; + unsigned int C = ChunkSize(H_In2), F = CoreId*C, L = Min(H_In2, F+C); + int OffLine = 0, OffCol = 0; + + if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; + for (Col=0; ColIn1; + float * __restrict__ In2 = (float *__restrict__) Arg->In2; + float * __restrict__ Out = (float *__restrict__) Arg->Out; + unsigned int W_In1 = Arg->W_In1; + unsigned int H_In1 = Arg->H_In1; + unsigned int W_In2 = Arg->W_In2; /* H_In2 = W_In1 by construction */ + unsigned int W_Out = Arg->W_Out; + unsigned int OutFirstCol = Arg->OutFirstCol; + int ColFirst = Arg->ColFirst; + + unsigned int H_In2 = W_In1; + unsigned int H_Out = H_In1; + unsigned int Line, Col, i; + + unsigned int CoreId = gap_coreid(); + unsigned int ChunkCell = ChunkSize(H_In1); + unsigned int First = CoreId*ChunkCell, Last = Min(H_In1, First+ChunkCell); + unsigned int Iter = (Last>First)?(Last-First):0; + int OffLine = 0, OffCol = 0; + + if (ColFirst) OffLine = OutFirstCol; else OffCol = OutFirstCol; + float * pOut = Out + (OffLine+First)*W_Out + OffCol; + for (Line=0; LineMel_Coeffs; signed char *__restrict__ shift_buff = (signed char *__restrict__) Arg->shift_buff; fbank_type_t *__restrict__ Mel_FilterBank = (fbank_type_t *__restrict__) Arg->Mel_FilterBank; - short int Mel_NBanks = Arg->Mel_NBanks; + unsigned int Mel_NBanks = (unsigned int) Arg->Mel_NBanks; short int Mel_Coeff_Dyn = Arg->Mel_Coeff_dyn; unsigned int Chunk, First, Last, CoreId=gap_coreid(); @@ -86,7 +86,7 @@ void MelFilterBank_Fix32_Scal(MelFilterBank_T *Arg) signed char *__restrict__ shift_fft = (signed char *__restrict__) Arg->shift_fft; short int *__restrict__ Mel_Coeffs = (short int *__restrict__) Arg->Mel_Coeffs; fbank_type_t *__restrict__ Mel_FilterBank = (fbank_type_t *__restrict__) Arg->Mel_FilterBank; - short int Mel_NBanks = Arg->Mel_NBanks; + unsigned int Mel_NBanks = (unsigned int) Arg->Mel_NBanks; short int Mel_Coeff_Dyn = Arg->Mel_Coeff_dyn; signed char IsMagSquared = Arg->IsMagSquared; int MUL_EXP = IsMagSquared?2:1; @@ -112,7 +112,7 @@ void MelFilterBank_Fix32_Scal(MelFilterBank_T *Arg) } // align the block scaling on the min , compute the max value in the block for (k=0, j=Mel_FilterBank[i].Start; k<(unsigned int) NonZeroItems; j++, k++) { - int TMP = FramePower[j] >> (MUL_EXP * (shift_fft[j] - min_shift)); + unsigned int TMP = FramePower[j] >> (MUL_EXP * (shift_fft[j] - min_shift)); if (TMP > (unsigned int) maxin) maxin = TMP; } @@ -149,7 +149,7 @@ void MelFilterBank_f16(MelFilterBank_T *Arg) F16_DSP *__restrict__ Mel_Spectr = (F16_DSP *__restrict__) Arg->MelSpectr; F16_DSP *__restrict__ Mel_Coeffs = (F16_DSP *__restrict__) Arg->Mel_Coeffs; fbank_type_t *__restrict__ Mel_FilterBank = (fbank_type_t *__restrict__) Arg->Mel_FilterBank; - short int Mel_NBanks = Arg->Mel_NBanks; + unsigned int Mel_NBanks = (unsigned int) Arg->Mel_NBanks; unsigned int Chunk, First, Last, CoreId=gap_coreid(); //Chunk = ChunkSize(Mel_NBanks); @@ -183,7 +183,7 @@ void MelFilterBank_f32(MelFilterBank_T *Arg) float *__restrict__ Mel_Spectr = (float *__restrict__) Arg->MelSpectr; float *__restrict__ Mel_Coeffs = (float *__restrict__) Arg->Mel_Coeffs; fbank_type_t *__restrict__ Mel_FilterBank = (fbank_type_t *__restrict__) Arg->Mel_FilterBank; - short int Mel_NBanks = Arg->Mel_NBanks; + unsigned int Mel_NBanks = (unsigned int) Arg->Mel_NBanks; unsigned int Chunk, First, Last, CoreId=gap_coreid(); //Chunk = ChunkSize(Mel_NBanks); @@ -211,7 +211,7 @@ void MelFilterBank_f32(MelFilterBank_T *Arg) void MFCC_ComputeLog_Fix32(MFCC_Log_T *Arg) { - int i; + unsigned int i; int size = Arg->FrameSize; unsigned int *frameIn = (unsigned int *) Arg->FrameIn; short int *frameOut = (short int *) Arg->FrameOut; @@ -269,7 +269,7 @@ void MFCC_ComputeLog_Fix32(MFCC_Log_T *Arg) void MFCC_ComputeLog_Fix32_Scal(MFCC_Log_T *Arg) { - int i; + unsigned int i; int size = Arg->FrameSize; unsigned int *frameIn = (unsigned int *) Arg->FrameIn; short int *frameOut = (short int *) Arg->FrameOut; @@ -327,7 +327,7 @@ void MFCC_ComputeLog_Fix32_Scal(MFCC_Log_T *Arg) void MFCC_ComputeLog_f16( MFCC_LogF_T *Arg) { - int i; + unsigned int i; int size = Arg->FrameSize; F16_DSP *frameIn = (F16_DSP *) Arg->FrameIn; F16_DSP *frameOut = (F16_DSP *) Arg->FrameOut; @@ -360,7 +360,7 @@ void MFCC_ComputeLog_f16( MFCC_LogF_T *Arg) void MFCC_ComputeLog_f32(MFCC_LogF_T *Arg) { - int i; + unsigned int i; int size = Arg->FrameSize; float *frameIn = (float *) Arg->FrameIn; float *frameOut = (float *) Arg->FrameOut; @@ -392,7 +392,7 @@ void MFCC_ComputeLog_f32(MFCC_LogF_T *Arg) void MFCC_ComputeDB_Fix32(MFCC_Log_T *Arg) { - int i; + unsigned int i; int size = Arg->FrameSize; unsigned int *frameIn = (unsigned int *) Arg->FrameIn; short int *frameOut = (short int *) Arg->FrameOut; @@ -450,7 +450,7 @@ void MFCC_ComputeDB_Fix32(MFCC_Log_T *Arg) void MFCC_ComputeDB_Fix32_Scal(MFCC_Log_T *Arg) { - int i; + unsigned int i; int size = Arg->FrameSize; unsigned int *frameIn = (unsigned int *) Arg->FrameIn; short int *frameOut = (short int *) Arg->FrameOut; @@ -508,7 +508,7 @@ void MFCC_ComputeDB_Fix32_Scal(MFCC_Log_T *Arg) void MFCC_ComputeDB_f16( MFCC_LogF_T *Arg) { - int i; + unsigned int i; int size = Arg->FrameSize; F16_DSP *frameIn = (F16_DSP *) Arg->FrameIn; F16_DSP *frameOut = (F16_DSP *) Arg->FrameOut; @@ -540,7 +540,7 @@ void MFCC_ComputeDB_f16( MFCC_LogF_T *Arg) void MFCC_ComputeDB_f32(MFCC_LogF_T *Arg) { - int i; + unsigned int i; int size = Arg->FrameSize; float *frameIn = (float *) Arg->FrameIn; float *frameOut = (float *) Arg->FrameOut; @@ -577,7 +577,7 @@ void norm_clip_16(Norm_Clip_args_T *Args) short int Norm = Args->Norm; int N = Args->N; - int i; + unsigned int i; unsigned int Chunk, First, Last, CoreId=gap_coreid(); if (CoreId==0) { @@ -604,7 +604,7 @@ void norm_clip_32_melspect(MFCC_Clip_32_T *Args) { unsigned int Chunk, First, Last, CoreId=gap_coreid(); if (CoreId==0){ - for (i=0; i<(unsigned int)N; i++) { + for (i=0; i> Norm):0; @@ -635,12 +635,12 @@ void norm_clip_32_melspect_scal(MFCC_Clip_32_T *Args) if (CoreId==0){ if (IsMagSquared){ - for (i=0; i<(unsigned int)N; i++) { + for (i=0; i> Norm):0; } } else { - for (i=0; i<(unsigned int)N; i++) { + for (i=0; i> Norm):0; } @@ -660,8 +660,8 @@ void MFCC_ComputeDCT_II_Fix16(DCT_II_Arg_T *Args) v2s * in_dct = (v2s * __restrict__ ) Args->Data; short int * DCTCoeff = (short int * __restrict__) Args->DCTCoeff; short int * FeatList = (short int * __restrict__ ) Args->FeatList; - short int NDCT = Args->n_dct; - short int NInputs = Args->n_input; + unsigned int NDCT = (unsigned int) Args->n_dct; + unsigned int NInputs = (unsigned int) Args->n_input; unsigned int Chunk, First, Last, CoreId=gap_coreid(); @@ -692,8 +692,8 @@ void MFCC_ComputeDCT_II_f16(DCT_II_Arg_T *Args) F16V_DSP * in_dct = (F16V_DSP * __restrict__ ) Args->Data; F16_DSP * FeatList = (F16_DSP * __restrict__ ) Args->FeatList; F16_DSP * DCTCoeff = (F16_DSP * __restrict__) Args->DCTCoeff; - short int NDCT = Args->n_dct; - short int NInputs = Args->n_input; + unsigned int NDCT = (unsigned int) Args->n_dct; + unsigned int NInputs = (unsigned int) Args->n_input; unsigned int Chunk, First, Last, CoreId=gap_coreid(); @@ -725,8 +725,8 @@ void MFCC_ComputeDCT_II_f32(DCT_II_Arg_T *Args) float * in_dct = (float * __restrict__ ) Args->Data; float * FeatList = (float * __restrict__ ) Args->FeatList; float * DCTCoeff = (float * __restrict__) Args->DCTCoeff; - short int NDCT = Args->n_dct; - short int NInputs = Args->n_input; + unsigned int NDCT = (unsigned int) Args->n_dct; + unsigned int NInputs = (unsigned int) Args->n_input; unsigned int Chunk, First, Last, CoreId=gap_coreid(); diff --git a/tools/autotiler_v3/DSP_Libraries/PreProcessing.c b/tools/autotiler_v3/DSP_Libraries/PreProcessing.c index 8d39cca00..e4dae722e 100644 --- a/tools/autotiler_v3/DSP_Libraries/PreProcessing.c +++ b/tools/autotiler_v3/DSP_Libraries/PreProcessing.c @@ -27,7 +27,7 @@ void get_max(PreEmphasis_T *Arg) maxin[CoreId]=0; if (CoreId==0) maxin[0] = Abs(Arg->Prev); - for (int j=First;jmaxin[CoreId]) maxin[CoreId]=Abs((int)Frame[j]); } gap_waitbarrier(0); diff --git a/tools/autotiler_v3/Emulation/GapSystem.h b/tools/autotiler_v3/Emulation/GapSystem.h index 558bb6688..4729a268e 100644 --- a/tools/autotiler_v3/Emulation/GapSystem.h +++ b/tools/autotiler_v3/Emulation/GapSystem.h @@ -98,6 +98,8 @@ static int Private_call(void (*fn)(void *), void * arg, __event_cb * event) #define gap_setupbarrier(BarN, CoreM) #define gap_waitbarrier(BarN) #define gap_waitbarrier_cc(BarN) +#define gap_cl_critical_enter() +#define gap_cl_critical_exit() #define rt_event_sched_init(x) #define rt_event_alloc(x,y) 0 @@ -190,7 +192,8 @@ static inline void __cl_dma_memcpy_2d(uint32_t ext, uint32_t loc, uint16_t size, #define gap_waitbarrier_cc() eu_bar_trig_wait_clr(eu_bar_addr(1)) #endif - +#define gap_cl_critical_enter() pi_cl_team_critical_enter() +#define gap_cl_critical_exit() pi_cl_team_critical_exit() #endif diff --git a/tools/autotiler_v3/Emulation/at_api_emul.h b/tools/autotiler_v3/Emulation/at_api_emul.h index ce57b8ecf..f56578a4e 100644 --- a/tools/autotiler_v3/Emulation/at_api_emul.h +++ b/tools/autotiler_v3/Emulation/at_api_emul.h @@ -55,6 +55,10 @@ extern unsigned int __L3_Read, __L3_Write, __L2_Read, __L2_Write; #define AT_QSPIRAM_FREE(dev,ptr,size) free(ptr) +#define AT_OSPIRAM_ALLOC(dev,size) malloc(size) + +#define AT_OSPIRAM_FREE(dev,ptr,size) free(ptr) + #define AT_L2_ALLOC(dev,size) malloc(size) #define AT_L2_FREE(dev,ptr,size) free(ptr) @@ -307,6 +311,78 @@ do { \ #define AT_QSPIRAM_CL_WAIT(dev,event) + +/* + * OSpiram + */ + +#define AT_OSPIRAM_TYPE 0 + +typedef int AT_OSPIRAM_CONF_T; +typedef int AT_OSPIRAM_T; +typedef char * AT_OSPIRAM_EXT_ADDR_TYPE; +typedef char * AT_OSPIRAM_LOC_ADDR_TYPE; +typedef int AT_OSPIRAM_FC_EVENT; +typedef int AT_OSPIRAM_CL_EVENT; +typedef char * AT_OSPIRAM_POINTER; +typedef char * AT_OSPIRAM_INT_ADDR_TYPE; + +#define AT_OSPIRAM_EXT2LOC 0 +#define AT_OSPIRAM_LOC2EXT 1 + +#define AT_OSPIRAM_CONF_INIT(dev,type,name) + +#define AT_OSPIRAM_OPEN(dev,conf,err) \ + do { *(err) = 0; } while (0) + +#define AT_OSPIRAM_CLOSE(dev) + +#define AT_OSPIRAM_FC_COPY(dev,ext,loc,size,dir,event) \ +do { \ + int i; \ + char *To = (dir==AT_OSPIRAM_EXT2LOC)?((char *) (loc)):((char *) (ext)); \ + char *From = (dir==AT_OSPIRAM_EXT2LOC)?((char *) (ext)):((char *) (loc)); \ + \ + if (dir==AT_OSPIRAM_EXT2LOC) { \ + if (1) __L3_Read += size; else __L2_Read += size; \ + } else { \ + if (1) __L3_Write += size; else __L2_Write += size; \ + } \ + \ + for (i=0; i size) + length = size; + + fseek(file, ext, SEEK_SET); + if (dir==AT_QSPIFLASH_FS_EXT2LOC) fread(loc, 1, length, file); + else fwrite(loc, 1, length, file); + + loc = ((char *)loc) + length; + ext += stride; + } +} + + +#define AT_OSPIFLASH_FS_CONF_INIT(dev,type,name) + +#define AT_OSPIFLASH_FS_OPEN(file,conf,filename,err) \ + do { *(file) = fopen(filename, "r"); *(err) = *(file) == NULL; } while(0) + +#define AT_OSPIFLASH_FS_OPEN_WRITE(file,conf,filename,err) \ + do { *(file) = fopen(filename, "w"); *(err) = *(file) == NULL; } while(0) + +#define AT_OSPIFLASH_FS_OPEN_SET_SIZE(file, size) + +#define AT_OSPIFLASH_FS_CLOSE(file) \ + fclose(*file) + +#define AT_OSPIFLASH_FS_FC_COPY(file,ext,loc,size,dir,event) \ + __at_ospiflash_fs_copy(*(file), ext, loc, size, dir) + +#define AT_OSPIFLASH_FS_FC_COPY2D(file, dev,ext,loc,size,stride,len,dir,event) \ + __at_ospiflash_fs_copy_2d(*(file), ext, loc, size, stride, len, dir) + +#define AT_OSPIFLASH_FS_FC_WAIT(file,event) + +#define AT_OSPIFLASH_FS_CL_COPY(file,ext,loc,size,dir,event) \ + __at_ospiflash_fs_copy(*(file), ext, loc, size, dir) + +#define AT_OSPIFLASH_FS_CL_COPY2D(file, dev,ext,loc,size,stride,len,dir,event) \ + __at_ospiflash_fs_copy_2d(*(file), ext, loc, size, stride, len, dir) + +#define AT_OSPIFLASH_FS_CL_WAIT(file,event) + /* * EMRAMflash diff --git a/tools/autotiler_v3/Emulation/at_api_pmsis.h b/tools/autotiler_v3/Emulation/at_api_pmsis.h index 733992315..584fc99ce 100644 --- a/tools/autotiler_v3/Emulation/at_api_pmsis.h +++ b/tools/autotiler_v3/Emulation/at_api_pmsis.h @@ -18,6 +18,7 @@ #define __AT__AT_API_PMSIS_H__ #include "pmsis.h" +#include #include "bsp/ram/hyperram.h" #include "bsp/ram/spiram.h" #include "bsp/flash/hyperflash.h" @@ -83,6 +84,10 @@ static inline uint32_t gap_cl_readhwtimer() #define AT_QSPIRAM_FREE(dev,ptr,size) pi_ram_free((dev), (ptr), (size)) +#define AT_OSPIRAM_ALLOC(dev,size) ({ uint32_t ptr; int err = pi_ram_alloc((dev), &ptr, (size)); if (!err && ptr == 0) err = pi_ram_alloc((dev), &ptr, (size)); if (err) ptr = 0; ptr; }) + +#define AT_OSPIRAM_FREE(dev,ptr,size) pi_ram_free((dev), (ptr), (size)) + #define AT_L2_ALLOC(dev,size) pmsis_l2_malloc(size) #define AT_L2_FREE(dev,ptr,size) pmsis_l2_malloc_free((ptr), (size)) @@ -328,6 +333,53 @@ typedef char * AT_QSPIRAM_INT_ADDR_TYPE; pi_cl_ram_copy_wait(event) +/* + * OctaSpiram + */ + +#ifdef __GAP9__ +#define AT_OSPIRAM_TYPE 0 + +typedef struct pi_aps25xxxn_conf AT_OSPIRAM_CONF_T; +typedef struct pi_device AT_OSPIRAM_T; +typedef uint32_t AT_OSPIRAM_EXT_ADDR_TYPE; +typedef void * AT_OSPIRAM_LOC_ADDR_TYPE; +typedef pi_task_t AT_OSPIRAM_FC_EVENT; +typedef pi_cl_ram_req_t AT_OSPIRAM_CL_EVENT; +typedef uint32_t AT_OSPIRAM_POINTER; +typedef char * AT_OSPIRAM_INT_ADDR_TYPE; + +#define AT_OSPIRAM_EXT2LOC 0 +#define AT_OSPIRAM_LOC2EXT 1 + +#define AT_OSPIRAM_CONF_INIT(dev,type,name) \ + pi_aps25xxxn_conf_init(dev) + +#define AT_OSPIRAM_OPEN(dev,conf,err) \ + do { pi_open_from_conf((dev), (conf)); *(err) = pi_ram_open(dev); } while(0) + +#define AT_OSPIRAM_CLOSE(dev) \ + pi_ram_close(dev) + +#define AT_OSPIRAM_FC_COPY(dev,ext,loc,size,dir,event) \ + pi_ram_copy_async(dev, (AT_OSPIRAM_EXT_ADDR_TYPE)(ext), (AT_OSPIRAM_LOC_ADDR_TYPE)(loc), (size), !(dir), pi_task_block(event)) + +#define AT_OSPIRAM_FC_COPY2D(dev,ext,loc,size,stride,len,dir,event) \ + pi_ram_copy_2d_async(dev, (AT_OSPIRAM_EXT_ADDR_TYPE)(ext), (AT_OSPIRAM_LOC_ADDR_TYPE)(loc), (size), (stride), (len), !(dir), pi_task_block(event)) + +#define AT_OSPIRAM_FC_WAIT(dev,event) \ + pi_task_wait_on(event) + +#define AT_OSPIRAM_CL_COPY(dev,ext,loc,size,dir,event) \ + pi_cl_ram_copy(dev, (AT_OSPIRAM_EXT_ADDR_TYPE)(ext), (AT_OSPIRAM_LOC_ADDR_TYPE)(loc), (size), !(dir), (event)) + +#define AT_OSPIRAM_CL_COPY2D(dev,ext,loc,size,stride,len,dir,event) \ + pi_cl_ram_copy_2d(dev, (AT_OSPIRAM_EXT_ADDR_TYPE)(ext), (AT_OSPIRAM_LOC_ADDR_TYPE)(loc), (size), (stride), (len), !(dir), (event)) + +#define AT_OSPIRAM_CL_WAIT(dev,event) \ + pi_cl_ram_copy_wait(event) +#endif + /* * Spiflash */ @@ -362,6 +414,47 @@ typedef pi_cl_ram_req_t AT_QSPIFLASH_EVENT; #define AT_QSPIFLASH_WAIT(dev,event) +/* + * OctaSpiflash + */ + +#ifdef __GAP9__ +#define AT_OSPIFLASH_TYPE 1 + +#if defined(CONFIG_ATXP032) +typedef struct pi_atxp032_conf AT_OSPIFLASH_CONF_T; +#else +#if defined(CONFIG_MX25U51245G) +typedef struct pi_mx25u51245g_conf AT_OSPIFLASH_CONF_T; +#endif +#endif +typedef struct pi_device AT_OSPIFLASH_T; +typedef uint32_t AT_OSPIFLASH_EXT_ADDR_TYPE; +typedef void * AT_OSPIFLASH_LOC_ADDR_TYPE; +typedef pi_cl_ram_req_t AT_OSPIFLASH_EVENT; + +#define AT_OSPIFLASH_EXT2LOC 0 +#define AT_OSPIFLASH_LOC2EXT 1 + +#define AT_OSPIFLASH_CONF_INIT(dev,type,name) \ + pi_spiflash_conf_init(dev) + +#define AT_OSPIFLASH_OPEN(dev,conf,err) \ + do { pi_open_from_conf((dev), (conf)); *(err) = pi_flash_open(dev); } while(0) + +#define AT_OSPIFLASH_CLOSE(dev) \ + pi_flash_close(dev) + +// TODO not yet supported +#define AT_OSPIFLASH_COPY(dev,ext,loc,size,dir,event) + +// TODO not yet supported +#define AT_OSPIFLASH_COPY2D(dev,ext,loc,size,stride,len,dir,event) + +// TODO not yet supported +#define AT_OSPIFLASH_WAIT(dev,event) +#endif + /* * SPIflash FS @@ -463,6 +556,116 @@ static inline void __at_qspiflash_fs_close(AT_QSPIFLASH_FS_T *file) #define AT_QSPIFLASH_FS_CL_WAIT(file,event) \ pi_cl_fs_wait(event) + +/* + * OctoSPIflash FS + */ + +#ifdef __GAP9__ +#define AT_OSPIFLASH_FS_TYPE 1 + +typedef struct pi_fs_conf AT_OSPIFLASH_FS_CONF_T; + +typedef struct +{ + struct pi_device fs; + struct pi_device ospiflash; + pi_fs_file_t *file; +} AT_OSPIFLASH_FS_T; + +typedef unsigned int AT_OSPIFLASH_FS_EXT_ADDR_TYPE; +typedef void *AT_OSPIFLASH_FS_INT_ADDR_TYPE; +typedef pi_task_t AT_OSPIFLASH_FS_FC_EVENT; +typedef pi_cl_fs_req_t AT_OSPIFLASH_FS_CL_EVENT; + +static inline void __at_ospiflash_fs_open(AT_OSPIFLASH_FS_T *file, int is_write, struct pi_fs_conf *conf, const char *filename, int *err) +{ + #if defined(CONFIG_ATXP032) + struct pi_atxp032_conf flash_conf; + pi_atxp032_conf_init(&flash_conf); + #else + #if defined(CONFIG_MX25U51245G) + struct pi_mx25u51245g_conf flash_conf; + pi_mx25u51245g_conf_init(&flash_conf); + #endif + #endif + pi_open_from_conf(&file->ospiflash, &flash_conf); + if (pi_flash_open(&file->ospiflash)) + { + *err = -1; + return; + } + conf->flash = &file->ospiflash; + if (is_write) + conf->type = PI_FS_HOST; + else + conf->type = PI_FS_READ_ONLY; + + pi_open_from_conf(&file->fs, conf); + if (pi_fs_mount(&file->fs)) + { + pi_flash_close(&file->ospiflash); + *err = -1; + return; + } + file->file = pi_fs_open(&file->fs, filename, is_write ? PI_FS_FLAGS_WRITE : 0); + if (file->file == NULL) + { + pi_fs_unmount(&file->fs); + pi_flash_close(&file->ospiflash); + *err = -1; + return; + } + *err = 0; + + if (is_write) + file->file->size = 4*1024*1024; +} + +static inline void __at_ospiflash_fs_close(AT_OSPIFLASH_FS_T *file) +{ + pi_fs_close(file->file); + pi_fs_unmount(&file->fs); + pi_flash_close(&file->ospiflash); +} + +#define AT_OSPIFLASH_FS_EXT2LOC 0 +#define AT_OSPIFLASH_FS_LOC2EXT 1 + +#define AT_OSPIFLASH_FS_CONF_INIT(dev,type,name) \ + pi_fs_conf_init(dev) + +#define AT_OSPIFLASH_FS_OPEN(file,conf,filename,err) \ + __at_ospiflash_fs_open(file, 0, conf, filename, err) + +#define AT_OSPIFLASH_FS_OPEN_WRITE(file,conf,filename,err) \ + __at_ospiflash_fs_open(file, 1, conf, filename, err) + +#define AT_OSPIFLASH_FS_OPEN_SET_SIZE(file, size) \ + file->file->size = size + +#define AT_OSPIFLASH_FS_CLOSE(file) \ + __at_ospiflash_fs_close(file) + +#define AT_OSPIFLASH_FS_FC_COPY(fs,ext,loc,size,dir,event) \ + pi_fs_copy_async((fs)->file, ext, loc, size, !(dir), pi_task_block(event)) + +#define AT_OSPIFLASH_FS_FC_COPY2D(file, dev,ext,loc,size,stride,len,dir,event) \ + pi_fs_copy_2d_async(file->file, ext, loc, size, stride, len, !(dir), pi_task_block(event)) + +#define AT_OSPIFLASH_FS_FC_WAIT(file,event) \ + pi_task_wait_on(event) + +#define AT_OSPIFLASH_FS_CL_COPY(fs,ext,loc,size,dir,event) \ + pi_cl_fs_copy((fs)->file, ext, loc, size, !(dir), event) + +#define AT_OSPIFLASH_FS_CL_COPY2D(file, dev,ext,loc,size,stride,len,dir,event) \ + pi_cl_fs_copy_2d(file->file, ext, loc, size, stride, len, !(dir), event) + +#define AT_OSPIFLASH_FS_CL_WAIT(file,event) \ + pi_cl_fs_wait(event) +#endif + #ifdef __GAP9__ /* diff --git a/tools/autotiler_v3/Makefile b/tools/autotiler_v3/Makefile index dc12e7fd7..d099d66b9 100644 --- a/tools/autotiler_v3/Makefile +++ b/tools/autotiler_v3/Makefile @@ -1,4 +1,4 @@ -TILER_VER=4.3.0 +TILER_VER=4.3.2 export TILER_LIB=libtile.${TILER_VER}.a ifdef GAP_SDK_HOME export TILER_URL=$(GAP_SDK_HOME)/.tiler_url diff --git a/tools/autotiler_v3/version.cfg b/tools/autotiler_v3/version.cfg index dbce13460..047a40256 100644 --- a/tools/autotiler_v3/version.cfg +++ b/tools/autotiler_v3/version.cfg @@ -3,7 +3,7 @@ { "version": "autotiler-v3", "magicNum": 718930176, - "git-hash": "bd6fd2447d2ccd4dcdd8c774a3a130b3141fac22" + "git-hash": "4be2dc2f29bb4719d481b20c8cd37ae3b68937cf" } ] } \ No newline at end of file diff --git a/tools/jenkins/gap_sdk_version.txt b/tools/jenkins/gap_sdk_version.txt index dbbe1c752..86cc31dbb 100644 --- a/tools/jenkins/gap_sdk_version.txt +++ b/tools/jenkins/gap_sdk_version.txt @@ -1 +1 @@ -1f3f3d29ae92199246b03f00e4c207540022b502 +65d7014bdc0a46fff8f45d826301de74829b89ab diff --git a/tools/nntool/_version.py b/tools/nntool/_version.py index 62227b113..a1297615f 100644 --- a/tools/nntool/_version.py +++ b/tools/nntool/_version.py @@ -13,4 +13,4 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -__version__ = '3.11' +__version__ = '4.1' diff --git a/tools/nntool/autotiler/generators/nntool_extra_generators.c b/tools/nntool/autotiler/generators/nntool_extra_generators.c deleted file mode 100644 index a38bc6614..000000000 --- a/tools/nntool/autotiler/generators/nntool_extra_generators.c +++ /dev/null @@ -1,489 +0,0 @@ -#include -#include -#include -#include "AutoTilerLib.h" -#include "nntool_extra_generators.h" -#include "Gap.h" - -// Returns floor of square root of x -int floorSqrt(int x) -{ - // Base cases - if (x == 0 || x == 1) - return x; - - // Staring from 1, try all numbers until - // i*i is greater than or equal to x. - int i = 1, result = 1; - while (result <= x) - { - i++; - result = i * i; - } - return i - 1; -} - -int primeFactors(int n) -{ - int original_n = n; - int W = 1; - // Print the number of 2s that divide n - while (n % 2 == 0 && W < n) - { - W *= 2; - n = n/2; - } - - // n must be odd at this point. So we can skip - // one element (Note i = i +2) - for (int i = 3; i <= floorSqrt(n); i = i + 2) - { - // While i divides n, print i and divide n - while (n % i == 0 && W < n) - { - W *= i; - n = n/i; - } - } - - // This condition is to handle the case when n - // is a prime number greater than 2 - if (n > 2 && W < n) - W = n; - - return Max(W, n); -} - -int largest_factor(int sz) -{ - int limit = floorSqrt(sz); - for (int i=2; i<=limit; i++) - { - int c=0; - for (int j=1; j<=i; j++) - { - if (i%j==0) - { - c++; - } - } - if (c==2 && sz%i==0) return sz/i; - } - return 1; -} - -#define D0 KER_ITER_D0 -#define D1 KER_ITER_D1 -#define D2 KER_ITER_D2 -#define D3 KER_ITER_D3 -#define T0 KER_ITER_TILE0 -#define T1 KER_ITER_TILE1 -#define T2 KER_ITER_TILE2 - -void LoadNNTools_Extra_Library() - -{ - LibKernel("CNN_NormRGB565_offset_fps", CALL_PARALLEL, - CArgs(6, - TCArg("unsigned short *__restrict__", "In"), - TCArg("signed char *__restrict__", "Out0"), - TCArg("signed char *__restrict__", "Out1"), - TCArg("signed char *__restrict__", "Out2"), - TCArg("unsigned short int", "W"), - TCArg("unsigned short int", "H") - ), - "KerNormRGB565_fps_T", NULL - ); - - LibKernel("CNN_NormRGB565_shift_fps", CALL_PARALLEL, - CArgs(6, - TCArg("unsigned short *__restrict__", "In"), - TCArg("signed char *__restrict__", "Out0"), - TCArg("signed char *__restrict__", "Out1"), - TCArg("signed char *__restrict__", "Out2"), - TCArg("unsigned short int", "W"), - TCArg("unsigned short int", "H") - ), - "KerNormRGB565_fps_T", NULL - ); - - LibKernel("CNN_NormRGB888_offset_fps", CALL_PARALLEL, - CArgs(6, - TCArg("unsigned char *__restrict__", "In"), - TCArg("signed char *__restrict__", "Out0"), - TCArg("signed char *__restrict__", "Out1"), - TCArg("signed char *__restrict__", "Out2"), - TCArg("unsigned short int", "W"), - TCArg("unsigned short int", "H") - ), - "KerNormRGB888_fps_T", NULL - ); - - LibKernel("CNN_NormRGB888_shift_fps", CALL_PARALLEL, - CArgs(6, - TCArg("unsigned char *__restrict__", "In"), - TCArg("signed char *__restrict__", "Out0"), - TCArg("signed char *__restrict__", "Out1"), - TCArg("signed char *__restrict__", "Out2"), - TCArg("unsigned short int", "W"), - TCArg("unsigned short int", "H") - ), - "KerNormRGB888_fps_T", NULL - ); - - LibKernel("CNN_NormRGB16_fp", CALL_PARALLEL, - CArgs(6, - TCArg("unsigned char *__restrict__", "In"), - TCArg("signed short int *__restrict__", "Out0"), - TCArg("signed short int *__restrict__", "Out1"), - TCArg("signed short int *__restrict__", "Out2"), - TCArg("unsigned short int", "W"), - TCArg("unsigned short int", "H") - ), - "KerNormRGB16_fp_T", NULL - ); - - LibKernel("CNN_NormBW_offset_fps", CALL_PARALLEL, - CArgs(4, - TCArg("unsigned char *__restrict__", "In"), - TCArg("signed char *__restrict__", "Out"), - TCArg("unsigned short int", "W"), - TCArg("unsigned short int", "H") - ), - "KerNormBW_fps_T", NULL - ); - - LibKernel("CNN_NormBW_shift_fps", CALL_PARALLEL, - CArgs(4, - TCArg("unsigned char *__restrict__", "In"), - TCArg("signed char *__restrict__", "Out"), - TCArg("unsigned short int", "W"), - TCArg("unsigned short int", "H") - ), - "KerNormBW_fps_T", NULL - ); - - LibKernel("CNN_NormBW_fp", CALL_PARALLEL, - CArgs(4, - TCArg("unsigned char *__restrict__", "In"), - TCArg("signed short int *__restrict__", "Out"), - TCArg("unsigned short int", "W"), - TCArg("unsigned short int", "H") - ), - "KerNormBW_fp_T", NULL - ); - - LibKernel("CNN_FpsFpu", CALL_PARALLEL, - CArgs(5, - TCArg("signed char *__restrict__", "In"), - TCArg("unsigned char *__restrict__", "Out"), - TCArg("unsigned short int", "W"), - TCArg("unsigned short int", "H"), - TCArg("signed char *__restrict__", "Infos") - ), - "CNN_FpsFpu_T", NULL - ); - - LibKernel("CNN_FpuFps", CALL_PARALLEL, - CArgs(5, - TCArg("unsigned char *__restrict__", "In"), - TCArg("signed char *__restrict__", "Out"), - TCArg("unsigned short int", "W"), - TCArg("unsigned short int", "H"), - TCArg("signed char *__restrict__", "Infos") - ), - "CNN_FpuFps_T", NULL - ); - - // LibKernel("CNN_Copy_fps", CALL_PARALLEL, - // CArgs(4, - // TCArg("signed char *__restrict__", "In"), - // TCArg("signed char *__restrict__", "Out"), - // TCArg("unsigned int", "W"), - // TCArg("unsigned int", "H") - // ), - // "KerCopy_fps_T", NULL - // ); -} - -/********************************************************************************************************************************************************************* - Generator for RGB565 image preprocessing: - -Template: -Name: Name of the generated user kernel - -Width Image width -Height Image height - -DoOffset If true offset pixel by -128 - -Signature: Name(In, Out) - -Kop: NNTOOL_KOP_RGB16, NNTOOL_KOP_RGB565, NNTOOL_KOP_RGB888 - - *********************************************************************************************************************************************************************/ - -int CNN_NormRGB( - char *Name, - int Width, - int Height, - int DoOffset, - nntool_kop_t kop - ) - -{ - int Log = 1; - char *BodyName = AppendNames(Name, "Body"); - unsigned long long int LayerOp = (Width*Height*4) + (Width*Height*(DoOffset?2:1))/4; - unsigned long long int LayerBandwidth = 0; - - char *NormRGBKerName = (kop==NNTOOL_KOP_RGB16?"CNN_NormRGB16_fp":(kop==NNTOOL_KOP_RGB565?(DoOffset?"CNN_NormRGB565_offset_fps":"CNN_NormRGB565_shift_fps"):(DoOffset?"CNN_NormRGB888_offset_fps":"CNN_NormRGB888_shift_fps"))); - - LayerBandwidth += 2*Width*Height*1; - LayerBandwidth += 3*Width*Height*1; - - if (Log) { - printf("CNN_NormRGB%d: %s\n", (kop==NNTOOL_KOP_RGB16?16:(kop==NNTOOL_KOP_RGB565?565:888)), Name); - printf("In => Feat: %d W: %4d, H: %4d\n", (kop==NNTOOL_KOP_RGB565?1:3), Width, Height); - printf("Out => Feat: 3, W: %4d, H: %4d\n", Width, Height); - if (NormRGBKerName) printf("%20s: %s\n", "KerName", NormRGBKerName); - printf("Nb Oper : %lld\n", LayerOp); - } - - Object_T **PKerArgs = AllocateKerArgs(4); - PKerArgs[0] = KerArg("In", KerArgSpace(1,T0), O_IN|O_DB, Width*(kop==NNTOOL_KOP_RGB565?1:3), Height, (kop==NNTOOL_KOP_RGB565?2:1), 0, 0, 0, "In"); - PKerArgs[1] = KerArg("Out0", KerArgSpace(1,T0), O_OUT|O_DB, Width, Height, (kop==NNTOOL_KOP_RGB16?2:1), 0, 0, 0, "Out0"); - PKerArgs[2] = KerArg("Out1", KerArgSpace(1,T0), O_OUT|O_DB, Width, Height, (kop==NNTOOL_KOP_RGB16?2:1), 0, 0, 0, "Out1"); - PKerArgs[3] = KerArg("Out2", KerArgSpace(1,T0), O_OUT|O_DB, Width, Height, (kop==NNTOOL_KOP_RGB16?2:1), 0, 0, 0, "Out2"); - OpenKernelGroup(Name); - UserKernel(BodyName, - KernelIterSpace(1, IterTiledSpace(T0)), - TILE_HOR, - CArgs(4, TCArg(CNN_ArgDataTypeUns((kop==NNTOOL_KOP_RGB565?2:1),1,1), "In"), - TCArg(CNN_ArgDataType((kop==NNTOOL_KOP_RGB16?2:1),1,1), "Out0"), - TCArg(CNN_ArgDataType((kop==NNTOOL_KOP_RGB16?2:1),1,1), "Out1"), - TCArg(CNN_ArgDataType((kop==NNTOOL_KOP_RGB16?2:1),1,1), "Out2") - ), - Calls(1, - Call(NormRGBKerName, LOC_LOOP, - Bindings(6, - K_Arg("In", KER_ARG_TILE), /* Input tile */ - K_Arg("Out0", KER_ARG_TILE), /* Output tile */ - K_Arg("Out1", KER_ARG_TILE), /* Output tile */ - K_Arg("Out2", KER_ARG_TILE), /* Output tile */ - K_Arg((kop==NNTOOL_KOP_RGB565?"In":"Out0"), KER_ARG_TILE_W), /* tile width */ - K_Arg((kop==NNTOOL_KOP_RGB565?"In":"Out0"), KER_ARG_TILE_H) /* tile height */ - ) - ) - ), - PKerArgs - ); - AddKernelInfos(BodyName, AT_KERINFO_OPER, LayerOp, 0); - AddKernelInfos(BodyName, AT_KERINFO_BANDWIDTH, LayerBandwidth, 0); - AddKernelArgDim(BodyName, "In", 4, (kop==NNTOOL_KOP_RGB565?1:3), Height, Width, (kop==NNTOOL_KOP_RGB565?2:1)); - AddKernelArgDim(BodyName, "Out0", 4, 1, Height, Width, (kop==NNTOOL_KOP_RGB16?2:1)); - AddKernelArgDim(BodyName, "Out1", 4, 1, Height, Width, (kop==NNTOOL_KOP_RGB16?2:1)); - AddKernelArgDim(BodyName, "Out2", 4, 1, Height, Width, (kop==NNTOOL_KOP_RGB16?2:1)); - CloseKernelGroup(); - CKernel_Arg_T **KCArgs = AllocateCArgs(2); - int Ca=0; - KCArgs[Ca++] = TCArg(CNN_ArgDataTypeUns((kop==NNTOOL_KOP_RGB565?2:1),1,1), "In"); - KCArgs[Ca++] = TCArg(CNN_ArgDataType( (kop==NNTOOL_KOP_RGB16?2:1), 1,1), "Out"); - Object_T **KArgs = AllocateKerArgs(7); - int Ka=0; - KArgs[Ka++] = KerGroupArg("In", O_IN, Width*Height*(kop==NNTOOL_KOP_RGB565?1:3), (kop==NNTOOL_KOP_RGB565?2:1), "In"); - KArgs[Ka++] = KerGroupArg("Out", O_OUT, Width*Height*3, (kop==NNTOOL_KOP_RGB16?2:1), "Out"); - UserKernelGroup(Name, - KCArgs, - Calls(1, - UserKernelCall(BodyName, LOC_GROUP, - Bindings(4, - C_Arg("In"), - C_ArgPlusImmOffset("Out", 0), - C_ArgPlusImmOffset("Out", Height * Width), - C_ArgPlusImmOffset("Out", Height * Width * 2) - - ) - ) - ) - ); - return 0; - -} - -int CNN_NormBW( - char *Name, - int Width, - int Height, - int DoOffset, - nntool_kop_t kop - ) -{ - int Log = 1; - unsigned long long int LayerOp = Width*Height; - unsigned long long int LayerBandwidth = 0; - char *NormBWKerName = (kop==NNTOOL_KOP_BW16?"CNN_NormBW_fp":(DoOffset?"CNN_NormBW_offset_fps":"CNN_NormBW_shift_fps")); - - LayerBandwidth += Width*Height*1; - LayerBandwidth += Width*Height*1; - - if (Log) { - printf("CNN_NormBW: %s\n", Name); - printf("In => Feat: 1 W: %4d, H: %4d\n", Width, Height); - printf("Out => Feat: 1, W: %4d, H: %4d\n", Width, Height); - if (NormBWKerName) printf("%20s: %s\n", "KerName", NormBWKerName); - printf("Nb Oper : %lld\n", LayerOp); - } - - Object_T **PKerArgs = AllocateKerArgs(2); - PKerArgs[0] = KerArg("In", KerArgSpace(1,T0), O_IN|O_DB, Width, Height, 1, 0, 0, 0, "In"); - PKerArgs[1] = KerArg("Out", KerArgSpace(1,T0), O_OUT|O_DB, Width, Height, (kop==NNTOOL_KOP_BW16?2:1), 0, 0, 0, "Out"); - UserKernel(Name, - KernelIterSpace(1, IterTiledSpace(T0)), - TILE_HOR, - CArgs(2, TCArg(CNN_ArgDataTypeUns(1,1,1), "In"), TCArg(CNN_ArgDataType((kop==NNTOOL_KOP_BW16?2:1),1,1), "Out")), - Calls(1, - Call(NormBWKerName, LOC_LOOP, - Bindings(4, - K_Arg("In", KER_ARG_TILE), /* Input tile */ - K_Arg("Out", KER_ARG_TILE), /* Output tile */ - K_Arg("In", KER_ARG_TILE_W), /* Input tile width */ - K_Arg("In", KER_ARG_TILE_H) /* Input tile width */ - ) - ) - ), - PKerArgs - ); - AddKernelInfos(Name, AT_KERINFO_OPER, LayerOp, 0); - AddKernelInfos(Name, AT_KERINFO_BANDWIDTH, LayerBandwidth, 0); - AddKernelArgDim(Name, "In", 4, 1, Height, Width, 1); - AddKernelArgDim(Name, "Out", 4, 1, Height, Width, 1); - return 0; -} - -int CNN_Norm( - char *Name, - int Width, - int Height, - int DoOffset, - nntool_kop_t kop - ) -{ - if (kop == NNTOOL_KOP_BW || kop == NNTOOL_KOP_BW16) { - return CNN_NormBW(Name, Width, Height, DoOffset, kop); - } else { - return CNN_NormRGB(Name, Width, Height, DoOffset, kop); - } -} - -int CNN_SignedUnsigned( - char *Name, - int In_DataSize, - int Out_DataSize, - int Sz -) -{ - int Log = 1; - int Width = primeFactors(Sz); - int Height = Sz / Width; - unsigned long long int LayerOp = 1 * Sz; - unsigned long long int LayerBandwidth = 0; - char * kop; - if (In_DataSize == 1 && Out_DataSize == -1) { - kop = "CNN_FpsFpu"; - } else if (In_DataSize == -1 && Out_DataSize == 1) { - kop = "CNN_FpuFps"; - } else { - GenTilingError("CNN_SignedUnsigned Kernel: %s, Invalid input data size", Name); - } - - LayerBandwidth += Sz*2; - - if (Log) { - printf("CNN_SignedUnsigned: %s\n", Name); - printf("In => Feat: 1 W: %4d, H: %4d\n", Width, Height); - printf("Out => Feat: 1, W: %4d, H: %4d\n", Width, Height); - printf("Nb Oper : %lld\n", LayerOp); - } - - Object_T **PKerArgs = AllocateKerArgs(3); - PKerArgs[0] = KerArg("In", KerArgSpace(1,T0), O_IN|O_DB, Width, Height, 1, 0, 0, 0, "In"); - PKerArgs[1] = KerArg("Out", KerArgSpace(1,T0), O_OUT|O_DB, Width, Height, 1, 0, 0, 0, "Out"); - PKerArgs[2] = KerArg("Infos",KerArgSpace(1,T0), O_IN|O_BUFF|O_NTILED, 1, 1, 1, 0, 0, 0, "Infos"); - Kernel_T *Kernel = UserKernel(Name, - KernelIterSpace(1, IterTiledSpace(T0)), - TILE_HOR, - CArgs(3, - TCArg(CNN_ArgDataType(1,1,1), "In"), - TCArg(CNN_ArgDataType(1,1,1), "Out"), - TCArg(CNN_ArgDataType(1,1,1), "Infos") - ), - Calls(1, - Call(kop, LOC_LOOP, - Bindings(5, - K_Arg("In", KER_ARG_TILE), /* Input tile */ - K_Arg("Out", KER_ARG_TILE), /* Output tile */ - K_Arg("In", KER_ARG_TILE_W), /* Input tile width */ - K_Arg("In", KER_ARG_TILE_H), /* Input tile height */ - K_Arg("Infos", KER_ARG_TILE) - ) - ) - ), - PKerArgs - ); - if (Kernel) { - AddKernelInfos(Name, AT_KERINFO_OPER, LayerOp, 0); - AddKernelInfos(Name, AT_KERINFO_BANDWIDTH, LayerBandwidth, 0); - AddKernelArgDim(Name, "In", 4, 1, Height, Width, 1); - AddKernelArgDim(Name, "Out", 4, 1, Height, Width, 1); - AddKernelArgDim(Name, "Infos", 2, 1, 1); - } - return (Kernel!=0); -} - -// int CNN_Copy( -// char *Name, -// CNN_GenControl_T *Ctrl, -// int Sz) -// { -// int Log = 1; -// int Width = Sz; -// int Height = Sz / Width; -// unsigned long long int LayerOp = 0; -// unsigned long long int LayerBandwidth = 0; - -// LayerBandwidth += Sz*2; - -// if (Log) { -// printf("CNN_Copy: %s\n", Name); -// printf("In => Feat: 1 W: %4d, H: %4d\n", Width, Height); -// printf("Out => Feat: 1, W: %4d, H: %4d\n", Width, Height); -// printf("Nb Oper : %lld\n", LayerOp); -// } - -// Object_T **PKerArgs = AllocateKerArgs(2); -// PKerArgs[0] = KerArg("In", KerArgSpace(1,T0), O_IN|O_DB, Width, Height, 1, 0, 0, 0, "In"); -// PKerArgs[1] = KerArg("Out", KerArgSpace(1,T0), O_OUT|O_DB, Width, Height, 1, 0, 0, 0, "Out"); -// UserKernel(Name, -// KernelIterSpace(1, IterTiledSpace(T0)), -// TILE_HOR, -// CArgs(2, TCArg(CNN_ArgDataType(1,1,1), "In"), TCArg(CNN_ArgDataType(1,1,1), "Out")), -// Calls(1, -// Call("CNN_Copy_fps", LOC_LOOP, -// Bindings(4, -// K_Arg("In", KER_ARG_TILE), /* Input tile */ -// K_Arg("Out", KER_ARG_TILE), /* Output tile */ -// K_Arg("In", KER_ARG_TILE_W), /* Input tile width */ -// K_Arg("In", KER_ARG_TILE_H) /* Input tile height */ -// ) -// ) -// ), -// PKerArgs -// ); -// AddKernelInfos(Name, AT_KERINFO_OPER, LayerOp, 0); -// AddKernelInfos(Name, AT_KERINFO_BANDWIDTH, LayerBandwidth, 0); -// AddKernelArgDim(Name, "In", 4, 1, Height, Width, 1); -// AddKernelArgDim(Name, "Out", 4, 1, Height, Width, 1); -// return 0; -// } - diff --git a/tools/nntool/autotiler/generators/nntool_extra_generators.h b/tools/nntool/autotiler/generators/nntool_extra_generators.h deleted file mode 100644 index 44e09fea7..000000000 --- a/tools/nntool/autotiler/generators/nntool_extra_generators.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __NNTOOL_EXTRA_GENERATORS__ -#define __NNTOOL_EXTRA_GENERATORS__ -#include -#include "AutoTilerLib.h" - -typedef enum { - NNTOOL_KOP_RGB565, - NNTOOL_KOP_RGB888, - NNTOOL_KOP_RGB16, - NNTOOL_KOP_BW, - NNTOOL_KOP_BW16 -} nntool_kop_t; - -void LoadNNTools_Extra_Library(); -int CNN_Norm( - char *Name, - - int Width, - int Height, - int DoOffset, - nntool_kop_t kop -); -int CNN_SignedUnsigned( - char *Name, - int In_DataSize, - int Out_DataSize, - int Sz -); -// int CNN_Copy( -// char *Name, -// CNN_GenControl_T *Ctrl, -// int Sz -// ); - -#endif diff --git a/tools/nntool/autotiler/kernels/copy.c b/tools/nntool/autotiler/kernels/copy.c deleted file mode 100644 index ad5c5f6da..000000000 --- a/tools/nntool/autotiler/kernels/copy.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2021 GreenWaves Technologies, SAS - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wextra" -#pragma GCC diagnostic ignored "-Wpointer-sign" -#pragma GCC diagnostic ignored "-Wsign-compare" - -#include "nntool_extra_kernels.h" - -static int CoreCountDynamic = 1; -static int ActiveCore = gap_ncore(); - -static inline unsigned int __attribute__((always_inline)) ChunkSize(unsigned int X) - -{ - unsigned int NCore; - unsigned int Log2Core; - unsigned int Chunk; - - if (CoreCountDynamic) NCore = ActiveCore; else NCore = gap_ncore(); - Log2Core = gap_fl1(NCore); - Chunk = (X>>Log2Core) + ((X&(NCore-1))!=0); - return Chunk; -} - -#define B_CLR(x, bits) ((x)&(~((1<<(bits))-1))) - -// void CNN_Copy_fps(KerCopy_fps_T * Arg) -// { -// unsigned int Size = Arg->W * Arg->H; -// unsigned int CoreId = gap_coreid(); -// unsigned int Chunk = ChunkSize(Size), First = Chunk*CoreId, Last = Min(First+Chunk, Size); -// unsigned int Iter = Max(0, Last-First); -// signed char *__restrict__ From = Arg->In; -// signed char *__restrict__ To = Arg->Out; - -// int *pFrom = (int *) (From+First), *pTo = (int *) (To+First); -// for (int i=0; i(b))?(a):(b)) -#endif - -#ifdef GENASM -#ifdef __EMUL__ -#define gap_ncore() 8 -#define gap_coreid() __builtin_pulp_CoreId() -#endif -#endif - -// typedef struct { -// signed char *__restrict__ In; /**< Input matrix */ -// signed char *__restrict__ Out; /**< Output matrix */ -// unsigned int W; /**< Tile width */ -// unsigned int H; /**< Tile height */ -// } KerCopy_fps_T; - -typedef struct { - unsigned short *__restrict__ In; /**< Input matrix */ - signed char *__restrict__ Out0; /**< Output matrix */ - signed char *__restrict__ Out1; /**< Output matrix */ - signed char *__restrict__ Out2; /**< Output matrix */ - unsigned int W; /**< Matrix width */ - unsigned int H; /**< Matrix height */ -} KerNormRGB565_fps_T; - -typedef struct { - unsigned char *__restrict__ In; /**< Input matrix */ - signed char *__restrict__ Out0; /**< Output matrix */ - signed char *__restrict__ Out1; /**< Output matrix */ - signed char *__restrict__ Out2; /**< Output matrix */ - unsigned int W; /**< Matrix width */ - unsigned int H; /**< Matrix height */ -} KerNormRGB888_fps_T; - -typedef struct { - unsigned char *__restrict__ In; /**< Input matrix */ - signed short int *__restrict__ Out0; /**< Output matrix */ - signed short int *__restrict__ Out1; /**< Output matrix */ - signed short int *__restrict__ Out2; /**< Output matrix */ - unsigned int W; /**< Matrix width */ - unsigned int H; /**< Matrix height */ -} KerNormRGB16_fp_T; - -typedef struct { - unsigned char *__restrict__ In; /**< Input matrix */ - signed char *__restrict__ Out; /**< Output matrix */ - unsigned int W; /**< Matrix width */ - unsigned int H; /**< Matrix height */ -} KerNormBW_fps_T; - -typedef struct { - unsigned char *__restrict__ In; /**< Input matrix */ - signed short int *__restrict__ Out; /**< Output matrix */ - unsigned int W; /**< Matrix width */ - unsigned int H; /**< Matrix height */ -} KerNormBW_fp_T; - - -typedef struct { - signed char *__restrict__ In; - unsigned char *__restrict__ Out; - unsigned short int W; - unsigned short int H; - signed char *__restrict__ Infos; -} CNN_FpsFpu_T; - -typedef struct { - unsigned char *__restrict__ In; - signed char *__restrict__ Out; - unsigned short int W; - unsigned short int H; - signed char *__restrict__ Infos; -} CNN_FpuFps_T; - -void CNN_NormRGB565_offset_fps(KerNormRGB565_fps_T *Arg); -void CNN_NormRGB565_shift_fps(KerNormRGB565_fps_T *Arg); -void CNN_NormRGB888_offset_fps(KerNormRGB888_fps_T *Arg); -void CNN_NormRGB888_shift_fps(KerNormRGB888_fps_T *Arg); -void CNN_NormRGB16_fp(KerNormRGB16_fp_T *Arg); -void CNN_NormBW_offset_fps(KerNormBW_fps_T *Arg); -void CNN_NormBW_shift_fps(KerNormBW_fps_T *Arg); -void CNN_NormBW_fp(KerNormBW_fp_T *Arg); -void CNN_FpuFps(CNN_FpuFps_T *Args); -void CNN_FpsFpu(CNN_FpsFpu_T *Args); -// void CNN_Copy_fps(KerCopy_fps_T * args); - -#endif diff --git a/tools/nntool/autotiler/kernels/norm_transpose.c b/tools/nntool/autotiler/kernels/norm_transpose.c deleted file mode 100644 index b8c07b281..000000000 --- a/tools/nntool/autotiler/kernels/norm_transpose.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright 2021 GreenWaves Technologies, SAS - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wextra" -#pragma GCC diagnostic ignored "-Wpointer-sign" -#pragma GCC diagnostic ignored "-Wsign-compare" - -#include "nntool_extra_kernels.h" - -static int CoreCountDynamic = 1; -static int ActiveCore = gap_ncore(); - -static inline unsigned int __attribute__((always_inline)) ChunkSize(unsigned int X) - -{ - unsigned int NCore; - unsigned int Log2Core; - unsigned int Chunk; - - if (CoreCountDynamic) NCore = ActiveCore; else NCore = gap_ncore(); - Log2Core = gap_fl1(NCore); - Chunk = (X>>Log2Core) + ((X&(NCore-1))!=0); - return Chunk; -} - -void CNN_NormRGB565_offset_fps(KerNormRGB565_fps_T *Arg) - -{ - unsigned short *__restrict__ In = Arg->In; - signed char *__restrict__ Out0 = Arg->Out0; - signed char *__restrict__ Out1 = Arg->Out1; - signed char *__restrict__ Out2 = Arg->Out2; - unsigned int W = Arg->W; - unsigned int H = Arg->H; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H), First = Chunk*CoreId, Last = Min(First+Chunk, H); - for (int h=First; hIn; - signed char *__restrict__ Out0 = Arg->Out0; - signed char *__restrict__ Out1 = Arg->Out1; - signed char *__restrict__ Out2 = Arg->Out2; - unsigned int W = Arg->W; - unsigned int H = Arg->H; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(H), First = Chunk*CoreId, Last = Min(First+Chunk, H); - - for (int h=First; hIn; - signed char *__restrict__ Out0 = Arg->Out0; - signed char *__restrict__ Out1 = Arg->Out1; - signed char *__restrict__ Out2 = Arg->Out2; - unsigned int W = Arg->W; - unsigned int H = Arg->H; - unsigned int Sz = W * H; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Sz), First = Chunk*CoreId, Last = Min(First+Chunk, Sz); - - unsigned int Diff = Last-First; - for (int OutIdx=First; OutIdx<(First+((Diff*4)/4)); OutIdx+=4) { - int InIdx0 = OutIdx * 3, InIdx1 = InIdx0 + 6; - *((v4u *)&Out0[OutIdx]) = __builtin_shuffle(*((v4u *) &In[InIdx0++]), *((v4u *) &In[InIdx1++]), (v4u) {0, 3, 4, 7}) >> 1; - *((v4u *)&Out1[OutIdx]) = __builtin_shuffle(*((v4u *) &In[InIdx0++]), *((v4u *) &In[InIdx1++]), (v4u) {0, 3, 4, 7}) >> 1; - *((v4u *)&Out2[OutIdx]) = __builtin_shuffle(*((v4u *) &In[InIdx0++]), *((v4u *) &In[InIdx1++]), (v4u) {0, 3, 4, 7}) >> 1; - } - int Left = Diff&0x3; - for (int i=Last-Left, InIdx=i*3; i> 1; - Out1[i] = In[InIdx++] >> 1; - Out2[i] = In[InIdx++] >> 1; - } - gap_waitbarrier(0); -} - -void CNN_NormRGB888_offset_fps(KerNormRGB888_fps_T *Arg) -{ - unsigned char *__restrict__ In = Arg->In; - signed char *__restrict__ Out0 = Arg->Out0; - signed char *__restrict__ Out1 = Arg->Out1; - signed char *__restrict__ Out2 = Arg->Out2; - unsigned int W = Arg->W; - unsigned int H = Arg->H; - unsigned int Sz = W * H; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Sz), First = Chunk*CoreId, Last = Min(First+Chunk, Sz); - - unsigned int InIdx = First * 3; - for (int OutIdx=First; OutIdxIn; - signed short int *__restrict__ Out0 = Arg->Out0; - signed short int *__restrict__ Out1 = Arg->Out1; - signed short int *__restrict__ Out2 = Arg->Out2; - unsigned int W = Arg->W; - unsigned int H = Arg->H; - unsigned int Sz = W * H; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Sz), First = Chunk*CoreId, Last = Min(First+Chunk, Sz); - - unsigned int InIdx = First * 3; - for (int OutIdx=First; OutIdxIn; - signed char *__restrict__ Out = Arg->Out; - unsigned int W = Arg->W; - unsigned int H = Arg->H; - unsigned int Sz = W * H; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Sz), First = Chunk*CoreId, Last = Min(First+Chunk, Sz); - - unsigned int Diff = Last-First; - for (int Idx=First; Idx> 1; - } - int Left = Diff&0x3; - for (int i=Last-Left; i> 1; - } - gap_waitbarrier(0); -} - -void CNN_NormBW_offset_fps(KerNormBW_fps_T *Arg) -{ - unsigned char *__restrict__ In = Arg->In; - signed char *__restrict__ Out = Arg->Out; - unsigned int W = Arg->W; - unsigned int H = Arg->H; - unsigned int Sz = W * H; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Sz), First = Chunk*CoreId, Last = Min(First+Chunk, Sz); - - for (int Idx=First; IdxIn; - signed short int *__restrict__ Out = Arg->Out; - unsigned int W = Arg->W; - unsigned int H = Arg->H; - unsigned int Sz = W * H; - unsigned int CoreId = gap_coreid(), Chunk = ChunkSize(Sz), First = Chunk*CoreId, Last = Min(First+Chunk, Sz); - - unsigned int Diff = Last-First; - for (int Idx=First; IdxW * Arg->H; - unsigned int CoreId = gap_coreid(); - unsigned int Chunk = ChunkSize(Size), First = Chunk*CoreId, Last = Min(First+Chunk, Size); - unsigned int Iter = Max(0, Last-First); - Int8toUint8((Arg->In + First), (signed char *)(Arg->Out + First), (unsigned char) Arg->Infos[0], Iter); -} - -void CNN_FpuFps(CNN_FpuFps_T * Arg) -{ - unsigned int Size = Arg->W * Arg->H; - unsigned int CoreId = gap_coreid(); - unsigned int Chunk = ChunkSize(Size), First = Chunk*CoreId, Last = Min(First+Chunk, Size); - unsigned int Iter = Max(0, Last-First); - unsigned char Offset = (unsigned char) Arg->Infos[0]; - Int8toUint8((signed char *)(Arg->In + First), (Arg->Out + First), (unsigned char) Arg->Infos[0], Iter); -} - - -#pragma GCC diagnostic pop diff --git a/tools/nntool/autotiler/math_funcs/float_math_funcs.c b/tools/nntool/autotiler/math_funcs/float_math_funcs.c deleted file mode 100644 index 88ea52834..000000000 --- a/tools/nntool/autotiler/math_funcs/float_math_funcs.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2021 GreenWaves Technologies, SAS - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "float_math_funcs.h" - -float32_t ffast_cos(float32_t val) { - return plp_cos_f32s_xpulpv2(val); -} - -float32_t ffast_sin(float32_t val) { - return plp_sin_f32s_xpulpv2(val); -} - -float32_t ffast_sigmoid(float32_t val, float32_t alpha) { - return 0.5F * (val * alpha / (1.0F + fabs(val*alpha))) + 0.5F; -} - -float32_t fsigmoid(float32_t val) { - return 1.0F / (1.0F + exp(-val)); -} diff --git a/tools/nntool/autotiler/math_funcs/math_funcs.c b/tools/nntool/autotiler/math_funcs/math_funcs.c deleted file mode 100644 index 1689b7ae0..000000000 --- a/tools/nntool/autotiler/math_funcs/math_funcs.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright 2021 GreenWaves Technologies, SAS - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wextra" -#pragma GCC diagnostic ignored "-Wpointer-sign" -#pragma GCC diagnostic ignored "-Wsign-compare" - -#include "math_funcs.h" - -typedef unsigned long long uint64; -typedef unsigned int uint32; -typedef unsigned short uint16; -typedef unsigned char uint8; - -typedef signed long long int64; -typedef signed int int32; -typedef signed short int16; -typedef signed char int8; - -#define ARRAYSIZE(x) (sizeof(x) / sizeof(x[ 0 ])) - -/** - * ln(2) in 1.15 format - */ - -#define LN_2_1F15 0x000058B9 - - -/* square root coefficients in 17.15 fixed point format */ - -int SqrtCoeffTable[] = -{ - 0x00001A91, 0x0000BA3A, 0xFFFF53DA, 0x00008DAC, - 0xFFFFBB54, 0x00000E5A -}; - -/* square root of 2 powered to (index - 15) in 17.15 format */ - -int Sqrt2Powers[] = -{ - 0x000000B5, 0x00000100, 0x0000016A, 0x00000200, - 0x000002D4, 0x00000400, 0x000005A8, 0x00000800, - 0x00000B50, 0x00001000, 0x000016A1, 0x00002000, - 0x00002D41, 0x00004000, 0x00005A82, 0x00008000, - 0x0000B505, 0x00010000, 0x00016A0A, 0x00020000, - 0x0002D414, 0x00040000, 0x0005A828, 0x00080000, - 0x000B504F, 0x00100000, 0x0016A09E, 0x00200000, - 0x002D413D, 0x00400000, 0x005A827A, 0x00800000 -}; - -/* natural logarithm coefficients in 17.15 fixed point format */ - -int LognCoeffTable[] = // N -{ - 0x00007FE3, 0xFFFFC149, 0x00002491, 0xFFFFEEF8, - 0x00000404 -}; - -/* integer and fraction parts of exponent values */ - -static unsigned short int IntegerExpLUT[] = -{ - 0x0001, 0x0002, 0x0007, 0x0014, - 0x0036, 0x0094, 0x0193, 0x0448, - 0x0BA4, 0x1FA7, 0x560A, 0xE9E2 -}; - -static unsigned short int FractionExpLUT[] = -{ - 0x0000, 0x5BF1, 0x31CD, 0x0AF3, - 0x4C90, 0x34E2, 0x36E3, 0x510B, - 0x7A9F, 0x0ABE, 0x3B9F, 0x1224 -}; - -/* 17.15 fixed point format */ -static unsigned short int ExpCoeffLUT[] = { - 0x7FFF, 0x7FFF, 0x4000, 0x1555, - 0x0555, 0x0111, 0x002E, 0x0007, - 0x0001 -}; - -uint32 sqrt_17_15(uint32 x) - -{ - unsigned int exponent, y, result, z; - - if (!x) - return 0; - if (x > 0x7FFFFFFF) return 0; /* negative value */ - exponent = (unsigned int) gap_clb ((int) x); - y = ((x << exponent) >> 16); - - /* sqrt(x) = 0.2075806 + 1.454895 * x - 1.34491 * x^2 + 1.106812 * x^3 - 0.536499 * x^4 + 0.1121216 * x^5 */ - z = y; - result = 0; - for (int i = 1; i < ARRAYSIZE (SqrtCoeffTable); i++) { - result += z * SqrtCoeffTable[ i ]; - z = ((z * y) >> 15); - } - result >>= 15; - result += SqrtCoeffTable[ 0 ]; - if (exponent != 16) { - if (exponent < 12) result = (((result>>(12-exponent)) * Sqrt2Powers[ 31 - exponent ]) >> (15-(12-exponent))); - else result = ((result * Sqrt2Powers[ 31 - exponent ]) >> 15); - } - - return (uint32) result; -} - -uint32 logn_17_15(uint32 x) -{ - register unsigned int i, exponent; - register int result, y, z; - - if (!x) - return 0x80000000; - if (x > 0x7FFFFFFF) - return 0x80000000; /* negative value */ - - // exponent = (unsigned int) norm ((int) x); - exponent = (unsigned int) gap_clb ((int) x); - y = ((x << exponent) >> 15) - 0x8000; - - /** - * ln(x) = 0.9991150 * (x -1) - 0.4899597 * (x -1) ^ 2 - * + 0.2856751 * (x -1) ^ 3 - 0.1330566 * (x -1) ^ 4 - * + 0.03137207 * (x -1) ^ 5 - */ - z = ((y * y) >> 15); - result = LognCoeffTable[ 0 ] * y; - for (i = 1; i < ARRAYSIZE (LognCoeffTable); i++) - { - result += z * LognCoeffTable[ i ]; - z = ((z * y) >> 15); - } - result >>= 15; - if (exponent != 15) - result += LN_2_1F15 * (15 - exponent); - - return (uint32) result; -} - -#define gap_mulshRN(x, y, n) (short int) gap_mulsRN(x, y, n) -#define ARRAYSIZE(x) (sizeof(x) / sizeof(x[ 0 ])) - -/* X : fixed point, format Q17.15, returns in Q17.15 */ -unsigned int exp_17_15(unsigned int X) - -{ - int Y, Result, IntX, FractX, ScaledInt; - short int Z_s, FractX_s; - unsigned short int ScaledFract; - - if (!X) return 0x8000; - Y = gap_abs((int)X); - IntX = (Y >> 15); - if (IntX >= (int) ARRAYSIZE (IntegerExpLUT)) { - if (Y==X) return 0x7FFFFFFF; else return 0; - } - FractX = (Y & 0x7FFF); - if (gap_bitextractu(FractX, 1, 14)) { - /* Taylor series converges quickly only when | FractX | < 0.5 */ - FractX -= 0x8000; IntX++; - } - ScaledInt = IntegerExpLUT[IntX]; ScaledFract = FractionExpLUT[IntX]; - /* Taylor's series: exp(x) = 1 + x + x ^ 2 / 2 + x ^ 3 / 3! + x ^ 4 / 4! + x ^ 5 / 5! + x ^ 6 / 6! + x ^ 7 / 7! + x ^ 8 / 8! */ - FractX_s = FractX; Z_s = FractX; Result = 0; - for (int i = 1; i < ARRAYSIZE (ExpCoeffLUT); i++) { - Result += Z_s*ExpCoeffLUT[i]; // gap_macs(Result, Z, ExpCoeffLUT[ i ]); - Z_s = gap_mulsRN(Z_s, FractX_s, 15); - } - Result = gap_roundnorm(Result, 15) + ExpCoeffLUT[0]; - unsigned short int U_Res = Result; - Result = gap_muluRN(U_Res, ScaledFract, 15) + U_Res * ScaledInt; - if (Result && (X > 0x7FFFFFFF)) - Result = ((0x7FFFFFFF / Result) >> 1); /* negative value */ - return (unsigned int) Result; -} - -uint32 pow_17_15(uint32 x, uint32 y) -{ - if (x==0) return (unsigned int)(y==0 ? 1<<15 : 0); - int expo = gap_clipr((int)logn_17_15(x), (1 << gap_clb(y)) - 1); - return exp_17_15((unsigned int)gap_roundnorm_reg((int)y * expo, 15)); -} - -int square_17_15(int x) -{ - return gap_roundnorm_reg(x * x, 15); -} - -#define PI_Q17_15_DIV4 25736 // int(math.floor(0.5 + PI_Q17_15 / 4)) -#define PI_Q1_30_DIV4 843314857 // int(math.floor(0.5 + math.pi * math.pow(2, 30) / 4)) -#define ARCTAN_FAC_Q17_15 8946 // int(math.floor(0.5 + 0.273 * math.pow(2, 15))) -#define ONE_Q17_15 32768 // 1 << 15 - -int arctan_17_15(int x) -{ - // Valid for 1 > x > -1 - // This can use p.mulsRN and p.adduRN on GAP so 4 cycles - // p.mulsRN(x, p.adduRN(PI_Q1_30_DIV4, ARCTAN_FAC_Q17_15 * (ONE_Q17_15 - x))) - return gap_roundnorm_reg(x * gap_addroundnorm_reg(PI_Q1_30_DIV4, ARCTAN_FAC_Q17_15 * (ONE_Q17_15 - x), 15), 15); -} - -int16 fpsin(int16 i) -{ - /* Convert (signed) input to a value between 0 and 8192. (8192 is pi/2, which is the region of the curve fit). */ - /* ------------------------------------------------------------------- */ - i <<= 1; - int c = i<0; //set carry for output pos/neg - - if(i == (i|0x4000)) // flip input value to corresponding value in range [0..8192) - i = (1<<15) - i; - i = (i & 0x7FFF) >> 1; - /* ------------------------------------------------------------------- */ - - /* The following section implements the formula: - = y * 2^-n * ( A1 - 2^(q-p)* y * 2^-n * y * 2^-n * [B1 - 2^-r * y * 2^-n * C1 * y]) * 2^(a-q) - Where the constants are defined as follows: - */ - enum {A1=3370945099UL, B1=2746362156UL, C1=292421UL}; - enum {n=13, p=32, q=31, r=3, a=12}; - - uint32 y = (C1*((uint32)i))>>n; - y = B1 - (((uint32)i*y)>>r); - y = (uint32)i * (y>>n); - y = (uint32)i * (y>>n); - y = A1 - (y>>(p-q)); - y = (uint32)i * (y>>n); - y = gap_roundnormu(y, (q-a)); // Rounding - - return (c ? -((int16)y) : ((int16)y)); -} - -#pragma GCC diagnostic pop diff --git a/tools/nntool/autotiler/math_funcs/math_funcs.h b/tools/nntool/autotiler/math_funcs/math_funcs.h deleted file mode 100644 index 3512cee92..000000000 --- a/tools/nntool/autotiler/math_funcs/math_funcs.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2021 GreenWaves Technologies, SAS - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef __MATH_FUNCS_H -#define __MATH_FUNCS_H - -#include -#include -#include -#include "Gap.h" - -typedef unsigned long long uint64; -typedef unsigned int uint32; -typedef unsigned short uint16; -typedef unsigned char uint8; - -typedef signed long long int64; -typedef signed int int32; -typedef signed short int16; -typedef signed char int8; - -uint32 sqrt_17_15(uint32 x); -uint32 logn_17_15(uint32 x); -uint32 exp_17_15(uint32 x); -uint32 pow_17_15(uint32 x, uint32 y); - -int square_17_15(int x); - -int16 fpsin(int16 i); -// Cos(x) = sin(x + pi/2) -#define fpcos(i) fpsin((int16)(((uint16)(i)) + 8192U)) - -#endif \ No newline at end of file diff --git a/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_common_tables.c b/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_common_tables.c deleted file mode 100644 index d1cb1c3dc..000000000 --- a/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_common_tables.c +++ /dev/null @@ -1,131 +0,0 @@ -/** ========================================================================== - * @file plp_common_tables.c - * @brief File containing common tables - * @version V0 - * @date 28. June 2020 - * =========================================================================== */ -/* - * Copyright (C) 2020 ETH Zurich and University of Bologna. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PLP_COMMON_TABLES_H__ -#define __PLP_COMMON_TABLES_H__ - -#include "plp_math_extract.h" - -/** - @par - Example code for the generation of the floating-point sine table: -
-  tableSize = 512;
-  for (n = 0; n < (tableSize + 1); n++)
-  {
-  sinTable[n] = sin(2*PI*n/tableSize);
-  }
- @par - where PI value is 3.14159265358979 - */ - -const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1] = { - 0.00000000f, 0.01227154f, 0.02454123f, 0.03680722f, 0.04906767f, 0.06132074f, - 0.07356456f, 0.08579731f, 0.09801714f, 0.11022221f, 0.12241068f, 0.13458071f, - 0.14673047f, 0.15885814f, 0.17096189f, 0.18303989f, 0.19509032f, 0.20711138f, - 0.21910124f, 0.23105811f, 0.24298018f, 0.25486566f, 0.26671276f, 0.27851969f, - 0.29028468f, 0.30200595f, 0.31368174f, 0.32531029f, 0.33688985f, 0.34841868f, - 0.35989504f, 0.37131719f, 0.38268343f, 0.39399204f, 0.40524131f, 0.41642956f, - 0.42755509f, 0.43861624f, 0.44961133f, 0.46053871f, 0.47139674f, 0.48218377f, - 0.49289819f, 0.50353838f, 0.51410274f, 0.52458968f, 0.53499762f, 0.54532499f, - 0.55557023f, 0.56573181f, 0.57580819f, 0.58579786f, 0.59569930f, 0.60551104f, - 0.61523159f, 0.62485949f, 0.63439328f, 0.64383154f, 0.65317284f, 0.66241578f, - 0.67155895f, 0.68060100f, 0.68954054f, 0.69837625f, 0.70710678f, 0.71573083f, - 0.72424708f, 0.73265427f, 0.74095113f, 0.74913639f, 0.75720885f, 0.76516727f, - 0.77301045f, 0.78073723f, 0.78834643f, 0.79583690f, 0.80320753f, 0.81045720f, - 0.81758481f, 0.82458930f, 0.83146961f, 0.83822471f, 0.84485357f, 0.85135519f, - 0.85772861f, 0.86397286f, 0.87008699f, 0.87607009f, 0.88192126f, 0.88763962f, - 0.89322430f, 0.89867447f, 0.90398929f, 0.90916798f, 0.91420976f, 0.91911385f, - 0.92387953f, 0.92850608f, 0.93299280f, 0.93733901f, 0.94154407f, 0.94560733f, - 0.94952818f, 0.95330604f, 0.95694034f, 0.96043052f, 0.96377607f, 0.96697647f, - 0.97003125f, 0.97293995f, 0.97570213f, 0.97831737f, 0.98078528f, 0.98310549f, - 0.98527764f, 0.98730142f, 0.98917651f, 0.99090264f, 0.99247953f, 0.99390697f, - 0.99518473f, 0.99631261f, 0.99729046f, 0.99811811f, 0.99879546f, 0.99932238f, - 0.99969882f, 0.99992470f, 1.00000000f, 0.99992470f, 0.99969882f, 0.99932238f, - 0.99879546f, 0.99811811f, 0.99729046f, 0.99631261f, 0.99518473f, 0.99390697f, - 0.99247953f, 0.99090264f, 0.98917651f, 0.98730142f, 0.98527764f, 0.98310549f, - 0.98078528f, 0.97831737f, 0.97570213f, 0.97293995f, 0.97003125f, 0.96697647f, - 0.96377607f, 0.96043052f, 0.95694034f, 0.95330604f, 0.94952818f, 0.94560733f, - 0.94154407f, 0.93733901f, 0.93299280f, 0.92850608f, 0.92387953f, 0.91911385f, - 0.91420976f, 0.90916798f, 0.90398929f, 0.89867447f, 0.89322430f, 0.88763962f, - 0.88192126f, 0.87607009f, 0.87008699f, 0.86397286f, 0.85772861f, 0.85135519f, - 0.84485357f, 0.83822471f, 0.83146961f, 0.82458930f, 0.81758481f, 0.81045720f, - 0.80320753f, 0.79583690f, 0.78834643f, 0.78073723f, 0.77301045f, 0.76516727f, - 0.75720885f, 0.74913639f, 0.74095113f, 0.73265427f, 0.72424708f, 0.71573083f, - 0.70710678f, 0.69837625f, 0.68954054f, 0.68060100f, 0.67155895f, 0.66241578f, - 0.65317284f, 0.64383154f, 0.63439328f, 0.62485949f, 0.61523159f, 0.60551104f, - 0.59569930f, 0.58579786f, 0.57580819f, 0.56573181f, 0.55557023f, 0.54532499f, - 0.53499762f, 0.52458968f, 0.51410274f, 0.50353838f, 0.49289819f, 0.48218377f, - 0.47139674f, 0.46053871f, 0.44961133f, 0.43861624f, 0.42755509f, 0.41642956f, - 0.40524131f, 0.39399204f, 0.38268343f, 0.37131719f, 0.35989504f, 0.34841868f, - 0.33688985f, 0.32531029f, 0.31368174f, 0.30200595f, 0.29028468f, 0.27851969f, - 0.26671276f, 0.25486566f, 0.24298018f, 0.23105811f, 0.21910124f, 0.20711138f, - 0.19509032f, 0.18303989f, 0.17096189f, 0.15885814f, 0.14673047f, 0.13458071f, - 0.12241068f, 0.11022221f, 0.09801714f, 0.08579731f, 0.07356456f, 0.06132074f, - 0.04906767f, 0.03680722f, 0.02454123f, 0.01227154f, 0.00000000f, -0.01227154f, - -0.02454123f, -0.03680722f, -0.04906767f, -0.06132074f, -0.07356456f, -0.08579731f, - -0.09801714f, -0.11022221f, -0.12241068f, -0.13458071f, -0.14673047f, -0.15885814f, - -0.17096189f, -0.18303989f, -0.19509032f, -0.20711138f, -0.21910124f, -0.23105811f, - -0.24298018f, -0.25486566f, -0.26671276f, -0.27851969f, -0.29028468f, -0.30200595f, - -0.31368174f, -0.32531029f, -0.33688985f, -0.34841868f, -0.35989504f, -0.37131719f, - -0.38268343f, -0.39399204f, -0.40524131f, -0.41642956f, -0.42755509f, -0.43861624f, - -0.44961133f, -0.46053871f, -0.47139674f, -0.48218377f, -0.49289819f, -0.50353838f, - -0.51410274f, -0.52458968f, -0.53499762f, -0.54532499f, -0.55557023f, -0.56573181f, - -0.57580819f, -0.58579786f, -0.59569930f, -0.60551104f, -0.61523159f, -0.62485949f, - -0.63439328f, -0.64383154f, -0.65317284f, -0.66241578f, -0.67155895f, -0.68060100f, - -0.68954054f, -0.69837625f, -0.70710678f, -0.71573083f, -0.72424708f, -0.73265427f, - -0.74095113f, -0.74913639f, -0.75720885f, -0.76516727f, -0.77301045f, -0.78073723f, - -0.78834643f, -0.79583690f, -0.80320753f, -0.81045720f, -0.81758481f, -0.82458930f, - -0.83146961f, -0.83822471f, -0.84485357f, -0.85135519f, -0.85772861f, -0.86397286f, - -0.87008699f, -0.87607009f, -0.88192126f, -0.88763962f, -0.89322430f, -0.89867447f, - -0.90398929f, -0.90916798f, -0.91420976f, -0.91911385f, -0.92387953f, -0.92850608f, - -0.93299280f, -0.93733901f, -0.94154407f, -0.94560733f, -0.94952818f, -0.95330604f, - -0.95694034f, -0.96043052f, -0.96377607f, -0.96697647f, -0.97003125f, -0.97293995f, - -0.97570213f, -0.97831737f, -0.98078528f, -0.98310549f, -0.98527764f, -0.98730142f, - -0.98917651f, -0.99090264f, -0.99247953f, -0.99390697f, -0.99518473f, -0.99631261f, - -0.99729046f, -0.99811811f, -0.99879546f, -0.99932238f, -0.99969882f, -0.99992470f, - -1.00000000f, -0.99992470f, -0.99969882f, -0.99932238f, -0.99879546f, -0.99811811f, - -0.99729046f, -0.99631261f, -0.99518473f, -0.99390697f, -0.99247953f, -0.99090264f, - -0.98917651f, -0.98730142f, -0.98527764f, -0.98310549f, -0.98078528f, -0.97831737f, - -0.97570213f, -0.97293995f, -0.97003125f, -0.96697647f, -0.96377607f, -0.96043052f, - -0.95694034f, -0.95330604f, -0.94952818f, -0.94560733f, -0.94154407f, -0.93733901f, - -0.93299280f, -0.92850608f, -0.92387953f, -0.91911385f, -0.91420976f, -0.90916798f, - -0.90398929f, -0.89867447f, -0.89322430f, -0.88763962f, -0.88192126f, -0.87607009f, - -0.87008699f, -0.86397286f, -0.85772861f, -0.85135519f, -0.84485357f, -0.83822471f, - -0.83146961f, -0.82458930f, -0.81758481f, -0.81045720f, -0.80320753f, -0.79583690f, - -0.78834643f, -0.78073723f, -0.77301045f, -0.76516727f, -0.75720885f, -0.74913639f, - -0.74095113f, -0.73265427f, -0.72424708f, -0.71573083f, -0.70710678f, -0.69837625f, - -0.68954054f, -0.68060100f, -0.67155895f, -0.66241578f, -0.65317284f, -0.64383154f, - -0.63439328f, -0.62485949f, -0.61523159f, -0.60551104f, -0.59569930f, -0.58579786f, - -0.57580819f, -0.56573181f, -0.55557023f, -0.54532499f, -0.53499762f, -0.52458968f, - -0.51410274f, -0.50353838f, -0.49289819f, -0.48218377f, -0.47139674f, -0.46053871f, - -0.44961133f, -0.43861624f, -0.42755509f, -0.41642956f, -0.40524131f, -0.39399204f, - -0.38268343f, -0.37131719f, -0.35989504f, -0.34841868f, -0.33688985f, -0.32531029f, - -0.31368174f, -0.30200595f, -0.29028468f, -0.27851969f, -0.26671276f, -0.25486566f, - -0.24298018f, -0.23105811f, -0.21910124f, -0.20711138f, -0.19509032f, -0.18303989f, - -0.17096189f, -0.15885814f, -0.14673047f, -0.13458071f, -0.12241068f, -0.11022221f, - -0.09801714f, -0.08579731f, -0.07356456f, -0.06132074f, -0.04906767f, -0.03680722f, - -0.02454123f, -0.01227154f, -0.00000000f -}; -#endif \ No newline at end of file diff --git a/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_common_tables.h b/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_common_tables.h deleted file mode 100644 index fcc12cbec..000000000 --- a/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_common_tables.h +++ /dev/null @@ -1,31 +0,0 @@ -/** ========================================================================== - * @file plp_common_tables.h - * @brief File containing common tables - * @version V0 - * @date 28. June 2020 - * =========================================================================== */ -/* - * Copyright (C) 2020 ETH Zurich and University of Bologna. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PLP_COMMON_TABLES_H__ -#define __PLP_COMMON_TABLES_H__ - -#include "plp_math_extract.h" - -extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; -#endif \ No newline at end of file diff --git a/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_cos_f32s_xpulpv2.c b/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_cos_f32s_xpulpv2.c deleted file mode 100644 index c0f13fb6d..000000000 --- a/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_cos_f32s_xpulpv2.c +++ /dev/null @@ -1,91 +0,0 @@ -/* ===================================================================== - * Project: PULP DSP Library - * Title: plp_cos_f32s_xpulpv2.c - * Description: Calculates cosine of a floating point number in radians - * - * $Date: 30.07.2020 - * - * Target Processor: PULP cores - * ===================================================================== */ -/* - * Copyright (C) 2020 ETH Zurich and University of Bologna. - * - * Author: Michael Rogenmoser, ETH Zurich - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Notice: project inspired by ARM CMSIS DSP and parts of source code - * ported and adopted for RISC-V PULP platform from ARM CMSIS DSP - * released under Copyright (C) 2010-2019 ARM Limited or its affiliates - * with Apache-2.0. - */ - -#include "plp_common_tables.h" -#include "plp_math_extract.h" - -/** - * @brief Glue code for f32 cosine function - * - * @param[in] x input value in radians - * - * @return cos(x) - */ - -float32_t plp_cos_f32s_xpulpv2(float32_t x) { - float32_t cosVal, fract, in; /* Temporary input, output variables */ - uint16_t index; /* Index variable */ - float32_t a, b; /* Two nearest output values */ - int32_t n; - float32_t findex; - - /* input x is in radians */ - /* Scale input to [0 1] range from [0 2*PI] , divide input by 2*pi, add 0.25 (pi/2) to read sine - * table */ - in = x * 0.159154943092f + 0.25f; - - /* Calculation of floor value of input */ - n = (int32_t)in; - - /* Make negative values towards -infinity */ - if (in < 0.0f) { - n--; - } - - /* Map input value to [0 1] */ - in = in - (float32_t)n; - - /* Calculation of index of the table */ - findex = (float32_t)FAST_MATH_TABLE_SIZE * in; - index = (uint16_t)findex; - - /* when "in" is exactly 1, we need to rotate the index down to 0 */ - if (index >= FAST_MATH_TABLE_SIZE) { - index = 0; - findex -= (float32_t)FAST_MATH_TABLE_SIZE; - } - - /* fractional value calculation */ - fract = findex - (float32_t)index; - - /* Read two nearest values of input value from the cos table */ - a = sinTable_f32[index]; - b = sinTable_f32[index + 1]; - - /* Linear interpolation process */ - cosVal = (1.0f - fract) * a + fract * b; - - /* Return output value */ - return (cosVal); -} diff --git a/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_math_extract.h b/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_math_extract.h deleted file mode 100644 index e525f17ff..000000000 --- a/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_math_extract.h +++ /dev/null @@ -1,40 +0,0 @@ -/** ========================================================================== - * @file plp_math_extract.h - * @brief Public header file for PULP DSP Library - * @version V0 - * @date 16. May 2019 - * =========================================================================== */ -/* - * Copyright (C) 2019 ETH Zurich and University of Bologna. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PLP_MATH_H__ -#define __PLP_MATH_H__ - -#include -#include - -#define FAST_MATH_TABLE_SIZE 512 - -typedef float float32_t; - -extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; - -float32_t plp_cos_f32s_xpulpv2(float32_t x); -float32_t plp_sin_f32s_xpulpv2(float32_t x); - -#endif \ No newline at end of file diff --git a/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_sin_f32s_xpulpv2.c b/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_sin_f32s_xpulpv2.c deleted file mode 100644 index fb8c1847a..000000000 --- a/tools/nntool/autotiler/math_funcs/pulp_dsp/plp_sin_f32s_xpulpv2.c +++ /dev/null @@ -1,90 +0,0 @@ -/* ===================================================================== - * Project: PULP DSP Library - * Title: plp_sin_f32s_xpulpv2.c - * Description: Calculates sine of a floating point number in radians - * - * $Date: 30.07.2020 - * - * Target Processor: PULP cores - * ===================================================================== */ -/* - * Copyright (C) 2020 ETH Zurich and University of Bologna. - * - * Author: Michael Rogenmoser, ETH Zurich - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Notice: project inspired by ARM CMSIS DSP and parts of source code - * ported and adopted for RISC-V PULP platform from ARM CMSIS DSP - * released under Copyright (C) 2010-2019 ARM Limited or its affiliates - * with Apache-2.0. - */ - -#include "plp_common_tables.h" -#include "plp_math_extract.h" - -/** - * @brief F32 sine function for XPULPV2 - * - * @param[in] x input value in radians - * - * @return sin(x) - */ - -float32_t plp_sin_f32s_xpulpv2(float32_t x) { - float32_t sinVal, fract, in; /* Temporary input, output variables */ - uint16_t index; /* Index variable */ - float32_t a, b; /* Two nearest output values */ - int32_t n; - float32_t findex; - - /* input x is in radians */ - /* Scale input to [0 1] range from [0 2*PI] , divide input by 2*pi */ - in = x * 0.159154943092f; - - /* Calculation of floor value of input */ - n = (int32_t)in; - - /* Make negative values towards -infinity */ - if (in < 0.0f) { - n--; - } - - /* Map input value to [0 1] */ - in = in - (float32_t)n; - - /* Calculation of index of the table */ - findex = (float32_t)FAST_MATH_TABLE_SIZE * in; - index = (uint16_t)findex; - - /* when "in" is exactly 1, we need to rotate the index down to 0 */ - if (index >= FAST_MATH_TABLE_SIZE) { - index = 0; - findex -= (float32_t)FAST_MATH_TABLE_SIZE; - } - - /* fractional value calculation */ - fract = findex - (float32_t)index; - - /* Read two nearest values of input value from the sin table */ - a = sinTable_f32[index]; - b = sinTable_f32[index + 1]; - - /* Linear interpolation process */ - sinVal = (1.0f - fract) * a + fract * b; - - /* Return output value */ - return (sinVal); -} diff --git a/tools/nntool/execution/graph_executer.py b/tools/nntool/execution/graph_executer.py index 09e05cba8..297ea50e3 100644 --- a/tools/nntool/execution/graph_executer.py +++ b/tools/nntool/execution/graph_executer.py @@ -22,7 +22,7 @@ FusionInputParameters, FusionOutputParameters, InputParameters, MatMulOpFusionParameters, PaddedAddFusionParameters, Parameters) -from quantization.kernels.kernel_executer import KernelExecuter +from execution.kernels.kernel_executer import KernelExecuter from quantization.new_qrec import QRec from utils.graph import Graph from utils.node_id import NodeId @@ -73,7 +73,7 @@ def execute_qnoq_iterator(self, G = self._G saved_outputs = {} - for node in G.dfs(): + for node in G.topological_sort(): step_idx = node.step_idx if step_idx_limit is not None and step_idx > step_idx_limit: break @@ -166,7 +166,7 @@ def execute_iterator(self, if not silent: LOG.info("execute uncached: quantization mode %s", qmode) ExecutionProgress.start() - for node in G.dfs(): + for node in G.topological_sort(): step_idx = node.step_idx if step_idx_limit is not None and step_idx > step_idx_limit: break @@ -321,6 +321,7 @@ def execute(self, qmode: QuantizationMode = None, all_details=None, yield_fusions=False, + append_fusion_output=False, silent=False): if qmode is None: @@ -330,7 +331,7 @@ def execute(self, iterator = [(qoutput, qdetails, fnode) for _, _, _, _, qoutput, qdetails, fnode in self.execute_qnoq_iterator(in_tensors, - yield_fusions=yield_fusions, + yield_fusions=yield_fusions or append_fusion_output, step_idx_limit=step_idx_limit, silent=silent)] else: @@ -338,7 +339,7 @@ def execute(self, for _, _, fnode, output_tensors, details in self.execute_iterator(in_tensors, step_idx_limit=step_idx_limit, qmode=qmode, - yield_fusions=yield_fusions, + yield_fusions=yield_fusions or append_fusion_output, only_yield_step=only_yield_step, yield_details=all_details is not None, silent=silent)] @@ -355,7 +356,12 @@ def execute(self, fusion_outputs = None for output_tensors, details, fnode in iterator: - if yield_fusions: + if append_fusion_output and fnode: + outputs.append([output_tensor.copy() + for output_tensor in output_tensors]) + if all_details is not None: + all_details.append(details) + elif not append_fusion_output and yield_fusions: if fnode: fusion_outputs.append([output_tensor.copy() for output_tensor in output_tensors]) diff --git a/tools/nntool/quantization/kernels/__init__.py b/tools/nntool/execution/kernels/__init__.py similarity index 100% rename from tools/nntool/quantization/kernels/__init__.py rename to tools/nntool/execution/kernels/__init__.py diff --git a/tools/nntool/quantization/float/kernels/__init__.py b/tools/nntool/execution/kernels/float/__init__.py similarity index 100% rename from tools/nntool/quantization/float/kernels/__init__.py rename to tools/nntool/execution/kernels/float/__init__.py diff --git a/tools/nntool/quantization/float/kernels/activations.py b/tools/nntool/execution/kernels/float/activations.py similarity index 95% rename from tools/nntool/quantization/float/kernels/activations.py rename to tools/nntool/execution/kernels/float/activations.py index 3f6c97e99..bb94a19f0 100644 --- a/tools/nntool/quantization/float/kernels/activations.py +++ b/tools/nntool/execution/kernels/float/activations.py @@ -19,7 +19,7 @@ ReluActivationParameters, SigmoidActivationParameters) from graph.types.activations import (HTanHActivationParameters, TanHActivationParameters) -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import AllFloatQRec, QRec from utils.fast_float import np_fastsigmoid, np_fasttanh from utils.sigmoid_tanh_lut import sigmoid_lut_float, tanh_lut_float @@ -39,7 +39,7 @@ def execute(cls, params, in_tensor = qrec.prepare_inputs(params, in_tensors, ktype="float")[0] in_dtype = qrec.in_qs[0].dtype if qrec.ktype.startswith( 'float') else np.float32 - return qrec.get_outputs(params, [in_tensor * np.minimum(np.maximum(in_tensor + in_dtype(3), in_dtype(0)), in_dtype(6)) / in_dtype(6)], ktype="float") + return qrec.get_outputs(params, [in_tensor * np.minimum(np.maximum(in_tensor + in_dtype(params.offset), in_dtype(0)), in_dtype(params.upper_bound)) * in_dtype(params.mult)], ktype="float") @params_type(HSigmoidActivationParameters) @@ -56,7 +56,7 @@ def execute(cls, params, in_tensor = qrec.prepare_inputs(params, in_tensors, ktype="float")[0] in_dtype = qrec.in_qs[0].dtype if qrec.ktype.startswith( 'float') else np.float32 - return qrec.get_outputs(params, [np.minimum(np.maximum(in_tensor + params.offset, in_dtype(0)), in_dtype(6)) / in_dtype(6)], ktype="float") + return qrec.get_outputs(params, [np.minimum(np.maximum(in_tensor + params.offset, in_dtype(0)), in_dtype(params.upper_bound)) * in_dtype(params.mult)], ktype="float") @params_type(SigmoidActivationParameters) diff --git a/tools/nntool/quantization/float/kernels/dsp_preprocessing.py b/tools/nntool/execution/kernels/float/dsp_preprocessing.py similarity index 95% rename from tools/nntool/quantization/float/kernels/dsp_preprocessing.py rename to tools/nntool/execution/kernels/float/dsp_preprocessing.py index 59e5c51ec..111146cb3 100644 --- a/tools/nntool/quantization/float/kernels/dsp_preprocessing.py +++ b/tools/nntool/execution/kernels/float/dsp_preprocessing.py @@ -17,9 +17,7 @@ import numpy as np from graph.types import MFCCPreprocessingParameters, RFFT2DPreprocessingParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type -from quantization.multiplicative.mulbias import (apply_multiplicative_bias, - apply_zero_offset_bias) +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import QRec from utils.at_norm import at_norm diff --git a/tools/nntool/quantization/float/kernels/fast_conv.py b/tools/nntool/execution/kernels/float/fast_conv.py similarity index 95% rename from tools/nntool/quantization/float/kernels/fast_conv.py rename to tools/nntool/execution/kernels/float/fast_conv.py index 449fe6b9b..8c20195bd 100644 --- a/tools/nntool/quantization/float/kernels/fast_conv.py +++ b/tools/nntool/execution/kernels/float/fast_conv.py @@ -17,7 +17,7 @@ import numpy as np from graph.types import Conv2DParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.multiplicative.mulbias import apply_multiplicative_bias from quantization.new_qrec import AllFloatQRec, QRec @@ -51,7 +51,9 @@ def execute(cls, params, details['max_acc'] = float("-Infinity") details['min_pre_mul_bias'] = float("Infinity") details['max_pre_mul_bias'] = float("-Infinity") - + in_rank = len(in_tensor.shape) + if in_rank != 3: + raise NotImplementedError(f'{params.name} input has input rank of {in_rank} shape {in_tensor.shape} which is not supported by nntool kernels') in_tensor = in_tensor.transpose( in_dims.transpose_to_order(['h', 'w', 'c'])) if params.padding.h + params.padding.w > 0: diff --git a/tools/nntool/quantization/float/kernels/image_format.py b/tools/nntool/execution/kernels/float/image_format.py similarity index 95% rename from tools/nntool/quantization/float/kernels/image_format.py rename to tools/nntool/execution/kernels/float/image_format.py index 68cb56a94..bdc05f5c6 100644 --- a/tools/nntool/quantization/float/kernels/image_format.py +++ b/tools/nntool/execution/kernels/float/image_format.py @@ -14,7 +14,7 @@ import numpy as np from graph.types import ImageFormatParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import QRec from utils.formatters import FORMAT_CHANGES, NORMALIZATIONS diff --git a/tools/nntool/quantization/float/kernels/linear.py b/tools/nntool/execution/kernels/float/linear.py similarity index 97% rename from tools/nntool/quantization/float/kernels/linear.py rename to tools/nntool/execution/kernels/float/linear.py index 94fd660c0..898e0c1bd 100644 --- a/tools/nntool/quantization/float/kernels/linear.py +++ b/tools/nntool/execution/kernels/float/linear.py @@ -17,7 +17,7 @@ import numpy as np from graph.types import FcParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.multiplicative.mulbias import apply_multiplicative_bias from quantization.new_qrec import AllFloatQRec, QRec diff --git a/tools/nntool/quantization/float/kernels/matrix_operations.py b/tools/nntool/execution/kernels/float/matrix_operations.py similarity index 98% rename from tools/nntool/quantization/float/kernels/matrix_operations.py rename to tools/nntool/execution/kernels/float/matrix_operations.py index 5ee185f17..fa84e469c 100644 --- a/tools/nntool/quantization/float/kernels/matrix_operations.py +++ b/tools/nntool/execution/kernels/float/matrix_operations.py @@ -25,7 +25,7 @@ RSqrtOpParameters, SinOpParameters, SqrtOpParameters, UnaryOpParameters) from graph.types.tensor_arithmetic import Broadcastable, MatMulOpParameters, MatMulTransposedParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import AllFloatQRec, QRec @@ -130,7 +130,7 @@ def execute(cls, params, in_tensors = qrec.prepare_inputs(params, in_tensors, ktype="float") if isinstance(params, MatMulTransposedParameters): - mat1, mat2 = in_tensors[0], np.transpose(in_tensors[1], (1, 0)) + mat1, mat2 = in_tensors[0], np.swapaxes(in_tensors[1], -2, -1) else: mat1, mat2 = in_tensors[0], in_tensors[1] diff --git a/tools/nntool/quantization/float/kernels/pad.py b/tools/nntool/execution/kernels/float/pad.py similarity index 94% rename from tools/nntool/quantization/float/kernels/pad.py rename to tools/nntool/execution/kernels/float/pad.py index fea8b43b3..b4e3b0f0c 100644 --- a/tools/nntool/quantization/float/kernels/pad.py +++ b/tools/nntool/execution/kernels/float/pad.py @@ -15,7 +15,7 @@ import numpy as np from graph.types import PadParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import AllFloatQRec, QRec diff --git a/tools/nntool/quantization/float/kernels/pool.py b/tools/nntool/execution/kernels/float/pool.py similarity index 99% rename from tools/nntool/quantization/float/kernels/pool.py rename to tools/nntool/execution/kernels/float/pool.py index 15819e5d6..cc1d3c241 100644 --- a/tools/nntool/quantization/float/kernels/pool.py +++ b/tools/nntool/execution/kernels/float/pool.py @@ -20,7 +20,7 @@ from graph.types import (AveragePoolParameters, GlobalAveragePoolParameters, GlobalMaxPoolParameters, GlobalMinPoolParameters, GlobalSumPoolParameters, MaxPoolParameters) -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import AllFloatQRec, QRec LOG = logging.getLogger("nntool." + __name__) diff --git a/tools/nntool/quantization/float/kernels/readme.md b/tools/nntool/execution/kernels/float/readme.md similarity index 100% rename from tools/nntool/quantization/float/kernels/readme.md rename to tools/nntool/execution/kernels/float/readme.md diff --git a/tools/nntool/quantization/float/kernels/resize.py b/tools/nntool/execution/kernels/float/resize.py similarity index 97% rename from tools/nntool/quantization/float/kernels/resize.py rename to tools/nntool/execution/kernels/float/resize.py index 9670bfdb7..3dbab897c 100644 --- a/tools/nntool/quantization/float/kernels/resize.py +++ b/tools/nntool/execution/kernels/float/resize.py @@ -18,7 +18,7 @@ import numpy as np from graph.types import (BilinearResizerParameters, NearestNeighborResizerParameters) -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import AllFloatQRec, QRec diff --git a/tools/nntool/quantization/float/kernels/rnn.py b/tools/nntool/execution/kernels/float/rnn.py similarity index 97% rename from tools/nntool/quantization/float/kernels/rnn.py rename to tools/nntool/execution/kernels/float/rnn.py index 8a5fa268f..35d481e4e 100644 --- a/tools/nntool/quantization/float/kernels/rnn.py +++ b/tools/nntool/execution/kernels/float/rnn.py @@ -19,7 +19,7 @@ import numpy as np from graph.types import LSTMParameters, RNNParameters from graph.types.rnn import GRUParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import AllFloatQRec, QRec from utils.diag_collector import DiagCollector @@ -114,7 +114,7 @@ def execute(cls, params, details, 'range_cell', ) - elif isinstance(params, GRUParameters): + elif isinstance(params, (GRUParameters, RNNParameters)): DiagCollector.active_set('__rnn_quant') new_c_state = None @@ -135,7 +135,16 @@ def execute(cls, params, record_stat(details, 'range_cell', args['c_state']) if details is not None: - if isinstance(params, LSTMParameters): + if isinstance(params, RNNParameters): + DiagCollector.store_ranges( + details, + '__rnn_quant', + 'input_dot', + 'state_dot', + ) + DiagCollector.deactivate() + DiagCollector.clear(set_name='__rnn_quant') + elif isinstance(params, LSTMParameters): DiagCollector.store_ranges( details, '__rnn_quant', diff --git a/tools/nntool/quantization/float/kernels/softmax.py b/tools/nntool/execution/kernels/float/softmax.py similarity index 95% rename from tools/nntool/quantization/float/kernels/softmax.py rename to tools/nntool/execution/kernels/float/softmax.py index 421cd9a55..84da44683 100644 --- a/tools/nntool/quantization/float/kernels/softmax.py +++ b/tools/nntool/execution/kernels/float/softmax.py @@ -16,7 +16,7 @@ import numpy as np import scipy.special from graph.types import SoftMaxParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import AllFloatQRec, QRec diff --git a/tools/nntool/quantization/float/kernels/ssd_postprocess.py b/tools/nntool/execution/kernels/float/ssd_postprocess.py similarity index 96% rename from tools/nntool/quantization/float/kernels/ssd_postprocess.py rename to tools/nntool/execution/kernels/float/ssd_postprocess.py index 4cedd7819..516abe6b2 100644 --- a/tools/nntool/quantization/float/kernels/ssd_postprocess.py +++ b/tools/nntool/execution/kernels/float/ssd_postprocess.py @@ -16,7 +16,7 @@ import collections import numpy as np from graph.types.ssd import NMSParameters, SSDDetectorParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import AllFloatQRec, QRec from utils.ssd_utils import (CNTX_IDX, CNTY_IDX, H_IDX, W_IDX, XMAX_IDX, XMIN_IDX, YMAX_IDX, YMIN_IDX, convert_cnts2cors, convert_cors2cnts, @@ -106,7 +106,10 @@ def execute(cls, params, # out_boxes, out_scores, out_classes = cls.nms( # params, qrec, decoded_bboxes, valid_scores) # out_count = np.array([sum(out_classes != 0)]) - return qrec.get_outputs(params, [out_boxes, out_classes, out_scores], ktype="float") + outputs = [out_boxes, out_classes, out_scores] + if params.output_detection_count: + outputs.append(np.array([out_idx])) + return qrec.get_outputs(params, outputs, ktype="float") @params_type(NMSParameters) @qrec_type('float') diff --git a/tools/nntool/quantization/float/kernels/tensor_functions.py b/tools/nntool/execution/kernels/float/tensor_functions.py similarity index 98% rename from tools/nntool/quantization/float/kernels/tensor_functions.py rename to tools/nntool/execution/kernels/float/tensor_functions.py index f0a1750c7..704afc0a7 100644 --- a/tools/nntool/quantization/float/kernels/tensor_functions.py +++ b/tools/nntool/execution/kernels/float/tensor_functions.py @@ -13,20 +13,20 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import math from typing import cast as typing_cast -from utils.at_norm import at_norm import numpy as np +from skimage.transform import resize + +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from graph.types import (ConcatParameters, ConstantInputParameters, CopyParameters, InputParameters, OutputParameters, ReshapeParameters, ReverseParameters, SplitParameters, StridedSliceParameters, TransposeParameters) -from graph.types.others import (ExpandParameters, GatherParameters, NoOPParameters, - QuantizeParameters) -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from graph.types.others import (ExpandParameters, GatherParameters, + NoOPParameters, QuantizeParameters) from quantization.new_qrec import AllFloatQRec, QRec -from skimage.transform import resize +from utils.at_norm import at_norm @params_type(InputParameters) diff --git a/tools/nntool/quantization/kernels/fusion_inout.py b/tools/nntool/execution/kernels/fusion_inout.py similarity index 100% rename from tools/nntool/quantization/kernels/fusion_inout.py rename to tools/nntool/execution/kernels/fusion_inout.py diff --git a/tools/nntool/quantization/kernels/kernel_base.py b/tools/nntool/execution/kernels/kernel_base.py similarity index 100% rename from tools/nntool/quantization/kernels/kernel_base.py rename to tools/nntool/execution/kernels/kernel_base.py diff --git a/tools/nntool/quantization/kernels/kernel_executer.py b/tools/nntool/execution/kernels/kernel_executer.py similarity index 94% rename from tools/nntool/quantization/kernels/kernel_executer.py rename to tools/nntool/execution/kernels/kernel_executer.py index 4b6b1a706..f6cd6505c 100644 --- a/tools/nntool/quantization/kernels/kernel_executer.py +++ b/tools/nntool/execution/kernels/kernel_executer.py @@ -17,13 +17,13 @@ from typing import Sequence import numpy as np -from graph.types import Parameters, TransposeParameters +from graph.types import Parameters from quantization.handlers_helpers import get_all_subclasses from quantization.new_qrec import AllFloatQRec, QRec # pylint: disable=wildcard-import,unused-wildcard-import -from ..float.kernels import * # noqa -from ..symmetric.kernels import * # noqa +from .float import * # noqa +from .quant import * # noqa from .fusion_inout import * # noqa from .kernel_base import KernelBase diff --git a/tools/nntool/quantization/symmetric/kernels/__init__.py b/tools/nntool/execution/kernels/quant/__init__.py similarity index 100% rename from tools/nntool/quantization/symmetric/kernels/__init__.py rename to tools/nntool/execution/kernels/quant/__init__.py diff --git a/tools/nntool/quantization/symmetric/kernels/activations.py b/tools/nntool/execution/kernels/quant/activations.py similarity index 78% rename from tools/nntool/quantization/symmetric/kernels/activations.py rename to tools/nntool/execution/kernels/quant/activations.py index 0229dbc98..73bec1c78 100644 --- a/tools/nntool/quantization/symmetric/kernels/activations.py +++ b/tools/nntool/execution/kernels/quant/activations.py @@ -21,7 +21,7 @@ ReluActivationParameters, SigmoidActivationParameters) from graph.types.activations import (HTanHActivationParameters, TanHActivationParameters) -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.multiplicative.mulbias import compute_in_out_scale from quantization.multiplicative.utils.scale import compute_scales from quantization.new_qrec import QRec @@ -69,15 +69,15 @@ def execute(cls, params, **kwargs): in_tensor = qrec.prepare_inputs( params, in_tensors, ktype="symmetric")[0] - compute_in_out_scale(qrec) + # compute_in_out_scale(qrec) in_tensor = in_tensor.astype(np.int32) - neg_in = at_norm(in_tensor * leak_mult_gen_factor_q7(params), 7) + neg_in = at_norm((in_tensor) * qrec.cache["leak_factor"], 7) in_tensor = in_tensor * (in_tensor > 0) + neg_in * (in_tensor < 0) scale_mul_biases_q = qrec.cache['scale_mul_biases_q'] - in_tensor = scale_mul_biases_q.apply_scales(in_tensor) - if qrec.out_qs[0] != qrec.in_qs[0]: - return qrec.get_outputs(params, [qrec.out_qs[0].reduce_from(in_tensor, qrec.in_qs[0])], ktype="symmetric") - return qrec.get_outputs(params, [in_tensor], ktype="symmetric") + in_tensor = scale_mul_biases_q.apply_scales(in_tensor) + qrec.cache["zero_point"] + #if qrec.out_qs[0] != qrec.in_qs[0]: + # return qrec.get_outputs(params, [qrec.out_qs[0].reduce_from(in_tensor, qrec.in_qs[0])], ktype="symmetric") + return qrec.get_outputs(params, [qrec.out_qs[0].clip(in_tensor)], ktype="symmetric") def sigmoid(params, @@ -102,7 +102,7 @@ def execute(cls, params, **kwargs): in_tensor = qrec.prepare_inputs( params, in_tensors, ktype="symmetric")[0] - compute_in_out_scale(qrec) + # compute_in_out_scale(qrec) relu_lb = qrec.in_qs[0].quantize(params.lower_bound) in_tensor = np.maximum(in_tensor, relu_lb) if params.upper_bound is not None and not NNForceRelu.FORCE_RELU: @@ -147,26 +147,7 @@ def hsigmoid_mult_gen_factors(params, qrec): return fac_1, upper_bound, lower_bound -@params_type(HSigmoidActivationParameters) -@qrec_type('scaled') -class HSigmoidSymmetricMult(KernelBase): - @classmethod - def execute(cls, params, - in_tensors, - qrec: QRec, - **kwargs): - in_tensor = qrec.prepare_inputs( - params, in_tensors, ktype="symmetric")[0] - fac_1, upper_bound, lower_bound = hsigmoid_mult_gen_factors( - params, qrec) - in_tensor = in_tensor.astype(np.int32) - in_tensor_relued = np.minimum(np.maximum( - in_tensor + fac_1, lower_bound), upper_bound) - scale_mul_biases_q = qrec.cache['scale_mul_biases_q'] - in_tensor = scale_mul_biases_q.apply_scales(in_tensor_relued) - return qrec.get_outputs(params, - [in_tensor], - ktype="symmetric") + @params_type(HSigmoidActivationParameters) @@ -215,9 +196,9 @@ def execute(cls, params, return qrec.get_outputs(params, [in_tensor], ktype="symmetric") -@params_type(SigmoidActivationParameters) +@params_type(SigmoidActivationParameters, TanHActivationParameters) @qrec_type('scaled') -class SigmoidScaledSymmetricMult(KernelBase): +class SigmoidTanHScaledSymmetricMult(KernelBase): @classmethod def execute(cls, params, in_tensors, @@ -225,12 +206,22 @@ def execute(cls, params, **kwargs): in_tensor = qrec.prepare_inputs( params, in_tensors, ktype="symmetric")[0] - out_q15 = sigmoid_lut(in_tensor.astype(np.int32) << 8) - compute_in_out_scale(qrec, extra_scale=QType.Pow2( - bits=32, q=7, signed=True).scale/qrec.in_qs[0].scale) + if in_tensor.dtype == np.int8: # Q4 + in_tensor = in_tensor.astype(np.int32) << 8 + elif in_tensor.dtype == np.uint8: # Q4 sym + in_tensor = in_tensor.astype(np.int32) - (1 << 8) + in_tensor <<= 8 + elif in_tensor.dtype == np.uint16: # Q12 sym + in_tensor = in_tensor.astype(np.int32) - (1 << 16) + else: # Q12 + in_tensor = in_tensor.astype(np.int32) + if isinstance(params, TanHActivationParameters): + out_q15 = tanh_lut(in_tensor) + else: + out_q15 = sigmoid_lut(in_tensor) scale_mul_biases_q = qrec.cache['scale_mul_biases_q'] - output = scale_mul_biases_q.apply_scales(out_q15 >> 8) - + outp = scale_mul_biases_q.apply_scales(out_q15) + qrec.cache['zero_point'] + output = qrec.out_qs[0].clip(outp) return qrec.get_outputs(params, [output], ktype="symmetric") @@ -262,25 +253,35 @@ def execute(cls, params, ktype="symmetric") -@params_type(TanHActivationParameters) -@qrec_type('scaled') -class TanHScaledMult(KernelBase): - @classmethod - def execute(cls, params, - in_tensors, - qrec: QRec, - **kwargs): - in_tensor = qrec.prepare_inputs( - params, in_tensors, ktype="symmetric")[0] - out_q15 = tanh_lut(in_tensor.astype(np.int32) << 8) - compute_in_out_scale(qrec, extra_scale=QType.Pow2( - bits=32, q=7, signed=True).scale/qrec.in_qs[0].scale) - scale_mul_biases_q = qrec.cache['scale_mul_biases_q'] - output = scale_mul_biases_q.apply_scales(out_q15 >> 8) - - return qrec.get_outputs(params, - [output], - ktype="symmetric") +# @params_type(TanHActivationParameters) +# @qrec_type('scaled') +# class TanHScaledMult(KernelBase): +# @classmethod +# def execute(cls, params, +# in_tensors, +# qrec: QRec, +# **kwargs): +# in_tensor = qrec.prepare_inputs( +# params, in_tensors, ktype="symmetric")[0] +# if in_tensor.dtype == np.int8: # Q4 +# in_tensor = in_tensor.astype(np.int32) << 8 +# elif in_tensor.dtype == np.uint8: # Q4 sym +# in_tensor = in_tensor.astype(np.int32) - (1 << 8) +# in_tensor <<= 8 +# elif in_tensor.dtype == np.uint16: # Q12 sym +# in_tensor = in_tensor.astype(np.int32) - (1 << 16) +# else: # Q12 +# in_tensor = in_tensor.astype(np.int32) + +# out_q15 = tanh_lut(in_tensor) +# # compute_in_out_scale(qrec, extra_scale=QType.Pow2( +# # bits=32, q=7, signed=True).scale/qrec.in_qs[0].scale) +# scale_mul_biases_q = qrec.cache['scale_mul_biases_q'] +# outp = scale_mul_biases_q.apply_scales(out_q15) + qrec.cache['zero_point'] +# output = qrec.out_qs[0].clip(outp) +# return qrec.get_outputs(params, +# [output], +# ktype="symmetric") @params_type(TanHActivationParameters) @@ -309,15 +310,6 @@ def execute(cls, params, ktype="symmetric") -def hswish_mult_gen_factors(qrec): - in_q = qrec.in_qs[0] - fac_1 = in_q.quantize(np.array([3.])) - # The scale of the result is actually in in_scale * in_scale since it is multiplied by itself - compute_in_out_scale(qrec, extra_scale=qrec.in_qs[0].scale * 1/6) - upper_bound = in_q.quantize([6.]) - lower_bound = in_q.quantize([0.]) - return fac_1, upper_bound, lower_bound - @params_type(HSwishActivationParameters) @qrec_type('scaled') @@ -329,18 +321,50 @@ def execute(cls, params, **kwargs): in_tensor = qrec.prepare_inputs( params, in_tensors, ktype="symmetric")[0] - fac_1, upper_bound, lower_bound = hswish_mult_gen_factors(qrec) in_tensor = in_tensor.astype(np.int32) + + offset = qrec.cache['offset'] + upper_bound = qrec.cache['upper_bound'] + zero_point = qrec.cache['zero_point'] + in_tensor_relued = np.minimum(np.maximum( - in_tensor + fac_1, lower_bound), upper_bound) + in_tensor + offset, 0), upper_bound) scale_mul_biases_q = qrec.cache['scale_mul_biases_q'] in_tensor = scale_mul_biases_q.apply_scales( in_tensor * in_tensor_relued) + in_tensor += zero_point + in_tensor = qrec.out_qs[0].clip(in_tensor) return qrec.get_outputs(params, [in_tensor], ktype="symmetric") +@params_type(HSigmoidActivationParameters) +@qrec_type('scaled') +class HSigmoidSymmetricMult(KernelBase): + @classmethod + def execute(cls, params, + in_tensors, + qrec: QRec, + **kwargs): + in_tensor = qrec.prepare_inputs( + params, in_tensors, ktype="symmetric")[0] + in_tensor = in_tensor.astype(np.int32) + + offset = qrec.cache['offset'] + upper_bound = qrec.cache['upper_bound'] + zero_point = qrec.cache['zero_point'] + + in_tensor_relued = np.minimum(np.maximum( + in_tensor + offset, 0), upper_bound) + scale_mul_biases_q = qrec.cache['scale_mul_biases_q'] + in_tensor = scale_mul_biases_q.apply_scales(in_tensor_relued) + in_tensor += zero_point + in_tensor = qrec.out_qs[0].clip(in_tensor) + return qrec.get_outputs(params, + [in_tensor], + ktype="symmetric") + @params_type(HSwishActivationParameters) @qrec_type('symmetric') class HSwishSymmetric(KernelBase): diff --git a/tools/nntool/quantization/symmetric/kernels/dsp_preprocessing.py b/tools/nntool/execution/kernels/quant/dsp_preprocessing.py similarity index 93% rename from tools/nntool/quantization/symmetric/kernels/dsp_preprocessing.py rename to tools/nntool/execution/kernels/quant/dsp_preprocessing.py index e6ba670bd..ddf0263a1 100644 --- a/tools/nntool/quantization/symmetric/kernels/dsp_preprocessing.py +++ b/tools/nntool/execution/kernels/quant/dsp_preprocessing.py @@ -16,13 +16,14 @@ import logging import numpy as np +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from graph.types import (MFCCPreprocessingParameters, RFFT2DPreprocessingParameters) -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import QRec from utils.at_norm import at_norm from utils.fft_quant import (Rad2_FFT_DIF_Fix16, Rad4_FFT_DIF_Fix16, RFFT_Step_Fix16, SwapSamples) +from utils.numpy_helpers import np_asscalar from utils.pow_sqrt import (LN_2_1F15, LN_10_INV_Q10, LOG10_2, gap_fl1, logn_17_15, sqrt_17_15) @@ -84,7 +85,7 @@ def melspectrogram_step(cls, params, in_data, filterbanks_sparsity, filterbank_c max_in = np.max(in_data[start:start+nonzero_items]) logn_items = gap_fl1(nonzero_items) shift0 = gap_fl1(max_in) if max_in else 0 - shift = np.asscalar( + shift = np_asscalar( np.int32(shift0 + mel_coeff_q + logn_items - 31 if shift0 + mel_coeff_q + logn_items > 31 else 0)) melbin = 0 @@ -130,9 +131,11 @@ def execute(cls, params, qrec: QRec, **kwargs): in_data = in_tensors[0] - fft_twiddles = np.stack([in_tensors[2][::2], in_tensors[2][1::2]], axis=0) + fft_twiddles = np.stack( + [in_tensors[2][::2], in_tensors[2][1::2]], axis=0) swap_table = in_tensors[3] - rfft_twiddles = np.stack([in_tensors[4][::2], in_tensors[4][1::2]], axis=0) + rfft_twiddles = np.stack( + [in_tensors[4][::2], in_tensors[4][1::2]], axis=0) spectrograms = [] for frame_idx in range(params.n_frames): @@ -164,9 +167,11 @@ def execute(cls, params, in_tensors, qrec: QRec, **kwargs): - fft_twiddles = np.stack([in_tensors[2][::2], in_tensors[2][1::2]], axis=0) + fft_twiddles = np.stack( + [in_tensors[2][::2], in_tensors[2][1::2]], axis=0) swap_table = in_tensors[3] - rfft_twiddles = np.stack([in_tensors[4][::2], in_tensors[4][1::2]], axis=0) + rfft_twiddles = np.stack( + [in_tensors[4][::2], in_tensors[4][1::2]], axis=0) mel_filterbank_sparsity_mat = in_tensors[5] mel_filterbank_coeff = in_tensors[6] diff --git a/tools/nntool/quantization/symmetric/kernels/fast_conv.py b/tools/nntool/execution/kernels/quant/fast_conv.py similarity index 93% rename from tools/nntool/quantization/symmetric/kernels/fast_conv.py rename to tools/nntool/execution/kernels/quant/fast_conv.py index bd4037e53..493c38be1 100644 --- a/tools/nntool/quantization/symmetric/kernels/fast_conv.py +++ b/tools/nntool/execution/kernels/quant/fast_conv.py @@ -17,9 +17,8 @@ import numpy as np from graph.types import Conv2DParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type -from quantization.multiplicative.mulbias import (apply_multiplicative_bias, - apply_zero_offset_bias) +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type +from quantization.multiplicative.mulbias import apply_multiplicative_bias from quantization.new_qrec import QRec FORCE_INT64 = False @@ -43,11 +42,10 @@ def execute(cls, params, in_dims, out_dims = params.in_dims[0], params.out_dims[0] prepared_in_tensors = qrec.prepare_inputs(params, in_tensors, ktype="symmetric") - # if zero offset is already applied in biases by constant quantizer this does nothing - prepared_in_tensors = apply_zero_offset_bias(qrec, params, prepared_in_tensors, ktype="symmetric") in_tensor = prepared_in_tensors[0] # expand the weights to apply the zero offset weights = prepared_in_tensors[1].astype(np.int32) - qrec.in_qs[1].zero_point.astype(np.int32) + # if zero offset is already applied in biases by constant quantizer this does nothing biases = prepared_in_tensors[2] acc_q = qrec.cache.get('acc_q') or qrec.in_qs[2] @@ -99,7 +97,6 @@ def execute(cls, params, out_h = ((in_h - dillated_filter_h + pad_h)) // params.stride.h + 1 if params.has_bias: - # biases = qrec.prepare_biases(params, params.biases, params.weights, ktype="symmetric") if acc_q != qrec.in_qs[2]: biases = acc_q.expand_from(biases, qrec.in_qs[2]) result = np.broadcast_to(biases.reshape( diff --git a/tools/nntool/quantization/symmetric/kernels/image_format.py b/tools/nntool/execution/kernels/quant/image_format.py similarity index 94% rename from tools/nntool/quantization/symmetric/kernels/image_format.py rename to tools/nntool/execution/kernels/quant/image_format.py index c48df5a51..50e3ee0fe 100644 --- a/tools/nntool/quantization/symmetric/kernels/image_format.py +++ b/tools/nntool/execution/kernels/quant/image_format.py @@ -14,7 +14,7 @@ # along with this program. If not, see . from graph.types.image_formatter import ImageFormatParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import QRec from utils.formatters import FORMAT_CHANGES, NORMALIZATIONS diff --git a/tools/nntool/quantization/symmetric/kernels/linear.py b/tools/nntool/execution/kernels/quant/linear.py similarity index 93% rename from tools/nntool/quantization/symmetric/kernels/linear.py rename to tools/nntool/execution/kernels/quant/linear.py index 0040b4f62..f8a7a4ff4 100644 --- a/tools/nntool/quantization/symmetric/kernels/linear.py +++ b/tools/nntool/execution/kernels/quant/linear.py @@ -17,9 +17,8 @@ import numpy as np from graph.types.linear import FcParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type -from quantization.multiplicative.mulbias import (apply_multiplicative_bias, - apply_zero_offset_bias) +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type +from quantization.multiplicative.mulbias import apply_multiplicative_bias from quantization.new_qrec import QRec LOG = logging.getLogger("nntool." + __name__) @@ -38,8 +37,6 @@ def execute(cls, params, in_dims, out_dims = params.in_dims[0], params.out_dims[0] prepared_in_tensors = qrec.prepare_inputs( params, in_tensors, ktype="symmetric") - prepared_in_tensors = apply_zero_offset_bias( - qrec, params, prepared_in_tensors, ktype="symmetric") in_tensor = prepared_in_tensors[0] # expand the weights to apply the zero offset weights = prepared_in_tensors[1].astype(np.int32) - qrec.in_qs[1].zero_point.astype(np.int32) diff --git a/tools/nntool/quantization/symmetric/kernels/matrix_operations.py b/tools/nntool/execution/kernels/quant/matrix_operations.py similarity index 93% rename from tools/nntool/quantization/symmetric/kernels/matrix_operations.py rename to tools/nntool/execution/kernels/quant/matrix_operations.py index fad901498..162b7e477 100644 --- a/tools/nntool/quantization/symmetric/kernels/matrix_operations.py +++ b/tools/nntool/execution/kernels/quant/matrix_operations.py @@ -22,10 +22,8 @@ from graph.types.expression_fusion import ExpressionFusionParameters from graph.types.fusions import MatScaleFusionParameters from graph.types.tensor_arithmetic import Broadcastable, MatMulTransposedParameters -from quantization.kernels.kernel_base import (KernelBase, params_type, +from execution.kernels.kernel_base import (KernelBase, params_type, qrec_type) -from quantization.multiplicative.mulbias import (compute_in_out_scale, - set_add_in_scale) from quantization.qtype import QType from quantization.new_qrec import QRec from utils.at_norm import at_norm @@ -56,14 +54,14 @@ def execute(cls, params, op = func['op'] if func['is_mult']: - compute_in_out_scale(qrec, in_idx=(0, 1), out_idx=0) + # compute_in_out_scale(qrec, in_idx=(0, 1), out_idx=0) scale_mul_biases_q = qrec.cache['scale_mul_biases_q'] i1 = in_tensors[0].astype(np.int32) i2 = in_tensors[1].astype(np.int32) out_tensor = scale_mul_biases_q.apply_scales(op(i1, i2, np.int32)) else: # larger scale should be scaled - set_add_in_scale(qrec) + # set_add_in_scale(qrec) scale_mul_biases_q = qrec.cache['scale_mul_biases_q'] if qrec.cache['scaled_idx']: i1 = in_tensors[0].astype(np.int32) @@ -166,8 +164,7 @@ def execute(cls, params, in_tensors, qrec: QRec, **kwargs): - in_tensors = [in_tensor.astype(np.int32) for in_tensor in qrec.prepare_inputs( - params, in_tensors, ktype="symmetric")] + in_tensors = qrec.prepare_inputs(params, in_tensors, ktype="symmetric") details = kwargs.get('details') if details is not None: results = {} @@ -195,7 +192,7 @@ def execute(cls, params, in_tensors = [in_tensor.astype(np.int32) for in_tensor in qrec.prepare_inputs( params, in_tensors, ktype="symmetric")] if isinstance(params, MatMulTransposedParameters): - mat1, mat2 = in_tensors[0], np.transpose(in_tensors[1], (1, 0)) + mat1, mat2 = in_tensors[0], np.swapaxes(in_tensors[1], -2, -1) else: mat1, mat2 = in_tensors[0], in_tensors[1] @@ -210,8 +207,10 @@ def execute(cls, params, biases = 0 out_tensor = np.matmul(mat1, mat2) + biases + out_rank = len(out_tensor.shape) mul_biases_q = qrec.cache['mul_biases_q'] - scale_axis = None if len(mul_biases_q.scale) == 1 else 1 + scale_axis = None if len(mul_biases_q.scale) == 1 else \ + (out_rank-1 if isinstance(params, MatMulTransposedParameters) else out_rank-2) out_tensor = mul_biases_q.apply_scales(out_tensor, scale_axis) return qrec.get_outputs(params, [out_tensor], ktype="symmetric") @@ -229,7 +228,7 @@ def execute(cls, params, params, in_tensors, ktype="symmetric")] if isinstance(params, MatMulTransposedParameters): - mat1, mat2 = in_tensors[0], np.transpose(in_tensors[1], (1, 0)) + mat1, mat2 = in_tensors[0], np.swapaxes(in_tensors[1], -2, -1) else: mat1, mat2 = in_tensors[0], in_tensors[1] diff --git a/tools/nntool/quantization/symmetric/kernels/pad.py b/tools/nntool/execution/kernels/quant/pad.py similarity index 94% rename from tools/nntool/quantization/symmetric/kernels/pad.py rename to tools/nntool/execution/kernels/quant/pad.py index 027bc253c..a5c5b723a 100644 --- a/tools/nntool/quantization/symmetric/kernels/pad.py +++ b/tools/nntool/execution/kernels/quant/pad.py @@ -18,7 +18,7 @@ from quantization.new_qrec import QRec -from quantization.kernels.kernel_base import (KernelBase, params_type, +from execution.kernels.kernel_base import (KernelBase, params_type, qrec_type) @params_type(PadParameters) @qrec_type('symmetric', 'scaled') diff --git a/tools/nntool/quantization/symmetric/kernels/pool.py b/tools/nntool/execution/kernels/quant/pool.py similarity index 96% rename from tools/nntool/quantization/symmetric/kernels/pool.py rename to tools/nntool/execution/kernels/quant/pool.py index cf7688d37..d3791adf2 100644 --- a/tools/nntool/quantization/symmetric/kernels/pool.py +++ b/tools/nntool/execution/kernels/quant/pool.py @@ -20,7 +20,7 @@ import numpy as np from graph.types import (AveragePoolParameters, GlobalPoolingParameters, MaxPoolParameters) -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.multiplicative.mulbias import compute_in_out_scale from quantization.new_qrec import QRec from utils.at_norm import at_norm @@ -154,7 +154,7 @@ def execute(cls, params, in_tensor = qrec.prepare_inputs( params, in_tensors, ktype="symmetric")[0] out_dims = params.out_dims[0] - compute_in_out_scale(qrec, in_idx=0, out_idx=0) + # compute_in_out_scale(qrec, in_idx=0, out_idx=0) sum_by_chan = np.sum(in_tensor, dtype=np.int32, axis=tuple( params.axis), keepdims=params.keep_dims) @@ -210,8 +210,8 @@ def execute(cls, params, # Prepare the quantization levels in_tensor = qrec.prepare_inputs( params, in_tensors, ktype="symmetric")[0] - if qrec.ktype == 'scaled': - compute_in_out_scale(qrec, in_idx=0, out_idx=0) + # if qrec.ktype == 'scaled': + # compute_in_out_scale(qrec, in_idx=0, out_idx=0) return qrec.get_outputs(params, [np.max(in_tensor, axis=tuple(params.axis), keepdims=params.keep_dims)], ktype="symmetric") @@ -228,8 +228,8 @@ def execute(cls, params, in_tensor = qrec.prepare_inputs( params, in_tensors, ktype="symmetric")[0] - if qrec.ktype == 'scaled': - compute_in_out_scale(qrec, in_idx=0, out_idx=0) + # if qrec.ktype == 'scaled': + # compute_in_out_scale(qrec, in_idx=0, out_idx=0) res = np.sum(in_tensor, axis=tuple(params.axis), keepdims=params.keep_dims, diff --git a/tools/nntool/quantization/symmetric/kernels/resize.py b/tools/nntool/execution/kernels/quant/resize.py similarity index 98% rename from tools/nntool/quantization/symmetric/kernels/resize.py rename to tools/nntool/execution/kernels/quant/resize.py index ec0211f18..255c06619 100644 --- a/tools/nntool/quantization/symmetric/kernels/resize.py +++ b/tools/nntool/execution/kernels/quant/resize.py @@ -17,7 +17,7 @@ import numpy as np from graph.types import (BilinearResizerParameters, NearestNeighborResizerParameters) -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import QRec diff --git a/tools/nntool/quantization/symmetric/kernels/rnn.py b/tools/nntool/execution/kernels/quant/rnn.py similarity index 99% rename from tools/nntool/quantization/symmetric/kernels/rnn.py rename to tools/nntool/execution/kernels/quant/rnn.py index 02cc0675a..12666b139 100644 --- a/tools/nntool/quantization/symmetric/kernels/rnn.py +++ b/tools/nntool/execution/kernels/quant/rnn.py @@ -20,7 +20,7 @@ import numpy as np from graph.types import LSTMParameters, RNNParameters from graph.types.rnn import GRUParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import QRec from quantization.qtype import QType from utils.at_norm import at_norm @@ -857,10 +857,11 @@ def step_kernelu16_u8(cls, params: GRUParameters, DiagCollector.record('h_state_out_prenorm', h_state, scale=math.pow(2, -30), node=params) - h_state = qrec.out_qs[0].clip(at_norm(h_state, 30-15) + qrec.out_qs[0].zero_point) + h_state = at_norm(h_state, 30-qrec.out_qs[0].q) # normalize to output q (normally Q15) + h_state = qrec.out_qs[0].clip(h_state + qrec.out_qs[0].zero_point) DiagCollector.record('h_state_out', h_state, - scale=math.pow(2, -15), + scale=scales['state'], zero_point=0x8000, node=params) args['h_state'][0] = h_state.copy() diff --git a/tools/nntool/quantization/symmetric/kernels/softmax.py b/tools/nntool/execution/kernels/quant/softmax.py similarity index 97% rename from tools/nntool/quantization/symmetric/kernels/softmax.py rename to tools/nntool/execution/kernels/quant/softmax.py index 04941a351..9590b9b3b 100644 --- a/tools/nntool/quantization/symmetric/kernels/softmax.py +++ b/tools/nntool/execution/kernels/quant/softmax.py @@ -15,7 +15,7 @@ import numpy as np from graph.types.activations import SoftMaxParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import QRec from utils.exp_17_15 import exp_fp_17_15 diff --git a/tools/nntool/quantization/symmetric/kernels/ssd_postprocess.py b/tools/nntool/execution/kernels/quant/ssd_postprocess.py similarity index 96% rename from tools/nntool/quantization/symmetric/kernels/ssd_postprocess.py rename to tools/nntool/execution/kernels/quant/ssd_postprocess.py index ce0d7ff6b..3cb5a609f 100644 --- a/tools/nntool/quantization/symmetric/kernels/ssd_postprocess.py +++ b/tools/nntool/execution/kernels/quant/ssd_postprocess.py @@ -16,7 +16,7 @@ import numpy as np from graph.types import SSDDetectorParameters from graph.types.ssd import NMSParameters -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.multiplicative.mulbias import set_ssd_scales from quantization.new_qrec import QRec from utils.at_norm import at_norm @@ -131,7 +131,10 @@ def execute(cls, params, # params, qrec, offsets, anchors, scores, anchors_type='centers') # out_boxes, out_scores, out_classes = cls.nms(params, qrec, decoded_bboxes, valid_scores) # out_count = np.array([sum(out_classes != 0)]) - return qrec.get_outputs(params, [out_boxes, out_classes, out_scores], ktype="symmetric") + outputs = [out_boxes, out_classes, out_scores] + if params.output_detection_count: + outputs.append(np.array([out_idx], dtype=np.int32)) + return qrec.get_outputs(params, outputs, ktype="symmetric") @params_type(NMSParameters) @qrec_type('scaled') diff --git a/tools/nntool/quantization/symmetric/kernels/tensor_functions.py b/tools/nntool/execution/kernels/quant/tensor_functions.py similarity index 92% rename from tools/nntool/quantization/symmetric/kernels/tensor_functions.py rename to tools/nntool/execution/kernels/quant/tensor_functions.py index 5957ef088..9487d3b9e 100644 --- a/tools/nntool/quantization/symmetric/kernels/tensor_functions.py +++ b/tools/nntool/execution/kernels/quant/tensor_functions.py @@ -16,7 +16,7 @@ import numpy as np from graph.types import (ConstantInputParameters, InputParameters, OutputParameters) -from quantization.kernels.kernel_base import KernelBase, params_type, qrec_type +from execution.kernels.kernel_base import KernelBase, params_type, qrec_type from quantization.new_qrec import QRec from skimage.transform import resize @@ -44,7 +44,9 @@ def execute(cls, params, else: in_tensor = resize(in_tensor, params.dims.shape) # output_tensors = qrec.get_outputs(params, [in_tensor], ktype="symmetric") - return [qrec.out_qs[0].quantize(in_tensor)] + if in_tensor.dtype != qrec.out_qs[0].dtype: + in_tensor = qrec.out_qs[0].quantize(in_tensor) + return [in_tensor] @params_type(OutputParameters) diff --git a/tools/nntool/expressions/symbolic/assignments.py b/tools/nntool/expressions/symbolic/assignments.py index 3cadfaf6f..ba376a030 100644 --- a/tools/nntool/expressions/symbolic/assignments.py +++ b/tools/nntool/expressions/symbolic/assignments.py @@ -1,4 +1,4 @@ -# Copyright (C) 2021 GreenWaves Technologies, SAS +# Copyright (C) 2022 GreenWaves Technologies, SAS # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -13,265 +13,251 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from collections.abc import Sequence as ABCSequence +from copy import deepcopy -from functools import reduce -from typing import Mapping - -import numpy as np +from expressions.symbolic.quantization_base import QuantizationHandlerBase from generation.code_block import CodeBlock - -from .iteration_space import IterationSpace -from .symbol import Constant, Symbol, Variable, copy_props -from .variable_container import VariableContainerAndAssigner - - -@copy_props('var') -class Assignment(VariableContainerAndAssigner, Symbol): - def __init__(self, arg, name="", var=None, **kwargs): - if var is None: - self._var = Variable(name, shape=arg.shape, symbol_binding=arg) - else: - name = var.name - self._var = var - super(Assignment, self).__init__(arg, name=name, **kwargs) +from utils.disjoint_reduction import disjoint_reduction + +from .symbol import Symbol, Variable + + +class Assignments(ABCSequence): + def __init__(self, assignments=None, returns=None, qrecs=None) -> None: + super().__init__() + self._assignments = [] + self._returns = set(returns if returns is not None else []) + self._outputs = None + self._inputs = None + self._inters = None + self._vars = [] + self._qrecs = qrecs + if assignments: + for assignment in assignments: + self.add(*assignment) + self._update() @property - def unbound_variables(self): - return self.contents[0].unbound_variables + def max_shape(self): + return tuple(max(elems) for elems in zip(*Symbol.extend_shapes(*[ass[1].shape for ass in self._assignments]))) @property - def var(self): - return self._var - - def find(self, name): - for elem in [self._var, self.contents[0]]: - res = elem.find(name) - if res: - return res - return None - - @property - def var_shapes(self): - shapes = {self.name: self.contents[0].shape} - shapes.update(zip(self.contents[0].unbound_variables, self.contents[0].unbound_shapes)) - return shapes - - def _resolve(self, **kwargs): - """Given a set of substitions for variable in kwargs resolve all variables""" - return self._contents[0].resolve(**kwargs) - - def _resolve_assignment(self, substitute_all=False, **kwargs) -> Mapping[str, Symbol]: - return {self.name: self._contents[0].resolve(**kwargs)} - - def _calculate(self, calculate_ranges=False, **kwargs): - res = self._contents[0].resolve(**kwargs) - if not isinstance(res, Constant): - raise ValueError( - f"unable to calculate {self.name}") - if calculate_ranges: - self.control.add_stat(self, res.value) - return res.value - - def _calculate_assignment(self, **kwargs) -> Mapping[str, np.ndarray]: - return {self.name: self._calculate(**kwargs)} - - def c_block(self, code_block: CodeBlock = None, iteration_space: IterationSpace = None): - if code_block is None: - code_block = CodeBlock() - if iteration_space: - if self.var.name in iteration_space.temporary_variables: - code_block.write( - f"{self.var.c_expr(declare=True, dtype=self.contents[0].dtype)}" - f" = {self.contents[0].c_expr(iteration_space=iteration_space)};") - else: - code_block.write( - f"{self.var.c_expr(dtype=self.contents[0].dtype)}{iteration_space.c_index(self.var.name)}" - f" = {self.contents[0].c_expr(iteration_space=iteration_space)};") - else: - code_block.write(f'{self.var.name} = {self.contents[0].c_expr()};') - return code_block + def unbound_shapes(self): + return tuple(self._vars[name].shape for name in self.unbound_variables) @property - def returned_variables(self): - return [self.name] + def input_names(self): + return self._inputs @property - def shape(self): - return self._contents[0].shape - - def _py_expr(self, *args, **kwargs): - return self._contents[0].py_expr(*args, **kwargs) - - def _c_expr(self, *args, **kwargs): - return self._contents[0].c_expr(*args, **kwargs) - - def __repr__(self) -> str: - return f"{{{self.var.name} <- {self.contents[0].__repr__()}}}" - - -@copy_props('preconditions', 'returned_variables') -class Let(VariableContainerAndAssigner, Symbol): - def __init__(self, *args, preconditions=None, returned_variables=None, name="", **kwargs): - args = [Assignment(arg[1], name=arg[0]) if isinstance( - arg, tuple) else arg for arg in args] - super(Let, self).__init__(*args, name=name, **kwargs) - if preconditions is None: - preconditions = [] - else: - preconditions = [Assignment(arg[1], name=arg[0]) if isinstance( - arg, tuple) else arg for arg in preconditions] - self._preconditions = preconditions - self._returned_variables = returned_variables - -# pylint: disable=invalid-name - def In(self, *expressions): - return Let(*expressions, preconditions=[self]) - - def Return(self, *variable_names): - produced = self.produced_variables - if not all(variable in produced for variable in variable_names): - raise ValueError('not all variables are produced') - return Let(*self.contents, preconditions=self.preconditions, name=self.name, returned_variables=variable_names) + def output_names(self): + return self._outputs @property def unbound_variables(self): - resolution = self.resolve_assignment() - _vars = reduce(lambda s, x: s | set( - x.unbound_variables.values()), resolution.values(), set()) - return {var.name: var for var in _vars if var.name not in set(resolution.keys())} + return self._inputs @property - def produced_variables(self): - resolution = self.resolve_assignment() - return set(resolution.keys()) + def intermediate_names(self): + return self._inters @property - def preconditions(self): - return self._preconditions + def variables(self): + return self._vars @property - def returned_variables(self): - return self._returned_variables - - @staticmethod - def substitute_variables(assignments): - res = {} - substitutions = {} - for var_name, val in assignments.items(): - if isinstance(val, (Constant, np.ndarray, int, float)): - substitutions[var_name] = val - else: - substitutions[var_name] = Variable(var_name, shape=val.shape) - res[var_name] = val - return res, substitutions - - def find(self, name): - for elem in list(self._preconditions) + list(self.contents): - res = elem.find(name) - if res: - return res - return None - - def _resolve_assignment(self, substitute_all=False, **kwargs) -> Mapping[str, Symbol]: - """Given a set of substitions for variable in kwargs resolve all variables - return a dictionary of variables""" - preconditions = self._resolve_contents( - contents=self._preconditions, substitute_all=substitute_all, **kwargs) - return self._resolve_contents(contents=self.contents, substitute_all=substitute_all, **preconditions) - - def _calculate_assignment(self, **kwargs) -> Mapping[str, np.ndarray]: - preconditions = self._calculate_contents( - contents=self._preconditions, **kwargs) - res = self._calculate_contents(contents=self.contents, **preconditions) - if self.returned_variables: - res = {vname: val for vname, val in res.items( - ) if vname in self.returned_variables} - return res - - @staticmethod - def _resolve_contents(contents=None, substitute_all=False, **kwargs): - if substitute_all: - substitutions = kwargs - res = kwargs - else: - res, substitutions = Let.substitute_variables(kwargs) - for elem in contents: - elem_res = elem.resolve_assignment( - substitute_all=substitute_all, **substitutions) - if substitute_all: - substitutions.update(elem_res) - res.update(elem_res) - else: - elem_res, elem_substitutions = Let.substitute_variables( - elem_res) - res.update(elem_res) - substitutions.update(elem_substitutions) - return res - - @staticmethod - def _calculate_contents(contents=None, **kwargs): - for elem in contents: - kwargs.update(elem.calculate_assignment(**kwargs)) - return kwargs - - def _resolve(self, **kwargs): - """Given a set of substitions for variable in kwargs resolve all variables - return a single symbol""" - preconditions = self._resolve_contents( - contents=self._preconditions, substitute_all=True, **kwargs) - resolution = self._resolve_contents( - contents=self.contents, substitute_all=True, **preconditions) - return Assignment(resolution[self.contents[-1].name], name=self.contents[-1].name) - - def _calculate(self, calculate_ranges=False, **kwargs): - res = self._resolve(**kwargs) - if not isinstance(res.contents[0], Constant): - raise ValueError( - f"unable to calculate {self.name}") - if calculate_ranges: - self.control.add_stat(self, res.value) - return res.contents[0].value + def axes(self): + var_shapes = Symbol.extend_shapes(*self.unbound_shapes, max_length=len(self.max_shape)) + axes = disjoint_reduction(set(frozenset(idx for idx, dim in enumerate( + shape) if dim != 1) for shape in var_shapes)) + return tuple(sorted([tuple(x) for x in axes])) @property def var_shapes(self): - shapes = {} - for var_name, elem in self.resolve_assignment().items(): - shapes[var_name] = elem.shape - shapes.update(dict(zip(elem.unbound_variables, elem.unbound_shapes))) - return shapes + return {var.name: var.shape for var in self._vars.values()} @property - def shape(self): - return self._contents[-1].shape + def ops(self): + # TODO: Implement + return 1 - def _py_expr(self, *args, **kwargs): - return self._contents[0].py_expr(*args, **kwargs) + @property + def qrecs(self): + return self._qrecs - def c_block(self, code_block: CodeBlock = None, iteration_space: IterationSpace = None, with_loops=False): + @property + def c_header_set(self): + return set().union(*[assignment[1].c_header_set + for assignment in self._assignments]) + + def variable(self, name): + return self._vars[name] + + def _add_int(self, var, func): + for uname, uvar in func.unbound_variables.items(): + if uname in self._vars: + uvar.shape = self._vars[uname].shape + uvar.qrec = self._vars[uname].qrec + if isinstance(var, str): + if var in self._vars: + var = self._vars[var] + else: + var = Variable(var, shape=func.shape, dtype=func.dtype) + self._assignments.append((var, func)) + + def add(self, var, func): + self._add_int(var, func) + self._update() + + def _update(self): + self._vars = {} + free_var_names = set() + for var, func in self._assignments: + self._vars[var.name] = var + for name, uvar in func.unbound_variables.items(): + self._vars[name] = uvar + free_var_names.add(name) + + # these are all the produced variables + prod_var_names = set( + [assignment[0].name for assignment in self._assignments]) + # sort all the variable names to keep a determined order + # the outputs are things produced that are not consumed + self._outputs = sorted( + list((prod_var_names - free_var_names) | self._returns)) + # the inputs are variables that are not produced + self._inputs = sorted(list(free_var_names - prod_var_names)) + # the intermediates are the produced variables that are not in the outputs + self._inters = sorted(list(prod_var_names - set(self._outputs))) + + def c_block(self, code_block: CodeBlock = None, iteration_space: 'IterationSpace' = None, + with_loops=False, with_comment=True, with_fixed=False, tags=None): if code_block is None: code_block = CodeBlock() + # create loops from iteration space if with_loops: assert iteration_space, "must have space" - for idx, _ in enumerate(iteration_space.axis_shape): - if idx in iteration_space.fixed_spaces: + if with_comment: + # write some comments describing the iteration space + code_block.comment( + f"Max shape: {iteration_space.shape} var shapes:") + writer = code_block.start_long_comment() + for shape_comment in [f'{name}: {shape}' + for name, shape in iteration_space.var_shapes.items()]: + writer.write(shape_comment) + writer.end() + code_block.comment( + f'Iteration reduced to spaces {iteration_space.spaces}') + code_block.comment( + f'Fixed spaces {iteration_space.fixed_spaces}') + code_block.comment( + f'Parameteric spaces {iteration_space.parametric_spaces}') + code_block.comment( + f'Paralelized space {iteration_space.paralellized_space}') + code_block.comment( + f'Interior spaces {iteration_space.interior_spaces}') + # write the loops + for space in iteration_space.spaces: + if not with_fixed and space in iteration_space.fixed_spaces: continue - code_block.write(f"{iteration_space.c_for(idx)} {{") + code_block.write(f"{iteration_space.c_for(space, with_fixed=with_fixed)} {{") code_block.indent() - for precondition in self.preconditions: - precondition.c_block(code_block=code_block, - iteration_space=iteration_space) - for item in self.contents: - item.c_block(code_block=code_block, - iteration_space=iteration_space) + # write each assignment + for var, func in self._assignments: + this_tags = {} if tags is None else tags.copy() + + # write comment with quantization if present + if with_comment: + uvars = [f'{uvar.name}: {uvar.qrec}' + for uvar in func.unbound_variables.values() + if uvar.qrec] + if uvars: + writer = code_block.start_long_comment() + writer.write('inputs') + for uvar in uvars: + writer.write(uvar) + writer.end() + code_block.comment(f'{var.name} = {repr(func)}') + # if iteration space is present pick up if this is a temporary or an output + # assignment from that + if iteration_space: + if var.name in iteration_space.temporary_names: + this_tags[func] = (var, True) + else: + this_tags[func] = (var, False) + else: + this_tags[func] = (var, var.name in self.intermediate_names) + + # The iteration space will be passed down the symbol structure + func.tag = True + func.c_block(code_block=code_block, + tags=this_tags, + iteration_space=iteration_space, + with_comment=with_comment) + func.tag = False + if with_loops: - for idx, _ in enumerate(iteration_space.axis_shape): - if idx in iteration_space.fixed_spaces: + for space in iteration_space.spaces: + if not with_fixed and space in iteration_space.fixed_spaces: continue code_block.deindent() code_block.write("}") return code_block - def _c_expr(self, *args, **kwargs): - return self._contents[0].c_expr(*args, **kwargs) + def quantize(self, quantizer: QuantizationHandlerBase, symbol_control, quantize_inputs=False, qtypes=None): + funcs = [] + out_qrecs = {} + in_qrecs = {} + for var, func in self._assignments: + qfunc, qrec = quantizer.quantize( + func, + symbol_control, + quantize_inputs=quantize_inputs, + prequantized_variables=out_qrecs, + qtypes=qtypes) + qfunc = qfunc.resolve() + in_qrecs.update(qfunc.variable_quantization) + if var.name in self._outputs: + qfunc, qrec = quantizer.quantize_output( + func, + qfunc, + var, + symbol_control, + qrec, + quantize_inputs=quantize_inputs, + prequantized_variables=out_qrecs, + qtypes=qtypes) + qfunc = qfunc.resolve() + var = deepcopy(var) + var.qrec = qrec + funcs.append((var, qfunc(substitute=True))) + out_qrecs[var.name] = qrec + in_qrecs.update(out_qrecs) + return Assignments(funcs, returns=self._returns, qrecs=in_qrecs) + + def __getitem__(self, idx): + return self._assignments[idx] + + def __len__(self) -> int: + return len(self._assignments) + + def __iter__(self): + return iter(self._assignments) + + def __call__(self, quantize_inputs=False, dequantize_outputs=False, **subs): + subs = dict(subs) + if quantize_inputs: + subs = {name: self.qrecs[name].quantize_and_clip(val) if name in self.qrecs else val + for name, val in subs.items()} + for var, func in self._assignments: + subs[var.name] = func( + dequantize_outputs=dequantize_outputs, **subs) + res = dict(filter(lambda elem: elem[0] in self._outputs, subs.items())) + if dequantize_outputs: + if self.qrecs is None: + raise ValueError('assignments are not quantized') + res = {name: self.qrecs[name].dequantize( + val) for name, val in res.items()} + return res - def __repr__(self) -> str: - return (f"Let({','.join([elem.__repr__() for elem in self.preconditions])})" - f".In({','.join([elem.__repr__() for elem in self.contents])})") diff --git a/tools/nntool/expressions/symbolic/basic.py b/tools/nntool/expressions/symbolic/basic.py index c7917ff48..862dbb065 100644 --- a/tools/nntool/expressions/symbolic/basic.py +++ b/tools/nntool/expressions/symbolic/basic.py @@ -13,14 +13,19 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import logging +import math + import numpy as np from bfloat16 import bfloat16 from quantization.qtype import DTYPE_GAP_CTYPE from scipy.special import expit from .function import Function -from .symbol import (Constant, Rational, c_headers, copy_props, environment, - handles, handlesr, nargs) +from .symbol import (Constant, QRecBase, Rational, Symbol, Variable, c_headers, + copy_props, environment, handles, handlesr, nargs) + +LOG = logging.getLogger('nntool.'+__name__) @nargs(2) @@ -29,7 +34,8 @@ class Add(Function): def _impl(self, *args, **kwargs): - return np.add(args[0], args[1], dtype=self.dtype) + res = np.add(args[0], args[1], dtype=self.dtype) + return res def _py_expr(self, *args, **kwargs): return "np.add(%s, %s)" % (args[0], args[1]) @@ -178,6 +184,7 @@ class GapAbs(Abs): def _c_expr(self, *args, **kwargs): return "gap_abs(%s)" % (args[0]) + @nargs(1) class Round(Function): @@ -271,6 +278,7 @@ def _py_expr(self, *args, **kwargs): def _c_expr(self, *args, **kwargs): return "sqrtf(%s)" % (args[0],) + @nargs(1) @c_headers('') class RSqrt(Function): @@ -284,6 +292,7 @@ def _py_expr(self, *args, **kwargs): def _c_expr(self, *args, **kwargs): return "1.0f/sqrtf(%s)" % (args[0],) + @nargs(1) @c_headers('') class Log(Function): @@ -353,13 +362,14 @@ def _py_expr(self, *args, **kwargs): def _c_expr(self, *args, **kwargs): return f"square({args[0]}))" + @nargs(2) @c_headers('') class Pow(Function): def _impl(self, *args, **kwargs): if any(b < 0 and e < 1 for b, e in np.broadcast(*args)): - raise ValueError( + LOG.warning( 'fractional powers are being passed to a negative base for Pow operator') return np.power(args[0], args[1], dtype=self.dtype) @@ -452,6 +462,8 @@ def __init__(self, *args, **kwargs): self._inner_function = self._eval(*args, **kwargs) # self._inner_function.name = self.name self._inner_function.qrec = self.qrec + self._inner_function.tag = self.tag + self._inner_function.comment = self.comment def _collect_globals(self) -> dict: global_dict = self.ENVIRONMENT or {} @@ -470,6 +482,9 @@ def _resolve(self, **kwargs): func = self._inner_function.resolve(**kwargs) # func.name = self.name func.qrec = self.qrec + if isinstance(func, Function): + func.tag = self.tag + func.comment = self.comment return func def _eval(self, *args, **kwargs): @@ -492,6 +507,14 @@ def _py_expr(self, *args, **kwargs): def _c_expr(self, *args, **kwargs): return self._inner_function.c_expr(*args, **kwargs) + def c_block(self, code_block=None, tags=None, **kwargs): + if tags is not None and self._inner_function not in tags: + name = tags.get(self, f'{self.SYMBOL_PREFEX}{self.name}') + if isinstance(name, str): + name = (Variable(name, dtype=self.dtype), True) + tags[self._inner_function] = name + return self._inner_function.c_block(code_block=code_block, tags=tags, **kwargs) + @nargs(1) class HTanh(CompoundFunction): @@ -536,32 +559,123 @@ def _eval(self, *args, **kwargs): return args[0] +@nargs(3) +class ClipFloat(CompoundFunction): + + def _eval(self, *args, **kwargs): + return Min(Max(args[0], args[1], dtype=self.dtype), args[2], dtype=self.dtype) + + @nargs(1) @copy_props('_from_qrec', '_to_qrec') -class ConvertFloatScaled(CompoundFunction): - def __init__(self, *args, from_qrec=None, to_qrec=None, **kwargs): +class ConvertQuantization(CompoundFunction): + def __init__(self, *args, from_qrec: QRecBase=None, to_qrec: QRecBase=None, **kwargs): self._from_qrec = from_qrec self._to_qrec = to_qrec super().__init__(*args, **kwargs) @property - def from_qrec(self): + def from_qrec(self) -> QRecBase: return self._from_qrec @property - def to_qrec(self): - return self._to_qrec + def from_is_float(self) -> bool: + return self._from_qrec.dtype in [np.float16, np.float32, bfloat16] - def _eval_float_to_quant(self, *args, **kwargs): - raise NotImplementedError() + @property + def from_is_fix(self) -> bool: + return self._from_qrec.dtype in [np.int8, np.uint8, np.int16, np.uint16, np.int32] - def _eval_quant_to_float(self, *args, **kwargs): - raise NotImplementedError() + @property + def to_is_float(self) -> bool: + return self._to_qrec.dtype in [np.float16, np.float32, bfloat16] + + @property + def to_is_fix(self) -> bool: + return self._to_qrec.dtype in [np.int8, np.uint8, np.int16, np.uint16, np.int32] + + @property + def to_qrec(self) -> QRecBase: + return self._to_qrec + + def _eval_float_to_fix(self, *args, **kwargs) -> Symbol: + to_qrec = self.to_qrec + from_qrec = self.from_qrec + scaled_val = Mul( + args[0], + Constant( + [math.pow(2, to_qrec.q)/to_qrec.scale], + dtype=from_qrec.dtype), + dtype=from_qrec.dtype) + if to_qrec.zero_point != 0: + # need to add zero_point plus rounding + scaled_val = Add( + scaled_val, + Constant([to_qrec.zero_point + 0.5], dtype=from_qrec.dtype), + dtype=from_qrec.dtype) + else: + # Just add rounding + scaled_val = Add( + scaled_val, + Constant([0.5], dtype=from_qrec.dtype), + dtype=from_qrec.dtype) + iinfo = np.iinfo(to_qrec.dtype) + return Cast( + ClipFloat( + scaled_val, + Constant(iinfo.min, dtype=from_qrec.dtype), + Constant(iinfo.max, dtype=from_qrec.dtype), + dtype=from_qrec.dtype), + dtype=to_qrec.dtype, + tag=self.tag, + comment=self.comment) + + def _eval_fix_to_float(self, *args, **kwargs) -> Symbol: + to_qrec = self.to_qrec + from_qrec = self.from_qrec + float_val = Cast(args[0], dtype=to_qrec.dtype) + if from_qrec.zero_point != 0: + float_val = Sub( + float_val, + Constant([from_qrec.zero_point], dtype=to_qrec.dtype), + dtype=to_qrec.dtype) + float_val = Mul( + float_val, + Constant( + [from_qrec.scale/math.pow(2, from_qrec.q)], + dtype=to_qrec.dtype), + dtype=to_qrec.dtype, + tag=self.tag, + comment=self.comment) + return float_val + + def _eval(self, *args, **kwargs) -> Symbol: + if self.from_is_float: + if self.to_is_fix: + return self._eval_float_to_fix(*args, **kwargs) + elif self.to_is_float: + if self.to_qrec.dtype != self.from_qrec.dtype: + return Cast( + *args, + dtype=self.to_qrec.dtype, + **kwargs) + return args[0] + elif self.from_is_fix: + if self.to_is_float: + return self._eval_fix_to_float(*args, **kwargs) + elif self.to_is_fix: + # if self.to_qrec.dtype == self.from_qrec.dtype: + # return args[0] + # sign_change = from_qrec.signed != to_qrec.signed + # growing = from_qrec.size < to_qrec.size + # reducing = from_qrec.size > to_qrec.size + # zeropoint_change = from_qrec.zero_point != to_qrec.zero_point + # scale_change = from_qrec.scale != to_qrec.scale + # q_change = from_qrec.q != to_qrec.q + raise NotImplementedError() + + raise ValueError('unsupported conversion') - def _eval(self, *args, **kwargs): - if self._from_qrec.dtype == np.int16 or self._from_qrec.dtype == bfloat16: - return self._eval_float_to_quant(*args, **kwargs) - return self._eval_quant_to_float(*args, **kwargs) @nargs(2) class SquaredDifference(CompoundFunction): diff --git a/rtos/pmsis/pmsis_bsp/.gitmodules b/tools/nntool/expressions/symbolic/common/__init__.py similarity index 100% rename from rtos/pmsis/pmsis_bsp/.gitmodules rename to tools/nntool/expressions/symbolic/common/__init__.py diff --git a/tools/nntool/expressions/symbolic/float_quantization/float_qrec.py b/tools/nntool/expressions/symbolic/float_quantization/float_qrec.py index 5f2d4a2d7..bcb463e6f 100644 --- a/tools/nntool/expressions/symbolic/float_quantization/float_qrec.py +++ b/tools/nntool/expressions/symbolic/float_quantization/float_qrec.py @@ -26,6 +26,9 @@ def __init__(self, dtype: np.dtype, min_val=None, max_val=None) -> None: self._min_val = min_val self._max_val = max_val + def __repr__(self) -> str: + return self._dtype.__name__ + @property def min_val(self): return self._min_val diff --git a/tools/nntool/expressions/symbolic/float_quantization/float_quantization.py b/tools/nntool/expressions/symbolic/float_quantization/float_quantization.py index 00eb69f0c..fb6eae262 100644 --- a/tools/nntool/expressions/symbolic/float_quantization/float_quantization.py +++ b/tools/nntool/expressions/symbolic/float_quantization/float_quantization.py @@ -13,19 +13,17 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import math from typing import Tuple import numpy as np -from ..basic import Cast, ConvertFloatScaled +from ..basic import Cast, ConvertQuantization from ..q15_quantization.q15_scale_q_rec import Q15ScaleQRec from ..quantization_base import (QRecBase, QuantizationHandlerBase, handles_scheme) from ..symbol import Symbol, SymbolStats from .float_qrec import FloatQRec - @handles_scheme('Float') class FloatQuantization(QuantizationHandlerBase): @@ -64,28 +62,19 @@ def _quantize_output(cls, qtypes = kwargs.get('qtypes', {}) # first see if this has already been quantized by nntool # note that the qtype will be stored against the name of the output symbol - max_val, out_dtype, out_q = cls._get_scale_dtype_from_qtypes(osym, qtypes) - if max_val is not None: - qrec_out = Q15ScaleQRec(out_dtype, max_val, out_q) - # scale clip and cast to output type - return (ConvertFloatScaled(qsym, from_qrec=qrec, to_qrec=qrec_out), qrec_out) - if not out_dtype: - out_dtype = kwargs.get('out_dtype', np.float32) - # Just cast - return (Cast(qsym, dtype=out_dtype), FloatQRec(dtype=out_dtype, min_val=qrec.min_val, max_val=qrec.max_val)) + if not qtypes or osym.name not in qtypes: + out_dtype = kwargs.get('out_dtype', np.float32) + qrec_out = FloatQRec(out_dtype) + return (Cast(qsym, dtype=out_dtype), qrec_out) - @classmethod - def _get_scale_dtype_from_qtypes(cls, sym, qtypes): - if not qtypes or sym.name not in qtypes: - return None, None, None - qtype = qtypes[sym.name] - if qtype.dtype == np.int8: - if len(qtype.scale) > 1: - return None, None, None - return qtype.scale[0] * math.pow(2, 7), np.int8, 7 - elif qtype.dtype == np.int16: + qtype = qtypes[osym.name] + if qtype.dtype in [np.int8, np.uint8, np.int16, np.uint16]: if len(qtype.scale) > 1: - return None, None, None - return qtype.scale[0] * math.pow(2, 15), np.int16, 15 - else: - return None, qtype.dtype, None + out_dtype = kwargs.get('out_dtype', np.float32) + qrec_out = FloatQRec(out_dtype) + return (Cast(qsym, dtype=out_dtype), qrec_out) + max_val, min_val, bitlen = Q15ScaleQRec.dtype_zp_to_min_max(qtype.dtype, qtype.scale[0], qtype.zero_point) + qrec_out = Q15ScaleQRec(qtype.dtype, max_val, bitlen, min_val=min_val, max_val=max_val, zero_point=qtype.zero_point) + return (ConvertQuantization(qsym, from_qrec=qrec, to_qrec=qrec_out), qrec_out) + qrec_out = FloatQRec(dtype=qtype.dtype, max_val=qtype.max_val, min_val=qtype.min_val) + return (Cast(qsym, dtype=qtype.dtype),qrec_out) diff --git a/tools/nntool/expressions/symbolic/float_quantization/handlers.py b/tools/nntool/expressions/symbolic/float_quantization/handlers.py index 298139bcc..0c5c8a5e6 100644 --- a/tools/nntool/expressions/symbolic/float_quantization/handlers.py +++ b/tools/nntool/expressions/symbolic/float_quantization/handlers.py @@ -23,7 +23,7 @@ np_fastpow2, np_fastrsqrt, np_fastsigmoid, np_fasttanh) -from ..basic import (Abs, Add, ATan, Cast, Cos, Div, Exp, HSigmoid, HTanh, Log, +from ..basic import (Abs, Add, ATan, Cast, ConvertQuantization, Cos, Div, Exp, HSigmoid, HTanh, Log, Max, Min, Mul, Pow, RSqrt, Sigmoid, Sin, Sqrt, Sub, TanH) from ..function import Function from ..quantization_base import qhandler @@ -35,7 +35,6 @@ # from utils.sigmoid_tanh_lut import sigmoid_lut_float, tanh_lut_float - @qhandler("Float", Constant, Rational) class BasicConstantQuant(FloatQuantization): @@ -58,7 +57,7 @@ def _quantize(cls, sym_ctrl: SymbolStats, qrec: FloatQRec = None, **kwargs) -> Tuple[Symbol, FloatQRec]: - + # TODO: Needs merging with Q15 version prequantized_variables = kwargs.get('prequantized_variables', {}) qtypes = kwargs.get('qtypes', {}) @@ -75,25 +74,27 @@ def _quantize(cls, qrec = cls.qrec_from_qtype(qtypes[sym.name], max_val) if qrec: sym.qrec = qrec - return (sym, qrec) + if isinstance(qrec, FloatQRec): + return (sym, qrec) + out_dtype = kwargs.get('out_dtype', np.float32) + out_qrec = FloatQRec(dtype=out_dtype, max_val=max_val, min_val=-max_val) + return ( + ConvertQuantization(sym, from_qrec=qrec, to_qrec=out_qrec, tag=sym.name), + out_qrec) out_dtype = kwargs.get('out_dtype', np.float32) return sym, FloatQRec(dtype=out_dtype, max_val=max_val, min_val=-max_val) @classmethod def qrec_from_qtype(cls, qtype, max_val): - if qtype.dtype == np.int8 or qtype.dtype == np.int16: - if qtype.dtype == np.int8: - if len(qtype.scale) > 1: - qtype.scale = np.max(qtype.scale) - q = 7 - dtype = np.int8 - elif qtype.dtype == np.int16: - if len(qtype.scale) > 1: - qtype.scale = np.max(qtype.scale) - q = 15 - dtype = np.int16 - return Q15ScaleQRec(dtype, max_val, q, max_val=max_val, min_val=-max_val) + if qtype.dtype in [np.int8, np.uint8, np.int16, np.uint16]: + if len(qtype.scale) > 1: + return None + max_val, min_val, bitlen = Q15ScaleQRec.dtype_zp_to_min_max( + qtype.dtype, qtype.scale[0], qtype.zero_point[0]) + return Q15ScaleQRec(qtype.dtype, max_val, bitlen, + max_val=max_val, min_val=min_val, + zero_point=qtype.zero_point[0]) elif qtype.dtype in [np.float32, np.float16, bfloat16]: return FloatQRec(dtype=qtype.dtype, max_val=max_val, min_val=-max_val) else: @@ -157,6 +158,7 @@ def _c_expr(self, *args, **kwargs): # TODO - Need numpy equivalents of sin and cos # TODO - All of these should return correct function based on output type (i.e. bfloat16/ieee16 version) + @nargs(1) @environment({ 'npcos': np.cos, diff --git a/tools/nntool/expressions/symbolic/function.py b/tools/nntool/expressions/symbolic/function.py index e09fabecb..b44404655 100644 --- a/tools/nntool/expressions/symbolic/function.py +++ b/tools/nntool/expressions/symbolic/function.py @@ -16,6 +16,8 @@ import numpy as np +from generation.code_block import CodeBlock + from .symbol import Constant, Symbol, Variable, environment from .variable_container import VariableContainer @@ -81,16 +83,17 @@ def _resolve(self, **kwargs): for elem in self._contents] return self._eval(*contents, **kwargs) - def _calculate(self, calculate_ranges=False, track_results=None, **kwargs): + def _calculate(self, calculate_ranges=False, track_results=None, dequantize_outputs=False, **kwargs): contents = [elem.calculate(calculate_ranges=calculate_ranges, track_results=track_results, + dequantize_outputs=dequantize_outputs, **kwargs) for elem in self._contents] res = self._eval(*contents, **kwargs) if calculate_ranges: self.control.add_stat(self, res.value) if track_results is not None: - if self.qrec is not None: + if self.qrec is not None and dequantize_outputs: track_results[self.name] = self.qrec.dequantize( res.value.copy()) else: @@ -136,6 +139,38 @@ def py_compiled_lambda(self): def c_expr(self, *args, **kwargs) -> str: return self._c_expr(*(arg.c_expr(*args, **kwargs) for arg in self._contents)) + def c_block(self, code_block=None, tags=None, with_comment=False, **kwargs): + if code_block is None: + code_block = CodeBlock() + if tags is not None: + args = [] + for arg in self._contents: + arg.c_block(code_block=code_block, tags=tags, + with_comment=with_comment, **kwargs) + if arg.tag: + if arg in tags: + args.append(tags[arg]) + else: + name = tags.get(arg, f'{self.SYMBOL_PREFEX}{arg.name}') + if isinstance(name, tuple): + name = name[0].c_expr() + args.append(name) + else: + args.append(code_block.lines.pop(-1).strip()) + if self.tag: + if self.comment and with_comment: + code_block.write(f'// {self.comment}') + name = tags.get(self, f'{self.ctype} {self.SYMBOL_PREFEX}{self.name}') + if isinstance(name, tuple): + name = name[0].c_expr( + dtype=name[0].dtype, declare=name[1], **kwargs) + code_block.write(f'{name} = {self._c_expr(*args)};') + else: + code_block.write(f'{self._c_expr(*args)}') + else: + code_block.write(self.c_expr(*args, **kwargs)) + return code_block + @property def py_lambda(self) -> str: return "lambda %s: %s" % (",".join("%s=None" % (var) for var in self.unbound_variables), self.py_expr()) diff --git a/tools/nntool/expressions/symbolic/function_collection.py b/tools/nntool/expressions/symbolic/function_collection.py index d4c7e9774..880c3f5b8 100644 --- a/tools/nntool/expressions/symbolic/function_collection.py +++ b/tools/nntool/expressions/symbolic/function_collection.py @@ -31,7 +31,7 @@ class FunctionCollection(): def __init__(self, functions: Sequence[Tuple[Variable, Symbol]], qrecs=None) -> None: self._qrecs = qrecs # save map from produced variable to function - self._functions = {k: v for k, v in functions} + self._functions = {k: v for k, v in functions} # now create a map with producted variable name to free variables in function self._freevars = {var.name: set([name for name in func.unbound_variables.keys()]) for var, func in self._functions.items()} @@ -51,16 +51,18 @@ def __init__(self, functions: Sequence[Tuple[Variable, Symbol]], qrecs=None) -> for name, symbol in func.unbound_variables.items(): if name in self._vars: if self._vars[name] != symbol: - raise ValueError('%s points to more than one variable' % name) + raise ValueError( + '%s points to more than one variable' % name) else: self._vars[name] = symbol if res_symbol.name in self._vars: if self._vars[res_symbol.name] != res_symbol: - raise ValueError('%s points to more than one variable' % res_symbol.name) + raise ValueError( + '%s points to more than one variable' % res_symbol.name) else: self._vars[res_symbol.name] = res_symbol self.init_indexes() - + def init_indexes(self): # iterators contains list of iterators self._iterators = None @@ -123,6 +125,10 @@ def ops(self): def c_header_set(self): return set().union(*[func.c_header_set for func in self._functions.values()]) + def set_var_shapes(self): + for var, func in self.functions.items(): + var.shape = func.shape + @staticmethod def split_indexes(unique_axis_groups): uaq = sorted(unique_axis_groups, key=len) @@ -164,7 +170,8 @@ def _create_indexes(self): key=lambda x: next(i for i in x)) idx_names = ["_".join(["d%s" % idx for idx in sorted(list(idxes))]) for idxes in unique_indexes] - idx_dims = [reduce(lambda x, y: x*max_shape[y], idxes, 1) for idxes in unique_indexes] + idx_dims = [reduce(lambda x, y: x*max_shape[y], idxes, 1) + for idxes in unique_indexes] self._iterators = [Variable(idx_name, shape=tuple([idx_dim]), dtype=np.int32) for idx_name, idx_dim in zip(idx_names, idx_dims)] if not self._iterators: @@ -198,7 +205,8 @@ def get_iterator_vars(self): if depth == 0: iters.extend([('First', 0), ('Last', var.shape[0])]) else: - iters.append((self.iterators[depth].name.upper(), var.shape[0])) + iters.append( + (self.iterators[depth].name.upper(), var.shape[0])) return iters def create_kernel(self, parallel_iterator, fixed_iterators, code_block=None): @@ -251,13 +259,23 @@ def create_kernel(self, parallel_iterator, fixed_iterators, code_block=None): assert produced_idx >= len(execution_order) return code_block - def produce_functions(self, produced_idx, execution_order, index_dependencies, depth, code_block): + def produce_functions(self, produced_idx, execution_order, index_dependencies, depth, code_block, tags=None): while (produced_idx < len(execution_order) and index_dependencies[execution_order[produced_idx].name] == depth): + this_tags = {} if tags is None else tags.copy() var = execution_order[produced_idx] declare = var.name in self.intermediate_names - code_block.write("{} = {};", var.c_expr(declare=declare, dtype=var.dtype), - self._functions[var].c_expr()) + # write comment with quantization if present + uvars = [f'{uvar.name}: {uvar.qrec}' + for uvar in self._functions[var].unbound_variables.values() + if uvar.qrec] + if uvars: + uvars = " ".join(uvars) + code_block.write(f'// inputs {uvars}') + this_tags[self._functions[var]] = (var, declare) + self._functions[var].tag = True + self._functions[var].c_block(code_block=code_block, tags=this_tags) + self._functions[var].tag = False produced_idx += 1 return produced_idx diff --git a/tools/nntool/expressions/symbolic/iteration_space.py b/tools/nntool/expressions/symbolic/iteration_space.py index fe07dea7b..c2f8327ee 100644 --- a/tools/nntool/expressions/symbolic/iteration_space.py +++ b/tools/nntool/expressions/symbolic/iteration_space.py @@ -1,4 +1,4 @@ -# Copyright (C) 2021 GreenWaves Technologies, SAS +# Copyright (C) 2022 GreenWaves Technologies, SAS # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -13,31 +13,69 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . + from functools import partial, reduce from itertools import groupby from operator import itemgetter from typing import List, Sequence import numpy as np -from quantization.qtype import DTYPE_GAP_CTYPE +from bfloat16 import bfloat16 +from generation.code_block import CodeBlock +from quantization.qtype import DTYPE_GAP_CTYPE, DTYPES +from .assignments import Assignments from .symbol import Symbol -from .variable_container import VariableContainerAndAssigner def split_list(sequence: Sequence): return [list(map(itemgetter(1), g)) for k, g in groupby(enumerate(sequence), lambda x: x[0]-x[1])] +def tabulate(lines): + """Takes a list of lists of strings and lines up lengths to improve formating""" + # get max length of each segment + max_len = tuple(max(elems) for elems + in zip(*[tuple(len(line_elem) for line_elem in line) + for line in lines])) + # add spaces to each line segment + + def reduction(s, x): + s.append( + f'{"".join(elem + " " * (max_len[idx] - len(elem)) for idx, elem in enumerate(x[:-1]))}{x[-1]}') + return s + return reduce(reduction, lines, []) + + +AT_ARG_DATATYPES = { + np.uint8: ('CNN_ArgDataTypeUns', 1, False, False), + np.uint16: ('CNN_ArgDataTypeUns', 2, False, False), + np.uint32: ('CNN_ArgDataTypeUns', 4, False, False), + np.uint64: ('CNN_ArgDataTypeUns', 8, False, False), + np.int8: ('CNN_ArgDataType', 1, True, False), + np.int16: ('CNN_ArgDataType', 2, True, False), + np.int32: ('CNN_ArgDataType', 4, True, False), + np.int64: ('CNN_ArgDataType', 8, True, False), + np.float16: ('CNN_ArgDataTypeF', 2, True, True), + bfloat16: ('CNN_ArgDataTypeF', 2, True, True), + np.float32: ('CNN_ArgDataTypeF', 4, True, True), +} + class IterationSpace(): - def __init__(self, assigner: VariableContainerAndAssigner, min_interior_space=1000) -> None: - self._assigner = assigner + def __init__(self, assignments: Assignments, constants=None, min_interior_space=1000, max_interior_space=10000, num_parameteric_spaces=2) -> None: + self._assignments = assignments self._var_shapes = None self._var_axes = None + self._var_is_constant = {} self._spaces = None + self._var_axes_idx = None self._min_interior_space = min_interior_space + self._max_interior_space = max_interior_space self._num_workers = 8 self._var_strides = {} + self._num_parameteric_spaces = num_parameteric_spaces + if constants: + self.vars_are_constant(*constants) @staticmethod def _var_name(idx): @@ -68,10 +106,27 @@ def set_var_stride(self, vname, stride): self._var_axes = None self._spaces = None self._var_strides[vname] = stride + self._var_axes_idx = None + + def is_var_constant(self, var_name): + return self._var_is_constant.get(var_name, False) + + def vars_are_constant(self, *var_names): + for var_name in var_names: + self._var_is_constant[var_name] = True + return self + + @property + def assignments(self): + return self._assignments + + @property + def real_shape(self): + return tuple(dim for dim in self.shape if dim != 1) @property def shape(self): - return max(zip(*Symbol.extend_shapes(*self._assigner.unbound_shapes))) + return self.assignments.max_shape @property def full_rank(self): @@ -96,16 +151,16 @@ def extended_strides(self): return tuple(reduce(lambda state, x: state + [frozenset(set.union(*x))], zip(*tuple(vstrides.values())), [])) @property - def produced_variables(self): - return set(self._assigner.returned_variables) + def output_names(self): + return self._assignments.output_names @property - def consumed_variables(self): - return set(self._assigner.unbound_variables) + def input_names(self): + return self._assignments.input_names @property - def temporary_variables(self): - return set(self.variables) - self.produced_variables - self.consumed_variables + def temporary_names(self): + return self._assignments.intermediate_names def space_for_axis(self, axis): return next((axes for axes in self.spaces if axis in axes), None) @@ -123,18 +178,35 @@ def var_axes(self): for vname, shape in self.var_shapes.items()} return self._var_axes + @property + def var_axes_idx(self): + """Map of variable name to index of iteration space used + + Returns: + dict: Map of variable name to index of iteration space used + """ + if self._var_axes_idx is None: + self._var_axes_idx = {vname: tuple(self.spaces.index(dim) for dim in axes) + for vname, axes in self.var_axes.items()} + return self._var_axes_idx + @property def variables(self): """Set of variable names """ return set(self.var_shapes) + @property + def spaces_size(self): + return tuple(int(np.prod([self.shape[idx] for idx in space])) for space in self.spaces) + @property def spaces(self): """Set of disjoint iteration spaces that have the same set of strides """ if self._spaces is None: - spaces = self._assigner.axes + max_shape = self.assignments.max_shape + spaces = self._assignments.axes # here we modify grouped spaces so that continuous spaces have the same stride if self._var_strides: final_spaces = list(spaces) @@ -148,12 +220,14 @@ def spaces(self): def reduction(var_stride, state: List, space): space_strides = {} for dim in space: - space_strides.setdefault(var_stride[dim], []).append(dim) + space_strides.setdefault( + var_stride[dim], []).append(dim) for space_group in space_strides.values(): state.extend(split_list(space_group)) return state - final_spaces = reduce(partial(reduction, var_stride), final_spaces, []) + final_spaces = reduce( + partial(reduction, var_stride), final_spaces, []) self._spaces = tuple(sorted(tuple(sorted(space)) for space in final_spaces)) else: @@ -161,57 +235,89 @@ def reduction(var_stride, state: List, space): return self._spaces + @property + def expanded_spaces(self): + res = [] + last = 0 + for space in self.spaces: + res.append(tuple(range(last, min(space))) + space) + if res: + res[-1] = res[-1] + tuple(range(max(res[-1])+1, len(self.shape))) + return tuple(res) + + @property + def space_total_items(self): + return tuple(np.stack(list(self.var_shapes.values())).sum(axis=0)) + + @property + def space_total_bytes(self): + variables = [self.assignments.variables[name] for name in self.var_shapes] + sizes = [1 if var.dtype is None else AT_ARG_DATATYPES[var.dtype][1] for var in variables] + return tuple((np.stack(list(self.var_shapes.values())) * np.array(sizes).reshape((-1, 1))).sum(axis=0)) + @property def var_shapes(self): if self._var_shapes is None: - self._var_shapes = self._assigner.var_shapes.copy() + self._var_shapes = self._assignments.var_shapes.copy() self._var_shapes = dict( zip(self._var_shapes.keys(), Symbol.extend_shapes(*self._var_shapes.values()))) return self._var_shapes @property - def axis_shape(self): - return tuple(np.prod([self.shape[axis] for axis in axis_set]) for axis_set in self.spaces) + def has_scalar_parameters(self): + return any(len(shape) == 1 and shape[0] == 1 for shape in self.var_shapes.values()) + @property def iterator_names(self): return [self._var_name(idx) for idx in range(len(self.spaces))] @property - def interior_space(self): + def interior_spaces(self): """This provides the minimum tile space if it is more than one axis""" + expanded_spaces = list(self.expanded_spaces) + if len(expanded_spaces) <= 1: + return tuple() dims = [] - shape = list(self.axis_shape) + bytes = self.space_total_bytes total = 1 - while len(shape) > 1 and total < self._min_interior_space: - dims.append(len(shape) - 1) - total *= shape[-1] - shape = shape[0:-1] - return tuple(reversed(dims)) + while len(expanded_spaces) > 1 and total < self._min_interior_space: + new_size = total * np.prod([bytes[idx] for idx in expanded_spaces[-1]]) + if new_size * 8 > self._max_interior_space: + break + dims.append(len(expanded_spaces) - 1) + total = new_size + expanded_spaces = expanded_spaces[0:-1] + return tuple(self.spaces[idx] for idx in reversed(dims)) @property def interior_shape(self): - shape = list(self.axis_shape) - return tuple(shape[idx] for idx in self.interior_space) + return tuple(self.shape[self.spaces.index(space)] for space in self.interior_spaces) @property def exterior_spaces(self): - return tuple(range(len(self.axis_shape) - len(self.interior_space))) + return tuple(self.spaces[idx] for idx in range(len(self.spaces_size) - len(self.interior_spaces))) @property def exterior_space_names(self): - return tuple(self._par_name(idx) for idx in range(len(self.exterior_spaces))) + return tuple(self._par_name(self.spaces.index(space)) for space in range(len(self.exterior_spaces))) @property def exterior_shape(self): - shape = list(self.axis_shape) + shape = list(self.spaces_size) num_ext_spaces = len(self.exterior_spaces) return tuple(shape[:num_ext_spaces - 1] + [shape[num_ext_spaces - 1] * np.prod(self.interior_shape)]) @property - def parameteric_spaces(self): - return tuple(self.exterior_spaces[-2:]) + def parametric_spaces(self): + return tuple(self.exterior_spaces[-self._num_parameteric_spaces:]) + + @property + def paralellized_space(self): + if self.parametric_spaces: + return max([(space, self.real_shape[self.spaces.index(space)]) for space in self.parametric_spaces], key=lambda x: x[1])[0] + return 0 @property def interior_shape_size(self): @@ -219,7 +325,7 @@ def interior_shape_size(self): @property def fixed_spaces(self): - return tuple(self.exterior_spaces[:-2]) + return tuple(self.exterior_spaces[:-self._num_parameteric_spaces]) def preferred_divisor(self, space): if space == 0: @@ -232,19 +338,22 @@ def preferred_divisor(self, space): return 1 def c_indexed_var(self, var_name, declare=False, assignment=False): - if var_name in self.temporary_variables: + # if var_name.startswith('_SYMBOL'): + # return var_name + if var_name in self.temporary_names: if declare or assignment: - dtype = self._assigner.find(var_name).dtype + dtype = self._assignments.variable(var_name).dtype return f"{DTYPE_GAP_CTYPE[dtype]} {var_name}" return var_name if declare: - dtype = self._assigner.find(var_name).dtype + dtype = self._assignments.variable(var_name).dtype return f"{DTYPE_GAP_CTYPE[dtype]} *{var_name}" - return f'{var_name}{self.c_index(var_name)}' + c_index = self.c_index(var_name) + if c_index: + return f'{var_name}{c_index}' + return f'*{var_name}' def c_index(self, var_name): - var_spaces = [self.spaces.index(space) - for space in self.var_axes[var_name]] var_ext_shape = self.var_shapes[var_name] var_shape = [np.prod([var_ext_shape[dim] for dim in space]) for space in self.var_axes[var_name]] @@ -256,23 +365,24 @@ def c_index(self, var_name): assert all(var_stride_in_space[-1] == var_stride[dim] for dim in space[1:]) else: - var_stride_in_space = [1] * len(var_spaces) + var_stride_in_space = [1] * len(self.var_axes[var_name]) def reduction(state, x): var_space, space_dim, var_stride = x + var_space_idx = self.spaces.index(var_space) # fixed spaces are iterated by tiler code if var_space in self.fixed_spaces: return state space_size = str( - space_dim) if var_space in self.interior_space else self._var_max_name(var_space) + space_dim) if var_space == self.interior_spaces else self._var_max_name(var_space_idx) assert abs(var_stride) == 1, "non unit strides not supported yet" if var_stride < 0: if var_space == 0: - index = f'(Last-1-{self._var_name(var_space)})' + index = f'(Last-1-{self._var_name(var_space_idx)})' else: - index = f'({space_size}-1-{self._var_name(var_space)})' + index = f'({space_size}-1-{self._var_name(var_space_idx)})' else: - index = f'{self._var_name(var_space)}' + index = f'{self._var_name(var_space_idx)}' if state[0]: state[1].insert( 0, f"({index}*{'*'.join(state[0])})") @@ -280,20 +390,313 @@ def reduction(state, x): state[1].insert(0, index) state[0].insert(0, str( - space_dim) if var_space in self.interior_space else self._var_max_name(var_space)) + space_dim) if var_space == self.interior_spaces else self._var_max_name(var_space_idx)) return state - index = reduce(reduction, zip(reversed(var_spaces), + index = reduce(reduction, zip(reversed(self.var_axes[var_name]), reversed(var_shape), reversed(var_stride_in_space)), ([], []))[1] - return f"[{'+'.join(index)}]" + return f"[{'+'.join(index)}]" if index else "" + + def get_iterator_vars(self): + iters = [] + for idx, space in enumerate(self.spaces): + if space in self.interior_spaces: + continue + if space == self.paralellized_space: + iters.extend([('First', 0), ('Last', self.spaces_size[idx]), (self._var_max_name(idx), self.spaces_size[idx])]) + else: + iters.append( + (self._var_max_name(idx), self.spaces_size[idx])) + return iters - def c_for(self, space): - if space in self.fixed_spaces: + def c_for(self, space, with_fixed=False): + if not with_fixed and space == self.fixed_spaces: raise ValueError( - "space is fixed so not iterated and requires no for loop") - var_name = self._var_name(space) - if space in self.interior_space: - return f"for (int {var_name}=0; {var_name}<{self.shape[space]}; {var_name}++)" - if space == 0: + "space is fixed so not iterated inside basic kernel and requires no for loop") + space_index = self.spaces.index(space) + var_name = self._var_name(space_index) + if space in self.interior_spaces: + return f"for (int {var_name}=0; {var_name}<{self.real_shape[space_index]}; {var_name}++)" + if space == self.paralellized_space: return f"for (int {var_name}=First; {var_name}= len(self.exterior_spaces): + int_size *= self.spaces_size[space_idx] + continue + if var_stride and var_stride[var_dim_idx] < 0: + iter_space_descrs.append( + f'KER_ITER_D{space_idx}|SPACE_PROP_REVERT') + else: + iter_space_descrs.append(f'KER_ITER_D{space_idx}') + if iter_space_descrs: + argspace = f'KerArgSpace({len(iter_space_descrs)}, {", ".join(iter_space_descrs)})' + else: + argspace = 'KerArgSpace(1, KER_ITER_TILE0)' + if var_name in self.output_names: + constraints = "O_OUT|O_DB" if iter_space_descrs else "O_OUT|O_BUFF|O_NTILED" + elif self.is_var_constant(var_name): + constraints = "O_IN|O_DB|O_CONST" + else: + constraints = "O_IN|O_DB" if iter_space_descrs else "O_IN|O_BUFF|O_NTILED" + kargs.append( + (f'KerArg("{var_name}", ', + f'{argspace}, ', + f'{constraints}, ', + f'1, 1, ', + f'{self.ctype_len(var_name) * int_size}, ', + f'0, 0, 0, "{var_name}")')) + return tabulate(kargs) + + @property + def at_uk_cargs(self): + return ([f'TCArg({self.at_argdatatype(var_name, pointer=True, restrict=True)}, "{var_name}")' + for var_set in [self.input_names, self.output_names] + for var_name in sorted(var_set)]) + + @property + def at_uk_kinfos(self): + cvars = sorted(self.input_names) + pvars = sorted(self.output_names) + in_sizes = [np.prod(self.var_shapes[var_name]) + for var_name in cvars] + out_sizes = [np.prod(self.var_shapes[var_name]) + for var_name in pvars] + bandwidth = sum(in_sizes + out_sizes) + kinfos = [ + f"AddKernelInfos(Name, AT_KERINFO_OPER, {self._assignments.ops * max(in_sizes)}, 0)", + f"AddKernelInfos(Name, AT_KERINFO_BANDWIDTH, {bandwidth}, 0)" + ] + ksize_infos = [] + for var_name in cvars + pvars: + shape = reduce( + lambda s, x: s + [x] if x > 1 or s else s, self.var_shapes[var_name], []) + _, item_size, _, is_float = AT_ARG_DATATYPES[ + self._assignments.variables[var_name].dtype] + add_arg_func = "AddKernelFloatArgDim" if is_float else "AddKernelArgDim" + ksize_infos.append( + (f'{add_arg_func}(Name, "{var_name}", ', + f'{len(shape) + 1}, ', + f'{", ".join(str(dim) for dim in shape) if shape else 1}, ', + f'{item_size})')) + return kinfos + tabulate(ksize_infos) + + @property + def kernel_args(self): + return ([(self._var_max_name(self.spaces.index(space)), 'unsigned int') for space in self.exterior_spaces] + + [(var_name, self.ctype(var_name, pointer=True, restrict=True)) + for var_set in [self.input_names, self.output_names] + for var_name in sorted(var_set)]) + + @property + def at_uk_kerbindings(self): + bindings = [ + f"K_ArgPar(\"{max(self.output_names, key=lambda x: self.var_shapes[x][idx])}\", KER_ARG_PARTILE_SIZE, KER_ITER_D{idx})" + for idx in range(len(self.exterior_shape)) + ] + [ + f"K_Arg(\"{var_name}\", KER_ARG_TILE)" + for var_set in [self.input_names, self.output_names] + for var_name in sorted(var_set) + ] + return bindings + + def comment_attrs(self, code, *attrs): + code.comment("".join(f'{name}: {getattr(self, name)} ' if getattr(self, name) else '' + for name in attrs)) + + def gen_kernel_headers(self, code: CodeBlock = None): + if code is None: + code = CodeBlock() + for include in self._assignments.c_header_set: + code.write('#include {}', include) + return code + + def gen_user_kernel(self, ukname: str, kname: str, code: CodeBlock = None): + if code is None: + code = CodeBlock() + code.write(f"int {ukname}(char *Name) {{") + code.indent() + code.write("Kernel_T *Kernel = UserKernel(") + code.indent() + code.write("Name,") + # include some useful parameters as comment + self.comment_attrs(code, + 'shape', + 'spaces') + self.comment_attrs(code, + 'fixed_spaces', + 'parametric_spaces', + 'interior_spaces') + self.comment_attrs(code, + 'exterior_shape', + 'interior_shape') + code.write(f'{self.at_uk_iterspace},') + kargs = self.at_uk_kargs + code.write("TILE_VER,") + cargs = self.at_uk_cargs + code.write(f"CArgs({len(cargs)},") + code.indent() + for carg in cargs[: -1:]: + code.write(f"{carg},") + code.write(f"{cargs[-1]}") + code.deindent() + code.write("),") + code.write("Calls(1,") + code.indent() + code.write(f'Call("{kname}", LOC_D{len(self.exterior_shape) - 1},') + code.indent() + bindings = self.at_uk_kerbindings + code.write(f"Bindings({len(bindings)},") + code.indent() + for binding in bindings[: -1:]: + code.write(f"{binding},") + code.write(f"{bindings[-1]}") + code.deindent() + code.write(")") + code.deindent() + code.write(")") + code.deindent() + code.write("),") + for var_name, idxes in self.var_axes_idx.items(): + if var_name in self.temporary_names: + continue + stride = f" stride: {self._var_strides[var_name]}" if var_name in self._var_strides else "" + code.comment(f'var: {var_name} axes: {idxes}{stride}') + code.write("KerArgs({0},", len(kargs)) + code.indent() + for karg in kargs[: -1:]: + code.write("{0},", karg) + code.write("{0}", kargs[-1]) + code.deindent() + code.write(")") + code.deindent() + code.write(");") + code.write("if (Kernel) {") + code.indent() + for kinfo in self.at_uk_kinfos: + code.write("{0};", kinfo) + code.deindent() + code.write("}") + code.write("return (Kernel!=0);") + code.deindent() + code.write("}") + return code + + def gen_function(self, kernel_name: str, kernel_arg_type_name: str, code: CodeBlock = None): + if code is None: + code = CodeBlock() + + code.comment( + f'Output iteration space reduced to {len(self.interior_spaces)} internal ' + f'and {len(self.exterior_spaces)} external iteration spaces') + code.write(f"void {kernel_name}({kernel_arg_type_name} *Args) {{") + code.indent() + comments = [] + for kerarg_name, _ in self.kernel_args: + # TODO - add qrecs for quantized kernels + comments.append([ + f'{self.var_shapes[kerarg_name]} ' if kerarg_name in self.var_shapes else '', + f'{self._assignments.qrecs[kerarg_name]}' if kerarg_name in self._assignments.qrecs else '' + ]) + comments = tabulate(comments) + for idx, (kerarg_name, kerarg_type) in enumerate(self.kernel_args): + # TODO - add qrecs for quantized kernels + comment = comments[idx] + if comment.strip(): + comment = f' // {comment}' + else: + comment = '' + code.write( + f'{kerarg_type} {kerarg_name} = Args->{kerarg_name};{comment}') + # paralellize on largest dimension + last_first = self._var_max_name(self.spaces.index(self.paralellized_space)) + code.write('unsigned int CoreId = gap_coreid();') + code.write(f'unsigned int Chunk = ChunkSize({last_first});') + code.write('unsigned int First = Chunk*CoreId;') + code.write(f'unsigned int Last = gap_min(First+Chunk, {last_first});') + self._assignments.c_block(code, iteration_space=self, + with_loops=True, with_comment=True) + code.write('gap_waitbarrier(0);') + code.deindent() + code.write('}') + return code + + def gen_kernel_arg_typedecl(self, type_name, code=None): + if code is None: + code = CodeBlock() + code.write('typedef struct {') + code.indent() + for kerarg_name, kerarg_type in self.kernel_args: + code.write(f'{kerarg_type} {kerarg_name};') + code.deindent() + code.write(f'}} {type_name};') + return code + + def gen_kernel_model(self, kernel_name, kernel_arg_type_name, code=None): + if code is None: + code = CodeBlock() + code.write('LibKernelTemplate(') + code.indent() + code.write(f'"{kernel_arg_type_name}",') + code.write(f'CArgs({len(self.kernel_args)},') + code.indent() + for idx, (kerarg_name, kerarg_type) in enumerate(self.kernel_args): + code.write('TCArg("{}", "{}"){}', + kerarg_type, + kerarg_name, + "," if idx < (len(self.kernel_args) - 1) else '') + code.deindent() + code.write(')') + code.deindent() + code.write(');') + code.write('') + code.write('LibKernel(') + code.indent() + code.write('"{}",', kernel_name) + code.write('CALL_PARALLEL,') + code.write('0,') + code.write('"{}",', kernel_arg_type_name) + code.write('0') + code.deindent() + code.write(');') + + return code diff --git a/tools/nntool/expressions/symbolic/kernel_codegen.py b/tools/nntool/expressions/symbolic/kernel_codegen.py deleted file mode 100644 index 1e45a6ab3..000000000 --- a/tools/nntool/expressions/symbolic/kernel_codegen.py +++ /dev/null @@ -1,313 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import logging -from typing import Sequence - -import numpy as np -from generation.code_block import CodeBlock -from quantization.qtype import DTYPES - -from .function_collection import FunctionCollection - -LOG = logging.getLogger("nntool." + __name__) - - -class BasicKernel(): - def __init__(self, func_col: FunctionCollection, constant_input_names: Sequence[str]) -> None: - self._func_col = func_col - self._constant_input_names = constant_input_names - - @property - def func_col(self): - return self._func_col - - @property - def input_names(self): - return self._func_col.input_names - - @property - def input_names_and_ctypes(self): - return [(name, self.func_col.qrecs[name].ctype) for name in self.input_names] - - @property - def output_names(self): - return self._func_col.output_names - - @property - def output_names_and_ctypes(self): - return [(name, self.func_col.qrecs[name].ctype) for name in self.output_names] - - @property - def intermediate_names(self): - return self._func_col.intermediate_names - - @property - def shapes(self): - return self._func_col.var_shapes - - @property - def kernel_dims(self): - return self._func_col.kernel_dims - - @property - def kernel_args(self): - kernel_args = [] - for kiter in self.func_col.iterators: - kernel_args.append((kiter.name.upper(), "unsigned int")) - for input_name, ctype in self.input_names_and_ctypes: - kernel_args.append((input_name, f"{ctype} *")) - for output_name, ctype in self.output_names_and_ctypes: - kernel_args.append((output_name, f"{ctype} *")) - return kernel_args - - def ctype_len(self, sym_name): - dtype = self.func_col.qrecs[sym_name].dtype - if dtype not in DTYPES: - raise ValueError(f"don't know dtype {dtype}") - return DTYPES[dtype][0]//8 - - def gen_kernel_headers(self, code: CodeBlock = None): - if code is None: - code = CodeBlock() - for include in self._func_col.c_header_set: - code.write('#include {}', include) - return code - - def gen_user_kernel(self, ukname: str, kname: str, code: CodeBlock = None): - if code is None: - code = CodeBlock() - code.write("int {0}(char *Name) {{", ukname) - code.indent() - code.write("Kernel_T *Kernel = UserKernel(") - code.indent() - code.write("Name,") - code.write("{0},", self.gen_iterspace()) - kargs = self.gen_kargs() - code.write("TILE_HOR,") - cargs = self.gen_cargs() - code.write("CArgs({0},", len(cargs)) - code.indent() - for carg in cargs[:-1:]: - code.write("{0},", carg) - code.write("{0}", cargs[-1]) - code.deindent() - code.write("),") - code.write("Calls(1,") - code.indent() - code.write("Call(\"{0}\", LOC_D{1},", kname, - len(self.func_col.iterators) - 1) - code.indent() - bindings = self.gen_kerbingings() - code.write("Bindings({0},", len(bindings)) - code.indent() - for binding in bindings[:-1:]: - code.write("{0},", binding) - code.write("{0}", bindings[-1]) - code.deindent() - code.write(")") - code.deindent() - code.write(")") - code.deindent() - code.write("),") - code.write("KerArgs({0},", len(cargs)) - code.indent() - for karg in kargs[:-1:]: - code.write("{0},", karg) - code.write("{0}", kargs[-1]) - code.deindent() - code.write(")") - code.deindent() - code.write(");") - code.write("if (Kernel) {") - code.indent() - for kinfo in self.gen_kinfos(): - code.write("{0};", kinfo) - code.deindent() - code.write("}") - code.write("return (Kernel!=0);") - code.deindent() - code.write("}") - return code - - def gen_kinfos(self): - in_sizes = [np.prod(self._func_col.var_shapes[var_name]) - for var_name in self._func_col.input_names] - bandwidth = sum([np.prod(self._func_col.var_shapes[var_name]) - for var_name in self._func_col.output_names]) + sum(in_sizes) - kinfos = [ - "AddKernelInfos(Name, AT_KERINFO_OPER, {0}, 0)".format( - self._func_col.ops * max(in_sizes)), - "AddKernelInfos(Name, AT_KERINFO_BANDWIDTH, {0}, 0)".format( - bandwidth) - ] - for name_type in self.input_names_and_ctypes + self.output_names_and_ctypes: - name = name_type[0] - shape = self.shapes[name] - kinfos.append("{0}(Name, \"{1}\", {2}, {3}, {4})".format( - "AddKernelFloatArgDim" if name_type[1] == 'F16' or name_type[1] == 'float' else "AddKernelArgDim", - name, len(shape) + 1, ", ".join(str(dim) for dim in shape), - self.ctype_len(name))) - return kinfos - - def gen_cargs(self): - cargs = [] - for name_type in self.input_names_and_ctypes + self.output_names_and_ctypes: - name = name_type[0] - if name_type[1] == 'F16' or name_type[1] == 'float': - cargs.append("TCArg(CNN_ArgDataTypeF({0},1,1),\"{1}\")".format( - self.ctype_len(name), name)) - else: - cargs.append("TCArg(CNN_ArgDataType({0},1,1),\"{1}\")".format( - self.ctype_len(name), name)) - return cargs - - def gen_kargs(self): - kargs = [] - for input_name in self.input_names: - arg_indexes = self._func_col.variable_indexes[input_name] - argspaces = ", ".join(f'KER_ITER_D{idx}' for idx in arg_indexes) - argspace = f'KerArgSpace({len(arg_indexes)}, {argspaces})' if arg_indexes else f'KerArgSpace(1, KER_ITER_TILE0)' - if input_name in self._constant_input_names: - constraints = "O_IN|O_DB|O_CONST" - else: - constraints = "O_IN|O_DB" if arg_indexes else "O_IN|O_BUFF|O_NTILED" - kargs.append("KerArg(\"{0}\", {1}, {2}, {3}, {4}, {5}, 0, 0, 0, \"{0}\")".format( - input_name, - argspace, - constraints, - 1, - 1, - self.ctype_len(input_name))) - - for output_name in self.output_names: - arg_indexes = self._func_col.variable_indexes[output_name] - argspaces = ", ".join(f'KER_ITER_D{idx}' for idx in arg_indexes) - argspace = f'KerArgSpace({len(arg_indexes)}, {argspaces})' if arg_indexes else 'KerArgSpace(1, KER_ITER_TILE0)' - name = output_name - constraints = "O_OUT|O_DB" if arg_indexes else "O_OUT|O_BUFF|O_NTILED" - kargs.append("KerArg(\"{0}\", {1}, {2}, {3}, {4}, {5}, 0, 0, 0, \"{0}\")".format( - name, argspace, constraints, 1, 1, - self.ctype_len(output_name))) - return kargs - - def gen_iterspace(self): - # All iterators are in parametric spaces. The iterator we will - # parallelize on has its preferred div set to 8 - # since only 3 tiled spaces are allowed including the dummy TILE0 space if there are scalars - # we check for that and only tile the first 3 spaces - tiled_iterators = self.tiled_iterators - iterators = [ - f'IterFixedSpace(KER_ITER_D{idx}, {iterator.shape[0]})' - if iterator not in tiled_iterators else - f'IterParSpace(KER_ITER_D{idx}, {iterator.shape[0]}, ' - f'{min(8, iterator.shape[0]) if iterator == self.parallel_iterator else 1})' - for idx, iterator in enumerate(self._func_col.iterators)] - # append dummy TILE0 space to put scalars into if there are scalar inputs (which is unlikely) - if self.has_scalar_parameters: - iterators.append('IterTiledSpace(KER_ITER_TILE0)') - return f'KernelIterSpace({len(iterators)}, {",".join(iterators)})' - - - def gen_kerbingings(self): - max_dim_var = max(self.output_names, key=lambda x: len(self.shapes[x])) - bindings = [ - f"K_ArgPar(\"{max_dim_var}\", KER_ARG_PARTILE_SIZE, KER_ITER_D{idx})" - for idx in range(len(self._func_col.iterators)) - ] + [ - f"K_Arg(\"{name}\", KER_ARG_TILE)" - for name in self.input_names + self.output_names - ] - return bindings - - @property - def parallel_iterator(self): - return max(self.func_col.iterators, key=lambda x: x.shape[0]) - - @property - def tiled_iterators(self): - return sorted(self.func_col.iterators, key=lambda x: x.shape[0])[-2::] - - @property - def fixed_iterators(self): - tiled_iterators = self.tiled_iterators - return [iterator for iterator in self.func_col.iterators if iterator not in tiled_iterators] - - @property - def has_scalar_parameters(self): - return any(not self._func_col.variable_indexes[input_name] - for input_name in self.input_names + self.output_names) - - def gen_function(self, kernel_name, kernel_arg_type_name, code=None): - if code is None: - code = CodeBlock() - - code.comment( - "Output iteration space reduced to %s iteration spaces" % (self.kernel_dims)) - code.write(f"void {kernel_name}({kernel_arg_type_name} *Args) {{") - code.indent() - for kerarg_name, kerarg_type in self.kernel_args: - code.write('{0} {1} = Args->{1};', kerarg_type, kerarg_name) - # paralellize on largest dimension - last_first = self.parallel_iterator.name.upper() - code.write('unsigned int CoreId = gap_coreid();') - code.write('unsigned int Chunk = ChunkSize({});', last_first) - code.write('unsigned int First = Chunk*CoreId;') - code.write('unsigned int Last = gap_min(First+Chunk, {});', last_first) - self._func_col.create_kernel(self.parallel_iterator, self.fixed_iterators, code) - code.write('gap_waitbarrier(0);') - code.deindent() - code.write('}') - return code - - def kernel_arg_type_codegen(self, type_name, code=None): - if code is None: - code = CodeBlock() - code.write('typedef struct {') - code.indent() - for kerarg_name, kerarg_type in self.kernel_args: - code.write('{} {};', kerarg_type, kerarg_name) - code.deindent() - code.write('}} {};', type_name) - return code - - def gen_kernel_model(self, kernel_name, kernel_arg_type_name, code=None): - if code is None: - code = CodeBlock() - code.write('LibKernelTemplate(') - code.indent() - code.write('"{}",', kernel_arg_type_name) - code.write('CArgs({},', len(self.kernel_args)) - code.indent() - for idx, (kerarg_name, kerarg_type) in enumerate(self.kernel_args): - code.write('TCArg("{}", "{}"){}', - kerarg_type, - kerarg_name, - "," if idx < (len(self.kernel_args) - 1) else '') - code.deindent() - code.write(')') - code.deindent() - code.write(');') - code.write('LibKernel(') - code.indent() - code.write('"{}",', kernel_name) - code.write('CALL_PARALLEL,') - code.write('0,') - code.write('"{}",', kernel_arg_type_name) - code.write('0') - code.deindent() - code.write(');') - - return code diff --git a/tools/nntool/expressions/symbolic/q15_quantization/clip_norm.py b/tools/nntool/expressions/symbolic/q15_quantization/clip_norm.py index b3fd805e7..76fc4d5ed 100644 --- a/tools/nntool/expressions/symbolic/q15_quantization/clip_norm.py +++ b/tools/nntool/expressions/symbolic/q15_quantization/clip_norm.py @@ -63,6 +63,7 @@ class Norm(Function): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + x=0 def _impl(self, *args, **kwargs): dtype = self.dtype diff --git a/tools/nntool/expressions/symbolic/q15_quantization/handlers.py b/tools/nntool/expressions/symbolic/q15_quantization/handlers.py index 530f5f8b8..eab7394a4 100644 --- a/tools/nntool/expressions/symbolic/q15_quantization/handlers.py +++ b/tools/nntool/expressions/symbolic/q15_quantization/handlers.py @@ -17,24 +17,26 @@ from typing import Tuple import numpy as np +from bfloat16 import bfloat16 +from expressions.symbolic.float_quantization.float_qrec import FloatQRec from utils.exp_17_15 import exp_fp_17_15 -from utils.pow_sqrt import (arctan_17_15alt, logn_17_15, pow_17_15, rsqrt_16_16, sqrt_17_15, - square_17_15) +from utils.pow_sqrt import (arctan_17_15alt, logn_17_15, pow_17_15, + rsqrt_16_16, sqrt_17_15, square_17_15) from utils.sigmoid_tanh_lut import sigmoid_lut, tanh_lut from utils.sin_cos import fpcos, fpsin from ..basic import (Abs, Add, ATan, Cast, Cos, Div, Exp, GapAbs, GapMax, - GapMin, Log, LShift, Max, Min, Mul, Pow, RSqrt, Sigmoid, Sin, - Sqrt, Sub, TanH) + GapMin, Log, LShift, Max, Min, Mul, Pow, RSqrt, Sigmoid, + Sin, Sqrt, Sub, TanH) from ..function import Function from ..quantization_base import qhandler -from ..symbol import (Constant, Rational, Symbol, SymbolStats, Variable, - c_headers, environment, nargs) +from ..symbol import (Constant, QuantizedConstant, QuantizedValue, Rational, + Symbol, SymbolStats, Variable, c_headers, environment, + nargs) from .clip_norm import Clip, Norm from .q15_scale_float import Q15ScaleFloat from .q15_scale_q_rec import Q15ScaleQRec from .q15_scaled_quantization import Q15ScaledQuantization -from .quantized_constant import QuantizedConstant, QuantizedValue from .scale_quantized import ScaleQuantized @@ -91,10 +93,22 @@ def _quantize(cls, # see if an nntool quantizer qtype is available if not qrec and qtypes and sym.name in qtypes: - sym, qrec = cls.qrec_from_qtype(sym, qtypes[sym.name]) + in_range = sym_ctrl.get_range(sym) + qtype = qtypes[sym.name] + if in_range is None: + if qtype.max_val is not None and qtype.min_val is None: + in_range = (qtype.min_val, qtype.max_val) + else: + in_range = (qtype.min, qtype.max) + osym, qrec = cls.qrec_from_qtype(sym, qtypes[sym.name], in_range) if qrec: - sym.qrec = qrec - return (sym, qrec) + osym.qrec = qrec + if isinstance(qrec, Q15ScaleQRec) and qrec.zero_point != 0: + osym = Sub(Cast(osym, dtype=np.int32), QuantizedConstant( + qrec.zero_point), dtype=np.int32, tag=True) + qrec = Q15ScaleQRec.override( + qrec, dtype=np.int32, zero_point=0) + return (osym, qrec) # figure out the quantization from the maximum value recorded max_val = sym_ctrl.get_max(sym) @@ -110,41 +124,41 @@ def _quantize(cls, return (sym, qrec) @classmethod - def qrec_from_qtype(cls, sym, qtype): - if qtype.dtype == np.int8: + def qrec_from_qtype(cls, sym, qtype, in_range): + if qtype.dtype in [np.int8, np.uint8, np.int16, np.uint16]: if len(qtype.scale) > 1: return sym, None - max_val = qtype.scale[0] * (math.pow(2, 7) - qtype.zero_point[0]) - min_val = -qtype.scale[0] * (math.pow(2, 7) + qtype.zero_point[0]) - return sym, Q15ScaleQRec(np.int8, max_val, 7, - max_val=max_val, min_val=min_val, - zero_point=qtype.zero_point[0]) - elif qtype.dtype == np.int16: - if len(qtype.scale) > 1: - return sym, None - max_val = qtype.scale[0] * (math.pow(2, 15) - qtype.zero_point[0]) - min_val = -qtype.scale[0] * (math.pow(2, 15) + qtype.zero_point[0]) - return sym, Q15ScaleQRec(np.int16, max_val, 15, - max_val=max_val, min_val=min_val, - zero_point=qtype.zero_point[0]) - elif qtype.dtype == np.uint8: - if len(qtype.scale) > 1: - return sym, None - max_val = qtype.scale[0] * (math.pow(2, 8) - qtype.zero_point[0]) - min_val = qtype.scale[0] * -qtype.zero_point[0] - return sym, Q15ScaleQRec(np.uint8, max_val, 8, - max_val=max_val, min_val=min_val, - zero_point=qtype.zero_point[0]) - elif qtype.dtype == np.uint16: - if len(qtype.scale) > 1: - return sym, None - max_val = qtype.scale[0] * (math.pow(2, 16) - qtype.zero_point[0]) - min_val = qtype.scale[0] * -qtype.zero_point[0] - return sym, Q15ScaleQRec(np.uint16, max_val, 16, - max_val=max_val, min_val=min_val, - zero_point=qtype.zero_point[0]) - else: - return None + max_val, min_val, bitlen = Q15ScaleQRec.dtype_zp_to_min_max( + qtype.dtype, qtype.scale[0], qtype.zero_point[0]) + qrec = Q15ScaleQRec(qtype.dtype, max_val, bitlen, + max_val=max_val, min_val=min_val, + zero_point=qtype.zero_point[0]) + sym.qrec = qrec + return sym, qrec + if qtype.dtype in [np.float16, bfloat16, np.float32]: + qrec = FloatQRec(dtype=qtype.dtype) + sym.qrec = qrec + max_val = np.max(np.maximum( + np.abs(in_range[0]), np.abs(in_range[1]))) + return ( + Cast( + Add( + Mul( + sym, + Constant( + np.atleast_1d(math.pow(2, 15) / + max_val).astype(qtype.dtype), + dtype=qtype.dtype), + dtype=qtype.dtype), + Constant([0.5], dtype=qtype.dtype), + dtype=qtype.dtype + ), + dtype=np.int32), + Q15ScaleQRec(np.int32, max_val, 15, + max_val=max_val, min_val=-max_val, + zero_point=0)) + raise NotImplementedError( + "don't know how to convert input type to Q15 quantization") @qhandler("Q15Scale", QuantizedValue) @@ -184,7 +198,8 @@ def cast_symbols(in_syms, qrecs, dtype=np.int32): def find_range(sym, qrecs): - assert all(qrec.min_val is not None and qrec.max_val is not None for qrec in qrecs), 'all values must be set' + assert all( + qrec.min_val is not None and qrec.max_val is not None for qrec in qrecs), 'all values must be set' val_range = np.array([ sym.call_with_constants(qrecs[0].min_val, qrecs[1].min_val), sym.call_with_constants(qrecs[0].max_val, qrecs[1].min_val), @@ -240,12 +255,21 @@ def _quantize(cls, if scale_to == 0: in_syms = [ in_syms[0], - ScaleQuantized(in_syms[1], from_qrec=in_qrecs[1], to_qrec=in_qrecs[0])] + ScaleQuantized( + in_syms[1], + from_qrec=in_qrecs[1], + to_qrec=in_qrecs[0], + tag=True, + comment=f"{sym.name} scale arg 1 to 0 - {in_qrecs[1]} -> {in_qrecs[0]}")] calc_qrec = Q15ScaleQRec.override(in_qrecs[0], dtype=np.int32) elif scale_to == 1: in_syms = [ ScaleQuantized( - in_syms[0], from_qrec=in_qrecs[0], to_qrec=in_qrecs[1]), + in_syms[0], + from_qrec=in_qrecs[0], + to_qrec=in_qrecs[1], + tag=True, + comment=f"{sym.name} scale arg 0 to 1 - {in_qrecs[0]} -> {in_qrecs[1]}"), in_syms[1]] calc_qrec = Q15ScaleQRec.override(in_qrecs[1], dtype=np.int32) else: @@ -258,11 +282,16 @@ def _quantize(cls, # Try not to scale if we are still in bounds # This creates more error -> if np.abs(calc_qrec.quantize(max_val)) < max_short or - if calc_qrec == out_qrec: - return (sym_cls(*in_syms), calc_qrec) + # if calc_qrec == out_qrec: + return (sym_cls(*in_syms), calc_qrec) - return (ScaleQuantized(sym_cls(*in_syms, dtype=out_qrec.dtype), - from_qrec=calc_qrec, to_qrec=out_qrec), out_qrec) + # return ( + # ScaleQuantized( + # sym_cls(*in_syms, dtype=out_qrec.dtype), + # from_qrec=calc_qrec, + # to_qrec=out_qrec, + # tag=True, + # comment=f'{sym.name} scale result to output - {calc_qrec} -> {out_qrec}'), out_qrec) @qhandler("Q15Scale", Mul) @@ -294,8 +323,13 @@ def _quantize(cls, out_qrec = Q15ScaleQRec(np.int32, prod_scale, min( prod_q, 15), max_val=prod_scale, min_val=-prod_scale) if prod_q > 15: - qsym = Norm(sym_cls(*in_syms, dtype=np.int32), - QuantizedConstant(prod_q - 15)) + qsym = Norm( + sym_cls(*in_syms, dtype=np.int32), + QuantizedConstant(prod_q - 15), + dtype=np.int32, + tag=True, + comment=f'normalize input to Q15 - {prod_q - 15}' + ) else: qsym = sym_cls(*in_syms) return (qsym, out_qrec) @@ -399,7 +433,7 @@ def _quantize(cls, in_qrec.q - 15), dtype=in_sym.dtype) out_qrec = Q15ScaleQRec(np.int32, new_scale, 15) - return (Cast(Sqrt1715(in_sym, dtype=np.uint32), dtype=np.int32), out_qrec) + return (Cast(Sqrt1715(in_sym, dtype=np.uint32), dtype=np.int32, tag=True), out_qrec) @nargs(1) @@ -450,7 +484,7 @@ def _quantize(cls, in_sym = in_syms[0] out_qrec = Q15ScaleQRec(np.int32, new_scale, 15) - return (Cast(Norm(RSqrt1616(in_sym, dtype=np.uint32), QuantizedConstant(norm), dtype=np.uint32), dtype=np.int32), out_qrec) + return (Cast(Norm(RSqrt1616(in_sym, dtype=np.uint32), QuantizedConstant(norm), dtype=np.uint32), dtype=np.int32, tag=True), out_qrec) @nargs(1) @@ -503,7 +537,7 @@ def _quantize(cls, max_bits = math.ceil(math.log2(math.fabs(-340695 + qlog_off))) + 2 return ( ScaleQuantized(Add(Log1715(in_sym, dtype=np.int32), QuantizedConstant( - qlog_off), dtype=np.int32), from_qrec=calc_qrec, to_qrec=out_qrec, num_bits=31-max_bits), + qlog_off), dtype=np.int32), from_qrec=calc_qrec, to_qrec=out_qrec, num_bits=31-max_bits, tag=True), out_qrec) @@ -570,7 +604,7 @@ def _quantize(cls, if val == 2: out_qrec = Q15ScaleQRec(np.int32, np.power(lhs_qrec.scale, 2), 15) - return (Cast(Square1715(lhs, dtype=np.int32), dtype=np.int32), out_qrec) + return (Cast(Square1715(lhs, dtype=np.int32), dtype=np.int32, tag=True), out_qrec) if val == -2: out_qrec = Q15ScaleQRec( np.int32, 1/np.power(lhs_qrec.scale, 2), 15) @@ -582,10 +616,20 @@ def _quantize(cls, out_qrec = Q15ScaleQRec(np.int32, 1, 0) return (QuantizedConstant(1), out_qrec) if val > 0 and val < 1: + out_scale = np.power(lhs_qrec.scale, val).item() out_qrec = Q15ScaleQRec( - np.uint32, np.power(lhs_qrec.scale, val), 15) + np.uint32, out_scale, 15) qval = int(math.floor(val * math.pow(2, 15) + 0.5)) - return (Cast(Pow1715(lhs, QuantizedConstant(qval), dtype=np.int32), dtype=np.int32), out_qrec) + return ( + Cast( + Pow1715( + lhs, + QuantizedConstant(qval), + dtype=np.int32), + dtype=np.int32, + comment=f'{sym.name} POW on scale {lhs_qrec.scale:.3f} -> {out_scale:.3f}', + tag=True), + out_qrec) raise NotImplementedError( "power is currently only supported with fractional constants, 2, 1, & 0") @@ -630,7 +674,7 @@ def _quantize(cls, return (ScaleQuantized(Cast(Exp1715(arg, dtype=np.uint32), dtype=np.int32), from_qrec=calc_qrec, - to_qrec=out_qrec), + to_qrec=out_qrec, tag=True), out_qrec) @@ -668,7 +712,7 @@ def _quantize(cls, in_syms, in_qrecs = cls.cast_symbols(in_syms, in_qrecs) lhs = ScaleQuantized( in_syms[0], from_qrec=in_qrecs[0], to_qrec=calc_qrec) - return (Arctan1715(lhs), calc_qrec) + return (Arctan1715(lhs, tag=True), calc_qrec) @nargs(1) @@ -722,8 +766,17 @@ def _quantize(cls, # output is Q12 * 1 out_qrec = Q15ScaleQRec(np.int16, 1, 12) in_syms, in_qrecs = cls.cast_symbols(in_syms, in_qrecs) - lhs = Cast(Clip(ScaleQuantized( - in_syms[0], from_qrec=in_qrecs[0], to_qrec=calc_qrec), dtype=calc_qrec.dtype, clip_dtype=np.int16), dtype=np.int16) + lhs = Cast( + Clip( + ScaleQuantized( + in_syms[0], + from_qrec=in_qrecs[0], + to_qrec=calc_qrec), + dtype=calc_qrec.dtype, + clip_dtype=np.int16), + dtype=np.int16, + tag=True, + comment=f'{sym.name} scale and clip input - {in_qrecs[0]} -> {calc_qrec}') if isinstance(sym, Cos): qsym = Cos_Q15 else: @@ -781,7 +834,8 @@ def _quantize(cls, func = 'tanh' if isinstance(sym, TanH) else 'sigmoid' calc_qrec = Q15ScaleQRec(np.int32, 1, 12) # output is Q15 * 1 - out_qrec = Q15ScaleQRec(np.int32, 1, 15, min_val=-1.0 if func == 'tanh' else 0.0, max_val=1.0) + out_qrec = Q15ScaleQRec( + np.int32, 1, 15, min_val=-1.0 if func == 'tanh' else 0.0, max_val=1.0) in_syms, in_qrecs = cls.cast_symbols(in_syms, in_qrecs) lhs = ScaleQuantized( in_syms[0], from_qrec=in_qrecs[0], to_qrec=calc_qrec) diff --git a/tools/nntool/expressions/symbolic/q15_quantization/q15_scale_q_rec.py b/tools/nntool/expressions/symbolic/q15_quantization/q15_scale_q_rec.py index 5e43157ba..0cb6e4d7f 100644 --- a/tools/nntool/expressions/symbolic/q15_quantization/q15_scale_q_rec.py +++ b/tools/nntool/expressions/symbolic/q15_quantization/q15_scale_q_rec.py @@ -18,12 +18,16 @@ import numpy as np +from quantization.qtype import DTYPES + from ..quantization_base import QRecBase class Q15ScaleQRec(QRecBase): def __init__(self, dtype: np.dtype, scale: float, q: int, min_val=None, max_val=None, zero_point=0) -> None: super(Q15ScaleQRec, self).__init__(dtype) + if isinstance(scale, np.ndarray): + scale = scale.item() self._scale = scale self._q = q self._min_val = min_val @@ -31,7 +35,7 @@ def __init__(self, dtype: np.dtype, scale: float, q: int, min_val=None, max_val= self._zero_point = zero_point def __repr__(self) -> str: - return f"{self._dtype.__name__} {self.scale} Q{self._q}" + return f"{self._dtype.__name__} {self.scale:.3f} Q{self._q}" @classmethod def inherit(cls, rec, dtype: np.dtype = None, scale: float = None, q: int = None, max_val=None, min_val=None, zero_point=None): @@ -157,3 +161,14 @@ def __str__(self) -> str: def __eq__(self, o: object) -> bool: return self.q == o.q and self.scale == o.scale and self.dtype == o.dtype and self.zero_point == o.zero_point + + @staticmethod + def dtype_zp_to_min_max(dtype, scale, zero_point): + bitlen, signed = DTYPES[dtype] + maxquns = math.pow(2, bitlen) + zpoff = math.pow(2, bitlen - 1) if signed else 0 + maxq_range = maxquns - (zero_point + zpoff) + minq_range = maxquns - maxq_range + max_val = maxq_range * scale + min_val = minq_range * scale + return max_val, min_val, bitlen - (1 if signed or zero_point != 0 else 0) diff --git a/tools/nntool/expressions/symbolic/q15_quantization/q15_scaled_quantization.py b/tools/nntool/expressions/symbolic/q15_quantization/q15_scaled_quantization.py index 5f5f81185..1f7488c90 100644 --- a/tools/nntool/expressions/symbolic/q15_quantization/q15_scaled_quantization.py +++ b/tools/nntool/expressions/symbolic/q15_quantization/q15_scaled_quantization.py @@ -13,12 +13,14 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from typing import Tuple, cast +import math +from typing import Tuple import numpy as np -import math +from bfloat16 import bfloat16 +from expressions.symbolic.float_quantization.float_qrec import FloatQRec -from ..basic import Cast +from ..basic import Cast, ConvertQuantization from ..quantization_base import (QRecBase, QuantizationHandlerBase, handles_scheme) from ..symbol import Symbol, SymbolStats @@ -63,6 +65,55 @@ def _dequantize_py_expr(cls, py_expr: str, qrec: Q15ScaleQRec, **kwargs) -> np.n def _dequantize_c_expr(cls, c_expr: str, qrec: Q15ScaleQRec, **kwargs) -> np.ndarray: return qrec.dequantize_c_expr(c_expr) + # @classmethod + # def _quantize_output(cls, + # sym: Symbol, + # qsym: Symbol, + # osym: Symbol, + # sym_ctrl: SymbolStats, + # qrec: QRecBase, + # **kwargs) -> Tuple[Symbol, QRecBase]: + # from_qrec = qrec + # qtypes = kwargs.get('qtypes', {}) + # # first see if this has already been quantized by nntool + # # note that the qtype will be stored against the name of the output symbol + # res = cls._get_scale_dtype_from_qtypes( + # osym, qtypes) + # if res is None: + # max_val = math.fabs(sym_ctrl.get_max(sym)) + # min_val = -max_val + # out_dtype = np.int8 + # out_q = 7 + # zero_point = 0 + # else: + # max_val, min_val, out_dtype, out_q, zero_point = res + + # qrec_scale = Q15ScaleQRec(np.int32, max_val, out_q, min_val=min_val, max_val=max_val, zero_point=zero_point) + # qrec_out = Q15ScaleQRec(out_dtype, max_val, out_q, min_val=min_val, max_val=max_val, zero_point=zero_point) + # # scale clip and cast to output type + # return ( + # Cast( + # Clip( + # ScaleQuantized(qsym, + # from_qrec=from_qrec, + # to_qrec=qrec_scale), + # clip_dtype=out_dtype, + # dtype=qrec_scale.dtype), + # dtype=qrec.dtype), qrec_out) + + # @classmethod + # def _get_scale_dtype_from_qtypes(cls, sym, qtypes): + # if not qtypes or sym.name not in qtypes: + # return None + # qtype = qtypes[sym.name] + # if qtype.dtype in [np.int8, np.uint8, np.int16, np.uint16]: + # if len(qtype.scale) > 1: + # return None + # max_val, min_val, bitlen = Q15ScaleQRec.dtype_zp_to_min_max(qtype.dtype, qtype.scale[0], qtype.zero_point) + # return max_val, min_val, qtype.dtype, bitlen, qtype.zero_point + # else: + # return None + @classmethod def _quantize_output(cls, sym: Symbol, @@ -75,49 +126,56 @@ def _quantize_output(cls, qtypes = kwargs.get('qtypes', {}) # first see if this has already been quantized by nntool # note that the qtype will be stored against the name of the output symbol - max_val, out_dtype, out_q, zero_point = cls._get_scale_dtype_from_qtypes( - osym, qtypes) - if max_val is None: + + if qtypes and osym.name in qtypes: + qtype = qtypes[osym.name] + if qtype.dtype in [np.int8, np.uint8, np.int16, np.uint16]: + max_val, min_val, out_q = Q15ScaleQRec.dtype_zp_to_min_max( + qtype.dtype, qtype.scale[0], qtype.zero_point) + out_dtype = qtype.dtype + zero_point = qtype.zero_point + elif qtype.dtype in [np.float16, bfloat16, np.float32]: + min_val = qtype.min_val + max_val = qtype.max_val + out_dtype = qtype.dtype + else: + raise ValueError(f"don't know how to output {qtype.dtype}") + else: + out_dtype = kwargs.get('out_dtype', np.int8) + assert out_dtype in [np.int8, np.int16] max_val = math.fabs(sym_ctrl.get_max(sym)) - out_dtype = np.int8 - out_q = 7 + min_val = -max_val + out_dtype = out_dtype + out_q = 7 if out_dtype == np.int8 else 15 zero_point = 0 -#pylint: disable=invalid-unary-operand-type - min_val = -max_val - qrec_scale = Q15ScaleQRec(np.int32, max_val, out_q, min_val=min_val, max_val=max_val, zero_point=zero_point) - qrec_out = Q15ScaleQRec(out_dtype, max_val, out_q, min_val=min_val, max_val=max_val, zero_point=zero_point) - # scale clip and cast to output type + if out_dtype in [np.float16, bfloat16, np.float32]: + qrec_out = FloatQRec( + dtype=out_dtype, max_val=max_val, min_val=min_val) + return ( + ConvertQuantization( + qsym, + from_qrec=from_qrec, + to_qrec=qrec_out, + comment=f'convert quantization - {from_qrec} -> {qrec_out}' + ), qrec_out) + + qrec_scale = Q15ScaleQRec( + np.int32, max_val, out_q, min_val=min_val, max_val=max_val, zero_point=zero_point) + qrec_out = Q15ScaleQRec( + out_dtype, max_val, out_q, min_val=min_val, max_val=max_val, zero_point=zero_point) return ( Cast( Clip( - ScaleQuantized(qsym, - from_qrec=from_qrec, - to_qrec=qrec_scale), + ScaleQuantized( + qsym, + from_qrec=from_qrec, + to_qrec=qrec_scale + ), clip_dtype=out_dtype, - dtype=qrec_scale.dtype), - dtype=qrec.dtype), qrec_out) - - @classmethod - def _get_scale_dtype_from_qtypes(cls, sym, qtypes): - if not qtypes or sym.name not in qtypes: - return None, None, None, None - qtype = qtypes[sym.name] - if qtype.dtype == np.int8: - if len(qtype.scale) > 1: - return None, None, None, None - return qtype.scale[0] * math.pow(2, 7), np.int8, 7, qtype.zero_point - if qtype.dtype == np.uint8: - if len(qtype.scale) > 1: - return None, None, None, None - return qtype.scale[0] * math.pow(2, 8), np.uint8, 8, qtype.zero_point - elif qtype.dtype == np.int16: - if len(qtype.scale) > 1: - return None, None, None - return qtype.scale[0] * math.pow(2, 15), np.int16, 15, qtype.zero_point - if qtype.dtype == np.uint16: - if len(qtype.scale) > 1: - return None, None, None, None - return qtype.scale[0] * math.pow(2, 16), np.uint16, 16, qtype.zero_point - else: - return None, None, None, None + dtype=qrec_scale.dtype + ), + dtype=qrec_out.dtype, + comment=f'scale clip and cast - {from_qrec} -> {qrec_out}' + ), + qrec_out) diff --git a/tools/nntool/expressions/symbolic/q15_quantization/scale_quantized.py b/tools/nntool/expressions/symbolic/q15_quantization/scale_quantized.py index 76a4d77bd..90eb9c791 100644 --- a/tools/nntool/expressions/symbolic/q15_quantization/scale_quantized.py +++ b/tools/nntool/expressions/symbolic/q15_quantization/scale_quantized.py @@ -14,16 +14,15 @@ # along with this program. If not, see . import math +from xml.etree.ElementTree import Comment import numpy as np -from numpy.core.getlimits import iinfo from expressions.symbolic.function import Function from ..basic import Add, Cast, CompoundFunction, LShift, Mul, Sub, copy_props -from ..symbol import c_headers, nargs +from ..symbol import QuantizedConstant, c_headers, nargs from .clip_norm import Norm from .q15_scale_q_rec import Q15ScaleQRec -from .quantized_constant import QuantizedConstant @nargs(2) @@ -54,7 +53,7 @@ def _c_expr(self, *args, **kwargs): @c_headers('"Gap.h"') @copy_props('from_qrec', 'to_qrec', 'num_bits') class ScaleQuantized(CompoundFunction): - def __init__(self, *args, from_qrec=None, to_qrec=None, num_bits=15, **kwargs): + def __init__(self, *args, from_qrec=None, to_qrec=None, num_bits=8, **kwargs): self._from_qrec = from_qrec self._to_qrec = to_qrec self._qbias, self._qnorm = None, None @@ -87,7 +86,13 @@ def _eval(self, *args, **kwargs): # this should be safe as we never go much above Q15 and the scaling step # is also a Q15 if isinstance(sym, ScaleQuantized): - return ScaleQuantized(*sym.contents, from_qrec=sym.from_qrec, to_qrec=self.to_qrec, num_bits=min(self._num_bits, sym.num_bits)) + return ScaleQuantized( + *sym.contents, + from_qrec=sym.from_qrec, + to_qrec=self.to_qrec, + num_bits=min(self._num_bits, sym.num_bits), + tag=self.tag, + comment=self.comment) # Check if we do nothing if self._from_qrec == self._to_qrec: return sym @@ -130,7 +135,8 @@ def _eval(self, *args, **kwargs): ), #pylint: disable=invalid-unary-operand-type QuantizedConstant(-qnorm, dtype=np.int8), - name=self.name + name=self.name, + dtype=self._to_qrec.dtype ) elif qnorm > 0: sym = Norm( @@ -140,7 +146,8 @@ def _eval(self, *args, **kwargs): dtype=self._to_qrec.dtype ), QuantizedConstant(qnorm, dtype=np.int8), - name=self.name + name=self.name, + dtype=self._to_qrec.dtype ) else: sym = Mul( @@ -157,6 +164,8 @@ def _eval(self, *args, **kwargs): if self._to_qrec.dtype != np.int32: sym = Cast(sym, dtype=self._to_qrec.dtype) + sym.tag = self.tag + sym.comment=self.comment return sym def __repr__(self) -> str: diff --git a/tools/nntool/expressions/symbolic/quantization_base.py b/tools/nntool/expressions/symbolic/quantization_base.py index 48221469c..c66d6f346 100644 --- a/tools/nntool/expressions/symbolic/quantization_base.py +++ b/tools/nntool/expressions/symbolic/quantization_base.py @@ -1,8 +1,24 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + from typing import Tuple import numpy as np from expressions.symbolic.basic import CompoundFunction +from expressions.symbolic.function import Function from .symbol import Symbol, SymbolStats, Variable, QRecBase @@ -123,6 +139,8 @@ def quantize(cls, if not isinstance(sym, Variable): qsym.name = sym.name qsym.qrec = qrec + if isinstance(sym, Function): + qsym.tag = True return (qsym, qrec) @classmethod diff --git a/tools/nntool/expressions/symbolic/symbol.py b/tools/nntool/expressions/symbolic/symbol.py index 0480073bc..31bf41972 100644 --- a/tools/nntool/expressions/symbolic/symbol.py +++ b/tools/nntool/expressions/symbolic/symbol.py @@ -19,7 +19,7 @@ import numpy as np from bfloat16 import bfloat16 from generation.code_block import CodeBlock -from quantization.qtype import DTYPE_GAP_CTYPE +from quantization.qtype import DTYPE_GAP_CTYPE, DTYPES class SymbolStats(): @@ -64,17 +64,21 @@ def reset_ranges(self): class QRecBase(): DTYPE_TO_CTYPE = { - np.int8: 'int8_t', - np.int16: 'int16_t', - np.int32: 'int32_t', - np.uint8: 'uint8_t', - np.uint16: 'uint16_t', - np.uint32: 'uint32_t', + np.int8: 'signed char', + np.int16: 'short', + np.int32: 'int', + np.uint8: 'unsigned char', + np.uint16: 'unsigned short', + np.uint32: 'unsigned int', np.float32: 'float', bfloat16: 'F16', np.float16: 'F16' } def __init__(self, dtype=None) -> None: + if isinstance(dtype, np.dtype): + dtype = dtype.type + if dtype is not None and dtype not in self.DTYPE_TO_CTYPE: + raise ValueError('unknown dtype') self._dtype = dtype @property @@ -89,6 +93,14 @@ def dtype(self, val): def ctype(self): return self.DTYPE_TO_CTYPE[self.dtype] + @property + def signed(self): + return DTYPES[self.dtype][1] + + @property + def size(self): + return DTYPES[self.dtype][0] + class Symbol(): NARGS = None CURRENT_CONTROL = SymbolStats() @@ -96,9 +108,10 @@ class Symbol(): COUNTS = {} C_HEADERS = [] COPY_PROPS = tuple() + SYMBOL_PREFEX = '_SYMBOL_' #pylint: disable=unused-argument - def __init__(self, *args, name="", shape=None, dtype=np.float32, qrec: QRecBase = None, **kwargs): + def __init__(self, *args, name="", shape=None, dtype=np.float32, qrec: QRecBase = None, tag=None, comment: str=None, **kwargs): super(Symbol, self).__init__(**kwargs) if self.NARGS is not None and len(args) != self.NARGS: raise ValueError("wrong number of arguments to Symbol %s"%self.__class__.__name__) @@ -107,6 +120,8 @@ def __init__(self, *args, name="", shape=None, dtype=np.float32, qrec: QRecBase self._dtype = dtype self._shape = shape self._qrec = qrec + self._tag = tag + self._comment = comment @classmethod def get_name(cls, cls_to_name): @@ -114,6 +129,22 @@ def get_name(cls, cls_to_name): cls.COUNTS[cls_to_name] += 1 return name + @property + def tag(self): + return self._tag + + @tag.setter + def tag(self, val): + self._tag = val + + @property + def comment(self): + return self._comment + + @comment.setter + def comment(self, val): + self._comment = val + @property def qrec(self): return self._qrec @@ -153,6 +184,10 @@ def dtype(self): return self._qrec.dtype return self._dtype + @property + def ctype(self): + return QRecBase.DTYPE_TO_CTYPE[self.dtype] + @property def name(self): return self._name @@ -182,10 +217,11 @@ def set_default_control(cls, control): cls.CURRENT_CONTROL = control @staticmethod - def extend_shapes(*shapes): + def extend_shapes(*shapes, max_length=None): if len(shapes) == 1: return list(shapes) - max_length = max(len(x) for x in shapes) + if max_length is None: + max_length = max(len(x) for x in shapes) return [tuple([1] * (max_length - len(x)) + list(x)) for x in shapes] @staticmethod @@ -226,7 +262,10 @@ def resolve(self, **kwargs): def calculate(self, calculate_ranges=False, **kwargs): """Given a set of substitions for variable in kwargs calculate a result""" - return self._calculate(calculate_ranges=calculate_ranges, **kwargs) + val = self._calculate(calculate_ranges=calculate_ranges, **kwargs) + if self.tag and 'details' in kwargs: + kwargs['details'][self.tag[0]] = val + return val def collect_globals(self) -> dict: """Returns a dict of globals necessary to execute a lambda of this symbol. Globals @@ -330,10 +369,19 @@ def py_expr(self, *args, **kwargs): def c_expr(self, *args, **kwargs): return self._c_expr([], **kwargs) - def c_block(self, code_block=None, **kwargs): + def c_block(self, code_block=None, with_comment=False, tags=None, **kwargs): if code_block is None: - code_block = CodeBlock - code_block.write(self.c_expr) + code_block = CodeBlock() + if tags is not None and self.tag: + if self.comment and with_comment: + code_block.write(f'// {self.comment}') + name = tags.get(self, f'{self.ctype} {self.SYMBOL_PREFEX}{self.name}') + if isinstance(name, tuple): + name = name[0].c_expr(dtype=name[0].dtype, declare=name[1], **kwargs) + code_block.write(f'{name} = {self._c_expr([], **kwargs)};') + else: + code_block.write(self._c_expr([], **kwargs)) + return code_block def _equivalent(self, other) -> bool: pass @@ -466,7 +514,7 @@ def _c_expr(self, *args, **kwargs): return f"(F16){print_float_constant(val)}" elif self.dtype == np.float32: return print_float_constant(val) - return val + return str(val) def __repr__(self) -> str: return str(self._value) @@ -524,6 +572,7 @@ def __init__(self, var_name, shape=None, symbol_binding=None, name="", **kwargs) self._shape = shape self._index_vars = None self._ispointer = False + self._cindex = None @property def shape(self): @@ -560,6 +609,14 @@ def value(self): def unbound_variables(self): return {self._name: self} + @property + def cindex(self): + return self._cindex + + @cindex.setter + def cindex(self, val): + self._cindex = val + @property def index_vars(self): return self._index_vars @@ -586,11 +643,11 @@ def _impl(self, *args, **kwargs): val = np.array(kwargs[self.name]) if self.shape is not None: val = np.reshape(val, self.shape) - quantize_inputs = kwargs.get('quantize_inputs', False) - if quantize_inputs is True or isinstance(quantize_inputs, Iterable) and self.name in quantize_inputs: - if self.qrec is None: - raise ValueError("can't quantize %s. no quantization record is set."%self.name) - val = self.qrec.quantize_and_clip(val) + # quantize_inputs = kwargs.get('quantize_inputs', False) + # if quantize_inputs is True or isinstance(quantize_inputs, Iterable) and self.name in quantize_inputs: + # if self.qrec is None: + # raise ValueError("can't quantize %s. no quantization record is set."%self.name) + # val = self.qrec.quantize_and_clip(val) if calculate_ranges: self.control.add_stat(self, val) return val @@ -645,8 +702,8 @@ def gen_index(index_vars): #pylint: disable=arguments-differ def _c_expr(self, *args, declare=False, dtype=None, pointer=None, iteration_space=None, **kwargs): - if iteration_space: - return iteration_space.c_indexed_var(self.name) + if iteration_space and not self.name.startswith(self.SYMBOL_PREFEX): + return iteration_space.c_indexed_var(self.name, declare=declare) if pointer is None: pointer = self._ispointer if declare: @@ -666,3 +723,17 @@ def _c_expr(self, *args, declare=False, dtype=None, pointer=None, iteration_spac def __repr__(self) -> str: return f'{self.name}' + +class QuantizedConstant(Constant): + def __init__(self, *args, dtype=np.int32, **kwargs): + super().__init__(*args, dtype=dtype, **kwargs) + +class QuantizedValue(Symbol): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + def _calculate(self, calculate_ranges=False, **kwargs): + raise ValueError('wrapper class for quantization purposes - not designed to be evaluated') + + def _impl(self, *args, **kwargs): + raise ValueError('wrapper class for quantization purposes - not designed to be evaluated') diff --git a/tools/nntool/expressions/symbolic/variable_container.py b/tools/nntool/expressions/symbolic/variable_container.py index 3647509d2..89399bc32 100644 --- a/tools/nntool/expressions/symbolic/variable_container.py +++ b/tools/nntool/expressions/symbolic/variable_container.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from abc import ABC, abstractmethod, abstractproperty -from typing import Mapping +from collections import Counter +from itertools import chain import numpy as np from utils.disjoint_reduction import disjoint_reduction @@ -22,54 +22,41 @@ from .symbol import Symbol, Variable -class VariableAssigner(ABC): - @abstractmethod - def _resolve_assignment(self, substitute_all=False, **kwargs) -> Mapping[str, Symbol]: - """ Resolves an container that is one or more assigments substituting values contained in - **kwargs into unresolved variables - - Args: - substitute_all (bool, optional): If False only expressions that resolve to constants will be substituted. - Defaults to False. - - Returns: - Mapping[str, Symbol]: A map of the variable names and their values (Symbols) - """ - - def resolve_assignment(self, substitute_all=False, **kwargs) -> Mapping[str, Symbol]: - return self._resolve_assignment(substitute_all=substitute_all, **kwargs) - - @abstractmethod - def _calculate_assignment(self, **kwargs) -> Mapping[str, np.ndarray]: - """ Attempts to resolve a series of assignments to a map of values - - Returns: - Mapping[str, np.ndarray]: Map of resolved values - """ - - def calculate_assignment(self, **kwargs) -> Mapping[str, np.ndarray]: - return self._calculate_assignment(**kwargs) - - @abstractproperty - def returned_variables(self): - pass - - @abstractproperty - def var_shapes(self): - pass +def search_variables(elem): + if isinstance(elem, Variable): + return [elem] + if type(elem) == int or type(elem) == float or isinstance(elem, np.ndarray): + return [] + return chain(*[search_variables(sub_elem) for sub_elem in elem.contents]) class VariableContainer(): def __init__(self, *args, **kwargs): + args = list(args) + # if string variable names are provided match existing variables or create a new one + if any(isinstance(arg, str) for arg in args): + all_vars = {var.name: var + for var in chain(*[search_variables(arg) + for arg in args if not isinstance(arg, str)])} + for idx, arg in enumerate(args): + if isinstance(arg, str): + if arg in all_vars: + args[idx] = all_vars[arg] + else: + all_vars[arg] = Variable(arg) + args[idx] = all_vars[arg] super().__init__(*args, **kwargs) - self._unbound_variables = self._init_unbound_variables(*args) + # variables with same name must be the same variable instance + names = list( + {object.__hash__(var): var.name for var in search_variables(self)}.values()) + if len(set(names)) != len(names): + bad_vars = [item[0] for item in filter( + lambda x: x[1] > 1, Counter(names).items())] + raise ValueError( + f'duplicate variable names detected: {" ".join(bad_vars)}') @property def unbound_variables(self): - return self._unbound_variables - - @unbound_variables.setter - def unbound_variables(self, val): - self._unbound_variables = val + return {var.name: var for var in search_variables(self)} @property def unbound_shapes(self): @@ -83,12 +70,10 @@ def extended_unbound_var_shapes(self): return {vname: tuple(([1] * (max_length - len(var.shape))) + list(var.shape)) for vname, var in self.unbound_variables.items()} - @staticmethod def adjust(axes, adjust): return tuple(tuple(dim+adjust for dim in axes_group) for axes_group in axes) - @property def axes(self): var_shapes = Symbol.extend_shapes(*self.unbound_shapes) @@ -96,28 +81,6 @@ def axes(self): shape) if dim != 1) for shape in var_shapes)) return tuple(sorted([tuple(x) for x in axes])) - @staticmethod - def _init_unbound_variables(*args): - unbound_variables = {} - for arg in args: - if isinstance(arg, Variable): - if arg.name in unbound_variables: - if unbound_variables[arg.name].shape != arg.shape: - raise ValueError( - 'there is more than one variable called %s with different shapes' % arg.name) - else: - unbound_variables[arg.name] = arg - elif isinstance(arg, VariableContainer): - unbound_variables.update(arg.unbound_variables) - elif isinstance(arg, str): - if arg in unbound_variables: - raise ValueError( - 'there is more than one variable called %s' % arg) - else: - unbound_variables[arg] = Variable(arg) - - return unbound_variables - def vars_to_axes(self, axes=None): if axes is None: axes = self.axes @@ -129,20 +92,3 @@ def axes_sizes(self, axes=None): axes = self.axes shape = Symbol.broadcast(*self.unbound_shapes) return {axis: int(np.prod([shape[x] for x in axis])) for axis in axes} - - -class VariableContainerAndAssigner(VariableContainer, VariableAssigner): - @property - def var_axes(self): - elems = self.resolve_assignment(substitute_all=True) - max_axis_groups = np.array( - [max(max(x) for x in elem.axes) for elem in elems.values()]) - max_axis = np.max(max_axis_groups) - axis_adjust = max_axis - max_axis_groups - - axes = {} - for elem_idx, (elem_name, elem) in enumerate(elems.items()): - axes[elem_name] = self.adjust(elem.axes, axis_adjust[elem_idx]) - for vname, vaxes in elem.vars_to_axes().items(): - axes[vname] = self.adjust(vaxes, axis_adjust[elem_idx]) - return axes diff --git a/tools/nntool/generation/at_generators/cnn_convolution_pool_relu.py b/tools/nntool/generation/at_generators/cnn_convolution_pool_relu.py index 258fdc484..c5709b71c 100644 --- a/tools/nntool/generation/at_generators/cnn_convolution_pool_relu.py +++ b/tools/nntool/generation/at_generators/cnn_convolution_pool_relu.py @@ -139,6 +139,8 @@ def gen_activation_op(activation): aop = "KOP_LEAKYRELU" elif activation == "sigmoid": aop = "KOP_SIGMOID" + elif activation == "tanh": + aop = "KOP_TANH" else: raise NotImplementedError("activation type %s not implemented" % activation) return aop diff --git a/tools/nntool/generation/at_generators/utils.py b/tools/nntool/generation/at_generators/utils.py index 6bb76f8ac..39622ed3c 100644 --- a/tools/nntool/generation/at_generators/utils.py +++ b/tools/nntool/generation/at_generators/utils.py @@ -16,9 +16,9 @@ def at_bits(qtype): if qtype is None: return 0 - if qtype.bits not in [8, 16, 32]: + if qtype.dtype_bits not in [8, 16, 32]: raise NotImplementedError("unsupported number of bits") - size = qtype.bits // 8 + size = qtype.dtype_bits // 8 if not qtype.signed: return -size return size diff --git a/tools/nntool/generation/at_types/at_params.py b/tools/nntool/generation/at_types/at_params.py index 0d08c3026..0ba4358cd 100644 --- a/tools/nntool/generation/at_types/at_params.py +++ b/tools/nntool/generation/at_types/at_params.py @@ -22,6 +22,10 @@ NO_ACTIVATION = ActivationATParam(ReLUOper='KOP_NONE') +def need_padding_in_at(params): + same_h, same_w = params.padding.calculate_same_h_w(params.in_dims[0], params.filter, params.stride, dilation=getattr(params.padding, "dilation", None)) + return params.padding.h >= same_h and params.padding.w >= same_w + def gen_activation_op(activation, force_relu=False, asymmetric=False): if activation is None or activation == "none": aop = "KOP_NONE" @@ -38,22 +42,22 @@ def gen_activation_op(activation, force_relu=False, asymmetric=False): else: aop = "KOP_RELUN" if not force_relu else "KOP_RELU" elif activation == "hsigmoid": - assert not asymmetric, 'asymmetric not supported' + #assert not asymmetric, 'asymmetric not supported' aop = "KOP_HSIGMOID" elif activation == "htanh": - assert not asymmetric, 'asymmetric not supported' + #assert not asymmetric, 'asymmetric not supported' aop = "KOP_HTANH" elif activation == "swish" or activation == "hswish": - assert not asymmetric, 'asymmetric not supported' + #assert not asymmetric, 'asymmetric not supported' aop = "KOP_HSWISH" elif activation == "leaky": - assert not asymmetric, 'asymmetric not supported' + #assert not asymmetric, 'asymmetric not supported' aop = "KOP_LEAKYRELU" elif activation == "sigmoid": - assert not asymmetric, 'asymmetric not supported' + #assert not asymmetric, 'asymmetric not supported' aop = "KOP_SIGMOID" elif activation == "tanh": - assert not asymmetric, 'asymmetric not supported' + #assert not asymmetric, 'asymmetric not supported' aop = "KOP_TANH" else: raise NotImplementedError("activation type %s not implemented" % activation) @@ -122,7 +126,7 @@ def gen_conv_at_params(params, pad_compatibilities): Dcy=params.dilation.h, Scx=params.stride.w, Scy=params.stride.h, - ConvPad=params.has_at_zero_pad() and 1 or 0 + ConvPad=params.has_at_zero_pad() and need_padding_in_at(params) and 1 or 0 ) else: cop = "KOP_CONV" @@ -136,7 +140,7 @@ def gen_conv_at_params(params, pad_compatibilities): Dcy=params.dilation.h, Scx=params.stride.w, Scy=params.stride.h, - ConvPad=params.has_at_zero_pad() and 1 or 0 + ConvPad=params.has_at_zero_pad() and need_padding_in_at(params) and 1 or 0 ) # POOL @@ -170,7 +174,7 @@ def gen_pool_at_params(params, pad_compatibilities): Dpy=1, Spx=params.stride.w, Spy=params.stride.h, - PoolPad=params.has_at_zero_pad() and 1 or 0 + PoolPad=params.has_at_zero_pad() and need_padding_in_at(params) and 1 or 0 ) GlobalPoolATParam = namedtuple('GlobalPoolATParam', [ diff --git a/tools/nntool/generation/at_types/gen_ctrl.py b/tools/nntool/generation/at_types/gen_ctrl.py index 08318c367..e0be2bcdc 100644 --- a/tools/nntool/generation/at_types/gen_ctrl.py +++ b/tools/nntool/generation/at_types/gen_ctrl.py @@ -69,7 +69,9 @@ def gen_graph_ctrl(op, val, code_block): "OUTPUT_DATASIZE": int, "GATE_PRENORM": int, "FLOAT_DUMP": int, - "MFCC_LOG_OFFSET": int + "MFCC_LOG_OFFSET": int, + "EXPLICIT_PAD_CONV": int, + "EXPLICIT_PAD_POOL": int, } diff --git a/tools/nntool/generation/autotiler_options.py b/tools/nntool/generation/autotiler_options.py index 308e29cf6..4b5a22a38 100644 --- a/tools/nntool/generation/autotiler_options.py +++ b/tools/nntool/generation/autotiler_options.py @@ -115,7 +115,7 @@ 'l1_size': 64000, 'l2_size': 300000, 'l3_size': 8000000, - 'l3_flash_mb': 20, + 'l3_flash_mb': 64, 'fc_freq': 250000000, 'cl_freq': 175000000, 'cluster_stack_size': 1024 * 4, diff --git a/tools/nntool/generation/code_block.py b/tools/nntool/generation/code_block.py index e615c6844..659b61847 100644 --- a/tools/nntool/generation/code_block.py +++ b/tools/nntool/generation/code_block.py @@ -15,12 +15,39 @@ QUOTE = lambda s: '"'+s+'"' + class CodeBlock(): + + class CommentWriter(): + def __init__(self, cb, max_len) -> None: + self._cb = cb + self._max_len = max_len + self.reset() + + def write(self, comment): + for elem in comment.split(' '): + if self._cur_len + len(elem) + 1 > self._max_len: + self.end() + self._cur_line.append(elem) + self._cur_len += len(elem) + 1 + + def end(self): + self._cb.write(f'// {" ".join(self._cur_line)}') + self.reset() + + def reset(self): + self._cur_line = [] + self._cur_len = len(self._cb.get_indent()) + 3 + def __init__(self, starting_indent=0, indent_char=" "): self._indent = starting_indent self._indent_char = indent_char self._lines = [] + @property + def lines(self): + return self._lines + def indent(self): self._indent += 1 return self @@ -60,6 +87,9 @@ def write_start(self, fmt, *args): self._lines.insert(0, fmt.format(*args)) return self + def start_long_comment(self, max_len=80): + return CodeBlock.CommentWriter(self, max_len) + def comment(self, fmt, *args): fmt = self.get_indent() + '// ' + fmt if args: diff --git a/tools/nntool/generation/code_generator.py b/tools/nntool/generation/code_generator.py index 378885bb5..093eff2fe 100644 --- a/tools/nntool/generation/code_generator.py +++ b/tools/nntool/generation/code_generator.py @@ -17,15 +17,18 @@ import numpy as np from bfloat16 import bfloat16 -from expressions.symbolic.kernel_codegen import BasicKernel +from expressions.symbolic.iteration_space import IterationSpace +from graph.manipulations.dimensions import add_dimensions from graph.types import (ConcatParameters, ConstantInputParameters, - InputParameters, OutputParameters, ReshapeParameters, - SplitParameters, TransposeParameters) -from graph.types.lstm import LSTMParameters + InputParameters, OutputParameters, SplitParameters, + TransposeParameters) +from graph.types.base import NNEdge +from graph.types.fusions import FusionBase from graph.types.others import CopyParameters, QuantizeParameters from graph.types.rnn import RNNBaseParameters from utils.node_id import NodeId +from generation.gen_utils import ModelGenerationInternalError from generation.generator_decorators import RegisteredGeneratorsMixin # pylint: disable=wildcard-import,unused-wildcard-import from generation.generators import * @@ -116,6 +119,17 @@ class CodeGenerator(NewGenerator, RegisteredGeneratorsMixin): def __init__(self, G, naming_convension, opts=None): super().__init__() self.G = G + # this generates a view of the graph with all nodes that are not generated removed + self.hidden_graph = G.with_hidden_nodes( + lambda node: node.no_model_code, + edge_class=NNEdge + ) + self.sorted_nodes = sorted( + self.hidden_graph.nodes(), key=lambda node: node.step_idx) + naming_convension.G = self.hidden_graph + # the edge parameters are generated from the graph with the hidden nodes but the dimensions + # are not updated. They are read from the nodes + add_dimensions(self.hidden_graph, update_graph=False) self.naming_convension = naming_convension self.name_cache = NameCache() self.bindings = [] @@ -132,14 +146,22 @@ def __init__(self, G, naming_convension, opts=None): self.opts.update(opts) if self.opts['include_project_header']: self.include_files.append(self.project_name + '.h') - has_vcd = False - for step in G.graph_state.steps: - node = step['node'] - if node.at_options.vcd_trace_on is not None: - has_vcd = True - if has_vcd: + if any(step and step['node'].at_options.vcd_trace_on is not None + for step in G.graph_state.steps): self.include_files.append('hal/gvsoc/gvsoc.h') + @property + def output_nodes(self): + for node in sorted(self.hidden_graph.outputs(), key=lambda node: node.step_idx): + if isinstance(node, OutputParameters): + yield node + + @property + def input_nodes(self): + for node in sorted(self.hidden_graph.inputs(), key=lambda node: node.step_idx): + if isinstance(node, InputParameters): + yield node + @property def project_name(self): return self.naming_convension.get_project_name() @@ -159,8 +181,9 @@ def get_edge_name(self, eparams): def get_node_name(self, params, target): try: return self.name_cache[params][target] - except: - raise ValueError(f"Name Cache: {params.name} {target} not found") + except KeyError as ex: + raise ModelGenerationInternalError( + f"Name Cache: {params.name} {target} not found") from ex def memory_device_generator(self, indent=0): self.opts['memory_devices'].set_l2_ram_ext_managed( @@ -199,68 +222,36 @@ def binding_generator(self, indent=0): return str(code_block) @staticmethod - def real_up_connection(G, eparams, set_real=False): - while isinstance(eparams.creating_node, ReshapeParameters) or \ - (isinstance(eparams.creating_node, TransposeParameters) and eparams.creating_node.does_nothing()): - set_real = True - eparams = G.in_edges(eparams.creating_node.name)[0].params - return eparams, set_real - - @staticmethod - def real_down_connection(G, eparams): - oedge = G.out_edges(eparams.creating_node.name)[ + def get_output(G, eparams): + oedges = G.indexed_out_edges(eparams.creating_node.name)[ eparams.creating_node_idx] - while isinstance(oedge.to_node, ReshapeParameters) or \ - (isinstance(oedge.to_node, TransposeParameters) and oedge.to_node.does_nothing()): - # TODO - This assert is removed but there are some corner cases where this will break - # it would be better to create an edge alias map before code gen - # need a test for x -> reshape -> y and output and y -> z -> another output - # assert len(G.indexed_out_edges(oedge.to_node.name)) <= 1 - oedge = G.out_edges(oedge.to_node.name)[0] - return oedge + if len(oedges) != 1 or not isinstance(oedges[0].to_node, OutputParameters): + return None + return oedges[0] def local_generator(self, indent=0): - edges = set(edge.params for edge in self.G.edges()) + edges = set(edge.params for edge in self.hidden_graph.edges()) sorted_edges = list(edges) sorted_edges.sort(key=lambda eparams: eparams.creating_step) for eparams in sorted_edges: - # check if the following real node is an output - if isinstance(eparams.creating_node, ConcatParameters): - rout_edge = self.real_down_connection(self.G, eparams) - if isinstance(rout_edge.to_node, OutputParameters): - rout_eparams = rout_edge.params - cname = self.naming_convension.get_edge_name(rout_eparams.creating_node, - rout_eparams.creating_step, - rout_eparams.edge_type, - rout_eparams.edge_order) - LOG.info("edge from step %s %s is not used and is replaced with edge to step %s:%s %s cname: %s", - eparams.creating_node.step_idx, eparams.creating_node.name, - rout_eparams.creating_node.name, rout_eparams.creating_node.step_idx, - rout_eparams.creating_step, cname) - self.name_cache.set(eparams, 'edge', cname) - continue - - rin_eparams, set_real = self.real_up_connection(self.G, eparams) - if rin_eparams.edge_type == "out": - # The edge was marked as an output so find the real edge down - rin_eparams = self.real_down_connection( - self.G, rin_eparams).params + if eparams.edge_type == "out": + # The edge was marked as an output so find the real output edge + oedges = self.hidden_graph.indexed_out_edges(eparams.creating_node.name)[ + eparams.creating_node_idx] + oedges = list(filter(lambda edge: isinstance( + edge.to_node, OutputParameters), oedges)) + if not oedges: + raise ModelGenerationInternalError( + f'output edge created by {eparams.creating_node.name}:{eparams.creating_node_idx} ' + f'is not connected to an output - {" ".join(edge.to_node.name for edge in oedges)}') + if len(oedges) > 1: + raise ModelGenerationInternalError( + f'output edge created by {eparams.creating_node.name}:{eparams.creating_node_idx} ' + f'is connected to more than one output - {" ".join(edge.to_node.name for edge in oedges)}') + + rin_eparams = oedges[0].params self.name_cache.set(eparams, 'edge', rin_eparams.name) continue - else: - if set_real: - # Code will not be generated for reshape or empty transpose so the input to the - # following node is the input to this node - cname = self.naming_convension.get_edge_name(rin_eparams.creating_node, - rin_eparams.creating_step, - rin_eparams.edge_type, - rin_eparams.edge_order) - LOG.info("edge from step %s %s is not used and is replaced with edge from step %s:%s %s cname: %s", - eparams.creating_node.step_idx, eparams.creating_node.name, - rin_eparams.creating_node.name, rin_eparams.creating_node.step_idx, - rin_eparams.creating_step, cname) - self.name_cache.set(eparams, 'edge', cname) - continue cname = self.naming_convension.get_edge_name(eparams.creating_node, eparams.creating_step, @@ -305,7 +296,7 @@ def local_generator(self, indent=0): return str(code_block) def stack_generator(self, indent=0): - edges = set(edge.params for edge in self.G.edges()) + edges = set(edge.params for edge in self.hidden_graph.edges()) sorted_edges = list(edges) sorted_edges.sort(key=lambda eparams: eparams.creating_step) concat_edges = list([eparams for eparams in sorted_edges if isinstance( @@ -314,15 +305,15 @@ def stack_generator(self, indent=0): node = eparams.creating_node cname_out = self.name_cache[eparams]['edge'] in_edge_names = [self.name_cache[edge.params]['edge'] - for edge in self.G.indexed_in_edges(node.name)] + for edge in self.hidden_graph.indexed_in_edges(node.name)] self.stacked_tensors.append(TensorStack(cname_out, in_edge_names)) - split_nodes = [node for node in self.G.nodes( + split_nodes = [node for node in self.hidden_graph.nodes( ) if isinstance(node, SplitParameters)] for split_node in split_nodes: - eparams_in = self.G.in_edges(split_node.name)[0].params + eparams_in = self.hidden_graph.in_edges(split_node.name)[0].params eparams_out = [ - edge_bundle[0].params for edge_bundle in self.G.indexed_out_edges(split_node.name)] + edge_bundle[0].params for edge_bundle in self.hidden_graph.indexed_out_edges(split_node.name)] cname_in = self.name_cache[eparams_in]['edge'] cnames_out = [self.name_cache[eparams]['edge'] for eparams in eparams_out] @@ -360,22 +351,27 @@ def global_generator(self, indent=0): def generate_outputs(self): outputs = set() - count_outputs = 0 - for node in self.G.output_nodes(): + for node in self.output_nodes: qrec = self.G.quantization[NodeId(node)] - for edge in self.G.in_edges(node.name): - if isinstance(edge.from_node, (LSTMParameters, )) and count_outputs: + for edge in self.hidden_graph.in_edges(node.name): + if isinstance(edge.from_node, (RNNBaseParameters, )) and edge.from_idx > 0: continue - eparams, _ = self.real_up_connection(self.G, edge.params) + eparams = edge.params if eparams in outputs: continue eparams.edge_type = "out" outputs.add(eparams) self.execute_phase("outputs", node, qrec, edge) - count_outputs += 1 + + def sorted_nodes_and_fusions(self): + for node in self.sorted_nodes: + if isinstance(node, FusionBase) and node.quantize_internals: + for fnode in node.contained_nodes(): + yield node, fnode + yield node, None def generate_constants(self): - for _, pnode, _, fnode in self.G.nodes_iterator(): + for pnode, fnode in self.sorted_nodes_and_fusions(): anode = pnode if not fnode else fnode qrec = self.G.quantization.get(NodeId(pnode, fnode)) if not self.new_execute_phase("globals", anode, qrec, pnode, fnode): @@ -383,9 +379,9 @@ def generate_constants(self): def generate_inputs(self): inputs = set() - for node in self.G.input_nodes(): + for node in self.input_nodes: qrec = self.G.quantization[NodeId(node)] - for edge in self.G.out_edges(node.name): + for edge in self.hidden_graph.out_edges(node.name): eparams = edge.params if eparams in inputs: continue @@ -396,17 +392,17 @@ def cnn_includes_generator(self): includes = [] if any(qrec.ktype == "scaled" for qrec in self.G.quantization.values()): includes.append('"CNN_Generators_SQ8.h"') - if self.G.has_rnn: + if self.G.has_rnn(ktype='scaled'): includes.append('"RNN_Generators_SQ8.h"') if any(qrec.ktype == "symmetric" for qrec in self.G.quantization.values()): includes.append('"CNN_Generators.h"') if any(qrec.ktype == "float" for qrec in self.G.quantization.values()): includes.append('"CNN_Generators_fp16.h"') - if self.G.has_rnn: + if self.G.has_rnn(ktype='float'): includes.append('"RNN_Generators_fp16.h"') if any(qrec.cache.get('ne16') for qrec in self.G.quantization.values()): includes.append('"CNN_Generators_NE16.h"') - if self.G.has_rnn: + if self.G.has_rnn(ne16=True): includes.append('"RNN_Generators_NE16.h"') if self.G.has_resizer: includes.append('"ResizeGenerator.h"') @@ -424,7 +420,7 @@ def cnn_kernels(self): kernels.append('\"CNN_BasicKernels_NE16.h\"') if '\"CNN_BasicKernels_SQ8.h\"' not in kernels: kernels.append('\"CNN_BasicKernels_SQ8.h\"') - if self.G.has_rnn: + if self.G.has_rnn(ne16=True): kernels.append('"RNN_BasicKernels_NE16.h"') return kernels @@ -475,22 +471,22 @@ def get_node_cname(self, node): def kernel_generator(self, indent=0): code_block = CodeBlock(starting_indent=indent) - for _, node, _, _ in self.G.nodes_iterator(yield_fusions=False): + for node in self.sorted_nodes: name = node.name cname = self.get_node_cname(node) if node.at_options.vcd_trace_on is not None: self.add_vcd_trace_binding(cname, node.at_options.vcd_trace_on) self.name_cache.set(node, 'node', cname) - in_eparams = self.G.get_in_params(name) - out_eparams = self.G.get_out_params(name) + in_eparams = [edge.params if edge else None + for edge in self.hidden_graph.indexed_in_edges(name)] + out_eparams = [edge_bundle[0].params if edge_bundle else None + for edge_bundle in self.hidden_graph.indexed_out_edges(name)] try: qrec = self.G.quantization[NodeId(node)] except KeyError as err: LOG.error("Quantization record not found for node %s", node.name) raise err - if isinstance(node, ReshapeParameters): - continue - if isinstance(node, TransposeParameters) and node.does_nothing(): + if node.no_model_code: continue elif isinstance(node, (InputParameters, OutputParameters)): continue @@ -508,7 +504,8 @@ def kernel_generator(self, indent=0): in_eparams, out_eparams, cname) if not (self.new_execute_phase("kernels", node, qrec, in_eparams, out_eparams, cname) or self.execute_phase("kernels", node, qrec, in_eparams, out_eparams, cname)): - raise NotImplementedError(f"Don't know how to generate kernel for parameter type {node.name} {node.CLS_OP_NAME}. " + raise NotImplementedError("Don't know how to generate kernel for parameter type " + f"{node.name} {node.CLS_OP_NAME}. " "Perhaps you need to run fusions -a expression_matcher.") # if self.opts['generate_checksums']: @@ -528,16 +525,17 @@ def add_vcd_trace_binding(self, cname, enable): before=True)) def add_checksum_binding(self, cname, name, step_idx, eparams, before): - node = self.G[name] + node = self.hidden_graph[name] if before: size = node.in_dims[0].size() else: size = node.out_dims[0].size() self.bindings.append( FunctionBindingList(cname, - checksum_func(self.G, name), + checksum_func(self.hidden_graph, name), Imm(step_idx), - Imm(calc_value_checksum(self.G, name)), + Imm(calc_value_checksum( + self.hidden_graph, name)), GArgEdge(eparams[0]), Imm(size), before=before) @@ -551,7 +549,7 @@ def load_basic_kernel_library(self, indent=0): code_block = CodeBlock(starting_indent=indent) if any(qrec.ktype == "scaled" for qrec in self.G.quantization.values()): code_block.write("LoadCNN_SQ8_Library();") - if self.G.has_rnn: + if self.G.has_rnn(ktype='scaled'): code_block.write("Load_RNN_SQ8_Library();") if self.G.has_ssd_postprocess: code_block.write("LoadSSDLibrary();") @@ -559,14 +557,14 @@ def load_basic_kernel_library(self, indent=0): code_block.write("LoadCNNLibrary();") if any(qrec.ktype == "float" for qrec in self.G.quantization.values()): code_block.write("LoadCNNLibrary_fp16();") - if self.G.has_rnn: + if self.G.has_rnn(ktype='float'): code_block.write("LoadRNN_fp16_Library();") if self.G.has_ssd_postprocess: code_block.write("LoadSSDLibrary_fp16();") if any(qrec.cache.get('ne16') for qrec in self.G.quantization.values()): # We need to ensure that also LoadCNN_SQ8_Library is called code_block.write("LoadCNN_NE16_SQ8_Library();") - if self.G.has_rnn: + if self.G.has_rnn(ne16=True): code_block.write("Load_RNN_NE16_Library();") if self.G.has_resizer: code_block.write("LoadResizeLibrary();") @@ -579,9 +577,7 @@ def load_basic_kernel_library(self, indent=0): def header_generator(self, indent=0): code_block = CodeBlock(starting_indent=indent) - for _, node, _, fnode in self.G.nodes_iterator(): - if fnode: - continue + for node in self.sorted_nodes: cname = self.name_cache[node]['node'] qrec = self.G.quantization[NodeId(node)] code_block.comment(cname) @@ -614,8 +610,8 @@ def expressions_foreach_basic_kernel(self): basic_kernel = self.expressions_kernel_cache.get(node) if not basic_kernel: qrec = self.G.quantization[NodeId(node)] - basic_kernel = BasicKernel(qrec.cache['qfunc_col'], - [inp.name for inp in node.constant_inputs]) + basic_kernel = IterationSpace(qrec.cache['qfunc_col'], + constants=[inp.name for inp in node.constant_inputs]) self.expressions_kernel_cache[node] = basic_kernel yield node, basic_kernel @@ -633,12 +629,12 @@ def expressions_kernel_types_generator(self): code_block = CodeBlock(starting_indent=0) for node, basic_kernel in self.expressions_foreach_basic_kernel(): _, arg_name = self.expressions_get_names(node) - basic_kernel.kernel_arg_type_codegen(arg_name, code=code_block) + basic_kernel.gen_kernel_arg_typedecl(arg_name, code=code_block) return str(code_block) def expressions_kernel_includes_generator(self): code_block = CodeBlock(starting_indent=0) - includes = set.union(*[basic_kernel.func_col.c_header_set for node, + includes = set.union(*[basic_kernel.assignments.c_header_set for node, basic_kernel in self.expressions_foreach_basic_kernel()]) for include in includes: code_block.write('#include {}', include) @@ -688,7 +684,7 @@ def expressions_user_kernel_source_generator(self, indent=0): def generate_main_appl_inout_def(self, test_inputs=None, test_outputs=None, indent=0): code_block = CodeBlock(starting_indent=indent) code_block.write("/* Inputs */") - for i, node in enumerate(self.G.input_nodes()): + for i, node in enumerate(self.input_nodes): if node.at_options.allocate or node.at_options.extern_input_pointer: continue nodeq = self.G.quantization[NodeId(node, None)].out_qs[0] @@ -704,7 +700,7 @@ def generate_main_appl_inout_def(self, test_inputs=None, test_outputs=None, inde code_block.write( f"L2_MEM {CTYPE[nodeq.ctype]} {node.name.capitalize()}[{node.out_dims[0].size()}];") code_block.write("/* Outputs */") - for node in self.G.output_nodes(): + for node in self.output_nodes: if node.at_options.allocate: continue nodeq = self.G.quantization[NodeId(node, None)].out_qs[0] @@ -712,7 +708,7 @@ def generate_main_appl_inout_def(self, test_inputs=None, test_outputs=None, inde f"L2_MEM {CTYPE[nodeq.ctype]} {node.name.capitalize()}[{node.out_dims[0].size()}];") if test_outputs: - for out_n, outp in zip(self.G.output_nodes(), test_outputs): + for out_n, outp in zip(self.output_nodes, test_outputs): code_block.write( 'L2_MEM {} {}_gt[] = {{{}}};', dtype2ctype(outp), @@ -723,15 +719,13 @@ def generate_main_appl_inout_def(self, test_inputs=None, test_outputs=None, inde def gen_inout_list(self): inout_str = "" - for node in self.G.input_nodes(): + for node in self.input_nodes: if node.at_options.allocate or node.at_options.extern_input_pointer: continue inout_str += f"{node.name.capitalize()}, " - rnn_present = any([isinstance(node, RNNBaseParameters) - for node in self.G.nodes()]) - if rnn_present: + if self.hidden_graph.nodes(node_classes=RNNBaseParameters): inout_str += "1, " - for node in self.G.output_nodes(): + for node in self.output_nodes: if node.at_options.allocate: continue inout_str += f"{node.name.capitalize()}, " @@ -740,25 +734,25 @@ def gen_inout_list(self): def generate_output_check(self, tol=0.0, indent=0): code = CodeBlock(starting_indent=indent) code.write('int errors;') - for idx, out_node in enumerate(self.G.output_nodes()): + for idx, out_node in enumerate(self.output_nodes): out_sz = out_node.out_dims[0].size() nodeq = self.G.quantization[NodeId(out_node, None)].out_qs[0] dtype = "%f" if nodeq.is_floating else "%d" code.write('errors = 0;') - if tol: - code.write(f"{dtype2ctype(nodeq)} max_diff = 0;") + code.write(f"{'float' if nodeq.is_floating else 'int'} max_diff_{idx} = 0;") code.write(f'for (int j=0; j<{out_sz}; j++) {{') code.indent() + code.write( + f"{'float' if nodeq.is_floating else 'int'} diff = {out_node.name.capitalize()}[j] - " + f"{out_node.name.capitalize()}_gt[j];") + code.write("diff = (diff>0)?diff:(-diff);") + code.write(f"if (diff > max_diff_{idx}) max_diff_{idx} = diff;") if tol: code.write( - f"{dtype2ctype(nodeq)} diff = {out_node.name.capitalize()}[j] - " - f"{out_node.name.capitalize()}_gt[j];") - code.write("diff = (diff>0)?diff:(-diff);") - code.write(f"if (diff > max_diff) max_diff = diff;") - code.write(f'if (diff > {nodeq.quantize(np.array(tol)).item()}) {{') + f'if (diff > {nodeq.quantize(np.array(tol)).item()}) {{') else: code.write( - f'if ({out_node.name.capitalize()}[j] != {out_node.name.capitalize()}_gt[j]) {{') + f'if (diff > 0) {{') code.indent() code.write('errors++;') code.write(f'printf("Error @ %d: {dtype} instead of {dtype}\\n", j, ' @@ -769,6 +763,5 @@ def generate_output_check(self, tol=0.0, indent=0): code.write('}') code.write( f'printf("{out_node.name.capitalize()}: %d/{out_sz} errors\\n", errors);') - if tol: - code.write(f'printf("Max error: {dtype}\\n", max_diff);') + code.write(f'printf("Max error: {dtype}\\n", max_diff_{idx});') return str(code) diff --git a/tools/nntool/generation/default_appl_main_template.py b/tools/nntool/generation/default_appl_main_template.py index c6493a947..d6b20ecf2 100644 --- a/tools/nntool/generation/default_appl_main_template.py +++ b/tools/nntool/generation/default_appl_main_template.py @@ -57,7 +57,6 @@ def generate_main_appl_template(G, gen, test_inputs=None, test_outputs=None, tol * Put here Your input settings * <--------------- */ - #ifndef __EMUL__ /* Configure And open cluster. */ @@ -70,22 +69,19 @@ def generate_main_appl_template(G, gen, test_inputs=None, test_outputs=None, tol printf("Cluster open failed !\\n"); pmsis_exit(-4); } - int cur_fc_freq = pi_freq_set(PI_FREQ_DOMAIN_FC, ${gen.opts['fc_freq']}); - if (cur_fc_freq == -1) + + /* Frequency Settings: defined in the Makefile */ + int cur_fc_freq = pi_freq_set(PI_FREQ_DOMAIN_FC, FREQ_FC*1000*1000); + int cur_cl_freq = pi_freq_set(PI_FREQ_DOMAIN_CL, FREQ_CL*1000*1000); + int cur_pe_freq = pi_freq_set(PI_FREQ_DOMAIN_PERIPH, FREQ_PE*1000*1000); + if (cur_fc_freq == -1 || cur_cl_freq == -1 || cur_pe_freq == -1) { printf("Error changing frequency !\\nTest failed...\\n"); pmsis_exit(-4); } + printf("FC Frequency as %d Hz, CL Frequency = %d Hz, PERIIPH Frequency = %d Hz\\n", + pi_freq_get(PI_FREQ_DOMAIN_FC), pi_freq_get(PI_FREQ_DOMAIN_CL), pi_freq_get(PI_FREQ_DOMAIN_PERIPH)); - int cur_cl_freq = pi_freq_set(PI_FREQ_DOMAIN_CL, ${gen.opts['cl_freq']}); - if (cur_cl_freq == -1) - { - printf("Error changing frequency !\\nTest failed...\\n"); - pmsis_exit(-5); - } -#ifdef __GAP9__ - pi_freq_set(PI_FREQ_DOMAIN_PERIPH, 250000000); -#endif #endif // IMPORTANT - MUST BE CALLED AFTER THE CLUSTER IS SWITCHED ON!!!! printf("Constructor\\n"); @@ -99,7 +95,8 @@ def generate_main_appl_template(G, gen, test_inputs=None, test_outputs=None, tol printf("Call cluster\\n"); #ifndef __EMUL__ - struct pi_cluster_task task = {0}; + struct pi_cluster_task task; + pi_cluster_task(&task,NULL,NULL); task.entry = cluster; task.arg = NULL; task.stack_size = (unsigned int) STACK_SIZE; @@ -186,7 +183,7 @@ def generate_main_appl_make(G, gen, quantized, open_args=""): TRAINED_MODEL = ${os.path.split(G.graph_identity.filename)[1]} -MODEL_EXPRESSIONS = ${"$(MODEL_BUILD)/" + gen.opts['basic_kernel_source_file'] if gen.G.has_expressions else ""} +MODEL_EXPRESSIONS = ${"$(MODEL_BUILD)/" + gen.opts['basic_kernel_source_file']} NNTOOL_EXTRA_FLAGS += ${open_args} ${"MODEL_QUANTIZED=1" if quantized else ""} @@ -201,6 +198,15 @@ def generate_main_appl_make(G, gen, quantized, open_args=""): CLUSTER_SLAVE_STACK_SIZE=${gen.opts['cluster_slave_stack_size']} CLUSTER_NUM_CORES=${gen.opts['cluster_num_cores']} +# FLASH and RAM type +FLASH_TYPE = ${"MRAM" if gen.opts['l3_flash_device'] == 'AT_MEM_L3_MRAMFLASH' else \ + "QSPI" if gen.opts['l3_flash_device'] == 'AT_MEM_L3_QSPIFLASH' else \ + "OSPI" if gen.opts['l3_flash_device'] == 'AT_MEM_L3_OSPIFLASH' else \ + "HYPER"} +RAM_TYPE = ${"QSPI" if gen.opts['l3_ram_device'] == 'AT_MEM_L3_QSPIRAM' else \ + "OSPI" if gen.opts['l3_ram_device'] == 'AT_MEM_L3_OSPIRAM' else \ + "HYPER"} + NNTOOL_SCRIPT = nntool_script ${"APP_CFLAGS += -DSTD_FLOAT" if any(qrec[1].out_qs[0].dtype == np.float16 for qrec in G.quantization.sorted_iterator(G)) else ""} ${"APP_LDFLAGS += -lm" if gen.G.has_expressions and "FLOAT" in gen.G.quantization.schemes_present else ""} @@ -225,7 +231,7 @@ def generate_main_appl_make_atproject(G, gen, quantized, model_path): AT_MODEL_PATH=${model_path} -MODEL_EXPRESSIONS = ${gen.opts['basic_kernel_source_file'] if gen.G.has_expressions else ""} +MODEL_EXPRESSIONS = ${gen.opts['basic_kernel_source_file']} ${"MODEL_QUANTIZED=1" if quantized else ""} diff --git a/tools/nntool/generation/gen_utils.py b/tools/nntool/generation/gen_utils.py index 0744c27ab..c2207782a 100644 --- a/tools/nntool/generation/gen_utils.py +++ b/tools/nntool/generation/gen_utils.py @@ -13,6 +13,11 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import os + +from utils.exception import NNToolInternelError + + def at_bits(qtype): if qtype is None: return 0 @@ -32,3 +37,11 @@ def at_q(qtype): def at_bits_and_q(qtype): return "{}, {}".format(at_bits(qtype), qtype.q) + +def write_empty(model_directory, model_file, comment): + model_path = os.path.join(model_directory, model_file) + with open(model_path, "w") as output_fp: + output_fp.write(f"/** {comment}\n**/") + +class ModelGenerationInternalError(NNToolInternelError): + pass diff --git a/tools/nntool/generation/generators/bindings/__init__.py b/tools/nntool/generation/generators/bindings/__init__.py index 338706bf5..8007e72e0 100644 --- a/tools/nntool/generation/generators/bindings/__init__.py +++ b/tools/nntool/generation/generators/bindings/__init__.py @@ -3,7 +3,6 @@ from .float16 import * from .general import * -from .mult8 import * from .pow2 import * __all__ = [ diff --git a/tools/nntool/generation/generators/bindings/general/multi_inout_bindings_generator.py b/tools/nntool/generation/generators/bindings/general/multi_inout_bindings_generator.py deleted file mode 100644 index 346444a76..000000000 --- a/tools/nntool/generation/generators/bindings/general/multi_inout_bindings_generator.py +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -from generation.bindings import (CommentBindingList, GNodeArgEdge, - NodeBindingList) -from generation.generator_decorators import (QREC_MULT8, QREC_POW2, QREC_FLOAT, - generation_function) -from graph.types import ExpressionFusionParameters - - -@generation_function("bindings", (ExpressionFusionParameters, ), qrec_types=(QREC_MULT8, QREC_POW2, QREC_FLOAT)) -def multi_in_out_bindings_generator(gen, node, qrec, in_eparams, out_eparams, cname) -> bool: - set_multi_in_out_bindings(gen, in_eparams, out_eparams, cname, node, qrec) - - -def set_multi_in_out_bindings(gen, in_eparams, out_eparams, cname, node, qrec): - gen.bindings.append( - CommentBindingList("Node {} in_qs [{}] out_qs [{}]", node.name, - ",".join(str(in_q) for in_q in qrec.in_qs), - ",".join(str(out_q) for out_q in qrec.out_qs)) - ) - - # the input order of the generated function can vary since it passes through a set - params = [GNodeArgEdge(in_eparams[idx]) for idx in node.input_shuffle] + \ - [GNodeArgEdge(out_eparams[idx], "GNA_OUT") for idx in node.output_shuffle] - gen.bindings.append( - NodeBindingList(cname, *params) - ) diff --git a/tools/nntool/generation/generators/bindings/mult8/__init__.py b/tools/nntool/generation/generators/bindings/mult8/__init__.py deleted file mode 100644 index 5b372dc5a..000000000 --- a/tools/nntool/generation/generators/bindings/mult8/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -import os -import pkgutil - -__all__ = [ - modname for _, modname, _ in pkgutil.walk_packages( - path=[os.path.split(__file__)[0]]) -] diff --git a/tools/nntool/generation/generators/bindings/mult8/conv_bindings_generator.py b/tools/nntool/generation/generators/bindings/mult8/conv_bindings_generator.py deleted file mode 100644 index bcb13fd9c..000000000 --- a/tools/nntool/generation/generators/bindings/mult8/conv_bindings_generator.py +++ /dev/null @@ -1,78 +0,0 @@ -# # Copyright (C) 2020 GreenWaves Technologies, SAS - -# # This program is free software: you can redistribute it and/or modify -# # it under the terms of the GNU Affero General Public License as -# # published by the Free Software Foundation, either version 3 of the -# # License, or (at your option) any later version. - -# # This program is distributed in the hope that it will be useful, -# # but WITHOUT ANY WARRANTY; without even the implied warranty of -# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# # GNU Affero General Public License for more details. -# # You should have received a copy of the GNU Affero General Public License -# # along with this program. If not, see . - -# from generation.bindings import (CommentBindingList, GNodeArgEdge, -# GNodeArgNode, NodeBindingList) -# from generation.generator_decorators import QREC_MULT8, generation_function -# from generation.generators.globals.global_names import (INFOS, MULSCALE, -# MULSHIFT) -# from graph.types import (ActivationParameters, Conv2DParameters, -# ConvFusionParameters) -# from utils.node_id import NodeId - - -# @generation_function("bindings", (Conv2DParameters, ConvFusionParameters, ActivationParameters), qrec_types=(QREC_MULT8,)) -# def conv_bindings_generator(gen, node, qrec, in_eparams, out_eparams, cname) -> bool: -# step_idx = node.step_idx -# if isinstance(node, ActivationParameters): -# set_act_bindings(gen, step_idx, in_eparams, out_eparams, cname, node, qrec) -# elif isinstance(node, Conv2DParameters): -# set_conv_bindings(gen, step_idx, in_eparams, out_eparams, cname, node, qrec) -# elif isinstance(node, ConvFusionParameters): -# cnodes = node.contained_nodes() -# quants = [gen.G.quantization[NodeId(node, fnode)] for fnode in cnodes] -# if node.fusion_type in ("conv_active_pool", "conv_active", "conv_pool"): -# set_conv_bindings(gen, step_idx, in_eparams, out_eparams, -# cname, cnodes[0], quants[0], out_q=quants[1]) -# elif node.fusion_type == "conv_pool_active": -# set_conv_bindings(gen, step_idx, in_eparams, out_eparams, -# cname, cnodes[0], quants[0], out_q=quants[2]) -# else: -# return False -# else: -# return False -# return True - - -# def set_conv_bindings(gen, step_idx, in_eparams, out_eparams, cname, -# conv_params, conv_q, out_q=None): -# del step_idx -# if out_q is None: -# out_q = conv_q -# gen.bindings.append( -# CommentBindingList("Node {} inq {} weightsq {} outq {} biasesq {}", cname, -# conv_q.in_qs[0], conv_q.in_qs[1], out_q.out_qs[0], conv_q.in_qs[2]) -# ) -# gen.bindings.append( -# NodeBindingList(cname, GNodeArgEdge(in_eparams[0]), -# GNodeArgEdge(in_eparams[1]), -# GNodeArgEdge(in_eparams[2]), -# GNodeArgEdge(out_eparams[0], "GNA_OUT"), -# GNodeArgNode(conv_params, MULSCALE), -# GNodeArgNode(conv_params, MULSHIFT), -# GNodeArgNode(conv_params, INFOS) -# )) - -# def set_act_bindings(gen, step_idx, in_eparams, out_eparams, cname, -# act_params, act_qrec): -# del step_idx -# gen.bindings.append( -# CommentBindingList("Node {} inq {} outq {}", cname, -# act_qrec.in_qs[0], act_qrec.out_qs[0]) -# ) -# gen.bindings.append( -# NodeBindingList(cname, GNodeArgEdge(in_eparams[0]), -# GNodeArgEdge(out_eparams[0], "GNA_OUT"), -# GNodeArgNode(act_params, INFOS) -# )) diff --git a/tools/nntool/generation/generators/bindings/mult8/fc_binding_generator.py b/tools/nntool/generation/generators/bindings/mult8/fc_binding_generator.py deleted file mode 100644 index 4bafff1f3..000000000 --- a/tools/nntool/generation/generators/bindings/mult8/fc_binding_generator.py +++ /dev/null @@ -1,58 +0,0 @@ -# # Copyright (C) 2020 GreenWaves Technologies, SAS - -# # This program is free software: you can redistribute it and/or modify -# # it under the terms of the GNU Affero General Public License as -# # published by the Free Software Foundation, either version 3 of the -# # License, or (at your option) any later version. - -# # This program is distributed in the hope that it will be useful, -# # but WITHOUT ANY WARRANTY; without even the implied warranty of -# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# # GNU Affero General Public License for more details. -# # You should have received a copy of the GNU Affero General Public License -# # along with this program. If not, see . - - -# from generation.bindings import (CommentBindingList, GNodeArgEdge, -# GNodeArgNode, NodeBindingList) -# from generation.generator_decorators import QREC_MULT8, generation_function -# from generation.generators.globals.global_names import (INFOS, MULSCALE, -# MULSHIFT) -# from graph.types import LinearFusionParameters, FcParameters -# from utils.node_id import NodeId - - -# @generation_function("bindings", (LinearFusionParameters, FcParameters), qrec_types=(QREC_MULT8, )) -# def fc_bindings_generator(gen, node, qrec, in_eparams, out_eparams, cname) -> bool: -# step_idx = node.step_idx -# if isinstance(node, FcParameters): -# set_fc_bindings(gen, step_idx, in_eparams, -# out_eparams, cname, node, qrec) -# elif isinstance(node, LinearFusionParameters): -# cnodes = node.contained_nodes() -# quants = [gen.G.quantization[NodeId(node, fnode)] for fnode in cnodes] -# set_fc_bindings(gen, step_idx, in_eparams, out_eparams, -# cname, cnodes[0], quants[0], out_q=quants[1]) -# else: -# return False -# return True - - -# def set_fc_bindings(gen, step_idx, in_eparams, out_eparams, cname, -# params, linear_q, out_q=None): -# del step_idx -# if out_q is None: -# out_q = linear_q -# gen.bindings.append( -# CommentBindingList("Node {} inq {} weightsq {} outq {}", params.name, -# linear_q.in_qs[0], linear_q.in_qs[1], out_q.out_qs[0]) -# ) -# gen.bindings.append( -# NodeBindingList(cname, GNodeArgEdge(in_eparams[0]), -# GNodeArgEdge(in_eparams[1]), -# GNodeArgEdge(in_eparams[2]), -# GNodeArgEdge(out_eparams[0], "GNA_OUT"), -# GNodeArgNode(params, MULSCALE), -# GNodeArgNode(params, MULSHIFT), -# GNodeArgNode(params, INFOS) -# )) diff --git a/tools/nntool/generation/generators/bindings/mult8/inout_bindings_generator.py b/tools/nntool/generation/generators/bindings/mult8/inout_bindings_generator.py deleted file mode 100644 index 5faebf6f1..000000000 --- a/tools/nntool/generation/generators/bindings/mult8/inout_bindings_generator.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -from generation.bindings import (CommentBindingList, GNodeArgEdge, - NodeBindingList) -from generation.generator_decorators import QREC_MULT8, generation_function -from graph.types import ( ImageFormatParameters, - ResizerParameters, StridedSliceParameters, - TransposeParameters) - - -@generation_function("bindings", (TransposeParameters, ImageFormatParameters, - ResizerParameters, StridedSliceParameters), qrec_types=(QREC_MULT8, )) -def in_out_bindings_generator(gen, node, qrec, in_eparams, out_eparams, cname) -> bool: - if isinstance(node, TransposeParameters): - _, real_transpose = node.real_shape() - if len(real_transpose) <= 1: - return True - set_in_out_bindings(gen, in_eparams, out_eparams, cname, node, qrec) - - -def set_in_out_bindings(gen, in_eparams, out_eparams, cname, node, node_q, out_q=None): - if out_q is None: - out_q = node_q - gen.bindings.append( - CommentBindingList("Node {} inq {} outq {}", node.name, - str(node_q.in_qs[0]), str(out_q.out_qs[0])) - ) - gen.bindings.append( - NodeBindingList(cname, GNodeArgEdge(in_eparams[0]), - GNodeArgEdge(out_eparams[0], "GNA_OUT"))) diff --git a/tools/nntool/generation/generators/bindings/mult8/inout_infos_bindings_generator.py b/tools/nntool/generation/generators/bindings/mult8/inout_infos_bindings_generator.py deleted file mode 100644 index ddab24192..000000000 --- a/tools/nntool/generation/generators/bindings/mult8/inout_infos_bindings_generator.py +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -from generation.generators.bindings.mult8.inout_bindings_generator import set_in_out_bindings -from generation.bindings import (CommentBindingList, GNodeArgEdge, - GNodeArgNode, NodeBindingList) -from generation.generator_decorators import QREC_MULT8, generation_function -from graph.types import (ActivationFusionBase, ActivationParameters, - ConvFusionParameters, GlobalPoolingParameters, GlobalAveragePoolParameters, GlobalMaxPoolParameters, GlobalSumPoolParameters, - PoolingParameters) - - -@generation_function("bindings", (PoolingParameters, ConvFusionParameters, ActivationParameters, - GlobalAveragePoolParameters, GlobalMaxPoolParameters, GlobalSumPoolParameters, ActivationFusionBase), qrec_types=(QREC_MULT8, )) -def in_out_infos_bindings_generator(gen, node, qrec, in_eparams, out_eparams, cname) -> bool: - if isinstance(node, ActivationFusionBase): - cnodes = node.contained_nodes() - if isinstance(cnodes[0], (GlobalPoolingParameters, PoolingParameters)): - set_in_out_infos_bindings(gen, in_eparams, out_eparams, - cname, cnodes[0], qrec) - return True - return False - if isinstance(node, (GlobalPoolingParameters, PoolingParameters)): - set_in_out_infos_bindings(gen, in_eparams, out_eparams, cname, node, qrec) - elif isinstance(node, ConvFusionParameters) and node.fusion_type == "pool_active": - cnodes = node.contained_nodes() - set_in_out_infos_bindings(gen, in_eparams, out_eparams, cname, cnodes[0], qrec) - else: - return False - return True - - -def set_in_out_infos_bindings(gen, in_eparams, out_eparams, cname, node, node_q, out_q=None): - if out_q is None: - out_q = node_q - gen.bindings.append( - CommentBindingList("Node {} inq {} outq {}", node.name, - str(node_q.in_qs[0]), str(out_q.out_qs[0])) - ) - gen.bindings.append( - NodeBindingList(cname, GNodeArgEdge(in_eparams[0]), - GNodeArgEdge(out_eparams[0], "GNA_OUT"), GNodeArgNode(node, "infos"))) diff --git a/tools/nntool/generation/generators/bindings/mult8/mat_vect_mult_bindings_generator.py b/tools/nntool/generation/generators/bindings/mult8/mat_vect_mult_bindings_generator.py deleted file mode 100644 index 222b32d73..000000000 --- a/tools/nntool/generation/generators/bindings/mult8/mat_vect_mult_bindings_generator.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -from generation.bindings import (CommentBindingList, GNodeArgEdge, - GNodeArgNode, NodeBindingList) -from generation.generator_decorators import QREC_MULT8, generation_function -from graph.types import ActivationFusionBase, MatrixMulParameters -from utils.node_id import NodeId - - -@generation_function("bindings", (MatrixMulParameters, ActivationFusionBase), qrec_types=(QREC_MULT8,)) -def mat_vect_mul_bindings_generator(gen, node, qrec, in_eparams, out_eparams, cname) -> bool: - step_idx = node.step_idx - if isinstance(node, ActivationFusionBase): - cnodes = node.contained_nodes() - quants = [gen.G.quantization[NodeId(node, fnode)] for fnode in cnodes] - if isinstance(cnodes[0], MatrixMulParameters): - set_mat_vect_mul_bindings(gen, cnodes[0], step_idx, in_eparams, out_eparams, - cname, quants[0], out_q=quants[1]) - return True - return False - set_mat_vect_mul_bindings( - gen, node, step_idx, in_eparams, out_eparams, cname, qrec) - return True - - -def set_mat_vect_mul_bindings(gen, node, step_idx, in_eparams, out_eparams, cname, qrec, out_q=None): - del step_idx - if out_q is None: - out_q = qrec - gen.bindings.append( - CommentBindingList("Node {} in1q {} in2q {} outq {}", cname, - qrec.in_qs[0], qrec.in_qs[1], out_q.out_qs[0]) - ) - gen.bindings.append( - NodeBindingList(cname, GNodeArgEdge(in_eparams[0]), - GNodeArgEdge(in_eparams[1]), - GNodeArgEdge(out_eparams[0], "GNA_OUT"), - GNodeArgNode(node, 'infos') - )) diff --git a/tools/nntool/generation/generators/bindings/mult8/matadd_bindings_generator.py b/tools/nntool/generation/generators/bindings/mult8/matadd_bindings_generator.py deleted file mode 100644 index 8adc8f2bb..000000000 --- a/tools/nntool/generation/generators/bindings/mult8/matadd_bindings_generator.py +++ /dev/null @@ -1,76 +0,0 @@ -# # Copyright (C) 2020 GreenWaves Technologies, SAS - -# # This program is free software: you can redistribute it and/or modify -# # it under the terms of the GNU Affero General Public License as -# # published by the Free Software Foundation, either version 3 of the -# # License, or (at your option) any later version. - -# # This program is distributed in the hope that it will be useful, -# # but WITHOUT ANY WARRANTY; without even the implied warranty of -# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# # GNU Affero General Public License for more details. -# # You should have received a copy of the GNU Affero General Public License -# # along with this program. If not, see . - -# from generation.bindings import (CommentBindingList, GNodeArgEdge, -# GNodeArgNode, NodeBindingList) -# from generation.generator_decorators import QREC_MULT8, generation_function -# from graph.types import (ActivationFusion, MatrixAddParameters, -# PaddedAddFusionParameters) -# from quantization.multiplicative.mulbias import set_add_in_scale -# from utils.node_id import NodeId - - -# @generation_function("bindings", (PaddedAddFusionParameters, ), qrec_types=(QREC_MULT8,)) -# def matadd_bindings_generator(gen, node, qrec, in_eparams, out_eparams, cname) -> bool: -# step_idx = node.step_idx -# if isinstance(node, PaddedAddFusionParameters): -# cnodes = node.contained_nodes() -# add_node = [node for node in cnodes if isinstance( -# node, MatrixAddParameters)] -# if add_node: -# quants = [gen.G.quantization[NodeId( -# node, fnode)] for fnode in cnodes] -# set_matadd_bindings(gen, node, step_idx, in_eparams, out_eparams, -# cname, quants[1], out_q=quants[-1]) -# return True -# return False -# # if isinstance(node, ActivationFusion): -# # cnodes = node.contained_nodes() -# # quants = [gen.G.quantization[NodeId(node, fnode)] for fnode in cnodes] -# # if isinstance(cnodes[0], MatrixAddParameters): -# # set_matadd_bindings(gen, cnodes[0], step_idx, in_eparams, out_eparams, -# # cname, quants[0], out_q=quants[1]) -# # return True -# # return False -# # set_matadd_bindings(gen, node, step_idx, in_eparams, -# # out_eparams, cname, qrec) -# # return True - - -# def set_matadd_bindings(gen, node, step_idx, in_eparams, out_eparams, cname, qrec, out_q=None): -# del step_idx -# if out_q is None: -# out_q = qrec -# set_add_in_scale(qrec) -# scaled_idx = qrec.cache['scaled_idx'] -# not_scaled_idx = 0 if scaled_idx else 1 -# gen.bindings.append( -# CommentBindingList("Node {} in1q {} in2q {} outq {}", cname, -# qrec.in_qs[scaled_idx], qrec.in_qs[not_scaled_idx], out_q.out_qs[0]) -# ) -# if isinstance(node, PaddedAddFusionParameters): -# gen.bindings.append( -# NodeBindingList(cname, GNodeArgEdge(in_eparams[scaled_idx]), -# GNodeArgEdge(in_eparams[not_scaled_idx]), -# GNodeArgEdge(out_eparams[0], "GNA_OUT"), -# GNodeArgNode(node, 'infos'), -# GNodeArgNode(node.contained_nodes()[0], 'infos') -# )) -# else: -# gen.bindings.append( -# NodeBindingList(cname, GNodeArgEdge(in_eparams[scaled_idx]), -# GNodeArgEdge(in_eparams[not_scaled_idx]), -# GNodeArgEdge(out_eparams[0], "GNA_OUT"), -# GNodeArgNode(node, 'infos') -# )) diff --git a/tools/nntool/generation/generators/bindings/mult8/matmul_bindings_generator.py b/tools/nntool/generation/generators/bindings/mult8/matmul_bindings_generator.py deleted file mode 100644 index 4582be486..000000000 --- a/tools/nntool/generation/generators/bindings/mult8/matmul_bindings_generator.py +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -from utils.node_id import NodeId -from generation.bindings import (CommentBindingList, GNodeArgEdge, - GNodeArgNode, NodeBindingList) -from generation.generator_decorators import QREC_MULT8, generation_function -from generation.generators.globals.global_names import (INFOS, MULSCALE, - MULSHIFT) -from graph.types import MatMulOpParameters -from graph.types.fusions import MatMulOpFusionParameters - - -@generation_function("bindings", (MatMulOpFusionParameters, MatMulOpParameters), qrec_types=(QREC_MULT8, )) -def matmul_mult_bindings_generator(gen, node, qrec, in_eparams, out_eparams, cname) -> bool: - if isinstance(node, MatMulOpFusionParameters): - cnodes = node.contained_nodes() - quants = [gen.G.quantization[NodeId( - node, fnode)] for fnode in cnodes] - set_in_out_bindings(gen, in_eparams, out_eparams, - cname, cnodes[0], quants[0], out_q=quants[-1]) - return True - if isinstance(node, MatMulOpParameters): - set_in_out_bindings(gen, in_eparams, out_eparams, cname, node, qrec) - else: - return False - return True - - -def set_in_out_bindings(gen, in_eparams, out_eparams, cname, node, node_q, out_q=None): - if out_q is None: - out_q = node_q - gen.bindings.append( - CommentBindingList( - "Node {} inq {} outq {}", node.name, - str(node_q.in_qs[0]), str(out_q.out_qs[0])) - ) - if len(node.in_dims) == 3: - if len(node_q.in_qs[0].scale) > 1: - gen.bindings.append( - NodeBindingList( - cname, - GNodeArgEdge(in_eparams[1]), - GNodeArgEdge(in_eparams[0]), - GNodeArgEdge(in_eparams[2]), - GNodeArgEdge(out_eparams[0], "GNA_OUT"), - GNodeArgNode(node, MULSCALE), - GNodeArgNode(node, MULSHIFT), - GNodeArgNode(node, INFOS))) - else: - gen.bindings.append( - NodeBindingList( - cname, - GNodeArgEdge(in_eparams[1]), - GNodeArgEdge(in_eparams[0]), - GNodeArgEdge(in_eparams[2]), - GNodeArgEdge(out_eparams[0], "GNA_OUT"), - GNodeArgNode(node, INFOS))) - else: - gen.bindings.append( - NodeBindingList( - cname, - GNodeArgEdge(in_eparams[1]), - GNodeArgEdge(in_eparams[0]), - GNodeArgEdge(out_eparams[0], "GNA_OUT"), - GNodeArgNode(node, INFOS))) diff --git a/tools/nntool/generation/generators/bindings/mult8/rnn_bindings_generator.py b/tools/nntool/generation/generators/bindings/mult8/rnn_bindings_generator.py deleted file mode 100644 index 4765aa62a..000000000 --- a/tools/nntool/generation/generators/bindings/mult8/rnn_bindings_generator.py +++ /dev/null @@ -1,176 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -from generation.at_types.tc_arg_info import LocalArgInfo -from generation.bindings import (CommentBindingList, GArgName, GNodeArgEdge, - GNodeArgNode, NoArg, NodeBindingList) -from generation.generator_decorators import QREC_MULT8, generation_function -from generation.generators.globals.global_names import INFOS -from graph.types import (GRUParameters, LSTMParameters, RNNBaseParameters, - RNNParameters) - - -@generation_function("bindings", (RNNParameters, LSTMParameters, GRUParameters), qrec_types=(QREC_MULT8,)) -def rnn_bindings_generator(gen, node, qrec, in_eparams, out_eparams, cname) -> bool: - step_idx = node.step_idx - if isinstance(node, RNNParameters): - set_rnn_bindings(gen, step_idx, in_eparams, - out_eparams, cname, node, qrec) - elif isinstance(node, LSTMParameters): - set_lstm_bindings(gen, step_idx, in_eparams, - out_eparams, cname, node, qrec) - elif isinstance(node, GRUParameters): - set_gru_bindings(gen, step_idx, in_eparams, - out_eparams, cname, node, qrec) - - return True - - -def num_sequences(node: RNNBaseParameters): - n1 = min(node.n_input_cells, node.n_cells - node.n_output_cells) - n3 = node.n_cells - max(node.n_input_cells, - node.n_cells - node.n_output_cells) - n2 = node.n_cells - (n1 + n3) - return sum(1 if n > 0 else 0 for n in [n1, n2, n3]) - - -def set_lstm_bindings(gen, step_idx, in_eparams, out_eparams, cname, - rnn_params, rnn_q): - - names = rnn_params.get_name_indexes() - - gen.bindings.append( - CommentBindingList("Node {} inq {} outq {}", cname, - rnn_q.in_qs[0], - rnn_q.out_qs[0]) - ) - c_state_eparams = in_eparams[names['c_state']] - i_state_eparams = in_eparams[names['i_state']] - - num_seq = num_sequences(rnn_params) - if num_seq > 1: - gen.locals.append(LocalArgInfo( - "int8", "S%s_CellInternal01" % step_idx)) - gen.locals.append(LocalArgInfo( - "int8", "S%s_StateInternal01" % step_idx)) - - if num_seq > 2: - gen.locals.append(LocalArgInfo( - "int8", "S%s_CellInternal02" % step_idx)) - gen.locals.append(LocalArgInfo( - "int8", "S%s_StateInternal02" % step_idx)) - - reset_name = i_state_eparams.creating_node.reset_name if not rnn_params.rnn_states_as_inputs else f"{rnn_params.name}_Reset" - gen.bindings.append( - NodeBindingList(cname, - GNodeArgEdge(c_state_eparams, direction="GNA_INOUT"), - GNodeArgEdge(i_state_eparams, direction="GNA_INOUT"), - GNodeArgEdge("S%s_CellInternal01" % step_idx, alias=c_state_eparams, - direction="GNA_INOUT") if num_seq > 1 else NoArg(), - GNodeArgEdge("S%s_StateInternal01" % step_idx, alias=i_state_eparams, - direction="GNA_INOUT") if num_seq > 1 else NoArg(), - GNodeArgEdge("S%s_CellInternal02" % step_idx, alias="S%s_CellInternal01" % - step_idx, direction="GNA_INOUT") if num_seq > 2 else NoArg(), - GNodeArgEdge("S%s_StateInternal02" % step_idx, alias="S%s_CellInternal01" % - step_idx, direction="GNA_INOUT") if num_seq > 2 else NoArg(), - GNodeArgEdge(in_eparams[0]), - GNodeArgEdge(in_eparams[names['r_2_f_w']]), - GNodeArgEdge(in_eparams[names['f_b']]), - GNodeArgEdge(in_eparams[names['r_2_i_w']]), - GNodeArgEdge(in_eparams[names['i_b']]), - GNodeArgEdge(in_eparams[names['r_2_c_w']]), - GNodeArgEdge(in_eparams[names['c_b']]), - GNodeArgEdge(in_eparams[names['r_2_o_w']]), - GNodeArgEdge(in_eparams[names['o_b']]), - GNodeArgEdge(out_eparams[0], direction="GNA_OUT"), - GNodeArgNode(rnn_params, INFOS), - GArgName(reset_name) - )) - - -def set_rnn_bindings(gen, step_idx, in_eparams, out_eparams, cname, - rnn_params, rnn_q): - names = rnn_params.get_name_indexes() - - gen.bindings.append( - CommentBindingList("Node {} inq {} weightsq {} outq {} biasesq {}", cname, - rnn_q.in_qs[0], rnn_q.in_qs[names['r_2_i_w']], - rnn_q.out_qs[0], rnn_q.in_qs[names['i_b']]) - ) - num_seq = num_sequences(rnn_params) - if num_seq > 1: - gen.locals.append(LocalArgInfo( - "int8", "S%s_StateInternal01" % step_idx)) - - if num_seq > 2: - gen.locals.append(LocalArgInfo( - "int8", "S%s_StateInternal02" % step_idx)) - - i_state_eparams = in_eparams[names['i_state']] - reset_name = i_state_eparams.creating_node.reset_name if not rnn_params.rnn_states_as_inputs else f"{rnn_params.name}_Reset" - gen.bindings.append( - NodeBindingList(cname, - GNodeArgEdge(i_state_eparams, direction="GNA_INOUT"), - GNodeArgEdge("S%s_StateInternal01" % step_idx, alias=i_state_eparams, - direction="GNA_INOUT") if num_seq > 1 else NoArg(), - GNodeArgEdge("S%s_StateInternal02" % step_idx, alias="S%s_CellInternal01" % - step_idx, direction="GNA_INOUT") if num_seq > 2 else NoArg(), - GNodeArgEdge(in_eparams[0]), - GNodeArgEdge(in_eparams[names['r_2_i_w']]), - GNodeArgEdge(in_eparams[names['i_b']]), - GNodeArgEdge(out_eparams[0], direction="GNA_OUT"), - GNodeArgNode(rnn_params, INFOS), - GArgName(reset_name) - )) - - -def set_gru_bindings(gen, step_idx, in_eparams, out_eparams, cname, - rnn_params, rnn_q): - names = rnn_params.get_name_indexes() - - gen.bindings.append( - CommentBindingList("Node {} inq {} outq {}", cname, - rnn_q.in_qs[0], - rnn_q.out_qs[0]) - ) - num_seq = num_sequences(rnn_params) - if num_seq > 1: - gen.locals.append(LocalArgInfo( - "int8", "S%s_StateInternal01" % step_idx)) - - if num_seq > 2: - gen.locals.append(LocalArgInfo( - "int8", "S%s_StateInternal02" % step_idx)) - - i_state_eparams = in_eparams[names['h_state']] - reset_name = i_state_eparams.creating_node.reset_name if not rnn_params.rnn_states_as_inputs else f"{rnn_params.name}_Reset" - gen.bindings.append( - NodeBindingList(cname, - GNodeArgEdge(i_state_eparams, direction="GNA_INOUT"), - GNodeArgEdge("S%s_StateInternal01" % step_idx, alias=i_state_eparams, - direction="GNA_INOUT") if num_seq > 1 else NoArg(), - GNodeArgEdge("S%s_StateInternal02" % step_idx, alias="S%s_CellInternal01" % - step_idx, direction="GNA_INOUT") if num_seq > 2 else NoArg(), - GNodeArgEdge(in_eparams[0]), - GNodeArgEdge(in_eparams[names['r_2_r_w']]), - GNodeArgEdge(in_eparams[names['r_b']]), - GNodeArgEdge(in_eparams[names['r_2_z_w']]), - GNodeArgEdge(in_eparams[names['z_b']]), - GNodeArgEdge(in_eparams[names['r_2_h_w']]), - GNodeArgEdge(in_eparams[names['w_h_b']]), - GNodeArgEdge(in_eparams[names['r_h_b']]), - GNodeArgEdge(out_eparams[0], direction="GNA_OUT"), - GNodeArgNode(rnn_params, INFOS), - GArgName(reset_name) - )) diff --git a/tools/nntool/generation/generators/bindings/mult8/softmax_bindings_generator.py b/tools/nntool/generation/generators/bindings/mult8/softmax_bindings_generator.py deleted file mode 100644 index 0b33e775a..000000000 --- a/tools/nntool/generation/generators/bindings/mult8/softmax_bindings_generator.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -import numpy as np -from generation.bindings import (CommentBindingList, GNodeArgEdge, - GNodeArgNode, NodeBindingList) -from generation.generator_decorators import QREC_MULT8, generation_function -from graph.types import SoftMaxParameters - - -@generation_function("bindings", (SoftMaxParameters,), qrec_types=(QREC_MULT8,)) -def softmax_bindings_generator(gen, node, qrec, in_eparams, out_eparams, cname) -> bool: - set_softmax_bindings(gen, in_eparams, out_eparams, cname, node, qrec) - return True - - -def set_softmax_bindings(gen, in_eparams, out_eparams, cname, params, node_q): - in_q = -np.ceil(np.log2(node_q.in_qs[0].scale)) - out_q = -np.ceil(np.log2(node_q.out_qs[0].scale)) - gen.bindings.append( - CommentBindingList("Node {} inq {} outq {}", - params.name, int(in_q[0]), int(out_q[0])) - ) - gen.bindings.append( - NodeBindingList(cname, GNodeArgEdge(in_eparams[0]), - GNodeArgEdge(out_eparams[0], "GNA_OUT"), - GNodeArgNode(params, 'infos') - )) diff --git a/tools/nntool/generation/generators/bindings/mult8/ssd_postprocess_bindings_generator.py b/tools/nntool/generation/generators/bindings/mult8/ssd_postprocess_bindings_generator.py deleted file mode 100644 index 806ff0667..000000000 --- a/tools/nntool/generation/generators/bindings/mult8/ssd_postprocess_bindings_generator.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -# from generation.bindings import (CommentBindingList, GNodeArgEdge, -# GNodeArgNode, NodeBindingList) -# from generation.generator_decorators import QREC_MULT8, generation_function -# from generation.generators.globals.global_names import (INFOS, SSD_NORMS, -# SSD_SCALES) -# from graph.types import SSDDetectorParameters - - -# @generation_function("bindings", (SSDDetectorParameters, ), qrec_types=(QREC_MULT8, )) -# def ssd_postprocess_bindings_generator(gen, node, qrec, in_eparams, out_eparams, cname) -> bool: -# set_ssd_postprocess_bindings( -# gen, in_eparams, out_eparams, cname, node, qrec) -# return True - - -# def set_ssd_postprocess_bindings(gen, in_eparams, out_eparams, cname, node, node_q, out_q=None): -# if out_q is None: -# out_q = node_q -# gen.bindings.append( -# CommentBindingList("Node {} offsetsq {} scoresq {} anchorsq {} outboxesq {}", node.name, -# str(node_q.in_qs[0]), str(node_q.in_qs[1]), str(node_q.in_qs[2]), str(out_q.out_qs[0])) -# ) -# gen.bindings.append( -# NodeBindingList(cname, -# GNodeArgEdge(in_eparams[0]), -# GNodeArgEdge(in_eparams[1]), -# GNodeArgEdge(in_eparams[2]), -# GNodeArgEdge(out_eparams[0], "GNA_OUT"), -# GNodeArgEdge(out_eparams[1], "GNA_OUT"), -# GNodeArgEdge(out_eparams[2], "GNA_OUT"), -# GNodeArgNode(node, SSD_SCALES), -# GNodeArgNode(node, SSD_NORMS), -# GNodeArgNode(node, INFOS))) diff --git a/tools/nntool/generation/generators/globals/constant_input_generator.py b/tools/nntool/generation/generators/globals/constant_input_generator.py index 526cd8755..7ac6691b4 100644 --- a/tools/nntool/generation/generators/globals/constant_input_generator.py +++ b/tools/nntool/generation/generators/globals/constant_input_generator.py @@ -18,11 +18,13 @@ from generation.at_types.constant_info import ConstantInfo from generation.at_types.tc_arg_info import (GlobalArgInfo, GlobalResetArgInfo, InputArgInfo) +from generation.gen_utils import ModelGenerationInternalError from generation.generator_decorators import (QREC_FLOAT, QREC_MULT8, QREC_POW2, generation_function) from graph.types import ConstantInputParameters -from graph.types.fusions import ConvFusionParameters, LinearFusionParameters -from graph.types.linear import FcParameters +from graph.types.fusions import (ConvFusionParameters, + LinearFusionParameters, + MatMulOpFusionParameters) from utils.node_id import NodeId from utils.numpy_helpers import interleave, packbits @@ -83,13 +85,15 @@ def constant_input_globals_generator(gen, node, qrec, pnode, fnode) -> bool: if qtype.attr.ne16_biases: to_node = gen.G.out_edges(pnode.name)[0].to_node - if isinstance(to_node, (ConvFusionParameters, LinearFusionParameters)): + if isinstance(to_node, (ConvFusionParameters, LinearFusionParameters, MatMulOpFusionParameters)): cnodes = to_node.contained_nodes() quants = [gen.G.quantization[NodeId( to_node, fnode)] for fnode in cnodes] filter_qrec = quants[0] else: filter_qrec = gen.G.quantization[NodeId(to_node)] + if 'mul_biases_q' not in filter_qrec.cache: + raise ModelGenerationInternalError(f"mul_biases_q not found in qrec for {to_node.name}") mul_qbiases = filter_qrec.cache['mul_biases_q'].qbiases mul_qnorms = filter_qrec.cache['mul_biases_q'].qnorms value = np.where(mul_qnorms > 0, diff --git a/tools/nntool/generation/generators/globals/mult8_filter_generator.py b/tools/nntool/generation/generators/globals/mult8_filter_generator.py deleted file mode 100644 index d32b24867..000000000 --- a/tools/nntool/generation/generators/globals/mult8_filter_generator.py +++ /dev/null @@ -1,39 +0,0 @@ -# # Copyright (C) 2020 GreenWaves Technologies, SAS - -# # This program is free software: you can redistribute it and/or modify -# # it under the terms of the GNU Affero General Public License as -# # published by the Free Software Foundation, either version 3 of the -# # License, or (at your option) any later version. - -# # This program is distributed in the hope that it will be useful, -# # but WITHOUT ANY WARRANTY; without even the implied warranty of -# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# # GNU Affero General Public License for more details. -# # You should have received a copy of the GNU Affero General Public License -# # along with this program. If not, see . - -# from generation.generator_decorators import QREC_MULT8, generation_function -# from generation.helpers.gen_scales import gen_scales -# from graph.types import ConvFusionParameters, Conv2DParameters -# from utils.node_id import NodeId - -# # pylint: disable=wildcard-import, unused-wildcard-import -# from .global_names import * - - -# @generation_function("globals", (Conv2DParameters, ConvFusionParameters), qrec_types=(QREC_MULT8,)) -# def mult8_filter_globals_generator(gen, node, qrec, pnode, fnode) -> bool: -# if fnode is not None: -# return False -# if isinstance(pnode, Conv2DParameters): -# gen_scales(gen, pnode, pnode, qrec) -# elif isinstance(pnode, ConvFusionParameters): -# cnodes = node.contained_nodes() -# quants = [gen.G.quantization[NodeId(node, fnode)] for fnode in cnodes] -# if node.fusion_type in ("conv_active_pool", "conv_active", "linear_active", "conv_pool_active", "conv_pool"): -# gen_scales(gen, pnode, cnodes[0], quants[0]) -# else: -# return False -# else: -# return False -# return True diff --git a/tools/nntool/generation/generators/globals/mult8_infos_generator.py b/tools/nntool/generation/generators/globals/mult8_infos_generator.py deleted file mode 100644 index 2628e34ea..000000000 --- a/tools/nntool/generation/generators/globals/mult8_infos_generator.py +++ /dev/null @@ -1,338 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -from graph.types.conv2d import Conv2DParameters -from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType -from graph.types.activations import HTanHActivationParameters, TanHActivationParameters -import math -import numpy as np -from generation.at_types.constant_info import ConstantInfo -from generation.at_types.tc_arg_info import GlobalArgInfo -from generation.generator_decorators import QREC_MULT8, generation_function -from generation.helpers.gen_constant import gen_constant -from generation.helpers.gen_scales import gen_scales -from graph.types import (ActivationFusionBase, ActivationParameters,LinearFusionParameters, - ConvFusionParameters, FilterParameters, - GlobalAveragePoolParameters, GlobalMaxPoolParameters, - GlobalPoolingParameters, GlobalSumPoolParameters, - HSigmoidActivationParameters, - HSwishActivationParameters, LeakyActivationParameters, - MatMulOpFusionParameters, MatMulOpParameters, - MatrixAddParameters, MatrixMulParameters, - PaddedAddFusionParameters, PoolingParameters, - QuantizeParameters, ReluActivationParameters, - SigmoidActivationParameters, SoftMaxParameters) -from quantization.multiplicative.mulbias import (compute_in_out_scale, set_add_in_scale) -from quantization.qtype import QType -from quantization.symmetric.kernels.activations import ( - hsigmoid_mult_gen_factors, hswish_mult_gen_factors, - leak_mult_gen_factor_q7) -from utils.node_id import NodeId - -# pylint: disable=wildcard-import,unused-wildcard-import -from .global_names import * - - -@generation_function("globals", - (ActivationParameters, - MatrixMulParameters, - ActivationFusionBase, SoftMaxParameters, PaddedAddFusionParameters), - qrec_types=(QREC_MULT8,)) -def mult8_infos_generator(gen, node, qrec, pnode, fnode) -> bool: - if fnode is not None: - return False - # if isinstance(pnode, Conv2DParameters): - # for_ne16 = qrec.cache.get('ne16') - # in_zero_point = qrec.in_qs[0].zero_point - # conv_mul_bias = qrec.cache.get('mul_biases_q') - # prenorm = conv_mul_bias.pre_normalization if isinstance(conv_mul_bias, MultMulBiasScaleQType) else 0 - # act_infos(gen, pnode, pnode, None, None, prenorm=prenorm, extra1=0, - # for_ne16=for_ne16, in_zero_point=in_zero_point) - # elif isinstance(pnode, (GlobalPoolingParameters, PoolingParameters)): - # compute_in_out_scale(qrec) - # act_infos(gen, pnode, pnode, None, qrec) - elif isinstance(pnode, ActivationParameters): - act_infos(gen, pnode, pnode, pnode, gen.G.quantization[NodeId(pnode)]) - # elif isinstance(pnode, ConvFusionParameters): - # cnodes = node.contained_nodes() - # quants = [gen.G.quantization[NodeId(node, fnode)] for fnode in cnodes] - # for_ne16 = any([qrec.cache.get('ne16') for qrec in quants]) - # in_zero_point = quants[0].in_qs[0].zero_point - # for qrec in quants: - # compute_in_out_scale(qrec) - # if node.fusion_type.startswith('linear') or node.fusion_type.startswith('conv') or node.fusion_type.startswith('pool'): - # if node.fusion_type in ("pool_active"): - # act_infos(gen, pnode, cnodes[0], cnodes[1], quants[1], - # extra1=0, for_ne16=for_ne16, in_zero_point=in_zero_point) - # else: - # conv_mul_bias = quants[0].cache.get('mul_biases_q') - # prenorm = conv_mul_bias.pre_normalization if isinstance(conv_mul_bias, MultMulBiasScaleQType) else 0 - # if node.fusion_type in ("conv_active_pool", "conv_active", "linear_active"): - # act_infos(gen, pnode, cnodes[0], cnodes[1], quants[1], prenorm=prenorm, - # extra1=0, for_ne16=for_ne16, in_zero_point=in_zero_point) - # elif node.fusion_type == "conv_pool_active": - # act_infos(gen, pnode, cnodes[0], cnodes[2], quants[2], prenorm=prenorm, - # extra1=0, for_ne16=for_ne16, in_zero_point=in_zero_point) - # elif node.fusion_type == "conv_pool": - # act_infos(gen, pnode, cnodes[0], None, None, prenorm=prenorm, - # extra1=0, for_ne16=for_ne16) - elif isinstance(pnode, MatrixMulParameters): - compute_in_out_scale(qrec, in_idx=(0, 1), out_idx=0) - act_infos(gen, pnode, pnode, None, None, - extra1=qrec.cache['scale_mul_biases_q'].qbiases[0], - extra2=qrec.cache['scale_mul_biases_q'].qnorms[0]) - elif isinstance(pnode, SoftMaxParameters): - act_infos(gen, pnode, pnode, pnode, qrec) - # elif isinstance(pnode, ActivationFusionBase): - # cnodes = node.contained_nodes() - # quants = [gen.G.quantization[NodeId(node, fnode)] for fnode in cnodes] - # for qrec in quants: - # compute_in_out_scale(qrec) - # if isinstance(cnodes[0], (GlobalPoolingParameters, PoolingParameters)): - # act_infos(gen, pnode, cnodes[0], cnodes[1], quants[1]) - # else: - # return False - # return True - elif isinstance(pnode, (MatMulOpParameters, MatMulOpFusionParameters)): - if isinstance(pnode, MatMulOpFusionParameters): - cnodes = node.contained_nodes() - quants = [gen.G.quantization[NodeId( - node, fnode)] for fnode in cnodes] - mul_node = cnodes[0] - mul_qrec = quants[0] - act_node = cnodes[1] - act_qrec = quants[1] - else: - mul_node = pnode - mul_qrec = qrec - act_node = None - act_qrec = None - - if len(pnode.in_dims) == 3 and len(mul_qrec.in_qs[0].scale) > 1: - gen_scales(gen, pnode, mul_node, mul_qrec) - extra3 = 0 - extra4 = 0 - else: - extra3 = mul_qrec.cache['mul_biases_q'].qbiases[0] - extra4 = mul_qrec.cache['mul_biases_q'].qnorms[0] - - act_infos(gen, pnode, mul_node, act_node, act_qrec, - extra3=extra3, - extra4=extra4) - elif isinstance(pnode, QuantizeParameters): - in_q = qrec.in_qs[0] - out_q = qrec.out_qs[0] - comment = f'in q: {in_q} out_q: {out_q}' - if qrec.cache['kernel_type'] == 'KOP_CONVERT_FP_FP_ZEROPOINT': - bits = 8 if in_q.dtype == np.int8 else 16 - if in_q.signed: - contents = ( - (int(math.pow(2, bits)) + in_q.zero_point[0] - out_q.zero_point[0]) % int(math.pow(2, bits))).astype(np.uint8) - else: - contents = ( - int(math.pow(2, bits)) - in_q.zero_point[0] + out_q.zero_point[0]).astype(np.uint8) - # if in_q.dtype == np.int8 and out_q.dtype == np.uint8: - # if not np.allclose(in_q.scale, out_q.scale): - # return False - # if not np.all(in_q.zero_point == (out_q.zero_point - 128)): - # return False - # contents = ( - # (256 + in_q.zero_point[0] - out_q.zero_point[0]) % 256).astype(np.uint8) - # elif in_q.dtype == np.uint8 and out_q.dtype == np.int8: - # if not np.allclose(in_q.scale, out_q.scale): - # return False - # if not np.all(in_q.zero_point == (out_q.zero_point - 128)): - # return False - # contents = ( - # 256 - in_q.zero_point[0] + out_q.zero_point[0]).astype(np.uint8) - elif in_q.dtype == np.int8 and out_q.dtype == np.int16: - if qrec.cache['kernel_type'] == 'KOP_CONVERT_FP_FP': - return True - raise NotImplementedError() - elif in_q.dtype == np.int16 and out_q.dtype == np.int8: - if qrec.cache['kernel_type'] == 'KOP_CONVERT_FP_FP': - return True - raise NotImplementedError() - else: - raise ValueError(f"strange dtype change in {pnode.name}") - cname, file_name = gen_constant(gen, pnode, pnode, INFOS) - const_info = ConstantInfo(file_name, QType.Pow2( - bits=8, q=0, signed=True), contents=contents) - - gen.globals.append(GlobalArgInfo("int8", cname, - gen.opts['default_global_home_location'], - gen.opts['default_global_exec_location'], - const_info=const_info, - comment=comment)) - else: - return False - return True - - -def act_infos(gen, pnode, fnode, act_params, act_q, - extra1=0, extra2=0, extra3=0, extra4=0, extra5=None, extra6=None, - prenorm=0, extra_name='', for_ne16=False, in_zero_point=0): - if isinstance(pnode, FilterParameters): - comment = str.format("BiasQ: {}", extra1) - elif isinstance(pnode, MatrixAddParameters): - comment = str.format("In1Scale: {} In1ScaleN: {} OutScale: {} OutScaleN: {}", - extra1, extra2, extra3, extra4) - else: - comment = "" - - if act_params is None: - contents = np.array([0, 0, 0, 0, 0], dtype=np.int8) - elif isinstance(act_params, ReluActivationParameters): - compute_in_out_scale(act_q) - actscale = act_q.cache['scale_mul_biases_q'].qbiases[0] - actscalen = act_q.cache['scale_mul_biases_q'].qnorms[0] - if act_params.upper_bound is None: # or fnode is not None: - if act_q.in_qs[0].zero_point == 0: - contents = np.array( - [actscale, actscalen, 0, 0, 0], dtype=np.int8) - if len(comment) == 0: - comment = "all 0" - else: - fac_1 = act_q.in_qs[0].zero_point - contents = np.array( - [actscale, actscalen, fac_1, 0, 0], dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} A0: {} B0: 0 C0: 0", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - fac_1[0]) - else: - if act_q.in_qs[0].zero_point == 0: - fac_1 = act_q.in_qs[0].quantize(act_params.upper_bound) - contents = np.array([actscale, actscalen, fac_1, 0, 0], - dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} A0: {} B0: 0 C0: 0", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - fac_1[0]) - else: - fac_1 = act_q.in_qs[0].zero_point - fac_2 = act_q.in_qs[0].quantize(act_params.upper_bound) - contents = np.array([actscale, actscalen, fac_1, fac_2, 0], - dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} A0: {} B0: {} C0: 0", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - fac_1[0], - fac_2[0]) - elif isinstance(act_params, HSigmoidActivationParameters): - # currently combines all scaling factors into one scale and shift - assert act_q.in_qs[0].zero_point == 0 and act_q.out_qs[0].zero_point == 0, "asymmetric not supported" - fac_1, upper_bound, _ = hsigmoid_mult_gen_factors(act_params, act_q) - contents = np.array([act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - upper_bound, fac_1, 1], - dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} qbias: {} qnorm: {} A0: {} B0: {} C0: 1", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - upper_bound[0], fac_1[0]) - elif isinstance(act_params, HSwishActivationParameters): - # currently combines all scaling factors into one scale and shift - assert act_q.in_qs[0].zero_point == 0 and act_q.out_qs[0].zero_point == 0, "asymmetric not supported" - fac_1, upper_bound, _ = hswish_mult_gen_factors(act_q) - contents = np.array([act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - upper_bound, fac_1, 1], - dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} qbias: {} qnorm: {} A0: {} B0: {} C0: 1", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - upper_bound[0], fac_1[0]) - elif isinstance(act_params, SoftMaxParameters): - assert act_q.in_qs[0].zero_point == 0 and act_q.out_qs[0].zero_point == 0, "asymmetric not supported" - norm = 15 + np.ceil(np.log2(act_q.in_qs[0].scale)) - contents = np.array([norm, 0, 0, 0, 0], dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} NORM: {}", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - int(norm[0])) - elif isinstance(act_params, LeakyActivationParameters): - assert act_q.in_qs[0].zero_point == 0 and act_q.out_qs[0].zero_point == 0, "asymmetric not supported" - compute_in_out_scale(act_q) - leak_factor_quant = leak_mult_gen_factor_q7(act_params) - contents = np.array([act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - leak_factor_quant, 0, 0], - dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} qbias: {} qnorm: {} A0: {} B0: x C0: x", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - leak_factor_quant) - elif isinstance(act_params, (SigmoidActivationParameters, TanHActivationParameters)): - assert act_q.in_qs[0].zero_point == 0 and act_q.out_qs[0].zero_point == 0, "asymmetric not supported" - compute_in_out_scale(act_q, extra_scale=QType.Pow2( - bits=32, q=7, signed=True).scale/act_q.in_qs[0].scale) - contents = np.array([act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - 0, 0, 0], - dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} qbias: {} qnorm: {} A0: x B0: x C0: x", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0]) - else: - raise NotImplementedError("activation tye not implemented") - - if isinstance(pnode, (GlobalPoolingParameters, PoolingParameters)): - contents = np.array([act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - 0, 0, 0], - dtype=np.int8) - - contents = np.append(contents, [extra1, extra2, extra3, extra4]) - if extra5 is not None: - contents = np.append(contents, [extra5]) - if extra6 is not None: - contents = np.append(contents, [extra6]) - - if for_ne16: - # append weights_offset and pad_val for ne16 - # TODO - default config maybe in future - if isinstance(pnode, (ConvFusionParameters, LinearFusionParameters)): - filt_q = gen.G.quantization[NodeId(pnode, fnode)] - else: - filt_q = gen.G.quantization[NodeId(pnode)] - pad_value = np.array(in_zero_point).astype(np.int16) - pad_value1 = np.bitwise_and(pad_value, 0xFF) - pad_value2 = np.bitwise_and(pad_value, 0xFF00) >> 8 - w_offset = - np.array(filt_q.in_qs[1].zero_point).astype(np.int32) - w_offset1 = np.bitwise_and(w_offset, 0xFF) - w_offset2 = np.bitwise_and(w_offset, 0xFF00) >> 8 - w_offset3 = np.bitwise_and(w_offset, 0xFF0000) >> 16 - w_offset4 = np.bitwise_and(w_offset, 0xFF000000) >> 24 - - contents = np.append( - contents, [[prenorm] if prenorm else [0], pad_value1, pad_value2, w_offset1, w_offset2, w_offset3, w_offset4]) - - cname, file_name = gen_constant(gen, pnode, fnode, INFOS, extra_name) - const_info = ConstantInfo(file_name, QType.Pow2( - bits=8, q=0, signed=True), contents=contents) - - gen.globals.append(GlobalArgInfo("int8", cname, - gen.opts['default_global_home_location'], - gen.opts['default_global_exec_location'], - const_info=const_info, - comment=comment)) diff --git a/tools/nntool/generation/generators/globals/mult8_rnn_infos_generator.py b/tools/nntool/generation/generators/globals/mult8_rnn_infos_generator.py deleted file mode 100644 index 73d045e3d..000000000 --- a/tools/nntool/generation/generators/globals/mult8_rnn_infos_generator.py +++ /dev/null @@ -1,340 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import numpy as np -from generation.at_types.constant_info import ConstantInfo -from generation.at_types.tc_arg_info import GlobalArgInfo, GlobalResetArgInfo -from generation.generator_decorators import QREC_MULT8, generation_function -from graph.types import GRUParameters, LSTMParameters, RNNParameters -from quantization.qtype import QType -from quantization.symmetric.kernels.rnn import internal_qtype - -from .global_names import * -from .mult8_infos_generator import gen_constant - - -@generation_function("globals", - (RNNParameters, LSTMParameters, GRUParameters), - qrec_types=(QREC_MULT8,)) -def mult8_rnn_infos_generator(gen, node, qrec, pnode, fnode) -> bool: - del pnode - if fnode is not None: - return False - if isinstance(node, RNNParameters): - rnn_infos(gen, node, qrec) - elif isinstance(node, LSTMParameters): - lstm_infos(gen, node, qrec) - elif isinstance(node, GRUParameters): - gru_infos(gen, node, qrec) - else: - raise ValueError() - if node.rnn_states_as_inputs: - gen.globals.append(GlobalResetArgInfo( - f"{node.name}_Reset", 'AT_MEM_L2', 'AT_MEM_UNDEF')) - return True - - -def sigmoid_infos(gate_name, mult_qtype, qtype): - scale = mult_qtype.qbiases[0] - scale_n = mult_qtype.qnorms[0] - three = qtype.quantize(np.array([3]))[0] - sixth = qtype.quantize(np.array([1/6]))[0] - six = qtype.quantize(np.array([6]))[0] - actn = qtype.q - comment = str.format("{0}_scale: {1} {0}_scale_n: {2} A0: {3} B0: {4} C0: {5}", - gate_name, scale, scale_n, six, three, sixth, 1, actn) - contents = np.array([scale, scale_n, six, three, - sixth, 1, actn], dtype=np.int8) - return contents, comment - - -def htanh_infos(gate_name, mult_qtype, qtype): - scale = mult_qtype.qbiases[0] - scale_n = mult_qtype.qnorms[0] - one = qtype.quantize(np.array([1]))[0] - comment = str.format("{0}_scale: {1} {0}_scale_n: {2} A0: {3} B0: {4}", - gate_name, scale, scale_n, -one, one) - contents = np.array([scale, scale_n, -one, one], dtype=np.int8) - return contents, comment - - -def scale_infos(gate_name, mult_qtype): - scale = mult_qtype.qbiases[0] - scale_n = mult_qtype.qnorms[0] - comment = str.format("{0}_scale: {1} {0}_scale_n: {2}", - gate_name, scale, scale_n) - contents = np.array([scale, scale_n], dtype=np.int8) - return contents, comment - - -LSTM_INFOS_ORDER = { - 'f': 'sigmoid', - 'i': 'sigmoid', - 'c': 'htanh', - 'o': 'sigmoid', -} - -GRU_INFOS_ORDER = { - 'r': 'sigmoid', - 'z': 'sigmoid', - 'h': 'htanh', -} - -INFOS_FUNCS = { - 'sigmoid': sigmoid_infos, - 'htanh': htanh_infos, - 'tanh': htanh_infos, -} - - -def highb(x): - return (x >> 8) & 0xff - - -def lowb(x): - return x & 0xff - -# define LSTM_F_INF 2 -# define LSTM_F_OFF 0 -# define LSTM_F_SCALE 0 -# define LSTM_F_SCALEN 1 - -# define LSTM_I_INF 2 -# define LSTM_I_OFF (LSTM_F_OFF+LSTM_F_INF) -# define LSTM_I_SCALE (0 + LSTM_I_OFF) -# define LSTM_I_SCALEN (1 + LSTM_I_OFF) - -# define LSTM_G_INF 2 -# define LSTM_G_OFF (LSTM_I_OFF+LSTM_I_INF) -# define LSTM_G_SCALE (0 + LSTM_G_OFF) -# define LSTM_G_SCALEN (1 + LSTM_G_OFF) - -# define LSTM_O_INF 2 -# define LSTM_O_OFF (LSTM_G_OFF+LSTM_G_INF) -# define LSTM_O_SCALE (0 + LSTM_O_OFF) -# define LSTM_O_SCALEN (1 + LSTM_O_OFF) - -# define LSTM_COUT_INF 6 -# define LSTM_COUT_OFF (LSTM_O_OFF+LSTM_O_INF) -# define LSTM_CIN_SCALE (0 + LSTM_COUT_OFF) -# define LSTM_CIN_SCALEN (1 + LSTM_COUT_OFF) -# define LSTM_COUT_SCALE (2 + LSTM_COUT_OFF) -# define LSTM_COUT_SCALEN (3 + LSTM_COUT_OFF) -# define LSTM_OUT_SCALE (4 + LSTM_COUT_OFF) -# define LSTM_OUT_SCALEN (5 + LSTM_COUT_OFF) - -# define LSTM_INT_INF 7 -# define LSTM_INT_OFF (LSTM_COUT_OFF+LSTM_COUT_INF) -# define LSTM_INT_A0 (0 + LSTM_INT_OFF) -# define LSTM_INT_B0 (2 + LSTM_INT_OFF) -# define LSTM_INT_C0 (4 + LSTM_INT_OFF) -# define LSTM_INT_Q (6 + LSTM_INT_OFF) - -# define LSTM_X_IN_INF 7 -# define LSTM_X_IN_OFF (LSTM_INT_OFF+LSTM_INT_INF) -# define LSTM_F_IN_SCALE (0 + LSTM_X_IN_OFF) -# define LSTM_F_IN_SCALEN (1 + LSTM_X_IN_OFF) -# define LSTM_I_IN_SCALE (2 + LSTM_X_IN_OFF) -# define LSTM_I_IN_SCALEN (3 + LSTM_X_IN_OFF) -# define LSTM_G_IN_SCALE (4 + LSTM_X_IN_OFF) -# define LSTM_G_IN_SCALEN (5 + LSTM_X_IN_OFF) -# define LSTM_O_IN_SCALE (6 + LSTM_X_IN_OFF) -# define LSTM_O_IN_SCALEN (7 + LSTM_X_IN_OFF) - - -def lstm_infos(gen, node, qrec): - i_qtype = internal_qtype(qrec) - contents = [] - comments = [] - for k, v in LSTM_INFOS_ORDER.items(): - info, comment = scale_infos(k, qrec.cache["r_2_%s_q" % k]) - contents.append(info) - comments.append(comment) - cin_scale = qrec.cache['cell_in_q'].qbiases[0] - cin_scalen = qrec.cache['cell_in_q'].qnorms[0] - cout_scale = qrec.cache['cell_out_q'].qbiases[0] - cout_scalen = qrec.cache['cell_out_q'].qnorms[0] - out_scale = qrec.cache['state_out_q'].qbiases[0] - out_scalen = qrec.cache['state_out_q'].qnorms[0] - comments.append(str.format("cin_scale: {} cin_scale_n: {} cout_scale: {} cout_scale_n: {}", - cin_scale, cin_scalen, cout_scale, cout_scalen,)) - - comments.append(str.format("out_scale: {} out_scale_n: {}", - out_scale, out_scalen)) - contents.append(np.array([cin_scale, cin_scalen, cout_scale, cout_scalen, - out_scale, out_scalen], dtype=np.int8)) - - three = i_qtype.quantize(np.array([3]))[0] - six = i_qtype.quantize(np.array([6]))[0] - sixth = i_qtype.quantize(np.array([1/6]))[0] - - comments.append(str.format("int_q: {} A0: {} B0: {} C0: {}", - i_qtype.q, six, three, sixth)) - contents.append(np.array([lowb(six), highb(six), - lowb(three), highb(three), - lowb(sixth), highb(sixth), i_qtype.q], - dtype=np.int8)) - - for k in LSTM_INFOS_ORDER.keys(): - info, comment = scale_infos(k, qrec.cache["i_2_%s_q" % k]) - contents.append(info) - comments.append(comment) - - cname, file_name = gen_constant(gen, node, node, INFOS) - const_info = ConstantInfo(file_name, QType.Pow2(bits=8, q=0, signed=True), - contents=np.hstack(tuple(contents))) - - gen.globals.append(GlobalArgInfo("int8", cname, - gen.opts['default_global_home_location'], - gen.opts['default_global_exec_location'], - const_info=const_info, - comment=" ".join(comments))) - -# define RNN_F_INF 8 -# define RNN_F_OFF 0 -# define RNN_F_SCALE 0 -# define RNN_F_SCALEN 1 -# define RNN_F_A0 2 -# define RNN_F_B0 3 - -# define RNN_F_IN_SCALE 4 -# define RNN_F_IN_SCALEN 5 -# define RNN_OUT_SCALE 6 -# define RNN_OUT_SCALEN 7 - - -def rnn_infos(gen, node, qrec): - i_state_q = qrec.in_qs[node.INPUT_NAMES.index('i_state')] - - contents = [] - comments = [] - - # info for activation (scale the act input to the proper scale) - info, comment = INFOS_FUNCS[node.activation]( - "f", qrec.cache['s_2_s_q'], i_state_q) - contents.append(info) - comments.append(comment) - - # info for input scaling (only used with non SameInputStateScale kernels) - info, comment = scale_infos("f", qrec.cache["i_2_a_q"]) - contents.append(info) - comments.append(comment) - - # info for scaling the activation out to out scale (only used for non Hard activations kernels) - info, comment = scale_infos("f", qrec.cache["s_2_o_q"]) - contents.append(info) - comments.append(comment) - - cname, file_name = gen_constant(gen, node, node, INFOS) - const_info = ConstantInfo(file_name, QType.Pow2(bits=8, q=0, signed=True), - contents=np.hstack(tuple(contents))) - - gen.globals.append(GlobalArgInfo("int8", cname, - gen.opts['default_global_home_location'], - gen.opts['default_global_exec_location'], - const_info=const_info, - comment=comment)) - -# define GRU_R_INF 4 -# define GRU_R_OFF 0 -# define GRU_R_INT_SCALE 0 -# define GRU_R_INT_SCALEN 1 -# define GRU_R_IN_SCALE 2 -# define GRU_R_IN_SCALEN 3 - -# define GRU_Z_INF 4 -# define GRU_Z_OFF (GRU_R_OFF+GRU_R_INF) -# define GRU_Z_INT_SCALE (0 + GRU_Z_OFF) -# define GRU_Z_INT_SCALEN (1 + GRU_Z_OFF) -# define GRU_Z_IN_SCALE (2 + GRU_Z_OFF) -# define GRU_Z_IN_SCALEN (3 + GRU_Z_OFF) - -# define GRU_HT_INF 2 -# define GRU_HT_OFF (GRU_Z_OFF+GRU_Z_INF) -# define GRU_HT_IN_SCALE (0 + GRU_HT_OFF) -# define GRU_HT_IN_SCALEN (1 + GRU_HT_OFF) - -# define GRU_H_INF 2 -# define GRU_H_OFF (GRU_HT_OFF+GRU_HT_INF) -# define GRU_H_INT_SCALE (0 + GRU_H_OFF) -# define GRU_H_INT_SCALEN (1 + GRU_H_OFF) - -# define GRU_INT_INF 3 -# define GRU_INT_OFF (GRU_H_OFF+GRU_H_INF) -# define GRU_INT_A0 (2 + GRU_INT_OFF) -# define GRU_INT_B0 (3 + GRU_INT_OFF) -# define GRU_INT_C0 (4 + GRU_INT_OFF) - -# define GRU_CELL_INFOS (GRU_R_INF+GRU_Z_INF+GRU_HT_INF+GRU_H_INF+GRU_INT_INF) - - -def gru_infos(gen, node, qrec): - i_qtype = internal_qtype(qrec) - contents = [] - comments = [] - r_to_int_scale = qrec.cache['r_WR_2_int_q'].qbiases[0] - r_to_int_scalen = qrec.cache['r_WR_2_int_q'].qnorms[0] - r_to_in_scale = qrec.cache['i_2_r_WR_q'].qbiases[0] - r_to_in_scalen = qrec.cache['i_2_r_WR_q'].qnorms[0] - z_to_int_scale = qrec.cache['z_WR_2_int_q'].qbiases[0] - z_to_int_scalen = qrec.cache['z_WR_2_int_q'].qnorms[0] - z_to_in_scale = qrec.cache['i_2_z_WR_q'].qbiases[0] - z_to_in_scalen = qrec.cache['i_2_z_WR_q'].qnorms[0] - ht_to_in_scale = qrec.cache['i_2_h_WR_q'].qbiases[0] - ht_to_in_scalen = qrec.cache['i_2_h_WR_q'].qnorms[0] - h_to_int_scale = qrec.cache['h_WR_2_int_q'].qbiases[0] - h_to_int_scalen = qrec.cache['h_WR_2_int_q'].qnorms[0] - - # GRU_R_INFOS - comments.append(str.format("r_to_int_scale: {} r_to_int_scalen: {} r_to_in_scale: {} r_to_in_scalen: {}", - r_to_int_scale, r_to_int_scalen, r_to_in_scale, r_to_in_scalen,)) - contents.append(np.array( - [r_to_int_scale, r_to_int_scalen, r_to_in_scale, r_to_in_scalen], dtype=np.int8)) - - # GRU_Z_INFOS - comments.append(str.format("z_to_int_scale: {} z_to_int_scalen: {} z_to_in_scale: {} z_to_in_scalen: {}", - z_to_int_scale, z_to_int_scalen, z_to_in_scale, z_to_in_scalen,)) - contents.append(np.array( - [z_to_int_scale, z_to_int_scalen, z_to_in_scale, z_to_in_scalen], dtype=np.int8)) - - # GRU_HT_INFOS - comments.append(str.format("ht_to_in_scale: {} ht_to_in_scalen: {}", - ht_to_in_scale, ht_to_in_scalen,)) - contents.append(np.array([ht_to_in_scale, ht_to_in_scalen], dtype=np.int8)) - - # GRU_H_INFOS - comments.append(str.format("h_to_int_scale: {} h_to_int_scalen: {}", - h_to_int_scale, h_to_int_scalen,)) - contents.append(np.array([h_to_int_scale, h_to_int_scalen], dtype=np.int8)) - - three = i_qtype.quantize(np.array([3]))[0] - six = i_qtype.quantize(np.array([6]))[0] - sixth = i_qtype.quantize(np.array([1/6]))[0] - - comments.append(str.format("int_q: {} A0: {} B0: {} C0: {}", - i_qtype.q, six, three, sixth)) - contents.append(np.array([lowb(six), highb(six), - lowb(three), highb(three), - lowb(sixth), highb(sixth), i_qtype.q], - dtype=np.int8)) - - cname, file_name = gen_constant(gen, node, node, INFOS) - const_info = ConstantInfo(file_name, QType.Pow2(bits=8, q=0, signed=True), - contents=np.hstack(tuple(contents))) - - gen.globals.append(GlobalArgInfo("int8", cname, - gen.opts['default_global_home_location'], - gen.opts['default_global_exec_location'], - const_info=const_info, - comment=" ".join(comments))) diff --git a/tools/nntool/generation/generators/kernels/__init__.py b/tools/nntool/generation/generators/kernels/__init__.py index 338706bf5..e0e464996 100644 --- a/tools/nntool/generation/generators/kernels/__init__.py +++ b/tools/nntool/generation/generators/kernels/__init__.py @@ -2,8 +2,6 @@ import pkgutil from .float16 import * -from .general import * -from .mult8 import * from .pow2 import * __all__ = [ diff --git a/tools/nntool/generation/generators/kernels/general/__init__.py b/tools/nntool/generation/generators/kernels/general/__init__.py deleted file mode 100644 index 5b372dc5a..000000000 --- a/tools/nntool/generation/generators/kernels/general/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -import os -import pkgutil - -__all__ = [ - modname for _, modname, _ in pkgutil.walk_packages( - path=[os.path.split(__file__)[0]]) -] diff --git a/tools/nntool/generation/generators/kernels/general/expressions_kernels_generator.py b/tools/nntool/generation/generators/kernels/general/expressions_kernels_generator.py deleted file mode 100644 index 197b3fa09..000000000 --- a/tools/nntool/generation/generators/kernels/general/expressions_kernels_generator.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import logging - -from generation.code_block import CodeBlock -from generation.generator_decorators import (QREC_MULT8, QREC_POW2, QREC_FLOAT, - generation_function) -from graph.types import ExpressionFusionParameters - -from ..autotiler_kernel import AutotilerKernel - -LOG = logging.getLogger("nntool." + __name__) - - -@generation_function("kernels", (ExpressionFusionParameters, ), qrec_types=(QREC_MULT8, QREC_POW2, QREC_FLOAT)) -def expressions_kernels_generator(gen, node, qrec, in_eparams, out_eparams, cname): - del in_eparams, out_eparams, qrec - func_name, _ = gen.expressions_get_names(node) - gen.kernels.append(ExpressionKernel(node.name, func_name + "_gen", cname)) - return True - - -class ExpressionKernel(AutotilerKernel): - def __init__(self, node_name, gen_name, cname): - self.node_name = node_name - self.gen_name = gen_name - self.cname = cname - - def code(self, code_block=None): - if code_block is None: - code_block = CodeBlock() - - code_block.comment("generator for {}", self.node_name) - - code_block.write('{}("{}");'.format(self.gen_name, self.cname)) - return code_block diff --git a/tools/nntool/generation/generators/kernels/general/imageformat_kernels_generator.py b/tools/nntool/generation/generators/kernels/general/imageformat_kernels_generator.py deleted file mode 100644 index a44b15173..000000000 --- a/tools/nntool/generation/generators/kernels/general/imageformat_kernels_generator.py +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import logging - -from generation.code_block import CodeBlock -from generation.generator_decorators import generation_function -from graph.types import ImageFormatParameters - -from ..autotiler_kernel import AutotilerKernel - -LOG = logging.getLogger("nntool." + __name__) - -KOP_NORM = {"RGB565_RGB888": "KOP_NORM_RGB565", - "RGB888": "KOP_NORM_RGB888", - "RGB16": "KOP_NORM_RGB16", - "BW8": "KOP_NORM_BW", - "BW16": "KOP_NORM_BW16"} - - -def gen_at_imageformat(code_block, name, in_dim, do_offset, kop_norm): - if in_dim.has_key('w') and in_dim.has_key('h'): - code_block.write('CNN_Norm("{}", {}, {}, {}, {});', - name, in_dim.w, in_dim.h, do_offset and "1" or "0", kop_norm) - else: - if len(in_dim.shape) > 2: - LOG.warning(f"Input Dim has no hints -> we are assuming HxWxC order in this case -> {in_dim.shape[0]}x{in_dim.shape[1]}x{in_dim.shape[2]}, for .onnx graphs may not be the case") - code_block.write('CNN_Norm("{}", {}, {}, {}, {});', - name, in_dim.shape[1], in_dim.shape[0], do_offset and "1" or "0", kop_norm) - - -@generation_function("kernels", (ImageFormatParameters, )) -def imageformat_kernels_generator(gen, node, qrec, in_eparams, out_eparams, cname): - del in_eparams, out_eparams, qrec - gen.kernels.append(ImageFormatKernel(cname, node)) - return True - - -class ImageFormatKernel(AutotilerKernel): - def __init__(self, cname, params): - self.in_dim = params.in_dims[0] - self.cname = cname - self.node_name = params.name - assert params.format_change in ("RGB565_RGB888", "RGB888", - "RGB16", "BW8", "BW16"), "unknown format change" - assert params.norm_func in ("OFFSET_INT8", "SHIFT_INT8", - "OUT_INT16"), "unknown normalization" - self.in_format = params.format_change - self.do_offset = params.norm_func == "OFFSET_INT8" - - def code(self, code_block=None): - if code_block is None: - code_block = CodeBlock() - - code_block.comment("generator for {}", self.node_name) - - gen_at_imageformat(code_block, self.cname, self.in_dim, - self.do_offset, KOP_NORM[self.in_format]) - return code_block diff --git a/tools/nntool/generation/generators/kernels/general/quantize_kernels_generator.py b/tools/nntool/generation/generators/kernels/general/quantize_kernels_generator.py deleted file mode 100644 index ee3bfd987..000000000 --- a/tools/nntool/generation/generators/kernels/general/quantize_kernels_generator.py +++ /dev/null @@ -1,106 +0,0 @@ -# # Copyright (C) 2020 GreenWaves Technologies, SAS - -# # This program is free software: you can redistribute it and/or modify -# # it under the terms of the GNU Affero General Public License as -# # published by the Free Software Foundation, either version 3 of the -# # License, or (at your option) any later version. - -# # This program is distributed in the hope that it will be useful, -# # but WITHOUT ANY WARRANTY; without even the implied warranty of -# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# # GNU Affero General Public License for more details. -# # You should have received a copy of the GNU Affero General Public License -# # along with this program. If not, see . - -# import logging -# import math -# import numpy as np -# from generation.at_types.gen_ctrl import GenCtrl -# from generation.code_block import CodeBlock -# from generation.generator_decorators import generation_function -# from graph.types.others import QuantizeParameters - -# from ..autotiler_kernel import AutotilerKernel - -# LOG = logging.getLogger("nntool." + __name__) - -# @generation_function("kernels", (QuantizeParameters,)) -# def quantize_kernel_generator(gen, node, qrec, in_eparams, out_eparams, cname): -# del in_eparams, out_eparams -# in_q = qrec.in_qs[0] -# out_q = qrec.out_qs[0] -# if in_q.dtype == np.int8 and out_q.dtype == np.uint8: -# if not np.allclose(in_q.scale, out_q.scale): -# LOG.warning('quantize kernel generator only supports type changes not scale') -# return False -# if not np.all(in_q.zero_point == (out_q.zero_point - 128)): -# LOG.warning('quantize kernel generator cannot move zero point') -# return False -# qrec.cache['kernel_type'] = 'KOP_CONVERT_FP_FP_ZEROPOINT' -# gen.kernels.append( -# ConversionKernel(node.name, cname, 1, -1, node.in_dims[0].size(), 'KOP_CONVERT_FP_FP_ZEROPOINT') -# ) -# return True -# if in_q.dtype == np.uint8 and out_q.dtype == np.int8: -# if not np.all((in_q.zero_point - 128) == out_q.zero_point): -# LOG.warning('quantize kernel generator cannot move zero point') -# return False -# qrec.cache['kernel_type'] = 'KOP_CONVERT_FP_FP_ZEROPOINT' -# gen.kernels.append( -# ConversionKernel(node.name, cname, -1, 1, node.in_dims[0].size(), 'KOP_CONVERT_FP_FP_ZEROPOINT') -# ) -# return True -# if in_q.dtype == np.int8 and out_q.dtype == np.int16: -# if np.allclose(in_q.scale, (out_q.scale * np.power(2, 8)), atol=0.0001): -# qrec.cache['kernel_type'] = 'KOP_CONVERT_FP_FP' -# gen.kernels.append( -# ConversionKernel(node.name, cname, 1, 2, node.in_dims[0].size(), 'KOP_CONVERT_FP_FP') -# ) -# else: -# qrec.cache['kernel_type'] = 'KOP_CONVERT_FP_FP_SCALE' -# gen.kernels.append( -# ConversionKernel(node.name, cname, 1, 2, node.in_dims[0].size(), 'KOP_CONVERT_FP_FP_SCALE') -# ) -# return True -# if in_q.dtype == np.int16 and out_q.dtype == np.int8: -# if np.allclose(out_q.scale, (in_q.scale * np.power(2, 8)), atol=0.0001): -# qrec.cache['kernel_type'] = 'KOP_CONVERT_FP_FP' -# gen.kernels.append( -# ConversionKernel(node.name, cname, 2, 1, node.in_dims[0].size(), 'KOP_CONVERT_FP_FP') -# ) -# else: -# qrec.cache['kernel_type'] = 'KOP_CONVERT_FP_FP_SCALE' -# gen.kernels.append( -# ConversionKernel(node.name, cname, 2, 1, node.in_dims[0].size(), 'KOP_CONVERT_FP_FP_SCALE') -# ) -# return True - - - - -# return True - -# class ConversionKernel(AutotilerKernel): -# def __init__(self, node_name, cname, in_type, out_type, size, kop, at_ver=3, gen_ctrl=None): -# if gen_ctrl is None: -# self.gen_ctrl = gen_ctrl = GenCtrl(None, cname=cname) -# else: -# gen_ctrl.cname = cname -# self.gen_ctrl = gen_ctrl - -# self.cname = cname -# self.node_name = node_name -# self.at_ver = at_ver -# self.in_type = in_type -# self.out_type = out_type -# self.size = size -# self.kop = kop - -# def code(self, code_block=None): -# if code_block is None: -# code_block = CodeBlock() - -# code_block.comment("generator for {}", self.node_name) -# code_block.write(f'CNN_Convert("{self.cname}", {self.in_type}, {self.out_type}, {self.size}, {self.kop});') - -# return code_block diff --git a/tools/nntool/generation/generators/kernels/general/resizer_kernel_generator.py b/tools/nntool/generation/generators/kernels/general/resizer_kernel_generator.py deleted file mode 100644 index 439282e95..000000000 --- a/tools/nntool/generation/generators/kernels/general/resizer_kernel_generator.py +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import logging - -from generation.code_block import CodeBlock -from generation.generator_decorators import generation_function -from graph.types import ResizerParameters - -from ..autotiler_kernel import AutotilerKernel - -LOG = logging.getLogger("nntool." + __name__) - -RESIZE_KOP = {"bilinear": "KOP_BILINEAR_RESIZE", - "nearest_neighbor": "KOP_NEAREST_NEIGHBOR_RESIZE"} - - -def gen_at_resizer(code_block, name, in_dim, new_shape, inout_t, resize_kop, q16mode, fp16): - if in_dim.has_key('w') and in_dim.has_key('h'): - in_dim_w, in_dim_h, in_dim_c = in_dim.w, in_dim.h, in_dim.c - else: - in_dim_w, in_dim_h, in_dim_c = in_dim.shape[2], in_dim.shape[1], in_dim.shape[0] - - win, wout = in_dim_w, new_shape[1] - hin, hout = in_dim_h, new_shape[0] - chin = in_dim_c - if in_dim_w == 1 and in_dim_h == 1: - # If both are 1s the autotiler cannot solve the tiling problem - # --> exchange channels with one of the HW dimensions (the one that does not change) - if 1 in new_shape: - idx_one = new_shape.index(1) - win, wout = (in_dim_w, new_shape[1]) if idx_one == 0 else (in_dim_c, in_dim_c) - hin, hout = (in_dim_h, new_shape[0]) if idx_one == 1 else (in_dim_c, in_dim_c) - chin = 1 - else: - # If both HW change from 1x1 to HxW this is not going to work - LOG.warning(f"Resize Node {name} has 1x1xc input but resizes both HW dimension, could not work in autotiler") - - if fp16: - GenKernel = "GenerateResizeMultiChannel_fp16" - else: - GenKernel = "GenerateResizeMultiChannelQ16" if q16mode else "GenerateResizeMultiChannel" - code_block.write('{}("{}", {}, {}, {}, {}, {}, {}, {});', GenKernel, - name, win, hin, wout, hout, chin, inout_t, resize_kop) - - -@generation_function("kernels", (ResizerParameters, )) -def resize_kernels_generator(gen, node, qrec, in_eparams, out_eparams, cname): - del in_eparams, out_eparams - gen.kernels.append(ResizeKernel(cname, node, qrec)) - return True - - -class ResizeKernel(AutotilerKernel): - def __init__(self, cname, params, qrec): - self.in_dim = params.in_dims[0] - self.cname = cname - self.node_name = params.name - self.inout_type = "SIGNED_INOUT" if qrec.in_qs[0].signed else "UNSIGNED_INOUT" - self.type = params.op_name - self.new_shape = params.new_shape - self.q16 = qrec.in_qs[0].dtype_bits == 16 - self.fp16 = qrec.in_qs[0].is_floating - - def code(self, code_block=None): - if code_block is None: - code_block = CodeBlock() - - code_block.comment("generator for {}", self.node_name) - - gen_at_resizer(code_block, self.cname, self.in_dim, - self.new_shape, self.inout_type, RESIZE_KOP[self.type], - self.q16, self.fp16) - return code_block diff --git a/tools/nntool/generation/generators/kernels/general/three_d_transpose_kernels_generator.py b/tools/nntool/generation/generators/kernels/general/three_d_transpose_kernels_generator.py deleted file mode 100644 index 9108dd417..000000000 --- a/tools/nntool/generation/generators/kernels/general/three_d_transpose_kernels_generator.py +++ /dev/null @@ -1,163 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import logging - -from generation.at_types.gen_ctrl import GenCtrl -from generation.code_block import CodeBlock -from generation.generator_decorators import generation_function, QREC_MULT8, QREC_POW2, QREC_FLOAT -from generation.gen_utils import at_bits -from graph.types import TransposeParameters - -from ..autotiler_kernel import AutotilerKernel - -LOG = logging.getLogger("nntool." + __name__) - - -@generation_function("kernels", (TransposeParameters, ), qrec_types=(QREC_MULT8, QREC_FLOAT, QREC_POW2)) -def three_d_transpose_kernels_generator(gen, node, qrec, in_eparams, out_eparams, cname): - del in_eparams, out_eparams - real_in_shape, real_transpose = node.real_shape() - if len(real_transpose) <= 1: - return True - if len(real_transpose) == 2: - gen.kernels.append(TwoDTransposeKernel(cname, node, real_in_shape, - real_transpose, qrec, at_ver=gen.opts['at_ver'])) - elif len(real_transpose) == 3: - gen.kernels.append(ThreeDTransposeKernel(cname, node, real_in_shape, - real_transpose, qrec, at_ver=gen.opts['at_ver'])) - else: - raise NotImplementedError("only 2D or 3D transposes are currently supported") - LOG.info("generating for transpose in %s out %s trans %s", - node.in_dims[0], node.out_dims[0], node.transpose) - return True - -# extern int CNN_MatTranspose( -# char *Name, -# CNN_GenControl_T *Ctrl, -# int DataSize, -# int InFeat, -# int Width, -# int Height, -# KernelOper_T MatTransOper -# ); -def gen_at_2d_transpose(code_block, name, datasize, - in_shape, gen_ctrl=None, - at_ver=3): - code_block.write('CNN_MatTranspose("{}", {}, {}, 1, {}, {}, KOP_MATTRANSP);', - name, gen_ctrl, datasize, in_shape[1], in_shape[0]) - - -class TwoDTransposeKernel(AutotilerKernel): - def __init__(self, cname, params, real_in_shape, real_transpose, qrec, gen_ctrl=None, at_ver=3): - if gen_ctrl is None: - self.gen_ctrl = GenCtrl(None, cname=cname) - else: - gen_ctrl.cname = cname - self.gen_ctrl = gen_ctrl - - if qrec.out_qs[0].is_floating: - self.gen_ctrl.float_dump = 1 - - self.in_q = qrec.in_qs[0] - self.out_q = qrec.out_qs[0] - self.in_shape = real_in_shape - self.in_dim = params.in_dims[0] - self.out_dim = params.out_dims[0] - self.real_transpose = real_transpose - self.cname = cname - self.node_name = params.name - self.at_ver = at_ver - - def code(self, code_block=None): - if code_block is None: - code_block = CodeBlock() - - code_block.comment("generator for {}", self.node_name) - code_block.comment("transpose from {} to {} ({})", self.in_dim, - self.out_dim, self.real_transpose) - - if not self.gen_ctrl.is_unmodified: - self.gen_ctrl.gen_ctrl_decl(code_block) - gen_ctrl = self.gen_ctrl.ctrl_name - else: - gen_ctrl = "0" - - gen_at_2d_transpose(code_block, self.cname, - abs(at_bits(self.in_q)), self.in_shape, gen_ctrl=gen_ctrl) - return code_block - - -# extern int CNN_3DTensorPermute( -# char *Name, -# CNN_GenControl_T *Ctrl, -# int Size, -# int InFeat, -# int Width, -# int Height, -# KernelOper_T MatPermOper -# ); - -def gen_at_3d_transpose(code_block, name, datasize, - in_shape, permop, gen_ctrl=None, - at_ver=3): - - code_block.write('CNN_3DTensorPermute("{}", {}, {}, {}, {}, {}, {});', - name, gen_ctrl, datasize, in_shape[0], in_shape[2], in_shape[1], - permop) - - -class ThreeDTransposeKernel(AutotilerKernel): - def __init__(self, cname, params, real_in_shape, real_transpose, qrec, gen_ctrl=None, at_ver=3): - if gen_ctrl is None: - self.gen_ctrl = GenCtrl(None, cname=cname) - else: - gen_ctrl.cname = cname - self.gen_ctrl = gen_ctrl - - if qrec.out_qs[0].is_floating: - self.gen_ctrl.float_dump = 1 - - self.in_shape = real_in_shape - dim_names = ['C', 'H', 'W'] - perm = [dim_names[i] for i in real_transpose] - self.permop = "KOP_MATPERM_CHW2{}".format("".join(perm)) - self.real_transpose = real_transpose - - self.in_q = qrec.in_qs[0] - self.out_q = qrec.out_qs[0] - self.in_dim = params.in_dims[0] - self.out_dim = params.out_dims[0] - self.cname = cname - self.node_name = params.name - self.at_ver = at_ver - - def code(self, code_block=None): - if code_block is None: - code_block = CodeBlock() - - - code_block.comment("generator for {}", self.node_name) - code_block.comment("transpose from {} to {} ({})", self.in_dim, - self.out_dim, self.real_transpose) - - if not self.gen_ctrl.is_unmodified: - self.gen_ctrl.gen_ctrl_decl(code_block) - gen_ctrl = self.gen_ctrl.ctrl_name - else: - gen_ctrl = "0" - - gen_at_3d_transpose(code_block, self.cname, abs(at_bits(self.in_q)), - self.in_shape, self.permop, gen_ctrl=gen_ctrl) - return code_block diff --git a/tools/nntool/generation/generators/kernels/mult8/__init__.py b/tools/nntool/generation/generators/kernels/mult8/__init__.py deleted file mode 100644 index 5b372dc5a..000000000 --- a/tools/nntool/generation/generators/kernels/mult8/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -import os -import pkgutil - -__all__ = [ - modname for _, modname, _ in pkgutil.walk_packages( - path=[os.path.split(__file__)[0]]) -] diff --git a/tools/nntool/generation/generators/kernels/mult8/conv_pool_relu_kernels_generator.py b/tools/nntool/generation/generators/kernels/mult8/conv_pool_relu_kernels_generator.py deleted file mode 100644 index 662d069ca..000000000 --- a/tools/nntool/generation/generators/kernels/mult8/conv_pool_relu_kernels_generator.py +++ /dev/null @@ -1,342 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -from graph.types.pooling import PoolingParameters -import logging - -from generation.at_types.at_params import (NO_ACTIVATION, NO_CONV, NO_POOL, - ConvATParam, GroupedConvATParam, - gen_active_at_params, - gen_conv_at_params, - gen_pool_at_params) -from generation.at_types.gen_ctrl import GenCtrl -from generation.code_block import CodeBlock -from generation.generator_decorators import (QREC_MULT8, - generation_function) -from graph.dim import PadDim -from graph.types import (ActivationParameters, Conv2DParameters, - ConvFusionParameters) -from utils.node_id import NodeId - -from ..autotiler_kernel import (AutotilerKernel, gen_include_paths, - gen_includes, gen_sources, - kernel_include_paths, kernel_includes, - kernel_sources) - -LOG = logging.getLogger("nntool." + __name__) - - -@generation_function("kernels", - (Conv2DParameters, - ConvFusionParameters, - ActivationParameters), - qrec_types=(QREC_MULT8,)) -def conv_pool_relu_kernels_generator(gen, node, qrec, in_eparams, out_eparams, cname) -> bool: - del in_eparams, out_eparams - if isinstance(node, Conv2DParameters): - gen.kernels.append(ConvPoolReluKernel(node.name, cname, node, qrec, None, - None, None, None, at_ver=gen.opts['at_ver'], - gen_ctrl=node.get_gen_ctrl(), force_relu=gen.force_relu)) - # We want to match the pool_act generator for PoolingParameters - # elif isinstance(node, PoolingParameters): - # gen.kernels.append(ConvPoolReluKernel(node.name, cname, None, None, - # node, qrec, None, None, at_ver=gen.opts['at_ver'], - # gen_ctrl=node.get_gen_ctrl())) - elif isinstance(node, ActivationParameters): - # self.set_in_out_bindings(in_eparams, out_eparams, cname, node, qrec) - gen.kernels.append(ConvPoolReluKernel(node.name, cname, None, None, - None, None, node, qrec, at_ver=gen.opts['at_ver'], - gen_ctrl=node.get_gen_ctrl(), force_relu=gen.force_relu)) - elif isinstance(node, ConvFusionParameters): - cnodes = node.contained_nodes() - quants = [gen.G.quantization[NodeId(node, fnode)] for fnode in cnodes] - if node.fusion_type == "conv_active_pool": - gen.kernels.append(ConvPoolReluKernel(node.name, cname, cnodes[0], quants[0], cnodes[2], quants[2], - cnodes[1], quants[1], at_ver=gen.opts['at_ver'], - gen_ctrl=node.get_gen_ctrl(), force_relu=gen.force_relu)) - elif node.fusion_type == "conv_pool_active": - gen.kernels.append(ConvPoolReluKernel(node.name, cname, cnodes[0], quants[0], cnodes[1], quants[1], - cnodes[2], quants[2], at_ver=gen.opts['at_ver'], - gen_ctrl=node.get_gen_ctrl(), force_relu=gen.force_relu)) - elif node.fusion_type == "conv_active": - gen.kernels.append(ConvPoolReluKernel(node.name, cname, cnodes[0], quants[0], None, None, cnodes[1], - quants[1], at_ver=gen.opts['at_ver'], - gen_ctrl=node.get_gen_ctrl(), force_relu=gen.force_relu)) - elif node.fusion_type == "conv_pool": - gen.kernels.append(ConvPoolReluKernel(node.name, cname, cnodes[0], quants[0], cnodes[1], quants[1], None, - None, at_ver=gen.opts['at_ver'], gen_ctrl=node.get_gen_ctrl(), - force_relu=gen.force_relu)) - elif node.fusion_type == "pool_active" and isinstance(cnodes[0], PoolingParameters): - gen.kernels.append(ConvPoolReluKernel(node.name, cname, None, None, cnodes[0], quants[0], - cnodes[1], quants[1], at_ver=gen.opts['at_ver'], - gen_ctrl=node.get_gen_ctrl(), force_relu=gen.force_relu)) - else: - return False - else: - return False - return True - - -def gen_cnn_conv_pool_act_qs8(code_block, cname, - in_feat, out_feat, width, height, bias_size, - conv_oper, fcx, fcy, dcx, dcy, scx, scy, conv_pad, - pool_oper, fpx, fpy, dpx, dpy, spx, spy, pool_pad, - act_oper, gen_ctrl, at_ver=3): - del at_ver - code_block.write('CNN_ConvolutionPoolAct_SQ8("{}", {}, {}, {}, {}, {}, {}, {},', - cname, - gen_ctrl, - bias_size, - 1, - in_feat, - out_feat, - width, - height) - code_block.indent() - code_block.write('{}, {}, {}, {}, {}, {}, {}, {},', - conv_oper, fcx, fcy, dcx, dcy, scx, scy, conv_pad) - code_block.write('{}, {}, {}, {}, {}, {}, {}, {},', - pool_oper, fpx, fpy, dpx, dpy, spx, spy, pool_pad) - code_block.write('{});', act_oper) - code_block.deindent() - - -def gen_cnn_conv_pool_act_ne16_qs8(code_block, cname, in_size, out_size, filter_bits, - in_feat, out_feat, width, height, bias_size, - conv_oper, fcx, fcy, dcx, dcy, scx, scy, conv_pad, pad_value, - pool_oper, fpx, fpy, dpx, dpy, spx, spy, pool_pad, - act_oper, gen_ctrl, at_ver=3): - del at_ver - code_block.write('CNN_ConvolutionNE16("{}", {}, {}, {}, {}, {}, {}, {}, {}, {}, {},', - cname, - gen_ctrl, - in_size, - out_size, - bias_size, - 1, - filter_bits, - in_feat, - out_feat, - width, - height) - code_block.indent() - code_block.write('{}, {}, {}, {}, {}, {}, {}, {}, {},', - conv_oper, fcx, fcy, dcx, dcy, scx, scy, conv_pad, pad_value) - code_block.write('{}, {}, {}, {}, {}, {}, {}, {},', - pool_oper, fpx, fpy, dpx, dpy, spx, spy, pool_pad) - code_block.write('{});', act_oper) - code_block.deindent() - - -def gen_cnn_grp_conv_pool_act_qs8(code_block, cname, - grp_in, grp_out, in_feat, out_feat, width, height, bias_size, - conv_oper, fcx, fcy, dcx, dcy, scx, scy, conv_pad, - pool_oper, fpx, fpy, dpx, dpy, spx, spy, pool_pad, - act_oper, gen_ctrl, at_ver=3): - del at_ver - code_block.write('CNN_GroupedConvolutionPoolAct_SQ8("{}", {}, {}, {}, {}, {}, {}, {}, {}, {},', - cname, - gen_ctrl, - grp_in, - grp_out, - bias_size, - 1, - in_feat, - out_feat, - width, - height) - code_block.indent() - code_block.write('{}, {}, {}, {}, {}, {}, {}, {},', - conv_oper, fcx, fcy, dcx, dcy, scx, scy, conv_pad) - code_block.write('{}, {}, {}, {}, {}, {}, {}, {},', - pool_oper, fpx, fpy, dpx, dpy, spx, spy, pool_pad) - code_block.write('{});', act_oper) - code_block.deindent() - - -class ConvPoolReluKernel(AutotilerKernel): - def __init__(self, node_name, cname, conv_params, conv_q, - pool_params, pool_q, act_params, act_q, at_ver=3, - gen_ctrl=None, force_relu=True): - self.ne16 = False - if gen_ctrl is None: - self.gen_ctrl = gen_ctrl = GenCtrl(None, cname=cname) - else: - gen_ctrl.cname = cname - self.gen_ctrl = gen_ctrl - self.hwc = False - self.is_dw_conv = False - - in_q = filter_q = out_q = bias_q = mul_biases_q = None - in_dim = out_dim = None - pad_compatibilities = [] - if conv_params is not None: - self.ne16 = conv_q.cache.get('ne16') - if not self.ne16 and conv_params.ker_in_order and conv_params.ker_in_order[0] == ["h", "w", "c"]: - self.hwc = True - self.gen_ctrl.hwc = 1 - at_conv_params = gen_conv_at_params( - conv_params, pad_compatibilities) - in_dim = conv_params.in_dims[0] - out_dim = conv_params.out_dims[0] - # Set ENABLEIM2COL on 1x1 filters by default - if not self.ne16 and not self.hwc and conv_params.filter.h == 1 and conv_params.filter.w == 1 and gen_ctrl.enableim2col is None: - gen_ctrl.enableim2col = 1 - filter_q = conv_q.in_qs[1] - in_q = conv_q.in_qs[0] - out_q = conv_q.out_qs[0] - bias_q = conv_q.in_qs[2] - if conv_params.has_mul_bias: - mul_biases_q = conv_q.mul_biases_q - self.pad_val = in_q.zero_point - else: - at_conv_params = NO_CONV - - if pool_params is not None: - if pool_params.ker_in_order and pool_params.ker_in_order[0] == ["h", "w", "c"]: - self.hwc = True - self.gen_ctrl.hwc = 1 - at_pool_params = gen_pool_at_params( - pool_params, pad_compatibilities) - if in_dim is None: - in_dim = pool_params.in_dims[0] - out_dim = pool_params.out_dims[0] - if in_q is None: - in_q = pool_q.in_qs[0] - out_q = pool_q.out_qs[0] - else: - at_pool_params = NO_POOL - - if act_params is not None: - if act_params.ker_in_order and act_params.ker_in_order[0] == ["h", "w", "c"]: - self.hwc = True - self.gen_ctrl.hwc = 1 - if in_q is None: - in_q = act_q.in_qs[0] - at_act_params = gen_active_at_params( - act_params, force_relu=force_relu, asymmetric=act_q.in_qs[0].zero_point != 0) - if in_dim is None: - in_dim = act_params.in_dims[0].expand_to_chw() - if out_dim is None: - out_dim = act_params.out_dims[0].expand_to_chw() - out_q = act_q.out_qs[0] - - else: - at_act_params = NO_ACTIVATION - - if pad_compatibilities: - reduction = PadDim.pad_compatibility_reduce(*pad_compatibilities, - "convolution padding is not compatible with pool padding") - if not reduction[2]: # default is balanced pad left - at_pad_ctrl = next(i for i, v in enumerate(reduction) if v) - LOG.debug("%s: generating pad control block", node_name) - self.gen_ctrl.PadType = at_pad_ctrl - self.in_dim = in_dim - self.out_dim = out_dim - self.in_q = in_q - self.bias_q = bias_q - self.out_q = out_q - self.filter_q = filter_q - self.mul_biases_q = mul_biases_q - self.at_act_params = at_act_params - self.at_pool_params = at_pool_params - self.at_conv_params = at_conv_params - self.cname = cname - self.node_name = node_name - self.at_ver = at_ver - - def code(self, code_block=None): - if code_block is None: - code_block = CodeBlock() - - code_block.comment("generator for {}", self.node_name) - - if not self.gen_ctrl.is_unmodified: - self.gen_ctrl.gen_ctrl_decl(code_block) - gen_ctrl = self.gen_ctrl.ctrl_name - else: - gen_ctrl = "0" - - if self.at_conv_params == NO_CONV: - pp = self.at_pool_params - ap = self.at_act_params - gen_cnn_conv_pool_act_qs8(code_block, self.cname, self.in_dim.c, - self.out_dim.c, self.in_dim.w, self.in_dim.h, - self.bias_q.dtype_bits//8 if self.bias_q is not None else 0, - "KOP_NONE", 0, 0, 0, 0, 0, 0, 0, - pp.PoolOper, pp.Fpx, pp.Fpy, pp.Dpx, pp.Dpy, - pp.Spx, pp.Spy, pp.PoolPad, - ap.ReLUOper, gen_ctrl, - at_ver=self.at_ver) - else: - cp = self.at_conv_params - pp = self.at_pool_params - ap = self.at_act_params - if isinstance(self.at_conv_params, ConvATParam): - if self.ne16: - LOG.debug("NE16 !!! %s: conv pool relu inq %s outq %s control block", - self.node_name, self.in_q, self.out_q) - gen_cnn_conv_pool_act_ne16_qs8(code_block, self.cname, - self.in_q.dtype_bits//8 if self.in_q.signed else -self.in_q.dtype_bits//8, - self.out_q.dtype_bits//8 if self.out_q.signed else -self.out_q.dtype_bits//8, - self.filter_q.bits, self.in_dim.c, self.out_dim.c, self.in_dim.w, - self.in_dim.h, self.bias_q.dtype_bits//8, - cp.ConvOper, cp.Fcx, cp.Fcy, cp.Dcx, cp.Dcy, - cp.Scx, cp.Scy, cp.ConvPad, self.in_q.zero_point[0], - pp.PoolOper, pp.Fpx, pp.Fpy, pp.Dpx, pp.Dpy, - pp.Spx, pp.Spy, pp.PoolPad, - ap.ReLUOper, gen_ctrl, - at_ver=self.at_ver) - else: - if self.in_dim.w == 1 and self.at_conv_params.Fcx == 1: - LOG.debug("%s: conv pool relu inq %s outq %s control block", - self.node_name, self.in_q, self.out_q) - gen_cnn_conv_pool_act_qs8(code_block, self.cname, self.in_dim.c, - self.out_dim.c, self.in_dim.h, 1, - self.bias_q.dtype_bits//8, - cp.ConvOper, cp.Fcy, 1, cp.Dcy, 1, - cp.Scy, 1, cp.ConvPad, - pp.PoolOper, pp.Fpx, pp.Fpy, pp.Dpx, pp.Dpy, - pp.Spx, pp.Spy, pp.PoolPad, - ap.ReLUOper, gen_ctrl, - at_ver=self.at_ver) - else: - LOG.debug("%s: conv pool relu inq %s outq %s control block", - self.node_name, self.in_q, self.out_q) - gen_cnn_conv_pool_act_qs8(code_block, self.cname, self.in_dim.c, - self.out_dim.c, self.in_dim.w, self.in_dim.h, - self.bias_q.dtype_bits//8, - cp.ConvOper, cp.Fcx, cp.Fcy, cp.Dcx, cp.Dcy, - cp.Scx, cp.Scy, cp.ConvPad, - pp.PoolOper, pp.Fpx, pp.Fpy, pp.Dpx, pp.Dpy, - pp.Spx, pp.Spy, pp.PoolPad, - ap.ReLUOper, gen_ctrl, - at_ver=self.at_ver) - elif isinstance(self.at_conv_params, GroupedConvATParam): - LOG.debug("%s: grouped mulconv pool relu inq %s outq %s control block", - self.node_name, self.in_q, self.out_q) - gen_cnn_grp_conv_pool_act_qs8(code_block, self.cname, cp.GroupIn, cp.GroupOut, - self.in_dim.c, - self.out_dim.c, self.in_dim.w, self.in_dim.h, - self.bias_q.dtype_bits//8, - cp.ConvOper, cp.Fcx, cp.Fcy, cp.Dcx, cp.Dcy, - cp.Scx, cp.Scy, cp.ConvPad, - pp.PoolOper, pp.Fpx, pp.Fpy, pp.Dpx, pp.Dpy, - pp.Spx, pp.Spy, pp.PoolPad, - ap.ReLUOper, gen_ctrl, - at_ver=self.at_ver) - else: - raise ValueError('Internal error') - - return code_block diff --git a/tools/nntool/generation/generators/kernels/mult8/global_pool_kernels_generator.py b/tools/nntool/generation/generators/kernels/mult8/global_pool_kernels_generator.py deleted file mode 100644 index 19689c8d1..000000000 --- a/tools/nntool/generation/generators/kernels/mult8/global_pool_kernels_generator.py +++ /dev/null @@ -1,119 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import logging -from functools import reduce -from utils.node_id import NodeId - -from generation.at_types.at_params import NO_ACTIVATION, gen_active_at_params -from generation.at_types.gen_ctrl import GenCtrl -from generation.code_block import CodeBlock -from generation.generator_decorators import QREC_MULT8, generation_function -from graph.types import (ActivationFusionBase, GlobalAveragePoolParameters, - GlobalMaxPoolParameters, GlobalPoolingParameters, - GlobalSumPoolParameters) -from utils.largest_factor import balanced_divisors - -from ..autotiler_kernel import (AutotilerKernel, gen_include_paths, - gen_includes, gen_sources, - kernel_include_paths, kernel_includes, - kernel_sources) -from ..pow2.global_pool_kernels_generator import gen_globalpool_at_params - -LOG = logging.getLogger("nntool." + __name__) - - -@generation_function("kernels", (GlobalAveragePoolParameters, GlobalMaxPoolParameters, GlobalSumPoolParameters, ActivationFusionBase), qrec_types=(QREC_MULT8, )) -def global_pool_kernels_generator(gen, node, qrec, in_eparams, out_eparams, cname): - del in_eparams, out_eparams, qrec - if isinstance(node, ActivationFusionBase): - cnodes = node.contained_nodes() - if isinstance(cnodes[0], GlobalPoolingParameters): - act_q = gen.G.quantization[NodeId(node, cnodes[1])] - gen.kernels.append(GlobalPoolKernel( - node.name, cname, cnodes[0], cnodes[1], act_q, at_ver=gen.opts['at_ver'], force_relu=gen.force_relu)) - return True - return False - gen.kernels.append(GlobalPoolKernel(node.name, cname, node, - None, at_ver=gen.opts['at_ver'], force_relu=gen.force_relu)) - return True - - -def gen_cnn_globalpool_sq8(code_block, cname, ctrl, feat, width, height, pooloper, actoper): - code_block.write('CNN_GlobalPoolAct_SQ8("{}", {}, {}, {}, {}, {}, {});'.format(cname, ctrl, - feat, width, - height, pooloper, - actoper)) - - -@kernel_sources( - '$(TILER_CNN_KERNEL_PATH_SQ8)/CNN_Pooling_SQ8.c') -@kernel_include_paths( - '$(TILER_CNN_KERNEL_PATH)', - '$(TILER_CNN_KERNEL_PATH_SQ8)') -@kernel_includes( - 'CNN_BasicKernels_SQ8.h') -@gen_sources( - '$(TILER_CNN_GENERATOR_PATH)/CNN_Generator_Util.c', - '$(TILER_CNN_GENERATOR_PATH_SQ8)/CNN_Generators_SQ8.c') -@gen_include_paths( - '$(TILER_CNN_GENERATOR_PATH)', - '$(TILER_CNN_GENERATOR_PATH_SQ8)') -@gen_includes( - 'CNN_Generators_SQ8.h') -class GlobalPoolKernel(AutotilerKernel): - def __init__(self, node_name, cname, pool_params, act_params, act_q=None, gen_ctrl=None, at_ver=3, force_relu=True): - if gen_ctrl is None: - self.gen_ctrl = GenCtrl(None, cname=cname) - else: - gen_ctrl.cname = cname - self.gen_ctrl = gen_ctrl - if pool_params.ker_in_order and pool_params.ker_in_order[0] == ["h", "w", "c"]: - self.gen_ctrl.hwc = 1 - - if act_params is not None: - self.at_act_params = gen_active_at_params( - act_params, force_relu=force_relu, - asymmetric=act_q.in_qs[0].zero_point != 0) - else: - self.at_act_params = NO_ACTIVATION - - self.at_globalpool_params = gen_globalpool_at_params(pool_params) - in_dim = pool_params.in_dims[0] - reduce_sz = reduce(lambda x, y: x * y, (sz for idx, sz in enumerate(in_dim.shape) - if idx not in pool_params.axis), 1) - #self.c = in_dim.size()/reduce_sz - self.c = reduce_sz - (self.h, self.w) = balanced_divisors(in_dim.size()/reduce_sz) - self.cname = cname - self.node_name = node_name - self.at_ver = at_ver - - def code(self, code_block=None): - if code_block is None: - code_block = CodeBlock() - - code_block.comment("generator for {}", self.node_name) - - if not self.gen_ctrl.is_unmodified: - self.gen_ctrl.gen_ctrl_decl(code_block) - gen_ctrl = self.gen_ctrl.ctrl_name - else: - gen_ctrl = "0" - - gen_cnn_globalpool_sq8(code_block, self.cname, gen_ctrl, self.c, - self.h, self.w, - self.at_globalpool_params.GlobalPoolOper, - self.at_act_params.ReLUOper) - return code_block diff --git a/tools/nntool/generation/generators/kernels/mult8/linear_relu_kernels_generator.py b/tools/nntool/generation/generators/kernels/mult8/linear_relu_kernels_generator.py deleted file mode 100644 index d94b4af8d..000000000 --- a/tools/nntool/generation/generators/kernels/mult8/linear_relu_kernels_generator.py +++ /dev/null @@ -1,172 +0,0 @@ -# # Copyright (C) 2020 GreenWaves Technologies, SAS - -# # This program is free software: you can redistribute it and/or modify -# # it under the terms of the GNU Affero General Public License as -# # published by the Free Software Foundation, either version 3 of the -# # License, or (at your option) any later version. - -# # This program is distributed in the hope that it will be useful, -# # but WITHOUT ANY WARRANTY; without even the implied warranty of -# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# # GNU Affero General Public License for more details. -# # You should have received a copy of the GNU Affero General Public License -# # along with this program. If not, see . - -# import logging - -# from generation.at_types.at_params import (NO_ACTIVATION, gen_active_at_params, -# gen_linear_at_params) -# from generation.at_types.gen_ctrl import GenCtrl -# from generation.code_block import CodeBlock -# from generation.generator_decorators import (QREC_MULT8, -# generation_function) -# from graph.types import LinearFusionParameters, FcParameters -# from utils.node_id import NodeId - -# from ..autotiler_kernel import (AutotilerKernel, gen_include_paths, -# gen_includes, gen_sources, -# kernel_include_paths, kernel_includes, -# kernel_sources) - -# LOG = logging.getLogger("nntool." + __name__) - - -# @generation_function("kernels", (LinearFusionParameters, FcParameters), qrec_types=(QREC_MULT8, )) -# def linear_relu_kernels_generator(gen, node, qrec, in_eparams, out_eparams, cname): -# del in_eparams, out_eparams -# if isinstance(node, FcParameters): -# gen.kernels.append(LinearReluKernel(node.name, cname, node, qrec, None, None, -# at_ver=gen.opts['at_ver'], gen_ctrl=node.get_gen_ctrl( -# ), -# force_relu=gen.force_relu)) -# elif isinstance(node, LinearFusionParameters) and node.fusion_type == "linear_active": -# cnodes = node.contained_nodes() -# quants = [gen.G.quantization[NodeId(node, fnode)] for fnode in cnodes] -# gen.kernels.append(LinearReluKernel(node.name, cname, cnodes[0], quants[0], -# cnodes[1], quants[1], at_ver=gen.opts['at_ver'], -# gen_ctrl=node.get_gen_ctrl(), force_relu=gen.force_relu)) -# else: -# return False -# return True - - -# def gen_at_linear_relu(code_block, cname, biases_ds, mulbiases_ds, -# in_dim, out_dim, linear_oper, act_oper, gen_ctrl, at_ver=3): -# del at_ver -# code_block.write('CNN_LinearAct_SQ8("{}", {}, {}, {}, {}, {}, {}, {});', -# cname, -# gen_ctrl, -# biases_ds, -# mulbiases_ds, -# in_dim, -# out_dim, -# linear_oper, -# act_oper) - - -# def gen_at_linear_relu_ne16(code_block, cname, in_size, out_size, filter_bits, biases_ds, mulbiases_ds, -# in_dim, out_dim, linear_oper, act_oper, gen_ctrl, at_ver=3): -# del at_ver -# code_block.write('CNN_LinearAct_NE16("{}", {}, {}, {}, {}, {}, {}, {}, {}, {}, {});', -# cname, -# gen_ctrl, -# in_size, -# out_size, -# biases_ds, -# mulbiases_ds, -# filter_bits, -# in_dim, -# out_dim, -# linear_oper, -# act_oper) - - -# @kernel_sources( -# '$(TILER_CNN_KERNEL_PATH_SQ8)/CNN_Bias_Linear_SQ8.c') -# @kernel_include_paths( -# '$(TILER_CNN_KERNEL_PATH)', -# '$(TILER_CNN_KERNEL_PATH_SQ8)') -# @kernel_includes( -# 'CNN_BasicKernels_SQ8.h') -# @gen_sources( -# '$(TILER_CNN_GENERATOR_PATH)/CNN_Generator_Util.c', -# '$(TILER_CNN_GENERATOR_PATH_SQ8)/CNN_Generators_SQ8.c') -# @gen_include_paths( -# '$(TILER_CNN_GENERATOR_PATH)', -# '$(TILER_CNN_GENERATOR_PATH_SQ8)') -# @gen_includes( -# 'CNN_Generators_SQ8.h') -# class LinearReluKernel(AutotilerKernel): -# def __init__(self, node_name, cname, linear_params, linear_q, act_params, act_q, at_ver=3, gen_ctrl=None, force_relu=True): -# if gen_ctrl is None: -# self.gen_ctrl = GenCtrl(None, cname=cname) -# else: -# gen_ctrl.cname = cname -# self.gen_ctrl = gen_ctrl - -# assert linear_params is not None, "linear should always be included" -# at_linear_params = gen_linear_at_params(linear_params) -# in_dim = linear_params.in_dims[0] -# out_dim = linear_params.out_dims[0] -# filter_q = linear_q.in_qs[1] -# in_q = linear_q.in_qs[0] -# out_q = linear_q.out_qs[0] -# bias_q = linear_q.in_qs[2] -# mulbiases_q = linear_q.cache['mul_biases_q'] - -# if act_params is not None: -# at_act_params = gen_active_at_params(act_params, force_relu=force_relu, -# asymmetric=act_q.in_qs[0].zero_point != 0) -# if in_dim is None: -# in_dim = act_params.in_dims[0] -# if out_dim is None: -# out_dim = act_params.out_dims[0] -# if in_q is None: -# in_q = act_q.in_qs[0] -# out_q = act_q.out_qs[0] -# else: -# at_act_params = NO_ACTIVATION - -# self.at_linear_params = at_linear_params -# self.in_dim = in_dim.size() -# self.out_dim = out_dim.size() -# self.in_q = in_q -# self.bias_q = bias_q -# self.mulbiases_q = mulbiases_q -# self.out_q = out_q -# self.filter_q = filter_q -# self.at_act_params = at_act_params -# self.cname = cname -# self.node_name = node_name -# self.at_ver = at_ver -# self.ne16 = linear_q.cache.get('ne16') - -# def code(self, code_block=None): -# if code_block is None: -# code_block = CodeBlock() - -# code_block.comment("generator for {}", self.node_name) - -# if not self.gen_ctrl.is_unmodified: -# self.gen_ctrl.gen_ctrl_decl(code_block) -# gen_ctrl = self.gen_ctrl.ctrl_name -# else: -# gen_ctrl = "0" - -# if self.ne16: -# gen_at_linear_relu_ne16(code_block, self.cname, -# self.in_q.dtype_bits//8 if self.in_q.signed else -self.in_q.dtype_bits//8, -# self.out_q.dtype_bits//8 if self.out_q.signed else -self.out_q.dtype_bits//8, -# self.filter_q.bits, self.bias_q.dtype_bits//8, self.mulbiases_q.dtype_bits//8, -# self.in_dim, self.out_dim, -# self.at_linear_params.LinearOper, -# self.at_act_params.ReLUOper, -# at_ver=self.at_ver, gen_ctrl=gen_ctrl) -# else: -# gen_at_linear_relu(code_block, self.cname, self.bias_q.dtype_bits//8, self.mulbiases_q.dtype_bits//8, -# self.in_dim, self.out_dim, -# self.at_linear_params.LinearOper, -# self.at_act_params.ReLUOper, -# at_ver=self.at_ver, gen_ctrl=gen_ctrl) - -# return code_block diff --git a/tools/nntool/generation/generators/kernels/mult8/mat_mul_kernels_generator.py b/tools/nntool/generation/generators/kernels/mult8/mat_mul_kernels_generator.py deleted file mode 100644 index 9aef1299c..000000000 --- a/tools/nntool/generation/generators/kernels/mult8/mat_mul_kernels_generator.py +++ /dev/null @@ -1,100 +0,0 @@ -# Copyright (C) 2020, 2021 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import logging - -from generation.at_generators.utils import at_bits -from generation.at_types.at_params import gen_activation_op -from generation.at_types.gen_ctrl import GenCtrl -from generation.generator_decorators import QREC_MULT8, generation_function -from graph.types import (ActivationParameters, MatMulOpFusionParameters, - MatMulOpParameters) - -from ..autotiler_kernel import NewAutoTilerKernel - -LOG = logging.getLogger("nntool." + __name__) - -MAT_MUL_OPER = "KOP_MATMUL" - - -@generation_function( - "kernels", - (MatMulOpParameters, MatMulOpFusionParameters), - qrec_types=(QREC_MULT8, )) -def mat_mul_kernel_generator(gen, node, qrec, in_eparams, out_eparams, cname): - del in_eparams, out_eparams - if isinstance(node, MatMulOpFusionParameters): - cnodes = node.contained_nodes() - act_node = cnodes[-1] if isinstance(cnodes[-1], - ActivationParameters) else None - else: - act_node = None - - gen.kernels.append( - MatMulKernel( - node.name, cname, node, qrec, act_node, force_relu=gen.force_relu)) - return True - -class MatMulKernel(NewAutoTilerKernel): - CALL_TEMPLATE = ''' -// generator for {node_name} -CNN_MatMulAct_SQ8("{cname}", {gen_ctrl}, {bias_datasize}, 1, {width_1}, - {height_1}, {width_2}, {height_2}, 0, 0, 1, 1, {matmul_op}, {act_op}); -''' - - def __init__(self, node_name, cname, matmul_params, matmul_qrec, act_params, gen_ctrl=None, force_relu=True): - if gen_ctrl is None: - self.gen_ctrl = gen_ctrl = GenCtrl(None, cname=cname) - else: - gen_ctrl.cname = cname - self.gen_ctrl = gen_ctrl - - if act_params is not None: - act_op = gen_activation_op( - act_params.activation, force_relu=force_relu) - else: - act_op = 'KOP_NONE' - - if len(matmul_params.in_dims) == 3: - bias_datasize = at_bits(matmul_qrec.in_qs[2]) - if len(matmul_qrec.in_qs[0].scale) == 1: - matmul_op = 'KOP_MATMUL_SCALE_SCALAR' - else: - matmul_op = 'KOP_MATMUL' - else: - bias_datasize = 0 - matmul_op = 'KOP_MATMUL_NOBIAS' - - height_1 = matmul_params.in_dims[0][0] - width_1 = matmul_params.in_dims[0][1] - height_2 = matmul_params.in_dims[1][0] - width_2 = matmul_params.in_dims[1][1] - - # attributes affecting generation - attrs = { - 'height_1': height_1, - 'width_1': width_1, - 'height_2': height_2, - 'width_2': width_2, - 'bias_datasize': bias_datasize, - 'matmul_op': matmul_op, - 'act_op': act_op - } - - # other attributes - extra_attrs = { - 'cname': cname, - 'node_name': node_name - } - super().__init__(attrs, extra_attrs, gen_ctrl=gen_ctrl) diff --git a/tools/nntool/generation/generators/kernels/mult8/mat_vect_mult_kernels_generator.py b/tools/nntool/generation/generators/kernels/mult8/mat_vect_mult_kernels_generator.py deleted file mode 100644 index aa7b96039..000000000 --- a/tools/nntool/generation/generators/kernels/mult8/mat_vect_mult_kernels_generator.py +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import logging - -import numpy as np -from generation.at_types.at_params import NO_ACTIVATION, gen_active_at_params -from generation.at_types.gen_ctrl import GenCtrl -from generation.code_block import CodeBlock -from generation.generator_decorators import QREC_MULT8, generation_function -from graph.types import ActivationFusionBase, MatrixMulParameters - -from ..autotiler_kernel import AutotilerKernel - -LOG = logging.getLogger("nntool." + __name__) - -MAT_VECT_MUL_OPER = "KOP_MATVECTMUL" - -def validate_kernel(node): - shape1 = node.in_dims[0] - shape2 = node.in_dims[1] - if len(shape1) != 3 or len(shape1) != len(shape2): - return None - if np.prod(shape1) == shape2[0]: - return 0 - if np.prod(shape1) == shape2[0]: - return 1 - return None - -@generation_function("kernels", (MatrixMulParameters, ActivationFusionBase), qrec_types=(QREC_MULT8, )) -def mat_vect_mult_kernel_generator(gen, node, qrec, in_eparams, out_eparams, cname): - del in_eparams, out_eparams, qrec - if isinstance(node, ActivationFusionBase): - cnodes = node.contained_nodes() - if isinstance(cnodes[0], MatrixMulParameters) and validate_kernel(cnodes[0]) is not None: - gen.kernels.append(MatVectMulKernel(node.name, cname, cnodes[0], cnodes[1], - at_ver=gen.opts['at_ver'], force_relu=gen.force_relu)) - return True - return False - elif validate_kernel(node) is not None: - gen.kernels.append(MatVectMulKernel(node.name, cname, node, None, at_ver=gen.opts['at_ver'], - force_relu=gen.force_relu)) - return True - return False - - -def gen_mat_vect_mul_sq8(code_block, cname, ctrl, feat, width, height, act_oper): - code_block.write('CNN_TensorVectMultAct_SQ8("{}", {}, {}, {}, {}, {}, {});'.format(cname, ctrl, - feat, width, - height, - MAT_VECT_MUL_OPER, - act_oper)) - - -class MatVectMulKernel(AutotilerKernel): - def __init__(self, node_name, cname, tens_vect_mul_params, act_params, at_ver=3, gen_ctrl=None, force_relu=True): - if gen_ctrl is None: - self.gen_ctrl = gen_ctrl = GenCtrl(None, cname=cname) - else: - gen_ctrl.cname = cname - self.gen_ctrl = gen_ctrl - - self.cname = cname - self.node_name = node_name - self.at_ver = at_ver - - if act_params is not None: - self.at_act_params = gen_active_at_params( - act_params, force_relu=force_relu) - else: - self.at_act_params = NO_ACTIVATION - - self.tens_vect_mul_params = tens_vect_mul_params - if tens_vect_mul_params.in_dims[0] == tens_vect_mul_params.in_dims[1]: - # broadcast matrix * matrix - self.feat_dim = tens_vect_mul_params.in_dims[0].size() - self.height = 1 - self.width = 1 - else: - # probably need more logic here to handle - dimensions = tens_vect_mul_params.in_dims[0] - self.feat_dim = dimensions[0] - self.width = dimensions[1] - self.height = dimensions[2] - - def code(self, code_block=None): - if code_block is None: - code_block = CodeBlock() - - code_block.comment("generator for {}", self.node_name) - - if not self.gen_ctrl.is_unmodified: - self.gen_ctrl.gen_ctrl_decl(code_block) - gen_ctrl = self.gen_ctrl.ctrl_name - else: - gen_ctrl = "0" - - gen_mat_vect_mul_sq8(code_block, self.cname, gen_ctrl, self.feat_dim, - self.width, self.height, self.at_act_params.ReLUOper) - - return code_block diff --git a/tools/nntool/generation/generators/kernels/mult8/matadd_kernels_generator.py b/tools/nntool/generation/generators/kernels/mult8/matadd_kernels_generator.py deleted file mode 100644 index b4da33347..000000000 --- a/tools/nntool/generation/generators/kernels/mult8/matadd_kernels_generator.py +++ /dev/null @@ -1,140 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -from functools import reduce -import logging -from utils.node_id import NodeId - -from generation.at_types.at_params import (NO_ACTIVATION, gen_active_at_params) -from generation.at_types.gen_ctrl import GenCtrl -from generation.code_block import CodeBlock -from generation.generator_decorators import generation_function, QREC_MULT8 -from graph.types import MatrixAddParameters, ActivationFusionBase - -from ..autotiler_kernel import (AutotilerKernel, gen_include_paths, - gen_includes, gen_sources, - kernel_include_paths, kernel_includes, - kernel_sources) - - -LOG = logging.getLogger("nntool." + __name__) - -MAT_ADD_OPER = "KOP_MATADD" - - -@generation_function("kernels", (MatrixAddParameters, ActivationFusionBase), qrec_types=(QREC_MULT8, )) -def matadd_kernel_generator(gen, node, qrec, in_eparams, out_eparams, cname): - del out_eparams, qrec - if isinstance(node, ActivationFusionBase): - cnodes = node.contained_nodes() - if isinstance(cnodes[0], MatrixAddParameters): - if in_eparams[0].dims.size() != in_eparams[1].dims.size(): - raise ValueError( - "missing generator: the matrix add generator only handles adds of tensors of the same size") - act_q = gen.G.quantization[NodeId(node, cnodes[1])] - gen.kernels.append(MatAddKernel(node.name, cname, cnodes[0], cnodes[1], act_q, at_ver=gen.opts['at_ver'], - force_relu=gen.force_relu)) - return True - return False - if in_eparams[0].dims.size() != in_eparams[1].dims.size(): - raise ValueError( - "missing generator: the matrix add generator only handles adds of tensors of the same size") - gen.kernels.append(MatAddKernel(node.name, cname, node, None, - at_ver=gen.opts['at_ver'], force_relu=gen.force_relu)) - return True - - -def gen_mat_add_sq8(code_block, cname, ctrl, feat, width, height, act_oper): - code_block.write('CNN_MatAddAct_SQ8("{}", {}, {}, {}, {}, {}, {});'.format(cname, ctrl, - feat, width, - height, - MAT_ADD_OPER, - act_oper)) - - -def balanced_factors(num): - factors = [(x, num//x) for x in range(2, int(num/2)+1) if num % x == 0] - differences = [abs(x[0] - x[1]) for x in factors] - min_idx = differences.index(min(differences)) - return factors[min_idx] - - -def make_three_dims(dims): - if len(dims) == 1: - factors = balanced_factors(dims[0]) - return (1, factors[0], factors[1]) - if len(dims) == 2: - return (1, dims[0], dims[1]) - if len(dims) == 3: - return dims - prod = reduce(lambda x, y: x * y, dims[1:]) - factors = balanced_factors(prod) - return (dims[0], factors[0], factors[1]) - - -@kernel_sources( - '$(TILER_CNN_KERNEL_PATH_SQ8)/CNN_MatAlgebra_SQ8.c') -@kernel_include_paths( - '$(TILER_CNN_KERNEL_PATH)', - '$(TILER_CNN_KERNEL_PATH_SQ8)') -@kernel_includes( - 'CNN_BasicKernels_SQ8.h') -@gen_sources( - '$(TILER_CNN_GENERATOR_PATH)/CNN_Generator_Util.c', - '$(TILER_CNN_GENERATOR_PATH_SQ8)/CNN_Generators_SQ8.c') -@gen_include_paths( - '$(TILER_CNN_GENERATOR_PATH)', - '$(TILER_CNN_GENERATOR_PATH_SQ8)') -@gen_includes( - 'CNN_Generators_SQ8.h') -class MatAddKernel(AutotilerKernel): - def __init__(self, node_name, cname, matrixadd_params, act_params, act_q=None, at_ver=3, gen_ctrl=None, force_relu=True): - if gen_ctrl is None: - self.gen_ctrl = gen_ctrl = GenCtrl(None, cname=cname) - else: - gen_ctrl.cname = cname - self.gen_ctrl = gen_ctrl - - self.cname = cname - self.node_name = node_name - self.at_ver = at_ver - - if act_params is not None: - self.at_act_params = gen_active_at_params( - act_params, force_relu=force_relu, asymmetric=act_q.in_qs[0].zero_point != 0) - else: - self.at_act_params = NO_ACTIVATION - - self.matrixadd_params = matrixadd_params - dimensions = make_three_dims(matrixadd_params.in_dims[0]) - self.feat_dim = dimensions[0] - self.width = dimensions[1] - self.height = dimensions[2] - - def code(self, code_block=None): - if code_block is None: - code_block = CodeBlock() - - code_block.comment("generator for {}", self.node_name) - - if not self.gen_ctrl.is_unmodified: - self.gen_ctrl.gen_ctrl_decl(code_block) - gen_ctrl = self.gen_ctrl.ctrl_name - else: - gen_ctrl = "0" - - gen_mat_add_sq8(code_block, self.cname, gen_ctrl, self.feat_dim, - self.width, self.height, self.at_act_params.ReLUOper) - - return code_block diff --git a/tools/nntool/generation/generators/kernels/mult8/padded_add_kernels_generator.py b/tools/nntool/generation/generators/kernels/mult8/padded_add_kernels_generator.py deleted file mode 100644 index 245ff5609..000000000 --- a/tools/nntool/generation/generators/kernels/mult8/padded_add_kernels_generator.py +++ /dev/null @@ -1,128 +0,0 @@ -# # Copyright (C) 2020 GreenWaves Technologies, SAS - -# # This program is free software: you can redistribute it and/or modify -# # it under the terms of the GNU Affero General Public License as -# # published by the Free Software Foundation, either version 3 of the -# # License, or (at your option) any later version. - -# # This program is distributed in the hope that it will be useful, -# # but WITHOUT ANY WARRANTY; without even the implied warranty of -# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# # GNU Affero General Public License for more details. -# # You should have received a copy of the GNU Affero General Public License -# # along with this program. If not, see . - -# from functools import reduce -# import logging - -# from generation.at_types.at_params import (NO_ACTIVATION, gen_activation_op) -# from generation.at_types.gen_ctrl import GenCtrl -# from generation.code_block import CodeBlock -# from generation.generator_decorators import generation_function, QREC_MULT8 -# from graph.types import PaddedAddFusionParameters - -# from ..autotiler_kernel import (AutotilerKernel, gen_include_paths, -# gen_includes, gen_sources, -# kernel_include_paths, kernel_includes, -# kernel_sources) - -# LOG = logging.getLogger("nntool." + __name__) - -# MAT_ADD_OPER = "KOP_MATADD" - -# @generation_function("kernels", (PaddedAddFusionParameters, ), qrec_types=(QREC_MULT8, )) -# def padded_matadd_kernel_generator(gen, node, qrec, in_eparams, out_eparams, cname): -# del out_eparams, qrec -# cnodes = node.contained_nodes() -# if len(cnodes) > 2: -# act_node = cnodes[2] -# else: -# act_node = None -# pad_node = cnodes[0] -# gen.kernels.append(PaddedMatAddKernel(node.name, cname, node, pad_node, act_node, at_ver=gen.opts['at_ver'], force_relu=gen.force_relu)) -# return True - -# @kernel_sources( -# '$(TILER_CNN_KERNEL_PATH_SQ8)/CNN_MatAlgebra_SQ8.c') -# @kernel_include_paths( -# '$(TILER_CNN_KERNEL_PATH)', -# '$(TILER_CNN_KERNEL_PATH_SQ8)') -# @kernel_includes( -# 'CNN_BasicKernels_SQ8.h') -# @gen_sources( -# '$(TILER_CNN_GENERATOR_PATH)/CNN_Generator_Util.c', -# '$(TILER_CNN_GENERATOR_PATH_SQ8)/CNN_Generators_SQ8.c') -# @gen_include_paths( -# '$(TILER_CNN_GENERATOR_PATH)', -# '$(TILER_CNN_GENERATOR_PATH_SQ8)') -# @gen_includes( -# 'CNN_Generators_SQ8.h') -# def gen_pad_mat_add_sq8(code_block, cname, ctrl, feat, width, height, padtop, padbot, padded_idx, act_oper): -# code_block.write('CNN_MatAddPaddedAct_SQ8("{}", {}, {}, {}, {}, {}, {}, {}, {}, {});'.format(cname, ctrl, -# feat, width, height, -# padtop, padbot, padded_idx, -# MAT_ADD_OPER, -# act_oper)) - -# def balanced_factors(num): -# factors = [(x, num//x) for x in range(2,int(num/2)+1) if num%x==0] -# differences = [abs(x[0] - x[1]) for x in factors] -# min_idx = differences.index(min(differences)) -# return factors[min_idx] - -# def make_three_dims(dims): -# if len(dims) == 1: -# factors = balanced_factors(dims[0]) -# return (1, factors[0], factors[1]) -# if len(dims) == 2: -# return (1, dims[0], dims[1]) -# if len(dims) == 3: -# return dims -# prod = reduce(lambda x, y: x * y, dims[1:]) -# factors = balanced_factors(prod) -# return (dims[0], factors[0], factors[1]) - -# class PaddedMatAddKernel(AutotilerKernel): -# def __init__(self, node_name, cname, matrixadd_params, pad_params, act_params, at_ver=3, gen_ctrl=None, force_relu=True): -# if gen_ctrl is None: -# self.gen_ctrl = gen_ctrl = GenCtrl(None, cname=cname) -# else: -# gen_ctrl.cname = cname -# self.gen_ctrl = gen_ctrl - -# self.cname = cname -# self.node_name = node_name -# self.at_ver = at_ver - -# if act_params is not None: -# self.at_act_params = gen_activation_op(act_params.activation, force_relu=force_relu) -# else: -# self.at_act_params = NO_ACTIVATION - -# self.padtop = pad_params.padding[0][0] -# self.padbot = pad_params.padding[0][1] -# self.padded_idx = 0 if matrixadd_params.in_dims[0].size() > matrixadd_params.in_dims[1].size() else 1 -# self.matrixadd_params = matrixadd_params -# dimensions0 = make_three_dims(matrixadd_params.in_dims[0]) -# dimensions1 = make_three_dims(matrixadd_params.in_dims[1]) -# self.feat_dim = max(dimensions0[0], dimensions1[0]) -# self.width = dimensions0[1] -# self.height = dimensions0[2] - -# def code(self, code_block=None): -# if code_block is None: -# code_block = CodeBlock() - -# code_block.comment("generator for {}", self.node_name) - -# if not self.gen_ctrl.is_unmodified: -# self.gen_ctrl.gen_ctrl_decl(code_block) -# gen_ctrl = self.gen_ctrl.ctrl_name -# else: -# gen_ctrl = "0" - -# gen_pad_mat_add_sq8(code_block, self.cname, gen_ctrl, self.feat_dim, -# self.width, self.height, self.padtop, self.padbot, -# self.padded_idx, self.at_act_params) - -# return code_block diff --git a/tools/nntool/generation/generators/kernels/mult8/pool_relu_kernels_generator.py b/tools/nntool/generation/generators/kernels/mult8/pool_relu_kernels_generator.py deleted file mode 100644 index df6ffcad1..000000000 --- a/tools/nntool/generation/generators/kernels/mult8/pool_relu_kernels_generator.py +++ /dev/null @@ -1,109 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import logging -from utils.node_id import NodeId - -from generation.at_types.at_params import (NO_ACTIVATION, gen_active_at_params, - gen_pool_at_params) -from generation.at_types.gen_ctrl import GenCtrl -from generation.code_block import CodeBlock -from generation.generator_decorators import (QREC_MULT8, - generation_function) -from graph.types import ActivationFusionBase, PoolingParameters -from graph.types.pooling import AveragePoolParameters, MaxPoolParameters - -from ..autotiler_kernel import AutotilerKernel - -LOG = logging.getLogger("nntool." + __name__) - - -@generation_function("kernels", (MaxPoolParameters, AveragePoolParameters, ActivationFusionBase), qrec_types=(QREC_MULT8, )) -def pool_act_kernels_generator(gen, node, qrec, in_eparams, out_eparams, cname): - del in_eparams, out_eparams - if isinstance(node, ActivationFusionBase): - cnodes = node.contained_nodes() - if isinstance(cnodes[0], PoolingParameters): - act_q = gen.G.quantization[NodeId(node, cnodes[1])] - gen.kernels.append(PoolKernel(node.name, cname, cnodes[0], cnodes[1], qrec, act_q, - at_ver=gen.opts['at_ver'], force_relu=gen.force_relu)) - return True - return False - gen.kernels.append(PoolKernel(node.name, cname, node, None, - qrec, at_ver=gen.opts['at_ver'], force_relu=gen.force_relu)) - return True - - -def gen_cnn_pool_act_sq8(code_block, cname, ctrl, feat, width, height, at_pool_params, actoper): - code_block.write('CNN_PoolAct_SQ8("{}", {}, {}, {}, {},'.format( - cname, ctrl, feat, width, height)) - code_block.indent() - code_block.write('{}, {}, {}, {}, {}, {}, {}, {}, {});'.format(at_pool_params.PoolOper, - at_pool_params.Fpx, - at_pool_params.Fpy, - at_pool_params.Dpx, - at_pool_params.Dpy, - at_pool_params.Spx, - at_pool_params.Spy, - at_pool_params.PoolPad, - actoper)) - code_block.deindent() - - -class PoolKernel(AutotilerKernel): - def __init__(self, node_name, cname, pool_params, act_params, qrec, act_q=None, gen_ctrl=None, at_ver=3, force_relu=True): - if gen_ctrl is None: - self.gen_ctrl = GenCtrl(None, cname=cname) - else: - gen_ctrl.cname = cname - self.gen_ctrl = gen_ctrl - if pool_params.ker_in_order and pool_params.ker_in_order[0] == ["h", "w", "c"]: - self.gen_ctrl.hwc = 1 - if not qrec.out_qs[0].signed: - self.gen_ctrl.output_datasize = - qrec.out_qs[0].dtype_bits//8 - if not qrec.in_qs[0].signed: - self.gen_ctrl.input_datasize = - qrec.in_qs[0].dtype_bits//8 - - if act_params is not None: - self.at_act_params = gen_active_at_params(act_params, force_relu=force_relu, - asymmetric=act_q.in_qs[0].zero_point != 0) - else: - self.at_act_params = NO_ACTIVATION - - pad_compatibilities = [] - self.at_pool_params = gen_pool_at_params( - pool_params, pad_compatibilities) - self.in_dim = pool_params.in_dims[0] - self.out_dim = pool_params.out_dims[0] - self.cname = cname - self.node_name = node_name - self.at_ver = at_ver - - def code(self, code_block=None): - if code_block is None: - code_block = CodeBlock() - - code_block.comment("generator for {}", self.node_name) - - if not self.gen_ctrl.is_unmodified: - self.gen_ctrl.gen_ctrl_decl(code_block) - gen_ctrl = self.gen_ctrl.ctrl_name - else: - gen_ctrl = "0" - - gen_cnn_pool_act_sq8(code_block, self.cname, gen_ctrl, self.in_dim.c, - self.in_dim.w, self.in_dim.h, - self.at_pool_params, - self.at_act_params.ReLUOper) - return code_block diff --git a/tools/nntool/generation/generators/kernels/mult8/rnn_kernels_generator.py b/tools/nntool/generation/generators/kernels/mult8/rnn_kernels_generator.py deleted file mode 100644 index 37f2a00a8..000000000 --- a/tools/nntool/generation/generators/kernels/mult8/rnn_kernels_generator.py +++ /dev/null @@ -1,136 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import logging - -from generation.at_types.gen_ctrl import GenCtrl -from generation.code_block import CodeBlock -from generation.generator_decorators import generation_function, QREC_MULT8 -from graph.types import RNNParameters, LSTMParameters, GRUParameters - -from ..autotiler_kernel import AutotilerKernel - -LOG = logging.getLogger("nntool." + __name__) - - -@generation_function("kernels", (RNNParameters, LSTMParameters, GRUParameters), qrec_types=(QREC_MULT8, )) -def rnn_kernels_generator(gen, node, qrec, in_eparams, out_eparams, cname): - del in_eparams, out_eparams, qrec - gen.kernels.append(RNNKernel(node.name, cname, node, - at_ver=gen.opts['at_ver'], - gen_ctrl=node.get_gen_ctrl())) - return True - -# int RNN_Stack_SQ8( -# char *Name, -# CNN_GenControl_T *Ctrl, -# int BiasDataSize, -# int FeatDataSize, -# int NCells, -# int K0, -# int K1, -# int DimState, -# int DimIn, -# int AlwaysReset, -# int Revert -# ); - -# int LSTM_Stack_SQ8( -# char *Name, -# CNN_GenControl_T *Ctrl, -# int BiasDataSize, -# int FeatDataSize, -# int NCells, -# int K0, -# int K1, -# int DimState, -# int DimIn, -# int AlwaysReset, -# int Revert -# ); - -# int GRU_Stack_SQ8( -# char *Name, -# CNN_GenControl_T *Ctrl, -# int BiasDataSize, -# int FeatDataSize, -# int NCells, -# int K0, -# int K1, -# int DimState, -# int DimIn, -# int AlwaysReset, -# int Revert -# ); - -def gen_rnn_sq8(code_block, kname, cname, ctrl, ncells, k0, k1, dim_state, dim_in, revert): - code_block.write( - '{}("{}", {}, 4, 1, {}, {}, {}, {}, {}, 0, {});'.format(kname, cname, ctrl, - ncells, k0, - k1, dim_state, - dim_in, - revert)) - - -class RNNKernel(AutotilerKernel): - def __init__(self, node_name, cname, rnn_params, gen_ctrl=None, at_ver=3): - if gen_ctrl is None: - self.gen_ctrl = GenCtrl(None, cname=cname) - else: - gen_ctrl.cname = cname - self.gen_ctrl = gen_ctrl - - if isinstance(rnn_params, RNNParameters): - self.kname = "RNN_Stack_SQ8" - elif isinstance(rnn_params, LSTMParameters): - self.kname = "LSTM_Stack_SQ8" - elif isinstance(rnn_params, GRUParameters): - self.kname = "GRU_Stack_SQ8" - if not rnn_params.linear_before_reset: - # gen_ctrl.linear_before_reset = 0 - raise ValueError("In {} linear_before_reset == 0 not supported by the Autotiler kernels") - else: - raise ValueError("unknown RNN parameter type") - self.n_cells = rnn_params.n_cells - self.n_states = rnn_params.n_states - self.n_inputs = rnn_params.n_inputs - self.n_input_cells = rnn_params.n_input_cells - self.n_output_cells = rnn_params.n_output_cells - self.revert = rnn_params.revert - if not rnn_params.hard_act: - gen_ctrl.rnn_use_hardact = 0 - if not rnn_params.rnn_same_inout_scale: - gen_ctrl.rnn_same_inout_scale = 0 - self.cname = cname - self.node_name = node_name - self.at_ver = at_ver - - def code(self, code_block=None): - if code_block is None: - code_block = CodeBlock() - - code_block.comment("generator for {}", self.node_name) - - if not self.gen_ctrl.is_unmodified: - self.gen_ctrl.gen_ctrl_decl(code_block) - gen_ctrl = self.gen_ctrl.ctrl_name - else: - gen_ctrl = "0" - - gen_rnn_sq8(code_block, self.kname, self.cname, gen_ctrl, self.n_cells, - self.n_input_cells, self.n_output_cells, - self.n_states, - self.n_inputs, - self.revert and "1" or "0") - return code_block diff --git a/tools/nntool/generation/generators/kernels/mult8/softmax_kernels_generator.py b/tools/nntool/generation/generators/kernels/mult8/softmax_kernels_generator.py deleted file mode 100644 index 2f566722e..000000000 --- a/tools/nntool/generation/generators/kernels/mult8/softmax_kernels_generator.py +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import logging - -from generation.at_types.at_params import gen_softmax_at_params -from generation.at_types.gen_ctrl import GenCtrl -from generation.code_block import CodeBlock -from generation.generator_decorators import generation_function, QREC_MULT8 -from graph.types import SoftMaxParameters - -from ..autotiler_kernel import AutotilerKernel - -LOG = logging.getLogger("nntool." + __name__) - -GEN_SOFTMAX = "CNN_SoftMax_SQ8" -# extern void CNN_SoftMax( -# char *Name, -# CNN_GenControl_T *Ctrl, -# int Dim, -# KernelOper_T SoftMaxOper -# ); - -def gen_at_softmax(code_block, name, in_dim, at_softmax_params, gen_ctrl=None, is_2d=False, axis=1, at_ver=3): - if is_2d: - code_block.write('CNN_SoftMax2D_SQ8("{}", {}, {}, {}, {});', - name, gen_ctrl, - in_dim.shape[axis], - in_dim.size() // in_dim.shape[axis], - at_softmax_params) - else: - code_block.write('CNN_SoftMax_SQ8("{}", {}, {}, {});', - name, gen_ctrl, - in_dim.size(), at_softmax_params) - - -@generation_function("kernels", (SoftMaxParameters, ), qrec_types=(QREC_MULT8, )) -def softmax_kernels_generator(gen, node, qrec, in_eparams, out_eparams, cname): - del in_eparams, out_eparams - # gen_ctrl = node.get_gen_ctrl() if node.at_options.out_8bits == 1 else None - gen_ctrl = None - gen.kernels.append(SoftmaxKernel(cname, node, qrec, gen_ctrl, at_ver=gen.opts['at_ver'])) - return True - - -class SoftmaxKernel(AutotilerKernel): - def __init__(self, cname, params, qrec, gen_ctrl=None, at_ver=3): - if gen_ctrl is None: - self.gen_ctrl = GenCtrl(None, cname=cname) - else: - gen_ctrl.cname = cname - self.gen_ctrl = gen_ctrl - if (not qrec.out_qs[0].dtype_bits == 16) or (not qrec.out_qs[0].signed): - self.gen_ctrl.output_datasize = qrec.out_qs[0].dtype_bits//8 if qrec.out_qs[0].signed else -qrec.out_qs[0].dtype_bits//8 - - self.at_softmax_params = gen_softmax_at_params(params) - self.in_dim = params.in_dims[0] - self.softmax_axis = params.axis - in_size = self.in_dim.size() - self.softmax2d = (in_size // self.in_dim.shape[params.axis]) != 1 - self.cname = cname - self.node_name = params.name - self.at_ver = at_ver - - def code(self, code_block=None): - if code_block is None: - code_block = CodeBlock() - - code_block.comment("generator for {}", self.node_name) - - if not self.gen_ctrl.is_unmodified: - self.gen_ctrl.gen_ctrl_decl(code_block) - - gen_at_softmax(code_block, self.cname, self.in_dim, - self.at_softmax_params.SoftMaxOper, - self.gen_ctrl.ctrl_name, - self.softmax2d, self.softmax_axis, - at_ver=self.at_ver) - return code_block diff --git a/tools/nntool/generation/generators/kernels/mult8/ssd_postprocess_kernels_generator.py b/tools/nntool/generation/generators/kernels/mult8/ssd_postprocess_kernels_generator.py deleted file mode 100644 index 6bc923330..000000000 --- a/tools/nntool/generation/generators/kernels/mult8/ssd_postprocess_kernels_generator.py +++ /dev/null @@ -1,75 +0,0 @@ -# # Copyright (C) 2020 GreenWaves Technologies, SAS - -# # This program is free software: you can redistribute it and/or modify -# # it under the terms of the GNU Affero General Public License as -# # published by the Free Software Foundation, either version 3 of the -# # License, or (at your option) any later version. - -# # This program is distributed in the hope that it will be useful, -# # but WITHOUT ANY WARRANTY; without even the implied warranty of -# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# # GNU Affero General Public License for more details. -# # You should have received a copy of the GNU Affero General Public License -# # along with this program. If not, see . - -# import logging - -# from generation.at_types.gen_ctrl import GenCtrl -# from generation.code_block import CodeBlock -# from generation.generator_decorators import generation_function, QREC_MULT8 -# from graph.types import SSDDetectorParameters - -# from ..autotiler_kernel import AutotilerKernel - -# LOG = logging.getLogger("nntool." + __name__) - -# GEN_SSD = "CNN_SSD_PostProcess_SQ8" - -# def gen_at_ssd_parameter(code_block, name, num_anchors, num_classes, out_boxes, max_bb_before_nms, -# gen_ctrl=None, at_ver=3): -# if gen_ctrl is None: -# gen_ctrl = "0" -# else: -# raise NotImplementedError("genctrl is not yet implemented") - -# code_block.write('{}("{}", {}, {}, {}, {}, {});', -# GEN_SSD, name, gen_ctrl, num_anchors, num_classes, out_boxes, max_bb_before_nms) - - -# @generation_function("kernels", (SSDDetectorParameters, ), qrec_types=(QREC_MULT8, )) -# def ssdpostprocess_kernels_generator(gen, node, qrec, in_eparams, out_eparams, cname): -# del in_eparams, out_eparams -# gen.kernels.append(SSDPostProcessKernel(cname, node, qrec, at_ver=gen.opts['at_ver'])) -# return True - - -# class SSDPostProcessKernel(AutotilerKernel): -# def __init__(self, cname, params, qrec, gen_ctrl=None, at_ver=3): -# del qrec -# if gen_ctrl is None: -# self.gen_ctrl = GenCtrl(None, cname=cname) -# else: -# gen_ctrl.cname = cname -# self.gen_ctrl = gen_ctrl - -# self.num_anchors = params.in_dims[0].shape[0] # num_boxes x 4 -# self.num_classes = params.in_dims[1].shape[1] # num_boxes x num_classes -# self.out_boxes = params.out_dims[0].shape[0] # out_boxes x 4 -# self.max_bb_before_nms = params.max_bb_before_nms -# self.cname = cname -# self.node_name = params.name -# self.at_ver = at_ver - -# def code(self, code_block=None): -# if code_block is None: -# code_block = CodeBlock() - -# code_block.comment("generator for {}", self.node_name) - -# if not self.gen_ctrl.is_unmodified: -# self.gen_ctrl.gen_ctrl_decl(code_block) - -# gen_at_ssd_parameter(code_block, self.cname, self.num_anchors, -# self.num_classes, self.out_boxes, -# self.max_bb_before_nms, at_ver=self.at_ver) -# return code_block diff --git a/tools/nntool/generation/naming_convension.py b/tools/nntool/generation/naming_convension.py index cc05166c2..60d10abd8 100644 --- a/tools/nntool/generation/naming_convension.py +++ b/tools/nntool/generation/naming_convension.py @@ -28,9 +28,16 @@ class NamingConvension(ABC): - def __init__(self, G): - self.G = G - self.multi_out_edges = {} + def __init__(self, G=None): + self._G = G + + @property + def G(self): + return self._G + + @G.setter + def G(self, val): + self._G = val @abstractmethod def get_node_name(self, node_name, step_idx, params): diff --git a/tools/nntool/generation/new_generators/float/matadd_float.py b/tools/nntool/generation/new_generators/float/matadd_float.py index 914afcc10..c1fc69507 100644 --- a/tools/nntool/generation/new_generators/float/matadd_float.py +++ b/tools/nntool/generation/new_generators/float/matadd_float.py @@ -13,21 +13,18 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from graph.types.fusions import PaddedAddFusionParameters import logging from functools import reduce import numpy as np -from generation.at_types.at_params import NO_ACTIVATION, gen_activation_op, gen_active_at_params +from generation.at_types.at_params import gen_activation_op from generation.at_types.gen_ctrl import GenCtrl -from generation.bindings import (CommentBindingList, GNodeArgEdge, - GNodeArgNode, NodeBindingList) -from generation.generators.globals.mult8_infos_generator import act_infos +from generation.bindings import (CommentBindingList, GNodeArgEdge, NodeBindingList) from generation.generators.kernels.autotiler_kernel import NewAutoTilerKernel from generation.new_generators.generator_base import (GeneratorBase, ktype, paramstype) -from graph.types import ActivationFusion, MatrixAddParameters, BroadcastableActivationFusion -from quantization.multiplicative.mulbias import set_add_in_scale +from graph.types import (ActivationFusion, BroadcastableActivationFusion, + MatrixAddParameters) from utils.node_id import NodeId LOG = logging.getLogger("nntool." + __name__) diff --git a/tools/nntool/generation/new_generators/float/pool_float.py b/tools/nntool/generation/new_generators/float/pool_float.py index 40aac877d..6ee39a5e6 100644 --- a/tools/nntool/generation/new_generators/float/pool_float.py +++ b/tools/nntool/generation/new_generators/float/pool_float.py @@ -13,28 +13,23 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from functools import reduce -from utils.largest_factor import balanced_divisors -from quantization.multiplicative.mulbias import compute_in_out_scale -from generation.new_generators.helpers.in_out_bindings_mixin import InOutBindingsMixin -from graph.types.global_pooling import GlobalAveragePoolParameters, GlobalSumPoolParameters -from graph.dim import PadDim -from generation.new_generators.helpers.act_infos import gen_act_infos -from generation.at_types.at_params import NO_POOL, gen_activation_op, gen_globalpool_at_params, gen_pool_at_params import logging -from utils.node_id import NodeId +from functools import reduce -import numpy as np -from generation.at_types.constant_info import ConstantInfo +from generation.at_types.at_params import (gen_activation_op, + gen_globalpool_at_params, + gen_pool_at_params) from generation.at_types.gen_ctrl import GenCtrl -from generation.at_types.tc_arg_info import GlobalArgInfo -from generation.generators.globals.global_names import INFOS from generation.generators.kernels.autotiler_kernel import NewAutoTilerKernel -from generation.helpers.gen_constant import gen_constant -from generation.new_generators.generator_base import (GeneratorBase, - paramstype, ktype) -from graph.types import GlobalPoolingParameters, PoolingParameters, ActivationFusion -from quantization.qtype import QType +from generation.new_generators.generator_base import (GeneratorBase, ktype, + paramstype) +from generation.new_generators.helpers.in_out_bindings_mixin import \ + InOutBindingsMixin +from graph.dim import PadDim +from graph.types import (ActivationFusion, GlobalPoolingParameters, + PoolingParameters) +from utils.largest_factor import balanced_divisors +from utils.node_id import NodeId LOG = logging.getLogger("nntool." + __name__) diff --git a/tools/nntool/generation/new_generators/general/expressions.py b/tools/nntool/generation/new_generators/general/expressions.py new file mode 100644 index 000000000..3752f18b3 --- /dev/null +++ b/tools/nntool/generation/new_generators/general/expressions.py @@ -0,0 +1,66 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging + +from generation.generators.kernels.autotiler_kernel import NewAutoTilerKernel +from generation.new_generators.generator_base import GeneratorBase, paramstype +from generation.new_generators.helpers.in_out_bindings_mixin import \ + InOutBindingsMixin +from graph.types import ExpressionFusionParameters + +LOG = logging.getLogger("nntool." + __name__) + + +@paramstype(ExpressionFusionParameters) +class GenExpressionParameters(GeneratorBase, InOutBindingsMixin): + @classmethod + def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: + return True + + @classmethod + def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: + cls.set_multi_in_out_bindings( + gen, in_eparams, out_eparams, cname, node, qrec) + return True + + @classmethod + def kernel_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: + del in_eparams, out_eparams + func_name, _ = gen.expressions_get_names(node) + gen_name = f'{func_name}_gen' + gen.kernels.append(ExpressionKernel(cname, node, qrec, gen_name)) + return True + + +class ExpressionKernel(NewAutoTilerKernel): + CALL_TEMPLATE = ''' +// generator for {node_name} +{gen_name}("{cname}"); +''' + + def __init__(self, cname, params, qrec, gen_name): + + attrs = { + 'gen_name': gen_name + } + + # other attributes + extra_attrs = { + 'cname': cname, + 'node_name': params.name + } + + super().__init__(attrs, extra_attrs,) diff --git a/tools/nntool/generation/new_generators/general/imageformat.py b/tools/nntool/generation/new_generators/general/imageformat.py new file mode 100644 index 000000000..76068ac29 --- /dev/null +++ b/tools/nntool/generation/new_generators/general/imageformat.py @@ -0,0 +1,91 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging + +from generation.generators.kernels.autotiler_kernel import NewAutoTilerKernel +from generation.new_generators.generator_base import GeneratorBase, paramstype +from generation.new_generators.helpers.in_out_bindings_mixin import \ + InOutBindingsMixin +from graph.types import ImageFormatParameters + +LOG = logging.getLogger("nntool." + __name__) + + +@paramstype(ImageFormatParameters) +class GenImageFormat(GeneratorBase, InOutBindingsMixin): + + @classmethod + def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: + return True + + @classmethod + def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: + cls.set_in_out_bindings( + gen, in_eparams, out_eparams, cname, node, qrec) + return True + + @classmethod + def kernel_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: + del in_eparams, out_eparams + gen.kernels.append(ImageFormatKernel(cname, node, qrec)) + return True + + +KOP_NORM = { + "RGB565_RGB888": "KOP_NORM_RGB565", + "RGB888": "KOP_NORM_RGB888", + "RGB16": "KOP_NORM_RGB16", + "BW8": "KOP_NORM_BW", + "BW16": "KOP_NORM_BW16" +} + + +class ImageFormatKernel(NewAutoTilerKernel): + CALL_TEMPLATE = ''' +// generator for {node_name} +CNN_Norm("{cname}", {width}, {height}, {do_offset}, {kop_norm}); +''' + + def __init__(self, cname, params, qrec): + + if params.format_change not in KOP_NORM: + raise NotImplementedError( + f'{params.format_change} not implemented') + + attrs = { + 'do_offset': 1 if params.norm_func == "OFFSET_INT8" else 0, + 'kop_norm': KOP_NORM[params.format_change], + } + + in_dim = params.in_dims[0] + if in_dim.has_key('w') and in_dim.has_key('h'): + attrs['width'] = in_dim.w + attrs['height'] = in_dim.h + else: + if len(in_dim.shape) > 2: + LOG.warning( + "Input Dim has no hints -> we are assuming HxWxC order in this case " + f"-> {in_dim.shape[0]}x{in_dim.shape[1]}x{in_dim.shape[2]}, for .onnx graphs may not be the case") + attrs['width'] = in_dim.shape[1] + attrs['height'] = in_dim.shape[0] + + # other attributes + extra_attrs = { + 'cname': cname, + 'node_name': params.name + } + + super().__init__(attrs, extra_attrs) diff --git a/tools/nntool/generation/new_generators/general/resizer.py b/tools/nntool/generation/new_generators/general/resizer.py new file mode 100644 index 000000000..c32ef32b7 --- /dev/null +++ b/tools/nntool/generation/new_generators/general/resizer.py @@ -0,0 +1,128 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging + +from generation.generators.kernels.autotiler_kernel import NewAutoTilerKernel +from generation.new_generators.generator_base import GeneratorBase, paramstype +from generation.new_generators.helpers.in_out_bindings_mixin import \ + InOutBindingsMixin +from graph.types import ResizerParameters + +LOG = logging.getLogger("nntool." + __name__) + + +@paramstype(ResizerParameters) +class GenResizerParameters(GeneratorBase, InOutBindingsMixin): + @classmethod + def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: + return True + + @classmethod + def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: + cls.set_in_out_bindings( + gen, in_eparams, out_eparams, cname, node, qrec) + return True + + @classmethod + def kernel_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: + del in_eparams, out_eparams + if qrec.in_qs[0].is_floating: + kernel = FP16ResizerKernel + elif qrec.in_qs[0].dtype_bits == 16: + kernel = Q16ResizerKernel + else: + kernel = Q8ResizerKernel + + gen.kernels.append( + kernel(cname, node, qrec)) + return True + + +class ResizeKernelBase(NewAutoTilerKernel): + RESIZE_KOP = { + "bilinear": "KOP_BILINEAR_RESIZE", + "nearest_neighbor": "KOP_NEAREST_NEIGHBOR_RESIZE"} + + def __init__(self, cname, params, qrec): + + in_dim = params.in_dims[0] + if in_dim.has_key('w') and in_dim.has_key('h'): + in_dim_w, in_dim_h, in_dim_c = in_dim.w, in_dim.h, in_dim.c + else: + in_dim_w, in_dim_h, in_dim_c = in_dim.shape[2], in_dim.shape[1], in_dim.shape[0] + + new_shape = params.new_shape + chin = in_dim_c + win, wout = in_dim_w, new_shape[1] + hin, hout = in_dim_h, new_shape[0] + + if in_dim_w == 1 and in_dim_h == 1: + # If both are 1s the autotiler cannot solve the tiling problem + # --> exchange channels with one of the HW dimensions (the one that does not change) + if 1 in new_shape: + idx_one = new_shape.index(1) + win, wout = (in_dim_w, new_shape[1]) if idx_one == 0 else ( + in_dim_c, in_dim_c) + hin, hout = (in_dim_h, new_shape[0]) if idx_one == 1 else ( + in_dim_c, in_dim_c) + chin = 1 + else: + # If both HW change from 1x1 to HxW this is not going to work + LOG.warning(f"Resize Node {params.name} has 1x1xc input but resizes both " + "HW dimension, could not work in autotiler") + + if params.op_name not in self.RESIZE_KOP: + raise NotImplementedError( + f'{params.op_name} resize generator not implemented') + + attrs = { + 'win': win, + 'hin': hin, + 'chin': chin, + 'wout': wout, + 'hout': hout, + 'inout_t': "SIGNED_INOUT" if qrec.in_qs[0].signed else "UNSIGNED_INOUT", + 'resize_kop': self.RESIZE_KOP[params.op_name], + } + + # other attributes + extra_attrs = { + 'cname': cname, + 'node_name': params.name + } + + super().__init__(attrs, extra_attrs) + + +class FP16ResizerKernel(ResizeKernelBase): + CALL_TEMPLATE = ''' +// generator for {node_name} +GenerateResizeMultiChannel_fp16("{cname}", {win}, {hin}, {wout}, {hout}, {chin}, {inout_t}, {resize_kop}); +''' + + +class Q16ResizerKernel(ResizeKernelBase): + CALL_TEMPLATE = ''' +// generator for {node_name} +GenerateResizeMultiChannelQ16("{cname}", {win}, {hin}, {wout}, {hout}, {chin}, {inout_t}, {resize_kop}); +''' + + +class Q8ResizerKernel(ResizeKernelBase): + CALL_TEMPLATE = ''' +// generator for {node_name} +GenerateResizeMultiChannel("{cname}", {win}, {hin}, {wout}, {hout}, {chin}, {inout_t}, {resize_kop}); +''' diff --git a/tools/nntool/generation/new_generators/general/transpose.py b/tools/nntool/generation/new_generators/general/transpose.py new file mode 100644 index 000000000..6e513dc31 --- /dev/null +++ b/tools/nntool/generation/new_generators/general/transpose.py @@ -0,0 +1,113 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging + +from generation.at_types.gen_ctrl import GenCtrl +from generation.generators.kernels.autotiler_kernel import NewAutoTilerKernel +from generation.new_generators.generator_base import GeneratorBase, paramstype +from generation.new_generators.helpers.in_out_bindings_mixin import \ + InOutBindingsMixin +from graph.types.others import TransposeParameters + +LOG = logging.getLogger("nntool." + __name__) + + +@paramstype(TransposeParameters) +class GenTransposeParameters(GeneratorBase, InOutBindingsMixin): + @classmethod + def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: + return True + + @classmethod + def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: + cls.set_in_out_bindings( + gen, in_eparams, out_eparams, cname, node, qrec) + return True + + @classmethod + def kernel_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: + del in_eparams, out_eparams + real_in_shape, real_transpose = node.real_shape() + if len(real_transpose) <= 1: + return True + if len(real_transpose) == 2: + gen.kernels.append( + MatTransposeKernel( + cname, node, (1, real_in_shape[0], real_in_shape[1]), real_transpose, qrec)) + elif len(real_transpose) == 3: + dim_names = ['C', 'H', 'W'] + perm = ''.join([dim_names[i] for i in real_transpose]) + gen.kernels.append( + TensorPermuteKernel( + cname, node, real_in_shape, real_transpose, qrec, + perm_op=f"KOP_MATPERM_CHW2{perm}")) + else: + raise NotImplementedError( + "only 2D or 3D transposes are currently supported") + LOG.info("generating for transpose in %s out %s trans %s", + node.in_dims[0], node.out_dims[0], node.transpose) + return True + + +class TransposeKernelBase(NewAutoTilerKernel): + def __init__(self, cname, params, in_shape, real_transpose, qrec, perm_op=None, gen_ctrl=None): + if gen_ctrl is None: + gen_ctrl = GenCtrl(None, cname=cname) + else: + gen_ctrl.cname = cname + + if qrec.out_qs[0].is_floating: + gen_ctrl.float_dump = 1 + + datasize = qrec.out_qs[0].dtype_bits//8 + if not qrec.out_qs[0].signed: + datasize = -datasize + + attrs = { + 'in_dim': params.in_dims[0], + 'out_dim': params.out_dims[0], + 'real_transpose': real_transpose, + 'size': params.out_dims[0].size(), + 'features': in_shape[0], + 'height': in_shape[1], + 'width': in_shape[2], + 'perm_op': perm_op, + 'datasize': datasize + } + + # other attributes + extra_attrs = { + 'cname': cname, + 'node_name': params.name + } + + super().__init__(attrs, extra_attrs, gen_ctrl=gen_ctrl) + + +class MatTransposeKernel(TransposeKernelBase): + CALL_TEMPLATE = ''' +// generator for {node_name} Transpose {in_dim} -> {out_dim} ({real_transpose}) +CNN_MatTranspose("{cname}", {gen_ctrl}, {datasize}, + {features}, {width}, {height}, KOP_MATTRANSP); +''' + + +class TensorPermuteKernel(TransposeKernelBase): + CALL_TEMPLATE = ''' +// generator for {node_name} Transpose {in_dim} -> {out_dim} ({real_transpose}) +CNN_3DTensorPermute("{cname}", {gen_ctrl}, {datasize}, + {features}, {width}, {height}, {perm_op}); +''' diff --git a/tools/nntool/generation/new_generators/generator_helpers.py b/tools/nntool/generation/new_generators/generator_helpers.py index 598bcf093..de5649470 100644 --- a/tools/nntool/generation/new_generators/generator_helpers.py +++ b/tools/nntool/generation/new_generators/generator_helpers.py @@ -30,6 +30,15 @@ 'globals': 'globals_generator', } +def test_option(cache, k, v): + if isinstance(v, bool): + return cache.get(k, False) == v + elif v is None: + return cache.get(k, None) is None + else: + return cache.get(k) == v + + class NewGenerator(): def __init__(self) -> None: self._generators = {} @@ -62,8 +71,8 @@ def new_execute_phase(self, phase_name, param, qrec, *args, break_on_true=False, gen_class = None if gen_class: if gen_class.QREC_OPTIONS is not None: - if not all(qrec.cache.get(k) == v for k, v in gen_class.QREC_OPTIONS.items()): - return res + if not all(test_option(qrec.cache, k, v) for k, v in gen_class.QREC_OPTIONS.items()): + continue LOG.debug("gen phase %s: matched generator class %s", phase_name, gen_class.__name__) diff --git a/tools/nntool/generation/new_generators/helpers/act_infos.py b/tools/nntool/generation/new_generators/helpers/act_infos.py index c8a24f610..c47d75ffe 100644 --- a/tools/nntool/generation/new_generators/helpers/act_infos.py +++ b/tools/nntool/generation/new_generators/helpers/act_infos.py @@ -1,114 +1,74 @@ -from quantization.qtype import QType +# Copyright (C) 2022 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + import numpy as np -from graph.types import (HSigmoidActivationParameters, HSwishActivationParameters, - LeakyActivationParameters, TanHActivationParameters, ReluActivationParameters, - SigmoidActivationParameters, SoftMaxParameters) -from quantization.multiplicative.mulbias import compute_in_out_scale -from quantization.symmetric.kernels.activations import (hsigmoid_mult_gen_factors, hswish_mult_gen_factors, leak_mult_gen_factor_q7) +from generation.gen_utils import ModelGenerationInternalError +from graph.types import (HSigmoidActivationParameters, + HSwishActivationParameters, LeakyActivationParameters, + ReluActivationParameters, SigmoidActivationParameters, + SoftMaxParameters, TanHActivationParameters) +from graph.types.activations import HTanHActivationParameters + def gen_act_infos(act_params, act_q): comment = "" if isinstance(act_params, ReluActivationParameters): - compute_in_out_scale(act_q) - actscale = act_q.cache['scale_mul_biases_q'].qbiases[0] - actscalen = act_q.cache['scale_mul_biases_q'].qnorms[0] - if act_params.upper_bound is None: # or fnode is not None: - if act_q.in_qs[0].zero_point == 0: - contents = np.array( - [actscale, actscalen, 0, 0, 0], dtype=np.int8) - if len(comment) == 0: - comment = "all 0" - else: - fac_1 = act_q.in_qs[0].zero_point - contents = np.array( - [actscale, actscalen, fac_1, 0, 0], dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} A0: {} B0: 0 C0: 0", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - fac_1[0]) - else: - if act_q.in_qs[0].zero_point == 0: - fac_1 = act_q.in_qs[0].quantize(act_params.upper_bound) - contents = np.array([actscale, actscalen, fac_1, 0, 0], - dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} A0: {} B0: 0 C0: 0", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - fac_1[0]) - else: - fac_1 = act_q.in_qs[0].zero_point - fac_2 = act_q.in_qs[0].quantize(act_params.upper_bound) - contents = np.array([actscale, actscalen, fac_1, fac_2, 0], - dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} A0: {} B0: {} C0: 0", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - fac_1[0], - fac_2[0]) - elif isinstance(act_params, HSigmoidActivationParameters): - # currently combines all scaling factors into one scale and shift - assert act_q.in_qs[0].zero_point == 0 and act_q.out_qs[0].zero_point == 0, "asymmetric not supported" - fac_1, upper_bound, _ = hsigmoid_mult_gen_factors(act_params, act_q) - contents = np.array([act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - upper_bound, fac_1, 1], - dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} qbias: {} qnorm: {} A0: {} B0: {} C0: 1", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - upper_bound[0], fac_1[0]) - elif isinstance(act_params, HSwishActivationParameters): - # currently combines all scaling factors into one scale and shift - assert act_q.in_qs[0].zero_point == 0 and act_q.out_qs[0].zero_point == 0, "asymmetric not supported" - fac_1, upper_bound, _ = hswish_mult_gen_factors(act_q) - contents = np.array([act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - upper_bound, fac_1, 1], - dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} qbias: {} qnorm: {} A0: {} B0: {} C0: 1", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - upper_bound[0], fac_1[0]) + contents = { + 'actscale': act_q.cache['scale_mul_biases_q'].qbiases.astype(np.uint8), + 'actscalen': act_q.cache['scale_mul_biases_q'].qnorms.astype(np.uint8) + } + contents.update({ + 'a0': act_q.cache['lower_bound'] if "lower_bound" in act_q.cache else np.uint8(0), + 'b0': act_q.cache['upper_bound'] if "upper_bound" in act_q.cache else np.uint8(0), + 'c0': np.uint8(0), + }) + + elif isinstance(act_params, (HSigmoidActivationParameters, HSwishActivationParameters)): + # mult factor is combined into scale + contents = { + 'actscale': act_q.cache['scale_mul_biases_q'].qbiases.astype(np.uint8), + 'actscalen': act_q.cache['scale_mul_biases_q'].qnorms.astype(np.uint8), + 'a0': act_q.cache['upper_bound'], + 'b0': act_q.cache['offset'], + 'c0': act_q.cache['zero_point'] + } elif isinstance(act_params, SoftMaxParameters): assert act_q.in_qs[0].zero_point == 0 and act_q.out_qs[0].zero_point == 0, "asymmetric not supported" - norm = 15 + np.ceil(np.log2(act_q.in_qs[0].scale)) - contents = np.array([norm, 0, 0, 0, 0], dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} NORM: {}", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - int(norm[0])) + contents = { + # 'bias_sm': np.uint8(15 + np.ceil(np.log2(act_q.in_qs[0].scale))) + 'bias_sm': act_q.cache['bias_sm'] + } elif isinstance(act_params, LeakyActivationParameters): - assert act_q.in_qs[0].zero_point == 0 and act_q.out_qs[0].zero_point == 0, "asymmetric not supported" - compute_in_out_scale(act_q) - leak_factor_quant = leak_mult_gen_factor_q7(act_params) - contents = np.array([act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - leak_factor_quant, 0, 0], - dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} qbias: {} qnorm: {} A0: {} B0: x C0: x", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - leak_factor_quant) + #assert act_q.in_qs[0].zero_point == 0 and act_q.out_qs[0].zero_point == 0, "asymmetric not supported" + contents = { + 'actscale': act_q.cache['scale_mul_biases_q'].qbiases.astype(np.uint8), + 'actscalen': act_q.cache['scale_mul_biases_q'].qnorms.astype(np.uint8), + 'a0': act_q.cache['leak_factor'], + 'b0': act_q.cache['zero_point'], + 'c0': np.uint8(0), + } elif isinstance(act_params, (SigmoidActivationParameters, TanHActivationParameters)): - assert act_q.in_qs[0].zero_point == 0 and act_q.out_qs[0].zero_point == 0, "asymmetric not supported" - compute_in_out_scale(act_q, extra_scale=QType.Pow2( - bits=32, q=7, signed=True).scale/act_q.in_qs[0].scale) - contents = np.array([act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0], - 0, 0, 0], - dtype=np.int8) - comment += str.format("in: {:05f} out: {:05f} qbias: {} qnorm: {} A0: x B0: x C0: x", - act_q.in_qs[0].scale[0], - act_q.out_qs[0].scale[0], - act_q.cache['scale_mul_biases_q'].qbiases[0], - act_q.cache['scale_mul_biases_q'].qnorms[0]) + contents = { + 'actscale': act_q.cache['scale_mul_biases_q'].qbiases.astype(np.uint8), + 'actscalen': act_q.cache['scale_mul_biases_q'].qnorms.astype(np.uint8), + 'a0': act_q.cache["zero_point"], + 'b0': np.uint8(0), + 'c0': np.uint8(0), + } else: - raise NotImplementedError("activation tye not implemented") + raise ModelGenerationInternalError( + f"activation type {act_params.__class__.__name__} not implemented in model generator") + comment += f"in: {act_q.in_qs[0].scale[0]:.5f} out: {act_q.out_qs[0].scale[0]:.5f} " return contents, comment diff --git a/tools/nntool/generation/new_generators/helpers/in_out_bindings_mixin.py b/tools/nntool/generation/new_generators/helpers/in_out_bindings_mixin.py index 88f2cde5f..c684bc0c3 100644 --- a/tools/nntool/generation/new_generators/helpers/in_out_bindings_mixin.py +++ b/tools/nntool/generation/new_generators/helpers/in_out_bindings_mixin.py @@ -40,3 +40,17 @@ def set_in_out_infos_bindings(cls, gen, in_eparams, out_eparams, cname, node, no NodeBindingList(cname, GNodeArgEdge(in_eparams[0]), GNodeArgEdge(out_eparams[0], "GNA_OUT"), GNodeArgNode(node, "infos"))) + @classmethod + def set_multi_in_out_bindings(cls, gen, in_eparams, out_eparams, cname, node, qrec): + gen.bindings.append( + CommentBindingList("Node {} in_qs [{}] out_qs [{}]", node.name, + ",".join(str(in_q) for in_q in qrec.in_qs), + ",".join(str(out_q) for out_q in qrec.out_qs)) + ) + + # the input order of the generated function can vary since it passes through a set + params = [GNodeArgEdge(in_eparams[idx]) for idx in node.input_shuffle] + \ + [GNodeArgEdge(out_eparams[idx], "GNA_OUT") for idx in node.output_shuffle] + gen.bindings.append( + NodeBindingList(cname, *params) + ) diff --git a/tools/nntool/generation/new_generators/mult8/conv_pool_mult8.py b/tools/nntool/generation/new_generators/mult8/conv_pool_mult8.py index 7720c2dd7..6e197e35e 100644 --- a/tools/nntool/generation/new_generators/mult8/conv_pool_mult8.py +++ b/tools/nntool/generation/new_generators/mult8/conv_pool_mult8.py @@ -13,34 +13,44 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from graph.dim import PadDim -from graph.types.pooling import PoolingParameters -from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType -from generation.new_generators.helpers.act_infos import gen_act_infos -from generation.helpers.gen_scales import gen_scales -from generation.at_types.at_params import NO_POOL, gen_activation_op, gen_conv_at_params, gen_pool_at_params import logging -from utils.node_id import NodeId +import os import numpy as np +from generation.at_types.at_params import (NO_POOL, gen_activation_op, + gen_conv_at_params, + gen_pool_at_params) from generation.at_types.constant_info import ConstantInfo from generation.at_types.gen_ctrl import GenCtrl from generation.at_types.tc_arg_info import GlobalArgInfo from generation.bindings import (CommentBindingList, GNodeArgEdge, GNodeArgNode, NodeBindingList) -from generation.generators.globals.global_names import INFOS, MULSCALE, MULSHIFT +from generation.generators.globals.global_names import (INFOS, MULSCALE, + MULSHIFT) from generation.generators.kernels.autotiler_kernel import NewAutoTilerKernel from generation.helpers.gen_constant import gen_constant -from generation.new_generators.generator_base import (GeneratorBase, - paramstype, ktype) +from generation.helpers.gen_scales import gen_scales +from generation.new_generators.generator_base import (GeneratorBase, ktype, + paramstype) +from generation.new_generators.helpers.act_infos import gen_act_infos +from graph.dim import PadDim from graph.types import Conv2DParameters, ConvFusionParameters +from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType from quantization.qtype import QType +from utils.diag_collector import thread_singleton +from utils.node_id import NodeId +from utils.process_header import InfosBase LOG = logging.getLogger("nntool." + __name__) def verify_scalar(arr): return [item.item() if isinstance(item, np.ndarray) else item for item in arr] +@thread_singleton +class SQ8ActInfos(InfosBase): + def __init__(self) -> None: + super().__init__('CNN_Infos_SQ8.h', [os.environ.get('TILER_CNN_KERNEL_PATH_SQ8')]) + @paramstype(Conv2DParameters, ConvFusionParameters) @ktype('scaled') class ConvActGenerator(GeneratorBase): @@ -49,7 +59,7 @@ class ConvActGenerator(GeneratorBase): def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: if isinstance(pnode, Conv2DParameters): gen_scales(gen, pnode, pnode, qrec) - infos, infos_comment = np.array([0, 0, 0, 0, 0]), "no activation" + infos, infos_comment = {}, "no activation" filt_q = qrec fnode = pnode elif isinstance(pnode, ConvFusionParameters) and isinstance(fnode, Conv2DParameters): @@ -62,30 +72,29 @@ def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: elif pnode.fusion_type == "conv_pool_active": infos, infos_comment = gen_act_infos(cnodes[2], quants[2]) elif pnode.fusion_type == "conv_pool": - infos, infos_comment = np.array([0, 0, 0, 0, 0]), "no activation" + infos, infos_comment = {}, "no activation" else: return False - infos = np.append(infos, [0, 0, 0, 0]) - comment = str.format("BiasQ: {}", 0) + infos_comment - infos[5] = 0 # BiasQ + + + infos['BIASN'] = np.int8(0) # BiasQ + conv_mul_bias = filt_q.cache.get('mul_biases_q') + infos['PRENORM'] = np.uint8(conv_mul_bias.pre_normalization if isinstance(conv_mul_bias, MultMulBiasScaleQType) else 0) if filt_q.cache.get('ne16'): - conv_mul_bias = filt_q.cache.get('mul_biases_q') - prenorm = conv_mul_bias.pre_normalization if isinstance(conv_mul_bias, MultMulBiasScaleQType) else 0 - pad_value = np.array(filt_q.in_qs[0].zero_point).astype(np.int16) - pad_value1 = np.bitwise_and(pad_value, 0xFF) - pad_value2 = np.bitwise_and(pad_value, 0xFF00) >> 8 - w_offset = -np.array(filt_q.in_qs[1].zero_point).astype(np.int32) - w_offset1 = np.bitwise_and(w_offset, 0xFF) - w_offset2 = np.bitwise_and(w_offset, 0xFF00) >> 8 - w_offset3 = np.bitwise_and(w_offset, 0xFF0000) >> 16 - w_offset4 = np.bitwise_and(w_offset, 0xFF000000) >> 24 - - infos = np.append( - infos, verify_scalar([prenorm if prenorm else 0, pad_value1, pad_value2, w_offset1, w_offset2, w_offset3, w_offset4])) + infos['NE16_PADVAL'] = np.atleast_1d(filt_q.in_qs[0].zero_point).astype(filt_q.in_qs[0].dtype) + infos['NE16_WOFFSET'] = -np.array(filt_q.in_qs[1].zero_point).astype(np.int32) + infos_len = 'NE16_DIM' + else: + infos_len = 'DIM' + + + infos_encoder = SQ8ActInfos() + contents, new_comment = infos_encoder.gen_infos_array(infos_len, **infos) + comment = infos_comment + new_comment cname, file_name = gen_constant(gen, pnode, fnode, INFOS) - const_info = ConstantInfo(file_name, QType.Pow2(bits=8, q=0, signed=True), contents=infos) + const_info = ConstantInfo(file_name, QType.Pow2(bits=8, q=0, signed=True), contents=contents) gen.globals.append(GlobalArgInfo("int8", cname, gen.opts['default_global_home_location'], gen.opts['default_global_exec_location'], @@ -214,6 +223,10 @@ def __init__(self, node_name, cname, conv_params, conv_q, pool_params, pool_q, a at_pad_ctrl = next(i for i, v in enumerate(reduction) if v) LOG.debug("%s: generating pad control block", node_name) self.gen_ctrl.PadType = at_pad_ctrl + # if conv_params is not None and conv_params.padding != 0: + # self.gen_ctrl.explicit_pad_conv = (conv_params.padding.l) | (conv_params.padding.r << 8) | (conv_params.padding.t << 16) | (conv_params.padding.b << 24) + # if pool_params is not None and pool_params.padding != 0: + # self.gen_ctrl.explicit_pad_pool = (pool_params.padding.l) | (pool_params.padding.r << 8) | (pool_params.padding.t << 16) | (pool_params.padding.b << 24) attrs = { 'in_size': in_q.dtype_bits//8 if in_q.signed else -in_q.dtype_bits//8, diff --git a/tools/nntool/generation/new_generators/mult8/linear_mult8.py b/tools/nntool/generation/new_generators/mult8/linear_mult8.py index 4bd9e0f68..9c6364661 100644 --- a/tools/nntool/generation/new_generators/mult8/linear_mult8.py +++ b/tools/nntool/generation/new_generators/mult8/linear_mult8.py @@ -1,4 +1,4 @@ -# Copyright (C) 2021 GreenWaves Technologies, SAS +# Copyright (C) 2021, 2022 GreenWaves Technologies, SAS # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -13,30 +13,32 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from generation.new_generators.mult8.conv_pool_mult8 import verify_scalar -from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType -from generation.new_generators.helpers.act_infos import gen_act_infos -from generation.helpers.gen_scales import gen_scales -from generation.at_types.at_params import gen_activation_op import logging -from utils.node_id import NodeId import numpy as np +from generation.at_types.at_params import gen_activation_op from generation.at_types.constant_info import ConstantInfo from generation.at_types.gen_ctrl import GenCtrl from generation.at_types.tc_arg_info import GlobalArgInfo from generation.bindings import (CommentBindingList, GNodeArgEdge, GNodeArgNode, NodeBindingList) -from generation.generators.globals.global_names import INFOS, MULSCALE, MULSHIFT +from generation.generators.globals.global_names import (INFOS, MULSCALE, + MULSHIFT) from generation.generators.kernels.autotiler_kernel import NewAutoTilerKernel from generation.helpers.gen_constant import gen_constant -from generation.new_generators.generator_base import (GeneratorBase, - paramstype, ktype) -from graph.types import LinearFusionParameters, FcParameters +from generation.helpers.gen_scales import gen_scales +from generation.new_generators.generator_base import (GeneratorBase, ktype, + paramstype) +from generation.new_generators.helpers.act_infos import gen_act_infos +from generation.new_generators.mult8.conv_pool_mult8 import SQ8ActInfos +from graph.types import FcParameters, LinearFusionParameters +from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType from quantization.qtype import QType +from utils.node_id import NodeId LOG = logging.getLogger("nntool." + __name__) + @paramstype(LinearFusionParameters, FcParameters) @ktype('scaled') class LinearActSQ8Generator(GeneratorBase): @@ -45,54 +47,59 @@ class LinearActSQ8Generator(GeneratorBase): def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: if isinstance(pnode, FcParameters): gen_scales(gen, pnode, pnode, qrec) - infos, infos_comment = np.array([0, 0, 0, 0, 0]), "no activation" + infos, infos_comment = {}, "no activation" fnode = pnode filt_q = qrec elif isinstance(pnode, LinearFusionParameters) and isinstance(fnode, FcParameters) and pnode.fusion_type == "linear_active": cnodes = pnode.contained_nodes() - quants = [gen.G.quantization[NodeId(pnode, fnode)] for fnode in cnodes] + quants = [gen.G.quantization[NodeId( + pnode, fnode)] for fnode in cnodes] filt_q = quants[0] gen_scales(gen, pnode, cnodes[0], quants[0]) infos, infos_comment = gen_act_infos(cnodes[1], quants[1]) else: return False - infos = np.append(infos, [0, 0, 0, 0]) - comment = str.format("BiasQ: {}", 0) + infos_comment - infos[5] = 0 # BiasQ + + infos['BIASN'] = np.int8(0) # BiasQ + conv_mul_bias = filt_q.cache.get('mul_biases_q') + infos['PRENORM'] = np.uint8(conv_mul_bias.pre_normalization if isinstance( + conv_mul_bias, MultMulBiasScaleQType) else 0) if filt_q.cache.get('ne16'): - conv_mul_bias = filt_q.cache.get('mul_biases_q') - prenorm = conv_mul_bias.pre_normalization if isinstance(conv_mul_bias, MultMulBiasScaleQType) else 0 - pad_value = np.array(filt_q.in_qs[0].zero_point).astype(np.int16) - pad_value1 = np.bitwise_and(pad_value, 0xFF) - pad_value2 = np.bitwise_and(pad_value, 0xFF00) >> 8 - w_offset = -np.array(filt_q.in_qs[1].zero_point).astype(np.int32) - w_offset1 = np.bitwise_and(w_offset, 0xFF) - w_offset2 = np.bitwise_and(w_offset, 0xFF00) >> 8 - w_offset3 = np.bitwise_and(w_offset, 0xFF0000) >> 16 - w_offset4 = np.bitwise_and(w_offset, 0xFF000000) >> 24 - - infos = np.append( - infos, verify_scalar([prenorm if prenorm else 0, pad_value1, pad_value2, w_offset1, w_offset2, w_offset3, w_offset4])) + infos['NE16_PADVAL'] = np.atleast_1d( + filt_q.in_qs[0].zero_point).astype(np.uint16) + infos['NE16_WOFFSET'] = - \ + np.array(filt_q.in_qs[1].zero_point).astype(np.int32) + infos_len = 'NE16_DIM' + else: + infos_len = 'DIM' + + infos_encoder = SQ8ActInfos() + contents, new_comment = infos_encoder.gen_infos_array(infos_len, **infos) + comment = infos_comment + new_comment cname, file_name = gen_constant(gen, pnode, fnode, INFOS) - const_info = ConstantInfo(file_name, QType.Pow2(bits=8, q=0, signed=True), contents=infos) + const_info = ConstantInfo(file_name, QType.Pow2( + bits=8, q=0, signed=True), contents=contents) gen.globals.append(GlobalArgInfo("int8", cname, - gen.opts['default_global_home_location'], - gen.opts['default_global_exec_location'], - const_info=const_info, - comment=comment)) + gen.opts['default_global_home_location'], + gen.opts['default_global_exec_location'], + const_info=const_info, + comment=comment)) return True @classmethod def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: step_idx = node.step_idx if isinstance(node, FcParameters): - set_fc_bindings(gen, step_idx, in_eparams, out_eparams, cname, node, qrec) + set_fc_bindings(gen, step_idx, in_eparams, + out_eparams, cname, node, qrec) elif isinstance(node, LinearFusionParameters): cnodes = node.contained_nodes() - quants = [gen.G.quantization[NodeId(node, fnode)] for fnode in cnodes] - set_fc_bindings(gen, step_idx, in_eparams, out_eparams, cname, cnodes[0], quants[0], out_q=quants[1]) + quants = [gen.G.quantization[NodeId( + node, fnode)] for fnode in cnodes] + set_fc_bindings(gen, step_idx, in_eparams, out_eparams, + cname, cnodes[0], quants[0], out_q=quants[1]) else: return False return True @@ -100,15 +107,18 @@ def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> @classmethod def kernel_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: if isinstance(node, FcParameters): - lin_kernel = LinearActNE16Kernel if qrec.cache.get("ne16") else LinearActSQ8Kernel + lin_kernel = LinearActNE16Kernel if qrec.cache.get( + "ne16") else LinearActSQ8Kernel gen.kernels.append( lin_kernel( node.name, cname, node, None, qrec, None, gen.force_relu) ) elif isinstance(node, LinearFusionParameters) and node.fusion_type == "linear_active": cnodes = node.contained_nodes() - quants = [gen.G.quantization[NodeId(node, fnode)] for fnode in cnodes] - lin_kernel = LinearActNE16Kernel if quants[0].cache.get("ne16") else LinearActSQ8Kernel + quants = [gen.G.quantization[NodeId( + node, fnode)] for fnode in cnodes] + lin_kernel = LinearActNE16Kernel if quants[0].cache.get( + "ne16") else LinearActSQ8Kernel gen.kernels.append( lin_kernel( node.name, cname, cnodes[0], cnodes[1], quants[0], quants[1], gen.force_relu) @@ -137,6 +147,7 @@ def set_fc_bindings(gen, step_idx, in_eparams, out_eparams, cname, GNodeArgNode(params, INFOS) )) + class LinearActKernel(NewAutoTilerKernel): def __init__(self, node_name, cname, linear_params, act_params, linear_q, act_q, force_relu, gen_ctrl=None): @@ -179,6 +190,7 @@ def __init__(self, node_name, cname, linear_params, act_params, linear_q, act_q, } super().__init__(attrs, extra_attrs, gen_ctrl=gen_ctrl) + class LinearActSQ8Kernel(LinearActKernel): CALL_TEMPLATE = """// generator for {node_name} CNN_LinearAct_SQ8("{cname}", {gen_ctrl}, @@ -187,6 +199,7 @@ class LinearActSQ8Kernel(LinearActKernel): KOP_LINEAR, {act_op}); """ + class LinearActNE16Kernel(LinearActKernel): CALL_TEMPLATE = """// generator for {node_name} CNN_LinearAct_NE16("{cname}", {gen_ctrl}, diff --git a/tools/nntool/generation/new_generators/mult8/matadd_mult8.py b/tools/nntool/generation/new_generators/mult8/matadd_mult8.py index 8a2b1b8c7..507a69e59 100644 --- a/tools/nntool/generation/new_generators/mult8/matadd_mult8.py +++ b/tools/nntool/generation/new_generators/mult8/matadd_mult8.py @@ -13,21 +13,27 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from graph.types.fusions import PaddedAddFusionParameters import logging from functools import reduce import numpy as np from generation.at_types.at_params import NO_ACTIVATION, gen_active_at_params +from generation.at_types.constant_info import ConstantInfo from generation.at_types.gen_ctrl import GenCtrl +from generation.at_types.tc_arg_info import GlobalArgInfo from generation.bindings import (CommentBindingList, GNodeArgEdge, GNodeArgNode, NodeBindingList) -from generation.generators.globals.mult8_infos_generator import act_infos +from generation.generators.globals.global_names import INFOS from generation.generators.kernels.autotiler_kernel import NewAutoTilerKernel +from generation.helpers.gen_constant import gen_constant from generation.new_generators.generator_base import (GeneratorBase, ktype, paramstype) -from graph.types import ActivationFusionBase, MatrixAddParameters, BroadcastableActivationFusion -from quantization.multiplicative.mulbias import set_add_in_scale +from generation.new_generators.helpers.act_infos import gen_act_infos +from generation.new_generators.mult8.conv_pool_mult8 import SQ8ActInfos +from graph.types import (ActivationFusionBase, BroadcastableActivationFusion, + MatrixAddParameters) +from graph.types.fusions import PaddedAddFusionParameters +from quantization.qtype import QType from utils.node_id import NodeId LOG = logging.getLogger("nntool." + __name__) @@ -43,37 +49,45 @@ def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: if isinstance(pnode, (ActivationFusionBase, BroadcastableActivationFusion)): cnodes = pnode.contained_nodes() quants = [gen.G.quantization[NodeId(pnode, cnode)] for cnode in cnodes] - if isinstance(fnode, MatrixAddParameters): - set_add_in_scale(quants[0]) - if not quants[0].in_qs[0].signed: - add_quant_bias_value1 = np.bitwise_and(quants[0].cache['add_bias_offset'], 0xFF) - add_quant_bias_value2 = np.bitwise_and(quants[0].cache['add_bias_offset'], 0xFF00) >> 8 - else: - add_quant_bias_value1 = add_quant_bias_value2 = None - - act_infos(gen, pnode, pnode, cnodes[1], quants[1], - extra1=quants[0].cache['scale_in_mul_biases_q'].qbiases[0], - extra2=quants[0].cache['scale_in_mul_biases_q'].qnorms[0], - extra3=quants[0].cache['scale_mul_biases_q'].qbiases[0], - extra4=quants[0].cache['scale_mul_biases_q'].qnorms[0], - extra5=add_quant_bias_value1, - extra6=add_quant_bias_value2) - return True + add_node = cnodes[0] + if isinstance(add_node, MatrixAddParameters): + if fnode: + return True + infos, acomments = gen_act_infos(cnodes[1], quants[1]) + add_quant = quants[0] else: return False - set_add_in_scale(qrec) - if not qrec.in_qs[0].signed: - add_quant_bias_value1 = np.bitwise_and(qrec.cache['add_bias_offset'], 0xFF) - add_quant_bias_value2 = np.bitwise_and(qrec.cache['add_bias_offset'], 0xFF00) >> 8 else: - add_quant_bias_value1 = add_quant_bias_value2 = None - act_infos(gen, pnode, pnode, None, None, - extra1=qrec.cache['scale_in_mul_biases_q'].qbiases[0], - extra2=qrec.cache['scale_in_mul_biases_q'].qnorms[0], - extra3=qrec.cache['scale_mul_biases_q'].qbiases[0], - extra4=qrec.cache['scale_mul_biases_q'].qnorms[0], - extra5=add_quant_bias_value1, - extra6=add_quant_bias_value2) + add_node = pnode + add_quant = qrec + infos = {} + acomments = "no activation - " + + infos.update({ + 'IN1SCALE': add_quant.cache['scale_in_mul_biases_q'].qbiases, + 'IN1SCALEN': add_quant.cache['scale_in_mul_biases_q'].qnorms, + 'OUTSCALE': add_quant.cache['scale_mul_biases_q'].qbiases, + 'OUTSCALEN': add_quant.cache['scale_mul_biases_q'].qnorms + }) + if not add_quant.in_qs[0].signed: + infos['ADD_BIAS'] = add_quant.cache['add_bias_offset'] + infos_len = 'ASYM_ADD_DIM' + else: + infos_len = 'DIM' + + + infos_encoder = SQ8ActInfos() + contents, new_comment = infos_encoder.gen_infos_array(infos_len, **infos) + comments = acomments + new_comment + + cname, file_name = gen_constant(gen, pnode, pnode, INFOS) + const_info = ConstantInfo(file_name, QType.Pow2( + bits=8, q=0, signed=True), contents=contents) + gen.globals.append(GlobalArgInfo("int8", cname, + gen.opts['default_global_home_location'], + gen.opts['default_global_exec_location'], + const_info=const_info, + comment=comments)) return True @classmethod @@ -89,7 +103,7 @@ def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> else: out_q = qrec - set_add_in_scale(qrec) + # set_add_in_scale(qrec) scaled_idx = qrec.cache['scaled_idx'] not_scaled_idx = 0 if scaled_idx else 1 gen.bindings.append( diff --git a/tools/nntool/generation/new_generators/mult8/matmul_mult8.py b/tools/nntool/generation/new_generators/mult8/matmul_mult8.py index c09c847db..cdb59f43b 100644 --- a/tools/nntool/generation/new_generators/mult8/matmul_mult8.py +++ b/tools/nntool/generation/new_generators/mult8/matmul_mult8.py @@ -1,4 +1,4 @@ -# Copyright (C) 2021 GreenWaves Technologies, SAS +# Copyright (C) 2021, 2022 GreenWaves Technologies, SAS # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -13,29 +13,32 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from generation.new_generators.mult8.conv_pool_mult8 import verify_scalar -from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType -from graph.types.tensor_arithmetic import MatMulTransposedParameters -from generation.bindings import CommentBindingList, GNodeArgEdge, GNodeArgNode, NodeBindingList -from generation.helpers.gen_scales import gen_scales -from generation.at_generators.utils import at_bits -from generation.new_generators.helpers.in_out_bindings_mixin import InOutBindingsMixin -from generation.new_generators.helpers.act_infos import gen_act_infos -from generation.at_types.at_params import NO_POOL, gen_activation_op import logging -from utils.node_id import NodeId import numpy as np +from generation.at_generators.utils import at_bits +from generation.at_types.at_params import gen_activation_op from generation.at_types.constant_info import ConstantInfo from generation.at_types.gen_ctrl import GenCtrl from generation.at_types.tc_arg_info import GlobalArgInfo -from generation.generators.globals.global_names import INFOS, MULSCALE, MULSHIFT +from generation.bindings import (CommentBindingList, GNodeArgEdge, + GNodeArgNode, NodeBindingList) +from generation.gen_utils import ModelGenerationInternalError +from generation.generators.globals.global_names import (INFOS, MULSCALE, + MULSHIFT) from generation.generators.kernels.autotiler_kernel import NewAutoTilerKernel from generation.helpers.gen_constant import gen_constant -from generation.new_generators.generator_base import (GeneratorBase, - paramstype, ktype) -from graph.types import MatMulOpParameters, MatMulOpFusionParameters, ActivationParameters +from generation.helpers.gen_scales import gen_scales +from generation.new_generators.generator_base import (GeneratorBase, ktype, + paramstype) +from generation.new_generators.helpers.act_infos import gen_act_infos +from generation.new_generators.mult8.conv_pool_mult8 import SQ8ActInfos +from graph.types import (ActivationParameters, MatMulOpFusionParameters, + MatMulOpParameters) +from graph.types.tensor_arithmetic import MatMulTransposedParameters +from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType from quantization.qtype import QType +from utils.node_id import NodeId LOG = logging.getLogger("nntool." + __name__) @@ -48,45 +51,49 @@ def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: if isinstance(pnode, MatMulOpParameters): mul_node = pnode mul_qrec = qrec - fnode = pnode - infos, comment = np.array([0, 0, 0, 0, 0]), "no activation" - elif isinstance(pnode, MatMulOpFusionParameters) and isinstance(fnode, MatMulOpParameters): + infos, comment = {}, "no activation" + elif isinstance(pnode, MatMulOpFusionParameters): cnodes = pnode.contained_nodes() - quants = [gen.G.quantization[NodeId( - pnode, fnode)] for fnode in cnodes] mul_node = cnodes[0] - mul_qrec = quants[0] - infos, comment = gen_act_infos(cnodes[1], quants[1]) + if isinstance(mul_node, MatMulOpParameters): + if fnode is not None: + return True + quants = [gen.G.quantization[NodeId( + pnode, fnode)] for fnode in cnodes] + mul_node = cnodes[0] + mul_qrec = quants[0] + infos, comment = gen_act_infos(cnodes[1], quants[1]) + else: + return False else: return False if len(mul_qrec.in_qs[1].scale) > 1: gen_scales(gen, pnode, mul_node, mul_qrec) - pl_scale = 0 - pl_scalen = 0 + infos['OUTSCALE'] = np.uint8(0) + infos['OUTSCALEN'] = np.uint8(0) else: - pl_scale = mul_qrec.cache['mul_biases_q'].qbiases[0] - pl_scalen = mul_qrec.cache['mul_biases_q'].qnorms[0] + infos['OUTSCALE'] = mul_qrec.cache['mul_biases_q'].qbiases[0] + infos['OUTSCALEN'] = mul_qrec.cache['mul_biases_q'].qnorms[0] - infos = np.append(infos, [0, 0, pl_scale, pl_scalen]) + conv_mul_bias = mul_qrec.cache.get('mul_biases_q') + infos['PRENORM'] = np.uint8(conv_mul_bias.pre_normalization if isinstance(conv_mul_bias, MultMulBiasScaleQType) else 0) if mul_qrec.cache.get('ne16'): - conv_mul_bias = mul_qrec.cache.get('mul_biases_q') - prenorm = conv_mul_bias.pre_normalization if isinstance(conv_mul_bias, MultMulBiasScaleQType) else 0 - pad_value = np.array(mul_qrec.in_qs[0].zero_point).astype(np.int16) - pad_value1 = np.bitwise_and(pad_value, 0xFF) - pad_value2 = np.bitwise_and(pad_value, 0xFF00) >> 8 - w_offset = -np.array(mul_qrec.in_qs[1].zero_point).astype(np.int32) - w_offset1 = np.bitwise_and(w_offset, 0xFF) - w_offset2 = np.bitwise_and(w_offset, 0xFF00) >> 8 - w_offset3 = np.bitwise_and(w_offset, 0xFF0000) >> 16 - w_offset4 = np.bitwise_and(w_offset, 0xFF000000) >> 24 - - infos = np.append( - infos, verify_scalar([prenorm if prenorm else 0, pad_value1, pad_value2, w_offset1, w_offset2, w_offset3, w_offset4])) - - cname, file_name = gen_constant(gen, pnode, fnode, INFOS) - const_info = ConstantInfo(file_name, QType.Pow2(bits=8, q=0, signed=True), contents=infos) + infos['NE16_PADVAL'] = np.atleast_1d( + mul_qrec.in_qs[0].zero_point).astype(mul_qrec.in_qs[0].dtype) + infos['NE16_WOFFSET'] = - \ + np.array(mul_qrec.in_qs[1].zero_point).astype(np.int32) + infos_len = 'NE16_DIM' + else: + infos_len = 'DIM' + + infos_encoder = SQ8ActInfos() + contents, new_comment = infos_encoder.gen_infos_array(infos_len, **infos) + comment += new_comment + + cname, file_name = gen_constant(gen, pnode, mul_node, INFOS) + const_info = ConstantInfo(file_name, QType.Pow2(bits=8, q=0, signed=True), contents=contents) gen.globals.append(GlobalArgInfo("int8", cname, gen.opts['default_global_home_location'], gen.opts['default_global_exec_location'], @@ -179,12 +186,41 @@ def set_matmul_bindings(gen, in_eparams, out_eparams, cname, node, node_q, out_q GNodeArgEdge(out_eparams[0], "GNA_OUT"), GNodeArgNode(node, INFOS))) +def calculate_dimensions(node_name, matmul_params): + in1_shape = tuple(matmul_params.in_dims[0].shape) + in2_shape = tuple(matmul_params.in_dims[1].shape) + + rank1 = len(in1_shape) + rank2 = len(in2_shape) + + if rank2 <= 2: + if rank2 == 1: + # TODO - is this correct if transposed? + in2_shape = (in2_shape[0], 1) + channels = 1 + if rank1 > 2 and not all(dim == 1 for dim in in1_shape[:-2]): + in1_shape = (int(np.prod(in1_shape[:-1])), in1_shape[-1]) + elif rank1 == 1: + in1_shape = (1, in1_shape[0]) + elif rank1 == rank2 and in1_shape[:-2] == in2_shape[:-2]: + channels = np.prod(in1_shape[:-2]) + LOG.warning(f'Matmul over batches is not yet properly generated - output will not be correct') + else: + raise ModelGenerationInternalError( + f'{node_name} Invalid dimensions for matmul kernel {in1_shape} {in2_shape}') + + height_1 = in1_shape[-2] + width_1 = in1_shape[-1] + height_2 = in2_shape[-2] + width_2 = in2_shape[-1] + return height_1,width_1, height_2, width_2, channels + class MatMulKernel(NewAutoTilerKernel): CALL_TEMPLATE = '''// generator for {node_name} -CNN_MatMulAct_SQ8("{cname}", {gen_ctrl}, {bias_datasize}, 1, - {width_1}, {height_1}, {width_2}, {height_2}, - 0, 0, 1, 1, {matmul_op}, {act_op}); +CNN_BatchedMatMulAct_SQ8("{cname}", {gen_ctrl}, {bias_datasize}, 1, + {batch_size}, {width_1}, {height_1}, {width_2}, {height_2}, + 0, 0, 1, 1, {matmul_op}, {act_op}); ''' def __init__(self, node_name, cname, matmul_params, matmul_qrec, act_params, gen_ctrl=None, force_relu=True): @@ -200,10 +236,7 @@ def __init__(self, node_name, cname, matmul_params, matmul_qrec, act_params, gen else: act_op = 'KOP_NONE' - height_1 = matmul_params.in_dims[0][0] - width_1 = matmul_params.in_dims[0][1] - height_2 = matmul_params.in_dims[1][0] - width_2 = matmul_params.in_dims[1][1] + height_1, width_1, height_2, width_2, batch_size = calculate_dimensions(node_name, matmul_params) if len(matmul_params.in_dims) == 3: bias_datasize = at_bits(matmul_qrec.in_qs[2]) @@ -217,8 +250,7 @@ def __init__(self, node_name, cname, matmul_params, matmul_qrec, act_params, gen if isinstance(matmul_params, MatMulTransposedParameters): matmul_op += '_TRANSPOSED' - height_2 = matmul_params.in_dims[1][1] - width_2 = matmul_params.in_dims[1][0] + height_2, width_2 = width_2, height_2 # attributes affecting generation attrs = { @@ -226,6 +258,7 @@ def __init__(self, node_name, cname, matmul_params, matmul_qrec, act_params, gen 'width_1': width_1, 'height_2': height_2, 'width_2': width_2, + 'batch_size': batch_size, 'bias_datasize': bias_datasize, 'matmul_op': matmul_op, 'act_op': act_op @@ -238,6 +271,7 @@ def __init__(self, node_name, cname, matmul_params, matmul_qrec, act_params, gen } super().__init__(attrs, extra_attrs, gen_ctrl=gen_ctrl) + class MatMulKernelNE16(NewAutoTilerKernel): CALL_TEMPLATE = '''// generator for {node_name} CNN_MatMulAct_NE16("{cname}", {gen_ctrl}, {in1_datasize}, {out_datasize}, {bias_datasize}, {in2_datasize_bits}, @@ -258,10 +292,7 @@ def __init__(self, node_name, cname, matmul_params, matmul_qrec, act_params, gen else: act_op = 'KOP_NONE' - height_1 = matmul_params.in_dims[0][0] - width_1 = matmul_params.in_dims[0][1] - height_2 = matmul_params.in_dims[1][1] - width_2 = matmul_params.in_dims[1][0] + height_1, width_1, width_2, height_2, channels = calculate_dimensions(node_name, matmul_params) bias_datasize = at_bits(matmul_qrec.in_qs[2]) in1_datasize = at_bits(matmul_qrec.in_qs[0]) in2_datasize_bits = matmul_qrec.in_qs[1].bits diff --git a/tools/nntool/generation/new_generators/mult8/padded_matadd_mult8.py b/tools/nntool/generation/new_generators/mult8/padded_matadd_mult8.py index 5fe872b8f..c6de99bd2 100644 --- a/tools/nntool/generation/new_generators/mult8/padded_matadd_mult8.py +++ b/tools/nntool/generation/new_generators/mult8/padded_matadd_mult8.py @@ -14,60 +14,100 @@ # along with this program. If not, see . import logging +from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType + +import numpy as np from generation.at_types.at_params import NO_ACTIVATION, gen_activation_op +from generation.at_types.constant_info import ConstantInfo from generation.at_types.gen_ctrl import GenCtrl +from generation.at_types.tc_arg_info import GlobalArgInfo from generation.bindings import (CommentBindingList, GNodeArgEdge, GNodeArgNode, NodeBindingList) -from generation.generators.globals.mult8_infos_generator import act_infos +from generation.generators.globals.global_names import INFOS from generation.generators.kernels.autotiler_kernel import NewAutoTilerKernel +from generation.helpers.gen_constant import gen_constant from generation.new_generators.generator_base import (GeneratorBase, ktype, paramstype) +from generation.new_generators.helpers.act_infos import gen_act_infos +from generation.new_generators.mult8.conv_pool_mult8 import SQ8ActInfos from generation.new_generators.mult8.matadd_mult8 import make_three_dims -from graph.types import MatrixAddParameters, ActivationParameters, PaddedAddFusionParameters -from quantization.multiplicative.mulbias import compute_in_out_scale, set_add_in_scale +from graph.types import (ActivationParameters, MatrixAddParameters, + PaddedAddFusionParameters) +from quantization.qtype import QType from utils.node_id import NodeId LOG = logging.getLogger("nntool." + __name__) - @paramstype(PaddedAddFusionParameters) @ktype("scaled") class PaddedMatAddSQ8Generator(GeneratorBase): @classmethod def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: - cnodes = node.contained_nodes() - quants = [gen.G.quantization[NodeId(node, fnode)] for fnode in cnodes] - for qrec in quants: - compute_in_out_scale(qrec) - act_node = [cnode for cnode in cnodes if isinstance( - cnode, ActivationParameters)] - act_node = act_node[0] if act_node else None - act_qrec = quants[-1] if act_node else None - set_add_in_scale(quants[1]) - act_infos(gen, pnode, pnode, act_node, act_qrec, - extra1=quants[1].cache['scale_in_mul_biases_q'].qbiases[0], - extra2=quants[1].cache['scale_in_mul_biases_q'].qnorms[0], - extra3=quants[1].cache['scale_mul_biases_q'].qbiases[0], - extra4=quants[1].cache['scale_mul_biases_q'].qnorms[0]) - act_infos(gen, pnode, cnodes[0], act_node, act_qrec, extra_name="Pad", - extra1=quants[1].cache['scale_mul_biases_q'].qbiases[0], - extra2=quants[1].cache['scale_mul_biases_q'].qnorms[0]) + cnodes = pnode.contained_nodes() + quants = [gen.G.quantization[NodeId(pnode, cnode)] for cnode in cnodes] + + if len(cnodes) == 3: + assert isinstance(cnodes[2], ActivationParameters) + infos, acomments = gen_act_infos(cnodes[2], quants[2]) + else: + infos, acomments = {}, "no activation" + + # TODO: Why separate infos? Ask Marco + + infos1 = infos.copy() + infos1.update({ + 'IN1SCALE': quants[1].cache['scale_in_mul_biases_q'].qbiases, + 'IN1SCALEN': quants[1].cache['scale_in_mul_biases_q'].qnorms, + 'OUTSCALE': quants[1].cache['scale_mul_biases_q'].qbiases, + 'OUTSCALEN': quants[1].cache['scale_mul_biases_q'].qnorms + }) + infos_encoder = SQ8ActInfos() + contents, comments = infos_encoder.gen_infos_array('DIM', **infos1) + + cname, file_name = gen_constant(gen, pnode, pnode, INFOS) + const_info = ConstantInfo(file_name, QType.Pow2( + bits=8, q=0, signed=True), contents=contents) + gen.globals.append(GlobalArgInfo("int8", cname, + gen.opts['default_global_home_location'], + gen.opts['default_global_exec_location'], + const_info=const_info, + comment=comments)) + + # Padded part needs to apply out scale of the matadd + act scale + double_scale = MultMulBiasScaleQType( + dtype=np.uint8, + scale=quants[1].cache['scale_mul_biases_q'].scale * quants[2].cache['scale_mul_biases_q'].scale \ + if len(cnodes) == 3 else \ + quants[1].cache['scale_mul_biases_q'].scale + ) + infos['actscale'] = double_scale.qbiases + infos['actscalen'] = double_scale.qnorms + infos_encoder = SQ8ActInfos() + contents, comments = infos_encoder.gen_infos_array('DIM', **infos) + + cname, file_name = gen_constant(gen, pnode, cnodes[0], INFOS, extra_name='Pad') + const_info = ConstantInfo(file_name, QType.Pow2( + bits=8, q=0, signed=True), contents=contents) + gen.globals.append(GlobalArgInfo("int8", cname, + gen.opts['default_global_home_location'], + gen.opts['default_global_exec_location'], + const_info=const_info, + comment=comments)) return True + @classmethod - def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: - step_idx = node.step_idx - cnodes = node.contained_nodes() - quants = [gen.G.quantization[NodeId(node, fnode)] for fnode in cnodes] + def bindings_generator(cls, gen, pnode, qrec, in_eparams, out_eparams, cname) -> bool: + cnodes = pnode.contained_nodes() + quants = [gen.G.quantization[NodeId(pnode, fnode)] for fnode in cnodes] add_node = [node for node in cnodes if isinstance( node, MatrixAddParameters)] if add_node: quants = [gen.G.quantization[NodeId( - node, fnode)] for fnode in cnodes] + pnode, fnode)] for fnode in cnodes] - set_add_in_scale(quants[1]) scaled_idx = quants[1].cache['scaled_idx'] not_scaled_idx = 0 if scaled_idx else 1 gen.bindings.append( @@ -78,8 +118,8 @@ def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> NodeBindingList(cname, GNodeArgEdge(in_eparams[scaled_idx]), GNodeArgEdge(in_eparams[not_scaled_idx]), GNodeArgEdge(out_eparams[0], "GNA_OUT"), - GNodeArgNode(node, 'infos'), - GNodeArgNode(node.contained_nodes()[0], 'infos') + GNodeArgNode(pnode, 'infos'), + GNodeArgNode(cnodes[0], 'infos') )) return True diff --git a/tools/nntool/generation/new_generators/mult8/pool_mult8.py b/tools/nntool/generation/new_generators/mult8/pool_mult8.py index 45cbd7851..f98a9e881 100644 --- a/tools/nntool/generation/new_generators/mult8/pool_mult8.py +++ b/tools/nntool/generation/new_generators/mult8/pool_mult8.py @@ -1,4 +1,4 @@ -# Copyright (C) 2021 GreenWaves Technologies, SAS +# Copyright (C) 2021, 2022 GreenWaves Technologies, SAS # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -13,78 +13,100 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from functools import reduce -from utils.largest_factor import balanced_divisors -from quantization.multiplicative.mulbias import compute_in_out_scale -from generation.new_generators.helpers.in_out_bindings_mixin import InOutBindingsMixin -from graph.types.global_pooling import GlobalAveragePoolParameters, GlobalSumPoolParameters -from graph.dim import PadDim -from generation.new_generators.helpers.act_infos import gen_act_infos -from generation.at_types.at_params import NO_POOL, gen_activation_op, gen_globalpool_at_params, gen_pool_at_params import logging -from utils.node_id import NodeId +from functools import reduce import numpy as np +from generation.at_types.at_params import (gen_activation_op, + gen_globalpool_at_params, + gen_pool_at_params) from generation.at_types.constant_info import ConstantInfo from generation.at_types.gen_ctrl import GenCtrl from generation.at_types.tc_arg_info import GlobalArgInfo from generation.generators.globals.global_names import INFOS from generation.generators.kernels.autotiler_kernel import NewAutoTilerKernel from generation.helpers.gen_constant import gen_constant -from generation.new_generators.generator_base import (GeneratorBase, - paramstype, ktype) -from graph.types import GlobalPoolingParameters, PoolingParameters, ActivationFusion +from generation.new_generators.generator_base import (GeneratorBase, ktype, + paramstype) +from generation.new_generators.helpers.act_infos import gen_act_infos +from generation.new_generators.helpers.in_out_bindings_mixin import \ + InOutBindingsMixin +from generation.new_generators.mult8.conv_pool_mult8 import SQ8ActInfos +from graph.dim import PadDim +from graph.types import (ActivationFusion, ActivationParameters, + GlobalPoolingParameters, GlobalSumPoolParameters, + PoolingParameters) from quantization.qtype import QType +from utils.largest_factor import balanced_divisors +from utils.node_id import NodeId LOG = logging.getLogger("nntool." + __name__) -@paramstype(ActivationFusion, GlobalPoolingParameters, PoolingParameters) + +@paramstype(ActivationFusion, GlobalPoolingParameters, PoolingParameters, ActivationParameters) @ktype('scaled') class PoolActGenerator(GeneratorBase, InOutBindingsMixin): @classmethod def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: if isinstance(pnode, (GlobalPoolingParameters, PoolingParameters, GlobalSumPoolParameters)): - compute_in_out_scale(qrec) - infos, comment = np.array([qrec.cache['scale_mul_biases_q'].qbiases[0], - qrec.cache['scale_mul_biases_q'].qnorms[0], - 0, 0, 0]), "no activation" - fnode = pnode + infos = { + 'ACTSCALE': qrec.cache['scale_mul_biases_q'].qbiases.astype(np.uint8), + 'ACTSCALEN': qrec.cache['scale_mul_biases_q'].qnorms.astype(np.uint8) + } + comment = "no activation" + pool_node = pnode pool_q = qrec - elif isinstance(pnode, ActivationFusion) and isinstance(fnode, (GlobalPoolingParameters, PoolingParameters)): + elif isinstance(pnode, ActivationFusion): cnodes = pnode.contained_nodes() - quants = [gen.G.quantization[NodeId(pnode, fnode)] for fnode in cnodes] - pool_q = quants[0] - infos, comment = gen_act_infos(cnodes[1], quants[1]) + pool_node = cnodes[0] + if isinstance(pool_node, (GlobalPoolingParameters, PoolingParameters)) and isinstance(cnodes[1], ActivationParameters): + if fnode is not None: + return True + quants = [gen.G.quantization[NodeId( + pnode, fnode)] for fnode in cnodes] + pool_q = quants[0] + infos, comment = gen_act_infos(cnodes[1], quants[1]) + else: + return False + elif isinstance(pnode, ActivationParameters): + pool_node = None + infos, comment = gen_act_infos(node, qrec) else: return False - infos = np.append(infos, [0, 0, 0, 0]) - if isinstance(fnode, GlobalSumPoolParameters): - compute_in_out_scale(pool_q, in_idx=0, out_idx=0) - infos[0] = 0 - infos[1] = 0 - infos[5] = pool_q.cache['scale_mul_biases_q'].qbiases[0] - infos[6] = pool_q.cache['scale_mul_biases_q'].qnorms[0] - - cname, file_name = gen_constant(gen, pnode, fnode, INFOS) - const_info = ConstantInfo(file_name, QType.Pow2(bits=8, q=0, signed=True), contents=infos) + + if pool_node and isinstance(pool_node, GlobalSumPoolParameters): + # compute_in_out_scale(pool_q, in_idx=0, out_idx=0) + infos['ACTSCALE'] = infos['ACTSCALEN'] = np.int8(0) + infos['GLOBAL_SUM_SCALE'] = pool_q.cache['scale_mul_biases_q'].qbiases + infos['GLOBAL_SUM_SCALEN'] = pool_q.cache['scale_mul_biases_q'].qnorms + + infos_encoder = SQ8ActInfos() + contents, new_comment = infos_encoder.gen_infos_array('DIM', **infos) + comment += new_comment + + cname, file_name = gen_constant(gen, pnode, pnode, INFOS) + const_info = ConstantInfo(file_name, QType.Pow2( + bits=8, q=0, signed=True), contents=contents) gen.globals.append(GlobalArgInfo("int8", cname, - gen.opts['default_global_home_location'], - gen.opts['default_global_exec_location'], - const_info=const_info, - comment=comment)) + gen.opts['default_global_home_location'], + gen.opts['default_global_exec_location'], + const_info=const_info, + comment=comment)) return True @classmethod def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: if isinstance(node, ActivationFusion): cnodes = node.contained_nodes() - if isinstance(cnodes[0], (GlobalPoolingParameters, PoolingParameters)): - cls.set_in_out_infos_bindings(gen, in_eparams, out_eparams, cname, cnodes[0], qrec) + if isinstance(cnodes[0], (GlobalPoolingParameters, PoolingParameters, ActivationParameters)): + cls.set_in_out_infos_bindings( + gen, in_eparams, out_eparams, cname, node, qrec) return True return False - elif isinstance(node, (GlobalPoolingParameters, PoolingParameters)): - cls.set_in_out_infos_bindings(gen, in_eparams, out_eparams, cname, node, qrec) + elif isinstance(node, (GlobalPoolingParameters, PoolingParameters, ActivationParameters)): + cls.set_in_out_infos_bindings( + gen, in_eparams, out_eparams, cname, node, qrec) else: return False return True @@ -92,17 +114,25 @@ def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> @classmethod def kernel_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: if isinstance(node, (GlobalPoolingParameters, PoolingParameters)): - pool_kernel = PoolActKernel if isinstance(node, PoolingParameters) else GlobalPoolActKernel + pool_kernel = PoolActKernel if isinstance( + node, PoolingParameters) else GlobalPoolActKernel gen.kernels.append(pool_kernel(node.name, cname, node, qrec, None, None, force_relu=gen.force_relu, gen_ctrl=node.get_gen_ctrl())) elif isinstance(node, ActivationFusion): cnodes = node.contained_nodes() - quants = [gen.G.quantization[NodeId(node, fnode)] for fnode in cnodes] - pool_kernel = PoolActKernel if isinstance(cnodes[0], PoolingParameters) else GlobalPoolActKernel + quants = [gen.G.quantization[NodeId( + node, fnode)] for fnode in cnodes] + pool_kernel = PoolActKernel if isinstance( + cnodes[0], PoolingParameters) else GlobalPoolActKernel gen.kernels.append(pool_kernel(node.name, cname, cnodes[0], quants[0], cnodes[1], quants[1], force_relu=gen.force_relu, gen_ctrl=node.get_gen_ctrl())) + elif isinstance(node, ActivationParameters): + gen.kernels.append(PoolActKernel(node.name, cname, None, None, node, qrec, + force_relu=gen.force_relu, gen_ctrl=node.get_gen_ctrl())) + return True + class PoolActKernel(NewAutoTilerKernel): CALL_TEMPLATE = """// generator for {node_name} CNN_PoolAct_SQ8("{cname}", {gen_ctrl}, @@ -110,27 +140,54 @@ class PoolActKernel(NewAutoTilerKernel): {kop_pool}, {fpx}, {fpy}, {dpx}, {dpy}, {spx}, {spy}, {pool_pad}, {kop_act}); """ + def __init__(self, node_name, cname, pool_params, pool_q, act_params, act_q, force_relu, gen_ctrl=None): if gen_ctrl is None: self.gen_ctrl = gen_ctrl = GenCtrl(None, cname=cname) else: gen_ctrl.cname = cname self.gen_ctrl = gen_ctrl - if pool_params.ker_in_order and pool_params.ker_in_order[0] == ["h", "w", "c"]: - hwc = True - gen_ctrl.hwc = 1 pad_compatibilities = [] - at_pool_params = gen_pool_at_params( - pool_params, pad_compatibilities) - in_dim = pool_params.in_dims[0] - out_dim = pool_params.out_dims[0] - in_q = pool_q.in_qs[0] - out_q = pool_q.out_qs[0] + if pool_params is not None: + if pool_params.ker_in_order and pool_params.ker_in_order[0] == ["h", "w", "c"]: + gen_ctrl.hwc = 1 + at_pool_params = gen_pool_at_params( + pool_params, pad_compatibilities) + pool_pad_settings = { + 'fpx': at_pool_params.Fpx, + 'fpy': at_pool_params.Fpy, + 'dpx': at_pool_params.Dpx, + 'dpy': at_pool_params.Dpy, + 'spx': at_pool_params.Spx, + 'spy': at_pool_params.Spy, + 'pool_pad': at_pool_params.PoolPad, + } + in_dim = pool_params.in_dims[0] + out_dim = pool_params.out_dims[0] + in_q = pool_q.in_qs[0] + out_q = pool_q.out_qs[0] + if pool_params.pool_type == "average": + pool_op = "KOP_AVGPOOL" + elif pool_params.pool_type == "max": + pool_op = "KOP_MAXPOOL" + else: + raise NotImplementedError() + else: + # only activation + pool_op = "KOP_NONE" + if act_params is None: + raise ValueError('neither pool nor activation is set') + out_dim = in_dim = None if act_params is not None: act_op = gen_activation_op( act_params.activation, force_relu=force_relu, asymmetric=act_q.in_qs[0].zero_point != 0) + if in_dim is None: + in_q = act_q.in_qs[0] + in_dim = act_params.in_dims[0].expand_to_chw() + pool_pad_settings = {k: 0 for k in ['fpx', 'fpy', 'dpx', 'dpy', + 'spx', 'spy', 'pool_pad']} if out_dim is None: out_dim = act_params.out_dims[0].expand_to_chw() out_q = act_q.out_qs[0] @@ -145,35 +202,37 @@ def __init__(self, node_name, cname, pool_params, pool_q, act_params, act_q, for LOG.debug("%s: generating pad control block", node_name) self.gen_ctrl.PadType = at_pad_ctrl + if not out_q.signed: + gen_ctrl.output_datasize = -out_q.dtype_bits//8 + if not in_q.signed: + gen_ctrl.input_datasize = -in_q.dtype_bits//8 + attrs = { 'in_size': in_q.dtype_bits//8 if in_q.signed else -in_q.dtype_bits//8, 'out_size': out_q.dtype_bits//8 if out_q.signed else -out_q.dtype_bits//8, 'feat': in_dim.c, 'width': in_dim.w, 'height': in_dim.h, - 'kop_pool': at_pool_params.PoolOper, - 'fpx': at_pool_params.Fpx, - 'fpy': at_pool_params.Fpy, - 'dpx': at_pool_params.Dpx, - 'dpy': at_pool_params.Dpy, - 'spx': at_pool_params.Spx, - 'spy': at_pool_params.Spy, - 'pool_pad': at_pool_params.PoolPad, + 'kop_pool': pool_op, 'kop_act': act_op } + attrs.update(pool_pad_settings) + extra_attrs = { 'cname': cname, 'node_name': node_name } super().__init__(attrs, extra_attrs, gen_ctrl=gen_ctrl) + class GlobalPoolActKernel(NewAutoTilerKernel): CALL_TEMPLATE = """// generator for {node_name} CNN_GlobalPoolAct_SQ8("{cname}", {gen_ctrl}, {feat}, {width}, {height}, {kop_pool}, {kop_act}); """ + def __init__(self, node_name, cname, pool_params, pool_q, act_params, act_q, force_relu, gen_ctrl=None): if gen_ctrl is None: self.gen_ctrl = gen_ctrl = GenCtrl(None, cname=cname) @@ -181,7 +240,6 @@ def __init__(self, node_name, cname, pool_params, pool_q, act_params, act_q, for gen_ctrl.cname = cname self.gen_ctrl = gen_ctrl - at_pool_params = gen_globalpool_at_params(pool_params) in_dim = pool_params.in_dims[0] out_dim = pool_params.out_dims[0] in_q = pool_q.in_qs[0] @@ -201,13 +259,23 @@ def __init__(self, node_name, cname, pool_params, pool_q, act_params, act_q, for else: act_op = "KOP_NONE" + if pool_params.pool_type == "average": + pool_op = "KOP_GLOBAL_AVGPOOL" + elif pool_params.pool_type == "max": + pool_op = "KOP_GLOBAL_MAXPOOL" + elif pool_params.pool_type == "sum": + pool_op = "KOP_GLOBAL_SUMPOOL" + else: + raise NotImplementedError( + f'global pool type {pool_params.pool_type} has no AT kernel') + attrs = { 'in_size': in_q.dtype_bits//8 if in_q.signed else -in_q.dtype_bits//8, 'out_size': out_q.dtype_bits//8 if out_q.signed else -out_q.dtype_bits//8, 'feat': feat, 'width': width, 'height': height, - 'kop_pool': at_pool_params.GlobalPoolOper, + 'kop_pool': pool_op, 'kop_act': act_op } diff --git a/tools/nntool/generation/new_generators/mult8/rnn_mult8.py b/tools/nntool/generation/new_generators/mult8/rnn_mult8.py new file mode 100644 index 000000000..30987b3ec --- /dev/null +++ b/tools/nntool/generation/new_generators/mult8/rnn_mult8.py @@ -0,0 +1,582 @@ +# Copyright (C) 2021, 2022 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging + +import numpy as np +from execution.kernels.quant.rnn import internal_qtype +from generation.at_types.constant_info import ConstantInfo +from generation.at_types.gen_ctrl import GenCtrl +from generation.at_types.tc_arg_info import (GlobalArgInfo, GlobalResetArgInfo, + LocalArgInfo) +from generation.bindings import (CommentBindingList, GArgName, GNodeArgEdge, + GNodeArgNode, NoArg, NodeBindingList) +from generation.generators.globals.global_names import INFOS +from generation.generators.kernels.autotiler_kernel import NewAutoTilerKernel +from generation.helpers.gen_constant import gen_constant +from generation.new_generators.generator_base import (GeneratorBase, ktype, qrec_options, + paramstype) +from graph.types import (GRUParameters, LSTMParameters, RNNBaseParameters, + RNNParameters) +from graph.types.lstm import LSTMParameters +from graph.types.rnn import GRUParameters, RNNParameters +from quantization.qtype import QType + +LOG = logging.getLogger("nntool." + __name__) + + +@paramstype(RNNParameters, GRUParameters, LSTMParameters) +@qrec_options(ne16=False) +@ktype('scaled') +class RNNGenerator(GeneratorBase): + + @classmethod + def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: + del pnode + if fnode is not None: + return False + if isinstance(node, RNNParameters): + rnn_infos(gen, node, qrec) + elif isinstance(node, LSTMParameters): + lstm_infos(gen, node, qrec) + elif isinstance(node, GRUParameters): + gru_infos(gen, node, qrec) + else: + raise ValueError() + if node.rnn_states_as_inputs: + gen.globals.append(GlobalResetArgInfo( + f"{node.name}_Reset", 'AT_MEM_L2', 'AT_MEM_UNDEF')) + return True + + @classmethod + def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: + step_idx = node.step_idx + if isinstance(node, RNNParameters): + cls.set_rnn_bindings(gen, step_idx, in_eparams, + out_eparams, cname, node, qrec) + elif isinstance(node, LSTMParameters): + cls.set_lstm_bindings(gen, step_idx, in_eparams, + out_eparams, cname, node, qrec) + elif isinstance(node, GRUParameters): + cls.set_gru_bindings(gen, step_idx, in_eparams, + out_eparams, cname, node, qrec) + + return True + + @classmethod + def num_sequences(cls, node: RNNBaseParameters): + n1 = min(node.n_input_cells, node.n_cells - node.n_output_cells) + n3 = node.n_cells - max(node.n_input_cells, + node.n_cells - node.n_output_cells) + n2 = node.n_cells - (n1 + n3) + return sum(1 if n > 0 else 0 for n in [n1, n2, n3]) + + @classmethod + def set_lstm_bindings(cls, gen, step_idx, in_eparams, out_eparams, cname, + rnn_params, rnn_q): + + names = rnn_params.get_name_indexes() + + gen.bindings.append( + CommentBindingList("Node {} inq {} outq {}", cname, + rnn_q.in_qs[0], + rnn_q.out_qs[0]) + ) + c_state_eparams = in_eparams[names['c_state']] + i_state_eparams = in_eparams[names['i_state']] + + num_seq = cls.num_sequences(rnn_params) + if num_seq > 1: + gen.locals.append(LocalArgInfo( + "int8", "S%s_CellInternal01" % step_idx)) + gen.locals.append(LocalArgInfo( + "int8", "S%s_StateInternal01" % step_idx)) + + if num_seq > 2: + gen.locals.append(LocalArgInfo( + "int8", "S%s_CellInternal02" % step_idx)) + gen.locals.append(LocalArgInfo( + "int8", "S%s_StateInternal02" % step_idx)) + + reset_name = i_state_eparams.creating_node.reset_name if not rnn_params.rnn_states_as_inputs else f"{rnn_params.name}_Reset" + gen.bindings.append( + NodeBindingList(cname, + GNodeArgEdge(c_state_eparams, + direction="GNA_INOUT"), + GNodeArgEdge(i_state_eparams, + direction="GNA_INOUT"), + GNodeArgEdge("S%s_CellInternal01" % step_idx, alias=c_state_eparams, + direction="GNA_INOUT") if num_seq > 1 else NoArg(), + GNodeArgEdge("S%s_StateInternal01" % step_idx, alias=i_state_eparams, + direction="GNA_INOUT") if num_seq > 1 else NoArg(), + GNodeArgEdge("S%s_CellInternal02" % step_idx, alias="S%s_CellInternal01" % + step_idx, direction="GNA_INOUT") if num_seq > 2 else NoArg(), + GNodeArgEdge("S%s_StateInternal02" % step_idx, alias="S%s_CellInternal01" % + step_idx, direction="GNA_INOUT") if num_seq > 2 else NoArg(), + GNodeArgEdge(in_eparams[0]), + GNodeArgEdge(in_eparams[names['r_2_f_w']]), + GNodeArgEdge(in_eparams[names['f_b']]), + GNodeArgEdge(in_eparams[names['r_2_i_w']]), + GNodeArgEdge(in_eparams[names['i_b']]), + GNodeArgEdge(in_eparams[names['r_2_c_w']]), + GNodeArgEdge(in_eparams[names['c_b']]), + GNodeArgEdge(in_eparams[names['r_2_o_w']]), + GNodeArgEdge(in_eparams[names['o_b']]), + GNodeArgEdge(out_eparams[0], direction="GNA_OUT"), + GNodeArgNode(rnn_params, INFOS), + GArgName(reset_name) + )) + + @classmethod + def set_rnn_bindings(cls, gen, step_idx, in_eparams, out_eparams, cname, + rnn_params, rnn_q): + names = rnn_params.get_name_indexes() + + gen.bindings.append( + CommentBindingList("Node {} inq {} weightsq {} outq {} biasesq {}", cname, + rnn_q.in_qs[0], rnn_q.in_qs[names['r_2_i_w']], + rnn_q.out_qs[0], rnn_q.in_qs[names['i_b']]) + ) + num_seq = cls.num_sequences(rnn_params) + if num_seq > 1: + gen.locals.append(LocalArgInfo( + "int8", "S%s_StateInternal01" % step_idx)) + + if num_seq > 2: + gen.locals.append(LocalArgInfo( + "int8", "S%s_StateInternal02" % step_idx)) + + i_state_eparams = in_eparams[names['i_state']] + reset_name = i_state_eparams.creating_node.reset_name if not rnn_params.rnn_states_as_inputs else f"{rnn_params.name}_Reset" + gen.bindings.append( + NodeBindingList(cname, + GNodeArgEdge(i_state_eparams, + direction="GNA_INOUT"), + GNodeArgEdge("S%s_StateInternal01" % step_idx, alias=i_state_eparams, + direction="GNA_INOUT") if num_seq > 1 else NoArg(), + GNodeArgEdge("S%s_StateInternal02" % step_idx, alias="S%s_CellInternal01" % + step_idx, direction="GNA_INOUT") if num_seq > 2 else NoArg(), + GNodeArgEdge(in_eparams[0]), + GNodeArgEdge(in_eparams[names['r_2_i_w']]), + GNodeArgEdge(in_eparams[names['i_b']]), + GNodeArgEdge(out_eparams[0], direction="GNA_OUT"), + GNodeArgNode(rnn_params, INFOS), + GArgName(reset_name) + )) + + @classmethod + def set_gru_bindings(cls, gen, step_idx, in_eparams, out_eparams, cname, + rnn_params, rnn_q): + names = rnn_params.get_name_indexes() + + gen.bindings.append( + CommentBindingList("Node {} inq {} outq {}", cname, + rnn_q.in_qs[0], + rnn_q.out_qs[0]) + ) + num_seq = cls.num_sequences(rnn_params) + if num_seq > 1: + gen.locals.append(LocalArgInfo( + "int8", "S%s_StateInternal01" % step_idx)) + + if num_seq > 2: + gen.locals.append(LocalArgInfo( + "int8", "S%s_StateInternal02" % step_idx)) + + i_state_eparams = in_eparams[names['h_state']] + reset_name = i_state_eparams.creating_node.reset_name if not rnn_params.rnn_states_as_inputs else f"{rnn_params.name}_Reset" + gen.bindings.append( + NodeBindingList(cname, + GNodeArgEdge(i_state_eparams, + direction="GNA_INOUT"), + GNodeArgEdge("S%s_StateInternal01" % step_idx, alias=i_state_eparams, + direction="GNA_INOUT") if num_seq > 1 else NoArg(), + GNodeArgEdge("S%s_StateInternal02" % step_idx, alias="S%s_CellInternal01" % + step_idx, direction="GNA_INOUT") if num_seq > 2 else NoArg(), + GNodeArgEdge(in_eparams[0]), + GNodeArgEdge(in_eparams[names['r_2_r_w']]), + GNodeArgEdge(in_eparams[names['r_b']]), + GNodeArgEdge(in_eparams[names['r_2_z_w']]), + GNodeArgEdge(in_eparams[names['z_b']]), + GNodeArgEdge(in_eparams[names['r_2_h_w']]), + GNodeArgEdge(in_eparams[names['w_h_b']]), + GNodeArgEdge(in_eparams[names['r_h_b']]), + GNodeArgEdge(out_eparams[0], direction="GNA_OUT"), + GNodeArgNode(rnn_params, INFOS), + GArgName(reset_name) + )) + + @classmethod + def kernel_generator(cls, gen, params, qrec, in_eparams, out_eparams, cname) -> bool: + del in_eparams, out_eparams + + if isinstance(params, RNNParameters): + kernel = RNNKernel + elif isinstance(params, LSTMParameters): + kernel = LSTMKernel + elif isinstance(params, GRUParameters): + kernel = GRUKernel + if not params.linear_before_reset: + # gen_ctrl.linear_before_reset = 0 + raise ValueError( + "In {} linear_before_reset == 0 not supported by the Autotiler kernels") + else: + raise ValueError("unknown RNN parameter type") + + gen.kernels.append(kernel(params.name, cname, params, qrec)) + return True + + +class RNNKernelBase(NewAutoTilerKernel): + def __init__(self, node_name, cname, params, qrec, gen_ctrl=None): + if gen_ctrl is None: + gen_ctrl = GenCtrl(None, cname=cname) + else: + gen_ctrl.cname = cname + + if not params.hard_act: + gen_ctrl.rnn_use_hardact = 0 + if not params.rnn_same_inout_scale: + gen_ctrl.rnn_same_inout_scale = 0 + + # attributes affecting generation + attrs = { + 'n_cells': params.n_cells, + 'n_states': params.n_states, + 'n_inputs': params.n_inputs, + 'k0': params.n_input_cells, + 'k1': params.n_output_cells, + 'revert': 1 if params.revert else 0 + } + + # other attributes + extra_attrs = { + 'cname': cname, + 'node_name': node_name + } + super().__init__(attrs, extra_attrs, gen_ctrl=gen_ctrl) + + +class RNNKernel(RNNKernelBase): + CALL_TEMPLATE = '''// generator for {node_name} +RNN_Stack_SQ8("{cname}", {gen_ctrl}, 4, 1, {n_cells}, {k0}, {k1}, {n_states}, {n_inputs}, 0, {revert}); +''' + + +class GRUKernel(RNNKernelBase): + CALL_TEMPLATE = '''// generator for {node_name} +GRU_Stack_SQ8("{cname}", {gen_ctrl}, 4, 1, {n_cells}, {k0}, {k1}, {n_states}, {n_inputs}, 0, {revert}); +''' + + +class LSTMKernel(RNNKernelBase): + CALL_TEMPLATE = '''// generator for {node_name} +LSTM_Stack_SQ8("{cname}", {gen_ctrl}, 4, 1, {n_cells}, {k0}, {k1}, {n_states}, {n_inputs}, 0, {revert}); +''' + + +def sigmoid_infos(gate_name, mult_qtype, qtype): + scale = mult_qtype.qbiases[0] + scale_n = mult_qtype.qnorms[0] + three = qtype.quantize(np.array([3]))[0] + sixth = qtype.quantize(np.array([1/6]))[0] + six = qtype.quantize(np.array([6]))[0] + actn = qtype.q + comment = str.format("{0}_scale: {1} {0}_scale_n: {2} A0: {3} B0: {4} C0: {5}", + gate_name, scale, scale_n, six, three, sixth, 1, actn) + contents = np.array([scale, scale_n, six, three, + sixth, 1, actn], dtype=np.int8) + return contents, comment + + +def htanh_infos(gate_name, mult_qtype, qtype): + scale = mult_qtype.qbiases[0] + scale_n = mult_qtype.qnorms[0] + one = qtype.quantize(np.array([1]))[0] + comment = str.format("{0}_scale: {1} {0}_scale_n: {2} A0: {3} B0: {4}", + gate_name, scale, scale_n, -one, one) + contents = np.array([scale, scale_n, -one, one], dtype=np.int8) + return contents, comment + + +def scale_infos(gate_name, mult_qtype): + scale = mult_qtype.qbiases[0] + scale_n = mult_qtype.qnorms[0] + comment = str.format("{0}_scale: {1} {0}_scale_n: {2}", + gate_name, scale, scale_n) + contents = np.array([scale, scale_n], dtype=np.int8) + return contents, comment + + +LSTM_INFOS_ORDER = { + 'f': 'sigmoid', + 'i': 'sigmoid', + 'c': 'htanh', + 'o': 'sigmoid', +} + +GRU_INFOS_ORDER = { + 'r': 'sigmoid', + 'z': 'sigmoid', + 'h': 'htanh', +} + +INFOS_FUNCS = { + 'sigmoid': sigmoid_infos, + 'htanh': htanh_infos, + 'tanh': htanh_infos, +} + + +def highb(x): + return (x >> 8) & 0xff + + +def lowb(x): + return x & 0xff + +# define LSTM_F_INF 2 +# define LSTM_F_OFF 0 +# define LSTM_F_SCALE 0 +# define LSTM_F_SCALEN 1 + +# define LSTM_I_INF 2 +# define LSTM_I_OFF (LSTM_F_OFF+LSTM_F_INF) +# define LSTM_I_SCALE (0 + LSTM_I_OFF) +# define LSTM_I_SCALEN (1 + LSTM_I_OFF) + +# define LSTM_G_INF 2 +# define LSTM_G_OFF (LSTM_I_OFF+LSTM_I_INF) +# define LSTM_G_SCALE (0 + LSTM_G_OFF) +# define LSTM_G_SCALEN (1 + LSTM_G_OFF) + +# define LSTM_O_INF 2 +# define LSTM_O_OFF (LSTM_G_OFF+LSTM_G_INF) +# define LSTM_O_SCALE (0 + LSTM_O_OFF) +# define LSTM_O_SCALEN (1 + LSTM_O_OFF) + +# define LSTM_COUT_INF 6 +# define LSTM_COUT_OFF (LSTM_O_OFF+LSTM_O_INF) +# define LSTM_CIN_SCALE (0 + LSTM_COUT_OFF) +# define LSTM_CIN_SCALEN (1 + LSTM_COUT_OFF) +# define LSTM_COUT_SCALE (2 + LSTM_COUT_OFF) +# define LSTM_COUT_SCALEN (3 + LSTM_COUT_OFF) +# define LSTM_OUT_SCALE (4 + LSTM_COUT_OFF) +# define LSTM_OUT_SCALEN (5 + LSTM_COUT_OFF) + +# define LSTM_INT_INF 7 +# define LSTM_INT_OFF (LSTM_COUT_OFF+LSTM_COUT_INF) +# define LSTM_INT_A0 (0 + LSTM_INT_OFF) +# define LSTM_INT_B0 (2 + LSTM_INT_OFF) +# define LSTM_INT_C0 (4 + LSTM_INT_OFF) +# define LSTM_INT_Q (6 + LSTM_INT_OFF) + +# define LSTM_X_IN_INF 7 +# define LSTM_X_IN_OFF (LSTM_INT_OFF+LSTM_INT_INF) +# define LSTM_F_IN_SCALE (0 + LSTM_X_IN_OFF) +# define LSTM_F_IN_SCALEN (1 + LSTM_X_IN_OFF) +# define LSTM_I_IN_SCALE (2 + LSTM_X_IN_OFF) +# define LSTM_I_IN_SCALEN (3 + LSTM_X_IN_OFF) +# define LSTM_G_IN_SCALE (4 + LSTM_X_IN_OFF) +# define LSTM_G_IN_SCALEN (5 + LSTM_X_IN_OFF) +# define LSTM_O_IN_SCALE (6 + LSTM_X_IN_OFF) +# define LSTM_O_IN_SCALEN (7 + LSTM_X_IN_OFF) + + +def lstm_infos(gen, node, qrec): + i_qtype = internal_qtype(qrec) + contents = [] + comments = [] + for k, v in LSTM_INFOS_ORDER.items(): + info, comment = scale_infos(k, qrec.cache["r_2_%s_q" % k]) + contents.append(info) + comments.append(comment) + cin_scale = qrec.cache['cell_in_q'].qbiases[0] + cin_scalen = qrec.cache['cell_in_q'].qnorms[0] + cout_scale = qrec.cache['cell_out_q'].qbiases[0] + cout_scalen = qrec.cache['cell_out_q'].qnorms[0] + out_scale = qrec.cache['state_out_q'].qbiases[0] + out_scalen = qrec.cache['state_out_q'].qnorms[0] + comments.append(str.format("cin_scale: {} cin_scale_n: {} cout_scale: {} cout_scale_n: {}", + cin_scale, cin_scalen, cout_scale, cout_scalen,)) + + comments.append(str.format("out_scale: {} out_scale_n: {}", + out_scale, out_scalen)) + contents.append(np.array([cin_scale, cin_scalen, cout_scale, cout_scalen, + out_scale, out_scalen], dtype=np.int8)) + + three = i_qtype.quantize(np.array([3]))[0] + six = i_qtype.quantize(np.array([6]))[0] + sixth = i_qtype.quantize(np.array([1/6]))[0] + + comments.append(str.format("int_q: {} A0: {} B0: {} C0: {}", + i_qtype.q, six, three, sixth)) + contents.append(np.array([lowb(six), highb(six), + lowb(three), highb(three), + lowb(sixth), highb(sixth), i_qtype.q], + dtype=np.int8)) + + for k in LSTM_INFOS_ORDER.keys(): + info, comment = scale_infos(k, qrec.cache["i_2_%s_q" % k]) + contents.append(info) + comments.append(comment) + + cname, file_name = gen_constant(gen, node, node, INFOS) + const_info = ConstantInfo(file_name, QType.Pow2(bits=8, q=0, signed=True), + contents=np.hstack(tuple(contents))) + + gen.globals.append(GlobalArgInfo("int8", cname, + gen.opts['default_global_home_location'], + gen.opts['default_global_exec_location'], + const_info=const_info, + comment=" ".join(comments))) + +# define RNN_F_INF 8 +# define RNN_F_OFF 0 +# define RNN_F_SCALE 0 +# define RNN_F_SCALEN 1 +# define RNN_F_A0 2 +# define RNN_F_B0 3 + +# define RNN_F_IN_SCALE 4 +# define RNN_F_IN_SCALEN 5 +# define RNN_OUT_SCALE 6 +# define RNN_OUT_SCALEN 7 + + +def rnn_infos(gen, node, qrec): + i_state_q = qrec.in_qs[node.INPUT_NAMES.index('i_state')] + + contents = [] + comments = [] + + # info for activation (scale the act input to the proper scale) + info, comment = INFOS_FUNCS[node.activation]( + "f", qrec.cache['s_2_s_q'], i_state_q) + contents.append(info) + comments.append(comment) + + # info for input scaling (only used with non SameInputStateScale kernels) + info, comment = scale_infos("f", qrec.cache["i_2_a_q"]) + contents.append(info) + comments.append(comment) + + # info for scaling the activation out to out scale (only used for non Hard activations kernels) + info, comment = scale_infos("f", qrec.cache["s_2_o_q"]) + contents.append(info) + comments.append(comment) + + cname, file_name = gen_constant(gen, node, node, INFOS) + const_info = ConstantInfo(file_name, QType.Pow2(bits=8, q=0, signed=True), + contents=np.hstack(tuple(contents))) + + gen.globals.append(GlobalArgInfo("int8", cname, + gen.opts['default_global_home_location'], + gen.opts['default_global_exec_location'], + const_info=const_info, + comment=comment)) + +# define GRU_R_INF 4 +# define GRU_R_OFF 0 +# define GRU_R_INT_SCALE 0 +# define GRU_R_INT_SCALEN 1 +# define GRU_R_IN_SCALE 2 +# define GRU_R_IN_SCALEN 3 + +# define GRU_Z_INF 4 +# define GRU_Z_OFF (GRU_R_OFF+GRU_R_INF) +# define GRU_Z_INT_SCALE (0 + GRU_Z_OFF) +# define GRU_Z_INT_SCALEN (1 + GRU_Z_OFF) +# define GRU_Z_IN_SCALE (2 + GRU_Z_OFF) +# define GRU_Z_IN_SCALEN (3 + GRU_Z_OFF) + +# define GRU_HT_INF 2 +# define GRU_HT_OFF (GRU_Z_OFF+GRU_Z_INF) +# define GRU_HT_IN_SCALE (0 + GRU_HT_OFF) +# define GRU_HT_IN_SCALEN (1 + GRU_HT_OFF) + +# define GRU_H_INF 2 +# define GRU_H_OFF (GRU_HT_OFF+GRU_HT_INF) +# define GRU_H_INT_SCALE (0 + GRU_H_OFF) +# define GRU_H_INT_SCALEN (1 + GRU_H_OFF) + +# define GRU_INT_INF 3 +# define GRU_INT_OFF (GRU_H_OFF+GRU_H_INF) +# define GRU_INT_A0 (2 + GRU_INT_OFF) +# define GRU_INT_B0 (3 + GRU_INT_OFF) +# define GRU_INT_C0 (4 + GRU_INT_OFF) + +# define GRU_CELL_INFOS (GRU_R_INF+GRU_Z_INF+GRU_HT_INF+GRU_H_INF+GRU_INT_INF) + + +def gru_infos(gen, node, qrec): + i_qtype = internal_qtype(qrec) + contents = [] + comments = [] + r_to_int_scale = qrec.cache['r_WR_2_int_q'].qbiases[0] + r_to_int_scalen = qrec.cache['r_WR_2_int_q'].qnorms[0] + r_to_in_scale = qrec.cache['i_2_r_WR_q'].qbiases[0] + r_to_in_scalen = qrec.cache['i_2_r_WR_q'].qnorms[0] + z_to_int_scale = qrec.cache['z_WR_2_int_q'].qbiases[0] + z_to_int_scalen = qrec.cache['z_WR_2_int_q'].qnorms[0] + z_to_in_scale = qrec.cache['i_2_z_WR_q'].qbiases[0] + z_to_in_scalen = qrec.cache['i_2_z_WR_q'].qnorms[0] + ht_to_in_scale = qrec.cache['i_2_h_WR_q'].qbiases[0] + ht_to_in_scalen = qrec.cache['i_2_h_WR_q'].qnorms[0] + h_to_int_scale = qrec.cache['h_WR_2_int_q'].qbiases[0] + h_to_int_scalen = qrec.cache['h_WR_2_int_q'].qnorms[0] + + # GRU_R_INFOS + comments.append(str.format("r_to_int_scale: {} r_to_int_scalen: {} r_to_in_scale: {} r_to_in_scalen: {}", + r_to_int_scale, r_to_int_scalen, r_to_in_scale, r_to_in_scalen,)) + contents.append(np.array( + [r_to_int_scale, r_to_int_scalen, r_to_in_scale, r_to_in_scalen], dtype=np.int8)) + + # GRU_Z_INFOS + comments.append(str.format("z_to_int_scale: {} z_to_int_scalen: {} z_to_in_scale: {} z_to_in_scalen: {}", + z_to_int_scale, z_to_int_scalen, z_to_in_scale, z_to_in_scalen,)) + contents.append(np.array( + [z_to_int_scale, z_to_int_scalen, z_to_in_scale, z_to_in_scalen], dtype=np.int8)) + + # GRU_HT_INFOS + comments.append(str.format("ht_to_in_scale: {} ht_to_in_scalen: {}", + ht_to_in_scale, ht_to_in_scalen,)) + contents.append(np.array([ht_to_in_scale, ht_to_in_scalen], dtype=np.int8)) + + # GRU_H_INFOS + comments.append(str.format("h_to_int_scale: {} h_to_int_scalen: {}", + h_to_int_scale, h_to_int_scalen,)) + contents.append(np.array([h_to_int_scale, h_to_int_scalen], dtype=np.int8)) + + three = i_qtype.quantize(np.array([3]))[0] + six = i_qtype.quantize(np.array([6]))[0] + sixth = i_qtype.quantize(np.array([1/6]))[0] + + comments.append(str.format("int_q: {} A0: {} B0: {} C0: {}", + i_qtype.q, six, three, sixth)) + contents.append(np.array([lowb(six), highb(six), + lowb(three), highb(three), + lowb(sixth), highb(sixth), i_qtype.q], + dtype=np.int8)) + + cname, file_name = gen_constant(gen, node, node, INFOS) + const_info = ConstantInfo(file_name, QType.Pow2(bits=8, q=0, signed=True), + contents=np.hstack(tuple(contents))) + + gen.globals.append(GlobalArgInfo("int8", cname, + gen.opts['default_global_home_location'], + gen.opts['default_global_exec_location'], + const_info=const_info, + comment=" ".join(comments))) diff --git a/tools/nntool/generation/new_generators/mult8/softmax_mult.py b/tools/nntool/generation/new_generators/mult8/softmax_mult.py new file mode 100644 index 000000000..98cf23325 --- /dev/null +++ b/tools/nntool/generation/new_generators/mult8/softmax_mult.py @@ -0,0 +1,120 @@ +# Copyright (C) 2021, 2022 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging + +import numpy as np +from generation.at_types.constant_info import ConstantInfo +from generation.at_types.gen_ctrl import GenCtrl +from generation.at_types.tc_arg_info import GlobalArgInfo +from generation.generators.globals.global_names import (INFOS) +from generation.generators.kernels.autotiler_kernel import NewAutoTilerKernel +from generation.helpers.gen_constant import gen_constant +from generation.helpers.gen_scales import gen_scales +from generation.new_generators.generator_base import (GeneratorBase, ktype, + paramstype) +from generation.new_generators.helpers.in_out_bindings_mixin import \ + InOutBindingsMixin +from generation.new_generators.mult8.conv_pool_mult8 import SQ8ActInfos +from graph.types import SoftMaxParameters +from quantization.qtype import QType +from utils.node_id import NodeId + +LOG = logging.getLogger("nntool." + __name__) + +@paramstype(SoftMaxParameters) +@ktype('scaled') +class SoftMaxGenerator(GeneratorBase, InOutBindingsMixin): + + @classmethod + def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: + assert qrec.in_qs[0].zero_point == 0 and qrec.out_qs[0].zero_point == 0, "asymmetric not supported" + norm = 15 + np.ceil(np.log2(qrec.in_qs[0].scale)) + infos = { + 'BIASL_SM': np.uint8(15 + np.ceil(np.log2(qrec.in_qs[0].scale))) + } + comment = f"in: {qrec.in_qs[0].scale[0]:.5f} out: {qrec.out_qs[0].scale[0]:.5f} " + + infos_encoder = SQ8ActInfos() + contents, new_comment = infos_encoder.gen_infos_array('DIM', **infos) + comment += new_comment + + cname, file_name = gen_constant(gen, pnode, pnode, INFOS) + const_info = ConstantInfo(file_name, QType.Pow2(bits=8, q=0, signed=True), contents=contents) + gen.globals.append(GlobalArgInfo("int8", cname, + gen.opts['default_global_home_location'], + gen.opts['default_global_exec_location'], + const_info=const_info, + comment=comment)) + return True + + @classmethod + def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: + cls.set_in_out_infos_bindings(gen, in_eparams, out_eparams, cname, node, qrec) + return True + + @classmethod + def kernel_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> bool: + del in_eparams, out_eparams + + is_2d = (node.in_dims[0].size() // node.in_dims[0].shape[node.axis]) != 1 + if is_2d: + kernel = SoftMax2DKernel(node.name, cname, node, qrec) + else: + kernel = SoftMaxKernel(node.name, cname, node, qrec) + gen.kernels.append(kernel) + return True + +class SoftMaxKernelBase(NewAutoTilerKernel): + def __init__(self, node_name, cname, params, qrec, gen_ctrl=None): + if gen_ctrl is None: + self.gen_ctrl = gen_ctrl = GenCtrl(None, cname=cname) + else: + gen_ctrl.cname = cname + self.gen_ctrl = gen_ctrl + + if (not qrec.out_qs[0].dtype_bits == 16) or (not qrec.out_qs[0].signed): + self.gen_ctrl.output_datasize = qrec.out_qs[0].dtype_bits//8 if qrec.out_qs[0].signed else -qrec.out_qs[0].dtype_bits//8 + + in_dim = params.in_dims[0] + axis = params.axis + + softmax_op = 'KOP_SOFTMAX' + + # attributes affecting generation + attrs = { + 'size': in_dim.size(), + 'width': in_dim.size()//in_dim.shape[axis], + 'height': in_dim.shape[axis], + 'softmax_op': softmax_op + } + + # other attributes + extra_attrs = { + 'cname': cname, + 'node_name': node_name + } + super().__init__(attrs, extra_attrs, gen_ctrl=gen_ctrl) + + +class SoftMaxKernel(SoftMaxKernelBase): + CALL_TEMPLATE = '''// generator for {node_name} +CNN_SoftMax_SQ8("{cname}", {gen_ctrl}, {size}, {softmax_op}); +''' + +class SoftMax2DKernel(SoftMaxKernelBase): + CALL_TEMPLATE = '''// generator for {node_name} +CNN_SoftMax2D_SQ8("{cname}", {gen_ctrl}, {height}, {width}, {softmax_op}); +''' diff --git a/tools/nntool/generation/new_generators/ne16/gru_ne16.py b/tools/nntool/generation/new_generators/ne16/gru_ne16.py index 34a6db4af..b7a352828 100644 --- a/tools/nntool/generation/new_generators/ne16/gru_ne16.py +++ b/tools/nntool/generation/new_generators/ne16/gru_ne16.py @@ -71,9 +71,6 @@ def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: gen.opts['default_global_exec_location'], const_info=const_info, comment=f"{node.name} scales and norms")) - if node.rnn_states_as_inputs: - gen.globals.append(GlobalResetArgInfo( - f"{node.name}_Reset", 'AT_MEM_L2', 'AT_MEM_UNDEF')) out_q = qrec.out_qs[0] @@ -131,7 +128,11 @@ def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> f"unsigned {in_ctype}", f"S{step_idx}_StateInternal02")) i_state_eparams = in_eparams[names['h_state']] - reset_name = i_state_eparams.creating_node.reset_name if node.rnn_states_as_inputs else "Reset" + if node.rnn_states_as_inputs: + reset_name = f'{node.name}_Reset' + else: + reset_name = 'Reset' + bindings = [ GNodeArgEdge(i_state_eparams, direction="GNA_INOUT"), GNodeArgEdge("S%s_StateInternal01" % step_idx, alias=i_state_eparams, diff --git a/tools/nntool/generation/new_generators/ne16/lstm_ne16.py b/tools/nntool/generation/new_generators/ne16/lstm_ne16.py index 6e5c34d3d..b9cfec8f4 100644 --- a/tools/nntool/generation/new_generators/ne16/lstm_ne16.py +++ b/tools/nntool/generation/new_generators/ne16/lstm_ne16.py @@ -71,9 +71,6 @@ def globals_generator(cls, gen, node, qrec, pnode, fnode) -> bool: gen.opts['default_global_exec_location'], const_info=const_info, comment=f"{node.name} scales and norms")) - if node.rnn_states_as_inputs: - gen.globals.append(GlobalResetArgInfo( - f"{node.name}_Reset", 'AT_MEM_L2', 'AT_MEM_UNDEF')) out_q = qrec.out_qs[0] out_scale = qrec.cache["state_out_q"].qbiases[0] @@ -183,7 +180,11 @@ def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> i_state_eparams = in_eparams[names['i_state']] c_state_eparams = in_eparams[names['c_state']] - reset_name = i_state_eparams.creating_node.reset_name if node.rnn_states_as_inputs else "Reset" + if node.rnn_states_as_inputs: + reset_name = f'{node.name}_Reset' + else: + reset_name = 'Reset' + bindings = [ GNodeArgEdge(c_state_eparams, direction="GNA_INOUT"), GNodeArgEdge(i_state_eparams, direction="GNA_INOUT"), diff --git a/tools/nntool/generation/new_generators/ne16/rnn_ne16.py b/tools/nntool/generation/new_generators/ne16/rnn_ne16.py index 41e3468f1..b51675a26 100644 --- a/tools/nntool/generation/new_generators/ne16/rnn_ne16.py +++ b/tools/nntool/generation/new_generators/ne16/rnn_ne16.py @@ -130,7 +130,10 @@ def bindings_generator(cls, gen, node, qrec, in_eparams, out_eparams, cname) -> "uint8", f"S{node.step_idx}_StateInternal02")) i_state_eparams = in_eparams[names['i_state']] - reset_name = i_state_eparams.creating_node.reset_name if node.rnn_states_as_inputs else "Reset" + if node.rnn_states_as_inputs: + reset_name = f'{node.name}_Reset' + else: + reset_name = 'Reset' gen.bindings.append( NodeBindingList(cname, GNodeArgEdge(i_state_eparams, diff --git a/tools/nntool/generation/project_template/Makefile b/tools/nntool/generation/project_template/Makefile index b3be0c7f6..c1f528ea8 100644 --- a/tools/nntool/generation/project_template/Makefile +++ b/tools/nntool/generation/project_template/Makefile @@ -11,22 +11,46 @@ endif include common.mk include $(RULES_DIR)/at_common_decl.mk -io=stdout +io?=host -RAM_FLASH_TYPE ?= HYPER +FLASH_TYPE ?= HYPER +RAM_TYPE ?= HYPER #PMSIS_OS=freertos -ifeq '$(RAM_FLASH_TYPE)' 'HYPER' -APP_CFLAGS += -DUSE_HYPER -MODEL_L3_EXEC=hram -MODEL_L3_CONST=hflash -else -APP_CFLAGS += -DUSE_SPI -CONFIG_SPIRAM = 1 -MODEL_L3_EXEC=qspiram -MODEL_L3_CONST=qpsiflash +ifeq '$(FLASH_TYPE)' 'HYPER' + MODEL_L3_CONST=AT_MEM_L3_HFLASH +else ifeq '$(FLASH_TYPE)' 'MRAM' + MODEL_L3_CONST=AT_MEM_L3_MRAMFLASH + READFS_FLASH = target/chip/soc/mram +else ifeq '$(FLASH_TYPE)' 'QSPI' + MODEL_L3_CONST=AT_MEM_L3_QSPIFLASH + READFS_FLASH = target/board/devices/spiflash +else ifeq '$(FLASH_TYPE)' 'OSPI' + MODEL_L3_CONST=AT_MEM_L3_OSPIFLASH + READFS_FLASH = target/board/devices/ospiflash +endif + +ifeq '$(RAM_TYPE)' 'HYPER' + MODEL_L3_EXEC=AT_MEM_L3_HRAM +else ifeq '$(RAM_TYPE)' 'QSPI' + MODEL_L3_EXEC=AT_MEM_L3_QSPIRAM +else ifeq '$(RAM_TYPE)' 'OSPI' + MODEL_L3_EXEC=AT_MEM_L3_OSPIRAM endif +ifeq '$(TARGET_CHIP_FAMILY)' 'GAP9' +FREQ_CL?=370 +FREQ_FC?=370 +FREQ_PE?=370 +else +ifeq '$(TARGET_CHIP)' 'GAP8_V3' +FREQ_CL?=175 +else +FREQ_CL?=50 +endif +FREQ_FC?=250 +FREQ_PE?=250 +endif $(info Building NNTOOL model) NNTOOL_EXTRA_FLAGS ?= @@ -37,13 +61,13 @@ include common/model_decl.mk # PULP_APP = $(MODEL_PREFIX) APP = $(MODEL_PREFIX) -APP_SRCS += $(MODEL_PREFIX).c $(MODEL_GEN_C) $(MODEL_COMMON_SRCS) $(CNN_LIB) +APP_SRCS += $(MODEL_PREFIX).c $(MODEL_GEN_C) $(MODEL_EXPRESSIONS) $(MODEL_COMMON_SRCS) $(CNN_LIB) APP_CFLAGS += -g -O3 -mno-memcpy -fno-tree-loop-distribute-patterns APP_CFLAGS += -I. -I$(MODEL_COMMON_INC) -I$(TILER_EMU_INC) -I$(TILER_INC) $(CNN_LIB_INCLUDE) -I$(MODEL_BUILD) APP_CFLAGS += -DPERF -DAT_MODEL_PREFIX=$(MODEL_PREFIX) $(MODEL_SIZE_CFLAGS) APP_CFLAGS += -DSTACK_SIZE=$(CLUSTER_STACK_SIZE) -DSLAVE_STACK_SIZE=$(CLUSTER_SLAVE_STACK_SIZE) -APP_CFLAGS += -DAT_IMAGE=$(IMAGE) +APP_CFLAGS += -DAT_IMAGE=$(IMAGE) -DFREQ_FC=$(FREQ_FC) -DFREQ_CL=$(FREQ_CL) -DFREQ_PE=$(FREQ_PE) READFS_FILES=$(abspath $(MODEL_TENSORS)) diff --git a/tools/nntool/generation/project_template/common/model_decl.mk b/tools/nntool/generation/project_template/common/model_decl.mk index cda41991c..4f72f28e4 100644 --- a/tools/nntool/generation/project_template/common/model_decl.mk +++ b/tools/nntool/generation/project_template/common/model_decl.mk @@ -31,8 +31,8 @@ else endif MODEL_HEADER = $(MODEL_PREFIX)Info.h MODEL_GEN = $(MODEL_BUILD)/$(MODEL_PREFIX)Kernels -MODEL_GEN_C = $(addsuffix .c, $(MODEL_GEN)) $(MODEL_EXPRESSIONS) -MODEL_GEN_CLEAN = $(MODEL_GEN_C) $(addsuffix .h, $(MODEL_GEN)) $(MODEL_EXPRESSIONS) +MODEL_GEN_C = $(addsuffix .c, $(MODEL_GEN)) +MODEL_GEN_CLEAN = $(MODEL_GEN_C) $(addsuffix .h, $(MODEL_GEN)) MODEL_GEN_EXE = $(MODEL_BUILD)/GenTile ifdef MODEL_QUANTIZED @@ -48,11 +48,21 @@ RM=rm -f NNTOOL?=nntool -TOTAL_STACK_SIZE=$(shell expr $(CLUSTER_STACK_SIZE) \+ $(CLUSTER_SLAVE_STACK_SIZE) \* 7) +ifeq '$(TARGET_CHIP_FAMILY)' 'GAP9' +CLUSTER_SLAVE_PE=8 +else ifeq '$(TARGET_CHIP_FAMILY)' 'GAP8' +CLUSTER_SLAVE_PE=7 +else + $(error TARGE_CHIP_FAMILY not found in env or not correct) +endif + +TOTAL_STACK_SIZE=$(shell expr $(CLUSTER_STACK_SIZE) \+ $(CLUSTER_SLAVE_STACK_SIZE) \* $(CLUSTER_SLAVE_PE)) MODEL_L1_MEMORY=$(shell expr $(TARGET_L1_SIZE) \- $(TOTAL_STACK_SIZE)) MODEL_L2_MEMORY=$(TARGET_L2_SIZE) MODEL_L3_MEMORY=$(TARGET_L3_SIZE) + + # hram - HyperBus RAM # qspiram - Quad SPI RA # hflash - HyperBus Flash diff --git a/tools/nntool/generation/project_template/common/model_rules.mk b/tools/nntool/generation/project_template/common/model_rules.mk index 757d5f7e8..d0adab70f 100644 --- a/tools/nntool/generation/project_template/common/model_rules.mk +++ b/tools/nntool/generation/project_template/common/model_rules.mk @@ -35,29 +35,29 @@ $(MODEL_BUILD): # The model is already available at AT_MODEL_PATH ifndef MODEL_AT_ONLY - $(MODEL_PATH): $(TRAINED_MODEL) | $(MODEL_BUILD) +$(MODEL_PATH): $(TRAINED_MODEL) | $(MODEL_BUILD) cp $< $@ - # Creates an NNTOOL state file by running the commands in the script - # These commands could be run interactively - # The commands: - # Adjust the model to match AutoTiler tensor order - # Fuse nodes together to match fused AutoTiler generators - # Quantize the graph if not already done with tflite quantization - # Save the graph state files +# Creates an NNTOOL state file by running the commands in the script +# These commands could be run interactively +# The commands: +# Adjust the model to match AutoTiler tensor order +# Fuse nodes together to match fused AutoTiler generators +# Quantize the graph if not already done with tflite quantization +# Save the graph state files - $(MODEL_STATE): $(MODEL_PATH) $(IMAGES) $(NNTOOL_SCRIPT) | $(MODEL_BUILD) +$(MODEL_STATE): $(MODEL_PATH) $(IMAGES) $(NNTOOL_SCRIPT) | $(MODEL_BUILD) echo "GENERATING NNTOOL STATE FILE" $(NNTOOL) -s $(NNTOOL_SCRIPT) $< $(NNTOOL_EXTRA_FLAGS) - nntool_state: $(MODEL_STATE) +nntool_state: $(MODEL_STATE) - # Runs NNTOOL with its state file to generate the autotiler model code +# Runs NNTOOL with its state file to generate the autotiler model code - $(AT_MODEL_PATH) $(MODEL_EXPRESSIONS): $(MODEL_STATE) $(MODEL_PATH) | $(MODEL_BUILD) +$(AT_MODEL_PATH) $(MODEL_EXPRESSIONS): $(MODEL_STATE) $(MODEL_PATH) | $(MODEL_BUILD) echo "GENERATING AUTOTILER MODEL" $(NNTOOL) -g -M $(MODEL_BUILD) -m $(MODEL_SRC) -T $(TENSORS_DIR) -H $(MODEL_HEADER) $(MODEL_GENFLAGS_EXTRA) $< - nntool_gen: $(AT_MODEL_PATH) +nntool_gen: $(AT_MODEL_PATH) endif # Build the code generator from the model code @@ -73,7 +73,7 @@ $(MODEL_GEN_C): $(MODEL_GEN_EXE) $(MODEL_GEN_EXE) -o $(MODEL_BUILD) -c $(MODEL_BUILD) $(MODEL_GEN_EXTRA_FLAGS) # A phony target to simplify including this in the main Makefile -model: $(MODEL_GEN_C) +model: $(MODEL_GEN_C) $(MODEL_EXPRESSIONS) clean_at_model: $(RM) $(MODEL_GEN_EXE) diff --git a/tools/nntool/graph/dim.py b/tools/nntool/graph/dim.py index c1a2fd5e4..d93382c66 100644 --- a/tools/nntool/graph/dim.py +++ b/tools/nntool/graph/dim.py @@ -464,10 +464,10 @@ def __getattr__(self, name): return super().__getattribute__(name) # @IgnoreException self._verify_is_named() try: - idx = self._names.index(name) + idx = self._names.index(name) # @IgnoreException return self._shape[idx] except ValueError: - raise AttributeError("{} not found".format(name)) + raise AttributeError("{} not found".format(name)) # @IgnoreException def __setattr__(self, name, val): if name.startswith('_'): @@ -581,6 +581,10 @@ def __str__(self): return "scalar" return 'x'.join([str(v) for v in self._shape]) + def __repr__(self) -> str: + if self.is_named: + return f"Dim({self.__str__()}, {self.keys})" + return f"Dim({self.__str__()})" PAD_DIMS = ['t', 'b', 'l', 'r'] PAD_VERT_DIMS = ['t', 'b'] @@ -722,8 +726,7 @@ def is_same(self) -> bool: '''checks if PadDim is set same''' return self._same_type is not None - def calculate_same(self, in_dim, filt, stride, dilation=None) -> Dim: - '''calculates the actual padding from the input dimension''' + def calculate_same_h_w(self, in_dim, filt, stride, dilation=None): out_height = ceil(float(in_dim.h) / float(stride.h)) out_width = ceil(float(in_dim.w) / float(stride.w)) if dilation is None: @@ -740,6 +743,11 @@ def calculate_same(self, in_dim, filt, stride, dilation=None) -> Dim: pad_along_width = max( (out_width - 1) * stride.w + ((dilation.w - 1) * (filt.w - 1) + filt.w) - in_dim.w, 0) + return pad_along_height, pad_along_width + + def calculate_same(self, in_dim, filt, stride, dilation=None) -> Dim: + '''calculates the actual padding from the input dimension''' + pad_along_height, pad_along_width = self.calculate_same_h_w(in_dim, filt, stride, dilation) if self._same_type == "left": self.set( t=pad_along_height, diff --git a/tools/nntool/graph/manipulations/__init__.py b/tools/nntool/graph/manipulations/__init__.py index f7ce2002b..e69de29bb 100644 --- a/tools/nntool/graph/manipulations/__init__.py +++ b/tools/nntool/graph/manipulations/__init__.py @@ -1,19 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -from .dimensions import add_dimensions -from .adjust_order import adjust_order -from .liveness import calculate_liveness -from .balance_filter import balance_filter, balance_all_filters diff --git a/tools/nntool/graph/manipulations/adjust_base.py b/tools/nntool/graph/manipulations/adjust_base.py index 98ff7f199..6881a1444 100644 --- a/tools/nntool/graph/manipulations/adjust_base.py +++ b/tools/nntool/graph/manipulations/adjust_base.py @@ -66,7 +66,7 @@ def apply_input_trans(self, G, node, trans: list, index=None): if node.in_dims_hint: node.in_dims_hint[idx] = apply_transpose(node.in_dims_hint[idx], trans) nid = NodeId(node) - if G.quantization: + if G.quantization and nid in G.quantization: G.quantization.copy_qrec(node, 'in', idx, params) def apply_output_trans(self, G, node, trans: list, index=None): @@ -86,7 +86,8 @@ def apply_output_trans(self, G, node, trans: list, index=None): ) if node.out_dims_hint: node.out_dims_hint[idx] = apply_transpose(node.out_dims_hint[idx], self.invert(trans)) - if G.quantization: + nid = NodeId(node) + if G.quantization and nid in G.quantization: G.quantization.copy_qrec(node, 'out', idx, params) @staticmethod diff --git a/tools/nntool/graph/manipulations/dimensions.py b/tools/nntool/graph/manipulations/dimensions.py index f883d4d02..a6c79b97d 100644 --- a/tools/nntool/graph/manipulations/dimensions.py +++ b/tools/nntool/graph/manipulations/dimensions.py @@ -13,12 +13,13 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from graph.verify import verify_graph import logging from typing import Sequence from generation.naming_convension import (DefaultNamingConvension, NamingConvension) +from utils.graph import GraphView +# from graph.verify import verify_graph from ..dim import Dim, MissMatchedInputsError, MoreThanOneInputError from ..types import (ConcatParameters, ConstantInputParameters, EdgeParameters, @@ -30,9 +31,10 @@ def set_out_edges_multi(G, node: Parameters, dims: Sequence[Dim], step_idx: int, - naming_convension: NamingConvension, edge_type: str = "in_out"): + naming_convension: NamingConvension, update_graph, edge_type: str = "in_out"): # clone the dims first so that the edge dims are the same objects as the node output dims - dims = node.set_output_size(dims) + if update_graph: + dims = node.set_output_size(dims) out_edges = G.indexed_out_edges(node) is_multi_out = len(out_edges) > 1 for edge_idx, edge_group in enumerate(out_edges): @@ -49,17 +51,20 @@ def set_out_edges_multi(G, node: Parameters, dims: Sequence[Dim], step_idx: int, def set_out_edges_one(G, node: Parameters, dim: Dim, step_idx: int, - naming_convension: NamingConvension, edge_type: str = "in_out"): + naming_convension: NamingConvension, update_graph, edge_type: str = "in_out"): ename = naming_convension.get_edge_name(node, step_idx, edge_type) eparams = EdgeParameters(ename, dim, node, 0, step_idx, edge_type) for edge in G.out_edges(node.name): assert edge.from_idx == 0, "Only for use with nodes that have one output" edge.params = eparams LOG.debug("%s %s", node.name, ename) - eparams.dims = node.set_output_size([dim])[0] + if update_graph: + eparams.dims = node.set_output_size([dim])[0] + else: + eparams.dims = node.out_dims[0] -def validate_one_in_edge(G, node: Parameters, expect_named: bool = True): +def validate_one_in_edge(G, node: Parameters, update_graph, expect_named: bool = True): edges = G.in_edges(node.name) if len(edges) != 1: if len(edges) > 1: @@ -70,11 +75,12 @@ def validate_one_in_edge(G, node: Parameters, expect_named: bool = True): assert eparams is not None, "edge parameters not yet set" assert not expect_named or eparams.dims.has_keys( ['c', 'h', 'w']), "dimensions not yet set" - eparams.dims = node.set_input_size([eparams.dims])[0] + if update_graph: + eparams.dims = node.set_input_size([eparams.dims])[0] return eparams -def validate_multi_in_edge(G, node: Parameters, expect_named: bool = True): +def validate_multi_in_edge(G, node: Parameters, update_graph, expect_named: bool = True): dims = [] for edge in G.indexed_in_edges(node.name): if edge is None: @@ -85,64 +91,77 @@ def validate_multi_in_edge(G, node: Parameters, expect_named: bool = True): assert not expect_named or eparams.dims.has_keys( ['c', 'h', 'w']), "dimensions not yet set" dims.append(eparams.dims) - try: - dims = node.set_input_size(dims) - except MissMatchedInputsError as exc: - raise ValueError(f'missmatched inputs on node {node.name}') from exc + if update_graph: + try: + dims = node.set_input_size(dims) + except MissMatchedInputsError as exc: + raise ValueError(f'missmatched inputs on node {node.name}') from exc return dims def add_dimensions_concat(G, node: Parameters, step_idx: int, - naming_convension: NamingConvension, indexes): + naming_convension: NamingConvension, + indexes, update_graph): del indexes - in_dims = validate_multi_in_edge(G, node, expect_named=False) - out_dims = node.get_output_size(in_dims) - set_out_edges_one(G, node, out_dims[0], step_idx, naming_convension) + in_dims = validate_multi_in_edge(G, node, update_graph, expect_named=False) + if update_graph: + out_dims = node.get_output_size(in_dims) + else: + out_dims = node.out_dims + set_out_edges_one(G, node, out_dims[0], step_idx, naming_convension, update_graph ) def add_dimensions_constant(G, node: Parameters, step_idx: int, - naming_convension: NamingConvension, indexes): + naming_convension: NamingConvension, indexes, update_graph): node.index = indexes['constant'] indexes['constant'] += 1 constant_dims = node.get_output_size(None) set_out_edges_one(G, node, constant_dims[0], step_idx, - naming_convension, edge_type="in") + naming_convension, update_graph, edge_type="in") def add_dimensions_input(G, node: Parameters, step_idx: int, - naming_convension: NamingConvension, indexes): + naming_convension: NamingConvension, indexes, update_graph): node.index = indexes['input'] indexes['input'] += 1 input_dims = node.get_output_size(None) node.set_input_size(input_dims) set_out_edges_one(G, node, input_dims[0], step_idx, - naming_convension, edge_type="in") + naming_convension, update_graph , edge_type="in") def add_dimensions_output(G, node: Parameters, step_idx: int, - naming_convension: NamingConvension, indexes): + naming_convension: NamingConvension, indexes, update_graph): node.index = indexes['output'] indexes['output'] += 1 - eparams = validate_one_in_edge(G, node, expect_named=False) + eparams = validate_one_in_edge(G, node, update_graph, expect_named=False) eparams.edge_type = "out" eparams.name = naming_convension.get_edge_name(node, step_idx, "out") # set the dimensions of the output node - node.set_output_size(node.get_output_size([eparams.dims])) + if update_graph: + node.set_output_size(node.get_output_size([eparams.dims])) def add_dimensions_unknown_single(G, node: Parameters, step_idx: int, - naming_convension: NamingConvension, indexes): + naming_convension: NamingConvension, indexes, update_graph): del indexes - eparams = validate_one_in_edge(G, node, expect_named=False) - out_dims = node.get_output_size([eparams.in_dims]) - set_out_edges_one(G, node, out_dims[0], step_idx, naming_convension) + eparams = validate_one_in_edge(G, node, update_graph, expect_named=False) + if update_graph: + out_dims = node.get_output_size([eparams.in_dims]) + else: + out_dims = node.out_dims + set_out_edges_one(G, node, out_dims[0], step_idx, naming_convension, update_graph) def add_dimensions_unknown(G, node: Parameters, step_idx: int, - naming_convension: NamingConvension): - in_dims = validate_multi_in_edge(G, node, expect_named=False) - set_out_edges_multi(G, node, node.get_output_size(in_dims), - step_idx, naming_convension) + naming_convension: NamingConvension, update_graph): + in_dims = validate_multi_in_edge(G, node, update_graph, expect_named=False) + if update_graph: + out_dims = node.get_output_size(in_dims) + else: + out_dims = node.out_dims + set_out_edges_multi(G, node, out_dims, + step_idx, naming_convension, update_graph) OP_ROUTINES = { @@ -154,7 +173,7 @@ def add_dimensions_unknown(G, node: Parameters, step_idx: int, } -def add_dimensions(G, naming_convension: NamingConvension = None) -> list: +def add_dimensions(G: GraphView, naming_convension: NamingConvension = None, update_graph=True) -> list: """ Walks graph setting all edge names and dimensions """ if naming_convension is None: @@ -171,15 +190,21 @@ def add_dimensions(G, naming_convension: NamingConvension = None) -> list: # else "b" + (str(node.step_idx) if node.step_idx else node.name))) LOG.debug("inputs: %s", [node.name for node in inputs]) - for node in G.dfs(inputs): + def add_step(step, idx): + if len(steps) <= idx: + steps.extend([None] * (idx + 1 - len(steps))) + steps[idx] = step + + for node in G.topological_sort(inputs): LOG.debug("add dimensions to: %s", node.name) - node.step_idx = len(steps) - steps.append({'node': node}) + if update_graph: + node.step_idx = len(steps) + add_step({'node': node}, node.step_idx) if node.__class__ in OP_ROUTINES: OP_ROUTINES[node.__class__]( - G, node, node.step_idx, naming_convension, indexes) + G, node, node.step_idx, naming_convension, indexes, update_graph) else: - add_dimensions_unknown(G, node, node.step_idx, naming_convension) + add_dimensions_unknown(G, node, node.step_idx, naming_convension, update_graph) set_aliases(G) # verify_graph(G, throw_exception=True) return steps diff --git a/tools/nntool/graph/manipulations/eliminate_transposes/eliminate_transposes.py b/tools/nntool/graph/manipulations/eliminate_transposes/eliminate_transposes.py index 86174f2f4..986119294 100644 --- a/tools/nntool/graph/manipulations/eliminate_transposes/eliminate_transposes.py +++ b/tools/nntool/graph/manipulations/eliminate_transposes/eliminate_transposes.py @@ -1,4 +1,4 @@ -# Copyright (C) 2021 GreenWaves Technologies, SAS +# Copyright (C) 2021, 2022 GreenWaves Technologies, SAS # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -13,29 +13,26 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from functools import reduce import logging from collections.abc import MutableSet from copy import deepcopy from typing import Iterator, Sequence -from graph.dim import Dim -from graph.types import (BinaryOpParameters, ConcatParameters, - ConstantInputParameters, FcParameters, - InputParameters, LinearFusionParameters, - OutputParameters, PadParameters, ReshapeParameters, - ReverseParameters, StridedSliceParameters, - TransposeParameters, ActivationParameters) -from graph.types.base import NNEdge, SensitiveToOrder -from graph.types.others import CopyParameters, UnaryOpParameters -from graph.types.tensor_arithmetic import Broadcastable -from utils.compatible_transposes import (find_all_compatible_transposes, - find_combination) +from graph.types import (ActivationParameters, BinaryOpParameters, + Broadcastable, ConcatParameters, + ConstantInputParameters, CopyParameters, FcParameters, + GlobalPoolingParameters, InputParameters, + LinearFusionParameters, NNEdge, OutputParameters, + PadParameters, PowOpParameters, ReshapeParameters, + ReverseParameters, SensitiveToOrder, + StridedSliceParameters, TransposeParameters, + UnaryOpParameters) +from utils.compatible_transposes import reverse_reshape from utils.graph import Node -from utils.graph_utils.copy_expressions import do_transpose from utils.node_id import NodeId -from .eliminate_transposes_actions import (Action, DeleteReshapeAction, +from .eliminate_transposes_actions import (Action, CantContinueError, + DeleteReshapeAction, DeleteTransposeAction, EndActionDown, EndActionUp, InsertReshapeAction, @@ -46,11 +43,11 @@ SetReshapeAction, SetTransposeAction, SwitchBatchLinearAction, - TransposePad, TransposeReverse, + TransposePad, + TransposeReverse, TransposeSlidedSlice) -from .transpose_helpers import (apply_transpose, get_reshape_transpose, - identity_transpose, reshape_is_transpose, - reverse_transpose, reverses_transpose, +from .transpose_helpers import (apply_transpose, identity_transpose, + reverse_transpose, reverses_transpose_up, transpose_does_nothing) LOG = logging.getLogger("nntool." + __name__) @@ -67,7 +64,7 @@ def debug(msg): TRANSIENT_ACTIONS = { PadParameters: TransposePad, ReverseParameters: TransposeReverse, - StridedSliceParameters: TransposeSlidedSlice + StridedSliceParameters: TransposeSlidedSlice, } NODES_TO_EXPLORE_UP = { @@ -77,10 +74,6 @@ def debug(msg): } -class CantContinueError(Exception): - pass - - class TransposeHistory(): def __init__(self, node, from_shape=None, transpose=None, to_shape=None) -> None: self.node = node @@ -140,13 +133,13 @@ def visited_down(self, node, idx=None) -> bool: def visit_up(self, node, idx): val = self._nodes.setdefault(node, set()) - val.add('up{idx}') + val.add(f'up{idx}') def visited_up(self, node, idx=None) -> set: visited = self._nodes.get(node, set()) if idx is None: return any(k.startswith('up') for k in visited) - return 'up{idx}' in visited or 'up*' in visited + return f'up{idx}' in visited or 'up*' in visited def visited_direction(self, direction, idx, node) -> bool: return f'{direction}{idx}' in self._nodes.get(node, set()) @@ -180,55 +173,6 @@ def __repr__(self) -> str: return "{" + ",".join(f"{repr(node)}: {visited}" for node, visited in self._nodes.items()) + "}" -def is_broadcasted(from_shape, to_shape): - from_len = len(from_shape) - to_len = len(to_shape) - if from_len >= to_len: - return False - return tuple(([1] * (to_len - from_len)) + list(from_shape)) == tuple(to_shape) - - -def expand_to_len(trans, length): - extra = length-len(trans) - return tuple(list(range(extra)) + [dim + extra for dim in trans]) - - -def reverse_reshape(trans, from_shape, to_shape): - """reverses the effect of this reshape on the transpose""" - # if the from_shape -> to_shape is actually a broadcast reshape - # i.e. 4, 10, 1 -> 1, 4, 10, 1 we absolutely need to keep the order 4, 10, 1 in - # the transpose however the 2 1s in the result are ambiguous so handle this as a - # (simple) special case. Just expand the transpose with no transpose at the start - # and expand_len + original transpose dim at the end - if len(from_shape) == 0 or len(to_shape) == 0: - return None - if is_broadcasted(from_shape, to_shape): - return expand_to_len(trans, len(to_shape)) - - return next(iter([t for t in find_all_compatible_transposes(find_combination(from_shape, to_shape), trans) - if len(t) == len(to_shape)]), None) - - -def none_or_idx(trans, idx): - return None if trans[idx] is None else idx - - -def reverse_broadcast(old_shape, new_shape, transpose): - old_shape_idx = new_shape_idx = 0 - res_pos = {} - while old_shape_idx < len(old_shape) or new_shape_idx < len(new_shape): - if old_shape_idx < len(old_shape) and old_shape[old_shape_idx] == new_shape[new_shape_idx]: - res_pos[old_shape_idx] = new_shape_idx - old_shape_idx += 1 - new_shape_idx += 1 - elif new_shape_idx < len(new_shape) and new_shape[new_shape_idx] == 1: - new_shape_idx += 1 - else: - raise ValueError( - f'reverse broadcast not possible between {old_shape} and {new_shape}') - return tuple([res_pos[idx] for idx in transpose] + [idx for idx, _ in enumerate(new_shape) if idx not in res_pos.values()]) - - def requires_reshape(trans1, trans2, dim): """Checks if layout shape doesn't change but a reshape is necessary due to 1 position""" if (tuple(dim.shape) != tuple(dim.layout_shape) and @@ -240,57 +184,38 @@ def requires_reshape(trans1, trans2, dim): return False -def strip_nones(trans): - return [i for i in trans if i is not None] +def check_for_null_transpose(node, transpose): + if transpose is None: + raise CantContinueError(f"can't continue at {node.name}") # @IgnoreException -def broadcast_reduce(out_shape, in_shape, transpose): - """Looking at a broadcasted input that has a lower rank than out_shape find - the equivalent transpose to the transpose on the broadcasted shape before - the broadcast +def check_continue(visited_nodes: VisitedNodes, cur_visited_nodes: VisitedNodes, exclude_nodes, node, direction, idx): + """Checks to see if we should skip visiting node on edge Args: - out_shape (Sequence): The full shape of the output of the broadcasted operation - in_shape (Sequence): The shape of the unbroadcasted input - transpose (Sequence): The transpose on the output + visited_nodes (VisitedNodes): All nodes visited in previous eliminations + cur_visited_nodes (VisitedNodes): Nodes visited on this branch + exclude_nodes (Sequence[Parameters]): Don't visit these nodes + node (Parameters): Node on edge + direction (str): direction of visit 'down' or 'up' + idx (int): edge index + + Raises: + CantContinueError: Fail this transpose test Returns: - Tuple: The in shape, the broadcasted in shape, the equivalent transpose + bool: True if skip False if visit """ - diff_shape = len(out_shape) - len(in_shape) - # broadcast shape with nones - exp_in_shape = ([None] * diff_shape) + list(range(len(in_shape))) - # apply the reverse of the transpose. now we have the broadcasted shape before the transpose - transpose_exp_in_shape = apply_transpose( - exp_in_shape, reverse_transpose(transpose)) - # strip the nones and reverse the result. This gives the transpose of the unbroadcasted shape - new_transpose = reverse_transpose(strip_nones(transpose_exp_in_shape)) - new_shape = ([1] * diff_shape) + in_shape - return in_shape, new_shape, new_transpose - - -def broadcast_expand(out_shape, in_shape, transpose): - diff_shape = len(out_shape) - len(in_shape) - exp_in_shape = ([None] * diff_shape) + list(range(len(in_shape))) - transpose_exp_in_shape = apply_transpose(exp_in_shape, transpose) - new_transpose = list(range(diff_shape)) + \ - [dim + diff_shape for dim in transpose] - new_shape = ([1] * diff_shape) + in_shape - return in_shape, new_shape, new_transpose - - -def check_for_null_transpose(node, transpose): - if transpose is None: - raise CantContinueError( - f"can't continue at {node.name}") # @IgnoreException - - -def check_continue(visited_nodes: VisitedNodes, cur_visited_nodes: VisitedNodes, exclude_nodes, node, direction, idx): all_visited = visited_nodes | cur_visited_nodes - if direction == 'up' and all_visited.visited_down(node): - return True - if direction == 'down' and all_visited.visited_up(node): - raise CantContinueError() # @IgnoreException + # if the node is sensitive to order then even if we have already visited it down + # we must visit it up and vice versa so that we maybe insert a reshape/transpose after it + if not isinstance(node, SensitiveToOrder): + if direction == 'up' and all_visited.visited_down(node): + # trying to visit node that was already visited in the other direction. + return True + if direction == 'down' and all_visited.visited_up(node): + # trying to visit node that was already visited in the other direction. + return True if all_visited.visited_direction(direction, idx, node): raise CantContinueError() # @IgnoreException if node in exclude_nodes: @@ -298,16 +223,11 @@ def check_continue(visited_nodes: VisitedNodes, cur_visited_nodes: VisitedNodes, return False -def strip_leading_ones(shape, in_len): - res = [] - seen_dim = False - for dim in shape: - if seen_dim: - res.append(dim) - elif dim != 1: - res.append(dim) - seen_dim = True - return res +def strip_leading_dim(shape, dim=1): + res = list(shape.copy()) + while len(res) > 1 and res[0] == dim: + res.pop(0) + return tuple(res) def compute_max_shape(dims): @@ -344,9 +264,9 @@ def search_down(G, node, exclude_nodes, visited_nodes: VisitedNodes, in_edge, node : The node to look at visited_nodes : Nodes already traversed in_edge : The edge we are arriving on at this node - transpose_history : A history of the reshapes passed that did not allow us to determine the transpose - transpose : The current transpose being propagated. Can be None to indicate that we cannot translate - the transpose via that reshape + transpose_history : A history of the reshapes passed that did not allow us + to determine the transpose. Transposes + are in the downwards direction. Returns: A tuple of a list of actions and a list of nodes traversed @@ -386,7 +306,7 @@ def search_down(G, node, exclude_nodes, visited_nodes: VisitedNodes, in_edge, # if arriving on a broadcasted input the transpose needs to be expanded # since the transpose is only acting on the broadcasted dimensions no reshape is necessary - if isinstance(node, Broadcastable) and len(in_shape) != node.out_dims[0].rank: + if isinstance(node, (Broadcastable, PowOpParameters)) and len(in_shape) != node.out_dims[0].rank: check_for_null_transpose(node, transpose) # This could be an expression so need to broadcaset the output max_shape = compute_max_shape(node.out_dims) @@ -415,15 +335,15 @@ def search_down(G, node, exclude_nodes, visited_nodes: VisitedNodes, in_edge, if len(edge_in_shape) != len(max_shape): # strip the broadcasted axis from the transpose b_axes = broadcasted_axes(edge_in_shape, max_shape) - transpose_without_broadcast = strip_axes_from_transpose( - reverse_transpose(transpose), b_axes) - # from shape will be the old shape with the unbroadcasted transpose + # Transpose moving down through the broadcast - strip the broadcast off it + transpose_without_broadcast = strip_axes_from_transpose(transpose, b_axes) + # from shape will be the old shape with the reversed unbroadcasted transpose - i.e. going up from_shape = apply_transpose( - edge_in_shape, transpose_without_broadcast) - # to shape is the broadcasted input shape with the transpose with the leading ones removed + edge_in_shape, reverse_transpose(transpose_without_broadcast)) + # to shape is the broadcasted input shape with the reverse transpose with the leading ones removed broadcasted_shape = ([1] * len(b_axes)) + list(edge_in_shape) - to_shape = strip_leading_ones(apply_transpose( - broadcasted_shape, reverse_transpose(transpose)), len(from_shape)) + to_shape = strip_leading_dim(apply_transpose( + broadcasted_shape, reverse_transpose(transpose))) # if they are not equal insert a reshape if from_shape != to_shape: info( @@ -457,27 +377,36 @@ def search_down(G, node, exclude_nodes, visited_nodes: VisitedNodes, in_edge, if filter_node.batch_size > 1: info( f"rejected {node.name} - multibatch linear layer - inserting transpose {transpose}") - return [InsertTransposeAction(node, direction='in', idx=in_edge.to_idx, transpose=transpose), EndActionDown(node)], cur_visited_nodes + return [ + InsertTransposeAction( + node, direction='in', idx=in_edge.to_idx, transpose=transpose), + EndActionDown(node)], cur_visited_nodes info( f"accepted {node.name} - linear layer reorder input - {transpose}") qrec = G.quantization and G.quantization[NodeId(node)] - return cur_actions + [ReorderLinearAction.in_from_history(node, transpose_history, qrec), EndActionDown(node)], cur_visited_nodes + return cur_actions + [ + ReorderLinearAction.in_from_history(node, transpose_history, qrec), + EndActionDown(node)], cur_visited_nodes if isinstance(node, TransposeParameters): - # TODO - Might be able to get rid of this and check history check_for_null_transpose(node, transpose) - if reverses_transpose(transpose, node.transpose, node.out_dims[0]): + reverses_transpose, old_shape = reverses_transpose_up(transpose, node.transpose, node.out_dims[0]) + if reverses_transpose: info( f"accepted {node.name} - transpose {node.transpose} reversed in by {transpose} on {node.in_dims[0]}") - reshape = requires_reshape( - transpose, node.transpose, node.in_dims[0]) - if reshape: + if old_shape: + reshape = (old_shape, node.out_dims[0].shape) info(f"requires reshape {reshape[0]} -> {reshape[1]}") + else: + reshape = None return [DeleteTransposeAction(node, reshape=reshape), EndActionDown(node)], cur_visited_nodes new_transpose = apply_transpose(transpose, node.transpose) info( - f"rejected {node.name} - transpose - does not reverse - absorbing {transpose} into {node.transpose} -> {new_transpose}") - return [SetTransposeAction(node, new_transpose), EndActionDown(node)], cur_visited_nodes + f"rejected {node.name} - transpose - does not reverse - absorbing {transpose} " + f"into {node.transpose} -> {new_transpose}") + return [ + SetTransposeAction(node, new_transpose), + EndActionDown(node)], cur_visited_nodes if isinstance(node, OutputParameters): # TODO - Might be able to get rid of this and check history @@ -485,7 +414,10 @@ def search_down(G, node, exclude_nodes, visited_nodes: VisitedNodes, in_edge, if node.fixed_order: info( f"rejected {node.name} - fixed order output - inserting transpose {transpose}") - return [InsertTransposeAction(node, direction='in', idx=in_edge.to_idx, transpose=transpose), EndActionDown(node)], cur_visited_nodes + return [ + InsertTransposeAction( + node, direction='in', idx=in_edge.to_idx, transpose=transpose), + EndActionDown(node)], cur_visited_nodes info( f"accepted {node.name} - output without fixed order - transpose output {transpose}") # No change here since the output dimensions will be computed by the shape inference @@ -494,23 +426,20 @@ def search_down(G, node, exclude_nodes, visited_nodes: VisitedNodes, in_edge, if isinstance(node, StridedSliceParameters) and node.slice_shape != node.out_shape: # strided slice that is also reshaping check_for_null_transpose(node, transpose) - new_transpose = reverse_transpose(reverse_reshape( - reverse_transpose(transpose), node.slice_shape, node.out_shape)) + new_transpose, from_shape, to_shape = reverse_reshape( + transpose, node.slice_shape, node.out_shape) if new_transpose is None: info( - f"rejected {node.name} - transpose out - does not reverse - inserting transpose {transpose}") + f"rejected {node.name} - cannot pass slice reshape - inserting transpose {transpose}") return [InsertTransposeAction(node, direction='in', idx=in_edge.to_idx, transpose=transpose), EndActionDown(node)], cur_visited_nodes cur_actions.append(TransposeSlidedSlice( - node, reverse_transpose(transpose), transpose_out=reverse_transpose(new_transpose), dir="down")) + node, transpose, out_shape=to_shape, dir="down")) if identity_transpose(new_transpose): return cur_actions + [EndActionDown(node)], cur_visited_nodes - from_shape = do_transpose(reverse_transpose( - transpose), node.slice_shape) if transpose is not None else None - transpose_history = transpose_history + \ [TransposeHistory(node, node.slice_shape, new_transpose, node.out_shape)] @@ -522,49 +451,21 @@ def search_down(G, node, exclude_nodes, visited_nodes: VisitedNodes, in_edge, elif isinstance(node, ReshapeParameters): # TODO - Might be able to get rid of this and check history check_for_null_transpose(node, transpose) - if reshape_is_transpose(node.old_shape.shape, node.shape.shape): - # if the reshape looks like a transpose then treat it as one. THe reshape rewriter sometimes gets - # the order wrong in this case - old_transpose = get_reshape_transpose( - node.old_shape.shape, node.shape.shape) - if reverses_transpose(transpose, old_transpose): - cur_actions += [ - DeleteReshapeAction( - node - ) - ] - return cur_actions + [ - DeleteReshapeAction( - node - ), - EndActionDown(node)], cur_visited_nodes - new_transpose = apply_transpose( - transpose, old_transpose) - info( - f"pass reshape that is transpose {node.name} down trans: old {transpose} new {new_transpose} shape: old {node.old_shape} new {node.shape}") - # insert an action to rewrite the reshape shapes - from_shape = apply_transpose( - node.old_shape.shape, reverse_transpose(transpose)) - to_shape = apply_transpose( - node.shape.shape, reverse_transpose(transpose)) - else: - # the transpose that we are actually applying is the reverse of the transpose that we are propagating down - # So we reverse the transpose before evaluating the reshape and then reverse the result - new_transpose = reverse_transpose(reverse_reshape( - reverse_transpose(transpose), node.old_shape, node.shape)) + new_transpose, from_shape, to_shape = reverse_reshape( + transpose, node.old_shape, node.shape) + info( + f"pass reshape {node.name} down trans: old {transpose} new {new_transpose} " + f"shape: old {node.old_shape} new {node.shape}") + + if new_transpose is None and len(node.shape) > 1: info( - f"pass reshape {node.name} down trans: old {transpose} new {new_transpose} shape: old {node.old_shape} new {node.shape}") + f"rejected {node.name} - cannot pass reshape - inserting transpose {transpose}") + return [ + InsertTransposeAction( + node, direction='in', idx=in_edge.to_idx, transpose=transpose), + EndActionDown(node)], cur_visited_nodes - if new_transpose is None and len(node.shape) > 1: - info( - f"rejected {node.name} - transpose out - does not reverse - inserting transpose {transpose}") - return [InsertTransposeAction(node, direction='in', idx=in_edge.to_idx, transpose=transpose), EndActionDown(node)], cur_visited_nodes - - # insert an action to rewrite the reshape shapes - from_shape = apply_transpose(node.old_shape.shape, - reverse_transpose(transpose)) if transpose is not None else None - to_shape = apply_transpose(node.shape.shape, reverse_transpose( - new_transpose)) if new_transpose is not None else None + # insert an action to rewrite the reshape shapes info(f"rewrite reshape to {from_shape}->{to_shape}") if from_shape is None or to_shape is None or from_shape != to_shape: cur_actions += [ @@ -590,16 +491,21 @@ def search_down(G, node, exclude_nodes, visited_nodes: VisitedNodes, in_edge, if new_transpose is None: try: - return continue_down(G, node, exclude_nodes, visited_nodes, cur_visited_nodes.copy(), cur_actions.copy(), transpose_history, new_transpose) + return continue_down(G, node, exclude_nodes, visited_nodes, cur_visited_nodes.copy(), + cur_actions.copy(), transpose_history, new_transpose) except CantContinueError as ex: if transpose is None: raise ex info( - f"rejected {node.name} - transpose out - does not reverse - inserting transpose {transpose}") - return [InsertTransposeAction(node, direction='in', idx=in_edge.to_idx, transpose=transpose), EndActionDown(node)], cur_visited_nodes + f"rejected {node.name} - cannot continue {ex} - inserting transpose {transpose}") + return [ + InsertTransposeAction( + node, direction='in', idx=in_edge.to_idx, transpose=transpose), + EndActionDown(node)], cur_visited_nodes transpose = new_transpose - return continue_down(G, node, exclude_nodes, visited_nodes, cur_visited_nodes, cur_actions, transpose_history, transpose) + return continue_down(G, node, exclude_nodes, visited_nodes, cur_visited_nodes, + cur_actions, transpose_history, transpose) def continue_down(G, node, exclude_nodes, visited_nodes, cur_visited_nodes, cur_actions, transpose_history, transpose): @@ -607,7 +513,7 @@ def continue_down(G, node, exclude_nodes, visited_nodes, cur_visited_nodes, cur_ if check_continue(visited_nodes, cur_visited_nodes, exclude_nodes, edge.to_node, 'down', edge.to_idx): continue new_actions, visited_down_nodes = search_down( - G, edge.to_node, exclude_nodes, visited_nodes | cur_visited_nodes, edge, transpose_history) + G, edge.to_node, exclude_nodes, visited_nodes | cur_visited_nodes, edge, transpose_history.copy()) cur_visited_nodes |= visited_down_nodes cur_actions += new_actions return cur_actions, cur_visited_nodes @@ -622,7 +528,8 @@ def search_up(G, node, exclude_nodes, visited_nodes, out_edge, transpose_history info( f'accepted {node.name} - single dimension transpose') return [EndActionUp(node)], cur_visited_nodes - if isinstance(node, SensitiveToOrder) and transpose_does_nothing(reverse_transpose(transpose), node.out_dims[out_edge.from_idx].shape): + if (isinstance(node, SensitiveToOrder) and + transpose_does_nothing(reverse_transpose(transpose), node.out_dims[out_edge.from_idx].shape)): new_shape = apply_transpose( node.out_dims[out_edge.from_idx].shape, reverse_transpose(transpose)) # could be that the transpose does nothing to the data layout but still changes the positions of @@ -644,7 +551,10 @@ def search_up(G, node, exclude_nodes, visited_nodes, out_edge, transpose_history check_for_null_transpose(node, transpose) info( f'rejected {node.name} - sensitive to order - inserting transpose {transpose}') - return [InsertTransposeAction(node, direction='out', idx=out_edge.from_idx, out_edge=out_edge, transpose=reverse_transpose(transpose)), EndActionUp(node)], cur_visited_nodes + return [ + InsertTransposeAction(node, direction='out', idx=out_edge.from_idx, + out_edge=out_edge, transpose=reverse_transpose(transpose)), + EndActionUp(node)], cur_visited_nodes cur_actions = [] @@ -665,7 +575,9 @@ def search_up(G, node, exclude_nodes, visited_nodes, out_edge, transpose_history exclude_nodes, visited_nodes | cur_visited_nodes, edge, - [TransposeHistory(node, node.out_dims[edge.from_idx], transpose, apply_transpose(node.out_dims[edge.from_idx], transpose))]) + [ + TransposeHistory(node, node.out_dims[edge.from_idx], transpose, + apply_transpose(node.out_dims[edge.from_idx], transpose))]) cur_visited_nodes |= visited_down_nodes cur_actions += new_actions @@ -681,15 +593,20 @@ def search_up(G, node, exclude_nodes, visited_nodes, out_edge, transpose_history f"accepted {node.name} - linear layer switch batch dimension") return cur_actions + [SwitchBatchLinearAction(node), EndActionUp(node)], cur_visited_nodes info(f"rejected {node.name} - batched linear") - return [InsertTransposeAction(node, direction='out', idx=out_edge.from_idx, out_edge=out_edge, transpose=reverse_transpose(transpose)), EndActionUp(node)], cur_visited_nodes + return [ + InsertTransposeAction(node, direction='out', idx=out_edge.from_idx, + out_edge=out_edge, transpose=reverse_transpose(transpose)), + EndActionUp(node)], cur_visited_nodes info(f"accepted {node.name} - linear layer reorder output") qrec = G.quantization and G.quantization[NodeId(node)] - return cur_actions + [ReorderLinearAction.out_from_history(node, transpose_history, qrec), EndActionUp(node)], cur_visited_nodes + return cur_actions + [ + ReorderLinearAction.out_from_history( + node, transpose_history, qrec), + EndActionUp(node)], cur_visited_nodes # Transpose may reverse the propagated transpose or be reordered if isinstance(node, TransposeParameters): check_for_null_transpose(node, transpose) - # TODO - in_dims or out_dims - 99% sure in_dims if tuple(node.transpose) == tuple(transpose): info( f"accepted {node.name} - transpose {node.transpose} equals {transpose} on {node.in_dims[0]}") @@ -697,11 +614,18 @@ def search_up(G, node, exclude_nodes, visited_nodes, out_edge, transpose_history node.transpose, transpose, node.out_dims[0]) if reshape: info(f"requires reshape {reshape[0]} -> {reshape[1]}") - return cur_actions + [DeleteTransposeAction(node, reshape=reshape), EndActionUp(node)], cur_visited_nodes - # TODO - This should merge with the existing Transpose - new_transpose = apply_transpose(node.transpose, transpose) + return cur_actions + [ + DeleteTransposeAction(node, reshape=reshape), EndActionUp(node)], cur_visited_nodes + + # absorb transpose in a -> tranpose T1 -> b -> existing trans node T2 -> c + # a -> TNew -> c + # Apply reversed T1 to T2 + + new_transpose = apply_transpose( + node.transpose, reverse_transpose(transpose)) info( - f"rejected {node.name} - transpose - does not reverse - absorbing {transpose} into {node.transpose} -> {new_transpose}") + f"rejected {node.name} - transpose - does not reverse - absorbing " + f"{transpose} into {node.transpose} -> {new_transpose}") return [SetTransposeAction(node, new_transpose), EndActionDown(node)], cur_visited_nodes # Input can be reordered if not frozen @@ -709,30 +633,48 @@ def search_up(G, node, exclude_nodes, visited_nodes, out_edge, transpose_history check_for_null_transpose(node, transpose) if node.fixed_order: info(f"rejected {node.name} - fixed order input") - return [InsertTransposeAction(node, direction='out', idx=out_edge.from_idx, out_edge=out_edge, transpose=transpose), EndActionUp(node)], cur_visited_nodes + return [ + InsertTransposeAction(node, direction='out', idx=out_edge.from_idx, + out_edge=out_edge, transpose=transpose), EndActionUp(node)], cur_visited_nodes info( f"accepted {node.name} - input without fixed order - transpose input {reverse_transpose(transpose)}") - return cur_actions + [ReorderInputDims.from_history(node, transpose_history, transpose=reverse_transpose(transpose)), EndActionUp(node)], cur_visited_nodes + return cur_actions + [ + ReorderInputDims.from_history( + node, transpose_history, transpose=reverse_transpose(transpose)), + EndActionUp(node)], cur_visited_nodes # Constant can be reordered if isinstance(node, ConstantInputParameters): check_for_null_transpose(node, transpose) info( f"accepted {node.name} - constant input - transpose constant {transpose}") - return cur_actions + [ReorderConstantInput.from_history(node, transpose_history, transpose=reverse_transpose(transpose)), EndActionUp(node)], cur_visited_nodes + return cur_actions + [ + ReorderConstantInput.from_history( + node, transpose_history, transpose=reverse_transpose(transpose)), + EndActionUp(node)], cur_visited_nodes # Conditions that can pass through the Transpose if isinstance(node, StridedSliceParameters) and node.changes_shape: - reversed_below = reverse_transpose(transpose) - reversed_above = reverse_broadcast( - node.out_shape, node.post_slice_shape, reversed_below) - new_transpose = reverse_transpose(reversed_above) + # special case for a strided slice that also has a reshape + check_for_null_transpose(node, transpose) + new_transpose, from_shape, to_shape = reverse_reshape( + transpose, node.slice_shape, node.out_shape, going_up=True) + if new_transpose is None: + info( + f"rejected {node.name} - cannot pass slice reshape - inserting transpose {transpose}") + return [InsertTransposeAction(node, direction='out', idx=0, transpose=reverse_transpose(transpose)), + EndActionDown(node)], cur_visited_nodes + + cur_actions.append(TransposeSlidedSlice( + node, reverse_transpose(transpose), out_shape=to_shape)) + + if identity_transpose(new_transpose): + return cur_actions + [EndActionUp(node)], cur_visited_nodes + transpose_history = transpose_history + \ [TransposeHistory(node, node.out_shape, - new_transpose, node.post_slice_shape)] - cur_actions.append( - TransposeSlidedSlice(node, reversed_above, "up", transpose)) + new_transpose, node.in_dims[0].shape)] transpose = new_transpose elif node.__class__ in TRANSIENT_ACTIONS: check_for_null_transpose(node, transpose) @@ -742,26 +684,28 @@ def search_up(G, node, exclude_nodes, visited_nodes, out_edge, transpose_history elif isinstance(node, ReshapeParameters): check_for_null_transpose(node, transpose) # TODO - may eliminate - new_transpose = reverse_reshape(reverse_transpose( - transpose), node.shape, node.old_shape) + # reversed transpose is being propagated up + new_transpose, from_shape, to_shape = reverse_reshape( + transpose, node.old_shape, node.shape, going_up=True) # if the upwards shape has one dimension we keep going since we want to find # nodes such as a linear layer that can reorder their output filters # This could be extended to recurrent layers for the inner dimension info( - f"pass reshape {node.name} up trans: old {transpose} new {new_transpose} shape: {node.old_shape} -> {node.shape}") + f"pass reshape {node.name} up trans: old {transpose} new {new_transpose} " + f"shape: {node.old_shape} -> {node.shape}") if new_transpose is None and len(node.old_shape) > 1: - info(f"rejected {node.name} - transpose in - does not reverse") - return [InsertTransposeAction(node, direction='out', idx=out_edge.from_idx, out_edge=out_edge, transpose=reverse_transpose(transpose)), EndActionUp(node)], cur_visited_nodes + info(f"rejected {node.name} - cannot pass reshape - inserting transpose {transpose}") + # since we are going up the transpose is in the up direction so needs to be reversed + return [ + InsertTransposeAction(node, direction='out', idx=out_edge.from_idx, + out_edge=out_edge, transpose=reverse_transpose(transpose)), + EndActionUp(node)], cur_visited_nodes # insert an action to rewrite the reshape shapes - from_shape = node.old_shape.calc_transpose( - new_transpose) if new_transpose is not None else None - to_shape = node.shape.calc_transpose( - reverse_transpose(transpose)) if transpose is not None else None transpose_history = transpose_history + \ [TransposeHistory(node, node.shape, new_transpose, node.old_shape)] info(f"rewrite reshape to {from_shape}->{to_shape}") - if from_shape is None or to_shape is None or from_shape.shape != to_shape.shape: + if from_shape is None or to_shape is None or from_shape != to_shape: cur_actions.extend([ SetReshapeAction( node, @@ -782,16 +726,21 @@ def search_up(G, node, exclude_nodes, visited_nodes, out_edge, transpose_history if new_transpose is None: try: # @IgnoreException - return continue_up(G, node, exclude_nodes, visited_nodes, cur_visited_nodes.copy(), cur_actions.copy(), transpose_history, transpose) + return continue_up(G, node, exclude_nodes, visited_nodes, cur_visited_nodes.copy(), + cur_actions.copy(), transpose_history, transpose) except CantContinueError as ex: if transpose is None: raise ex - info(f"rejected {node.name} - transpose in - does not reverse") - return [InsertTransposeAction(node, direction='out', idx=out_edge.from_idx, out_edge=out_edge, transpose=reverse_transpose(transpose)), EndActionUp(node)], cur_visited_nodes + info(f"rejected {node.name} - cannot continue {ex} - inserting transpose {transpose}") + return [ + InsertTransposeAction(node, direction='out', idx=out_edge.from_idx, + out_edge=out_edge, transpose=reverse_transpose(transpose)), + EndActionUp(node)], cur_visited_nodes transpose = new_transpose # Continue to visit upwards - return continue_up(G, node, exclude_nodes, visited_nodes, cur_visited_nodes, cur_actions, transpose_history, transpose) + return continue_up(G, node, exclude_nodes, visited_nodes, cur_visited_nodes, + cur_actions, transpose_history, transpose) def continue_up(G, node, exclude_nodes, visited_nodes, cur_visited_nodes, cur_actions, transpose_history, transpose): @@ -803,19 +752,18 @@ def continue_up(G, node, exclude_nodes, visited_nodes, cur_visited_nodes, cur_ac if check_continue(visited_nodes, cur_visited_nodes, exclude_nodes, edge.from_node, 'up', edge.from_idx): continue edge_in_shape = node.in_dims[edge.to_idx].shape - if isinstance(node, Broadcastable) and len(edge_in_shape) != node.out_dims[0].rank: + if isinstance(node, (Broadcastable, PowOpParameters)) and len(edge_in_shape) != node.out_dims[0].rank: max_shape = compute_max_shape(node.out_dims) b_axes = broadcasted_axes(edge_in_shape, max_shape) - transpose_without_broadcast = strip_axes_from_transpose( - reverse_transpose(transpose), b_axes) + transpose_without_broadcast = strip_axes_from_transpose(transpose, b_axes) # from shape will be the old shape with the unbroadcasted transpose from_shape = apply_transpose( - edge_in_shape, transpose_without_broadcast) + edge_in_shape, reverse_transpose(transpose_without_broadcast)) # to shape is the broadcasted input shape with the transpose with the leading ones removed broadcasted_shape = ([1] * len(b_axes)) + list(edge_in_shape) - to_shape = strip_leading_ones(apply_transpose( - broadcasted_shape, reverse_transpose(transpose)), len(from_shape)) + to_shape = strip_leading_dim(apply_transpose( + broadcasted_shape, reverse_transpose(transpose))) # if they are not equal insert a reshape if from_shape != to_shape: info( @@ -897,7 +845,8 @@ def combine_transposes(G): for tstart, tend in trans_pairs: new_transpose = apply_transpose(tstart.transpose, tend.transpose) info( - f'combine transposes {tstart.name} and {tend.name} {tstart.transpose} & {tend.transpose} -> {new_transpose}') + f'combine transposes {tstart.name} and {tend.name} {tstart.transpose} & ' + f'{tend.transpose} -> {new_transpose}') tstart.transpose = new_transpose G.remove_and_reconnect(tend, edge_class=NNEdge) @@ -949,10 +898,12 @@ def delete_step_idx(G, action: DeleteTransposeAction): return G.in_edges(action.node)[0].from_node.step_idx -def eliminate_transposes(G, debug_function=None, steps=None, single_step=False, do_silly=True): +def eliminate_transposes(G, debug_function=None, steps=None, single_step=False, do_silly=True, only_up=False): info("eliminating unnecessary transposes") found_results = True pass_count = 0 + # keep trying to eliminate until we can't do more + # This should not loop since there is a bias in pushing transposes down while found_results: if steps is not None: if pass_count >= steps: @@ -966,7 +917,8 @@ def eliminate_transposes(G, debug_function=None, steps=None, single_step=False, visited_nodes = set() actions = [] info(f"search for transposes +++ STEP {pass_count}") - transposes = G.nodes(node_classes=TransposeParameters) + transposes = sorted( + G.nodes(node_classes=TransposeParameters), key=lambda node: node.name) while transposes: transpose_node = transposes.pop(0) if transpose_node in visited_nodes: @@ -999,6 +951,8 @@ def eliminate_transposes(G, debug_function=None, steps=None, single_step=False, cur_actions_up.insert(0, DeleteTransposeAction(transpose_node)) # search down for elimination try: + if only_up: + raise CantContinueError cur_visited_down = VisitedNodes() cur_visited_down.visit_down(transpose_node, 0) cur_actions_down = [] @@ -1033,7 +987,7 @@ def eliminate_transposes(G, debug_function=None, steps=None, single_step=False, down_count = count_eliminated(cur_actions_down) # if the count is zero then the transpose has been eliminated however # 1 is better than 0 since another real transpose was deleted rather than a reorder etc - # always choose up before down since up is where we will transpose constants rather than reshaping them + # always favor up before down since up is where we will transpose constants if up_count > 0 and up_count >= down_count: info( f'found elimination for {transpose_node.name} upwards - {up_count} eliminated') @@ -1043,7 +997,7 @@ def eliminate_transposes(G, debug_function=None, steps=None, single_step=False, visited_nodes.add(transpose_node) if single_step or steps is not None: break - # if transpose cannot be removed upwards movement push the transpose down if it actually moved + # if transpose cannot be removed upwards push the transpose down if it actually moved elif down_count > 0 or (down_count == 0 and transpose_moved(G, cur_actions_down)): info( f'found elimination for {transpose_node.name} downwards - {down_count} eliminated') @@ -1054,8 +1008,7 @@ def eliminate_transposes(G, debug_function=None, steps=None, single_step=False, if single_step or steps is not None: break else: - info( - f'no elimination for {transpose_node.name} found') + info(f'no elimination for {transpose_node.name} found') if found_results: info("eliminate transposes") diff --git a/tools/nntool/graph/manipulations/eliminate_transposes/eliminate_transposes_actions.py b/tools/nntool/graph/manipulations/eliminate_transposes/eliminate_transposes_actions.py index 55927a224..6a0d8c462 100644 --- a/tools/nntool/graph/manipulations/eliminate_transposes/eliminate_transposes_actions.py +++ b/tools/nntool/graph/manipulations/eliminate_transposes/eliminate_transposes_actions.py @@ -1,4 +1,4 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS +# Copyright (C) 2020, 2022 GreenWaves Technologies, SAS # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -28,12 +28,19 @@ LOG = logging.getLogger("nntool." + __name__) + +class CantContinueError(Exception): + pass + + def info(msg): LOG.info(msg) + def debug(msg): LOG.debug(msg) + class Action(ABC): def __init__(self, node) -> None: self.node = node @@ -162,6 +169,7 @@ def _execute(self, node, G): def __str__(self) -> str: return f"insert reshape at {self.node.name}:{self.direction}_{self.idx} in {self.in_shape} out {self.out_shape}" + def make_dim(shape): if shape is None: return shape @@ -169,6 +177,7 @@ def make_dim(shape): return shape.clone() return Dim.unnamed(shape) + class SetReshapeAction(Action): def __init__(self, node, in_shape=None, out_shape=None) -> None: super(SetReshapeAction, self).__init__(node) @@ -196,21 +205,22 @@ def __str__(self) -> str: class TransposeSlidedSlice(Action): - def __init__(self, node, transpose_in, dir=None, transpose_out=None) -> None: + def __init__(self, node, transpose, dir=None, out_shape=None) -> None: super(TransposeSlidedSlice, self).__init__(node) - self.transpose_in = tuple(transpose_in) - if transpose_out is None: - self.transpose_out = self.transpose_in - else: - self.transpose_out = tuple(transpose_out) + self.transpose = tuple(transpose) + self.shape_out = out_shape def _execute(self, node, G): info(f"{self}") - node.act_slice = [node.act_slice[idx] for idx in self.transpose_in] - node.out_shape = [node.out_shape[idx] for idx in self.transpose_out] + node.act_slice = apply_transpose(node.act_slice, self.transpose) + if self.shape_out is not None: + node.out_shape = self.shape_out + else: + node.out_shape = apply_transpose(node.out_shape, self.transpose) def __str__(self) -> str: - return "%s transpose slided slice parameters with %s/%s" % (self.node.name, self.transpose_in, self.transpose_out) + out_shape = "unchanged" if self.shape_out is None else f"changed to {self.shape_out}" + return f"{self.node.name} transpose slided slice parameters with {self.transpose} out shape {out_shape}" class TransposePad(Action): @@ -227,19 +237,26 @@ def __str__(self) -> str: return "%s transpose pad parameters with %s" % (self.node.name, self.transpose) -class TransposeReverse(Action): +class TransposeAxisBase(Action): def __init__(self, node, transpose, dir=None) -> None: - super(TransposeReverse, self).__init__(node) + super(TransposeAxisBase, self).__init__(node) self.transpose = tuple(transpose) def _execute(self, node, G): info(f"{self}") node.axis = self.transpose[node.axis] + +class TransposeReverse(TransposeAxisBase): def __str__(self) -> str: return "%s transpose reverse parameters with %s" % (self.node.name, self.transpose) +class TransposeGlobalPool(TransposeAxisBase): + def __str__(self) -> str: + return "%s transpose global pool parameters with %s" % (self.node.name, self.transpose) + + class TransposeInputBase(Action): def __init__(self, node, transpose, dir=None) -> None: super(TransposeInputBase, self).__init__(node) @@ -360,25 +377,35 @@ def __str__(self) -> str: class ReorderLinearAction(Action): - def __init__(self, node, direction, transpose, shape, qrec=None) -> None: + def __init__(self, node, direction, transpose, shape, set_reshape_shape=None, qrec=None) -> None: super(ReorderLinearAction, self).__init__(node) self.direction = direction self.shape = shape self.transpose = tuple(transpose) self.qrec = qrec + self.set_reshape_shape = set_reshape_shape @classmethod - def from_history(cls, node, history, qrec, dir): + def from_history(cls, node, history, qrec, direction): # Find the first entry in the transpose history that actually has a transpose - first_valid_entry = next(iter([rec - for rec in reversed(history) - if rec.transpose])) + entry_idx, first_valid_entry = next(iter([(idx, rec) for idx, rec in enumerate(reversed(history)) + if rec.transpose])) # arriving from the top the transpose is in the down direction and from the # bottom in the up direction so in both cases we need to reverse it transpose = tuple(reverse_transpose(first_valid_entry.transpose)) # shape closest to the node shape = tuple(first_valid_entry.to_shape) - return cls(node, dir, transpose, shape, qrec=qrec) + set_reshape_shape = None + # if direction == "out": + # first_reshape = next(iter([elem.node for elem + # in list(reversed(history))[:entry_idx] if isinstance(elem.node, ReshapeParameters)]), None) + # if first_reshape: + # if shape != tuple(first_reshape.shape.shape): + # raise CantContinueError(f'reshape {first_reshape.name} after linear {node.name} has ' + # f'incorrect out shape {first_reshape.shape.shape} to apply transpose {transpose}') + # set_reshape_shape = (first_reshape, apply_transpose(first_reshape.shape.shape, transpose)) + + return cls(node, direction, transpose, shape, set_reshape_shape=set_reshape_shape, qrec=qrec) @classmethod def out_from_history(cls, node, history, qrec): @@ -390,7 +417,8 @@ def in_from_history(cls, node, history, qrec): def _execute(self, node, G): info(f"{self}") - filter_node = node.contained_filters()[0] if isinstance(node, LinearFusionParameters) else node + filter_node = node.contained_filters()[0] if isinstance( + node, LinearFusionParameters) else node in_edges = G.indexed_in_edges(node.name) weights_node = in_edges[1].from_node if self.direction == "in": @@ -425,7 +453,11 @@ def _execute(self, node, G): list(self.transpose) ), biases_node.value.shape) - nid = NodeId(node, filter_node) if isinstance(node, LinearFusionParameters) else NodeId(node) + nid = NodeId(node, filter_node) if isinstance( + node, LinearFusionParameters) else NodeId(node) + if self.set_reshape_shape: + self.set_reshape_shape[0].shape = Dim.unnamed( + self.set_reshape_shape[1]) # since the output channel order has changed we need to make channel scaled qrec match this if G.quantization and nid in G.quantization: qrec = G.quantization[nid] @@ -446,8 +478,6 @@ def _execute(self, node, G): if len(qrec.in_qs) > 2: fqrec.in_qs[2] = qrec.in_qs[2] - - def __str__(self) -> str: return "reorder linear layer %s %s with shape %s transposed %s" % (self.node.name, self.direction, self.shape, self.transpose) diff --git a/tools/nntool/graph/manipulations/eliminate_transposes/transpose_helpers.py b/tools/nntool/graph/manipulations/eliminate_transposes/transpose_helpers.py index 00b865e59..f043bd65a 100644 --- a/tools/nntool/graph/manipulations/eliminate_transposes/transpose_helpers.py +++ b/tools/nntool/graph/manipulations/eliminate_transposes/transpose_helpers.py @@ -22,20 +22,6 @@ def reverse_transpose(trans): return [trans.index(idx) for idx in range(len(trans))] -def reverses_transpose(trans1, trans2, dim=None): - """Checks if one transpose reverses another. If a dim is provided then - look if the transpose sequence produces an equivalent dim to cope with 1s in - dimensions.""" - if trans1 is None or trans2 is None: - return False - if dim and dim.layout_shape == dim.calc_transpose(trans1).calc_transpose(trans2).layout_shape: - return True - for idx, val in enumerate(trans1): - if trans2[val] != idx: - return False - return True - - def identity_transpose(trans): if trans is None: return False @@ -46,6 +32,35 @@ def apply_transpose(elems, trans): return [elems[i] for i in trans] +def strip_ones(shape): + return tuple(dim for dim in shape if dim != 1) + + +def reverses_transpose_up(trans1, trans2, dim=None): + """trans1->trans2->dim + 1) without dim do the transposes cancel + 2) with dim to the transposes cancel considering layout shape (i.e. without 1s in shape""" + if dim is not None and not isinstance(dim, tuple): + dim = tuple(dim.shape) + if trans1 is None or trans2 is None: + return False, None + if identity_transpose(apply_transpose(trans1, trans2)): + return True, None + if dim is not None: + # apply dim -> reverse t2 -> reverse t1 + # strip 1s and see if it is the same + layout_shape_after = strip_ones(dim) + shape_before = apply_transpose( + apply_transpose(dim, reverse_transpose(trans2)), + reverse_transpose(trans1)) + return strip_ones(shape_before) == layout_shape_after, shape_before + return False, None + + +def indexes_of(trans1, trans2): + return [trans1.index(i) for i in trans2] + + def transpose_does_nothing(transpose, shape): if transpose is None: return False @@ -57,10 +72,6 @@ def reduce_mask(mask): return reduce_mask(mask) == tmask -def strip_ones(shape): - return tuple(dim for dim in shape if dim != 1) - - def reshape_is_transpose(old_shape, new_shape): # TODO - check the order of the non 1 dimensions if len(old_shape) != len(new_shape): diff --git a/tools/nntool/graph/manipulations/extract.py b/tools/nntool/graph/manipulations/extract.py index 81028aee3..ffb07dc93 100644 --- a/tools/nntool/graph/manipulations/extract.py +++ b/tools/nntool/graph/manipulations/extract.py @@ -15,24 +15,50 @@ import logging +from graph.types.constant_input import ConstantInputParameters +from quantization.new_qrec import QRec +from utils.node_id import NodeId from ..nngraph import NNGraph from ..types import Parameters, SingleInputAndOutput, NNEdge LOG = logging.getLogger("nntool." + __name__) + def extract_node(G: NNGraph, keep_node: Parameters): if not isinstance(keep_node, SingleInputAndOutput): - raise NotImplementedError("exclude only works with single input and output nodes at present") + raise NotImplementedError( + "exclude only works with single input and output nodes at present") LOG.info("extracting node %s into new graph", keep_node.name) - for node in list(G.nodes()): - if node != keep_node: + in_edges = G.indexed_in_edges(keep_node) + out_edges = G.indexed_out_edges(keep_node) + keep_nodes = [edge.from_node for edge in in_edges + if edge is not None and isinstance(edge.from_node, ConstantInputParameters)] + [keep_node] + in_edges = [edge for edge in in_edges if edge is not None and edge.from_node not in keep_nodes] + nid = NodeId(keep_node) + in_qrecs = [] + out_qrecs = [] + if G.quantization and nid in G.quantization: + qrec = G.quantization[nid] + for edge in in_edges: + if edge.to_idx >= len(in_qrecs): + in_qrecs.extend([None] * (edge.to_idx + 1 - len(in_qrecs))) + in_qrec = G.quantization[nid] + in_qrecs[edge.to_idx] = QRec.copy_ktype(qrec, out_qs=[qrec.in_qs[edge.to_idx]]) + for idx, _ in enumerate(out_edges): + out_qrecs.append(QRec.copy_ktype(qrec, in_qs=[qrec.out_qs[edge.from_idx]], out_qs=[qrec.out_qs[edge.from_idx]])) + + for node in G.nodes(): + if node not in keep_nodes and node.name in G: + LOG.info(f'remove {node.name}') G.remove(node) - G.reset_inout_counts() - if isinstance(keep_node, SingleInputAndOutput): - input_node = G.add_input(keep_node.in_dims[0]) + for edge in in_edges: + input_node = G.add_input(edge.from_node.out_dims[edge.from_idx]) + G.add_edge(NNEdge(input_node, keep_node, to_idx=edge.to_idx)) + if in_qrecs: + G.quantization[NodeId(input_node)] = in_qrecs[edge.to_idx] + for idx, _ in enumerate(out_edges): output_node = G.add_output() - G.add_edge(NNEdge(input_node, keep_node)) - G.add_edge(NNEdge(keep_node, output_node)) - G.add_dimensions() - else: - raise NotImplementedError() + G.add_edge(NNEdge(keep_node, output_node, from_idx=idx)) + if out_qrecs: + G.quantization[NodeId(output_node)] = out_qrecs[idx] + G.add_dimensions() diff --git a/tools/nntool/graph/manipulations/formatter.py b/tools/nntool/graph/manipulations/formatter.py new file mode 100644 index 000000000..d3ff09531 --- /dev/null +++ b/tools/nntool/graph/manipulations/formatter.py @@ -0,0 +1,122 @@ +# Copyright (C) 2022 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from copy import deepcopy + +from graph.types import ImageFormatParameters, NNEdge, TransposeParameters +from quantization.qtype import QType +from utils.node_id import NodeId + + +def insert_formatter(G, input_node, formatter, normalizer): + format_node = ImageFormatParameters(input_node.name + "_formatter", + norm_func=normalizer.upper(), + format_change=formatter.upper()) + out_edges = G.out_edges(input_node.name) + + # dims updated to reflect formatter + if format_node.output_channels is not None and format_node.input_channels is not None: + out_dim = input_node.get_output_size(None)[0] + if formatter.upper() in ("BW8", "BW16"): + assert format_node.input_channels == 1 + in_dim = out_dim.clone() + format_node.out_dims_hint = input_node.out_dims_hint + format_node.in_dims_hint = input_node.out_dims_hint + input_node.dims = in_dim + for out_edge in out_edges: + G.remove_edge(out_edge) + else: + if not out_dim.is_named or out_dim.c != format_node.output_channels: + raise ValueError( + "current graph input is not named or does not match formatter output channels") + if formatter.upper() in ("RGB16", "BW16") and normalizer.upper() != "OUT_INT16": + raise ValueError( + "rgb16 and bw16 formatters must have out_int16 as normalization function") + in_dim = out_dim.clone() + in_dim.c = format_node.input_channels + in_dim.impose_order(("h", "w", "c")) + format_node.in_dims_hint = [["h", "w", "c"]] + input_node.dims = in_dim + if input_node.fixed_order: + new_out_edges = [] + for out_edge in out_edges: + if isinstance(out_edge.to_node, TransposeParameters): + trans_node = out_edge.to_node + transpose_edges = G.out_edges(trans_node.name) + new_out_edges.extend(transpose_edges) + G.remove(trans_node) + if G.quantization: + nid = NodeId(trans_node) + if nid in G.quantization: + del G.quantization[NodeId(trans_node)] + else: + new_out_edges.append(out_edge) + out_edges = new_out_edges + else: + input_node.fixed_order = True + for out_edge in out_edges: + G.remove_edge(out_edge) + format_node.out_dims_hint = [["c", "h", "w"]] * len(out_edges) + input_node.out_dims_hint = [["h", "w", "c"]] + G.node_options[NodeId(input_node)] = input_node.at_options + # qrec updated to reflect formatter + input_qrec = G.quantization and G.quantization.get(NodeId(input_node)) + if input_qrec and format_node.input_dtype and format_node.output_dtype: + formatter_qrec = G.quantization.get(NodeId(format_node)) + if not formatter_qrec: + if input_qrec.out_qs[0].dtype != format_node.output_dtype: + raise ValueError( + "current graph input output quantization does not match formatter output") + formatter_qrec = deepcopy(input_qrec) + formatter_qrec.out_qs[0] = deepcopy(formatter_qrec.out_qs[0]) + if formatter_qrec.ktype.startswith('scaled'): + formatter_in_q = QType( + scale=1, zero_point=0, dtype=format_node.input_dtype) + elif formatter_qrec.ktype.startswith('symmetric'): + formatter_in_q = QType(q=0, dtype=format_node.input_dtype) + else: + raise NotImplementedError("quantization has unknown type") + if len(formatter_qrec.in_qs) > 0: + formatter_qrec.in_qs[0] = formatter_in_q + input_qrec.in_qs[0] = formatter_in_q + else: + formatter_qrec.in_qs.append(formatter_in_q) + input_qrec.in_qs.append(formatter_in_q) + input_qrec.out_qs[0] = formatter_in_q + G.quantization[NodeId(format_node)] = formatter_qrec + + G.add_node(format_node) + G.add_edge(NNEdge(input_node, format_node)) + for out_edge in out_edges: + G.add_edge(NNEdge(format_node, out_edge.to_node, to_idx=out_edge.to_idx)) + + +def remove_formatter(G, fmt_node): + input_edges = G.in_edges(fmt_node.name) + assert len(input_edges) == 1, "formatter node should only have one input" + input_node = input_edges[0].from_node + fmt_edges = G.out_edges(fmt_node.name) + fmt_qrec = G.quantization and G.quantization.get(NodeId(fmt_node)) + G.remove(fmt_node) + + input_node.dims = fmt_node.out_dims[0] + input_node.out_dims_hint = fmt_node.out_dims_hint + for fmt_edge in fmt_edges: + G.add_edge(NNEdge(input_node, fmt_edge.to_node, to_idx=fmt_edge.to_idx)) + if fmt_qrec: + input_qrec = G.quantization[NodeId(input_node)] + input_qrec.out_qs = fmt_qrec.out_qs + input_qrec.in_qs = fmt_qrec.out_qs + G.quantization.remove_node(fmt_node) diff --git a/tools/nntool/graph/manipulations/liveness.py b/tools/nntool/graph/manipulations/liveness.py index 66e8a1aae..0c3959d83 100644 --- a/tools/nntool/graph/manipulations/liveness.py +++ b/tools/nntool/graph/manipulations/liveness.py @@ -15,6 +15,8 @@ from typing import Mapping, Sequence +from graph.types.input_output import InputBaseParameters, InputParameters, OutputParameters + def calculate_liveness(G, steps: Sequence[Mapping]) -> Mapping[str, Mapping]: liveness = {} for i, step in enumerate(steps): @@ -23,7 +25,7 @@ def calculate_liveness(G, steps: Sequence[Mapping]) -> Mapping[str, Mapping]: step['start'] = [] step['end'] = [] # input nodes create tensors - if G.is_input(node): + if isinstance(node, InputBaseParameters): edges = G.out_edges(node.name) if edges: assert all(edge.from_idx == 0 for edge in edges), "inputs should create a single tensor" @@ -40,7 +42,7 @@ def calculate_liveness(G, steps: Sequence[Mapping]) -> Mapping[str, Mapping]: assert live is not None, "Inputs to node must have already been created" if live['end'] < i: live['end'] = i - if G.is_output(node): + if isinstance(node, OutputParameters): live['is_output'] = True # check what we create for edge in G.out_edges(node.name): diff --git a/tools/nntool/graph/manipulations/set_aliases.py b/tools/nntool/graph/manipulations/set_aliases.py index dd7ff1614..94bbf8192 100644 --- a/tools/nntool/graph/manipulations/set_aliases.py +++ b/tools/nntool/graph/manipulations/set_aliases.py @@ -34,13 +34,7 @@ def walk_up(G, edge, concat_node): edge.to_node.name, edge.to_idx) edge.params.is_alias = True node = edge.from_node - if isinstance(node, ReshapeParameters): - # since it is a reshape it can only have one input - return walk_up(G, G.in_edges(node.name)[0], concat_node) - if isinstance(node, TransposeParameters): - if not node.does_nothing(): - return False - # since it is a reshape it can only have one input + if node.no_model_code: return walk_up(G, G.in_edges(node.name)[0], concat_node) if isinstance(node, SplitParameters): LOG.warning("split node %s is directly connected to concat node %s", @@ -61,12 +55,7 @@ def walk_down(G, edge, split_node): edge.params.is_alias = True node = edge.to_node errors = False - if isinstance(node, ReshapeParameters): - for edge in G.out_edges(node.name): - errors = errors or walk_down(G, edge, split_node) - elif isinstance(node, TransposeParameters): - if not node.does_nothing(): - return errors + if node.no_model_code: for edge in G.out_edges(node.name): errors = errors or walk_down(G, edge, split_node) elif isinstance(node, ConcatParameters): diff --git a/tools/nntool/graph/matches/fusions.py b/tools/nntool/graph/matches/fusions.py new file mode 100644 index 000000000..544a30ad1 --- /dev/null +++ b/tools/nntool/graph/matches/fusions.py @@ -0,0 +1,49 @@ +# Copyright (C) 2022 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from graph.matches.matches import get_matches +from graph.types.constant_input import ConstantInputParameters +from quantization.verify_quantization import verify_quantization +from quantization.quantizer.new_quantizer import NewQuantizer + + +def fusions(nngraph, *match_names, no_postprocess: bool = False): + state = ConstantInputParameters.save_compression_state(nngraph) + try: + match_group = get_matches(*match_names) + while match_group: + match_group.match(nngraph) + nngraph.add_dimensions() + if no_postprocess: + break + if match_group.run_qtune: + quantizer = NewQuantizer(nngraph) + quantizer.quantize() + if match_group.run_adjust: + nngraph.adjust_order() + if match_group.run_again: + match_group = get_matches(*match_group.run_again) + else: + match_group = None + + if nngraph.quantization and verify_quantization(nngraph): + quantizer = NewQuantizer(nngraph) + quantizer.quantize() + problems = verify_quantization(nngraph) + if problems: + problems = "\n".join(problems) + raise ValueError(f'quantization issue after fusions\n{problems}\n') + finally: + ConstantInputParameters.restore_compression_state(nngraph, state) diff --git a/tools/nntool/graph/matches/match_utils.py b/tools/nntool/graph/matches/match_utils.py index bdffdc756..6ebb02ee4 100644 --- a/tools/nntool/graph/matches/match_utils.py +++ b/tools/nntool/graph/matches/match_utils.py @@ -30,7 +30,7 @@ def search_down(G, edge, for_node_classes, can_pass=None, can_pass_fn=None, edge multi_on_target (bool, optional): Allow target to have multiple edges. Defaults to True. Returns: - Optional[Sequence[Edge]]: Edges found or None + Optional[Sequence[Edge]]: Edges found or None """ if edge_list is None: edge_list = [] @@ -71,18 +71,19 @@ def search_up(G, edge, for_node_classes, can_pass=None, can_pass_fn=None, edge_l Args: G (NNGraph): Graph - edge (Edge): Edge to look down + edge (Edge): Edge to look up for_node_classes (Union[Parameters, Tuple[Parameters]]): Node class or classes to look for can_pass (Union[Parameters, Tuple[Parameters]], optional): Will pass through this node class or classes. Defaults to None. can_pass_fn (Callable, optional): function with graph and node as parameters. Should return True if search can pass this node. Defaults to None. - follow_multi (str, optional): Follow multi edge outputs. Defaults to empty string which means don't follow can be same or any. + follow_multi (str, optional): Follow multi edge outputs. Defaults to empty string which means don't + follow can be same or any. follow_first (bool, optional): Only follow first input. Defaults to True. multi_on_target (bool, optional): Allow target to have multiple edges. Defaults to True. Returns: - Optional[Sequence[Edge]]: Edges found or None + Optional[Sequence[Edge]]: Edges found or None """ if edge_list is None: edge_list = [] diff --git a/tools/nntool/graph/matches/matcher.py b/tools/nntool/graph/matches/matcher.py index 216b959fc..809d595a6 100644 --- a/tools/nntool/graph/matches/matcher.py +++ b/tools/nntool/graph/matches/matcher.py @@ -15,11 +15,10 @@ import logging from abc import ABC, abstractmethod -from typing import Generator, Sequence +from typing import Sequence +from utils.graph import GraphView, MatchNode from utils.node_id import NodeId -from utils.graph import GraphView, MatchNode, Node - LOG = logging.getLogger("nntool." + __name__) @@ -41,6 +40,9 @@ class Matcher(ABC): RUN_BEFORE = [] RUN_AFTER = [] GROUPS = [] + RUN_AGAIN_ON_MATCH = [] + RUN_QTUNE_ON_MATCH = False + RUN_ADJUST_ON_MATCH = False def __init__(self, identity: str = None): if identity is None: @@ -52,6 +54,18 @@ def __init__(self, identity: str = None): def name(self): return self.NAME + @property + def run_again(self): + return self.RUN_AGAIN_ON_MATCH + + @property + def run_qtune(self): + return self.RUN_QTUNE_ON_MATCH + + @property + def run_adjust(self): + return self.RUN_ADJUST_ON_MATCH + @staticmethod def remove_quantization(G, node): if G.quantization: @@ -80,7 +94,7 @@ def description(val): @staticmethod def needs_valid_dimension(val): - return Matcher.property_register("DESCRIPTION", val) + return Matcher.property_register("NEEDS_VALID_DIMENSION", val) @staticmethod def modifies_dimensions(val): @@ -94,6 +108,20 @@ def run_before(*args): def run_after(*args): return Matcher.property_register("RUN_AFTER", args) + @staticmethod + def run_again_on_match(*args): + return Matcher.property_register("RUN_AGAIN_ON_MATCH", args) + + @staticmethod + def run_qtune_on_match(cls): + setattr(cls, 'RUN_QTUNE_ON_MATCH', True) + return cls + + @staticmethod + def run_adjust_on_match(cls): + setattr(cls, 'RUN_ADJUST_ON_MATCH', True) + return cls + @staticmethod def groups(*args): return Matcher.property_register("GROUPS", args) @@ -113,60 +141,11 @@ def deco(cls): modifies_dimensions = Matcher.modifies_dimensions run_before = Matcher.run_before run_after = Matcher.run_after -groups = Matcher.groups - -class DontReplaceError(Exception): - pass - - -class DefaultMatcher(Matcher): - @abstractmethod - def match_function(self, G: GraphView) -> Generator[GraphView, None, None]: - pass - - @abstractmethod - def replace_function(self, G: GraphView, subgraph: GraphView) -> Node: - pass - - def _match(self, G: GraphView, set_identity: bool = True, **kwargs) -> bool: - replaced = True - has_modified_graph = False - while replaced: - replaced = False - for subgraph in self.match_function(G): - # TODO - Save in and out edges here since the replace function may modify the - # subgraph - in_edges = [in_edge for input_node in subgraph.inputs() - for in_edge in G.in_edges(input_node.name)] - out_edges = [out_edge for output_node in subgraph.outputs() - for out_edge in G.out_edges(output_node.name)] - try: - replacement, edge_in_mapping, edge_out_mapping = self.replace_function( - G, subgraph) - if replacement is None: - G.remove_fragment(subgraph) - has_modified_graph = True - elif isinstance(replacement, Node): - # use saved in and out edges - G.replace_fragment(subgraph, - replacement, - frag_in_edges=in_edges, - frag_out_edges=out_edges, - edge_in_mapping=edge_in_mapping, - edge_out_mapping=edge_out_mapping) - has_modified_graph = True - else: - raise TypeError( - "unexcepted return value from replace_function") - replaced = True - break - except DontReplaceError: - pass +run_again_on_match = Matcher.run_again_on_match +run_qtune_on_match = Matcher.run_qtune_on_match +run_adjust_on_match = Matcher.run_adjust_on_match - if set_identity: - self.set_identity(G) - - return has_modified_graph +groups = Matcher.groups # This can be used to define groups of matches to be selected @@ -176,52 +155,56 @@ class MatchGroup(Matcher): def __init__(self, *args: Sequence[Matcher], identity: str = None): super().__init__(identity) - self.matches = list(args) + self._matches = {match.name: match for match in args} + self._matches_pending = [] + self._adjust_pending = False + self._qtune_pending = False + + @property + def run_again(self): + return self._matches_pending + + @property + def run_qtune(self): + return self._qtune_pending + + @property + def run_adjust(self): + return self._adjust_pending def add_match(self, match: Matcher): - self.matches.append(match) + self._matches.append(match) def _match(self, G: GraphView, set_identity: bool = True, **kwargs): # Note: assumption is that dimensions are valid when a match is called found_match = True dimensions_set = True + self._matches_pending = [] + self._adjust_pending = False + self._qtune_pending = False while found_match: found_match = False - for match_instance in self.matches: - LOG.debug("fusions - start %s", match_instance.name) - if match_instance.NEEDS_VALID_DIMENSION and not dimensions_set: + matches = list(self._matches.values()) + while matches: + match = matches.pop(0) + LOG.debug("fusions - start %s", match.name) + if match.NEEDS_VALID_DIMENSION and not dimensions_set: G.add_dimensions(quiet=True) dimensions_set = True - has_modified_graph = match_instance.match( + has_modified_graph = match.match( G, set_identity=False, group_identity=self._identity) if has_modified_graph: - LOG.info("++ fusion %s modified graph", match_instance.name) + LOG.info("++ fusion %s modified graph", match.name) found_match = True G.add_dimensions(quiet=True) + for required_match in match.run_again: + if match not in self._matches_pending: + self._matches_pending.append(required_match) + self._adjust_pending = self._adjust_pending or match.run_adjust + if G.quantization: + self._qtune_pending = self._qtune_pending or match.run_qtune + if dimensions_set and has_modified_graph: dimensions_set = False if set_identity: self.set_identity(G) - - -def find_forward(G: GraphView, edge, find_node_classes, skip_node_classes=None, find_skip=None): - if find_skip is None: - find_skip = [find_node_classes, skip_node_classes] - for idx, elem in enumerate(find_skip): - if elem is not None and not isinstance(elem, tuple): - if isinstance(elem, list): - find_skip[idx] = tuple(elem) - else: - find_skip[idx] = tuple([elem]) - if isinstance(edge.to_node, find_skip[0]): - return [[edge]] - if skip_node_classes and isinstance(edge.to_node, find_skip[0]): - res = [] - for out_edge in G.out_edges(edge.to_node.name): - edge_lists = find_forward(G, out_edge, find_node_classes, - find_skip=find_skip) - if not edge_lists: - continue - res.extend([[edge] + edge_list for edge_list in edge_lists]) - return res - return [] diff --git a/tools/nntool/graph/matches/matchers/batchnorm_to_discrete_ops.py b/tools/nntool/graph/matches/matchers/batchnorm_to_discrete_ops.py new file mode 100644 index 000000000..9b7e9ae39 --- /dev/null +++ b/tools/nntool/graph/matches/matchers/batchnorm_to_discrete_ops.py @@ -0,0 +1,70 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging + +import numpy as np +from graph.dim import Dim +from graph.types import (ConstantInputParameters, MatrixSubParameters, + NNEdge) +from graph.types.conv2d import BatchNormalizationParameters +from graph.types.tensor_arithmetic import MatrixMulParameters +from utils.graph import GraphView + +from ..matcher import Matcher, match_name, description, groups, run_qtune_on_match + +LOG = logging.getLogger("nntool." + __name__) + + +@match_name('batchnorm_to_discrete_ops') +@description('Convert BatchNormParameters into a set of broadcasted operations') +@groups('scaled', 'symmetric') +class FuseBatchnorm(Matcher): + + def _match(self, G: GraphView, set_identity: bool = True, **kwargs): + + has_modified_graph = False + for bn_node in G.nodes(node_classes=BatchNormalizationParameters): + w_bn = bn_node.scale / \ + np.sqrt(bn_node.epsilon + bn_node.running_variance) + b_bn = bn_node.bias - bn_node.running_mean * bn_node.scale / \ + np.sqrt(bn_node.running_variance + bn_node.epsilon) + + mul_params = MatrixMulParameters( + G.unique_name(f"{bn_node.name}_mul")) + add_params = MatrixSubParameters( + G.unique_name(f"{bn_node.name}_add")) + broadcasted_shape = [1 if i != bn_node.axis else dim for i, dim in enumerate( + bn_node.in_dims[0].shape)] + scale_node = ConstantInputParameters(G.unique_name(f"{bn_node.name}_scale"), value=w_bn.reshape( + broadcasted_shape), dims=Dim.unnamed(broadcasted_shape)) + bias_node = ConstantInputParameters(G.unique_name(f"{bn_node.name}_bias"), value=b_bn.reshape( + broadcasted_shape), dims=Dim.unnamed(broadcasted_shape)) + + from_node = G.in_edges(bn_node)[0].from_node + to_node = G.out_edges(bn_node)[0].to_node + G.remove(bn_node) + G.add_edge(NNEdge(from_node, mul_params)) + G.add_edge(NNEdge(scale_node, mul_params, to_idx=1)) + G.add_edge(NNEdge(mul_params, add_params)) + G.add_edge(NNEdge(bias_node, add_params, to_idx=1)) + G.add_edge(NNEdge(add_params, to_node)) + + has_modified_graph = True + + if set_identity: + self.set_identity(G) + + return has_modified_graph diff --git a/tools/nntool/graph/matches/matchers/concat_slice.py b/tools/nntool/graph/matches/matchers/concat_slice.py new file mode 100644 index 000000000..3fa4f2c44 --- /dev/null +++ b/tools/nntool/graph/matches/matchers/concat_slice.py @@ -0,0 +1,186 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging +from functools import reduce + +from graph.matches.match_utils import search_up +from graph.types import ConcatParameters, NNEdge +from graph.types.others import (NoOPParameters, ReshapeParameters, + StridedSliceParameters) +from utils.compatible_transposes import find_combination +from utils.graph import GraphView + +from ..matcher import (Matcher, description, groups, match_name, + needs_valid_dimension, run_qtune_on_match) + +LOG = logging.getLogger("nntool." + __name__) + + +def info(msg): + LOG.info(msg) + +def validate_slice(node: StridedSliceParameters): + if any(sl[2] != 1 for sl in node.act_slice): + return [None] * 2 + slices_axes = node.slices_axes + if len(slices_axes) != 1: + return [None] * 2 + axis = slices_axes[0] + act_slice = node.act_slice[axis] + return axis, (act_slice[0], act_slice[1]-act_slice[0]) + +def up_from_slice(G, edge, axis, shape, remove_nodes=None, removing=True, reshape=None): + if remove_nodes is None: + remove_nodes = [] + if removing: + remove_nodes.append(edge.to_node) + node = edge.from_node + if isinstance(node, ConcatParameters): + if axis != node.axis: + return [None] * 4 + offsets = node.offsets + if shape[0] not in offsets: + return [None] * 4 + index = offsets.index(shape[0]) + length = node.in_dims[index].shape[node.axis] + if shape[1] != length: + return [None] * 4 + return (remove_nodes, edge, index, reshape) + else: + if isinstance(node, ReshapeParameters): + if reshape is None: + reshape = node + combinations = find_combination(node.shape, node.old_shape) + combination = next(iter([comb for comb in combinations if (axis,) in comb]), None) + if combination is None: + return [None] * 4 + axis = combination.index((axis,)) + elif not isinstance(node, NoOPParameters): + return [None] * 4 + return up_from_slice( + G, + G.in_edges(node)[0], + axis, + shape, + remove_nodes=remove_nodes, + removing=removing and len(G.out_edges(node)) == 1, + reshape=reshape + ) + +@groups('*') +@run_qtune_on_match +@needs_valid_dimension(True) +@match_name("concat_slice") +@description("removes slices after concats that match an input of the concat") +class ConcatSliceMatch(Matcher): + + def _match(self, G: GraphView, set_identity: bool = True, **kwargs) -> bool: + has_modified_graph = False + concat_slice_edges = {} + for slice_node in G.nodes(node_classes=StridedSliceParameters): + # validate that slice is positive unit stride on a single axis + axis, shape = validate_slice(slice_node) + if axis is None: + continue + # search up for a concat + remove_nodes, concat_edge, concat_in_idx, reshape = up_from_slice( + G, + G.in_edges(slice_node)[0], + axis, + shape) + if not remove_nodes: + continue + concat = concat_edge.from_node + concat_slice_edges.setdefault( + concat, []).append((slice_node, remove_nodes, concat_in_idx, reshape)) + if not concat_slice_edges: + return False + + for concat, slices in concat_slice_edges.items(): + for (slice_node, remove_nodes, concat_in_idx, reshape) in slices: + self.eliminate_slice(G, concat, slice_node, remove_nodes, concat_in_idx, reshape) + if not G.out_edges(concat): + has_modified_graph = True + concat_in_edges = G.in_edges(concat) + info(f"removing concat {concat.name}") + if concat_in_edges: + self.resolve_unused_concat_in_edges( + G, concat, concat_in_edges) + if concat.name in G: + G.remove(concat) + + if set_identity: + self.set_identity(G) + + return has_modified_graph + + def search_delete_nodes_up(self, G, edge): + out_edges = G.out_edges(edge.from_node) + if len(out_edges) > 1: + return [] + return [edge.from_node] + self.search_delete_nodes_up(G, G.in_edges(edge.from_node)[0]) + + @staticmethod + def edge_list_str(G, edges): + edge_list = list(reversed([edge.to_node.name for edge in edges])) + if len(G.out_edges(edges[-1].from_node)) == 1: + edge_list.insert(0, f'{edges[-1].from_node.name} (removed)') + else: + edge_list.insert(0, edges[-1].from_node.name) + return "->".join(edge_list) + + def resolve_unused_concat_in_edges(self, G, concat, concat_in_edges): + for edge in concat_in_edges: + nodes = self.search_delete_nodes_up(G, edge) + if nodes: + info(f"removing unused nodes {' '.join(node.name for node in nodes)}") + for node in nodes: + if node.name in G: + G.remove(node) + + def eliminate_slice(self, G, concat, slice_node, remove_nodes, concat_in_idx, reshape_in): + concat_in_edge = G.indexed_in_edges(concat)[concat_in_idx] + node_idx = (concat_in_edge.from_node, concat_in_edge.from_idx) + info(f'removing slice {slice_node.name} and connecting {concat_in_edge.from_node.name}:{concat_in_edge.from_idx} to its edges') + if reshape_in: + reshape = ReshapeParameters( + G.unique_name(f'{slice_node.name}_reshape'), + old_shape=concat_in_edge.from_node.out_dims[concat_in_edge.from_idx].shape, + shape=slice_node.out_shape) + elif slice_node.changes_shape: + reshape = ReshapeParameters( + G.unique_name(f'{slice_node.name}_reshape'), + old_shape=slice_node.slice_shape, + shape=slice_node.out_shape) + else: + reshape = None + if reshape: + G.add_edge( + NNEdge( + from_node=node_idx[0], + from_idx=node_idx[1], + to_node=reshape)) + node_idx = (reshape, 0) + + slice_out_edges = G.out_edges(slice_node) + for rnode in remove_nodes: + if rnode.name in G: + G.remove(rnode) + if slice_node.name in G: + G.remove(slice_node) + for edge in slice_out_edges: + G.add_edge(NNEdge(from_node=node_idx[0], from_idx=node_idx[1], + to_node=edge.to_node, to_idx=edge.to_idx)) diff --git a/tools/nntool/graph/matches/matchers/concat_split.py b/tools/nntool/graph/matches/matchers/concat_split.py index 9b5151ab7..d253489a2 100644 --- a/tools/nntool/graph/matches/matchers/concat_split.py +++ b/tools/nntool/graph/matches/matchers/concat_split.py @@ -14,13 +14,12 @@ # along with this program. If not, see . import logging +from graph.matches.match_utils import search_up from graph.types import ConcatParameters, NNEdge, SplitParameters -from graph.types.others import CopyParameters, NoOPParameters +from graph.types.others import CopyParameters from utils.graph import GraphView -from utils.node_id import NodeId -from ..match_utils import search_down from ..matcher import Matcher, description, groups, match_name, run_before LOG = logging.getLogger("nntool." + __name__) @@ -29,20 +28,21 @@ @groups('*') @match_name("concat_split") @description("removes concat/split pair where all in edges on the concat match the out edges on the split") +@run_before('insert_copies') class ConcatSplitMatch(Matcher): def _match(self, G: GraphView, set_identity: bool = True, **kwargs) -> bool: has_modified_graph = False - for split_node in set([node for node in G.nodes() if isinstance(node, SplitParameters)]): + for split_node in G.nodes(node_classes=SplitParameters): in_edges = G.in_edges(split_node.name) if len(in_edges) > 1: continue in_edge = in_edges[0] - if not isinstance(in_edge.from_node, ConcatParameters): - continue - concat_node = in_edge.from_node - if len(G.out_edges(concat_node.name)) > 1: + edges = search_up(G, in_edge, ConcatParameters, can_pass=(CopyParameters,), multi_on_target=False) + if not edges: continue + nodes = [split_node] + [edge.from_node for edge in edges] + concat_node = nodes[-1] if concat_node.axis != split_node.axis: continue axis = concat_node.axis @@ -57,8 +57,7 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs) -> bool: concat_node.name, split_node.name) concat_in_edges = G.indexed_in_edges(concat_node.name) split_out_edges = G.indexed_out_edges(split_node.name) - G.remove(split_node) - G.remove(concat_node) + G.remove_all(nodes) for idx, in_edge in enumerate(concat_in_edges): for out_edge in split_out_edges[idx]: G.add_edge(NNEdge(from_node=in_edge.from_node, from_idx=in_edge.from_idx, @@ -68,106 +67,3 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs) -> bool: self.set_identity(G) return has_modified_graph - - -def reduce_slices(slices, shapes): - res_slice = [] - res_shape = [] - for slice_axis, shape_axis in zip(zip(*slices), zip(*shapes)): - if slice_axis[0] == slice_axis[1]: - res_slice.append(slice_axis[0]) - res_shape.append(shape_axis[0]) - else: - res_slice.append( - (slice_axis[0][0], - slice_axis[-1][1], - slice_axis[0][2])) - res_shape.append(sum(shape_axis)) - return res_slice, res_shape - - -def remove_edges(G, edges): - if not edges: - return - edges = edges.copy() - while len(edges) > 1: - edge = edges.pop(0) - G.remove(edge.to_node) - if G.quantization: - nid = NodeId(edge.to_node) - if nid in G.quantization: - del G.quantization[nid] - try: - G.remove_edge(edges[0]) # @IgnoreException - except KeyError: - pass - - -@groups('*') -@match_name("split_concat") -@run_before('remove_noops', 'remove_copies') -@description("removes splits that go to concats where all the out edges of the split are in sequence in the concat") -class SplitConcatMatch(Matcher): - def _match(self, G: GraphView, set_identity: bool = True, **kwargs) -> bool: - edge_groups = [] - for node in G.nodes(node_classes=SplitParameters): - cur_group = None - for out_edge_bundle in G.indexed_out_edges(node): - if len(out_edge_bundle) == 1: - out_edge = out_edge_bundle[0] - concat_node_edges = search_down(G, out_edge, ConcatParameters, - can_pass=(CopyParameters, NoOPParameters)) - if concat_node_edges: - if cur_group: - this_concat_edge = concat_node_edges[-1] - last_concat_edge = cur_group[-1][-1] - if this_concat_edge.to_node == last_concat_edge.to_node and this_concat_edge.to_idx == last_concat_edge.to_idx + 1: - cur_group.append(concat_node_edges) - continue - if len(cur_group) > 1: - edge_groups.append(cur_group) - cur_group = [concat_node_edges] - continue - if cur_group: - if len(cur_group) > 1: - edge_groups.append(cur_group) - cur_group = None - if cur_group: - if len(cur_group) > 1: - edge_groups.append(cur_group) - cur_group = None - # we leave the splits and concats after this since they will be cleared up by remove_noops - for edge_group in edge_groups: - split_node = edge_group[0][0].from_node - concat_node = edge_group[0][-1].to_node - from_idx = edge_group[0][0].from_idx - to_idx = edge_group[-1][0].from_idx - LOG.info(f"combining outputs {from_idx}:{to_idx} on split node {split_node.name} followed by concat {concat_node.name}") - # combine slices and shapes on edges in group - new_slice, new_shape = reduce_slices( - split_node.act_slices[from_idx:to_idx+1], - split_node.out_shapes[from_idx:to_idx+1] - ) - split_node.act_slices = split_node.act_slices[:from_idx] + [ - new_slice] + split_node.act_slices[to_idx+1:] - split_node.out_shapes = split_node.out_shapes[:from_idx] + [ - new_shape] + split_node.out_shapes[to_idx+1:] - # remove all edges and intermediate nodes on all edge groups except the first - for edge_list in edge_group[1:]: - remove_edges(G, edge_list) - out_edge_bundles = G.indexed_out_edges(split_node) - # move edges beyond the edge group after the first index - for offset, edge_list in enumerate(out_edge_bundles[to_idx+1:]): - assert len(edge_list) == 1 - edge = edge_list[0] - G.remove_edge(edge) - G.add_edge(NNEdge.clone(edge, from_idx=from_idx+1+offset)) - # reindex the in edges in the concat - from_idx = edge_group[0][-1].to_idx - to_idx = edge_group[-1][-1].to_idx - in_edges = G.indexed_in_edges(concat_node) - for offset, in_edge in enumerate(in_edges[to_idx+1:]): - G.remove_edge(in_edge) - G.add_edge(NNEdge.clone(in_edge, to_idx=from_idx+1+offset)) - - return bool(edge_groups) diff --git a/tools/nntool/graph/matches/matchers/copy_on_outputs.py b/tools/nntool/graph/matches/matchers/copy_on_outputs.py new file mode 100644 index 000000000..3a4462842 --- /dev/null +++ b/tools/nntool/graph/matches/matchers/copy_on_outputs.py @@ -0,0 +1,82 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging + +from graph.types import CopyParameters, NNEdge, OutputParameters +from utils.graph import GraphView +from utils.node_id import NodeId + +from ..matcher import (Matcher, description, groups, match_name, + modifies_dimensions, run_before) + +LOG = logging.getLogger("nntool." + __name__) + + +def search_down(G, edge): + node = edge.to_node + if node.no_model_code: + res = [] + for out_edge in G.out_edges(node): + res.extend(search_down(G, out_edge)) + return res + elif isinstance(node, OutputParameters): + return [node] + else: + return [] + + +def search_up(G, edge): + node = edge.from_node + out_edges = G.indexed_out_edges(node)[edge.from_idx] + res = [] + if len(out_edges) > 1: + for out_edge in out_edges: + if out_edge == edge: + continue + res.extend(search_down(G, out_edge)) + if node.no_model_code: + edge = G.in_edges(node)[0] + res.extend(search_up(G, edge)) + return res + + +@match_name("copy_on_outputs") +@description("Insert copy on multiple edges from same node output to graph outputs") +@modifies_dimensions(True) +@groups('*') +@run_before('*') +class CopyOnOutputs(Matcher): + + def _match(self, G: GraphView, set_identity: bool = True, **kwargs): + outputs = G.nodes(node_classes=OutputParameters) + results = [] + while outputs: + outp = outputs.pop(0) + other_outputs = search_up(G, G.in_edges(outp)[0]) + for other_outp in other_outputs: + if other_outp in outputs: + outputs.remove(other_outp) + results.extend(other_outputs) + for output in results: + LOG.info( + "Insert copy before output %s", output.name) + copy_node = CopyParameters(G.unique_name(f'{output.name}_copy')) + G.insert_node_before(copy_node, output, edge_class=NNEdge) + nid = NodeId(output) + if G.quantization and nid in G.quantization: + G.quantization.copy_qrec(output, 'in', 0, copy_node) + + return bool(results) diff --git a/tools/nntool/graph/matches/matchers/copy_on_split_inputs.py b/tools/nntool/graph/matches/matchers/copy_on_split_inputs.py deleted file mode 100644 index 4b0be9606..000000000 --- a/tools/nntool/graph/matches/matchers/copy_on_split_inputs.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -from graph.matches.matchers.insert_copies import find_real_in_edge -import logging - -from graph.types import InputParameters, ReshapeParameters, ConstantInputParameters -from graph.types.others import ConcatParameters, CopyParameters, SplitParameters -from utils.graph import GraphView - -from ..matcher import Matcher, groups, match_name, description, modifies_dimensions, run_after - -LOG = logging.getLogger("nntool." + __name__) - - -def search_up_for_input(G, node, going_up=None): - if going_up is None or isinstance(node, ReshapeParameters): - return search_up_for_input(G, G.in_edges(node.name)[0].from_node, going_up=True) - if isinstance(node, (InputParameters, ConstantInputParameters)): - return node - return None - -@match_name("copy_on_split_inputs") -@description("Insert copy on inputs that could be in a tensor stack") -@modifies_dimensions(True) -@groups('*') -class CopyOnSplitInputs(Matcher): - - def _match(self, G: GraphView, set_identity: bool = True, **kwargs): - - candidates = [node for node in G.nodes(node_classes=(SplitParameters, ConcatParameters))] - need_a_copy_edges = [] - for node in candidates: - for idx, edge in enumerate(G.indexed_in_edges(node.name)): - real_from_node, _ = find_real_in_edge(G, edge) - if isinstance(real_from_node, (InputParameters, ConstantInputParameters)): - need_a_copy_edges.append((edge, idx)) - has_modified_graph = False - for edge in need_a_copy_edges: - LOG.info( - "Insert copy on split input %s", edge[0].to_node.name) - has_modified_graph = True - cnode = CopyParameters(G.unique_name(f'{edge[0].to_node.name}_copy')) - G.insert_node_at_edge(cnode, edge[0]) - if G.quantization: - G.quantization.copy_qrec(edge[0].to_node, 'in', 0, cnode) - if set_identity: - self.set_identity(G) - return has_modified_graph diff --git a/tools/nntool/graph/matches/matchers/duplicate_constants.py b/tools/nntool/graph/matches/matchers/duplicate_constants.py index 6aebf13cb..bd4a103c3 100644 --- a/tools/nntool/graph/matches/matchers/duplicate_constants.py +++ b/tools/nntool/graph/matches/matchers/duplicate_constants.py @@ -22,7 +22,7 @@ LOG = logging.getLogger("nntool." + __name__) -@match_name("match_duplicate_constants") +@match_name("duplicate_constants") @description("""Find constants that are linked to more than one node and duplicate them""") @run_before('*') @groups('symmetric', 'scaled') diff --git a/tools/nntool/graph/matches/matchers/duplicate_operations.py b/tools/nntool/graph/matches/matchers/duplicate_operations.py index 4ac00b591..6072c389f 100644 --- a/tools/nntool/graph/matches/matchers/duplicate_operations.py +++ b/tools/nntool/graph/matches/matchers/duplicate_operations.py @@ -12,32 +12,37 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from graph.dim import Dim import logging from copy import deepcopy from functools import partial from itertools import groupby import numpy as np +from graph.dim import Dim from graph.types import SplitParameters from graph.types.base import ComparableParameters, NNEdge from utils.graph import GraphView -from ..matcher import Matcher, description, groups, match_name, run_before +from ..matcher import Matcher, description, groups, match_name, run_before, run_qtune_on_match LOG = logging.getLogger("nntool." + __name__) -@match_name("match_duplicate_operations") + +@match_name("duplicate_operations") @description("""Removes operations that are duplicates on the same edge""") @run_before("*") @groups('symmetric', 'scaled') +@run_qtune_on_match class MatchDuplicateOperations(Matcher): + def __init__(self, identity: str = None, limit_to_dest_classes=None): + super().__init__(identity) + self._limit_to_dest_classes = limit_to_dest_classes def _match(self, G: GraphView, set_identity: bool = True, **kwargs): - if G.quantization: - LOG.warning( - 'match_duplicate_operations does not handle quantized graphs') - return False + # if G.quantization: + # LOG.warning( + # 'duplicate_operations does not handle quantized graphs') + # return False def same_source_edge_fn(x): return f"{x.from_node.__hash__()}##{x.from_idx}" @@ -53,6 +58,11 @@ def same_dest_edge(x): # all have the same origin same_source_edges = [elem for elem in same_source_edges if len(elem) > 1] + if self._limit_to_dest_classes: + same_source_edges = list( + filter( + lambda edges: all(isinstance(edge.to_node, self._limit_to_dest_classes) for edge in edges), + same_source_edges)) same_dest_edges = [] same_dest_group_edges = [] @@ -63,7 +73,7 @@ def same_dest_edge(x): first = same_source_edge.pop(0) others = list(filter(partial(lambda x, y: x.to_node != y.to_node and y.to_node.is_same_operation_as(G, - x.to_node), first), same_source_edge)) + x.to_node), first), same_source_edge)) if others: same_dest_edges.append(tuple([first] + others)) for other in others: @@ -83,10 +93,11 @@ def same_dest_edge(x): while same_dest_edges: edge_set = same_dest_edges.pop(0) keep_node = edge_set[0].to_node - other_edge_sets = [edges for edges in same_dest_edges if any(edge.to_node == keep_node for edge in edges)] + other_edge_sets = [edges for edges in same_dest_edges if any( + edge.to_node == keep_node for edge in edges)] for other_edge_set in other_edge_sets: same_dest_edges.remove(other_edge_set) - + nodes_to_delete = set() for edge_set in [edge_set] + other_edge_sets: for edge in edge_set: @@ -95,13 +106,13 @@ def same_dest_edge(x): continue nodes_to_delete.add(other_node) for out_edge in G.out_edges(other_node): - G.add_edge(NNEdge(from_node=keep_node, to_node=out_edge.to_node, to_idx=out_edge.to_idx)) + G.add_edge( + NNEdge(from_node=keep_node, to_node=out_edge.to_node, to_idx=out_edge.to_idx)) LOG.info( f'removed duplicates {",".join(node.name for node in nodes_to_delete)} to {keep_node.name}') for node in nodes_to_delete: G.remove(node) - - + # # all are multiple edges that go to something comparable # for edge_set in same_dest_edges: @@ -145,7 +156,8 @@ def same_dest_edge(x): out_edges = G.out_edges(first_node.name) for edge in out_edges: G.remove_edge(edge) - G.add_edge(NNEdge(from_node=split1, from_idx=out_num, to_node=edge.to_node, to_idx=edge.to_idx)) + G.add_edge(NNEdge(from_node=split1, from_idx=out_num, + to_node=edge.to_node, to_idx=edge.to_idx)) G.add_edge(NNEdge(from_node=first_node, to_node=split1)) # first split output goes to original output for other in edge_set[1::]: @@ -169,7 +181,8 @@ def same_dest_edge(x): G.remove(weights_other) G.remove(biases_other) for edge in out_edges: - G.add_edge(NNEdge(from_node=split1, from_idx=out_num, to_node=edge.to_node, to_idx=edge.to_idx)) + G.add_edge(NNEdge(from_node=split1, from_idx=out_num, + to_node=edge.to_node, to_idx=edge.to_idx)) LOG.info( f'merged convolutions {",".join(dup_nodes)} into {first_node.name}') if not found_more: diff --git a/tools/nntool/graph/matches/matchers/duplicate_operations_out.py b/tools/nntool/graph/matches/matchers/duplicate_operations_out.py index 1700adb7c..98078efe8 100644 --- a/tools/nntool/graph/matches/matchers/duplicate_operations_out.py +++ b/tools/nntool/graph/matches/matchers/duplicate_operations_out.py @@ -23,7 +23,7 @@ LOG = logging.getLogger("nntool." + __name__) -@match_name("match_duplicate_operations_out") +@match_name("duplicate_operations_out") @description("""Removes operations that are duplicates on the same out edge""") @run_before("*") @groups('*') @@ -37,7 +37,8 @@ def explore(self, G, nodes, result=None): out_edges_bundle = [G.indexed_out_edges(node.name) for node in nodes] if any(len(out_edges) != 1 or len(out_edges[0]) != 1 for out_edges in out_edges_bundle): return result - if any(not isinstance(node, ComparableParameters) or not node.is_same_operation_as(G, nodes[0]) + # node == nodes[0] added since node could be a multi input expression + if any(not isinstance(node, ComparableParameters) or not node.is_same_operation_as(G, nodes[0]) or node == nodes[0] for node in nodes[1::]): return result if not result: diff --git a/tools/nntool/graph/matches/matchers/equalize_sym_mult_concats.py b/tools/nntool/graph/matches/matchers/equalize_sym_mult_concats.py deleted file mode 100644 index a3aa280ac..000000000 --- a/tools/nntool/graph/matches/matchers/equalize_sym_mult_concats.py +++ /dev/null @@ -1,91 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import logging - -from graph.types import (ConcatParameters, ReshapeParameters, SplitParameters, - TransposeParameters) -from graph.types.base import FilterParameters -from utils.graph import Edge, GraphView -from utils.node_id import NodeId - -from ..matcher import Matcher, description, groups, match_name, modifies_dimensions - -LOG = logging.getLogger("nntool." + __name__) - -CAN_PASS = ( - ReshapeParameters, - TransposeParameters, - SplitParameters -) - -# TODO - This match should be rewritten to use the quantizer - - -def set_in_scale(qrec, index, scale): - in_q = qrec.in_qs[index] - assert qrec.ktype.startswith( - 'scaled'), "not supported on other quantization types" - in_q.scale = scale - - -def set_out_scale(node, qrec, index, scale): - out_q = qrec.out_qs[index] - assert qrec.ktype.startswith( - 'scaled'), "not supported on other quantization types" - if isinstance(node, FilterParameters): - assert index == 0, "trying to set strange index on filter quantization record" - out_q.scale = scale - qrec.cache['mul_biases_q'].scale = qrec.in_qs[0].scale * \ - qrec.in_qs[1].scale / out_q.scale - else: - out_q.scale = scale - - -def propagate_qtype_up(G, qtype, edge: Edge): - LOG.info("propagating scale up from node %s to node %s", - edge.to_node.name, edge.from_node.name) - qrec_out = G.quantization[NodeId(edge.from_node)] - set_out_scale(edge.from_node, qrec_out, edge.from_idx, qtype.scale) - qrec_in = G.quantization[NodeId(edge.to_node)] - set_in_scale(qrec_in, edge.to_idx, qtype.scale) - if isinstance(edge.from_node, CAN_PASS): - for edge in G.in_edges(edge.from_node.name): - propagate_qtype_up(G, qtype, edge) - -@match_name("equalize_sm_concats") -@description("""Equalize input quantization of concats with symmetric multiplicative quantization""") -@groups('symmetric') -@modifies_dimensions(False) -class EqualizeSymmetricMultiplicativeQuantivedConcats(Matcher): - - def _match(self, G: GraphView, set_identity: bool = True, **kwargs): - if not G.quantization: - return - concats = [node for node in G.nodes() if isinstance(node, - ConcatParameters)] - qrecs = [G.quantization[NodeId(node)] for node in concats] - if not all(qrec.ktype.startswith('scaled') for qrec in qrecs): - return - for concat, qrec in zip(concats, qrecs): - out_q = qrec.out_qs[0] - for edge in G.in_edges(concat.name): - in_q = qrec.in_qs[edge.to_idx] - if in_q != out_q: - propagate_qtype_up(G, out_q, edge) - - if set_identity: - self.set_identity(G) - - return False diff --git a/tools/nntool/graph/matches/matchers/expand_to_reshape.py b/tools/nntool/graph/matches/matchers/expand_to_reshape.py new file mode 100644 index 000000000..547f0852b --- /dev/null +++ b/tools/nntool/graph/matches/matchers/expand_to_reshape.py @@ -0,0 +1,50 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from graph.manipulations.eliminate_transposes.transpose_helpers import strip_ones +from graph.types.others import ExpandParameters, TransposeParameters +import logging + +from graph.dim import Dim +from graph.types import NNEdge, ReshapeParameters +from utils.graph import GraphView +from utils.node_id import NodeId + +from ..matcher import Matcher, match_name, description, run_before, groups, needs_valid_dimension + +LOG = logging.getLogger("nntool." + __name__) + +@match_name("expand_to_reshape") +@description("remove expands that are really just reshapes") +@run_before('*') +@groups('*') +@needs_valid_dimension(True) +class ExpandToReshape(Matcher): + + def _match(self, G: GraphView, set_identity: bool = True, **kwargs): + modified_graph = False + for node in G.nodes(node_classes=ExpandParameters): + in_shape = node.in_dims[0].shape + out_shape = node.out_dims[0].shape + if strip_ones(in_shape) != strip_ones(out_shape): + continue + LOG.info(f'replacing expand {node.name} with a reshape') + reshape = ReshapeParameters(G.unique_name(f'{node.name}_reshape'), old_shape=in_shape, shape=out_shape) + G.replace_node(node, reshape) + modified_graph = True + + if set_identity: + self.set_identity(G) + + return modified_graph diff --git a/tools/nntool/graph/matches/matchers/expression_matcher.py b/tools/nntool/graph/matches/matchers/expression_matcher.py index cd1f8c5d8..4f25528f1 100644 --- a/tools/nntool/graph/matches/matchers/expression_matcher.py +++ b/tools/nntool/graph/matches/matchers/expression_matcher.py @@ -250,7 +250,7 @@ def find_connected_groups(G): @match_name("expression_matcher") @description("Groups piecewise expressions for kernel generation") -@run_after('expand_transposes') +@run_after('*') @needs_valid_dimension(True) class ExpressionMatcher(Matcher): diff --git a/tools/nntool/graph/matches/matchers/filt_bigger_than_in.py b/tools/nntool/graph/matches/matchers/filter_bigger_than_input.py similarity index 100% rename from tools/nntool/graph/matches/matchers/filt_bigger_than_in.py rename to tools/nntool/graph/matches/matchers/filter_bigger_than_input.py diff --git a/tools/nntool/graph/matches/matchers/find_asymmetric_quantization.py b/tools/nntool/graph/matches/matchers/find_asymmetric_quantization.py deleted file mode 100644 index 411a35991..000000000 --- a/tools/nntool/graph/matches/matchers/find_asymmetric_quantization.py +++ /dev/null @@ -1,203 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# import logging - -# from graph.matches.matcher import Matcher -# from graph.types import (ActivationParameters, ConcatParameters, -# ConstantInputParameters, Conv2DParameters, -# ConvFusionParameters, FcParameters, -# GlobalPoolingParameters, InputParameters, -# MatrixAddParameters, OutputParameters, -# PoolingParameters, ReshapeParameters) - -# from utils.graph import GraphView -# from utils.node_id import NodeId - -# LOG = logging.getLogger("nntool." + __name__) - -# CAN_CHANGE_OUTPUT = ( -# InputParameters, ConstantInputParameters, Conv2DParameters, -# ConvFusionParameters, FcParameters, MatrixAddParameters -# ) - -# CAN_CHANGE_INPUT = ( -# OutputParameters, Conv2DParameters, ConvFusionParameters, -# FcParameters, MatrixAddParameters -# ) - -# CAN_PROPAGATE_INPUT = ( -# GlobalPoolingParameters, ReshapeParameters, ConcatParameters, ActivationParameters, PoolingParameters -# ) - -# ARE_MULTI_INPUT = ( -# ConcatParameters -# ) - -# class FindAsymmetricQuantization(Matcher): -# NAME = "find_asymmetric_quantization" -# DESCRIPTION = """Find nodes that can have asymmetric quantization. Must run after padding has been fused.""" - -# def can_change_input(self, G, node, exclude=None): -# """Returns None or a list of tuples of (node, multi_input_node) where node is an -# input of multi_input_node. An empty list is a confirmed string. A list that contains -# multi input nodes needs to be reconciled. An empty list means that this node -# cannot be changed.""" - -# if isinstance(node, CAN_PROPAGATE_INPUT): -# if exclude and node in exclude: -# return None -# nodes = [] -# for succ in [succ -# for succs in G.successors(node.name) -# for succ in succs]: -# can_change = self.can_change_input(G, succ, exclude=exclude) -# if can_change is None: -# return None -# nodes += can_change -# if isinstance(succ, ARE_MULTI_INPUT): -# nodes.append((node, succ)) -# return nodes -# if not isinstance(node, CAN_CHANGE_INPUT): -# return None -# if isinstance(node, ConvFusionParameters): -# filters = node.contained_filters() -# if len(filters) == 1 and not filters[0].padding.has_padding: -# return [] -# else: -# return None -# if isinstance(node, Conv2DParameters): -# return None if node.padding.has_padding else [] -# return [] - -# def can_change_output(self, node): -# return isinstance(node, CAN_CHANGE_OUTPUT) - -# def validate_multi_input(self, G, input_dict): -# # {start_node: [(pred, mi_node), ..]} -# mi_nodes = {} -# # index all of the predecessor nodes by mi node -# for pr_node, mi_node in [match for matches in input_dict.values() for match in matches]: -# pr_node_set = mi_nodes.get(mi_node) -# if pr_node_set is None: -# pr_node_set = set() -# mi_nodes[mi_node] = pr_node_set -# pr_node_set.add(pr_node) -# bad_mi_nodes = [] -# # check that all the predecessors were OK -# for mi_node, pr_nodes in mi_nodes.items(): -# if not all(node in pr_nodes for node in G.predecessors(mi_node)): -# bad_mi_nodes.append(mi_node) -# start_nodes = [] -# # find the records that have bad nodes in them -# if bad_mi_nodes: -# for start_node, matches in input_dict.items(): -# if any(mi_node in bad_mi_nodes for _, mi_node in matches): -# start_nodes.append(start_nodes) -# for start_node in start_nodes: -# del input_dict[start_node] -# matches = self.can_change_input(G, start_node, exclude=bad_mi_nodes) -# if matches is not None: -# assert len(matches) == 0 -# input_dict[start_node] = [] -# return input_dict - -# def change_output_to_async(self, G, node, idx): -# if isinstance(node, ConvFusionParameters): -# changing = False -# for fnode in node.contained_nodes(): -# if changing: -# nid = NodeId(node, fnode) -# qrec = G.quantization[nid] -# if isinstance(qrec.in_qs[0], SymmetricMultQTypeWrapper): -# qrec.in_qs[0] = qrec.in_qs[0].wrapped -# if isinstance(qrec.out_qs[0], SymmetricMultQTypeWrapper): -# qrec.out_qs[0] = qrec.out_qs[0].wrapped -# elif isinstance(fnode, (Conv2DParameters, FcParameters)): -# changing = True -# nid = NodeId(node, fnode) -# qrec = G.quantization[nid] -# if isinstance(qrec.out_qs[0], SymmetricMultQTypeWrapper): -# qrec.out_qs[0] = qrec.out_qs[0].wrapped - -# nid = NodeId(node) -# qrec = G.quantization[nid] -# if isinstance(qrec.out_qs[idx], SymmetricMultQTypeWrapper): -# qrec.out_qs[idx] = qrec.out_qs[idx].wrapped - -# def change_input_to_async(self, G, node, idx): -# if isinstance(node, ConvFusionParameters): -# for fnode in node.contained_nodes(): -# nid = NodeId(node, fnode) -# qrec = G.quantization[nid] -# if isinstance(fnode, (Conv2DParameters, FcParameters)): -# if isinstance(qrec.in_qs[0], SymmetricMultQTypeWrapper): -# qrec.in_qs[0] = qrec.in_qs[0].wrapped -# qrec.in_qs[2].link(qrec.in_qs[1], qrec.in_qs[0]) -# return -# if isinstance(qrec.in_qs[0], SymmetricMultQTypeWrapper): -# qrec.in_qs[0] = qrec.in_qs[0].wrapped -# if isinstance(qrec.out_qs[0], SymmetricMultQTypeWrapper): -# qrec.out_qs[0] = qrec.out_qs[0].wrapped - -# nid = NodeId(node) -# qrec = G.quantization[nid] -# if isinstance(qrec.in_qs[idx], SymmetricMultQTypeWrapper): -# qrec.in_qs[idx] = qrec.in_qs[idx].wrapped -# if isinstance(node, (Conv2DParameters, FcParameters)): -# qrec.in_qs[2].link(qrec.in_qs[1], qrec.in_qs[idx]) -# if isinstance(node, OutputParameters) and isinstance(qrec.out_qs[0], SymmetricMultQTypeWrapper): -# qrec.out_qs[0] = qrec.out_qs[0].wrapped - -# def do_change(self, G, node, idx=0): -# self.change_output_to_async(G, node, idx) -# for edge in G.out_edges(node.name): -# if isinstance(edge.to_node, CAN_PROPAGATE_INPUT): -# self.change_input_to_async(G, edge.to_node, edge.to_idx) -# self.do_change(G, edge.to_node, edge.from_idx) -# else: -# assert isinstance(edge.to_node, CAN_CHANGE_INPUT) -# if isinstance(edge.to_node, ConvFusionParameters): -# filters = edge.to_node.contained_filters() -# assert len(filters) == 1 and not filters[0].padding.has_padding -# if isinstance(edge.to_node, Conv2DParameters): -# assert not edge.to_node.padding.has_padding -# self.change_input_to_async(G, edge.to_node, edge.to_idx) - -# def _match(self, G: GraphView, set_identity: bool = True, **kwargs): -# if not G.quantization: -# return -# input_dict = {} -# for node in G.nodes(): -# if not self.can_change_output(node): -# continue -# all_matches = [] -# for succ in [succ for succs in G.successors(node.name) for succ in succs]: -# matches = self.can_change_input(G, succ) -# if matches is None: -# all_matches = None -# break -# all_matches += matches -# if all_matches is None: -# continue -# input_dict[node] = all_matches - -# input_dict = self.validate_multi_input(G, input_dict) -# for node in input_dict: -# # all nodes that can currently change output have one output -# self.do_change(G, node) - -# if set_identity: -# self.set_identity(G) -# return False diff --git a/tools/nntool/graph/matches/matchers/fuse_batchnorm.py b/tools/nntool/graph/matches/matchers/fuse_batchnorm.py new file mode 100644 index 000000000..57722664f --- /dev/null +++ b/tools/nntool/graph/matches/matchers/fuse_batchnorm.py @@ -0,0 +1,87 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging + +import numpy as np +from graph.types import (ConstantInputParameters, MatMulOpParameters, MatMulTransposedParameters, + NNEdge) +from graph.types.conv2d import BatchNormalizationParameters +from utils.graph import GraphView + +from ..matcher import Matcher, match_name, description, groups, run_qtune_on_match + +LOG = logging.getLogger("nntool." + __name__) + + +@match_name('fuse_batchnorm') +@description('Fuse batch normalization into MatMul') +@groups('scaled', 'symmetric') +@run_qtune_on_match +class FuseBatchnorm(Matcher): + + def _match(self, G: GraphView, set_identity: bool = True, **kwargs): + + has_modified_graph = False + nodes = [] + for node in G.nodes(node_classes=BatchNormalizationParameters): + in_node = G.indexed_in_edges(node)[0].from_node + if isinstance(in_node, MatMulOpParameters): + nodes.append((node, in_node)) + + for bn_node, filt_node in nodes: + filt_in_edges = G.indexed_in_edges(filt_node.name) + weights_node = filt_in_edges[1].from_node + biases_node = filt_in_edges[2].from_node if len( + filt_in_edges) > 2 else None + w_bn = bn_node.scale / np.sqrt(bn_node.epsilon + bn_node.running_variance) + if not isinstance(weights_node, ConstantInputParameters): + continue + weights = weights_node.dqvalue + if len(w_bn) > 1: + if not isinstance(filt_node, MatMulTransposedParameters): + weights = np.swapaxes(weights.copy(), -2, -1) + if weights.shape[-2] != len(w_bn): + LOG.info(f'{filt_node.name} - weights shape does not match batch norm') + continue + if biases_node is None: + biases = np.zeros((weights.shape[-1],)) + biases_node = ConstantInputParameters( + G.unique_name(f'{filt_node.name}_biases'), value=biases) + G.add_edge(NNEdge(from_node=biases, + to_node=filt_node, to_idx=2)) + elif not isinstance(biases_node, ConstantInputParameters): + continue + else: + biases = biases_node.dqvalue + # fold batch norm into conv weights and biases + if len(w_bn) > 1: + w_bn = np.diag(w_bn) + weights = np.matmul(w_bn, weights) + else: + weights = weights * w_bn + biases = bn_node.bias + ((biases - bn_node.running_mean) * + bn_node.scale / np.sqrt(bn_node.running_variance + bn_node.epsilon)) + if len(w_bn) > 1 and not isinstance(filt_node, MatMulTransposedParameters): + weights = np.swapaxes(weights, -2, -1) + weights_node.value = weights + biases_node.value = biases + G.remove_and_reconnect(bn_node, edge_class=NNEdge) + has_modified_graph = True + + if set_identity: + self.set_identity(G) + + return has_modified_graph diff --git a/tools/nntool/graph/matches/matchers/match_external_bias.py b/tools/nntool/graph/matches/matchers/fuse_external_bias.py similarity index 80% rename from tools/nntool/graph/matches/matchers/match_external_bias.py rename to tools/nntool/graph/matches/matchers/fuse_external_bias.py index 213a99851..fe258b10f 100644 --- a/tools/nntool/graph/matches/matchers/match_external_bias.py +++ b/tools/nntool/graph/matches/matchers/fuse_external_bias.py @@ -20,9 +20,8 @@ MatrixAddParameters, MatrixMulParameters, NNEdge) from graph.types.others import ReshapeParameters from utils.graph import GraphView -from utils.node_id import NodeId -from ..matcher import Matcher, match_name, description, groups, run_before +from ..matcher import Matcher, match_name, description, groups, run_before, run_qtune_on_match LOG = logging.getLogger("nntool." + __name__) @@ -33,10 +32,13 @@ MatrixMulParameters: (np.multiply, True) } + @match_name('fuse_external_bias') @description('Fuse bias addition after filter with filter bias') @groups('scaled', 'symmetric') -@run_before('match_op_activation', 'move_pooling_scale8', 'move_activations_pow2', 'move_activations_scale8') +@run_before('fuse_op_activation_scale8', 'fuse_op_activation_pow2', 'move_pooling_scale8', + 'move_activations_up') +@run_qtune_on_match class MatchExternalBias(Matcher): def _match(self, G: GraphView, set_identity: bool = True, **kwargs): @@ -77,37 +79,35 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs): LOG.warning('could not absorb %s into %s', const_node.name, filter_node.name) break - # If there is quantization then essentially the output of the filter - # takes the quantization of the output of the operation. - # The biases will not change since their quantization depends on the weights - # and input - fnid = NodeId(filter_node) - opnid = NodeId(op_node) - if G.quantization and (fnid in G.quantization or opnid in G.quantization): - if not (fnid in G.quantization and opnid in G.quantization): - LOG.warning( - 'could not absorb %s into %s - graph is partially quantized', const_node.name, filter_node.name) - break - fqrec = G.quantization[fnid] - opqrec = G.quantization[opnid] - fqrec.out_qs[0] = opqrec.out_qs[0] has_modified_graph = True LOG.info("fusing bias in %s into %s", const_node.name, filter_node.name) self.fuse_bias(G, filter_node, other_idx, op, flat_value, 2) if weights_and_biases: - # TODO - need to adjust weights quantization here LOG.info("fusing multiplicative bias in %s into %s", const_node.name, filter_node.name) self.fuse_bias(G, filter_node, other_idx, op, flat_value, 1) - out_edges = G.out_edges(op_node.name) + # save out edges and remove the mul or add + out_edges = G.out_edges(op_node) G.remove(op_node) if remove_constant: G.remove(const_node) + + # it's possible that there is a broadcast on the op from the constant + # if there is insert a reshape since it will no longer happen + in_shape = tuple(op_node.in_dims[out_edge.to_idx].shape) + out_shape = tuple(op_node.out_dims[0].shape) from_node = seen_reshape[-1] if seen_reshape else filter_node + if in_shape != out_shape: + reshape = ReshapeParameters(G.unique_name(f'{op_node.name}_reshape'), + old_shape=in_shape, shape=out_shape) + G.add_edge(NNEdge(from_node=from_node, to_node=reshape)) + from_node = reshape + + # connect up the output nodes for edge in out_edges: G.add_edge(NNEdge(from_node=from_node, to_node=edge.to_node, to_idx=edge.to_idx)) diff --git a/tools/nntool/graph/matches/matchers/match_external_bias_matmul.py b/tools/nntool/graph/matches/matchers/fuse_external_bias_matmul.py similarity index 92% rename from tools/nntool/graph/matches/matchers/match_external_bias_matmul.py rename to tools/nntool/graph/matches/matchers/fuse_external_bias_matmul.py index 04aa887c8..03c50aee0 100644 --- a/tools/nntool/graph/matches/matchers/match_external_bias_matmul.py +++ b/tools/nntool/graph/matches/matchers/fuse_external_bias_matmul.py @@ -21,7 +21,7 @@ RemoveUnnecessaryQuantizeOperators from graph.types import (ConstantInputParameters, MatrixAddParameters, MatrixMulParameters, NNEdge) -from graph.types.tensor_arithmetic import MatMulOpParameters +from graph.types.tensor_arithmetic import MatMulOpParameters, MatMulTransposedParameters from quantization.quantizer.new_quantizer import NewQuantizer from utils.graph import GraphView from utils.node_id import NodeId @@ -65,7 +65,7 @@ def reverse_matmul(G: GraphView, params): @match_name('fuse_external_bias_matmul') @description('Fuse bias addition after matmul') @groups('scaled', 'symmetric') -@run_before('match_op_activation', 'move_pooling_scale8', 'move_activations_pow2', 'move_activations_scale8', 'fuse_op_activation_scale8', 'fuse_op_activation_pow2') +@run_before('fuse_op_activation_scale8', 'fuse_op_activation_pow2', 'move_pooling_scale8', 'move_activations_up', 'fuse_op_activation_scale8', 'fuse_op_activation_pow2') class MatchExternalBiasMatmul(Matcher): def _match(self, G: GraphView, set_identity: bool = True, **kwargs): @@ -98,10 +98,7 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs): flat_value = const_node.dqvalue.flatten() out_shape = matmul.out_dims[0].shape - if len(out_shape) != 2: - raise ValueError( - f'strange outputs shape of {out_shape} for matmul {params.name}') - if len(flat_value) != out_shape[0] and len(flat_value) != out_shape[1]: + if len(flat_value) != out_shape[-1] and len(flat_value) != out_shape[-2]: LOG.info("can't fuse %s into %s - value shape is not correct for bias", const_node.name, matmul.name) break @@ -110,7 +107,7 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs): out_node = seen_reshape[-1] if seen_reshape else matmul if isinstance(op_node, MatrixAddParameters): if has_bias: - if len(flat_value.shape) != len(matmul.in_dims[2]): + if len(flat_value) != matmul.in_dims[2].size(): LOG.info( "can't fuse %s into %s - bias shape is not the same", const_node.name, matmul.name) break @@ -120,7 +117,7 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs): "folding additive bias from %s into existing bias on %s", op_node.name, matmul.name) bias_node.value = bias_node.dqvalue + flat_value else: - if len(flat_value) != out_shape[1]: + if len(flat_value) != out_shape[-1]: # matmul needs to be transposed to fuse this in_nodes, trans_node = reverse_matmul(G, matmul) if seen_reshape: diff --git a/tools/nntool/graph/matches/matchers/fuse_gap_convs.py b/tools/nntool/graph/matches/matchers/fuse_gap_convs.py new file mode 100644 index 000000000..beecee70c --- /dev/null +++ b/tools/nntool/graph/matches/matchers/fuse_gap_convs.py @@ -0,0 +1,231 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging +from copy import deepcopy + +from graph.types import (ActivationParameters, Conv2DParameters, + ConvFusionParameters, HSigmoidActivationParameters, + HSwishActivationParameters, LeakyActivationParameters, + NNEdge, PoolingParameters, ReluActivationParameters, + SigmoidActivationParameters) +from graph.types.activations import (HTanHActivationParameters, + TanHActivationParameters) +from graph.types.base import NNNodeRef +from graph.types.fusions import FusionInputParameters, FusionOutputParameters +from utils.graph import GraphView + +from ..matcher import (Matcher, description, groups, match_name, run_qtune_on_match) + +LOG = logging.getLogger("nntool." + __name__) + +VALID_ACTIVATIONS_SQ8 = ( + ReluActivationParameters, + LeakyActivationParameters, + HSigmoidActivationParameters, + HSwishActivationParameters, + SigmoidActivationParameters, + TanHActivationParameters, + HTanHActivationParameters +) + +VALID_FUSIONS_SQ8 = ( + 'conv_active', + 'conv_max_active', + 'conv_average_active', + 'conv_active_max', + 'conv_max', + 'conv_average', +) + +VALID_ACTIVATIONS_POW2 = ( + ReluActivationParameters, + LeakyActivationParameters, + HSigmoidActivationParameters, + HSwishActivationParameters, + SigmoidActivationParameters +) + +VALID_FUSIONS_POW2 = ( + 'conv_active', + 'conv_max_active', + 'conv_average_active', + 'conv_active_max', + 'conv_max', + 'conv_average', +) + + +class MergeStopError(Exception): + pass + + +class MergeAbortError(Exception): + pass +class NewFusionMatch(): + def __init__(self, valid_activations, valid_fusions) -> None: + self.fusion = None + self.conv = None + self.pool = None + self.active = None + self.valid_activations = valid_activations + self.valid_fusions = valid_fusions + self.order = [] + self.nodes_in_fusion = 0 + + @classmethod + def from_node(cls, G, node, valid_activations, valid_fusions) -> 'NewFusionMatch': + matcher = cls(valid_activations, valid_fusions) + try: + matcher.add_node(node) + while node: + edges = G.out_edges(node) + if len(edges) > 1: + break + node = edges[0].to_node + matcher.add_node(node) + except MergeStopError: + pass + except MergeAbortError: + return None + return matcher + + @staticmethod + def calc_fusion_type(contents, pool_type=False): + return '_'.join(['conv' if isinstance(params, Conv2DParameters) + else 'active' if isinstance(params, ActivationParameters) + else params.pool_type if pool_type else 'pool' for params in contents]) + + def can_add(self, node): + fusion_type = self.calc_fusion_type( + self.order + [node], pool_type=True) + return any(valid_fusion.startswith(fusion_type) for valid_fusion in self.valid_fusions) + + def add_node(self, params, in_fusion=False): + if in_fusion: + self.nodes_in_fusion += 1 + if isinstance(params, ConvFusionParameters): + if self.fusion: + raise MergeStopError() # @IgnoreException + self.fusion = params + try: + for cnode in params.contained_nodes(): + self.add_node(cnode, in_fusion=True) + except MergeStopError: + raise MergeAbortError() # @IgnoreException + elif isinstance(params, Conv2DParameters): + if self.conv or not self.can_add(params): + raise MergeStopError() # @IgnoreException + self.order.append(params) + self.conv = params + elif isinstance(params, self.valid_activations): + if self.active or not self.can_add(params): + raise MergeStopError() # @IgnoreException + self.order.append(params) + self.active = params + elif isinstance(params, PoolingParameters): + if self.pool or not self.can_add(params): + raise MergeStopError() # @IgnoreException + self.order.append(params) + self.pool = params + else: + raise MergeStopError() # @IgnoreException + + @property + def can_fuse(self): + return (self.calc_fusion_type(self.order, pool_type=True) in self.valid_fusions + and len(self.order) > self.nodes_in_fusion) + + def fuse(self, G: GraphView): + fusion_outputs = G.out_edges(self.order[-1]) + if self.fusion is None: + fuse_node_name = G.unique_name(self.conv.name + '_fusion') + subg = GraphView() + inputs = [NNNodeRef(subg, FusionInputParameters(f'{fuse_node_name}_in_{idx}', + idx=idx, dims=self.conv.in_dims[0].shape), 0) for idx in range(3)] + in_edges = G.indexed_in_edges(self.conv) + else: + fuse_node_name = self.fusion.name + subg = self.fusion.subgraph + subg_output = subg.outputs() + assert len(subg_output) == 1 + inputs = [NNNodeRef(subg, subg.in_edges(subg_output[0])[0].from_node, 0)] + subg.remove_all(subg_output) + in_edges = None + nodes_to_fuse = self.order[self.nodes_in_fusion:] + LOG.info(f'fusing nodes {",".join(node.name for node in nodes_to_fuse)}' + f' into {fuse_node_name}') + node = None + while nodes_to_fuse: + node = nodes_to_fuse.pop(0) + G.remove(node) + inputs = [node(*inputs)] + FusionOutputParameters( + f'{fuse_node_name}_out_0', + dims=node.out_dims[0].shape)(*inputs) + if not self.fusion: + fusion = ConvFusionParameters( + fuse_node_name, + fusion_type=self.fusion_type, + subgraph=subg, + in_dims_hint=self.conv.in_dims_hint, + out_dims_hint=self.conv.out_dims_hint, + in_dims=deepcopy(self.conv.in_dims), + out_dims=deepcopy(self.order[-1].out_dims), + inout_set=True) + for edge in in_edges: + G.add_edge(edge.clone(to_node=fusion)) + else: # in the fusion case the outputs will already be removed since the node after was removed + fusion = self.fusion + for edge in fusion_outputs: + G.add_edge(edge.clone(from_node=fusion)) + if G.quantization: + for node in self.order[self.nodes_in_fusion:]: + G.quantization.move_to_fusion(node, fusion) + + + @property + def fusion_type(self): + return self.calc_fusion_type(self.order) + + +@groups('*') +@match_name("fuse_gap_convs") +@run_qtune_on_match +@description( + 'Fuse convolutions, pools and activations to match GAP AutoTiler operations. Pooling and activation nodes' + ' are also fused into existing convolution fusions.') +class MatchAllGapConv(Matcher): + def _match(self, G: GraphView, set_identity: bool = True, **kwargs): + has_modified_graph = False + group_identity = kwargs.get('group_identity') + if group_identity == 'pow2_match_group': + valid_activations = VALID_ACTIVATIONS_POW2 + valid_fusions = VALID_FUSIONS_POW2 + else: + valid_activations = VALID_ACTIVATIONS_SQ8 + valid_fusions = VALID_FUSIONS_SQ8 + + for conv_node in G.nodes(node_classes=(Conv2DParameters, ConvFusionParameters)): + matcher = NewFusionMatch.from_node(G, conv_node, valid_activations, valid_fusions) + if not matcher or not matcher.can_fuse: + continue + has_modified_graph = True + matcher.fuse(G) + + if set_identity: + self.set_identity(G) + + return has_modified_graph diff --git a/tools/nntool/graph/matches/matchers/match_gap_linear.py b/tools/nntool/graph/matches/matchers/fuse_gap_linear.py similarity index 89% rename from tools/nntool/graph/matches/matchers/match_gap_linear.py rename to tools/nntool/graph/matches/matchers/fuse_gap_linear.py index 634bcb62b..4ba1624e6 100644 --- a/tools/nntool/graph/matches/matchers/match_gap_linear.py +++ b/tools/nntool/graph/matches/matchers/fuse_gap_linear.py @@ -19,11 +19,11 @@ HSwishActivationParameters, LeakyActivationParameters, LinearFusionParameters, NNEdge, ReluActivationParameters, SigmoidActivationParameters) -from quantization.new_qrec import QRec +from graph.types.activations import TanHActivationParameters from utils.graph import GraphView -from utils.node_id import NodeId -from ..matcher import Matcher, description, groups, match_name +from ..matcher import (Matcher, description, groups, match_name, + run_adjust_on_match, run_qtune_on_match) LOG = logging.getLogger("nntool." + __name__) @@ -32,7 +32,8 @@ LeakyActivationParameters, HSigmoidActivationParameters, HSwishActivationParameters, - SigmoidActivationParameters + SigmoidActivationParameters, + TanHActivationParameters, ) VALID_ACTIVATIONS_POW2 = ( @@ -80,6 +81,8 @@ def move_stats_to_fusion(fusion, stats): @groups('*') +@run_qtune_on_match +@run_adjust_on_match @match_name("fuse_gap_linear") @description('Fuse linear layers and activations to match GAP AutoTiler operations') class MatchGapLinear(Matcher): @@ -124,14 +127,8 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs): input_mapping=input_mapping, output_mapping=output_mapping) if G.quantization: - # TODO - stats - qrecs = G.quantization.get_all(pnode.contained_nodes()) - if qrecs: - prec = QRec.copy_ktype( - qrecs[0], in_qs=qrecs[0].in_qs, out_qs=qrecs[-1].out_qs) - for node in pnode.contained_nodes(): - G.quantization.move_to_fusion(node, pnode) - G.quantization[NodeId(pnode)] = prec + for node in pnode.contained_nodes(): + G.quantization.move_to_fusion(node, pnode) in_edges = G.in_edges(node_list.linear.name) out_edges = G.out_edges(last_node.name) for node in node_list.order: diff --git a/tools/nntool/graph/matches/matchers/match_gap_pool.py b/tools/nntool/graph/matches/matchers/fuse_gap_pool.py similarity index 84% rename from tools/nntool/graph/matches/matchers/match_gap_pool.py rename to tools/nntool/graph/matches/matchers/fuse_gap_pool.py index 8b0314d5a..db7aa2997 100644 --- a/tools/nntool/graph/matches/matchers/match_gap_pool.py +++ b/tools/nntool/graph/matches/matchers/fuse_gap_pool.py @@ -14,20 +14,17 @@ # along with this program. If not, see . import logging -from copy import deepcopy -import numpy as np from graph.types import (HSigmoidActivationParameters, HSwishActivationParameters, LeakyActivationParameters, NNEdge, PoolingParameters, ReluActivationParameters, SigmoidActivationParameters) from graph.types.fusions import ActivationFusion from graph.types.global_pooling import GlobalPoolingParameters -from quantization.new_qrec import QRec from utils.graph import GraphView -from utils.node_id import NodeId -from ..matcher import Matcher, description, groups, match_name, run_after +from ..matcher import (Matcher, description, groups, match_name, + run_adjust_on_match, run_after, run_qtune_on_match) LOG = logging.getLogger("nntool." + __name__) @@ -86,7 +83,10 @@ def fusion_type(self): @groups('*') + @match_name("fuse_gap_pool") +@run_qtune_on_match +@run_adjust_on_match @description('Fuse pooling layers and activations to match GAP AutoTiler operations') @run_after('fuse_gap_convs') class MatchGapPool(Matcher): @@ -135,19 +135,8 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs): output_mapping=output_mapping) if G.quantization: # TODO - stats - qrecs = G.quantization.get_all(pnode.contained_nodes()) - if qrecs: - prec = QRec.copy_ktype( - qrecs[0], in_qs=qrecs[0].in_qs, out_qs=qrecs[-1].out_qs) - for node in pnode.contained_nodes(): - G.quantization.move_to_fusion(node, pnode) - if isinstance(node, GlobalPoolingParameters): - # Global pooling fused with activations need to have only the activation scale - G.quantization[NodeId(pnode, node)].out_qs[0] = deepcopy( - G.quantization[NodeId(pnode, node)].in_qs[0]) - G.quantization[NodeId( - pnode, node)].out_qs[0].dtype = np.int32 - G.quantization[NodeId(pnode)] = prec + for node in pnode.contained_nodes(): + G.quantization.move_to_fusion(node, pnode) in_edges = G.in_edges(node_list.pool.name) out_edges = G.out_edges(last_node.name) for node in node_list.order: diff --git a/tools/nntool/graph/matches/matchers/matscale.py b/tools/nntool/graph/matches/matchers/fuse_matscale.py similarity index 100% rename from tools/nntool/graph/matches/matchers/matscale.py rename to tools/nntool/graph/matches/matchers/fuse_matscale.py diff --git a/tools/nntool/graph/matches/matchers/match_op_activation.py b/tools/nntool/graph/matches/matchers/fuse_op_activation.py similarity index 92% rename from tools/nntool/graph/matches/matchers/match_op_activation.py rename to tools/nntool/graph/matches/matchers/fuse_op_activation.py index 406dbde5c..11dd896f3 100644 --- a/tools/nntool/graph/matches/matchers/match_op_activation.py +++ b/tools/nntool/graph/matches/matchers/fuse_op_activation.py @@ -13,7 +13,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from graph.types.tensor_arithmetic import MatMulTransposedParameters import logging from abc import abstractproperty @@ -22,14 +21,13 @@ GlobalPoolingParameters, HSigmoidActivationParameters, HSwishActivationParameters, LeakyActivationParameters, MatMulOpFusionParameters, MatMulOpParameters, - MatrixAddParameters, NNEdge, - PoolingParameters, ReluActivationParameters, - SigmoidActivationParameters) -from quantization.new_qrec import QRec + MatrixAddParameters, NNEdge, PoolingParameters, + ReluActivationParameters, SigmoidActivationParameters) +from graph.types.tensor_arithmetic import MatMulTransposedParameters from utils.graph import GraphView from utils.node_id import NodeId -from ..matcher import Matcher, description, groups, match_name, run_after +from ..matcher import Matcher, description, groups, match_name, run_after, run_qtune_on_match, run_adjust_on_match LOG = logging.getLogger("nntool." + __name__) @@ -134,6 +132,8 @@ def fusion_type(self): @run_after('fuse_gap_pool', 'fuse_external_bias_matmul') +@run_qtune_on_match +@run_adjust_on_match class MatchOpActivation(Matcher): @abstractproperty @@ -179,13 +179,8 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs): output_mapping=output_mapping) if G.quantization: # TODO - stats - qrecs = G.quantization.get_all(pnode.contained_nodes()) - if qrecs: - prec = QRec.copy_ktype( - qrecs[0], in_qs=qrecs[0].in_qs, out_qs=qrecs[-1].out_qs) - for fnode in pnode.contained_nodes(): - G.quantization.move_to_fusion(fnode, pnode) - G.quantization[NodeId(pnode)] = prec + for fnode in pnode.contained_nodes(): + G.quantization.move_to_fusion(fnode, pnode) in_edges = G.in_edges(node_list.node.name) out_edges = G.out_edges(last_node.name) for snode in node_list.order: diff --git a/tools/nntool/graph/matches/matchers/fuse_pad.py b/tools/nntool/graph/matches/matchers/fuse_pad.py index d5826ce5b..ed00d72eb 100644 --- a/tools/nntool/graph/matches/matchers/fuse_pad.py +++ b/tools/nntool/graph/matches/matchers/fuse_pad.py @@ -53,7 +53,7 @@ def expand_padding(from_shape, to_shape, padding): @match_name('fuse_pad') @description('Fuse pad operation to subsequent Convolution or Pool') @groups('*') -@run_before('match_gap_conv', 'match_gap_pool') +@run_before('fuse_gap_convs', 'fuse_gap_pool') class MatchFusePad(Matcher): @staticmethod def remove_padding(shape, padding): diff --git a/tools/nntool/graph/matches/matchers/match_channel_padded_add.py b/tools/nntool/graph/matches/matchers/fuse_padded_add.py similarity index 91% rename from tools/nntool/graph/matches/matchers/match_channel_padded_add.py rename to tools/nntool/graph/matches/matchers/fuse_padded_add.py index a650765a4..e4f8ba545 100644 --- a/tools/nntool/graph/matches/matchers/match_channel_padded_add.py +++ b/tools/nntool/graph/matches/matchers/fuse_padded_add.py @@ -22,7 +22,7 @@ from utils.graph import GraphView from utils.node_id import NodeId -from ..matcher import Matcher, match_name, description, groups +from ..matcher import Matcher, match_name, description, groups, run_before, run_qtune_on_match LOG = logging.getLogger("nntool." + __name__) @@ -64,6 +64,8 @@ def fusion_type(self): @match_name('fuse_padded_add') @description('Fuse convolutions, pools and activations to match GAP AutoTiler operations') +@run_before('fuse_op_activation_scale8') +@run_qtune_on_match @groups('scaled') class MatchPadAddAct(Matcher): @@ -109,14 +111,8 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs): input_mapping=input_mapping, output_mapping=output_mapping) if G.quantization: - qrecs = G.quantization.get_all(pnode.contained_nodes()) - # TODO - stats - if qrecs: - prec = QRec.copy_ktype( - qrecs[1], in_qs=qrecs[1].in_qs, out_qs=qrecs[-1].out_qs) - for node in pnode.contained_nodes(): - G.quantization.move_to_fusion(node, pnode) - G.quantization[NodeId(pnode)] = prec + for node in pnode.contained_nodes(): + G.quantization.move_to_fusion(node, pnode) if padded_input_idx == 0: in_edges = G.in_edges(node_list.pad.name) + \ G.indexed_in_edges(node_list.add.name)[1::] diff --git a/tools/nntool/graph/matches/matchers/gather_to_split.py b/tools/nntool/graph/matches/matchers/gather_to_split.py index 05aae2550..3acd9dc47 100644 --- a/tools/nntool/graph/matches/matchers/gather_to_split.py +++ b/tools/nntool/graph/matches/matchers/gather_to_split.py @@ -37,6 +37,8 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs) -> bool: group = gathers_by_origin.setdefault((in_edge.from_node, in_edge.from_idx), []) group.append(gather) for in_edge, gathers in gathers_by_origin.items(): + if len(gathers[0].indices.shape) > 1: + continue # This is too difficult to handle if there are multiple slices axis = gathers[0].axis if not all(gather.axis == axis and len(gather.indices.shape) <= 1 diff --git a/tools/nntool/graph/matches/matchers/insert_copies.py b/tools/nntool/graph/matches/matchers/insert_copies.py index 31946b945..dce28ef08 100644 --- a/tools/nntool/graph/matches/matchers/insert_copies.py +++ b/tools/nntool/graph/matches/matchers/insert_copies.py @@ -1,4 +1,4 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS +# Copyright (C) 2020, 2022 GreenWaves Technologies, SAS # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -16,9 +16,10 @@ import logging from copy import deepcopy -from graph.types import (ConcatParameters, CopyParameters, NNEdge, - NoOPParameters, OutputParameters, ReshapeParameters, - SplitParameters, TransposeParameters) +from graph.types import (ConcatParameters, CopyParameters, InputParameters, RNNBaseParameters, + NNEdge, NoOPParameters, OutputParameters, ConstantInputParameters, + ReshapeParameters, SplitParameters, + TransposeParameters) from quantization.new_qrec import QRec from utils.graph import GraphView from utils.node_id import NodeId @@ -28,145 +29,180 @@ LOG = logging.getLogger("nntool." + __name__) -def find_real_in_edge(G, edge): - from_node = edge.from_node - if isinstance(from_node, ReshapeParameters): - res = find_real_in_edge(G, G.in_edges(from_node.name)[0]) - return res - if isinstance(from_node, NoOPParameters): - res = find_real_in_edge(G, G.in_edges(from_node.name)[0]) - return res - if isinstance(from_node, TransposeParameters): - _, real_transpose = from_node.real_shape() - if len(real_transpose) <= 1: - res = find_real_in_edge(G, G.in_edges(from_node.name)[0]) - return res - return (edge.from_node, edge.from_idx) + +class VisitEdge(): + def __init__(self, edge, direction) -> None: + self.edge = edge + self.direction = direction + + def __eq__(self, other: object) -> bool: + return isinstance(other, VisitEdge) and self.edge == other.edge + + def __hash__(self) -> int: + return self.edge.__hash__() + @match_name('insert_copies') -@description('insert copy nodes on edges that link splits to concats') -@run_after('insert_transposes') +@description('insert copy nodes on edges that link stacked tensors between themselves or to inputs or outputs') @groups('*') @needs_valid_dimension(True) class MatchInsertCopies(Matcher): - def find_concat_edge(self, G, edge): - to_node = edge.to_node - if isinstance(to_node, (ConcatParameters, SplitParameters)): - return [edge] - if isinstance(to_node, ReshapeParameters): - res = self.find_concat_edge(G, G.out_edges(to_node.name)[0]) - return [edge] + res if res else res - if isinstance(to_node, NoOPParameters): - res = self.find_concat_edge(G, G.out_edges(to_node.name)[0]) - return [edge] + res if res else res - if isinstance(to_node, TransposeParameters): - _, real_transpose = to_node.real_shape() - if len(real_transpose) <= 1: - res = self.find_concat_edge(G, G.out_edges(to_node.name)[0]) - return [edge] + res if res else res - - return [] - - def find_split_to_output_edge(self, G, edge): - to_node = edge.to_node - if isinstance(to_node, OutputParameters): - return [edge] - if isinstance(to_node, ReshapeParameters): - res = self.find_split_to_output_edge( - G, G.out_edges(to_node.name)[0]) - return [edge] + res if res else res - if isinstance(to_node, NoOPParameters): - res = self.find_split_to_output_edge( - G, G.out_edges(to_node.name)[0]) - return [edge] + res if res else res - if isinstance(to_node, TransposeParameters): - _, real_transpose = to_node.real_shape() - if len(real_transpose) <= 1: - res = self.find_split_to_output_edge( - G, G.out_edges(to_node.name)[0]) - return [edge] + res if res else res - - return [] - - def find_split_concat(self, G, split_node, find_output=True): - out_edges = G.indexed_out_edges(split_node.name) - res = [[] for _ in range(len(out_edges))] - found_some = False - for edge_group in out_edges: - for edge in edge_group: - concat_edges = self.find_concat_edge(G, edge) - if find_output: - concat_edges += self.find_split_to_output_edge(G, edge) - if concat_edges: - found_some = True - res[edge.from_idx].append(concat_edges) - return res if found_some else None - - def insert_copy_on_common_concat_in(self, G, concat_nodes): - # in every concat nodes collect all the in edges (from_node, from_idx) - # if there are repetition of tuples, insert a copy in every repetition - # different concats cannot have the same in edge (from_node, from_idx) - concat_in_edges = [] + @staticmethod + def can_pass_node(node): + # nodes that do not generate any kernel + return node.no_model_code + + def find_split_concat_down(self, G, edge): + # search for a split or concat on any downward edge + if isinstance(edge.to_node, (SplitParameters, ConcatParameters)): + return True + elif self.can_pass_node(edge.to_node): + for out_edge in G.out_edges(edge.to_node): + if self.find_split_concat_down(G, out_edge): + return True + return False + + def search_up_for_duplicate(self, G, edge): + # search up for multi out edges on the same edge idx + # if found then search down for a concat or split ignoring ungenerated nodes + # return the original out edge where the concat/split was found + out_edges = G.indexed_out_edges(edge.from_node)[edge.from_idx] + if len(out_edges) > 1: + out_edges.remove(edge) + for out_edge in out_edges: + if self.find_split_concat_down(G, out_edge): + return out_edge + elif self.can_pass_node(edge.from_node): + return self.search_up_for_duplicate(G, G.in_edges(edge.from_node)[0]) + return None + + @staticmethod + def insert_copy_at_edge(G, edge): + copy_node = CopyParameters( + G.unique_name(f'{edge.from_node.name}_copy')) + LOG.info(f'inserting copy between {edge.from_node.name}:{edge.from_idx} ' + f'and {edge.to_node.name}:{edge.to_idx}') + G.insert_node_at_edge(copy_node, edge, edge_class=NNEdge) + nid = NodeId(edge.from_node) + if G.quantization and nid in G.quantization: + qrec = G.quantization[nid] + qtype = deepcopy(qrec.out_qs[edge.from_idx]) + G.quantization[NodeId(copy_node)] = QRec.copy_ktype(qrec, in_qs=[qtype], out_qs=[qtype]) + + def find_common_in_edges(self, G: GraphView): + # Look for splits and concats that share a common in edge + # the split is a stacked tensor and the concat is an alias in a different stack + # a copy is always necessary + # RNNBaseParameters are also here since they create a UserKernelGroup where their + # input can already be in a stack so causes a tiler error + nodes = G.nodes(node_classes=(SplitParameters, + ConcatParameters, RNNBaseParameters)) has_modified_graph = False - for concat_node in concat_nodes: - for idx, in_edge in enumerate(G.indexed_in_edges(concat_node.name)): - real_in_edge = find_real_in_edge(G, in_edge) - if real_in_edge in concat_in_edges: - has_modified_graph = True - copy_node = CopyParameters("%s_copy_%s" % (concat_node.name, idx)) - G.remove_edge(in_edge) - LOG.info('common_concat: inserting copy between %s/%s and %s/%s', - in_edge.from_node.name, idx, concat_node.name, in_edge.to_idx) - G.add_edge(NNEdge(in_edge.from_node, copy_node, from_idx=in_edge.from_idx)) - G.add_edge(NNEdge(copy_node, concat_node, to_idx=in_edge.to_idx)) - if G.quantization: - qrec = G.quantization[NodeId(concat_node)] - G.quantization[NodeId(copy_node)] = QRec.copy_ktype(qrec, - in_qs=[deepcopy(qrec.in_qs[idx])], - out_qs=[deepcopy(qrec.in_qs[idx])]) - else: - concat_in_edges.append(real_in_edge) + while nodes: + node = nodes.pop(0) + for in_edge in G.indexed_in_edges(node): + if isinstance(node, RNNBaseParameters) and in_edge.to_idx > 0: + break + # find another edge that would be generated as the same edge + # with a concat/split on it. If found then insert a copy + # and search again on that node to find others + dup_edge = self.search_up_for_duplicate(G, in_edge) + if dup_edge is None: + continue + has_modified_graph = True + self.insert_copy_at_edge(G, dup_edge) + nodes.append(node) + break return has_modified_graph - def find_direct_connects(self, G, node, has_modified_graph, find_output=True): - # traverse reshapes or transposes that do nothing - check gen - # find edges connected to concats - res = self.find_split_concat(G, node, find_output=find_output) - if res is None: - return has_modified_graph - if G.quantization: - qrec = G.quantization[NodeId(node)] - for idx, bundle in enumerate(res): - if not bundle: - continue - has_modified_graph = True - copy_node = CopyParameters("%s_copy_%s" % (node.name, idx)) - for edge_set in bundle: - first_edge = edge_set[0] - G.remove_edge(first_edge) - LOG.info('inserting copy between %s/%s and %s/%s', - node.name, idx, first_edge.to_node.name, first_edge.to_idx) - G.add_edge(NNEdge(copy_node, first_edge.to_node, - to_idx=first_edge.to_idx)) - G.add_edge(NNEdge(node, copy_node, from_idx=idx)) - if G.quantization: - G.quantization[NodeId(copy_node)] = QRec.copy_ktype(qrec, - in_qs=[ - deepcopy(qrec.out_qs[idx])], - out_qs=[deepcopy(qrec.out_qs[idx])]) - return True + def search_up_for(self, G, edge, node_class): + if isinstance(edge.from_node, node_class): + return edge + elif self.can_pass_node(edge.from_node): + return self.search_up_for(G, G.in_edges(edge.from_node)[0], node_class) + return None + + def on_same_edge_as(self, G, node, node_class, visited=None, last_direction=None, start_edge=None): + if visited is None: + visited = set() + if start_edge: + to_visit = {VisitEdge(start_edge, 'up')} + else: + to_visit = set(VisitEdge(edge, 'up') for edge in G.in_edges(node)) + + while to_visit: + visited_edge = to_visit.pop() + visit_node = visited_edge.edge.from_node if visited_edge.direction == "up" else visited_edge.edge.to_node + visited.add(visited_edge) + # if node class is a tuple of class and direction then see if we are visiting that side of the class + # this copes with splits and concats that are converted to stacks in the model. + # A stack alias cannot be an output. The aliases will be the output side of a split and the input side + # of a concat + if isinstance(node_class[0], tuple): + if visited_edge.direction == "up": + if any(pair[1] == "down" and isinstance(visit_node, pair[0]) for pair in node_class): + return visited_edge.edge + else: + if any(pair[1] == "up" and isinstance(visit_node, pair[0]) for pair in node_class): + return visited_edge.edge + elif isinstance(visit_node, node_class): + return visited_edge.edge + if visited_edge.direction == "up": + if self.can_pass_node(visit_node): + # if arriving upwards on the node and can pass visit all its edges that we have not visited + to_visit |= (set(VisitEdge(edge, 'up') + for edge in G.in_edges(visit_node)) - visited) + to_visit |= (set(VisitEdge(edge, 'down') + for edge in G.out_edges(visit_node)) - visited) + else: + # can't pass but must still visit all the edges on the same out idx + to_visit |= (set(VisitEdge(edge, 'down') + for edge in G.indexed_out_edges(visit_node)[visited_edge.edge.from_idx]) - visited) + else: + # the other up edges case is not here since if it is a concat it would already have + # triggered the return + if self.can_pass_node(visit_node): + to_visit |= (set(VisitEdge(edge, 'down') + for edge in G.out_edges(visit_node)) - visited) + return None + + COPIES_BETWEEN_CLSES = [ + # any stack -> any stack (different memory - must always copy) + {'from': (SplitParameters, ConcatParameters), 'to': ( + ConcatParameters, SplitParameters)}, + # stacked memory -> stack in user kernel group + {'from': (SplitParameters, ConcatParameters), 'to': (RNNBaseParameters,)}, + # stacked alias -> output (name is lost since it is an alias - could be fixed in AT) + {'from': ((SplitParameters, 'down'), (ConcatParameters, 'up')), 'to': (OutputParameters,)}, + # # stacked tensor -> alias (different memory - must always copy) + # input -> stacked tensor (can be fixed in AT) + # input -> stacked alias (name is lost since it is an alias - could be fixed in AT) + {'from': (InputParameters,), 'to': ( + ConcatParameters, SplitParameters)}, + # constant -> stacked alias (I guess the constant could be loaded here in some cases by AT) + # constant -> stack (not sure if this works or not. Including for safety. If it doesn't work it could.) + {'from': (ConstantInputParameters,), 'to': ( + ConcatParameters, SplitParameters)}, + ] + + def insert_copies_between(self, G, from_clses, to_clses): + # insert copys between splits and outputs or concats + nodes = G.nodes(node_classes=to_clses) + has_modified_graph = False + while nodes: + node = nodes.pop(0) + for edge in G.indexed_in_edges(node): + found_edge = self.on_same_edge_as(G, node, from_clses, start_edge=edge) + if found_edge: + has_modified_graph = True + self.insert_copy_at_edge(G, found_edge) + return has_modified_graph def _match(self, G: GraphView, set_identity: bool = True, **kwargs): - split_nodes = [node for node in G.nodes(node_classes=SplitParameters)] has_modified_graph = False - for node in split_nodes: - has_modified_graph = self.find_direct_connects( - G, node, has_modified_graph) - concat_nodes = [node for node in G.nodes( - node_classes=ConcatParameters)] - for node in concat_nodes: - has_modified_graph = self.find_direct_connects( - G, node, has_modified_graph, find_output=False) - has_modified_graph |= self.insert_copy_on_common_concat_in(G, concat_nodes) + for clses in self.COPIES_BETWEEN_CLSES: + has_modified_graph |= self.insert_copies_between( + G, clses['from'], clses['to']) + has_modified_graph |= self.find_common_in_edges(G) return has_modified_graph diff --git a/tools/nntool/graph/matches/matchers/match_gap_conv.py b/tools/nntool/graph/matches/matchers/match_gap_conv.py deleted file mode 100644 index cbb5ca865..000000000 --- a/tools/nntool/graph/matches/matchers/match_gap_conv.py +++ /dev/null @@ -1,171 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -from graph.types.activations import TanHActivationParameters -import logging -from copy import deepcopy - -from graph.types import (ActivationParameters, Conv2DParameters, - ConvFusionParameters, HSigmoidActivationParameters, - HSwishActivationParameters, LeakyActivationParameters, - NNEdge, PoolingParameters, ReluActivationParameters, - SigmoidActivationParameters) -from quantization.new_qrec import QRec -from utils.graph import GraphView -from utils.node_id import NodeId - -from ..matcher import Matcher, description, groups, match_name - -LOG = logging.getLogger("nntool." + __name__) - -VALID_ACTIVATIONS_SQ8 = ( - ReluActivationParameters, - LeakyActivationParameters, - HSigmoidActivationParameters, - HSwishActivationParameters, - SigmoidActivationParameters, - TanHActivationParameters -) - -VALID_ACTIVATIONS_POW2 = ( - ReluActivationParameters, - LeakyActivationParameters, - HSigmoidActivationParameters, - HSwishActivationParameters, - SigmoidActivationParameters -) - - -class FusionMatch(): - def __init__(self, valid_activations) -> None: - self.conv = None - self.pool = None - self.active = None - self.tensor_order = None - self.valid_activations = valid_activations - self.order = [] - - def add_node(self, params): - if isinstance(params, Conv2DParameters): - if self.conv: - return None - self.tensor_order = params.ker_out_order[0] - self.order.append(params) - self.conv = params - return self - elif isinstance(params, self.valid_activations): - if self.active: - return None - self.order.append(params) - self.active = params - return self - elif isinstance(params, PoolingParameters): - if self.pool: - return None - if self.tensor_order != params.ker_in_order[0]: - return None - self.order.append(params) - self.pool = params - return self - else: - return None - - @property - def fusion_type(self): - return '_'.join(['conv' if isinstance(params, Conv2DParameters) - else 'active' if isinstance(params, ActivationParameters) - else 'pool' for params in self.order]) - - -@groups('*') -@match_name("fuse_gap_convs") -@description('Fuse convolutions, pools and activations to match GAP AutoTiler operations') -class MatchAllGapConv(Matcher): - - def get_node_list(self, G, params, valid_activations, result=None): - if result is None: - result = FusionMatch(valid_activations) - if not result.add_node(params): - return result - out_edges = G.out_edges(params.name) - if len(out_edges) > 1: - return result - return self.get_node_list(G, out_edges[0].to_node, valid_activations, result=result) - - def _match(self, G: GraphView, set_identity: bool = True, **kwargs): - has_modified_graph = False - group_identity = kwargs.get('group_identity') - if group_identity == 'pow2_match_group': - valid_activations = VALID_ACTIVATIONS_POW2 - else: - valid_activations = VALID_ACTIVATIONS_SQ8 - for conv_node in [params for params in G.nodes() if isinstance(params, Conv2DParameters)]: - node_list = self.get_node_list(G, conv_node, valid_activations) - if node_list is None or len(node_list.order) < 2: - continue - if node_list.fusion_type == 'conv_active_pool': - if node_list.pool.pool_type == "average": - node_list.order = node_list.order[:2:] - node_list.pool = None - elif node_list.fusion_type == 'conv_pool_active': - # NOTE: This is only for old POW2 kernels - SQ8 can handle this - if node_list.pool.pool_type == "average" and node_list.active.activation != "relu": - continue - LOG.info("fusing nodes %s", ",".join( - (node.name for node in node_list.order))) - has_modified_graph = True - subgraph = GraphView() - last_node = None - for node in node_list.order: - if last_node is not None: - subgraph.add_edge( - NNEdge(from_node=last_node, to_node=node)) - last_node = node - input_mapping = [[(node_list.conv, idx)] for idx in range(3)] - output_mapping = [(last_node, 0)] - pnode = ConvFusionParameters( - node_list.conv.name + '_fusion', - fusion_type=node_list.fusion_type, - subgraph=subgraph, - in_dims_hint=node_list.conv.in_dims_hint, - out_dims_hint=node_list.conv.out_dims_hint, - in_dims=deepcopy(node_list.conv.in_dims), - out_dims=deepcopy(node_list.order[-1].out_dims), - input_mapping=input_mapping, - output_mapping=output_mapping) - if G.quantization: - qrecs = G.quantization.get_all(pnode.contained_nodes()) - if qrecs: - # TODO - stats - prec = QRec.copy_ktype( - qrecs[0], in_qs=deepcopy(qrecs[0].in_qs), out_qs=deepcopy(qrecs[-1].out_qs)) - for node in pnode.contained_nodes(): - G.quantization.move_to_fusion(node, pnode) - G.quantization[NodeId(pnode)] = prec - in_edges = G.in_edges(node_list.conv.name) - out_edges = G.out_edges(last_node.name) - for node in node_list.order: - G.remove(node) - for edge in in_edges: - G.add_edge(NNEdge(edge.from_node, pnode, - from_idx=edge.from_idx, to_idx=edge.to_idx)) - for edge in out_edges: - G.add_edge(NNEdge(pnode, edge.to_node, - from_idx=edge.from_idx, to_idx=edge.to_idx)) - - if set_identity: - self.set_identity(G) - - return has_modified_graph diff --git a/tools/nntool/graph/matches/matchers/find_hsigmoid.py b/tools/nntool/graph/matches/matchers/match_hsigmoid.py similarity index 100% rename from tools/nntool/graph/matches/matchers/find_hsigmoid.py rename to tools/nntool/graph/matches/matchers/match_hsigmoid.py diff --git a/tools/nntool/graph/matches/matchers/match_matmul_add_bias.py b/tools/nntool/graph/matches/matchers/match_matmul_add_bias.py deleted file mode 100644 index 16e4b6b2c..000000000 --- a/tools/nntool/graph/matches/matchers/match_matmul_add_bias.py +++ /dev/null @@ -1,140 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -# import logging - -# from graph.types import (ActivationParameters, ConstantInputParameters, -# MatMulOpFusionParameters, MatMulOpParameters, -# MatrixAddParameters, NNEdge) -# from quantization.new_qrec import QRec -# from utils.graph import GraphView -# from utils.node_id import NodeId - -# from ..matcher import Matcher, groups, match_name, description - -# LOG = logging.getLogger("nntool." + __name__) - - -# class FusionMatch(): -# def __init__(self) -> None: -# self.matmul = None -# self.add = None -# self.active = None -# self.order = [] - -# def add_node(self, params, G): -# if isinstance(params, MatMulOpParameters): -# if self.matmul: -# return None -# self.order.append(params) -# self.matmul = params -# return self -# elif isinstance(params, ActivationParameters): -# if self.active: -# return None -# self.order.append(params) -# self.active = params -# return self -# elif isinstance(params, MatrixAddParameters): -# if self.add or self.active: -# return None -# can_fuse = False -# for in_edge in G.in_edges(params.name): -# can_fuse = can_fuse or isinstance( -# in_edge.from_node, ConstantInputParameters) -# if not can_fuse: -# return None -# self.order.append(params) -# self.add = params -# return self -# else: -# return None - -# @property -# def fusion_type(self): -# return '_'.join(['matmul' if isinstance(params, MatMulOpParameters) -# else 'with_bias' if isinstance(params, MatrixAddParameters) -# else 'active' for params in self.order]) - -# @groups('*') -# @match_name("fuse_gap_matmul") -# @description('Fuse matmul layers with optional add and/or activations to match GAP AutoTiler operations') -# class MatchMatMulAddBias(Matcher): - -# def get_node_list(self, G, params, result=None): -# if result is None: -# result = FusionMatch() -# if not result.add_node(params, G): -# return result -# out_edges = G.out_edges(params.name) -# if len(out_edges) > 1: -# return result -# return self.get_node_list(G, out_edges[0].to_node, result=result) - -# def _match(self, G: GraphView, set_identity: bool = True, **kwargs): -# has_modified_graph = False -# for matmul_node in [params for params in G.nodes() if isinstance(params, MatMulOpParameters)]: -# node_list = self.get_node_list(G, matmul_node) -# if node_list is None or len(node_list.order) < 2: -# continue -# LOG.info("fusing nodes %s", ",".join( -# (node.name for node in node_list.order))) -# has_modified_graph = True -# subgraph = GraphView() -# if node_list.active is not None: -# subgraph.add_edge( -# NNEdge(from_node=node_list.matmul, to_node=node_list.active)) -# input_mapping = [[(node_list.matmul, idx)] for idx in range(2)] -# if node_list.add: -# input_mapping += [[(node_list.matmul, 2)]] -# output_mapping = [(node_list.active, 0)] if node_list.active else [ -# (node_list.matmul, 0)] -# pnode = MatMulOpFusionParameters( -# node_list.matmul.name + '_fusion', -# fusion_type=node_list.fusion_type, -# subgraph=subgraph, -# input_mapping=input_mapping, -# output_mapping=output_mapping) -# if G.quantization: -# # if there are quantization stats then clear them. They need to be created again -# G.quantization.stats = None -# qrecs = G.quantization.get_all(pnode.contained_nodes()) -# if qrecs: -# prec = QRec.copy_ktype( -# qrecs[0], in_qs=qrecs[0].in_qs, out_qs=qrecs[-1].out_qs) -# for node in pnode.contained_nodes(): -# G.quantization.move_to_fusion(node, pnode) -# G.quantization[NodeId(pnode)] = prec -# in_edges = G.in_edges(node_list.matmul.name) -# if node_list.add: -# bias_edge = [add_edge for add_edge in G.in_edges(node_list.add.name) if isinstance( -# add_edge.from_node, ConstantInputParameters)][0] -# out_edges = G.out_edges(node_list.order[-1].name) -# for node in node_list.order: -# G.remove(node) -# for edge in in_edges: -# G.add_edge(NNEdge(edge.from_node, pnode, -# from_idx=edge.from_idx, to_idx=edge.to_idx)) -# if node_list.add: -# G.add_edge(NNEdge(bias_edge.from_node, pnode, -# from_idx=bias_edge.from_idx, to_idx=2)) -# for edge in out_edges: -# G.add_edge(NNEdge(pnode, edge.to_node, -# from_idx=edge.from_idx, to_idx=edge.to_idx)) - -# if set_identity: -# self.set_identity(G) - -# return has_modified_graph diff --git a/tools/nntool/graph/matches/matchers/match_transpose_matmul.py b/tools/nntool/graph/matches/matchers/match_transpose_matmul.py index b9ddb5c92..1b7cc5d53 100644 --- a/tools/nntool/graph/matches/matchers/match_transpose_matmul.py +++ b/tools/nntool/graph/matches/matchers/match_transpose_matmul.py @@ -13,30 +13,23 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from graph.types.tensor_arithmetic import MatMulTransposedParameters import logging -from abc import abstractproperty -from graph.types import (TransposeParameters, ActivationParameters, - BroadcastableActivationFusion, - GlobalPoolingParameters, HSigmoidActivationParameters, - HSwishActivationParameters, LeakyActivationParameters, - MatMulOpFusionParameters, MatMulOpParameters, - MatrixAddParameters, NNEdge, - PoolingParameters, ReluActivationParameters, - SigmoidActivationParameters) -from quantization.new_qrec import QRec +from graph.manipulations.eliminate_transposes.transpose_helpers import \ + identity_transpose +from graph.types import MatMulOpParameters, NNEdge, TransposeParameters +from graph.types.tensor_arithmetic import MatMulTransposedParameters from utils.graph import GraphView -from utils.node_id import NodeId -from ..matcher import Matcher, description, groups, match_name, run_after, run_before +from ..matcher import (Matcher, description, groups, match_name, run_after, + run_before) LOG = logging.getLogger("nntool." + __name__) @run_after('fuse_external_bias_matmul') @run_before('fuse_op_activation_scale8', 'fuse_op_activation_pow2') @groups('*') -@match_name("match_trans_matmul") +@match_name("match_transpose_matmul") @description("spots Transpose followed by matmul and generates the proper matmul generator") class MatchTransMatMul(Matcher): @@ -56,6 +49,11 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs): trans_node = in_edges[1].from_node if not isinstance(trans_node, TransposeParameters): continue + transpose = tuple(trans_node.transpose) + if not identity_transpose(transpose[:-2]): + continue + if transpose[-2:] != (len(transpose) - 1, len(transpose) - 2): + continue if isinstance(node, MatMulTransposedParameters): new_node = MatMulOpParameters(node.name) else: diff --git a/tools/nntool/graph/matches/matchers/move_node_up.py b/tools/nntool/graph/matches/matchers/move_node_up.py index 76b1545ec..36c815b66 100644 --- a/tools/nntool/graph/matches/matchers/move_node_up.py +++ b/tools/nntool/graph/matches/matchers/move_node_up.py @@ -19,12 +19,12 @@ MatrixAddParameters, MatrixMulParameters, NNEdge, PoolingParameters, ReluActivationParameters, ReshapeParameters, TransposeParameters, MatMulTransposedParameters) -from graph.types.others import ReverseParameters, StridedSliceParameters +from graph.types.others import QuantizeParameters, ReverseParameters, StridedSliceParameters from graph.types.tensor_arithmetic import MatMulOpParameters from utils.graph import GraphView from utils.node_id import NodeId -from ..matcher import Matcher, match_name, groups, run_before, description, needs_valid_dimension +from ..matcher import Matcher, match_name, groups, run_before, description, needs_valid_dimension, run_qtune_on_match LOG = logging.getLogger("nntool." + __name__) @@ -40,35 +40,41 @@ class MoveNodeUpMatcher(Matcher): ValidNodes = None def execute_tests(self, G, tests, node): - if len(G.out_edges(node.name)) > 1: - return False return any(isinstance(node, test) if inspect.isclass(test) else test(node) for test in tests) - def find_home_for_node(self, - G, - node, - edge=None): - if edge is None: - in_edge = G.in_edges(node.name)[0] - yield from self.find_home_for_node(G, - node, - edge=in_edge) - elif self.execute_tests(G, self.ValidNodesToPass, edge.from_node): - if isinstance(edge.from_node, ConcatParameters): - for in_edge in G.in_edges(edge.from_node.name): + def find_home_for_node(self, G, node, first=True): + # search up for a place to move a node such as an activation to to allow it to fuse properly + if self.execute_tests(G, self.ValidNodes, node): + # should only see node to move at start + if not first: + raise LocationNotFoundError() # @IgnoreException + in_edge = G.in_edges(node)[0] + yield from self.find_home_for_node(G, in_edge.from_node, first=False) + elif self.execute_tests(G, self.ValidNodesToPass, node): + # intermediate nodes cannot have multiple outputs + if len(G.out_edges(node)) > 1: + raise LocationNotFoundError() # @IgnoreException + # Concat can have multiple inputs that must all acccept moved node + if isinstance(node, ConcatParameters): + # important to use indexed here so the order is always the same + for in_edge in G.indexed_in_edges(node): yield from self.find_home_for_node(G, - node, - edge=in_edge) + in_edge.from_node, + first=False) else: - in_edge = G.in_edges(edge.from_node.name)[0] + in_edge = G.in_edges(node.name)[0] yield from self.find_home_for_node(G, - node, - edge=in_edge) - elif self.execute_tests(G, self.ValidFusions, edge.from_node): - yield edge + in_edge.from_node, + first=False) + elif self.execute_tests(G, self.ValidFusions, node): + out_edges = G.out_edges(node) + # Node to move after can only have one output + if len(out_edges) > 1: + raise LocationNotFoundError() # @IgnoreException + # yeild the edge that node needs to move onto + yield out_edges[0] else: - - raise LocationNotFoundError() # @IgnoreException + raise LocationNotFoundError() # @IgnoreException @staticmethod def move_node(G, node, edges): @@ -88,7 +94,7 @@ def move_node(G, node, edges): node.name, edge.from_node.name, edge.to_node.name) if cnt > 0: new_node = deepcopy(node) - new_node.name = f'{original_node.name}_{cnt}' + new_node.name = G.unique_name(f'{original_node.name}_{cnt}') else: new_node = node cnt += 1 @@ -135,16 +141,18 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs): "Should be run before match_gap_ * fusions.") @needs_valid_dimension(True) @run_before('fuse_gap_convs', 'fuse_gap_linear', 'fuse_gap_pool', 'fuse_op_activation_scale8', 'fuse_op_activation_pow2') +@run_qtune_on_match class MoveActivationsMatcherScale8(MoveNodeUpMatcher): ValidNodesToPass = (ReshapeParameters, StridedSliceParameters, ReverseParameters, - TransposeParameters, ConcatParameters) + TransposeParameters, ConcatParameters, QuantizeParameters) ValidFusions = (Conv2DParameters, FcParameters, PoolingParameters, GlobalPoolingParameters, MatrixAddParameters, MatrixMulParameters, MatMulOpParameters, MatMulTransposedParameters) ValidNodes = (ActivationParameters,) + @groups('scaled') @match_name("move_pooling_scale8") @description("Tries to move pooling layers so they are after layers that they can be fused with." @@ -153,9 +161,7 @@ class MoveActivationsMatcherScale8(MoveNodeUpMatcher): @run_before('fuse_gap_convs', 'fuse_gap_linear', 'fuse_gap_pool', 'fuse_op_activation_scale8') class MoveMaxPoolMatcherScale8(MoveNodeUpMatcher): - - ValidNodesToPass = (ReshapeParameters, TransposeParameters, - ReluActivationParameters, ConcatParameters) + ValidNodesToPass = (ReluActivationParameters, ConcatParameters) ValidFusions = (Conv2DParameters, FcParameters) ValidNodes = (lambda node: isinstance( node, PoolingParameters) and node.pool_type == "max",) diff --git a/tools/nntool/graph/matches/matchers/move_nodes_before_split.py b/tools/nntool/graph/matches/matchers/move_nodes_before_split.py index 8749112a5..213685af4 100644 --- a/tools/nntool/graph/matches/matchers/move_nodes_before_split.py +++ b/tools/nntool/graph/matches/matchers/move_nodes_before_split.py @@ -14,7 +14,7 @@ from graph.types import NNEdge from graph.types.base import ComparableParameters -from graph.types.others import SplitParameters +from graph.types.others import ReshapeParameters, SplitParameters, StridedSliceParameters, TransposeParameters from quantization.quantizer.new_quantizer import NewQuantizer from utils.graph import GraphView from utils.node_id import NodeId @@ -44,6 +44,9 @@ def moveable_same_operation_edges(G, node): return None if first_node.in_dims[0] != first_node.out_dims[0]: return None + # actually transpose can be moved and reshape and sss maybe but the split needs to be modified + if isinstance(first_node, (TransposeParameters, ReshapeParameters, StridedSliceParameters)): + return None for edge in out_edges[1::]: if not isinstance(edge.to_node, ComparableParameters): return None diff --git a/tools/nntool/graph/matches/matchers/propagate_rnn_sym_mult_qrec.py b/tools/nntool/graph/matches/matchers/propagate_rnn_sym_mult_qrec.py deleted file mode 100644 index 3303b64af..000000000 --- a/tools/nntool/graph/matches/matchers/propagate_rnn_sym_mult_qrec.py +++ /dev/null @@ -1,44 +0,0 @@ -# # This program is free software: you can redistribute it and/or modify -# # it under the terms of the GNU Affero General Public License as -# # published by the Free Software Foundation, either version 3 of the -# # License, or (at your option) any later version. - -# # This program is distributed in the hope that it will be useful, -# # but WITHOUT ANY WARRANTY; without even the implied warranty of -# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# # GNU Affero General Public License for more details. - -# # You should have received a copy of the GNU Affero General Public License -# # along with this program. If not, see . - -# from graph.types import RNNBaseParameters -# from utils.graph import GraphView -# from utils.node_id import NodeId - -# from ..matcher import Matcher, groups, match_name, description -# from .equalize_sym_mult_concats import propagate_qtype_up - - -# @groups('scaled') -# @match_name("propagate_up_rnn_in_qs") -# @description("After quantization of rnn their in_q and out_q are the same " -# "so in_q may be changed and we need to propagate it up") -# class PropagateUpRNNInputQ(Matcher): - -# def _match(self, G: GraphView, set_identity: bool = True, **kwargs): -# if not G.quantization: -# return -# rnns = [node for node in G.nodes() if isinstance( -# node, RNNBaseParameters)] -# qrecs = [G.quantization[NodeId(node)] for node in rnns] -# for rnn, qrec in zip(rnns, qrecs): -# in_idx = rnn.INPUT_NAMES.index('input') -# in_edge = [edge for edge in G.in_edges( -# rnn.name) if edge.to_idx == in_idx][0] -# in_q = qrec.in_qs[in_idx] -# propagate_qtype_up(G, in_q, in_edge) - -# if set_identity: -# self.set_identity(G) - -# return False diff --git a/tools/nntool/graph/matches/matchers/reduce_max_to_pool.py b/tools/nntool/graph/matches/matchers/reduce_max_to_pool.py deleted file mode 100644 index 55b51139c..000000000 --- a/tools/nntool/graph/matches/matchers/reduce_max_to_pool.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -# from graph.types import ReduceMaxParameters, GlobalPoolingParameters -# from utils.graph import GraphView -# from .matcher import DefaultMatcher, MatchNode, DontReplaceError - -# class MatchReduceMax(DefaultMatcher): -# NAME = 'match_reduce_max_nodes' -# DESCRIPTION = 'Match reduce max nodes and replace them with GlobalMaxPooling' - -# def match_function(self, G: GraphView): -# sub = GraphView() -# sub.add_node(MatchNode('0', matcher=lambda node: -# isinstance(node, ReduceMaxParameters))) -# return G.match_fragment(sub) - -# def replace_function(self, G: GraphView, subgraph: GraphView): -# reduce_max_node = list(subgraph.nodes())[0] - -# for idx, in_dim in enumerate(reduce_max_node.in_dims[0].shape): -# if idx > 0 and idx not in reduce_max_node.axis and in_dim == 1: -# raise DontReplaceError() -# return GlobalPoolingParameters(reduce_max_node.name + "_GLOBAL_MAXPOOL", pool_type='max', -# in_dims_hint=reduce_max_node.in_dims_hint, -# out_dims_hint=reduce_max_node.out_dims_hint), None, None diff --git a/tools/nntool/graph/matches/matchers/remove_copies.py b/tools/nntool/graph/matches/matchers/remove_copies.py index 302b9321a..69dba7e5c 100644 --- a/tools/nntool/graph/matches/matchers/remove_copies.py +++ b/tools/nntool/graph/matches/matchers/remove_copies.py @@ -33,7 +33,7 @@ @description("Remove unnecessary copies") @modifies_dimensions(True) @groups('*') -@run_after('expand_transposes', 'remove_noops') +@run_after('remove_noops') class RemoveCopies(Matcher): def _match(self, G: GraphView, set_identity: bool = True, **kwargs): @@ -47,15 +47,13 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs): G, out_edges[0], (OutputParameters, InputParameters, ConstantInputParameters, SplitParameters, ConcatParameters), - can_pass=(ReshapeParameters, NoOPParameters), - can_pass_fn=lambda G, node: isinstance(node, TransposeParameters) and node.does_nothing, + can_pass_fn=lambda G, node: node.no_model_code, follow_multi=True) and search_up( G, G.in_edges(node)[0], (InputParameters, OutputParameters, ConstantInputParameters, SplitParameters, ConcatParameters), - can_pass=(ReshapeParameters, NoOPParameters), - can_pass_fn=lambda G, node: isinstance(node, TransposeParameters) and node.does_nothing, + can_pass_fn=lambda G, node: node.no_model_code, follow_multi=True)): continue nodes_to_remove.append(node) diff --git a/tools/nntool/graph/matches/matchers/remove_noops.py b/tools/nntool/graph/matches/matchers/remove_noops.py index d469cccf2..3f902fd85 100644 --- a/tools/nntool/graph/matches/matchers/remove_noops.py +++ b/tools/nntool/graph/matches/matchers/remove_noops.py @@ -15,9 +15,7 @@ import logging -from graph.types import NNEdge, NoOPParameters -from graph.types.others import (ConcatParameters, ReshapeParameters, - SplitParameters, TransposeParameters) +from graph.types import NNEdge from utils.graph import GraphView from ..matcher import Matcher, description, groups, match_name, run_before @@ -34,30 +32,9 @@ @groups('symmetric', 'scaled') class RemoveNoOPs(Matcher): - @staticmethod - def one_inedge(G, node, idx=None): - in_edges = G.in_edges(node) - return len(in_edges) == 1 and (idx is None or in_edges[0].to_idx == idx) - - @staticmethod - def one_outedge(G, node, idx=None): - out_edges = G.out_edges(node) - return len(out_edges) == 1 and (idx is None or out_edges[0].from_idx == idx) - - @staticmethod - def one_in_and_outedge(G, node, idx=None): - return RemoveNoOPs.one_inedge(G, node, idx=idx) and RemoveNoOPs.one_outedge(G, node, idx=idx) - - @staticmethod - def node_does_nothing(G, node): - return (isinstance(node, NoOPParameters) or - isinstance(node, TransposeParameters) and node.transpose is None or - isinstance(node, ReshapeParameters) and node.old_shape == node.shape or - (isinstance(node, (ConcatParameters, SplitParameters)) and RemoveNoOPs.one_in_and_outedge(G, node, idx=0))) - def _match(self, G: GraphView, set_identity: bool = True, **kwargs) -> bool: has_modified_graph = False - for node in [node for node in G.nodes() if self.node_does_nothing(G, node)]: + for node in [node for node in G.nodes() if node.does_nothing]: has_modified_graph = True in_edge = G.in_edges(node.name)[0] G.remove_edge(in_edge) diff --git a/tools/nntool/graph/matches/matchers/remove_reshapes.py b/tools/nntool/graph/matches/matchers/remove_reshapes.py index 573d056da..1d9defb7b 100644 --- a/tools/nntool/graph/matches/matchers/remove_reshapes.py +++ b/tools/nntool/graph/matches/matchers/remove_reshapes.py @@ -43,7 +43,7 @@ def validate_reshape(G, reshape): return False candidate = edge.to_node if isinstance(candidate, TransposeParameters): - if not candidate.does_nothing(): + if not candidate.no_model_code: return False out_shape = tuple(candidate.out_dims[0].shape) else: @@ -56,12 +56,13 @@ def validate_reshape(G, reshape): return (reshape, candidates, out_shape) def _match(self, G: GraphView, set_identity: bool = True, **kwargs): - modified_graph = True - while modified_graph: - modified_graph = False + modified_graph = False + found_reshapes = True + while found_reshapes: + found_reshapes = False for reshape in G.nodes(node_classes=(ReshapeParameters,)): if reshape.shape.shape == reshape.old_shape.shape: - modified_graph = True + found_reshapes = modified_graph = True LOG.info('removing reshape that does nothing %s', reshape.name) G.remove_and_reconnect(reshape, edge_class=NNEdge) nid = NodeId(reshape) @@ -72,7 +73,7 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs): res = self.validate_reshape(G, reshape) if res: LOG.info('unnecessary reshape found after %s', reshape.name) - modified_graph = True + found_reshapes = modified_graph = True (reshape, candidates, out_shape) = res for candidate in candidates: LOG.info( diff --git a/tools/nntool/graph/matches/matchers/remove_ssd_output.py b/tools/nntool/graph/matches/matchers/remove_ssd_output.py new file mode 100644 index 000000000..7e77b587e --- /dev/null +++ b/tools/nntool/graph/matches/matchers/remove_ssd_output.py @@ -0,0 +1,49 @@ +# Copyright (C) 2020, 2022 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging +from copy import deepcopy + +from graph.types import SSDDetectorParameters +from utils.graph import GraphView + +from ..matcher import (Matcher, description, groups, match_name, run_qtune_on_match, + needs_valid_dimension) + +LOG = logging.getLogger("nntool." + __name__) + + +@match_name('remove_ssd_output') +@description('remove the 4th output on the ssd detector - num detections. This is necessary for ' + 'operation with GAP kernels') +@groups('*') +@needs_valid_dimension(True) +@run_qtune_on_match +class RemoveSSDOutput(Matcher): + + def _match(self, G: GraphView, set_identity: bool = True, **kwargs): + has_modified_graph = False + for node in G.nodes(node_classes=SSDDetectorParameters): + if not node.output_detection_count: + continue + has_modified_graph = True + LOG.info(f'removing detection count output on {node.name}') + edges_below = G.indexed_out_edges(node)[3] + for edge in edges_below: + G.remove_below(edge.to_node) + G.remove(edge.to_node) + node.output_detection_count = False + + return has_modified_graph diff --git a/tools/nntool/graph/matches/matchers/match_reversed_rnn.py b/tools/nntool/graph/matches/matchers/rnn_reverse.py similarity index 100% rename from tools/nntool/graph/matches/matchers/match_reversed_rnn.py rename to tools/nntool/graph/matches/matchers/rnn_reverse.py diff --git a/tools/nntool/graph/matches/matchers/match_rnn_unpack.py b/tools/nntool/graph/matches/matchers/rnn_unpack.py similarity index 99% rename from tools/nntool/graph/matches/matchers/match_rnn_unpack.py rename to tools/nntool/graph/matches/matchers/rnn_unpack.py index cbbd746d6..bbf2d3316 100644 --- a/tools/nntool/graph/matches/matchers/match_rnn_unpack.py +++ b/tools/nntool/graph/matches/matchers/rnn_unpack.py @@ -291,7 +291,7 @@ def _match(self, G: GraphView, set_identity: bool = True, **kwargs): if changes_shape: reshape = ReshapeParameters(unpack_node.name + '_reshape', old_shape=Dim.unnamed( - unpack_node.post_slice_shape), + unpack_node.slice_shape), shape=Dim.unnamed(unpack_node.out_shape)) G.add_edge(NNEdge(from_node=in_edge.from_node, to_node=reshape, from_idx=in_edge.from_idx)) diff --git a/tools/nntool/graph/matches/matchers/slice_to_split.py b/tools/nntool/graph/matches/matchers/slice_to_split.py index 20f601e88..74a577db7 100644 --- a/tools/nntool/graph/matches/matchers/slice_to_split.py +++ b/tools/nntool/graph/matches/matchers/slice_to_split.py @@ -118,7 +118,7 @@ def slices_to_sizes(slices_and_shapes, shape_rest): @ match_name("slice_to_split") @ description("collects slices from a single node and converts to a single split") -@ run_before('unused_concats') +@ run_before('remove_noops', 'insert_copies') @ groups('*') class SliceToSplitMatch(Matcher): @ staticmethod @@ -140,9 +140,11 @@ def slice_to_split(G, slice_nodes, slices): axis_dim = in_dims[axis] outs = [] splits = [] + two_unused = axis_slice[0] > 0 and axis_slice[1] < axis_dim if axis_slice[0] > 0: + two_unused = True splits.append(axis_slice[0]) - oparams = OutputParameters(G.unique_name('unused')) + oparams = OutputParameters(G.unique_name(f'{slice_node.name}_unused{0 if two_unused else ""}')) oparams.at_options.allocate = 1 outs.append( ((oparams, 0),)) @@ -151,7 +153,7 @@ def slice_to_split(G, slice_nodes, slices): for edge in G.out_edges(slice_node.name)]) if axis_slice[1] < axis_dim: splits.append(axis_dim - axis_slice[1]) - oparams = OutputParameters(G.unique_name('unused')) + oparams = OutputParameters(G.unique_name(f'{slice_node.name}_unused{1 if two_unused else ""}')) oparams.at_options.allocate = 1 outs.append( ((oparams, 0),)) diff --git a/tools/nntool/graph/matches/matchers/split_concat.py b/tools/nntool/graph/matches/matchers/split_concat.py new file mode 100644 index 000000000..ef2615cda --- /dev/null +++ b/tools/nntool/graph/matches/matchers/split_concat.py @@ -0,0 +1,149 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging + +from graph.dim import Dim +from graph.types import ConcatParameters, NNEdge, SplitParameters +from graph.types.others import (CopyParameters, NoOPParameters, + ReshapeParameters, TransposeParameters) +from utils.graph import GraphView +from utils.node_id import NodeId + +from ..match_utils import search_down +from ..matcher import Matcher, description, groups, match_name, run_before + +LOG = logging.getLogger("nntool." + __name__) + + +def reduce_slices(slices, shapes): + res_slice = [] + res_shape = [] + for slice_axis, shape_axis in zip(zip(*slices), zip(*shapes)): + if slice_axis[0] == slice_axis[1]: + res_slice.append(slice_axis[0]) + res_shape.append(shape_axis[0]) + else: + res_slice.append( + (slice_axis[0][0], + slice_axis[-1][1], + slice_axis[0][2])) + res_shape.append(sum(shape_axis)) + return res_slice, res_shape + + +def remove_edges(G, edges): + if not edges: + return + edges = edges.copy() + while len(edges) > 1: + edge = edges.pop(0) + G.remove(edge.to_node) + if G.quantization: + nid = NodeId(edge.to_node) + if nid in G.quantization: + del G.quantization[nid] + try: + G.remove_edge(edges[0]) # @IgnoreException + except KeyError: + pass + + +@groups('*') +@match_name("split_concat") +@run_before('remove_noops', 'remove_copies') +@description("removes splits that go to concats where all the out edges of the split are in sequence in the concat") +class SplitConcatMatch(Matcher): + def _match(self, G: GraphView, set_identity: bool = True, **kwargs) -> bool: + edge_groups = [] + for node in G.nodes(node_classes=SplitParameters): + cur_group = None + for out_edge_bundle in G.indexed_out_edges(node): + if len(out_edge_bundle) == 1: + out_edge = out_edge_bundle[0] + concat_node_edges = search_down( + G, out_edge, ConcatParameters, + can_pass=(CopyParameters,), + can_pass_fn=lambda _, node: node.no_model_code) + if concat_node_edges: + if cur_group: + this_concat_edge = concat_node_edges[-1] + last_concat_edge = cur_group[-1][-1] + if (this_concat_edge.to_node == last_concat_edge.to_node and + this_concat_edge.to_idx == last_concat_edge.to_idx + 1): + cur_group.append(concat_node_edges) + continue + if len(cur_group) > 1: + edge_groups.append(cur_group) + cur_group = [concat_node_edges] + continue + if cur_group: + if len(cur_group) > 1: + edge_groups.append(cur_group) + cur_group = None + if cur_group: + if len(cur_group) > 1: + edge_groups.append(cur_group) + cur_group = None + # we leave the splits and concats after this since they will be cleared up by remove_noops + for edge_group in edge_groups: + split_node = edge_group[0][0].from_node + concat_node = edge_group[0][-1].to_node + from_idx = edge_group[0][0].from_idx + to_idx = edge_group[-1][0].from_idx + from_concat_idx = edge_group[0][-1].to_idx + to_concat_idx = edge_group[1][-1].to_idx + LOG.info( + f"combining outputs {from_idx}:{to_idx} on split node {split_node.name} " + f"followed by concat {concat_node.name}") + # combine slices and shapes on edges in group + new_slice, new_shape = reduce_slices( + split_node.act_slices[from_idx:to_idx+1], + split_node.out_shapes[from_idx:to_idx+1] + ) + new_concat_shape = Dim.combine( + [concat_node.in_dims[idx] + for idx in range(from_concat_idx, to_concat_idx+1)], + concat_node.axis) + split_node.act_slices = split_node.act_slices[:from_idx] + [ + new_slice] + split_node.act_slices[to_idx+1:] + # the slice may need to reshape since we will remove everything in between + split_node.out_shapes = split_node.out_shapes[:from_idx] + [ + new_concat_shape.shape] + split_node.out_shapes[to_idx+1:] + + # remove all edges and intermediate nodes on all edge groups + for edge_list in edge_group: + remove_edges(G, edge_list) + # add back a direct edge to the first idx + G.add_edge(NNEdge(from_node=split_node, + from_idx=edge_group[0][0].from_idx, + to_node=concat_node, + to_idx=edge_group[0][-1].to_idx)) + out_edge_bundles = G.indexed_out_edges(split_node) + # move edges beyond the edge group after the first index + for offset, edge_list in enumerate(out_edge_bundles[to_idx+1:]): + assert len(edge_list) == 1 + edge = edge_list[0] + G.remove_edge(edge) + G.add_edge(NNEdge.clone(edge, from_idx=from_idx+1+offset)) + # reindex the in edges in the concat + from_idx = edge_group[0][-1].to_idx + to_idx = edge_group[-1][-1].to_idx + in_edges = G.indexed_in_edges(concat_node) + for offset, in_edge in enumerate(in_edges[to_idx+1:]): + G.remove_edge(in_edge) + G.add_edge(NNEdge.clone(in_edge, to_idx=from_idx+1+offset)) + + return bool(edge_groups) diff --git a/tools/nntool/graph/matches/matches.py b/tools/nntool/graph/matches/matches.py index 451dc92fe..fe1130680 100644 --- a/tools/nntool/graph/matches/matches.py +++ b/tools/nntool/graph/matches/matches.py @@ -17,32 +17,19 @@ import logging -from graph.matches.matcher import Matcher, MatchGroup +from graph.matches.matcher import Matcher, MatchGroup, match_name, description from utils.subclasses import get_all_subclasses from .matchers import * LOG = logging.getLogger("nntool." + __name__) - -def general_validation(match: Matcher): - if match.DESCRIPTION is None: - LOG.warning('matcher %s has no description', match.NAME) - if match.NAME is None: - raise ValueError(f'match {match.NAME} has no name') - if '*' in match.RUN_BEFORE and '*' in match.RUN_AFTER: - raise ValueError( - f'match {match.NAME} has wildcard in run_before and run_after') - return match - - -ALL_MATCHERS = [general_validation(match_class) for match_class in get_all_subclasses(Matcher) - if match_class.NAME is not None] +ALL_MATCHERS = {} def select_matchers(group=None): - return [match_class for match_class in ALL_MATCHERS - if (group is None or '*' in match_class.GROUPS or group in match_class.GROUPS)] + return [match_class for match_class in ALL_MATCHERS.values() + if ('*' in match_class.GROUPS or group in match_class.GROUPS)] def order_matchers(matchers): @@ -75,22 +62,39 @@ def select_sorted_matcher_instances(group=None): def get_fusions(): return sorted( [(match_class.NAME, match_class.DESCRIPTION) - for match_class in ALL_MATCHERS], + for match_class in ALL_MATCHERS.values()], key=lambda x: x[0]) +@match_name("pow2_match_group") +@description("a selection of matches that are relevant for POW2 quantized graphs") +class POW2MatchGroup(MatchGroup): + def __init__(self): + super().__init__(*select_sorted_matcher_instances(group='symmetric'), + identity='pow2_match_group') + + +@match_name("scaled_match_group") +@description("a selection of matches that are relevant for scaled quantized graphs") +class ScaledMatchGroup(MatchGroup): + def __init__(self): + super().__init__(*select_sorted_matcher_instances(group='scaled'), + identity='scaled_match_group') + + def get_pow2_match_group(): - return MatchGroup( - *select_sorted_matcher_instances(group='symmetric'), - identity="pow2_match_group" - ) + return POW2MatchGroup() def get_scale8_match_group(): - return MatchGroup( - *select_sorted_matcher_instances(group='scaled'), - identity="std_match_group" - ) + return ScaledMatchGroup() + + +def get_matches(*match_names, identity="custom"): + not_found = set(match_names) - set(ALL_MATCHERS) + if not_found: + raise ValueError(f'matches {" ".join(not_found)} not found') + return MatchGroup(*[ALL_MATCHERS[name]() for name in match_names], identity=identity) def get_fusion(name): @@ -98,8 +102,10 @@ def get_fusion(name): return get_pow2_match_group() if name in ["std_match_group", "scale8_match_group"]: return get_scale8_match_group() - match_class = next((match_class for match_class in select_matchers() - if match_class.NAME == name), None) - if match_class is not None: - return match_class() + if name in ALL_MATCHERS: + return ALL_MATCHERS[name]() return None + + +ALL_MATCHERS.update({match_class.NAME: match_class for match_class in get_all_subclasses(Matcher) + if match_class.NAME is not None}) diff --git a/tools/nntool/graph/nngraph.py b/tools/nntool/graph/nngraph.py index abf34a24d..f7d83da0e 100644 --- a/tools/nntool/graph/nngraph.py +++ b/tools/nntool/graph/nngraph.py @@ -1,4 +1,4 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS +# Copyright (C) 2020, 2022 GreenWaves Technologies, SAS # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -16,29 +16,40 @@ import logging import os import re -from typing import Generator, Sequence, Union +from typing import Any, Callable, Generator, Mapping, Sequence, Tuple, Union import numpy as np +from execution.graph_executer import GraphExecuter +from execution.quantization_mode import QuantizationMode +from interpreter.commands.qtune import SCHEME_NAME_MAPPINGS from quantization.quantization_set import QuantizationSet +from quantization.quantizer.new_quantizer import NewQuantizer from reports.graph_reporter import GraphReporter -from reports.quantization_reporter import QuantizationReporter +from stats.activation_ranges_collector import ActivationRangesCollector from utils.graph import Graph, Node +from utils.node_id import NodeId +from utils.stats_funcs import cos_similarity, qsnr from utils.tabular import TextTableRenderer from graph.dim import Dim -from graph.dump_tensor import PrintDumper, dump_tensor from graph.graph_identity import GraphIdentity -from graph.manipulations import (add_dimensions, adjust_order, - balance_all_filters, calculate_liveness) -from graph.manipulations.balance_filter import balance_filter_with_constants +from graph.manipulations.adjust_order import adjust_order +from graph.manipulations.balance_filter import (balance_all_filters, + balance_filter_with_constants) +from graph.manipulations.dimensions import add_dimensions +from graph.manipulations.liveness import calculate_liveness +from graph.matches.fusions import fusions +from graph.matches.matches import get_fusions from graph.types import (ConstantInputParameters, InputBaseParameters, InputParameters, MultiplicativeBiasParameters, OutputParameters, ResizerParameters, RNNBaseParameters, SSDDetectorParameters) -from graph.types.base import NNNodeRef +from graph.types.base import NNEdge, NNNodeRef, Parameters from graph.types.dsp_preprocessing import DSPParameters from graph.types.expression_fusion import ExpressionFusionParameters -from graph.types.fusions import FilterFusionBase, FusionBase +from graph.types.fusions import (ActivationFusionBase, FilterFusionBase, + FusionBase, MatMulOpFusionParameters, + PaddedAddFusionParameters) LOG = logging.getLogger("nntool." + __name__) @@ -79,78 +90,140 @@ def liveness(self): def liveness(self, val): self._state['liveness'] = val - @property - def has_quantization_info(self): - return self._state['quantization'] - - @has_quantization_info.setter - def has_quantization_info(self, val): - self._state['quantization'] = val - class NNGraph(Graph): def __init__(self, model=None, name=None, filename=None): - super().__init__() - - self.model = model - self.num_inputs = 0 - self.num_outputs = 0 - self.num_constants = 0 - self.node_options = {} - self.num_rinputs = 0 - self.num_routputs = 0 + attrs = { + 'model': model, + 'node_options': {}, - self.graph_state = NNGraphState() - - self.load_function = None - self.graphname = name - self.graph_identity = GraphIdentity(filename) - self._info = { 'quantization': None, + 'has_quantized_parameters': False, + 'graphname': name, + 'graph_state': NNGraphState(), + 'graph_identity': GraphIdentity(filename) } + super().__init__(**attrs) + + INVALID_CHARS = re.compile(r'[^A-Za-z0-9_]') + + @staticmethod + def valid_c_identifier(val: str) -> str: + return NNGraph.INVALID_CHARS.sub('_', val) + + @property + def _edge_class(self): + return NNEdge + + @property + def name(self) -> str: + """Returns the name of the graph potentially modified to be a valid C identifier + + Returns: + str: The graph name + """ + if self._attr['graphname'] is None: + base, _ = os.path.splitext( + os.path.basename(self._attr['graph_identity'].filename)) + return self.valid_c_identifier(base) + return self.valid_c_identifier(self._attr['graphname']) + + @name.setter + def name(self, val: str): + """Sets the name of the graph + + Args: + val (str): The name of the graph + """ + self._attr['graphname'] = val + + @property + def model(self): + """The original model that generated the NNTool graph + + Returns: + Any: The model file (TFLite or ONNX graph descriptor) + """ + return self._attr['model'] @property - def info(self): - return self._info + def num_inputs(self) -> int: + """Current number of inputs - @info.setter - def info(self, val): - self._info = val + Returns: + int: Number of inputs + """ + return len(self.nodes(node_classes=InputParameters)) @property - def quantization(self) -> QuantizationSet: - return self._info.get('quantization') + def num_outputs(self) -> int: + """Current number of outputs + + Returns: + int: Number of outputs + """ + return len(self.nodes(node_classes=OutputParameters)) + + @property + def num_constants(self) -> int: + """Current number of constant inputs + + Returns: + int: Number of constant inputs + """ + return len(self.nodes(node_classes=ConstantInputParameters)) + + @property + def node_options(self) -> dict: + return self._attr['node_options'] + + @property + def quantization(self) -> Union[QuantizationSet, None]: + """Current graph Quantization + + Returns: + Union[QuantizationSet, None]: quantization set + """ + return self._attr['quantization'] @quantization.setter - def quantization(self, val: QuantizationSet): - self._info['quantization'] = val + def quantization(self, val: Union[QuantizationSet, None]): + """Sets or clears the quantization + + Args: + val (Union[QuantizationSet, None]): quantization set + """ + self._attr['quantization'] = val @property def has_quantized_parameters(self) -> bool: - return self._info.get('has_quantized_parameters') + """Graph was imported with quantized parameters + + Returns: + bool: quantized parameters or not + """ + return self._attr['has_quantized_parameters'] @has_quantized_parameters.setter def has_quantized_parameters(self, val: bool): - self._info['has_quantized_parameters'] = val + """Graph was imported with quantized parameters - INVALID_CHARS = re.compile(r'[^A-Za-z0-9_]') - - @staticmethod - def valid_c_identifier(val: str) -> str: - return NNGraph.INVALID_CHARS.sub('_', val) + Args: + val (bool): quantized parameters or not + """ + self._attr['has_quantized_parameters'] = val + @property + def graph_state(self) -> NNGraphState: + return self._attr['graph_state'] @property - def name(self) -> str: - if self.graphname is None: - base, _ = os.path.splitext( - os.path.basename(self.graph_identity.filename)) - return self.valid_c_identifier(base) - return self.valid_c_identifier(self.graphname) + def graph_identity(self) -> GraphIdentity: + return self._attr['graph_identity'] @property def inputs_dim(self) -> list: @@ -160,144 +233,276 @@ def inputs_dim(self) -> list: def outputs_dim(self) -> list: return [out_node.out_dims[0].shape for out_node in self.output_nodes()] - @name.setter - def name(self, val): - self.graphname = val - @property - def has_ssd_postprocess(self): + def has_ssd_postprocess(self) -> bool: + """Graph has SSD detector nodes + + Returns: + bool: True if present + """ return self.has_node_type(SSDDetectorParameters) @property - def has_resizer(self): + def has_resizer(self) -> bool: + """Graph has resizer nodes + + Returns: + bool: True if present + """ return self.has_node_type(ResizerParameters) @property - def has_expressions(self): + def has_expressions(self) -> bool: + """Graph has compiled expressions + + Returns: + bool: True if present + """ return self.has_node_type(ExpressionFusionParameters) @property - def has_rnn(self): - return self.has_node_type(RNNBaseParameters) + def has_dsp(self) -> bool: + """Graph has DSP nodes - @property - def has_dsp(self): + Returns: + bool: True if present + """ return self.has_node_type(DSPParameters) @property - def all_expressions(self): - return self.all_node_types(ExpressionFusionParameters) + def all_expressions(self) -> Sequence[ExpressionFusionParameters]: + """All the expression nodes in the graph - def has_node_type(self, node_type): - return any(isinstance(node, node_type) for node in self.nodes()) + Returns: + Sequence[ExpressionFusionParameters]: List of nodes + """ + return self.nodes(node_classes=ExpressionFusionParameters) - def all_node_types(self, node_type): - return [node for node in self.nodes() if isinstance(node, node_type)] - - def set_load_function(self, func): - self.load_function = func - - def load_tensors(self, file=None): - assert self.load_function - self.load_function(self, file) - - def get_in_params(self, name: str) -> set: - in_edges = self.in_edges(name) - if not in_edges: - return in_edges - in_edges.sort(key=lambda edge: edge.to_idx) - res = [] - in_idx = 0 - for real_idx in range(max(edge.to_idx for edge in in_edges) + 1): - if real_idx == in_edges[in_idx].to_idx: - res.append(in_edges[in_idx].params) - in_idx += 1 - else: - res.append(None) + @property + def nodes_by_step_idx(self) -> Sequence[Parameters]: + """All the nodes in the graph ordered by execution order - return res + Returns: + Sequence[Parameters]: List of nodes + """ + return [step['node'] for step in self.graph_state.steps] - def get_out_params(self, name: str) -> set: - out_edges = self.indexed_out_edges(name) - return [edge_list[0].params for edge_list in out_edges] + @property + def nodes_by_step_idx_with_fusions(self) -> Sequence[Parameters]: + """Nodes ordered by execution order but also including internal nodes + for fusions + + Returns: + Sequence[Parameters]: List of nodes + """ + nodes = [] + for step in self.graph_state.steps: + node = step['node'] + if isinstance(node, (FilterFusionBase, ActivationFusionBase, + PaddedAddFusionParameters, MatMulOpFusionParameters)): + nodes.extend(node.contained_nodes()) + nodes.append(node) + return nodes - def all_inputs(self) -> Generator[Node, None, None]: - return (node for node in self.nodes() if isinstance(node, (InputBaseParameters))) + @property + def total_ops(self) -> int: + """Estimated total operations in the graph + + Returns: + int: Number of operations + """ + tot_ops = 0 + for node in self.nodes(): + ops = node.compute_load() + tot_ops += ops if ops else 0 + return tot_ops + + def has_rnn(self, ktype: str = None, ne16: bool = False) -> bool: + """Graph has RNN nodes + + Args: + ktype (str, optional): kernel type to match or all. Defaults to None. + ne16 (bool, optional): match nodes that will map to ne16 kernels. Defaults to False. + + Returns: + bool: True if present + """ + nodes = self.nodes(node_classes=RNNBaseParameters) + if not nodes: + return False + if ktype is not None and not any(self.quantization[NodeId(node)].ktype == ktype for node in nodes): + return False + if ne16 and not any(self.quantization[NodeId(node)].cache.get('ne16') for node in nodes): + return False + return True + + def has_node_type(self, node_type: Parameters) -> bool: + """Returns True if graph contains node type + + Args: + node_type (Parameters): Node class + + Returns: + bool: True if present + """ + return any(isinstance(node, node_type) for node in self.nodes()) def inputs_and_constants(self) -> Generator[Node, None, None]: + """Iterate over all inputs and constants + + Returns: + Generator[Node]: a generator for all nodes + """ return (node for node in self.nodes() if isinstance(node, InputBaseParameters)) def input_nodes(self) -> Generator[Node, None, None]: + """Iterate over all inputs + + Returns: + Generator[Node]: a generator for all nodes + """ return (node for node in self.nodes() if isinstance(node, InputParameters)) def output_nodes(self) -> Generator[Node, None, None]: - return (node for node in self.nodes() if isinstance(node, OutputParameters)) + """Iterate over all outputs - def is_input(self, node_name: Union[str, Node]) -> bool: - if isinstance(node_name, str): - return isinstance(self[node_name], InputParameters) - return isinstance(node_name, InputParameters) + Returns: + Generator[Node]: a generator for all nodes + """ + return (node for node in self.nodes() if isinstance(node, OutputParameters)) - def is_output(self, node_name: Union[str, Node]) -> bool: - if isinstance(node_name, str): - return isinstance(self[node_name], OutputParameters) - return isinstance(node_name, OutputParameters) + def add_input(self, dim: Union[Dim, Tuple[int]], name: str = None, **kwargs) -> NNNodeRef: + """Create an input node. If a name is not supplied then one will be automatically chosen. - def reset_inout_counts(self): - self.num_inputs = 0 - self.num_outputs = 0 - self.num_constants = 0 + Args: + dim (Union[Dim, Tuple[int]]): Input dimension + name (str, optional): Node name. Defaults to None. - def add_input(self, dim: Dim, name=None, **kwargs) -> InputParameters: - self.num_inputs += 1 - node_name = "input_"+str(self.num_inputs) if not name else name + Returns: + NNNodeRef: Reference to created node in graph + """ + node_name = self.unique_name( + f"input_{self.num_inputs + 1}") if not name else name node = InputParameters(node_name, dims=dim, **kwargs) self.add_node(node) - return NNNodeRef(node, 0, self) - - def add_constant(self, dim: Dim, name: str = None, - adjust_transpose=None, is_mutated=False, - is_intermediate=False, short_name=None) -> ConstantInputParameters: - self.num_constants += 1 - node_name = name if name else "constant_"+str(self.num_constants) + return NNNodeRef(self, node, 0) + + def add_constant(self, dim: Union[Dim, Tuple[int]] = None, + name: str = None, + value: np.ndarray = None, + adjust_transpose: Sequence[int] = None, + is_mutated=False, + is_intermediate=False, + short_name: str = None) -> NNNodeRef: + """Creates a constant node + + Args: + dim (Union[Dim, Tuple[int]], optional): Dimension of constant if not supplied then a value must be. Defaults to None. + name (str, optional): Optional name. A unique one will be created if None. Defaults to None. + value (np.ndarray, optional): Numpy array with value. Defaults to None. + adjust_transpose (Sequence[int], optional): Adjust will transpose the value using this transpose. Defaults to None. + is_mutated (bool, optional): Constant is both an input and an output. Defaults to False. + is_intermediate (bool, optional): Constant is marked as intermediate at import. Defaults to False. + short_name (str, optional): Preferred short name for model generation. Defaults to None. + + Returns: + NNNodeRef: A reference to the Node in the Graph + """ + node_name = name if name else self.unique_name( + f"constant_{self.num_constants}") node = ConstantInputParameters(node_name, dims=dim, + value=value, adjust_transpose=adjust_transpose, is_intermediate=is_intermediate, is_mutated=is_mutated, short_name=short_name) self.add_node(node) - return NNNodeRef(node, 0, self) - - def variable_in_edges(self, node_name): - return list([edge for edge in self.in_edges(node_name) - if not isinstance(edge.from_node, ConstantInputParameters)]) + return NNNodeRef(self, node, 0) def add_output(self, name=None) -> OutputParameters: - self.num_outputs += 1 - node_name = "output_"+str(self.num_outputs) if name is None else name + """Create an output node. If a name is not supplied then one will be automatically chosen. + + Args: + name (str, optional): Node name. Defaults to None. + + Returns: + OutputParameters: Created node + """ + node_name = self.unique_name( + f"output_{self.num_outputs + 1}") if name is None else name node = OutputParameters(node_name) self.add_node(node) return node def nodes_iterator(self, yield_fusions=True): + """Yields a tuple of length 4 with the step idx and parameters of each node. Optionally + when in a fusion yields tuples containing the fusion internal step id and node for each internal + node. + + Args: + yield_fusions (bool, optional): Whether to yield fusion nodes. Defaults to True. + + Yields: + [Tuple[int, Parameters, Optional[int], Optional[Parameters]]]: Tuple containing node_idx, node, fusion_idx, fusion_node + """ for step_idx, step in enumerate(self.graph_state.steps): node = step['node'] - if isinstance(node, (FusionBase)) and not isinstance(node, ExpressionFusionParameters): - if yield_fusions: + if yield_fusions: + if isinstance(node, (FusionBase)) and not isinstance(node, ExpressionFusionParameters): for fusion_idx, fnode in enumerate(node.contained_nodes()): yield (step_idx, node, fusion_idx, fnode) - yield (step_idx, node, None, None) - else: - yield (step_idx, node, None, None) - - def adjust_order(self, reshape_weights=True, postprocess=True, debug_function=None, steps=None, single_step=False): + yield (step_idx, node, None, None) + + def adjust_order( + self, + reshape_weights=True, + no_postprocess=False, + debug_function: Callable = None, + steps: int = None, + single_step=False + ): + """Adjusts tensor order to match selected kernels + + Args: + reshape_weights (bool, optional): Whether weights should be modified to remove transposes. Defaults to True. + no_postprocess (bool, optional): Whether post processing such as transpose elimination is run. Defaults to False. + debug_function (Callable, optional): Function to be called after each transpose elimination step. Defaults to None. + steps (int, optional): Number of elimination steps to run. Defaults to None. + single_step (bool, optional): Execute only one transpose elimination step in each cycle. Defaults to False. + """ adjust_order(self, reshape_weights=reshape_weights, - postprocess=postprocess, debug_function=debug_function, + postprocess=not no_postprocess, debug_function=debug_function, steps=steps, single_step=single_step) LOG.info("adjusted order") self.graph_identity.is_adjusted = True - def add_dimensions(self, quiet=False): + @staticmethod + def get_fusions(): + """Returns a dictionary of all the fusion/graph optimization pass names and descriptions + + Returns: + Dict[str, str]: Names and descriptions of graph optimisation passes + """ + return get_fusions() + + def fusions(self, *match_names, no_postprocess: bool = False): + """Run matchers on the graph + + Args: + match_names (str): Names of matches to apply + no_postprocess (bool, optional): Do not execute postprocessing such as transpose elimination. Defaults to False. + """ + fusions(self, *match_names, no_postprocess=no_postprocess) + + def add_dimensions( + self, + quiet=False + ): + """Add dimensions to the graph and calculate execution order and liveness + + Args: + quiet (bool, optional): Do not log progress. Defaults to False. + """ if not quiet: LOG.info("update graph dimensions") self.graph_state.steps = add_dimensions(self) @@ -307,7 +512,131 @@ def add_dimensions(self, quiet=False): self, self.graph_state.steps) - def balance_filters(self, step_idx=None, precision_threshold=0.20): + def collect_statistics( + self, + input_tensors_iterator: Union[Sequence[Sequence[np.ndarray]], Sequence[np.ndarray]] + ) -> Mapping[Union[str, Tuple[str, str]], Mapping]: + """Collect tensor statistics for quantization + + Args: + input_tensors_iterator (Union[Sequence[Sequence[np.ndarray]], Sequence[np.ndarray]]): + If the graph has a single input this can just be an iterator over numpy arrays. If the graph has + multiple inputs then it should be an iterator over sequences of numpy arrays. + + Returns: + Mapping[Union[str, Tuple[str, str]], Mapping]: Mapping of statistics for each node's inputs and outputs + """ + stats_collector = ActivationRangesCollector() + for input_tensors in input_tensors_iterator: + if isinstance(input_tensors, np.ndarray): + input_tensors = [input_tensors] + stats_collector.collect_stats(self, input_tensors) + return {k.key: v for k, v in stats_collector.stats.items()} + + @staticmethod + def qsnrs(tensors1, tensors2, idx=0): + return tuple([qsnr(t1[idx], t2[idx]) if len(t1) > idx and len(t2) > idx else None for t1, t2 in zip(tensors1, tensors2)]) + + @staticmethod + def cos_sim(tensors1, tensors2, idx=0): + return tuple([cos_similarity(t1[idx], t2[idx]) if len(t1) > idx and len(t2) > idx else None for t1, t2 in zip(tensors1, tensors2)]) + + def quantize( + self, + statistics: Mapping[Union[str, Tuple[str, str]], Mapping] = None, + schemes: Sequence[str] = None, + graph_options: Mapping[str, Any] = None, + node_options: Mapping[Union[str, Tuple[str, str]], + Mapping[str, Any]] = None, + read_existing_options = True + ) -> None: + """Quantize the graph + + Args: + statistics (Mapping[Union[str, Tuple[str, str]], Mapping], optional): Statistics collected by the NNGraph.collect_statistics + method. + schemes (Sequence[], optional): Sequence of schemes "scaled", "pow2", or "float" to use in priority order. If None use scaled. Defaults to None. + graph_options (Mapping[str, Any], optional): Quantization options to set for the whole graph. Defaults to None. + node_options (Mapping[Union[str, Tuple[str, str]], Mapping[str, Any]], optional): + Quantization options to set for specific nodes. The map key should be the node name or if the node is inside a fusion + then a tuple of the fusion name and the node name. Defaults to None. + read_existing_options (bool, optional): Incorporate existing quantization options and schemes in the graph. Leaving this as + True and just supplying graph_option, node_options and/or schemes is the equivalent of the nntool qtune command + """ + quantizer = NewQuantizer(self) + if schemes: + for scheme in schemes: + scheme = scheme.lower() + if scheme not in SCHEME_NAME_MAPPINGS: + raise ValueError(f'invalid scheme name {scheme}') + quantizer.schemes.append(SCHEME_NAME_MAPPINGS[scheme]) + elif 'SQ8' not in quantizer.schemes: + quantizer.schemes.append('SQ8') + options = {} + if graph_options: + options.update(graph_options) + if node_options: + options.update({NodeId(name) if isinstance(name, str) else NodeId(*name): v + for name, v in node_options.items()}) + quantizer.set_stats(statistics) + quantizer.update_options(options) + quantizer.quantize() + + def execute( + self, + input_tensors: Union[np.ndarray, Sequence[np.ndarray]], + quantize=False, + dequantize=False, + output_fusion_tensors=False + ) -> Sequence[Sequence[np.ndarray]]: + """Runs inference on the graph + + Args: + input_tensors (Union[np.ndarray, Sequence[np.ndarray]]): + Numpy arrays containing inputs (which should be normalized and in float) + If there is only one input it can be specified without a sequence. + quantize (bool, optional): Run the graph using quantization parameters. Defaults to False. + dequantize (bool, optional): Dequantize outputs. Implies quantize. Defaults to False. + output_fusion_tensors (bool, optional): Output outputs from nodes that have been fused. Defaults to False. + + Raises: + ValueError: Incorrect parameters + + Returns: + Sequence[Sequence[np.ndarray]]: List of lists of outputs of each node in the graph. If output_fusion_tensors + is True this will also include the output of nodes contained inside fusions (except fused expressions) + """ + if dequantize: + quantize = True + if quantize: + if self.quantization is None or not self.quantization.verify_quantization(self): + raise ValueError('graph is not quantized') + if dequantize: + qmode = QuantizationMode.all_dequantize() + else: + qmode = QuantizationMode.all() + else: + qmode = QuantizationMode.none() + if isinstance(input_tensors, np.ndarray): + input_tensors = [input_tensors] + executer = GraphExecuter(self, self.quantization) + return executer.execute(input_tensors, qmode=qmode, append_fusion_output=output_fusion_tensors) + + def balance_filters( + self, + step_idx: int = None, + precision_threshold=0.20 + ): + """Experimental filter balancing routines + + Args: + step_idx (int, optional): Step to balance. Defaults to None. + precision_threshold (float, optional): Precision threshold. Defaults to 0.20. + + Raises: + ValueError: Bad parameters + NotImplementedError: Bad graph structure + """ if step_idx is not None: if step_idx > len(self.graph_state.steps) or step_idx < 0: raise ValueError("step idx out of range") @@ -330,57 +659,13 @@ def balance_filters(self, step_idx=None, precision_threshold=0.20): else: balance_all_filters(self, precision_threshold=precision_threshold) - def print_intermediates(self, outputs, limit=None, width=8, - precision=4, channel=None, order=None, - checksum=False, print_constants=False): - def print_step(step, outs, index): - node = step['node'] - if checksum: - for out_idx, out in enumerate(outs): - if isinstance(node, ConstantInputParameters): - continue - print(f"S{index} - {node.name}\n\tChecksum = {np.sum(out) if out.dtype != np.uint8 else np.sum(out.astype(np.int8))}") - else: - print(node.name) - for out_idx, out in enumerate(outs): - dims = node.out_dims[out_idx] - if order is not None and dims.is_named and order != dims.order and all(k in dims.order - for k in order): - transpose = dims.transpose_to_order(order) - out = out.transpose(transpose) - if channel is not None: - out = out[channel:channel+1:1, ...] - dump_tensor(out, PrintDumper( - out, width=width, precision=precision)) - - if limit is not None: - print_step(self.graph_state.steps[limit], outputs[limit], limit) - else: - for idx, out in enumerate(outputs): - print_step(self.graph_state.steps[idx], out, idx) - print() - - def qshow(self): - tab = QuantizationReporter().report(self, self.quantization) - renderer = TextTableRenderer(150) - tab.render(renderer) - return renderer.get_output() - - def merge(self, other: 'NNGraph'): - if self != other: - for edge in other.edges: - self.add_edge(edge) - return self + def __getitem__(self, key) -> Parameters: + if isinstance(key, int): + return self.nodes_by_step_idx[key] + return super().__getitem__(key) - def __repr__(self): + def __repr__(self) -> str: tab = GraphReporter().report(self) renderer = TextTableRenderer(150) tab.render(renderer) return renderer.get_output() - - def total_ops(self): - tot_ops = 0 - for node in self.nodes(): - ops = node.compute_load() - tot_ops += ops if ops else 0 - return tot_ops diff --git a/tools/nntool/graph/types/activations.py b/tools/nntool/graph/types/activations.py index a29e6f68b..59f75d7b9 100644 --- a/tools/nntool/graph/types/activations.py +++ b/tools/nntool/graph/types/activations.py @@ -14,13 +14,16 @@ # along with this program. If not, see . -from generation.at_types.gen_ctrl import GenCtrl import logging from expressions.symbolic.basic import HSigmoid, HTanh, Relu, Sigmoid, TanH +from generation.at_types.gen_ctrl import GenCtrl + +from utils.subclasses import get_all_subclasses -from .base import (CanFuseToExpression, ComparableParameters, NoSizeChangeParameters, Parameters, SensitiveToOrder, - SingleInputAndOutput, expression_op, cls_op_name) +from .base import (CanFuseToExpression, ComparableParameters, + NoSizeChangeParameters, Parameters, SensitiveToOrder, + SingleInputAndOutput, cls_op_name, expression_op) LOG = logging.getLogger("nntool." + __name__) @@ -39,7 +42,7 @@ def get_activation(cls, activation_type: str, name: str): if activation_type == "relu6": return ReluActivationParameters(name, upper_bound=6) actnames = { - act_class.CLS_OP_NAME: act_class for act_class in ActivationParameters.__subclasses__()} + act_class.CLS_OP_NAME: act_class for act_class in get_all_subclasses(ActivationParameters)} if activation_type in actnames: return actnames[activation_type](name) raise ValueError("don't know how to create %s" % activation_type) @@ -137,51 +140,67 @@ def is_same_operation_as(self, G, other): return (isinstance(other, LeakyActivationParameters) and self.leak_factor == other.leak_factor) -@expression_op(HSigmoid) -@cls_op_name('hsigmoid') -class HSigmoidActivationParameters(ActivationParameters, CanFuseToExpression): - def __init__(self, name, offset=3): - super(HSigmoidActivationParameters, self).__init__(name) - self._offset = offset +class HardSigSwiActivationBase(ActivationParameters): + def __init__(self, name, offset=3, upper_bound=6, mult=1/6): + super(HardSigSwiActivationBase, self).__init__(name) + self._factors = [offset, upper_bound, mult] + + @property + def factors(self): + return self._factors @property def offset(self): - return self._offset + return self._factors[0] + + @property + def upper_bound(self): + return self._factors[1] + + @property + def mult(self): + return self._factors[2] @offset.setter def offset(self, val): - self._offset = val - - def get_gen_ctrl(self): - gen_ctrl = GenCtrl(self.at_options) - if self.offset != 3.0: - gen_ctrl.relun = self.offset - return gen_ctrl + self._factors[0] = val @property def can_equalize(self): return False def is_same_operation_as(self, G, other): - return (isinstance(other, HSigmoidActivationParameters) and self.offset == other.offset) + return (isinstance(other, self.__class__) and + self.factors == other.factors) def __str__(self): - return "Activation {} offset={} {}".format( - self.activation, - self.offset, - self.at_options - ) + return f"Activation {self.activation} offset={self.offset} {self.at_options}" -@cls_op_name('hswish') -class HSwishActivationParameters(ActivationParameters): +@expression_op(HSigmoid) +@cls_op_name('hsigmoid') +class HSigmoidActivationParameters(HardSigSwiActivationBase, CanFuseToExpression): + + @classmethod + def from_alpha_beta(cls, name, alpha, beta): + return cls(name, offset=beta/alpha, upper_bound=1/alpha, mult=alpha) + @property def activation(self): - return "hswish" + return "hsigmoid" + def get_gen_ctrl(self): + gen_ctrl = GenCtrl(self.at_options) + if self.offset != 3.0: + gen_ctrl.relun = self.offset + return gen_ctrl + + +@cls_op_name('hswish') +class HSwishActivationParameters(HardSigSwiActivationBase): @property - def can_equalize(self): - return False + def activation(self): + return "hswish" @expression_op(HTanh) @@ -207,10 +226,6 @@ class TanHActivationParameters(ActivationParameters, CanFuseToExpression): def can_equalize(self): return False - def should_fuse(self, node_set, qrec=None): - # TODO - TanH is only supported in an expression currently - return True - @expression_op(Sigmoid) @cls_op_name('sigmoid') diff --git a/tools/nntool/graph/types/base.py b/tools/nntool/graph/types/base.py index a0b2f82b3..a75113604 100644 --- a/tools/nntool/graph/types/base.py +++ b/tools/nntool/graph/types/base.py @@ -20,6 +20,7 @@ from expressions.symbolic.symbol import Symbol from generation.at_types.gen_ctrl import CTRL_FEATURES, GenCtrl from graph.dim import Dim, PadDim, StrideDim +from stats.ranges_utils import collect_stat from utils.graph import Edge, Node, NodeRef from utils.option_list import OptionList @@ -27,14 +28,6 @@ LOG = logging.getLogger("nntool." + __name__) -class ParameterError(Exception): - pass - - -class CantPromoteQError(ParameterError): - pass - - class NodeOptions(OptionList): def __init__(self, *args, **kwargs): super(NodeOptions, self).__init__(*args, **kwargs) @@ -64,25 +57,13 @@ def clone_dims(dims: Sequence[Dim], hints: Sequence[Dim]): class NNNodeRef(NodeRef): - def __init__(self, node, idx, G) -> None: - super(NNNodeRef, self).__init__(node) - self._G = G - self._idx = idx - - @property - def G(self): - return self._G - - @property - def ref(self): - return ((self._node, self._idx), self._G) def __getattr__(self, name): return getattr(self._node, name) def __setattr__(self, name, val): if name in ['_node', '_G', '_idx']: - super().__setattr__(name, val) + return super().__setattr__(name, val) return setattr(self._node, name, val) def __hasattr__(self, name): @@ -94,26 +75,14 @@ def __str__(self) -> str: def __repr__(self) -> str: return self._node.__repr__() - def __eq__(self, o: object) -> bool: - if isinstance(o, NNNodeRef): - return super().__eq__(o) - return self._node.__eq__(o) - - def __hash__(self) -> int: - return self._node.__hash__() - - def __call__(self, *args, **kwargs): - raise ValueError("this is already a reference") - class Parameters(Node): CLS_OP_NAME = None NARGS = {1} NOT_GENERATED = False - def __init__(self, name, *args, in_dims_hint=None, out_dims_hint=None, **kwargs): - super().__init__(name, *args, **kwargs) - del args, kwargs + def __init__(self, name, in_dims_hint=None, out_dims_hint=None, **kwargs): + super().__init__(name, **kwargs) self._in_dims = None self._out_dims = None self._in_dims_hint = in_dims_hint @@ -134,17 +103,19 @@ def __str__(self): def __repr__(self): return f'{self.__class__.__name__}({self.name})' - def __call__(self, *args, **kwargs): + @property + def _edge_class(self): + return NNEdge + + @property + def _noderef_class(self): + return NNNodeRef + + def __call__(self, *args, num_outputs=1, **kwargs): # set of number of args if isinstance(self.NARGS, set): if '*' not in self.NARGS and len(args) not in self.NARGS: raise ValueError("incorrect number of arguments") - inputs, fragments = [], [] - for arg in args: - if arg is not None and not isinstance(arg, NNNodeRef): - raise ValueError("expecting NNNodeRef") - inputs.append(arg.ref[0] if arg else None) - fragments.append(arg.ref[1] if arg else None) # list of possible inputs passed in kwargs. Things passed in args get # copied to kwargs with their index from the names in nargs @@ -153,32 +124,37 @@ def __call__(self, *args, **kwargs): if idx >= len(self.nargs): raise ValueError('Too many inputs for this node type') kwargs[self.nargs[idx]] = arg - inputs = [] - fragments = [] + args = [] for name in self.nargs: if name in kwargs: ref = kwargs[name] if not isinstance(ref, NNNodeRef): raise ValueError("expecting NNNodeRef") - inputs.append(ref[0]) - fragments.append(ref[1]) + args.append(ref) else: - inputs.append(None) - fragments.append(None) - if inputs[0] is None: + args.append(None) + if args[0] is None: raise ValueError('Expecting at least an input') - fragment = [frag for frag in fragments if frag is not None][0] - if len(fragments) > 1: - for other in fragments[1::]: - if other is not None: - fragment.merge(other) - for to_idx, from_tuple in enumerate(inputs): - if from_tuple is not None: - from_node, from_idx = from_tuple - fragment.add_edge(NNEdge(from_node=from_node, - from_idx=from_idx, to_node=self, to_idx=to_idx)) - return NNNodeRef(self, 0, fragment) + return super().__call__(*args, num_outputs=num_outputs) + + @property + def no_model_code(self) -> bool: + """Returns True if node results in no kernel, global or local generation in model + + Returns: + bool: True if nothing generated + """ + return False + + @property + def does_nothing(self) -> bool: + """Returns True if the node does not modify its input in any way + + Returns: + bool: True if node could be eliminated with no effect + """ + return False @property def graph_label(self): @@ -269,13 +245,6 @@ def value(self): def value(self, val): self._value = val - @property - def can_promoteq(self): - return False - - def promoteq(self): - raise CantPromoteQError() - @property def in_dims(self): return self._in_dims @@ -314,6 +283,9 @@ def can_equalize(self): def op_name(self): return self.CLS_OP_NAME + def details_collector(self, stats, stat, details): + pass + def compute_load(self): return None @@ -531,6 +503,8 @@ def __init__(self, *args, filt=None, has_bias=True, use_compressed=False, **kwar self.details = None self.at_options.update_valid_options(CTRL_FEATURES) + def details_collector(self, stats, stat, details): + collect_stat(stat, 'range_acc', details, details_name='acc') class MultiplicativeBiasParameters(FilterParameters): def __init__(self, *args, **kwargs): @@ -538,6 +512,11 @@ def __init__(self, *args, **kwargs): self.has_mul_bias = False self._mul_biases = None + def details_collector(self, stats, stat, details): + super().details_collector(stats, stat, details) + if self.mul_biases: + collect_stat(stat, 'range_pre_mul_bias', details, details_name='pre_mul_bias') + @property def mul_biases(self): return self._mul_biases @@ -635,6 +614,9 @@ def edge_order(self): def edge_order(self, val): self._edge_order = val + def __repr__(self) -> str: + return f"EdgeParameters({self.creating_node.name}:{self.creating_node_idx})" + class NNEdge(Edge): def __init__(self, from_node: Union[str, Node], to_node: Union[str, Node], diff --git a/tools/nntool/graph/types/constant_input.py b/tools/nntool/graph/types/constant_input.py index 940deecd1..a7a55fb02 100644 --- a/tools/nntool/graph/types/constant_input.py +++ b/tools/nntool/graph/types/constant_input.py @@ -53,7 +53,7 @@ def __init__(self, *args, adjust_transpose=None, is_mutated=False, def __call__(self, graph): if graph.__class__.__name__ != 'NNGraph': raise ValueError('expecting NNGraph as parameter') - return NNNodeRef(self, 0, graph) + return NNNodeRef(graph, self, 0) @classmethod def fake(cls, G, val): diff --git a/tools/nntool/graph/types/conv2d.py b/tools/nntool/graph/types/conv2d.py index de85d7e01..3e7b7bed2 100644 --- a/tools/nntool/graph/types/conv2d.py +++ b/tools/nntool/graph/types/conv2d.py @@ -27,7 +27,7 @@ class BatchNormalizationParameters(NoSizeChangeParameters, SingleInputAndOutput, SensitiveToOrder): #pylint: disable-msg=too-many-arguments - def __init__(self, name, scale=None, bias=None, running_mean=None, + def __init__(self, name, scale=None, bias=None, running_mean=None, axis=0, running_variance=None, spatial=None, momentum=None, epsilon=None, **kwargs): super(BatchNormalizationParameters, self).__init__(name, **kwargs) self.scale = scale @@ -37,6 +37,7 @@ def __init__(self, name, scale=None, bias=None, running_mean=None, self.spatial = spatial self.momentum = momentum self.epsilon = epsilon + self.axis = axis @property def can_equalize(self): @@ -80,7 +81,7 @@ def __init__(self, name, dilation=None, groups=None, multiplier=1, # The multiplier parameter correspond to the channel multiplier option # in tensorflow. There are multiplier filters per input channel in # a depthwise convolution - if groups is None: + if groups is None or groups == 0: self.groups = 1 self.cannot_be_dw = True else: @@ -107,7 +108,7 @@ def __init__(self, name, dilation=None, groups=None, multiplier=1, self._ker_in_order = ker_in_order self._ker_out_order = ker_out_order - LOG.debug("created CON2D %s", str(self)) + LOG.debug("created CON2D %s %s", self.name, str(self)) @property def graph_label(self): diff --git a/tools/nntool/graph/types/expression_fusion.py b/tools/nntool/graph/types/expression_fusion.py index 51d7ac65f..554027cc2 100644 --- a/tools/nntool/graph/types/expression_fusion.py +++ b/tools/nntool/graph/types/expression_fusion.py @@ -13,10 +13,12 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from copy import deepcopy import logging from collections import Counter from expressions.symbolic.function_collection import FunctionCollection +from expressions.symbolic.iteration_space import Assignments from expressions.symbolic.symbol import Constant, Variable from utils.node_id import NodeId @@ -121,12 +123,25 @@ def set_min_max(qrecs, symbol, node): qtype = qrec.out_qs[0] symbol.control.add_min_max(symbol, qtype.min_val, qtype.max_val) + def details_collector(self, stats, stat, details): + if 'expression' in stat: + stat = stat['expression'] + for sym_name, rec in details.items(): + if sym_name == "results": + continue + stat_rec = stat.setdefault( + sym_name, {'min': float('inf'), 'max': float('-inf')}) + stat_rec['min'] = min(stat_rec['min'], rec['min']) + stat_rec['max'] = max(stat_rec['max'], rec['max']) + else: + stat['expression'] = deepcopy(details) + def is_same_operation_as(self, G, other): if not isinstance(other, ExpressionFusionParameters): return False - if len(self.func_col.functions) != 1 or len(other.func_col.functions) != 1: + if len(self.func_col) != 1 or len(other.func_col) != 1: return False - if next(iter(self.func_col.functions.values())).equivalent(next(iter(other.func_col.functions.values()))): + if self.func_col[0][1].equivalent(other.func_col[0][1]): return True return False @@ -142,7 +157,7 @@ def decompose(self, qrecs=None): LOG.info("expression decomposed into %s intermediate and %s output expressions", len(intermediates), len(outputs)) - expressions = [] + expressions = Assignments() inter_vars = {node: Variable( node.name, shape=node.dims.shape) for node in inputs} # TODO - Intermediates are not sorted here so there may be interdependences @@ -158,36 +173,37 @@ def decompose(self, qrecs=None): variable=variable, qrecs=qrecs) inter_vars[node] = variable - expressions.append(expr) + expressions.add(*expr) for node in outputs: expr = self.compose_expression( self.subgraph, node, inter_vars, qrecs=qrecs) - expressions.append(expr) + expressions.add(*expr) # sort the inputs by idx inputs = sorted([node for node in inputs], key=lambda x: x.idx) outputs = sorted([node for node in outputs], key=lambda x: x.idx) - func_col = FunctionCollection(expressions) - return [node.name for node in inputs], [node.name for node in outputs], func_col + return [node.name for node in inputs], [node.name for node in outputs], expressions def get_output_size(self, in_dims): # the input shapes may have changed so the expression variables shapes could have # changed and the iterators will need to be recalculated - dim_change = False + # dim_change = False in_vars = [self.func_col.variables[name] for name in self.input_symbols] for idx, dim in enumerate(in_dims): shape = tuple(dim.shape) if tuple(in_vars[idx].shape) != shape: in_vars[idx].shape = shape - dim_change = True + # dim_change = True + # if dim_change: + # self.func_col.set_var_shapes() out_dims = super().get_output_size(in_dims) - if dim_change: # if the input shapes haven't changed then the output shapes have not changed - out_vars = [self.func_col.variables[name] for name in self.output_symbols] - for idx, dim in enumerate(out_dims): - out_vars[idx].shape = tuple(dim.shape) - self.func_col.init_indexes() # recalculate the iterators + # if dim_change: # if the input shapes haven't changed then the output shapes have not changed + # out_vars = [self.func_col.variables[name] for name in self.output_symbols] + # for idx, dim in enumerate(out_dims): + # out_vars[idx].shape = tuple(dim.shape) + # self.func_col.init_indexes() # recalculate the iterators return out_dims def __str__(self): diff --git a/tools/nntool/graph/types/fusions.py b/tools/nntool/graph/types/fusions.py index 01d3d33f0..8e894dbe6 100644 --- a/tools/nntool/graph/types/fusions.py +++ b/tools/nntool/graph/types/fusions.py @@ -19,6 +19,8 @@ from graph.types.others import PadParameters from graph.types.pooling import PoolingParameters from graph.types.tensor_arithmetic import Broadcastable +from utils.graph import GraphView +from utils.node_id import NodeId from ..dim import Dim from .base import (FilterParameters, NNEdge, NodeOptions, Parameters, @@ -69,7 +71,7 @@ class FusionBase(Parameters): fusion_op_name = "!!NOT SET!!" quantize_internals = True - def __init__(self, name, *args, fusion_type=None, subgraph=None, + def __init__(self, name, *args, fusion_type=None, subgraph: GraphView=None, input_mapping=None, output_mapping=None, in_dims=None, out_dims=None, @@ -157,11 +159,11 @@ def op_name(self): return self.fusion_op_name @property - def subgraph(self): + def subgraph(self) -> GraphView: return self._subgraph def contained_nodes(self): - return [node for node in self.subgraph.dfs() + return [node for node in self.subgraph.topological_sort() if not isinstance(node, FusionInputOutputParameters)] def get_contained_node(self, name): @@ -197,7 +199,7 @@ def get_parameter_size(self): def get_output_size(self, in_dims): node_out_dims = [] - for node in self.subgraph.dfs(): + for node in self.subgraph.topological_sort(): if isinstance(node, FusionInputParameters): node_in_dims = [self.clone_dim_with_hint( in_dims[node.idx], node.idx)] diff --git a/tools/nntool/graph/types/input_output.py b/tools/nntool/graph/types/input_output.py index 9d25014a4..9a7ef936f 100644 --- a/tools/nntool/graph/types/input_output.py +++ b/tools/nntool/graph/types/input_output.py @@ -34,6 +34,8 @@ def __init__(self, *args, imported_dtype=None, dims=None, fixed_order=False, sho self._index = None self._short_name = short_name self.imported_dtype = imported_dtype + if isinstance(dims, (tuple, list)): + dims = Dim.unnamed(dims) self.dims = dims self.at_options.valid_options['ALLOCATE'] = int self.at_options.valid_options['FIXED_ORDER'] = int @@ -129,7 +131,7 @@ def __init__(self, *args, **kwargs): def __call__(self, graph): if graph.__class__.__name__ != 'NNGraph': raise ValueError('expecting NNGraph as parameter') - return NNNodeRef(self, 0, graph) + return NNNodeRef(graph, self, 0) def verify(self, G): problems = [] diff --git a/tools/nntool/graph/types/others.py b/tools/nntool/graph/types/others.py index 2d033305c..f22874cc6 100644 --- a/tools/nntool/graph/types/others.py +++ b/tools/nntool/graph/types/others.py @@ -15,6 +15,7 @@ import logging import math +from functools import reduce import numpy as np from expressions.symbolic.basic import (Abs, Ceil, Cos, Exp, Log, Max, Min, @@ -24,7 +25,7 @@ from utils.real_transpose import real_transpose from .base import (CanFuseToExpression, ComparableParameters, - InsensitiveToQuantization, NNNodeRef, + InsensitiveToQuantization, NoSizeChangeParameters, Parameters, SensitiveToOrder, SingleInputAndOutput, cls_op_name, expression_op, nargs, not_generated) @@ -63,7 +64,8 @@ def get_parameter_size(self): def permute(self, val): return [val[i] for i in self.transpose] - def does_nothing(self): + @property + def no_model_code(self): if not self.transpose: return True if not self.in_dims or not self.in_dims[0]: @@ -75,9 +77,13 @@ def does_nothing(self): for idx in trans if shape_idx[idx] is not None] return shape_trans == sorted(shape_trans) + @property + def does_nothing(self) -> bool: + return self._transpose is None + @property def is_not_generated(self): - return self.does_nothing() + return self.does_nothing def is_same_operation_as(self, G, other): if not isinstance(other, TransposeParameters): @@ -136,7 +142,7 @@ def __str__(self): @cls_op_name('expand') -class ExpandParameters(Parameters, InsensitiveToQuantization): +class ExpandParameters(Parameters, SensitiveToOrder, InsensitiveToQuantization): def __init__(self, *args, shape=None, **kwargs): super(ExpandParameters, self).__init__(*args, **kwargs) self.shape = shape @@ -172,9 +178,29 @@ def get_output_size(self, in_dims): def __str__(self): return f"{self.shape}" +@cls_op_name('scatternd') +class ScatterNdParameters(Parameters, SensitiveToOrder): + def __init__(self, *args, indices=None, updates=None, reduction=None, **kwargs): + super(ScatterNdParameters, self).__init__(*args, **kwargs) + self.indices = indices + self.updates = updates + self.reduction = reduction + + def get_parameter_size(self): + return 0 + + @property + def can_equalize(self): + return False + + def get_output_size(self, in_dims): + return [Dim.unnamed(in_dims[0].shape)] + + def __str__(self): + return "" @cls_op_name('quantize') -class QuantizeParameters(Parameters): +class QuantizeParameters(Parameters, ComparableParameters): def __init__(self, *args, from_qtype=None, to_qtype=None, inserted_by_quantizer=False, **kwargs): @@ -187,6 +213,11 @@ def __init__(self, *args, from_qtype=None, to_qtype=None, def get_parameter_size(self): return 0 + def is_same_operation_as(self, G, other): + return (isinstance(other, QuantizeParameters) and + self.from_qtype == other.from_qtype and + self.to_qtype == other.to_qtype) + @property def can_equalize(self): return False @@ -224,10 +255,11 @@ def __str__(self): @not_generated class ConcatParameters(Parameters, SensitiveToOrder): - def __init__(self, *args, axis=None, axis_hint=None, **kwargs): + def __init__(self, *args, axis=None, **kwargs): super(ConcatParameters, self).__init__(*args, **kwargs) + if axis is None: + raise ValueError("axis must be set") self._axis = axis - self._axis_hint = axis_hint @property def graph_label(self): @@ -245,6 +277,10 @@ def axis(self): def axis(self, val): self._axis = val + @property + def does_nothing(self) -> bool: + return self.in_dims and len(self.in_dims) == 1 + def get_parameter_size(self): return 0 @@ -252,9 +288,16 @@ def get_parameter_size(self): def can_equalize(self): return False + @property + def offsets(self): + return reduce( + lambda state, in_dim: ( + state[0] + [state[1]], state[1] + in_dim.shape[self.axis]), + self.in_dims, + ([], 0) + )[0] + def get_output_size(self, in_dims): - if in_dims[0].is_named and self._axis_hint: - self._axis = in_dims[0].get_order_idx(self._axis_hint) out_dim = Dim.combine([in_dim for in_dim in in_dims], self.axis) return [out_dim] @@ -281,8 +324,11 @@ def __init__(self, *args, self.axis = axis def __call__(self, *args, **kwargs): - noderef = super(SplitParameters, self).__call__(*args, **kwargs) - return tuple(NNNodeRef(self, i, noderef.ref[1]) for i in range(len(self.act_slices))) + return super().__call__(*args, num_outputs=len(self.act_slices), **kwargs) + + @property + def does_nothing(self) -> bool: + return self.out_dims and len(self.out_dims) == 1 @property def graph_label(self): @@ -308,7 +354,8 @@ def get_splits(in_shape, axis, splits=None, num_splits=None): if splits: if in_shape[axis] is not None and any(split == -1 for split in splits): rest_sz = sum(split for split in splits if split > 0) - splits = (split if split > 0 else in_shape[axis] - rest_sz for split in splits) + splits = (split if split > + 0 else in_shape[axis] - rest_sz for split in splits) for sz in splits: act_slices.append([(in_idx, in_idx + sz, 1) if idx == axis else (0, shape, 1) for idx, shape in enumerate(in_shape) @@ -392,7 +439,6 @@ def can_equalize(self): def __str__(self): return "A %s I %s" % (self.axis, self.indices) - @cls_op_name('strided_slice') class StridedSliceParameters(Parameters, SingleInputAndOutput, ComparableParameters, InsensitiveToQuantization): @@ -403,7 +449,6 @@ def __init__(self, *args, super(StridedSliceParameters, self).__init__(*args, **kwargs) self.act_slice = act_slice - self.slice_shape = tuple(int(abs(math.ceil((sl[1] - sl[0])/sl[2]))) for sl in self.act_slice) self.out_shape = tuple(out_shape) @property @@ -414,6 +459,24 @@ def graph_label(self): def graph_anon_label(self): return ['Slice'] + ["(%s,%s,%s)" % elem for elem in self.act_slice] + @property + def slice_shape(self): + return tuple( + int(abs(math.ceil((max(sl[1], -1) - max(sl[0], -1))/sl[2]))) for sl in self.act_slice) + + @property + def slices_axes(self): + in_shape = self.in_dims[0].shape + return tuple(idx for idx, shapes in enumerate(zip(self.slice_shape, in_shape)) if shapes[0] != shapes[1]) + + @property + def changes_shape(self): + return self.slice_shape != self.out_shape + + @property + def can_equalize(self): + return False + def numpy_slice(self, arr: np.ndarray): slice_spec = [slice(elem[0], elem[1], elem[2]) for elem in self.act_slice if len(elem) == 3] @@ -447,12 +510,14 @@ def only_slices(self, axis): for idx, dim in enumerate(self.in_dims[0].shape) if axis != idx) @property - def post_slice_shape(self): - return [(sl[1] - sl[0])//sl[2] for sl in self.act_slice] + def does_nothing(self) -> bool: + return self.no_model_code and not self.changes_shape @property - def changes_shape(self): - return len(self.post_slice_shape) > len(self.out_shape) + def no_model_code(self) -> bool: + if not self.in_dims: + return False + return self.slice_shape == tuple(self.in_dims[0].shape) def get_parameter_size(self): return 0 @@ -460,10 +525,6 @@ def get_parameter_size(self): def get_output_size(self, in_dims): return [Dim.unnamed(self.out_shape)] - @property - def can_equalize(self): - return False - def __str__(self): return ",".join("(%s,%s,%s)" % elem for elem in self.act_slice) @@ -675,14 +736,19 @@ def __init__(self, *args, old_shape=None, shape=None, **kwargs): @property def graph_label(self): - return [self.name, f'{self.old_shape} to {self.shape}'] + return [f'Reshape({self.name})', f'{self.old_shape} to {self.shape}'] @property def graph_anon_label(self): return ['Reshape', f'{self.old_shape} to {self.shape}'] + @property def does_nothing(self): - return self.shape.layout_shape == self.old_shape.layout_shape + return tuple(self.shape.shape) == tuple(self.old_shape.shape) + + @property + def no_model_code(self) -> bool: + return True def get_parameter_size(self): return 0 @@ -691,7 +757,7 @@ def exp_red_pattern(self): """ If the reshape is an expand or reduce dim i.e. adds or removes 1 size axes then return a pattern with True indicating an added axis, False a removed axis and None an unchanged axis""" - if not self.does_nothing(): + if not self.does_nothing: return None res = [] s1 = self._old_shape.shape.copy() @@ -781,6 +847,14 @@ def get_parameter_size(self): def can_equalize(self): return False + @property + def no_model_code(self) -> bool: + return True + + @property + def does_nothing(self) -> bool: + return True + def compute_load(self): return 0 diff --git a/tools/nntool/graph/types/rnn.py b/tools/nntool/graph/types/rnn.py index 12f0912e0..aa3a01fdb 100644 --- a/tools/nntool/graph/types/rnn.py +++ b/tools/nntool/graph/types/rnn.py @@ -18,6 +18,7 @@ from graph.dim import Dim from graph.types import (ConstantInputParameters, NNEdge, Parameters, SensitiveToOrder, SingleInputAndOutput) +from stats.ranges_utils import collect_stat from .base import cls_op_name, nargs @@ -60,6 +61,10 @@ def graph_label(self): def graph_anon_label(self): return ["Filt"] + def details_collector(self, stats, stat, details): + for k in filter(lambda x: x.startswith('range_'), details): + collect_stat(stat, k, details[k]) + def get_parameter_size(self): return 0 diff --git a/tools/nntool/graph/types/ssd.py b/tools/nntool/graph/types/ssd.py index 826b1b73c..a18fe59d4 100644 --- a/tools/nntool/graph/types/ssd.py +++ b/tools/nntool/graph/types/ssd.py @@ -17,7 +17,7 @@ from graph.dim import Dim -from .base import NNNodeRef, Parameters, SensitiveToOrder, cls_op_name, nargs +from .base import Parameters, SensitiveToOrder, cls_op_name, nargs LOG = logging.getLogger("nntool." + __name__) @@ -41,14 +41,26 @@ def __init__(self, *args, parameters=None, **kwargs): self.nms_config = {'using_json_config': {'INCLUDE': False, 'json_config_path': ''}, 'using_pipeline_config': {'INCLUDE': False, 'pipeline_config_path': ''}, 'using_params': {'INCLUDE': True, 'params': self._parameters}} + self.at_options.valid_options['NMS_SCORE_THRESHOLD'] = float + self.at_options.valid_options['NMS_IOU_THRESHOLD'] = float + self.nms_score_threshold = self._parameters['nms_score_threshold'] + self.nms_iou_threshold = self._parameters['nms_iou_threshold'] + self._output_detection_count = True def __call__(self, *args, **kwargs): - noderef = super(SSDDetectorParameters, self).__call__(*args, **kwargs) - return tuple(NNNodeRef(self, i, noderef.ref[1]) for i in range(3)) + return super().__call__(*args, num_outputs=4 if self._output_detection_count else 3, **kwargs) def get_parameter_size(self): return 0 + @property + def output_detection_count(self): + return self._output_detection_count + + @output_detection_count.setter + def output_detection_count(self, val): + self._output_detection_count = val + @property def can_equalize(self): return False @@ -69,14 +81,6 @@ def w_scale(self): def h_scale(self): return self._parameters['h_scale'] - @property - def nms_score_threshold(self): - return self._parameters['nms_score_threshold'] - - @nms_score_threshold.setter - def nms_score_threshold(self, val): - self._parameters['nms_score_threshold'] = val - @property def max_bb_before_nms(self): return self._parameters['max_bb_before_nms'] @@ -95,7 +99,19 @@ def use_exp_for_wh_decode(self, val): @property def nms_iou_threshold(self): - return self._parameters['nms_iou_threshold'] + return self.at_options.nms_iou_threshold + + @nms_iou_threshold.setter + def nms_iou_threshold(self, val): + self.at_options.nms_iou_threshold = val + + @property + def nms_score_threshold(self): + return self.at_options.nms_score_threshold + + @nms_score_threshold.setter + def nms_score_threshold(self, val): + self.at_options.nms_score_threshold = val @property def max_detections(self): @@ -108,18 +124,18 @@ def max_classes_per_detection(self): def get_output_size(self, in_dims): num_detected_boxes = self._parameters['max_detections'] * \ self._parameters['max_classes_per_detection'] - return [ - Dim(shape=[num_detected_boxes, 4], is_ordered=True), - Dim(shape=[num_detected_boxes], is_ordered=True), - Dim(shape=[num_detected_boxes], is_ordered=True), - Dim(shape=[num_detected_boxes], is_ordered=True), + outputs = [ + Dim.unnamed([num_detected_boxes, 4]), + Dim.unnamed([num_detected_boxes]), + Dim.unnamed([num_detected_boxes]), ] + if self.output_detection_count: + outputs.append(Dim.unnamed([1])) + return outputs def __str__(self): - return "{} SCORE_THR {:.2f} IOU_THR {:.2f}".format( - self.at_options, - self.nms_score_threshold, - self.nms_iou_threshold + return "{}".format( + self.at_options ) @@ -148,10 +164,13 @@ def __init__(self, *args, parameters=None, in_dims_hint=None, out_dims_hint=None self._ker_in_order = [['batch', 'spatial_dim', 'box'], [ 'batch', 'class', 'spatial_dim']] self._ker_out_order = [['spatial_dim', 'index']] + self.at_options.valid_options['NMS_SCORE_THRESHOLD'] = float + self.at_options.valid_options['NMS_IOU_THRESHOLD'] = float + self.nms_score_threshold = self._parameters['nms_score_threshold'] + self.nms_iou_threshold = self._parameters['nms_iou_threshold'] def __call__(self, *args, **kwargs): - noderef = super(NMSParameters, self).__call__(*args, **kwargs) - return tuple(NNNodeRef(self, i, noderef.ref[1]) for i in range(2)) + return super().__call__(*args, num_outputs=2, **kwargs) def get_parameter_size(self): return 0 @@ -160,17 +179,21 @@ def get_parameter_size(self): def can_equalize(self): return False + @property + def nms_iou_threshold(self): + return self.at_options.nms_iou_threshold + + @nms_iou_threshold.setter + def nms_iou_threshold(self, val): + self.at_options.nms_iou_threshold = val + @property def nms_score_threshold(self): - return self._parameters['nms_score_threshold'] + return self.at_options.nms_score_threshold @nms_score_threshold.setter def nms_score_threshold(self, val): - self._parameters['nms_score_threshold'] = val - - @property - def nms_iou_threshold(self): - return self._parameters['nms_iou_threshold'] + self.at_options.nms_score_threshold = val @property def max_output_boxes_per_class(self): @@ -192,8 +215,6 @@ def get_output_size(self, in_dims): ] def __str__(self): - return "{} SCORE_THR {:.2f} IOU_THR {:.2f}".format( - self.at_options, - self.nms_score_threshold, - self.nms_iou_threshold + return "{}".format( + self.at_options ) diff --git a/tools/nntool/graph/types/tensor_arithmetic.py b/tools/nntool/graph/types/tensor_arithmetic.py index f83ac516f..2111e7700 100644 --- a/tools/nntool/graph/types/tensor_arithmetic.py +++ b/tools/nntool/graph/types/tensor_arithmetic.py @@ -219,7 +219,7 @@ def compute_load(self): col_m1 = self.in_dims[0].shape[-1] col_m2 = self.in_dims[1].shape[-2] if isinstance(self, MatMulTransposedParameters) else self.in_dims[1].shape[-1] n_mat = np.prod(self.in_dims[1].shape[:-2]) - return n_mat * (line_m1 * col_m1 * col_m2) + return int(n_mat * (line_m1 * col_m1 * col_m2)) def get_output_size(self, in_dims): x_shape = list(in_dims[0].shape).copy() diff --git a/tools/nntool/importer/common/broadcast_mixin.py b/tools/nntool/importer/common/broadcast_mixin.py index e23c1bf8e..8a0627dd8 100644 --- a/tools/nntool/importer/common/broadcast_mixin.py +++ b/tools/nntool/importer/common/broadcast_mixin.py @@ -19,11 +19,16 @@ from .provisional_dim import ProvisionalDim +# reduces broadcasted constants on unknown dimensions. +# Setting this to false can provoke conception errors in matchers +FIX_CONSTANTS = True class BroadcastMixin(object): @classmethod - def get_broadcasted_shape(cls, x, y): + def get_broadcasted_shape(cls, x, y, is_constant=None): + if is_constant is None: + is_constant = (False, False) if len(x) < len(y): x = ([1] * (len(y) - len(x))) + x elif len(y) < len(x): @@ -34,9 +39,20 @@ def get_broadcasted_shape(cls, x, y): "{} and {} cannot be broadcasted".format(x, y) def broad(elem_x, elem_y): - if elem_x is None or elem_y is None: - return None - return elem_x if elem_y == 1 else elem_y + # if one element is not None then take it since that dimension will be broadcasted + if elem_x is None: + if elem_y is None or (FIX_CONSTANTS and is_constant[1] and elem_y == 1): + return None + else: + return elem_y + else: + if elem_y is None: + if FIX_CONSTANTS and is_constant[0] and elem_x == 1: + return None + else: + return elem_x + else: + return elem_x if elem_y == 1 else elem_y return [broad(elem_x, elem_y) for elem_x, elem_y in zip(x, y)] @classmethod @@ -62,8 +78,9 @@ def _fix_constant_inputs(cls, inputs, shape): @classmethod def implied_broadcast(cls, inputs): + is_constant = [isinstance(inp[0], ConstantInputParameters) for inp in inputs] x = inputs[0][2].shape y = inputs[1][2].shape - shape = cls.get_broadcasted_shape(x, y) + shape = cls.get_broadcasted_shape(x, y, is_constant=is_constant) cls._fix_constant_inputs(inputs, shape) return [ProvisionalDim(shape)] diff --git a/tools/nntool/importer/common/check_batchdim.py b/tools/nntool/importer/common/check_batchdim.py new file mode 100644 index 000000000..07d2dd098 --- /dev/null +++ b/tools/nntool/importer/common/check_batchdim.py @@ -0,0 +1,34 @@ +# Copyright (C) 2022 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from graph.types.base import NNEdge +from graph.types.others import ReshapeParameters +from importer.common.provisional_dim import ProvisionalDim + + +def check_batchdim(G, x, valid_name): + x_shape = x[2].shape + if x_shape[0] is not None: + if x_shape[0] != 1: + raise NotImplementedError( + f'{valid_name} pool is on more than one batch. This is not supported') + reshape = ReshapeParameters(G.unique_name(f'{valid_name}_reshape'), + old_shape=tuple(x_shape), shape=tuple(x_shape[1:])) + G.add_edge(NNEdge(from_node=x[0], from_idx=x[1], to_node=reshape)) + x_shape[0] = None + if len(x) == 3: + return (reshape, 0, ProvisionalDim(x_shape)) + return (reshape, 0, ProvisionalDim(x_shape), x[3]) + return x diff --git a/tools/nntool/importer/common/constant_mixin.py b/tools/nntool/importer/common/constant_mixin.py index ddaae71d0..8cc879542 100644 --- a/tools/nntool/importer/common/constant_mixin.py +++ b/tools/nntool/importer/common/constant_mixin.py @@ -47,3 +47,12 @@ def record_constant_qrec(cls, inp, cnode, **kwargs): if qrecs is None: return qrecs[NodeId(cnode)] = QRec.scaled(out_qs=[qtype]) + + @classmethod + def move_stat(cls, inp, new_name, **kwargs): + cnid = NodeId(new_name) + onid = NodeId(inp[0]) + qopts = kwargs.get('qopts', {}) + if onid in qopts: + qopts[cnid] = qopts[onid] + del qopts[onid] diff --git a/tools/nntool/importer/importer.py b/tools/nntool/importer/importer.py index 035c4c2f6..db57003a4 100644 --- a/tools/nntool/importer/importer.py +++ b/tools/nntool/importer/importer.py @@ -20,8 +20,8 @@ from .tflite2.tflite import NNGraph, TFLiteImporter GRAPH_IMPORTERS = { - 'onnx': {'matches':[r".*\.onnx$"], 'importer':OnnxImporter, 'loader': None}, - 'tflite': {'matches':[r".*\.tflite$"], 'importer':TFLiteImporter, 'loader': None}, + 'onnx': {'matches':[r".*\.onnx$"], 'importer':OnnxImporter}, + 'tflite': {'matches':[r".*\.tflite$"], 'importer':TFLiteImporter}, } class ImportException(Exception): @@ -51,7 +51,6 @@ def create_graph(filename: str, graph_format: str = None, opts: Mapping = None) if re.search(match, filename): importer = v['importer']() graph = importer.create_graph(filename, opts) - graph.set_load_function(v['loader']) return graph raise ValueError("Graph importer not found") diff --git a/tools/nntool/importer/onnx/common/__init__.py b/tools/nntool/importer/onnx/common/__init__.py index 834daa668..e238b949c 100644 --- a/tools/nntool/importer/onnx/common/__init__.py +++ b/tools/nntool/importer/onnx/common/__init__.py @@ -4,7 +4,20 @@ from onnx import TensorProto, mapping, helper -logger = logging.getLogger('nntool.' + __name__) +_logger = logging.getLogger('nntool.' + __name__) + +class logger: + @staticmethod + def info(*args, **kwargs): + _logger.info(*args, **kwargs) + + @staticmethod + def warning(*args, **kwargs): + _logger.warning(*args, **kwargs) + + @staticmethod + def debug(*args, **kwargs): + _logger.debug(*args, **kwargs) def get_unique_suffix(): """ Get unique suffix by using first 8 chars from uuid.uuid4 diff --git a/tools/nntool/importer/onnx/common/handler_helper.py b/tools/nntool/importer/onnx/common/handler_helper.py index 1a0102ea0..6d4723a46 100644 --- a/tools/nntool/importer/onnx/common/handler_helper.py +++ b/tools/nntool/importer/onnx/common/handler_helper.py @@ -14,12 +14,14 @@ # along with this program. If not, see . from onnx import defs +from onnx.defs import SchemaError from .. import common # pylint: disable=wildcard-import,unused-wildcard-import from ..handlers.backend import * # noqa from ..handlers.backend_handler import BackendHandler + def get_opset_status(): ops = [] onnx_ops = {} @@ -33,7 +35,8 @@ def get_opset_status(): counts_by_domain = {} for handler in BackendHandler.__subclasses__(): handler.check_cls() - counts_by_domain.setdefault(handler.DOMAIN, [0, onnx_ops.get(handler.DOMAIN, 0)]) + counts_by_domain.setdefault( + handler.DOMAIN, [0, onnx_ops.get(handler.DOMAIN, 0)]) counts_by_domain[handler.DOMAIN][0] += 1 ops.append([ handler.DOMAIN, @@ -47,6 +50,7 @@ def get_opset_status(): ]) return ops, counts_by_domain + def get_all_backend_handlers(opset_dict): """ Get a dict of all backend handler classes. e.g. {'domain': {'Abs': Abs handler class}, ...}, }. @@ -65,14 +69,16 @@ def get_all_backend_handlers(opset_dict): since_version = 1 if defs.has(handler.ONNX_OP, domain=handler.DOMAIN): try: - since_version = defs.get_schema( # @IgnoreException + since_version = defs.get_schema( #@IgnoreException handler.ONNX_OP, domain=handler.DOMAIN, max_inclusive_version=version).since_version - except RuntimeError: - common.logger.debug("Fail to get since_version of %s in domain `%s` " - "with max_inclusive_version=%s. Set to 1.", - handler.ONNX_OP, handler.DOMAIN, version) + except (SchemaError, RuntimeError): + versions = sorted([int(ver_func[len('varsion_'):]) for ver_func in dir(handler) if ver_func.startswith('version_')]) + since_version = versions[0] if versions else 1 + common.logger.debug( + f"Fail to load schema of {handler.ONNX_OP} in domain `{handler.DOMAIN}` " + f"with max_inclusive_version=version. Since version set to {since_version}.") else: common.logger.debug("Unknown op %s in domain `%s`.", handler.ONNX_OP, handler.DOMAIN or "ai.onnx") @@ -81,6 +87,7 @@ def get_all_backend_handlers(opset_dict): return handlers + def get_backend_coverage(): """ Get backend coverage for document. diff --git a/tools/nntool/importer/onnx/handlers/backend/add.py b/tools/nntool/importer/onnx/handlers/backend/add.py index 7b5dcff3a..fa67f4db9 100644 --- a/tools/nntool/importer/onnx/handlers/backend/add.py +++ b/tools/nntool/importer/onnx/handlers/backend/add.py @@ -37,3 +37,7 @@ def version_7(cls, node, **kwargs): @classmethod def version_13(cls, node, **kwargs): return cls._common(node, **kwargs) + + @classmethod + def version_14(cls, node, **kwargs): + return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/batch_normalization.py b/tools/nntool/importer/onnx/handlers/backend/batch_normalization.py index 0f01ef96a..645c72b30 100644 --- a/tools/nntool/importer/onnx/handlers/backend/batch_normalization.py +++ b/tools/nntool/importer/onnx/handlers/backend/batch_normalization.py @@ -95,7 +95,8 @@ def _common(cls, node, **kwargs): params = BatchNormalizationParameters(valid_name, scale=bn_scale, bias=bn_bias, running_mean=running_mean, running_variance=running_variance, spatial=spatial, - momentum=momentum, epsilon=epsilon) + momentum=momentum, epsilon=epsilon, + axis=0) G.add_edge(NNEdge(from_node=x[0], to_node=params, from_idx=x[1], to_idx=0)) all_nodes[node.output[0]] = (params, 0, deepcopy(x[2]), None) return params @@ -115,3 +116,11 @@ def version_7(cls, node, **kwargs): @classmethod def version_9(cls, node, **kwargs): return cls._common(node, **kwargs) + + @classmethod + def version_14(cls, node, **kwargs): + return cls._common(node, **kwargs) + + @classmethod + def version_15(cls, node, **kwargs): + return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/concat_from_sequence.py b/tools/nntool/importer/onnx/handlers/backend/concat_from_sequence.py index 0b4654fdc..bfab732c8 100644 --- a/tools/nntool/importer/onnx/handlers/backend/concat_from_sequence.py +++ b/tools/nntool/importer/onnx/handlers/backend/concat_from_sequence.py @@ -71,11 +71,3 @@ def _common(cls, node, **kwargs): @classmethod def version_11(cls, node, **kwargs): return cls._common(node, **kwargs) - - @classmethod - def version_9(cls, node, **kwargs): - return cls._common(node, **kwargs) - - @classmethod - def version_1(cls, node, **kwargs): - return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/concat_mixin.py b/tools/nntool/importer/onnx/handlers/backend/concat_mixin.py index a5a658467..0663e06c4 100644 --- a/tools/nntool/importer/onnx/handlers/backend/concat_mixin.py +++ b/tools/nntool/importer/onnx/handlers/backend/concat_mixin.py @@ -32,7 +32,7 @@ def gen_concat(cls, node, inputs, axis, **kwargs): all_nodes = kwargs['all_nodes'] G = kwargs['G'] valid_name = kwargs['valid_name'] - inputs = [all_nodes[inp] for inp in node.input] + inputs = [all_nodes[inp] for inp in node.input if all_nodes[inp][2].shape] input_shapes = [inp[2].shape for inp in inputs] axis_sum = sum(shape[axis] for shape in input_shapes) axis = axis if axis >= 0 else len(input_shapes[0]) + axis diff --git a/tools/nntool/importer/onnx/handlers/backend/conv_mixin.py b/tools/nntool/importer/onnx/handlers/backend/conv_mixin.py index ce52ae936..920394d11 100644 --- a/tools/nntool/importer/onnx/handlers/backend/conv_mixin.py +++ b/tools/nntool/importer/onnx/handlers/backend/conv_mixin.py @@ -17,6 +17,7 @@ from copy import deepcopy import numpy as np +from sklearn.utils import resample from graph.dim import Conv2DFilterDim, DilationDim, Dim, StrideDim from graph.types import (ConstantInputParameters, Conv2DParameters, NNEdge, ReshapeParameters) @@ -86,7 +87,9 @@ def conv(cls, node, quantized=False, **kwargs): # M x C/group x kH x kW weights_idx = 3 if quantized else 1 weights_node = inputs[weights_idx][0] - weights_node.name = f'{valid_name}_weights' + new_name = f'{valid_name}_weights' + cls.move_stat(inputs[weights_idx], new_name, **kwargs) + weights_node.name = new_name weights = cls.get_constant(inputs[weights_idx]) out_c = weights.shape[0] group = node.attrs.get("group", 1) @@ -176,14 +179,15 @@ def conv(cls, node, quantized=False, **kwargs): x_qtype = QType(dtype=x_zp.dtype, scale=x_scale, zero_point=x_zp) w_zp = cls.get_constant(inputs[5]) w_scale = cls.get_constant(inputs[4]) + quantized_dimension = 0 if len(w_scale) > 1 else None weights_node.qtype = w_qtype = QType( dtype=w_zp.dtype, scale=w_scale, - zero_point=w_zp, quantized_dimension=0 if len(w_scale) > 1 else None) + zero_point=w_zp, quantized_dimension=quantized_dimension) o_zp = cls.get_constant(inputs[7]) o_scale = cls.get_constant(inputs[6]) o_qtype = QType(dtype=o_zp.dtype, scale=o_scale, zero_point=o_zp) biases_node.qtype = b_qtype = QType( - dtype=biases.dtype, scale=w_scale*x_scale) + dtype=biases.dtype, scale=w_scale*x_scale, quantized_dimension=quantized_dimension) qrecs[NodeId(params)] = QRec.scaled( in_qs=[x_qtype, w_qtype, b_qtype], out_qs=[o_qtype], @@ -202,6 +206,11 @@ def conv(cls, node, quantized=False, **kwargs): # check if input needs a reshape if conv_in_shape != real_in_shape: + # if batch is present add it back + if batch is not None: + conv_in_shape = (batch,) + conv_in_shape + if np.prod(real_in_shape) != np.prod(conv_in_shape): + raise ValueError(f'shape inference issue {valid_name} filter indicates {conv_in_shape} but has an input of {real_in_shape}') r1_params = ReshapeParameters(f'{valid_name}_reshape_in', old_shape=Dim.unnamed(real_in_shape), shape=Dim.unnamed(conv_in_shape)) diff --git a/tools/nntool/importer/onnx/handlers/backend/conv_transpose.py b/tools/nntool/importer/onnx/handlers/backend/conv_transpose.py index cddd73fb2..17bd0f764 100644 --- a/tools/nntool/importer/onnx/handlers/backend/conv_transpose.py +++ b/tools/nntool/importer/onnx/handlers/backend/conv_transpose.py @@ -120,7 +120,7 @@ def _common(cls, node, **kwargs): dims=Dim.unnamed( biases.shape)) - padding, dilations, strides, output_padding = cls.calc_shapes(node, spatial_size, Dim2D((h, w)), Dim2D((filt_h, filt_w))) + padding, dilations, strides, output_padding = cls.calc_shapes(node, spatial_size, Dim2D(h, w), Dim2D(filt_h, filt_w)) params = TransposeConv2DParameters(valid_name, filt=filt_dim, diff --git a/tools/nntool/importer/onnx/handlers/backend/div.py b/tools/nntool/importer/onnx/handlers/backend/div.py index 39c9bc963..c668dd043 100644 --- a/tools/nntool/importer/onnx/handlers/backend/div.py +++ b/tools/nntool/importer/onnx/handlers/backend/div.py @@ -38,3 +38,7 @@ def version_7(cls, node, **kwargs): @classmethod def version_13(cls, node, **kwargs): return cls._common(node, **kwargs) + + @classmethod + def version_14(cls, node, **kwargs): + return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/equal.py b/tools/nntool/importer/onnx/handlers/backend/equal.py new file mode 100644 index 000000000..fcbaabbeb --- /dev/null +++ b/tools/nntool/importer/onnx/handlers/backend/equal.py @@ -0,0 +1,60 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +from graph.dim import Dim +from graph.types import ConstantInputParameters +from importer.common.constant_mixin import ConstantMixin +from importer.common.provisional_dim import ProvisionalDim + +from ..backend_handler import BackendHandler +from ..handler import onnx_op + + +@onnx_op("Equal") +class Equal(ConstantMixin, BackendHandler): + + @classmethod + def _common(cls, node, **kwargs): + all_nodes = kwargs['all_nodes'] + G = kwargs['G'] + valid_name = kwargs['valid_name'] + inputs = [all_nodes[inp] for inp in node.input] + x = inputs[0] + x_shape = x[2].shape + if all(cls.is_constant(inp) for inp in inputs): + a = cls.get_constant(inputs[0]) + b = cls.get_constant(inputs[1]) + params = ConstantInputParameters(valid_name, dims=Dim.unnamed(a.shape), value=(a==b)) + else: + raise ValueError("ONNX Equal operator is not implemented") + all_nodes[node.output[0]] = (params, 0, ProvisionalDim(x_shape), None) + return params + + @classmethod + def version_1(cls, node, **kwargs): + return cls._common(node, **kwargs) + + @classmethod + def version_7(cls, node, **kwargs): + return cls._common(node, **kwargs) + + @classmethod + def version_11(cls, node, **kwargs): + return cls._common(node, **kwargs) + + @classmethod + def version_13(cls, node, **kwargs): + return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/expand.py b/tools/nntool/importer/onnx/handlers/backend/expand.py index dd83c73c4..fa7026a8f 100644 --- a/tools/nntool/importer/onnx/handlers/backend/expand.py +++ b/tools/nntool/importer/onnx/handlers/backend/expand.py @@ -17,10 +17,11 @@ from graph.types import ConstantInputParameters, ExpandParameters from graph.types.base import NNEdge from importer.common.constant_mixin import ConstantMixin +from importer.common.provisional_dim import ProvisionalDim from importer.onnx.common import logger from ..backend_handler import BackendHandler -from ..handler import onnx_op, constant_only +from ..handler import constant_only, onnx_op from .broadcast_mixin import BroadcastMixin @@ -38,7 +39,6 @@ def _common(cls, node, **kwargs): y = inputs[1] shape = cls.get_constant(y) - pshape = cls.broadcast_to(x, shape) if cls.is_constant(x): logger.info("reducing %s to a constant", valid_name) x_val = cls.get_constant(x) @@ -47,7 +47,7 @@ def _common(cls, node, **kwargs): params = ExpandParameters(valid_name, shape=shape) G.add_edge(NNEdge(x[0], params, from_idx=x[1])) - all_nodes[node.output[0]] = (params, 0, pshape, x[3]) + all_nodes[node.output[0]] = (params, 0, ProvisionalDim(shape), x[3]) return params @classmethod diff --git a/tools/nntool/importer/onnx/handlers/backend/gather.py b/tools/nntool/importer/onnx/handlers/backend/gather.py index 1a2761e3d..b86f44828 100644 --- a/tools/nntool/importer/onnx/handlers/backend/gather.py +++ b/tools/nntool/importer/onnx/handlers/backend/gather.py @@ -13,13 +13,14 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import copy -from graph.types.others import StridedSliceParameters + import numpy as np from graph.types import ConstantInputParameters, GatherParameters, NNEdge +from graph.types.others import ReshapeParameters, StridedSliceParameters from importer.common.constant_mixin import ConstantMixin from importer.common.provisional_dim import ProvisionalDim from importer.onnx.common import logger +from utils.numpy_helpers import np_asscalar from ..backend_handler import BackendHandler from ..handler import onnx_op @@ -37,24 +38,42 @@ def _common(cls, node, **kwargs): x = inputs[0] x_shape = x[2].shape y = inputs[1] + y_shape = y[2].shape indices = cls.get_constant(y) axis = node.attrs.get('axis', 0) - pshape = ProvisionalDim(x_shape[:axis:] + list(indices.shape) + x_shape[axis + 1:]) + if not y_shape: + pshape = ProvisionalDim( + x_shape[:axis:] + x_shape[axis + 1:]) + else: + pshape = ProvisionalDim( + x_shape[:axis:] + list(indices.shape) + x_shape[axis + 1:]) if cls.is_constant(x): x_val = cls.get_constant(x) - logger.info(f"reducing {valid_name} to a constant {cls.print_small(x_val)}") - params = ConstantInputParameters(valid_name, value=np.take(x_val, indices, axis=axis)) + logger.info( + f"reducing {valid_name} to a constant {cls.print_small(x_val)}") + params = ConstantInputParameters(valid_name, value=np.take( + x_val, indices.astype(np.int64), axis=axis)) else: if np.ndim(indices) <= 1: - idx = np.asscalar(indices) - act_slice = tuple([(0, dim, 1) if i != axis else (idx, idx+1, 1) for i, dim in enumerate(x_shape) if dim is not None]) + idx = np_asscalar(indices) + act_slice = tuple([(0, dim, 1) if i != axis else ( + idx, idx+1, 1) for i, dim in enumerate(x_shape) if dim is not None]) out_shape = pshape.known_shape.copy() - params = StridedSliceParameters(valid_name, act_slice=act_slice, out_shape=out_shape) + params = StridedSliceParameters( + valid_name, act_slice=act_slice, out_shape=out_shape) + if params.slice_shape == tuple(x[2].known_shape): + if np.ndim(indices) == 0 and pshape.shape[idx] is not None: + del out_shape[idx] + pshape = ProvisionalDim(out_shape) + params = ReshapeParameters(valid_name, old_shape=tuple( + x[2].known_shape), shape=out_shape) else: axis = cls._trim_axis(axis, x_shape) - params = GatherParameters(valid_name, axis=axis, indices=indices) - G.add_edge(NNEdge(from_node=x[0], to_node=params, from_idx=x[1], to_idx=0)) + params = GatherParameters( + valid_name, axis=axis, indices=indices) + G.add_edge( + NNEdge(from_node=x[0], to_node=params, from_idx=x[1], to_idx=0)) all_nodes[node.output[0]] = (params, 0, pshape, x[3]) return params diff --git a/tools/nntool/importer/onnx/handlers/backend/gru.py b/tools/nntool/importer/onnx/handlers/backend/gru.py index 6e6bb8c2d..72625db7b 100644 --- a/tools/nntool/importer/onnx/handlers/backend/gru.py +++ b/tools/nntool/importer/onnx/handlers/backend/gru.py @@ -94,3 +94,7 @@ def version_3(cls, node, **kwargs): @classmethod def version_7(cls, node, **kwargs): return cls._common(node, **kwargs) + + @classmethod + def version_14(cls, node, **kwargs): + return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/hard_sigmoid.py b/tools/nntool/importer/onnx/handlers/backend/hard_sigmoid.py index f16113e18..171a10936 100644 --- a/tools/nntool/importer/onnx/handlers/backend/hard_sigmoid.py +++ b/tools/nntool/importer/onnx/handlers/backend/hard_sigmoid.py @@ -27,9 +27,17 @@ class Sigmoid(BasicMathMixin, BackendHandler): @classmethod def _common(cls, node, **kwargs): + alpha = node.attrs.get('alpha', 0.2) + beta = node.attrs.get('beta', 0.5) + params_args = { + 'offset': beta/alpha, + 'upper_bound': 1/alpha, + 'mult': alpha + } return super(Sigmoid, cls)._common(node, params_class=HSigmoidActivationParameters, - constant_operation=lambda x: np.maximum(0, np.minimum(1, 0.2 * x + 0.5)), + params_args=params_args, + constant_operation=lambda x: np.maximum(0, np.minimum(1, alpha * x + beta)), **kwargs) @classmethod diff --git a/tools/nntool/importer/onnx/handlers/backend/lstm.py b/tools/nntool/importer/onnx/handlers/backend/lstm.py index c043fd030..230aa0835 100644 --- a/tools/nntool/importer/onnx/handlers/backend/lstm.py +++ b/tools/nntool/importer/onnx/handlers/backend/lstm.py @@ -81,3 +81,7 @@ def version_1(cls, node, **kwargs): @classmethod def version_7(cls, node, **kwargs): return cls._common(node, **kwargs) + + @classmethod + def version_14(cls, node, **kwargs): + return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/mat_mul_mixin.py b/tools/nntool/importer/onnx/handlers/backend/mat_mul_mixin.py index 72c18169e..3324a1da2 100644 --- a/tools/nntool/importer/onnx/handlers/backend/mat_mul_mixin.py +++ b/tools/nntool/importer/onnx/handlers/backend/mat_mul_mixin.py @@ -101,8 +101,8 @@ def _handle(cls, node, quantized=False, **kwargs): NNEdge(from_node=y[0], to_node=trans2, from_idx=y[1], to_idx=0)) G.add_edge( NNEdge(from_node=trans2, to_node=params, from_idx=0, to_idx=1)) - biases_params = ConstantInputParameters(f'{valid_name}_biases', dims=Dim.unnamed([out_dims[0].shape[1]]), - value=np.zeros((out_dims[0].shape[1]), dtype=np.float32)) + biases_params = ConstantInputParameters(f'{valid_name}_biases', dims=Dim.unnamed([out_dims[0].shape[-1]]), + value=np.zeros((out_dims[0].shape[-1]), dtype=np.float32)) G.add_edge(NNEdge(from_node=biases_params, to_node=params, to_idx=2)) diff --git a/tools/nntool/importer/onnx/handlers/backend/mul.py b/tools/nntool/importer/onnx/handlers/backend/mul.py index da171f978..6c8f7f1d4 100644 --- a/tools/nntool/importer/onnx/handlers/backend/mul.py +++ b/tools/nntool/importer/onnx/handlers/backend/mul.py @@ -36,3 +36,7 @@ def version_7(cls, node, **kwargs): @classmethod def version_13(cls, node, **kwargs): return cls._common(node, **kwargs) + + @classmethod + def version_14(cls, node, **kwargs): + return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/nncf_fake_quantize.py b/tools/nntool/importer/onnx/handlers/backend/nncf_fake_quantize.py index ff395a6c3..9d322f005 100644 --- a/tools/nntool/importer/onnx/handlers/backend/nncf_fake_quantize.py +++ b/tools/nntool/importer/onnx/handlers/backend/nncf_fake_quantize.py @@ -18,6 +18,7 @@ import numpy as np from importer.common.constant_mixin import ConstantMixin from quantization.qtype import QType +from utils.node_id import NodeId from ..backend_handler import BackendHandler from ..handler import domain, onnx_op @@ -38,8 +39,7 @@ def _common(cls, node, **kwargs): if auto_broadcast != 'numpy': raise ValueError(f'{valid_name} - only numpy is supported for auto_broadcast') - qstats = kwargs.get('quant_stats', {}) - qopts = kwargs.get('quant_opts', {}) + qopts = kwargs.get('qopts', {}) x = inputs[0] # input_low = inputs[1] # input_high = inputs[2] @@ -54,6 +54,7 @@ def _common(cls, node, **kwargs): raise ValueError(f"{valid_name} - don't know how to handle more than {math.pow(2, 16)} levels") bits = int(math.log2(levels)) + qopts.setdefault(NodeId(x[0]), {'output_size': [None] * (x[1] + 1)})['output_size'][x[1]] = bits low_shape = output_low.shape high_shape = output_high.shape bc_dims_low = sum(1 for dim in high_shape if dim > 1) diff --git a/tools/nntool/importer/onnx/handlers/backend/pool_mixin.py b/tools/nntool/importer/onnx/handlers/backend/pool_mixin.py index 93b977116..69544b786 100644 --- a/tools/nntool/importer/onnx/handlers/backend/pool_mixin.py +++ b/tools/nntool/importer/onnx/handlers/backend/pool_mixin.py @@ -17,8 +17,8 @@ from graph.types import GlobalPoolingParameters, PoolingParameters from graph.types.base import NNEdge from importer.common.provisional_dim import ProvisionalDim +from importer.common.check_batchdim import check_batchdim -from ..handler import partial_support, ps_description from .pad_mixin import PadMixin @@ -31,6 +31,7 @@ def pool(cls, node, pool_type=None, copy_qtype=False, **kwargs): valid_name = kwargs['valid_name'] inputs = [all_nodes[inp] for inp in node.input] x = inputs[0] + x = check_batchdim(G, x, valid_name) x_shape = x[2].shape x_feature_shape = x_shape[2::] input_rank = len(x_feature_shape) diff --git a/tools/nntool/importer/onnx/handlers/backend/range.py b/tools/nntool/importer/onnx/handlers/backend/range.py new file mode 100644 index 000000000..242544e0f --- /dev/null +++ b/tools/nntool/importer/onnx/handlers/backend/range.py @@ -0,0 +1,47 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import numpy as np +from graph.types import ConstantInputParameters +from importer.common.constant_mixin import ConstantMixin +from importer.common.provisional_dim import ProvisionalDim + +from ..backend_handler import BackendHandler +from ..handler import constant_only, onnx_op + + +@onnx_op("Range") +@constant_only(True) +class Range(BackendHandler, ConstantMixin): + + @classmethod + def _common(cls, node, **kwargs): + all_nodes = kwargs['all_nodes'] + G = kwargs['G'] + valid_name = kwargs['valid_name'] + value = node.attrs.get('value', 0) + inputs = [all_nodes[inp] if inp else None for inp in node.input] + if len(inputs) != 3: + raise ValueError(f'Range {valid_name} does not have 3 inputs') + start, limit, delta = [cls.get_constant(x) for x in inputs] + value = np.arange(start, limit, delta, dtype=start.dtype) + params = ConstantInputParameters(valid_name, + value=value) + all_nodes[node.output[0]] = (params, 0, ProvisionalDim(value.shape), None) + return params + + @classmethod + def version_11(cls, node, **kwargs): + return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/reducer_mixin.py b/tools/nntool/importer/onnx/handlers/backend/reducer_mixin.py index 1d126bda0..945fed447 100644 --- a/tools/nntool/importer/onnx/handlers/backend/reducer_mixin.py +++ b/tools/nntool/importer/onnx/handlers/backend/reducer_mixin.py @@ -13,6 +13,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from functools import reduce + from graph.dim import Dim from graph.types import (ConstantInputParameters, GlobalPoolingParameters, NNEdge, NoOPParameters) @@ -20,6 +22,15 @@ from importer.common.provisional_dim import ProvisionalDim from importer.onnx.common import logger +def axis_reduction(shape, axes): + def reduction(state, idx_dim): + idx, dim = idx_dim + if dim is None: + return state[0], state[1] + if idx in axes: + return state[0] + 1, state[1] + [state[0]] + return state[0] + 1, state[1] + return tuple(reduce(reduction, enumerate(shape), (0,[]))[1]) class ReducerMixin(ConstantMixin): @classmethod @@ -43,8 +54,7 @@ def _common(cls, node, copy_qtype=False, constant_operation=None, **kwargs): x_rank for axis in axes), "axis out of bounds" keep_dims = node.attrs.get('keepdims', 1) - stripped_axes = [axis for axis in axes if x_shape[axis] is not None] - + stripped_axes = axis_reduction(x_shape, axes) if not stripped_axes: params = NoOPParameters(valid_name) pout_shape = x_shape.copy() @@ -57,22 +67,16 @@ def _common(cls, node, copy_qtype=False, constant_operation=None, **kwargs): else: pout_shape = [dim for idx, dim in enumerate( x_shape) if idx not in axes] - # if all(dim is None for dim in pout_shape): - # pout_shape.append(1) - # subtract 1 from axis for all None's preceeding it and remove - # axes that are not defined - axes = [ax - sum([1 if dim is None else 0 for dim in x_shape[:ax:]]) - for ax in stripped_axes] if cls.is_constant(x) and constant_operation: - val = constant_operation(cls.get_constant(x), axis=tuple(axes), keepdims=keep_dims) + val = constant_operation(cls.get_constant(x), axis=stripped_axes, keepdims=keep_dims) if val.size < 10: logger.info("reducing %s to a constant %s", valid_name, val) else: logger.info("reducing %s to a constant", valid_name) params = ConstantInputParameters(valid_name, value=val, dims=Dim.unnamed(val.shape)) else: - params = GlobalPoolingParameters(valid_name, pool_type=reduce_type, axis=tuple(axes), + params = GlobalPoolingParameters(valid_name, pool_type=reduce_type, axis=stripped_axes, keep_dims=keep_dims) G.add_edge( diff --git a/tools/nntool/importer/onnx/handlers/backend/relu.py b/tools/nntool/importer/onnx/handlers/backend/relu.py index 432208acc..626460a54 100644 --- a/tools/nntool/importer/onnx/handlers/backend/relu.py +++ b/tools/nntool/importer/onnx/handlers/backend/relu.py @@ -42,3 +42,7 @@ def version_6(cls, node, **kwargs): @classmethod def version_13(cls, node, **kwargs): return cls._common(node, **kwargs) + + @classmethod + def version_14(cls, node, **kwargs): + return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/reshape.py b/tools/nntool/importer/onnx/handlers/backend/reshape.py index d5f0dda54..ab930b296 100644 --- a/tools/nntool/importer/onnx/handlers/backend/reshape.py +++ b/tools/nntool/importer/onnx/handlers/backend/reshape.py @@ -111,3 +111,7 @@ def version_5(cls, node, **kwargs): @classmethod def version_13(cls, node, **kwargs): return cls._common(node, **kwargs) + + @classmethod + def version_14(cls, node, **kwargs): + return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/resize.py b/tools/nntool/importer/onnx/handlers/backend/resize.py index f5545d46a..0b3d42eda 100644 --- a/tools/nntool/importer/onnx/handlers/backend/resize.py +++ b/tools/nntool/importer/onnx/handlers/backend/resize.py @@ -14,8 +14,10 @@ # along with this program. If not, see . import numpy as np +from pytest import param from graph.dim import Dim from graph.types import NNEdge, ReshapeParameters +from graph.types.constant_input import ConstantInputParameters from graph.types.resizers import (BilinearResizerParameters, NearestNeighborResizerParameters) from importer.common.constant_mixin import ConstantMixin @@ -51,6 +53,13 @@ def _common(cls, node, scales, sizes, nearest_mode='round_prefer_ceil', **kwargs else: sizes = [None if x_shape[idx] is None else dim for idx, dim in enumerate(sizes)] + + if np.prod([sz for sz in sizes if sz is not None]) == 0: + logger.warn(f'{valid_name} has null output shape') + params = ConstantInputParameters(valid_name, value=np.array([])) + all_nodes[node.output[0]] = (params, 0, ProvisionalDim([]), x[3]) + return params + if spatial_size == 1: sizes.insert(-1, 1) diff --git a/tools/nntool/importer/onnx/handlers/backend/rnn.py b/tools/nntool/importer/onnx/handlers/backend/rnn.py index ce22a6340..a871f2719 100644 --- a/tools/nntool/importer/onnx/handlers/backend/rnn.py +++ b/tools/nntool/importer/onnx/handlers/backend/rnn.py @@ -80,3 +80,7 @@ def version_1(cls, node, **kwargs): @classmethod def version_7(cls, node, **kwargs): return cls._common(node, **kwargs) + + @classmethod + def version_14(cls, node, **kwargs): + return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/rnn_mixin.py b/tools/nntool/importer/onnx/handlers/backend/rnn_mixin.py index 6f8a17329..eac9090bc 100644 --- a/tools/nntool/importer/onnx/handlers/backend/rnn_mixin.py +++ b/tools/nntool/importer/onnx/handlers/backend/rnn_mixin.py @@ -121,6 +121,13 @@ def attach_rnn(G, x, rnn_params_class, extra_args, valid_name, tensors, t = tensors['forward' if i == 0 else 'backward'] for idx, name in enumerate(rnn_params.INPUT_NAMES): if name == 'input': + # x_shape = x[2].shape + # new_shape = [x_shape[0] if x_shape[0] is not None else 1, x_shape[-1]] + # reshape_param = ReshapeParameters(f"{valid_name}_reshape", old_shape=x_shape, shape=new_shape) + # G.add_edge( + # NNEdge(from_node=x[0], to_node=reshape_param, from_idx=x[1], to_idx=0)) + # G.add_edge( + # NNEdge(from_node=reshape_param, to_node=rnn_params, from_idx=0, to_idx=0)) G.add_edge( NNEdge(from_node=x[0], to_node=rnn_params, from_idx=x[1], to_idx=0)) continue diff --git a/tools/nntool/importer/onnx/handlers/backend/scatternd.py b/tools/nntool/importer/onnx/handlers/backend/scatternd.py new file mode 100644 index 000000000..9e3b6b3a0 --- /dev/null +++ b/tools/nntool/importer/onnx/handlers/backend/scatternd.py @@ -0,0 +1,83 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import numpy as np +from graph.types import ConstantInputParameters, NNEdge +from graph.types.others import ScatterNdParameters +from importer.common.constant_mixin import ConstantMixin +from importer.common.provisional_dim import ProvisionalDim +from importer.onnx.common import logger + +from ..backend_handler import BackendHandler +from ..handler import onnx_op, partial_support, ps_description + +def scatter_nd_impl(data, indices, updates, reduction='none'): + # Check tensor shapes + assert indices.shape[-1] <= len(data.shape) + assert updates.shape == indices.shape[:-1] + data.shape[indices.shape[-1]:] + + # Compute output + output = np.copy(data) + for i in np.ndindex(indices.shape[:-1]): + if reduction == 'add': + output[indices[i]] += updates[i] + elif reduction == 'mul': + output[indices[i]] *= updates[i] + else: + output[indices[i]] = updates[i] + return output + +@onnx_op("ScatterND") +@partial_support(True) +@ps_description('ScatterND is only supported at input and is not supported by nntool or autotiler kernels') +class ScatterND(ConstantMixin, BackendHandler): + + @classmethod + def _common(cls, node, **kwargs): + all_nodes = kwargs['all_nodes'] + G = kwargs['G'] + valid_name = kwargs['valid_name'] + inputs = [all_nodes[inp] for inp in node.input] + x = inputs[0] + x_shape = x[2].shape + indices = cls.get_constant(inputs[1]) + updates = inputs[2] + reduction = node.attrs.get('reduction', None) + + pshape = ProvisionalDim(x_shape) + if cls.is_constant(x) and cls.is_constant(updates): + logger.info("reducing %s to a constant", valid_name) + x_val = cls.get_constant(x) + updates_val = cls.get_constant(updates) + params = ConstantInputParameters(valid_name, value=scatter_nd_impl(x_val, indices, updates_val, reduction=reduction)) + else: + logger.warning(f'{valid_name} ScatterND is not currently supported in the nntool or Autotiler kernels') + params = ScatterNdParameters(valid_name, indices=indices, updates=updates, reduction=reduction) + G.add_edge(NNEdge(from_node=x[0], to_node=params, from_idx=x[1], to_idx=0)) + G.add_edge(NNEdge(from_node=updates[0], to_node=params, from_idx=updates[1], to_idx=1)) + all_nodes[node.output[0]] = (params, 0, pshape, x[3]) + return params + + @classmethod + def version_11(cls, node, **kwargs): + return cls._common(node, **kwargs) + + @classmethod + def version_13(cls, node, **kwargs): + return cls._common(node, **kwargs) + + @classmethod + def version_16(cls, node, **kwargs): + return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/sub.py b/tools/nntool/importer/onnx/handlers/backend/sub.py index 866db635c..a290997c3 100644 --- a/tools/nntool/importer/onnx/handlers/backend/sub.py +++ b/tools/nntool/importer/onnx/handlers/backend/sub.py @@ -35,3 +35,7 @@ def version_7(cls, node, **kwargs): @classmethod def version_13(cls, node, **kwargs): return cls._common(node, **kwargs) + + @classmethod + def version_14(cls, node, **kwargs): + return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/thresholded_relu.py b/tools/nntool/importer/onnx/handlers/backend/thresholded_relu.py new file mode 100644 index 000000000..b23f6f5f5 --- /dev/null +++ b/tools/nntool/importer/onnx/handlers/backend/thresholded_relu.py @@ -0,0 +1,40 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +# TODO - This is not mappable onto our current kernels. To add if needed by a customer + +# import numpy as np +# from graph.types.activations import ReluActivationParameters +# from importer.onnx.handlers.backend.math_mixin import BasicMathMixin + +# from ..backend_handler import BackendHandler +# from ..handler import onnx_op + + +# @onnx_op("ThresholdedRelu") +# class ThresholdedRelu(BasicMathMixin, BackendHandler): + +# @classmethod +# def _common(cls, node, **kwargs): +# alpha = node.attrs.get('alpha', 1.0) +# return super(ThresholdedRelu, cls)._common(node, +# params_class=ReluActivationParameters, +# constant_operation=lambda x: np.clip(x, alpha, np.inf), +# params_args={'lower_limit': alpha}, +# **kwargs) + +# @classmethod +# def version_10(cls, node, **kwargs): +# return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/unsqueeze.py b/tools/nntool/importer/onnx/handlers/backend/unsqueeze.py index 3314062eb..9cbc10f71 100644 --- a/tools/nntool/importer/onnx/handlers/backend/unsqueeze.py +++ b/tools/nntool/importer/onnx/handlers/backend/unsqueeze.py @@ -36,7 +36,7 @@ def _common(cls, node, **kwargs): out_rank = len(x_shape) + len(kwargs['axes']) axes = cls._resolve_negative_ranks(kwargs['axes'], out_rank) - old_shape = x_shape.copy() + old_shape = list(x_shape) new_shape = [1 if new_idx in axes else old_shape.pop(0) for new_idx in range(out_rank)] diff --git a/tools/nntool/importer/onnx/handlers/backend/upsample.py b/tools/nntool/importer/onnx/handlers/backend/upsample.py new file mode 100644 index 000000000..048a620c4 --- /dev/null +++ b/tools/nntool/importer/onnx/handlers/backend/upsample.py @@ -0,0 +1,117 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import numpy as np +from graph.dim import Dim +from graph.types import NNEdge, ReshapeParameters +from graph.types.constant_input import ConstantInputParameters +from graph.types.resizers import (BilinearResizerParameters, + NearestNeighborResizerParameters) +from importer.common.constant_mixin import ConstantMixin +from importer.common.provisional_dim import ProvisionalDim +from importer.onnx.common import logger +from pytest import param + +from ..backend_handler import BackendHandler +from ..handler import onnx_op + + +@onnx_op("Upsample") +class Upsample(ConstantMixin, BackendHandler): + + @classmethod + def _common(cls, node, inputs, scales, **kwargs): + all_nodes = kwargs['all_nodes'] + G = kwargs['G'] + valid_name = kwargs['valid_name'] + x = inputs[0] + x_shape = x[2].shape + x_rank = len(x_shape) + + mode = node.attrs.get('mode', 'nearest') + + spatial_size = x_rank - 2 + in_c = x_shape[1] + in_w = x_shape[-1] + sizes = [int(shape * scale) if shape is not None else None + for shape, scale in zip(x_shape, scales)] + + if np.prod([sz for sz in sizes if sz is not None]) == 0: + logger.warn(f'{valid_name} has null output shape') + params = ConstantInputParameters(valid_name, value=np.array([])) + all_nodes[node.output[0]] = (params, 0, ProvisionalDim([]), x[3]) + return params + + if spatial_size == 1: + sizes.insert(-1, 1) + + if spatial_size != 2 and spatial_size != 1: + raise ValueError('resize only supports 4D tensor in NCHW mode or 3D tensor in NCF mode' + f' - input shape is {x_shape} sizes is {sizes}') + + if not all(x_dim == size_dim for x_dim, size_dim in zip(x_shape[:2:], sizes[:2:])): + raise ValueError('resize only supports 4D tensor in NCHW mode or 3D tensor in NCF mode' + f' - input shape is {x_shape} sizes is {sizes}') + + params_class = BilinearResizerParameters if mode == 'linear' else NearestNeighborResizerParameters + + params = params_class(valid_name, + new_shape=tuple(sizes[2::]), + align_corners=False, + halfpixel_centers=False, + in_dims_hint=[['c', 'h', 'w']], + out_dims_hint=[['c', 'h', 'w']]) + + if spatial_size == 1: + r1_params = ReshapeParameters(f'{valid_name}_reshape2d', + old_shape=Dim.unnamed([in_c, in_w]), + shape=Dim.unnamed([in_c, 1, in_w])) + r2_params = ReshapeParameters(f'{valid_name}_reshape1d', + old_shape=Dim.unnamed( + [in_c, 1, sizes[-1]]), + shape=Dim.unnamed([in_c, sizes[-1]])) + G.add_edge( + NNEdge(from_node=x[0], to_node=r1_params, from_idx=x[1], to_idx=0)) + G.add_edge(NNEdge(from_node=r1_params, + to_node=params, from_idx=0, to_idx=0)) + G.add_edge(NNEdge(from_node=params, + to_node=r2_params, from_idx=0, to_idx=0)) + pout_dims = ProvisionalDim(sizes[:-2:] + sizes[-1::]) + params = r2_params + else: + pout_dims = ProvisionalDim(sizes) + G.add_edge( + NNEdge(from_node=x[0], to_node=params, from_idx=x[1], to_idx=0)) + + all_nodes[node.output[0]] = (params, 0, pout_dims, x[3]) + return params + + @classmethod + def version_7(cls, node, **kwargs): + all_nodes = kwargs['all_nodes'] + inputs = [all_nodes[inp] if inp else None for inp in node.input] + scales = node.attrs['scales'] + return cls._common(node, inputs, scales, **kwargs) + + @classmethod + def version_9(cls, node, **kwargs): + all_nodes = kwargs['all_nodes'] + inputs = [all_nodes[inp] if inp else None for inp in node.input] + scales = cls.get_constant(inputs[1]) + return cls._common(node, inputs, scales, **kwargs) + + @classmethod + def version_10(cls, node, **kwargs): + return cls.version_9(node, **kwargs) diff --git a/tools/nntool/importer/onnx/handlers/backend/where.py b/tools/nntool/importer/onnx/handlers/backend/where.py new file mode 100644 index 000000000..e7abcc53b --- /dev/null +++ b/tools/nntool/importer/onnx/handlers/backend/where.py @@ -0,0 +1,53 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import numpy as np +from graph.dim import Dim +from graph.types import ConstantInputParameters +from importer.common.constant_mixin import ConstantMixin +from importer.common.provisional_dim import ProvisionalDim + +from ..backend_handler import BackendHandler +from ..handler import onnx_op + + +@onnx_op("Where") +class Where(ConstantMixin, BackendHandler): + + @classmethod + def _common(cls, node, **kwargs): + all_nodes = kwargs['all_nodes'] + G = kwargs['G'] + valid_name = kwargs['valid_name'] + inputs = [all_nodes[inp] for inp in node.input] + x = inputs[0] + x_shape = x[2].shape + if all(cls.is_constant(inp) for inp in inputs): + condition = cls.get_constant(inputs[0]) + x = cls.get_constant(inputs[1]) + y = cls.get_constant(inputs[2]) + params = ConstantInputParameters(valid_name, dims=Dim.unnamed(x.shape), value=np.where(condition, x, y)) + else: + raise ValueError("ONNX Where operator is not implemented") + all_nodes[node.output[0]] = (params, 0, ProvisionalDim(x_shape), None) + return params + + @classmethod + def version_9(cls, node, **kwargs): + return cls._common(node, **kwargs) + + @classmethod + def version_16(cls, node, **kwargs): + return cls._common(node, **kwargs) diff --git a/tools/nntool/importer/onnx/onnx.py b/tools/nntool/importer/onnx/onnx.py index ad083709a..13032d210 100644 --- a/tools/nntool/importer/onnx/onnx.py +++ b/tools/nntool/importer/onnx/onnx.py @@ -70,7 +70,8 @@ def create_graph(self, filename, opts) -> NNGraph: opset_import = model.opset_import G = NNGraph(filename=filename, name=opts.get('name')) - G, qrecs = self._import_onnx_model(G, model.graph, opset_import, opts) + G, qrecs, qopts = self._import_onnx_model( + G, model.graph, opset_import, opts) G.add_dimensions(quiet=True) if qrecs: propagate_qrecs(G, qrecs) @@ -78,6 +79,7 @@ def create_graph(self, filename, opts) -> NNGraph: qset.update(qrecs) qset.scheme_priority = ['SQ8'] qset.schemes_present = {'SQ8'} + qset.options = qopts G.quantization = qset try: quantizer = NewQuantizer(G) @@ -88,9 +90,10 @@ def create_graph(self, filename, opts) -> NNGraph: clean_dangling_nodes(G) MatchDuplicateConstants().match(G) + G.add_dimensions(quiet=True) return G - def _update_qrecs(self, G, qrecs, all_nodes, ranges_dict): + def _update_qrecs(self, G, qrecs, all_nodes, ranges_dict, qopts): for node, idx, _, qtype in all_nodes.values(): if qtype is None and node.name not in ranges_dict.keys(): continue @@ -107,8 +110,11 @@ def _update_qrecs(self, G, qrecs, all_nodes, ranges_dict): if node.name in ranges_dict.keys(): out_min, out_max = ranges_dict[node.name]["range"] dtype = ranges_dict[node.name].get("dtype", np.int8) - bits = ranges_dict[node.name].get("n_bits", 8) + bits = ranges_dict[node.name].get("bits", 8) channel = ranges_dict[node.name].get("per_channel", None) + qopt = qopts.setdefault( + nid, {'output_size': [None] * len(G.indexed_out_edges(node))}) + qopt['output_size'][idx] = bits qtype = QType.from_min_max_sq( out_min, out_max, dtype=dtype, bits=bits, quantized_dimension=channel) qrec.out_qs[idx] = qtype @@ -127,14 +133,16 @@ def _import_onnx_model(self, G, graph, opset, opts): input_shapes=opts.get('input_shapes', {})) all_nodes.update(inputs) qrecs = {} + qopts = {} outputs = self._get_output_nodes( G, graph.output, substitutions=opts.get('substitutions', None)) shapes = {elem.name: elem.type for elem in graph.value_info} self._import_nodes( G, graph, self._handlers, all_nodes, outputs, - opts=opts, qrecs=qrecs, shapes=shapes) - self._update_qrecs(G, qrecs, all_nodes, opts.get('ranges_dict', {})) - return G, qrecs + opts=opts, qrecs=qrecs, shapes=shapes, qopts=qopts) + self._update_qrecs(G, qrecs, all_nodes, + opts.get('ranges_dict', {}), qopts) + return G, qrecs, qopts def import_subgraph(self, G, graph, opts, all_nodes=None): if all_nodes is None: @@ -153,7 +161,7 @@ def import_subgraph(self, G, graph, opts, all_nodes=None): self._import_nodes( G, graph, self._handlers, all_nodes, outputs, opts=opts, qrecs=qrecs) - self._update_qrecs(G, qrecs, all_nodes, {}) + self._update_qrecs(G, qrecs, all_nodes, {}, {}) return G, qrecs @staticmethod @@ -331,9 +339,14 @@ def _import_nodes(self, G, graph, handlers, all_nodes, outputs, **kwargs): continue handler = handlers[node.domain].get( node.op_type, None) if node.domain in handlers else None - if not handler or (handler.CONSTANT_ONLY and - not all(isinstance(all_nodes[inp_name][0], ConstantInputParameters) - for inp_name in node.input)): + if (handler and handler.CONSTANT_ONLY and + not all(isinstance(all_nodes[inp_name][0], ConstantInputParameters) + for inp_name in node.input)): + logger.warning( + f'{node.name} uses ONNX operator "{node.op_type}" domain ' + f'"{node.domain}" which is not currently supported in the Autotiler kernels. ' + 'It may be eliminated by graph optimisations') + if not handler: handler = handlers['__extensions'].get(node.op_type, None) if not handler: logger.warning( @@ -354,8 +367,14 @@ def _import_nodes(self, G, graph, handlers, all_nodes, outputs, **kwargs): from_idx=producer[1])) banned_inputs.update(node.output) continue - - params = handler.handle(OnnxNode(node), all_nodes=all_nodes, vars_dict=vars_dict, + onode = OnnxNode(node) + inputs = [all_nodes[inp] if inp else None for inp in onode.input] + if inputs: + x = inputs[0] + x_shape = x[2].shape + name = hasattr(node, 'name') and getattr(node, 'name') + x = 0 + params = handler.handle(onode, all_nodes=all_nodes, vars_dict=vars_dict, G=G, valid_name=self._node_name(node), used_tensors=used_tensors, importer=self, **kwargs) if params is None: diff --git a/tools/nntool/importer/tflite2/handlers/backend/concatenation.py b/tools/nntool/importer/tflite2/handlers/backend/concatenation.py index dd10ed7fb..4a9924777 100644 --- a/tools/nntool/importer/tflite2/handlers/backend/concatenation.py +++ b/tools/nntool/importer/tflite2/handlers/backend/concatenation.py @@ -61,6 +61,8 @@ def _common(cls, node: TFLiteNode, **kwargs): inputs = [all_nodes[t] for t in node.input] inp_shapes = [input[2].shape for input in inputs] + if not all(len(shape) == len(inp_shapes[0]) for shape in inp_shapes[1:]): + raise ValueError(f"Concat importer: {node.name} doesn't have all the shapes of same lenght {inp_shapes}") buffer_idxes = [tensor.buffer_idx for tensor in node.input] non_zero_idxes = [idx for idx in buffer_idxes if idx != 0] @@ -76,6 +78,8 @@ def _common(cls, node: TFLiteNode, **kwargs): inputs[dup_idx] = tuple([cparams, 0] + list(dup_inp[2:])) axis = node_opts.Axis() + if axis < 0: + axis += len(inp_shapes[0]) if any(inp_shape[axis] is None for inp_shape in inp_shapes): raise ValueError("concat on undefined axis in node %s" % node.name) @@ -92,7 +96,7 @@ def red_func(x, y): params = ConstantInputParameters(node.name, value=value) else: axis -= sum(1 if dim is None else 0 for dim in pout_shape[:axis:]) - params = ConcatParameters(node.name, axis=axis, axis_hint=None) + params = ConcatParameters(node.name, axis=axis) for idx, inp in enumerate(inputs): inp_node, inp_idx = cls._maybe_insert_reshape(G, inp, inp_shapes[idx], pout_shape) diff --git a/tools/nntool/importer/tflite2/handlers/backend/filter_mixin.py b/tools/nntool/importer/tflite2/handlers/backend/filter_mixin.py index 4b81f1682..53882f35d 100644 --- a/tools/nntool/importer/tflite2/handlers/backend/filter_mixin.py +++ b/tools/nntool/importer/tflite2/handlers/backend/filter_mixin.py @@ -137,7 +137,8 @@ def new_load_filter_parameters(cls, G, params, filter_shape, filter_scale_axis, # dqbias = bias_node.dqvalue bias_scale = (iqtype.scale * wqtype.scale).astype(np.float32) - bqtype = QType(dtype=np.int32, scale=bias_scale) + quantized_dimension = None if len(wqtype.scale) == 1 else 0 + bqtype = QType(dtype=np.int32, scale=bias_scale, quantized_dimension=quantized_dimension) # NOTE: In some tensorflow graphs the biases are hugely negative or hugely # positive. I've never seen this without a relun after and the weights on # these channels were 0. Actually they should be pruned. diff --git a/tools/nntool/importer/tflite2/handlers/backend/pack.py b/tools/nntool/importer/tflite2/handlers/backend/pack.py index 57f16a58b..73371e5fb 100644 --- a/tools/nntool/importer/tflite2/handlers/backend/pack.py +++ b/tools/nntool/importer/tflite2/handlers/backend/pack.py @@ -84,7 +84,7 @@ def _common(cls, node: TFLiteNode, **kwargs): G.add_edge(NNEdge(from_node=inputs[0][0], to_node=params, from_idx=inputs[0][1])) else: axis -= sum(1 if dim is None else 0 for dim in pconcat_out_shape[:axis:]) - params = ConcatParameters(node.name, axis=axis, axis_hint=None) + params = ConcatParameters(node.name, axis=axis) # insert reshapes on each input to add concat axis for idx, inp in enumerate(inputs): diff --git a/tools/nntool/importer/tflite2/handlers/backend/pool_mixin.py b/tools/nntool/importer/tflite2/handlers/backend/pool_mixin.py index 0c56a4034..791ce1bc9 100644 --- a/tools/nntool/importer/tflite2/handlers/backend/pool_mixin.py +++ b/tools/nntool/importer/tflite2/handlers/backend/pool_mixin.py @@ -19,6 +19,7 @@ from importer.common.provisional_dim import ProvisionalDim from importer.tflite2.tflite_schema_head.Pool2DOptions import Pool2DOptions from utils.node_id import NodeId +from importer.common.check_batchdim import check_batchdim from .filter_pad_mixin import FilterPadMixin @@ -34,6 +35,8 @@ def pool2d(cls, node, pool_type=None, **kwargs): inputs = [all_nodes[inp] for inp in node.input] x = inputs[0] + x = check_batchdim(G, x, node.name) + x = cls.remove_known_batch_dimension(G, x, node) x_shape = x[2].shape in_c = x_shape[1] diff --git a/tools/nntool/importer/tflite2/handlers/backend/resize_mixin.py b/tools/nntool/importer/tflite2/handlers/backend/resize_mixin.py index e61eb9707..b262697be 100644 --- a/tools/nntool/importer/tflite2/handlers/backend/resize_mixin.py +++ b/tools/nntool/importer/tflite2/handlers/backend/resize_mixin.py @@ -16,6 +16,7 @@ from graph.dim import Dim from graph.types.base import NNEdge +from importer.common.check_batchdim import check_batchdim from utils.node_id import NodeId @@ -32,6 +33,7 @@ def _common(cls, node, **kwargs): inputs = [all_nodes[inp] for inp in node.input] x = inputs[0] + x = check_batchdim(G, x, node.name) new_shape = tuple(cls._verify_constant(inputs[1])) params = params_class(node.name, new_shape=new_shape, diff --git a/tools/nntool/importer/tflite2/handlers/backend/tflite_detection_postprocess.py b/tools/nntool/importer/tflite2/handlers/backend/tflite_detection_postprocess.py index f8c23360e..8bbef202c 100644 --- a/tools/nntool/importer/tflite2/handlers/backend/tflite_detection_postprocess.py +++ b/tools/nntool/importer/tflite2/handlers/backend/tflite_detection_postprocess.py @@ -37,15 +37,10 @@ def _common(cls, node: TFLiteNode, **kwargs): opts = kwargs['opts'] all_nodes = kwargs['all_nodes'] importer = kwargs['importer'] - graph_outputs = kwargs['outputs'] - if len(node.output) > 3 and node.output[3] in graph_outputs: - G.remove(graph_outputs[node.output[3]][0]) - del graph_outputs[node.output[3]] inputs = [all_nodes[t] for t in node.input] outputs = [all_nodes.get(node.output[idx]) if idx < len(node.output) else None - for idx in range(3)] - # inp_shapes = [input[2].shape for input in inputs] + for idx in range(4)] if 'max_bb_before_nms' not in custom_opts: custom_opts['max_bb_before_nms'] = 300 @@ -79,9 +74,10 @@ def _common(cls, node: TFLiteNode, **kwargs): dtype=np.int16, scale=2**(-14)) o_scores_qtype = node.input[1].qtype o_class_qtype = QType(scale=1, dtype=np.int8) + o_num_detect = QType(scale=1, dtype=np.int8) qrec = QRec.scaled(in_qs=in_qtypes, out_qs=[o_boxes_qtype, o_class_qtype, - o_scores_qtype]) + o_scores_qtype, o_num_detect]) G.quantization[NodeId(params)] = qrec return params diff --git a/tools/nntool/importer/tflite2/handlers/backend/transpose_conv.py b/tools/nntool/importer/tflite2/handlers/backend/transpose_conv.py index 67e5b68ae..6de3241b5 100644 --- a/tools/nntool/importer/tflite2/handlers/backend/transpose_conv.py +++ b/tools/nntool/importer/tflite2/handlers/backend/transpose_conv.py @@ -12,7 +12,9 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from graph.dim import Conv2DFilterDim, PadDim, StrideDim +import numpy as np +from graph.types.constant_input import ConstantInputParameters +from graph.dim import Conv2DFilterDim, Dim, PadDim, StrideDim from graph.types import NNEdge, TransposeConv2DParameters from importer.common.constant_mixin import ConstantMixin from importer.common.provisional_dim import ProvisionalDim @@ -20,6 +22,7 @@ from importer.tflite2.tflite_schema_head.Padding import Padding from importer.tflite2.tflite_schema_head.TransposeConvOptions import \ TransposeConvOptions +from importer.common.check_batchdim import check_batchdim from ..backend_handler import BackendHandler from ..handler import tflite_op, partial_support, ps_description @@ -41,17 +44,22 @@ def version_1(cls, node: TFLiteNode, **kwargs): inputs = [all_nodes[t] for t in node.input] x = inputs[2] + x = check_batchdim(G, x, node.name) x_shape = x[2].shape in_b, in_h, in_w, in_c = tuple(x_shape) pout_shape = [dim if x_shape[idx] is not None else None for idx, dim in enumerate(cls.get_constant(inputs[0]))] out_b, out_h, out_w, out_c = tuple(pout_shape) + filt = inputs[1] weights_node = filt[0] filt_shape = filt[2].shape # # ['in_c', 'h', 'w', 'out_c'] filt_out_c, filt_h, filt_w, filt_in_c = tuple(filt_shape) + bias_node = ConstantInputParameters(f'{node.name}_bias', + dims=Dim.unnamed([filt_out_c]), + value=np.zeros([filt_out_c], dtype=np.float32)) # TODO - check filt_dim = Conv2DFilterDim(filt_h, filt_w, filt_out_c, in_c=filt_in_c) @@ -82,6 +90,7 @@ def version_1(cls, node: TFLiteNode, **kwargs): G.add_edge( NNEdge(from_node=x[0], to_node=params, from_idx=x[1], to_idx=0)) G.add_edge(NNEdge(from_node=weights_node, to_node=params, to_idx=1)) + G.add_edge(NNEdge(from_node=bias_node, to_node=params, to_idx=2)) pout_dims = ProvisionalDim(pout_shape) all_nodes[node.output[0]] = (params, 0, pout_dims) diff --git a/tools/nntool/importer/tflite2/remove_concats.py b/tools/nntool/importer/tflite2/remove_concats.py deleted file mode 100644 index c3a3391ca..000000000 --- a/tools/nntool/importer/tflite2/remove_concats.py +++ /dev/null @@ -1,88 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -import logging - -from graph.matches.matcher import find_forward -from graph.types import (ConcatParameters, NNEdge, NoOPParameters, - StridedSliceParameters) -from utils.node_id import NodeId - -LOG = logging.getLogger('nntool.' + __name__) - -def remove_concats(G): - concat_nodes = list([node for node in G.nodes() if isinstance(node, ConcatParameters)]) - strided_slices_removed = [] - concats_removed = [] - for node in concat_nodes: - concat_out_edges = G.indexed_out_edges(node.name)[0] - concat_in_edges = G.indexed_in_edges(node.name) - axis_slices = [] - start_idx = 0 - # find the slice patterns that can match inputs - for in_idx, dim in enumerate(node.in_dims): - slice_patterns = [(start_idx, start_idx + dim.shape[node.axis], 1)] - if dim.shape[node.axis] == 1: - # can also match reversed - slice_patterns.append((start_idx, start_idx - 1, -1)) - axis_slices.append(slice_patterns) - start_idx += dim.shape[node.axis] - for out_edge in concat_out_edges: - edge_lists = find_forward(G, out_edge, - StridedSliceParameters, - skip_node_classes=NoOPParameters) - # each list of edges goes to a strided slice - for edge_list in edge_lists: - edge = edge_list[-1] - assert isinstance(edge.to_node, StridedSliceParameters) - ssp = edge.to_node - LOG.info("found strided slice %s", ssp.name) - # must only slice axis of concat - if not ssp.only_slices_axis(node.axis): - LOG.info("rejected: slices more than one axis") - continue - # must match a slice pattern on the input - ssp_slice = ssp.act_slice[node.axis] - - in_idx = None - for idx, slice_patterns in enumerate(axis_slices): - if ssp_slice in slice_patterns: - in_idx = idx - break - if in_idx is None: - LOG.info("rejected: slices pattern matching concat not found") - continue - LOG.info("removing slice %s", ssp.name) - strided_slices_removed.append(ssp.name) - # save the out edges - ssp_out_edges = G.out_edges(ssp.name) - in_edge = concat_in_edges[in_idx] - # remove all the nodes including the ssp - for inter_edge in edge_list: - if G.quantization: - del G.quantization[NodeId(inter_edge.to_node)] - G.remove(inter_edge.to_node) - # connect all the ssp out edges to the node on the concat input - - for ssp_out_edge in ssp_out_edges: - G.add_edge(NNEdge(in_edge.from_node, ssp_out_edge.to_node, - from_idx=in_edge.from_idx, - to_idx=ssp_out_edge.to_idx)) - # if the concat now has no out edges remove it - if G.num_out_edges(node.name) == 0: - LOG.info("removing concat %s", node.name) - concats_removed.append(node.name) - G.remove(node) - - return (strided_slices_removed, concats_removed) diff --git a/tools/nntool/importer/tflite2/tflite.py b/tools/nntool/importer/tflite2/tflite.py index d0e35779d..2566e5906 100644 --- a/tools/nntool/importer/tflite2/tflite.py +++ b/tools/nntool/importer/tflite2/tflite.py @@ -40,7 +40,6 @@ from .common import LOG, check from .common.handler_helper import get_all_backend_handlers from .fix_split_in_edges import fix_split_in_edges -from .remove_concats import remove_concats # pylint: disable=E1101 @@ -104,7 +103,6 @@ def create_graph(self, filename, opts): RemoveReshapesBeforeLinear().match(G) # DrawGraphReporter().report(G) G.add_dimensions() - remove_concats(G) if opts['remove_quantize_ops']: RemoveQuantizeOperators().match(G) G.add_dimensions() diff --git a/tools/nntool/interpreter/commands/adjust.py b/tools/nntool/interpreter/commands/adjust.py index f03975ac8..65c51d756 100644 --- a/tools/nntool/interpreter/commands/adjust.py +++ b/tools/nntool/interpreter/commands/adjust.py @@ -47,5 +47,5 @@ def do_adjust(self, args): else: steps = None self.G.adjust_order( - postprocess=not args.no_postprocess, steps=steps, single_step=args.individual_step) + no_postprocess=args.no_postprocess, steps=steps, single_step=args.individual_step) self.G.add_dimensions() diff --git a/tools/nntool/interpreter/commands/aquant.py b/tools/nntool/interpreter/commands/aquant.py index d4c8f8019..e66fc99e4 100644 --- a/tools/nntool/interpreter/commands/aquant.py +++ b/tools/nntool/interpreter/commands/aquant.py @@ -14,9 +14,14 @@ # along with this program. If not, see . import argparse +import glob import logging +import pickle +from pathlib import Path from cmd2 import Cmd2ArgumentParser, with_argparser +from cmd2.cmd2 import Cmd +from interpreter.commands.qtune import load_options from interpreter.nntool_shell_base import (NNToolShellBase, store_once_in_history) from interpreter.shell_utils import glob_input_files, input_options @@ -45,6 +50,12 @@ class AquantCommand(NNToolShellBase): parser_aquant.add_argument('-s', '--scheme', type=str, choices=QUANTIZATION_SCHEMES, default='SQ8', help='quantize with scaling factors (TFlite quantization-like) [default] or POW2') + parser_aquant.add_argument('--stats', + completer_method=Cmd.path_complete, + help='pickle file containing statistics') + parser_aquant.add_argument('--json', + completer_method=Cmd.path_complete, + help='json file file containing saved quantization options using qtunesave command') add_options_to_parser(parser_aquant) input_options(parser_aquant) @@ -57,9 +68,24 @@ def do_aquant(self, args: argparse.Namespace): stats_collector = ActivationRangesCollector() # if replaying state file then load the activation stats if they are present opts = get_options_from_args(args) + + if args.json: + json_path = Path(args.json) + if not json_path.exists() or not json_path.is_file(): + self.perror(f'{json_path} does not exist or is not a file') + return + json_opts = load_options(json_path) + json_opts.update(opts) + opts = json_opts + state = ConstantInputParameters.save_compression_state(self.G) try: - if self.replaying_history and self.history_stats: + if args.stats: + stats_file = glob.glob(args.stats) + stats_file = stats_file[0] if stats_file else args.stats + with open(stats_file, 'rb') as file_pointer: + astats = pickle.load(file_pointer) + elif self.replaying_history and self.history_stats: astats = self.history_stats else: input_args = self._get_input_args(args) diff --git a/tools/nntool/interpreter/commands/compile_at_model.py b/tools/nntool/interpreter/commands/compile_at_model.py index 75db2c9f8..db5e6cc9a 100644 --- a/tools/nntool/interpreter/commands/compile_at_model.py +++ b/tools/nntool/interpreter/commands/compile_at_model.py @@ -111,7 +111,8 @@ def do_compile(self, args): at_gen_srcs.append(os.path.join(TILER_DSP_GENERATOR_PATH, "DSP_Generators.c")) objs = cc.compile( - srcs + at_gen_srcs, + sources=at_gen_srcs + srcs, + output_dir=args.model_dir, debug=1, extra_preargs=["-g"] ) diff --git a/tools/nntool/interpreter/commands/dsp_preprocessing.py b/tools/nntool/interpreter/commands/dsp_preprocessing.py index e8cf8e192..4d9c1e29c 100644 --- a/tools/nntool/interpreter/commands/dsp_preprocessing.py +++ b/tools/nntool/interpreter/commands/dsp_preprocessing.py @@ -13,6 +13,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from graph.types.base import NNEdge +from graph.types.others import ReshapeParameters import json import logging @@ -26,9 +28,11 @@ LOG = logging.getLogger("nntool") + class DSPPreprocessingCommand(NNToolShellBase): # GEN COMMAND parser_compile = Cmd2ArgumentParser() + def inputs_choices(self): if self.G is None: return [] @@ -37,8 +41,8 @@ def inputs_choices(self): def dsp_types(self): return [clas.__name__ for clas in DSPParameters.__subclasses__()] - - parser_dsp = Cmd2ArgumentParser("inserts dsp preprocessing node into graphs") + parser_dsp = Cmd2ArgumentParser( + "inserts dsp preprocessing node into graphs") parser_dsp.add_argument('input_node', choices_method=inputs_choices, help='input node name to format') @@ -49,6 +53,10 @@ def dsp_types(self): help='path to the config file for mfcc') parser_dsp.add_argument('--n_fft', type=int, help="n_fft bins") + parser_dsp.add_argument('--n_frames', type=int, + help="number of frames") + parser_dsp.add_argument('--n_fbanks', type=int, + help="number of filter banks") parser_dsp.add_argument('--frame_size', default=None, type=int, help='frame size in samples') parser_dsp.add_argument('--frame_step', default=None, type=int, @@ -68,6 +76,8 @@ def do_dsp_preprocessing(self, args): magsquared = args.magsquared win_fn = args.window_fn preemp_factor = args.preemp_factor + n_frames = args.n_frames + n_fbanks = args.n_fbanks config_dict = None if args.config_json: with open(args.config_json) as json_file: @@ -78,38 +88,42 @@ def do_dsp_preprocessing(self, args): magsquared = config_dict.get("magsquared", magsquared) win_fn = config_dict.get("window_fn", win_fn) preemp_factor = config_dict.get("preemp_factor", preemp_factor) + n_frames = config_dict.get("n_frames", n_frames) + n_fbanks = config_dict.get("n_fbanks", n_fbanks) assert frame_step, "frame_step is required" - spect_shape = self.G[args.input_node].out_dims[0].shape - if len(spect_shape) > 2: - if 1 in spect_shape: - temp = spect_shape[::-1] - temp.remove(1) - spect_shape = temp[::-1] - LOG.info(f"spectrogram shape expected as {spect_shape}") - n_frames = spect_shape[-2] - n_fbanks = spect_shape[-1] + assert n_fbanks and n_frames, "n_frames and n_fbanks are required" + org_input_dim = self.G[args.input_node].out_dims[0] + if org_input_dim.size() != (n_frames * n_fbanks): + raise ValueError( + f"Next layer has dimension {org_input_dim} (size: {org_input_dim.size()}) while you are trying to insert a DSP params with output size of {n_fbanks*n_frames} ({n_frames}x{n_fbanks})") LOG.info(f"N FRAMES: {n_frames}") new_input_size = frame_step * (n_frames - 1) + frame_size if args.dsp_node_type == "MFCCPreprocessingParameters": - dsp_params = MFCCPreprocessingParameters("MfccPreprocessing", conf_dict=config_dict) + dsp_params = MFCCPreprocessingParameters( + "MfccPreprocessing", conf_dict=config_dict) win_lut, fft_twiddles, swaptable, rfft_twiddles = dsp_params.gen_fft_twiddles() melfilt_coeff_sparse_node, melfilt_sparsity_node = dsp_params.gen_melfilter() - dct_matrix_node = dsp_params.gen_dct_matrix()(self.G) if dsp_params.n_dct else None - dsp_params_ref = dsp_params(None, win_lut(self.G) if win_lut else win_lut, fft_twiddles(self.G), swaptable(self.G), rfft_twiddles(self.G), melfilt_sparsity_node(self.G), melfilt_coeff_sparse_node(self.G), dct_matrix_node) + dct_matrix_node = dsp_params.gen_dct_matrix()( + self.G) if dsp_params.n_dct else None + dsp_params(None, win_lut(self.G) if win_lut else win_lut, fft_twiddles(self.G), swaptable(self.G), rfft_twiddles( + self.G), melfilt_sparsity_node(self.G), melfilt_coeff_sparse_node(self.G), dct_matrix_node) elif args.dsp_node_type == "RFFT2DPreprocessingParameters": - dsp_params = RFFT2DPreprocessingParameters("RfftPreprocessing", conf_dict=config_dict) + dsp_params = RFFT2DPreprocessingParameters( + "RfftPreprocessing", conf_dict=config_dict) win_lut, fft_twiddles, swaptable, rfft_twiddles = dsp_params.gen_fft_twiddles() - dsp_params_ref = dsp_params(None, win_lut(self.G) if win_lut else win_lut, fft_twiddles(self.G), swaptable(self.G), rfft_twiddles(self.G)) + dsp_params(None, win_lut(self.G) if win_lut else win_lut, fft_twiddles( + self.G), swaptable(self.G), rfft_twiddles(self.G)) - new_input_node = InputParameters(args.input_node, dims=Dim.unnamed([new_input_size])) + new_input_node = InputParameters( + args.input_node, dims=Dim.unnamed([new_input_size])) input_node_edge = self.G.out_edges(args.input_node)[0] input_node_edge.from_node.in_dims[0] = Dim.unnamed([new_input_size]) self.G.insert_node_at_edge(dsp_params, input_node_edge) self.G.replace_node(self.G[args.input_node], new_input_node) + dsp_out_dim = dsp_params.get_output_size([Dim.unnamed([new_input_size])])[0] + if dsp_out_dim != org_input_dim: + reshape = ReshapeParameters("reshape_dsp", old_shape=dsp_out_dim.shape, shape=org_input_dim.shape) + self.G.insert_node_after( + dsp_params, reshape, from_idx=0, edge_class=NNEdge) self.G.add_dimensions() - - - - - diff --git a/tools/nntool/interpreter/commands/dump.py b/tools/nntool/interpreter/commands/dump.py index b665bbfda..d6fa2498a 100644 --- a/tools/nntool/interpreter/commands/dump.py +++ b/tools/nntool/interpreter/commands/dump.py @@ -18,22 +18,56 @@ import pickle import numpy as np -from PIL import Image, ImageDraw from cmd2 import Cmd, Cmd2ArgumentParser, with_argparser - from execution.graph_executer import GraphExecuter from execution.quantization_mode import QuantizationMode -from graph.types import SSDDetectorParameters from interpreter.nntool_shell_base import NNToolShellBase, no_history -from interpreter.shell_utils import (glob_input_files, - input_options) +from interpreter.shell_utils import glob_input_files, input_options +from PIL import Image, ImageDraw +from utils.at_norm import get_do_rounding, set_do_rounding from utils.data_importer import import_data from utils.node_id import NodeId -from utils.at_norm import set_do_rounding, get_do_rounding + +from graph.dump_tensor import PrintDumper, dump_tensor +from graph.types import ConstantInputParameters, SSDDetectorParameters LOG = logging.getLogger('nntool.'+__name__) +def print_intermediates(G, outputs, limit=None, width=8, + precision=4, channel=None, order=None, + checksum=False, print_constants=False): + def print_step(step, outs, index): + node = step['node'] + if checksum: + for out_idx, out in enumerate(outs): + if isinstance(node, ConstantInputParameters): + continue + checksum_val = np.sum(out) if out.dtype != np.uint8 else np.sum( + out.astype(np.int8)) + print( + f"S{index} - {node.name}\n\tChecksum = {checksum_val}") + else: + print(node.name) + for out_idx, out in enumerate(outs): + dims = node.out_dims[out_idx] + if order is not None and dims.is_named and order != dims.order and all(k in dims.order + for k in order): + transpose = dims.transpose_to_order(order) + out = out.transpose(transpose) + if channel is not None: + out = out[channel:channel+1:1, ...] + dump_tensor(out, PrintDumper( + out, width=width, precision=precision)) + + if limit is not None: + print_step(G.graph_state.steps[limit], outputs[limit], limit) + else: + for idx, out in enumerate(outputs): + print_step(G.graph_state.steps[idx], out, idx) + print() + + class DumpCommand(NNToolShellBase): # DUMP COMMAND parser_dump = Cmd2ArgumentParser() @@ -49,6 +83,8 @@ class DumpCommand(NNToolShellBase): action='store_true', help='dequantize result') parser_dump.add_argument('--quantize_and_dequantize', action='store_true', help='quantize and dequantize float results') + parser_dump.add_argument('--append_fusion_output', + action='store_true', help='quantize and dequantize float results') parser_dump_group = parser_dump.add_mutually_exclusive_group( required=False) parser_dump_group.add_argument('-q', '--quantize', action='store_true', @@ -121,14 +157,14 @@ def do_dump(self, args: argparse.Namespace): qrecs = None if qmode.is_none else self.G.quantization executer = GraphExecuter(self.G, qrecs=qrecs) outputs = executer.execute(data, step_idx_limit=step, - qmode=qmode) + qmode=qmode, append_fusion_output=args.append_fusion_output) if args.pickle or self._in_py or args.save: pickles.append(outputs) else: - self.G.print_intermediates(outputs, limit=step, width=args.number_width, - precision=args.precision, channel=args.channel, - order=['c', 'h', 'w'], checksum=args.checksum) + print_intermediates(self.G, outputs, limit=step, width=args.number_width, + precision=args.precision, channel=args.channel, + order=['c', 'h', 'w'], checksum=args.checksum) if args.visualize_detection: img_in = Image.open(file_per_input[0]).convert('RGBA') diff --git a/tools/nntool/interpreter/commands/extract.py b/tools/nntool/interpreter/commands/extract.py index ce781d1ee..2599244cb 100644 --- a/tools/nntool/interpreter/commands/extract.py +++ b/tools/nntool/interpreter/commands/extract.py @@ -14,21 +14,24 @@ # along with this program. If not, see . from cmd2 import Cmd2ArgumentParser, with_argparser -from interpreter.nntool_shell_base import NNToolShellBase +from interpreter.nntool_shell_base import NODE_SELECTOR_HELP, NNToolShellBase from graph.manipulations.extract import extract_node class ExtractCommand(NNToolShellBase): # EXTRACT COMMAND parser_extract = Cmd2ArgumentParser() parser_extract.add_argument('step', - type=int, - help='step number to extract') + help='step to extract. ' + NODE_SELECTOR_HELP, + completer_method=NNToolShellBase.node_step_or_name_completer(allow_comma=True)) @with_argparser(parser_extract) def do_extract(self, args): """ -Extracts a single step out of a graph and forms a new graph with inputs and outputs to this step.""" +Extracts a single step out of a graph and forms a new graph with inputs (and constants) and outputs to this step.""" self._check_graph() - if args.step < 0 or args.step > len(self.G.graph_state.steps): - self.perror("step must be between 0 and {}".format(len(self.G.graph_state.steps))) - extract_node(self.G, self.G.graph_state.steps[args.step]['node']) + nodes, _ = self.get_node_step_or_name(args.step, allow_comma=True) + if not nodes: + self.perror('node not found') + if len(nodes) > 1: + self.perror('only one node can be extracted') + extract_node(self.G, nodes[0]) diff --git a/tools/nntool/interpreter/commands/fquant.py b/tools/nntool/interpreter/commands/fquant.py index 251d6aeeb..baa78b0d2 100644 --- a/tools/nntool/interpreter/commands/fquant.py +++ b/tools/nntool/interpreter/commands/fquant.py @@ -15,9 +15,11 @@ import argparse import logging +from pathlib import Path import numpy as np -from cmd2 import Cmd2ArgumentParser, with_argparser +from cmd2 import Cmd, Cmd2ArgumentParser, with_argparser +from interpreter.commands.qtune import load_options from interpreter.nntool_shell_base import NNToolShellBase from quantization.handlers_helpers import (add_options_to_parser, get_options_from_args) @@ -55,6 +57,9 @@ class FquantCommand(NNToolShellBase): parser_fquant.add_argument('--seed', type=int, default=0, help='numpy random seed, default not set and inputs change every time') + parser_fquant.add_argument('--json', + completer_method=Cmd.path_complete, + help='json file file containing saved quantization options using qtunesave command') add_options_to_parser(parser_fquant) @with_argparser(parser_fquant) @@ -65,6 +70,16 @@ def do_fquant(self, args: argparse.Namespace): weights and input data are avalaible.""" self._check_graph() opts = get_options_from_args(args) + opts = get_options_from_args(args) + if args.json: + json_path = Path(args.json) + if not json_path.exists() or not json_path.is_file(): + self.perror(f'{json_path} does not exist or is not a file') + return + json_opts = load_options(json_path) + json_opts.update(opts) + opts = json_opts + state = ConstantInputParameters.save_compression_state(self.G) try: if self.replaying_history and self.history_stats: diff --git a/tools/nntool/interpreter/commands/fusions.py b/tools/nntool/interpreter/commands/fusions.py index 4fae2751d..bf2bd21ec 100644 --- a/tools/nntool/interpreter/commands/fusions.py +++ b/tools/nntool/interpreter/commands/fusions.py @@ -16,13 +16,8 @@ import texttable from cmd2 import Cmd2ArgumentParser, with_argparser from interpreter.nntool_shell_base import NNToolShellBase -from quantization.quantizer.new_quantizer import NewQuantizer -from quantization.verify_quantization import verify_quantization -from graph.matches.matches import (get_fusion, get_fusions, - get_pow2_match_group, - get_scale8_match_group) -from graph.types import ConstantInputParameters +from graph.matches.matches import get_fusions class FusionsCommand(NNToolShellBase): @@ -31,6 +26,9 @@ def fusions_list(self): return [elem[0] for elem in get_fusions()] parser_fusions = Cmd2ArgumentParser("apply fusions to graph") + parser_fusions.add_argument('--no_postprocess', + action='store_true', + help="don't run adjust or qtune or rerun fusions (debugging option)") parser_fustions_exclusive = parser_fusions.add_mutually_exclusive_group() parser_fustions_exclusive.add_argument('-l', '--list', action='store_true', @@ -59,31 +57,17 @@ def do_fusions(self, args): self.ppaged(table.draw()) return self._check_graph() - state = ConstantInputParameters.save_compression_state(self.G) try: if args.apply: - fusions = [get_fusion(name) for name in args.apply] - invalid_names = [args.apply[idx] for idx, fusion in enumerate(fusions) if fusion is None] - if invalid_names: - self.perror(f'fusion{"s" if len(invalid_names) > 1 else ""} {", ".join(invalid_names)} not found') - return + fusions_names = args.apply elif args.pow2: - fusions = [get_pow2_match_group()] + fusions_names = ['pow2_match_group'] elif args.scale8: - fusions = [get_scale8_match_group()] + fusions_names = ['scaled_match_group'] else: - self.perror("No fusion set selected. Nothing to do. Select --pow2 or --scale8.") + self.perror( + "No fusion set selected. Nothing to do. Select --pow2 or --scale8.") return - for fusion in fusions: - fusion.match(self.G) - self.G.add_dimensions() - if self.G.quantization and verify_quantization(self.G): - quantizer = NewQuantizer(self.G) - quantizer.quantize() - problems = verify_quantization(self.G) - if problems: - self.perror('quantization issue after fusions') - for problem in problems: - self.perror(problem) - finally: - ConstantInputParameters.restore_compression_state(self.G, state) + self.G.fusions(*fusions_names, no_postprocess=args.no_postprocess) + except ValueError as ex: + self.perror(f'{ex}') diff --git a/tools/nntool/interpreter/commands/gen.py b/tools/nntool/interpreter/commands/gen.py index 6e083a8c8..ccbd77b9e 100644 --- a/tools/nntool/interpreter/commands/gen.py +++ b/tools/nntool/interpreter/commands/gen.py @@ -16,14 +16,19 @@ import argparse import logging import os + from cmd2 import Cmd, Cmd2ArgumentParser, with_argparser -from interpreter.nntool_shell_base import NNToolShellBase, no_history -from utils.data_importer import import_data from execution.graph_executer import GraphExecuter from execution.quantization_mode import QuantizationMode -from generation.default_template import basic_kernel_header_template, basic_kernel_source_template, default_template, dynamic_template, header_template -from generation.naming_convension import DefaultNamingConvension from generation.code_generator import CodeGenerator +from generation.default_template import (basic_kernel_header_template, + basic_kernel_source_template, + default_template, dynamic_template, + header_template) +from generation.gen_utils import write_empty +from generation.naming_convension import DefaultNamingConvension +from interpreter.nntool_shell_base import NNToolShellBase, no_history +from utils.data_importer import import_data LOG = logging.getLogger("nntool") @@ -92,9 +97,11 @@ def do_gen(self, args): self.settings['basic_kernel_source_file'] = args.basic_kernel_source_file self.settings['basic_kernel_header_file'] = args.basic_kernel_header_file self.settings['anonymise'] = args.anonymise - os.makedirs(os.path.abspath(self.settings['model_directory']), mode=0o750, exist_ok=True) - os.makedirs(os.path.abspath(self.settings['tensor_directory']), mode=0o750, exist_ok=True) - code_gen = CodeGenerator(self.G, DefaultNamingConvension(self.G, anonymise=args.anonymise), self.settings) + os.makedirs(os.path.abspath( + self.settings['model_directory']), mode=0o750, exist_ok=True) + os.makedirs(os.path.abspath( + self.settings['tensor_directory']), mode=0o750, exist_ok=True) + code_gen = CodeGenerator(self.G, DefaultNamingConvension(anonymise=args.anonymise), self.settings) if self.settings['template_file']: code_template = dynamic_template(self.settings['template_file']) @@ -108,18 +115,28 @@ def do_gen(self, args): if self.G.has_expressions: with open(os.path.join(self.settings['model_directory'], args.basic_kernel_source_file), "w") as output_fp: - output_fp.write(basic_kernel_source_template(self.G, code_generator=code_gen)) + output_fp.write(basic_kernel_source_template( + self.G, code_generator=code_gen)) with open(os.path.join(self.settings['model_directory'], args.basic_kernel_header_file), "w") as output_fp: - output_fp.write(basic_kernel_header_template(self.G, code_generator=code_gen)) + output_fp.write(basic_kernel_header_template( + self.G, code_generator=code_gen)) + else: + write_empty(self.settings['model_directory'], + args.basic_kernel_source_file, "no expressions used") + write_empty(self.settings['model_directory'], + args.basic_kernel_header_file, "no expressions used") else: self.ppaged(code_template(self.G, code_generator=code_gen)) if self.G.has_expressions: - self.ppaged(basic_kernel_source_template(self.G, code_generator=code_gen)) - self.ppaged(basic_kernel_header_template(self.G, code_generator=code_gen)) + self.ppaged(basic_kernel_source_template( + self.G, code_generator=code_gen)) + self.ppaged(basic_kernel_header_template( + self.G, code_generator=code_gen)) if args.output_tensors: code_gen.write_constants() if args.header_file: with open(os.path.join(self.settings['model_directory'], args.header_file), "w") as output_fp: - output_fp.write(header_template(self.G, code_generator=code_gen)) + output_fp.write(header_template( + self.G, code_generator=code_gen)) diff --git a/tools/nntool/interpreter/commands/gen_project.py b/tools/nntool/interpreter/commands/gen_project.py index b8202d8b3..83457d548 100644 --- a/tools/nntool/interpreter/commands/gen_project.py +++ b/tools/nntool/interpreter/commands/gen_project.py @@ -36,6 +36,7 @@ from generation.default_template import (basic_kernel_header_template, basic_kernel_source_template, default_template) +from generation.gen_utils import write_empty from generation.naming_convension import DefaultNamingConvension from interpreter.commands.aquant import AquantCommand from interpreter.commands.open import OpenCommand @@ -134,6 +135,11 @@ def do_gen_project(self, args): self._check_quantized() self._check_adjusted() + if "GAP_SDK_HOME" not in os.environ or "NNTOOL_PATH" not in os.environ: + self.perror( + 'you must run "source sourceme.sh" in the GAP SDK before using this command') + return + if args.input_tensors: if args.input_tensors not in self.tensor_store: self.perror( @@ -217,7 +223,7 @@ def do_performance(self, args): self._check_graph() self._check_quantized() self._check_adjusted() - if "GAP_SDK_HOME" not in os.environ: + if "GAP_SDK_HOME" not in os.environ or "NNTOOL_PATH" not in os.environ: self.perror( 'you must run "source sourceme.sh" in the GAP SDK before using this command') return @@ -281,7 +287,7 @@ def do_performance(self, args): self.tensor_store[args.output_tensors] = at_map_tensors( self.G, at_tensor_loader_int(fp)) - match_perf = r" +((?:S\d+|Tota)[^:]+): *Cycles: +(\d+)[^:]+: +(\d+)[^:]+: +([\d<.]+)" + match_perf = r" +((?:S\d+|Tota)[^:]+): *Cycles: +(\d+)[^:]+: +(\d+)[^:]+: +(.+)" matcher = re.compile(match_perf) perf = matcher.findall(res.stdout) if not perf: @@ -356,7 +362,9 @@ def process_script(script): if line.startswith('aquant'): # add abs path for input files and try to remake command args = aquant_parser.parse_args(line.rstrip().split(' ')[1:]) - input_files = [os.path.abspath(f) for f in args.input_files if f != ''] + input_files = [os.path.abspath(f) + for f in args.input_files if f != ''] +#pylint: disable=singleton-comparison opts = [f"--{k} {v}" if v != True else f"--{k}" for k, v in vars(args).items() if v and k != 'input_files'] line = " ".join(['aquant'] + opts + input_files) @@ -373,7 +381,7 @@ def gen_project(G, settings, project_folder, script_commands, overwrite=False, p settings['graph_produce_operinfos'] = True code_gen = CodeGenerator( - G, DefaultNamingConvension(G), settings) + G, DefaultNamingConvension(), settings) if not os.path.exists(project_folder): os.mkdir(project_folder) @@ -447,7 +455,7 @@ def gen_project(G, settings, project_folder, script_commands, overwrite=False, p if script_commands[-1] != "save_state": fp.write('save_state\n') if gen_atproject: - code_gen = CodeGenerator(G, DefaultNamingConvension(G), settings) + code_gen = CodeGenerator(G, DefaultNamingConvension(), settings) with open(os.path.join(project_folder, 'Model.c'), "w") as output_fp: output_fp.write(default_template(G, code_generator=code_gen)) if G.has_expressions: @@ -457,6 +465,12 @@ def gen_project(G, settings, project_folder, script_commands, overwrite=False, p with open(os.path.join(project_folder, "Expression_Kernels.h"), "w") as output_fp: output_fp.write(basic_kernel_header_template( G, code_generator=code_gen)) + else: + write_empty(project_folder, "Expression_Kernels.c", + "no expressions used") + write_empty(project_folder, "Expression_Kernels.h", + "no expressions used") + code_gen.write_constants(tensor_directory=project_folder) ignore_function = None if overwrite else skip_existing_files( project_folder) diff --git a/tools/nntool/interpreter/commands/imageformat.py b/tools/nntool/interpreter/commands/imageformat.py index 35f7755d9..f0468dc01 100644 --- a/tools/nntool/interpreter/commands/imageformat.py +++ b/tools/nntool/interpreter/commands/imageformat.py @@ -23,7 +23,7 @@ from graph.types import ImageFormatParameters, NNEdge, TransposeParameters - +from graph.manipulations.formatter import insert_formatter, remove_formatter class ImageFormatCommand(NNToolShellBase): def inputs_choices(self): if self.G is None: @@ -74,103 +74,3 @@ def do_imageformat(self, args: argparse.Namespace): f'format {args.image_formatter} and normalization {args.image_normalizer}') -def insert_formatter(G, input_node, formatter, normalizer): - format_node = ImageFormatParameters(input_node.name + "_formatter", - norm_func=normalizer.upper(), - format_change=formatter.upper()) - out_edges = G.out_edges(input_node.name) - - # dims updated to reflect formatter - if format_node.output_channels is not None and format_node.input_channels is not None: - out_dim = input_node.get_output_size(None)[0] - if formatter.upper() in ("BW8", "BW16"): - assert format_node.input_channels == 1 - in_dim = out_dim.clone() - format_node.out_dims_hint = input_node.out_dims_hint - format_node.in_dims_hint = input_node.out_dims_hint - input_node.dims = in_dim - for out_edge in out_edges: - G.remove_edge(out_edge) - else: - if not out_dim.is_named or out_dim.c != format_node.output_channels: - raise ValueError( - "current graph input is not named or does not match formatter output channels") - if formatter.upper() in ("RGB16", "BW16") and normalizer.upper() != "OUT_INT16": - raise ValueError( - "rgb16 and bw16 formatters must have out_int16 as normalization function") - in_dim = out_dim.clone() - in_dim.c = format_node.input_channels - in_dim.impose_order(("h", "w", "c")) - format_node.in_dims_hint = [["h", "w", "c"]] - input_node.dims = in_dim - if input_node.fixed_order: - new_out_edges = [] - for out_edge in out_edges: - if isinstance(out_edge.to_node, TransposeParameters): - trans_node = out_edge.to_node - transpose_edges = G.out_edges(trans_node.name) - new_out_edges.extend(transpose_edges) - G.remove(trans_node) - if G.quantization: - nid = NodeId(trans_node) - if nid in G.quantization: - del G.quantization[NodeId(trans_node)] - else: - new_out_edges.append(out_edge) - out_edges = new_out_edges - else: - input_node.fixed_order = True - for out_edge in out_edges: - G.remove_edge(out_edge) - format_node.out_dims_hint = [["c", "h", "w"]] * len(out_edges) - input_node.out_dims_hint = [["h", "w", "c"]] - G.node_options[NodeId(input_node)] = input_node.at_options - # qrec updated to reflect formatter - input_qrec = G.quantization and G.quantization.get(NodeId(input_node)) - if input_qrec and format_node.input_dtype and format_node.output_dtype: - formatter_qrec = G.quantization.get(NodeId(format_node)) - if not formatter_qrec: - if input_qrec.out_qs[0].dtype != format_node.output_dtype: - raise ValueError( - "current graph input output quantization does not match formatter output") - formatter_qrec = deepcopy(input_qrec) - formatter_qrec.out_qs[0] = deepcopy(formatter_qrec.out_qs[0]) - if formatter_qrec.ktype.startswith('scaled'): - formatter_in_q = QType( - scale=1, zero_point=0, dtype=format_node.input_dtype) - elif formatter_qrec.ktype.startswith('symmetric'): - formatter_in_q = QType(q=0, dtype=format_node.input_dtype) - else: - raise NotImplementedError("quantization has unknown type") - if len(formatter_qrec.in_qs) > 0: - formatter_qrec.in_qs[0] = formatter_in_q - input_qrec.in_qs[0] = formatter_in_q - else: - formatter_qrec.in_qs.append(formatter_in_q) - input_qrec.in_qs.append(formatter_in_q) - input_qrec.out_qs[0] = formatter_in_q - G.quantization[NodeId(format_node)] = formatter_qrec - - G.add_node(format_node) - G.add_edge(NNEdge(input_node, format_node)) - for out_edge in out_edges: - G.add_edge(NNEdge(format_node, out_edge.to_node, to_idx=out_edge.to_idx)) - - -def remove_formatter(G, fmt_node): - input_edges = G.in_edges(fmt_node.name) - assert len(input_edges) == 1, "formatter node should only have one input" - input_node = input_edges[0].from_node - fmt_edges = G.out_edges(fmt_node.name) - fmt_qrec = G.quantization and G.quantization.get(NodeId(fmt_node)) - G.remove(fmt_node) - - input_node.dims = fmt_node.out_dims[0] - input_node.out_dims_hint = fmt_node.out_dims_hint - for fmt_edge in fmt_edges: - G.add_edge(NNEdge(input_node, fmt_edge.to_node, to_idx=fmt_edge.to_idx)) - if fmt_qrec: - input_qrec = G.quantization[NodeId(input_node)] - input_qrec.out_qs = fmt_qrec.out_qs - input_qrec.in_qs = fmt_qrec.out_qs - G.quantization.remove_node(fmt_node) diff --git a/tools/nntool/interpreter/commands/nntool_force_relu.py b/tools/nntool/interpreter/commands/nntool_force_relu.py index 68cd1a6f7..b94774f99 100644 --- a/tools/nntool/interpreter/commands/nntool_force_relu.py +++ b/tools/nntool/interpreter/commands/nntool_force_relu.py @@ -18,7 +18,7 @@ from cmd2 import Cmd2ArgumentParser, with_argparser from interpreter.nntool_shell_base import NNToolShellBase -from quantization.symmetric.kernels.activations import (get_force_relu, +from execution.kernels.quant.activations import (get_force_relu, set_force_relu) LOG = logging.getLogger('nntool.'+__name__) diff --git a/tools/nntool/interpreter/commands/open.py b/tools/nntool/interpreter/commands/open.py index 2db6d849f..1e317bb5f 100644 --- a/tools/nntool/interpreter/commands/open.py +++ b/tools/nntool/interpreter/commands/open.py @@ -179,7 +179,11 @@ def do_open(self, args: argparse.Namespace): else: # reset the current graph self._graphs[self._graph_idx] = NO_GRAPH.copy() - self.__open_graph(args) + try: + self.__open_graph(args) + except FileNotFoundError: + self.perror(f'{args.nnfile} not found') + return self._update_prompt() self.py_locals['G'] = self.G diff --git a/tools/nntool/interpreter/commands/qtune.py b/tools/nntool/interpreter/commands/qtune.py index a77d1d925..f687fc392 100644 --- a/tools/nntool/interpreter/commands/qtune.py +++ b/tools/nntool/interpreter/commands/qtune.py @@ -75,7 +75,7 @@ def qtune_first_arg_mapper(self, nodestr): parser_tune.add_argument( '--json', completer_method=Cmd.path_complete, - help='json file to save quantization options') + help='json file to load quantization options from') @with_argparser(parser_tune, ns_provider=capture_shell) def do_qtune(self, args): @@ -88,7 +88,10 @@ def reduction(state, x): nodes = x[0] opts = x[1] if 'scheme' in opts: - opts['scheme'] = SCHEME_NAME_MAPPINGS.get(opts['scheme']) + scheme = opts['scheme'].lower() + if scheme not in SCHEME_NAME_MAPPINGS: + raise ValueError(f'invalid scheme name {opts["scheme"]}') + opts['scheme'] = SCHEME_NAME_MAPPINGS[scheme] for node in nodes: props = state.setdefault(NodeId(node), {}) props.update(opts) @@ -99,8 +102,7 @@ def reduction(state, x): if not json_path.exists() or not json_path.is_file(): self.perror(f'{json_path} does not exist or is not a file') return - with json_path.open('r') as fp: - options = json.load(fp, cls=JsonSerializableStateDecoder) + options = load_options(json_path) else: options = {} @@ -108,10 +110,21 @@ def reduction(state, x): options = reduce(reduction, args.step, options) quantizer = NewQuantizer(self.G) - quantizer.options.update(options) + quantizer.update_options(options) quantizer.quantize() self.pfeedback('quantization options set') +def load_options(file_path): + with file_path.open('r') as fp: + save_options = json.load(fp, cls=JsonSerializableStateDecoder) + options = save_options['global'] + for node_opt in save_options['nodes']: + if 'node_name' not in node_opt: + raise ValueError('node option missing node id') + options[NodeId(node_opt['node_name'])] = {opt: val for opt, val in node_opt.items() if opt != "node_name"} + return options + + class QTuneSaveCommand(NNToolShellBase): # QTUNESAVE COMMAND @@ -123,13 +136,35 @@ class QTuneSaveCommand(NNToolShellBase): @with_argparser(parser_qtune_save) def do_qtunesave(self, args): """ -Save set quantization options.""" +Save set quantization options. + +You can manually edit quantization options in the file. +The global section contains options that will be applied to the whole graph +The nodes array contains options for each node that override the global options +Each nodes entry should be a JSON mapping with a key node_name +node_name should contain a node name or and arry with the fusion name and fusion internal +node name. +""" self._check_graph() self._check_quantized() save_path = Path(args.jsonfile).with_suffix('.json') - options = self.G.quantization.options.copy() - if 'scheme' not in options: - options['scheme'] = self.G.quantization.scheme_priority[0] + save_options = { + "global": {}, + "nodes": [] + } + for optid, opt in self.G.quantization.options.items(): + if isinstance(optid, NodeId): + opt = opt.copy() + if 'qtype_ind' in opt: + del opt['qtype_ind'] + if opt: + opt['node_name'] = optid.id[0] if not optid.id[1] else optid + save_options['nodes'].append(opt) + else: + save_options['global'][optid] = opt + + if 'scheme' not in save_options: + save_options['scheme'] = self.G.quantization.scheme_priority[0] with save_path.open('w') as fp: - json.dump(options, fp, cls=JsonSerializableStateEncoder, indent=2) + json.dump(save_options, fp, cls=JsonSerializableStateEncoder, indent=2) self.pfeedback(f'quantization options saved to {save_path}') diff --git a/tools/nntool/interpreter/commands/remove.py b/tools/nntool/interpreter/commands/remove.py index f5b716a7d..17f51d84a 100644 --- a/tools/nntool/interpreter/commands/remove.py +++ b/tools/nntool/interpreter/commands/remove.py @@ -14,12 +14,16 @@ # along with this program. If not, see . import argparse +from functools import reduce +from itertools import chain, groupby from cmd2 import Cmd2ArgumentParser, with_argparser from interpreter.nntool_shell_base import NNToolShellBase from graph.types import ReshapeParameters, InputParameters, OutputParameters, ConstantInputParameters from graph.types.base import NNEdge +from quantization.new_qrec import QRec +from utils.node_id import NodeId class RemoveCommand(NNToolShellBase): @@ -40,52 +44,90 @@ def nodes_choices(self): parser_remove.add_argument('-u', '--up', action='store_true', help='when one node is specified remove it and everything above it') + parser_remove.add_argument('--leave', + action='store_true', + help='when one node is specified only remove what is above or below and not the node itself') @with_argparser(parser_remove) def do_remove(self, args: argparse.Namespace): """Removes all the edges and nodes between two node. Will only work if nodes do not affect shape of tensor.""" self._check_graph() - if any(node not in self.G for node in args.nodes): - self.perror("node not found in graph") - return + for node in args.nodes: + if node not in self.G: + self.perror(f"node {node} not found in graph") + return node_from = self.G[args.nodes[0]] if len(args.nodes) == 1: if args.up: - nodes_above = self.G.nodes_above(node_from) - out_edges = self.G.indexed_out_edges(node_from) - nodes_above.add(node_from) + nodes_above = set(self.G.nodes_above(node_from)) + if args.leave: + remove_nodes = nodes_above + # remove constant inputs on the node left as targets for removal + for in_edge in self.G.indexed_in_edges(node_from): + if isinstance(in_edge.from_node, ConstantInputParameters): + nodes_above.remove(in_edge.from_node) + else: + remove_nodes = nodes_above | {node_from} + # check for deleted nodes that have edges to left nodes. These need to be the new inputs. + # group them by source so common edges have one input + inputs_on = [ + list(edges) for _, edges in + groupby( + [edge for node in remove_nodes for edge in self.G.out_edges(node) + if edge.to_node not in remove_nodes], + key=lambda x: (x.from_node, x.from_idx))] + dims = [edges[0].to_node.in_dims[edges[0].to_idx] + for edges in inputs_on] input_names = sorted( - [node.name for node in nodes_above if isinstance(node, InputParameters)]) - self.G.remove_all(nodes_above | {node_from}) - for idx, edge_group in enumerate(out_edges): + [node.name for node in remove_nodes if isinstance(node, InputParameters)]) + self.G.remove_all(remove_nodes) + + for idx, edge_group in enumerate(inputs_on): name = input_names.pop(0) if input_names else None - in_node = self.G.add_input( - node_from.out_dims[idx], name=name) + in_node = self.G.add_input(dims[idx], name=name) self.pfeedback(f'adding input {in_node.name}') for edge in edge_group: self.G.add_edge(NNEdge(from_node=in_node, to_idx=edge.to_idx, to_node=edge.to_node)) + if self.G.quantization and edge_group: + edge = edge_group[0] + fnid = NodeId(edge.to_node) + if fnid in self.G.quantization: + qrec = self.G.quantization[fnid] + self.G.quantization[NodeId(in_node)] = QRec.copy_ktype( + qrec, out_qs=[qrec.in_qs[edge.to_idx]]) else: - nodes_below = self.G.nodes_below(node_from) - for node in list(nodes_below): - nodes_below.update(edge.from_node for edge in self.G.in_edges(node) - if isinstance(edge.from_node, ConstantInputParameters)) + nodes_below = set(self.G.nodes_below(node_from)) if self.G.is_vertex_cut(nodes_below): self.perror( f'removing everything below {node_from.name} would split the graph which is not permitted') return - nodes_below.add(node_from) - in_edges = self.G.in_edges(node_from.name) + if args.leave: + remove_nodes = nodes_below + outputs_on = [edge_bundle[0] + for edge_bundle in self.G.indexed_out_edges(node_from)] + else: + input_nodes = {edge.from_node for edge in self.G.in_edges(node_from) + if isinstance(edge.from_node, (InputParameters, ConstantInputParameters))} + remove_nodes = nodes_below | {node_from} | input_nodes + outputs_on = self.G.indexed_in_edges(node_from) output_names = sorted( - [node.name for node in nodes_below if isinstance(node, OutputParameters)]) - self.G.remove_all(nodes_below) - for edge in in_edges: + [node.name for node in remove_nodes if isinstance(node, OutputParameters)]) + + self.G.remove_all(remove_nodes) + for edge in outputs_on: name = output_names.pop(0) if output_names else None out_node = self.G.add_output(name=name) self.pfeedback(f'adding output {out_node.name}') self.G.add_edge(NNEdge(from_node=edge.from_node, from_idx=edge.from_idx, to_node=out_node)) + if self.G.quantization: + fnid = NodeId(edge.from_node) + if fnid in self.G.quantization: + qrec = self.G.quantization[fnid] + self.G.quantization[NodeId(out_node)] = QRec.copy_ktype( + qrec, in_qs=[qrec.out_qs[edge.from_idx]]) else: node_to = self.G[args.nodes[1]] nodes_between = self.G.nodes_between(node_from, node_to) @@ -98,8 +140,12 @@ def do_remove(self, args: argparse.Namespace): f'all paths from {node_from.name} must lead to {node_to.name}') return - edges_from = self.G.indexed_out_edges(node_from) - edges_to = self.G.indexed_in_edges(node_to.name) + edges_from = set(self.G.out_edges(node_from)) + edges_to = set(self.G.in_edges(node_to.name)) + between_edges = reduce(lambda s, x: s | set( + self.G.edges(x)), nodes_between, set()) + edges_from = edges_from.intersection(between_edges) + edges_to = edges_to.intersection(between_edges) if len(edges_from) != len(edges_to): self.perror( f"{node_from.name} has a different number of outputs than {node_to.name}'s inputs") diff --git a/tools/nntool/interpreter/commands/tflite.py b/tools/nntool/interpreter/commands/tflite.py index 71babab37..b8a729a11 100644 --- a/tools/nntool/interpreter/commands/tflite.py +++ b/tools/nntool/interpreter/commands/tflite.py @@ -15,14 +15,19 @@ from interpreter.nntool_shell_base import NNToolShellBase from importer.tflite2.common.handler_helper import get_backend_coverage, get_backend_partial_support_detail - +import texttable class HelpTFLiteCommand(NNToolShellBase): def help_tflite(self): ops_dict = get_backend_coverage()[0] bc_dict = get_backend_partial_support_detail() self.pfeedback("Supported operators and versions") + + table = texttable.Texttable() + table.set_cols_align(['l', 'l', 'l']) + table.set_max_width(120) + table.set_cols_width([30, 15, 60]) for op in ops_dict: - self.pfeedback("%s (%s)"%(op, ",".join(str(ver) for ver in ops_dict[op]))) - if op in bc_dict: - self.pfeedback(bc_dict[op]) + table.add_row([op, ",".join(str(ver) for ver in ops_dict[op]), bc_dict.get(op, "")]) + self.pfeedback("Supported operators and versions") + self.pfeedback(table.draw()+'\n') \ No newline at end of file diff --git a/tools/nntool/interpreter/generator.py b/tools/nntool/interpreter/generator.py index 5a89cc584..c271c2c65 100644 --- a/tools/nntool/interpreter/generator.py +++ b/tools/nntool/interpreter/generator.py @@ -24,6 +24,7 @@ basic_kernel_source_template, default_template, dynamic_template, header_template) +from generation.gen_utils import write_empty from generation.naming_convension import DefaultNamingConvension from interpreter.nntool_shell import NNToolShell @@ -51,7 +52,6 @@ def write_template(G, code_gen, model_directory, model_file, template, template_ with open(model_path, "w") as output_fp: output_fp.write(model) - def generate_code(args): LOG.propagate = False @@ -85,7 +85,7 @@ def generate_code(args): os.makedirs(os.path.abspath(opts['model_directory']), mode=0o750, exist_ok=True) os.makedirs(os.path.abspath(opts['tensor_directory']), mode=0o750, exist_ok=True) - code_gen = CodeGenerator(G, DefaultNamingConvension(G, anonymise=opts.get('anonymise')), opts) + code_gen = CodeGenerator(G, DefaultNamingConvension(anonymise=opts.get('anonymise')), opts) if args.template_file: code_template = dynamic_template(args.template_file) else: @@ -96,6 +96,9 @@ def generate_code(args): opts['basic_kernel_header_file'], basic_kernel_header_template, "kernel headers") write_template(G, code_gen, opts['model_directory'], opts['basic_kernel_source_file'], basic_kernel_source_template, "kernel source") + else: + write_empty(opts['model_directory'], opts['basic_kernel_header_file'], "no expressions used") + write_empty(opts['model_directory'], opts['basic_kernel_source_file'], "no expressions used") if args.header_file: with open(os.path.join(opts['model_directory'], args.header_file), "w") as output_fp: diff --git a/tools/nntool/quantization/clipping.py b/tools/nntool/quantization/clipping.py new file mode 100644 index 000000000..3cd8b8695 --- /dev/null +++ b/tools/nntool/quantization/clipping.py @@ -0,0 +1,99 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import math + +import numpy as np + +# import scipy.optimize as opt +# sigma=1.0 +# ALPHA_GAUS = {m: opt.minimize_scalar(lambda x: mse_gaussian(x, sigma=sigma, num_bits=m)).x for m in range(2,17,1)} +# b=1. +# ALPHA_LAPLACE = {m: opt.minimize_scalar(lambda x: mse_laplace(x, b=b, num_bits=m)).x for m in range(2,17,1)} + +ALPHA_GAUS = {2: 1.7106351863419305, 3: 2.1515927416420935, 4: 2.559136455058456, 5: 2.9362006203824396, + 6: 3.2869143669161147, 7: 3.615114210893466, 8: 3.924034014599462, 9: 4.216330919936089, + 10: 4.494170448727792, 11: 4.759309171709873, 12: 5.013218066309031, 13: 5.2570849373594974, + 14: 5.491968790304721, 15: 5.7186999893215, 16: 5.937970657819115} + +ALPHA_LAPLACE = {2: 2.830682989304011, 3: 3.89722946313961, 4: 5.028640140480669, 5: 6.204766334217521, + 6: 7.413126215019491, 7: 8.645619949475485, 8: 9.896759823828738, 9: 11.16268502214751, + 10: 12.440591336219248, 11: 13.728384769877623, 12: 15.024464757336403, 13: 16.32758309514459, + 14: 17.6367486184042, 15: 18.95116231019748, 16: 20.270171640301292} +GAUSSIAN_CONST = (0.5 * 0.35) * (1 + (math.pi * math.log(4)) ** 0.5) + + +def get_alpha_laplace(num_bits, stat): + alpha = ALPHA_LAPLACE[num_bits] * stat['b'] + return alpha, stat['b'] + + +def get_alpha_gaus(shape, num_bits, stat): + size = np.prod(shape) + std = ((stat['max'] - stat['min']) * GAUSSIAN_CONST) / \ + ((2 * math.log(size)) ** 0.5) + alpha = ALPHA_GAUS[num_bits] * std + return alpha, std + + +def mse_laplace(b, alpha, num_bits): + return 2 * (b ** 2) * np.exp(-alpha / b) + ((alpha ** 2) / (3 * 2 ** (2 * num_bits))) + + +def mse_gaussian(sigma, alpha, num_bits): + clipping_err = (sigma ** 2 + (alpha ** 2)) * (1 - math.erf(alpha / (sigma * np.sqrt(2.0)))) - \ + np.sqrt(2.0 / np.pi) * alpha * sigma * \ + (np.e ** ((-1) * (0.5 * (alpha ** 2)) / sigma ** 2)) + quant_err = (alpha ** 2) / (3 * (2 ** (2 * num_bits))) + return clipping_err + quant_err + + +def alpha2DeltaOffset(self, alpha, max_value, min_value, mean): + max_range = max_value - min_value + if alpha <= 0 or alpha >= max_range / 2: + delta = max_range + else: + delta = 2 * alpha + min_value = max(min_value, mean - delta / 2) + + return delta, min_value + + +def get_clip(shape, num_bits, stat, clip_type): + if clip_type == "laplace": + alpha, _ = get_alpha_laplace(num_bits, stat) + elif clip_type == "gaus": + alpha, _ = get_alpha_gaus(shape, num_bits, stat) + elif clip_type == "mix": + alpha_laplace, b = get_alpha_laplace(num_bits, stat) + alpha_gaus, std = get_alpha_gaus(shape, num_bits, stat) + mse_est_laplace = mse_laplace(b, alpha_laplace, num_bits) + mse_est_gaus = mse_gaussian(std, alpha_gaus, num_bits) + if mse_est_laplace < mse_est_gaus: + alpha = alpha_laplace + else: + alpha = alpha_gaus + elif clip_type == "none": + return stat['min'], stat['max'] + else: + raise ValueError('unknown clip type') + max_range = stat['max'] - stat['min'] + if alpha <= 0 or alpha >= max_range / 2: + return stat['min'], stat['max'] + + min_value = max(stat['min'], stat['mean'] - alpha) + max_value = min_value + 2 * alpha + + return min_value, max_value diff --git a/tools/nntool/quantization/float/float_quantization_handler.py b/tools/nntool/quantization/float/float_quantization_handler.py index 113e27947..776054095 100644 --- a/tools/nntool/quantization/float/float_quantization_handler.py +++ b/tools/nntool/quantization/float/float_quantization_handler.py @@ -23,7 +23,9 @@ FLOAT_DTYPES = { 'bfloat16': bfloat16, 'float16': np.float16, - 'float32': np.float32 + 'ieee16': np.float16, + 'float32': np.float32, + 'ieee32': np.float32 } #pylint: disable=abstract-method @@ -63,3 +65,10 @@ def _get_in_qs_from_stats(cls, params, stats, in_qs, **kwargs): for idx, dim in enumerate(params.in_dims)] return [QType(dtype=dtype) if dim is not None else None for idx, dim in enumerate(params.in_dims)] + + @classmethod + def get_min_max(cls, stats, idx=0, direction='out'): + if stats: + return (stats[f'range_{direction}'][idx]['min'], + stats[f'range_{direction}'][idx]['max']) + return None, None diff --git a/tools/nntool/quantization/float/quantizers/expression_fusion_float.py b/tools/nntool/quantization/float/quantizers/expression_fusion_float.py index ee45039e5..62fe5989e 100644 --- a/tools/nntool/quantization/float/quantizers/expression_fusion_float.py +++ b/tools/nntool/quantization/float/quantizers/expression_fusion_float.py @@ -30,8 +30,8 @@ # Fusion handler attribute not set since expressions are handled only by this handler @params_type(ExpressionFusionParameters) -@in_qs_constraint(MatchAll({'dtype': set([np.float32, np.float16, bfloat16])})) -@out_qs_constraint(MatchAll({'dtype': set([np.float32, np.float16, bfloat16])})) +@in_qs_constraint(MatchAll({'dtype': set([np.float32, np.float16, bfloat16, np.uint16, np.int16, np.uint8, np.int8])})) +@out_qs_constraint(MatchAll({'dtype': set([np.float32, np.float16, bfloat16, np.uint16, np.int16, np.uint8, np.int8])})) class ExpressionFusionFloat(FloatQuantizionHandler): @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): diff --git a/tools/nntool/quantization/float/quantizers/input_float.py b/tools/nntool/quantization/float/quantizers/input_float.py new file mode 100644 index 000000000..79c064ad9 --- /dev/null +++ b/tools/nntool/quantization/float/quantizers/input_float.py @@ -0,0 +1,54 @@ +# Copyright (C) 2020 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +from copy import deepcopy + +import numpy as np +from bfloat16 import bfloat16 +from graph.types import OutputParameters +from graph.types.input_output import InputParameters +from quantization.float.float_quantization_handler import \ + FloatQuantizionHandler +from quantization.new_qrec import QRec +from quantization.qtype import QType +from quantization.qtype_constraint import MatchAll +from quantization.quantizer_options import QTYPE_IND_OPTION +from quantization.unified_quantization_handler import (options, + out_qs_constraint, + params_type) + + +@params_type(InputParameters) +@out_qs_constraint(MatchAll({'dtype': set([np.float32, np.float16, bfloat16])})) +@options(QTYPE_IND_OPTION) +class FloatInput(FloatQuantizionHandler): + @classmethod + def _quantize(cls, params, in_qs, stats, **kwargs): + force_out_qs, dtype = cls.get_float_opts(**kwargs) + force_out_q = force_out_qs and force_out_qs[0] + opts = kwargs['opts'] + i_q_ind = opts.get('qtype_ind') + if force_out_q: + if force_out_q.dtype != dtype: + return None + i_q = deepcopy(force_out_q) + elif i_q_ind: + i_q = deepcopy(i_q_ind) + else: + min_val, max_val = cls.get_min_max(stats) + i_q = QType(dtype=dtype, min_val=min_val, max_val=max_val) + return QRec.float(out_qs=[i_q], + float_dtype=i_q.dtype) diff --git a/tools/nntool/quantization/float/quantizers/output_float.py b/tools/nntool/quantization/float/quantizers/output_float.py index 57e2daba0..2d506f890 100644 --- a/tools/nntool/quantization/float/quantizers/output_float.py +++ b/tools/nntool/quantization/float/quantizers/output_float.py @@ -14,6 +14,8 @@ # along with this program. If not, see . +from copy import deepcopy + import numpy as np from bfloat16 import bfloat16 from graph.types import OutputParameters @@ -22,7 +24,9 @@ from quantization.new_qrec import QRec from quantization.qtype import QType from quantization.qtype_constraint import MatchAll +from quantization.quantizer_options import QTYPE_IND_OPTION from quantization.unified_quantization_handler import (in_qs_constraint, + options, out_qs_constraint, params_type) @@ -30,12 +34,20 @@ @params_type(OutputParameters) @in_qs_constraint(MatchAll({'dtype': set([np.float32, np.float16, bfloat16])})) @out_qs_constraint(MatchAll({'dtype': set([np.float32, np.float16, bfloat16])})) +@options(QTYPE_IND_OPTION) class FloatOutput(FloatQuantizionHandler): @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): force_out_qs, dtype = cls.get_float_opts(**kwargs) if force_out_qs and any(qtype.dtype != dtype for qtype in force_out_qs if qtype is not None): return None - return QRec.float(in_qs=[QType(dtype=dtype)], - out_qs=[QType(dtype=dtype)], - float_dtype=dtype) + opts = kwargs['opts'] + o_q_ind = opts.get('qtype_ind') + if o_q_ind: + o_q = deepcopy(o_q_ind) + else: + min_val, max_val = cls.get_min_max(stats, direction='in') + o_q = QType(dtype=dtype, min_val=min_val, max_val=max_val) + return QRec.float(in_qs=[o_q], + out_qs=[o_q], + float_dtype=o_q.dtype) diff --git a/tools/nntool/quantization/multiplicative/mult_quantization_handler.py b/tools/nntool/quantization/multiplicative/mult_quantization_handler.py index 716424e90..fa33e39ee 100644 --- a/tools/nntool/quantization/multiplicative/mult_quantization_handler.py +++ b/tools/nntool/quantization/multiplicative/mult_quantization_handler.py @@ -30,6 +30,7 @@ class MultQuantizionHandler(QuantizionHandler): 8: np.int8, 16: np.int16 } + DEFAULT_DTYPE = np.int8 @classmethod def get_mult_opts(cls, **kwargs): @@ -71,7 +72,7 @@ def force_symmetric_and_dtype(cls, in_qs, dtype=None, idx=None): def _get_in_qs_from_stats(cls, params, stats, in_qs, **kwargs): return [QType.from_min_max_sq(stats['range_in'][idx]['min'], stats['range_in'][idx]['max'], - dtype=np.int8) + dtype=cls.DEFAULT_DTYPE) if dim is not None else None for idx, dim in enumerate(params.in_dims)] diff --git a/tools/nntool/quantization/multiplicative/quantizers/activation_mult.py b/tools/nntool/quantization/multiplicative/quantizers/activation_mult.py index 7b6067c00..0467048c0 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/activation_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/activation_mult.py @@ -14,52 +14,114 @@ # along with this program. If not, see . import logging +import math from copy import deepcopy import numpy as np -from pytest import param from graph.types.activations import (ActivationParameters, HSigmoidActivationParameters, HSwishActivationParameters, - HTanHActivationParameters, LeakyActivationParameters, + HTanHActivationParameters, + LeakyActivationParameters, ReluActivationParameters, SigmoidActivationParameters, TanHActivationParameters) -from quantization.multiplicative.mulbias import compute_in_out_scale +from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType from quantization.new_qrec import QRec from quantization.qtype import QType -from quantization.symmetric.kernels.activations import \ - SigmoidScaledSymmetricMult from quantization.unified_quantization_handler import (in_qs_constraint, - out_qs_constraint, - params_type, priority) + out_qs_constraint,option_constraint, + params_type, options, priority) from ..mult_quantization_handler import MultQuantizionHandler +from quantization.quantizer_options import * LOG = logging.getLogger('nntool.' + __name__) +@options( + FORCE_OUTPUT_SIZE_OPTION, +) class ActivationMultSWBase(MultQuantizionHandler): @classmethod - def _quantize_sw(cls, params, in_qs, stats, in_dtype, out_dtype, **kwargs): + def _quantize_sw(cls, params, in_qs, stats, in_dtype, out_dtype, out_asym, **kwargs): force_out_qs, _ = cls.get_mult_opts(**kwargs) force_out_q = force_out_qs and force_out_qs[0] fusion = kwargs.get('fusion', None) in_q = in_qs[0] - if not fusion and in_dtype == np.int32: - return None + if fusion: + in_dtype = np.int32 + bits = 8 if out_dtype == np.int8 or out_dtype == np.uint8 else 16 if isinstance(params, (HSwishActivationParameters, HSigmoidActivationParameters)): - max_val = in_q.scale * pow(2, in_q.bits - 1) - if max_val < 6: - in_q = QType.from_min_max_sq(-6, 6, - dtype=in_dtype, forced=True) - elif isinstance(params, SigmoidActivationParameters): - in_q = QType.from_min_max_sq(-8, 8, dtype=in_dtype, forced=True) + cls.check_valid_ranges(params, stats, idx=0, dirs='in') + # we need to be able to represent offset and upper_bound in output dtype + # input range should match stats since swish requires the full input range + if fusion: + # in a fusion the output container is smaller than the input container + # The input scale may be too small to represent offset and upper_bound + # in the output dtype + params_qtype = QType.from_min_max_sq( + 0, + np.maximum( + params.upper_bound, + params.offset), + bits=bits, + dtype=out_dtype) + in_q = QType.from_min_max_sq( + stats['range_in'][0]['min'], + stats['range_in'][0]['max'], + dtype=in_dtype) + # if params scale is larger then we must reduce precision + if np.all(params_qtype.scale > in_q.scale): + in_q.scale = params_qtype.scale + else: + # outside a fusion our in and out dtype is the same + # so we just need to check that offset and upper_bound can be represented + if in_dtype == np.uint8: + in_dtype = np.int8 + elif in_dtype == np.uint16: + in_dtype = np.int16 + if isinstance(params, HSwishActivationParameters): + lower = stats['range_in'][0]['min'] + upper = np.maximum( + np.maximum( + params.upper_bound, + params.offset), + stats['range_in'][0]['max']) + else: + lower = -params.offset + upper = params.upper_bound + + in_q = QType.from_min_max_sq( + lower, + upper, + dtype=in_dtype) + elif isinstance(params, (TanHActivationParameters, SigmoidActivationParameters)): + if in_dtype == np.int8: + in_q = QType.from_min_max_sq( + -8, + 8, + dtype=in_dtype, + forced=True) + elif in_dtype in [np.uint8, np.uint16]: + in_q = QType( + dtype=in_dtype, + scale=pow(2, -12), + zero_point=1<<(8 if in_dtype == np.uint8 else 16)) + else: + in_q = QType( + dtype=in_dtype, + scale=pow(2, -12)) + elif isinstance(params, (HTanHActivationParameters, )): + scale = 2 / pow(2, bits) + in_q = QType(scale=scale, dtype=in_dtype, forced=True) + elif isinstance(params, (LeakyActivationParameters, )): + max_out = max(abs(stats['range_out'][0]['max']), abs(stats['range_out'][0]['min'])) + scale = (2 * max_out) / pow(2, bits) + in_q = QType(scale=scale, dtype=in_dtype, forced=True) if force_out_q: - if force_out_q.signed != in_q.signed: - return None if fusion and fusion.fusion_type in ['conv_active_pool', 'conv_active']: if not isinstance(params, (SigmoidActivationParameters, HTanHActivationParameters, HSwishActivationParameters, HSigmoidActivationParameters)): @@ -71,27 +133,43 @@ def _quantize_sw(cls, params, in_qs, stats, in_dtype, out_dtype, **kwargs): else: cls.check_valid_ranges(params, stats, idx=0, dirs='out') - if (isinstance(params, ReluActivationParameters) and params.lower_bound == 0 and - in_q.dtype == np.int8): + if isinstance(params, ReluActivationParameters): max_val = params.upper_bound if params.upper_bound else stats['range_out'][0]['max'] o_q = QType.from_min_max_sq(0, max_val, dtype=out_dtype, - asymmetric=(in_q.zero_point != 0)) + asymmetric=(in_q.zero_point != 0) or out_dtype in [np.uint8, np.uint16]) in_q = deepcopy(o_q) + elif isinstance(params, TanHActivationParameters): + o_q = QType.from_min_max_sq( + min_val=-1, max_val=1, dtype=out_dtype, asymmetric=out_asym) + elif isinstance(params, SigmoidActivationParameters): + o_q = QType.from_min_max_sq( + min_val=0, max_val=1, dtype=out_dtype, asymmetric=out_asym) elif isinstance(params, LeakyActivationParameters): o_q = QType.from_min_max_sq(stats['range_out'][0]['min'], stats['range_out'][0]['max'], - dtype=out_dtype) - # force the preceeding filter to clip the negative range - in_q = deepcopy(o_q) + dtype=out_dtype, + asymmetric=out_asym) + in_q.scale = o_q.scale + elif isinstance(params, HSigmoidActivationParameters): + # hsigmoid prefer to output zeropoint 0 to represent 0 - 1 range + o_q = QType.from_min_max_sq( + min_val=0, max_val=1, dtype=out_dtype, asymmetric=out_asym) + elif isinstance(params, HSwishActivationParameters): + # hswish multiplies 0-upper bound range by input so take the upper bound from stats + o_q = QType.from_min_max_sq(stats['range_out'][0]['min'], + stats['range_out'][0]['max'], + dtype=out_dtype, + asymmetric=out_asym) else: o_q = QType.from_min_max_sq(stats['range_out'][0]['min'], stats['range_out'][0]['max'], - dtype=out_dtype) + dtype=out_dtype, + asymmetric=out_asym) qrec = QRec.scaled(in_qs=[in_q], out_qs=[o_q]) - qrec = cls.compute_scales(params, qrec) + qrec = cls.compute_cache(params, qrec, stats) return qrec @classmethod @@ -99,87 +177,127 @@ def get_prefered_input_dtypes(cls, params, **kwargs): return [np.int8] @classmethod - def compute_scales(cls, params, qrec): - if isinstance(params, (SigmoidScaledSymmetricMult, TanHActivationParameters)): - compute_in_out_scale(qrec, extra_scale=QType.Pow2( - bits=32, q=7, signed=True).scale/qrec.in_qs[0].scale) - elif isinstance(params, HSwishActivationParameters): - compute_in_out_scale(qrec, extra_scale=qrec.in_qs[0].scale * 1/6) + def compute_cache(cls, params, qrec, stats): + scale_mul_biases_q = MultMulBiasScaleQType(dtype=np.uint8) + qrec.cache['scale_mul_biases_q'] = scale_mul_biases_q + if isinstance(params, (ReluActivationParameters)): + if params.upper_bound: + qrec.cache['upper_bound'] = qrec.in_qs[0].quantize( + params.upper_bound).astype(qrec.out_qs[0].dtype) + if params.lower_bound: + qrec.cache['lower_bound'] = qrec.in_qs[0].quantize( + params.lower_bound).astype(qrec.out_qs[0].dtype) + scale_mul_biases_q.scale = ( + qrec.in_qs[0].scale/qrec.out_qs[0].scale) + elif isinstance(params, (SigmoidActivationParameters, TanHActivationParameters)): + scale_mul_biases_q.scale = math.pow(2, -15) / qrec.out_qs[0].scale + qrec.cache["zero_point"] = qrec.out_qs[0].zero_point.astype( + qrec.out_qs[0].dtype) + elif isinstance(params, (LeakyActivationParameters)): + scale_mul_biases_q.scale = ( + qrec.in_qs[0].scale/qrec.out_qs[0].scale) + qrec.cache['leak_factor'] = np.int8( + params.leak_factor*math.pow(2, 7) + 0.5) + qrec.cache['zero_point'] = qrec.out_qs[0].zero_point.astype(qrec.out_qs[0].dtype) + elif isinstance(params, (HSwishActivationParameters, HSigmoidActivationParameters)): + scale = (qrec.in_qs[0].scale * params.mult)/qrec.out_qs[0].scale + if isinstance(params, HSwishActivationParameters): + # HSwish multiplies HSigmoid by input + scale *= qrec.in_qs[0].scale + scale_mul_biases_q.scale = scale + qrec.cache['offset'] = qrec.in_qs[0].quantize( + params.offset).astype(qrec.out_qs[0].dtype) + qrec.cache['zero_point'] = qrec.out_qs[0].zero_point + qrec.cache['upper_bound'] = qrec.in_qs[0].quantize( + params.upper_bound).astype(qrec.out_qs[0].dtype) else: - compute_in_out_scale(qrec) + scale_mul_biases_q.scale = ( + qrec.in_qs[0].scale/qrec.out_qs[0].scale) return qrec @params_type(ActivationParameters) -@in_qs_constraint({'dtype': np.int8}) +@in_qs_constraint({'dtype': {np.int8, np.int16, np.int32}}) @out_qs_constraint({'dtype': np.int8}) -class ActivationMultSW8x8(ActivationMultSWBase): +@option_constraint(force_output_size={8, None}) +class ActivationMultSW_I_I8(ActivationMultSWBase): @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): - return cls._quantize_sw(params, in_qs, stats, np.int8, np.int8, **kwargs) + return cls._quantize_sw(params, in_qs, stats, in_qs[0].dtype, np.int8, out_asym=False, **kwargs) -@params_type(ActivationParameters) -@in_qs_constraint({'dtype': np.int32}) -@out_qs_constraint({'dtype': np.int8}) +@params_type(HSwishActivationParameters, HSigmoidActivationParameters) +@in_qs_constraint({'dtype': {np.int8, np.int16, np.int32}}) +@out_qs_constraint({'dtype': np.uint8}) +@option_constraint(force_output_size={8, None}) @priority(2) -class ActivationMultSW32x8(ActivationMultSWBase): +class ActivationMultSW_HSwish_I_U8(ActivationMultSWBase): + @classmethod + def _get_in_qs_from_stats(cls, params, stats, in_qs, **kwargs): + dtype = in_qs and in_qs[0] and in_qs[0].dtype + if dtype == np.uint16: + dtype = np.int16 + else: + dtype = np.int8 + return [QType.from_min_max_sq( + stats['range_in'][0]['min'], + stats['range_in'][0]['max'], + dtype=dtype)] + @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): - return cls._quantize_sw(params, in_qs, stats, np.int32, np.int8, **kwargs) + return cls._quantize_sw(params, in_qs, stats, in_qs[0].dtype, np.uint8, out_asym=False, **kwargs) -@params_type(ActivationParameters) -@in_qs_constraint({'dtype': np.int16}) -@out_qs_constraint({'dtype': np.int16}) -@priority(2) -class ActivationMultSW16x16(ActivationMultSWBase): +@params_type(HSwishActivationParameters, HSigmoidActivationParameters) +@in_qs_constraint({'dtype': {np.int8, np.int16, np.int32}}) +@out_qs_constraint({'dtype': np.uint16}) +@option_constraint(force_output_size=16) +class ActivationMultSW_HSwish_I_U16(ActivationMultSWBase): + @classmethod + def _get_in_qs_from_stats(cls, params, stats, in_qs, **kwargs): + dtype = in_qs and in_qs[0] and in_qs[0].dtype + if dtype == np.uint16: + dtype = np.int16 + else: + dtype = np.int8 + return [QType.from_min_max_sq( + stats['range_in'][0]['min'], + stats['range_in'][0]['max'], + dtype=dtype)] + @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): - return cls._quantize_sw(params, in_qs, stats, np.int16, np.int16, **kwargs) + return cls._quantize_sw(params, in_qs, stats, in_qs[0].dtype, np.uint16, out_asym=False, **kwargs) @params_type(ActivationParameters) -@in_qs_constraint({'dtype': np.int32}) +@in_qs_constraint({'dtype': {np.int8, np.int16, np.int32}}) @out_qs_constraint({'dtype': np.int16}) -@priority(2) -class ActivationMultSW32x16(ActivationMultSWBase): +@option_constraint(force_output_size=16) +class ActivationMultSW_I_I16(ActivationMultSWBase): @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): - return cls._quantize_sw(params, in_qs, stats, np.int32, np.int16, **kwargs) + return cls._quantize_sw(params, in_qs, stats, in_qs[0].dtype, np.int16, out_asym=False, **kwargs) -@params_type(ReluActivationParameters) -@in_qs_constraint({'dtype': {np.uint8, np.uint16, np.int8, np.int16}, 'attr': {'ne16': True}}) -@out_qs_constraint({'dtype': {np.uint8, np.uint16, np.int8, np.int16}}) -@priority(3) -class ActivationMultNe16(MultQuantizionHandler): +@params_type(LeakyActivationParameters, TanHActivationParameters, SigmoidActivationParameters, ReluActivationParameters) +@in_qs_constraint({'dtype': {np.uint8, np.int32}}) +@out_qs_constraint({'dtype': np.uint8}) +@option_constraint(force_output_size={8, None}) +class ActivationMultSW_U_U8(ActivationMultSWBase): + # This handler should be called only for NE16 for the moment --> out is asym @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): - force_out_qs, out_dtype = cls.get_mult_opts(**kwargs) - force_out_q = force_out_qs and force_out_qs[0] - in_q = in_qs[0] - if params.lower_bound != 0: - raise NotImplementedError( - 'relu with non zero lower bound is not implemented for NE16 quantizer') - cls.check_valid_ranges(params, stats, idx=0, dirs='out') - if force_out_q: - # since the relu is done by setting 0 zero point and scaling to the upper bound - # we cannot be forced to something that does not meet this requirement - if not force_out_q.zero_point_asymmetric_zero: - return None - if params.upper_bound is not None and not np.isclose(force_out_q.max, params.upper_bound, atol=0.01): - return None - # if the output has been forced then propagate it - in_q = force_out_q - else: - upper = params.upper_bound if params.upper_bound is not None else stats[ - 'range_out'][0]['max'] - in_q = QType.from_min_max_sq( - 0, upper, dtype=in_q.dtype, asymmetric=True, - ne16=True, dont_copy_attr=['ne16']) - o_q = deepcopy(in_q) - o_q.set_forced() - qrec = QRec.scaled(in_qs=[in_q], out_qs=[o_q], ne16=True) - compute_in_out_scale(qrec) - return qrec + return cls._quantize_sw(params, in_qs, stats, in_qs[0].dtype, np.uint8, out_asym=True, **kwargs) + + +@params_type(LeakyActivationParameters, TanHActivationParameters, SigmoidActivationParameters, ReluActivationParameters) +@in_qs_constraint({'dtype': {np.uint16, np.int32}}) +@out_qs_constraint({'dtype': np.uint16}) +@option_constraint(force_output_size=16) +class ActivationMultSW_U_U16(ActivationMultSWBase): + # This handler should be called only for NE16 for the moment --> out is asym + @classmethod + def _quantize(cls, params, in_qs, stats, **kwargs): + return cls._quantize_sw(params, in_qs, stats, in_qs[0].dtype, np.uint16, out_asym=True, **kwargs) diff --git a/tools/nntool/quantization/multiplicative/quantizers/add_sub_mult.py b/tools/nntool/quantization/multiplicative/quantizers/add_sub_mult.py index ca42f4f5f..8f9d5832b 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/add_sub_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/add_sub_mult.py @@ -1,4 +1,4 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS +# Copyright (C) 2020, 2021, 2022 GreenWaves Technologies, SAS # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -17,6 +17,7 @@ import numpy as np from graph.types import MatrixAddParameters, MatrixSubParameters +from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType from quantization.new_qrec import QRec from quantization.qtype import QType from quantization.unified_quantization_handler import (in_qs_constraint, @@ -37,6 +38,7 @@ def _quantize_sw(cls, params, in_qs, stats, inout_dtype, asym=False, **kwargs): params, MatrixAddParameters) else None if not asym: in_qs = cls.force_symmetric_and_dtype(in_qs) + if in_qs is None: return None @@ -61,8 +63,42 @@ def _quantize_sw(cls, params, in_qs, stats, inout_dtype, asym=False, **kwargs): in_qs = [in_q.set_forced(flags=['dtype']) for in_q in in_qs] else: o_q.set_forced(flags=['dtype', 'zero_point']) - in_qs = [in_q.set_forced(flags=['dtype', 'zero_point']) for in_q in in_qs] - return QRec.scaled(in_qs=in_qs, out_qs=[o_q], scaled_idx=scaled_idx, ne16=asym) + in_qs = [in_q.set_forced(flags=['dtype', 'zero_point']) + for in_q in in_qs] + qrec = QRec.scaled(in_qs=in_qs, out_qs=[o_q], ne16=asym) + + if scaled_idx is None: + scaled_idx = (1 if qrec.in_qs[1].scale > + qrec.in_qs[0].scale else 0) + qrec.cache['scaled_idx'] = scaled_idx + + not_scaled_idx = 0 if scaled_idx else 1 + scale_mul_biases_q = qrec.cache['scale_mul_biases_q'] = MultMulBiasScaleQType( + dtype=np.uint8) + scale_mul_biases_q.scale = qrec.in_qs[not_scaled_idx].scale / \ + qrec.out_qs[0].scale + + scale_in_mul_biases_q = qrec.cache['scale_in_mul_biases_q'] = MultMulBiasScaleQType( + dtype=np.uint8) + scale_in_mul_biases_q.scale = qrec.in_qs[scaled_idx].scale / \ + qrec.in_qs[not_scaled_idx].scale + + if qrec.in_qs[0].zero_point or qrec.in_qs[1].zero_point or qrec.out_qs[0].zero_point: + # (C - Zc)*Sc = (A - Za)*Sa + (B - Zb)*Sb = + # C = Sa/Sc*(A + B*Sb/Sa - Za - Zb*Sb/Sa) + Zc = + # = Sa/Sc*(A + B*Sb/Sa) + (Zc - Sa/Sc*(Za + Zb*Sb/Sa)) + # |---------- bias ----------| + add_bias = ( + qrec.out_qs[0].zero_point - qrec.cache['scale_mul_biases_q'].scale * + (qrec.in_qs[not_scaled_idx].zero_point + + scale_in_mul_biases_q.scale * qrec.in_qs[scaled_idx].zero_point) + ) + else: + add_bias = 0 + + qrec.cache['add_bias_offset'] = np.round(add_bias).astype(np.int16) + return qrec + @params_type(MatrixAddParameters, MatrixSubParameters) @in_qs_constraint({'dtype': np.int8}, @@ -73,6 +109,7 @@ class AddSubMult8x8(AddSubMultBase): def _quantize(cls, params, in_qs, stats, **kwargs): return cls._quantize_sw(params, in_qs, stats, np.int8, **kwargs) + @params_type(MatrixAddParameters, MatrixSubParameters) @in_qs_constraint({'dtype': np.int16}, {'dtype': np.int16}) @@ -82,6 +119,7 @@ class AddSubMult16x16(AddSubMultBase): def _quantize(cls, params, in_qs, stats, **kwargs): return cls._quantize_sw(params, in_qs, stats, np.int16, **kwargs) + @params_type(MatrixAddParameters, MatrixSubParameters) @in_qs_constraint({'dtype': np.uint8}, {'dtype': np.uint8}) diff --git a/tools/nntool/quantization/multiplicative/quantizers/concat_mult.py b/tools/nntool/quantization/multiplicative/quantizers/concat_mult.py index 814c711d6..2d9bae1b9 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/concat_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/concat_mult.py @@ -30,8 +30,8 @@ @params_type(ConcatParameters) -@in_qs_constraint(MatchAll({'dtype': set([np.int8, np.uint8])})) -@out_qs_constraint({'dtype': set([np.int8, np.uint8])}) +@in_qs_constraint(MatchAll({'dtype': {np.int8, np.uint8, np.int16, np.uint16}})) +@out_qs_constraint({'dtype': {np.int8, np.uint8, np.int16, np.uint16}}) @needs_stats(False) class ConcatMult(MultQuantizionHandler, ConcatMixin): @@ -47,6 +47,13 @@ def _get_common_q(cls, in_qs): # fits the most int bits # TODO - Need to handle unsigned / signed # take maximum amount of inputs of a type to force that type + + # get min and max representable range from each QType + # get max size dtype qtypes + # if one can represent range then return that + # else return new with same dtype + # vote for asymmetric + max_scale_idx = max( [(idx, in_q.scale) for idx, in_q in enumerate(in_qs)], key=lambda x: x[1])[0] return in_qs[max_scale_idx] diff --git a/tools/nntool/quantization/multiplicative/quantizers/constant_input_mult.py b/tools/nntool/quantization/multiplicative/quantizers/constant_input_mult.py index 0ad4f0e97..467bea16b 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/constant_input_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/constant_input_mult.py @@ -17,15 +17,18 @@ from graph.types import ConstantInputParameters from quantization.new_qrec import QRec -from quantization.qtype import QType -from quantization.quantizer_options import QTYPE_IND_OPTION +from quantization.qtype import QType, DTYPES +from quantization.quantizer_options import QTYPE_IND_OPTION, OUTPUT_SIZE_OPTION from quantization.unified_quantization_handler import (needs_stats, options, params_type) from ..mult_quantization_handler import MultQuantizionHandler -@options(QTYPE_IND_OPTION) +@options( + QTYPE_IND_OPTION, + OUTPUT_SIZE_OPTION +) @params_type(ConstantInputParameters) @needs_stats(False) class ConstantInputMult(MultQuantizionHandler): @@ -42,8 +45,12 @@ def _quantize(cls, params, in_qs, stats, **kwargs): # derive quantization from statistics else: opts = kwargs.get('opts', {}) - o_q = opts.get('qtype_ind') - if not o_q: - o_q = QType.from_array_sq(params.value, dtype=out_dtype) + output_size = opts.get('output_size') + if output_size and output_size[0]: + cur_bits = DTYPES[out_dtype][0] + bits = min(output_size[0], cur_bits) + else: + bits = None + o_q = QType.from_array_sq(params.value, dtype=out_dtype, bits=bits) o_q.is_constant = True return QRec.scaled(in_qs=[o_q], out_qs=[o_q]) diff --git a/tools/nntool/quantization/multiplicative/quantizers/conv_fusion_mult.py b/tools/nntool/quantization/multiplicative/quantizers/conv_fusion_mult.py index 1985193e8..f9caf8356 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/conv_fusion_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/conv_fusion_mult.py @@ -38,7 +38,7 @@ def check_options(params, opts=None, **kwargs): return is_ne16 if not opts.get('use_ne16'): return not is_ne16 - return is_ne16 and can_ne16(True, params) + return is_ne16 and can_ne16(params, **kwargs) return check_options diff --git a/tools/nntool/quantization/multiplicative/quantizers/dsp_mult.py b/tools/nntool/quantization/multiplicative/quantizers/dsp_mult.py index 7283859e8..d49127f47 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/dsp_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/dsp_mult.py @@ -13,12 +13,14 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from graph.types.dsp_preprocessing import MFCCPreprocessingParameters import numpy as np -from graph.types import RFFT2DPreprocessingParameters +from graph.types import (MFCCPreprocessingParameters, + RFFT2DPreprocessingParameters) from quantization.new_qrec import QRec from quantization.qtype import QType -from quantization.unified_quantization_handler import params_type, in_qs_constraint, needs_stats +from quantization.unified_quantization_handler import (in_qs_constraint, + needs_stats, + params_type) from ..mult_quantization_handler import MultQuantizionHandler @@ -27,6 +29,7 @@ MFCC_COEFF_Q = 15 DCT_TWIDDLE_Q = 7 + class DSPMultQuantHandler(MultQuantizionHandler): @classmethod def get_spectrogram_in_out_q(cls, in_q, params): @@ -34,7 +37,8 @@ def get_spectrogram_in_out_q(cls, in_q, params): fft_twiddles_q = QType.Pow2(bits=16, signed=True, q=FFT_TWIDDLES_Q) rfft_twiddles_q = QType.Pow2(bits=16, signed=True, q=FFT_TWIDDLES_Q) swap_table_q = QType.Pow2(bits=16, signed=False, q=0) - in_q = QType.Pow2(bits=16, signed=True, q=int(-np.ceil(np.log2(in_q.scale))), forced=True) + in_q = QType.Pow2(bits=16, signed=True, + q=int(-np.ceil(np.log2(in_q.scale))), forced=True) if params.is_radix4(): #in_q = QType.Pow2(bits=16, signed=True, q=12) fft_out_q = in_q.q - 2*(int(np.log2(params.n_cfft) / 2) - 2) - 1 @@ -46,7 +50,7 @@ def get_spectrogram_in_out_q(cls, in_q, params): if not params.magsquared: out_q = QType.Pow2(bits=32, signed=False, q=15) else: - out_q = QType.Pow2(bits=32, signed=False, q=15) #fft_out_q.q*2) + out_q = QType.Pow2(bits=32, signed=False, q=15) # fft_out_q.q*2) return in_q, win_q, fft_twiddles_q, swap_table_q, rfft_twiddles_q, fft_out_q, out_q @@ -61,8 +65,10 @@ def _quantize(cls, params, in_qs, stats, **kwargs): if force_out_q: return None - in_q, win_q, fft_twiddles_q, swap_table_q, rfft_twiddles_q, fft_out_q, out_q = cls.get_spectrogram_in_out_q(in_qs[0], params) - return QRec.symmetric(in_qs=[in_q, win_q, fft_twiddles_q, swap_table_q, rfft_twiddles_q], out_qs=[out_q], fft_out_q=fft_out_q) + in_q, win_q, fft_twiddles_q, swap_table_q, rfft_twiddles_q, fft_out_q, out_q = cls.get_spectrogram_in_out_q( + in_qs[0], params) + return QRec.symmetric(in_qs=[in_q, win_q, fft_twiddles_q, + swap_table_q, rfft_twiddles_q], out_qs=[out_q], fft_out_q=fft_out_q) @params_type(MFCCPreprocessingParameters) @@ -76,7 +82,8 @@ def _quantize(cls, params, in_qs, stats, **kwargs): if force_out_q: return None - in_q, win_q, fft_twiddles_q, swap_table_q, rfft_twiddles_q, fft_out_q, spect_q = cls.get_spectrogram_in_out_q(in_qs[0], params) + in_q, win_q, fft_twiddles_q, swap_table_q, rfft_twiddles_q, fft_out_q, spect_q = cls.get_spectrogram_in_out_q( + in_qs[0], params) melcoeff_q = QType.Pow2(bits=16, signed=True, q=MFCC_COEFF_Q) mel_sparsity_table_q = QType.Pow2(bits=16, signed=False, q=0) dctmat_q = QType.Pow2(bits=16, signed=True, q=DCT_TWIDDLE_Q) @@ -85,11 +92,12 @@ def _quantize(cls, params, in_qs, stats, **kwargs): elif params.mel_type == "logmelspectrogram": out_q = QType.Pow2(bits=16, signed=True, q=15-params.quant_norm) else: - out_q = QType.Pow2(bits=16, signed=True, q=15-params.quant_norm-DCT_TWIDDLE_Q) + out_q = QType.Pow2(bits=16, signed=True, q=15 - + params.quant_norm-DCT_TWIDDLE_Q) return QRec.symmetric( - in_qs=[in_q, win_q, fft_twiddles_q, swap_table_q, rfft_twiddles_q, mel_sparsity_table_q, melcoeff_q, dctmat_q], + in_qs=[in_q, win_q, fft_twiddles_q, swap_table_q, rfft_twiddles_q, + mel_sparsity_table_q, melcoeff_q, dctmat_q], out_qs=[out_q], fft_out_q=fft_out_q - ) - + ) diff --git a/tools/nntool/quantization/multiplicative/quantizers/expression_fusion_mult.py b/tools/nntool/quantization/multiplicative/quantizers/expression_fusion_mult.py index cd4be879e..6e4b47eed 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/expression_fusion_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/expression_fusion_mult.py @@ -26,14 +26,14 @@ from quantization.unified_quantization_handler import (in_qs_constraint, out_qs_constraint, params_type) - +from bfloat16 import bfloat16 from ..mult_quantization_handler import MultQuantizionHandler LOG = logging.getLogger('nntool.' + __name__) @params_type(ExpressionFusionParameters) -@in_qs_constraint(MatchAll({'dtype': {np.int8, np.uint8, np.int16, np.uint16}})) -@out_qs_constraint(MatchAll({'dtype': {np.int8, np.uint8, np.int16, np.uint16}})) +@in_qs_constraint(MatchAll({'dtype': {np.int8, np.uint8, np.int16, np.uint16, np.float16, bfloat16}})) +@out_qs_constraint(MatchAll({'dtype': {np.int8, np.uint8, np.int16, np.uint16, np.float16, bfloat16}})) class ExpressionFusionMult(MultQuantizionHandler): @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): diff --git a/tools/nntool/quantization/multiplicative/quantizers/filter_mult.py b/tools/nntool/quantization/multiplicative/quantizers/filter_mult.py index f28a6cac5..9b49b245c 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/filter_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/filter_mult.py @@ -13,15 +13,16 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from graph.types.constant_input import ConstantInputParameters -from graph.types.tensor_arithmetic import MatMulOpParameters, MatMulTransposedParameters import logging from copy import deepcopy import numpy as np -from graph.types import (Conv2DParameters, FcParameters, - HSigmoidActivationParameters, PoolingParameters, +from graph.types import (Conv2DParameters, FcParameters, FusionInputParameters, + HSigmoidActivationParameters, ReluActivationParameters, SigmoidActivationParameters) +from graph.types.constant_input import ConstantInputParameters +from graph.types.tensor_arithmetic import (MatMulTransposedParameters) +from quantization.clipping import get_clip from quantization.multiplicative.quantizers.rnn_mult_ne16 import \ limit_input_precision from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType @@ -49,14 +50,19 @@ AT_NE16_KER_OUT_ORDER = [['h', 'w', 'c']] -def can_ne16(fusion, params, G): +def can_ne16(params, G=None, cur_G=None, fusion=None, **kwargs): if not isinstance(params, (Conv2DParameters, FcParameters, MatMulTransposedParameters)): return False if isinstance(params, Conv2DParameters): if (params.is_depthwise_conv() and (params.filter.w != 3 or params.filter.h != 3)): return False elif isinstance(params, MatMulTransposedParameters): - in_nodes = [edge.from_node for edge in G.indexed_in_edges(params)] + in_nodes = [edge.from_node for edge in cur_G.indexed_in_edges(params)] + if fusion: + fusion_in_nodes = [ + edge.from_node for edge in G.indexed_in_edges(fusion)] + in_nodes = [fusion_in_nodes[node.idx] if isinstance(node, FusionInputParameters) else node + for node in in_nodes] if not isinstance(in_nodes[1], ConstantInputParameters): return False return True @@ -74,12 +80,11 @@ def check_options(params, opts=None, **kwargs): return False if not check_option(output_size, opts.get('force_output_size')): return False - fusion = kwargs.get('fusion') if opts.get('force_ne16'): return is_ne16 if not opts.get('use_ne16'): return not is_ne16 - return is_ne16 == can_ne16(fusion, params, kwargs["G"]) + return is_ne16 == can_ne16(params, **kwargs) return check_options @@ -92,7 +97,9 @@ def check_options(params, opts=None, **kwargs): ALLOW_ASYMMETRIC_OPTION, FORCE_INPUT_SIZE_OPTION, FORCE_OUTPUT_SIZE_OPTION, - HWC_OPTION + HWC_OPTION, + MAX_PRECISION_LIMIT_OPTION, + CLIP_TYPE_OPTION ) # pylint: disable=abstract-method class FilterMultBase(MultQuantizionHandler): @@ -200,24 +207,29 @@ def _quantize_sw(cls, params, in_qs, stats, in_out_dtype, **kwargs): dtype=np.int8, narrow_range=opts['narrow_weights'], bits=opts['weight_bits']) - min_val, max_val = cls.get_min_max( - fusion, stats, kwargs['all_stats'], params) + # min_val, max_val = cls.get_min_max( + # fusion, stats, kwargs['all_stats'], params) if force_out_q: o_q = force_out_q - # can't be forced to something not in_out_dtype - if o_q.dtype != in_out_dtype: + # can't be forced to something not in_out_dtype or int32 + if o_q.dtype != in_out_dtype and o_q.dtype != np.int32: return None - LOG.warning('node %s output forced to range %s/%s - actual range %s/%s %s', - params.name, o_q.min, o_q.max, min_val, max_val, - "asymmetric" if o_q.asymmetric else "symmetric") + LOG.warning(f'node {params.name} output forced to range {o_q.min}/{o_q.max} ' + f'{"asymmetric" if o_q.asymmetric else "symmetric"}') else: + cls.check_valid_ranges(params, stats, idx=0, dirs='out') + min_val, max_val = get_clip( + params.out_dims[0].shape, + 8 if in_out_dtype == np.int8 else 16, + stats['range_out'][0], + opts['clip_type']) o_q = QType.from_min_max_sq(min_val=min_val, max_val=max_val, dtype=in_out_dtype, asymmetric=opts['allow_asymmetric']) biases_q = QType( - dtype=np.int32, scale=weights_q.scale * in_q.scale) + dtype=np.int32, scale=weights_q.scale * in_q.scale, quantized_dimension=0) mul_biases_q = MultMulBiasScaleQType.from_filter( in_q, weights_q, o_q, params) @@ -267,7 +279,7 @@ def can_handle_asymmetric_input(cls, params, **kwargs): @params_type(FcParameters, Conv2DParameters) @in_qs_constraint({'dtype': np.int8}) -@out_qs_constraint({'dtype': np.int8}) +@out_qs_constraint({'dtype': set([np.int8, np.int32])}) @option_constraint(check_filter_options(False, input_size={8, None}, output_size={8, None})) class FilterSWMult8x8(FilterSWMultBase): @classmethod @@ -277,7 +289,7 @@ def _quantize(cls, params, in_qs, stats, **kwargs): @params_type(FcParameters, Conv2DParameters) @in_qs_constraint({'dtype': np.int16}) -@out_qs_constraint({'dtype': np.int16}) +@out_qs_constraint({'dtype': set([np.int8, np.int32])}) @option_constraint(check_filter_options(False, input_size={16, None}, output_size={16, None})) class FilterSWMult16x8(FilterSWMultBase): @classmethod @@ -289,7 +301,7 @@ class FilterMultNE16Base(FilterMultBase): @classmethod def _quantize_ne16(cls, params, in_qs, stats, input_dtype, **kwargs): # copy in_qs because we may modify it - in_qs = in_qs.copy() + in_qs = deepcopy(in_qs) input_bits = 16 if input_dtype in (np.uint16, np.int16) else 8 opts = kwargs['opts'] fusion = kwargs.get('fusion', None) @@ -299,39 +311,43 @@ def _quantize_ne16(cls, params, in_qs, stats, input_dtype, **kwargs): G = kwargs['G'] weights_node = cls.get_weights_node(G, fusion if fusion else params) min_val, max_val = None, None + wbits = (min(in_qs[1].bits, opts['weight_bits']) + if 'weight_bits' not in opts['set_on_node'] else opts['weight_bits']) weights_q = QType.from_array_sq(arr=weights_node.dqvalue, quantized_dimension=cls.get_quantized_dimension( params, opts), dtype=np.uint8, - narrow_range=True, - bit_pack=opts['weight_bits'], + narrow_range=opts['narrow_weights'], + bit_pack=wbits, no_compression=True, - bits=opts['weight_bits']) + bits=wbits) in_q = in_qs[0] - in_q = limit_input_precision( - params, input_bits, in_q, params.filter.sz, opts['narrow_weights'], opts['weight_bits']) - - # input dtype is either uint8 or int8 - if in_q.dtype != input_dtype: - if in_q.forced_dtype: - return None - cls.check_valid_ranges(params, stats, idx=0, dirs='in') - in_q = QType.from_min_max_sq(stats['range_in'][0]['min'], stats['range_in'][0]['max'], - dtype=input_dtype, - asymmetric=False) + if input_bits > 8: + in_q = limit_input_precision( + params, input_bits, in_q, params.filter.sz, + opts['narrow_weights'], wbits, + opts.get('max_precision_limit', + MAX_PRECISION_LIMIT_OPTION['default']), + out_ranges=stats.get('range_out'), + w_qs=[weights_q]) - min_val, max_val = cls.get_min_max( - fusion, stats, kwargs['all_stats'], params) + assert in_q.dtype == input_dtype if force_out_q: o_q = deepcopy(force_out_q) o_q.dont_copy_attr = ['ne16'] - LOG.warning('node %s output forced to range %s/%s - actual range %s/%s', - params.name, o_q.min, o_q.max, min_val, max_val) + LOG.warning( + f'node {params.name} output forced to range {o_q.min}/{o_q.max}') else: + cls.check_valid_ranges(params, stats, idx=0, dirs='out') force_output_size = opts.get('force_output_size', 8) output_dtype = np.uint8 if force_output_size == 8 else np.uint16 + min_val, max_val = get_clip( + params.out_dims[0].shape, + force_output_size, + stats['range_out'][0], + opts['clip_type']) o_q = QType.from_min_max_sq(min_val=min_val, max_val=max_val, dtype=output_dtype, @@ -339,7 +355,8 @@ def _quantize_ne16(cls, params, in_qs, stats, input_dtype, **kwargs): asymmetric=True) o_q.attr.ne16 = True biases_q = QType( - dtype=np.int32, scale=weights_q.scale * in_q.scale, ne16_biases=(input_bits!=16)) + dtype=np.int32, scale=weights_q.scale * in_q.scale, + ne16_biases=(input_bits != 16), quantized_dimension=0) mul_biases_q = MultMulBiasScaleQType.from_filter( in_q, weights_q, o_q, params) @@ -358,8 +375,6 @@ def _quantize_ne16(cls, params, in_qs, stats, input_dtype, **kwargs): prenorm = 0 mul_biases_q.pre_normalization = prenorm - # o_q.set_forced(flags=['dtype']) - # in_q.set_forced(flags=['dtype']) return QRec.scaled(in_qs=[in_q, weights_q, biases_q], out_qs=[o_q], acc_q=biases_q, @@ -382,7 +397,7 @@ def _get_in_qs_from_stats(cls, params, stats, in_qs, **kwargs): @params_type(FcParameters, Conv2DParameters) @in_qs_constraint({'dtype': np.uint8}) -@out_qs_constraint({'dtype': set([np.uint8, np.int8, np.uint16, np.int16])}) +@out_qs_constraint({'dtype': set([np.uint8, np.int8, np.uint16, np.int16, np.int32])}) @option_constraint(check_filter_options(True, input_size=set([8, None]), output_size=set([8, 16, None]))) class FilterMultNE16Feat8x8(FilterMultNE16Base): @classmethod @@ -392,7 +407,7 @@ def _quantize(cls, params, in_qs, stats, **kwargs): @params_type(FcParameters, Conv2DParameters) @in_qs_constraint({'dtype': np.uint16}) -@out_qs_constraint({'dtype': set([np.uint8, np.int8, np.uint16, np.int16])}) +@out_qs_constraint({'dtype': set([np.uint8, np.int8, np.uint16, np.int16, np.int32])}) @option_constraint(check_filter_options(True, input_size=set([16]), output_size=set([8, 16, None]))) class FilterMultNE16Feat16x8(FilterMultNE16Base): @classmethod diff --git a/tools/nntool/quantization/multiplicative/quantizers/from_stats_mult.py b/tools/nntool/quantization/multiplicative/quantizers/from_stats_mult.py index df9129c72..bd4ee3efe 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/from_stats_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/from_stats_mult.py @@ -1,4 +1,4 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS +# Copyright (C) 2020, 2022 GreenWaves Technologies, SAS # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -16,9 +16,10 @@ from copy import deepcopy import numpy as np -from graph.types import (BinaryOpParameters, - MatrixDivParameters, MatrixMulParameters, - MatScaleFusionParameters, UnaryOpParameters) +from graph.types import (BinaryOpParameters, MatrixDivParameters, + MatrixMulParameters, MatScaleFusionParameters, + UnaryOpParameters) +from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType from quantization.new_qrec import QRec from quantization.qtype import QType from quantization.qtype_constraint import MatchAll @@ -51,5 +52,7 @@ def _quantize(cls, params, in_qs, stats, **kwargs): o_q = QType.from_min_max_sq(stats['range_out'][0]['min'], stats['range_out'][0]['max'], dtype=out_dtype) + scale_mul_biases_q = MultMulBiasScaleQType(dtype=np.uint8) + scale_mul_biases_q.scale = (np.prod([qtype.scale for qtype in in_qs]) / o_q.scale) - return QRec.scaled(in_qs=in_qs, out_qs=[o_q]) + return QRec.scaled(in_qs=in_qs, out_qs=[o_q], scale_mul_biases_q=scale_mul_biases_q) diff --git a/tools/nntool/quantization/multiplicative/quantizers/generic_fusion_mult.py b/tools/nntool/quantization/multiplicative/quantizers/generic_fusion_mult.py index 9ff951800..c9767e147 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/generic_fusion_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/generic_fusion_mult.py @@ -22,36 +22,43 @@ in_qs_constraint, out_qs_constraint, params_type) +from utils.node_id import NodeId from ..mult_quantization_handler import MultQuantizionHandler +class GenericFusionMultBase(MultQuantizionHandler): + @classmethod + def _quantize(cls, params, in_qs, stats, **kwargs): + if 'out_qs' in kwargs: + return QRec.scaled(in_qs=in_qs, out_qs=kwargs['out_qs']) + fusion_G = params.subgraph + fusion_outputs = sorted(fusion_G.outputs(), key=lambda x: x.idx) + G = kwargs['G'] + qset = kwargs['qset'] + out_qs = [] + for foutp in fusion_outputs: + in_edge = fusion_G.in_edges(foutp)[0] + out_qs.append(qset[NodeId(params, in_edge.from_node)].out_qs[in_edge.from_idx]) + return QRec.scaled(in_qs=in_qs, out_qs=out_qs) + @params_type(ActivationFusionBase, MatMulOpFusionParameters, MatScaleFusionParameters, PaddedAddFusionParameters) @in_qs_constraint(MatchAll({'dtype': np.int8})) -@out_qs_constraint(MatchAll({'dtype': np.int8})) +#@out_qs_constraint(MatchAll({'dtype': np.int8})) @fusion_handler -class GenericFusionMult(MultQuantizionHandler): - @classmethod - def _quantize(cls, params, in_qs, stats, **kwargs): - out_qs = kwargs['out_qs'] - return QRec.scaled(in_qs=in_qs, out_qs=out_qs) +class GenericFusionMult(GenericFusionMultBase): + pass @params_type(ActivationFusionBase, MatMulOpFusionParameters, MatScaleFusionParameters, PaddedAddFusionParameters) @in_qs_constraint(MatchAll({'dtype': np.uint8})) -@out_qs_constraint(MatchAll({'dtype': np.uint8})) +#@out_qs_constraint(MatchAll({'dtype': np.uint8})) @fusion_handler -class GenericFusionMultU8(MultQuantizionHandler): - @classmethod - def _quantize(cls, params, in_qs, stats, **kwargs): - out_qs = kwargs['out_qs'] - return QRec.scaled(in_qs=in_qs, out_qs=out_qs) +class GenericFusionMultU8(GenericFusionMultBase): + pass @params_type(ActivationFusionBase, MatMulOpFusionParameters, MatScaleFusionParameters, PaddedAddFusionParameters) @in_qs_constraint(MatchAll({'dtype': np.uint16})) -@out_qs_constraint(MatchAll({'dtype': np.uint16})) +#@out_qs_constraint(MatchAll({'dtype': np.uint16})) @fusion_handler -class GenericFusionMultU16(MultQuantizionHandler): - @classmethod - def _quantize(cls, params, in_qs, stats, **kwargs): - out_qs = kwargs['out_qs'] - return QRec.scaled(in_qs=in_qs, out_qs=out_qs) +class GenericFusionMultU16(GenericFusionMultBase): + pass diff --git a/tools/nntool/quantization/multiplicative/quantizers/global_pooling_mult.py b/tools/nntool/quantization/multiplicative/quantizers/global_pooling_mult.py index 362479ad7..38fb1492f 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/global_pooling_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/global_pooling_mult.py @@ -20,6 +20,7 @@ from graph.types import GlobalPoolingParameters from graph.types.global_pooling import (GlobalAveragePoolParameters, GlobalSumPoolParameters) +from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType from quantization.new_qrec import QRec from quantization.qtype import QType from quantization.unified_quantization_handler import (in_qs_constraint, @@ -48,44 +49,48 @@ class GlobalPoolingMult(MultQuantizionHandler): def _quantize(cls, params, in_qs, stats, **kwargs): # copy in_qs because we may modify it in_qs = in_qs.copy() - opts = kwargs['opts'] + opts = kwargs.get('opts', {}) fusion = kwargs.get('fusion', None) force_out_qs, out_dtype = cls.get_mult_opts(**kwargs) force_out_q = force_out_qs and force_out_qs[0] - G = kwargs['G'] in_q = in_qs[0] - cls.check_valid_ranges(params, stats, idx=0, dirs='in') - min_val = stats['range_in'][0]['min'] - max_val = stats['range_in'][0]['max'] - if fusion: # Global pooling fused with activations need to have only the activation scale + #o_q = QType(scale=in_q.scale, dtype=np.int32) o_q = deepcopy(in_q) - o_q.dtype = np.int32 elif force_out_q: if force_out_q.zero_point != in_q.zero_point: return None o_q = force_out_q - LOG.warning('node %s output forced to range %s/%s %s - actual range %s/%s', - params.name, o_q.min, o_q.max, "asymmetric" if o_q.asymmetric else "symmetric", - min_val, max_val) + LOG.warning('node %s output forced to range %s/%s %s', + params.name, o_q.min, o_q.max, "asymmetric" if o_q.asymmetric else "symmetric") elif isinstance(params, GlobalAveragePoolParameters) or isinstance(params, GlobalSumPoolParameters): + cls.check_valid_ranges(params, stats, idx=0, dirs='in') + in_qs = cls.force_symmetric(in_qs) + if in_qs is None: + return None + in_q = in_qs[0] + # scaling needs to be based on stats and zero point o_q = QType.from_min_max_sq(stats['range_out'][0]['min'], stats['range_out'][0]['max'], dtype=out_dtype, - asymmetric=(stats['range_out'][0]['min'] == 0 and in_q.zero_point == -128)) + asymmetric=False) else: o_q = deepcopy(in_q) - if opts['hwc']: + if opts.get('hwc'): cls.check_order(params, [['h', 'w', 'c']], [['h', 'w', 'c']]) elif params.in_dims_hint: cls.check_order(params, [['c', 'h', 'w']], [['c', 'h', 'w']]) + scale_mul_biases_q = MultMulBiasScaleQType(dtype=np.uint8) + scale_mul_biases_q.scale = in_q.scale/o_q.scale return QRec.scaled(in_qs=[in_q], - out_qs=[o_q]) + out_qs=[o_q], + scale_mul_biases_q=scale_mul_biases_q + ) @classmethod def _get_in_qs_from_stats(cls, params, stats, in_qs, **kwargs): diff --git a/tools/nntool/quantization/multiplicative/quantizers/gru_mult_16_8.py b/tools/nntool/quantization/multiplicative/quantizers/gru_mult_16_8.py index 1cdb7efcc..4358fd900 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/gru_mult_16_8.py +++ b/tools/nntool/quantization/multiplicative/quantizers/gru_mult_16_8.py @@ -34,7 +34,6 @@ params_type) from ..mult_quantization_handler import MultQuantizionHandler -from .rescale_constant_mixin import RescaleConstantMixin LOG = logging.getLogger('nntool.' + __name__) @@ -55,7 +54,7 @@ @in_qs_constraint({'dtype': np.int16}) @out_qs_constraint({'dtype': np.int16}) @option_constraint(force_external_size=16, use_ne16={None, False}) -class GRUMult16x8(RescaleConstantMixin, MultQuantizionHandler): +class GRUMult16x8(MultQuantizionHandler): @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): force_out_qs, out_dtype = cls.get_mult_opts(**kwargs) @@ -117,14 +116,10 @@ def _quantize(cls, params, in_qs, stats, **kwargs): in_qs[names['h_state']] = state_q o_q = state_q - in_qs[names['z_b']].scale = int_scale - in_qs[names['z_b']].dtype = BIAS_DTYPE - in_qs[names['r_b']].scale = int_scale - in_qs[names['r_b']].dtype = BIAS_DTYPE - in_qs[names['w_h_b']].scale = in_scale * wWh_scale - in_qs[names['w_h_b']].dtype = BIAS_DTYPE - in_qs[names['r_h_b']].scale = state_scale * rWh_scale - in_qs[names['r_h_b']].dtype = BIAS_DTYPE + in_qs[names['z_b']] = QType(scale=int_scale, dtype=BIAS_DTYPE) + in_qs[names['r_b']] = QType(scale=int_scale, dtype=BIAS_DTYPE) + in_qs[names['w_h_b']] = QType(scale=in_scale * wWh_scale, dtype=BIAS_DTYPE) + in_qs[names['r_h_b']] = QType(scale=state_scale * rWh_scale, dtype=BIAS_DTYPE) return QRec.scaled( in_qs=in_qs, diff --git a/tools/nntool/quantization/multiplicative/quantizers/gru_mult_8_8.py b/tools/nntool/quantization/multiplicative/quantizers/gru_mult_8_8.py index 271504ad9..682b5729d 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/gru_mult_8_8.py +++ b/tools/nntool/quantization/multiplicative/quantizers/gru_mult_8_8.py @@ -29,7 +29,6 @@ params_type) from ..mult_quantization_handler import MultQuantizionHandler -from .rescale_constant_mixin import RescaleConstantMixin LOG = logging.getLogger('nntool.' + __name__) @@ -49,7 +48,7 @@ @in_qs_constraint({'dtype': np.int8}) @out_qs_constraint({'dtype': np.int8}) @option_constraint(force_external_size={8, None}, use_ne16={False, None}) -class GRUMult8x8(RescaleConstantMixin, MultQuantizionHandler): +class GRUMult8x8(MultQuantizionHandler): @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): force_out_qs, out_dtype = cls.get_mult_opts(**kwargs) @@ -124,14 +123,10 @@ def _quantize(cls, params, in_qs, stats, **kwargs): in_qs[0].scale = in_scale o_q.scale = state_scale - in_qs[names['z_b']].scale = in_scale * rWz_scale - in_qs[names['z_b']].dtype = BIAS_DTYPE - in_qs[names['r_b']].scale = in_scale * rWr_scale - in_qs[names['r_b']].dtype = BIAS_DTYPE - in_qs[names['w_h_b']].scale = in_scale * wWh_scale - in_qs[names['w_h_b']].dtype = BIAS_DTYPE - in_qs[names['r_h_b']].scale = in_scale * rWh_scale - in_qs[names['r_h_b']].dtype = BIAS_DTYPE + in_qs[names['z_b']] = QType(scale=in_scale * rWz_scale, dtype=BIAS_DTYPE) + in_qs[names['r_b']] = QType(scale=in_scale * rWr_scale, dtype=BIAS_DTYPE) + in_qs[names['w_h_b']] = QType(scale=in_scale * wWh_scale, dtype=BIAS_DTYPE) + in_qs[names['r_h_b']] = QType(scale=in_scale * rWh_scale, dtype=BIAS_DTYPE) in_qs[names['w_2_z_w']].scale = wWz_scale in_qs[names['w_2_r_w']].scale = wWr_scale diff --git a/tools/nntool/quantization/multiplicative/quantizers/gru_mult_ne16.py b/tools/nntool/quantization/multiplicative/quantizers/gru_mult_ne16.py index c628ac8a9..7e578f4e3 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/gru_mult_ne16.py +++ b/tools/nntool/quantization/multiplicative/quantizers/gru_mult_ne16.py @@ -13,6 +13,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from functools import reduce import logging import math from copy import deepcopy @@ -37,8 +38,7 @@ params_type) from utils.stats_funcs import calc_bits -from ..mult_quantization_handler import MultQuantizionHandler -from .rescale_constant_mixin import RescaleConstantMixin +from .rnn_mult_ne16 import NE16RNNMultQuantizionHandler, calc_bias_offset, calc_weight_q LOG = logging.getLogger('nntool.' + __name__) @@ -55,15 +55,32 @@ def get_max_or_one(stat): gate_max = np.maximum(np.abs(stat['min']), np.abs(stat['max'])) return np.where(gate_max == 0, 1.0, gate_max) +def combine_stats(stats, *keys): + stats = [stats[k] for k in keys if k in stats] + if not stats: + return None + def reduction(state, item): + return {'min': min(state['min'], item['min']), 'max': max(state['max'], item['max'])} + return reduce(reduction, stats) + +def combine_qtype_ranges(qtypes, *indexes): + qtypes = [qtypes[i] for i in indexes if qtypes[i] is not None] + if not qtypes: + return None + def reduction(state, item): + if state is None: + return {'min': item.min_val, 'max': item.max_val} + return {'min': np.min(np.minimum(state['min'], item.min_val)), 'max': np.max(np.maximum(state['max'], item.max_val))} + return reduce(reduction, qtypes, None) @options( NE16_WEIGHT_BITS_OPTION, FORCE_EXTERNAL_SIZE_OPTION, NARROW_WEIGHTS_OPTION, USE_NE16_OPTION, - NARROW_STATE_OPTION + MAX_PRECISION_LIMIT_OPTION ) -class GRUMultMultNE16Base(RescaleConstantMixin, MultQuantizionHandler): +class GRUMultMultNE16Base(NE16RNNMultQuantizionHandler): @classmethod def _quantize_gru(cls, params, in_qs, stats, input_bits, **kwargs): @@ -93,59 +110,71 @@ def _quantize_gru(cls, params, in_qs, stats, input_bits, **kwargs): names = {val: idx for idx, val in enumerate( GRUParameters.INPUT_NAMES)} - # output/state is always Q15 or Q7 symmetric - o_q = in_qs[names['h_state']] = QType.from_min_max_sq( + # o_q = in_qs[names['h_state']] = QType.from_min_max_sq( + # min_val=-1, + # max_val=1, + # dtype=in_out_dtype, + # narrow_range=opts['narrow_state']) + + o_q = in_qs[names['h_state']] = QType( + q=15 if input_bits == 16 else 7, + zero_point=in_out_dtype(math.pow(2, input_bits-1)), min_val=-1, max_val=1, - dtype=in_out_dtype, - narrow_range=opts['narrow_state']) + dtype=in_out_dtype) # set weight qtypes int_num_inp = roundup(params.n_inputs, input_bits == 16) int_num_states = roundup(params.n_states, input_bits == 16) - woffs = {} + for gate in ['z', 'r', 'h']: + i_idx = names[f'w_2_{gate}_w'] + r_idx = names[f'r_2_{gate}_w'] + + in_qs[i_idx] = calc_weight_q(in_edges[i_idx].from_node, (params.n_states, params.n_inputs), + (params.n_states, int_num_inp), + opts['weight_bits'], + opts.get('narrow_weights')) + + in_qs[r_idx] = calc_weight_q(in_edges[r_idx].from_node, (params.n_states, params.n_states), + (params.n_states, int_num_states), + opts['weight_bits'], + opts.get('narrow_weights')) + + # check for overflow in_q = limit_input_precision( params, input_bits, in_q, int_num_inp, opts['narrow_weights'], - opts['weight_bits']) + opts['weight_bits'], + opts.get('max_precision_limit', MAX_PRECISION_LIMIT_OPTION['default']), + w_qs=[in_qs[names[f'w_2_{gate}_w']] for gate in ['z', 'r']], + out_ranges=[stats.get(f'range_{gate}_gate_inp') for gate in ['z', 'r']]) - # o_q = limit_input_precision( - # params, - # input_bits, - # o_q, - # int_num_states, - # opts['narrow_weights'], - # opts['weight_bits'], - # extra_correction=-1 if opts.get('narrow_state') else 0) + # The state out is not limited but include this to print warnings + o_q = limit_input_precision( + params, + input_bits, + o_q, + int_num_states, + opts['narrow_weights'], + opts['weight_bits'], + 0, + w_qs=[in_qs[names[f'r_2_{gate}_w']] for gate in ['z', 'r', 'h']], + out_ranges=[stats.get(f'range_{gate}_gate_state') for gate in ['z', 'r', 'h']]) + # setup zero offset bias adjustment + woffs = {} for gate in ['z', 'r', 'h']: i_idx = names[f'w_2_{gate}_w'] r_idx = names[f'r_2_{gate}_w'] - woffs[gate] = woff_gate = [None, None] - woff_gate[0] = calculatate_weight_q( - in_qs, - in_edges, - i_idx, - in_q.zero_point[0], - (params.n_states, params.n_inputs), - (params.n_states, int_num_inp), - opts['weight_bits'], - opts.get('narrow_weights')) - - woff_gate[1] = calculatate_weight_q( - in_qs, - in_edges, - r_idx, - o_q.zero_point[0], - (params.n_states, params.n_states), - (params.n_states, int_num_states), - opts['weight_bits'], - opts.get('narrow_weights')) + woffs[gate] = [ + calc_bias_offset(in_edges[i_idx].from_node, in_qs[i_idx], in_q.zero_point), + calc_bias_offset(in_edges[r_idx].from_node, in_qs[r_idx], o_q.zero_point), + ] # get weight scales scale_pairs = {chan: ('w_2_%s_w' % chan, 'r_2_%s_w' % chan) @@ -207,6 +236,7 @@ def _quantize_gru(cls, params, in_qs, stats, input_bits, **kwargs): dtype=np.int32, scale=i_pscales[gate], offset=i_zp_b, + quantized_dimension=0 ) else: i_zp_b = woffs[gate][0] * qscale.qbiases.astype( @@ -216,6 +246,7 @@ def _quantize_gru(cls, params, in_qs, stats, input_bits, **kwargs): dtype=np.int32, scale=i_pscales[gate] / qscale.qbiases, offset=i_zp_b, + quantized_dimension=0 ) scale_qtypes[f"r_2_{gate}_q"] = qscale = MultMulBiasScaleQType( @@ -234,7 +265,8 @@ def _quantize_gru(cls, params, in_qs, stats, input_bits, **kwargs): dtype=np.int32, scale=r_pscales[gate], offset=r_zp_b, - interleaved_values=interleaved_values + interleaved_values=interleaved_values, + quantized_dimension=0 ) else: r_zp_b = woffs[gate][1] * qscale.qbiases.astype( @@ -243,7 +275,8 @@ def _quantize_gru(cls, params, in_qs, stats, input_bits, **kwargs): dtype=np.int32, scale=r_pscales[gate] / qscale.qbiases, offset=r_zp_b, - interleaved_values=interleaved_values + interleaved_values=interleaved_values, + quantized_dimension=0 ) # NOTE - for 16 bit pre-normalize the scales to give us room but make sure it isn't negative @@ -265,7 +298,7 @@ def _quantize_gru(cls, params, in_qs, stats, input_bits, **kwargs): 'act_in': int_scale, 'act_out': out_tanh_sig_scale, 'act_in_q': act_in_q, - 'act_out_q': act_out_q + 'act_out_q': act_out_q } scale_qtypes['i_qtype'] = QType(q=act_in_q, dtype=np.int32) diff --git a/tools/nntool/quantization/multiplicative/quantizers/input_mult.py b/tools/nntool/quantization/multiplicative/quantizers/input_mult.py index dddbc5893..9a35a16ce 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/input_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/input_mult.py @@ -19,7 +19,7 @@ from graph.types import InputParameters from quantization.new_qrec import QRec from quantization.qtype import QType -from quantization.quantizer_options import ALLOW_ASYMMETRIC_OPTION +from quantization.quantizer_options import ALLOW_ASYMMETRIC_OPTION, QTYPE_IND_OPTION from quantization.unified_quantization_handler import (options, out_qs_constraint, params_type) @@ -28,7 +28,8 @@ @options( - ALLOW_ASYMMETRIC_OPTION + ALLOW_ASYMMETRIC_OPTION, + QTYPE_IND_OPTION ) @params_type(InputParameters) @out_qs_constraint({'dtype': set([np.int8, np.uint8, np.int16, np.uint16])}) @@ -40,8 +41,11 @@ def _quantize(cls, params, in_qs, stats, **kwargs): out_dtype = in_qs[0].dtype force_out_q = force_out_qs and force_out_qs[0] opts = kwargs['opts'] + o_q_ind = opts.get('qtype_ind') if force_out_q: o_q = deepcopy(force_out_q) + elif o_q_ind: + o_q = deepcopy(o_q_ind) else: cls.check_valid_ranges(params, stats, idx=0, dirs='out') o_q = QType.from_min_max_sq(stats['range_out'][0]['min'], diff --git a/tools/nntool/quantization/multiplicative/quantizers/lstm_mult_16_8.py b/tools/nntool/quantization/multiplicative/quantizers/lstm_mult_16_8.py index a19410fed..4a7824526 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/lstm_mult_16_8.py +++ b/tools/nntool/quantization/multiplicative/quantizers/lstm_mult_16_8.py @@ -31,7 +31,6 @@ from utils.stats_funcs import calc_bits from ..mult_quantization_handler import MultQuantizionHandler -from .rescale_constant_mixin import RescaleConstantMixin LOG = logging.getLogger('nntool.' + __name__) @@ -54,7 +53,7 @@ def get_max(stat): @in_qs_constraint({'dtype': np.int16}) @out_qs_constraint({'dtype': np.int16}) @option_constraint(force_external_size=16, use_ne16={None, False}) -class LSTMMultMult16x8(RescaleConstantMixin, MultQuantizionHandler): +class LSTMMultMult16x8(MultQuantizionHandler): @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): @@ -132,16 +131,18 @@ def _quantize(cls, params, in_qs, stats, **kwargs): in_q.max_val, dtype=np.int8, narrow_range=opts.get('narrow_weights'), + bits = opts['weight_bits'], dont_generate_value=True) - in_qs[names[scale_pair[0]]].bits = opts['weight_bits'] + # in_qs[names[scale_pair[0]]].bits = opts['weight_bits'] in_q = in_qs[names[scale_pair[1]]] in_qs[names[scale_pair[1]]] = QType.from_min_max_sq( in_q.min_val, in_q.max_val, dtype=np.int8, narrow_range=opts.get('narrow_weights'), + bits = opts['weight_bits'], concatenated_nodes=[edges[names[scale_pair[0]]].from_node.name]) - in_qs[names[scale_pair[1]]].bits = opts['weight_bits'] + # in_qs[names[scale_pair[1]]].bits = opts['weight_bits'] # get weight scales w_scales = [(in_qs[names[namei]].scale, in_qs[names[namer]].scale) diff --git a/tools/nntool/quantization/multiplicative/quantizers/lstm_mult_8_8.py b/tools/nntool/quantization/multiplicative/quantizers/lstm_mult_8_8.py index c97eb13f4..d0107585f 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/lstm_mult_8_8.py +++ b/tools/nntool/quantization/multiplicative/quantizers/lstm_mult_8_8.py @@ -33,7 +33,6 @@ from utils.stats_funcs import calc_bits from ..mult_quantization_handler import MultQuantizionHandler -from .rescale_constant_mixin import RescaleConstantMixin LOG = logging.getLogger('nntool.' + __name__) @@ -48,7 +47,7 @@ @in_qs_constraint({'dtype': np.int8}) @out_qs_constraint({'dtype': np.int8}) @option_constraint(force_external_size={8, None}, use_ne16={None, False}) -class LSTMMultMult8x8(RescaleConstantMixin, MultQuantizionHandler): +class LSTMMultMult8x8(MultQuantizionHandler): @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): force_out_qs, out_dtype = cls.get_mult_opts(**kwargs) @@ -121,16 +120,18 @@ def _quantize(cls, params, in_qs, stats, **kwargs): in_q.max_val, dtype=np.int8, narrow_range=opts.get('narrow_weights'), + bits = opts['weight_bits'], dont_generate_value=True) - in_qs[names[scale_pair[0]]].bits = opts['weight_bits'] + # in_qs[names[scale_pair[0]]].bits = opts['weight_bits'] in_q = in_qs[names[scale_pair[1]]] in_qs[names[scale_pair[1]]] = QType.from_min_max_sq( in_q.min_val, in_q.max_val, dtype=np.int8, + bits = opts['weight_bits'], narrow_range=opts.get('narrow_weights'), concatenated_nodes=[edges[names[scale_pair[0]]].from_node.name]) - in_qs[names[scale_pair[1]]].bits = opts['weight_bits'] + # in_qs[names[scale_pair[1]]].bits = opts['weight_bits'] w_scales = [(in_qs[names[namei]].scale, in_qs[names[namer]].scale) for k, (namei, namer) in scale_pairs.items()] @@ -209,8 +210,7 @@ def _quantize(cls, params, in_qs, stats, **kwargs): scale_qtypes['i_qtype'] = QType(q=int_q, bits=32, signed=True) # set biases to output of perceptron for gate in ['i', 'o', 'c', 'f']: - in_qs[names[f"{gate}_b"]].scale = r_pscales[gate] - in_qs[names[f"{gate}_b"]].dtype = np.int32 + in_qs[names[f"{gate}_b"]] = QType(scale=r_pscales[gate], dtype=np.int32) if params.lstm_output_c_state: out_qs = [o_q, in_qs[names['c_state']]] else: diff --git a/tools/nntool/quantization/multiplicative/quantizers/lstm_mult_ne16.py b/tools/nntool/quantization/multiplicative/quantizers/lstm_mult_ne16.py index 9406c2232..b906e52d6 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/lstm_mult_ne16.py +++ b/tools/nntool/quantization/multiplicative/quantizers/lstm_mult_ne16.py @@ -32,8 +32,7 @@ params_type) from utils.stats_funcs import calc_bits -from ..mult_quantization_handler import MultQuantizionHandler -from .rescale_constant_mixin import RescaleConstantMixin +from .rnn_mult_ne16 import NE16RNNMultQuantizionHandler, calc_bias_offset, calc_weight_q LOG = logging.getLogger('nntool.' + __name__) @@ -56,9 +55,10 @@ def get_max_or_one(stat): FORCE_EXTERNAL_SIZE_OPTION, NARROW_WEIGHTS_OPTION, USE_NE16_OPTION, - NARROW_STATE_OPTION + NARROW_STATE_OPTION, + MAX_PRECISION_LIMIT_OPTION ) -class LSTMMultMultNE16Base(RescaleConstantMixin, MultQuantizionHandler): +class LSTMMultMultNE16Base(NE16RNNMultQuantizionHandler): @classmethod def _quantize_lstm(cls, params, in_qs, stats, input_bits, **kwargs): @@ -81,6 +81,14 @@ def _quantize_lstm(cls, params, in_qs, stats, input_bits, **kwargs): in_q = in_qs[0] + # if in_q.dtype != in_out_dtype: + # cls.check_valid_ranges(params, stats, idx=0, dirs='in') + # in_q = in_qs[0] = QType.from_min_max_sq( + # min_val=stats['range_in'][0]['min'], + # max_val=stats['range_in'][0]['max'], + # dtype=in_out_dtype, + # asymmetric=True) + cls.check_valid_ranges(params, stats, idx=0, dirs='out') in_edges = G.indexed_in_edges(params.name) @@ -137,7 +145,24 @@ def _quantize_lstm(cls, params, in_qs, stats, input_bits, **kwargs): # set weight qtypes int_num_inp = roundup(params.n_inputs, input_bits == 16) int_num_states = roundup(params.n_states, input_bits == 16) - woffs = {} + + for gate in ['i', 'o', 'c', 'f']: + i_idx = names[f'i_2_{gate}_w'] + r_idx = names[f'r_2_{gate}_w'] + + in_qs[i_idx] = calc_weight_q( + in_edges[i_idx].from_node, + (params.n_states, params.n_inputs), + (params.n_states, int_num_inp), + opts['weight_bits'], + opts.get('narrow_weights')) + + in_qs[r_idx] = calc_weight_q( + in_edges[r_idx].from_node, + (params.n_states, params.n_states), + (params.n_states, int_num_states), + opts['weight_bits'], + opts.get('narrow_weights')) in_q = limit_input_precision( params, @@ -145,7 +170,10 @@ def _quantize_lstm(cls, params, in_qs, stats, input_bits, **kwargs): in_q, int_num_inp, opts['narrow_weights'], - opts['weight_bits']) + opts['weight_bits'], + opts.get('max_precision_limit', MAX_PRECISION_LIMIT_OPTION['default']), + w_qs=[in_qs[names[f'i_2_{gate}_w']] for gate in ['i', 'o', 'c', 'f']], + out_ranges=[stats.get(f'range_{gate}_gate_i') for gate in ['i', 'o', 'c', 'f']]) o_q = limit_input_precision( params, @@ -154,32 +182,23 @@ def _quantize_lstm(cls, params, in_qs, stats, input_bits, **kwargs): int_num_states, opts['narrow_weights'], opts['weight_bits'], - extra_correction=-1 if opts.get('narrow_state') else 0) + opts.get('max_precision_limit', + MAX_PRECISION_LIMIT_OPTION['default']), + extra_correction=-1 if opts.get('narrow_state') else 0, + w_qs=[in_qs[names[f'r_2_{gate}_w']] for gate in ['i', 'o', 'c', 'f']], + out_ranges=[stats.get(f'range_{gate}_gate_r') for gate in ['i', 'o', 'c', 'f']]) + # setup zero offset bias adjustment + woffs = {} for gate in ['i', 'o', 'c', 'f']: i_idx = names[f'i_2_{gate}_w'] r_idx = names[f'r_2_{gate}_w'] - woffs[gate] = woff_gate = [None, None] - woff_gate[0] = calculatate_weight_q( - in_qs, - in_edges, - i_idx, - in_q.zero_point[0], - (params.n_states, params.n_inputs), - (params.n_states, int_num_inp), - opts['weight_bits'], - opts.get('narrow_weights')) + woffs[gate] = [ + calc_bias_offset(in_edges[i_idx].from_node, in_qs[i_idx], in_q.zero_point), + calc_bias_offset(in_edges[r_idx].from_node, in_qs[r_idx], o_q.zero_point), + ] - woff_gate[1] = calculatate_weight_q( - in_qs, - in_edges, - r_idx, - o_q.zero_point[0], - (params.n_states, params.n_states), - (params.n_states, int_num_states), - opts['weight_bits'], - opts.get('narrow_weights')) # get weight scales scale_pairs = {chan: ('i_2_%s_w' % chan, 'r_2_%s_w' % chan) @@ -248,7 +267,8 @@ def _quantize_lstm(cls, params, in_qs, stats, input_bits, **kwargs): dtype=np.int32, scale=r_pscales[gate], offset=r_zp_b, - interleaved_values=[i_zp_b] + interleaved_values=[i_zp_b], + quantized_dimension=0 ) else: r_zp_b = woffs[gate][1] * qscale.qbiases.astype( @@ -257,7 +277,8 @@ def _quantize_lstm(cls, params, in_qs, stats, input_bits, **kwargs): dtype=np.int32, scale=r_pscales[gate] / qscale.qbiases, offset=r_zp_b, - interleaved_values=[i_zp_b] + interleaved_values=[i_zp_b], + quantized_dimension=0 ) # NOTE - for 16 bit pre-normalize the scales to give us room but make sure it isn't negative diff --git a/tools/nntool/quantization/multiplicative/quantizers/matmult_mult.py b/tools/nntool/quantization/multiplicative/quantizers/matmult_mult.py index 1b6a5e289..8b400b01d 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/matmult_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/matmult_mult.py @@ -14,21 +14,30 @@ # along with this program. If not, see . import logging -from quantization.multiplicative.quantizers.rnn_mult_ne16 import limit_input_precision, roundup -from quantization.multiplicative.quantizers.filter_mult import check_filter_options -from quantization.quantizer_options import NE16_WEIGHT_BITS_OPTION, USE_NE16_OPTION, FORCE_INPUT_SIZE_OPTION, FORCE_OUTPUT_SIZE_OPTION -from quantization.unified_quantization_handler import (in_qs_constraint, - option_constraint, - options) + import numpy as np from graph.types import (ConstantInputParameters, HSigmoidActivationParameters, MatMulOpParameters, ReluActivationParameters, SigmoidActivationParameters, TransposeParameters) +from graph.types.activations import (HSwishActivationParameters, + TanHActivationParameters) from graph.types.base import NNEdge +from graph.types.tensor_arithmetic import MatMulTransposedParameters +from quantization.multiplicative.quantizers.filter_mult import \ + check_filter_options +from quantization.multiplicative.quantizers.rnn_mult_ne16 import ( + limit_input_precision, roundup) from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType from quantization.new_qrec import QRec from quantization.qtype import QType +from quantization.quantizer_options import (FORCE_INPUT_SIZE_OPTION, + FORCE_OUTPUT_SIZE_OPTION, + MAX_PRECISION_LIMIT_OPTION, + NE16_WEIGHT_BITS_OPTION, + USE_NE16_OPTION) from quantization.unified_quantization_handler import (in_qs_constraint, + option_constraint, + options, out_qs_constraint, params_type) from utils.graph import GraphView @@ -38,11 +47,13 @@ LOG = logging.getLogger('nntool.' + __name__) + @options( NE16_WEIGHT_BITS_OPTION, USE_NE16_OPTION, FORCE_INPUT_SIZE_OPTION, FORCE_OUTPUT_SIZE_OPTION, + MAX_PRECISION_LIMIT_OPTION ) class MatMultMultBase(MultQuantizionHandler): @classmethod @@ -75,9 +86,12 @@ def move_constant(cls, G: GraphView, params, in_qs): G.add_edge(new_edge) to_idx = 1 - to_idx # use A.B = (BT.AT)T identity - tin1 = TransposeParameters(G.unique_name(f'{params.name}_tin1'), transpose=(1, 0)) - tin2 = TransposeParameters(G.unique_name(f'{params.name}_tin2'), transpose=(1, 0)) - tout = TransposeParameters(G.unique_name(f'{params.name}_tout'), transpose=(1, 0)) + tin1 = TransposeParameters(G.unique_name( + f'{params.name}_tin1'), transpose=(1, 0)) + tin2 = TransposeParameters(G.unique_name( + f'{params.name}_tin2'), transpose=(1, 0)) + tout = TransposeParameters(G.unique_name( + f'{params.name}_tout'), transpose=(1, 0)) G.insert_node_before(tin1, params) G.insert_node_before(tin2, params, to_idx=1) G.insert_node_after(params, tout) @@ -94,11 +108,14 @@ def get_min_max(cls, fusion, stats, all_stats, params): fnodes = fusion.contained_nodes() if len(fnodes) > 1: act_node = fnodes[1] - if isinstance(act_node, HSigmoidActivationParameters): - # Hard sigmoid implements a RELU, be sure 6 can be represented - min_val, max_val = 0, 6 - elif isinstance(act_node, SigmoidActivationParameters): - # Guarantee Q12 input to sigmoid + if isinstance(act_node, (HSigmoidActivationParameters, HSwishActivationParameters)): + # Hard sigmoid/swish have parameters that need to be representable + cls.check_valid_ranges(params, stats, idx=0, dirs='out') + min_val, max_val = stats['range_out'][0]['min'], stats['range_out'][0]['max'] + max_val = np.maximum(max_val, max( + params.upper_bound, params.offset)) + elif isinstance(act_node, (SigmoidActivationParameters, TanHActivationParameters)): + # Guarantee Q12 input to lut based sigmoid and tan min_val, max_val = -8, 8 elif isinstance(act_node, ReluActivationParameters): # Take stats from activation after the convolution @@ -109,9 +126,10 @@ def get_min_max(cls, fusion, stats, all_stats, params): min_val, max_val = stats['range_out'][0]['min'], stats['range_out'][0]['max'] return min_val, max_val + @params_type(MatMulOpParameters) @in_qs_constraint({'dtype': set([np.int8])}) -@out_qs_constraint({'dtype': set([np.int8])}) +@out_qs_constraint({'dtype': set([np.int8, np.int32])}) @option_constraint(check_filter_options(False, input_size={8, None}, output_size={8, None})) class MatMultMultSW8(MatMultMultBase): @classmethod @@ -133,7 +151,8 @@ def _quantize(cls, params, in_qs, stats, **kwargs): kwargs['graph_update']['requires_adjust'] = True in_q2 = QType.from_array_sq( arr=in2_node.dqvalue, - quantized_dimension=0, + quantized_dimension=(len(in2_node.dqvalue.shape) - + (2 if isinstance(params, MatMulTransposedParameters) else 1)), dtype=np.int8, narrow_range=True, bits=8) @@ -142,36 +161,41 @@ def _quantize(cls, params, in_qs, stats, **kwargs): in_q1 = in_qs[0].make_symmetric_signed() - min_val, max_val = cls.get_min_max( - fusion, stats, kwargs['all_stats'], params) + # min_val, max_val = cls.get_min_max( + # fusion, stats, kwargs['all_stats'], params) if force_out_q: o_q = force_out_q # can't be forced to something not np.int8 - if o_q.dtype != np.int8 or o_q.asymmetric: + if (o_q.dtype != np.int8 and o_q.dtype != np.int32) or o_q.asymmetric: return None - LOG.warning('node %s output forced to range %s/%s - actual range %s/%s %s', - params.name, o_q.min, o_q.max, min_val, max_val, - "asymmetric" if o_q.asymmetric else "symmetric") + LOG.warning(f'node {params.name} output forced to range {o_q.min}/{o_q.max} ' + f'{"asymmetric" if o_q.asymmetric else "symmetric"}') else: + cls.check_valid_ranges(params, stats, idx=0, dirs='out') + min_val, max_val = stats['range_out'][0]['min'], stats['range_out'][0]['max'] o_q = QType.from_min_max_sq(min_val=min_val, max_val=max_val, dtype=out_dtype) if len(in_qs) == 3: + bias_scale = in_q1.scale * in_q2.scale + quantized_dimension = None if len(bias_scale) == 1 else 0 biases_q = QType( - dtype=np.int32, scale=in_q1.scale * in_q2.scale) + dtype=np.int32, + scale=in_q1.scale * in_q2.scale, + quantized_dimension=quantized_dimension) out_in_qs = [in_q1, in_q2, biases_q] else: out_in_qs = [in_q1, in_q2] - - mul_biases_q = MultMulBiasScaleQType() - mul_biases_q.scale = in_q1.scale * in_q2.scale / o_q.scale + mul_biases_q = MultMulBiasScaleQType( + scale=(in_q1.scale*in_q2.scale)/o_q.scale) return QRec.scaled(in_qs=out_in_qs, out_qs=[o_q], mul_biases_q=mul_biases_q) + class MatMultMultNE16Base(MatMultMultBase): @classmethod def _quantize_ne16(cls, params, in_qs, stats, input_dtype, **kwargs): @@ -189,7 +213,8 @@ def _quantize_ne16(cls, params, in_qs, stats, input_dtype, **kwargs): in2_node, in_qs = cls.move_constant( G, fusion if fusion else params, in_qs) if not in2_node: - raise ValueError(f"Not supported in NE16 this matmul {params.name}") + raise ValueError( + f"Not supported in NE16 this matmul {params.name}") w1, h1 = params.in_dims[0].shape[0], params.in_dims[0].shape[1] h2, w2 = params.in_dims[1].shape[0], params.in_dims[1].shape[1] @@ -210,18 +235,22 @@ def _quantize_ne16(cls, params, in_qs, stats, input_dtype, **kwargs): dtype=input_dtype, asymmetric=True) in_q1 = limit_input_precision( - params, input_bits, in_q1, w1, False, opts['weight_bits']) - + params, input_bits, in_q1, w1, False, opts['weight_bits'], + opts.get('max_precision_limit', + MAX_PRECISION_LIMIT_OPTION['default']), + out_ranges=stats.get('range_out'), + w_qs=[in_q2]) - min_val, max_val = cls.get_min_max( - fusion, stats, kwargs['all_stats'], params) + # min_val, max_val = cls.get_min_max( + # fusion, stats, kwargs['all_stats'], params) if force_out_q: o_q = force_out_q - LOG.warning('node %s output forced to range %s/%s - actual range %s/%s %s', - params.name, o_q.min, o_q.max, min_val, max_val, - "asymmetric" if o_q.asymmetric else "symmetric") + LOG.warning(f'node {params.name} output forced to range {o_q.min}/{o_q.max} ' + f'{"asymmetric" if o_q.asymmetric else "symmetric"}') else: + cls.check_valid_ranges(params, stats, idx=0, dirs='out') + min_val, max_val = stats['range_out'][0]['min'], stats['range_out'][0]['max'] force_output_size = opts.get('force_output_size', 8) out_dtype = np.uint8 if force_output_size == 8 else np.uint16 o_q = QType.from_min_max_sq(min_val=min_val, @@ -231,10 +260,12 @@ def _quantize_ne16(cls, params, in_qs, stats, input_dtype, **kwargs): dtype=out_dtype) if len(in_qs) == 3: biases_q = QType( - dtype=np.int32, scale=in_q1.scale * in_q2.scale, ne16_biases=(input_bits!=16)) + dtype=np.int32, scale=in_q1.scale * in_q2.scale, ne16_biases=(input_bits != 16), + quantized_dimension=0) # calculate bias offset - this will be added to the bias in the kernel # it is already in quantized form - bias_offset = np.zeros((in2_node.dqvalue.shape[0], ), dtype=np.int32) + bias_offset = np.zeros( + (in2_node.dqvalue.shape[0], ), dtype=np.int32) if in_q1.zero_point != 0: # input zero correction is sum(W * Zin) by out_c if weights are channel scaled bias_offset -= np.sum(np.multiply(in_q1.zero_point, @@ -247,7 +278,7 @@ def _quantize_ne16(cls, params, in_qs, stats, input_dtype, **kwargs): # output zero correction is So/(Si * Sw) * ZPo by out_c if weights are channel scaled scale = o_q.scale / (in_q1.scale * in_q2.scale) bias_offset += np.floor((o_q.zero_point * - scale) + 0.5).astype(np.int32) + scale) + 0.5).astype(np.int32) if not np.all(bias_offset == 0): biases_q.offset = bias_offset out_in_qs = [in_q1, in_q2, biases_q] @@ -269,18 +300,20 @@ def _quantize_ne16(cls, params, in_qs, stats, input_dtype, **kwargs): mul_biases_q=mul_biases_q, ne16=True) + @params_type(MatMulOpParameters) @in_qs_constraint({'dtype': set([np.uint8])}) -@out_qs_constraint({'dtype': set([np.uint8, np.int8, np.uint16, np.int16])}) +@out_qs_constraint({'dtype': set([np.uint8, np.int8, np.uint16, np.int16, np.int32])}) @option_constraint(check_filter_options(True, input_size={8, None}, output_size={8, 16, None})) class MatMultMultNE16_8v8(MatMultMultNE16Base): @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): return cls._quantize_ne16(params, in_qs, stats, np.uint8, **kwargs) + @params_type(MatMulOpParameters) @in_qs_constraint({'dtype': set([np.uint16])}) -@out_qs_constraint({'dtype': set([np.uint8, np.int8, np.uint16, np.int16])}) +@out_qs_constraint({'dtype': set([np.uint8, np.int8, np.uint16, np.int16, np.int32])}) @option_constraint(check_filter_options(True, input_size={16, None}, output_size={8, 16, None})) class MatMultMultNE16_16v8(MatMultMultNE16Base): @classmethod diff --git a/tools/nntool/quantization/multiplicative/quantizers/output_mult.py b/tools/nntool/quantization/multiplicative/quantizers/output_mult.py index 47a9c2367..4b1a0f67d 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/output_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/output_mult.py @@ -18,7 +18,8 @@ import numpy as np from graph.types import OutputParameters from quantization.new_qrec import QRec -from quantization.unified_quantization_handler import (out_qs_constraint, +from quantization.quantizer_options import QTYPE_IND_OPTION +from quantization.unified_quantization_handler import (out_qs_constraint, options, params_type, needs_stats) from ..mult_quantization_handler import MultQuantizionHandler @@ -27,7 +28,14 @@ @params_type(OutputParameters) @out_qs_constraint({'dtype': set([np.int8, np.uint8, np.int16])}) @needs_stats(False) +@options(QTYPE_IND_OPTION) class OutputMult(MultQuantizionHandler): @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): - return QRec.scaled(in_qs=deepcopy(in_qs), out_qs=deepcopy(in_qs)) + opts = kwargs['opts'] + in_q_ind = opts.get('qtype_ind') + if in_q_ind: + in_q = deepcopy(in_q_ind) + else: + in_q = deepcopy(in_qs[0]) + return QRec.scaled(in_qs=[in_q], out_qs=[in_q]) diff --git a/tools/nntool/quantization/multiplicative/quantizers/pooling_mult.py b/tools/nntool/quantization/multiplicative/quantizers/pooling_mult.py index 2c23d9a97..fc6fd2adb 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/pooling_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/pooling_mult.py @@ -1,4 +1,4 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS +# Copyright (C) 2020, 2022 GreenWaves Technologies, SAS # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -18,9 +18,11 @@ import numpy as np from graph.types import PoolingParameters +from quantization.multiplicative.scaling_qtypes import MultMulBiasScaleQType from quantization.new_qrec import QRec from quantization.qtype import QType -from quantization.quantizer_options import FORCE_NE16_OPTION, HWC_OPTION, USE_NE16_OPTION +from quantization.quantizer_options import (FORCE_NE16_OPTION, HWC_OPTION, + USE_NE16_OPTION) from quantization.unified_quantization_handler import (in_qs_constraint, options, out_qs_constraint, @@ -30,6 +32,7 @@ LOG = logging.getLogger('nntool.' + __name__) + @options( HWC_OPTION ) @@ -61,11 +64,13 @@ def _quantize(cls, params, in_qs, stats, **kwargs): if force_out_q: if force_out_q.asymmetric and not opts.get('allow_asymmetric'): - LOG.warning('%s could be asymmetricaly quantized but allow_asymmetric option not selected', params.name) + LOG.warning( + '%s could be asymmetricaly quantized but allow_asymmetric option not selected', params.name) return None if force_out_q.dtype != in_q.dtype: return None o_q = force_out_q + # in_q is always out_q since AT pool kernels cannot change scale in_q = deepcopy(force_out_q) if force_out_q.dtype != in_q.dtype or force_out_q.zero_point != in_q.zero_point: if in_q.forced and force_out_q.zero_point != 0: @@ -80,8 +85,12 @@ def _quantize(cls, params, in_qs, stats, **kwargs): cls.check_order(params, [['h', 'w', 'c']], [['h', 'w', 'c']]) else: cls.check_order(params, [['c', 'h', 'w']], [['c', 'h', 'w']]) + scale_mul_biases_q = MultMulBiasScaleQType(dtype=np.uint8) + scale_mul_biases_q.scale = in_q.scale/o_q.scale + return QRec.scaled(in_qs=[in_q], - out_qs=[o_q]) + out_qs=[o_q], + scale_mul_biases_q=scale_mul_biases_q) @classmethod def can_handle_asymmetric_input(cls, params, **kwargs): @@ -139,9 +148,13 @@ def _quantize(cls, params, in_qs, stats, **kwargs): o_q = deepcopy(in_q) o_q.attr.ne16 = True cls.check_order(params, [['h', 'w', 'c']], [['h', 'w', 'c']]) + scale_mul_biases_q = MultMulBiasScaleQType(dtype=np.uint8) + scale_mul_biases_q.scale = in_q.scale/o_q.scale + return QRec.scaled(in_qs=[in_q], out_qs=[o_q], - ne16=True) + ne16=True, + scale_mul_biases_q=scale_mul_biases_q) @classmethod def _get_in_qs_from_stats(cls, params, stats, in_qs, **kwargs): diff --git a/tools/nntool/quantization/multiplicative/quantizers/rnn_mult_16_8.py b/tools/nntool/quantization/multiplicative/quantizers/rnn_mult_16_8.py index 5bf0530d4..9207c86ed 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/rnn_mult_16_8.py +++ b/tools/nntool/quantization/multiplicative/quantizers/rnn_mult_16_8.py @@ -31,7 +31,6 @@ from utils.node_id import NodeId from ..mult_quantization_handler import MultQuantizionHandler -from .rescale_constant_mixin import RescaleConstantMixin LOG = logging.getLogger('nntool.' + __name__) @@ -46,7 +45,7 @@ @in_qs_constraint({'dtype': np.int16}) @out_qs_constraint({'dtype': np.int16}) @option_constraint(force_external_size=16, use_ne16={False, None}) -class RNNMultMult16x8(RescaleConstantMixin, MultQuantizionHandler): +class RNNMultMult16x8(MultQuantizionHandler): @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): force_out_qs, out_dtype = cls.get_mult_opts(**kwargs) @@ -93,9 +92,7 @@ def _quantize(cls, params, in_qs, stats, **kwargs): i_2_a_q = MultMulBiasScaleQType( scale=in_qs[0].scale * in_qs[names['i_2_i_w']].scale/act_input_scale) - in_qs[names['i_b']].scale = o_q.scale * in_qs[names['r_2_i_w']].scale - in_qs[names['i_b']].dtype = np.int32 - # cls.rescale_constant(input_nodes['i_b'], state_w_scale, qrecs, dtype=np.int32) + in_qs[names['i_b']] = QType(scale=o_q.scale * in_qs[names['r_2_i_w']].scale, dtype=np.int32) act_output_scale = math.pow(2, -15) s_2_s_q = MultMulBiasScaleQType( scale=o_q.scale * in_qs[names['r_2_i_w']].scale/act_input_scale) diff --git a/tools/nntool/quantization/multiplicative/quantizers/rnn_mult_8_8.py b/tools/nntool/quantization/multiplicative/quantizers/rnn_mult_8_8.py index 53cb9cbae..917f7b1ef 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/rnn_mult_8_8.py +++ b/tools/nntool/quantization/multiplicative/quantizers/rnn_mult_8_8.py @@ -31,7 +31,6 @@ from utils.node_id import NodeId from ..mult_quantization_handler import MultQuantizionHandler -from .rescale_constant_mixin import RescaleConstantMixin LOG = logging.getLogger('nntool.' + __name__) @@ -46,7 +45,7 @@ @in_qs_constraint({'dtype': np.int8}) @out_qs_constraint({'dtype': np.int8}) @option_constraint(force_external_size={8, None}, use_ne16={False, None}) -class RNNMultMult8x8(RescaleConstantMixin, MultQuantizionHandler): +class RNNMultMult8x8(MultQuantizionHandler): @classmethod def _quantize(cls, params, in_qs, stats, **kwargs): force_out_qs, out_dtype = cls.get_mult_opts(**kwargs) @@ -108,8 +107,7 @@ def _quantize(cls, params, in_qs, stats, **kwargs): in_qs[names['i_2_i_w']].scale = w_scales in_qs[names['r_2_i_w']].scale = w_scales state_w_scale = i_state_scale * w_scales - in_qs[names['i_b']].scale = state_w_scale - in_qs[names['i_b']].dtype = np.int32 + in_qs[names['i_b']] = QType(scale=state_w_scale, dtype=np.int32) if params.hard_act: s_2_s_q = MultMulBiasScaleQType( diff --git a/tools/nntool/quantization/multiplicative/quantizers/rnn_mult_ne16.py b/tools/nntool/quantization/multiplicative/quantizers/rnn_mult_ne16.py index 8342df98c..8c0a7eb03 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/rnn_mult_ne16.py +++ b/tools/nntool/quantization/multiplicative/quantizers/rnn_mult_ne16.py @@ -31,7 +31,6 @@ from utils.node_id import NodeId from ..mult_quantization_handler import MultQuantizionHandler -from .rescale_constant_mixin import RescaleConstantMixin LOG = logging.getLogger('nntool.' + __name__) @@ -47,34 +46,43 @@ def limit_input_precision(params, input_size, narrow, qw, - extra_correction=0): - calc_bits = (input_bits + qw - (1 if narrow else 0) + extra_correction + - math.ceil(math.log2(input_size)) + 1) - reduce_precision = calc_bits - 31 if calc_bits > 31 else 0 - reduce_precision = 8 if reduce_precision > 8 else reduce_precision - if reduce_precision: - LOG.warning("%s: too much dynamic: reducing %s precision by %s bits. " - "use weight_bits option to reduce weight precision", - params.name, - "input", - reduce_precision) - in_q.bits -= reduce_precision + max_correction, + extra_correction=0, + accumulator_bits=31, + out_ranges=None, + w_qs=None): + if out_ranges and all(stat is not None for stat in out_ranges) and w_qs: + calc_bits = 0 + for stat, w_q in zip(out_ranges, w_qs): + res_scale = np.min(w_q.scale * in_q.scale) + max_out = max(abs(stat['min']), abs(stat['max'])) + if max_out == 0: + continue + calc_bits = max(calc_bits, math.ceil(math.log2(max_out/res_scale))) + # add one safety bit if basing off stats + calc_bits += 1 + else: + calc_bits = (input_bits + qw - (1 if narrow else 0) + extra_correction + + math.ceil(math.log2(input_size)) + 1) + reduce_by = max(calc_bits - accumulator_bits, 0) + if reduce_by > max_correction: + LOG.warning(f"{params.name}: too much dynamic: quantizer estimates {reduce_by} bit overflow. " + f"max_precision_limit set to {max_correction}") + reduce_by = min(reduce_by, max_correction) + if reduce_by: + LOG.warning( + f"{params.name}: too much dynamic: reducing input precision by {reduce_by} bits. ") + in_q = in_q.reduce_precision(reduce_by) return in_q -def calculatate_weight_q(in_qs, - in_edges, - w_idx, - in_zero_point, - real_dim, - padded_dim, - qw, - narrow): - # calculates weight qtype and zero offset bias correction - - wnode = in_edges[w_idx].from_node +def calc_weight_q(wnode, + real_dim, + padded_dim, + qw, + narrow): extra_attrs = {'bit_pack': qw} if qw < 8 else {} - in_qs[w_idx] = QType.from_array_sq( + return QType.from_array_sq( wnode.dqvalue, dtype=np.uint8, bits=qw, @@ -93,33 +101,55 @@ def calculatate_weight_q(in_qs, }, no_compression=True, **extra_attrs) - w_q = in_qs[w_idx] + +def calc_bias_offset(wnode, w_q, in_zero_point): # since the weight zero offset is added by NE16 use signed value weight_val = wnode.value_as(w_q).astype(np.int32) - w_q.zero_point - # return zero offset return np.sum( -in_zero_point.astype(np.int32) * weight_val, axis=1, dtype=np.int32) -# @options( -# { -# 'name': 'state_width', -# 'type': int, -# 'choices': ['8', '16'], -# 'help': 'sets width of recurrent state', -# 'default': 8 -# }) +def calculatate_weight_q(in_qs, + in_edges, + w_idx, + in_zero_point, + real_dim, + padded_dim, + qw, + narrow): + # calculates weight qtype and zero offset bias correction + in_qs[w_idx] = calc_weight_q( + in_edges[w_idx].from_node, real_dim, padded_dim, qw, narrow) + return calc_bias_offset(in_edges[w_idx].from_node, in_qs[w_idx], in_zero_point) + + +class NE16RNNMultQuantizionHandler(MultQuantizionHandler): + + @classmethod + def _get_in_qs_from_stats(cls, params, stats, in_qs, **kwargs): + opts = kwargs['opts'] + in_dtype = np.uint8 if opts.get( + 'force_external_size', 8) == 8 else np.uint16 + return [QType.from_min_max_sq(stats['range_in'][idx]['min'], + stats['range_in'][idx]['max'], + dtype=in_dtype if idx == 0 else np.uint8, + asymmetric=(idx == 0)) + if dim is not None and stats['range_in'][idx] else None + for idx, dim in enumerate(params.in_dims)] + + @options( NE16_WEIGHT_BITS_OPTION, FORCE_EXTERNAL_SIZE_OPTION, NARROW_WEIGHTS_OPTION, USE_NE16_OPTION, - NARROW_STATE_OPTION + NARROW_STATE_OPTION, + MAX_PRECISION_LIMIT_OPTION ) -class RNNMultMultNE16Base(RescaleConstantMixin, MultQuantizionHandler): +class RNNMultMultNE16Base(NE16RNNMultQuantizionHandler): @classmethod def _quantize_rnn(cls, params, in_qs, stats, input_bits, **kwargs): force_out_qs, out_dtype = cls.get_mult_opts(**kwargs) @@ -137,8 +167,10 @@ def _quantize_rnn(cls, params, in_qs, stats, input_bits, **kwargs): cls.check_valid_ranges(params, stats, idx=0, dirs='out') - o_q = QType.from_min_max_sq(min_val=stats['range_out'][0]['min'], - max_val=stats['range_out'][0]['max'], + assert in_q.dtype == in_out_dtype + + o_q = QType.from_min_max_sq(min_val=-1, + max_val=1, dtype=in_out_dtype, narrow_range=opts['narrow_state']) @@ -149,6 +181,21 @@ def _quantize_rnn(cls, params, in_qs, stats, input_bits, **kwargs): woff = {} int_num_inp = roundup(params.n_inputs, input_bits == 16) + int_num_states = roundup(params.n_states, input_bits == 16) + + in_qs[names['i_2_i_w']] = calc_weight_q( + in_edges[names['i_2_i_w']].from_node, + (params.n_states, params.n_inputs), + (params.n_states, int_num_inp), + opts['weight_bits'], + opts.get('narrow_weights')) + + in_qs[names['r_2_i_w']] = calc_weight_q( + in_edges[names['r_2_i_w']].from_node, + (params.n_states, params.n_states), + (params.n_states, int_num_states), + opts['weight_bits'], + opts.get('narrow_weights')) in_q = limit_input_precision( params, @@ -156,19 +203,11 @@ def _quantize_rnn(cls, params, in_qs, stats, input_bits, **kwargs): in_q, int_num_inp, opts['narrow_weights'], - opts['weight_bits']) - - woff['i_2_i_w'] = calculatate_weight_q( - in_qs, - in_edges, - names['i_2_i_w'], - in_q.zero_point[0], - (params.n_states, params.n_inputs), - (params.n_states, int_num_inp), opts['weight_bits'], - opts['narrow_weights']) - - int_num_states = roundup(params.n_states, input_bits == 16) + opts.get('max_precision_limit', + MAX_PRECISION_LIMIT_OPTION['default']), + w_qs=[in_qs[names['i_2_i_w']]], + out_ranges=[stats.get('range_input_dot')]) o_q = limit_input_precision( params, @@ -177,17 +216,17 @@ def _quantize_rnn(cls, params, in_qs, stats, input_bits, **kwargs): int_num_states, opts['narrow_weights'], opts['weight_bits'], - extra_correction=-1 if opts.get('narrow_state') else 0) + opts.get('max_precision_limit', + MAX_PRECISION_LIMIT_OPTION['default']), + extra_correction=-1 if opts.get('narrow_state') else 0, + w_qs=[in_qs[names['r_2_i_w']]], + out_ranges=[stats.get('range_state_dot')]) - woff['r_2_i_w'] = calculatate_weight_q( - in_qs, - in_edges, - names['r_2_i_w'], - o_q.zero_point[0], - (params.n_states, params.n_states), - (params.n_states, int_num_states), - opts['weight_bits'], - opts['narrow_weights']) + woff['i_2_i_w'] = calc_bias_offset( + in_edges[names['i_2_i_w']].from_node, in_qs[names['i_2_i_w']], in_q.zero_point) + + woff['r_2_i_w'] = calc_bias_offset( + in_edges[names['r_2_i_w']].from_node, in_qs[names['r_2_i_w']], o_q.zero_point) i_state_scale = in_qs[names['i_state']].scale # rescale input * weight result to state * weight result so that they can be accumulated @@ -241,15 +280,15 @@ def _quantize_rnn(cls, params, in_qs, stats, input_bits, **kwargs): scale=act_output_scale/o_q.scale) if input_bits == 8: - in_qs[names['i_b']].scale = state_w_scale / s_2_s_q.qbiases - in_qs[names['i_b']].dtype = np.int32 + in_qs[names['i_b']] = QType( + scale=state_w_scale / s_2_s_q.qbiases, dtype=np.int32, quantized_dimension=0) in_qs[names['i_b']].offset = woff * s_2_s_q.qbiases.astype( np.int32) + (1 << (s_2_s_q.qnorms.astype(np.int32) - 1)) if i_zp_b is not None: in_qs[names['i_b']].attr.interleaved_values = [i_zp_b] else: - in_qs[names['i_b']].scale = state_w_scale - in_qs[names['i_b']].dtype = np.int32 + in_qs[names['i_b']] = QType( + scale=state_w_scale, dtype=np.int32, quantized_dimension=0) in_qs[names['i_b']].offset = woff # Interleave input zero offset bias with state bias at generation time in_qs[names['i_b']].attr.interleaved_values = [i_zp_b] diff --git a/tools/nntool/quantization/multiplicative/quantizers/sig_tan_mult.py b/tools/nntool/quantization/multiplicative/quantizers/sig_tan_mult.py deleted file mode 100644 index d6d366503..000000000 --- a/tools/nntool/quantization/multiplicative/quantizers/sig_tan_mult.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import numpy as np -from graph.types import SigmoidActivationParameters, TanHActivationParameters -from quantization.new_qrec import QRec -from quantization.qtype import QType -from quantization.unified_quantization_handler import (in_qs_constraint, - out_qs_constraint, - params_type) - -from ..mult_quantization_handler import MultQuantizionHandler - - -@params_type(SigmoidActivationParameters, TanHActivationParameters) -@in_qs_constraint({'dtype': np.int8}) -@out_qs_constraint({'dtype': np.int8}) -class SigmoidTanHMult(MultQuantizionHandler): - @classmethod - def _quantize(cls, params, in_qs, stats, **kwargs): - force_out_qs, out_dtype = cls.get_mult_opts(**kwargs) - force_out_q = force_out_qs and force_out_qs[0] - if force_out_q: - return None - in_qs = [QType.from_min_max_sq(-8, 8, dtype=np.int8, forced=True)] - o_q = QType.from_min_max_sq(min_val=-1.0, - max_val=1.0, - dtype=out_dtype, - forced=True) - return QRec.scaled(in_qs=in_qs, out_qs=[o_q]) diff --git a/tools/nntool/quantization/multiplicative/quantizers/softmax_tanh_mult.py b/tools/nntool/quantization/multiplicative/quantizers/softmax_tanh_mult.py index a90c5d6e4..16ee1aad0 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/softmax_tanh_mult.py +++ b/tools/nntool/quantization/multiplicative/quantizers/softmax_tanh_mult.py @@ -18,7 +18,7 @@ from graph.types.activations import HTanHActivationParameters from quantization.new_qrec import QRec from quantization.qtype import QType -from quantization.quantizer_options import SOFTMAX_OUT_8BITS_OPTION +from quantization.quantizer_options import SOFTMAX_OUT_8BITS_OPTION, OUTPUT_SIZE_OPTION from quantization.unified_quantization_handler import (in_qs_constraint, out_qs_constraint, params_type, options) @@ -39,7 +39,7 @@ def _quantize(cls, params, in_qs, stats, **kwargs): force_out_q = force_out_qs and force_out_qs[0] opts = kwargs['opts'] if force_out_q: - if force_out_q.forced_scale or force_out_q.forced_zero_point: + if force_out_q.forced_scale or (force_out_q.forced_zero_point and not np.all(in_qs[0].zero_point == 0)): return None if in_qs[0].dtype == np.int8: dtypes = [np.int8, np.int16] @@ -80,26 +80,26 @@ def _get_in_qs_from_stats(cls, params, stats, in_qs, **kwargs): if dim is not None else None for idx, dim in enumerate(params.in_dims)] -@params_type(HTanHActivationParameters) -@in_qs_constraint({'dtype': np.int8}) -@out_qs_constraint({'dtype': np.int16}) -class TanHMult(MultQuantizionHandler): - @classmethod - def _quantize(cls, params, in_qs, stats, **kwargs): - force_out_qs, _ = cls.get_mult_opts(**kwargs) - force_out_q = force_out_qs and force_out_qs[0] - opts = kwargs['opts'] - if force_out_q: - if force_out_q.forced_scale or force_out_q.forced_zero_point: - return None +# @params_type(HTanHActivationParameters) +# @in_qs_constraint({'dtype': np.int8}) +# @out_qs_constraint({'dtype': np.int16}) +# class TanHMult(MultQuantizionHandler): +# @classmethod +# def _quantize(cls, params, in_qs, stats, **kwargs): +# force_out_qs, _ = cls.get_mult_opts(**kwargs) +# force_out_q = force_out_qs and force_out_qs[0] +# opts = kwargs['opts'] +# if force_out_q: +# if force_out_q.forced_scale or force_out_q.forced_zero_point: +# return None - in_qs = cls.force_symmetric_and_dtype(in_qs, dtype=np.int8) - if in_qs is None: - return None - # force the input to be POW2 scaled - pow2_scale = np.power(2, np.ceil(np.log2(in_qs[0].scale))) - in_q = QType(min_val=in_qs[0].min_val, max_val=in_qs[0].max_val, - dtype=np.int8, scale=pow2_scale, forced=True) - o_q = QType(min_val=-1, max_val=1, dtype=np.int16, - scale=2**(-15)) - return QRec.scaled(in_qs=[in_q], out_qs=[o_q]) +# in_qs = cls.force_symmetric_and_dtype(in_qs, dtype=np.int8) +# if in_qs is None: +# return None +# # force the input to be POW2 scaled +# pow2_scale = np.power(2, np.ceil(np.log2(in_qs[0].scale))) +# in_q = QType(min_val=in_qs[0].min_val, max_val=in_qs[0].max_val, +# dtype=np.int8, scale=pow2_scale, forced=True) +# o_q = QType(min_val=-1, max_val=1, dtype=np.int16, +# scale=2**(-15)) +# return QRec.scaled(in_qs=[in_q], out_qs=[o_q]) diff --git a/tools/nntool/quantization/multiplicative/quantizers/ssd_postprocess.py b/tools/nntool/quantization/multiplicative/quantizers/ssd_postprocess.py index 6f2e413ad..667da7a53 100644 --- a/tools/nntool/quantization/multiplicative/quantizers/ssd_postprocess.py +++ b/tools/nntool/quantization/multiplicative/quantizers/ssd_postprocess.py @@ -26,7 +26,7 @@ @in_qs_constraint({'dtype': np.int8}) class SSDDetectorParametersMult(MultQuantizionHandler): @classmethod - def _quantize(cls, params, in_qs, stats, **kwargs): + def _quantize(cls, params: SSDDetectorParameters, in_qs, stats, **kwargs): force_out_qs, _ = cls.get_mult_opts(**kwargs) force_out_q = force_out_qs and force_out_qs[0] if force_out_q: @@ -39,4 +39,7 @@ def _quantize(cls, params, in_qs, stats, **kwargs): dtype=np.int16, scale=2**(-14)) o_scores_qtype = in_qs[1] o_class_qtype = QType(scale=1, dtype=np.int8) - return QRec.scaled(in_qs=in_qs, out_qs=[o_boxes_qtype, o_class_qtype, o_scores_qtype, o_class_qtype]) + outputs = [o_boxes_qtype, o_class_qtype, o_scores_qtype] + if params.output_detection_count: + outputs.append(QType(scale=1, dtype=np.int32)) + return QRec.scaled(in_qs=in_qs, out_qs=outputs) diff --git a/tools/nntool/quantization/multiplicative/scaling_qtypes.py b/tools/nntool/quantization/multiplicative/scaling_qtypes.py index 6aab14823..217953b82 100644 --- a/tools/nntool/quantization/multiplicative/scaling_qtypes.py +++ b/tools/nntool/quantization/multiplicative/scaling_qtypes.py @@ -111,7 +111,8 @@ class MultMulBiasScaleQType(ScalingQType): ] def __init__(self, *args, scale=None, dtype=np.uint8, available_bits=None, calc_dtype=np.int32, **kwargs): - super(MultMulBiasScaleQType, self).__init__(*args, dtype=dtype, **kwargs) + super(MultMulBiasScaleQType, self).__init__( + *args, dtype=dtype, **kwargs) if available_bits is None: if dtype == np.uint8: available_bits = 8 @@ -122,15 +123,16 @@ def __init__(self, *args, scale=None, dtype=np.uint8, available_bits=None, calc_ self._available_bits = available_bits self._pre_normalization = 0 - self._calc_dtype=np.int64 + self._calc_dtype = np.int64 self.scale = scale @classmethod def from_filter(cls, in_q, weights_q, out_q, params, dtype=np.uint8): available_bits = ( 31 - (math.ceil(math.log2(params.filter.sz)) + 7 + 7)) - qtype = cls(dtype=dtype, available_bits=available_bits) - qtype.scale = in_q.scale * weights_q.scale / out_q.scale + qtype = cls(dtype=dtype, + available_bits=available_bits, + scale=in_q.scale * weights_q.scale / out_q.scale) return qtype @property @@ -213,7 +215,8 @@ class MultFractionalMulBiasQType(ScalingQType): ] def __init__(self, *args, scale=None, **kwargs): - super(MultFractionalMulBiasQType, self).__init__(*args, dtype=np.uint32, **kwargs) + super(MultFractionalMulBiasQType, self).__init__( + *args, dtype=np.uint32, **kwargs) self._scale = None self.scale = scale @@ -230,7 +233,8 @@ def scale(self, val): if val is not None: if not isinstance(val, np.ndarray): val = np.array([val]) - assert np.all(val >= 0) and np.all(val <= 1), "scale should be positive and fractional" + assert np.all(val >= 0) and np.all( + val <= 1), "scale should be positive and fractional" self._scale = val self.compute_scales() else: @@ -260,12 +264,14 @@ def apply_scales(self, arr: np.ndarray, axis: int = None): assert len(mul_biases) == 1 and len( mul_biases_norm) == 1, "no axis set. should have single scale" else: - shape = [len(self.qbiases) if idx == axis else 1 for idx in range(len(arr.shape))] + shape = [len(self.qbiases) if idx == + axis else 1 for idx in range(len(arr.shape))] mul_biases = self.qbiases.reshape(shape) mul_biases_norm = self.qnorms.reshape(shape) #arr = np.multiply(arr, mul_biases, dtype=np.int64) >> 32 - arr = at_norm(np.multiply(arr, mul_biases, dtype=np.int64), 32 + mul_biases_norm) + arr = at_norm(np.multiply(arr, mul_biases, + dtype=np.int64), 32 + mul_biases_norm) return arr.astype(np.int32) def str_by_chan(self, chan: int): diff --git a/tools/nntool/quantization/new_qrec.py b/tools/nntool/quantization/new_qrec.py index 7438a5f69..4f0e6badb 100644 --- a/tools/nntool/quantization/new_qrec.py +++ b/tools/nntool/quantization/new_qrec.py @@ -158,7 +158,7 @@ def get_outputs(self, del params if ktype == "symmetric": if self._auto_dequantize_outputs: - return [self.out_qs[idx].dequantize(output_tensor) for idx, output_tensor in enumerate(output_tensors)] + return [self.out_qs[idx].dequantize(x) for idx, x in enumerate(output_tensors)] output_tensors = [self.out_qs[idx].clip(output_tensor) for idx, output_tensor in enumerate(output_tensors)] return output_tensors diff --git a/tools/nntool/quantization/qtype.py b/tools/nntool/quantization/qtype.py index b53902be8..45324622d 100644 --- a/tools/nntool/quantization/qtype.py +++ b/tools/nntool/quantization/qtype.py @@ -15,7 +15,7 @@ import math from copy import deepcopy -from functools import reduce +from functools import cmp_to_key, reduce import numpy as np from bfloat16 import bfloat16 @@ -129,10 +129,10 @@ def divide_ignore(a, b): return np.nan_to_num(res) -IGNORE_KEYS = {'ne16'} +IGNORE_KEYS = {'ne16', 'to_dict'} -class AttrNamespace: +class AttrNamespace(): def __init__(self, **kwargs): self.__dict__.update(kwargs) @@ -149,10 +149,11 @@ def __delattr__(self, name: str) -> None: del self.__dict__[name] def __iter__(self): - yield from [a for a in dir(self) if not a.startswith('__')] + yield from [a for a in dir(self) if not a.startswith('__') and a != 'to_dict'] def __repr__(self): - items = (f"{k}={v!r}" for k, v in self.__dict__.items()) + items = (f"{k}={v!r}" for k, + v in self.__dict__.items() if k != 'to_dict') return "({})".format(", ".join(items)) def __eq__(self, other): @@ -175,6 +176,9 @@ def __getstate__(self): def __setstate__(self, state): self.__dict__.update(state) + def to_dict(self): + return {k: getattr(self, k) for k in self} + FORCED_FLAGS = [ 'q', @@ -202,12 +206,15 @@ class QType(JsonSerializable, EventEmitter): 'is_constant' ] - def __init__(self, *args, q=None, bits=None, signed=True, zero_point=0, scale=None, + def __init__(self, *args, q=None, bits=None, signed=None, zero_point=0, scale=None, min_val=None, max_val=None, quantized_dimension=None, dtype=None, offset=None, - narrow_range=None, forced=False, asymmetric=False, dont_copy_attr=None, **kwargs): + narrow_range=None, forced=False, asymmetric=None, dont_copy_attr=None, **kwargs): super(QType, self).__init__(*args) self._q = q self._scale = self.init_array(scale) + if self._scale is not None and len(self._scale) != 1 and quantized_dimension is None: + raise ValueError( + "quantized dimension must be set if scale is an array") self._min_val = self.init_array(min_val) self._max_val = self.init_array(max_val) self._zero_point = np.atleast_1d(zero_point) @@ -217,19 +224,56 @@ def __init__(self, *args, q=None, bits=None, signed=True, zero_point=0, scale=No self._offset = offset self._attr = AttrNamespace(**kwargs) self._is_constant = None + self._dtype = None self._dont_copy_attr = dont_copy_attr - self._asymmetric = asymmetric - if bits is None: - self.dtype = dtype - elif dtype is None: - self._bits = bits - self._signed = signed - self._update_dtype() + if dtype is None: + if signed is None: + signed = True + if bits is None: + raise ValueError('bits and signed or dtype must be set') + else: + self._bits = bits + self._signed = signed + self._update_dtype() else: - self.dtype = dtype - self.bits = bits + if isinstance(dtype, np.dtype): + dtype = dtype.type + if dtype not in DTYPES: + raise ValueError(f'invalid dtype {dtype}') + self._dtype = dtype + inf_bits, inf_signed = DTYPES[dtype] + if bits is not None: + if inf_bits < bits: + raise ValueError(f'dtype {dtype} cannot fit {bits} bits') + self._bits = bits + else: + self._bits = inf_bits + if signed is not None: + if signed != inf_signed: + raise ValueError( + f'dtype {dtype} is {"signed" if inf_signed else "unsigned"} but {signed} required') + self._signed = signed + else: + self._signed = inf_signed # asymmeric is tested at creation so that it stays constant # i.e. you cannot make a symmetric QType asymmetric by changing properties + if asymmetric is None: + self._asymmetric = self.test_if_asymmetric() + else: + self._asymmetric = asymmetric + + def reduce_precision(self, bits): + if self.is_pow2: + return QType(dtype=self.dtype, q=self.q-bits, + min_val=self.min_val, max_val=self.max_val, + zero_point=self.zero_point, + narrow_range=self.narrow_range, + **self._attr.to_dict()) + return self.from_min_max( + self.min_val, self.max_val, dtype=self.dtype, reduce_scale=math.pow( + 2, bits), + scaled=self.is_sq, asymmetric=self.asymmetric, narrow_range=self.narrow_range, + quantized_dimension=self.quantized_dimension, **self._attr.to_dict()) def make_symmetric_signed(self): if self.is_sq and (self.asymmetric or not self.signed): @@ -254,6 +298,26 @@ def __setstate__(self, state): setattr(self, '_dtype', STR_DTYPE[state['dtype']]) setattr(self, '_EventEmitter__raw_listeners', {}) + def _encapsulate(self): + res = {} + for k in self.EXPORT: + v = getattr(self, f'_{k}') + if v is None: + continue + if k == "attr": + res[k] = v.__getstate__() + else: + res[k] = v + return res + + @classmethod + def _dencapsulate(cls, val): + if 'attr' in val: + attr = val['attr'] + val['attr'] = AttrNamespace() + val['attr'].__setstate__(attr) + return QType(**val) + @property def zero_point_asymmetric_zero(self): if self.dtype in [np.int8, np.int16, np.int32]: @@ -291,26 +355,6 @@ def attr(self): def Pow2(cls, bits, q, signed, forced=False): return cls(bits=bits, q=q, signed=signed, forced=forced) - def link_scales(self, *others): - def set_scale(*args): - del args - if all(other.is_pow2 for other in others): - self.q = sum(other.q for other in others) - else: - self.scale = np.atleast_1d( - reduce(np.multiply, [other.scale for other in others], 1.0)) - for other in others: - other.on('scale_changed', set_scale) - set_scale() - return self - - def _encapsulate(self): - return {k: getattr(self, f'_{k}') for k in self.EXPORT - if getattr(self, f'_{k}') is not None} - - @classmethod - def _dencapsulate(cls, val): - return QType(**val) def _update_dtype(self): if self._signed is None or self._bits is None: @@ -349,6 +393,27 @@ def forced_dtype(self): def forced_scale(self): return self._forced.get('scale') + @staticmethod + def precision_key(): + """ Returns a key function that compares precision + """ + def cmp(a, b): + a = float(a) + b = float(b) + return (a > b) - (a < b) + def cmp_func(q1: QType, q2: QType): + if q1.is_floating: + if q2.is_floating: + return cmp(q1.bits, q2.bits) + else: + return 1 # q1 > q2 + elif q2.is_floating: + return -1 + # lower scale is more precise + return cmp(np.max(q2.scale), np.max(q1.scale)) + return cmp_to_key(cmp_func) + + def set_forced(self, val=True, flags=None): if flags is None: flags = FORCED_FLAGS @@ -420,8 +485,14 @@ def dtype(self, val): val = next((dtype for dtype in DTYPES if val == dtype), None) if val is None: raise ValueError('dtype not found') + if self._dtype == val: + return self._dtype = val self._bits, self._signed = DTYPES[val] + if self.is_sq and self._min_val is not None and self._max_val is not None: + self.recalculate_scale( + self._min_val, self._max_val, narrow_range=self.narrow_range) + self.emit('dtype_changed', self._dtype) @property @@ -446,18 +517,18 @@ def bits(self): def qbits(self): return self._bits - (1 if self.narrow_range else 0) - @bits.setter - def bits(self, val): - if self._bits == val: - return - self._bits = val - if self._dtype is None: - self._update_dtype() + # @bits.setter + # def bits(self, val): + # if self._bits == val: + # return + # self._bits = val + # if self._dtype is None: + # self._update_dtype() - self.emit('bits_changed', self._dtype) - if self.is_sq and self.min_val is not None and self.max_val is not None: - self.recalculate_scale( - self.min_val, self.max_val, self.narrow_range) + # self.emit('bits_changed', self._dtype) + # if self.is_sq and self._min_val is not None and self._max_val is not None: + # self.recalculate_scale( + # self._min_val, self._max_val, narrow_range=self.narrow_range) @property def dtype_bits(self): @@ -491,7 +562,8 @@ def scale(self, val): @property def has_valid_range(self): - return (self._min_val is not None and self._max_val is not None) or self._scale is not None + return ((self._min_val is not None and self._max_val is not None) or + self._scale is not None or self._q is not None) @property def min_val(self): @@ -509,7 +581,7 @@ def max_val(self): def max_abs_val(self): if self._max_val is None or self._min_val is None: return self.max - return max(abs(self._max_val), abs(self._min_val)) + return np.max(np.maximum(np.abs(self._max_val), np.abs(self._min_val))) @property def min(self): @@ -581,12 +653,14 @@ def calculate_scale(rmin, rmax, qmin, qmax, dtype, asymmetric=False, if zero_point is not None: qpos_range = qmax - zero_point qneg_range = zero_point - qmin - rpos_range = np.max(rmax, 0) - rneg_range = np.min(rmin, 0) + rpos_range = rmax # np.max(rmax, 0) + rneg_range = rmin # np.min(rmin, 0) scale = np.maximum( divide_ignore(rpos_range, qpos_range), divide_ignore(rneg_range, qneg_range)) - return np.atleast_1d(scale), np.atleast_1d(zero_point) + scale = np.atleast_1d(scale) + scale[scale == 0] = 1 + return scale, np.atleast_1d(zero_point) elif asymmetric: if narrow_range: raise ValueError( @@ -633,7 +707,9 @@ def calculate_scale(rmin, rmax, qmin, qmax, dtype, asymmetric=False, nudged_zero_point = qmax else: nudged_zero_point = np.round(zero_point).astype(dtype) - return np.atleast_1d(scale), np.atleast_1d(nudged_zero_point) + scale = np.atleast_1d(scale) + scale[scale == 0] = 1 + return scale, np.atleast_1d(nudged_zero_point) else: scale = QType.calculate_symmetric_scales( qrange, rmin, rmax, narrow_range=narrow_range) @@ -646,20 +722,28 @@ def calculate_scale(rmin, rmax, qmin, qmax, dtype, asymmetric=False, else: zero_point = np.atleast_1d( np.ceil(qrange/2) + qmin).astype(dtype) - return np.atleast_1d(scale), zero_point + scale = np.atleast_1d(scale) + scale[scale == 0] = 1 + return scale, zero_point - def recalculate_scale(self, min_val, max_val, narrow_range=None, zero_point=None): + def recalculate_scale(self, min_val, max_val, narrow_range=None): if narrow_range is None: narrow_range = self.narrow_range qmin, qmax = self.calculate_quantized_range( self.bits, narrow_range=narrow_range, signed=self.signed) + if self.quantized_dimension is None: + rmin_val = np.atleast_1d(np.min(min_val)) + rmax_val = np.atleast_1d(np.max(max_val)) + else: + rmin_val = min_val + rmax_val = max_val scale, zero_point = self.calculate_scale( - min_val, max_val, qmin, qmax, self.dtype, - asymmetric=self.asymmetric, narrow_range=narrow_range, - zero_point=zero_point) - self._zero_point = zero_point + rmin_val, rmax_val, qmin, qmax, self.dtype, + asymmetric=self.asymmetric, narrow_range=narrow_range) if np.any(scale != self.scale): self.scale = scale + if np.any(zero_point != self._zero_point): + self._zero_point = zero_point def scale_to_pow2(self): # closest above pow2 not channel scaled @@ -690,7 +774,8 @@ def reorder(self, trans, shape): @classmethod def from_min_max(cls, min_val, max_val, dtype=None, bits=None, scaled=False, asymmetric=False, narrow_range=False, quantized_dimension=None, - scale_zero_as_one=False, forced=False, zero_point=None, **kwargs): + scale_zero_as_one=False, forced=False, zero_point=None, + reduce_scale=None, **kwargs): min_val = cls.init_array(min_val) max_val = cls.init_array(max_val) # check for scalar @@ -718,12 +803,21 @@ def from_min_max(cls, min_val, max_val, dtype=None, bits=None, scaled=False, if scaled: qmin, qmax = cls.calculate_quantized_range( bits, narrow_range=narrow_range, signed=signed) + if quantized_dimension is None: + # if quantized dimension is not set then scale will be tensorwide + rmin_val = np.atleast_1d(np.min(min_val)) + rmax_val = np.atleast_1d(np.max(max_val)) + else: + rmin_val = min_val + rmax_val = max_val scale, zero_point = cls.calculate_scale( - min_val, max_val, qmin, qmax, dtype, asymmetric=asymmetric, + rmin_val, rmax_val, qmin, qmax, dtype, asymmetric=asymmetric, scale_zero_as_one=scale_zero_as_one, narrow_range=narrow_range, zero_point=zero_point) if len(scale) == 1: quantized_dimension = None + if reduce_scale: + scale *= reduce_scale return cls(bits=bits, signed=signed, dtype=dtype, scale=scale, zero_point=zero_point, quantized_dimension=quantized_dimension, min_val=min_val, max_val=max_val, narrow_range=narrow_range, diff --git a/tools/nntool/quantization/quantization_set.py b/tools/nntool/quantization/quantization_set.py index 1e7fe2138..deae94a7e 100644 --- a/tools/nntool/quantization/quantization_set.py +++ b/tools/nntool/quantization/quantization_set.py @@ -185,6 +185,12 @@ def move_to_fusion(self, node: Parameters, new_pnode: Parameters): del self.qset[nid] if self.stats and nid in self.stats: self.stats[fnid] = self.stats[nid] + if self.options and nid in self.options: + pnid = NodeId(new_pnode) + options = self.options[nid] + del self.options[nid] + self.options[fnid] = options + self.options.setdefault(pnid, {}).update(options) def move_to_node(self, node: Parameters, new_pnode: Parameters): nid = NodeId(node) diff --git a/tools/nntool/quantization/quantizer/new_quantizer.py b/tools/nntool/quantization/quantizer/new_quantizer.py index 70f5d922d..51a353c09 100644 --- a/tools/nntool/quantization/quantizer/new_quantizer.py +++ b/tools/nntool/quantization/quantizer/new_quantizer.py @@ -15,10 +15,13 @@ import logging from functools import reduce -from operator import attrgetter +from graph.matches.matchers.duplicate_operations import \ + MatchDuplicateOperations +from graph.matches.matchers.insert_copies import MatchInsertCopies from graph.matches.matchers.remove_copies import RemoveCopies -from graph.matches.matchers.remove_unnecessary_quantize_operators import RemoveUnnecessaryQuantizeOperators +from graph.matches.matchers.remove_unnecessary_quantize_operators import \ + RemoveUnnecessaryQuantizeOperators from graph.types import (FusionBase, FusionInputParameters, FusionOutputParameters, QuantizeParameters) from graph.types.base import NNEdge @@ -93,6 +96,14 @@ def options(self, val): def set_options(self, **kwargs): self._options.update(kwargs) + def update_options(self, new_options): + for k, v in new_options.items(): + old_v = self._options.get(k, None) + if isinstance(old_v, dict) and isinstance(v, dict): + old_v.update(v) + else: + self._options[k] = v + @property def schemes(self): return self._schemes @@ -287,14 +298,36 @@ def select_qtype_fusion(qtypes): return qtypes[0] raise CantContinueError() - def get_outqtypes_up(self, G, node): + @staticmethod + def most_precise(qtypes, stat): + # reduce to unique qtypes and sort most precise first + sorted_qtypes = sorted( + reduce( + lambda s, x: s if x in s else s + [x], + qtypes, + []), + key=QType.precision_key(), reverse=True) + if sorted_qtypes[0].is_floating: + return sorted_qtypes[0] + assert stat + # here none are float + # choose closest to range with max bits + max_bits = max(x.bits for x in sorted_qtypes) + sorted_qtypes = filter(lambda x: x.bits == max_bits, sorted_qtypes) + sorted_qtypes = sorted( + sorted_qtypes, + key=lambda x: abs(x.min - stat['min']) + abs(x.max - stat['max'])) + return sorted_qtypes[0] + + + def get_outqtypes_up(self, G, node, stat): # this function copes with the conflict on output edges which is the most complicated scenario since # there can be multiple competing forces. This only handles the cases that we have seen in real models # or been able to emulate in synthetic models. qtypes = [] - for cur_qtypes, forced_qtypes in [zip(*[(self.get_qtype_forced_up(edge), self.get_conflict_up(edge)) - for edge in edge_bundle]) - for edge_bundle in G.indexed_out_edges(node)]: + for (cur_qtypes, forced_qtypes), edge_idx in [(zip(*[(self.get_qtype_forced_up(edge), self.get_conflict_up(edge)) + for edge in edge_bundle]), idx) + for idx, edge_bundle in enumerate(G.indexed_out_edges(node))]: forced_qtypes = no_nones(forced_qtypes) if not forced_qtypes: qtypes.append(None) @@ -304,30 +337,10 @@ def get_outqtypes_up(self, G, node): qtypes.append(forced_qtypes[0]) continue else: - # more than one output edge - if any(qtype.is_floating for qtype in forced_qtypes): - return sorted(forced_qtypes, key=attrgetter('bits'))[-1] - uniq_cur_qtypes = reduce( - lambda s, x: s if x in s else s + [x], cur_qtypes, []) - if len(uniq_cur_qtypes) == 1: - uniq_cur_qtype = uniq_cur_qtypes[0] - if len(cur_qtypes) > len(forced_qtypes): - qtypes.append(uniq_cur_qtype) - continue - else: - # all outputs are forced. we want to keep the one that best represents - # the output so we calculate the maximum overlapping range - # TODO - what about 16 bit versus 8 bit - if the range overlap is similar - # then lower scale should be taken into account - range_diffs = sorted([(qtype, min(qtype.max, uniq_cur_qtype.max_val) - max( - qtype.min, uniq_cur_qtype.min_val)) for qtype in forced_qtypes], key=lambda x: x[1]) - qtypes.append(range_diffs[-1][0]) - continue - cur_qtypes = ",".join(str(qtype) for qtype in cur_qtypes) - forced_qtypes = ",".join(str(qtype) for qtype in forced_qtypes) - raise NotImplementedError( - f'unexpected quantization conflict seen cur {cur_qtypes} forced {forced_qtypes}' - ' - please contact GreenWaves') + edge_stat = stat and stat['range_out'][edge_idx] + qtypes.append(self.most_precise(cur_qtypes + forced_qtypes, edge_stat)) + continue + return qtypes def get_outqtypes_up_fusion(self, G, node): @@ -364,6 +377,7 @@ def get_options(self, nid, handler=None): node_options = self._options.get(nid, {}) opts.update({k: v for k, v in node_options.items() if k in opts}) + opts['set_on_node'] = list(node_options.keys()) else: opts = {k: v for k, v in self._options.items() if not isinstance(k, NodeId)} @@ -411,7 +425,8 @@ def setup_kwargs(self, cur_G, out_qs, opts, fusion, set_out_qs, direction): 'all_stats': self._stats, 'fusion': fusion, 'cur_G': cur_G, - 'graph_update': self._postprocess + 'graph_update': self._postprocess, + 'qset': self.qset } if set_out_qs: kwargs['out_qs'] = out_qs @@ -625,7 +640,7 @@ def elimination_pass_down(self, cur_G, edge, qtype, visited, fusion=None): self.set_qtype_up(edge, qrec.in_qs[edge.to_idx]) if self.is_conflict(edge): if fusion: - raise CantContinueError() + raise CantContinueError() # @IgnoreException if not was_conflict: self.report_conflict(edge) else: @@ -723,7 +738,7 @@ def elimination_fusion_pass_up(self, parent_node, qrecs, in_qs, out_qs): for edge in edge_bundle: was_conflict = self.is_conflict( edge) if edge in self._qtypes else False - self.set_qtype_up(edge, out_qtypes[edge.from_idx]) + self.set_qtype_down(edge, out_qtypes[edge.from_idx]) if self.is_conflict(edge): if not was_conflict: self.report_conflict(edge) @@ -743,13 +758,13 @@ def elimination_fusion_pass_up(self, parent_node, qrecs, in_qs, out_qs): def evaluate(self, cur_G, node, direction, qrecs, fusion=None): in_qs = self.get_inqtypes_down(cur_G, node) - if fusion: - out_qs = self.get_outqtypes_up_fusion(cur_G, node) - else: - out_qs = self.get_outqtypes_up(cur_G, node) nid = NodeId(node) if fusion is None else NodeId(fusion, fnode=node) pnid = NodeId(node) if fusion is None else NodeId(fusion) stat = self._stats.get(nid, None) + if fusion: + out_qs = self.get_outqtypes_up_fusion(cur_G, node) + else: + out_qs = self.get_outqtypes_up(cur_G, node, stat) opts = self.get_options(pnid) scheme_priority = self.get_scheme_priority(pnid) if isinstance(node, FusionBase) and node.quantize_internals: @@ -793,7 +808,8 @@ def continue_down(self, cur_G, qrecs, visited, node, qrec, exclude_edge=None, fu if not self.is_conflict(out_edge): continue qrecs.update(self.elimination_pass_down(cur_G, - out_edge, self.get_qtype_down(out_edge), + out_edge, self.get_qtype_down( + out_edge), visited + [node], fusion=fusion)) def continue_up(self, cur_G, qrecs, visited, node, qrec, exclude_edge=None, fusion=None): @@ -881,6 +897,9 @@ def insert_quantizers(self): for out_edge in self._graph.out_edges(qnode): self._qtypes[out_edge] = to_qtype RemoveCopies().match(self._graph) + MatchDuplicateOperations( + limit_to_dest_classes=QuantizeParameters).match(self._graph) + MatchInsertCopies().match(self._graph) def remove_quantizers(self, only_inserted=False): for node in self._graph.nodes(node_classes=QuantizeParameters): diff --git a/tools/nntool/quantization/quantizer/qrec_to_stats.py b/tools/nntool/quantization/quantizer/qrec_to_stats.py index 5c46424ca..5e86998a3 100644 --- a/tools/nntool/quantization/quantizer/qrec_to_stats.py +++ b/tools/nntool/quantization/quantizer/qrec_to_stats.py @@ -30,17 +30,13 @@ def ranges_are_valid(ranges): return not any(rng['min'] is None or rng['max'] is None for rng in ranges if rng is not None) -def build_stat_from_qrec(qrec, node=None): - if qrec is None: - return None - if qrec.in_qs is None or qrec.out_qs is None: - return None +def build_stat_from_qtypes(in_qs, out_qs, node=None): range_in = [None if qtype is None else ({'min': qtype.min_val, 'max': qtype.max_val} if qtype.has_valid_range else {'min': None, 'max': None}) - for qtype in qrec.in_qs] + for qtype in in_qs] range_out = [None if qtype is None else ({'min': qtype.min_val, 'max': qtype.max_val} if qtype and qtype.has_valid_range else {'min': None, 'max': None}) - for qtype in qrec.out_qs] + for qtype in out_qs] range_in_valid = ranges_are_valid(range_in) range_out_valid = ranges_are_valid(range_out) if not range_in_valid or not range_out_valid: @@ -62,6 +58,47 @@ def build_stat_from_qrec(qrec, node=None): } +def build_stat_from_qrec(qrec, node=None): + if qrec is None: + return None + if qrec.in_qs is None or qrec.out_qs is None: + return None + return build_stat_from_qtypes(qrec.in_qs, qrec.out_qs, node=node) + + +def build_fusion_stats(stats: dict, fusion: FusionBase): + inputs = fusion.subgraph.inputs() + in_stats = [None] * len(inputs) + for sub_node in inputs: + edge = fusion.subgraph.out_edges(sub_node)[0] + stat = stats.get(NodeId(edge.to_node)) + if stat is None: + in_stats = None + break + range_in = stat['range_in'] + if len(range_in) <= edge.to_idx: + in_stats = None + break + in_stats[sub_node.idx] = range_in[edge.to_idx] + outputs = fusion.subgraph.outputs() + out_stats = [None] * len(outputs) + for sub_node in outputs: + edge = fusion.subgraph.in_edges(sub_node)[0] + stat = stats.get(NodeId(edge.from_node)) + if stat is None: + out_stats = None + break + range_out = stat['range_out'] + if len(range_out) <= edge.from_idx: + out_stats = None + break + out_stats[sub_node.idx] = range_out[edge.from_idx] + return { + 'range_in': in_stats, + 'range_out': out_stats + } + + def build_stat(G, nid, node=None): if not G.quantization: return None @@ -87,6 +124,9 @@ def set_stats(G, current_stats=None, current_options=None): qrec = G.quantization.get( nid) if G.quantization else None stats[nid] = build_stat_from_qrec(qrec) + nid = NodeId(node) + if G.quantization and nid not in G.quantization: + stats[nid] = build_fusion_stats(stats, node) elif isinstance(node, ExpressionFusionParameters): if stats[nid] is None or 'expression' not in stats[nid]: if (G.quantization is None or nid not in G.quantization or G.quantization[nid].cache is None or @@ -96,6 +136,7 @@ def set_stats(G, current_stats=None, current_options=None): stats[nid]['expression'] = G.quantization[nid].cache['expression'] elif isinstance(node, ConstantInputParameters): if G.quantization and nid in G.quantization: - current_options.setdefault(nid, {})['qtype_ind'] = G.quantization[nid].out_qs[0] + current_options.setdefault( + nid, {})['qtype_ind'] = G.quantization[nid].out_qs[0] return stats, current_options diff --git a/tools/nntool/quantization/quantizer_options.py b/tools/nntool/quantization/quantizer_options.py index 068dce310..59e56015f 100644 --- a/tools/nntool/quantization/quantizer_options.py +++ b/tools/nntool/quantization/quantizer_options.py @@ -30,6 +30,13 @@ 'default': True } +MAX_PRECISION_LIMIT_OPTION = { + 'name': 'max_precision_limit', + 'type': int, + 'help': 'maximum number of bits to degrade input scale precision by to stop overflow of accumulator.', + 'default': 2 +} + NARROW_STATE_OPTION = { 'name': 'narrow_state', 'type': bool, @@ -82,6 +89,12 @@ 'default': 8 } +OUTPUT_SIZE_OPTION = { + 'name': 'output_size', + 'type': None, + 'default': None +} + FORCE_EXTERNAL_SIZE_OPTION = { 'name': 'force_external_size', 'type': int, @@ -129,6 +142,14 @@ 'default': 'fastfloat' } +CLIP_TYPE_OPTION = { + 'name': 'clip_type', + 'type': str, + 'choices': ['laplace', 'gaus', 'mix', 'none'], + 'help': 'Clipping method for filter output activations min max. laplace or gaussian distribution or choose based on MSE or no clipping', + 'default': 'none' +} + BIAS_SIZE_OPTION = { 'name': 'pow2_biases', 'type': int, diff --git a/tools/nntool/quantization/quantizers/no_change_mixin.py b/tools/nntool/quantization/quantizers/no_change_mixin.py index b65fa8911..e918a8f94 100644 --- a/tools/nntool/quantization/quantizers/no_change_mixin.py +++ b/tools/nntool/quantization/quantizers/no_change_mixin.py @@ -51,4 +51,4 @@ def _handle(cls, params, in_qs, _, ktype, **kwargs): "output of %s is forced and inputs don't match - rejecting", params.name) return None - return QRec(in_qs=in_qs, out_qs=[deepcopy(in_qs[0])], ktype=ktype) + return QRec(in_qs=deepcopy(in_qs), out_qs=[deepcopy(in_qs[0])], ktype=ktype) diff --git a/tools/nntool/quantization/symmetric/quantizers/matmult_pow2.py b/tools/nntool/quantization/symmetric/quantizers/matmult_pow2.py index 25808b2ad..0eb3c6f52 100644 --- a/tools/nntool/quantization/symmetric/quantizers/matmult_pow2.py +++ b/tools/nntool/quantization/symmetric/quantizers/matmult_pow2.py @@ -55,7 +55,7 @@ def _quantize(cls, params, in_qs, stats, **kwargs): range_out = stats['range_out'][0] in_q1 = deepcopy(in_qs[0]).scale_to_pow2() - in_q2 = deepcopy(in_qs[0]).scale_to_pow2() + in_q2 = deepcopy(in_qs[1]).scale_to_pow2() biases_q = QType.Pow2(32, in_q1.q + in_q2.q, True) if force_out_q: diff --git a/tools/nntool/reports/draw_graph_reporter.py b/tools/nntool/reports/draw_graph_reporter.py index 10c85d99d..812299e88 100644 --- a/tools/nntool/reports/draw_graph_reporter.py +++ b/tools/nntool/reports/draw_graph_reporter.py @@ -17,7 +17,7 @@ from expressions.symbolic.symbol import Constant, Variable from graph.nngraph import NNGraph -from graph.types import ExpressionFusionParameters, FusionBase +from graph.types import ExpressionFusionParameters, FusionBase, Parameters from graph.types.fusions import FusionInputParameters, FusionOutputParameters from graphviz import Digraph, nohtml from quantization.qtype import QType @@ -92,6 +92,12 @@ def insert_tag(idx, tag, names): names[idx] = [f'{tag} {name}'] + names[idx][1::] return + @staticmethod + def get_label(node, anon): + if hasattr(node, 'graph_label'): + return node.graph_anon_label if anon else node.graph_label + return [node.name] + @staticmethod def build_nodebox(node, ports, num_in, num_out, anon=False): trans_in = DrawGraphReporter.get_trans(node, 'in') @@ -106,10 +112,10 @@ def build_nodebox(node, ports, num_in, num_out, anon=False): edges = [ f' {idx if num_in > 1 else ""}{trans[idx] if idx < len(trans) else ""}' for idx in range(num_in)] names.append(edges) - names.extend(node.graph_anon_label if anon else node.graph_label) + names.extend(DrawGraphReporter.get_label(node, anon)) else: ports[0] = [f'{node.name}:name'] - names.extend(node.graph_anon_label if anon else node.graph_label) + names.extend(DrawGraphReporter.get_label(node, anon)) DrawGraphReporter.insert_tag(0, f'', names) if num_out > 1 or trans_out: if trans_out: @@ -154,7 +160,8 @@ def out_label(self, G, edge, qrecs, parent=None, to_node=True, from_node=True): if qrec is None: qtype = 'no qrec' else: - qtype = qrec.out_qs[idx] if qrec.out_qs and idx < len(qrec.out_qs) else None + qtype = qrec.out_qs[idx] if qrec.out_qs and idx < len( + qrec.out_qs) else None if not qtype: qtype = 'no qtype' else: @@ -165,7 +172,8 @@ def out_label(self, G, edge, qrecs, parent=None, to_node=True, from_node=True): to_qrec = qrecs.get(nid) if to_qrec is None: return f'{qtype}/no qrec', True - to_qtype = to_qrec.in_qs[edge.to_idx] if to_qrec.in_qs and edge.to_idx < len(to_qrec.in_qs) else None + to_qtype = to_qrec.in_qs[edge.to_idx] if to_qrec.in_qs and edge.to_idx < len( + to_qrec.in_qs) else None if not to_qtype: return f'{qtype}/no qtype', True else: @@ -194,7 +202,8 @@ def in_label(self, G, edge, qrecs, parent=None, to_node=True, from_node=True): if qrec is None: qtype = 'no qrec' else: - qtype = qrec.in_qs[idx] if qrec.in_qs and idx < len(qrec.in_qs) else None + qtype = qrec.in_qs[idx] if qrec.in_qs and idx < len( + qrec.in_qs) else None if qtype is None: return 'no qtype', True else: @@ -205,7 +214,8 @@ def in_label(self, G, edge, qrecs, parent=None, to_node=True, from_node=True): from_qrec = qrecs.get(nid) if from_qrec is None: return f'no qrec/{qtype}', True - from_qtype = from_qrec.out_qs[edge.from_idx] if from_qrec.out_qs and edge.from_idx < len(from_qrec.out_qs) else None + from_qtype = from_qrec.out_qs[edge.from_idx] if from_qrec.out_qs and edge.from_idx < len( + from_qrec.out_qs) else None if not from_qtype: return f'no qtype/{qtype}', True else: @@ -218,16 +228,18 @@ def in_label(self, G, edge, qrecs, parent=None, to_node=True, from_node=True): if not from_qtype.quantization_equal(qtype): return f'{from_qtype}/{qtype}', True return str(qtype), False - else: + elif isinstance(node, Parameters): if node.in_dims: return self.dim_or_error(node.in_dims, idx) return 'not set', True + return '', False + def report_graph(self, G: NNGraph, dot, all_ports, fake_idx, nodes=None, all_dims=False, anonymise=False, expressions=False, qrecs=None, fusions=False, parent=None): if nodes is None: nodes = set(G.nodes()) - for node in G.dfs(): + for node in G.topological_sort(): if node not in nodes: continue if isinstance(node, (FusionInputParameters)): @@ -235,7 +247,7 @@ def report_graph(self, G: NNGraph, dot, all_ports, fake_idx, nodes=None, all_dim if expressions and isinstance(node, ExpressionFusionParameters): all_ports[node] = self.report_expression( dot, G, node, anonymise=anonymise, report_quantized=expressions == "quantized") - elif fusions and isinstance(node, FusionBase): + elif fusions and isinstance(node, FusionBase) and node.quantize_internals: all_ports[node] = self.report_fusion( dot, G, node, all_ports, fake_idx, all_dims=all_dims, anonymise=anonymise, expressions=expressions, qrecs=qrecs) @@ -247,8 +259,13 @@ def report_graph(self, G: NNGraph, dot, all_ports, fake_idx, nodes=None, all_dim if not isinstance(node, FusionOutputParameters): names = self.build_nodebox( node, ports, num_in_edges, num_out_edges, anon=anonymise) - dot.node(node.name, nohtml(names), shape='record', - xlabel=str(node.step_idx), color="blue" if node.is_not_generated else "black") + if not isinstance(node, Parameters): + dot.node(node.name, nohtml(names), + shape='record', color='black') + else: + dot.node(node.name, nohtml(names), shape='record', + xlabel=f"{node.step_idx}" if parent is None else "", + color="blue" if node.is_not_generated else "black") for edge in G.in_edges(node.name): if edge.from_node not in nodes: if not all_dims: @@ -260,7 +277,8 @@ def report_graph(self, G: NNGraph, dot, all_ports, fake_idx, nodes=None, all_dim to_node_id = self.get_to_id(all_ports, edge, in_port) edge_label, edge_error = self.in_label( G, edge, qrecs, parent=parent, - from_node=not isinstance(edge.from_node, FusionInputParameters), + from_node=not isinstance( + edge.from_node, FusionInputParameters), to_node=not isinstance(edge.to_node, FusionOutputParameters)) dot.edge( from_node_id, @@ -293,7 +311,8 @@ def report_graph(self, G: NNGraph, dot, all_ports, fake_idx, nodes=None, all_dim from_node_id = self.get_from_id(all_ports, edge, out_port) edge_label, edge_error = self.out_label( G, edge, qrecs, parent=parent, - from_node=not isinstance(edge.from_node, FusionInputParameters), + from_node=not isinstance( + edge.from_node, FusionInputParameters), to_node=not isinstance(edge.to_node, FusionOutputParameters)) dot.edge( from_node_id, @@ -312,7 +331,7 @@ def report(self, G: NNGraph, nodes=None, graph_format='PDF', all_dims=False, qrecs = None self.init_name_cache() all_ports = {} - graph_name = G.graphname if hasattr(G, 'graphname') else 'graph' + graph_name = G.name if hasattr(G, 'name') else 'graph' dot = Digraph(comment=graph_name, format=graph_format, node_attr={ 'height': '.1'}, edge_attr={'fontsize': '10.0'}) fake_idx = 0 @@ -354,8 +373,14 @@ def report_expression(self, dot: Digraph, G: NNGraph, else: func_col = node.func_col intermediates = {} - with dot.subgraph(name=f'cluster{node.name}', node_attr={'style': 'solid(dashed)'}) as sub: - for var, func in func_col.functions.items(): + with dot.subgraph(name=f'cluster{node.name}', + graph_attr={ + 'style': 'dashed', + 'label': f"{node.step_idx}", + 'labelloc': 't', + 'labeljust': 'l'}, + node_attr={'style': 'solid(dashed)'}) as sub: + for var, func in func_col: node_id, shape = self.report_symbol( sub, func, intermediates, anonymise=anonymise) var_name = self.get_next('Var') if anonymise else var.name @@ -364,7 +389,8 @@ def report_expression(self, dot: Digraph, G: NNGraph, else: dot.node(var.name, nohtml(var_name), shape='plaintext', fontsize='10.0') - sub.edge(node_id, var.name, xlabel=f'{str_shape(shape)}') + sub.edge( + node_id, var.name, xlabel=f'{str_shape(shape)}', color="red" if shape is None else "black") return [node.input_symbols, node.output_symbols] @@ -389,8 +415,14 @@ def report_fusion(self, dot: Digraph, G: NNGraph, shape='plaintext', fontsize='10.0') all_ports[output_node] = [[output_node.name], [output_node.name]] output_symbols.append(output_node.name) - with dot.subgraph(name=f'cluster{node.name}', node_attr={'style': 'solid(dashed)'}) as sub: - self.report_graph(node.subgraph, dot, all_ports, fake_idx, all_dims=all_dims, + with dot.subgraph(name=f'cluster{node.name}', + graph_attr={ + 'style': 'dashed', + 'label': f"{node.step_idx}", + 'labelloc': 't', + 'labeljust': 'l'}, + node_attr={'style': 'solid(dashed)'}) as sub: + self.report_graph(node.subgraph, sub, all_ports, fake_idx, all_dims=all_dims, anonymise=anonymise, expressions=expressions, qrecs=qrecs, parent=node) return [input_symbols, output_symbols] @@ -406,12 +438,17 @@ def report_symbol(self, dot, symbol, intermediates, anonymise=False): const_name = self.get_next('Const') dot.node(const_name, 'Const' if anonymise else str( symbol.value[0]), shape='oval', fontsize='10.0') - return const_name, None if len(symbol.shape) == 1 else symbol.shape + return const_name, symbol.shape ids_and_shapes = [self.report_symbol(dot, sym, intermediates, anonymise=anonymise) for sym in symbol.contents] func_label = self.get_next( 'Op') if anonymise else symbol.__class__.__name__ dot.node(symbol.name, nohtml(func_label), shape='record') for child_id, shape in ids_and_shapes: - dot.edge(child_id, symbol.name, xlabel=f'{str_shape(shape)}') - return symbol.name, symbol.shape + dot.edge(child_id, symbol.name, + xlabel=f'{str_shape(shape)}', color="red" if shape is None else "black") + try: + symbol_shape = symbol.shape + except ValueError: + symbol_shape = None + return symbol.name, symbol_shape diff --git a/tools/nntool/reports/quantization_reporter.py b/tools/nntool/reports/quantization_reporter.py index 8b8673fc6..09ce00a52 100644 --- a/tools/nntool/reports/quantization_reporter.py +++ b/tools/nntool/reports/quantization_reporter.py @@ -14,6 +14,7 @@ # along with this program. If not, see . from graph.types import ConstantInputParameters +from graph.types.activations import ActivationParameters from graph.types.base import FilterParameters from utils.node_id import NodeId from utils.tabular import Tabular, TabularColumn @@ -92,6 +93,8 @@ def report(self, G, stats, nodes=None): row.append(self.emit_qs([qrec.cache[key]])) else: row.append("") + elif "scale_mul_biases_q" in qrec.cache: + row += ["", "", self.emit_qs([qrec.cache["scale_mul_biases_q"]]), "", ""] else: row += ["", "", "", "", ""] else: diff --git a/tools/nntool/requirements.txt b/tools/nntool/requirements.txt index 4921886b3..4694226d8 100644 --- a/tools/nntool/requirements.txt +++ b/tools/nntool/requirements.txt @@ -12,9 +12,9 @@ argcomplete==1.10.0 Cython==0.29.21 scikit-image==0.17.2 scikit-learn==0.21.3 -onnx==1.8.0 +onnx==1.10.2 prettytable==0.7.2 iteration-utilities==0.11.0 bfloat16==1.0 -graphviz==0.16.0 +graphviz==0.19.1 kmeans1d==0.3.1 diff --git a/tools/nntool/stats/activation_ranges_collector.py b/tools/nntool/stats/activation_ranges_collector.py index 42c8fd593..913187d3f 100644 --- a/tools/nntool/stats/activation_ranges_collector.py +++ b/tools/nntool/stats/activation_ranges_collector.py @@ -18,10 +18,9 @@ import numpy as np from execution.graph_executer import GraphExecuter -from graph.types import (FilterParameters, LSTMParameters, - MultiplicativeBiasParameters, RNNBaseParameters) -from graph.types.expression_fusion import ExpressionFusionParameters from graph.types.fusions import FusionBase, FusionInputParameters +from stats.ranges_utils import collect_stat, update_ranges +from utils.json_serializable import JsonSerializable from utils.node_id import NodeId from .stats_collector import GraphStatsCollector @@ -41,10 +40,75 @@ def update_peraxis(var, arr: np.ndarray): per_axis_elem['max'] = np.maximum( per_axis_elem['max'], arr.max(axis=other_axis)) +class Rolling(JsonSerializable): + def __init__(self) -> None: + self._values = [] -def update_ema(ema, value, decay): - ema = value * decay + (1 - decay) * ema - return ema + def __float__(self): + if not self._values: + return 0 + return float(np.sum(self._values)/len(self._values)) + + def add_val(self, val: float): + self._values.append(val) + + def _encapsulate(self): + return float(self) + + def __mul__(self, other): + return float(self).__mul__(other) + + def __add__(self, other): + return float(self).__add__(other) + + def __truediv__(self, other): + return float(self).__truediv__(other) + + def __floordiv__(self, other): + return float(self).__floordiv__(other) + + def __mod__(self, other): + return float(self).__mod__(other) + + def __divmod__(self, other): + return float(self).__divmod__(other) + + def __pow__(self, other): + return float(self).__pow__(other) + + def __sub__(self, other): + return float(self).__sub__(other) + + def __radd__(self, other): + return float(self).__radd__(other) + + def __rsub__(self, other): + return float(self).__rsub__(other) + + def __rmul__(self, other): + return float(self).__rmul__(other) + + def __rtruediv__(self, other): + return float(self).__rtruediv__(other) + + def __rfloordiv__(self, other): + return float(self).__rfloordiv__(other) + + def __rmod__(self, other): + return float(self).__rmod__(other) + + def __rpow__(self, other): + return float(self).__rpow__(other) + + @classmethod + def _dencapsulate(cls, val): + return val + + def __repr__(self) -> str: + return f'{float(self)}' + + def __str__(self) -> str: + return f'{float(self)}' class ActivationRangesCollector(GraphStatsCollector): @@ -55,40 +119,10 @@ def __init__(self, graph_execution=None, use_ema=False, ema_decay=0.999): self.use_ema = use_ema self.ema_decay = ema_decay - def update_expression_ranges(self, stat, details): - if 'expression' in stat: - stat = stat['expression'] - for sym_name, rec in details.items(): - if sym_name == "results": - continue - stat_rec = stat.setdefault( - sym_name, {'min': float('inf'), 'max': float('-inf')}) - stat_rec['min'] = min(stat_rec['min'], rec['min']) - stat_rec['max'] = max(stat_rec['max'], rec['max']) - else: - stat['expression'] = deepcopy(details) - - def collect_stat(self, stat, name, details, details_name=None): - range_stat = stat.get(name) - if not range_stat: - range_stat = {'min': float('inf'), 'max': float('-inf')} - stat[name] = range_stat - if details_name is None: - self.update_ranges( - range_stat, details[name]['min'], details[name]['max']) - else: - self.update_ranges( - range_stat, details['min_' + details_name], details['max_' + details_name]) - - def update_ranges(self, range_out, tensor_min, tensor_max): - if self.use_ema and all([range_out['min'] != float('inf'), range_out['max'] != float('-inf')]): - range_out['min'] = update_ema( - range_out['min'], tensor_min, self.ema_decay) - range_out['max'] = update_ema( - range_out['max'], tensor_max, self.ema_decay) - else: - range_out['min'] = min(range_out['min'], tensor_min) - range_out['max'] = max(range_out['max'], tensor_max) + + def collect_stat(self, stat: dict, name, details, details_name=None): + ema_decay = self.ema_decay if self.use_ema else None + collect_stat(stat, name, details, details_name=details_name, ema_decay=ema_decay) def collect_stats(self, G, input_tensors, step_idx=None): if self._graph_execution is None: @@ -113,7 +147,9 @@ def collect_stats(self, G, input_tensors, step_idx=None): { 'min': float('inf'), 'max': float('-inf'), - 'std': 0.0 + 'std': Rolling(), + 'mean': Rolling(), + 'b': Rolling() } for _ in output_tensors] stat = { 'range_in': range_in, @@ -145,26 +181,18 @@ def collect_stats(self, G, input_tensors, step_idx=None): for idx, tensor in enumerate(output_tensors): range_out = stat['range_out'][idx] - self.update_ranges(range_out, tensor.min(), tensor.max()) - range_out['std'] = np.std(tensor) + ema_decay = self.ema_decay if self.use_ema else None + update_ranges(range_out, tensor.min(), tensor.max(), ema_decay=ema_decay) + range_out['std'].add_val(np.std(tensor)) + mean = np.mean(tensor) + range_out['mean'].add_val(mean) + range_out['b'].add_val(np.mean(np.abs(tensor - mean))) update_peraxis(range_out, tensor) - if isinstance(node, FilterParameters): - if details: - self.collect_stat(stat, 'range_acc', - details, details_name='acc') - if isinstance(node, MultiplicativeBiasParameters) and node.has_mul_bias: - self.collect_stat( - stat, 'range_pre_mul_bias', details, details_name='pre_mul_bias') - elif isinstance(node, RNNBaseParameters): - if details: - for k in details: - if k.startswith('range_'): - self.collect_stat(stat, k, details) - elif isinstance(node, ExpressionFusionParameters): - if details: - self.update_expression_ranges(stat, details) - elif isinstance(node, FusionBase) and pnode.quantize_internals: + if details: + node.details_collector(self.stats, stat, details) + + if isinstance(node, FusionBase) and pnode.quantize_internals: for inode in node.subgraph.nodes(node_classes=FusionInputParameters): finput_in_stat = stat['range_in'][inode.idx] for edge in node.subgraph.out_edges(inode.name): diff --git a/tools/nntool/stats/ranges_utils.py b/tools/nntool/stats/ranges_utils.py new file mode 100644 index 000000000..0c0bdad70 --- /dev/null +++ b/tools/nntool/stats/ranges_utils.py @@ -0,0 +1,37 @@ +# Copyright (C) 2022 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import numpy as np + + +def update_ema(ema, value, decay): + ema = value * decay + (1 - decay) * ema + return ema + +def update_ranges(range_out, tensor_min, tensor_max, ema_decay=None): + if ema_decay is not None and all([range_out['min'] != float('inf'), range_out['max'] != float('-inf')]): + range_out['min'] = update_ema( + range_out['min'], tensor_min, ema_decay) + range_out['max'] = update_ema( + range_out['max'], tensor_max, ema_decay) + else: + range_out['min'] = min(range_out['min'], tensor_min) + range_out['max'] = max(range_out['max'], tensor_max) + +def collect_stat(stat: dict, name, details, details_name=None, ema_decay=None): + range_stat = stat.setdefault(name, {'min': float('inf'), 'max': float('-inf')}) + postfix = "" if details_name is None else f'_{details_name}' + tensors = tuple(details[f'{key}{postfix}'] for key in ('min', 'max')) + update_ranges(range_stat, *tensors, ema_decay=ema_decay) diff --git a/tools/nntool/utils/compatible_transposes.py b/tools/nntool/utils/compatible_transposes.py index d5c869381..eb3251931 100644 --- a/tools/nntool/utils/compatible_transposes.py +++ b/tools/nntool/utils/compatible_transposes.py @@ -13,8 +13,11 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from typing import Sequence from functools import reduce +from typing import Sequence + +from graph.manipulations.eliminate_transposes.transpose_helpers import ( + apply_transpose, indexes_of, reverse_transpose) def reduce_one(state, num): @@ -85,7 +88,7 @@ def find_first(combination, idx): return fc_idx elif idx in fc_set: # item is not first so no match - raise IndexError() # @IgnoreException + raise IndexError() # @IgnoreException return None @@ -98,7 +101,7 @@ def len_at_start(l, elem): def compatible_transpose(combination, trans): - """Determines if the transpose can be expressed in the combination in fc + """Determines if the transpose can be expressed in the combination in descriptor found by find_combination """ res = [] trans = list(trans) @@ -114,9 +117,9 @@ def compatible_transpose(combination, trans): continue # we have a segment who's first element matches the transpose # the rest of the elements in the segment must be in order - fc_idx = first_idx - while trans and fc_idx < len(combination): - segs = combination[fc_idx] + descriptor_idx = first_idx + while trans and descriptor_idx < len(combination): + segs = combination[descriptor_idx] if segs is not None: # if segs is none then it matches anything # the first seg must match since it was found by find_first # this tests if another seg doesn't match in which case we are @@ -131,16 +134,16 @@ def compatible_transpose(combination, trans): # so no solution if trans[0] != oidx: return False - fc_idx += 1 + descriptor_idx += 1 # this trans element no longer matches the next segment or we # reached the end if trans: trans.pop(0) # add range from first to last on first time around # this will include idxes idxes of Nones after this segment - res += list(range(first_idx, fc_idx)) + res += list(range(first_idx, descriptor_idx)) at_start = len_at_start(combination, None) - # The only bit we won't have matched is a fc that starts with None's so + # The only bit we won't have matched is a descriptor that starts with None's so # add those indexes to the start return tuple(list(range(0, at_start)) + res) @@ -154,3 +157,170 @@ def find_all_compatible_transposes(combinations, trans): def find_compatible_transpose(fcs, trans): return next(find_all_compatible_transposes(fcs, trans), None) + + +def expand_to_len(trans, length): + extra = length-len(trans) + return tuple(list(range(extra)) + [dim + extra for dim in trans]) + + +def reduce_to_len(trans, length): + extra = len(trans) - length + return tuple([dim - extra for dim in trans if dim >= extra]) + + +def no_ones(l): + return tuple(elem for elem in l if elem != 1) + + +def ones_shuffled(from_shape, to_shape): + if len(from_shape) != len(to_shape) or no_ones(from_shape) != no_ones(to_shape): + return False + return True + + +def reshape_shuffle_trans(from_shape, to_shape): + from_shape = list(enumerate(from_shape)) + to_shape = list(enumerate(to_shape)) + ones_pos_from = tuple(shape[0] for shape in from_shape if shape[1] == 1) + ones_pos_to = list(shape[0] for shape in to_shape if shape[1] == 1) + idx_to = 0 + idx_from = 0 + idx_from_ones = 0 + trans = [] + for idx_to in range(len(to_shape)): + if idx_to in ones_pos_to: + trans.append(ones_pos_from[idx_from_ones]) + idx_from_ones += 1 + else: + while idx_from in ones_pos_from: + idx_from += 1 + trans.append(idx_from) + idx_from += 1 + return trans + + +def is_broadcasted(from_shape, to_shape): + from_len = len(from_shape) + to_len = len(to_shape) + if from_len >= to_len: + return False + return tuple(([1] * (to_len - from_len)) + list(from_shape)) == tuple(to_shape) + + +def broadcast_transpose(from_shape, to_shape, going_up): + from_len = len(from_shape) + to_len = len(to_shape) + if going_up: + return tuple((idx,) for idx in range(to_len - from_len, to_len)) + return tuple(([None] * (to_len - from_len))+list(range(from_len))) + + +def apply_combination(shape, comb): + res = [] + comb = list(comb) + while comb: + elem = comb.pop(0) + if elem is None: + res.append(1) + else: + res.append(reduce(lambda x, y: x*y, [shape[i] for i in elem])) + return tuple(res) + + +def transpose_combination(comb, trans): + res = [] + comb = list(comb) + while comb: + elem = comb.pop(0) + if elem is None: + res.append(None) + else: + res.append(tuple(trans.index(i) for i in elem)) + return tuple(res) + + +def calc_new_reshape(trans, new_trans, from_shape, to_shape, going_up): + if going_up: + # transpose is in the up direction so is reversed + # we want to apply it in the down direction so reverse it + new_to_shape = apply_transpose(to_shape, reverse_transpose(trans)) + # the from_shape gets the new transpose applied to it - this may result in the reshape being eliminated + # since the shape change that it caused is already in the transpose + # NOTE - Looking at the reshape as a transpose itself is not correct. It is a shuffle not a transpose + # the tensor physical order is not changed unlike a transpose + new_from_shape = apply_transpose( + from_shape, reverse_transpose(new_trans)) + else: + # transpose is in the down direction but we want to pass it through this reshape so + # we want to reverse its effect + new_from_shape = apply_transpose(from_shape, reverse_transpose(trans)) + # the to_shape gets the new transpose applied to it - this may result in the reshape being eliminated + # since the shape change that it caused is already in the transpose + new_to_shape = apply_transpose(to_shape, reverse_transpose(new_trans)) + return ( + tuple(new_trans), + tuple(new_from_shape), + tuple(new_to_shape)) + + +def calc_failure_reshapes(trans, from_shape, to_shape, going_up): + if going_up: + new_to_shape = tuple(apply_transpose( + to_shape, reverse_transpose(trans))) + new_from_shape = None + else: + new_from_shape = tuple(apply_transpose( + from_shape, reverse_transpose(trans))) + new_to_shape = None + return ( + None, + new_from_shape, + new_to_shape) + + +def reverse_reshape(trans, from_shape, to_shape, going_up=False): + """reverses the effect of this reshape on the transpose. If going up is set then then + the transpose is in the direction to_shape -> from_shape""" + + if len(from_shape) == 0 or len(to_shape) == 0: + return calc_failure_reshapes(trans, from_shape, to_shape, going_up) + + # if the from_shape -> to_shape is actually a broadcast reshape + # i.e. 4, 10, 1 -> 1, 4, 10, 1 we absolutely need to keep the order 4, 10, 1 in + # the transpose however the 2 1s in the result are ambiguous so handle this as a + # (simple) special case. Just expand the transpose with no transpose at the start + # and expand_len + original transpose dim at the end + if is_broadcasted(from_shape, to_shape): + broad_trans = broadcast_transpose(from_shape, to_shape, going_up) + if going_up: + new_trans = reverse_transpose(reduce_to_len( + reverse_transpose(trans), len(from_shape))) + else: + new_trans = reverse_transpose(expand_to_len( + reverse_transpose(trans), len(to_shape))) + return calc_new_reshape(trans, new_trans, from_shape, to_shape, going_up) + + # consider the shapes in the correct order + shape_order = (to_shape, from_shape) if going_up else ( + from_shape, to_shape) + + if ones_shuffled(shape_order[0], shape_order[1]): + shuffle_trans = reshape_shuffle_trans(shape_order[0], shape_order[1]) + new_trans = apply_transpose(trans, shuffle_trans) + return calc_new_reshape(trans, new_trans, from_shape, to_shape, going_up) + + for combination in find_combination(*shape_order): + if not combination: + continue + # going down we are looking at where we could transpose the reshape combination back up the + # graph in a valid way and then reverse that transpose + # going up re are propagating a reversed transpose so we still need to reverse + reversed_new_trans = compatible_transpose( + combination, reverse_transpose(trans)) + if not reversed_new_trans or len(reversed_new_trans) != len(shape_order[1]): + continue + new_trans = reverse_transpose(reversed_new_trans) + return calc_new_reshape(trans, new_trans, from_shape, to_shape, going_up) + + return calc_failure_reshapes(trans, from_shape, to_shape, going_up) diff --git a/tools/nntool/utils/diag_collector.py b/tools/nntool/utils/diag_collector.py index 50ea50704..75b93a5e8 100644 --- a/tools/nntool/utils/diag_collector.py +++ b/tools/nntool/utils/diag_collector.py @@ -41,8 +41,8 @@ def __new__(cls, *args, **kwargs): return instance def __init__(self, *args, **kwargs): - if self not in ThreadSingleton.__initialized: - ThreadSingleton.__initialized.add(self) + if object.__hash__(self) not in ThreadSingleton.__initialized: + ThreadSingleton.__initialized.add(object.__hash__(self)) super().__init__(*args, **kwargs) return ThreadSingleton diff --git a/tools/nntool/utils/exception.py b/tools/nntool/utils/exception.py new file mode 100644 index 000000000..a4771cd5e --- /dev/null +++ b/tools/nntool/utils/exception.py @@ -0,0 +1,20 @@ +# Copyright (C) 2022 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +class NNToolInternelError(Exception): + pass + +class NNToolNotImplementedError(NotImplementedError): + pass diff --git a/tools/nntool/utils/graph.py b/tools/nntool/utils/graph.py index 4162eb988..e3372f99e 100644 --- a/tools/nntool/utils/graph.py +++ b/tools/nntool/utils/graph.py @@ -1,4 +1,4 @@ -# Copyright (C) 2020 GreenWaves Technologies, SAS +# Copyright (C) 2020, 2022 GreenWaves Technologies, SAS # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -15,9 +15,16 @@ from itertools import zip_longest -from collections import OrderedDict, deque from collections.abc import Iterable, Mapping -from typing import Union, Sequence +from typing import Optional, Set, Tuple, Union, Sequence + + +def is_iterable(x): + try: + iter(x) # @IgnoreException + except TypeError: + return False + return True class GraphError(Exception): @@ -46,9 +53,13 @@ class Node(): '''Node class to inherit for nodes''' def __init__(self, name: str, *args, **kwargs): - super(Node, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self._name = name + @property + def _noderef_class(self): + return NodeRef + @property def name(self): '''Node name - must not be changed once node is in graph''' @@ -59,18 +70,72 @@ def name(self, name): '''Node name - must not be changed once node is in graph''' self._name = name + def __call__(self, *args, num_outputs=1): + inputs = [] + fragments = set() + for arg in args: + if arg is not None and not isinstance(arg, self._noderef_class): + raise ValueError( + f"expecting {self._noderef_class.__name__} or None") + inputs.append(arg.ref[0] if arg else None) + fragments.add(arg.ref[1] if arg else None) + fragment = next( + iter([frag for frag in fragments if frag is not None]), None) + if fragment is None: + raise ValueError("No inputs") + other_fragments = fragments - {fragment} + + for other in other_fragments: + if hasattr(fragment, 'merge'): + if other is not None: + fragment.merge(other) + else: + raise ValueError('graph has no merge method') + + for to_idx, from_tuple in enumerate(inputs): + if from_tuple is not None: + from_node, from_idx = from_tuple + fragment.add_edge(fragment._edge_class(from_node=from_node, + from_idx=from_idx, + to_node=self, + to_idx=to_idx)) + if num_outputs == 1: + return self._noderef_class(fragment, self, 0) + return tuple(self._noderef_class(fragment, self, idx) for idx in range(num_outputs)) + def __str__(self): return self._name class NodeRef(): - def __init__(self, node) -> None: + def __init__(self, G: "GraphView", node: Node, idx: int) -> None: + self._G = G self._node = node + self._idx = idx + + @property + def G(self) -> "GraphView": + return self._G + + @property + def ref(self) -> Tuple[Tuple[Node, int], "GraphView"]: + return ((self._node, self._idx), self._G) @property - def node(self): + def node(self) -> Node: return self._node + def __eq__(self, o: object) -> bool: + if isinstance(o, NodeRef): + return super().__eq__(o) + return self._node.__eq__(o) + + def __hash__(self) -> int: + return self._node.__hash__() + + def __call__(self, *args, **kwargs): + raise ValueError("this is already a reference") + class MatchNode(Node): '''Node class to inherit for node matchers''' @@ -136,6 +201,12 @@ def __init__(self, from_node: Union[str, Node, NodeRef], to_node: Union[str, Nod raise ValueError('expecting int for to_idx') self._link = (from_node, from_idx, to_node, to_idx) + @classmethod + def from_src_to_dest(cls, from_edge, to_edge): + return cls( + from_node=from_edge.from_node, from_idx=from_edge.from_idx, + to_node=to_edge.to_node, to_idx=to_edge.to_idx) + @property def from_node(self): '''Edge start node''' @@ -194,16 +265,53 @@ def __hash__(self): class GraphView(Mapping): - def __init__(self): - self._out_edges = OrderedDict() - self._in_edges = OrderedDict() - self._nodes = OrderedDict() + def __init__(self, **attr): + self._out_edges = {} + self._in_edges = {} + self._nodes = {} + self._attr = attr @classmethod # pylint: disable=unused-argument def clone_factory(cls, G): return cls() + def with_hidden_nodes(self, hidden_fn, edge_class=None): + if edge_class is None: + edge_class = Edge + + def real_up_node(G, edge): + if hidden_fn(edge.from_node): + edges = G.in_edges(edge.from_node) + assert len(edges) == 1 + return real_up_node(G, edges[0]) + return edge.from_node, edge.from_idx + + def copy_node(G, new_graph, node): + for edge in self.in_edges(node): + from_node, from_idx = real_up_node(G, edge) + new_edge = edge_class(from_node=from_node, from_idx=from_idx, + to_node=node, to_idx=edge.to_idx) + if new_graph.has_edge(new_edge): + continue + new_graph.add_edge(new_edge) + copy_node(G, new_graph, from_node) + + new_graph = self.__class__() + setattr(new_graph, '_attr', self._attr) + for node in self.outputs(): + copy_node(self, new_graph, node) + return new_graph + + def has_edge(self, edge): + edges = self._in_edges.get(edge.to_node.name) + if not edges: + return False + edges = edges.get(edge.from_node.name) + if not edges: + return False + return edge in edges + def clear(self): '''Clears the graph view''' if self._nodes: @@ -219,6 +327,12 @@ def clone(self) -> 'GraphView': clone._nodes = self._nodes.copy() return clone + def merge(self, other: 'Graph'): + if self != other: + for edge in other.edges: + self.add_edge(edge) + return self + def num_nodes(self): '''Number of nodes len(GraphView) also works''' return len(self) @@ -230,14 +344,8 @@ def num_edges(self): for edge in edge_list) def __add_in_edge(self, edge: Edge, update=False): - edges = self._in_edges.get(edge.to_node.name) - if not edges: - edges = {} - self._in_edges[edge.to_node.name] = edges - edge_list = edges.get(edge.from_node.name) - if edge_list is None: - edge_list = [] - edges[edge.from_node.name] = edge_list + edges = self._in_edges.setdefault(edge.to_node.name, {}) + edge_list = edges.setdefault(edge.from_node.name, []) edge_idx = next((i for i, x in enumerate(edge_list) if x == edge), -1) if edge_idx >= 0: if update: @@ -253,14 +361,8 @@ def __add_in_edge(self, edge: Edge, update=False): edge_list.append(edge) def __add_out_edge(self, edge: Edge, update=False): - edges = self._out_edges.get(edge.from_node.name) - if not edges: - edges = {} - self._out_edges[edge.from_node.name] = edges - edge_list = edges.get(edge.to_node.name) - if edge_list is None: - edge_list = [] - edges[edge.to_node.name] = edge_list + edges = self._out_edges.setdefault(edge.from_node.name, {}) + edge_list = edges.setdefault(edge.to_node.name, []) edge_idx = next((i for i, x in enumerate(edge_list) if x == edge), -1) if edge_idx >= 0: if update: @@ -382,7 +484,8 @@ def predecessor_names(self, node_name: str) -> Iterable: def nodes(self, node_classes=None, sort=False): '''All the nodes in the graph. GraphView.values() also works.''' if node_classes is not None: - nodes = [node for node in self._nodes.values() if isinstance(node, node_classes)] + nodes = [node for node in self._nodes.values( + ) if isinstance(node, node_classes)] else: nodes = list(self._nodes.values()) if sort: @@ -435,34 +538,48 @@ def connected_nodes(self, node_or_node_name): edge.to_node for edge in self.out_edges(node_or_node_name)) return list(connected_nodes) - def is_vertex_cut(self, node_set, node=None, visited=None): - if visited is None: - visited = set() - if node is None: - inputs = set(self.inputs()) - # choose one input node (or successor) that is not in the node_set - start_node = None - while inputs: - node = inputs.pop() - # if the input node is actually in the set then move past it - # this ensures that if the node_set is at the start of the graph - # and does not divide the graph it is not reported as a cut - if node not in node_set: - start_node = node - break - inputs.update(edge.to_node for edge in self.out_edges(node)) - self.is_vertex_cut(node_set, node=start_node, visited=visited) - return len(visited) < (len(self) - len(node_set)) - # undirected dfs + def _old_undirected_dfs(self, node, stop_at, pass_at, visited): + if node in stop_at or node in visited: + return + if pass_at and node not in pass_at: + return visited.add(node) - for edge in self.out_edges(node): - if edge.to_node in visited | node_set: - continue - self.is_vertex_cut(node_set, node=edge.to_node, visited=visited) + yield node for edge in self.in_edges(node): - if edge.from_node in visited | node_set: - continue - self.is_vertex_cut(node_set, node=edge.from_node, visited=visited) + yield from self._old_undirected_dfs(edge.from_node, stop_at, pass_at, visited) + for edge in self.out_edges(node): + yield from self._old_undirected_dfs(edge.to_node, stop_at, pass_at, visited) + + def old_undirected_dfs(self, stop_at=None, start_at=None, pass_at=None): + if start_at is None: + start_at = list(self.inputs()) + elif is_iterable(start_at): + start_at = list(start_at) + else: + start_at = [start_at] + if stop_at is None: + stop_at = set() + elif not is_iterable(stop_at): + stop_at = {stop_at} + else: + stop_at = set(stop_at) + if pass_at is None: + pass_at = set() + elif not is_iterable(pass_at): + pass_at = {stop_at} + else: + pass_at = set(pass_at) + + visited = set() + while start_at: + yield from self._old_undirected_dfs(start_at.pop(0), stop_at, pass_at, visited) + + def is_vertex_cut(self, node_set): + start_at = next( + iter([node for node in self.nodes() if node not in node_set])) + visited = list(self.old_undirected_dfs( + start_at=start_at, stop_at=node_set)) + return len(visited) < (len(self) - len(node_set)) def nodes_between_in(self, node_from, node_to, node_set, start=True): """Check that the only nodes between from and to are in node set""" @@ -496,25 +613,38 @@ def nodes_between(self, node_from, node_to, visited=None, path=None): visited=visited, path=path + [edge.to_node]) return visited - def nodes_below(self, node, visited=None): + def paths_between(self, node_from, node_to, path=None, topo=None): + if topo is None: + topo = {node: idx for idx, node in enumerate(self.topological_sort())} + path = [] + if node_from == node_to: + return path + if topo[node_from] > topo[node_to]: + return None + found_paths = [] + for edge in self.in_edges(node_to): + up_path = self.paths_between(node_from, edge.from_node, path=[edge] + path, topo=topo) + if up_path is None: + continue + found_paths.append(up_path) + if not found_paths: + return None + if len(found_paths) == 1: + return found_paths[0] + return found_paths + + def nodes_below(self, node): """Return nodes below node not including node""" - if visited is None: - node = resolve_node_or_str(node, G=self) - visited = set() - for edge in self.out_edges(node): - visited.add(edge.to_node) - self.nodes_below(edge.to_node, visited=visited) - return visited + nodes_below = set(self.directed_dfs(node)) + nodes_above = set(self.undirected_dfs( + node, start_up=True, stop_down_at=nodes_below)) + return tuple(self.undirected_dfs(node, stop_up_at=nodes_above)) def nodes_above(self, node, visited=None): """Return nodes above node not including node""" - if visited is None: - node = resolve_node_or_str(node, G=self) - visited = set() - for edge in self.in_edges(node): - visited.add(edge.from_node) - self.nodes_above(edge.from_node, visited=visited) - return visited + nodes_above = set(self.directed_dfs(node, go_up=True)) + nodes_below = set(self.undirected_dfs(node, stop_up_at=nodes_above)) + return tuple(self.undirected_dfs(node, stop_down_at=nodes_below, start_up=True)) def nodes_below_are_class(self, node, classes, visited=None): """Check all nodes below are in classes""" @@ -530,6 +660,169 @@ def nodes_below_are_class(self, node, classes, visited=None): return False return True + def directed_dfs(self, + node_or_name: Union[str, Node], + stop_at: Optional[Set[Node]] = None, + go_up: bool = False, + yield_start_node=False, + visited=None): + """Yields all nodes above or below this node searched directed. This is almost a dfs + since it yields in order going down the graph rather than bottom up + + Args: + node_or_name (Union[str, Node]): Node or node name to start at + stop_at (Optional[Set[Node]], optional): Stop at this set of nodes. Defaults to None. + go_up (bool, optional): Go in an upward direction or downwards if False. Defaults to False. + + Yields: + Node: Nodes visited + """ + node = resolve_node_or_str(node_or_name, G=self) + if visited is None: + visited = {node} + started = False + if stop_at is None: + stop_at = {} + else: + started = True + if node in stop_at: + return + if started or yield_start_node: + yield node + if not go_up: + for edge in self.out_edges(node.name): + if edge.to_node in visited: + continue + visited.add(edge.to_node) + yield from self.directed_dfs(edge.to_node, stop_at=stop_at, go_up=go_up, visited=visited) + if go_up: + for edge in self.in_edges(node.name): + if edge.from_node in visited: + continue + visited.add(edge.from_node) + yield from self.directed_dfs(edge.from_node, stop_at=stop_at, go_up=go_up, visited=visited) + + def connected_groups(self): + nodes = set(self.nodes()) + groups = [] + while nodes: + start = nodes.pop() + group = set(self.undirected_dfs(start))|set(self.undirected_dfs(start, start_up=True))|{start} + groups.append(group) + nodes -= group + return groups + + def undirected_dfs(self, + node_or_name: Union[str, Node], + stop_at: Optional[Set[Node]] = None, + stop_down_at: Optional[Set[Node]] = None, + stop_up_at: Optional[Set[Node]] = None, + start_up: bool = False, + yield_start_node: bool = False, + yield_stop_node: bool = False, + visited=None): + """Yields all nodes above or below this node searched undirected. This is almost a dfs + since it yields in order going down the graph rather than bottom up. It also has a few modes + where it is edge direction sensitive for stopping + + Args: + node_or_name (Union[str, Node]): Node or node name to start at + stop_at (Optional[Set[Node]], optional): Stop at this set of nodes. Defaults to None. + stop_down_at (Optional[Set[Node]], optional): Stop at this set of nodes going down. Defaults to None. + stop_up_at (Optional[Set[Node]], optional): Stop at this set of nodes going up. Defaults to None. + start_up (bool, optional): Start in an upward direction or downwards if False. Defaults to False. + + Yields: + Node: Nodes visited + """ + node = resolve_node_or_str(node_or_name, G=self) + if visited is None: + visited = {node} + started = False + if stop_at is None: + stop_at = {} + if stop_down_at is None: + stop_down_at = {} + if stop_up_at is None: + stop_up_at = {} + else: + started = True + if node in stop_at: + if yield_stop_node: + yield node + return + if started or yield_start_node: + yield node + if not start_up or started: + for edge in self.out_edges(node.name): + if edge.to_node in visited or edge.to_node in stop_down_at: + continue + visited.add(edge.to_node) + yield from self.undirected_dfs(edge.to_node, stop_at=stop_at, stop_down_at=stop_down_at, + stop_up_at=stop_up_at, visited=visited) + if start_up or started: + for edge in self.in_edges(node.name): + if edge.from_node in visited or edge.from_node in stop_up_at: + continue + visited.add(edge.from_node) + yield from self.undirected_dfs(edge.from_node, stop_at=stop_at, stop_down_at=stop_down_at, + stop_up_at=stop_up_at, visited=visited) + + def _topological_sort(self, node: Node, visited_edges): + yield node + for edge_bundle in self.indexed_out_edges(node): + for edge in edge_bundle: + visited_edges.add(edge) + if set(self.in_edges(edge.to_node)).issubset(visited_edges): + yield from self._topological_sort(edge.to_node, visited_edges) + + def _topological_sort_reversed(self, node: Node, visited_edges): + yield node + for edge in reversed(self.indexed_in_edges(node)): + visited_edges.add(edge) + if set(self.out_edges(edge.from_node)).issubset(visited_edges): + yield from self._topological_sort_reversed(edge.from_node, visited_edges) + + def topological_sort(self, + start_node_or_nodes: Optional[Union[str, + Node, + Sequence[Union[str, Node]]]] = None, + reverse: bool = False): + """[summary] + + Args: + start_node_or_nodes (Optional[Union[str, Node, Sequence[Union[str, Node]]]], optional): + Optional start node or nodes. Can also be node names. Defaults to None. + reverse (bool, optional): Sort from bottom of the graph up. Tries to be a perfect reverse of order. Defaults to False. + + Raises: + ValueError: Bad parameters given + + Yields: + (Node): Yields nodes in desired sort order + """ + if start_node_or_nodes is None: + if reverse: + nodes = list(reversed(self.outputs())) + else: + nodes = self.inputs() + elif isinstance(start_node_or_nodes, str): + nodes = [self._nodes[start_node_or_nodes]] + elif isinstance(start_node_or_nodes, Iterable): + nodes = [node if isinstance(node, Node) else + self[node] for node in start_node_or_nodes] + else: + raise ValueError('invalid argument') + visited_edges = set() + if reverse: + while nodes: + node = nodes.pop(0) + yield from self._topological_sort_reversed(node, visited_edges) + else: + while nodes: + node = nodes.pop(0) + yield from self._topological_sort(node, visited_edges) + def nodes_above_are_class(self, node, classes, visited=None): """Check all nodes above are in classes""" if visited is None: @@ -601,64 +894,6 @@ def num_out_edges(self, node_or_name: Union[str, Node]) -> int: node_name = resolve_name(node_or_name) return len(self.out_edges(node_name)) - def flood_above(self, node_or_name: Union[str, Node], res=None, in_edge=None): - """Return all nodes above this node including it and those connected to it - - Args: - node (Node): Node to flood - - Returns: - [Sequence[Node]]: Nodes found including node - """ - node = resolve_node_or_str(node_or_name, G=self) - if res is None: - first = True - res = {node} - else: - first = False - for edge in self.in_edges(node.name): - if edge.from_node not in res: - res.add(edge.from_node) - self.flood_above(edge.from_node, res=res, in_edge=edge) - if not first: - for edge in self.out_edges(node.name): - if edge == in_edge: - continue - if edge.to_node != node and edge.to_node not in res: - res.add(edge.to_node) - self.flood_below(edge.to_node, res=res) - return res - - def flood_below(self, node_or_name: Union[str, Node], stop_at=None, res=None, out_edge=None): - """Return all nodes below this node including it and those connected to it - - Args: - node (Node): Node to flood - stop_at (Node): Optional node to stop flooding at - Returns: - [Sequence[Node]]: Nodes found including node - """ - node = resolve_node_or_str(node_or_name, G=self) - if stop_at: - stop_at = resolve_node_or_str(stop_at, G=self) - if res is None: - first = True - res = {node, stop_at} if stop_at else {node} - else: - first = False - for edge in self.out_edges(node.name): - if edge.to_node not in res: - res.add(edge.to_node) - self.flood_below(edge.to_node, res=res, out_edge=edge) - if not first: - for edge in self.in_edges(node.name): - if edge == out_edge: - continue - if edge.from_node != node and edge.from_node not in res: - res.add(edge.from_node) - self.flood_above(edge.from_node, res=res) - return res - def remove_all(self, nodes: Sequence[Node]): """Remove all nodes @@ -675,26 +910,20 @@ def remove_all(self, nodes: Sequence[Node]): self.remove(del_node) def remove_below(self, node: Node): - """Remove the nodes below this node. Note: If there are links below this node - that go back above it this will do nothing since all nodes are flooded. Use - keep_between in this case. + """Remove the nodes below this node. Args: node (Node): Remove below this node """ - keep_nodes = self.flood_above(node) - self.remove_all(set(self._nodes.values()) - keep_nodes) + self.remove_all(self.nodes_below(node)) def remove_above(self, node: Node): - """Remove the nodes above this node. Note: If there are links above this node - that go down below it this will do nothing since all nodes are flooded. Use - keep_between in this case. + """Remove the nodes above this node.. Args: node (Node): Remove below this node """ - keep_nodes = self.flood_below(node) - self.remove_all(set(self._nodes.values()) - keep_nodes) + self.remove_all(self.nodes_above(node)) def keep_between(self, from_node: Node, to_node: Node): """Remove all nodes that are not between from_node and to_node @@ -703,8 +932,18 @@ def keep_between(self, from_node: Node, to_node: Node): from_node (Node): Remove above this node to_node (Node): Remove below this node """ - keep_nodes = self.flood_below(from_node, stop_at=to_node) - self.remove_all(set(self._nodes.values()) - keep_nodes) + keep_nodes = set( + self.directed_dfs( + from_node, + stop_at={to_node}, + yield_start_node=True) + ) | set( + self.directed_dfs( + to_node, + stop_at={from_node}, + go_up=True, + yield_start_node=True)) + self.remove_all(set(self._nodes.values()) - set(keep_nodes)) def remove(self, node_or_name: Union[str, Node]): '''Removes a node and all its connected edges''' @@ -741,6 +980,10 @@ def edge_match(x): if not self._out_edges[edge.from_node.name][edge.to_node.name]: del self._out_edges[edge.from_node.name][edge.to_node.name] + def remove_edges(self, edges): + for edge in edges: + self.remove_edge(edge) + def edge_in_graph(self, edge): if edge.to_node.name in self._in_edges: edges = self._in_edges[edge.to_node.name] @@ -898,7 +1141,8 @@ def remove_fragment(self, frag: 'Graph'): in_nodes.add(edge.from_node) del frag_in_edges, in_nodes - frag_out_nodes = set((edge.to_node, edge.to_idx) for frag_out_node in frag.outputs(ignore_names=nodes_not_in_graph) + frag_out_nodes = set((edge.to_node, edge.to_idx) + for frag_out_node in frag.outputs(ignore_names=nodes_not_in_graph) for edge in self.out_edges(frag_out_node.name)) assert len(frag_out_nodes) == 1, "doesn't work if more than one output" frag_out_node = list(frag_out_nodes)[0] @@ -930,96 +1174,6 @@ def outputs(self, ignore_names=None): if node_name not in self._out_edges or all(output_name in ignore_names for output_name in self._out_edges[node_name])] - def fast_dfs(self): - visited_edges = set() - nodes = deque(self.inputs()) - while nodes: - node = nodes.pop() - node_name = node.name - if node_name in self._in_edges and not set(edge for edge_list in self._in_edges[node_name].values() for edge in edge_list).issubset(visited_edges): - continue - yield node - if node_name not in self._out_edges: - return - for edge_list in self._out_edges[node_name].values(): - for out_edge in edge_list: - visited_edges.add(out_edge) - nodes.append(out_edge.to_node) - - def __revdfs(self, node, condition, visited_nodes, visited_edges, from_node, from_edge): - if not node: - return - if isinstance(node, str): - node = self._nodes[node] - if node not in visited_nodes and\ - (from_node is None or - all((out_edge in visited_edges) for out_edge in self.out_edges(node.name))) and\ - (not condition or condition(self, from_node, node, from_edge)): - - yield node - visited_nodes.add(node) - in_edges = self.in_edges(node.name) - # Edges are visited in a repeatable order - in_edges.sort(key=lambda x: str(x.from_idx) + x.from_node.name + str(x.to_idx), - reverse=True) - for edge in in_edges: - visited_edges.add(edge) - - yield from self.__revdfs(edge.from_node, - condition, - visited_nodes, - visited_edges, - node, - edge) - - def __dfs(self, node, condition, visited_nodes, visited_edges, from_node, from_edge): - if not node: - return - if isinstance(node, str): - node = self._nodes[node] - if node not in visited_nodes and \ - (from_node is None or all((in_edge in visited_edges) for in_edge in self.in_edges(node.name))) and \ - (not condition or condition(self, from_node, node, from_edge)): - yield node - visited_nodes.add(node) - out_edges = self.out_edges(node.name) - # Edges are visited in a repeatable order - out_edges.sort(key=lambda x: str(x.from_idx) + - x.to_node.name + str(x.to_idx)) - for edge in out_edges: - visited_edges.add(edge) - - yield from self.__dfs(edge.to_node, - condition, - visited_nodes, - visited_edges, - node, - edge) - - def dfs(self, node_or_name=None, condition=None, reverse=False): - if node_or_name is None: - if reverse: - nodes = list(self.outputs()) - # This isn't really necessary but helps with tests - nodes.reverse() - else: - nodes = self.inputs() - elif isinstance(node_or_name, str): - nodes = [self._nodes[node_or_name]] - elif isinstance(node_or_name, Iterable): - nodes = [node if isinstance(node, Node) else - self[node] for node in node_or_name] - else: - raise TypeError() - - visited_nodes = set() - visited_edges = set() - for node in nodes: - if reverse: - yield from self.__revdfs(node, condition, visited_nodes, visited_edges, None, None) - else: - yield from self.__dfs(node, condition, visited_nodes, visited_edges, None, None) - @staticmethod def match_semantics(edges, match_edge): for edge in edges: @@ -1158,49 +1312,20 @@ def match_down_edge(self, matched_graphview, fragment, graph_edge, return False return True - def match_fragment(self, fragment: 'GraphView', node_or_name: Node = None, allow_extra_edges=False): - """Matches a graph fragment against this graph""" - inputs = fragment.inputs() - - start_points = {} - - def match_start_points(G, from_node, to_node, unused1): - del unused1 - nonlocal inputs, start_points - edge = None if from_node is None else G.edge( - from_node.name, to_node.name) - for fragment_input_node in inputs: - if isinstance(fragment_input_node, MatchNode) and fragment_input_node._match(G, to_node, edge): - start_points[to_node] = fragment_input_node - return True + @property + def _edge_class(self): + return Edge - _ = list(self.dfs(condition=match_start_points, - node_or_name=node_or_name)) - # start points will now be a list of pairs with the start_node name in the graph and the - # corresponding node in the fragment. The start points have all matched an input none in the - # fragment - - matched_fragments = [] - while True: - graph_node = next(start_points.__iter__(), None) - if graph_node is None: - return matched_fragments - match_node = start_points[graph_node] - del start_points[graph_node] - - matched_graphview = GraphView() - matched_graphview.add_node(graph_node) - visited_nodes = set() - if self.match_down_node(matched_graphview, fragment, - graph_node, match_node, - visited_nodes, start_points, - allow_extra_edges=allow_extra_edges): - matched_fragments.append(matched_graphview) - return matched_fragments + @property + def _noderef_class(self): + return NodeRef def __eq__(self, other): return set(self.nodes()) == set(other.nodes()) and set(self.edges()) == set(other.edges()) + def __hash__(self) -> int: + return (tuple(self.nodes()), tuple(self.edges())).__hash__() + def __len__(self): return len(self._nodes) diff --git a/tools/nntool/utils/json_serializable.py b/tools/nntool/utils/json_serializable.py index b5bae0632..3a0f3e7f9 100644 --- a/tools/nntool/utils/json_serializable.py +++ b/tools/nntool/utils/json_serializable.py @@ -64,6 +64,10 @@ def default(self, o): '__contents': o.tolist(), '__dtype': o.dtype.name } + if hasattr(o, 'dtype'): + if np.issubdtype(o.dtype, np.bool): + return bool(o) + # Let the base class default method raise the try: return json.JSONEncoder.default(self, o) diff --git a/tools/nntool/utils/maximizer.py b/tools/nntool/utils/maximizer.py index 061e9b6ea..49a51e9b8 100644 --- a/tools/nntool/utils/maximizer.py +++ b/tools/nntool/utils/maximizer.py @@ -25,7 +25,7 @@ def __init__(self, func, var_min, var_max, func_change=None, int_step=False): self._args = tuple() self._int_step = int_step - @lru_cache + @lru_cache(maxsize=128, typed=False) def func(self, var): return self._func(var, *self._args) diff --git a/tools/nntool/utils/node_id.py b/tools/nntool/utils/node_id.py index 2703db6b5..b44e6105e 100644 --- a/tools/nntool/utils/node_id.py +++ b/tools/nntool/utils/node_id.py @@ -25,6 +25,12 @@ def __init__(self, node, fnode=None): fnode_name = None if fnode is None else fnode if isinstance(fnode, str) else fnode.name self._id = [node.name, "" if fnode is None else fnode_name] + @property + def key(self): + if self._id[1]: + return self._id + return self._id[0] + @property def id(self): return self._id diff --git a/tools/nntool/utils/numpy_helpers.py b/tools/nntool/utils/numpy_helpers.py index a8a841af3..9641702d9 100644 --- a/tools/nntool/utils/numpy_helpers.py +++ b/tools/nntool/utils/numpy_helpers.py @@ -36,3 +36,8 @@ def packbits(value, bits): )[:, 0:bits:].flatten(), bitorder='little' ) + +def np_asscalar(elem): + if isinstance(elem, np.ndarray): + return elem.item() + return elem diff --git a/tools/nntool/utils/option_list.py b/tools/nntool/utils/option_list.py index 6334269a3..78832424f 100644 --- a/tools/nntool/utils/option_list.py +++ b/tools/nntool/utils/option_list.py @@ -52,7 +52,7 @@ def __setattr__(self, name, value): def __getattr__(self, name): upper_name = name.upper() - valid_options = super(OptionList, self).__getattribute__('_valid_options') + valid_options = super(OptionList, self).__getattribute__('_valid_options') # @IgnoreException options = super(OptionList, self).__getattribute__('_options') if upper_name in valid_options: return options.get(upper_name) diff --git a/tools/nntool/utils/process_header.py b/tools/nntool/utils/process_header.py new file mode 100644 index 000000000..adcb5f261 --- /dev/null +++ b/tools/nntool/utils/process_header.py @@ -0,0 +1,182 @@ +# Copyright (C) 2022 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import os +import re +import sys +from collections.abc import Mapping + +import numpy as np + +from .diag_collector import thread_singleton + + +class ProcessHeader(Mapping): + P_DEFINE = re.compile('^[\t ]*#[\t ]*define[\t ]+([a-zA-Z0-9_]+)[\t ]+') + + P_MACRO = re.compile( + '^[\t ]*#[\t ]*define[\t ]+' + '([a-zA-Z0-9_]+)\(([_a-zA-Z][_a-zA-Z0-9]*)\)[\t ]+') + + P_INCLUDE = re.compile('^[\t ]*#[\t ]*include[\t ]+<([a-zA-Z0-9_/\.]+)') + + P_COMMENT = re.compile(r'/\*([^*]+|\*+[^/])*(\*+/)?') + P_CPP_COMMENT = re.compile('//.*') + + P_CHAR = re.compile(r"'(\\.[^\\]*|[^\\])'") + + P_HEX = re.compile(r"0x([0-9a-fA-F]+)L?") + IGNORES = [P_COMMENT, P_CPP_COMMENT] + + def __init__(self, searchdirs=[]) -> None: + self._env = {} + self._filedict = {} + self._searchdirs = searchdirs + + def __getitem__(self, __k): + return self._env[__k] # @IgnoreException + + def __iter__(self): + return iter([k for k in self._env if k[0] != '__builtins__']) + + def __len__(self) -> int: + return len(self._env) - (1 if '__builtins__' in self else 0) + + @property + def env(self): + return self._env + + @staticmethod + def pytify(body): + # replace ignored patterns by spaces + for pattern in ProcessHeader.IGNORES: + body = pattern.sub(' ', body) + # replace char literals by ord(...) + body = ProcessHeader.P_CHAR.sub("ord('\\1')", body) + # Compute negative hexadecimal constants + start = 0 + UMAX = 2*(sys.maxsize+1) + while 1: + match = ProcessHeader.P_HEX.search(body, start) + if not match: + break + span, element = match.span() + val = int(body[slice(*match.span(1))], 16) + if val > sys.maxsize: + val -= UMAX + body = body[:span] + "(" + str(val) + ")" + body[element:] + start = span + 1 + return body + + def open_file(self, filename): + try: + fp = open(filename) # @IgnoreException + return fp + except IOError: + pass + for searchdir in self._searchdirs: + try: + # @IgnoreException + fp = open(os.path.join(searchdir, filename)) + return fp + except IOError: + pass + raise IOError(f'{filename} not found') + + def process(self, fp): + if isinstance(fp, str): + fp = self.open_file(fp) + lineno = 0 + while 1: + line = fp.readline() + if not line: + break + lineno = lineno + 1 + match = self.P_DEFINE.match(line) + if match: + # gobble up continuation lines + while line[-2:] == '\\\n': + nextline = fp.readline() + if not nextline: + break + lineno = lineno + 1 + line = line + nextline + name = match.group(1) + body = line[match.end():] + body = self.pytify(body) + stmt = '%s = %s\n' % (name, body.strip()) +#pylint: disable=exec-used + exec(stmt, self._env) + match = self.P_MACRO.match(line) + if match: + macro, arg = match.group(1, 2) + body = line[match.end():] + body = self.pytify(body) + stmt = 'def %s(%s): return %s\n' % (macro, arg, body) +#pylint: disable=exec-used + exec(stmt, self._env) + match = self.P_INCLUDE.match(line) + if match: + regs = match.regs + part_1, part_2 = regs[1] + filename = line[part_1:part_2] + if filename not in self._filedict: + self._filedict[filename] = None + self.process(self.open_file(filename)) + + def __str__(self) -> str: + vals = ", ".join([f'{repr(k)}:{repr(v)}' for k, v in self]) + return f'{{{vals}}}' + + +class InfosBase(ProcessHeader): + PREFIX = 'AT_INF_' + LEN_SUFFIX = '_LEN' + + def __init__(self, filename, searchdirs) -> None: + super().__init__(searchdirs=searchdirs) + self.process(filename) + + def inf(self, __k): + return self._env[f'{self.PREFIX}{__k.upper()}'] + + def inf_len(self, __k): + this_key = f'{self.PREFIX}{__k.upper()}' + this_len_key = f'{this_key}{self.LEN_SUFFIX}' + if this_len_key in self._env: + return self._env[this_len_key] + this_val = self[this_key] + other_keys = [k for k in self if not(k.endswith(self.LEN_SUFFIX) or k == this_key) and + self[k] == this_val and f'{k}{self.LEN_SUFFIX}' in self] + if len(other_keys) != 1: + raise ValueError(f'unique length key for {__k} not found') + return self[f'{other_keys[0]}{self.LEN_SUFFIX}'] + + def gen_infos_array(self, len_key, **vals): + keys = sorted([(key, self.inf(key), self.inf_len(key)) + for key in vals], key=lambda x: x[1]) + bvals = np.full((self.inf(len_key),), 0, dtype=np.uint8) + comment = "" + for key, info, info_len in keys: + val = np.atleast_1d(vals[key]) + val = val.newbyteorder('>') + val = np.frombuffer(val.tobytes(), dtype=np.uint8) + val_len = len(val) + if val_len > info_len: + raise ValueError( + f'value for {key} is too long {val_len}>{info_len}') + bvals[info:info+len(val):1] = val + comment += f" {key}: {vals[key]}" + return bvals, comment diff --git a/tools/nntool/utils/random_iter.py b/tools/nntool/utils/random_iter.py new file mode 100644 index 000000000..8007aeade --- /dev/null +++ b/tools/nntool/utils/random_iter.py @@ -0,0 +1,42 @@ +# Copyright (C) 2022 GreenWaves Technologies, SAS + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import numpy as np + + +class RandomIter(): + def __init__(self, count, shapes, ranges, gen=None) -> None: + self._vars = list(zip(shapes, ranges)) + self._gen = gen + self._count = count + self._cur = count + if self._gen is None: + self._gen = np.random.default_rng() + + def __iter__(self): + self._cur = self._count + return self + + def __next__(self): + if self._cur <= 0: + raise StopIteration() + self._cur -= 1 + return self.val() + + def val(self): + res = [] + for shape, (minv, maxv) in self._vars: + res.append((self._gen.random(shape) * (maxv - minv)) + minv) + return res diff --git a/tools/nntool/utils/sigmoid_tanh_lut.py b/tools/nntool/utils/sigmoid_tanh_lut.py index 6e9c89c07..45bc84ae0 100644 --- a/tools/nntool/utils/sigmoid_tanh_lut.py +++ b/tools/nntool/utils/sigmoid_tanh_lut.py @@ -101,7 +101,7 @@ NEAREST = True -def sigmoid_lut(x, qtype=None): +def sigmoid_lut(x, qtype=None, q16_out=False): """ Lookup table based sigmoid. Input is in Q12 Output is in Q15""" @@ -119,6 +119,8 @@ def sigmoid_lut(x, qtype=None): (ua << 9) + ut * (ub-ua)) # Q16*Q8 = Q24 result = np.where(x > 0, result + (1 << 9), (1 << (9+16))-result+(1 << 9)-1) + if q16_out: + return result >> 9 return result >> 10 else: abs_x = (np.abs(x) * 3) >> 9 # input in Q12 @@ -127,6 +129,8 @@ def sigmoid_lut(x, qtype=None): 0xFFFF, sigmoid_table[abs_x_masked]) # Q16*Q8 = Q24 result = np.where(x > 0, result, (1 << 16)-result) + if q16_out: + return result return result >> 1 diff --git a/tools/nntool/utils/stats_funcs.py b/tools/nntool/utils/stats_funcs.py index 4a27f356b..d82c333b3 100644 --- a/tools/nntool/utils/stats_funcs.py +++ b/tools/nntool/utils/stats_funcs.py @@ -101,6 +101,8 @@ def max_error(orig, quant): def qsnr(orig, quant, axis=None): """Calculate the QSNR between two tensors """ + orig = orig.astype(np.float64) + quant = quant.astype(np.float64) qerr = orig - quant if axis is not None: axis = tuple(i for i in range(len(qerr.shape)) if i != axis) diff --git a/tools/profiler/.gitignore b/tools/profiler/.gitignore deleted file mode 100644 index a6f8ec3da..000000000 --- a/tools/profiler/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -*/build/* -docs/ -gui/Makefile -*.qmake.stash -*.debug_info -gui/uic_wrapper.sh -function_statistics.txt diff --git a/tools/profiler/Doxyfile b/tools/profiler/Doxyfile deleted file mode 100644 index 90e2f5b37..000000000 --- a/tools/profiler/Doxyfile +++ /dev/null @@ -1,2427 +0,0 @@ -# Doxyfile 1.8.11 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a double hash (##) is considered a comment and is placed in -# front of the TAG it is preceding. -# -# All text after a single hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists, items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (\" \"). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. -# The default value is: UTF-8. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by -# double-quotes, unless you are using Doxywizard) that should identify the -# project for which the documentation is generated. This name is used in the -# title of most generated pages and in a few other places. -# The default value is: My Project. - -PROJECT_NAME = "GAP Profiler" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. This -# could be handy for archiving the generated documentation or if some version -# control system is used. - -PROJECT_NUMBER = - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer a -# quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = "A tool to help to optimize GAP programs" - -# With the PROJECT_LOGO tag one can specify a logo or an icon that is included -# in the documentation. The maximum height of the logo should not exceed 55 -# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy -# the logo to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path -# into which the generated documentation will be written. If a relative path is -# entered, it will be relative to the location where doxygen was started. If -# left blank the current directory will be used. - -OUTPUT_DIRECTORY = docs/ - -# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- -# directories (in 2 levels) under the output directory of each output format and -# will distribute the generated files over these directories. Enabling this -# option can be useful when feeding doxygen a huge amount of source files, where -# putting all generated files in the same directory would otherwise causes -# performance problems for the file system. -# The default value is: NO. - -CREATE_SUBDIRS = NO - -# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII -# characters to appear in the names of generated files. If set to NO, non-ASCII -# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode -# U+3044. -# The default value is: NO. - -ALLOW_UNICODE_NAMES = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, -# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), -# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, -# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, -# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, -# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, -# Ukrainian and Vietnamese. -# The default value is: English. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member -# descriptions after the members that are listed in the file and class -# documentation (similar to Javadoc). Set to NO to disable this. -# The default value is: YES. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief -# description of a member or function before the detailed description -# -# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. -# The default value is: YES. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator that is -# used to form the text in various listings. Each string in this list, if found -# as the leading text of the brief description, will be stripped from the text -# and the result, after processing the whole list, is used as the annotated -# text. Otherwise, the brief description is used as-is. If left blank, the -# following values are used ($name is automatically replaced with the name of -# the entity):The $name class, The $name widget, The $name file, is, provides, -# specifies, contains, represents, a, an and the. - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# doxygen will generate a detailed section even if there is only a brief -# description. -# The default value is: NO. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. -# The default value is: NO. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path -# before files name in the file list and in the header files. If set to NO the -# shortest path that makes the file name unique will be used -# The default value is: YES. - -FULL_PATH_NAMES = YES - -# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. -# Stripping is only done if one of the specified strings matches the left-hand -# part of the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the path to -# strip. -# -# Note that you can specify absolute paths here, but also relative paths, which -# will be relative from the directory where doxygen is started. -# This tag requires that the tag FULL_PATH_NAMES is set to YES. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the -# path mentioned in the documentation of a class, which tells the reader which -# header file to include in order to use a class. If left blank only the name of -# the header file containing the class definition is used. Otherwise one should -# specify the list of include paths that are normally passed to the compiler -# using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but -# less readable) file names. This can be useful is your file systems doesn't -# support long names like on DOS, Mac, or CD-ROM. -# The default value is: NO. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the -# first line (until the first dot) of a Javadoc-style comment as the brief -# description. If set to NO, the Javadoc-style will behave just like regular Qt- -# style comments (thus requiring an explicit @brief command for a brief -# description.) -# The default value is: NO. - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first -# line (until the first dot) of a Qt-style comment as the brief description. If -# set to NO, the Qt-style will behave just like regular Qt-style comments (thus -# requiring an explicit \brief command for a brief description.) -# The default value is: NO. - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a -# multi-line C++ special comment block (i.e. a block of //! or /// comments) as -# a brief description. This used to be the default behavior. The new default is -# to treat a multi-line C++ comment block as a detailed description. Set this -# tag to YES if you prefer the old behavior instead. -# -# Note that setting this tag to YES also means that rational rose comments are -# not recognized any more. -# The default value is: NO. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the -# documentation from any documented member that it re-implements. -# The default value is: YES. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new -# page for each member. If set to NO, the documentation of a member will be part -# of the file/class/namespace that contains it. -# The default value is: NO. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen -# uses this value to replace tabs by spaces in code fragments. -# Minimum value: 1, maximum value: 16, default value: 4. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that act as commands in -# the documentation. An alias has the form: -# name=value -# For example adding -# "sideeffect=@par Side Effects:\n" -# will allow you to put the command \sideeffect (or @sideeffect) in the -# documentation, which will result in a user-defined paragraph with heading -# "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. For -# instance, some of the names that are used will be different. The list of all -# members will be omitted, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or -# Python sources only. Doxygen will then generate output that is more tailored -# for that language. For instance, namespaces will be presented as packages, -# qualified scopes will look different, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources. Doxygen will then generate output that is tailored for Fortran. -# The default value is: NO. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for VHDL. -# The default value is: NO. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. -# -# Note: For files without extension you can use no_extension as a placeholder. -# -# Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments -# according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you can -# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in -# case of backward compatibilities issues. -# The default value is: YES. - -MARKDOWN_SUPPORT = YES - -# When enabled doxygen tries to link words that correspond to documented -# classes, or namespaces to their corresponding documentation. Such a link can -# be prevented in individual cases by putting a % sign in front of the word or -# globally by setting AUTOLINK_SUPPORT to NO. -# The default value is: YES. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should set this -# tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); -# versus func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. -# The default value is: NO. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. -# The default value is: NO. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen -# will parse them like normal C++ but will assume all classes use public instead -# of private inheritance when no explicit protection keyword is present. -# The default value is: NO. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES will make -# doxygen to replace the get and set methods by a property in the documentation. -# This will only work if the methods are indeed getting or setting a simple -# type. If this is not the case, or you want to show the methods anyway, you -# should set this option to NO. -# The default value is: YES. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. -# The default value is: NO. - -DISTRIBUTE_GROUP_DOC = NO - -# If one adds a struct or class to a group and this option is enabled, then also -# any nested class or struct is added to the same group. By default this option -# is disabled and one has to add nested compounds explicitly via \ingroup. -# The default value is: NO. - -GROUP_NESTED_COMPOUNDS = NO - -# Set the SUBGROUPING tag to YES to allow class member groups of the same type -# (for instance a group of public functions) to be put as a subgroup of that -# type (e.g. under the Public Functions section). Set it to NO to prevent -# subgrouping. Alternatively, this can be done per class using the -# \nosubgrouping command. -# The default value is: YES. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions -# are shown inside the group in which they are included (e.g. using \ingroup) -# instead of on a separate page (for HTML and Man pages) or section (for LaTeX -# and RTF). -# -# Note that this feature does not work in combination with -# SEPARATE_MEMBER_PAGES. -# The default value is: NO. - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions -# with only public data fields or simple typedef fields will be shown inline in -# the documentation of the scope in which they are defined (i.e. file, -# namespace, or group documentation), provided this scope is documented. If set -# to NO, structs, classes, and unions are shown on a separate page (for HTML and -# Man pages) or section (for LaTeX and RTF). -# The default value is: NO. - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or -# enum is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically be -# useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. -# The default value is: NO. - -TYPEDEF_HIDES_STRUCT = NO - -# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This -# cache is used to resolve symbols given their name and scope. Since this can be -# an expensive process and often the same symbol appears multiple times in the -# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small -# doxygen will become slower. If the cache is too large, memory is wasted. The -# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range -# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 -# symbols. At the end of a run doxygen will report the cache usage and suggest -# the optimal cache size from a speed point of view. -# Minimum value: 0, maximum value: 9, default value: 0. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in -# documentation are documented, even if no documentation was available. Private -# class members and static file members will be hidden unless the -# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. -# Note: This will also disable the warnings about undocumented members that are -# normally produced when WARNINGS is set to YES. -# The default value is: NO. - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will -# be included in the documentation. -# The default value is: NO. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal -# scope will be included in the documentation. -# The default value is: NO. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be -# included in the documentation. -# The default value is: NO. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined -# locally in source files will be included in the documentation. If set to NO, -# only classes defined in header files are included. Does not have any effect -# for Java sources. -# The default value is: YES. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. If set to YES, local methods, -# which are defined in the implementation section but not in the interface are -# included in the documentation. If set to NO, only methods in the interface are -# included. -# The default value is: NO. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base name of -# the file that contains the anonymous namespace. By default anonymous namespace -# are hidden. -# The default value is: NO. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all -# undocumented members inside documented classes or files. If set to NO these -# members will be included in the various overviews, but no documentation -# section is generated. This option has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. If set -# to NO, these classes will be included in the various overviews. This option -# has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO, these declarations will be -# included in the documentation. -# The default value is: NO. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any -# documentation blocks found inside the body of a function. If set to NO, these -# blocks will be appended to the function's detailed documentation block. -# The default value is: NO. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation that is typed after a -# \internal command is included. If the tag is set to NO then the documentation -# will be excluded. Set it to YES to include the internal documentation. -# The default value is: NO. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES, upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. -# The default value is: system dependent. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with -# their full class and namespace scopes in the documentation. If set to YES, the -# scope will be hidden. -# The default value is: NO. - -HIDE_SCOPE_NAMES = NO - -# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will -# append additional text to a page's title, such as Class Reference. If set to -# YES the compound reference will be hidden. -# The default value is: NO. - -HIDE_COMPOUND_REFERENCE= NO - -# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of -# the files that are included by a file in the documentation of that file. -# The default value is: YES. - -SHOW_INCLUDE_FILES = YES - -# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each -# grouped member an include statement to the documentation, telling the reader -# which file to include in order to use the member. -# The default value is: NO. - -SHOW_GROUPED_MEMB_INC = NO - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include -# files with double quotes in the documentation rather than with sharp brackets. -# The default value is: NO. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the -# documentation for inline members. -# The default value is: YES. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the -# (detailed) documentation of file and class members alphabetically by member -# name. If set to NO, the members will appear in declaration order. -# The default value is: YES. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief -# descriptions of file, namespace and class members alphabetically by member -# name. If set to NO, the members will appear in declaration order. Note that -# this will also influence the order of the classes in the class list. -# The default value is: NO. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the -# (brief and detailed) documentation of class members so that constructors and -# destructors are listed first. If set to NO the constructors will appear in the -# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. -# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief -# member documentation. -# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting -# detailed member documentation. -# The default value is: NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy -# of group names into alphabetical order. If set to NO the group names will -# appear in their defined order. -# The default value is: NO. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by -# fully-qualified names, including namespaces. If set to NO, the class list will -# be sorted only by class name, not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the alphabetical -# list. -# The default value is: NO. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper -# type resolution of all parameters of a function it will reject a match between -# the prototype and the implementation of a member function even if there is -# only one candidate or it is obvious which candidate to choose by doing a -# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still -# accept a match between prototype and implementation in such cases. -# The default value is: NO. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo -# list. This list is created by putting \todo commands in the documentation. -# The default value is: YES. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test -# list. This list is created by putting \test commands in the documentation. -# The default value is: YES. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug -# list. This list is created by putting \bug commands in the documentation. -# The default value is: YES. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) -# the deprecated list. This list is created by putting \deprecated commands in -# the documentation. -# The default value is: YES. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional documentation -# sections, marked by \if ... \endif and \cond -# ... \endcond blocks. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the -# initial value of a variable or macro / define can have for it to appear in the -# documentation. If the initializer consists of more lines than specified here -# it will be hidden. Use a value of 0 to hide initializers completely. The -# appearance of the value of individual variables and macros / defines can be -# controlled using \showinitializer or \hideinitializer command in the -# documentation regardless of this setting. -# Minimum value: 0, maximum value: 10000, default value: 30. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at -# the bottom of the documentation of classes and structs. If set to YES, the -# list will mention the files that were used to generate the documentation. -# The default value is: YES. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This -# will remove the Files entry from the Quick Index and from the Folder Tree View -# (if specified). -# The default value is: YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces -# page. This will remove the Namespaces entry from the Quick Index and from the -# Folder Tree View (if specified). -# The default value is: YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command command input-file, where command is the value of the -# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided -# by doxygen. Whatever the program writes to standard output is used as the file -# version. For an example see the documentation. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. You can -# optionally specify a file name after the option, if omitted DoxygenLayout.xml -# will be used as the name of the layout file. -# -# Note that if you run doxygen from a directory containing a file called -# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE -# tag is left empty. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files containing -# the reference definitions. This must be a list of .bib files. The .bib -# extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. -# For LaTeX the style of the bibliography can be controlled using -# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the -# search path. See also \cite for info how to create references. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated to -# standard output by doxygen. If QUIET is set to YES this implies that the -# messages are off. -# The default value is: NO. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES -# this implies that the warnings are on. -# -# Tip: Turn warnings on while writing the documentation. -# The default value is: YES. - -WARNINGS = YES - -# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate -# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag -# will automatically be disabled. -# The default value is: YES. - -WARN_IF_UNDOCUMENTED = NO - -# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some parameters -# in a documented function, or documenting parameters that don't exist or using -# markup commands wrongly. -# The default value is: YES. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that -# are documented, but have no documentation for their parameters or return -# value. If set to NO, doxygen will only warn about wrong or incomplete -# parameter documentation, but not about the absence of documentation. -# The default value is: NO. - -WARN_NO_PARAMDOC = NO - -# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when -# a warning is encountered. -# The default value is: NO. - -WARN_AS_ERROR = NO - -# The WARN_FORMAT tag determines the format of the warning messages that doxygen -# can produce. The string should contain the $file, $line, and $text tags, which -# will be replaced by the file and line number from which the warning originated -# and the warning text. Optionally the format may contain $version, which will -# be replaced by the version of the file (if it could be obtained via -# FILE_VERSION_FILTER) -# The default value is: $file:$line: $text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning and error -# messages should be written. If left blank the output is written to standard -# error (stderr). - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag is used to specify the files and/or directories that contain -# documented source files. You may enter file names like myfile.cpp or -# directories like /usr/src/myproject. Separate the files or directories with -# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING -# Note: If this tag is empty the current directory is searched. - -INPUT = - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses -# libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of -# possible encodings. -# The default value is: UTF-8. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and -# *.h) to filter out the source-files in the directories. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# read by doxygen. -# -# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, -# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, -# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, -# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f, *.for, *.tcl, -# *.vhd, *.vhdl, *.ucf, *.qsf, *.as and *.js. - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to specify whether or not subdirectories should -# be searched for input files as well. -# The default value is: NO. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = gui/build backend/build docs - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. -# The default value is: NO. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories use the pattern */test/* - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or directories -# that contain example code fragments that are included (see the \include -# command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank all -# files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude commands -# irrespective of the value of the RECURSIVE tag. -# The default value is: NO. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or directories -# that contain images that are to be included in the documentation (see the -# \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command: -# -# -# -# where is the value of the INPUT_FILTER tag, and is the -# name of an input file. Doxygen will then use the output that the filter -# program writes to standard output. If FILTER_PATTERNS is specified, this tag -# will be ignored. -# -# Note that the filter must not add or remove lines; it is applied before the -# code is scanned, but not when the output code is generated. If lines are added -# or removed, the anchors will not be placed correctly. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# properly processed by doxygen. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: pattern=filter -# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how -# filters are used. If the FILTER_PATTERNS tag is empty or if none of the -# patterns match the file name, INPUT_FILTER is applied. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# properly processed by doxygen. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will also be used to filter the input files that are used for -# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). -# The default value is: NO. - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and -# it is also possible to disable source filtering for a specific pattern using -# *.ext= (so without naming a filter). -# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page -# (index.html). This can be useful if you have a project on for instance GitHub -# and want to reuse the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = README.md - -#--------------------------------------------------------------------------- -# Configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will be -# generated. Documented entities will be cross-referenced with these sources. -# -# Note: To get rid of all source code in the generated output, make sure that -# also VERBATIM_HEADERS is set to NO. -# The default value is: NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body of functions, -# classes and enums directly into the documentation. -# The default value is: NO. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any -# special comment blocks from generated source code fragments. Normal C, C++ and -# Fortran comments will always remain visible. -# The default value is: YES. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. -# The default value is: NO. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES then for each documented function -# all documented entities called/used by that function will be listed. -# The default value is: NO. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set -# to YES then the hyperlinks from functions in REFERENCES_RELATION and -# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will -# link to the documentation. -# The default value is: YES. - -REFERENCES_LINK_SOURCE = YES - -# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the -# source code will show a tooltip with additional information such as prototype, -# brief description and links to the definition and documentation. Since this -# will make the HTML file larger and loading of large files a bit slower, you -# can opt to disable this feature. -# The default value is: YES. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -SOURCE_TOOLTIPS = YES - -# If the USE_HTAGS tag is set to YES then the references to source code will -# point to the HTML generated by the htags(1) tool instead of doxygen built-in -# source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version -# 4.8.6 or higher. -# -# To use it do the following: -# - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file -# - Make sure the INPUT points to the root of the source tree -# - Run doxygen as normal -# -# Doxygen will invoke htags (and that will in turn invoke gtags), so these -# tools must be available from the command line (i.e. in the search path). -# -# The result: instead of the source browser generated by doxygen, the links to -# source code will now point to the output of htags. -# The default value is: NO. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a -# verbatim copy of the header file for each class for which an include is -# specified. Set to NO to disable this. -# See also: Section \class. -# The default value is: YES. - -VERBATIM_HEADERS = YES - -# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. -# Note: The availability of this option depends on whether or not doxygen was -# generated with the -Duse-libclang=ON option for CMake. -# The default value is: NO. - -CLANG_ASSISTED_PARSING = NO - -# If clang assisted parsing is enabled you can provide the compiler with command -# line options that you would normally use when invoking the compiler. Note that -# the include paths will already be set by doxygen for the files and directories -# specified with INPUT and INCLUDE_PATH. -# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. - -CLANG_OPTIONS = - -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all -# compounds will be generated. Enable this if the project contains a lot of -# classes, structs, unions or interfaces. -# The default value is: YES. - -ALPHABETICAL_INDEX = YES - -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all classes will -# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag -# can be used to specify a prefix (or a list of prefixes) that should be ignored -# while generating the index headers. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output -# The default value is: YES. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each -# generated HTML page (for example: .htm, .php, .asp). -# The default value is: .html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a user-defined HTML header file for -# each generated HTML page. If the tag is left blank doxygen will generate a -# standard header. -# -# To get valid HTML the header file that includes any scripts and style sheets -# that doxygen needs, which is dependent on the configuration options used (e.g. -# the setting GENERATE_TREEVIEW). It is highly recommended to start with a -# default header using -# doxygen -w html new_header.html new_footer.html new_stylesheet.css -# YourConfigFile -# and then modify the file new_header.html. See also section "Doxygen usage" -# for information on how to generate the default header that doxygen normally -# uses. -# Note: The header is subject to change so you typically have to regenerate the -# default header when upgrading to a newer version of doxygen. For a description -# of the possible markers and block names see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each -# generated HTML page. If the tag is left blank doxygen will generate a standard -# footer. See HTML_HEADER for more information on how to generate a default -# footer and what special commands can be used inside the footer. See also -# section "Doxygen usage" for information on how to generate the default footer -# that doxygen normally uses. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style -# sheet that is used by each HTML page. It can be used to fine-tune the look of -# the HTML output. If left blank doxygen will generate a default style sheet. -# See also section "Doxygen usage" for information on how to generate the style -# sheet that doxygen normally uses. -# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as -# it is more robust and this tag (HTML_STYLESHEET) will in the future become -# obsolete. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined -# cascading style sheets that are included after the standard style sheets -# created by doxygen. Using this option one can overrule certain style aspects. -# This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefore more robust against future updates. -# Doxygen will copy the style sheet files to the output directory. -# Note: The order of the extra style sheet files is of importance (e.g. the last -# style sheet in the list overrules the setting of the previous ones in the -# list). For an example see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that the -# files will be copied as-is; there are no commands or markers available. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen -# will adjust the colors in the style sheet and background images according to -# this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value -# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 -# purple, and 360 is red again. -# Minimum value: 0, maximum value: 359, default value: 220. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use grayscales only. A -# value of 255 will produce the most vivid colors. -# Minimum value: 0, maximum value: 255, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the -# luminance component of the colors in the HTML output. Values below 100 -# gradually make the output lighter, whereas values above 100 make the output -# darker. The value divided by 100 is the actual gamma applied, so 80 represents -# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not -# change the gamma. -# Minimum value: 40, maximum value: 240, default value: 80. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to YES can help to show when doxygen was last run and thus if the -# documentation is up to date. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_TIMESTAMP = NO - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_DYNAMIC_SECTIONS = NO - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries -# shown in the various tree structured indices initially; the user can expand -# and collapse entries dynamically later on. Doxygen will expand the tree to -# such a level that at most the specified number of entries are visible (unless -# a fully collapsed tree already exceeds this amount). So setting the number of -# entries 1 will produce a full collapsed tree by default. 0 is a special value -# representing an infinite number of entries and will result in a full expanded -# tree by default. -# Minimum value: 0, maximum value: 9999, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files will be -# generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_DOCSET = NO - -# This tag determines the name of the docset feed. A documentation feed provides -# an umbrella under which multiple documentation sets from a single provider -# (such as a company or product suite) can be grouped. -# The default value is: Doxygen generated docs. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# This tag specifies a string that should uniquely identify the documentation -# set bundle. This should be a reverse domain-name style string, e.g. -# com.mycompany.MyDocSet. Doxygen will append .docset to the name. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. -# The default value is: org.doxygen.Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. -# The default value is: Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three -# additional HTML index files: index.hhp, index.hhc, and index.hhk. The -# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. -# -# The HTML Help Workshop contains a compiler that can convert all HTML output -# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML -# files are now used as the Windows 98 help format, and will replace the old -# Windows help format (.hlp) on all Windows platforms in the future. Compressed -# HTML files also contain an index, a table of contents, and you can search for -# words in the documentation. The HTML workshop also contains a viewer for -# compressed HTML files. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_HTMLHELP = NO - -# The CHM_FILE tag can be used to specify the file name of the resulting .chm -# file. You can add a path in front of the file if the result should not be -# written to the html output directory. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_FILE = - -# The HHC_LOCATION tag can be used to specify the location (absolute path -# including file name) of the HTML help compiler (hhc.exe). If non-empty, -# doxygen will try to run the HTML help compiler on the generated index.hhp. -# The file has to be specified with full path. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -HHC_LOCATION = - -# The GENERATE_CHI flag controls if a separate .chi index file is generated -# (YES) or that it should be included in the master .chm file (NO). -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -GENERATE_CHI = NO - -# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) -# and project file content. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_INDEX_ENCODING = - -# The BINARY_TOC flag controls whether a binary table of contents is generated -# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it -# enables the Previous and Next buttons. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members to -# the table of contents of the HTML help documentation and to the tree view. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that -# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help -# (.qch) of the generated HTML documentation. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify -# the file name of the resulting .qch file. The path specified is relative to -# the HTML output folder. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help -# Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt -# Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). -# The default value is: doc. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_VIRTUAL_FOLDER = doc - -# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom -# filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_SECT_FILTER_ATTRS = - -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be -# generated, together with the HTML files, they form an Eclipse help plugin. To -# install this plugin and make it available under the help contents menu in -# Eclipse, the contents of the directory containing the HTML and XML files needs -# to be copied into the plugins directory of eclipse. The name of the directory -# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. -# After copying Eclipse needs to be restarted before the help appears. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the Eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have this -# name. Each documentation set should have its own identifier. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# If you want full control over the layout of the generated HTML pages it might -# be necessary to disable the index and replace it with your own. The -# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top -# of each HTML page. A value of NO enables the index and the value YES disables -# it. Since the tabs in the index contain the same information as the navigation -# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. If the tag -# value is set to YES, a side panel will be generated containing a tree-like -# index structure (just like the one that is generated for HTML Help). For this -# to work a browser that supports JavaScript, DHTML, CSS and frames is required -# (i.e. any modern browser). Windows users are probably better off using the -# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can -# further fine-tune the look of the index. As an example, the default style -# sheet generated by doxygen has an example that shows how to put an image at -# the root of the tree instead of the PROJECT_NAME. Since the tree basically has -# the same information as the tab index, you could consider setting -# DISABLE_INDEX to YES when enabling this option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_TREEVIEW = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that -# doxygen will group on one line in the generated HTML documentation. -# -# Note that a value of 0 will completely suppress the enum values from appearing -# in the overview section. -# Minimum value: 0, maximum value: 20, default value: 4. -# This tag requires that the tag GENERATE_HTML is set to YES. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used -# to set the initial width (in pixels) of the frame in which the tree is shown. -# Minimum value: 0, maximum value: 1500, default value: 250. -# This tag requires that the tag GENERATE_HTML is set to YES. - -TREEVIEW_WIDTH = 250 - -# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to -# external symbols imported via tag files in a separate window. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of LaTeX formulas included as images in -# the HTML documentation. When you change the font size after a successful -# doxygen run you need to manually remove any form_*.png images from the HTML -# output directory to force them to be regenerated. -# Minimum value: 8, maximum value: 50, default value: 10. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are not -# supported properly for IE 6.0, but are supported on all modern browsers. -# -# Note that when changing this option you need to delete any form_*.png files in -# the HTML output directory before the changes have effect. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering -# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX -# installed or if you want to formulas look prettier in the HTML output. When -# enabled you may also need to install MathJax separately and configure the path -# to it using the MATHJAX_RELPATH option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -USE_MATHJAX = NO - -# When MathJax is enabled you can set the default output format to be used for -# the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. -# Possible values are: HTML-CSS (which is slower, but has the best -# compatibility), NativeMML (i.e. MathML) and SVG. -# The default value is: HTML-CSS. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the HTML -# output directory using the MATHJAX_RELPATH option. The destination directory -# should contain the MathJax.js script. For instance, if the mathjax directory -# is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax -# Content Delivery Network so you can quickly see the result without installing -# MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax -# extension names that should be enabled during MathJax rendering. For example -# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_EXTENSIONS = - -# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces -# of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an -# example see the documentation. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_CODEFILE = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box for -# the HTML output. The underlying search engine uses javascript and DHTML and -# should work on any modern browser. Note that when using HTML help -# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) -# there is already a search function so this one should typically be disabled. -# For large projects the javascript based search engine can be slow, then -# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to -# search using the keyboard; to jump to the search box use + S -# (what the is depends on the OS and browser, but it is typically -# , /