Home

Awesome

PyLog

PyLog: An Algorithm-Centric FPGA Programming and Synthesis Flow

Test Environment

Getting Started

Setting paths

Before running PyLog, please add the path to your PyLog directory to PYTHONPATH. You can add the following line into your ~/.bashrc file:

export PYTHONPATH=/your/path/to/pylog:$PYTHONPATH

Also, please modify the paths at the beginning the following files:

PyLog usage

To use PyLog, import pylog and simply add PyLog decorator @pylog to the function that you'd like to synthesize into an FPGA accelerator. Pass NumPy arrays to the decorated function and call the decorated function. Then run the whole Python program. In the following example, vecadd function will be compiled into HLS C code by PyLog.

import numpy as np
from pylog import *

@pylog
def vecadd(a, b, c):
    for i in range(1024):
        c[i] = a[i] + b[i]
    return 0

if __name__ == "__main__":
    length = 1024
    a = np.random.rand(length).astype(np.float32)
    b = np.random.rand(length).astype(np.float32)
    c = np.random.rand(length).astype(np.float32)
    
    vecadd(a, b, c)

You can also pass arguments to @pylog decorator to control the behavior of PyLog. The following arguments can be passed to @pylog:

Here is one example of configuring PyLog:

@pylog(mode='deploy', board='pynq-z2')

In this example, PyLog will run in deploy mode, targeting PYNQ board (implying the current program is running on a PYNQ board).

Tests

Example PyLog code can be found under tests. To run a test, simply run it as a regular Python script:

python tests/matmul.py