fstapi.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2009-2010 Tony Bybell.
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a
00005  * copy of this software and associated documentation files (the "Software"),
00006  * to deal in the Software without restriction, including without limitation
00007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008  * and/or sell copies of the Software, and to permit persons to whom the
00009  * Software is furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included in
00012  * all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00017  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00018  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00019  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00020  * DEALINGS IN THE SOFTWARE.
00021  */
00022 
00023 #ifndef FST_API_H
00024 #define FST_API_H
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029 
00030 #include <stdio.h>
00031 #include <stdlib.h>
00032 #include <string.h>
00033 #include <ctype.h>
00034 #include <zlib.h>
00035 #include <inttypes.h>
00036 #include <unistd.h>
00037 #include <time.h>
00038 
00039 #define FST_RDLOAD "FSTLOAD | "
00040 
00041 typedef uint32_t fstHandle;
00042 
00043 enum fstBlockType {
00044     FST_BL_HDR                 = 0,
00045     FST_BL_VCDATA              = 1,
00046     FST_BL_BLACKOUT            = 2,
00047     FST_BL_GEOM                = 3,
00048     FST_BL_HIER                = 4,
00049 
00050     FST_BL_ZWRAPPER            = 254,   /* indicates that whole trace is gz wrapped */
00051     FST_BL_SKIP                = 255    /* used while block is being written */
00052 };
00053 
00054 enum fstScopeType {
00055     FST_ST_VCD_MIN             = 0,
00056     FST_ST_VCD_MODULE          = 0,
00057     FST_ST_VCD_TASK            = 1,
00058     FST_ST_VCD_FUNCTION        = 2,
00059     FST_ST_VCD_BEGIN           = 3,
00060     FST_ST_VCD_FORK            = 4,
00061     FST_ST_VCD_MAX             = 4,
00062 
00063     FST_ST_MAX                 = 4,
00064 
00065     FST_ST_VCD_SCOPE           = 254,
00066     FST_ST_VCD_UPSCOPE         = 255
00067 };
00068 
00069 enum fstVarType {
00070     FST_VT_VCD_MIN             = 0,     /* start of VCD datatypes */
00071     FST_VT_VCD_EVENT           = 0,
00072     FST_VT_VCD_INTEGER         = 1,
00073     FST_VT_VCD_PARAMETER       = 2,
00074     FST_VT_VCD_REAL            = 3,
00075     FST_VT_VCD_REAL_PARAMETER  = 4,
00076     FST_VT_VCD_REG             = 5,
00077     FST_VT_VCD_SUPPLY0         = 6,
00078     FST_VT_VCD_SUPPLY1         = 7,
00079     FST_VT_VCD_TIME            = 8,  
00080     FST_VT_VCD_TRI             = 9,
00081     FST_VT_VCD_TRIAND          = 10,
00082     FST_VT_VCD_TRIOR           = 11,
00083     FST_VT_VCD_TRIREG          = 12,
00084     FST_VT_VCD_TRI0            = 13,
00085     FST_VT_VCD_TRI1            = 14,
00086     FST_VT_VCD_WAND            = 15,
00087     FST_VT_VCD_WIRE            = 16,
00088     FST_VT_VCD_WOR             = 17,
00089     FST_VT_VCD_PORT            = 18,
00090     FST_VT_VCD_ARRAY           = 19,    /* used to define the rownum (index) port on the array */
00091     FST_VT_VCD_REALTIME        = 20,
00092     FST_VT_VCD_MAX             = 20,    /* end of VCD datatypes */
00093 
00094     FST_VT_GEN_STRING          = 254,   /* generic string type   (max len is defined as the len in fstWriterCreateVar() */
00095     FST_VT_GEN_MEMBLOCK        = 255    /* generic memblock type (max len is defined as the len in fstWriterCreateVar() */
00096 };
00097 
00098 enum fstVarDir {
00099     FST_VD_IMPLICIT    = 0,
00100     FST_VD_INPUT       = 1,
00101     FST_VD_OUTPUT      = 2,
00102     FST_VD_INOUT       = 3,
00103 
00104     FST_VD_MAX         = 3
00105 };
00106 
00107 enum fstHierType {
00108     FST_HT_SCOPE       = 0,
00109     FST_HT_UPSCOPE     = 1,
00110     FST_HT_VAR         = 2,
00111 
00112     FST_HT_MAX         = 2
00113 };
00114 
00115 struct fstHier
00116 {
00117 unsigned char htyp;
00118 
00119 union {
00120         /* if htyp == FST_HT_SCOPE */
00121         struct fstHierScope {
00122                 unsigned char typ; /* FST_ST_VCD_MODULE ... FST_ST_VCD_FORK */
00123                 const char *name;
00124                 const char *component;
00125                 } scope;
00126 
00127         /* if htyp == FST_HT_VAR */
00128         struct fstHierVar {
00129                 unsigned char typ; /* FST_VT_VCD_EVENT ... FST_VT_VCD_REALTIME */
00130                 unsigned char direction; /* FST_VD_IMPLICIT ... FST_VD_INOUT */
00131                 const char *name;
00132                 uint32_t length;
00133                 fstHandle handle;
00134                 unsigned is_alias : 1;
00135                 } var;
00136         } u;
00137 };
00138 
00139 
00140 /*
00141  * writer functions
00142  */
00143 fstHandle fstWriterCreateVar(void *ctx, enum fstVarType vt, enum fstVarDir vd,
00144         uint32_t len, const char *nam, fstHandle aliasHandle);
00145 
00146 void fstWriterSetPackType(void *ctx, int typ);          /* type = 0 (libz), 1 (fastlz) */
00147 void fstWriterSetRepackOnClose(void *ctx, int enable);  /* type = 0 (none), 1 (libz) */
00148 void fstWriterSetDumpSizeLimit(void *ctx, uint64_t numbytes);
00149 int fstWriterGetDumpSizeLimitReached(void *ctx);
00150 
00151 void *fstWriterCreate(const char *nam, int use_compressed_hier);
00152 void fstWriterClose(void *ctx);
00153 void fstWriterSetDate(void *ctx, const char *dat);
00154 void fstWriterSetVersion(void *ctx, const char *vers);
00155 void fstWriterSetTimescale(void *ctx, int ts);
00156 void fstWriterSetTimescaleFromString(void *ctx, const char *s);
00157 void fstWriterSetScope(void *ctx, enum fstScopeType scopetype,
00158                 const char *scopename, const char *scopecomp);
00159 void fstWriterSetUpscope(void *ctx);
00160 void fstWriterEmitValueChange(void *ctx, fstHandle handle, const void *val);
00161 void fstWriterEmitDumpActive(void *ctx, int enable);
00162 void fstWriterEmitTimeChange(void *ctx, uint64_t tim);
00163 void fstWriterFlushContext(void *ctx);
00164 
00165 /*
00166  * reader functions
00167  */
00168 void *fstReaderOpen(const char *nam);
00169 void fstReaderClose(void *ctx);
00170 
00171 int fstReaderProcessHier(void *ctx, FILE *vcdhandle);
00172 int fstReaderIterateHierRewind(void *ctx);
00173 struct fstHier *fstReaderIterateHier(void *ctx);
00174 
00175 void fstReaderResetScope(void *ctx);
00176 const char *fstReaderPopScope(void *ctx);
00177 const char *fstReaderPushScope(void *ctx, const char *nam, void *user_info);
00178 const char *fstReaderGetCurrentFlatScope(void *ctx);
00179 void *fstReaderGetCurrentScopeUserInfo(void *ctx);
00180 
00181 signed char fstReaderGetTimescale(void *ctx);
00182 uint64_t fstReaderGetStartTime(void *ctx);
00183 uint64_t fstReaderGetEndTime(void *ctx);
00184 uint64_t fstReaderGetMemoryUsedByWriter(void *ctx);
00185 uint64_t fstReaderGetScopeCount(void *ctx);
00186 uint64_t fstReaderGetVarCount(void *ctx);
00187 fstHandle fstReaderGetMaxHandle(void *ctx);
00188 uint64_t fstReaderGetAliasCount(void *ctx);
00189 uint64_t fstReaderGetValueChangeSectionCount(void *ctx);
00190 int fstReaderGetDoubleEndianMatchState(void *ctx);
00191 const char *fstReaderGetVersionString(void *ctx);
00192 const char *fstReaderGetDateString(void *ctx);
00193 
00194 void fstReaderSetLimitTimeRange(void *ctx, uint64_t start_time, uint64_t end_time);
00195 void fstReaderSetUnlimitedTimeRange(void *ctx);
00196 
00197 uint32_t fstReaderGetNumberDumpActivityChanges(void *ctx);
00198 uint64_t fstReaderGetDumpActivityChangeTime(void *ctx, uint32_t idx);
00199 unsigned char fstReaderGetDumpActivityChangeValue(void *ctx, uint32_t idx);
00200 
00201 int fstReaderGetFacProcessMask(void *ctx, fstHandle facidx);
00202 void fstReaderSetFacProcessMask(void *ctx, fstHandle facidx);
00203 void fstReaderClrFacProcessMask(void *ctx, fstHandle facidx);
00204 void fstReaderSetFacProcessMaskAll(void *ctx);
00205 void fstReaderClrFacProcessMaskAll(void *ctx);
00206 
00207 void fstReaderIterBlocksSetNativeDoublesOnCallback(void *ctx, int enable);
00208 
00209 int fstReaderIterBlocks(void *ctx,
00210         void (*value_change_callback)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value),
00211         void *user_callback_data_pointer, FILE *vcdhandle);
00212 
00213 char *fstReaderGetValueFromHandleAtTime(void *ctx, uint64_t tim, fstHandle facidx, char *buf);
00214 
00215 #ifdef __cplusplus
00216 }
00217 #endif
00218 
00219 #endif
Generated on Sun Nov 21 00:55:35 2010 for Covered by  doxygen 1.6.3