2020-08-17 15:33:51 -05:00
.. _from_verilog_to_verification:
2020-05-25 01:31:27 -05:00
2020-08-17 15:33:51 -05:00
From Verilog to Verification
----------------------------
2020-05-25 01:31:27 -05:00
This tutorial will show an example how to
- generate Verilog netlists for a FPGA fabric
- generate Verilog testbenches for a RTL design
- run HDL simulation to verify the functional correctness of the implemented FPGA fabric
2021-02-06 18:46:56 -06:00
.. note :: Before running any design flows, please checkout the tutorial :ref: `tutorial_compile` , to ensure that you have an operating copy of OpenFPGA installed on your computer.
2020-05-25 01:31:27 -05:00
Netlist Generation
~~~~~~~~~~~~~~~~~~
We will use the openfpga_flow scripts (see details in :ref: `run_fpga_task` ) to generate the Verilog netlists and testbenches.
Here, we consider a representative but fairly simple FPGA architecture, which is based on 4-input LUTs.
We will map a 2-input AND gate to the FPGA fabric, and run a full testbench (see details in :ref: `fpga_verilog_testbench` )
We will simply execute the following openfpga task-run by
.. code-block :: shell
2020-10-28 09:58:19 -05:00
python3 openfpga_flow/scripts/run_fpga_task.py basic_tests/full_testbench/configuration_chain
2020-05-25 01:31:27 -05:00
2020-10-28 09:58:19 -05:00
Detailed settings, such as architecture XML files and RTL designs, can be found at `` ${OPENFPGA_PATH}/openfpga_flow/tasks/basic_tests/full_testbench/configuration_chain/config/task.conf `` .
2020-05-25 01:31:27 -05:00
.. note :: `` ${OPENFPGA_PATH} `` is the root directory of OpenFPGA
After this task-run, you can find all the generated netlists and testbenches at
.. code-block :: shell
2020-10-28 09:58:19 -05:00
${OPENFPGA_PATH}/openfpga_flow/tasks/basic_tests/full_testbench/configuration_chain/latest/k4_N4_tileable_40nm/and2/MIN_ROUTE_CHAN_WIDTH/SRC/
2020-05-25 01:31:27 -05:00
.. note :: See :ref: `fabric_netlists` and :ref: `fpga_verilog_testbench` for the netlist details.
Run icarus iVerilog Simulation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Through OpenFPGA Scripts
^^^^^^^^^^^^^^^^^^^^^^^^
By default, the `` configuration_chain `` task-run will execute iVerilog simulation automatically.
The simulation results are logged in
.. code-block :: shell
2020-10-28 09:58:19 -05:00
${OPENFPGA_PATH}/openfpga_flow/tasks/basic_tests/full_testbench/configuration_chain/latest/k4_N4_tileable_40nm/and2/MIN_ROUTE_CHAN_WIDTH/vvp_sim_output.txt
2020-05-25 01:31:27 -05:00
If the verification passed, you should be able to see `` Simulation Succeed `` in the log file.
All the waveforms are stored in the `` and2_formal.vcd `` file.
To visualize the waveforms, you can use the `GTKWave
<http://gtkwave.sourceforge.net/> `_.
.. code-block :: shell
2020-10-28 09:58:19 -05:00
gtkwave ${OPENFPGA_PATH}/openfpga_flow/tasks/basic_tests/full_testbench/configuration_chain/latest/k4_N4_tileable_40nm/and2/MIN_ROUTE_CHAN_WIDTH/and2_formal.vcd &
2020-05-25 01:31:27 -05:00
Manual Method
^^^^^^^^^^^^^
If you want to run iVerilog simulation manually, you can follow these steps:
.. code-block :: shell
2020-10-28 09:58:19 -05:00
cd ${OPENFPGA_PATH}/openfpga_flow/tasks/basic_tests/full_testbench/configuration_chain/latest/k4_N4_tileable_40nm/and2/MIN_ROUTE_CHAN_WIDTH
2020-05-25 01:31:27 -05:00
source iverilog_output.txt
vvp compiled_and2
Debugging Tips
^^^^^^^^^^^^^^
If you want to apply full visibility to the signals, you need to change the following line in
2020-06-24 11:36:08 -05:00
.. code-block :: shell
2020-05-25 01:31:27 -05:00
2020-10-28 09:58:19 -05:00
${OPENFPGA_PATH}/openfpga_flow/tasks/basic_tests/full_testbench/configuration_chain/latest/k4_N4_tileable_40nm/and2/MIN_ROUTE_CHAN_WIDTH/SRC/and2_autocheck_top_tb.v
2020-05-25 01:31:27 -05:00
from
.. code-block :: shell
$dumpvars (1, and2_autocheck_top_tb);
to
.. code-block :: shell
$dumpvars (12, and2_autocheck_top_tb);
Run Modelsim Simulation
~~~~~~~~~~~~~~~~~~~~~~~
Alternatively, you can run Modelsim simulations through openfpga_flow scripts or manually.
2020-10-28 09:58:19 -05:00
.. note :: Before starting, please ensure that Mentor Modelsim has been correctly installed on your local environment.
2020-05-25 01:31:27 -05:00
Through OpenFPGA Scripts
^^^^^^^^^^^^^^^^^^^^^^^^
You can simply call the python script in the following line:
.. code-block :: shell
2020-10-28 09:58:19 -05:00
python3 openfpga_flow/scripts/run_modelsim.py basic_tests/full_testbench/configuration_chain --run_sim
2020-05-25 01:31:27 -05:00
The script will automatically create a Modelsim project at
.. code-block :: shell
2020-10-28 09:58:19 -05:00
${OPENFPGA_PATH}/openfpga_flow/tasks/basic_tests/full_testbench/configuration_chain/latest/k4_N4_tileable_40nm/and2/MIN_ROUTE_CHAN_WIDTH/MSIM2/
2020-05-25 01:31:27 -05:00
and run the simulation.
You may open the project and visualize the simulation results.
Manual Method
^^^^^^^^^^^^^
Modify the `` fpga_defines.v `` (see details in :ref: `fabric_netlists` ) at
.. code-block :: shell
2020-06-24 11:36:08 -05:00
${OPENFPGA_PATH}/openfpga_flow/tasks/openfpga_shellfull_testbench//configuration_chain/latest/k4_N4_tileable_40nm/and2/MIN_ROUTE_CHAN_WIDTH/SRC/
2020-05-25 01:31:27 -05:00
by **deleting** the line
.. code-block :: shell
`define ICARUS_SIMULATOR 1
Create a folder `` MSIM `` under
.. code-block :: shell
2020-10-28 09:58:19 -05:00
${OPENFPGA_PATH}/openfpga_flow/tasks/basic_tests/full_testbench/configuration_chain/latest/k4_N4_tileable_40nm/and2/MIN_ROUTE_CHAN_WIDTH/
2020-05-25 01:31:27 -05:00
Under the `` MSIM `` folder, create symbolic links to `` SRC `` folder and reference benchmarks by
.. code-block :: shell
ln -s ../SRC ./
ln -s ../and2_output_verilog.v ./
.. note :: Depending on the operating system, you may use other ways to create the symbolic links
Launch ModelSim under the `` MSIM `` folder and create a project by following Modelsim user manuals.
Add the following file to your project:
.. code-block :: shell
2020-10-28 09:58:19 -05:00
${OPENFPGA_PATH}/openfpga_flow/tasks/basic_tests/full_testbench/configuration_chain/latest/k4_N4_tileable_40nm/and2/MIN_ROUTE_CHAN_WIDTH/SRC/and2_include_netlists.v
2020-05-25 01:31:27 -05:00
Compile the netlists, create a simulation configuration and specify `` and2_autocheck_top_tb `` at the top unit.
Execute simulation with `` run -all ``
You should see `` Simulation Succeed `` in the output log.