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.

116 lines
4.2 KiB

  1. # libvhdl
  2. A OHDL licensed library of reusable components for VHDL designs and testbenches
  3. ##sim
  4. (Non) synthesible components for testbenches
  5. ##### AssertP
  6. Package with various assertion procedures.
  7. * `assert_true(x[, str, level])` checks if boolean x = false
  8. * `assert_false(x[, str, level])` checks if boolean x = false
  9. * `assert_equal(x, y[, str, level])` checks if x = y
  10. * `assert_unequal(x, y[, str, level])` checks if x /= y
  11. All of the assert_* procedures have following optional parameters:
  12. * `str` print string str to console instead implemented one
  13. * `level` severity level (note, warning, error, failure)
  14. ##### SimP
  15. Package with various components general useful for simulation
  16. * `wait_cycles(x, n)` waits for n rising edges on std_logic signal x
  17. * `spi_master()` configurable master for SPI protocol, supports all cpol/cpha modes
  18. * `spi_slave()` configurable slave for SPI protocol, supports all cpol/cpha modes
  19. ##### QueueP
  20. Package with various implementations of queue types:
  21. * `t_simple_queue` simple array based FIFO queue
  22. * `t_list_queue` linked list FIFO queue using access types
  23. ##### DictP
  24. Package with implementation of dictionary (aka associative array) type:
  25. * `t_dict` linked list dictionary using access types
  26. ## syn
  27. Synthesizable components for implementing in FPGA
  28. ##### SpiMasterE
  29. Configurable SPI master with support modes 0-3 and simple VAI local backend.
  30. ##### SpiSlaveE
  31. Configurable SPI slave with support modes 0-3 and simple VAI local backend.
  32. ##### WishBoneMasterE
  33. Simple WishBone bus master with support of classic single write & read
  34. ##### WishBoneSlaveE
  35. Simple WishBone bus slave with support of classic single write & read and register backend
  36. ##test
  37. Unit tests for each component
  38. ##### QueueT
  39. Unit tests for components of QueueP package
  40. ##### SimT
  41. Unit tests for components of SimP package
  42. ##### SpiT
  43. Unit tests for SpiMasterE and SpiSlaveE components
  44. ##### WishBoneT
  45. Unit tests for WishBoneMasterE and WishBoneSlaveE components
  46. ## common
  47. Common utilities
  48. ##### UtilsP
  49. Common functions useful for simulation/synthesis
  50. * `and_reduce(x)` returns and of all items in x, collapsed to one std_logic/boolean
  51. * `or_reduce(x)` returns or of all items in x, collapsed to one std_logic/boolean
  52. * `xor_reduce(x)` returns xor of items in x, collapsed to one std_logic
  53. * `even_parity(x)` returns even parity of x
  54. * `odd_parity(x)` returns odd parity of x
  55. * `count_ones(x)` returns number of '1' in x
  56. * `one_hot(x)` returns true if x is one-hot coded, false otherwise
  57. * `is_unknown(x)` returns true if x contains 'U' bit, false otherwise
  58. * `uint_to_slv(x, l)` returns std_logic_vector (unsigned) with length l converted from x (natural)
  59. * `slv_to_uint(x)` returns natural converted from x (std_logic_vector) (unsigned)
  60. * `uint_bitsize(x)` returns number of bits needed for given x (natural)
  61. ## Dependencies
  62. To run the tests, you have to install GHDL. You can get it from
  63. [http://sourceforge.net/projects/ghdl-updates/](http://sourceforge.net/projects/ghdl-updates/).
  64. If you use the 0.31 version of GHDL, you need the VHDL-2008 proposed packages because libvhdl uses various VHDL-2008 features. To get the needed files, you can use the get_vhdl_2008.sh script which downloads the files into the vhdl_2008 folder and patches the env_c.vhdl file to get in compiled with GHDL.
  65. If you build GHDL from actual source or use another simulator with VHDL-2008 support, you don't need these packages. Instead you have to outcomment
  66. the references to these packages from the source files.
  67. libvhdl also 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. ```