OpenASIP 2.2
Loading...
Searching...
No Matches
BaseType.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 BaseType.hh
26 * @author Pekka Jääskeläinen (pjaaskel-no.spam-cs.tut.fi) 2003
27 * @note This file is used in compiled simulation. Keep dependencies *clean*
28 *
29 * This file contains definitions of base data types such as Word, HalfWord,
30 * Byte. These types have fixed, machine-independent bit width. If no
31 * base type of the host machine that matches the required bit width
32 * is found, compilation fails. In this case, it is necessary to add
33 * new cases to the type definitions for the host machine at hand.
34 *
35 * If the host machine does not support IEC 559 (formerly, IEEE-754)
36 * floating point types as native built-in types, then the floating point
37 * type definitions should be replaced by abstract data types with all the
38 * operators applicable to floating-point types appropriately overloaded.
39 */
40
41#ifndef TTA_BASETYPE_HH
42#define TTA_BASETYPE_HH
43
44#include "tce_config_public.h"
45
46#define SIZEOF_LONG 8
47
48#if SIZEOF_LONG == 8
49typedef unsigned long LongWord;
50typedef long SignedLongWord;
51typedef unsigned long ULongWord;
52typedef long SLongWord;
53#else
54typedef unsigned long long LongWord;
55typedef long long SignedLongWord;
56typedef unsigned long long ULongWord;
57typedef long long SLongWord;
58#endif
59
60
61#if SIZEOF_FLOAT == 4
62
63/**
64 * Machine-independent definition of 4-byte single precision IEC 559
65 * floating point type.
66 */
67typedef float Float;
68
69#else
70#error Host machine size of float not 4 bytes as expected.
71#endif
72
73#if SIZEOF_DOUBLE == 8
74
75/**
76 * Machine-independent definition of 8-byte double precision IEC 559
77 * floating point type.
78 */
79typedef double Double;
80
81#else
82#error Host machine size of double not 8 bytes as expected.
83#endif
84
85#if SIZEOF_INT == 4
86
87/**
88 * Machine-independent definition of 4-byte unsigned word type.
89 */
90typedef unsigned int Word;
91
92/**
93 * Machine-independent definition of 4-byte signed word type.
94 */
95typedef int SignedWord;
96
97
98#else
99#error Host machine size of int not 4 bytes as expected.
100#endif
101
102#if SIZEOF_SHORT == 2
103
104/**
105 * Machine-independent definition of 2-byte half-word type.
106 */
107typedef unsigned short int HalfWord;
108
109#else
110#error Host machine size of short int not 2 bytes as expected.
111#endif
112
113/**
114 * Machine-independent definition of byte type.
115 */
116typedef unsigned char Byte;
117
118/**
119 * HOST_WORDS_BIGENDIAN is 1 when the host machine lays out the most
120 * significant byte of the word at the lowest memory address.
121 */
122#ifndef WORDS_BIGENDIAN
123#define HOST_BIGENDIAN 0
124#define WORDS_BIGENDIAN 0
125#else
126#ifndef HOST_BIGENDIAN
127#define HOST_BIGENDIAN 1
128#endif
129#endif
130
131/**
132 * 32bit unsigned integer (alias for Word).
133 */
134typedef Word UInt32;
135
136const Byte BYTE_BITWIDTH = 8*sizeof(Byte);
137const Byte HALFWORD_BITWIDTH = 8*sizeof(HalfWord);
138const Byte WORD_BITWIDTH = 8*sizeof(Word);
140
141/**
142 * Maximum sized unsigned integer used in simulation in 32-bit mode.
143 */
144typedef Word UIntWord;
145
146/**
147 * Maximum sized signed integer used in simulation in 32-bit mode.
148 */
149typedef SignedWord SIntWord;
150
151/**
152 * Maximum size of integer in simulator.
153 */
154const Byte INT_WORD_SIZE = 8 * sizeof(UIntWord);
155
156/**
157 * A single-precision, IEC 559 floating-point number used in
158 * simulation.
159 */
160typedef float FloatWord;
161
162/**
163 * A double-precision, IEC 559 floating-point number used in
164 * simulation.
165 */
166typedef double DoubleWord;
167
168const Byte FLT_WORD_SIZE = 8 * sizeof(FloatWord);
169const Byte DBL_WORD_SIZE = 8 * sizeof(DoubleWord);
170
171/*
172 * Instruction and data addresses are represented as regular unsigned 32 bit
173 * integers.
174 */
177
178/// Type for storing addresses to memory image.
180
181/// Type for storing a MAU (must be unsigned type!). This limits
182/// the maximum size of the simulated minimum addressable unit in
183/// the target's data memory.
185
186/// Type for storing simulation cycle counts.
187typedef long long CycleCount;
188
189#endif
190
unsigned long ULongWord
Definition BaseType.hh:51
const Byte WORD_BITWIDTH
Definition BaseType.hh:138
long long CycleCount
Type for storing simulation cycle counts.
Definition BaseType.hh:187
const Byte FLT_WORD_SIZE
Definition BaseType.hh:168
unsigned long LongWord
Definition BaseType.hh:49
UInt32 DataAddress
Definition BaseType.hh:176
const Byte HALFWORD_BITWIDTH
Definition BaseType.hh:137
Word UIntWord
Definition BaseType.hh:144
UInt32 AddressImage
Type for storing addresses to memory image.
Definition BaseType.hh:179
const Byte INT_WORD_SIZE
Definition BaseType.hh:154
Word MinimumAddressableUnit
Type for storing a MAU (must be unsigned type!). This limits the maximum size of the simulated minimu...
Definition BaseType.hh:184
UInt32 InstructionAddress
Definition BaseType.hh:175
const Byte LONGWORD_BITWIDTH
Definition BaseType.hh:139
float FloatWord
Definition BaseType.hh:160
long SLongWord
Definition BaseType.hh:52
long SignedLongWord
Definition BaseType.hh:50
const Byte BYTE_BITWIDTH
Definition BaseType.hh:136
Word UInt32
Definition BaseType.hh:134
unsigned char Byte
Definition BaseType.hh:116
double DoubleWord
Definition BaseType.hh:166
SignedWord SIntWord
Definition BaseType.hh:149
const Byte DBL_WORD_SIZE
Definition BaseType.hh:169