hardware_fpga.rst 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. pyprofibus FPGA PHY documentation
  2. =================================
  3. Instead of using the serial port of the host computer to connect to the Profibus network an FPGA can be used. That improves the realtime capabilities and the speed of the pyprofibus system.
  4. FPGA boards
  5. ===========
  6. Currently only the `TinyFPGA BX <https://tinyfpga.com/>`_ is supported as FPGA.
  7. However it's possible to add support for other FPGAs. The TinyFPGA BX has been chosen, because it has a fully Open Source toolchain. So the pyprofibus FPGA Verilog sources can be translated to the binary FPGA bitstream using only freely available tools.
  8. The pyprofibus releases come with pre-built bitstream images. So there's no need for the user to install the toolchain and build the FPGA bitstream. The only tool that is needed is the "flashing/programming tool" that is used to transfer the binary bitstream to the FPGA board.
  9. Flashing / Programming tool
  10. ---------------------------
  11. For the purpose of writing/downloading/flashing the binary FPGA bitstream to the TinyFPGA BX board the `tinyprog <https://github.com/tinyfpga/TinyFPGA-Bootloader/>`_ tool can be used.
  12. The helper script `tinyfpga_bx_program.sh` shipped with pyprofibus in the subdirectory `phy_fpga/bin/tinyfpga_bx` can be used to conveniently call `tinyprog` with the correct parameters. Just connect the TinyFPGA BX board via USB to the computer and run the `tinyfpga_bx_program.sh` script. It does everything to program the pyprofibus PHY to your TinyFPGA BX.
  13. Build toolchain
  14. ---------------
  15. If you want to modify the FPGA sources and build your own version of the FPGA bitstream, the following tools are required:
  16. Project IceStorm
  17. ~~~~~~~~~~~~~~~~
  18. The `Project IceStorm <http://bygone.clairexen.net/icestorm/>`_ is needed to build the bitstream for the TinyFPGA BX board.
  19. Yosys
  20. ~~~~~
  21. The `Yosys Open SYnthesis Suite <https://yosyshq.net/yosys/>`_ is required to synthesize the Verilog sources.
  22. nextpnr
  23. ~~~~~~~
  24. The `nextpnr FPGA place and route tool <https://github.com/YosysHQ/nextpnr>`_ is required for FPGA routing.
  25. Python
  26. ~~~~~~
  27. `Python 3.7 <https://www.python.org/>`_ or later is required to auto-generate some parts of the sources.
  28. GNU make an other standard GNU/Linux shell utilities
  29. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  30. `GNU make <https://www.gnu.org/software/make/>`_ and various other standard GNU/Linux shell utilities, that are already installed on any Desktop Linux distribution. Building on Windows is not supported.
  31. Downloading and installing all toolchain tools
  32. ----------------------------------------------
  33. The script `build_fpga_toolchain.sh` that is included in the pyprofibus archive can be used to download, build and install all FPGA toolchain tools to the `$HOME` directory.
  34. Just run the script as follows. It will download all required packages, build and install everything to `$HOME/fpga-toolchain` by default.
  35. .. code:: sh
  36. cd phy_fpga/fpgamakelib
  37. ./build_fpga_toolchain.sh
  38. After successful execution of `build_fpga_toolchain.sh` please read the information about `$PATH` that the script prints to the console. The line printed by the script shall be added to your `$HOME/.bashrc`
  39. No changes to the operating system are necessary. Do *not* run `build_fpga_toolchain.sh` as root.
  40. The toolchain can be uninstalled by simply deleting the directory `$HOME/fpga-toolchain`
  41. Building pyprofibus PHY-FPGA
  42. ----------------------------
  43. To build the PHY-FPGA sources run the following commands:
  44. .. code:: sh
  45. cd phy_fpga
  46. make clean
  47. make