1 /*
2  * Copyright (c) 2013 Tony Bybell.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 public class fstAPI
24 {
25 static
26 {
27 System.loadLibrary("fstAPI");
28 }
29 
30 
bitStringInt(int i, int len)31 private static String bitStringInt(int i, int len)
32 {
33 len = Math.min(32, Math.max(len, 1));
34 char[] cs = new char[len];
35 for (int j = len - 1, b = 1; 0 <= j; --j, b <<= 1)
36 	{
37         cs[j] = ((i & b) == 0) ? '0' : '1';
38     	}
39 return(new String(cs));
40 }
41 
42 
fstWriterCreate(String nam, boolean use_compressed_hier)43 protected native long fstWriterCreate(String nam, boolean use_compressed_hier);
fstWriterClose(long ctx)44 protected native void fstWriterClose(long ctx);
fstWriterGetFseekFailed(long ctx)45 protected native boolean fstWriterGetFseekFailed(long ctx);
fstWriterGetDumpSizeLimitReached(long ctx)46 protected native boolean fstWriterGetDumpSizeLimitReached(long ctx);
fstWriterFlushContext(long ctx)47 protected native void fstWriterFlushContext(long ctx);
fstWriterSetUpscope(long ctx)48 protected native void fstWriterSetUpscope(long ctx);
fstWriterSetAttrEnd(long ctx)49 protected native void fstWriterSetAttrEnd(long ctx);
fstWriterSetPackType(long ctx, int typ)50 protected native void fstWriterSetPackType(long ctx, int typ);
fstWriterSetFileType(long ctx, int typ)51 protected native void fstWriterSetFileType(long ctx, int typ);
fstWriterSetRepackOnClose(long ctx, boolean enable)52 protected native void fstWriterSetRepackOnClose(long ctx, boolean enable);
fstWriterSetParallelMode(long ctx, boolean enable)53 protected native void fstWriterSetParallelMode(long ctx, boolean enable);
fstWriterSetTimescale(long ctx, int ts)54 protected native void fstWriterSetTimescale(long ctx, int ts);
fstWriterSetTimezero(long ctx, long tim)55 protected native void fstWriterSetTimezero(long ctx, long tim);
fstWriterSetDumpSizeLimit(long ctx, long numbytes)56 protected native void fstWriterSetDumpSizeLimit(long ctx, long numbytes);
fstWriterEmitDumpActive(long ctx, boolean enable)57 protected native void fstWriterEmitDumpActive(long ctx, boolean enable);
fstWriterEmitTimeChange(long ctx, long tim)58 protected native void fstWriterEmitTimeChange(long ctx, long tim);
fstWriterSetDate(long ctx, String dat)59 protected native void fstWriterSetDate(long ctx, String dat);
fstWriterSetVersion(long ctx, String vers)60 protected native void fstWriterSetVersion(long ctx, String vers);
fstWriterSetComment(long ctx, String comm)61 protected native void fstWriterSetComment(long ctx, String comm);
fstWriterSetEnvVar(long ctx, String envvar)62 protected native void fstWriterSetEnvVar(long ctx, String envvar);
fstWriterSetTimescaleFromString(long ctx, String s)63 protected native void fstWriterSetTimescaleFromString(long ctx, String s);
fstWriterCreateVar(long ctx, int vt, int vd, int len, String nam, int aliasHandle)64 protected native int fstWriterCreateVar(long ctx, int vt, int vd, int len, String nam, int aliasHandle);
fstWriterCreateVar2(long ctx, int vt, int vd, int len, String nam, int aliasHandle, String type, int svt, int sdt)65 protected native int fstWriterCreateVar2(long ctx, int vt, int vd, int len, String nam, int aliasHandle, String type, int svt, int sdt);
fstWriterSetSourceStem(long ctx, String path, int line, boolean use_realpath)66 protected native void fstWriterSetSourceStem(long ctx, String path, int line, boolean use_realpath);
fstWriterSetSourceInstantiationStem(long ctx, String path, int line, boolean use_realpath)67 protected native void fstWriterSetSourceInstantiationStem(long ctx, String path, int line, boolean use_realpath);
fstWriterSetScope(long ctx, int scopetype, String scopename, String scopecomp)68 protected native void fstWriterSetScope(long ctx, int scopetype, String scopename, String scopecomp);
fstWriterEmitVariableLengthValueChange(long ctx, int handle, String val, int len)69 protected native void fstWriterEmitVariableLengthValueChange(long ctx, int handle, String val, int len);
fstWriterSetAttrBegin(long ctx, int attrtype, int subtype, String attrname, long arg)70 protected native void fstWriterSetAttrBegin(long ctx, int attrtype, int subtype, String attrname, long arg);
fstWriterEmitValueChange(long ctx, int handle, String val)71 protected native void fstWriterEmitValueChange(long ctx, int handle, String val);
fstWriterEmitValueChange(long ctx, int handle, double val)72 protected native void fstWriterEmitValueChange(long ctx, int handle, double val);
fstWriterEmitValueChange(long ctx, int handle, int val)73 protected        void fstWriterEmitValueChange(long ctx, int handle, int val) { fstWriterEmitValueChange(ctx, handle, bitStringInt(val, 32)); }
74 
fstReaderOpen(String nam)75 protected native long fstReaderOpen(String nam);
fstReaderOpenForUtilitiesOnly()76 protected native long fstReaderOpenForUtilitiesOnly();
fstReaderClose(long ctx)77 protected native void fstReaderClose(long ctx);
fstReaderIterateHierRewind(long ctx)78 protected native boolean fstReaderIterateHierRewind(long ctx);
fstReaderResetScope(long ctx)79 protected native void fstReaderResetScope(long ctx);
fstReaderGetCurrentScopeLen(long ctx)80 protected native int fstReaderGetCurrentScopeLen(long ctx);
fstReaderGetFileType(long ctx)81 protected native int fstReaderGetFileType(long ctx);
fstReaderGetTimezero(long ctx)82 protected native long fstReaderGetTimezero(long ctx);
fstReaderGetStartTime(long ctx)83 protected native long fstReaderGetStartTime(long ctx);
fstReaderGetEndTime(long ctx)84 protected native long fstReaderGetEndTime(long ctx);
fstReaderGetMemoryUsedByWriter(long ctx)85 protected native long fstReaderGetMemoryUsedByWriter(long ctx);
fstReaderGetScopeCount(long ctx)86 protected native long fstReaderGetScopeCount(long ctx);
fstReaderGetVarCount(long ctx)87 protected native long fstReaderGetVarCount(long ctx);
fstReaderGetMaxHandle(long ctx)88 protected native int fstReaderGetMaxHandle(long ctx);
fstReaderGetAliasCount(long ctx)89 protected native long fstReaderGetAliasCount(long ctx);
fstReaderGetValueChangeSectionCount(long ctx)90 protected native long fstReaderGetValueChangeSectionCount(long ctx);
fstReaderGetFseekFailed(long ctx)91 protected native boolean fstReaderGetFseekFailed(long ctx);
fstReaderSetUnlimitedTimeRange(long ctx)92 protected native void fstReaderSetUnlimitedTimeRange(long ctx);
fstReaderSetLimitTimeRange(long ctx, long start_time, long end_time)93 protected native void fstReaderSetLimitTimeRange(long ctx, long start_time, long end_time);
fstReaderSetVcdExtensions(long ctx, boolean enable)94 protected native void fstReaderSetVcdExtensions(long ctx, boolean enable);
fstReaderGetNumberDumpActivityChanges(long ctx)95 protected native int fstReaderGetNumberDumpActivityChanges(long ctx);
fstReaderGetDumpActivityChangeTime(long ctx, int idx)96 protected native long fstReaderGetDumpActivityChangeTime(long ctx, int idx);
fstReaderGetFacProcessMask(long ctx, int facidx)97 protected native boolean fstReaderGetFacProcessMask(long ctx, int facidx);
fstReaderSetFacProcessMask(long ctx, int facidx)98 protected native void fstReaderSetFacProcessMask(long ctx, int facidx);
fstReaderClrFacProcessMask(long ctx, int facidx)99 protected native void fstReaderClrFacProcessMask(long ctx, int facidx);
fstReaderSetFacProcessMaskAll(long ctx)100 protected native void fstReaderSetFacProcessMaskAll(long ctx);
fstReaderClrFacProcessMaskAll(long ctx)101 protected native void fstReaderClrFacProcessMaskAll(long ctx);
fstReaderGetVersionString(long ctx)102 protected native String fstReaderGetVersionString(long ctx);
fstReaderGetDateString(long ctx)103 protected native String fstReaderGetDateString(long ctx);
fstReaderPopScope(long ctx)104 protected native String fstReaderPopScope(long ctx);
fstReaderGetCurrentFlatScope(long ctx)105 protected native String fstReaderGetCurrentFlatScope(long ctx);
fstReaderGetCurrentScopeUserInfo(long ctx)106 protected native String fstReaderGetCurrentScopeUserInfo(long ctx);
fstReaderPushScope(long ctx, String nam, long user_info)107 protected native String fstReaderPushScope(long ctx, String nam, long user_info);
fstReaderGetTimescale(long ctx)108 protected native int fstReaderGetTimescale(long ctx);
fstReaderGetDumpActivityChangeValue(long ctx, int idx)109 protected native boolean fstReaderGetDumpActivityChangeValue(long ctx, int idx);
fstReaderGetValueFromHandleAtTime(long ctx, long tim, int facidx)110 protected native String fstReaderGetValueFromHandleAtTime(long ctx, long tim, int facidx);
fstReaderIterateHier(long ctx, fstHier fh)111 protected native void fstReaderIterateHier(long ctx, fstHier fh);
fstReaderIterBlocks(long ctx, Object cbobj)112 protected native int fstReaderIterBlocks(long ctx, Object cbobj);
113 
fstUtilityBinToEsc(byte []s, int len)114 public native static String fstUtilityBinToEsc(byte []s, int len);
fstUtilityEscToBin(String s)115 public native static byte[] fstUtilityEscToBin(String s);
116 
117 
118 //
119 // example do-nothing callback for fstReaderIterateHier()
120 //
fstReaderCallback(long tim, int facidx, String value)121 public void fstReaderCallback(long tim, int facidx, String value)
122 {
123 }
124 
125 }
126