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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [sdram/] [board/] [sdram-rows.c] - Blame information for rev 426

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 349 julius
/*
2
 * SDRAM row test, for running on the board (with printfs)
3
 *
4
 * Tests accessing every row
5
 *
6
*/
7
 
8 426 julius
#include "cpu-utils.h"
9 349 julius
#include "board.h"
10
#include "sdram.h"
11
#include "uart.h"
12
#include "printf.h"
13 426 julius
 
14
#ifndef _SDRAM_H_
15
#define _SDRAM_H_
16
 
17
#ifdef  MT48LC32M16A2 // 64MB SDRAM part
18
#define SDRAM_SIZE 0x04000000
19
#define SDRAM_ROW_SIZE 2048 // in bytes (10 bits col addr, 2 bytes per)
20
#define SDRAM_NUM_ROWS_PER_BANK (8192) // 13-bit row address
21
#define SDRAM_NUM_BANKS 4
22
#endif
23
 
24
#ifdef  MT48LC16M16A2 // 32MB SDRAM part
25
#define SDRAM_SIZE 0x02000000
26
#define SDRAM_ROW_SIZE 1024 // in bytes (9 bits col addr, 2 bytes per)
27
#define SDRAM_NUM_ROWS_PER_BANK (8192) // 13-bit row address
28
#define SDRAM_NUM_BANKS 4
29
#endif
30
 
31
#ifdef MT48LC4M16A2 // 8MB SDRAM part
32
#define SDRAM_SIZE 0x800000
33
#define SDRAM_ROW_SIZE 512 // in bytes (8 bits col addr, 2 bytes per)
34
#define SDRAM_NUM_ROWS_PER_BANK (4096) // 12-bit row address
35
#define SDRAM_NUM_BANKS 4
36
#endif
37
 
38
 
39
#endif
40
 
41
 
42 349 julius
#define SDRAM_NUM_ROWS (SDRAM_NUM_ROWS_PER_BANK * SDRAM_NUM_BANKS)
43
 
44
#define START_ROW 128
45
 
46
int main()
47
{
48
 
49
  uart_init(DEFAULT_UART);
50
 
51
 
52
  printf("\n\tSDRAM rows test\n");
53
 
54
  printf("\n\tWriting\n");
55
 
56 426 julius
  int i; // Skip first 64KB, code/stack resides there - TODO determine this from
57
  // stack linker variable!
58 349 julius
  for(i=START_ROW;i<(SDRAM_NUM_ROWS);i++)
59
    {
60
      REG32((i*(SDRAM_ROW_SIZE))) = i;
61
      printf("\r\t0x%x", i);
62
    }
63
 
64
  printf("\n\tReading\n");
65
 
66
  int read_result = 0;
67
 
68
  for(i=START_ROW;i<(SDRAM_NUM_ROWS);i++)
69
    {
70
      printf("\r\t0x%x", i);
71
      read_result = REG32((i*(SDRAM_ROW_SIZE)));
72
      if (read_result != i)
73
        {
74
          printf("\n\Error at 0x%x, read 0x%x, expected 0x%x\n",
75
                 (i*SDRAM_ROW_SIZE), read_result, i);
76
          report(0xbaaaaaad);
77
          report(i);
78
          report(read_result);
79
          exit(0xbaaaaaad);
80
        }
81
    }
82
  printf("\n\tTest OK.\n");
83
  exit(0x8000000d);
84
}

powered by: WebSVN 2.1.0

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