00001
00002 #if !defined(oagFpgaSynthesis_P)
00003 #define oagFpgaSynthesis_P
00004
00005 #include "oaDesignDB.h"
00006
00007 #include "oagFpga.h"
00008 #include "oagFpgaVerilogDesign.h"
00009 #include "oagFpgaManager.h"
00010 #include "oagFpgaMultiRef.h"
00011 #include <list>
00012 #include <set>
00013 #include <string>
00014
00015 using namespace std;
00016
00017 namespace oagFpga {
00018
00019
00020
00021
00027
00028
00029
00030 class Synthesis {
00031
00032 friend class MapperUtils;
00033
00034 public:
00035
00036 static void setLibrary(oa::oaLib *library) { currentLibrary = library; }
00037 static void setView(oa::oaView *view) { currentView = view; }
00038 static void setOverwriteStructure(bool overwrite);
00039 static void addLeafLibrary(oa::oaLib *library) {
00040 leafLibs.push_back(library); }
00041 static void addLeafView(const oa::oaScalarName &viewName) {
00042 leafViews.push_back(viewName);
00043 }
00044
00045 protected:
00046
00047
00048
00049
00050
00051 typedef struct {int intValue; int bitWidth;} ConstantValue;
00052 typedef struct {int upper; int lower;} Bounds;
00053
00054
00055
00058
00059 static oa::oaModule* createModule(const string identifier);
00060 static oa::oaModScalarNet* createScalarNet(const string identifier);
00061 static oa::oaModBusNet* createBusNet(const string identifier,
00062 int start, int stop);
00063 static oa::oaModTerm* createTerm(oa::oaModNet* net,
00064 const string identifier,
00065 oa::oaTermType direction,
00066 unsigned int portPosition = oacNullIndex);
00067 static oa::oaModInst* instantiateModule(oa::oaDesign *master,
00068 const string name);
00069 static void connectPort(oa::oaModInst *inst,
00070 oa::oaModNet* net,
00071 unsigned int portPosition);
00072 static void connectPort(oa::oaModInst *inst,
00073 oa::oaModNet* net,
00074 const string port);
00078
00079 static oa::oaModNet* findNet(const string identifier);
00080 static oa::oaModScalarNet* findScalarNet(const string identifier);
00081 static oa::oaModBusNet* findBusNet(const string identifier);
00082 static oa::oaModBusNetBit* findBusNetBit(const string identifier,
00083 const int bit);
00084 static oa::oaModule* findModule(const string identifier);
00085 static bool checkForExistenceOfDesign(
00086 oa::oaScalarName libName,
00087 oa::oaScalarName cellName,
00088 oa::oaScalarName viewName);
00089
00093
00094 static void assignMultiRef(oa::oaModBitNet *net,
00095 const MultiRef e);
00096
00097
00098
00099
00100
00101
00102
00106 static MultiRef binaryOpt(RtlNode::OptType optType,
00107 MultiRef e1, MultiRef e2);
00108 static MultiRef unaryBusOpt(RtlNode::OptType optType, MultiRefBus &l);
00109 static MultiRef binaryBusOpt(RtlNode::OptType optType, MultiRefBus &l1,
00110 MultiRefBus &l2);
00111 static void unaryBusInputOutputOpt(RtlNode::OptType optType, int
00112 numOutBits, MultiRefBus &result, MultiRefBus &l) ;
00113 static void binaryBusInputOutputOpt(RtlNode::OptType optType, int
00114 numOutBits, MultiRefBus &result, MultiRefBus &l1,
00115 MultiRefBus &l2) ;
00116
00120
00121 static MultiRef notOf(MultiRef e);
00122 static MultiRef orOf(MultiRef e1, MultiRef e2);
00123 static MultiRef andOf(MultiRef e1, MultiRef e2);
00124 static MultiRef xorOf(MultiRef e1, MultiRef e2);
00125 static MultiRef norOf(MultiRef e1, MultiRef e2);
00126 static MultiRef nandOf(MultiRef e1, MultiRef e2);
00127 static MultiRef xnorOf(MultiRef e1, MultiRef e2);
00128 static MultiRef mux(MultiRef select,
00129 MultiRef in0, MultiRef in1);
00130
00134
00135 static MultiRef reductionOr(MultiRefBus &l);
00136 static MultiRef reductionAnd(MultiRefBus &l);
00137 static MultiRef reductionXor(MultiRefBus &l);
00138 static MultiRef reductionNand(MultiRefBus &l);
00139 static MultiRef reductionNor(MultiRefBus &l);
00140 static MultiRef reductionXnor(MultiRefBus &l);
00141 static MultiRef lessThan(MultiRefBus &l1, MultiRefBus &l2);
00142 static MultiRef lessThanEqual(MultiRefBus &l1,
00143 MultiRefBus &l2);
00144 static MultiRef equalTo(MultiRefBus &l1, MultiRefBus &l2);
00145 static MultiRef greaterThan(MultiRefBus &l1,
00146 MultiRefBus &l2);
00147 static MultiRef greaterThanEqual(MultiRefBus &l1,
00148 MultiRefBus &l2);
00149 static MultiRef notEqualTo(MultiRefBus &l1, MultiRefBus &l2);
00150 static MultiRef logicAnd(MultiRefBus &l1, MultiRefBus &l2);
00151 static MultiRef logicOr(MultiRefBus &l1, MultiRefBus &l2);
00152 static MultiRef logicNot(MultiRefBus &l1);
00153 static MultiRef mux(MultiRefBus& select, MultiRefBus &in0);
00154 static void mux(MultiRefBus &result,
00155 MultiRefBus &select,
00156 MultiRefBus &in0, MultiRefBus &in1);
00160
00161 static void arithmeticAdd(MultiRefBus &result,
00162 MultiRefBus &l1,
00163 MultiRefBus &l2);
00164 static void arithmeticSubtract(MultiRefBus &result,
00165 MultiRefBus &l1,
00166 MultiRefBus &l2);
00167 static void arithmeticSubtract(MultiRefBus &result,
00168 MultiRef &negFlag,
00169 MultiRefBus &l1,
00170 MultiRefBus &l2);
00171 static void arithmeticMultiply(MultiRefBus &result,
00172 MultiRefBus &l1,
00173 MultiRefBus &l2);
00174 static void arithmeticDivide(MultiRefBus &result,
00175 MultiRefBus &l1,
00176 MultiRefBus &l2);
00177 static void arithmeticModulo(MultiRefBus &result,
00178 MultiRefBus &l1,
00179 MultiRefBus &l2);
00180 static void leftShift(MultiRefBus &result,
00181 MultiRefBus &l1,
00182 MultiRefBus &l2);
00183
00187
00188 static MultiRef latch(MultiRef enable,
00189 MultiRef in,
00190 const string name = "");
00191 static MultiRef seq(MultiRef in, MultiRef clock,
00192 const string name = "");
00193 static MultiRef seq(MultiRef in, MultiRef clock,
00194 MultiRef aLoad, MultiRef aData,
00195 const string name = "");
00196
00200
00201 static MultiRef constantZero();
00202 static MultiRef constantOne();
00203 static void zeroExpand(MultiRefBus &l1,
00204 MultiRefBus &l2);
00205 static void multiBitConstant(MultiRefBus &result,
00206 int value, int bits = 0);
00207
00211
00212 static oa::oaNameSpace *nameSpace;
00213 static oa::oaLib *currentLibrary;
00214 static oa::oaView *currentView;
00215 static Manager *currentManager;
00216 static oa::oaModule *currentModule;
00217 static bool overwriteStructure;
00218
00219
00220 static list<oa::oaLib*> leafLibs;
00221 static list<oa::oaScalarName> leafViews;
00222
00223
00224 static const unsigned int NAME_LENGTH_LIMIT = 256;
00225
00227
00228
00229
00230 };
00231
00232 }
00233
00234 #endif