Skip to content
MathWorks - Mobile View
  • Inicie sesión cuenta de MathWorksInicie sesión cuenta de MathWorks
  • Access your MathWorks Account
    • Mi Cuenta
    • Mi perfil de la comunidad
    • Asociar Licencia
    • Cerrar sesión
  • Productos
  • Soluciones
  • Educación
  • Soporte
  • Comunidad
  • Eventos
  • Obtenga MATLAB
MathWorks
  • Productos
  • Soluciones
  • Educación
  • Soporte
  • Comunidad
  • Eventos
  • Obtenga MATLAB
  • Inicie sesión cuenta de MathWorksInicie sesión cuenta de MathWorks
  • Access your MathWorks Account
    • Mi Cuenta
    • Mi perfil de la comunidad
    • Asociar Licencia
    • Cerrar sesión

Vídeos y webinars

  • MathWorks
  • Vídeos
  • Vídeos-Inicio
  • Buscar
  • Vídeos-Inicio
  • Buscar
  • Comuníquese con ventas
  • Software de prueba
4:42 Video length is 4:42.
  • Description
  • Full Transcript
  • Related Resources

FPGA Design with MATLAB, Part 2: Modeling Hardware in Simulink

From the series: FPGA Design with MATLAB

Efficiently targeting an algorithm to FPGA or ASIC hardware requires adaptations to handle streaming data and to optimize the amount of fixed resources required. Simulink® helps visualize the hardware architecture and data flow. If your original algorithm was developed in MATLAB®, you can reuse much of that work as you use Simulink to adapt the algorithm for hardware implementation.

This video covers:

  • Sharing workspace variables between MATLAB and Simulink
  • Using hardware design experience to adapt the algorithm for efficient implementation
  • Logging signals as test points for debugging
  • Visualizing data types and how they propagate through the design
  • Re-using the MATLAB code in a streaming MATLAB function block
  • Using the MATLAB testbench to simulate and verify the output of the Simulink hardware implementation

Welcome to the HDL Coder Video Series. In this video series we will learn a popular production proven path to take a MATLAB digital signal-processing algorithm through Simulink, Fixed-Point Designer, and HDL Coder to target an FPGA.

In the first part of the video series we discussed the strength of MATLAB and Simulink and provided an overview of the HDL Coder Self-Guided Tutorial available on the MathWorks File Exchange website. 

In this part of the video series we will pay attention on implementing the Simulink model for the Pulse Detection Algorithm and compare it with the golden reference.

Before we create the Simulink model, run the pulse_detector_reference algorithm. This will initialize all the parameters in the MATLAB workspace, which we will pull into the Simulink model during the build.

To stream the data in the Simulink model, we will use the “Signal from Workspace” block which will stream the Receive Signal one sample at a time. The sampled data is passed through the discrete FIR Filter block with its coefficients referencing the CorrFilter variable. Enable logging of specific signals during the build stages of the Simulink model. We will utilize the logged signals to verify the output of the Simulink model with the golden reference algorithm.

To implement the hardware-friendly peak detector, use the raw sum of the square of the real and complex magnitudes since using complex operations such as square root will end up being resource expensive. To evaluate the magnitude squared, the signal is split into its real and imaginary components with the following blocks: Enable the signal Dimensions and Port Data, to visualize the data changes in Simulink.

To detect the peak, the Tapped delay block buffers the magnitude squared signal into 11 samples to create the sliding window

To implement the above peak detection, we will copy the “Hardware Friendly” algorithm in the Simulink model using the MATLAB Function Block.

Copy and paste the algorithm in the MATLAB function block. We will modify the algorithm to work with the buffered sample data and define the WindowLen Variable as a parameter.

This method enables to detect the pulse immediately, as this processes the data sample that follows the pulse as they arrive. In addition, this technique avoids storing the entire data sample in a fixed RAM. The parameter argument in the MATLAB function block takes the value from the MATLAB model workspace.

Clear the tunable option, WindowLen must be a constant expression for code generation purpose.

The middle sample in the stored 11 samples is compared to the other 10 to see if it’s the largest of the 11, and if so, if it’s larger than the threshold we specify. The threshold is the key for identifying the peak versus all the local ones as we slide the window. 

The output of the peak detection implementation, signals “MidSample”
 and “detected” are inputs to a unit delay enabled block, which will hold the peak value for display when the detected signal is TRUE. To visualize the outcome, connect a ‘Display’ block.

Using the test bench script ‘pulse_detector_v1’, we will run the output comparison of the MATLAB golden reference and the Simulink hardware implementation model. The comparison proves that the Simulink streaming model matches with the MATLAB reference, and the error is just the floating-point precision error.

In the second part of this video series on the HDL Coder, we have implemented the hardware implementation in Simulink and compared it against the MATLAB golden reference. We have also demonstrated the seamless interaction between MATLAB and Simulink environments during the Simulink model build.

In the next video we will prepare the Simulink model for HDL code generation.

Related Products

  • HDL Coder

Get HDL Coder Self-Guided Tutorial

Bridging Wireless Communications Design and Testing with MATLAB

Read white paper
Related Information
Related Information
Request HDL Coder Trial

Feedback

Featured Product

HDL Coder

  • Request Trial
  • Get Pricing

Up Next:

Learn how to balance speed and area optimization of hardware micro-architecture for RTL generation.
4:48
Part 3: Architecting Efficient Hardware
View full series (5 Videos)

Related Videos:

23:30
Rapid Prototyping of Unknown Solutions to Only Partially...
20:02
A Guided Workflow for Zynq Using MATLAB and Simulink
19:41
Prototyping SoC-based Motor Controllers with MATLAB and...
19:50
How to Build Custom Motor Controllers for Zynq SoCs with...
30:14
Rapid Deployment of MATLAB and Simulink Designs on Xilinx...

View more related videos

MathWorks - Domain Selector

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

  • Switzerland (English)
  • Switzerland (Deutsch)
  • Switzerland (Français)
  • 中国 (简体中文)
  • 中国 (English)

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文Chinese
    • English
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

  • Comuníquese con ventas
  • Software de prueba

MathWorks

Accelerating the pace of engineering and science

MathWorks es el líder en el desarrollo de software de cálculo matemático para ingenieros

Descubra…

Explorar productos

  • MATLAB
  • Simulink
  • Software para estudiantes
  • Soporte para hardware
  • File Exchange

Probar o comprar

  • Descargas
  • Software de prueba
  • Comuníquese con ventas
  • Precios y licencias
  • Cómo comprar

Aprender a utilizar

  • Documentación
  • Tutoriales
  • Ejemplos
  • Vídeos y webinars
  • Formación

Obtener soporte

  • Ayuda para la instalación
  • MATLAB Answers
  • Consultoría
  • Centro de licencias
  • Comuníquese con soporte

Acerca de MathWorks

  • Ofertas de empleo
  • Sala de prensa
  • Misión social
  • Casos prácticos
  • Acerca de MathWorks
  • Select a Web Site United States
  • Centro de confianza
  • Marcas comerciales
  • Política de privacidad
  • Antipiratería
  • Estado de las aplicaciones

© 1994-2022 The MathWorks, Inc.

  • Facebook
  • Twitter
  • Instagram
  • YouTube
  • LinkedIn
  • RSS

Únase a la conversación