OpenASIP 2.2
Loading...
Searching...
No Matches
Memory.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file Memory.hh
26 *
27 * Declaration of the base interface for the memory model (Memory class).
28 *
29 * @author Pekka Jääskeläinen 2004 (pekka.jaaskelainen-no.spam-tut.fi)
30 * @note This file is used in compiled simulation. Keep dependencies *clean*
31 * @note rating: red
32 */
33
34
35#ifndef TTA_MEMORY_MODEL_HH
36#define TTA_MEMORY_MODEL_HH
37
38#include "BaseType.hh"
39
40struct WriteRequest;
41struct RequestQueue;
42
43//////////////////////////////////////////////////////////////////////////////
44// Memory
45//////////////////////////////////////////////////////////////////////////////
46
47/**
48 * Memory Model interface provides methods for emulating memory access.
49 *
50 * The interface provides methods for emulating the access to data memory by
51 * operations of the target architecture such as load and store. In addition,
52 * an interface is implemented for direct access to the memory storage for
53 * the debugging user interfaces.
54 *
55 * The abstract base class Memory implements all functionality except for
56 * the actual write() and read() methods which write and read a single unit
57 * to the memory storage as efficiently as possible. That is left for the
58 * derived classes to implement, as it depends on the storage data structure
59 * used, etc.
60 *
61 * Memory base class implements the correct ordering of loads and stores within
62 * the same cycle: loads in the same cycle do not see the values of
63 * the writes in that cycle. That is, the writes are committed to the memory
64 * array at cycleAdvance() call. Derived classes may loosen this behavior
65 * and let the client take care of the correct ordering of the memory
66 * accesses, as is the case with the compiled simulation engine and the
67 * DirectAccessMemory implementation it uses for simulating data memory.
68 *
69 * The Memory abstraction deals with MAUs (commonly bytes). The client can
70 * access the Memory for storing writing doubles and floats in case it
71 * implements floating point memory operations. Interface for those is
72 * out of the abstraction level of this interface.
73 */
74class Memory {
75public:
77 typedef MAU* MAUTable;
78
80 virtual ~Memory();
81
82 virtual void advanceClock();
83
84 virtual void write(ULongWord address, MAU data) = 0;
85 virtual Memory::MAU read(ULongWord address) = 0;
86
87 virtual void writeBE(ULongWord address, int size, ULongWord data);
88 virtual void writeLE(ULongWord address, int size, ULongWord data);
89 void write(ULongWord address, int size, ULongWord data);
90
91 virtual void writeDirectlyBE(ULongWord address, int size, ULongWord data);
92 virtual void writeDirectlyLE(ULongWord address, int size, ULongWord data);
93
94 void write(ULongWord address, FloatWord data);
95 void write(ULongWord address, DoubleWord data);
96 void read(ULongWord address, int size, ULongWord& data);
97 void read(ULongWord address, DoubleWord& data);
98 void read(ULongWord address, FloatWord& data);
99
100 virtual void writeBE(ULongWord address, FloatWord data);
101 virtual void writeBE(ULongWord address, DoubleWord data);
102 virtual void writeLE(ULongWord address, FloatWord data);
103 virtual void writeLE(ULongWord address, DoubleWord data);
104// virtual void readBE(ULongWord address, int size, UIntWord& data);
105 // virtual void readLE(ULongWord address, int size, UIntWord& data);
106 virtual void readBE(ULongWord address, int size, ULongWord& data);
107 virtual void readLE(ULongWord address, int size, ULongWord& data);
108 virtual void readBE(ULongWord address, FloatWord& data);
109 virtual void readBE(ULongWord address, DoubleWord& data);
110 virtual void readLE(ULongWord address, FloatWord& data);
111 virtual void readLE(ULongWord address, DoubleWord& data);
112
113 virtual void reset();
114 virtual void fillWithZeros();
115
116 virtual ULongWord start() { return start_; }
117 virtual ULongWord end() { return end_; }
118 virtual ULongWord MAUSize() { return MAUSize_; }
119
120 bool isLittleEndian() { return littleEndian_; }
121protected:
122
123 void packBE(const Memory::MAUTable data, int size, ULongWord& value);
124 void unpackBE(const ULongWord& value, int size, Memory::MAUTable data);
125 void packLE(const Memory::MAUTable data, int size, ULongWord& value);
126 void unpackLE(const ULongWord& value, int size, Memory::MAUTable data);
127
129private:
130 /// Copying not allowed.
131 Memory(const Memory&);
132 /// Assignment not allowed.
134
135 void checkRange(ULongWord startAddress, int numberOfMAUs);
136
137 /// Starting point of the address space.
139 /// End point of the address space.
141 /// Size of the minimum adressable unit.
143
144 /// The uncommited write requests.
146 /// Mask bit pattern for unpacking IntULongWord to MAUs.
147 int mask_;
148
149};
150
151/// Maximum number of MAUs in a single request supported by the interface.
152#define MAX_ACCESS_SIZE 64
153
154#include "Memory.icc"
155
156#endif
unsigned long ULongWord
Definition BaseType.hh:51
Word MinimumAddressableUnit
Type for storing a MAU (must be unsigned type!). This limits the maximum size of the simulated minimu...
Definition BaseType.hh:184
float FloatWord
Definition BaseType.hh:160
double DoubleWord
Definition BaseType.hh:166
virtual void readLE(ULongWord address, int size, ULongWord &data)
Definition Memory.cc:682
virtual ULongWord end()
Definition Memory.hh:117
Memory(const Memory &)
Copying not allowed.
MAU * MAUTable
Definition Memory.hh:77
bool isLittleEndian()
Definition Memory.hh:120
void packBE(const Memory::MAUTable data, int size, ULongWord &value)
Definition Memory.cc:737
virtual ~Memory()
Definition Memory.cc:80
virtual void reset()
Definition Memory.cc:716
virtual void readBE(ULongWord address, int size, ULongWord &data)
Definition Memory.cc:640
Memory & operator=(const Memory &)
Assignment not allowed.
void unpackLE(const ULongWord &value, int size, Memory::MAUTable data)
Definition Memory.cc:800
bool littleEndian_
Definition Memory.hh:128
void checkRange(ULongWord startAddress, int numberOfMAUs)
Definition Memory.cc:844
ULongWord start_
Starting point of the address space.
Definition Memory.hh:138
ULongWord end_
End point of the address space.
Definition Memory.hh:140
virtual void advanceClock()
Definition Memory.cc:819
virtual void write(ULongWord address, MAU data)=0
Definition Memory.cc:95
RequestQueue * writeRequests_
The uncommited write requests.
Definition Memory.hh:145
virtual void writeDirectlyBE(ULongWord address, int size, ULongWord data)
Definition Memory.cc:112
ULongWord MAUSize_
Size of the minimum adressable unit.
Definition Memory.hh:142
virtual void writeLE(ULongWord address, int size, ULongWord data)
Definition Memory.cc:221
virtual Memory::MAU read(ULongWord address)=0
Definition Memory.cc:160
virtual ULongWord MAUSize()
Definition Memory.hh:118
virtual void writeBE(ULongWord address, int size, ULongWord data)
Definition Memory.cc:194
virtual ULongWord start()
Definition Memory.hh:116
virtual void fillWithZeros()
Definition Memory.cc:704
void packLE(const Memory::MAUTable data, int size, ULongWord &value)
Definition Memory.cc:757
MinimumAddressableUnit MAU
Definition Memory.hh:76
virtual void writeDirectlyLE(ULongWord address, int size, ULongWord data)
Definition Memory.cc:137
int mask_
Mask bit pattern for unpacking IntULongWord to MAUs.
Definition Memory.hh:147
void write(ULongWord address, FloatWord data)
void unpackBE(const ULongWord &value, int size, Memory::MAUTable data)
Definition Memory.cc:778