blob: 550f9fccc898018b73062815dff567f92a929996 [file] [log] [blame] [view]
Michael Schaffnerb5a88f22019-11-26 19:43:37 -08001---
2title: "Fpvgen: Initial FPV testbench generation tool"
3---
4
5# Overview
6
7`fpvgen` is a Python tool that can be used to generate the initial boilerplate code for an FPV testbench.
8It takes as input a SystemVerilog module file representing the top-level of an IP to be tested with FPV, and generates the following folders and files in the output directory (which defaults to `../fpv` with respect to the module file provided):
9```console
10.
11├── fpv // default output folder
12│   ├── <ip-name>_fpv.core
13│   ├── tb
14│   │   ├── <ip-name>_bind_fpv.sv
15│   │   └── <ip-name>_fpv.sv
16│   └── vip
17│   └── <ip-name>_assert_fpv.sv
18└── rtl // folder containing the SV module file
19    ├── <ip-name>.sv
20 ...
21```
22The `<ip-name>_fpv.sv` is the FPV testbench that can be used to instantiate different parameterizations of the DUT to be tested.
23`<ip-name>_bind_fpv.sv` contains the bind statement which binds the verification IP `<ip-name>_assert_fpv.sv` to all DUT instances.
24If the IP is flagged as being comportable using the `-c` switch, the CSR FPV assertions are bound to the module as well.
25
26# Examples
27Generating a non-comportable IP can be done as follows (using the LFSR as an example):
28```console
29util/fpvgen.py hw/ip/prim/rtl/prim_lfsr.sv
30```
31
32If the IP is comportable, only the `-c` switch has to be added.
33E.g., using the `pinmux` comportable IP as an example:
34```console
35util/fpvgen.py -c hw/ip/pinmux/rtl/pinmux.sv
36```
37
38If needed, the default output directory can be overridden using the `-o` switch.
39
40# Help Output
41This is the help output from the tool (switch `-h`).
42```console
43usage: fpvgen [-h] [-o OUTDIR] [-c] file
44
45 Boilerplate code generator for FPV testbenches. Can be used for
46 comportable or non-comportable IPs.
47
48 The generator creates the FuseSoC core file and two additional
49 subfolders 'tb' and 'vip' in the output directory. It will place stubs
50 for the testbench and bind files into the 'tb' subfolder, and a stub for
51 the FPV assertions into the 'vip' (verification IP) subfolder.
52
53 The generator needs the path to the top-level module of the IP to be
54 tested. E.g., suppose we would like to generate an FPV testbench for a
55 FIFO primitive located at 'hw/ip/prim/rtl/prim_fifo_sync.sv' we can
56 invoke the generator as follows:
57
58 util/fpvgen.py hw/ip/prim/rtl/prim_fifo_sync.sv
59
60 By default, the output directory is assumed to be '../fpv' with respect
61 to the toplevel module, but this can be overriden using the -eo switch.
62
63 Further if the IP is comportable, this can be indicated using the -c
64 switch, which causes the generator to add a bind statement for the CSR
65 FPV assertions in the testbench.
66
67positional arguments:
68 file Relative path to the SystemVerilog file of the module
69 for which the code shall be generated. This can be a
70 primitive or a comportable IP (for which the -c switch
71 should be set).
72
73optional arguments:
74 -h, --help show this help message and exit
75 -o OUTDIR, --outdir OUTDIR
76 Path where to place the testbench code. This is
77 defaults to '../fpv' w.r.t. to the module path. For
78 instance, if the module path is
79 'hw/ip/mymod/rtl/mymod.sv', the FPV testbench would be
80 generated under hw/ip/mymod/fpv.
81 -c, --is_cip Indicates whether this is a comportable IP. If yes,
82 FPV assertions for the TL-UL interface and CSRs are
83 automatically bound in the testbench. Note however
84 that these CSR assertions need to be generated
85 separately using the regtool automation.
86```