Skip to content

Commit

Permalink
[example] minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
stnolting committed Jul 21, 2024
1 parent 9f21272 commit 7a194dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions sw/example/demo_cfu/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
* @name Define macros for easy CFU instruction wrapping
**************************************************************************/
/**@{*/
#define xtea_hw_init(sum) neorv32_cfu_r3_instr(0b0000000, 0b100, sum, 0)
#define xtea_hw_enc_v0_step(v0, v1) neorv32_cfu_r3_instr(0b0000000, 0b000, v0, v1)
#define xtea_hw_enc_v1_step(v0, v1) neorv32_cfu_r3_instr(0b0000000, 0b001, v0, v1)
#define xtea_hw_dec_v0_step(v0, v1) neorv32_cfu_r3_instr(0b0000000, 0b010, v0, v1)
#define xtea_hw_dec_v1_step(v0, v1) neorv32_cfu_r3_instr(0b0000000, 0b011, v0, v1)
#define xtea_hw_illegal_inst() neorv32_cfu_r3_instr(0b0000000, 0b111, 0, 0)
#define xtea_hw_init(sum) neorv32_cfu_r3_instr(0b0000000, 0b100, sum, 0 )
#define xtea_hw_enc_v0_step(v0, v1) neorv32_cfu_r3_instr(0b0000000, 0b000, v0, v1)
#define xtea_hw_enc_v1_step(v0, v1) neorv32_cfu_r3_instr(0b0000000, 0b001, v0, v1)
#define xtea_hw_dec_v0_step(v0, v1) neorv32_cfu_r3_instr(0b0000000, 0b010, v0, v1)
#define xtea_hw_dec_v1_step(v0, v1) neorv32_cfu_r3_instr(0b0000000, 0b011, v0, v1)
#define xtea_hw_illegal_inst() neorv32_cfu_r3_instr(0b0000000, 0b111, 0, 0 )
/**@}*/

// The CFU custom instructions can be used as plain C functions as they are simple "intrinsics".
Expand Down Expand Up @@ -67,14 +67,19 @@
/**@{*/
/** XTEA delta (round-key update) */
const uint32_t xtea_delta = 0x9e3779b9;

/** Encryption/decryption key (128-bit) */
const uint32_t key[4] = {0x207230ba, 0x1ffba710, 0xc45271ef, 0xdd01768a};

/** Encryption input data */
uint32_t input_data[DATA_NUM];

/** Encryption results */
uint32_t cypher_data_sw[DATA_NUM], cypher_data_hw[DATA_NUM];

/** Decryption results */
uint32_t plain_data_sw[DATA_NUM], plain_data_hw[DATA_NUM];

/** Timing data */
uint32_t time_enc_sw, time_enc_hw, time_dec_sw, time_dec_hw;
/**@}*/
Expand Down
2 changes: 1 addition & 1 deletion sw/example/demo_newlib/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int main() {

// rand test
neorv32_uart0_printf("<rand> test... ");
srand(neorv32_cpu_csr_read(CSR_CYCLE)); // set random seed
srand(time(NULL)); // set random seed
neorv32_uart0_printf("%i, %i, %i, %i\n", rand() % 100, rand() % 100, rand() % 100, rand() % 100);


Expand Down

0 comments on commit 7a194dd

Please sign in to comment.