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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [peripheral/] [test.c] - Blame information for rev 1359

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 970 simons
#include <stdio.h>
2 1350 nogj
 
3
#include "config.h"
4
 
5
#ifdef HAVE_INTTYPES_H
6
#include <inttypes.h>
7
#endif
8
 
9
#include "port.h"
10
#include "arch.h"
11 970 simons
#include "sim-config.h"
12
#include "abstract.h"
13
#include "except.h"
14
 
15 1350 nogj
uint32_t array[128];
16 970 simons
 
17
/* Test write */
18 1359 nogj
void test_write32 (oraddr_t addr, uint32_t value, void *dat)
19 970 simons
{
20
  if (addr & 0x00000080)
21
    array[addr & 0x7f] = value;
22
  else
23
    except_handle(EXCEPT_BUSERR, cur_vadd);
24
}
25
 
26
/* Test read */
27 1359 nogj
uint32_t test_read32 (oraddr_t addr, void *dat)
28 970 simons
{
29
  if (addr & 0x00000080)
30
    return ~array[addr & 0x7f];
31
  else
32
    except_handle(EXCEPT_BUSERR, cur_vadd);
33
    return 0x00000000;
34
}
35
 
36
void test_reset ()
37
{
38
  int i;
39
 
40
  for (i = 0; i < 128; i++)
41
    array[i] = 0x00000000;
42
 
43
  if (config.test.enabled) {
44
    if (config.test.baseaddr)
45 1359 nogj
      register_memoryarea(config.test.baseaddr, 256, 4, 0, test_read32, test_write32, NULL);
46 970 simons
  }
47
}
48 1358 nogj
 
49
/*---------------------------------------------------[ Test configuration ]---*/
50
void test_enabled(union param_val val, void *dat)
51
{
52
  config.test.enabled = val.int_val;
53
}
54
 
55
void test_baseaddr(union param_val val, void *dat)
56
{
57
  config.test.baseaddr = val.addr_val;
58
}
59
 
60
void reg_test_sec(void)
61
{
62
  struct config_section *sec = reg_config_sec("test", NULL, NULL);
63
 
64
  reg_config_param(sec, "enabled", paramt_int, test_enabled);
65
  reg_config_param(sec, "baseaddr", paramt_addr, test_baseaddr);
66
}

powered by: WebSVN 2.1.0

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