You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-61Lines changed: 34 additions & 61 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,26 +6,13 @@ This project includes the HLS implementation and the approximation algorithms in
6
6
7
7
### SVD Approximation Algorithm
8
8
9
-
The bot AI is trained in Google Colab following the notebook in `ai/` folder.
10
-
11
-
### Hardware
12
-
13
-
The hardware part was implemented in Vivado High Level Synthesis (HLS) C++. It exploits Xilinx OpenCV libraries for resizing and stream the video frames generated by the game.
14
-
15
-
#### Pong Game Cosimulation
16
-
17
-
#### OpenCV Cosimulation
18
-
19
-
#### HDMI Modules
20
-
21
-
For instantiating the HDMI IPs, please follow this [guide](https://forums.xilinx.com/t5/Design-and-Debug-Techniques-Blog/Video-Series-23-Generate-a-video-output-on-Pynq-Z2-HDMI-out/ba-p/932553).
22
-
23
-
#### Vivado Project
9
+
The approximation algorithms are in the `python/` folder.
24
10
25
11
## Requirements
26
12
27
13
* CMake
28
-
* Xilinx Vivado 2018.3
14
+
* Xilinx Vivado 2018.3 (deprecated)
15
+
* Xilinx Vitis 2021.1 (deprecated)
29
16
30
17
### CMake Simulation
31
18
@@ -47,34 +34,29 @@ cmake ..
47
34
make all
48
35
```
49
36
50
-
## Notes on Using Vitis
37
+
## Notes on Using Vitis HLS
51
38
52
39
### AXIS Interface and DMA
53
40
54
-
Vitis to include the TLAST side channel if and only if TKEEP and TSTRB are also included.
41
+
Vitis will include the TLAST side channel if and only if TKEEP and TSTRB are also included.
55
42
56
43
In order to attach the port to a Xilinx DMA, the TLAST signal must be properly set HIGH at the end of the data transmission.
57
44
58
45
The TKEEP and TSTRB signals must be *always* set to HIGH, as indicated in the [AXIS documentation](https://developer.arm.com/documentation/ihi0051/a/Interface-Signals/Byte-qualifiers/TKEEP-and-TSTRB-combinations).
59
46
47
+
Note: for using external DMAs, we need the TLAST, TKEEP and TSTRB signals. In particular, TKEEP and TSTRB must be all set (i.e. all ones) in order to signal data packets.
However, since we are dealing with a `hls::vector` type, setting `dim=0` (all dimensions) will partition the array on the vector dimension too.
51
+
This repository contains a wrapper class for kernel arguments of type `hls::stream` named `AxiStreamInterface`. The class is implemented following a _Policy-based_ C++ paradigm, meaning that it accepts either a `AxiStreamPort` or `AxiStreamFifo` as possible policies (in practice, a template argument).
69
52
70
-
In the example above, Vitis will create `M * N * 4` different streams (instead of just `M * N`). To fix it, manually specify the partitioning on the dimensions, like so:
The idea is to have a kernel argument, i.e. an HLS port, which can be either an AXIS interface with side-channels, or a bare FIFO interface connected to another kernel. In fact, Vitis HLS doesn't allow stream interfaces with side-channels within an IP. To overcome the issue, the `AxiStreamInterface` can be customized to be an IP port or a FIFO port, depending on the use of the kernel.
54
+
55
+
An example of this can be seen in `HlsKernelU` and in `svd::SvdKernel`, which specialize the `svd::KernelU` function template. In the first case, the `svd::KernelU` has its output stream port `xu_port` connected to one of the IP's ports (with side-channels). In the latter case instead, `svd::KernelU` is connected to `svd::KernelS`, and so its `xu_port` argument is an internal FIFO (without side-channels).
56
+
57
+
The `AxiStreamInterface` class in `axis_lib.h` can also be used with `hls::vector` types.
76
58
77
-
### Implementing AXIS Interfaces
59
+
### AXIS Interfaces and `depth`
78
60
79
61
In order to implement AXIS interfaces, avoid using `depth` in the pragma, as follows:
The type `ap_axiu` must now be used to generate AXIS with side channels. Note: for using external DMAs, we need the TLAST, TKEEP and TSTRB signals. In particular, TKEEP and TSTRB must be all set (i.e. all ones) in order to signal data packets.
72
+
The type `ap_axiu` must now be used to generate AXIS with side channels.
91
73
92
-
#### AxiStreamInterface Class
74
+
## hls::vector Arrays on AXI-Lite Interfaces
93
75
94
-
This repository contains a wrapper class for kernel arguments of type `hls::stream` named `AxiStreamInterface`. The class is implemented following a _Policy-based_ C++ paradigm, meaning that it accepts either a `AxiStreamPort` or `AxiStreamFifo` as possible policies (in practice, a template argument).
76
+
In Vitis 2021.1 it **not** allowed to have `hls::vector` type arguments mapped to AXI-Lite interfaces.
77
+
Instead, use a bare arrays, *e.g.* `const int x[N]` instead of `const hls::vector<int, N> x`.
95
78
96
-
The idea is to have a kernel argument, i.e. an HLS port, which can be either an AXIS interface with side-channels, or a bare FIFO interface connected to another kernel. In fact, Vitis HLS doesn't allow stream interfaces with side-channels within an IP. To overcome the issue, the `AxiStreamInterface` can be customized to be an IP port or a FIFO port, depending on the use of the kernel.
97
79
98
-
An example of this can be seen in `HlsKernelU` and in `svd::SvdKernel`, which specialize the `svd::KernelU` function template. In the first case, the `svd::KernelU` has its output stream port `xu_port` connected to one of the IP's ports (with side-channels). In the latter case instead, `svd::KernelU` is connected to `svd::KernelS`, and so its `xu_port` argument is an internal FIFO (without side-channels).
80
+
### Partitioning hls::vector Arrays
99
81
100
-
The `AxiStreamInterface` class in `axis_lib.h` can also be used with `hls::vector` types.
However, since we are dealing with a `hls::vector` type, setting `dim=0` (all dimensions) will partition the array on the vector dimension too.
88
+
89
+
In the example above, Vitis will create `M * N * 4` different streams (instead of just `M * N`). To fix it, manually specify the partitioning on the dimensions, like so:
The DMA should be configured in the following way:
8
+
9
+
* Max burst length to maximum
10
+
* Register buffer width to maximum
11
+
12
+
### HP Ports
13
+
14
+
All HP ports should be set to their maximum size width (64bit for the PYNQ-Z1 board and 128bit for the ZCU104) in order to avoid receiving data interleaved by zeroes.
15
+
16
+
## Jupyter Notebook
17
+
18
+
### Generating Randomly-filled Buffer
19
+
20
+
```python
21
+
import numpy as np
22
+
23
+
R, N, G =64, 2, 4
24
+
25
+
xus = np.random.randn(R, N, G).astype(dtype=np.int16)
26
+
xus_buffer = pynq.allocate(shape=(R, N, G), dtype=np.int16)
27
+
np.copyto(xus_buffer, xus, casting='no')
28
+
```
29
+
30
+
### Storing and Loading Weights from bin file
31
+
32
+
```python
33
+
import numpy as np
34
+
35
+
R, N, G =64, 2, 4
36
+
37
+
tmp = np.random.randn(R, N, G).astype(dtype=np.int16)
0 commit comments