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.

121 lines
4.5 KiB

8 years ago
  1. [![test](https://github.com/tmeissner/libvhdl/workflows/test/badge.svg?branch=master)](https://github.com/tmeissner/libvhdl/actions?query=workflow%3Atest)
  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. ##### WishBoneMasterE
  38. Simple WishBone bus master with support of classic single write & read
  39. ##### WishBoneSlaveE
  40. Simple WishBone bus slave with support of classic single write & read and register backend
  41. ## test
  42. Unit tests for each component
  43. ##### QueueT
  44. Unit tests for components of QueueP package
  45. ##### SimT
  46. Unit tests for components of SimP package
  47. ##### SpiT
  48. Unit tests for SpiMasterE and SpiSlaveE components
  49. ##### WishBoneT
  50. Unit tests for WishBoneMasterE and WishBoneSlaveE components
  51. ## formal
  52. Formal verification for selected components
  53. ## common
  54. Common utilities
  55. ##### UtilsP
  56. Common functions useful for simulation/synthesis
  57. * `and_reduce(x)` returns and of all items in x, collapsed to one std_logic/boolean
  58. * `or_reduce(x)` returns or of all items in x, collapsed to one std_logic/boolean
  59. * `xor_reduce(x)` returns xor of items in x, collapsed to one std_logic
  60. * `even_parity(x)` returns even parity of x
  61. * `odd_parity(x)` returns odd parity of x
  62. * `count_ones(x)` returns number of '1' in x
  63. * `one_hot(x)` returns true if x is one-hot coded, false otherwise
  64. * `is_unknown(x)` returns true if x contains 'U' bit, false otherwise
  65. * `uint_to_slv(x, l)` returns std_logic_vector (unsigned) with length l converted from x (natural)
  66. * `slv_to_uint(x)` returns natural converted from x (std_logic_vector) (unsigned)
  67. * `uint_bitsize(x)` returns number of bits needed for given x (natural)
  68. ## Dependencies
  69. To run the tests, you have to install GHDL. You can get it from
  70. [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.
  71. 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
  72. the libvhdl Repository to get it: `git clone --recursive https://git.goodcleanfun.de/tmeissner/libvhdl`
  73. Another useful tool is GTKWave, install it if you want to use the waveform files generated by some of the tests.
  74. ## Building
  75. Type `make` to do all tests. You should see the successfully running tests like this:
  76. ```
  77. $ make
  78. ghdl -a --std=02 ../sim/QueueP.vhd QueueT.vhd
  79. ghdl -e --std=02 QueueT
  80. ghdl -r --std=02 QueueT
  81. QueueT.vhd:52:5:@0ms:(report note): INFO: t_simple_queue test finished successfully
  82. QueueT.vhd:87:5:@0ms:(report note): INFO: t_list_queue test finished successfully
  83. ```