File Exchange

image thumbnail

HDL Coder Self-Guided Tutorial

version 1.3 (2.02 MB) by Jack Erickson
Learn how to deploy an algorithm to an FPGA using MATLAB and Simulink.


Updated 14 Feb 2020

GitHub view license on GitHub

Editor's Note: This file was selected as MATLAB Central Pick of the Week

This tutorial will guide you through the steps necessary to implement a MATLAB algorithm in FPGA hardware, including:
* Create a streaming version of the algorithm using Simulink
* Implement the hardware architecture
* Convert the design to fixed-point
* Generate and synthesize the HDL code

Cite As

Jack Erickson (2020). HDL Coder Self-Guided Tutorial (, GitHub. Retrieved .

Comments and Ratings (14)

Ryan Bosley

Excellent intro to using Simulink/HDL Coder for signal processing!
Thanks for posting!!

Hi, is there any way to easily adapt this tutorial to R2018b? I am trying to run the testbench at step 7 and get the error:

Warning: Unconnected output line found on 'pulse_detector_v1/Discrete FIR Filter' (output port: 1)
> In pulse_detector_v1_tb (line 8)
Dot indexing is not supported for variables of this type.

Error in pulse_detector_v1_tb (line 11)
FilterOutSL = squeeze(slout.logsout.getElement('filter_out').Values.Data);

Jing Ma

Jack Erickson

Hi Suranga - thanks for pointing that out. In 2019a Simulink changed the way it names the simulation workspace data. We have updated the kit for 2019a.

The example doesn't work with 2019a. I get the error "Undefined variable "logsout" or class "logsout.getElement"" when trying to run the model.

Figured out the answer to my own question - posting in case some one else makes the same mistake. I used the first simulink "from workspace" I saw. That block , from a comment in this link "From Workspace blocks are not able to import "just plain data". From Workspace blocks are intended to deliver data at a particular time: they are blocks for execution of a model, where as importing plain data is something that would be used in a procedural language.”".

As it turns out there are two simulink from workspace block. One specifies “signal from workspace” and can be used to import “just plain data”.

Summarily, make sure to use "signal from workspace". You'll get an error otherwise.

Eric Cigan

Eric Cigan

Very helpful step-by-step guide for users new to HDL Coder.



Moved to GitHub repository


Updated for R2019a


Minor edits to two slides


Updated for R2018b

MATLAB Release Compatibility
Created with R2018a
Compatible with R2018a to R2018b
Platform Compatibility
Windows macOS Linux