Tier 2 Setup Instructions - cocotb/cocotb GitHub Wiki
cocotb has built-in support for many simulators and operating systems, some are better supported, some are not as well supported. The fully supported tier 1 setup instructions are given in the user manual at http://cocotb.readthedocs.io/. All other instructions can be added here to the wiki.
Additional development libraries are needed for building 32-bit Python on 64-bit systems.
Download and install miniconda from https://docs.conda.io/en/latest/miniconda.html
On Linux based operating systems:
$> conda create -n py3_32
$> conda activate py3_32
$> conda config --env --set subdir linux-32
$> conda install python=3 gxx_linux-32
On Windows:
$> conda create -n py3_32
$> conda activate py3_32
$> conda config --env --set subdir win-32
$> conda install -c msys2 python=3 m2-base m2-make m2w64-toolchain libpython
$> sudo dpkg --add-architecture i386
$> sudo apt-get update
$> sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git xz-utils wget curl llvm
$> sudo apt-get install -y make gcc-multilib g++-multilib libssl-dev:i386 zlib1g-dev:i386 libbz2-dev:i386 libreadline-dev:i386 libsqlite3-dev:i386 libncurses5-dev:i386 libncursesw5-dev:i386 libffi-dev:i386 liblzma-dev:i386
$> curl https://pyenv.run | bash
$> # follow instructions
$> env PYTHON_CONFIGURE_OPTS="--enable-shared" CC="gcc -m32" CFLAGS="-m32" LDFLAGS="-m32" pyenv install 3.11.3
$> env pyenv global 3.11.3
$> python3 -V
$> yum update
$> yum groupinstall "Development Tools"
$> sudo yum install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel findutils git
$> sudo yum install glibc.i686 glibc-devel.i686 libgcc.i686 libstdc++-devel.i686 ncurses-devel.i686 libstdc++-devel.i686 zlib-devel.i686 bzip2-devel.i686 readline-devel.i686 sqlite-devel.i686 openssl-devel.i686 xz-devel.i686 libffi-devel.i686
$> curl https://pyenv.run | bash
$> # follow instructions
$> env PYTHON_CONFIGURE_OPTS="--enable-shared" CC="gcc -m32" CFLAGS="-m32" LDFLAGS="-m32" pyenv install 3.11.3
$> env pyenv global 3.11.3
$> # install cocotb
$> CFLAGS="-I/usr/include/c++/4.8.5/i686-redhat-linux" pip3 install cocotb # you may need to adjust the path
This approach has been known to not work! Instead, please use Windows Subsystem for Linux and follow the normal installation instructions for Linux.
-
Download and install MSYS2 from https://www.msys2.org.
-
Start mingw32/64.exe from MSYS2 installation directory.
-
Update msys:
$> pacman -Syu
-
Installed needed packages:
-
For 32-bit version:
$> Pacman -S --needed make mingw-w64-i686-gcc mingw-w64-i686-python3-pip mingw-w64-i686-python3-setuptools mingw-w64-i686-python3-wheel
-
For 64-bit version:
$> pacman -S --needed make mingw-w64-x86_64-gcc mingw-w64-x86_64-python3-pip mingw-w64-x86_64-python3-setuptools mingw-w64-x86_64-python3-wheel
-
-
Install cocotb:
-
stable version:
$> pip3 install --no-build-isolation cocotb
-
development version:
$> pip3 install --no-build-isolation https://github.com/cocotb/cocotb/archive/master.zip
-
-
[Optional] Install simulators:
-
For 32-bit version:
$> pacman -S --needed mingw-w64-i686-iverilog mingw-w64-i686-ghdl mingw-w64-i686-verilator
-
For 64-bit version:
$> pacman -S --needed mingw-w64-x86_64-iverilog mingw-w64-x86_64-ghdl mingw-w64-x86_64-verilator
-
To get the cocotb working with Riviera-PRO 32-bit you have to provide additional steps:
-
Follow the official guide at http://cocotb.readthedocs.io/
-
Execute the endian_swapper example with additional ARCH switch:
cd cocotb/examples/endian_swapper/tests make SIM=aldec ARCH=i686 TOP_LEVEL=VHDL GUI=1
- As a result libvhpi.dll is generated but Riviera-PRO simulation ends with warning:
-
PLI: Loading library 'libvhpi.dll' PLI: Cannot load the "libvhpi.dll" library. The library does not exist or is corrupted. PLI: The specified procedure could not be found.
The libvhpi.dll exists so the problem is caused rather by some not linked procedures.
Workaround:
-
Set the Riviera-PRO/bin paths as a first one at Windows System PATH environment variable.
-
Execute Riviera-PRO directly from Windows (without installed mingw/msys environment)
-
Set the 'usr' and 'pyt' paths and then recompile all dll files using gcc from Riviera-PRO distribution. Just execute following script in Riviera-PRO console:
set usr "D:/MinGW/msys/1.0/home/user"
set pyt "D:/Python27"
cd $usr/cocotb/cocotb/share/lib/utils
gcc -m32 -g -DDEBUG -shared -DALDEC -c -I$usr/cocotb/cocotb/share/include -I$pyt\include -o $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/cocotb_utils.o cocotb_utils.c
gcc -m32 -g -DDEBUG -shared -DALDEC -shared -Wl,-no-undefined -Wl,-enable-runtime-pseudo-reloc-v2 -Wl,--enable-auto-import -L/d/Python27/libs -o $usr/cocotb/examples/endian_swapper/tests/build/libs/i686/libcocotbutils.dll $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/cocotb_utils.o
cd $usr/cocotb/cocotb/share/lib/embed
gcc -m32 -g -DDEBUG -shared -DPYTHON_SO_LIB=Python27.dll -DALDEC -c -I$usr/cocotb/cocotb/share//include -I$pyt/include -o $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/gpi_embed.o gpi_embed.c
gcc -m32 -g -DDEBUG -shared -DPYTHON_SO_LIB=Python27.dll -DALDEC -shared -Wl,-no-undefined -Wl,-enable-runtime-pseudo-reloc-v2 -Wl,--enable-auto-import -L$pyt/libs -o $usr/cocotb/examples/endian_swapper/tests/build/libs/i686/libcocotb.dll $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/gpi_embed.o -lPython27 -lgpilog -lcocotbutils -L$usr/cocotb/examples/endian_swapper/tests/build/libs/i686
cd $usr/cocotb/cocotb/share/lib/gpi
g++ -m32 -g -DDEBUG -shared -DVPI_CHECKING -DLIB_EXT=dll -DSINGLETON_HANDLES -DALDEC -c -I$usr/cocotb/cocotb/share//include -I$pyt\include -o $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/GpiCbHdl.o GpiCbHdl.cpp
g++ -m32 -g -DDEBUG -shared -DVPI_CHECKING -DLIB_EXT=dll -DSINGLETON_HANDLES -DALDEC -c -I$usr/cocotb/cocotb/share//include -I$pyt\include -o $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/GpiCommon.o GpiCommon.cpp
gcc -m32 -g -DDEBUG -shared -DALDEC -shared -Wl,-no-undefined -Wl,-enable-runtime-pseudo-reloc-v2 -Wl,--enable-auto-import -L/d/Python27/libs -o $usr/cocotb/examples/endian_swapper/tests/build/libs/i686/libgpi.dll $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/GpiCbHdl.o $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/GpiCommon.o -lcocotbutils -lgpilog -lcocotb -lstdc++ -L$usr/cocotb/examples/endian_swapper/tests/build/libs/i686
cd $usr/cocotb/cocotb/share/lib/simulator
gcc -m32 -g -DDEBUG -shared -DALDEC -c -I$usr/cocotb/cocotb/share//include -I$pyt/include -o $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/simulatormodule.o simulatormodule.c
gcc -m32 -g -DDEBUG -shared -DALDEC -shared -Wl,-no-undefined -Wl,-enable-runtime-pseudo-reloc-v2 -Wl,--enable-auto-import -L$pyt/libs -o $usr/cocotb/examples/endian_swapper/tests/build/libs/i686/libsim.dll $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/simulatormodule.o -lcocotbutils -lgpi -lgpilog -lPython27 -L$usr/cocotb/examples/endian_swapper/tests/build/libs/i686 #ln -sf libsim.dll $usr/cocotb/examples/endian_swapper/tests/build/libs/i686/simulator.pyd
cd $usr/cocotb/cocotb/share/lib/vhpi
g++ -m32 -g -DDEBUG -shared -DVHPI_CHECKING -DALDEC -c -I$usr/cocotb/cocotb/share//include -I$pyt\include -o $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/VhpiImpl.o VhpiImpl.cpp
g++ -m32 -g -DDEBUG -shared -DVHPI_CHECKING -DALDEC -c -I$usr/cocotb/cocotb/share//include -I$pyt\include -o $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/VhpiCbHdl.o VhpiCbHdl.cpp
gcc -m32 -g -DDEBUG -shared -DALDEC -shared -Wl,-no-undefined -Wl,-enable-runtime-pseudo-reloc-v2 -Wl,--enable-auto-import -L$pyt/libs -o $usr/cocotb/examples/endian_swapper/tests/build/libs/i686/libvhpi.dll $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/VhpiImpl.o $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/VhpiCbHdl.o -laldecpli -lgpilog -lgpi -lstdc++ -L$aldec/bin -L$usr/cocotb/examples/endian_swapper/tests/build/libs/i686
cd $usr/cocotb/cocotb/share/lib/vpi
g++ -m32 -g -DDEBUG -shared -DVPI_CHECKING -DALDEC -c -I$usr/cocotb/cocotb/share//include -I$pyt\include -o $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/VpiImpl.o VpiImpl.cpp
g++ -m32 -g -DDEBUG -shared -DVPI_CHECKING -DALDEC -c -I$usr/cocotb/cocotb/share//include -I$pyt\include -o $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/VpiCbHdl.o VpiCbHdl.cpp
gcc -m32 -g -DDEBUG -shared -DALDEC -shared -Wl,-no-undefined -Wl,-enable-runtime-pseudo-reloc-v2 -Wl,--enable-auto-import -L$pyt/libs -o $usr/cocotb/examples/endian_swapper/tests/build/libs/i686/libvpi.dll $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/VpiImpl.o $usr/cocotb/examples/endian_swapper/tests/build/obj/i686/VpiCbHdl.o -laldecpli -lgpilog -lgpi -lstdc++ -L$aldec/bin -L$usr/cocotb/examples/endian_swapper/tests/build/libs/i686
- start endian_swapper example once more under mingw/msys:
cd cocotb/examples/endian_swapper/tests
make SIM=aldec ARCH=i686 TOP_LEVEL=VHDL GUI=1
Verified at Windows 10 64-bit and Riviera-PRO version 2019.04.134.7332 built for Windows on May 10, 2019.
If you find yourself wanting to use cocotb on a computer that does not have unrestricted access to the internet, for instance you are behind a corporate firewall or working on a closed network, you can still install cocotb with a few additional steps.
Install the pre-requisites for your OS as described in the installation section of the documentation (https://docs.cocotb.org/en/stable/install.html#installation-of-prerequisites). You might have to work with your IT department to get the prerequisites installed on your system.
The easiest way to install cocotb at this point is using a snapshot (or the full history via a clone) of the repo. There is one hitch:
cd cocotb
pip install --no-build-isolation .
Without the --no-build-isolation
flag, pip
will attempt to download build prerequisites freshly for build isolation, likely leading to a failure to install.
cocotb 1.5.X depends on setuptools_scm and cocotb-bus, if you do not have these dependencies you can remove them by using the following short patch.
diff --git a/cocotb/_version.py b/cocotb/_version.py
new file mode 100644
index 00000000..ff42969a
--- /dev/null
+++ b/cocotb/_version.py
@@ -0,0 +1 @@
+__version__="1.5.1"
diff --git a/setup.py b/setup.py
index a9d4e188..96514270 100755
--- a/setup.py
+++ b/setup.py
@@ -84,11 +84,7 @@ log.addHandler(handler)
setup(
name='cocotb',
cmdclass={'build_ext': build_ext},
- use_scm_version=dict(
- write_to='cocotb/_version.py',
- write_to_template='__version__ = {version!r}',
- version_scheme='release-branch-semver'
- ),
+ version="1.5.1",
description='cocotb is a coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python.',
url='https://docs.cocotb.org',
license='BSD',
@@ -97,8 +93,8 @@ setup(
author='Chris Higgs, Stuart Hodgson',
maintainer='cocotb contributors',
maintainer_email='[email protected]',
- setup_requires=['setuptools_scm'],
- install_requires=['cocotb-bus<1.0'],
+ setup_requires=[],
+ install_requires=[],
python_requires='>=3.5',
packages=find_packages(),
package_data={