OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [testbench/] [mc_dram.c] - Diff between revs 997 and 1024

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 997 Rev 1024
Line 57... Line 57...
            mc_csc = (unsigned long*)(MC_BASE + MC_CSC(ch));
            mc_csc = (unsigned long*)(MC_BASE + MC_CSC(ch));
            SET_FIELD(*mc_csc, MC_CSC, MS,  mc_sdram_cs[ch].MS);
            SET_FIELD(*mc_csc, MC_CSC, MS,  mc_sdram_cs[ch].MS);
            SET_FIELD(*mc_csc, MC_CSC, BW,  mc_sdram_cs[ch].BW);
            SET_FIELD(*mc_csc, MC_CSC, BW,  mc_sdram_cs[ch].BW);
            SET_FIELD(*mc_csc, MC_CSC, SEL, mc_sdram_cs[ch].M);
            SET_FIELD(*mc_csc, MC_CSC, SEL, mc_sdram_cs[ch].M);
            SET_FLAG(*mc_csc, MC_CSC, EN);
            SET_FLAG(*mc_csc, MC_CSC, EN);
            PRINTF ("Channel Config %d - CSC = 0x%08lX\n", ch, *mc_csc);
            printf ("Channel Config %d - CSC = 0x%08lX\n", ch, *mc_csc);
        }
        }
    }
    }
 
 
    return 0;
    return 0;
}
}
Line 81... Line 81...
      mc_sdram_cs[ch].MS = GET_FIELD(*mc_csc, MC_CSC, MS);
      mc_sdram_cs[ch].MS = GET_FIELD(*mc_csc, MC_CSC, MS);
      mc_sdram_cs[ch].BW = GET_FIELD(*mc_csc, MC_CSC, BW);
      mc_sdram_cs[ch].BW = GET_FIELD(*mc_csc, MC_CSC, BW);
      mc_sdram_cs[ch].M  = GET_FIELD(*mc_csc, MC_CSC, SEL);
      mc_sdram_cs[ch].M  = GET_FIELD(*mc_csc, MC_CSC, SEL);
      mc_cs |= (1 << ch);
      mc_cs |= (1 << ch);
 
 
      PRINTF("get_config(%d) : MS=0x%0lx, BW=0x%0lx, M=0x%0lx\n", ch,
      printf("get_config(%d) : MS=0x%0lx, BW=0x%0lx, M=0x%0lx\n", ch,
             mc_sdram_cs[ch].MS,
             mc_sdram_cs[ch].MS,
             mc_sdram_cs[ch].BW,
             mc_sdram_cs[ch].BW,
             mc_sdram_cs[ch].M);
             mc_sdram_cs[ch].M);
    }
    }
  }
  }
  PRINTF("get_config() : cs=0x%0x\n", mc_cs);
  printf("get_config() : cs=0x%0x\n", mc_cs);
  return 0;
  return 0;
}
}
 
 
int main()
int main()
{
{
Line 118... Line 118...
    randomin(7435);
    randomin(7435);
    lpoc = *mc_poc;
    lpoc = *mc_poc;
 
 
#ifdef MC_READ_CONF
#ifdef MC_READ_CONF
    if (get_config()) {
    if (get_config()) {
      PRINTF("Error reading MC configuration\n");
      printf("Error reading MC configuration\n");
      report(0x00000001);
      report(0x00000001);
      return(1);
      return(1);
    }
    }
#else
#else
    mc_cs = MC_SDRAM_CSMASK;
    mc_cs = MC_SDRAM_CSMASK;
#endif
#endif
 
 
    for (ch=0; ch<8; ch++) {
    for (ch=0; ch<8; ch++) {
        if (mc_cs & (0x01 << ch) ) {
        if (mc_cs & (0x01 << ch) ) {
            PRINTF ("--- Begin Test on CS%d ---\n", ch);
            printf ("--- Begin Test on CS%d ---\n", ch);
 
 
            mc_csc = (unsigned long*)(MC_BASE + MC_CSC(ch));
            mc_csc = (unsigned long*)(MC_BASE + MC_CSC(ch));
            mc_tms = (unsigned long*)(MC_BASE + MC_TMS(ch));
            mc_tms = (unsigned long*)(MC_BASE + MC_TMS(ch));
            mc_sel = GET_FIELD(*mc_csc, MC_CSC, SEL);
            mc_sel = GET_FIELD(*mc_csc, MC_CSC, SEL);
 
 
Line 170... Line 170...
                nRowSize = MC_SDRAM_ROWSIZE_8;
                nRowSize = MC_SDRAM_ROWSIZE_8;
                nRows    = MC_SDRAM_ROWS_8;
                nRows    = MC_SDRAM_ROWS_8;
                nRowSh   = MC_SDRAM_ROWSH_8; break;
                nRowSh   = MC_SDRAM_ROWSH_8; break;
            }
            }
 
 
            PRINTF ("CS configuration : CSC - 0x%08lX, TMS - 0x%08lX, rs = %lu, nr = %lu, sh = %lu, sel = %lu\n",
            printf ("CS configuration : CSC - 0x%08lX, TMS - 0x%08lX, rs = %lu, nr = %lu, sh = %lu, sel = %lu\n",
                    *mc_csc, *mc_tms, nRowSize, nRows, nRowSh, mc_sel);
                    *mc_csc, *mc_tms, nRowSize, nRows, nRowSh, mc_sel);
 
 
            /*nRows -= MC_SDRAM_ROW_OFF;*/
            /*nRows -= MC_SDRAM_ROW_OFF;*/
            for (test=0; test<16; test++) {
            for (test=0; test<16; test++) {
                /* configure MC*/
                /* configure MC*/
Line 281... Line 281...
                    SET_FLAG(*mc_tms, MC_TMS_SDRAM, BT); /* interleaved burst */
                    SET_FLAG(*mc_tms, MC_TMS_SDRAM, BT); /* interleaved burst */
                    SET_FIELD(*mc_tms, MC_TMS_SDRAM, BL, 1); /* 2 */
                    SET_FIELD(*mc_tms, MC_TMS_SDRAM, BL, 1); /* 2 */
                    break;
                    break;
                } /*switch test*/
                } /*switch test*/
 
 
                PRINTF ("Begin TEST %lu : CSC - 0x%08lX, TMS - 0x%08lX\n", test, *mc_csc, *mc_tms);
                printf ("Begin TEST %lu : CSC - 0x%08lX, TMS - 0x%08lX\n", test, *mc_csc, *mc_tms);
 
 
                if (MC_SDRAM_ACC & MC_SDRAM_SROW) {
                if (MC_SDRAM_ACC & MC_SDRAM_SROW) {
                    /* perform sequential row access */
                    /* perform sequential row access */
                    PRINTF("Seuential Row\n");
                    printf("Seuential Row\n");
                    for (j=0; j<T_ROWS; j++) {
                    for (j=0; j<T_ROWS; j++) {
                        nAddress  = mc_sel << 21;
                        nAddress  = mc_sel << 21;
                        nAddress |= MC_MEM_BASE;
                        nAddress |= MC_MEM_BASE;
                        nAddress += ( (j + T_ROW_OFF) << nRowSh);
                        nAddress += ( (j + T_ROW_OFF) << nRowSh);
 
 
                        gpio_pat ^= 0x00000008;
                        gpio_pat ^= 0x00000008;
                        *rgpio_out = gpio_pat;
                        *rgpio_out = gpio_pat;
                        ret = mc_test_row(nAddress, nAddress + T_ROW_SIZE, MC_SDRAM_FLAGS);
                        ret = mc_test_row(nAddress, nAddress + T_ROW_SIZE, MC_SDRAM_FLAGS);
 
 
                        PRINTF("\trow - %lu: nAddress = 0x%08lX, ret = 0x%08lX\n", j, nAddress, ret);
                        printf("\trow - %lu: nAddress = 0x%08lX, ret = 0x%08lX\n", j, nAddress, ret);
 
 
                        if (ret) {
                        if (ret) {
                            gpio_pat ^= 0x00000080;
                            gpio_pat ^= 0x00000080;
                            *rgpio_out = gpio_pat;
                            *rgpio_out = gpio_pat;
                            report(ret);
                            report(ret);
Line 308... Line 308...
                    }
                    }
                }
                }
 
 
                if (MC_SDRAM_ACC & MC_SDRAM_RROW) {
                if (MC_SDRAM_ACC & MC_SDRAM_RROW) {
                    /* perform random row access */
                    /* perform random row access */
                    PRINTF("Random Row\n");
                    printf("Random Row\n");
                    for (j=0; j<T_ROWS; j++) {
                    for (j=0; j<T_ROWS; j++) {
                        nAddress = mc_sel << 21;
                        nAddress = mc_sel << 21;
                        nAddress |= MC_MEM_BASE;
                        nAddress |= MC_MEM_BASE;
                        nAddress += ( (T_ROW_OFF + random(nRows)) << nRowSh);
                        nAddress += ( (T_ROW_OFF + random(nRows)) << nRowSh);
 
 
                        gpio_pat ^= 0x00000008;
                        gpio_pat ^= 0x00000008;
                        *rgpio_out = gpio_pat;
                        *rgpio_out = gpio_pat;
                        ret = mc_test_row(nAddress, nAddress + T_ROW_SIZE, MC_SDRAM_FLAGS);
                        ret = mc_test_row(nAddress, nAddress + T_ROW_SIZE, MC_SDRAM_FLAGS);
 
 
                        PRINTF("\trow - %lu: nAddress = 0x%08lX, ret = 0x%08lX\n", j, nAddress, ret);
                        printf("\trow - %lu: nAddress = 0x%08lX, ret = 0x%08lX\n", j, nAddress, ret);
 
 
                        if (ret) {
                        if (ret) {
                            gpio_pat ^= 0x00000080;
                            gpio_pat ^= 0x00000080;
                            *rgpio_out = gpio_pat;
                            *rgpio_out = gpio_pat;
                            report(ret);
                            report(ret);
Line 331... Line 331...
                    }
                    }
                }
                }
 
 
                if (MC_SDRAM_ACC & MC_SDRAM_SGRP) {
                if (MC_SDRAM_ACC & MC_SDRAM_SGRP) {
                    /* perform sequential row in group access */
                    /* perform sequential row in group access */
                    PRINTF("Sequential Group ");
                    printf("Sequential Group ");
 
 
                    PRINTF("Group Size = %d\n", MC_SDRAM_GROUPSIZE);
                    printf("Group Size = %d\n", MC_SDRAM_GROUPSIZE);
                    for (i=0; i<T_GROUPS; i++) {
                    for (i=0; i<T_GROUPS; i++) {
                        nRowGrp = random(nRows - MC_SDRAM_GROUPSIZE) + T_ROW_OFF;
                        nRowGrp = random(nRows - MC_SDRAM_GROUPSIZE) + T_ROW_OFF;
                        for (j=0; j<MC_SDRAM_GROUPSIZE; j++) {
                        for (j=0; j<MC_SDRAM_GROUPSIZE; j++) {
                            nAddress = mc_sel << 21;
                            nAddress = mc_sel << 21;
                            nAddress |= MC_MEM_BASE;
                            nAddress |= MC_MEM_BASE;
Line 345... Line 345...
 
 
                            gpio_pat ^= 0x00000008;
                            gpio_pat ^= 0x00000008;
                            *rgpio_out = gpio_pat;
                            *rgpio_out = gpio_pat;
                            ret = mc_test_row(nAddress, nAddress + T_ROW_SIZE, MC_SDRAM_FLAGS);
                            ret = mc_test_row(nAddress, nAddress + T_ROW_SIZE, MC_SDRAM_FLAGS);
 
 
                            PRINTF("\trow - %lu: nAddress = 0x%08lX, ret = 0x%08lX\n", j, nAddress, ret);
                            printf("\trow - %lu: nAddress = 0x%08lX, ret = 0x%08lX\n", j, nAddress, ret);
 
 
                            if (ret) {
                            if (ret) {
                                gpio_pat ^= 0x00000080;
                                gpio_pat ^= 0x00000080;
                                *rgpio_out = gpio_pat;
                                *rgpio_out = gpio_pat;
                                report(ret);
                                report(ret);
Line 359... Line 359...
                    }
                    }
                }
                }
 
 
                if (MC_SDRAM_ACC & MC_SDRAM_RGRP) {
                if (MC_SDRAM_ACC & MC_SDRAM_RGRP) {
                    /* perform random row in group access */
                    /* perform random row in group access */
                    PRINTF("Random Group ");
                    printf("Random Group ");
 
 
                    PRINTF("Group Size = %d\n", MC_SDRAM_GROUPSIZE);
                    printf("Group Size = %d\n", MC_SDRAM_GROUPSIZE);
                    for (i=0; i<T_GROUPS; i++) {
                    for (i=0; i<T_GROUPS; i++) {
                        nRowGrp = random(nRows - T_GROUPS) + T_ROW_OFF;
                        nRowGrp = random(nRows - T_GROUPS) + T_ROW_OFF;
                        for (j=0; j<MC_SDRAM_GROUPSIZE; j++) {
                        for (j=0; j<MC_SDRAM_GROUPSIZE; j++) {
                            nAddress = mc_sel << 21;
                            nAddress = mc_sel << 21;
                            nAddress |= MC_MEM_BASE;
                            nAddress |= MC_MEM_BASE;
Line 373... Line 373...
 
 
                            gpio_pat ^= 0x00000008;
                            gpio_pat ^= 0x00000008;
                            *rgpio_out = gpio_pat;
                            *rgpio_out = gpio_pat;
                            ret = mc_test_row(nAddress, nAddress + T_ROW_SIZE, MC_SDRAM_FLAGS);
                            ret = mc_test_row(nAddress, nAddress + T_ROW_SIZE, MC_SDRAM_FLAGS);
 
 
                            PRINTF("\trow - %lu: nAddress = 0x%08lX, ret = 0x%08lX\n", j, nAddress, ret);
                            printf("\trow - %lu: nAddress = 0x%08lX, ret = 0x%08lX\n", j, nAddress, ret);
 
 
                            if (ret) {
                            if (ret) {
                                gpio_pat ^= 0x00000080;
                                gpio_pat ^= 0x00000080;
                                *rgpio_out = gpio_pat;
                                *rgpio_out = gpio_pat;
                                report(ret);
                                report(ret);
Line 388... Line 388...
                } /*for groups*/
                } /*for groups*/
 
 
            } /*for test*/
            } /*for test*/
        } /*if*/
        } /*if*/
    } /*for CS*/
    } /*for CS*/
    PRINTF("--- End SDRAM tests ---\n");
    printf("--- End SDRAM tests ---\n");
    report(0xDEADDEAD);
    report(0xDEADDEAD);
 
 
    gpio_pat ^= 0x00000020;
    gpio_pat ^= 0x00000020;
    *rgpio_out = gpio_pat;
    *rgpio_out = gpio_pat;
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.