This is a generic testbench which checks the width of the ouput pulse, depending on the given generics in the beginning of the simulation. The output pulse is high in the falling or in the rising edge of the input pulse.
# Testbench for [gc_edge_detect](../../../modules/common/gc_edge_detect.vhd) common core
2. Install [GHDL](https://github.com/ghdl/ghdl/releases). Note that GHDL with GCC backend is required for code coverage. For Ubuntu 20.04 it works with gcc 9.4.
## Testbench description
The testbench is running using VUnit and it uses OSVVM for randomization of the inputs and for basic coverage. It checks the width of the ouput pulse, depending on the given generics in the beginning of the simulation. It also verifys if the the output pulse is high in the falling or in the rising edge of the input pulse.
The generics of this core are the following:
- g_async_rst : Synchronous or asynchronous reset
- g_pulse_edge : Detect of positive or negative edges
- g_clock_edge : Clock edge sensitivity of edge detection
Regarding on the values of the above generics, there are the following test cases:
1. TRUE, positive, positive
2. TRUE, positive, negative
3. TRUE, negative, negative
4. TRUE, negative, negative
5. FALSE, positive, positive
6. FALSE, positive, negative
7. FALSE, negative, positive
8. FALSE, negative, negative
The testbench is using OSVVM for randomization of the inputs and for basic coverage. Simple assertions are using, to verify that the output is the same as the input, after one clock.
| Generics | Type | Values |
|--------------|:----------:|----------------:|
| g_async_rst | Boolean | True/False |
| g_pulse_edge | String |Positive/Negative|
| g_clock_edge | String |Positive/Negative|
Regarding on the values of the above generics and their combinations, there are 8 different test cases.
## How to run the testbench
This testbench has been tested using GHDL and Aldec Riviera Pro. VUnit will select the simulator based on the specified `$PATH`. So the same commands are used to run the testbench, regardless the simulator.
```
python3 run.py -v
```
Note: Each testbench using a common python module `sim_utils.py` which includes various functions.
## Basic information for VUnit
1. Basic arguments for VUnit `python3 run.py`
-`--list` for viewing the list of the tests
-`-v` for verbode run
-`--gtkwave-fmt=(vcd,ghw)` for generating a waveform file (only when using GHDL)
-`-g <name of the test>` for opening in GUI the running test