object.hxx

Go to the documentation of this file.
00001 /*
00002  *   anvil
00003  *   Copyright (C) 2007    Karl W. Pfalzer
00004  *
00005  *   This program is free software; you can redistribute it and/or
00006  *   modify it under the terms of the GNU General Public License
00007  *   as published by the Free Software Foundation; either version 2
00008  *   of the License, or (at your option) any later version.
00009  *
00010  *   This program is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with this program; if not, write to the
00017  *   Free Software Foundation, Inc.
00018  *   51 Franklin Street, Fifth Floor
00019  *   Boston, MA  02110-1301, USA.
00020  */
00021 #if !defined(_anvil_object_hxx_)
00022 #    define  _anvil_object_hxx_
00023 
00024 extern "C"
00025 {
00026 #include "vpi_user.h"
00027 }
00028 #include <string>
00029 #include "xyzzy/portable.hxx"
00030 #include "xyzzy/slist.hxx"
00031 #include "xyzzy/refcnt.hxx"
00032 
00033 namespace anvil
00034 {
00035 
00036 using namespace xyzzy;
00037 
00038 inline
00039 size_t 
00040 numVecVal(unsigned nbits)   //how many s_vpi_value for nbits
00041 {
00042     return (0 == nbits) ? 1 : ((nbits - 1)/32 + 1);
00043 }
00044 
00045 class TType : public TRcObj
00046 {
00047 public:
00048     explicit TType(const vpiHandle hnd);
00049 
00050     size_t getSize() const;
00051 
00052     // Return string representation
00053     static std::string toString(const s_vpi_vecval *pv, int m_numBits);
00054 
00055     static TUint64 time64(const s_vpi_time &tim);
00056 
00057     const int   m_type;
00058     const int   m_numBits;
00059 
00060     virtual ~TType();
00061 };
00062 
00063 typedef PTRcObjPtr<TType>   TRcType;
00064 
00065 class TObject : public TRcObj
00066 {
00067 public:
00068     explicit TObject(const vpiHandle hnd);
00069 
00070     const TType& getType() const {return m_type;}
00071 
00072     const vpiHandle& getHandle() const {return m_hnd;}
00073 
00074     const char* getName() const;
00075 
00076     // Get size to hold data and (local) name
00077     size_t getSize(bool doName = true) const;
00078 
00079     virtual bool isInput() const = 0;
00080 
00081     virtual ~TObject();
00082 
00083 private:
00084     const vpiHandle m_hnd;
00085     const TType     m_type;
00086 };
00087 
00088 typedef PTRcObjPtr<TObject> TRcObject;
00089 
00090 class TDutInput : public TObject
00091 {
00092 public:
00093     explicit TDutInput(const vpiHandle hnd);
00094 
00095     virtual bool isInput() const {return true;}
00096 
00097     virtual ~TDutInput();
00098 };
00099 
00100 class TDutOutput : public TObject
00101 {
00102 public:
00103     explicit TDutOutput(const vpiHandle hnd);
00104 
00105     virtual bool isInput() const {return false;}
00106 
00107     virtual ~TDutOutput();
00108 };
00109 
00110 class TObjectSet : public TRcObj
00111 {
00112 public:
00113     explicit TObjectSet();
00114 
00115     // Determine how many bytes needed to flatten entire structure.
00116     // This info will be used to construct shared memory area.
00117     size_t getRequiredSize();
00118 
00119     PTSlist<TRcObject>& getItems() {return m_objs;}
00120 
00121     void append(TRcObject obj);
00122 
00123     virtual ~TObjectSet();
00124 
00125 private:
00126     PTSlist<TRcObject>  m_objs;
00127 };
00128 
00129 typedef PTRcObjPtr<TObjectSet>  TRcObjectSet;
00130 
00131 };
00132 
00133 #endif //_anvil_object_hxx_

Generated on Thu Mar 22 13:51:07 2007 for anvil by  doxygen 1.5.1