CGRA-ME
TatumInterface.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * The software programs comprising "CGRA-ME" and the documentation provided
3  * with them are copyright by its authors and the University of Toronto. Only
4  * non-commercial, not-for-profit use of this software is permitted without ex-
5  * plicit permission. This software is provided "as is" with no warranties or
6  * guarantees of support. See the LICENCE for more details. You should have re-
7  * ceived a copy of the full licence along with this software. If not, see
8  * <http://cgra-me.ece.utoronto.ca/license/>.
9  ******************************************************************************/
10 
11 #ifndef __TATUMINTERFACE__H__
12 #define __TATUMINTERFACE__H__
13 
14 #include <algorithm>
15 #include <CGRA/Module.h>
16 #include <CGRA/ModuleComposites.h>
17 #include <CGRA/Mapping.h>
18 #include <CGRA/Util.h>
19 #include <CGRA/PerfEngine.h>
20 #include "tatum/TimingGraph.hpp"
21 #include "tatum/Time.hpp"
22 #include "tatum/TimingConstraints.hpp"
23 #include "tatum/delay_calc/FixedDelayCalculator.hpp"
24 #include "tatum/report/graphviz_dot_writer.hpp"
25 #include "tatum/timing_analyzers.hpp"
26 #include "tatum/graph_walkers.hpp"
27 #include "tatum/analyzer_factory.hpp"
28 #include "tatum/TimingReporter.hpp"
29 
30 using tatum::TimingGraph;
31 using tatum::NodeId;
32 using tatum::NodeType;
33 using tatum::EdgeId;
34 using tatum::EdgeType;
35 using tatum::Time;
36 using tatum::FixedDelayCalculator;
37 using tatum::TimingConstraints;
38 using tatum::TimingReporter;
39 using tatum::DomainId;
40 
41 using tatum::util::linear_map;
42 
43 // Edges represented by pair of MRRGNodes, where the Key drives the Value
44 typedef std::multimap<MRRG::NodeDescriptor, MRRG::NodeDescriptor> EdgeList;
45 
46 class MRRGNameResolver;
47 
48 class PerfEngine;
49 
50 typedef enum TGEntityType
51 {
54 } TGEntityType;
55 
56 typedef struct TGEntity
57 {
60 
61  unsigned width;
62  unsigned used_input = 0;
63  std::vector<std::vector<tatum::NodeId>> ipins; // FU ops tracks 2 lists
64  std::vector<tatum::NodeId> opins;
65 
66  // combinational logic exclusive variable:
67  std::vector<tatum::EdgeId> ipins2opins;
68 
69  // register exclusive variables:
70  std::vector<tatum::NodeId> cpins;
71  std::vector<tatum::NodeId> srcs;
72  std::vector<tatum::NodeId> snks;
73  std::vector<tatum::EdgeId> ipins2snks;
74  std::vector<tatum::EdgeId> srcs2opins;
75  std::vector<tatum::EdgeId> cpins2snks;
76  std::vector<tatum::EdgeId> cpins2srcs;
77 } TGEntity;
78 
80 {
81  public:
82  TatumInterface(std::map<std::string, double>&, PerfEngine*);
83 
84  TatumInterface(const TatumInterface&) = delete;
85  TatumInterface(TatumInterface&&) = delete;
86  TatumInterface& operator=(const TatumInterface&) = delete;
88 
89  void createTatumTimingGraph(EdgeList& m); // sets tg & nr
90  void initializeTatumEngine(EdgeList& m); // sets dc, tc, analyzer, & tr
91  void reportSetupAnalysis();
92  private:
93  std::map<std::string, double>& timingModels;
94  tatum::NodeId clk;
95  tatum::DomainId clkDid;
96  std::shared_ptr<tatum::TimingGraph> tg;
97  std::shared_ptr<MRRGNameResolver> nr;
98  std::shared_ptr<tatum::FixedDelayCalculator> dc;
99  std::shared_ptr<tatum::TimingConstraints> tc;
100  std::shared_ptr<tatum::SetupHoldTimingAnalyzer> analyzer;
101  std::shared_ptr<tatum::TimingReporter> tr;
103  linear_map<tatum::EdgeId, tatum::Time> maxComb;
104  linear_map<tatum::EdgeId, tatum::Time> minComb;
105  linear_map<tatum::EdgeId, tatum::Time> setup;
106  linear_map<tatum::EdgeId, tatum::Time> hold;
107  std::vector<tatum::NodeId> memOut; // FIXME: currently constrained as constant generator
108  std::map<MRRG::NodeDescriptor, std::shared_ptr<TGEntity>> mrrg2tg; // maps an MRRG node to its corresponding tg nodes
109  std::map<tatum::NodeId, MRRG::NodeDescriptor> tg2mrrg; // maps a TG node to its corresponding parent MRRG node
110  void removeWireNodes(EdgeList& orig, EdgeList& reduced);
111  void createTGEntity(MRRG::NodeDescriptor n, bool reduce = true);
112  void connectTGEntities(MRRG::NodeDescriptor from, MRRG::NodeDescriptor to, bool reduce = true);
113  void connectTGClock(MRRG::NodeDescriptor n, bool reduce = true);
115 };
116 
117 class MRRGNameResolver : public tatum::TimingGraphNameResolver
118 {
119  public:
120  MRRGNameResolver(const tatum::TimingGraph& tg): tg_(&tg) {}
121 
122  MRRGNameResolver(const MRRGNameResolver&) = delete;
124  MRRGNameResolver& operator=(const MRRGNameResolver&) = delete;
126 
127  std::string node_name(tatum::NodeId node) const override {
128  //return "Node(" + std::to_string(size_t(node)) + ")";
129  return node2inst[node];
130  }
131 
132  std::string node_type_name(tatum::NodeId node) const override {
133  auto type = tg_->node_type(node);
134  std::stringstream ss;
135  ss << type;
136  return ss.str();
137  }
138 
139  void set_node_name(tatum::NodeId node, std::string name) {
140  node2inst.insert(node, name);
141  }
142  private:
143  const tatum::TimingGraph* tg_;
144  linear_map<tatum::NodeId, std::string> node2inst = {};
145 };
146 
147 #endif
148 
TGEntity::cpins2srcs
std::vector< tatum::EdgeId > cpins2srcs
Definition: TatumInterface.h:76
Util.h
TGEntity::srcs
std::vector< tatum::NodeId > srcs
Definition: TatumInterface.h:71
ModuleComposites.h
TGEntity::width
unsigned width
Definition: TatumInterface.h:61
TG_COMB
@ TG_COMB
Definition: TatumInterface.h:53
TatumInterface::mrrg2tg
std::map< MRRG::NodeDescriptor, std::shared_ptr< TGEntity > > mrrg2tg
Definition: TatumInterface.h:108
TGEntityType
TGEntityType
Definition: TatumInterface.h:50
TatumInterface::maxComb
linear_map< tatum::EdgeId, tatum::Time > maxComb
Definition: TatumInterface.h:103
PerfEngine.h
Module.h
TatumInterface::clkDid
tatum::DomainId clkDid
Definition: TatumInterface.h:95
TatumInterface::dc
std::shared_ptr< tatum::FixedDelayCalculator > dc
Definition: TatumInterface.h:98
TatumInterface::TatumInterface
TatumInterface(std::map< std::string, double > &, PerfEngine *)
Definition: TatumInterface.cpp:15
MRRGNameResolver::tg_
const tatum::TimingGraph * tg_
Definition: TatumInterface.h:143
TatumInterface::parent
PerfEngine * parent
Definition: TatumInterface.h:102
TatumInterface::operator=
TatumInterface & operator=(const TatumInterface &)=delete
TatumInterface::setup
linear_map< tatum::EdgeId, tatum::Time > setup
Definition: TatumInterface.h:105
TatumInterface::connectTGClock
void connectTGClock(MRRG::NodeDescriptor n, bool reduce=true)
Definition: TatumInterface.cpp:706
TatumInterface::tc
std::shared_ptr< tatum::TimingConstraints > tc
Definition: TatumInterface.h:99
EdgeList
std::multimap< MRRG::NodeDescriptor, MRRG::NodeDescriptor > EdgeList
Definition: PerfEngine.h:26
MRRGNameResolver::MRRGNameResolver
MRRGNameResolver(const tatum::TimingGraph &tg)
Definition: TatumInterface.h:120
TatumInterface::tg
std::shared_ptr< tatum::TimingGraph > tg
Definition: TatumInterface.h:96
TatumInterface::clk
tatum::NodeId clk
Definition: TatumInterface.h:94
MRRGNameResolver::node_type_name
std::string node_type_name(tatum::NodeId node) const override
Definition: TatumInterface.h:132
TGEntity
struct TGEntity TGEntity
TatumInterface
Definition: TatumInterface.h:79
MRRGNameResolver::node2inst
linear_map< tatum::NodeId, std::string > node2inst
Definition: TatumInterface.h:144
TatumInterface::tg2mrrg
std::map< tatum::NodeId, MRRG::NodeDescriptor > tg2mrrg
Definition: TatumInterface.h:109
TatumInterface::tr
std::shared_ptr< tatum::TimingReporter > tr
Definition: TatumInterface.h:101
TGEntity::ipins2opins
std::vector< tatum::EdgeId > ipins2opins
Definition: TatumInterface.h:67
MRRGNameResolver
Definition: TatumInterface.h:117
TatumInterface::connectTGEntities
void connectTGEntities(MRRG::NodeDescriptor from, MRRG::NodeDescriptor to, bool reduce=true)
Definition: TatumInterface.cpp:621
TGEntity::cpins
std::vector< tatum::NodeId > cpins
Definition: TatumInterface.h:70
TatumInterface::minComb
linear_map< tatum::EdgeId, tatum::Time > minComb
Definition: TatumInterface.h:104
TatumInterface::initializeTatumEngine
void initializeTatumEngine(EdgeList &m)
Definition: TatumInterface.cpp:131
TatumInterface::getFanoutBasedRCDelay
double getFanoutBasedRCDelay(MRRG::NodeDescriptor src)
Definition: TatumInterface.cpp:688
TatumInterface::memOut
std::vector< tatum::NodeId > memOut
Definition: TatumInterface.h:107
MRRGNode
Definition: MRRG.h:60
TGEntity::used_input
unsigned used_input
Definition: TatumInterface.h:62
TGEntity::ipins2snks
std::vector< tatum::EdgeId > ipins2snks
Definition: TatumInterface.h:73
TatumInterface::timingModels
std::map< std::string, double > & timingModels
Definition: TatumInterface.h:93
TGEntity::cpins2snks
std::vector< tatum::EdgeId > cpins2snks
Definition: TatumInterface.h:75
TGEntity
Definition: TatumInterface.h:56
Mapping.h
TatumInterface::createTatumTimingGraph
void createTatumTimingGraph(EdgeList &m)
Definition: TatumInterface.cpp:95
MRRGNameResolver::operator=
MRRGNameResolver & operator=(const MRRGNameResolver &)=delete
PerfEngine
Definition: PerfEngine.h:28
TGEntity::srcs2opins
std::vector< tatum::EdgeId > srcs2opins
Definition: TatumInterface.h:74
TatumInterface::removeWireNodes
void removeWireNodes(EdgeList &orig, EdgeList &reduced)
Definition: TatumInterface.cpp:22
TGEntity::snks
std::vector< tatum::NodeId > snks
Definition: TatumInterface.h:72
TatumInterface::nr
std::shared_ptr< MRRGNameResolver > nr
Definition: TatumInterface.h:97
TatumInterface::hold
linear_map< tatum::EdgeId, tatum::Time > hold
Definition: TatumInterface.h:106
TGEntity::type
TGEntityType type
Definition: TatumInterface.h:58
TGEntity::parent
MRRG::NodeDescriptor parent
Definition: TatumInterface.h:59
TG_REG
@ TG_REG
Definition: TatumInterface.h:52
TGEntity::opins
std::vector< tatum::NodeId > opins
Definition: TatumInterface.h:64
MRRGNameResolver::node_name
std::string node_name(tatum::NodeId node) const override
Definition: TatumInterface.h:127
TatumInterface::createTGEntity
void createTGEntity(MRRG::NodeDescriptor n, bool reduce=true)
Definition: TatumInterface.cpp:232
TatumInterface::analyzer
std::shared_ptr< tatum::SetupHoldTimingAnalyzer > analyzer
Definition: TatumInterface.h:100
TatumInterface::reportSetupAnalysis
void reportSetupAnalysis()
Definition: TatumInterface.cpp:210
EdgeList
std::multimap< MRRG::NodeDescriptor, MRRG::NodeDescriptor > EdgeList
Definition: TatumInterface.h:44
TGEntity::ipins
std::vector< std::vector< tatum::NodeId > > ipins
Definition: TatumInterface.h:63
MRRGNameResolver::set_node_name
void set_node_name(tatum::NodeId node, std::string name)
Definition: TatumInterface.h:139