FiC library2 by nyacom kzh@nyacom.net
The library inspirated by original ficlib by hunga-san.
NOTE: Due to support both mk1 and mk2 boards, API names has changed (Remove bitwidth from API calls).
- FiC Library 2
- Build
- APIs
- Python bindings
- FAQ
- pyficprog.py
To build ficlib2, you should do for preparation on your Raspbian.
sudo apt install gcc make python3-dev
then make clean && make at ficlib2 directory.
make clean && make
after compilation, you will get ficlib2 and pyficlib2.so
pyficlib2.so is a python binding version of ficlib2. (please refer pyficlibtest.py for an example.)
- Open GPIO and creates LOCKFILE
- return is LOCKFILE fd
- return -1 is error
- Close GPIO and removes LOCKFILE
- return -1 is error
- Probe PW_OK signal from FiC board
- Probe DONE singal from FPGA
- Reset FiC I/O interface
- Program FiC FPGA by SelectMap x16 mode
- PROG_MODE is reset PROG_NORMAL or PROG_PR (Partial reconfiguration)
- Progress can observe by *tx
- return == -1 is error
- Program FiC FPGA by SelectMap x8 mode
- PROG_MODE is reset PROG_NORMAL or PROG_PR (Partial reconfiguration)
- Progress can observe by *tx
- return == -1 is error
- Invoke FPGA init (Reset FPGA)
Note: The interface available after FiCSW FPGA programmed.
- Write single byte data via fic 4bit interface.
- return -1 is error.
- Read single byte from addr to *buf via fic 8bit interface.
- return -1 is error.
Note: The interface available after FiCSW FPGA programmed.
- Send reset HLS reset command
- Send reset HLS start command
- Send size bytes of *data to the HLS module via 4bit interface
- All data is masked with 0x0f (so that only lower 4bit is valid)
- return -1 is error
- Receive size bytes of *data from HLS module via 4bit interface
- return -1 and buf == NULL is error.
- Write to data to DDR module
- Size and addr must be aligned to 4B (32bit)
- Read data from DDR module
- Size and addr must be aligned to 4B (32bit)
pyficlib2 is a python bindings of ficlib2.
Import pyficlib like below
import pyficlib2 as fic
...
fic.gpio_open()
-- do something --
fic.gpio_close()
- Wrap function of fic_gpio_open()
- Wrap function of fic_gpio_close()
- Wrap funcion of fic_prog_sm16
- progmode = 0 is Normal FPGA prog mode
- progmode = 1 is Normal PR FPGA prog mode
- return is transfered bytes
- Wrap funcion of fic_prog_sm8
- progmode = 0 is Normal FPGA prog mode
- progmode = 1 is Normal PR FPGA prog mode
- return is transfered bytes
Get trasnfered byte while prog_sm16 or prog_sm8
- Wrap function of fic_prog_init
- Init FPGA and erase configuration
- Wrap function of fic_read
- addr is 16bit address value
- return is single 8bit or 16bit value at addr
- Wrap function of fic_write
- addr is 16bit address value
- data is data value
- Wrap function of fic_hls_reset
- Send HLS reset CMD
- Wrap function of fic_hls_start4
- Send HLS start CMD via 4bit I/F
- Wrap function of fic_hls_send
- data is python bytes
- NOT WELL TESTED
- Wrap function of fic_hls_receive
- Read count of data from HLS module
- Return is bytes
- NOT WELL TESTED
To prevent confilicted GPIO manupulation, the library uses LOCKFILE to prevent confliction. This file will be creating /tmp/gpio.lock
An alternative ficprog utility using libfic2.
You can configure FPGA on RPi3 like follows:
nyacom@m2fic12:~/project/fic/libfic2$ ./pyficprog.py -h
usage: pyficprog.py [-h] [-m [{8,16}]] [-pr] bitfile
positional arguments:
bitfile FPGA configuration *.bit
optional arguments:
-h, --help show this help message and exit
-m [{8,16}], --mode [{8,16}]
Select map mode
-pr, --partial Partial reconfigure mode
nyacom@m2fic12:~/project/fic/libfic2$ ./pyficprog.py -m16 ../fpga/mk2virt4x4/fic_top_sm16.bin
pyficprog FiC FPGA configuration utility /\/\
by nyacom 2019 (C) <kzh@nyacom.net> =(____)=
------------------------------------------------U--U--------
INFO: Program mode: Selectmap 16
INFO: Partial mode: False
INFO: Open file ../fpga/mk2virt4x4/fic_top_sm16.bin
INFO: Bitstream is loaded 48251520B
INFO: RP_CFSEL is set for FiC Mark2 board
INFO: RP_CFSEL is set for FiC Mark2 board
Transfer 5217302 / 48251520 [10.81 %]
Transfer 11549474 / 48251520 [23.94 %]
Transfer 17871662 / 48251520 [37.04 %]
Transfer 24191372 / 48251520 [50.14 %]
Transfer 30519058 / 48251520 [63.25 %]
Transfer 36846288 / 48251520 [76.36 %]
Transfer 43177604 / 48251520 [89.48 %]
DEBUG: Waiting for RP_DONE
DEBUG: RP_DONE
INFO: FPGA configuration done