domingo, 9 de fevereiro de 2014

Install Verilator from sources

Prerequisites

This guide pretends to contain a summary of the necessary steps to complete a Verilator instalation from sources with also verilog-perl, SystemPerl and SystemC so coverage metrics can be extracted from a system simulation.
If you don't need those you can just use the packed binary from debian repo. It may also be usefull to install Gtkwave which is used to load the VCD files, in case you want take a look at some wave traces.

First let's start to install the necessary packages from the Debian repository:
:~$ sudo apt-get install bison flex autoconf build-essential perl g++ gtkwave

Install SystemC

Go to Accellera and download the SystemC 2.3.0 (now the file extension matches the file format). To compile all the needed software we will create a folder named softwr inside our home folder ~ . To install SystemC we will uncompress the file, create a directory to where it will be installed, configure and install.
:~$ mkdir softwr
:~$ mv Downloads/systemc-2.3.0.tgz softwr/.
:~$ cd softwr
:~/softwr$ tar -xzf systemc-2.3.0.tgz
:~/softwr$ cd systemc-2.3.0
:~/softwr/systemc-2.3.0$ mkdir objdir
:~/softwr/systemc-2.3.0$ cd objdir
:~/softwr/systemc-2.3.0/objdir$ sudo mkdir /usr/local/systemc-2.3.0
:~/softwr/systemc-2.3.0/objdir$ ../configure --prefix=/usr/local/systemc-2.3.0 --disable-shared
:~/softwr/systemc-2.3.0/objdir$ make 
:~/softwr/systemc-2.3.0/objdir$ sudo make install

Install Verilog-Perl

To install Verilog-Perl we will fetch the source code from veripool git repository.
:~/softwr/systemc-2.3.0/objdir$ cd ../../
:~/softwr$ git clone http://git.veripool.org/git/Verilog-Perl
:~/softwr$ cd Verilog-Perl 
:~/softwr/Verilog-Perl$ git pull 
Already up-to-date.
:~/softwr/Verilog-Perl$ git tag 
:~/softwr/Verilog-Perl$ perl Makefile.PL 
-Note: If building from 'git' sources (not from a CPAN tar file),
-Note: ignore any 'files are missing' below for */gen/ and README:
Checking if your kit is complete...
Warning: the following files are missing in your kit:
(...)
:~/softwr/Verilog-Perl$ make
(...)
:~/softwr/Verilog-Perl$ make test
(...)
t/86_vhier_tick.t .... ok 
All tests successful.
Files=32, Tests=419, 12 wallclock secs ( 0.25 usr  0.06 sys + 10.12 cusr  0.91 csys = 11.34 CPU)
Result: PASS
:~/softwr/Verilog-Perl$ sudo make install
Now let's add the following to .bashrc:
# SystemC 2.3.0
export SYSTEMC=/usr/local/systemc-2.3.0/
export SYSTEMC_INCLUDE=/usr/local/systemc-2.3.0/include/
export SYSTEMC_LIBDIR=/usr/local/systemc-2.3.0/lib-linux64/
export SYSTEMC_CXX_FLAGS=-pthread
Note: Do not add the SystemC lib path to LD_LIBRARY_PATH as we are using static lib. Let's finish this step by sourcing the new bashrc configuration.
:~/softwr/Verilog-Perl$ source ~/.bashrc

Install SystemPerl

To install SystemPerl we will also fetch the source code from veripool git repository.
:~/softwr/Verilog-Perl$ cd ..
:~/softwr$ git clone http://git.veripool.org/git/SystemPerl
:~/softwr$ cd SystemPerl
:~/softwr/SystemPerl$ git pull
Already up-to-date.
:~/softwr/SystemPerl$ git tag
:~/softwr/SystemPerl$ perl Makefile.PL
(...)
:~/softwr/SystemPerl$ make
:~/softwr/SystemPerl$ make test
...
All tests successful.
Files=19, Tests=167, 19 wallclock secs ( 0.13 usr  0.05 sys + 27.29 cusr  2.13 csys = 29.60 CPU)
Result: PASS
:~/softwr/SystemPerl$ sudo make install
Note: If make test fails, try calling with VERILATOR_AUTHOR_SITE=1 make test .
After we will have to add SystemPerl to the path. Add the following to .bashrc:
#SystemPerl
export SYSTEMPERL=/usr/local/bin/
export SYSTEMPERL_INCLUDE=/home/yourhomedir/softwr/SystemPerl/src
Now source bashrc again:
:~/softwr/SystemPerl$ source ~/.bashrc

Install Verilator

:~/softwr/SystemPerl$ cd ..
:~/softwr$ git clone http://git.veripool.org/git/verilator
:~/softwr$ cd verilator
:~/softwr/verilator$ git pull
Already up-to-date.
:~/softwr/verilator$ git tag
:~/softwr/verilator$ autoconf
(...)
:~/softwr/verilator$ unset VERILATOR_ROOT
(...)
:~/softwr/verilator$ ./configure
:~/softwr/verilator$ make
:~/softwr/verilator$ make test
(...)
Total coverage (72/146) 49.32%
See lines with '' in logs/coverage_source
(...)
:~/softwr/verilatorl$ sudo make install
Now add verilator root to the path. Add the following to .bashrc:
#Verilator
export VERILATOR_ROOT=/home/yourdir/softwr/verilator
Source bashrc.
:~/softwr/verilator$ source ~/.bashrc
And it is done!

Sources:
Verilator Installation Guide
Verilator Manual

quarta-feira, 1 de maio de 2013

Install Xilinx USB Cable Drivers 14.7 on Debian GNU/Linux Wheezy

For this installation we will not use the provided setup_usb script from Xilinx, because it makes the installation of the scripts in /etc/hotplug which were substituted by udev.
To start let us install the following packages
apt-get install fxload libusb-0.1-4 libusb-dev

After this take a look at the rules file provided by xilinx
cat /opt/Xilinx/14.7/ISE_DS/common/bin/lin64/xusbdfwu.rules

# version 0003
SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0008", MODE="666"
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0007", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusbdfwu.hex -D $TEMPNODE"
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0009", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xup.hex -D $TEMPNODE"
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="000d", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_emb.hex -D $TEMPNODE"
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="000f", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xlp.hex -D $TEMPNODE"
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0013", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xp2.hex -D $TEMPNODE"
BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0015", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xse.hex -D $TEMPNODE"
As for the rules for rules file creation, i created a copy of the which consisted, on removing BUS=="usb , replacing SYSFS by ATTRS and $TEMPNODE by $tempnode. To do this let's use sed:
sed /opt/Xilinx/14.7/ISE_DS/common/bin/lin64/xusbdfwu.rules -e 's:BUS=="usb", ::g' -e 's:SYSFS:ATTRS:g' -e 's:TEMPNODE:tempnode:g' > /etc/udev/rules.d/xusbdfwu.rules
Now let's copy the usb firmware to the expected location (/usr/share), so udev can load the appropriate firmware to the device.
cp /opt/Xilinx/14.7/ISE_DS/common/bin/lin64/xusb*.hex /usr/share/
Let's restart udev.
/etc/init.d/udev restart
Now connect your device to the computer. If everything went okay the device enumeration should go this way:
kernel: [36003.892056] usb 2-1: new high-speed USB device number 4 using ehci_hcd
kernel: [36004.024493] usb 2-1: New USB device found, idVendor=03fd, idProduct=000d
kernel: [36004.024499] usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
kernel: [36004.084649] usb 2-1: USB disconnect, device number 4
kernel: [36006.272080] usb 4-1: new full-speed USB device number 3 using uhci_hcd
kernel: [36006.411949] usb 4-1: not running at top speed; connect to a high speed hub
kernel: [36006.433946] usb 4-1: New USB device found, idVendor=03fd, idProduct=0008
kernel: [36006.433952] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
kernel: [36006.433956] usb 4-1: Product: XILINX    
kernel: [36006.433959] usb 4-1: Manufacturer: XILINX 
kernel: [36009.256112] usb 4-1: USB disconnect, device number 3
kernel: [36010.812067] usb 2-1: new high-speed USB device number 6 using ehci_hcd
kernel: [36010.944863] usb 2-1: New USB device found, idVendor=03fd, idProduct=0008
kernel: [36010.944869] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
kernel: [36010.944874] usb 2-1: Product: XILINX    
kernel: [36010.944877] usb 2-1: Manufacturer: XILINX 
What happens is that after the device is enumerated the udev loads the firmware into it through fxload, after that it gets enumerated and then it restarts it.So just after the second disconnect (third enumeration) the device is ready to used.
You will also need to create a link for the shared library, because impact will search for libusb in /usr/lib64/ and the libusb is installed on /usr/lib/x86_64-linux-gnu/
cd /usr/lib64/
ln -s ../lib/x86_64-linux-gnu/libusb-0.1.so.4 libusb.so
i also corrected the package names.

quinta-feira, 21 de março de 2013

Step by step guide to install Xilinx 14.7 on Debian GNU/Linux Wheezy

Installation performed on Debian wheezy

Download Xilinx_ISE_DS_Lin_14.7_1015_1.tar from Xilinx website.
Perform the following steps.
tar -xf Xilinx_ISE_DS_Lin_14.7_1015_1.tar 
cd Xilinx_ISE_DS_Lin_14.7_1015_1/
sudo ./xsetup

The installation is very easy, install everything under /opt.
To set the enviroment variables let's edit the ~/.bashrc and add the following at the end.
##Definições Xilinx
export LM_LICENSE_FILE="PORT@IP"
In this case i set the LM_LICENSE_FILE on the .bashrc because i am using a floating license, and in linux i can't use the xilinx license manager(xlcm) to set this variable(you can in windows). If you use a license file you can still use the xilinx license configuration manager.
when you want to run xps, ise or chipscope , or others, before run (Sh,Bash, ksh):
source /opt/Xilinx/14.7/ISE_DS/settings64.sh
There is a alternate version of script for c-shell in the same folder.
I am using settings64.sh since i am using a 64 bit OS, case you are using a 32 bit OS, use settings32.sh