The usage of the existing Overlay seems to have been introduced in other articles, so skip it and proceed to the next.
So, this time, I will make my own overlay as a continuation of previous. This video ~~ Paku ~~ Refer to it and make an overlay of c = a + b
.
The logic circuit part of PYNQ-Z1 can be handled from a program as if it were a library (?). For details, go to Official.
--Development PC: Windows10 - Vivado Design Suite - HLx Edition - 2019.2
The download alone will be 10GB, and after completion it will be close to 50GB, so you should work on it with sufficient time and storage. This time, I used Webpack (free version).
Here, let's try a circuit that just does c = a + b
according to the tutorial.
First, prepare a circuit that only adds on the FPGA.
Project Configuration
, specify project name as adder and Location as appropriate. (** If Japanese is included in the path, an error may occur later **)Solution Configuration
, search and select Part Selection-> xc7z020clg400-1
.Finish
to create a projectOnce a new project is created, it will be implemented.
adder.cpp
void add(int a, int b, int& c) {
#pragma HLS INTERFACE ap_ctrl_none port=return
#pragma HLS INTERFACE s_axilite port=a
#pragma HLS INTERFACE s_axilite port=b
#pragma HLS INTERFACE s_axilite port=c
c = a + b;
}
Press the green arrow
in the upper left of the image below.
If all goes well, you should see a screen like this.
The following files are generated in solution-> impl-> misc-> drivers-> add_v1_0-> src-> xadd_hw.h on the Explorer tab. If you look at this, you can see the correspondence table between variables and addresses.
variable | address |
---|---|
a | 0x10 |
b | 0x18 |
c | 0x20 |
This is to the right of the green arrow
earlier![Image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/382909/68a02ee2-8fda-1a21 Just click -b767-839ce80ccd4b.png) and press ʻOK`.
Configure Overlay using the ʻadder` created earlier
Since the information of PYNQ-Z1 is not registered in the Vivado web pack, download the data from here. I used it. Expand this and copy it to C: \ Xilinx \ Vivado \ 2019.2 \ data \ boards \ board_files
etc.
Create Project
Create a New Vivado Project
is displayed, click Next
.Project name
to project_1
and select an appropriate folder for Location
.RTL Project
for Project Type
.
Default Part
-> Board
-> PYNQ-Z1
.New Project Summary
is displayed, create a project with Finish
.We will continue to work with Vivado.
->
Create Block Design` on the left side of the screen and press OK in the pop-up.+
and select Search
-> ZYNQ7 Processing System
![Image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/ 0/382909/f3a0eba1-de3f-6758-118d-59f0bbf1ea66.png)Run Block Automation
-> OK
Tools
on the screen, go to Setting
-> ʻIP->
Repository, press
+, and select / add the ʻadder
folder you created earlier. this time. Also, change the name from ʻadd_0
to scalar_add
. Run Connection Automation
. Sources
-> design_1
-> Create HDL Wrapper
-> ʻOK`![Image.png](https://qiita-image-store. s3.ap-northeast-1.amazonaws.com/0/382909/d7dd5a93-4a5a-1a3f-5412-d1cf83d8c2f8.png)PROGRAM AND DEBUG
-> Generate Bitstream
-> Yes
-> ʻOK`.File
-> Export
-> Export Block Design
-> OK
Now that you have created a set of files, copy them to PYNQ-Z1 and execute them.
Copy the following 2 files in the project folder.
Rename them to ʻadder.bit, ʻadder.hwh
, and ʻadder.tcl` for easy understanding.
Enter \\ pynq
in the URL part of Explorer to tamper with the internal folder. Both ID and password are xilinx
.
Create a new directory ʻadderin
Network / pynq / xilinx / pynq / overlay and copy ʻadder.bit
, ʻadder.hwh, ʻadder.tcl
.
Access [http: // pynq: 9090](http: // pynq: 9090) and log in to jupyter (ID / password is xilinx). After connecting, create a new Python3 note from New
on the home screen and open it.
Then follow the Official.
First read.
In[1]
from pynq import Overlay
overlay = Overlay('/home/xilinx/pynq/overlays/adder/adder.bit')
In the next two, each usage is displayed in text.
In[2]
overlay?
In[3]
add_ip = overlay.add_0
add_ip?
Let's calculate 4 + 5
.
In[4]
add_ip.write(0x10, 4)
add_ip.write(0x18, 5)
add_ip.read(0x20) #Is output as 9
This is the same.
In[5]
add_ip.register_map.a = 3
add_ip.register_map.b = 4
add_ip.register_map.c
It worked for the time being. Next time, I would like to do something like speeding up arrays by parallel processing.