![]() |
NEORV32 Software Framework Documentation
The NEORV32 RISC-V Processor
|
Example program showing how to use the CFU's custom instructions (XTEA example). Take a look at the commented "hardware-counterpart" of this CFU example in 'rtl/core/neorv32_cpu_cp_cfu.vhd'. More...
#include <neorv32.h>Macros | |
User configuration | |
| #define | BAUD_RATE 19200 |
| #define | XTEA_ROUNDS 20 |
| #define | DATA_NUM 64 |
Define macros for easy CFU instruction wrapping | |
| #define | xtea_key_write(i, data) |
| #define | xtea_key_read(i) |
| #define | xtea_hw_init(sum) |
| #define | xtea_hw_enc_v0_step(v0, v1) |
| #define | xtea_hw_enc_v1_step(v0, v1) |
| #define | xtea_hw_dec_v0_step(v0, v1) |
| #define | xtea_hw_dec_v1_step(v0, v1) |
| #define | xtea_hw_illegal_inst() |
Functions | |
| void | xtea_sw_encipher (uint32_t num_cycles, uint32_t *v, const uint32_t k[4]) |
| void | xtea_sw_decipher (unsigned int num_cycles, uint32_t *v, const uint32_t k[4]) |
| int | main () |
Variables | |
Global variables | |
| const uint32_t | xtea_delta = 0x9e3779b9 |
| const uint32_t | key [4] = {0x207230ba, 0x1ffba710, 0xc45271ef, 0xdd01768a} |
| uint32_t | input_data [DATA_NUM] |
| uint32_t | cypher_data_sw [DATA_NUM] |
| uint32_t | cypher_data_hw [DATA_NUM] |
| uint32_t | plain_data_sw [DATA_NUM] |
| uint32_t | plain_data_hw [DATA_NUM] |
| uint32_t | time_enc_sw |
| uint32_t | time_enc_hw |
| uint32_t | time_dec_sw |
| uint32_t | time_dec_hw |
Example program showing how to use the CFU's custom instructions (XTEA example). Take a look at the commented "hardware-counterpart" of this CFU example in 'rtl/core/neorv32_cpu_cp_cfu.vhd'.
| #define BAUD_RATE 19200 |
UART BAUD rate
| #define DATA_NUM 64 |
Input data size (number of 32-bit words), has to be even
| #define xtea_hw_dec_v0_step | ( | v0, | |
| v1 ) |
| #define xtea_hw_dec_v1_step | ( | v0, | |
| v1 ) |
| #define xtea_hw_enc_v0_step | ( | v0, | |
| v1 ) |
| #define xtea_hw_enc_v1_step | ( | v0, | |
| v1 ) |
| #define xtea_hw_illegal_inst | ( | ) |
| #define xtea_hw_init | ( | sum | ) |
| #define xtea_key_read | ( | i | ) |
| #define xtea_key_write | ( | i, | |
| data ) |
| #define XTEA_ROUNDS 20 |
Number of XTEA rounds
| int main | ( | void | ) |
Main function: run pure-SW XTEA and compare with HW-accelerated XTEA
| void xtea_sw_decipher | ( | unsigned int | num_cycles, |
| uint32_t * | v, | ||
| const uint32_t | k[4] ) |
XTEA decryption - software reference Source: https://de.wikipedia.org/wiki/Extended_Tiny_Encryption_Algorithm
| [in] | num_cycles | Number of encryption cycles. |
| [in,out] | v | Decryption data/result array (2x32-bit). |
| [in] | k | Decryption key array (4x32-bit). |
| void xtea_sw_encipher | ( | uint32_t | num_cycles, |
| uint32_t * | v, | ||
| const uint32_t | k[4] ) |
XTEA encryption - software reference Source: https://de.wikipedia.org/wiki/Extended_Tiny_Encryption_Algorithm
| [in] | num_cycles | Number of encryption cycles. |
| [in,out] | v | Encryption data/result array (2x32-bit). |
| [in] | k | Encryption key array (4x32-bit). |
| uint32_t cypher_data_hw[DATA_NUM] |
XTEA delta (round-key update); do not change
| uint32_t cypher_data_sw[DATA_NUM] |
Encryption result buffer
| uint32_t input_data[DATA_NUM] |
Encryption input data
| const uint32_t key[4] = {0x207230ba, 0x1ffba710, 0xc45271ef, 0xdd01768a} |
Secret encryption/decryption key (128-bit)
| uint32_t plain_data_hw[DATA_NUM] |
XTEA delta (round-key update); do not change
| uint32_t plain_data_sw[DATA_NUM] |
Decryption result buffer
| uint32_t time_dec_hw |
XTEA delta (round-key update); do not change
| uint32_t time_dec_sw |
XTEA delta (round-key update); do not change
| uint32_t time_enc_hw |
XTEA delta (round-key update); do not change
| uint32_t time_enc_sw |
Timing data
| const uint32_t xtea_delta = 0x9e3779b9 |
XTEA delta (round-key update); do not change