# Posted in 2017

## Enable Your Simulator to Handle Complex Top-Level Generics

• 03 June 2017

A powerful feature in VUnit is the ability to run testbenches and test cases with different configurations (not to be confused with VHDL configurations). The typical use case is to run tests with different generics but you can also run with different simulator settings and register Python functions to be run before and after the test. The latter can be used to create stimuli and verify test outputs using the power of Python or some other external program like Matlab.

Over time VUnit users tend to get more advanced in the use of generics which inevitably leads to more complex data types. Rather than passing many generics of scalar types they want to create composite types like records and arrays. Unfortunately, many simulators have restrictions on what type of generics you can pass to the top-level testbench entity. Typically you’re limited to a small subset of the standard composite types like string and std_logic_vector and can’t use custom composite types. This is a limitation when trying to write clean and efficient code but something that can be worked around using VUnit. The trick is to encode your composite data type into something that the simulator _can_ handle and then decode back to the original type within the VHDL testbench. string is something most (all?) simulators can handle and what I will use in these examples.