generate tool - source question

Applications, development tools, FPGA, C, WEB
Post Reply
Arnold
Posts: 54
Joined: Wed Mar 11, 2015 3:07 pm

generate tool - source question

Post by Arnold » Mon Jun 01, 2015 4:45 pm

Hi,

Why is there a loop in the following code of the generate tool?
https://github.com/RedPitaya/RedPitaya/ ... #L329:L331

is it possible to replace the loop with a memcpy?

Thanks,

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: generate tool - source question

Post by Nils Roos » Mon Jun 01, 2015 8:13 pm

The thing with this loop is, g_awg_ch[ab]_mem are pointers into the fpga's address space. The implication here is that you should only access this region 32bits at a time.

So replacing the loop with memcpy might work if 32bit accesses are preserved, but if the compiler decides to optimize the accesses, it may not work and you will experience difficult to diagnose problems.

In conclusion, I wouldn't risk it.

Arnold
Posts: 54
Joined: Wed Mar 11, 2015 3:07 pm

Re: generate tool - source question

Post by Arnold » Mon Jun 01, 2015 11:11 pm

ok,

i think this issue is when you optimize your code with -O2 or -O3

could you memcpy from the /dev/mem to read the oscilloscope and memcpy to the /dev/mem to write to the awg? a for loops seems really slow...

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: generate tool - source question

Post by Nils Roos » Tue Jun 02, 2015 10:41 pm

mmapping dev/mem is just a way to tell the MMU how to retarget the accesses - the underlying restrictions of the targetted region remain in effect.

Arnold
Posts: 54
Joined: Wed Mar 11, 2015 3:07 pm

Re: generate tool - source question

Post by Arnold » Wed Jun 03, 2015 8:50 am

the code fails with -O3 optimization. the correct solution is to use a volatile pointer here! please fix this issue...

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: generate tool - source question

Post by Nils Roos » Wed Jun 03, 2015 9:35 am

I don't see an issue here - but if you do, I'll be welcoming useful contributions.

Arnold
Posts: 54
Joined: Wed Mar 11, 2015 3:07 pm

Re: generate tool - source question

Post by Arnold » Wed Jun 03, 2015 2:36 pm

did you build the source with -O3?

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: generate tool - source question

Post by Nils Roos » Wed Jun 03, 2015 2:46 pm

No, I didn't, but I trust you when you say that building with -O3 breaks something.

The thing is, nobody ever said that it SHOULD work with aggressive optimizations turned on. If you change something, it is your responsibility to deal with any resulting issues.

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 18 guests