lib_random: Random number generation£££doc/rst/lib_random.html#lib-random-random-number-generation

lib_random: Random number generation$$$Introduction£££doc/rst/lib_random.html#introduction

This library provides both hardware and software random number generation.

Hardware based generation uses an asynchronous oscillator in the xcore device.

lib_random: Random number generation$$$Usage£££doc/rst/lib_random.html#usage

To use the module you need to use lib_random in your application CMakeLists.txt, for example:

set(APP_DEPENDENT_MODULES "lib_random")

An application should then the random.h header file:

#include "random.h"

lib_random: Random number generation$$$Example£££doc/rst/lib_random.html#example

An example demonstrating how to generate random values using the lib_random library is provided in examples/app_random

It shows the two different methods for initialising a random number generator (software or hardware seed), and then also shows how to generate either a single random value or populate an array with random values.

To build and run the example, run the following from an XTC tools terminal:

cd examples/app_random
cmake -G "Unix Makefiles" -B build

The application binaries can be built using xmake:

xmake -C build

To run the application using the simulator, run the following command:

xsim bin/app_random.xe

The random data values will be printed in the terminal.

lib_random: Random number generation$$$Further Reading£££doc/rst/lib_random.html#further-reading