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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [bus/] [c_model/] [ahbarb.c] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tarookumic
#include <tmki.h>
2
#include "ahbarb.h"
3
 
4
ahbarb *ahbarb_create() {
5
  ahbarb *m;
6
 
7
  m = (ahbarb *) ti_alloc(sizeof(ahbarb));
8
  if (!m) { return 0; }
9
 
10
    ti_print_err("\
11
Create ahbarb model (0x%x):\n\
12
Max slaves : %i\n\n",
13
m,AHBARB_MAXSLAVE);
14
 
15
  return m;
16
}
17
 
18
ahbarb *ahbarb_add(ahbarb *m,ahb_write w,ahb_read r, unsigned int start, unsigned int end) {
19
  int i;
20
  for (i = 0;i < AHBARB_MAXSLAVE;i++) {
21
    if (m ->slaves[i].start == 0 &&
22
        m ->slaves[i].end == 0) {
23
      m ->slaves[i].start = start;
24
      m ->slaves[i].end = end;
25
      m ->slaves[i].read = r;
26
      m ->slaves[i].write = w;
27
    }
28
  }
29
}
30
 
31
int ahbarb_read(ahbarb *m,unsigned int addr, unsigned int *data) {
32
  int i;
33
  for (i = 0;i < AHBARB_MAXSLAVE;i++) {
34
    if (m ->slaves[i].start <= addr &&
35
        m ->slaves[i].end > addr) {
36
      return m ->slaves[i].read(addr,data);
37
    }
38
  }
39
  return 0;
40
}
41
 
42
int ahbarb_write(ahbarb *m,unsigned int addr, unsigned int data) {
43
  int i;
44
  for (i = 0;i < AHBARB_MAXSLAVE;i++) {
45
    if (m ->slaves[i].start <= addr &&
46
        m ->slaves[i].end > addr) {
47
      return m ->slaves[i].write(addr,data);
48
    }
49
  }
50
  return 0;
51
}

powered by: WebSVN 2.1.0

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