xref: /openwifi/doc/app_notes/hls.md (revision ce2baff7dfb4ec63aa859fb9274436f9795e52e4)
1*ce2baff7SHavingaThijs<!--
2*ce2baff7SHavingaThijsAuthor: Thijs Havinga
3*ce2baff7SHavingaThijsSPDX-FileCopyrightText: 2019 UGent
4*ce2baff7SHavingaThijsSPDX-License-Identifier: AGPL-3.0-or-later
5*ce2baff7SHavingaThijs-->
6*ce2baff7SHavingaThijs
7*ce2baff7SHavingaThijsIn order to speed up or ease FPGA development, it is possible to use High-Level Synthesis (HLS) for creating core baseband processing modules of openwifi. We have already programmed the receiver modules channel estimation and equalization in C++ and converted to Verilog using Vitis HLS. In order to use openwifi with these HLS modules, follow the [build instructions](#build-instructions).
8*ce2baff7SHavingaThijsIn order to modify these modules within Vitis HLS, follow [the instructions below](#modify-the-code-using-vitis-hls).
9*ce2baff7SHavingaThijs
10*ce2baff7SHavingaThijs## Build instructions
11*ce2baff7SHavingaThijs
12*ce2baff7SHavingaThijsFollow the [Build FPGA](https://github.com/open-sdr/openwifi-hw#build-fpga) instructions till before generating ip_repo. In order to switch to the HLS-version of openofdm_rx, use the following commands:
13*ce2baff7SHavingaThijs
14*ce2baff7SHavingaThijs```
15*ce2baff7SHavingaThijscd ip/openofdm_rx
16*ce2baff7SHavingaThijsgit checkout dot11zynq_hls
17*ce2baff7SHavingaThijs```
18*ce2baff7SHavingaThijs
19*ce2baff7SHavingaThijsNow continue with the instructions. Before generating the bitstream, update the openofdm_rx IP by making sure it is selected under "IP Status" and click "Upgrade Selected". Afterwards, continue with the instructions to generate the bitstream.
20*ce2baff7SHavingaThijs
21*ce2baff7SHavingaThijs## Modify the code using Vitis HLS
22*ce2baff7SHavingaThijsWhen in the `openwifi-hw` folder, make sure to run:
23*ce2baff7SHavingaThijs```
24*ce2baff7SHavingaThijs./get_ip_openofdm_rx.sh
25*ce2baff7SHavingaThijscd ip/openofdm_rx
26*ce2baff7SHavingaThijsgit checkout dot11zynq_hls
27*ce2baff7SHavingaThijs```
28*ce2baff7SHavingaThijsThen start Vitis HLS and create a new project. Import either all source files (except those ending on '_test.cpp') in the [ch_gain_cal](https://github.com/open-sdr/openofdm/tree/dot11zynq_hls/hls/ch_gain_cal) or [equalizer](https://github.com/open-sdr/openofdm/tree/dot11zynq_hls/hls/equalizer) folder to modify the channel estimation or equalizer module, respectively. Choose either 'equalizer' or 'ch_gain_cal' as top-level module. Next, select `equalizer_test.cpp` or `ch_gain_cal_test.cpp` as testbench file. In 'Part selection', select the right part corresponding to your board.
29*ce2baff7SHavingaThijs
30*ce2baff7SHavingaThijsAfter modifying the code and making sure C simulation and cosimulation is running fine, select 'Export RTL', which will generate a ZIP file with a folder `hdl/verilog` containing the generated Verilog files. Replace the current folder `openwifi-hw/ip/openofdm_rx/hls/equalizer/hdl/verilog/` (or `.../ch_gain_cal/hdl/verilog`) with this folder and change the `openofdm_rx.tcl` file to include the newly generated Verilog files. See [here](https://github.com/open-sdr/openofdm/blob/dot11zynq_hls/openofdm_rx.tcl#L268) for an example. If you modified the top-level function arguments, you will need to interface them accordingly in [dot11.v](https://github.com/open-sdr/openofdm/blob/dot11zynq_hls/verilog/dot11.v).
31*ce2baff7SHavingaThijs
32*ce2baff7SHavingaThijsNow follow the [Build FPGA](https://github.com/open-sdr/openwifi-hw#build-fpga) instructions, starting at the step "Generate ip_repo for the top level FPGA project". It will then use the modified .tcl file to include the correct files for your modified HLS module and build the FPGA using it.
33*ce2baff7SHavingaThijs
34*ce2baff7SHavingaThijsA similar approach can be followed to create other HLS modules, where you would need to execute these steps in the folder of the IP to be modified and integrate the modules in the corresponding top-level Verilog file.