Clear Filters
Clear Filters

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.
  2 Comments
Lee Kuang Shen
Lee Kuang Shen on 10 Feb 2017
First of all, thanks for spending your time to reply me. I am very appreciated with your answer. I am understood about the purpose of testbench.
I am willing to design a project which GMM algorithm is involved and the input is from camera. But my design is in DE1-SoC, that is why VHDL is preferred. In order to get the GMM algorithm from MATLAB exist code convert to VHDL, HDL coder is needed. On the other hand, if HDL coder is used, testbench of GMM algorithm is needed. Thus, I am confuse about the testbench of GMM algorithm.
From my understanding, the GMM algorithm is used to process the images and run it as video. It will detect cars and count number of cars. So, the input is the videofile. Does it meant, in my testbench of GMM, I just need to put the input is the videofile that I get from my camera?
Or any advise for it?
Thanks a lot.
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.

Categories

Find more on Code Generation in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!