Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20704 Discussions

matlab to nios ide

Altera_Forum
Honored Contributor II
1,435 Views

Hello, 

i am facing a problem in converting matlab code into nios ide. is there anyway to convert these code into C/C++ used in nios ide? My matlab code is regarding image processing. is there any reference for this part?thank you. 

 

regards, 

Liau
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
483 Views

You need to rewrite into C code your m-script code. 

 

 

Did you use MATLAB functions like imfilter? In that case the work is harder, and it would be necessary to write this code in C. 

 

 

try using mcc -m 'your_file.m' in MATLAB
0 Kudos
Altera_Forum
Honored Contributor II
484 Views

Am fairly sure that the MATLAB compiler won't produce any code useable with NIOS. I'm a little out of date, I'll admit, but it used to just generate lots of calls to MATLAB library functions. Almost certainly not what you want. You would also need to have a MATLAB compiler license.

0 Kudos
Altera_Forum
Honored Contributor II
483 Views

I'm afraid you have to re-write the code. :( 

But don't worry, it's not so complicated... 

Cheers 

OD
0 Kudos
Altera_Forum
Honored Contributor II
483 Views

 

--- Quote Start ---  

Hello, 

i am facing a problem in converting matlab code into nios ide. is there anyway to convert these code into C/C++ used in nios ide? My matlab code is regarding image processing. is there any reference for this part?thank you. 

 

regards, 

Liau 

--- Quote End ---  

 

 

There is no direct conversion. But there are ways which can lessen your burden: 

 

1. Write a C code that can be used both in MATLAB and NIOS with some changes: For MATLAB, write a mex file and for NIOS, modify the C-code with NIOS specific constructs. A simple code may not reuire much change for NIOS but a complicated one would need complete restructuring. 

2. Codes that need RTOS will have to be completely rewritten for NIOS and MATLAB. 

3. Or you can write a code in MATLAB, use its Link to ModelSim feature to convert it to HDL and then use it as an HDL component in SOPC Builder.
0 Kudos
Reply