Sign In

Don't have a Xilinx account yet?

  • Choose to receive important news and product information
  • Gain access to special content
  • Personalize your web experience on Xilinx.com

Create Account

Username

Password

Forgot your password?
XClose Panel
Xilinx Home
Reply
Visitor
imhiya
Posts: 5
Registered: ‎04-25-2012
0
Accepted Solution

MCODE - Error

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
--------------------------------

Super Contributor
vlavruhin
Posts: 195
Registered: ‎12-08-2010

Re: MCODE - Error

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_manuals/xilinx13_4/sysgen_ref.pdf

 

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.

 

Best Regards,
Vitaly.
Visitor
imhiya
Posts: 5
Registered: ‎04-25-2012
0

Re: MCODE - Error

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.

Visitor
imhiya
Posts: 5
Registered: ‎04-25-2012
0

Re: MCODE - Error

Sorry again, I sorted it by using a if statement if min is less then 0 switch the equation.