LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Advertise
  • Mirrors
  • Logos
  • Contact us
  • Find Resources
  • Job Opportunity
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Openrisc > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: Kuoping Hsu<kuoping@s...>
    Date: Fri Sep 30 09:00:02 CEST 2005
    Subject: [openrisc] GNU C keyword volatile, GNU compiler/optimizer and instruction re-ordering
    Top
    Hi all,

    I got one problem about the GNU compiler/optimizer on the instruction
    re-ordering. To explain my question, there's a simple device on the
    WISHBONE bus with 4 MMIO addressing I/O. When I write 0x8000000c to 1,
    it will calculate some arithmetic algorithms from source buffer 'src',
    and write the result back to destination buffer 'dst'.

    some_funtion(char *src, char *dst, int size) {
    int val;

    ....

    *(int volatile)(0x80000000) = (int)(src);
    *(int volatile)(0x80000004) = (int)(dst);
    *(int volatile)(0x80000008) = size;

    *(int volatile)(0x8000000c) = 1;

    ....

    val = dst[0];

    }

    My question is, the C compiler may be re-order the assignment of 'val'
    and '0x8000000c'. The variable 'val' will get the older value before the
    simple device do. How can I solve the problem. My solution is write
    another C function to program these MMIO, and put the C function to
    another C file to prevent C compiler in-line it. Does anyone have better
    solution?

    There is also a discuses article on the following URL link. It more
    precisely declare the re-ordering problem.

    http://compilers.iecc.com/comparch/article/02-09-118

    The re-ordering problem had greatly perplexed with me for a long time. I
    very appreciated any suggestion.

    Thanks and regards

    Kuoping Hsu


     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.