Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

stilevalengine.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * Copyright (c) 2006 International Business Machines Corporation
00003  * All rights reserved. This program and the accompanying materials
00004  * are made available under the terms of the Common Public License v1.0
00005  * which accompanies this distribution, and is available at
00006  * http://www.opensource.org/licenses/cpl1.0.php
00007  *
00008  * Contributors:
00009  *    Douglas Sprague, Joel Wheeler - initial API and implementation
00010  *
00011  *****************************************************************************/
00012 
00013 #ifndef STILEvalEngine_H
00014 #define STILEvalEngine_H
00015 
00016 #include "stilcom.h"
00017 #include "stilcomstr.h"
00018 
00019 #include "stilentitytable.h"
00020 #include "stiltermination.h"
00021 #include "stilvectoreventlist.h"
00022 #include "stilscanmatrix.h"
00023 
00024 #include <list>
00025 #include <map>
00026 #include <stack>
00027 
00028 //prototype
00029 class STIL;
00030 class STILSigRefExpr;
00031 class STILProcedure;
00032 class STILCall;
00033 class STILMacroDef;
00034 class STILMacro;
00035 class STILPatternBlock;
00036 class STILTiming;
00037 class STILWaveformTable;
00038 class STILWaveform;
00039 class STILWFCS;
00040 class STILCondition;
00041 class STILSignalList;
00042 class STILWaveformEval;
00043 class STILVectorBlock;
00044 
00045 
00046 //---------------------------------------------------------------------------
00052 //---------------------------------------------------------------------------
00053 class STILEvalEngine  {
00054 
00055   // - Make a friend of the STILSigRefExpr so that the
00056   // - STILEntityTable may be referenced for the STILSigRefExpr::eval function
00057   friend class STILSigRefExpr;
00058 
00059  public:
00060 
00061   // Mask of clock pin attributes.
00062   // A specific signal may have various attributes.
00063   // For example, a positive scan clock would be set to 0x0101
00064   enum STIL_CLKTYPE  {
00065     NOT_A_CLOCK         = 0,    
00066     POSITIVE_CLK        = 1,    
00067     NEGATIVE_CLK        = 2,    
00068     SCAN_CLOCK          = 4,    
00069     GENERIC_CLK         = 8     
00070   };
00071 
00072   // Scan pin attributes.
00073   // A specific signal may have various attributes.
00074   enum STIL_SCANTYPE  {
00075     NOT_A_SCAN         = 0,    
00076     SCAN_IN            = 1,    
00077     SCAN_OUT           = 2     
00078   };
00079 
00080   // - Default Constructor to create and initialize a STILEnvironment object
00081   STILEvalEngine();
00082 
00083   // - Copy Constructor
00084   STILEvalEngine(const STILEvalEngine &);
00085 
00086   // - Construct and point to parent STIL object
00087   STILEvalEngine(STIL*);
00088 
00089   // - Destructor which frees storage associated with the STILEnvironment
00090   ~STILEvalEngine();
00091 
00092   // - The assignment operator
00093   STILEvalEngine &  operator=(const STILEvalEngine &);
00094 
00095   // - Initialize this object
00096   void  init(STIL *);
00097 
00098   // - Load timing
00099   void loadTiming(const sstring&);
00100 
00101   // - Load Waveformtable
00102   void loadWaveformTable(const sstring&);
00103 
00104   // - Load a category
00105   void loadCategory(const sstring&);
00106 
00107   // - load a selector
00108   void loadSelector(const sstring&);
00109 
00110   // - load signal groups
00111   void loadSignalGroups(const sstring& sgs_name);
00112 
00113   // - load macro defs
00114   void loadMacroDefs(const sstring&);
00115 
00116   // - load procedures
00117   void loadProcedures(const sstring&);
00118 
00119   // - load scan structures
00120   void loadScanStructures(const sstring&);
00121 
00122   // - load termination
00123   void loadTermination(const STILSigRefExpr & sre, STILTermination);
00124 
00125   // - evaluate a sig ref expr
00126   const STILSignalList *      evalSigRefExpr(const STILSigRefExpr&);
00127 
00128   // - evaluate waveform character
00129   const STILVectorEventList * evalWFCS(const STILWFCS &,
00130                                        const STILSignalList &,
00131                                        bool no_audits = false);
00132 
00134   //make const:
00135   sstring & resolveWFCS(const STILWFCS &,
00136                         const STILSignalList &);
00137 
00138   const STILVectorEventList * evalResolvedWFCS(sstring &,
00139                                           const STILSignalList &);
00141 
00142   // - Locate a procedure being called & setup the EE for processing it
00143   const STILProcedure *       callProcedure(const STILCall &);
00144 
00145   // - Return from a procedure and cleanup processing associated with it
00146   const STILCondition *       returnProcedure();
00147 
00148   // - Locate a macro being called & setup the EE for processing it
00149   const STILMacroDef *        callMacroDef(const STILMacro &);
00150 
00151   // - Return from a macro and cleanup processing associated with it
00152   void                        returnMacroDef();
00153 
00154   // - Return whether the signal @ idx is a clock (or scan clk)
00155   BOOLEAN                     isClock(LONG idx);
00156   BOOLEAN                     isScanClock(LONG idx);
00157   // - Return whether the clock is positive or negative
00158   // - NOTE: FALSE = Positive CLK
00159   // -               Negative CLK
00160   // -   It is assumed that the user has determined this to be a clk ahead of
00161   // -     time. It will return FALSE(+) by default if the signal is not
00162   // -     a clk.
00163   BOOLEAN  getClockActiveState(LONG idx);
00164 
00165   // - Whether or not a pulse state exists on a particular signal index (held
00166   // -  over from a previous vector)
00167   BOOLEAN  hasPulse(LONG idx);
00168 
00169   // - Return whether the signal @idx is a scanin/scanout pin
00170   BOOLEAN                     isScanIn(LONG idx);
00171   BOOLEAN                     isScanOut(LONG idx);
00172   // - Return the overriding scan length of a given signal
00173   LONG                        getScanLength(LONG idx);
00174 
00175   // - Return the currently loaded Timing block
00176   const STILTiming * getLoadedTiming() const;
00177 
00178   // - Member function to find pins which are potentially clocks
00179   void findClocks();
00180 
00181   // - Member function to find pins which are potentially scan clocks
00182   void findScanClocks();
00183 
00184   // - Get whether or not we are operating in a 'validate-only' mode, where
00185   // _ only unique proc/macro parms are evaluated.
00186   void setValidateOnlyMode(bool valOnly);
00187   bool getValidateOnlyMode();
00188 
00189  private:
00190 
00191 
00192   //--- funcs: ---//
00193   // - Return the number of pre- & post- shift scan vectors with '#' per pin
00194   void getParameterizedVecCounts(const STILVectorBlock * pVB, std::vector<LONG>& paramVecCounts);
00195 
00196   // - Perform setup processing on a Procedure given the Call parms, or
00197   // - perform setup processing on a Macrodef given the Macro parms
00198   void setupMacroOrProcedure(STILPatternBlock & pattBlock,
00199                              const STILVectorBlock & vecBlock);
00200 
00201   // - Return the type of clock for Signal ID=idx
00202   LONG                clockType(LONG idx);
00203 
00204 
00205   // - Save the current Waveform table for later restoring
00206   void saveWaveformTable();
00207 
00208   // - Restore to the most recently saved Waveform table
00209   void restoreWaveformTable();
00210 
00211   // - Return an index into the symbol table stack for a string symbol ref
00212   LONG getSymtabStackIdx(const sstring &) const;
00213 
00214 
00215   //--- data: ---//
00216   STIL*                 m_pSTIL; // Pointer to the STIL object which contains this environment
00217 
00218   std::map<sstring, STILSignalList*>  m_signalSymtabs[2];
00219                                  //[0] = signals/global signal groups,
00220                                  //[1] = loaded signal groups (can override [0])
00221 
00222 
00223   STILEntityTable       m_proSymTab;    // Procedures symbol table
00224   STILEntityTable       m_macSymTab;    // MacroDefs symbol table
00225   STILTiming*           m_pTiming;      // Ptr to Timings used to resolve all Waveformtable references
00226 
00227   LONG                  m_wfArraySize;  // WaveFormArray size (==# of Signals)
00228                                         //  also the size of the m_clocksArray(==#of Signals)
00229   STILWaveformEval*     m_pCurrWFEval;  // Pointer to the current waveform table evaluator object
00230 
00231   std::map<sstring, STILWaveformEval> m_WFEvalMap;
00232   typedef std::map<sstring, STILWaveformEval>::iterator WFMIterator;
00233                                  // Map used to store arrays of waveforms
00234                                  // for quick loadWaveformTable
00235                                  // indexed into by name of WaveformTable
00236 
00237   STILVectorEventList   m_eventList;    // For use with evalWFCS
00238 
00239   UCHAR*                m_clocksArray;  // Array of clocks/clock types
00240   UCHAR*                m_scansArray;   // Array of scan pins/pin types
00241   LONG*                 m_scanlenArray; // Array of scan lengths
00242 
00243   sstring               m_currWFTName;  // Current active waveform table name
00244   sstring               m_currTimName;  // Current active Timing block name
00245 
00246   std::stack<sstring,std::list<sstring> > m_WFTStack;
00247                                  // Stack for managing the active waveform
00248                                  // tables within nested procedure blocks.
00249                                  // Note that this is just a stack of
00250                                  // WaveformTable names and not the actual
00251                                  // loaded waveform tables.  The member
00252                                  // function "loadWaveformTable" needs to
00253                                  // be called once a WFT name is popped
00254                                  // off this stack.
00255 
00256   STILScanMatrix        m_scanMatrix;
00257                                  // two dimensional scan matrix used
00258                                  // for storing scan data for a given instance
00259                                  // of a procedure or macrodef
00260 
00261   STILEntityTable       m_parmsTab;
00262                                  // SymbolTable of parameteters passed to
00263                                  // procedures or macros.  Key is parameter
00264                                  // name in call instance, Value is a pointer
00265                                  // to a STILVectorEventList
00266 
00267   BOOLEAN               m_findScanClkFlag;
00268                                  // Whether or not we want to findScanClocks
00269                                  //  when a waveformtable is loaded.
00270 
00271 
00272   std::vector<char>     m_padWFC;
00273                                  // Vector (indexed via signal ID) which holds the
00274                                  // WFC to use for padding for the given ID.
00275                                  // This is needed to implement padding as
00276                                  // specified in the 1450 spec clause 24.5
00277                                  // one of my favorite clauses!!
00278 
00279   std::vector<bool>     m_padWFCSaved;
00280                                  // Vector of flags (indexed via signal ID) indicating
00281                                  // that the pad WFC has been saved for this
00282                                  // signal for this procedure/macrodef
00283 
00284   BOOLEAN               m_inMacro;
00285                                  // Whether or not a macro is currently being
00286                                  //  processed.
00287 
00288   std::stack< sstring ,std::list<sstring> > m_WFCBufferStack;
00289                                  // Stack for storing WFC's, so that states
00290                                  //  prior to procedure calls may be restored
00291                                  //  after the procedure is exited.
00292 
00293   sstring               m_currWFCBuffer;
00294                                  // The currently buffered up WFCs
00295 
00296   std::vector<sstring>  m_signalNameList;
00297                                 // List of all signal names, by ID
00298 
00299   STILCondition *       m_pProcReturnCondition;
00300                                  // A Condition statement to return
00301                                  //  pins to their state before a Procedure call
00302                                  //  after exiting the Procedure.
00303 
00304   bool                  m_validateOnlyMode;
00305                                  // Whether or not to process procs/macros in
00306                                  // a "flattened" 'validate-only' mode
00307 
00308 };
00309 
00310 
00311 //--------------------------------------------------------------------------
00319 //--------------------------------------------------------------------------
00320 inline BOOLEAN STILEvalEngine::isClock(LONG idx)      { return ( clockType(idx) > NOT_A_CLOCK ); }
00321 
00322 //--------------------------------------------------------------------------
00330 //--------------------------------------------------------------------------
00331 inline BOOLEAN STILEvalEngine::isScanClock(LONG idx)  { return ( (clockType(idx) & SCAN_CLOCK) == SCAN_CLOCK);   }
00332 
00333 //--------------------------------------------------------------------------
00341 //--------------------------------------------------------------------------
00342 inline   BOOLEAN  STILEvalEngine::getClockActiveState(LONG idx) { return ((clockType(idx) & NEGATIVE_CLK) == NEGATIVE_CLK); }
00343 
00344 //--------------------------------------------------------------------------
00352 //--------------------------------------------------------------------------
00353   // - Return whether the signal @idx is a scanin/scanout pin
00354 inline   BOOLEAN                     STILEvalEngine::isScanIn(LONG idx) { return( (SCAN_IN & m_scansArray[idx]) > 0); }
00355 
00356 //--------------------------------------------------------------------------
00364 //--------------------------------------------------------------------------
00365 inline   BOOLEAN                     STILEvalEngine::isScanOut(LONG idx) { return( (SCAN_OUT & m_scansArray[idx]) > 0); }
00366 
00367 //--------------------------------------------------------------------------
00375 //--------------------------------------------------------------------------
00376   // - Return the overriding scan length of a given signal
00377 inline   LONG                        STILEvalEngine::getScanLength(LONG idx) { return m_scanlenArray[idx]; }
00378 
00379 
00380 //--------------------------------------------------------------------------
00388 //--------------------------------------------------------------------------
00389 inline const STILTiming * STILEvalEngine::getLoadedTiming() const { return (m_pTiming); }
00390 
00391 
00392 //--------------------------------------------------------------------------
00409 //--------------------------------------------------------------------------
00410 inline void STILEvalEngine::setValidateOnlyMode(bool valOnly)
00411 {
00412   m_validateOnlyMode = valOnly;
00413 }
00414 
00415 //--------------------------------------------------------------------------
00425 //--------------------------------------------------------------------------
00426 inline bool STILEvalEngine::getValidateOnlyMode()
00427 {
00428   return m_validateOnlyMode;
00429 }
00430 
00431 
00432 #endif

This page last updated on 6 Jul 2007

SourceForge.net Logo