Пример #1
0
sys.path.append("../..")
sys.path.append("..")

import udmalib.udma as udma
from ponq import Ponq
import cv2, numpy as np

# bit hacking functions for driving unit
fixpfactor = 1 << 29
int32max = (1 << 32) - 1
def float2fix(value): return int(value * fixpfactor)
def top32(data): return int((data >> 32) & int32max)
def bot32(data): return int(data & int32max)

# load udma buffer for hardware use
udmarepo = udma.udmas()
udmadev = udmarepo.getDevice(0)
ubuf = udmadev.map()
  
# hardware module parameters
udma_addy = udmadev.phys_addr

items = 1024
size = items*4

buf0addr = udmadev.phys_addr
buf1addr = udmadev.phys_addr + size
buf2addr = udmadev.phys_addr + 2*size


for i in range(items):
Пример #2
0
def top32(data):
    return int((data >> 32) & int32max)


def bot32(data):
    return int(data & int32max)


if len(sys.argv) != 3:
    print("Invalid arguments")
    print("\tUsage: " + sys.argv[0] + " input output")
    sys.exit(-1)

# allocate a buffer
ubuffers = udma.udmas()
fpga_rpc = fpga_rpc_client.Client()
bufno = fpga_rpc.Alloc()
if (bufno < 0): raise "could not allocate buffers"
ubuffer = ubuffers.getDevice(bufno)
buffer = ubuffer.map()

# read in images
input = cv2.imread(sys.argv[1], cv2.IMREAD_GRAYSCALE)
height = input.shape[0]
width = input.shape[1]
size = width * height

# calculate pointers
buf0addr = ubuffer.phys_addr
buf1addr = ubuffer.phys_addr + size