Various verilog modules that I use or develop

December 25, 2025 ยท View on GitHub

Various verilog modules that I use or develop

Contains

FileDescription
binary_debias.vModule to XOR two bits in a bistream into one. Used to remove a binary debias in a random stream.
charlieplex_display.vA generic addressable display that uses a charlieplexer.
charlieplexer.vGeneric charlieplexing module for N pins to control N*(N-1) LEDs.
clock_prescaler.vSimple clock prescaler implementation that also exposes the full prescaler counter.
debouncer.vButton debouncer.
demux.vGeneric demultiplexer.
lfsr.vGeneric linear feedback shift register (LFSR).
randomized_lfsr.vModule to generate metastable output and random numbers.
randomized_lfsr_weak.vModule to generate weak metastable output and weak random numbers.
randomized_spongent.vHigh quality entropy source using metastability fed into the spongent hash algorithm to whiten it.
rotary_encoder.vInput decoder for debounced digital rotary encoders like the EC11.
simple_spi_master.vSimple SPI master implementation.
simple_spi_slave.vSimple SPI slave implementation.
spongent_hash.vNibble-serial implementation of the Spongent hash algorithm.
synchronizer.vCross-clockdomain signal synchronizer.
synchronous_reset_timer.vModule to synchronize a sync reset signal to a clock domain and hold it for a defined number of cycles.
uart.vUART module by Timothy Goddard with some changes by me to add high speed capability.
lattice_ice40/Lattice iCE40 specific implementations
lattice_ice40/debounced_button.vDebounced button from an input pin.
lattice_ice40/metastable_oscillator.vCircuit generating a metastable output.
lattice_ice40/metastable_oscillator_depth2.vCircuit generating an even more metastable output than metastable_oscillator.
lattice_ice40/pullup_input.vInput with pullup.
lattice_ice40/ringoscillator.vRing oscillator implementation.
lattice_ice40/ringoscillator_adjustable.vAdjustable ring oscillator implementation.
lattice_ice40/rotary_encoder_pullup.vPull-up implementation for rotary encoder input controller.
lattice_ice40/tristate_output.vA tristateable output.
lattice_ecp5/Lattice ECP5 specific implementations
lattice_ecp5/metastable_oscillator.vCircuit generating a metastable output.
lattice_ecp5/metastable_oscillator_depth2.vCircuit generating an even more metastable output than metastable_oscillator.
lattice_ecp5/ringoscillator.vRing oscillator implementation.
lattice_ecp5/ringoscillator_adjustable.vAdjustable ring oscillator implementation.

Contains also testbenches (*_tb.v) for many of the modules, see below.

Note: most of the implementation-specific modules should be easily adaptable to other platforms.

Testbenches

Many of the modules have a testbench (*_tb.v). Testbenches are optimizes for use with the Icarus Verilog compiler. To run all tests, just run make. The build is successfull if and only if all testbenches were able to build and succeeded.

Authors/Contributors

WhoComments
David R. Piegdon dgit@piegdon.dehttps://github.com/dpiegdon
Timothy Goddard tim@goddard.net.nzAuthor uart.v
Arnaud Durand arnaud.durand@unifr.chContributor ringoscillator.v -> https://github.com/DurandA
David A. Roberts d@vidr.ccContributor lattice_ecp5/random.v, lattice_ecp5/ringoscillator.v -> https://github.com/davidar

Licensing

License exceptions:

  • uart.v -- MIT license, see header of file.

All OTHER contained files are licensed under the LGPL v3.0, see LICENSE.txt . That means that you may use the provided verilog modules in a proprietary software without publishing your proprietary code. But you must publish any changes that you did to the provided verilog modules.

I suggest that you include this repository as a submodule. That way you can easily publish any changes separately from your own code.