over 1 year ago

To make full use of MyHDL, it is strongly recommended to install and configure cosimulation modules. So that the output (Verilog/VHDL code) of MyHDL compiler backend can be evaluated, and the current MyHDL code can work with the conventional code base and migrate into industrial EDA workflow.

At this time, only Verilog users have to install it for cosimulation. So that we can use from_myhdl and to_myhdl in our example.

Here, I assume that MyHDL has been installed by the steps in the previous post.

Installing Icarus Verilog

MyHDL supports several popular RTL simulators. At this time, Icarus Verilog, GHDL, cver, and ModelSim were supported. Here, Icarus Verilog will be used as an example.

Icarus Verilog is already in some Linux distributions. For example, in Ubuntu, type the following command to install Icarus Verilog:

sudo apt install iverilog

For Windows users, Windows binaries might be useful.

VPI module

VPI module provides an interface for Verilog to share data with MyHDL.

Compiling VPI module

In the source code of MyHDL, the cosimulation folder contains several types of simulator that supported. In each subfolder, the README file describes how to install MyHDL support for these simulators.

For Icarus Verilog, go to cosimulation/icarus, and then use command make to compile the vpi module. Then, you will get myhdl.vpi after compiling.

You can copy myhdl.vpi to other places while needed.

Check installation

cd myhdl/test/core
py.test test_Cosimulation.py

Follow cosimulation chapter of the manual could also make sense, especially when you want to get a direct message of why the cosimulation does not work.

Please refer to corresponding manpages to get the meanings of options for iverilog and vvp.

Notes on Windows Installation

The process of Windows installation is almost the same, but there are still some difference. Here are the notes that may help your installation.

  1. After installing iverilog, remember to add the path of iverilog.exe and iverilog-vpi.exe to the system path.

  2. Before compiling VPI files, a MinGW implementation should be installed and added into system path.

  3. When compiling VPI modules, myhdl.c will probably be overwritten and fail to compile. If this situation occurs, please replace myhdl.c with the original one, and then copy the vlog_startup_routines function in myhdl_table.c to the end of myhdl.c, and then execute

iverilog-vpi myhdl.c
← GSoC #1: Setting Up Development Environment GSoC #3: Current Progress and Plans for Implementing fixbv →