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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [sw/] [devbus.h] - Blame information for rev 112

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

Line No. Rev Author Line
1 5 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    devbus.h
4
//
5
// Project:     XuLA2 board
6
//
7
// Purpose:     The purpose of this file is to document an interface which
8
//              any device with a bus, whether it be implemented over a UART,
9
//      an ethernet, or a PCI express bus, must implement.  This describes
10
//      only an interface, and not how that interface is to be accomplished.
11
//
12
//      The neat part of this interface is that, if programs are designed to
13
//      work with it, than the implementation details may be changed later
14
//      and any program that once worked with the interface should be able
15
//      to continue to do so.  (i.e., switch from a UART controlled bus to a
16
//      PCI express controlled bus, with minimal change to the software of
17
//      interest.)
18
//
19
//
20
// Creator:     Dan Gisselquist, Ph.D.
21
//              Gisselquist Technology, LLC
22
//
23
////////////////////////////////////////////////////////////////////////////////
24
//
25
// Copyright (C) 2015, Gisselquist Technology, LLC
26
//
27
// This program is free software (firmware): you can redistribute it and/or
28
// modify it under the terms of  the GNU General Public License as published
29
// by the Free Software Foundation, either version 3 of the License, or (at
30
// your option) any later version.
31
//
32
// This program is distributed in the hope that it will be useful, but WITHOUT
33
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
34
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
35
// for more details.
36
//
37
// License:     GPL, v3, as defined and found on www.gnu.org,
38
//              http://www.gnu.org/licenses/gpl.html
39
//
40
//
41
////////////////////////////////////////////////////////////////////////////////
42
//
43
//
44
//
45
#ifndef DEVBUS_H
46
#define DEVBUS_H
47
 
48
#include <stdio.h>
49
#include <unistd.h>
50
 
51
typedef unsigned int    uint32;
52
 
53
class   BUSERR {
54
public:
55
        uint32 addr;
56
        BUSERR(const uint32 a) : addr(a) {};
57
};
58
 
59
class   DEVBUS {
60
public:
61
        typedef uint32  BUSW;
62
 
63
        virtual void    kill(void) = 0;
64
        virtual void    close(void) = 0;
65
 
66
        // Write a single value to a single address
67 49 dgisselq
        //      a is the address of the value to be read as it exists on the
68
        //              wishbone bus within the FPGA.
69
        //      v is the singular value to write to this address
70 5 dgisselq
        virtual void    writeio(const BUSW a, const BUSW v) = 0;
71
 
72
        // Read a single value to a single address
73 49 dgisselq
        //      a is the address of the value to be read as it exists on the
74
        //              wishbone bus within the FPGA.
75
        //      This function returns the value read from the device wishbone
76
        //              at address a.
77 5 dgisselq
        virtual BUSW    readio(const BUSW a) = 0;
78
 
79
        // Read a series of values from values from a block of memory
80 49 dgisselq
        //      a is the address of the value to be read as it exists on the
81
        //              wishbone bus within the FPGA.
82
        //      len is the number of words to read
83
        //      buf is a pointer to a place to store the words once read.
84
        // This is equivalent to:
85
        //      for(int i=0; i<len; i++)
86
        //              buf[i] = readio(a+i);
87
        // only it's faster in our implementation.
88 5 dgisselq
        virtual void    readi(const BUSW a, const int len, BUSW *buf) = 0;
89
 
90 49 dgisselq
        // Read a series of values from the same address in memory.  This 
91
        // call is identical to readi, save that the address is not incremented
92
        // from one read to the next.  It is equivalent to:
93
        //      for(int i=0; i<len; i++)
94
        //              buf[i] = readio(a);
95
        // only it's faster in our implementation.
96
        //
97 5 dgisselq
        virtual void    readz(const BUSW a, const int len, BUSW *buf) = 0;
98
 
99 49 dgisselq
        // Write a series of values into a block of memory on the FPGA
100
        //      a is the address of the value to be written as it exists on the
101
        //              wishbone bus within the FPGA.
102
        //      len is the number of words to write
103
        //      buf is a pointer to a place to from whence to grab the data
104
        //              to be written.
105
        // This is equivalent to:
106
        //      for(int i=0; i<len; i++)
107
        //              writeio(a+i, buf[i]);
108
        // only it's faster in our implementation.
109 5 dgisselq
        virtual void    writei(const BUSW a, const int len, const BUSW *buf) = 0;
110 49 dgisselq
        // Write a series of values into the same address on the FPGA bus.  This
111
        // call is identical to writei, save that the address is not incremented
112
        // from one write to the next.  It is equivalent to:
113
        //      for(int i=0; i<len; i++)
114
        //              writeio(a, buf[i]);
115
        // only it's faster in our implementation.
116
        //
117 5 dgisselq
        virtual void    writez(const BUSW a, const int len, const BUSW *buf) = 0;
118
 
119
        // Query whether or not an interrupt has taken place
120
        virtual bool    poll(void) = 0;
121
 
122
        // Sleep until interrupt, but sleep no longer than msec milliseconds
123
        virtual void    usleep(unsigned msec) = 0;
124
 
125
        // Sleep until an interrupt, no matter how long it takes for that
126
        // interrupt to take place
127
        virtual void    wait(void) = 0;
128
 
129
        // Query whether or not a bus error has taken place.  This is somewhat
130
        // of a misnomer, as my current bus error detection code exits any
131
        // interface, but ... it is what it is.
132
        virtual bool    bus_err(void) const = 0;
133
 
134
        // Clear any bus error condition.
135
        virtual void    reset_err(void) = 0;
136
 
137
        // Clear any interrupt condition that has already been noticed by
138
        // the interface, does not check for further interrupt
139
        virtual void    clear(void) = 0;
140
 
141
        virtual ~DEVBUS(void) { };
142
};
143
 
144
#endif

powered by: WebSVN 2.1.0

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