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

Subversion Repositories wbscope

[/] [wbscope/] [trunk/] [sw/] [devbus.h] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    devbus.h
4
//
5
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
6
//
7
// Purpose:     The purpose of this file is to document an interface which
8 14 dgisselq
//              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 dgisselq
//
12 14 dgisselq
//      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 12 dgisselq
//
19 14 dgisselq
//
20 12 dgisselq
// Creator:     Dan Gisselquist, Ph.D.
21
//              Gisselquist Technology, LLC
22
//
23
////////////////////////////////////////////////////////////////////////////////
24
//
25 14 dgisselq
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
26 12 dgisselq
//
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
// You should have received a copy of the GNU General Public License along
38 14 dgisselq
// with this program.  (It's in the $(ROOT)/doc directory.  Run make with no
39 12 dgisselq
// target there if the PDF file isn't present.)  If not, see
40
// <http://www.gnu.org/licenses/> for a copy.
41
//
42
// License:     GPL, v3, as defined and found on www.gnu.org,
43
//              http://www.gnu.org/licenses/gpl.html
44
//
45
//
46
////////////////////////////////////////////////////////////////////////////////
47
//
48
//
49
#ifndef DEVBUS_H
50
#define DEVBUS_H
51
 
52
#include <stdio.h>
53
#include <unistd.h>
54
 
55
typedef unsigned int    uint32;
56
 
57
class   BUSERR {
58
public:
59
        uint32 addr;
60
        BUSERR(const uint32 a) : addr(a) {};
61
};
62
 
63
class   DEVBUS {
64
public:
65
        typedef uint32  BUSW;
66
 
67
        virtual void    kill(void) = 0;
68
        virtual void    close(void) = 0;
69
 
70
        // Write a single value to a single address
71 14 dgisselq
        //      a is the address of the value to be read as it exists on the
72
        //              wishbone bus within the FPGA.
73
        //      v is the singular value to write to this address
74 12 dgisselq
        virtual void    writeio(const BUSW a, const BUSW v) = 0;
75
 
76
        // Read a single value to a single address
77 14 dgisselq
        //      a is the address of the value to be read as it exists on the
78
        //              wishbone bus within the FPGA.
79
        //      This function returns the value read from the device wishbone
80
        //              at address a.
81 12 dgisselq
        virtual BUSW    readio(const BUSW a) = 0;
82
 
83
        // Read a series of values from values from a block of memory
84 14 dgisselq
        //      a is the address of the value to be read as it exists on the
85
        //              wishbone bus within the FPGA.
86
        //      len is the number of words to read
87
        //      buf is a pointer to a place to store the words once read.
88
        // This is equivalent to:
89
        //      for(int i=0; i<len; i++)
90
        //              buf[i] = readio(a+i);
91
        // only it's faster in our implementation.
92 12 dgisselq
        virtual void    readi(const BUSW a, const int len, BUSW *buf) = 0;
93
 
94 14 dgisselq
        // Read a series of values from the same address in memory.  This
95
        // call is identical to readi, save that the address is not incremented
96
        // from one read to the next.  It is equivalent to:
97
        //      for(int i=0; i<len; i++)
98
        //              buf[i] = readio(a);
99
        // only it's faster in our implementation.
100
        //
101 12 dgisselq
        virtual void    readz(const BUSW a, const int len, BUSW *buf) = 0;
102
 
103 14 dgisselq
        // Write a series of values into a block of memory on the FPGA
104
        //      a is the address of the value to be written as it exists on the
105
        //              wishbone bus within the FPGA.
106
        //      len is the number of words to write
107
        //      buf is a pointer to a place to from whence to grab the data
108
        //              to be written.
109
        // This is equivalent to:
110
        //      for(int i=0; i<len; i++)
111
        //              writeio(a+i, buf[i]);
112
        // only it's faster in our implementation.
113 12 dgisselq
        virtual void    writei(const BUSW a, const int len, const BUSW *buf) = 0;
114 14 dgisselq
        // Write a series of values into the same address on the FPGA bus.  This
115
        // call is identical to writei, save that the address is not incremented
116
        // from one write to the next.  It is equivalent to:
117
        //      for(int i=0; i<len; i++)
118
        //              writeio(a, buf[i]);
119
        // only it's faster in our implementation.
120
        //
121 12 dgisselq
        virtual void    writez(const BUSW a, const int len, const BUSW *buf) = 0;
122
 
123
        // Query whether or not an interrupt has taken place
124
        virtual bool    poll(void) = 0;
125
 
126
        // Sleep until interrupt, but sleep no longer than msec milliseconds
127
        virtual void    usleep(unsigned msec) = 0;
128
 
129
        // Sleep until an interrupt, no matter how long it takes for that
130
        // interrupt to take place
131
        virtual void    wait(void) = 0;
132
 
133
        // Query whether or not a bus error has taken place.  This is somewhat
134
        // of a misnomer, as my current bus error detection code exits any
135
        // interface, but ... it is what it is.
136
        virtual bool    bus_err(void) const = 0;
137
 
138
        // Clear any bus error condition.
139
        virtual void    reset_err(void) = 0;
140
 
141
        // Clear any interrupt condition that has already been noticed by
142
        // the interface, does not check for further interrupt
143
        virtual void    clear(void) = 0;
144
 
145
        virtual ~DEVBUS(void) { };
146
};
147
 
148
#endif

powered by: WebSVN 2.1.0

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