Example #1
0
def main():
    global restart

    # download overlay
    overlay = pynq.Overlay("./overlay/top.bit")
    pprint(overlay.ip_dict)

    # init dma_sg controller
    dma_pl2ps_description = overlay.ip_dict['axi_dma_write']
    dma_pl2ps = DMA_SG(dma_pl2ps_description)
    # init AXIGPIO controller
    axi_transmit_intr_description = overlay.ip_dict['axi_transmit_intr']
    axi_transmit_intr = AxiGPIO(axi_transmit_intr_description)
    axi_transmit_intr.setlength(1, channel=1)
    axi_transmit_intr.setdirection(AxiGPIO.Input, channel=1)
    pprint(axi_transmit_intr.channel1[0])

    # start reveiver channel
    buffer = dma_pl2ps.recvchannel.transferS2MM(data_size, restart=restart)
    restart = 0
    pprint("Ready to transmit!")

    # end-less loop
    while True:
        # wait AXIGPIO to be 1, enable the transmit
        axi_transmit_intr.channel1[0].wait_for_value(1)
        tools.print_descriptor_attr(dma_pl2ps.recvchannel.descriptor[0])
        tools.print_dma_status(dma_pl2ps)
        tools.print_buffer(buffer)
        buffer = dma_pl2ps.recvchannel.transferS2MM(data_size, restart=restart)
        # wait AXIGPIO to be 0, start next transmit
        axi_transmit_intr.channel1[0].wait_for_value(0)
def setup_accelerator(xclbin, wfile):
    ol = pynq.Overlay(xclbin)

    fcweights = np.genfromtxt(wfile, delimiter=',', dtype=np.int8)
    fcbuf = pynq.allocate((1000, 2048), dtype=np.int8, target=ol.PLRAM0)

    #csv reader erroneously adds one extra element to the end, so remove, then reshape
    fcweights = fcweights[:-1].reshape(1000, 2048)
    fcbuf[:] = fcweights
    fcbuf.sync_to_device()

    return ol, fcbuf
Example #3
0
from flask import Flask,request,jsonify,render_template,make_response
from PIL import Image, ImageEnhance, ImageOps
from scipy import misc
from array import *
import numpy as np
import urllib.request
import base64
import cv2
import io

app = Flask(__name__)
try:
  import pynq
  import bnn
  pynq_overlay = pynq.Overlay("base.bit")
  mnist_classifier = bnn.LfcClassifier(bnn.NETWORK_LFCW1A1,"mnist",bnn.RUNTIME_HW)
except ImportError:
  pynq = None

@app.route('/extension/<name>')
def extension_led(name):
  resp = make_response(render_template(name + '.js', url_root=request.url_root))
  resp.headers['Content-type'] = 'application/javascript'
  return resp

@app.route('/led')
def led():
  status = int(request.args.get('status')) 
  index  = int(request.args.get('index')) - 1
  print("status:", status)
  print("index:", index)
Example #4
0
import pynq
import cv2
import PIL.Image
import time
from pynq.lib.video import *

## Load overlay
ol = pynq.Overlay("/home/xilinx/jupyter_notebooks/overlays/base/edge/edge.bit")

## setup hdmi ports
ol.video.hdmi_in.configure()
ol.video.hdmi_out.configure(ol.video.hdmi_in.mode)

## Start HDMI
ol.video.hdmi_in.start()
ol.video.hdmi_out.start()

## Tie HMDI input port to output port
ol.video.hdmi_in.tie(ol.video.hdmi_out)

## Wait
time.sleep(120)

## Close both Ports
ol.video.hdmi_out.close()
ol.video.hdmi_in.close()
Example #5
0
## MQTT Publisher Setup
#####################################

## create client objec
print("############### Setting up MQTTT Publisher ###############")
mqttc = mqtt.Client()

## setup MQTT publisher
mqttSetup(brokerIP, port, user, password)

#####################################
## Setup Video Pipeline
#####################################

## load overlay for vehicle counting IP
ol = pynq.Overlay(overlayPath)

## Setup HDMI Pipeline
print("############### Setting up HDMI Pipeline ###############")
setupHDMIPipe()

#####################################
## Register Read Setup
#####################################

print("############### Setting up Register Access ###############")
mmio = MMIO(IP_BASE_ADDRESS, ADDRESS_RANGE)
frameCount = 0

####################################################
## Determining congestion based off result value
Example #6
0
                        type=int,
                        default=100,
                        help='Number of batches to run')
    args = parser.parse_args()

    # discover a compatible shell if there are multiple
    devices = Device.devices
    if len(devices) > 1:
        for i in range(len(devices)):
            print("{}) {}".format(i, devices[i].name))
            if devices[i].name == args.shell:
                print("Compatible shell found, using device", i)
                Device.active_device = devices[i]
                break

    ol = pynq.Overlay(args.xclbin)
    accelerator = ol.resnet50_1

    #allocate a buffer for FC weights, targeting the Alveo PLRAM 0
    fcbuf = pynq.allocate((1000, 2048), dtype=np.int8, target=ol.PLRAM0)

    # Load the weight from a CSV file and push them to the accelerator buffer:
    fcweights = np.genfromtxt(args.fcweights, delimiter=',', dtype=np.int8)
    #csv reader erroneously adds one extra element to the end, so remove, then reshape
    fcweights = fcweights[:-1].reshape(1000, 2048)
    fcbuf[:] = fcweights

    #Move the data to the Alveo DDR
    fcbuf.sync_to_device()

    fps, latency, power = benchmark_synthetic(args.bs, args.reps)
import pynq
import cv2
import PIL.Image
import time
from pynq.lib.video import *

## start time 
start = time.time()


#####################################
#  First Overlay
#####################################

## load overlay
ol = pynq.Overlay("/home/xilinx/jupyter_notebooks/overlays/1080p/hdmi_only/gray/gray.bit")


## video format setup
ol.video.hdmi_in.configure()
ol.video.hdmi_out.configure(ol.video.hdmi_in.mode)


ol.video.hdmi_in.start()
ol.video.hdmi_out.start()


ol.video.hdmi_in.tie(ol.video.hdmi_out)

## wait 30 seconds
time.sleep(30)
import pynq
import cv2
import PIL.Image
import time
from pynq.lib.video import *

## start time
start = time.time()

## load overlay
ol = pynq.Overlay(
    "/home/xilinx/jupyter_notebooks/overlays/1080p/motorway/motorway.bit")

#####################################
#  Register Memory setup
#####################################

IP_BASE_ADDRESS = 0x43C70000
ADDRESS_RANGE = 0x10000
ADDRESS_OFFSET = 0x10

from pynq import MMIO
mmio = MMIO(IP_BASE_ADDRESS, ADDRESS_RANGE)

#####################################
#  Register Read
#####################################
x = 0
while (x < 5):
    result = mmio.read(ADDRESS_OFFSET)
    print("Result is: " + str(result))
def _download(bitstream_data):
    with tempfile.NamedTemporaryFile() as f:
        f.write(bitstream_data)
        f.flush()
        ol = pynq.Overlay(f.name)
Example #10
0
 def __init__(self):
     self.overlay = pynq.Overlay("gameboy_overlay2.bit")
     self.xlnk = pynq.Xlnk()
     self.frame = self.xlnk.cma_array(shape=(144, 160, 3), dtype=np.uint8)
     self.frame_ptr = self.frame.physical_address