CGRA-ME
CGRA.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 __CGRA_H__
12 #define __CGRA_H__
13 
14 class CGRA;
15 
16 #include <CGRA/BitSetting.h>
17 #include <CGRA/Mapping.h>
18 #include <CGRA/Module.h>
19 
20 #include <memory>
21 #include <vector>
22 #include <unordered_map>
23 
24 class ConfigCell;
25 class Module;
26 class MRRG;
27 class OpGraph;
28 enum class VerilogType;
29 
34 class BitStream
35 {
36  public:
37  using BitArray = std::vector<std::vector<BitSetting>>;
38 
43  void append(const ConfigCell* ccell, const BitArray& bits, int con_used= 0);
44 
49  void printTestbench(std::ostream& os, const int& II, bool is_elastic = false) const;
50 
55  const BitArray& settingFor(const ConfigCell* cc) const { return setting_storage.at(cc); }
56 
60  auto& ccellOrder() const { return ccell_order; }
61 
65  friend std::ostream& operator<<(std::ostream& os, const BitStream& bs);
66 
67  private:
68  std::unordered_map<const ConfigCell*, BitArray> setting_storage = {};
69  std::vector<const ConfigCell*> ccell_order = {};
70  std::unordered_map<const ConfigCell*, int> contexts_used = {};
71 };
72 
73 namespace adl0 { class ADL; }
74 
75 // This class represents a top level CGRA architecture
76 class CGRA
77 {
78  public:
79  CGRA(std::string name = "CGRA", std::string templateName = "cgra");
80  BitStream genBitStream(const Mapping& mapping); // Function that generates bitstream
81  void genTimingConstraints(OpGraph * mappped_opgraph); // Function that determines timing analysis of design mapped onto CGRA
82  void genFloorPlan(); // Floorplans CGRA blocks. Only works well with a homogeneous array
85  void setNumRows(int numRows) {num_floorplan_rows = numRows;}
86  void setNumCols(int numCols) {num_floorplan_columns = numCols;}
87 
88  const MRRG& getMRRG(int II);
90  const Module& getTopLevelModule() const { return *top_level_module; }
91 
92  void genVerilog(VerilogType vt, std::string dir, const int& SII);
93  void genHybrid(VerilogType vt, std::string dir, int mem_size);
94 
95  std::vector<std::string> hybridPorts;
96  private:
97  friend class adl0::ADL;
98  std::unique_ptr<Module> top_level_module;
99  std::vector<std::shared_ptr<const MRRG>> mrrgs = {}; // Keeps references to all the MRRGs for each II
102 };
103 
104 #endif
105 
CGRA::getNumRows
int getNumRows()
Definition: CGRA.h:83
ConfigCell
Definition: Module.h:825
BitStream::ccell_order
std::vector< const ConfigCell * > ccell_order
Definition: CGRA.h:69
CGRA::getNumCols
int getNumCols()
Definition: CGRA.h:84
MRRG
Definition: MRRG.h:216
CGRA::genFloorPlan
void genFloorPlan()
Definition: CGRA.cpp:269
CGRA::genBitStream
BitStream genBitStream(const Mapping &mapping)
Definition: CGRA.cpp:64
BitStream
Definition: CGRA.h:34
VerilogType
VerilogType
Definition: Module.h:150
CGRA::genTimingConstraints
void genTimingConstraints(OpGraph *mappped_opgraph)
CGRA::genVerilog
void genVerilog(VerilogType vt, std::string dir, const int &SII)
Definition: CGRA.cpp:405
BitStream::setting_storage
std::unordered_map< const ConfigCell *, BitArray > setting_storage
Definition: CGRA.h:68
BitStream::settingFor
const BitArray & settingFor(const ConfigCell *cc) const
Definition: CGRA.h:55
adl0
Definition: CGRA.h:73
Module.h
CGRA
Definition: CGRA.h:76
CGRA::getTopLevelModule
const Module & getTopLevelModule() const
Definition: CGRA.h:90
Mapping
Definition: Mapping.h:31
CGRA::mrrgs
std::vector< std::shared_ptr< const MRRG > > mrrgs
Definition: CGRA.h:99
CGRA::getMRRG
const MRRG & getMRRG(int II)
Definition: CGRA.cpp:44
CGRA::getTopLevelModule
Module & getTopLevelModule()
Definition: CGRA.h:89
Module
Definition: Module.h:163
CGRA::num_floorplan_columns
int num_floorplan_columns
Definition: CGRA.h:101
BitStream::contexts_used
std::unordered_map< const ConfigCell *, int > contexts_used
Definition: CGRA.h:70
BitStream::BitArray
std::vector< std::vector< BitSetting > > BitArray
Definition: CGRA.h:37
CGRA::ADL
friend class adl0::ADL
Definition: CGRA.h:97
CGRA::top_level_module
std::unique_ptr< Module > top_level_module
Definition: CGRA.h:98
BitStream::append
void append(const ConfigCell *ccell, const BitArray &bits, int con_used=0)
Definition: BitStream.cpp:19
CGRA::hybridPorts
std::vector< std::string > hybridPorts
Definition: CGRA.h:95
BitStream::operator<<
friend std::ostream & operator<<(std::ostream &os, const BitStream &bs)
Definition: BitStream.cpp:28
BitSetting.h
Mapping.h
CGRA::CGRA
CGRA(std::string name="CGRA", std::string templateName="cgra")
Definition: CGRA.cpp:39
BitStream::ccellOrder
auto & ccellOrder() const
Definition: CGRA.h:60
CGRA::setNumRows
void setNumRows(int numRows)
Definition: CGRA.h:85
CGRA::setNumCols
void setNumCols(int numCols)
Definition: CGRA.h:86
CGRA::num_floorplan_rows
int num_floorplan_rows
Definition: CGRA.h:100
CGRA::genHybrid
void genHybrid(VerilogType vt, std::string dir, int mem_size)
Definition: CGRA.cpp:412
OpGraph
Definition: OpGraph.h:215
BitStream::printTestbench
void printTestbench(std::ostream &os, const int &II, bool is_elastic=false) const
Definition: BitStream.cpp:44