Network Wizard for VHDL Test Benches
PRBS

Pseudo-Random Binary Sequences

This library provides functions for generation of Pseudo-Random Binary Sequences. A maximum length sequence has some unique properties. If the order of the polynomial is n, then the length of the sequence will be 2^n - 1, the longest run of 1's will be n and the longest run of 0's in that sequence will be n - 1.

Functionality

  • Predefined polynomials for maximum-length sequences
  • Any data width and length


More details in nw_prbs_pkg

Example use

Include the libraries:

library nw_util;
context nw_util.nw_util_context;

Generate a data array of 8bit pseudo-random numbers:

array_8bit(0 to 127) := f_gen_prbs(C_POLY_X16_X15_X13_X4_1, 8, 128);
array_8bit(0 to 127) := f_gen_prbs(C_POLY_X16_X15_X13_X4_1, 8, 128, C_LSB_FIRST); -- same sequence, but words bitflipped
array_8bit(0 to 127) := f_gen_prbs(C_POLY_X16_X15_X13_X4_1, 8, 128, C_LSB_FIRST, x"8123"); -- same polynomial, but different init value

Maximum length sequences can also be utilized to generate a range of unique, random numbers. Say we want to generate 1024 unique MAC addresses to verify a MAC lookup table, from the range 7c:10:xx:xx:xx:xx:

mac_array(0 to 1023) := f_stack(f_gen_nrs(x"7c10", 1024, "0"), f_gen_prbs(C_POLY_X32_X22_X2_X1_1, 32, 1024));

See further examples in the test bench nw_util_tb.vhd.