Library of reusable VHDL components
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
4.7 KiB

8 years ago
  1. [![tests](https://github.com/tmeissner/libvhdl/workflows/tests/badge.svg?branch=master)](https://github.com/tmeissner/libvhdl/actions?query=workflow%3Atests)
  2. The original repository is now located on my own git-server at [https://git.goodcleanfun.de/tmeissner/libvhdl](https://git.goodcleanfun.de/tmeissner/libvhdl)
  3. It is mirrored to github with every push, so both should be in sync.
  4. # libvhdl
  5. A LGPL3 licensed library of reusable components for VHDL designs and testbenches.
  6. The intention of this library is not to realize the most optimized and highest performing code.
  7. Instead it serves more as an example how to implement various things in VHDL and test them efficiently.
  8. ## sim
  9. (Non-)synthesizable components for testbenches
  10. ##### AssertP (Deprecated, better use Alerts from OSVVM instead)
  11. Package with various assertion procedures.
  12. * `assert_true(x[, str, level])` checks if boolean x = false
  13. * `assert_false(x[, str, level])` checks if boolean x = false
  14. * `assert_equal(x, y[, str, level])` checks if x = y
  15. * `assert_unequal(x, y[, str, level])` checks if x /= y
  16. All of the assert_* procedures have following optional parameters:
  17. * `str` print string str to console instead implemented one
  18. * `level` severity level (note, warning, error, failure)
  19. ##### SimP
  20. Package with various components general useful for simulation
  21. * `wait_cycles(x, n)` waits for n rising edges on std_logic signal x
  22. * `spi_master()` configurable master for SPI protocol, supports all cpol/cpha modes
  23. * `spi_slave()` configurable slave for SPI protocol, supports all cpol/cpha modes
  24. ##### QueueP
  25. Generic package with various implementations of queue types:
  26. * `t_simple_queue` simple array based FIFO queue
  27. * `t_list_queue` linked list FIFO queue using access types
  28. ##### DictP
  29. Generic package with implementation of dictionary (aka associative array) type:
  30. * `t_dict` linked list dictionary using access types
  31. ## syn
  32. Synthesizable components for implementing in FPGA
  33. ##### SpiMasterE
  34. Configurable SPI master with support modes 0-3 and simple VAI local backend.
  35. ##### SpiSlaveE
  36. Configurable SPI slave with support modes 0-3 and simple VAI local backend.
  37. ##### UartTx
  38. Configurable UART transmitter
  39. ##### UartRx
  40. Configurable UART receiver
  41. ##### WishBoneMasterE
  42. Simple WishBone bus master with support of classic single write & read
  43. ##### WishBoneSlaveE
  44. Simple WishBone bus slave with support of classic single write & read and register backend
  45. ## test
  46. Unit tests for each component
  47. ##### QueueT
  48. Unit tests for components of QueueP package
  49. ##### SimT
  50. Unit tests for components of SimP package
  51. ##### SpiT
  52. Unit tests for SpiMasterE and SpiSlaveE components
  53. ##### UartT
  54. Unit test for UartTx and UartRx components
  55. ##### WishBoneT
  56. Unit tests for WishBoneMasterE and WishBoneSlaveE components
  57. ## formal
  58. Formal verification for selected components
  59. ## common
  60. Common utilities
  61. ##### UtilsP
  62. Common functions useful for simulation/synthesis
  63. * `and_reduce(x)` returns and of all items in x, collapsed to one std_logic/boolean
  64. * `or_reduce(x)` returns or of all items in x, collapsed to one std_logic/boolean
  65. * `xor_reduce(x)` returns xor of items in x, collapsed to one std_logic
  66. * `even_parity(x)` returns even parity of x
  67. * `odd_parity(x)` returns odd parity of x
  68. * `count_ones(x)` returns number of '1' in x
  69. * `one_hot(x)` returns true if x is one-hot coded, false otherwise
  70. * `is_unknown(x)` returns true if x contains 'U' bit, false otherwise
  71. * `uint_to_slv(x, l)` returns std_logic_vector (unsigned) with length l converted from x (natural)
  72. * `slv_to_uint(x)` returns natural converted from x (std_logic_vector) (unsigned)
  73. * `uint_bitsize(x)` returns number of bits needed for given x (natural)
  74. ## Dependencies
  75. To run the tests, you have to install GHDL. You can get it from
  76. [https://github.com/tgingold/ghdl/](https://github.com/tgingold/ghdl/). Your GHDL version should not be too old, because libvhdl needs VHDL-2008 support. So, it's best to get the latest stable release or build from latest sources.
  77. libvhdl uses the OSVVM library to generate random data for the unit tests. It is shipped with libvhdl as git submodule. You have to use the `--recursive` option when clone
  78. the libvhdl Repository to get it: `git clone --recursive https://git.goodcleanfun.de/tmeissner/libvhdl`
  79. Another useful tool is GTKWave, install it if you want to use the waveform files generated by some of the tests.
  80. ## Building
  81. Type `make` to do all tests. You should see the successfully running tests like this:
  82. ```
  83. $ make
  84. ghdl -a --std=02 ../sim/QueueP.vhd QueueT.vhd
  85. ghdl -e --std=02 QueueT
  86. ghdl -r --std=02 QueueT
  87. QueueT.vhd:52:5:@0ms:(report note): INFO: t_simple_queue test finished successfully
  88. QueueT.vhd:87:5:@0ms:(report note): INFO: t_list_queue test finished successfully
  89. ```