Fixpoint Controller Simulation

We already have a working and well tested plecs standalone simulation model. As a next step we would like to transform the control logic from plecs model into VHDL code for hardware implementation. There is no floating point unit on the FPGA available - the final controller must be of fixedpoint form. Is there any way to simulate a fixed point control logic?

Our first idea:

Write some script that implements the controller. For example a python script relying on https://pypi.org/project/pyPhix/ for fixed point operations.Run this python script using the “DLL” block that can be found under Library browser -> Control -> Functions & Tables.Unfortunately we did not get this DLL block to execute any python code at all. The manual only explains the inclusion of C/C++. We could not find a MWE in python so far.Last step would be to transfer from python script to VHDL. This is fairly easy once all fixedpoint number format are known.Any suggestions are warmly welcome!

Hi,

Unfortunately only DLLs using C and C++ are officially supported in PLECS. Googling gives a few option that you could try, but again this is fully experimental and not officially supported/tested by the Plexim developers.

  1. Implement the fixed-point control algorithm in C using the FixMath library (http://www.nongnu.org/fixmath/doc/index.html)
  2. Embed python into C, see e.g. https://docs.python.org/2/extending/embedding.html or https://www6.software.ibm.com/developerworks/education/l-pythonscript/l-pythonscript-ltr.pdf
  3. It might be possible to create a dll from Python using Cython (see https://cython.org/#about or https://docs.python.org/3/faq/windows.html#is-a-pyd-file-the-same-as-a-dll)

Best regards,
NF