OpenASIP  2.0
BEMGenerator.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 BEMGenerator.hh
26  *
27  * Declaration of BEMGenerator class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_BEM_GENERATOR_HH
34 #define TTA_BEM_GENERATOR_HH
35 
36 #include <map>
37 #include <vector>
38 
39 #include "Socket.hh"
40 
41 class BinaryEncoding;
42 class MoveSlot;
44 class DestinationField;
45 class SourceField;
46 class GuardField;
47 class SocketCodeTable;
48 
49 namespace TTAMachine {
50  class Machine;
51  class Socket;
52  class Bus;
53  class Bridge;
54  class BaseRegisterFile;
55  class OperationTriggeredFormat;
56 }
57 
58 /**
59  * Generates a binary encoding map for the given machine.
60  */
61 class BEMGenerator {
62 public:
64  virtual ~BEMGenerator();
65 
67 
68 private:
69  /// Map type for storing Socket - SocketCodeTable pairs.
70  typedef std::map<const TTAMachine::Socket*, SocketCodeTable*> SCTableMap;
71  /// Typedef for encoding (first = encoding, second = extra bits).
72  typedef std::pair<unsigned int, unsigned int> Encoding;
73 
76  void addTopLevelFields(BinaryEncoding& bem) const;
77  void addSubfields(MoveSlot& slot) const;
78  void addEncodings(ImmediateControlField& field) const;
79  void addEncodings(DestinationField& field) const;
80  void addEncodings(SourceField& field) const;
81  void addEncodings(GuardField& field) const;
82 
84  BinaryEncoding& bem) const;
85 
86  void addPortCodes(
87  SocketCodeTable& table,
88  const TTAMachine::Socket& socket) const;
91  const TTAMachine::Socket& socket) const;
93  const TTAMachine::Socket* socket,
94  SocketCodeTable* table);
95  std::multiset<int> socketCodeWidthsForBus(
96  const TTAMachine::Bus& bus,
97  TTAMachine::Socket::Direction socketDir) const;
98  unsigned int maxLongImmSlotWidth(const MoveSlot& slot) const;
99 
100  static int socketCount(
101  const TTAMachine::Bus& bus,
103  static TTAMachine::Socket& socket(
104  int index,
105  const TTAMachine::Bus& bus,
107  static bool needsSocketCodeTable(const TTAMachine::Socket& socket);
108  static bool haveEqualConnections(
109  const TTAMachine::Socket& socket1,
110  const TTAMachine::Socket& socket2);
111  static int sourceBridgeCount(const TTAMachine::Bus& bus);
113  int index,
114  const TTAMachine::Bus& bus);
115  static bool hasUnconditionalGuard(const TTAMachine::Bus& bus);
116  static int requiredIndexWidth(
117  const TTAMachine::BaseRegisterFile& regFile);
118  static void calculateEncodings(
119  const std::multiset<int>& oppositeFieldWidths,
120  bool leftAlignment,
121  std::multiset<Encoding>& encodings);
122  static void addExtraBits(
123  std::multiset<Encoding>& encodings,
124  int bitCount);
125 
126 
127  /// The machine for which the BEM is generated.
129  /// A map which tells which socket code table belongs to a socket.
131 };
132 
133 #endif
BinaryEncoding
Definition: BinaryEncoding.hh:61
BEMGenerator::socket
static TTAMachine::Socket & socket(int index, const TTAMachine::Bus &bus, TTAMachine::Socket::Direction direction)
Definition: BEMGenerator.cc:817
DestinationField
Definition: DestinationField.hh:44
MoveSlot
Definition: MoveSlot.hh:60
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
BEMGenerator::assignSocketCodeTable
void assignSocketCodeTable(const TTAMachine::Socket *socket, SocketCodeTable *table)
Definition: BEMGenerator.cc:770
BEMGenerator::socketCount
static int socketCount(const TTAMachine::Bus &bus, TTAMachine::Socket::Direction direction)
Definition: BEMGenerator.cc:788
TTAMachine::Bridge
Definition: Bridge.hh:51
BEMGenerator::socketCodeWidthsForBus
std::multiset< int > socketCodeWidthsForBus(const TTAMachine::Bus &bus, TTAMachine::Socket::Direction socketDir) const
Definition: BEMGenerator.cc:1039
TTAMachine::Bus
Definition: Bus.hh:53
BEMGenerator::SCTableMap
std::map< const TTAMachine::Socket *, SocketCodeTable * > SCTableMap
Map type for storing Socket - SocketCodeTable pairs.
Definition: BEMGenerator.hh:70
GuardField
Definition: GuardField.hh:55
BEMGenerator::maxLongImmSlotWidth
unsigned int maxLongImmSlotWidth(const MoveSlot &slot) const
Definition: BEMGenerator.cc:1295
BEMGenerator::addExtraBits
static void addExtraBits(std::multiset< Encoding > &encodings, int bitCount)
Definition: BEMGenerator.cc:1269
TTAMachine::Socket::Direction
Direction
Definition: Socket.hh:58
Socket.hh
BEMGenerator::socketCodeTable
SocketCodeTable * socketCodeTable(const TTAMachine::Socket &socket) const
Definition: BEMGenerator.cc:732
SocketCodeTable
Definition: SocketCodeTable.hh:68
BEMGenerator
Definition: BEMGenerator.hh:61
BEMGenerator::sourceBridge
static TTAMachine::Bridge & sourceBridge(int index, const TTAMachine::Bus &bus)
Definition: BEMGenerator.cc:1124
BEMGenerator::needsSocketCodeTable
static bool needsSocketCodeTable(const TTAMachine::Socket &socket)
Definition: BEMGenerator.cc:851
BEMGenerator::requiredIndexWidth
static int requiredIndexWidth(const TTAMachine::BaseRegisterFile &regFile)
Definition: BEMGenerator.cc:1175
TTAMachine::BaseRegisterFile
Definition: BaseRegisterFile.hh:48
BEMGenerator::addEncodings
void addEncodings(ImmediateControlField &field) const
Definition: BEMGenerator.cc:505
ImmediateControlField
Definition: ImmediateControlField.hh:57
BEMGenerator::addLongImmDstRegisterFields
void addLongImmDstRegisterFields(BinaryEncoding &bem) const
Definition: BEMGenerator.cc:363
BEMGenerator::suitableSocketCodeTable
SocketCodeTable * suitableSocketCodeTable(const TTAMachine::Socket &socket) const
Definition: BEMGenerator.cc:751
TTAMachine::Socket
Definition: Socket.hh:53
BEMGenerator::addSocketCodeTables
void addSocketCodeTables(BinaryEncoding &bem)
Definition: BEMGenerator.cc:125
BEMGenerator::calculateEncodings
static void calculateEncodings(const std::multiset< int > &oppositeFieldWidths, bool leftAlignment, std::multiset< Encoding > &encodings)
Definition: BEMGenerator.cc:1197
BEMGenerator::addPortCodes
void addPortCodes(SocketCodeTable &table, const TTAMachine::Socket &socket) const
Definition: BEMGenerator.cc:887
BEMGenerator::sourceBridgeCount
static int sourceBridgeCount(const TTAMachine::Bus &bus)
Definition: BEMGenerator.cc:1097
TTAMachine::OperationTriggeredFormat
Definition: OperationTriggeredFormat.hh:44
BEMGenerator::Encoding
std::pair< unsigned int, unsigned int > Encoding
Typedef for encoding (first = encoding, second = extra bits).
Definition: BEMGenerator.hh:72
BEMGenerator::BEMGenerator
BEMGenerator(const TTAMachine::Machine &machine)
Definition: BEMGenerator.cc:86
BEMGenerator::addRiscvFormat
void addRiscvFormat(TTAMachine::OperationTriggeredFormat *format, BinaryEncoding &bem) const
Definition: BEMGenerator.cc:198
BEMGenerator::addSubfields
void addSubfields(MoveSlot &slot) const
Definition: BEMGenerator.cc:462
BEMGenerator::scTableMap_
SCTableMap scTableMap_
A map which tells which socket code table belongs to a socket.
Definition: BEMGenerator.hh:130
BEMGenerator::~BEMGenerator
virtual ~BEMGenerator()
Definition: BEMGenerator.cc:94
BEMGenerator::hasUnconditionalGuard
static bool hasUnconditionalGuard(const TTAMachine::Bus &bus)
Definition: BEMGenerator.cc:1156
TTAMachine
Definition: Assembler.hh:48
BEMGenerator::addTopLevelFields
void addTopLevelFields(BinaryEncoding &bem) const
Definition: BEMGenerator.cc:150
BEMGenerator::generate
BinaryEncoding * generate()
Definition: BEMGenerator.cc:104
BEMGenerator::haveEqualConnections
static bool haveEqualConnections(const TTAMachine::Socket &socket1, const TTAMachine::Socket &socket2)
Definition: BEMGenerator.cc:1067
BEMGenerator::machine_
const TTAMachine::Machine * machine_
The machine for which the BEM is generated.
Definition: BEMGenerator.hh:128
TTAMachine::Machine
Definition: Machine.hh:73
SourceField
Definition: SourceField.hh:48