element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet & Tria Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
ZedBoard Hardware Design OCM vs DDR vs BRAM read/write speed
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Avnet Boards Forums to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 7 replies
  • Subscribers 340 subscribers
  • Views 2957 views
  • Users 0 members are here
Related

OCM vs DDR vs BRAM read/write speed

Former Member
Former Member over 10 years ago

Hi,

I executed an application that writes 8KB of data on OCM, DDR and BRAM for 2 Mega times (for each memory I wrote 16GB totally). I expected different memory speeds for OCM, DDR and BRAM but to my surprise all of these actions were done at the same time. I am using the memset() function for writing 8KB buffers. Anybody can explain it?

-Mohammad

  • Sign in to reply
  • Cancel
Parents
  • Former Member
    0 Former Member over 10 years ago

    Hi, there is my bare metal code for OCM and DDR Read/Write speed testing on zedboard.

    (0)We need some timer functions to record time
    int timer_read() {
    tint base, a;
    tbase = 0xf8002000;
    ta = REG_READ(base+0x18);
    treturn a;
    }
    double timer_value(int t, double fpclk) {
    t// t in timer units, fpclk in mhz
    t// returns timer value in seconds
    tdouble x;
    tx = ((double) t) * 65536.0 / (fpclk * 1000000.0);
    treturn x;
    }

    (1)Register set
    taddr_value(0xf8000910); // tttttttt slcr.OCM_CFG[RAM_HI] = 1000
    taddr_value(0xf8f00000); //mpcore.SCU_CONTROL_REGISTER[Address_filtering_enable] = 1
    taddr_value(0xf8f00040); //tt      mpcore.Filtering_Start_Address_Register = 0x0010_0000
    taddr_value(0xf8f00044); //ttt    mpcore.Filtering_End_Address_Register = 0xffe0_0000

    (2) prepare a random address offset data (stored in OCM) and write/read function
    tint random_offset[100] = {0x4700, 0x4300, 0x7300, 0x8600, 0x3600, 0x9600, 0x4700, 0x3600, 0x6100, 0x4600, 0x9900, 0x6900, 0x8100, 0x6200, 0x9700, 0x7400, 0x2400, 0x6700, 0x6200, 0x4200, 0x8100, 0x1400, 0x5700, 0x2000, 0x4200, 0x5300, 0x3200, 0x3700, 0x3200, 0x1600, 0x7600, 0x0200, 0x2700, 0x6600, 0x5600, 0x5000, 0x2600, 0x7100, 0x0700, 0x3200, 0x9000, 0x7900, 0x7800, 0x5300, 0x1200, 0x5600, 0x8500, 0x9900, 0x2600, 0x9600, 0x9600, 0x6800, 0x2700, 0x3100, 0x0500, 0x0300, 0x7200, 0x9300, 0x1500, 0x5500, 0x5900, 0x5600, 0x3500, 0x6400, 0x3800, 0x5400, 0x8200, 0x4600, 0x2200, 0x3100, 0x6200, 0x4300, 0x0900, 0x9000, 0x1600, 0x2200, 0x7700, 0x9400, 0x3900, 0x4900, 0x5400, 0x4300, 0x5400, 0x8200, 0x1700, 0x3700, 0x9300, 0x2300, 0x7800, 0x8400, 0x4200, 0x1700, 0x5300, 0x3100, 0x5700, 0x2400, 0x5500, 0x0600, 0x8800, 0x7700};

    Write/read function:
    #define REG_READ(addr)
    tt({int val;int a=addr; asm volatile ("ldr   %0,[%1]
    " : "=r"(val) : "r"(a)); val;})

    #define REG_WRITE(addr,val)
    tt({int v = val; int a = addr; __asm volatile ("str  %1,[%0]
    " :: "r"(a),"r"(v)); v;})


    (3) Test OCM, first prepare address:
    t//store random offset data in OCM block 2
    tint *ocm_data_int = 0x00010000;
    tfor(i = 0; i < 100 ; i++){
    ttocm_data_int[i] = OCM_BASE + random_offset[i];
    ttprint_addr_value(&ocm_data_int[i]);
    t}


    (3-1) Test OCM random write speed
            //random write 1.2GB data
    ttimer_init();
    tfor(j = 0; j<3145728; j++){ //2^20 = 1048576; 2^20 * 3 = 3145728
    ttfor(i=0; i<100; i++){
    tttREG_WRITE( ocm_data_int[i], 0xF0F00F0F);
    ttt//REG_WRITE( &ocm_data_int[i]+4, 0xF0F0000F);
    tt}
    t}
    ti = timer_read();
    ttest_time = timer_value(i, pclk);
    tprintf("     random write speed = %g MB/sr
    ", 1200.0/test_time);

    (3-2) Test OCM random read speed
    t// random read 1.2 GB data
    tint data_int=0;
    ttimer_init();
    tfor(j = 0; j<3145728; j++){ //2^20 = 1048576 (*3 = 3145728)
    ttfor(i=0; i<100; i++){
    tttdata_int = REG_READ(ocm_data_int[i]);
    tt}
    t}
    ti = timer_read();
    ttest_time = timer_value(i, pclk);
    tprintf("     random read speed = %g MB/sr
    ", 1200.0/test_time);


    (4) Test DDR, first we should prepare address as follows:
    tint DDR_BASE = 0x10020000;
    t//store random offset data in OCM block 2
    tfor(i = 0; i < 100 ; i++){
    ttocm_data_int[i] = DDR_BASE + random_offset[i];
    tt//print_addr_value(ocm_data_int[i]);
    t}

    (4-1) Test DDR random write speed
    ttimer_init();
    tfor(j = 0; j<3145728; j++){ //2^20 = 1048576 (*3 = 3145728)
    ttfor(i=0; i<100; i++){
    tttREG_WRITE( ocm_data_int[i], 0xF0F00F0F);
    tt}
    t}
    ti = timer_read();
    ttest_time = timer_value(i, pclk);
    tprintf("     random write speed = %g MB/sr
    ", 1200.0/test_time);

    (4-2) Test DDR random read speed
    ttimer_init();
    tfor(j = 0; j<3145728; j++){ //2^20 = 1048576 (*3 = 3145728)
    ttfor(i=0; i<100; i++){
    tttdata_int = REG_READ(ocm_data_int[i]);
    tt}
    t}
    ti = timer_read();
    tprintf("     random read time counter = %dr
    ", i);
    ttest_time = timer_value(i, pclk);
    tprintf("     random read 1.2GB time = %g secr
    ",  test_time);
    tprintf("     random read speed = %g MB/sr
    ", 1200.0/test_time);


    (5)Then I got the result:

         OCM random write speed = 498.653 MB/s
         OCM random read speed = 497.069 MB/s

         DDR  random write speed = 500.616 MB/s
         DDR  random read speed = 497.799 MB/s

    It seems like that there is not much difference between OCM and DDR for random WRITE/READ speed.

    Or, could you figure out that if there is any other problems?

    Thanks,
    Zeepen

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Former Member
    0 Former Member over 10 years ago

    Hi, there is my bare metal code for OCM and DDR Read/Write speed testing on zedboard.

    (0)We need some timer functions to record time
    int timer_read() {
    tint base, a;
    tbase = 0xf8002000;
    ta = REG_READ(base+0x18);
    treturn a;
    }
    double timer_value(int t, double fpclk) {
    t// t in timer units, fpclk in mhz
    t// returns timer value in seconds
    tdouble x;
    tx = ((double) t) * 65536.0 / (fpclk * 1000000.0);
    treturn x;
    }

    (1)Register set
    taddr_value(0xf8000910); // tttttttt slcr.OCM_CFG[RAM_HI] = 1000
    taddr_value(0xf8f00000); //mpcore.SCU_CONTROL_REGISTER[Address_filtering_enable] = 1
    taddr_value(0xf8f00040); //tt      mpcore.Filtering_Start_Address_Register = 0x0010_0000
    taddr_value(0xf8f00044); //ttt    mpcore.Filtering_End_Address_Register = 0xffe0_0000

    (2) prepare a random address offset data (stored in OCM) and write/read function
    tint random_offset[100] = {0x4700, 0x4300, 0x7300, 0x8600, 0x3600, 0x9600, 0x4700, 0x3600, 0x6100, 0x4600, 0x9900, 0x6900, 0x8100, 0x6200, 0x9700, 0x7400, 0x2400, 0x6700, 0x6200, 0x4200, 0x8100, 0x1400, 0x5700, 0x2000, 0x4200, 0x5300, 0x3200, 0x3700, 0x3200, 0x1600, 0x7600, 0x0200, 0x2700, 0x6600, 0x5600, 0x5000, 0x2600, 0x7100, 0x0700, 0x3200, 0x9000, 0x7900, 0x7800, 0x5300, 0x1200, 0x5600, 0x8500, 0x9900, 0x2600, 0x9600, 0x9600, 0x6800, 0x2700, 0x3100, 0x0500, 0x0300, 0x7200, 0x9300, 0x1500, 0x5500, 0x5900, 0x5600, 0x3500, 0x6400, 0x3800, 0x5400, 0x8200, 0x4600, 0x2200, 0x3100, 0x6200, 0x4300, 0x0900, 0x9000, 0x1600, 0x2200, 0x7700, 0x9400, 0x3900, 0x4900, 0x5400, 0x4300, 0x5400, 0x8200, 0x1700, 0x3700, 0x9300, 0x2300, 0x7800, 0x8400, 0x4200, 0x1700, 0x5300, 0x3100, 0x5700, 0x2400, 0x5500, 0x0600, 0x8800, 0x7700};

    Write/read function:
    #define REG_READ(addr)
    tt({int val;int a=addr; asm volatile ("ldr   %0,[%1]
    " : "=r"(val) : "r"(a)); val;})

    #define REG_WRITE(addr,val)
    tt({int v = val; int a = addr; __asm volatile ("str  %1,[%0]
    " :: "r"(a),"r"(v)); v;})


    (3) Test OCM, first prepare address:
    t//store random offset data in OCM block 2
    tint *ocm_data_int = 0x00010000;
    tfor(i = 0; i < 100 ; i++){
    ttocm_data_int[i] = OCM_BASE + random_offset[i];
    ttprint_addr_value(&ocm_data_int[i]);
    t}


    (3-1) Test OCM random write speed
            //random write 1.2GB data
    ttimer_init();
    tfor(j = 0; j<3145728; j++){ //2^20 = 1048576; 2^20 * 3 = 3145728
    ttfor(i=0; i<100; i++){
    tttREG_WRITE( ocm_data_int[i], 0xF0F00F0F);
    ttt//REG_WRITE( &ocm_data_int[i]+4, 0xF0F0000F);
    tt}
    t}
    ti = timer_read();
    ttest_time = timer_value(i, pclk);
    tprintf("     random write speed = %g MB/sr
    ", 1200.0/test_time);

    (3-2) Test OCM random read speed
    t// random read 1.2 GB data
    tint data_int=0;
    ttimer_init();
    tfor(j = 0; j<3145728; j++){ //2^20 = 1048576 (*3 = 3145728)
    ttfor(i=0; i<100; i++){
    tttdata_int = REG_READ(ocm_data_int[i]);
    tt}
    t}
    ti = timer_read();
    ttest_time = timer_value(i, pclk);
    tprintf("     random read speed = %g MB/sr
    ", 1200.0/test_time);


    (4) Test DDR, first we should prepare address as follows:
    tint DDR_BASE = 0x10020000;
    t//store random offset data in OCM block 2
    tfor(i = 0; i < 100 ; i++){
    ttocm_data_int[i] = DDR_BASE + random_offset[i];
    tt//print_addr_value(ocm_data_int[i]);
    t}

    (4-1) Test DDR random write speed
    ttimer_init();
    tfor(j = 0; j<3145728; j++){ //2^20 = 1048576 (*3 = 3145728)
    ttfor(i=0; i<100; i++){
    tttREG_WRITE( ocm_data_int[i], 0xF0F00F0F);
    tt}
    t}
    ti = timer_read();
    ttest_time = timer_value(i, pclk);
    tprintf("     random write speed = %g MB/sr
    ", 1200.0/test_time);

    (4-2) Test DDR random read speed
    ttimer_init();
    tfor(j = 0; j<3145728; j++){ //2^20 = 1048576 (*3 = 3145728)
    ttfor(i=0; i<100; i++){
    tttdata_int = REG_READ(ocm_data_int[i]);
    tt}
    t}
    ti = timer_read();
    tprintf("     random read time counter = %dr
    ", i);
    ttest_time = timer_value(i, pclk);
    tprintf("     random read 1.2GB time = %g secr
    ",  test_time);
    tprintf("     random read speed = %g MB/sr
    ", 1200.0/test_time);


    (5)Then I got the result:

         OCM random write speed = 498.653 MB/s
         OCM random read speed = 497.069 MB/s

         DDR  random write speed = 500.616 MB/s
         DDR  random read speed = 497.799 MB/s

    It seems like that there is not much difference between OCM and DDR for random WRITE/READ speed.

    Or, could you figure out that if there is any other problems?

    Thanks,
    Zeepen

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube