Home

Awesome

Must-have verilog systemverilog modules

Originally published as part of https://github.com/pConst/basic_verilog
by Konstantin Pavlov, pavlovconst@gmail.com

Hi! This is a collection of Verilog SystemVerilog synthesizable modules.

All the code is highly reusable across typical FPGA projects and mainstream FPGA vendors.

Please feel free to make pull requests or contact me in case you spot any code issues.

Also, give me a pleasure, tell me if the code has got succesfully implemented in your hobby, scientific or industrial projects!

Licensing

The code is licensed under CC BY-SA 4_0
That means, that you can remix, transform, and build upon the material for any purpose, even commercially.
However, YOU MUST provide the name of the creator and distribute your contributions under the same license as the original.

Contents description

For your convinience I`ve tagged some sources by their "difficulty":
:green_circle: - for the most basic tasks
:red_circle: - for advanced or special purpose routines

If you are a beginner in HW design - you may want to start exploring :green_circle: code first.
Almost every source file in the repository contains detailed description and instantiation template!

DIRECTORYDESCRIPTION
Advanced Synthesis Cookbook/useful code from Altera's cookbook
KCPSM6_Release9_30Sept14/Xilinx's Picoblaze soft processor sources
:red_circle:XilinxBoardStore_with_Alveo_cards_supportboard definitions for Xilinx Alveo accelerator cards
pacoblaze-2.2/version of Picoblaze adapted for Altera devices
avalon_mm_master_templates/Avalon-MM component templates from Altera
axi_master_slave_templates/AXI componet templates generated by Vivado
benchmark_projects/benchmarking various IDEs to compile exact same Verilog project
dual_port_ram_templates/Block RAM templates
example_projects/FPGA project boilerplates and examples
gitignores/gitignore files for FPGA projects
scripts/useful TCL, batch and shell scripts
:red_circle:scripts_for_intel_hls/useful scripts for compiling for Intel HLS
:red_circle:scripts_for_xilinx_hls/useful scripts for compiling for Xilinx HLS
xpmXilinx parametrizable macros sources
FILEDESCRIPTION
adder_tree.svadding multiple values together in parallel
axi4l_logger.svsniffs all AXI transactions and stores address and data to fifo
:green_circle:bin2gray.svcombinational Gray code to binary converter
bin2pos.svconverts binary coded value to positional (one-hot) code
cdc_data.svstandard two-stage data synchronizer
cdc_strobe.svclock crossing synchronizer for one-cycle strobes
:green_circle:clk_divider.svwide reference clock divider
clogb2.svhcalculates counter/address width based on specified vector/RAM depth
:green_circle:debounce.vtwo-cycle debounce for input buttons
:green_circle:delay.svuseful module to make static delays or to synchronize across clock domains
delayed_event.svgenerates delayed pulse one clock width
dynamic_delay.svdynamic delay for arbitrary input signal
:green_circle:edge_detect.svcombinational edge detector, gives one-tick pulses on every signal edge
encoder.vdigital encoder input logic module
:red_circle:fast_counter.svsynthetic counter
fifo_combiner.svaccumulates data words from multiple FIFOs to a single output FIFO
fifo_operator.svperforms custom operation on data words from multiple FIFOs and stores result to a single output FIFO
:red_circle:fifo_single_clock_ram_*.svsingle-clock FIFO buffer (queue) implementation
:red_circle:fifo_single_clock_reg_*.svsingle-clock FIFO buffer (queue) implementation
:green_circle:gray2bin.svcombinational binary to Gray code converter
:red_circle:gray_functions.vhGray code parametrizable converter functions
:green_circle:hex2ascii.svconverts 4-bit binary nibble to 8-bit human-readable ASCII char
leave_one_hot.svcombinational module that leaves only lowest hot bit
lifo.svsingle-clock LIFO buffer (stack) implementation
main_tb.svbasic testbench template
moving_average.svSimple moving average implementation
pack_unpack_array.vmacros for packing and unpacking 2D and 3D vectors in Verilog-2001
pattern_detect.svdetects data pattern specified
pdm_modulator.svpulse density modulation generator module
pos2bin.svconverts positional (one-hot) value to binary representation
prbs_gen_chk.svPRBS pattern generator or checker
preview_fifo.svFIFO with an ability to be read 0, 1 or 2 words at once
priority_enc.svcombinational priority_encoder
pulse_gen.svgenerates pulses with given width and delay
pulse_stretch.svconfigurable pulse stretcher/extender module
pwm_modulator.svpulse width modulation generator
:red_circle:read_ahead_buf.svsubstitutes fifo read port and performs fifo data update at the same clock cycle
reset_set.svSR trigger variant w/o metastable state, set dominates here
reset_set_comb.svsynchronous SR trigger, but has a combinational output
reverse_bytes.svreverses bytes order within multi-byte array
reverse_dimensions.svreverses dimension order in SystemVerilog 2D vector
reverse_vector.svreverses signal order within multi-bit bus
round_robin_enc.svround robin combinational encoder
round_robin_performance_enc.svperformance improved round robin encoder
set_reset.svSR trigger variant w/o metastable state, reset dominates here
set_reset_comb.svsynchronous SR trigger, but has a combinational output
sim_clk_gen.svtestbench clock generator
:red_circle:soft_latch.svcombinational data hold circuit
spi_master.svuniversal spi master module
:red_circle:true_dual_port_write_first_2_clock_ram.svdouble port RAM/ROM module
:red_circle:true_single_port_write_first_ram.svsingle port RAM/ROM module
uart_debug_printer.svdebug data printer to UART terminal
:green_circle:uart_rx.svstraightforward yet simple UART receiver
uart_rx_shifter.svUART-like receiver shifter for simple synchronous messaging inside the FPGA or between FPGAs
:green_circle:uart_tx.svstraightforward yet simple UART transmitter
uart_tx_shifter.svUART-like transmitter shifter for simple synchronous messaging inside the FPGA or between FPGAs

Also added testbenches for selected modules.