CNN using HLS

I am pleased to announce the release of the code for the article “How to Implement a Convolutional Neural Network Using High-Level Synthesis”.


The previous article discussed three main aspects:

  1. The used approach to implement a Convolutional Neural Network (CNN)
  2. The elements that I took into account when choosing the neural network architecture
  3. The specific High-Level Synthesis constructs that helped to achieve the targeted performance.


Now you can download the code from GitHub.
The GIT repository contains:

  • The CNN implementation
  • The python codes used for training
  • Modules for each type of layer (convolutional, pooling and fully connected) used for development and testing
  • Short guide on how to set up and run the code

The CNN code is provided as an OpenSource implementation under Apache License 2.0.
I welcome your feedback!


SP March 10th, 2020 21:14:39

Sorry, but I do not see the python codes used for training.

Pedro April 17th, 2020 14:31:36

Hello Sergiu Duda,

Please tell me if you can post the full version of your diploma thesis for review on github, or is it forbidden?

Thank you in advance.

anahita August 26th, 2020 20:42:20

,thanks for usefull information.I want to know whats the input of your code because I cant to simulate it with vivado hls , and how can I simulate it with vivado?can i add synthesis vhdl code to vivado for simulating it?would you mind help me?

    Sergiu Duda August 31st, 2020 08:26:01

    Hi Anahita,

    The image is sent as an input to the first CONV layer in nnet.cpp at line 333.

    To simulate it with Vivado, you will first need to export the RTL. For this you have two options:
    * use the button in VIvado HLS which is near the Synthesis button
    * Run a .tcl command: export_design -flow syn -rtl vhdl -format ip_catalog

    Then you need to import the IP in Vivado, through the IP catalog. After this step is done, you can instantiate the IP as any other Xilinx IPs in the Block Design.


Johanna March 30th, 2021 15:44:06


Super nice done!

I have a question about the data width. In the implementation on GitHub, is it using 24 bit floating point data type since its configured with float24_t. How can I change this if i want to implement 16 or int.

Kind regards,

Leave a Comment:

Your comment will be visible after approval.

(will not be published)

This site uses Akismet to reduce spam. Learn how your comment data is processed.