MATLAB Answers


Conversion of MATLAB (.m) coding into Verilog HDL

Asked by hamid
on 16 Sep 2011

Dear All

I am doing a project in which i have to convert image encryption MATLAB code into Verilog HDL language code and then implemented it on DE2 Board. I have already searcehd a lot of questions regarding this matter but every one said that you have to write MATLAB code either into Embedded MATLAB code or on Simulink. My question is that is this possible that i write a code in simple MATLAB coding means in .m extension (not on Simulink or in Embedded MATLAB code) and convert it into Verilog HDL Langugae. Because i have only .m extension MATLAB code to convert.

Looking forward for a positive response and thanking all in advance.

Thanks Regards



No products are associated with this question.

3 Answers

Answer by Walter Roberson
on 16 Sep 2011
 Accepted answer

You would probably have had to restrict the code to using the functions supported by Embedded MATLAB (even if not written with specific reference to Embedded MATLAB), and then you would probably have to run the code through MATLAB Coder (for Release R2011a or later). The result would be a C file, which you could then compile to HDL such as with one of these tools.

MATLAB Coder does not rely on any other toolboxes, but it seems likely to me that it is fairly expensive. I do not know, though, how the price would compare the alternatives.

  1 Comment

Fangjun Jiang
on 16 Sep 2011

Embedded MATLAB belongs to Simulink. With MATLAB alone, no need and can't use the Embedded MATLAB Function block.

Answer by Fangjun Jiang
on 16 Sep 2011

What you heard is probably right. If you are looking for a Yes answer, you are probably going to be disappointed. Look at all the products at, there are only two mentions of HDL. One is "Filter Design HDL Coder" toolbox under MATLAB. The other is "Simulink HDL Coder" toolbox under Simulink. That means you need to have at least one of the toolbox to be able to generate a HDL code. With only MATLAB, it can't be done at this point.


Answer by hamid
on 16 Sep 2011

Dear Walter!!! I have Matlab Release 2011a so can you Please explain how i can do conversion? also you wrote "fairly Expensive", i didn't get u clearly..Please also explain this. If you are talking about different toolboxes to be used in MATLAB then please tell me, i will try to arrange them.

Dear Fangjun!!! beside these two method is there any else method or i have to write the whole code by myself in Simulink or Embedded Matlab?


  1 Comment

Walter Roberson
on 16 Sep 2011

I do not have a price chart available, and I did not pay much attention to the MATLAB Coder price the last time I glanced at the chart. I think it was over $7000 for MATLAB Coder, but you would need to check with Sales to be sure (especially if you can get academic pricing.)

I did not investigate the C to HDL tools to see if any of them were free (and worth owning). It appears that many of them are specialized commercial products that I would expect would cost thousands of dollars.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!