- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
MCODE - Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-25-2012 09:42 AM
What is wrong with my code? I want it to wait until a image has finished being read into shared memory and then select a window from this memory by following this mcode.
------------------
function Address = addressgenerator(counter)
if counter == 262144
for n=0:100
for m=0:100
Address = ((512*n)+m);
end
if m == 100
m = 0;
end
end
else
end
--------------------------------
Solved! Go to Solution.
Re: MCODE - Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-25-2012 01:11 PM
Hi.
There are some issues with this code. The most important is that this whole MCode function will be "executed" at once per cycle. Well, to be more precise, that code will be synthesized in block that will output only last value of variable Address per one input cycle. So if you would like to output Address values sequentially, then you should calculate and return only one Address value per function call. It means that you need to have persistent (or static in terms of C language) variables n and m in your code.
Please have a look at page 280 of System Generator Reference Guide:
http://www.xilinx.com/support/documentation/sw_man
There is a detailed description of MCode block, its restrictions and allowed helper functions (e.g., xl_state()).
Also one should note following:
1. Value of returned variable (Address) should be defined in all branches of conditional code.
2. All loops are unrolled (and there is maximum unroll limit). But as stated above, you don't need loops.
Vitaly.
Re: MCODE - Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-27-2012 12:57 PM
Hello Again,
I seemed to have nearly finished what I'm doing and sorted everything. Learnt a lot :)
I just have one more question, I need to work out the minimum error so I need some way of producing the abs() function, within mcode. As I need minimum nearest to 0.
Re: MCODE - Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-27-2012 01:18 PM











