Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

oagFpgaVerilogSynthesis.h

Go to the documentation of this file.
00001 
00002 #if !defined(oagFpgaVerilogSynthesis_P)
00003 #define oagFpgaVerilogSynthesis_P
00004 
00005 #include "oaDesignDB.h"
00006 //#include "oagAiGraph.h"
00007 #include "oagFpga.h"
00008 #include "oagFpgaMultiRef.h"
00009 #include "oagFpgaVerilogDesign.h"
00010 #include "oagFpgaManager.h"
00011 #include "oagFpgaSynthesis.h"
00012 #include <list>
00013 #include <set>
00014 #include <string>
00015 
00016 using namespace std;
00017 
00018 namespace oagFpga {
00019 
00020 // *****************************************************************************
00021 // VerilogSynthesis
00022 //
00027 //
00028 // *****************************************************************************
00029 
00030 class VerilogSynthesis : public Synthesis {
00031 
00032     static const bool IMPLICIT_NET_WARNINGS = false;
00033 
00034     protected:
00035 
00036         // *********************************************************************
00037         // Type definitions for various Verilog objects.
00038         // *********************************************************************
00039 
00040         typedef map<string, ConstantValue> ParameterValues;
00041 
00042         class FunctionVariableAssignment : public map<int, MultiRef> {
00043             public:
00044 
00045                 int     start, stop;
00046 
00047                 FunctionVariableAssignment() { start = stop = 0; }
00048                 FunctionVariableAssignment(int st, int sp) { start = st; stop = sp; }
00049         };
00050 
00051         // *********************************************************************
00052         // ProceduralState
00053         //
00056         //
00057         // *********************************************************************
00058         
00059         class ProceduralState {
00060 
00061             public:
00062                 set<oa::oaModBitNet*>                   dependencies;
00063                 map<oa::oaModBitNet*, MultiRef>         blockingAssignments,
00064                                                         nonblockingAssignments;
00065                 bool                                    isRegister;
00066                 bool                                    isFunction;
00067                 map<string, FunctionVariableAssignment> functionAssignments;
00068 
00069                 set<oa::oaModBitNet*>                   normalTriggers, 
00070                                                         posTriggers, 
00071                                                         negTriggers;
00072                 set<oa::oaModBitNet*>                   nonClockTriggers;
00073 
00074                 // Differeciate synchronous and asynchronous signals
00075                 // (applicable only to IF scope
00076                 typedef enum { PSTATE_SYNC, PSTATE_ASYNC } PStateType;
00077                 PStateType                              pStateType;
00078                 // the asynchronous trigger in the condition of the current IF
00079                 // statement
00080                 MultiRef                                curTrigger;
00081 
00082                 // data of the asynchronous LOAD (applicable only when the ALOAD
00083                 // for this net exists)
00084                 map<oa::oaModBitNet*, MultiRef>         aData;
00085                 // the asynchronous LOAD signal associated with this net 
00086                 map<oa::oaModBitNet*, MultiRef>         aLoad;
00087 
00088                 ProceduralState()
00089                 {
00090                     isRegister = false;
00091                     isFunction = false;
00092                     pStateType = PSTATE_SYNC;
00093                 }
00094         };
00095 
00096         // *********************************************************************
00097         // ConditionalLvalRef
00098         //
00101         //
00102         // *********************************************************************
00103 
00104         class ConditionalLvalRef {
00105             public:
00106 
00107                 oa::oaModBitNet*    lval;
00108                 MultiRef            condition;
00109                 ConditionalLvalRef(oa::oaModBitNet *n, MultiRef c) 
00110                 { 
00111                     lval = n; condition = c; 
00112                 }
00113         };
00114 
00115         typedef enum{LVAL_UNKNOWN, LVAL_UNCONDITIONAL, LVAL_CONDITIONAL,
00116             LVAL_FUNCTION} LvalType;
00117 
00118         // *********************************************************************
00119         // LvalRef 
00120         // 
00122         //
00123         // *********************************************************************
00124 
00125         class LvalRef {
00126             public:
00127                 LvalType                 type;
00128 
00129                 oa::oaModBitNet*         unconditionalLval;
00130                 list<ConditionalLvalRef> conditionalLval;
00131                 string                   functionLvalName;
00132                 int                      functionLvalBit;
00133 
00134                 LvalRef(string c, int b); 
00135                 LvalRef(oa::oaModBitNet* n);
00136                 LvalRef();
00137                 void addConditional(oa::oaModBitNet *n, MultiRef c);
00138         };
00139 
00140         typedef list<LvalRef*> LvalRefBus;
00141 
00142         // *********************************************************************
00143 
00144     public:
00145 
00146         static void synthesize(VerilogDesign *design);
00147 
00148     protected:
00149 
00150         // synthesize particular subcomponents
00151         static void synthesizeModule(VerilogDesign::Module *module,
00152                 list<ConstantValue> &parameters);
00153         static void synthesizeModuleNets();
00154         static void synthesizeModuleTerms();
00155         static void synthesizeModuleAssigns();
00156         static void synthesizeModuleInsts();
00157         static void synthesizeModuleFunc();
00158         static void synthesizeBehavioral(VerilogDesign::Statement *statement, 
00159                 ProceduralState &state, ParameterValues *parameters);
00160         static void synthesizeBlock(VerilogDesign::Statement *statement, 
00161                 ProceduralState &state, ParameterValues *parameters);
00162         static void synthesizeIf(VerilogDesign::Statement *statement, 
00163                 ProceduralState &state, ParameterValues *parameters);
00164         static bool synthesizeCaseEasy(VerilogDesign::Statement *statement, 
00165                 ProceduralState &state, ParameterValues *parameters);
00166         static void synthesizeCase(VerilogDesign::Statement *statement, 
00167                 ProceduralState &state, ParameterValues *parameters);
00168         static void synthesizeBlockingassignment(
00169                 VerilogDesign::Statement *statement, 
00170                 ProceduralState &state, ParameterValues *parameters);
00171         static void synthesizeNonblockingassignment(
00172                 VerilogDesign::Statement *statement, 
00173                 ProceduralState &state, ParameterValues *parameters);
00174 
00175         static string getParameterizedModuleName(VerilogDesign::Module *vModule, 
00176                 list<ConstantValue> &parameters);
00177 
00178         // parse expression trees
00179         static void evaluateConstantExpression(ConstantValue &result, 
00180                 VerilogDesign::Expression *expression,
00181                 ParameterValues *parameters);
00182         static bool isConstantExpression(VerilogDesign::Expression *expression, 
00183                 ParameterValues *parameters);
00184         static bool evaluateExpression(MultiRefBus &result, 
00185                 VerilogDesign::Expression *expression, 
00186                 ProceduralState *state, ParameterValues *parameters);
00187         static void evaluateLval(LvalRefBus &result, 
00188                 VerilogDesign::Expression *expression, 
00189                 ProceduralState *state, ParameterValues *parameters);
00190         static MultiRef getContextualValue(oa::oaModBitNet *net, 
00191                 ProceduralState *state);
00192 
00193         // utility
00194         static void appendSuffix(string &root, const string suffix);
00195         static bool isAsynchronousSignal(oa::oaModBitNet* net, 
00196                 ProceduralState* state);
00197         static string printBitNetName(oa::oaModBitNet *n);
00198 
00201 
00202         // The names of the finished modules
00203         static set<string>              finishedModules;
00204 
00206         static VerilogDesign::Module    *currentVmodule;
00208         static ParameterValues          *currentParams;
00209 
00210         static map<string, Bounds>      twoDimRegisters;
00211 
00213 
00214 };
00215     
00216 }
00217 
00218 #endif

Generated on Mon Jul 9 14:17:21 2007 for OA Gear Fpga by  doxygen 1.3.9.1