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.

115 lines
4.3 KiB

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