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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [zipdbg/] [devbus.h] - Blame information for rev 194

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

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

powered by: WebSVN 2.1.0

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