AddressDataBus.h Source File
Back to the index.
src
include
AddressDataBus.h
Go to the documentation of this file.
1
#ifndef ADDRESSDATABUS_H
2
#define ADDRESSDATABUS_H
3
4
/*
5
* Copyright (C) 2008-2010 Anders Gavare. All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
*
10
* 1. Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
15
* 3. The name of the author may not be used to endorse or promote products
16
* derived from this software without specific prior written permission.
17
*
18
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28
* SUCH DAMAGE.
29
*/
30
31
#include "
misc.h
"
32
33
34
/**
35
* \brief An interface for implementing components that read/write data via an
36
* address bus.
37
*
38
* Any component which allows data to be read or written by using an address
39
* as an index/offset should implement this interface.
40
*
41
* A typical example of a Component which implements the functions
42
* of this class is the RAMComponent.
43
*/
44
class
AddressDataBus
45
{
46
public
:
47
/**
48
* \brief Constructs an AddressDataBus instance.
49
*/
50
AddressDataBus
() { }
51
52
virtual
~AddressDataBus
() { }
53
54
/**
55
* \brief Place an address on the bus.
56
*
57
* \param address The address to select.
58
*/
59
virtual
void
AddressSelect
(uint64_t address) = 0;
60
61
/**
62
* \brief Reads 8-bit data from the currently selected address.
63
*
64
* \param data A reference to a variable which will receive the data.
65
* \param endianness Selects the endianness of the operation. Ignored
66
* for 8-bit reads and writes.
67
* \return True if the access was successful, false otherwise (e.g.
68
* because of a timeout).
69
*/
70
virtual
bool
ReadData
(uint8_t&
data
,
Endianness
endianness =
BigEndian
) = 0;
71
72
/**
73
* \brief Reads 16-bit data from the currently selected address.
74
*
75
* \param data A reference to a variable which will receive the data.
76
* \param endianness Selects the endianness of the operation.
77
* \return True if the access was successful, false otherwise (e.g.
78
* because of a timeout).
79
*/
80
virtual
bool
ReadData
(uint16_t&
data
,
Endianness
endianness) = 0;
81
82
/**
83
* \brief Reads 32-bit data from the currently selected address.
84
*
85
* \param data A reference to a variable which will receive the data.
86
* \param endianness Selects the endianness of the operation.
87
* \return True if the access was successful, false otherwise (e.g.
88
* because of a timeout).
89
*/
90
virtual
bool
ReadData
(uint32_t&
data
,
Endianness
endianness) = 0;
91
92
/**
93
* \brief Reads 64-bit data from the currently selected address.
94
*
95
* \param data A reference to a variable which will receive the data.
96
* \param endianness Selects the endianness of the operation.
97
* \return True if the access was successful, false otherwise (e.g.
98
* because of a timeout).
99
*/
100
virtual
bool
ReadData
(uint64_t&
data
,
Endianness
endianness) = 0;
101
102
/**
103
* \brief Writes 8-bit data to the currently selected address.
104
*
105
* \param data A reference to a variable which contains the data.
106
* \param endianness Selects the endianness of the operation. Ignored
107
* for 8-bit reads and writes.
108
* \return True if the access was successful, false otherwise (e.g.
109
* because of a timeout).
110
*/
111
virtual
bool
WriteData
(
const
uint8_t&
data
,
Endianness
endianness =
BigEndian
) = 0;
112
113
/**
114
* \brief Writes 16-bit data to the currently selected address.
115
*
116
* \param data A reference to a variable which contains the data.
117
* \param endianness Selects the endianness of the operation.
118
* \return True if the access was successful, false otherwise (e.g.
119
* because of a timeout).
120
*/
121
virtual
bool
WriteData
(
const
uint16_t&
data
,
Endianness
endianness) = 0;
122
123
/**
124
* \brief Writes 32-bit data to the currently selected address.
125
*
126
* \param data A reference to a variable which contains the data.
127
* \param endianness Selects the endianness of the operation.
128
* \return True if the access was successful, false otherwise (e.g.
129
* because of a timeout).
130
*/
131
virtual
bool
WriteData
(
const
uint32_t&
data
,
Endianness
endianness) = 0;
132
133
/**
134
* \brief Writes 64-bit data to the currently selected address.
135
*
136
* \param data A reference to a variable which contains the data.
137
* \param endianness Selects the endianness of the operation.
138
* \return True if the access was successful, false otherwise (e.g.
139
* because of a timeout).
140
*/
141
virtual
bool
WriteData
(
const
uint64_t&
data
,
Endianness
endianness) = 0;
142
};
143
144
145
#endif // ADDRESSDATABUS_H
data
u_short data
Definition:
siireg.h:79
AddressDataBus::ReadData
virtual bool ReadData(uint8_t &data, Endianness endianness=BigEndian)=0
Reads 8-bit data from the currently selected address.
AddressDataBus::AddressDataBus
AddressDataBus()
Constructs an AddressDataBus instance.
Definition:
AddressDataBus.h:50
AddressDataBus::WriteData
virtual bool WriteData(const uint8_t &data, Endianness endianness=BigEndian)=0
Writes 8-bit data to the currently selected address.
misc.h
Endianness
Endianness
Definition:
misc.h:156
AddressDataBus::AddressSelect
virtual void AddressSelect(uint64_t address)=0
Place an address on the bus.
AddressDataBus::~AddressDataBus
virtual ~AddressDataBus()
Definition:
AddressDataBus.h:52
AddressDataBus
An interface for implementing components that read/write data via an address bus.
Definition:
AddressDataBus.h:44
BigEndian
@ BigEndian
Definition:
misc.h:158
Generated on Tue Mar 24 2020 14:04:48 for GXemul by
1.8.17