RTL Studio Open IDE

LFSR, PRBS & CRC

Additive Lagged Fibonacci 16

A 16-bit Additive Lagged Fibonacci pseudo-random number generator with taps j=3 and k=5.

About this block

Simulate it in the Verilog IDE

Easyverilogsimsyn

Additive Lagged Fibonacci 16 is a Verilog reference block in the LFSR, PRBS & CRC catalog. LFSR, PRBS, CRC, and pseudo-random sequence generators. Marked Easy: a small block you can read, simulate, and synthesize in one sitting.

This IP implements a 16-bit Additive Lagged Fibonacci Pseudo-Random Number Generator (PRNG). The generator uses taps $j=3$ and $k=5$ to produce pseudo-random sequences. The output is calculated as:

$$ x[n] = (x[n-3] + x[n-5]) \mod 2^{16} $$

This design is lightweight, suitable for embedded systems, and provides reproducible sequences via seed loading.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Additive Lagged Fibonacci 16.
  2. Read the Verilog module in the editor. The catalog line for this block: A 16-bit Additive Lagged Fibonacci pseudo-random number generator with taps j=3 and k=5.
  3. Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
  4. Run Yosys in the same IDE for a generic netlist. Sky130 liberty mapping is a separate Pro library option.

RTL Studio is the Verilog simulator and IDE around this block: Slang lint, Verilator, VCD waveforms, and Yosys, in the browser. Simulation guide · Yosys guide.

Features

  • 16-bit Parallel Data Path: Full 16-bit precision for state and output.
  • Synchronous Reset: Resets all internal state registers to zero.
  • Seed Loading: Allows initialization with a specific 16-bit seed for reproducibility.
  • Simple Logic: Uses basic combinatorial addition and shift register logic.
  • Low Resource Utilization: Minimal LUT/FF usage, ideal for resource-constrained FPGAs.

Interface

Port NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low synchronous reset
seed_inInput16Seed value for initialization
seed_loadInput1Active-high signal to load seed into state
rand_outOutput16Current pseudo-random output value

Architecture

The module maintains a 5-stage shift register for state storage. Each stage holds a 16-bit value representing previous outputs. The next state is computed by adding the values from taps 3 and 5 (indices 2 and 4 in 0-based indexing).

Verification

The testbench verifies the following scenarios:

Test CaseDescriptionExpected Result
TC1Reset CheckOutput is 0 after reset
TC2Seed Load CheckOutput matches seed
TC3PRNG Variation CheckOutput changes from seed
TC4Non-Zero Output CheckOutput is not all zeros

### Running Simulation

  1. Compile the RTL and testbench.
  2. Run the simulation.
  3. Check the Log panel for:

- INFO: TC1 Reset check PASS - INFO: TC2 Seed load check PASS - INFO: TC3 PRNG variation PASS - INFO: TC4 PRNG dynamic output PASS - INFO: PASS

  1. Inspect waveforms using sim/dump.vcd in your waveform viewer (e.g., RtlStudio Waveform tab).

More in LFSR, PRBS & CRC

All LFSR, PRBS & CRC blocks