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

stilsignalblock.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 STILSignalBlock_H
00014 #define STILSignalBlock_H
00015 
00016 #include <vector>
00017 
00018 #include "stilblock.h"        // Base class for all STIL objects
00019 #include "stiltermination.h"  // STILTermination enumeration
00020 #include "stilwfcs.h"
00021 
00022 
00023 //---------------------------------------------------------------------------
00030 //---------------------------------------------------------------------------
00031 class STILSignalBlock : public STILBlock {
00032 
00033   // - Global ostream << operator as friend to output STILSignalBlock object
00034   friend std::ostream& operator<<( std::ostream &os, const STILSignalBlock &);
00035 
00036   // - Public members
00037   public:
00038 
00039     // - DefaultState attribute
00040     enum STILDefaultState {
00041                UndefinedDefaultState,  
00042                ForceUp,                
00043                ForceDown,              
00044                ForceOff                
00045     };
00046 
00047     // - Base attribute
00048     enum STILBase {
00049                UndefinedBase,          
00050                Hex,                    
00051                Dec                     
00052                //WFC    // WFC is the default base
00053     };
00054 
00055     // - Alignment attribute
00056     enum STILAlignment {
00057       UndefinedAlignment,    
00058       MSB,                   
00059       LSB                    
00060     };
00061 
00062     // This needs work... The hex/dec translations not working, and not setup
00063     //  to translate quickly.
00065     struct WFCSTranslateStruct  {
00066       char wfc;       
00067       char * binstr;  
00068     };
00069     typedef struct WFCSTranslateStruct WFCSTranslator;
00070 
00071     // - Default Constructor
00072     STILSignalBlock();
00073 
00074     // - Construct given a Type
00075     STILSignalBlock(Type);
00076 
00077     // - Copy Constructor
00078     STILSignalBlock(const STILSignalBlock &);
00079 
00080     // - Destructor
00081     virtual ~STILSignalBlock();
00082 
00083     // - Assignment Operator
00084     STILSignalBlock & operator=(const STILSignalBlock &);
00085 
00086     // - Initialize this STILSignalBlock object.
00087     void              init();
00088 
00089     // - Member functions to set/get Termination
00090     void              setTermination(STILTermination);
00091     STILTermination   getTermination() const;
00092 
00093     // - Member functions to set/get DefaultState
00094     void              setDefaultState(STILDefaultState);
00095     STILDefaultState  getDefaultState() const;
00096 
00097     // - Member functions to set/get STILBase
00098     void              setBase(STILBase b, const STILWFCS & wfcs);
00099     STILBase          getBase() const;
00100     const STILWFCS &  getBaseWFCS() const;
00101     // - Member function to return the number of base bits
00102     LONG              getBaseNumBits() const;
00103 
00104     // - Member functions to set/get Alignment
00105     void              setAlignment(STILAlignment);
00106     STILAlignment     getAlignment() const;
00107 
00108     // - Member functions to set/get the ScanIn length
00109     //        -1 : signal not defined as ScanIn
00110     //         0 : signal defined as ScanIn with undefined default length
00111     //        >0 : signal defined as ScanIn with defined default length
00112     void              setScanIn(LONG length);
00113     LONG              getScanIn() const;
00114 
00115     // - Member functions to set/get the ScanOut length
00116     //        -1 : signal not defined as ScanOut
00117     //         0 : signal defined as ScanOut with undefined default length
00118     //        >0 : signal defined as ScanOut with defined default length
00119     void              setScanOut(LONG length);
00120     LONG              getScanOut() const;
00121 
00122     // - Member functions to set/get the DataBitCount
00123     //         0 : signal not defined as multiple data bit
00124     //        >0 : signal defined with multiple data bits
00125     void              setDataBitCount(LONG count);
00126     LONG              getDataBitCount() const;
00127 
00128     // - Static Member functions to convert enumerations to sstring values
00129     static const sstring &    convertTermination(STILTermination);
00130     static const sstring &    convertDefaultState(STILDefaultState);
00131     static const sstring &    convertBase(STILBase);
00132     static const sstring &    convertAlignment(STILAlignment);
00133 
00134     void print_vectortrans() const;
00135     void print_vectortrans(std::ofstream& ttofs) const;
00137     char evalTrans (sstring &, LONG ln=0) const ;
00138 
00139   // Protected members (accessable from derived classes)
00140   protected:
00141 
00142     // Translate a WFC character into a binary
00143     const sstring WFC2Bin(const char) const;
00144     // Translate a binary sstring into a WFC character
00145     const sstring Bin2WFC(const sstring) const;
00146 
00147     // SignalBlock attributes
00148     STILTermination             m_termination;
00149     STILDefaultState            m_defaultState;
00150     STILBase                    m_base;
00151     STILWFCS                    m_baseWFCS;
00152     STILAlignment               m_alignment;
00153     LONG                        m_scanin;
00154     LONG                        m_scanout;
00155     LONG                        m_databitcount;
00156 
00157 
00158     int                         m_numbits; // number of bits to represent the baseWFCS
00159     std::vector<WFCSTranslator> m_WFCSTransVec;
00160 
00161 
00162 }; // end STILSignalBlock class
00163 
00164 // Inline functions
00165 // - Member function to return the number of base bits
00166 //--------------------------------------------------------------------------
00174 //--------------------------------------------------------------------------
00175 inline    LONG  STILSignalBlock::getBaseNumBits() const { return m_numbits; }
00176 
00177 //--------------------------------------------------------------------------
00185 //--------------------------------------------------------------------------
00186 inline void                             STILSignalBlock::setTermination(STILTermination t) {
00187   m_termination = t;
00188   addEntity(Termination,"Termination",convertTermination(t));
00189 }
00190 
00191 //--------------------------------------------------------------------------
00199 //--------------------------------------------------------------------------
00200 inline STILTermination  STILSignalBlock::getTermination() const { return m_termination; }
00201 
00202 //--------------------------------------------------------------------------
00210 //--------------------------------------------------------------------------
00211 inline void                             STILSignalBlock::setDefaultState(STILDefaultState ds) {
00212   m_defaultState = ds;
00213   addEntity(DefaultState,"DefaultState",convertDefaultState(ds));
00214 }
00215 
00216 //--------------------------------------------------------------------------
00224 //--------------------------------------------------------------------------
00225 inline STILSignalBlock::STILDefaultState STILSignalBlock::getDefaultState() const { return m_defaultState; }
00226 
00227 //--------------------------------------------------------------------------
00235 //--------------------------------------------------------------------------
00236 inline STILSignalBlock::STILBase        STILSignalBlock::getBase() const { return m_base; }
00237 
00238 //--------------------------------------------------------------------------
00246 //--------------------------------------------------------------------------
00247 inline const STILWFCS &                 STILSignalBlock::getBaseWFCS() const { return m_baseWFCS; }
00248 
00249 //--------------------------------------------------------------------------
00257 //--------------------------------------------------------------------------
00258 inline void                             STILSignalBlock::setAlignment(STILAlignment a) {
00259   m_alignment = a;
00260   addEntity(Alignment,"Alignment",convertAlignment(a));
00261 }
00262 
00263 //--------------------------------------------------------------------------
00271 //--------------------------------------------------------------------------
00272 inline STILSignalBlock::STILAlignment    STILSignalBlock::getAlignment() const { return m_alignment; }
00273 
00274 //--------------------------------------------------------------------------
00282 //--------------------------------------------------------------------------
00283 inline void                             STILSignalBlock::setScanIn(LONG si) {
00284   m_scanin = si;
00285   char tmp[32];
00286   sprintf(tmp,"%d",si);
00287   addEntity(ScanIn,"ScanIn",tmp);
00288 }
00289 
00290 //--------------------------------------------------------------------------
00298 //--------------------------------------------------------------------------
00299 inline LONG                             STILSignalBlock::getScanIn() const { return m_scanin; }
00300 
00301 //--------------------------------------------------------------------------
00309 //--------------------------------------------------------------------------
00310 inline void                             STILSignalBlock::setScanOut(LONG so) {
00311   m_scanout = so;
00312   char tmp[32];
00313   sprintf(tmp,"%d",so);
00314   addEntity(ScanOut,"ScanOut",tmp);
00315 }
00316 
00317 //--------------------------------------------------------------------------
00325 //--------------------------------------------------------------------------
00326 inline LONG                             STILSignalBlock::getScanOut() const { return m_scanout; }
00327 
00328 //--------------------------------------------------------------------------
00336 //--------------------------------------------------------------------------
00337 inline void                             STILSignalBlock::setDataBitCount(LONG dbc) {
00338   m_databitcount = dbc;
00339   char tmp[32];
00340   sprintf(tmp,"%d",dbc);
00341   addEntity(DataBitCount,"DataBitCount",tmp);
00342 }
00343 
00344 //--------------------------------------------------------------------------
00352 //--------------------------------------------------------------------------
00353 inline LONG                             STILSignalBlock::getDataBitCount() const { return m_databitcount; }
00354 
00355 inline void destroy(STILSignalBlock::WFCSTranslateStruct*) { /* Let the class destructor free up the space */ }
00356 //inline void                             STILSignalBlock::setBase(STILBase b, const sstring & wfcs) {
00357 //  m_base     = b;
00358 //  m_baseWFCS = wfcs;
00359 //  addEntity(Base,"Base",convertBase(b) + " " + wfcs);
00360 //}
00361 
00362 #endif

This page last updated on 6 Jul 2007

SourceForge.net Logo