Forum Discussion
Matlab code to verilog
Hi there,
Is there a compiler which can convert Matlab code directly in to VHDL/verilog format so to implement the code directly in to FPGA? I am trying to write codes on MATLAB and would like to convert the code in to verilog format so to make my life easier.:) thnks22 Replies
- Altera_Forum
Honored Contributor
No, it will not work.
To properly achieve what I was saying you will need to program your algorithm using exclusively simulink blocks, with no .m functions. You basically need to rethink all your code and make it parallel. - Altera_Forum
Honored Contributor
Hi again,
I managed to make a Adaptive Noise Cancellation Algorithm on matlab. Can I transfer this code on to Simulink as a user define function block and then link my FPGA and transfer the code on to my FPGA???? - Altera_Forum
Honored Contributor
Yes, you will gets tons of delays and bad performance from such a system (automated conversions).
That is the reason that HDL engineers are well paid, but then again it takes a couple of years practice to be a good HDL coder. There is no such thing as "free meal" with automated converters. On the other hand if you use simulink model instead of matlab .m scripts as an entry language, then the translation to hardware is easy and straightforward. And even the automated tools can do a good job. That is why I told you guys to use "DSP builder" for simulink. But somehow you do not believe me. No problem, you are young, you will learn (the hard way) :) Good luck transforming .m into c and c into HDL. - Altera_Forum
Honored Contributor
Thanks alot saurabhraj
I want to explain a bit on what i have to do. I am using a MATLAB code for SPIHT image compression and i have individual files for each step, since SPIHT proceeds in several phases Dominant pass, Subordinate pass etc.. Now i was thinking if i could translate each file in to an individual module of Verilog. The links you sent me suggested converting to C and then to Verilog. It seems fairly undertandable to me, sadly I have zero experinece with C and do you think this will slow down the code? As in two steps will give significant delays? Thankyou - Altera_Forum
Honored Contributor
u can check the below link for converting Matlab to verilog
Matlab to c or c++ 1) http://www.mathworks.com/matlabcentral/newsreader/view_thread/270407 2) http://www.mathworks.com/matlabcentral/newsreader/view_thread/235465 C to verilog http://www.c-to-verilog.com/ - Altera_Forum
Honored Contributor
Hello
I read your posts and i was wondering if you succeeded. I have been trying to do the same and am stuck at it. I have a code on MATLAB and want to translate it to Verilog(Not VHDL).Please let me know if you had success at it. Thanks - Altera_Forum
Honored Contributor
A counter is good. And then use ChipScope to test it.
- Altera_Forum
Honored Contributor
thanks amilcar, but could you give me any suggestion on what should I do first to make sure that my FPGA is properly interfacing with simulink,,,,Should I begin by making a LP filter?
- Altera_Forum
Honored Contributor
No you do not need to learn VHDL nor Verilog. DSP builder does the job for you. Just use the library blocks that it provides and push the download buton.
- Altera_Forum
Honored Contributor
Okay here is some more information on the project that I am working on, I am student from BITS pilani university who is working on a project in which I want to apply Noise cancellation technique on to Altera FPGA using Digital Signal Processing in Matlab. I have the Algorithm for noise cancellation on Matlab but configuring FPGA with matlab is one major issue I am facing, but before I begin, I am trying to implement a low pass filter on to my FPGA using simulink, since I read online that this can be done easily on simulink, I have the ideas and plan on how to progress in my project but I lack technical knowledge in this field. I may have to learn Verilog and also need to know how to implement filter design on to a FPGA, I need any good tutorial or examples that could help me learn Verilog especially when it deals with filters and some examples that were already implemented on to an FPGA.
Maybe now you could better understand my problem :)