-
Notifications
You must be signed in to change notification settings - Fork 43
Home
casperfpga
is a python library used to interact and interface with CASPER Hardware. Functionality includes being able to reconfigure firmware, as well as read and write registers across the various communication interfaces.
This wiki builds on the following points mentioned in the README, and expands on the methods and utilities exposed to the end user:
From commit a5e7dcc
and earlier the method of instantiating e.g. a SKARAB object was as follows:
In [1]: import casperfpga
In [2]: skarab = casperfpga.SkarabFpga('skarab010103')
In [3]: roach = casperfpga.katcp_fpga.KatcpFpga('roach020203')
As of commit 4adffc0
the method of instantiating a ROACH or SKARAB was altered to be done intelligently. casperfpga
automatically works out whether the parameter given in its instantiation is a SKARAB or ROACH board.
In [1]: import casperfpga
In [2]: skarab = casperfpga.CasperFpga('skarab010103')
DEBUG:root:skarab010103 seems to be a SKARAB
INFO:casperfpga.transport_skarab:skarab010103: port(30584) created & connected.
DEBUG:root:casperfpga.casperfpga:skarab010103: now a CasperFpga
In [3]: roach = casperfpga.CasperFpga('roach020203')
DEBUG:root:roach020203 seems to be a ROACH
INFO:casperfpga.transport_katcp:roach020203: port(7147) created and connected.
DEBUG:root:casperfpga.casperfpga:roach020203: now a CasperFpga
There are a number of prerequisites required for the casperfpga package.
$ sudo apt-get install python-pip
$ sudo pip install ply tornado futures futures unittest2 mock ProxyTypes numpy
$ # mock might give some warnings, they are not critical and can be ignored.
Then clone the casperfpga repository. The master branch is home to the latest, most stable build of casperfpga.
$ git clone https://github.com/ska-sa/casperfpga.git
$ cd casperfpga
$ sudo python setup.py install
[sudo] password for user:
*
To check that casperfpga has been installed correctly open an ipython session and import casperfpga.
$ ipython
*
In [1]: import casperfpga
*
If you receive any errors after this please feel free to contact anyone on the CASPER Mailing List, or check the Mailing List Archive to see if your issue has been resolved already.
The introductory tutorials for ROACH, ROACH2 and SKARAB serve as a guide to the entire process of:
- Creating an FPGA design in Simulink using the CASPER and Xilinx Blocksets
- Building the design using the toolflow, and lastly
- Reconfiguring your SKARAB board with the generated .fpg file
casperfpga
is written in python and mainly used to communicate with CASPER Hardware and reconfigure it's firmware. Hence the medium of communication is usually done through an ipython session, as shown below:
import casperfpga
fpga = casperfpga.CasperFpga('skarab_host or roach_name')
fpga.upload_to_ram_and_program('your_file.fpg')
It is also worth noting at this moment that existing ROACH/2 users are familiar with the generated .bof files being stored on the ROACH's Network File System (NFS). This however is not the case with SKARAB, where an fpg file is stored on and programmed/uploaded from the client-side.
This in turn means that if you connect to a board and want to find out what registers are available to you, you would need the fpg file that was written to it in order to parse the information again (and access via fpga.listdev()). This is because the Register-Memory Mapping is not stored on the SKARAB, and is kept local to the ipython session in which it was last programmed/reconfigured.
The methods described here are part of the casperfpga
transport layer, and are common to CASPER Hardware unless otherwise specified. The descriptions below aim to clarify implementation of commonly-used methods, and assumes the following:
- You are working on a machine that has casperfpga and its associated requirements installed
- You are working on a machine that supports an interactive python (ipython) session
- You are in an ipython session and have imported casperfpga, as described above
In [1]: import casperfpga
In [2]: fpga = casperfpga.CasperFpga('skarab_host or roach_name')
*
In the case of reconfiguring SKARAB firmware, ensure that the fpg file is in the on the machine/server that is connected to your SKARAB.
In [3]: filename = 'your_file.fpg'
In [4]: fpga.upload_to_ram_and_program(filename)
*
In [5]: fpga.estimate_clock_speed()
*
Fork this repo, add your changes and issue a pull request.