1 |
60 |
zero_gravi |
<<<
|
2 |
|
|
:sectnums:
|
3 |
|
|
==== True Random-Number Generator (TRNG)
|
4 |
|
|
|
5 |
|
|
[cols="<3,<3,<4"]
|
6 |
|
|
[frame="topbot",grid="none"]
|
7 |
|
|
|=======================
|
8 |
|
|
| Hardware source file(s): | neorv32_trng.vhd |
|
9 |
|
|
| Software driver file(s): | neorv32_trng.c |
|
10 |
|
|
| | neorv32_trng.h |
|
11 |
|
|
| Top entity port: | none |
|
12 |
|
|
| Configuration generics: | _IO_TRNG_EN_ | implement TRNG when _true_
|
13 |
|
|
| CPU interrupts: | none |
|
14 |
|
|
|=======================
|
15 |
|
|
|
16 |
68 |
zero_gravi |
|
17 |
60 |
zero_gravi |
**Theory of Operation**
|
18 |
|
|
|
19 |
68 |
zero_gravi |
The NEORV32 true random number generator provides _physical_ true random numbers.
|
20 |
|
|
Instead of using a pseudo RNG like a LFSR, the TRNG uses a simple, straight-forward ring
|
21 |
|
|
oscillator concept as physical entropy source. Hence, voltage, thermal and also semiconductor manufacturing
|
22 |
|
|
fluctuations are used to provide a true physical entropy source.
|
23 |
60 |
zero_gravi |
|
24 |
73 |
zero_gravi |
The TRNG is based on the _neoTRNG_, which is a "spin-off project" of the
|
25 |
68 |
zero_gravi |
NEORV32 processor. The TRNG uses the default neoTRNG configuration, which showed very good results in the
|
26 |
|
|
`dieharder` battery of random number tests. More detailed information about the neoTRNG, it's architecture and a
|
27 |
|
|
detailed evaluation of the random number quality can be found it it's repository: https://github.com/stnolting/neoTRNG
|
28 |
|
|
|
29 |
60 |
zero_gravi |
[NOTE]
|
30 |
|
|
The TRNG features a platform independent architecture without FPGA-specific primitives, macros or
|
31 |
68 |
zero_gravi |
attributes so it can be synthesized for _any_ FPGA.
|
32 |
60 |
zero_gravi |
|
33 |
|
|
|
34 |
|
|
**Using the TRNG**
|
35 |
|
|
|
36 |
64 |
zero_gravi |
The TRNG features a single register for status and data access. When the _TRNG_CTRL_EN_ control register (`CTRL`)
|
37 |
|
|
bit is set, the TRNG is enabled and starts operation. As soon as the _TRNG_CTRL_VALID_ bit is set, the currently
|
38 |
|
|
sampled 8-bit random data byte can be obtained from the lowest 8 bits of the `CTRL` register
|
39 |
68 |
zero_gravi |
(_TRNG_CTRL_DATA_MSB_ : _TRNG_CTRL_DATA_LSB_). These bits always keep the latest valid data obtained from the TRNG
|
40 |
|
|
entropy source. The _TRNG_CTRL_VALID_ bit is automatically cleared when reading the control register.
|
41 |
60 |
zero_gravi |
|
42 |
68 |
zero_gravi |
[NOTE]
|
43 |
|
|
The TRNG core does not provide a dedicated reset. In order to ensure correct operations, the TRNG should be
|
44 |
|
|
disabled (=reset) by clearing the _TRNG_CTRL_EN_ and waiting some milliseconds before re-enabling it.
|
45 |
60 |
zero_gravi |
|
46 |
|
|
|
47 |
64 |
zero_gravi |
.TRNG register map (`struct NEORV32_TRNG`)
|
48 |
60 |
zero_gravi |
[cols="<2,<2,<4,^1,<7"]
|
49 |
|
|
[options="header",grid="all"]
|
50 |
|
|
|=======================
|
51 |
|
|
| Address | Name [C] | Bit(s), Name [C] | R/W | Function
|
52 |
68 |
zero_gravi |
.3+<| `0xffffffb8` .3+<| `NEORV32_TRNG.CTRL` <|`7:0` _TRNG_CTRL_DATA_MSB_ : _TRNG_CTRL_DATA_MSB_ ^| r/- <| 8-bit random data
|
53 |
|
|
<|`30` _TRNG_CTRL_EN_ ^| r/w <| TRNG enable
|
54 |
|
|
<|`31` _TRNG_CTRL_VALID_ ^| r/- <| random data is valid when set
|
55 |
60 |
zero_gravi |
|=======================
|