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.

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