Copyright (C) 2022,
Tomonori IZUMI,
Reconfigurable Sysems Lab @
Ritsumeikan U,
All rights reserved.
Random Number Generators for FPGAs

This site provides template codes
of random number generators
for FPGAs, utilizing High-Level Synthesis.
Design Policy
- Be simple!
- Just outputs random numbers
- Output as stream
- No start/done controls
- Seed is embedded in the code
- Initialized by the bitstream
- Readable and portable code
 
Source Codes for Vitis HLS
Linear Congruential Generator (LCG)
Linear Feedback Shift Register (LFSR)
Combined Tausworthe (TW)
- TW.cpp :
Template Code of TW
- (TW_orig.cpp :
Straightforward porting from a software code)
Mersenne Twister (MT)
- MT2.cpp :
Template Code of MT (high-throughput version)
- (MT.cpp :
Template Code of MT)
- (MT_orig.cpp :
Straightforward porting from a software code)
Testbench
Performance and Resource Usage
Speed and Resource Usage of the random number generators
evaluated with Vitis HLS 2020.2 and Vivado 2020.2,
targeted to xc7z010-clg400-1, 10.00ns.
source code |
Vitis HLS Synthesis estimate |
Vivado Synthesis estimate |
Timing |
Latency |
Interval |
BRAM |
DSP |
FF |
LUT |
BRAM |
DSP |
FF |
LUT |
LCG.cpp |
6.912 ns |
3 clocks |
2 clocks |
0 |
0 |
232 |
129 |
0 |
3 |
152 |
75 |
LFSR_orig.cpp |
0.992 ns |
1 clock |
1 clock |
0 |
0 |
34 |
78 |
0 |
0 |
101 |
25 |
LFSR.cpp |
0.992 ns |
1 clock |
1 clock |
0 |
0 |
34 |
78 |
0 |
0 |
101 |
25 |
TW_orig.cpp |
1.986 ns |
1 clock |
1 clock |
0 |
0 |
98 |
175 |
0 |
0 |
155 |
76 |
TW.cpp |
1.986 ns |
1 clock |
1 clock |
0 |
0 |
98 |
175 |
0 |
0 |
155 |
76 |
MT_orig.cpp |
7.226 ns |
1258 clocks |
1259 clocks |
2 |
0 |
328 |
794 |
1 |
0 |
364 |
285 |
MT.cpp |
6.508 ns |
3 clocks |
3 clocks |
2 |
0 |
170 |
467 |
1 |
0 |
186 |
132 |
MT2.cpp |
4.965 ns |
1 clock |
1 clock |
2 |
0 |
162 |
435 |
1 |
0 |
198 |
164 |
References
- Yuto ASAUMI, Tomonori IZUMI,
“FPGA向け乱数生成モジュールの高位合成IP化設計と比較検討”,
IEICE Technical Report,
RECONF2021-48,
Dec.2021 (in Japanese).
- Yuto ASAUMI, Tomonori IZUMI,
“高位合成向け乱数生成ライブラリの拡充”,
IEICE Technical Report,
RECONF2022-37,
Sep.2022 (in Japanese).
- 日本工業標準調査会,
“乱数生成及びランダム化の手順”,
JIS Z 9031:2012,日本規格協会,2012年4月20日改正.
- M. Matsumoto and T. Nishimura,
“Mersenne Twister: A random number generator (since 1997/10)”,
http://www.math.sci.hiroshima-u.ac.jp/m-mat/MT/mt.html