Conversion of GMM in MATLAB Code to VHDL using HDL Coder

1 view (last 30 days)
Happy New Year. I am a student from UniMap and doing a project by using simulink tool. I encounter a problem that need profession Matlab support.
May I know the way to use HDL coder for the purpose of converting the existing algorithm in MATLAB code which is the "Detection Car by using Gaussian Mixture Model (GMM)" into VHDL code?
The major problem is how to create a testbench for the algorithm since it needs to be used for the conversion or do it has the exist testbench for it?
Your help is really much appreciated. Thanks for spending your precious time to see and reply this message.
Regards, Lee Kuang Shen

Answers (1)

Tim McBrayer
Tim McBrayer on 9 Feb 2017
You mention Simulink, but then discuss generating code from MATLAB if I understand correctly. I will answer as if you are generating HDL from MATLAB code.
When you have a piece of MATLAB code that you want to convert to HDL, you need to have a testbench to go along with it. If you've already developed your design you should have testbench code that you have already written to ensure that your design works as desired. You can use it as is or modify it as necessary.
The testbench code should provide inputs to your design, and receive the outputs. These can be processed in any fashion; you can log the data, graph it, manipulate it, or discard it. Any MATLAB code is allowed in the testbench.
The testbench code is not just used for providing stimulus and receiving outputs. It also can define the data type of your input and output ports and potentially the actual data type of all the internal signals in your design.
I recommend that you study the documentation for generating HDL code from MATLAB carefully. The featured examples are designed to introduce and explain the topics that I've touched on here.
Tim McBrayer
Tim McBrayer on 10 Feb 2017
Yes, from your description it sounds like your testbench will consist of reading the video file from disk and transferring it to your design. You will need to figure out how to do this in a hardware-friendly fashion. The simple approach of passing a frame at a time, in a matrix, is not the way to go--FPGAs don't have that many pins. You'll need to stream your data in, probably a pixel at a time. This approach is well documented in the featured examples for HDL Coder, for both Simulink and MATLAB-based designs.
If you are not concerned about testing the correctness of your design, (in MATLAB, Simulink, or HDL) you can use a dummy testbench that simply defines the data types of the input and output ports, but doesn't actually provide any useful stimulus. This will let you generate HDL code, but with no way to validate that either your design or the generated code operates as expected.

Sign in to comment.



Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!