File Exchange

image thumbnail

HDL Coder Self-Guided Tutorial

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

95 Downloads

Updated 13 Mar 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 (https://github.com/mathworks/HDL-Coder-Self-Guided-Tutorial), GitHub. Retrieved .

Comments and Ratings (19)

Brian Farmer

Hi Jack: Your location result for peak is "location" and "location_2", both from "MATLAB Golden Reference" "pulse_dector_reference.mlx" and within "MATLAB Golden Reference" "Hardware friendly implementation of peak finder", respectively. Wouldn't it make more in line with what you are demonstrating if the Simulink model, i.e. "pulse_detector_v1.slx" 1 thru 4; had an output of the peak location? That way when you compare locations at the end of your MATLAB testbench, it will make more sense with what you are trying to compare (Golden verse Simulink, not Golden versus a Golden add on hardware friendly script portion). Thank you for comparing the peaks.

Would be nice if you also guided us through synthesis and simulation, using HDL Coder - possibly Workflow Advisor.

John Abh

Hi, I am using MATLAB 2015b, is there any way to get the simulink model files for MATLAB 2015b (because later version model will not work on earlier version of MATLAB). Otherwise can anybody covert these files to 2015b version and upload the same in some where and will provide me the link.

Curie Chung

Hi Jose - You can now download the R2018b tutorial files from GitHub:
https://github.com/mathworks/HDL-Coder-Self-Guided-Tutorial/releases

Hi Gill - Are you using R2018b or R2019b? The error is not expected for R2019b, even though the instructions have not been updated. Please feel free to contact us if you need further assistance.

Curie Chung

Hi Gill - Are you using R2018b or R2019b? The error is not expected for R2019b, even though the instructions have not been updated. Please feel free to contact us if you need further assistance.

Gill Duykers

I am using R2019b and have the same error posted by Jose Caballero on 7 Jan 2020. I have downloaded the 14Feb2020 version from Github but still get the error reported about dot indexing not supported for this data type (line 11).
Was there a fix and I missed it? Thanks for any help on this.

Ryan Bosley

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

Jose Caballero

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.

Suranga Handagala

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

Meabh Loughman

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 https://uk.mathworks.com/matlabcentral/answers/359452-error-input-uint8-simulink "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.

Raghu Sivakumar

Stephan van Beek

Pablo Romero

Werner Bachhuber

Eric Cigan

Steve Kuznicki

Eric Cigan

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

Stephan van Beek

Updates

1.33

Updated for R2019b

1.3

Moved to GitHub repository

1.2

Updated for R2019a

1.1.1

Minor edits to two slides

1.1.0

Updated for R2018b

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

pulse_detector/work