NEORV32 - Software Framework Documentation
Loading...
Searching...
No Matches
Functions
neorv32_trng.c File Reference

True Random Number Generator (TRNG) HW driver source file. More...

#include "neorv32.h"
#include "neorv32_trng.h"

Functions

int neorv32_trng_available (void)
 
void neorv32_trng_enable (uint32_t irq_mask)
 
void neorv32_trng_disable (void)
 
void neorv32_trng_fifo_clear (void)
 
int neorv32_trng_get_fifo_depth (void)
 
int neorv32_trng_get (uint8_t *data)
 
int neorv32_trng_check_sim_mode (void)
 

Detailed Description

True Random Number Generator (TRNG) HW driver source file.

Note
These functions should only be used if the TRNG unit was synthesized (IO_TRNG_EN = true).

Function Documentation

◆ neorv32_trng_available()

int neorv32_trng_available ( void  )

Check if TRNG unit was synthesized.

Returns
0 if TRNG was not synthesized, 1 if TRNG is available.

◆ neorv32_trng_check_sim_mode()

int neorv32_trng_check_sim_mode ( void  )

Check if TRNG is implemented using SIMULATION mode.

Warning
In simulation mode the physical entropy source is replaced by a PRNG (LFSR) with very bad random quality.
Returns
Simulation mode active when not zero.

◆ neorv32_trng_disable()

void neorv32_trng_disable ( void  )

Reset and disable TRNG.

◆ neorv32_trng_enable()

void neorv32_trng_enable ( uint32_t  irq_mask)

Reset, configure and enable TRNG.

Parameters
[in]irq_maskInterrupt configuration mask (CTRL's irq_* bits).

◆ neorv32_trng_fifo_clear()

void neorv32_trng_fifo_clear ( void  )

Flush TRNG random data FIFO.

◆ neorv32_trng_get()

int neorv32_trng_get ( uint8_t *  data)

Get random data byte from TRNG.

Parameters
[in,out]datauint8_t pointer for storing random data byte. Will be set to zero if no valid data available.
Returns
Data is valid when 0 and invalid otherwise.

◆ neorv32_trng_get_fifo_depth()

int neorv32_trng_get_fifo_depth ( void  )

Get TRNG FIFO depth.

Returns
TRNG FIFO size (number of entries).