Merge branch 'develop'
This commit is contained in:
commit
8e7e977ac5
|
@ -18,6 +18,6 @@
|
|||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc:com.minres.scviewer.parent}"/>
|
||||
</launchConfiguration>
|
||||
|
|
10
README.md
10
README.md
|
@ -1,12 +1,8 @@
|
|||
SCViewer
|
||||
========
|
||||
|
||||
SCViewer is composed of a set of eclipse plugins to display VCD and transaction streams
|
||||
created by the SystemC VCD trace implementation and the SystemC Verification Library (SCV).
|
||||
For further description of the SCV please refer to
|
||||
http://www.accellera.org/activities/committees/systemc-verification.
|
||||
|
||||
> If you encounter issue when running on Linux please try running as `SWT_GTK3=0 scviewer` as there exist issues wiht GTK3.
|
||||
SCViewer is composed of a set of eclipse plugins to display VCD (e.g. created by SystemC VCD trace) and transaction streams. Those streams can be
|
||||
created by the SystemC Verification Library (SCV, For further description of the SCV please refer to https://www.accellera.org/activities/working-groups/systemc-verification) or by the **L**ight**w**eight **T**ranasaction **R**ecording for SystemC ( [LWTR4SC](https://github.com/Minres/LWTR4SC) ).
|
||||
|
||||
The viewer has the following features
|
||||
- support of VCD files (compressed and uncompressed)
|
||||
|
@ -18,6 +14,8 @@ The viewer has the following features
|
|||
- sqlite based
|
||||
- visualization of transaction relations
|
||||
|
||||
> If you encounter issue when running on Linux please try running as `SWT_GTK3=0 scviewer` as there exist issues wiht GTK3.
|
||||
|
||||
To build the plugins the Eclipse SDK or PDE can be used.
|
||||
|
||||
Key Shortcuts
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.17.3</version>
|
||||
<version>2.18.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -77,4 +77,12 @@ http://www.eclipse.org/legal/epl-v10.html
|
|||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.minres.scviewer.database.fst"
|
||||
os="linux,win32"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.17.3</version>
|
||||
<version>2.18.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.17.3</version>
|
||||
<version>2.18.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.17.3</version>
|
||||
<version>2.18.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.17.3</version>
|
||||
<version>2.18.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.17.3</version>
|
||||
<version>2.18.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.17.3</version>
|
||||
<version>2.18.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="lib/jna-5.13.0.jar" sourcepath="lib/jna-5.13.0-sources.jar">
|
||||
<attributes>
|
||||
<attribute name="javadoc_location" value="jar:platform:/resource/com.minres.scviewer.database.fst/lib/jna-5.13.0-javadoc.jar!/"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/jna-jpms-5.13.0.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1,3 @@
|
|||
/bin/
|
||||
/.settings/
|
||||
/target/
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.minres.scviewer.database.fst</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ds.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,17 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: FST signal database
|
||||
Bundle-SymbolicName: com.minres.scviewer.database.fst
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: MINRES Technologies GmbH
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
|
||||
org.eclipse.osgi.services;bundle-version="3.4.0",
|
||||
com.google.guava;bundle-version="15.0.0"
|
||||
Service-Component: OSGI-INF/component.xml
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-ClassPath: lib/jna-5.13.0.jar,
|
||||
lib/jna-jpms-5.13.0.jar,
|
||||
.
|
||||
Automatic-Module-Name: com.minres.scviewer.database.fst
|
||||
Import-Package: org.osgi.framework;version="1.10.0"
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="FstDbLoaderFactory">
|
||||
<implementation class="com.minres.scviewer.database.fst.FstDbLoaderFactory"/>
|
||||
<service>
|
||||
<provide interface="com.minres.scviewer.database.IWaveformDbLoaderFactory"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -0,0 +1,9 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
lib/jna-5.13.0.jar,\
|
||||
lib/jna-jpms-5.13.0.jar,\
|
||||
linux-x86-64/,\
|
||||
win32-x86-64/,\
|
||||
OSGI-INF/
|
|
@ -0,0 +1 @@
|
|||
/build/
|
|
@ -0,0 +1,35 @@
|
|||
cmake_minimum_required (VERSION 3.0)
|
||||
|
||||
project (fstlib VERSION 1.0.0)
|
||||
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
#find_package(ZLIB REQUIRED)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
zlib
|
||||
URL https://www.zlib.net/zlib-1.2.13.tar.gz
|
||||
https://www.zlib.net/fossils/zlib-1.2.13.tar.gz
|
||||
https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.gz
|
||||
URL_HASH MD5=9b8aa094c4e5765dabf4da391f00d15c
|
||||
)
|
||||
FetchContent_Populate(zlib)
|
||||
add_subdirectory(${zlib_SOURCE_DIR} ${zlib_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
add_library(ZLIB::ZLIB ALIAS zlibstatic)
|
||||
target_include_directories(zlibstatic INTERFACE ${zlib_BINARY_DIR} ${zlib_SOURCE_DIR})
|
||||
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
add_library(fstapi fstapi.c lz4.c fastlz.c fst_helper.c)
|
||||
#target_include_directories(fstapi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIRS})
|
||||
target_link_libraries(fstapi PRIVATE zlibstatic)
|
||||
# hack to avoid creating dummy config.h
|
||||
target_compile_definitions(fstapi PRIVATE -DFST_CONFIG_INCLUDE="fstapi.h")
|
||||
|
||||
if(MSVC)
|
||||
# define __MINGW32__ to minimize changes to upstream
|
||||
target_compile_definitions(fstapi PRIVATE __MINGW32__ _CRT_SECURE_NO_WARNINGS FST_DO_MISALIGNED_OPS)
|
||||
target_compile_options(fstapi PRIVATE /wd4244 /wd4267 /wd4146 /wd4996)
|
||||
endif()
|
||||
|
||||
install(TARGETS fstapi
|
||||
LIBRARY DESTINATION .
|
||||
RUNTIME DESTINATION .)
|
|
@ -0,0 +1,130 @@
|
|||
See fstapi.h for the values for the FST_BL_XXX enums.
|
||||
|
||||
===========================================================================
|
||||
|
||||
compressed wrapper (typically over whole file)
|
||||
|
||||
uint8_t FST_BL_ZWRAPPER
|
||||
uint64_t section length
|
||||
uint64_t length of uncompressed data
|
||||
[zlib compressed data]
|
||||
|
||||
===========================================================================
|
||||
|
||||
header block
|
||||
|
||||
uint8_t FST_BL_HDR
|
||||
uint64_t section length
|
||||
uint64_t start time
|
||||
uint64_t end time
|
||||
double endian test for "e"
|
||||
uint64_t memory used by writer
|
||||
uint64_t scope creation count
|
||||
uint64_t var creation count
|
||||
uint64_t max var idcode
|
||||
uint64_t vc section count
|
||||
int8_t timescale exponent
|
||||
[128 bytes] version
|
||||
[128 bytes] date
|
||||
|
||||
===========================================================================
|
||||
|
||||
geometry block
|
||||
|
||||
uint8_t FST_BL_GEOM
|
||||
uint64_t section length
|
||||
uint64_t length of uncompressed geometry data
|
||||
uint64_t maxhandle
|
||||
[compressed data]
|
||||
|
||||
(length of compressed data is section length - 24)
|
||||
|
||||
===========================================================================
|
||||
|
||||
hierarchy block
|
||||
|
||||
uint8_t FST_BL_HIER
|
||||
uint64_t section length
|
||||
uint64_t length of uncompressed hier data
|
||||
[zlib compressed data]
|
||||
|
||||
or
|
||||
|
||||
uint8_t FST_BL_HIER_LZ4
|
||||
uint64_t section length
|
||||
uint64_t length of uncompressed hier data
|
||||
[lz4 compressed data]
|
||||
|
||||
uint8_t FST_BL_HIER_LZ4DUO
|
||||
uint64_t section length
|
||||
uint64_t length of uncompressed hier data
|
||||
varint length of hier data compressed once with lz4
|
||||
[lz4 double compressed data]
|
||||
|
||||
|
||||
===========================================================================
|
||||
|
||||
dumpon/off block
|
||||
|
||||
uint8_t FST_BL_BLACKOUT
|
||||
uint64_t section length
|
||||
varint num blackouts (section below is repeated this # times)
|
||||
[
|
||||
uint8_t on/off (nonzero = on)
|
||||
varint delta time
|
||||
]
|
||||
|
||||
===========================================================================
|
||||
|
||||
1..n value change blocks:
|
||||
|
||||
// header
|
||||
|
||||
uint8_t FST_BL_VCDATA (or FST_BL_VCDATA_DYN_ALIAS)
|
||||
uint64_t section length
|
||||
uint64_t begin time of section
|
||||
uint64_t end time of section
|
||||
uint64_t amount of buffer memory required in reader for full vc traversal
|
||||
varint maxvalpos (length of uncompressed data)
|
||||
varint length of compressed data
|
||||
varint maxhandle associated with this checkpoint data
|
||||
[compressed data]
|
||||
|
||||
---
|
||||
|
||||
// value changes
|
||||
|
||||
varint maxhandle associated with the value change data
|
||||
uint8_t pack type ('F' is fastlz, '4' is lz4,
|
||||
others ['Z'/'!'] are zlib)
|
||||
|
||||
varint chain 0 compressed data length (0 = uncompressed)
|
||||
[compressed data]
|
||||
...
|
||||
varint chain n compressed data length (0 = uncompressed)
|
||||
[compressed data]
|
||||
|
||||
---
|
||||
|
||||
// index: chain pointer table (from 0..maxhandle-1)
|
||||
|
||||
varint if &1 == 1, this is <<1 literal delta
|
||||
if &1 == 0, this is <<1 RLE count of zeros
|
||||
if == 0, next varint is handle of prev chain to use,
|
||||
bit only if FST_BL_VCDATA_DYN_ALIAS or
|
||||
later VCDATA format
|
||||
|
||||
---
|
||||
|
||||
uint64_t index length (subtract from here to get index position)
|
||||
|
||||
---
|
||||
|
||||
[compressed data for time section]
|
||||
uint64_t uncompressed data length in bytes
|
||||
uint64_t compressed data length in bytes
|
||||
uint64_t number of time items
|
||||
|
||||
// end of section
|
||||
|
||||
===========================================================================
|
|
@ -0,0 +1,2 @@
|
|||
cmake -B build -S . -DCMAKE_INSTALL_PREFIX=../../win32-x86-64
|
||||
cmake --build build --target install --config Release
|
|
@ -0,0 +1,2 @@
|
|||
cmake -B build -S . -DCMAKE_INSTALL_PREFIX=../../linux-x86-64 -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build build --target install
|
|
@ -0,0 +1,549 @@
|
|||
/*
|
||||
FastLZ - lightning-fast lossless compression library
|
||||
|
||||
Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
|
||||
Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
|
||||
Copyright (C) 2005 Ariya Hidayat (ariya@kde.org)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "fastlz.h"
|
||||
|
||||
#if !defined(FASTLZ__COMPRESSOR) && !defined(FASTLZ_DECOMPRESSOR)
|
||||
|
||||
/*
|
||||
* Always check for bound when decompressing.
|
||||
* Generally it is best to leave it defined.
|
||||
*/
|
||||
#define FASTLZ_SAFE
|
||||
|
||||
|
||||
/*
|
||||
* Give hints to the compiler for branch prediction optimization.
|
||||
*/
|
||||
#if defined(__GNUC__) && (__GNUC__ > 2)
|
||||
#define FASTLZ_EXPECT_CONDITIONAL(c) (__builtin_expect((c), 1))
|
||||
#define FASTLZ_UNEXPECT_CONDITIONAL(c) (__builtin_expect((c), 0))
|
||||
#else
|
||||
#define FASTLZ_EXPECT_CONDITIONAL(c) (c)
|
||||
#define FASTLZ_UNEXPECT_CONDITIONAL(c) (c)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Use inlined functions for supported systems.
|
||||
*/
|
||||
#if defined(__GNUC__) || defined(__DMC__) || defined(__POCC__) || defined(__WATCOMC__) || defined(__SUNPRO_C)
|
||||
#define FASTLZ_INLINE inline
|
||||
#elif defined(__BORLANDC__) || defined(_MSC_VER) || defined(__LCC__)
|
||||
#define FASTLZ_INLINE __inline
|
||||
#else
|
||||
#define FASTLZ_INLINE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Prevent accessing more than 8-bit at once, except on x86 architectures.
|
||||
*/
|
||||
#if !defined(FASTLZ_STRICT_ALIGN)
|
||||
#define FASTLZ_STRICT_ALIGN
|
||||
#if defined(__i386__) || defined(__386) /* GNU C, Sun Studio */
|
||||
#undef FASTLZ_STRICT_ALIGN
|
||||
#elif defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__amd64) /* GNU C */
|
||||
#undef FASTLZ_STRICT_ALIGN
|
||||
#elif defined(_M_IX86) /* Intel, MSVC */
|
||||
#undef FASTLZ_STRICT_ALIGN
|
||||
#elif defined(__386)
|
||||
#undef FASTLZ_STRICT_ALIGN
|
||||
#elif defined(_X86_) /* MinGW */
|
||||
#undef FASTLZ_STRICT_ALIGN
|
||||
#elif defined(__I86__) /* Digital Mars */
|
||||
#undef FASTLZ_STRICT_ALIGN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* prototypes */
|
||||
int fastlz_compress(const void* input, int length, void* output);
|
||||
int fastlz_compress_level(int level, const void* input, int length, void* output);
|
||||
int fastlz_decompress(const void* input, int length, void* output, int maxout);
|
||||
|
||||
#define MAX_COPY 32
|
||||
#define MAX_LEN 264 /* 256 + 8 */
|
||||
#define MAX_DISTANCE 8192
|
||||
|
||||
#if !defined(FASTLZ_STRICT_ALIGN)
|
||||
#define FASTLZ_READU16(p) *((const flzuint16*)(p))
|
||||
#else
|
||||
#define FASTLZ_READU16(p) ((p)[0] | (p)[1]<<8)
|
||||
#endif
|
||||
|
||||
#define HASH_LOG 13
|
||||
#define HASH_SIZE (1<< HASH_LOG)
|
||||
#define HASH_MASK (HASH_SIZE-1)
|
||||
#define HASH_FUNCTION(v,p) { v = FASTLZ_READU16(p); v ^= FASTLZ_READU16(p+1)^(v>>(16-HASH_LOG));v &= HASH_MASK; }
|
||||
|
||||
#undef FASTLZ_LEVEL
|
||||
#define FASTLZ_LEVEL 1
|
||||
|
||||
#undef FASTLZ_COMPRESSOR
|
||||
#undef FASTLZ_DECOMPRESSOR
|
||||
#define FASTLZ_COMPRESSOR fastlz1_compress
|
||||
#define FASTLZ_DECOMPRESSOR fastlz1_decompress
|
||||
static FASTLZ_INLINE int FASTLZ_COMPRESSOR(const void* input, int length, void* output);
|
||||
static FASTLZ_INLINE int FASTLZ_DECOMPRESSOR(const void* input, int length, void* output, int maxout);
|
||||
#include "fastlz.c"
|
||||
|
||||
#undef FASTLZ_LEVEL
|
||||
#define FASTLZ_LEVEL 2
|
||||
|
||||
#undef MAX_DISTANCE
|
||||
#define MAX_DISTANCE 8191
|
||||
#define MAX_FARDISTANCE (65535+MAX_DISTANCE-1)
|
||||
|
||||
#undef FASTLZ_COMPRESSOR
|
||||
#undef FASTLZ_DECOMPRESSOR
|
||||
#define FASTLZ_COMPRESSOR fastlz2_compress
|
||||
#define FASTLZ_DECOMPRESSOR fastlz2_decompress
|
||||
static FASTLZ_INLINE int FASTLZ_COMPRESSOR(const void* input, int length, void* output);
|
||||
static FASTLZ_INLINE int FASTLZ_DECOMPRESSOR(const void* input, int length, void* output, int maxout);
|
||||
#include "fastlz.c"
|
||||
|
||||
int fastlz_compress(const void* input, int length, void* output)
|
||||
{
|
||||
/* for short block, choose fastlz1 */
|
||||
if(length < 65536)
|
||||
return fastlz1_compress(input, length, output);
|
||||
|
||||
/* else... */
|
||||
return fastlz2_compress(input, length, output);
|
||||
}
|
||||
|
||||
int fastlz_decompress(const void* input, int length, void* output, int maxout)
|
||||
{
|
||||
/* magic identifier for compression level */
|
||||
int level = ((*(const flzuint8*)input) >> 5) + 1;
|
||||
|
||||
if(level == 1)
|
||||
return fastlz1_decompress(input, length, output, maxout);
|
||||
if(level == 2)
|
||||
return fastlz2_decompress(input, length, output, maxout);
|
||||
|
||||
/* unknown level, trigger error */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fastlz_compress_level(int level, const void* input, int length, void* output)
|
||||
{
|
||||
if(level == 1)
|
||||
return fastlz1_compress(input, length, output);
|
||||
if(level == 2)
|
||||
return fastlz2_compress(input, length, output);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* !defined(FASTLZ_COMPRESSOR) && !defined(FASTLZ_DECOMPRESSOR) */
|
||||
|
||||
static FASTLZ_INLINE int FASTLZ_COMPRESSOR(const void* input, int length, void* output)
|
||||
{
|
||||
const flzuint8* ip = (const flzuint8*) input;
|
||||
const flzuint8* ip_bound = ip + length - 2;
|
||||
const flzuint8* ip_limit = ip + length - 12;
|
||||
flzuint8* op = (flzuint8*) output;
|
||||
|
||||
const flzuint8* htab[HASH_SIZE];
|
||||
const flzuint8** hslot;
|
||||
flzuint32 hval;
|
||||
|
||||
flzuint32 copy;
|
||||
|
||||
/* sanity check */
|
||||
if(FASTLZ_UNEXPECT_CONDITIONAL(length < 4))
|
||||
{
|
||||
if(length)
|
||||
{
|
||||
/* create literal copy only */
|
||||
*op++ = length-1;
|
||||
ip_bound++;
|
||||
while(ip <= ip_bound)
|
||||
*op++ = *ip++;
|
||||
return length+1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* initializes hash table */
|
||||
for (hslot = htab; hslot < htab + HASH_SIZE; hslot++)
|
||||
*hslot = ip;
|
||||
|
||||
/* we start with literal copy */
|
||||
copy = 2;
|
||||
*op++ = MAX_COPY-1;
|
||||
*op++ = *ip++;
|
||||
*op++ = *ip++;
|
||||
|
||||
/* main loop */
|
||||
while(FASTLZ_EXPECT_CONDITIONAL(ip < ip_limit))
|
||||
{
|
||||
const flzuint8* ref;
|
||||
flzuint32 distance;
|
||||
|
||||
/* minimum match length */
|
||||
flzuint32 len = 3;
|
||||
|
||||
/* comparison starting-point */
|
||||
const flzuint8* anchor = ip;
|
||||
|
||||
/* check for a run */
|
||||
#if FASTLZ_LEVEL==2
|
||||
if(ip[0] == ip[-1] && FASTLZ_READU16(ip-1)==FASTLZ_READU16(ip+1))
|
||||
{
|
||||
distance = 1;
|
||||
/* ip += 3; */ /* scan-build, never used */
|
||||
ref = anchor - 1 + 3;
|
||||
goto match;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* find potential match */
|
||||
HASH_FUNCTION(hval,ip);
|
||||
hslot = htab + hval;
|
||||
ref = htab[hval];
|
||||
|
||||
/* calculate distance to the match */
|
||||
distance = anchor - ref;
|
||||
|
||||
/* update hash table */
|
||||
*hslot = anchor;
|
||||
|
||||
/* is this a match? check the first 3 bytes */
|
||||
if(distance==0 ||
|
||||
#if FASTLZ_LEVEL==1
|
||||
(distance >= MAX_DISTANCE) ||
|
||||
#else
|
||||
(distance >= MAX_FARDISTANCE) ||
|
||||
#endif
|
||||
*ref++ != *ip++ || *ref++!=*ip++ || *ref++!=*ip++)
|
||||
goto literal;
|
||||
|
||||
#if FASTLZ_LEVEL==2
|
||||
/* far, needs at least 5-byte match */
|
||||
if(distance >= MAX_DISTANCE)
|
||||
{
|
||||
if(*ip++ != *ref++ || *ip++!= *ref++)
|
||||
goto literal;
|
||||
len += 2;
|
||||
}
|
||||
|
||||
match:
|
||||
#endif
|
||||
|
||||
/* last matched byte */
|
||||
ip = anchor + len;
|
||||
|
||||
/* distance is biased */
|
||||
distance--;
|
||||
|
||||
if(!distance)
|
||||
{
|
||||
/* zero distance means a run */
|
||||
flzuint8 x = ip[-1];
|
||||
while(ip < ip_bound)
|
||||
if(*ref++ != x) break; else ip++;
|
||||
}
|
||||
else
|
||||
for(;;)
|
||||
{
|
||||
/* safe because the outer check against ip limit */
|
||||
if(*ref++ != *ip++) break;
|
||||
if(*ref++ != *ip++) break;
|
||||
if(*ref++ != *ip++) break;
|
||||
if(*ref++ != *ip++) break;
|
||||
if(*ref++ != *ip++) break;
|
||||
if(*ref++ != *ip++) break;
|
||||
if(*ref++ != *ip++) break;
|
||||
if(*ref++ != *ip++) break;
|
||||
while(ip < ip_bound)
|
||||
if(*ref++ != *ip++) break;
|
||||
break;
|
||||
}
|
||||
|
||||
/* if we have copied something, adjust the copy count */
|
||||
if(copy)
|
||||
/* copy is biased, '0' means 1 byte copy */
|
||||
*(op-copy-1) = copy-1;
|
||||
else
|
||||
/* back, to overwrite the copy count */
|
||||
op--;
|
||||
|
||||
/* reset literal counter */
|
||||
copy = 0;
|
||||
|
||||
/* length is biased, '1' means a match of 3 bytes */
|
||||
ip -= 3;
|
||||
len = ip - anchor;
|
||||
|
||||
/* encode the match */
|
||||
#if FASTLZ_LEVEL==2
|
||||
if(distance < MAX_DISTANCE)
|
||||
{
|
||||
if(len < 7)
|
||||
{
|
||||
*op++ = (len << 5) + (distance >> 8);
|
||||
*op++ = (distance & 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
*op++ = (7 << 5) + (distance >> 8);
|
||||
for(len-=7; len >= 255; len-= 255)
|
||||
*op++ = 255;
|
||||
*op++ = len;
|
||||
*op++ = (distance & 255);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* far away, but not yet in the another galaxy... */
|
||||
if(len < 7)
|
||||
{
|
||||
distance -= MAX_DISTANCE;
|
||||
*op++ = (len << 5) + 31;
|
||||
*op++ = 255;
|
||||
*op++ = distance >> 8;
|
||||
*op++ = distance & 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
distance -= MAX_DISTANCE;
|
||||
*op++ = (7 << 5) + 31;
|
||||
for(len-=7; len >= 255; len-= 255)
|
||||
*op++ = 255;
|
||||
*op++ = len;
|
||||
*op++ = 255;
|
||||
*op++ = distance >> 8;
|
||||
*op++ = distance & 255;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
if(FASTLZ_UNEXPECT_CONDITIONAL(len > MAX_LEN-2))
|
||||
while(len > MAX_LEN-2)
|
||||
{
|
||||
*op++ = (7 << 5) + (distance >> 8);
|
||||
*op++ = MAX_LEN - 2 - 7 -2;
|
||||
*op++ = (distance & 255);
|
||||
len -= MAX_LEN-2;
|
||||
}
|
||||
|
||||
if(len < 7)
|
||||
{
|
||||
*op++ = (len << 5) + (distance >> 8);
|
||||
*op++ = (distance & 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
*op++ = (7 << 5) + (distance >> 8);
|
||||
*op++ = len - 7;
|
||||
*op++ = (distance & 255);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* update the hash at match boundary */
|
||||
HASH_FUNCTION(hval,ip);
|
||||
htab[hval] = ip++;
|
||||
HASH_FUNCTION(hval,ip);
|
||||
htab[hval] = ip++;
|
||||
|
||||
/* assuming literal copy */
|
||||
*op++ = MAX_COPY-1;
|
||||
|
||||
continue;
|
||||
|
||||
literal:
|
||||
*op++ = *anchor++;
|
||||
ip = anchor;
|
||||
copy++;
|
||||
if(FASTLZ_UNEXPECT_CONDITIONAL(copy == MAX_COPY))
|
||||
{
|
||||
copy = 0;
|
||||
*op++ = MAX_COPY-1;
|
||||
}
|
||||
}
|
||||
|
||||
/* left-over as literal copy */
|
||||
ip_bound++;
|
||||
while(ip <= ip_bound)
|
||||
{
|
||||
*op++ = *ip++;
|
||||
copy++;
|
||||
if(copy == MAX_COPY)
|
||||
{
|
||||
copy = 0;
|
||||
*op++ = MAX_COPY-1;
|
||||
}
|
||||
}
|
||||
|
||||
/* if we have copied something, adjust the copy length */
|
||||
if(copy)
|
||||
*(op-copy-1) = copy-1;
|
||||
else
|
||||
op--;
|
||||
|
||||
#if FASTLZ_LEVEL==2
|
||||
/* marker for fastlz2 */
|
||||
*(flzuint8*)output |= (1 << 5);
|
||||
#endif
|
||||
|
||||
return op - (flzuint8*)output;
|
||||
}
|
||||
|
||||
static FASTLZ_INLINE int FASTLZ_DECOMPRESSOR(const void* input, int length, void* output, int maxout)
|
||||
{
|
||||
const flzuint8* ip = (const flzuint8*) input;
|
||||
const flzuint8* ip_limit = ip + length;
|
||||
flzuint8* op = (flzuint8*) output;
|
||||
flzuint8* op_limit = op + maxout;
|
||||
flzuint32 ctrl = (*ip++) & 31;
|
||||
int loop = 1;
|
||||
|
||||
do
|
||||
{
|
||||
const flzuint8* ref = op;
|
||||
flzuint32 len = ctrl >> 5;
|
||||
flzuint32 ofs = (ctrl & 31) << 8;
|
||||
|
||||
if(ctrl >= 32)
|
||||
{
|
||||
#if FASTLZ_LEVEL==2
|
||||
flzuint8 code;
|
||||
#endif
|
||||
len--;
|
||||
ref -= ofs;
|
||||
if (len == 7-1)
|
||||
#if FASTLZ_LEVEL==1
|
||||
len += *ip++;
|
||||
ref -= *ip++;
|
||||
#else
|
||||
do
|
||||
{
|
||||
code = *ip++;
|
||||
len += code;
|
||||
} while (code==255);
|
||||
code = *ip++;
|
||||
ref -= code;
|
||||
|
||||
/* match from 16-bit distance */
|
||||
if(FASTLZ_UNEXPECT_CONDITIONAL(code==255))
|
||||
if(FASTLZ_EXPECT_CONDITIONAL(ofs==(31 << 8)))
|
||||
{
|
||||
ofs = (*ip++) << 8;
|
||||
ofs += *ip++;
|
||||
ref = op - ofs - MAX_DISTANCE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FASTLZ_SAFE
|
||||
if (FASTLZ_UNEXPECT_CONDITIONAL(op + len + 3 > op_limit))
|
||||
return 0;
|
||||
|
||||
if (FASTLZ_UNEXPECT_CONDITIONAL(ref-1 < (flzuint8 *)output))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
if(FASTLZ_EXPECT_CONDITIONAL(ip < ip_limit))
|
||||
ctrl = *ip++;
|
||||
else
|
||||
loop = 0;
|
||||
|
||||
if(ref == op)
|
||||
{
|
||||
/* optimize copy for a run */
|
||||
flzuint8 b = ref[-1];
|
||||
*op++ = b;
|
||||
*op++ = b;
|
||||
*op++ = b;
|
||||
for(; len; --len)
|
||||
*op++ = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(FASTLZ_STRICT_ALIGN)
|
||||
const flzuint16* p;
|
||||
flzuint16* q;
|
||||
#endif
|
||||
/* copy from reference */
|
||||
ref--;
|
||||
*op++ = *ref++;
|
||||
*op++ = *ref++;
|
||||
*op++ = *ref++;
|
||||
|
||||
#if !defined(FASTLZ_STRICT_ALIGN)
|
||||
/* copy a byte, so that now it's word aligned */
|
||||
if(len & 1)
|
||||
{
|
||||
*op++ = *ref++;
|
||||
len--;
|
||||
}
|
||||
|
||||
/* copy 16-bit at once */
|
||||
q = (flzuint16*) op;
|
||||
op += len;
|
||||
p = (const flzuint16*) ref;
|
||||
for(len>>=1; len > 4; len-=4)
|
||||
{
|
||||
*q++ = *p++;
|
||||
*q++ = *p++;
|
||||
*q++ = *p++;
|
||||
*q++ = *p++;
|
||||
}
|
||||
for(; len; --len)
|
||||
*q++ = *p++;
|
||||
#else
|
||||
for(; len; --len)
|
||||
*op++ = *ref++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ctrl++;
|
||||
#ifdef FASTLZ_SAFE
|
||||
if (FASTLZ_UNEXPECT_CONDITIONAL(op + ctrl > op_limit))
|
||||
return 0;
|
||||
if (FASTLZ_UNEXPECT_CONDITIONAL(ip + ctrl > ip_limit))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
*op++ = *ip++;
|
||||
for(--ctrl; ctrl; ctrl--)
|
||||
*op++ = *ip++;
|
||||
|
||||
loop = FASTLZ_EXPECT_CONDITIONAL(ip < ip_limit);
|
||||
if(loop)
|
||||
ctrl = *ip++;
|
||||
}
|
||||
}
|
||||
while(FASTLZ_EXPECT_CONDITIONAL(loop));
|
||||
|
||||
return op - (flzuint8*)output;
|
||||
}
|
||||
|
||||
#endif /* !defined(FASTLZ_COMPRESSOR) && !defined(FASTLZ_DECOMPRESSOR) */
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
FastLZ - lightning-fast lossless compression library
|
||||
|
||||
Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
|
||||
Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
|
||||
Copyright (C) 2005 Ariya Hidayat (ariya@kde.org)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef FASTLZ_H
|
||||
#define FASTLZ_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#define flzuint8 uint8_t
|
||||
#define flzuint16 uint16_t
|
||||
#define flzuint32 uint32_t
|
||||
|
||||
|
||||
#define FASTLZ_VERSION 0x000100
|
||||
|
||||
#define FASTLZ_VERSION_MAJOR 0
|
||||
#define FASTLZ_VERSION_MINOR 0
|
||||
#define FASTLZ_VERSION_REVISION 0
|
||||
|
||||
#define FASTLZ_VERSION_STRING "0.1.0"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Compress a block of data in the input buffer and returns the size of
|
||||
compressed block. The size of input buffer is specified by length. The
|
||||
minimum input buffer size is 16.
|
||||
|
||||
The output buffer must be at least 5% larger than the input buffer
|
||||
and can not be smaller than 66 bytes.
|
||||
|
||||
If the input is not compressible, the return value might be larger than
|
||||
length (input buffer size).
|
||||
|
||||
The input buffer and the output buffer can not overlap.
|
||||
*/
|
||||
|
||||
int fastlz_compress(const void* input, int length, void* output);
|
||||
|
||||
/**
|
||||
Decompress a block of compressed data and returns the size of the
|
||||
decompressed block. If error occurs, e.g. the compressed data is
|
||||
corrupted or the output buffer is not large enough, then 0 (zero)
|
||||
will be returned instead.
|
||||
|
||||
The input buffer and the output buffer can not overlap.
|
||||
|
||||
Decompression is memory safe and guaranteed not to write the output buffer
|
||||
more than what is specified in maxout.
|
||||
*/
|
||||
|
||||
int fastlz_decompress(const void* input, int length, void* output, int maxout);
|
||||
|
||||
/**
|
||||
Compress a block of data in the input buffer and returns the size of
|
||||
compressed block. The size of input buffer is specified by length. The
|
||||
minimum input buffer size is 16.
|
||||
|
||||
The output buffer must be at least 5% larger than the input buffer
|
||||
and can not be smaller than 66 bytes.
|
||||
|
||||
If the input is not compressible, the return value might be larger than
|
||||
length (input buffer size).
|
||||
|
||||
The input buffer and the output buffer can not overlap.
|
||||
|
||||
Compression level can be specified in parameter level. At the moment,
|
||||
only level 1 and level 2 are supported.
|
||||
Level 1 is the fastest compression and generally useful for short data.
|
||||
Level 2 is slightly slower but it gives better compression ratio.
|
||||
|
||||
Note that the compressed data, regardless of the level, can always be
|
||||
decompressed using the function fastlz_decompress above.
|
||||
*/
|
||||
|
||||
int fastlz_compress_level(int level, const void* input, int length, void* output);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FASTLZ_H */
|
|
@ -0,0 +1,31 @@
|
|||
#include "fstapi.h"
|
||||
|
||||
int getHierType(struct fstHier * hier){
|
||||
return hier->htyp;
|
||||
}
|
||||
|
||||
void getHierScope(struct fstHier* h, struct fstHierScope* scope){
|
||||
if(h->htyp==FST_HT_SCOPE)
|
||||
*scope=h->u.scope;
|
||||
}
|
||||
|
||||
void getHierVar(struct fstHier* h, struct fstHierVar* var){
|
||||
if(h->htyp==FST_HT_VAR)
|
||||
*var=h->u.var;
|
||||
}
|
||||
|
||||
void getHierAttr(struct fstHier* h, struct fstHierAttr* attr){
|
||||
if(h->htyp==FST_HT_ATTRBEGIN)
|
||||
*attr=h->u.attr;
|
||||
}
|
||||
|
||||
typedef void (*value_change_callback)(uint64_t time, fstHandle facidx, const char *value);
|
||||
|
||||
static void forward_cb(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value) {
|
||||
//fprintf(stderr, "val: %s @ %ld\n", value, time);
|
||||
((value_change_callback)user_callback_data_pointer)(time, facidx, value);
|
||||
}
|
||||
|
||||
void iterateValueChanges(void* ctx, value_change_callback vcc) {
|
||||
fstReaderIterBlocks(ctx, forward_cb, vcc, NULL);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2009-2018 Tony Bybell.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef WIN_UNISTD_H
|
||||
#define WIN_UNISTD_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifdef _WIN64
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <sys/io.h>
|
||||
#endif
|
||||
|
||||
#include <process.h>
|
||||
|
||||
#define ftruncate _chsize_s
|
||||
#define unlink _unlink
|
||||
#define fileno _fileno
|
||||
#define lseek _lseeki64
|
||||
|
||||
#ifdef _WIN64
|
||||
#define ssize_t __int64
|
||||
#define SSIZE_MAX 9223372036854775807i64
|
||||
#else
|
||||
#define ssize_t long
|
||||
#define SSIZE_MAX 2147483647L
|
||||
#endif
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#endif //WIN_UNISTD_H
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,466 @@
|
|||
/*
|
||||
* Copyright (c) 2009-2018 Tony Bybell.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef FST_API_H
|
||||
#define FST_API_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <zlib.h>
|
||||
#include <inttypes.h>
|
||||
#if defined(_MSC_VER)
|
||||
#include "fst_win_unistd.h"
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
#define FST_RDLOAD "FSTLOAD | "
|
||||
|
||||
typedef uint32_t fstHandle;
|
||||
typedef uint32_t fstEnumHandle;
|
||||
|
||||
enum fstWriterPackType {
|
||||
FST_WR_PT_ZLIB = 0,
|
||||
FST_WR_PT_FASTLZ = 1,
|
||||
FST_WR_PT_LZ4 = 2
|
||||
};
|
||||
|
||||
enum fstFileType {
|
||||
FST_FT_MIN = 0,
|
||||
|
||||
FST_FT_VERILOG = 0,
|
||||
FST_FT_VHDL = 1,
|
||||
FST_FT_VERILOG_VHDL = 2,
|
||||
|
||||
FST_FT_MAX = 2
|
||||
};
|
||||
|
||||
enum fstBlockType {
|
||||
FST_BL_HDR = 0,
|
||||
FST_BL_VCDATA = 1,
|
||||
FST_BL_BLACKOUT = 2,
|
||||
FST_BL_GEOM = 3,
|
||||
FST_BL_HIER = 4,
|
||||
FST_BL_VCDATA_DYN_ALIAS = 5,
|
||||
FST_BL_HIER_LZ4 = 6,
|
||||
FST_BL_HIER_LZ4DUO = 7,
|
||||
FST_BL_VCDATA_DYN_ALIAS2 = 8,
|
||||
|
||||
FST_BL_ZWRAPPER = 254, /* indicates that whole trace is gz wrapped */
|
||||
FST_BL_SKIP = 255 /* used while block is being written */
|
||||
};
|
||||
|
||||
enum fstScopeType {
|
||||
FST_ST_MIN = 0,
|
||||
|
||||
FST_ST_VCD_MODULE = 0,
|
||||
FST_ST_VCD_TASK = 1,
|
||||
FST_ST_VCD_FUNCTION = 2,
|
||||
FST_ST_VCD_BEGIN = 3,
|
||||
FST_ST_VCD_FORK = 4,
|
||||
FST_ST_VCD_GENERATE = 5,
|
||||
FST_ST_VCD_STRUCT = 6,
|
||||
FST_ST_VCD_UNION = 7,
|
||||
FST_ST_VCD_CLASS = 8,
|
||||
FST_ST_VCD_INTERFACE = 9,
|
||||
FST_ST_VCD_PACKAGE = 10,
|
||||
FST_ST_VCD_PROGRAM = 11,
|
||||
|
||||
FST_ST_VHDL_ARCHITECTURE = 12,
|
||||
FST_ST_VHDL_PROCEDURE = 13,
|
||||
FST_ST_VHDL_FUNCTION = 14,
|
||||
FST_ST_VHDL_RECORD = 15,
|
||||
FST_ST_VHDL_PROCESS = 16,
|
||||
FST_ST_VHDL_BLOCK = 17,
|
||||
FST_ST_VHDL_FOR_GENERATE = 18,
|
||||
FST_ST_VHDL_IF_GENERATE = 19,
|
||||
FST_ST_VHDL_GENERATE = 20,
|
||||
FST_ST_VHDL_PACKAGE = 21,
|
||||
|
||||
FST_ST_MAX = 21,
|
||||
|
||||
FST_ST_GEN_ATTRBEGIN = 252,
|
||||
FST_ST_GEN_ATTREND = 253,
|
||||
|
||||
FST_ST_VCD_SCOPE = 254,
|
||||
FST_ST_VCD_UPSCOPE = 255
|
||||
};
|
||||
|
||||
enum fstVarType {
|
||||
FST_VT_MIN = 0, /* start of vartypes */
|
||||
|
||||
FST_VT_VCD_EVENT = 0,
|
||||
FST_VT_VCD_INTEGER = 1,
|
||||
FST_VT_VCD_PARAMETER = 2,
|
||||
FST_VT_VCD_REAL = 3,
|
||||
FST_VT_VCD_REAL_PARAMETER = 4,
|
||||
FST_VT_VCD_REG = 5,
|
||||
FST_VT_VCD_SUPPLY0 = 6,
|
||||
FST_VT_VCD_SUPPLY1 = 7,
|
||||
FST_VT_VCD_TIME = 8,
|
||||
FST_VT_VCD_TRI = 9,
|
||||
FST_VT_VCD_TRIAND = 10,
|
||||
FST_VT_VCD_TRIOR = 11,
|
||||
FST_VT_VCD_TRIREG = 12,
|
||||
FST_VT_VCD_TRI0 = 13,
|
||||
FST_VT_VCD_TRI1 = 14,
|
||||
FST_VT_VCD_WAND = 15,
|
||||
FST_VT_VCD_WIRE = 16,
|
||||
FST_VT_VCD_WOR = 17,
|
||||
FST_VT_VCD_PORT = 18,
|
||||
FST_VT_VCD_SPARRAY = 19, /* used to define the rownum (index) port for a sparse array */
|
||||
FST_VT_VCD_REALTIME = 20,
|
||||
|
||||
FST_VT_GEN_STRING = 21, /* generic string type (max len is defined dynamically via fstWriterEmitVariableLengthValueChange) */
|
||||
|
||||
FST_VT_SV_BIT = 22,
|
||||
FST_VT_SV_LOGIC = 23,
|
||||
FST_VT_SV_INT = 24, /* declare as size = 32 */
|
||||
FST_VT_SV_SHORTINT = 25, /* declare as size = 16 */
|
||||
FST_VT_SV_LONGINT = 26, /* declare as size = 64 */
|
||||
FST_VT_SV_BYTE = 27, /* declare as size = 8 */
|
||||
FST_VT_SV_ENUM = 28, /* declare as appropriate type range */
|
||||
FST_VT_SV_SHORTREAL = 29, /* declare and emit same as FST_VT_VCD_REAL (needs to be emitted as double, not a float) */
|
||||
|
||||
FST_VT_MAX = 29 /* end of vartypes */
|
||||
};
|
||||
|
||||
enum fstVarDir {
|
||||
FST_VD_MIN = 0,
|
||||
|
||||
FST_VD_IMPLICIT = 0,
|
||||
FST_VD_INPUT = 1,
|
||||
FST_VD_OUTPUT = 2,
|
||||
FST_VD_INOUT = 3,
|
||||
FST_VD_BUFFER = 4,
|
||||
FST_VD_LINKAGE = 5,
|
||||
|
||||
FST_VD_MAX = 5
|
||||
};
|
||||
|
||||
enum fstHierType {
|
||||
FST_HT_MIN = 0,
|
||||
|
||||
FST_HT_SCOPE = 0,
|
||||
FST_HT_UPSCOPE = 1,
|
||||
FST_HT_VAR = 2,
|
||||
FST_HT_ATTRBEGIN = 3,
|
||||
FST_HT_ATTREND = 4,
|
||||
|
||||
/* FST_HT_TREEBEGIN and FST_HT_TREEEND are not yet used by FST but are currently used when fstHier bridges other formats */
|
||||
FST_HT_TREEBEGIN = 5,
|
||||
FST_HT_TREEEND = 6,
|
||||
|
||||
FST_HT_MAX = 6
|
||||
};
|
||||
|
||||
enum fstAttrType {
|
||||
FST_AT_MIN = 0,
|
||||
|
||||
FST_AT_MISC = 0, /* self-contained: does not need matching FST_HT_ATTREND */
|
||||
FST_AT_ARRAY = 1,
|
||||
FST_AT_ENUM = 2,
|
||||
FST_AT_PACK = 3,
|
||||
|
||||
FST_AT_MAX = 3
|
||||
};
|
||||
|
||||
enum fstMiscType {
|
||||
FST_MT_MIN = 0,
|
||||
|
||||
FST_MT_COMMENT = 0, /* use fstWriterSetComment() to emit */
|
||||
FST_MT_ENVVAR = 1, /* use fstWriterSetEnvVar() to emit */
|
||||
FST_MT_SUPVAR = 2, /* use fstWriterCreateVar2() to emit */
|
||||
FST_MT_PATHNAME = 3, /* reserved for fstWriterSetSourceStem() string -> number management */
|
||||
FST_MT_SOURCESTEM = 4, /* use fstWriterSetSourceStem() to emit */
|
||||
FST_MT_SOURCEISTEM = 5, /* use fstWriterSetSourceInstantiationStem() to emit */
|
||||
FST_MT_VALUELIST = 6, /* use fstWriterSetValueList() to emit, followed by fstWriterCreateVar*() */
|
||||
FST_MT_ENUMTABLE = 7, /* use fstWriterCreateEnumTable() and fstWriterEmitEnumTableRef() to emit */
|
||||
FST_MT_UNKNOWN = 8,
|
||||
|
||||
FST_MT_MAX = 8
|
||||
};
|
||||
|
||||
enum fstArrayType {
|
||||
FST_AR_MIN = 0,
|
||||
|
||||
FST_AR_NONE = 0,
|
||||
FST_AR_UNPACKED = 1,
|
||||
FST_AR_PACKED = 2,
|
||||
FST_AR_SPARSE = 3,
|
||||
|
||||
FST_AR_MAX = 3
|
||||
};
|
||||
|
||||
enum fstEnumValueType {
|
||||
FST_EV_SV_INTEGER = 0,
|
||||
FST_EV_SV_BIT = 1,
|
||||
FST_EV_SV_LOGIC = 2,
|
||||
FST_EV_SV_INT = 3,
|
||||
FST_EV_SV_SHORTINT = 4,
|
||||
FST_EV_SV_LONGINT = 5,
|
||||
FST_EV_SV_BYTE = 6,
|
||||
FST_EV_SV_UNSIGNED_INTEGER = 7,
|
||||
FST_EV_SV_UNSIGNED_BIT = 8,
|
||||
FST_EV_SV_UNSIGNED_LOGIC = 9,
|
||||
FST_EV_SV_UNSIGNED_INT = 10,
|
||||
FST_EV_SV_UNSIGNED_SHORTINT = 11,
|
||||
FST_EV_SV_UNSIGNED_LONGINT = 12,
|
||||
FST_EV_SV_UNSIGNED_BYTE = 13,
|
||||
|
||||
FST_EV_REG = 14,
|
||||
FST_EV_TIME = 15,
|
||||
|
||||
FST_EV_MAX = 15
|
||||
};
|
||||
|
||||
enum fstPackType {
|
||||
FST_PT_NONE = 0,
|
||||
FST_PT_UNPACKED = 1,
|
||||
FST_PT_PACKED = 2,
|
||||
FST_PT_TAGGED_PACKED = 3,
|
||||
|
||||
FST_PT_MAX = 3
|
||||
};
|
||||
|
||||
enum fstSupplementalVarType {
|
||||
FST_SVT_MIN = 0,
|
||||
|
||||
FST_SVT_NONE = 0,
|
||||
|
||||
FST_SVT_VHDL_SIGNAL = 1,
|
||||
FST_SVT_VHDL_VARIABLE = 2,
|
||||
FST_SVT_VHDL_CONSTANT = 3,
|
||||
FST_SVT_VHDL_FILE = 4,
|
||||
FST_SVT_VHDL_MEMORY = 5,
|
||||
|
||||
FST_SVT_MAX = 5
|
||||
};
|
||||
|
||||
enum fstSupplementalDataType {
|
||||
FST_SDT_MIN = 0,
|
||||
|
||||
FST_SDT_NONE = 0,
|
||||
|
||||
FST_SDT_VHDL_BOOLEAN = 1,
|
||||
FST_SDT_VHDL_BIT = 2,
|
||||
FST_SDT_VHDL_BIT_VECTOR = 3,
|
||||
FST_SDT_VHDL_STD_ULOGIC = 4,
|
||||
FST_SDT_VHDL_STD_ULOGIC_VECTOR = 5,
|
||||
FST_SDT_VHDL_STD_LOGIC = 6,
|
||||
FST_SDT_VHDL_STD_LOGIC_VECTOR = 7,
|
||||
FST_SDT_VHDL_UNSIGNED = 8,
|
||||
FST_SDT_VHDL_SIGNED = 9,
|
||||
FST_SDT_VHDL_INTEGER = 10,
|
||||
FST_SDT_VHDL_REAL = 11,
|
||||
FST_SDT_VHDL_NATURAL = 12,
|
||||
FST_SDT_VHDL_POSITIVE = 13,
|
||||
FST_SDT_VHDL_TIME = 14,
|
||||
FST_SDT_VHDL_CHARACTER = 15,
|
||||
FST_SDT_VHDL_STRING = 16,
|
||||
|
||||
FST_SDT_MAX = 16,
|
||||
|
||||
FST_SDT_SVT_SHIFT_COUNT = 10, /* FST_SVT_* is ORed in by fstWriterCreateVar2() to the left after shifting FST_SDT_SVT_SHIFT_COUNT */
|
||||
FST_SDT_ABS_MAX = ((1<<(FST_SDT_SVT_SHIFT_COUNT))-1)
|
||||
};
|
||||
|
||||
|
||||
struct fstHier
|
||||
{
|
||||
unsigned char htyp;
|
||||
|
||||
union {
|
||||
/* if htyp == FST_HT_SCOPE */
|
||||
struct fstHierScope {
|
||||
unsigned char typ; /* FST_ST_MIN ... FST_ST_MAX */
|
||||
const char *name;
|
||||
const char *component;
|
||||
uint32_t name_length; /* strlen(u.scope.name) */
|
||||
uint32_t component_length; /* strlen(u.scope.component) */
|
||||
} scope;
|
||||
|
||||
/* if htyp == FST_HT_VAR */
|
||||
struct fstHierVar {
|
||||
unsigned char typ; /* FST_VT_MIN ... FST_VT_MAX */
|
||||
unsigned char direction; /* FST_VD_MIN ... FST_VD_MAX */
|
||||
unsigned char svt_workspace; /* zeroed out by FST reader, for client code use */
|
||||
unsigned char sdt_workspace; /* zeroed out by FST reader, for client code use */
|
||||
unsigned int sxt_workspace; /* zeroed out by FST reader, for client code use */
|
||||
const char *name;
|
||||
uint32_t length;
|
||||
fstHandle handle;
|
||||
uint32_t name_length; /* strlen(u.var.name) */
|
||||
unsigned is_alias : 1;
|
||||
} var;
|
||||
|
||||
/* if htyp == FST_HT_ATTRBEGIN */
|
||||
struct fstHierAttr {
|
||||
unsigned char typ; /* FST_AT_MIN ... FST_AT_MAX */
|
||||
unsigned char subtype; /* from fstMiscType, fstArrayType, fstEnumValueType, fstPackType */
|
||||
const char *name;
|
||||
uint64_t arg; /* number of array elements, struct members, or some other payload (possibly ignored) */
|
||||
uint64_t arg_from_name; /* for when name is overloaded as a variable-length integer (FST_AT_MISC + FST_MT_SOURCESTEM) */
|
||||
uint32_t name_length; /* strlen(u.attr.name) */
|
||||
} attr;
|
||||
} u;
|
||||
};
|
||||
|
||||
|
||||
struct fstETab
|
||||
{
|
||||
char *name;
|
||||
uint32_t elem_count;
|
||||
char **literal_arr;
|
||||
char **val_arr;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* writer functions
|
||||
*/
|
||||
void fstWriterClose(void *ctx);
|
||||
void * fstWriterCreate(const char *nam, int use_compressed_hier);
|
||||
fstEnumHandle fstWriterCreateEnumTable(void *ctx, const char *name, uint32_t elem_count, unsigned int min_valbits, const char **literal_arr, const char **val_arr);
|
||||
/* used for Verilog/SV */
|
||||
fstHandle fstWriterCreateVar(void *ctx, enum fstVarType vt, enum fstVarDir vd,
|
||||
uint32_t len, const char *nam, fstHandle aliasHandle);
|
||||
/* future expansion for VHDL and other languages. The variable type, data type, etc map onto
|
||||
the current Verilog/SV one. The "type" string is optional for a more verbose or custom description */
|
||||
fstHandle fstWriterCreateVar2(void *ctx, enum fstVarType vt, enum fstVarDir vd,
|
||||
uint32_t len, const char *nam, fstHandle aliasHandle,
|
||||
const char *type, enum fstSupplementalVarType svt, enum fstSupplementalDataType sdt);
|
||||
void fstWriterEmitDumpActive(void *ctx, int enable);
|
||||
void fstWriterEmitEnumTableRef(void *ctx, fstEnumHandle handle);
|
||||
void fstWriterEmitValueChange(void *ctx, fstHandle handle, const void *val);
|
||||
void fstWriterEmitValueChange32(void *ctx, fstHandle handle,
|
||||
uint32_t bits, uint32_t val);
|
||||
void fstWriterEmitValueChange64(void *ctx, fstHandle handle,
|
||||
uint32_t bits, uint64_t val);
|
||||
void fstWriterEmitValueChangeVec32(void *ctx, fstHandle handle,
|
||||
uint32_t bits, const uint32_t *val);
|
||||
void fstWriterEmitValueChangeVec64(void *ctx, fstHandle handle,
|
||||
uint32_t bits, const uint64_t *val);
|
||||
void fstWriterEmitVariableLengthValueChange(void *ctx, fstHandle handle, const void *val, uint32_t len);
|
||||
void fstWriterEmitTimeChange(void *ctx, uint64_t tim);
|
||||
void fstWriterFlushContext(void *ctx);
|
||||
int fstWriterGetDumpSizeLimitReached(void *ctx);
|
||||
int fstWriterGetFseekFailed(void *ctx);
|
||||
void fstWriterSetAttrBegin(void *ctx, enum fstAttrType attrtype, int subtype,
|
||||
const char *attrname, uint64_t arg);
|
||||
void fstWriterSetAttrEnd(void *ctx);
|
||||
void fstWriterSetComment(void *ctx, const char *comm);
|
||||
void fstWriterSetDate(void *ctx, const char *dat);
|
||||
void fstWriterSetDumpSizeLimit(void *ctx, uint64_t numbytes);
|
||||
void fstWriterSetEnvVar(void *ctx, const char *envvar);
|
||||
void fstWriterSetFileType(void *ctx, enum fstFileType filetype);
|
||||
void fstWriterSetPackType(void *ctx, enum fstWriterPackType typ);
|
||||
void fstWriterSetParallelMode(void *ctx, int enable);
|
||||
void fstWriterSetRepackOnClose(void *ctx, int enable); /* type = 0 (none), 1 (libz) */
|
||||
void fstWriterSetScope(void *ctx, enum fstScopeType scopetype,
|
||||
const char *scopename, const char *scopecomp);
|
||||
void fstWriterSetSourceInstantiationStem(void *ctx, const char *path, unsigned int line, unsigned int use_realpath);
|
||||
void fstWriterSetSourceStem(void *ctx, const char *path, unsigned int line, unsigned int use_realpath);
|
||||
void fstWriterSetTimescale(void *ctx, int ts);
|
||||
void fstWriterSetTimescaleFromString(void *ctx, const char *s);
|
||||
void fstWriterSetTimezero(void *ctx, int64_t tim);
|
||||
void fstWriterSetUpscope(void *ctx);
|
||||
void fstWriterSetValueList(void *ctx, const char *vl);
|
||||
void fstWriterSetVersion(void *ctx, const char *vers);
|
||||
|
||||
|
||||
/*
|
||||
* reader functions
|
||||
*/
|
||||
void fstReaderClose(void *ctx);
|
||||
void fstReaderClrFacProcessMask(void *ctx, fstHandle facidx);
|
||||
void fstReaderClrFacProcessMaskAll(void *ctx);
|
||||
uint64_t fstReaderGetAliasCount(void *ctx);
|
||||
const char * fstReaderGetCurrentFlatScope(void *ctx);
|
||||
void * fstReaderGetCurrentScopeUserInfo(void *ctx);
|
||||
int fstReaderGetCurrentScopeLen(void *ctx);
|
||||
const char * fstReaderGetDateString(void *ctx);
|
||||
int fstReaderGetDoubleEndianMatchState(void *ctx);
|
||||
uint64_t fstReaderGetDumpActivityChangeTime(void *ctx, uint32_t idx);
|
||||
unsigned char fstReaderGetDumpActivityChangeValue(void *ctx, uint32_t idx);
|
||||
uint64_t fstReaderGetEndTime(void *ctx);
|
||||
int fstReaderGetFacProcessMask(void *ctx, fstHandle facidx);
|
||||
int fstReaderGetFileType(void *ctx);
|
||||
int fstReaderGetFseekFailed(void *ctx);
|
||||
fstHandle fstReaderGetMaxHandle(void *ctx);
|
||||
uint64_t fstReaderGetMemoryUsedByWriter(void *ctx);
|
||||
uint32_t fstReaderGetNumberDumpActivityChanges(void *ctx);
|
||||
uint64_t fstReaderGetScopeCount(void *ctx);
|
||||
uint64_t fstReaderGetStartTime(void *ctx);
|
||||
signed char fstReaderGetTimescale(void *ctx);
|
||||
int64_t fstReaderGetTimezero(void *ctx);
|
||||
uint64_t fstReaderGetValueChangeSectionCount(void *ctx);
|
||||
char * fstReaderGetValueFromHandleAtTime(void *ctx, uint64_t tim, fstHandle facidx, char *buf);
|
||||
uint64_t fstReaderGetVarCount(void *ctx);
|
||||
const char * fstReaderGetVersionString(void *ctx);
|
||||
struct fstHier *fstReaderIterateHier(void *ctx);
|
||||
int fstReaderIterateHierRewind(void *ctx);
|
||||
int fstReaderIterBlocks(void *ctx,
|
||||
void (*value_change_callback)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value),
|
||||
void *user_callback_data_pointer, FILE *vcdhandle);
|
||||
int fstReaderIterBlocks2(void *ctx,
|
||||
void (*value_change_callback)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value),
|
||||
void (*value_change_callback_varlen)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value, uint32_t len),
|
||||
void *user_callback_data_pointer, FILE *vcdhandle);
|
||||
void fstReaderIterBlocksSetNativeDoublesOnCallback(void *ctx, int enable);
|
||||
void * fstReaderOpen(const char *nam);
|
||||
void * fstReaderOpenForUtilitiesOnly(void);
|
||||
const char * fstReaderPopScope(void *ctx);
|
||||
int fstReaderProcessHier(void *ctx, FILE *vcdhandle);
|
||||
const char * fstReaderPushScope(void *ctx, const char *nam, void *user_info);
|
||||
void fstReaderResetScope(void *ctx);
|
||||
void fstReaderSetFacProcessMask(void *ctx, fstHandle facidx);
|
||||
void fstReaderSetFacProcessMaskAll(void *ctx);
|
||||
void fstReaderSetLimitTimeRange(void *ctx, uint64_t start_time, uint64_t end_time);
|
||||
void fstReaderSetUnlimitedTimeRange(void *ctx);
|
||||
void fstReaderSetVcdExtensions(void *ctx, int enable);
|
||||
|
||||
|
||||
/*
|
||||
* utility functions
|
||||
*/
|
||||
int fstUtilityBinToEscConvertedLen(const unsigned char *s, int len); /* used for mallocs for fstUtilityBinToEsc() */
|
||||
int fstUtilityBinToEsc(unsigned char *d, const unsigned char *s, int len);
|
||||
int fstUtilityEscToBin(unsigned char *d, unsigned char *s, int len);
|
||||
struct fstETab *fstUtilityExtractEnumTableFromString(const char *s);
|
||||
void fstUtilityFreeEnumTable(struct fstETab *etab); /* must use to free fstETab properly */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,362 @@
|
|||
/*
|
||||
LZ4 - Fast LZ compression algorithm
|
||||
Header File
|
||||
Copyright (C) 2011-2015, Yann Collet.
|
||||
|
||||
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
You can contact the author at :
|
||||
- LZ4 source repository : https://github.com/Cyan4973/lz4
|
||||
- LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* lz4.h provides block compression functions, and gives full buffer control to programmer.
|
||||
* If you need to generate inter-operable compressed data (respecting LZ4 frame specification),
|
||||
* and can let the library handle its own memory, please use lz4frame.h instead.
|
||||
*/
|
||||
|
||||
/**************************************
|
||||
* Version
|
||||
**************************************/
|
||||
#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
|
||||
#define LZ4_VERSION_MINOR 7 /* for new (non-breaking) interface capabilities */
|
||||
#define LZ4_VERSION_RELEASE 1 /* for tweaks, bug-fixes, or development */
|
||||
#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
|
||||
int LZ4_versionNumber (void);
|
||||
|
||||
/**************************************
|
||||
* Tuning parameter
|
||||
**************************************/
|
||||
/*
|
||||
* LZ4_MEMORY_USAGE :
|
||||
* Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.)
|
||||
* Increasing memory usage improves compression ratio
|
||||
* Reduced memory usage can improve speed, due to cache effect
|
||||
* Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache
|
||||
*/
|
||||
#define LZ4_MEMORY_USAGE 14
|
||||
|
||||
|
||||
/**************************************
|
||||
* Simple Functions
|
||||
**************************************/
|
||||
|
||||
int LZ4_compress_default(const char* source, char* dest, int sourceSize, int maxDestSize);
|
||||
int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize);
|
||||
|
||||
/*
|
||||
LZ4_compress_default() :
|
||||
Compresses 'sourceSize' bytes from buffer 'source'
|
||||
into already allocated 'dest' buffer of size 'maxDestSize'.
|
||||
Compression is guaranteed to succeed if 'maxDestSize' >= LZ4_compressBound(sourceSize).
|
||||
It also runs faster, so it's a recommended setting.
|
||||
If the function cannot compress 'source' into a more limited 'dest' budget,
|
||||
compression stops *immediately*, and the function result is zero.
|
||||
As a consequence, 'dest' content is not valid.
|
||||
This function never writes outside 'dest' buffer, nor read outside 'source' buffer.
|
||||
sourceSize : Max supported value is LZ4_MAX_INPUT_VALUE
|
||||
maxDestSize : full or partial size of buffer 'dest' (which must be already allocated)
|
||||
return : the number of bytes written into buffer 'dest' (necessarily <= maxOutputSize)
|
||||
or 0 if compression fails
|
||||
|
||||
LZ4_decompress_safe() :
|
||||
compressedSize : is the precise full size of the compressed block.
|
||||
maxDecompressedSize : is the size of destination buffer, which must be already allocated.
|
||||
return : the number of bytes decompressed into destination buffer (necessarily <= maxDecompressedSize)
|
||||
If destination buffer is not large enough, decoding will stop and output an error code (<0).
|
||||
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
||||
This function is protected against buffer overflow exploits, including malicious data packets.
|
||||
It never writes outside output buffer, nor reads outside input buffer.
|
||||
*/
|
||||
|
||||
|
||||
/**************************************
|
||||
* Advanced Functions
|
||||
**************************************/
|
||||
#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
|
||||
#define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
|
||||
|
||||
/*
|
||||
LZ4_compressBound() :
|
||||
Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible)
|
||||
This function is primarily useful for memory allocation purposes (destination buffer size).
|
||||
Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example).
|
||||
Note that LZ4_compress_default() compress faster when dest buffer size is >= LZ4_compressBound(srcSize)
|
||||
inputSize : max supported value is LZ4_MAX_INPUT_SIZE
|
||||
return : maximum output size in a "worst case" scenario
|
||||
or 0, if input size is too large ( > LZ4_MAX_INPUT_SIZE)
|
||||
*/
|
||||
int LZ4_compressBound(int inputSize);
|
||||
|
||||
/*
|
||||
LZ4_compress_fast() :
|
||||
Same as LZ4_compress_default(), but allows to select an "acceleration" factor.
|
||||
The larger the acceleration value, the faster the algorithm, but also the lesser the compression.
|
||||
It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed.
|
||||
An acceleration value of "1" is the same as regular LZ4_compress_default()
|
||||
Values <= 0 will be replaced by ACCELERATION_DEFAULT (see lz4.c), which is 1.
|
||||
*/
|
||||
int LZ4_compress_fast (const char* source, char* dest, int sourceSize, int maxDestSize, int acceleration);
|
||||
|
||||
|
||||
/*
|
||||
LZ4_compress_fast_extState() :
|
||||
Same compression function, just using an externally allocated memory space to store compression state.
|
||||
Use LZ4_sizeofState() to know how much memory must be allocated,
|
||||
and allocate it on 8-bytes boundaries (using malloc() typically).
|
||||
Then, provide it as 'void* state' to compression function.
|
||||
*/
|
||||
int LZ4_sizeofState(void);
|
||||
int LZ4_compress_fast_extState (void* state, const char* source, char* dest, int inputSize, int maxDestSize, int acceleration);
|
||||
|
||||
|
||||
/*
|
||||
LZ4_compress_destSize() :
|
||||
Reverse the logic, by compressing as much data as possible from 'source' buffer
|
||||
into already allocated buffer 'dest' of size 'targetDestSize'.
|
||||
This function either compresses the entire 'source' content into 'dest' if it's large enough,
|
||||
or fill 'dest' buffer completely with as much data as possible from 'source'.
|
||||
*sourceSizePtr : will be modified to indicate how many bytes where read from 'source' to fill 'dest'.
|
||||
New value is necessarily <= old value.
|
||||
return : Nb bytes written into 'dest' (necessarily <= targetDestSize)
|
||||
or 0 if compression fails
|
||||
*/
|
||||
int LZ4_compress_destSize (const char* source, char* dest, int* sourceSizePtr, int targetDestSize);
|
||||
|
||||
|
||||
/*
|
||||
LZ4_decompress_fast() :
|
||||
originalSize : is the original and therefore uncompressed size
|
||||
return : the number of bytes read from the source buffer (in other words, the compressed size)
|
||||
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
||||
Destination buffer must be already allocated. Its size must be a minimum of 'originalSize' bytes.
|
||||
note : This function fully respect memory boundaries for properly formed compressed data.
|
||||
It is a bit faster than LZ4_decompress_safe().
|
||||
However, it does not provide any protection against intentionally modified data stream (malicious input).
|
||||
Use this function in trusted environment only (data to decode comes from a trusted source).
|
||||
*/
|
||||
int LZ4_decompress_fast (const char* source, char* dest, int originalSize);
|
||||
|
||||
/*
|
||||
LZ4_decompress_safe_partial() :
|
||||
This function decompress a compressed block of size 'compressedSize' at position 'source'
|
||||
into destination buffer 'dest' of size 'maxDecompressedSize'.
|
||||
The function tries to stop decompressing operation as soon as 'targetOutputSize' has been reached,
|
||||
reducing decompression time.
|
||||
return : the number of bytes decoded in the destination buffer (necessarily <= maxDecompressedSize)
|
||||
Note : this number can be < 'targetOutputSize' should the compressed block to decode be smaller.
|
||||
Always control how many bytes were decoded.
|
||||
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
||||
This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets
|
||||
*/
|
||||
int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedSize, int targetOutputSize, int maxDecompressedSize);
|
||||
|
||||
|
||||
/***********************************************
|
||||
* Streaming Compression Functions
|
||||
***********************************************/
|
||||
#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4)
|
||||
#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(long long))
|
||||
/*
|
||||
* LZ4_stream_t
|
||||
* information structure to track an LZ4 stream.
|
||||
* important : init this structure content before first use !
|
||||
* note : only allocated directly the structure if you are statically linking LZ4
|
||||
* If you are using liblz4 as a DLL, please use below construction methods instead.
|
||||
*/
|
||||
typedef struct { long long table[LZ4_STREAMSIZE_U64]; } LZ4_stream_t;
|
||||
|
||||
/*
|
||||
* LZ4_resetStream
|
||||
* Use this function to init an allocated LZ4_stream_t structure
|
||||
*/
|
||||
void LZ4_resetStream (LZ4_stream_t* streamPtr);
|
||||
|
||||
/*
|
||||
* LZ4_createStream will allocate and initialize an LZ4_stream_t structure
|
||||
* LZ4_freeStream releases its memory.
|
||||
* In the context of a DLL (liblz4), please use these methods rather than the static struct.
|
||||
* They are more future proof, in case of a change of LZ4_stream_t size.
|
||||
*/
|
||||
LZ4_stream_t* LZ4_createStream(void);
|
||||
int LZ4_freeStream (LZ4_stream_t* streamPtr);
|
||||
|
||||
/*
|
||||
* LZ4_loadDict
|
||||
* Use this function to load a static dictionary into LZ4_stream.
|
||||
* Any previous data will be forgotten, only 'dictionary' will remain in memory.
|
||||
* Loading a size of 0 is allowed.
|
||||
* Return : dictionary size, in bytes (necessarily <= 64 KB)
|
||||
*/
|
||||
int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
|
||||
|
||||
/*
|
||||
* LZ4_compress_fast_continue
|
||||
* Compress buffer content 'src', using data from previously compressed blocks as dictionary to improve compression ratio.
|
||||
* Important : Previous data blocks are assumed to still be present and unmodified !
|
||||
* 'dst' buffer must be already allocated.
|
||||
* If maxDstSize >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster.
|
||||
* If not, and if compressed data cannot fit into 'dst' buffer size, compression stops, and function returns a zero.
|
||||
*/
|
||||
int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int maxDstSize, int acceleration);
|
||||
|
||||
/*
|
||||
* LZ4_saveDict
|
||||
* If previously compressed data block is not guaranteed to remain available at its memory location
|
||||
* save it into a safer place (char* safeBuffer)
|
||||
* Note : you don't need to call LZ4_loadDict() afterwards,
|
||||
* dictionary is immediately usable, you can therefore call LZ4_compress_fast_continue()
|
||||
* Return : saved dictionary size in bytes (necessarily <= dictSize), or 0 if error
|
||||
*/
|
||||
int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int dictSize);
|
||||
|
||||
|
||||
/************************************************
|
||||
* Streaming Decompression Functions
|
||||
************************************************/
|
||||
|
||||
#define LZ4_STREAMDECODESIZE_U64 4
|
||||
#define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
|
||||
typedef struct { unsigned long long table[LZ4_STREAMDECODESIZE_U64]; } LZ4_streamDecode_t;
|
||||
/*
|
||||
* LZ4_streamDecode_t
|
||||
* information structure to track an LZ4 stream.
|
||||
* init this structure content using LZ4_setStreamDecode or memset() before first use !
|
||||
*
|
||||
* In the context of a DLL (liblz4) please prefer usage of construction methods below.
|
||||
* They are more future proof, in case of a change of LZ4_streamDecode_t size in the future.
|
||||
* LZ4_createStreamDecode will allocate and initialize an LZ4_streamDecode_t structure
|
||||
* LZ4_freeStreamDecode releases its memory.
|
||||
*/
|
||||
LZ4_streamDecode_t* LZ4_createStreamDecode(void);
|
||||
int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream);
|
||||
|
||||
/*
|
||||
* LZ4_setStreamDecode
|
||||
* Use this function to instruct where to find the dictionary.
|
||||
* Setting a size of 0 is allowed (same effect as reset).
|
||||
* Return : 1 if OK, 0 if error
|
||||
*/
|
||||
int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
|
||||
|
||||
/*
|
||||
*_continue() :
|
||||
These decoding functions allow decompression of multiple blocks in "streaming" mode.
|
||||
Previously decoded blocks *must* remain available at the memory position where they were decoded (up to 64 KB)
|
||||
In the case of a ring buffers, decoding buffer must be either :
|
||||
- Exactly same size as encoding buffer, with same update rule (block boundaries at same positions)
|
||||
In which case, the decoding & encoding ring buffer can have any size, including very small ones ( < 64 KB).
|
||||
- Larger than encoding buffer, by a minimum of maxBlockSize more bytes.
|
||||
maxBlockSize is implementation dependent. It's the maximum size you intend to compress into a single block.
|
||||
In which case, encoding and decoding buffers do not need to be synchronized,
|
||||
and encoding ring buffer can have any size, including small ones ( < 64 KB).
|
||||
- _At least_ 64 KB + 8 bytes + maxBlockSize.
|
||||
In which case, encoding and decoding buffers do not need to be synchronized,
|
||||
and encoding ring buffer can have any size, including larger than decoding buffer.
|
||||
Whenever these conditions are not possible, save the last 64KB of decoded data into a safe buffer,
|
||||
and indicate where it is saved using LZ4_setStreamDecode()
|
||||
*/
|
||||
int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxDecompressedSize);
|
||||
int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize);
|
||||
|
||||
|
||||
/*
|
||||
Advanced decoding functions :
|
||||
*_usingDict() :
|
||||
These decoding functions work the same as
|
||||
a combination of LZ4_setStreamDecode() followed by LZ4_decompress_x_continue()
|
||||
They are stand-alone. They don't need nor update an LZ4_streamDecode_t structure.
|
||||
*/
|
||||
int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxDecompressedSize, const char* dictStart, int dictSize);
|
||||
int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize);
|
||||
|
||||
|
||||
|
||||
/**************************************
|
||||
* Obsolete Functions
|
||||
**************************************/
|
||||
/* Deprecate Warnings */
|
||||
/* Should these warnings messages be a problem,
|
||||
it is generally possible to disable them,
|
||||
with -Wno-deprecated-declarations for gcc
|
||||
or _CRT_SECURE_NO_WARNINGS in Visual for example.
|
||||
You can also define LZ4_DEPRECATE_WARNING_DEFBLOCK. */
|
||||
#ifndef LZ4_DEPRECATE_WARNING_DEFBLOCK
|
||||
# define LZ4_DEPRECATE_WARNING_DEFBLOCK
|
||||
# define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
||||
# if (LZ4_GCC_VERSION >= 405) || defined(__clang__)
|
||||
# define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
|
||||
# elif (LZ4_GCC_VERSION >= 301)
|
||||
# define LZ4_DEPRECATED(message) __attribute__((deprecated))
|
||||
# elif defined(_MSC_VER)
|
||||
# define LZ4_DEPRECATED(message) __declspec(deprecated(message))
|
||||
# else
|
||||
# pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler")
|
||||
# define LZ4_DEPRECATED(message)
|
||||
# endif
|
||||
#endif /* LZ4_DEPRECATE_WARNING_DEFBLOCK */
|
||||
|
||||
/* Obsolete compression functions */
|
||||
/* These functions are planned to start generate warnings by r131 approximately */
|
||||
int LZ4_compress (const char* source, char* dest, int sourceSize);
|
||||
int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize);
|
||||
int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize);
|
||||
int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize);
|
||||
int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
|
||||
/* Obsolete decompression functions */
|
||||
/* These function names are completely deprecated and must no longer be used.
|
||||
They are only provided here for compatibility with older programs.
|
||||
- LZ4_uncompress is the same as LZ4_decompress_fast
|
||||
- LZ4_uncompress_unknownOutputSize is the same as LZ4_decompress_safe
|
||||
These function prototypes are now disabled; uncomment them only if you really need them.
|
||||
It is highly recommended to stop using these prototypes and migrate to maintained ones */
|
||||
/* int LZ4_uncompress (const char* source, char* dest, int outputSize); */
|
||||
/* int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize); */
|
||||
|
||||
/* Obsolete streaming functions; use new streaming interface whenever possible */
|
||||
LZ4_DEPRECATED("use LZ4_createStream() instead") void* LZ4_create (char* inputBuffer);
|
||||
LZ4_DEPRECATED("use LZ4_createStream() instead") int LZ4_sizeofStreamState(void);
|
||||
LZ4_DEPRECATED("use LZ4_resetStream() instead") int LZ4_resetStreamState(void* state, char* inputBuffer);
|
||||
LZ4_DEPRECATED("use LZ4_saveDict() instead") char* LZ4_slideInputBuffer (void* state);
|
||||
|
||||
/* Obsolete streaming decoding functions */
|
||||
LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize);
|
||||
LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize);
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>com.minres.scviewer.database.fst</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.18.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,190 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.fst;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.io.File;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.minres.scviewer.database.BitVector;
|
||||
import com.minres.scviewer.database.DoubleVal;
|
||||
import com.minres.scviewer.database.EventList;
|
||||
import com.minres.scviewer.database.IEventList;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbLoader;
|
||||
import com.minres.scviewer.database.InputFormatException;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
|
||||
/**
|
||||
* The Class VCDDb.
|
||||
*/
|
||||
public class FstDbLoader implements IWaveformDbLoader, IFstDatabaseBuilder {
|
||||
|
||||
|
||||
/** The module stack. */
|
||||
private ArrayDeque<String> moduleStack;
|
||||
|
||||
/** The signals. */
|
||||
private List<IWaveform> signals;
|
||||
|
||||
FstFileParser parser;
|
||||
/** The max time. */
|
||||
private long maxTime;
|
||||
|
||||
private long timeScaleFactor;
|
||||
|
||||
/** The pcs. */
|
||||
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||
|
||||
static long calculateTimescaleMultipierPower(long time_scale){
|
||||
long answer = 1;
|
||||
if(time_scale<=0){
|
||||
return answer;
|
||||
} else{
|
||||
for(int i = 1; i<= time_scale; i++)
|
||||
answer *= 10;
|
||||
return answer;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.ITrDb#load(java.io.File)
|
||||
*/
|
||||
@Override
|
||||
public void load(File file) throws InputFormatException {
|
||||
dispose();
|
||||
this.maxTime=0;
|
||||
boolean res = false;
|
||||
signals = new Vector<>();
|
||||
moduleStack= new ArrayDeque<>();
|
||||
parser = new FstFileParser(file);
|
||||
res = parser.open(this);
|
||||
moduleStack=null;
|
||||
if(!res)
|
||||
throw new InputFormatException("Could not parse VCD file");
|
||||
// calculate max time of this database
|
||||
pcs.firePropertyChange(IWaveformDbLoader.LOADING_FINISHED, null, null);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if(parser!=null) {
|
||||
parser.close();
|
||||
parser=null;
|
||||
}
|
||||
moduleStack=null;
|
||||
signals=null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.ITrDb#getMaxTime()
|
||||
*/
|
||||
@Override
|
||||
public long getMaxTime() {
|
||||
return maxTime;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.ITrDb#getAllWaves()
|
||||
*/
|
||||
@Override
|
||||
public Collection<IWaveform> getAllWaves() {
|
||||
return signals;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.vcd.ITraceBuilder#enterModule(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void enterModule(String tokenString) {
|
||||
if(moduleStack.isEmpty()) {
|
||||
if("SystemC".compareTo(tokenString)!=0)
|
||||
moduleStack.push(tokenString);
|
||||
} else
|
||||
moduleStack.push(moduleStack.peek()+"."+tokenString);
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.vcd.ITraceBuilder#exitModule()
|
||||
*/
|
||||
@Override
|
||||
public void exitModule() {
|
||||
if(!moduleStack.isEmpty()) moduleStack.pop();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.vcd.ITraceBuilder#newNet(java.lang.String, int, int)
|
||||
*/
|
||||
@Override
|
||||
public void newNet(String name, int handle, int width, int direction, boolean alias) {
|
||||
String netName = moduleStack.isEmpty()? name: moduleStack.peek()+"."+name;
|
||||
IWaveform signal = width==0?
|
||||
new FstSignal<DoubleVal>(this, handle, netName, width, direction):
|
||||
new FstSignal<BitVector>(this, handle, netName, direction, width);
|
||||
signals.add(signal);
|
||||
pcs.firePropertyChange(IWaveformDbLoader.SIGNAL_ADDED, null, Iterables.getLast(signals));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.vcd.ITraceBuilder#getNetWidth(int)
|
||||
*/
|
||||
@Override
|
||||
public int getNetWidth(int intValue) {
|
||||
FstSignal<?> signal = (FstSignal<?>) signals.get(intValue);
|
||||
return signal.getRowCount();
|
||||
}
|
||||
|
||||
public void setMaxTime(long maxTime, int timeScale) {
|
||||
if(timeScale>0) timeScale=-timeScale;
|
||||
long eff_time_scale=timeScale-IWaveformDb.databaseTimeScale;
|
||||
this.timeScaleFactor = calculateTimescaleMultipierPower(eff_time_scale);
|
||||
this.maxTime = maxTime*timeScaleFactor;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.IWaveformDbLoader#getAllRelationTypes()
|
||||
*/
|
||||
@Override
|
||||
public Collection<RelationType> getAllRelationTypes(){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the property change listener.
|
||||
*
|
||||
* @param l the l
|
||||
*/
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
pcs.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the property change listener.
|
||||
*
|
||||
* @param l the l
|
||||
*/
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
pcs.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
public void getEvents(int id, int width, IEventList values) {
|
||||
if(values instanceof EventList)
|
||||
parser.getValueChanges(id, width, timeScaleFactor, (EventList) values);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.fst;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.minres.scviewer.database.IWaveformDbLoader;
|
||||
import com.minres.scviewer.database.IWaveformDbLoaderFactory;
|
||||
|
||||
/**
|
||||
* The Class VCDDb.
|
||||
*/
|
||||
public class FstDbLoaderFactory implements IWaveformDbLoaderFactory {
|
||||
/**
|
||||
* Can load.
|
||||
*
|
||||
* @param inputFile the input file
|
||||
* @return true, if successful
|
||||
*/
|
||||
@Override
|
||||
public boolean canLoad(File inputFile) {
|
||||
if(!inputFile.isDirectory() || inputFile.exists()) {
|
||||
String name = inputFile.getName();
|
||||
return name.endsWith(".fst");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IWaveformDbLoader getLoader() {
|
||||
return new FstDbLoader();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.fst;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.minres.scviewer.database.BitVector;
|
||||
import com.minres.scviewer.database.EventList;
|
||||
import com.minres.scviewer.database.fst.FstLibrary.HierAttr;
|
||||
import com.minres.scviewer.database.fst.FstLibrary.HierScope;
|
||||
import com.minres.scviewer.database.fst.FstLibrary.HierType;
|
||||
import com.minres.scviewer.database.fst.FstLibrary.HierVar;
|
||||
import com.minres.scviewer.database.fst.FstLibrary.ValueChangeCallback;
|
||||
import com.sun.jna.Pointer;
|
||||
|
||||
class FstFileParser {
|
||||
long currentTime;
|
||||
final File file;
|
||||
Pointer fst;
|
||||
|
||||
public FstFileParser(File file) {
|
||||
this.file=file;
|
||||
}
|
||||
|
||||
public boolean open(IFstDatabaseBuilder builder) {
|
||||
fst = FstLibrary.fstReaderOpen(file.getAbsolutePath());
|
||||
if(!fst.equals(Pointer.NULL)) {
|
||||
// String version = FstLibrary.fstReaderGetVersionString(fst);
|
||||
long endTime = FstLibrary.fstReaderGetEndTime(fst);
|
||||
byte timeScale = FstLibrary.fstReaderGetTimescale(fst);
|
||||
builder.setMaxTime(endTime, -timeScale);
|
||||
FstLibrary.fstReaderIterateHierRewind(fst);
|
||||
Pointer p = FstLibrary.fstReaderIterateHier(fst);
|
||||
while(p!=null && !p.equals(Pointer.NULL)) {
|
||||
int hierType = FstLibrary.getHierType(p);
|
||||
HierType type = HierType.values()[hierType];
|
||||
switch(type) {
|
||||
case HT_SCOPE:
|
||||
HierScope scope = new HierScope();
|
||||
FstLibrary.getHierScope(p, scope);
|
||||
builder.enterModule(scope.name);
|
||||
break;
|
||||
case HT_UPSCOPE:
|
||||
builder.exitModule();
|
||||
break;
|
||||
case HT_VAR:
|
||||
HierVar v = new HierVar();
|
||||
FstLibrary.getHierVar(p, v);
|
||||
builder.newNet(v.name, v.handle, v.length, v.direction, v.is_alias!=0);
|
||||
break;
|
||||
case HT_ATTRBEGIN:
|
||||
HierAttr attr = new HierAttr();
|
||||
FstLibrary.getHierAttr(p, attr);
|
||||
break;
|
||||
case HT_ATTREND:
|
||||
break;
|
||||
case HT_TREEBEGIN:
|
||||
break;
|
||||
case HT_TREEEND:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
p = FstLibrary.fstReaderIterateHier(fst);
|
||||
}
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
public void getValueChanges(final int id, final int width, long timeScale, final EventList values) {
|
||||
FstLibrary.fstReaderClrFacProcessMaskAll(fst);
|
||||
FstLibrary.fstReaderSetFacProcessMask(fst, id);
|
||||
FstLibrary.iterateValueChanges(fst, new ValueChangeCallback() {
|
||||
@Override
|
||||
public void callback(long time, int facidx, String value) {
|
||||
values.put(time*timeScale, BitVector.fromString(width, value));
|
||||
}
|
||||
});
|
||||
}
|
||||
public void close() {
|
||||
FstLibrary.fstReaderClose(fst);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,224 @@
|
|||
package com.minres.scviewer.database.fst;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.Structure.FieldOrder;
|
||||
import com.sun.jna.Callback;
|
||||
|
||||
public class FstLibrary {
|
||||
public static enum ScopeType {
|
||||
MIN(0),
|
||||
VCD_MODULE(0),
|
||||
VCD_TASK(1),
|
||||
VCD_FUNCTION(2),
|
||||
VCD_BEGIN(3),
|
||||
VCD_FORK(4),
|
||||
VCD_GENERATE(5),
|
||||
VCD_STRUCT(6),
|
||||
VCD_UNION(7),
|
||||
VCD_CLASS(8),
|
||||
VCD_INTERFACE(9),
|
||||
VCD_PACKAGE(10),
|
||||
VCD_PROGRAM(11),
|
||||
|
||||
VHDL_ARCHITECTURE(12),
|
||||
VHDL_PROCEDURE(13),
|
||||
VHDL_FUNCTION(14),
|
||||
VHDL_RECORD(15),
|
||||
VHDL_PROCESS(16),
|
||||
VHDL_BLOCK(17),
|
||||
VHDL_FOR_GENERATE(18),
|
||||
VHDL_IF_GENERATE(19),
|
||||
VHDL_GENERATE(20),
|
||||
VHDL_PACKAGE(21),
|
||||
MAX(21),
|
||||
ST_GEN_ATTRBEGIN(252),
|
||||
ST_GEN_ATTREND(253),
|
||||
|
||||
ST_VCD_SCOPE(254),
|
||||
ST_VCD_UPSCOPE(255);
|
||||
|
||||
public final int label;
|
||||
private ScopeType(int label) {
|
||||
this.label = label;
|
||||
}
|
||||
};
|
||||
public static enum HierType {
|
||||
HT_SCOPE(0),
|
||||
HT_UPSCOPE(1),
|
||||
HT_VAR(2),
|
||||
HT_ATTRBEGIN(3),
|
||||
HT_ATTREND(4),
|
||||
HT_TREEBEGIN(5),
|
||||
HT_TREEEND(6);
|
||||
public final int type;
|
||||
private HierType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
};
|
||||
public static enum VarType {
|
||||
FST_VT_VCD_EVENT (0),
|
||||
FST_VT_VCD_INTEGER (1),
|
||||
FST_VT_VCD_PARAMETER (2),
|
||||
FST_VT_VCD_REAL (3),
|
||||
FST_VT_VCD_REAL_PARAMETER (4),
|
||||
FST_VT_VCD_REG (5),
|
||||
FST_VT_VCD_SUPPLY0 (6),
|
||||
FST_VT_VCD_SUPPLY1 (7),
|
||||
FST_VT_VCD_TIME (8),
|
||||
FST_VT_VCD_TRI (9),
|
||||
FST_VT_VCD_TRIAND (10),
|
||||
FST_VT_VCD_TRIOR (11),
|
||||
FST_VT_VCD_TRIREG (12),
|
||||
FST_VT_VCD_TRI0 (13),
|
||||
FST_VT_VCD_TRI1 (14),
|
||||
FST_VT_VCD_WAND (15),
|
||||
FST_VT_VCD_WIRE (16),
|
||||
FST_VT_VCD_WOR (17),
|
||||
FST_VT_VCD_PORT (18),
|
||||
FST_VT_VCD_SPARRAY (19), /* used to define the rownum (index) port for a sparse array */
|
||||
FST_VT_VCD_REALTIME (20),
|
||||
|
||||
FST_VT_GEN_STRING (21), /* generic string type (max len is defined dynamically via fstWriterEmitVariableLengthValueChange) */
|
||||
|
||||
FST_VT_SV_BIT (22),
|
||||
FST_VT_SV_LOGIC (23),
|
||||
FST_VT_SV_INT (24), /* declare as size = 32 */
|
||||
FST_VT_SV_SHORTINT (25), /* declare as size = 16 */
|
||||
FST_VT_SV_LONGINT (26), /* declare as size = 64 */
|
||||
FST_VT_SV_BYTE (27), /* declare as size = 8 */
|
||||
FST_VT_SV_ENUM (28), /* declare as appropriate type range */
|
||||
FST_VT_SV_SHORTREAL (29); /* declare and emit same as FST_VT_VCD_REAL (needs to be emitted as double, not a float) */
|
||||
public final int varType;
|
||||
private VarType(int varType) {
|
||||
this.varType = varType;
|
||||
}
|
||||
};
|
||||
|
||||
public static enum VarDir {
|
||||
FST_VD_IMPLICIT (0),
|
||||
FST_VD_INPUT (1),
|
||||
FST_VD_OUTPUT (2),
|
||||
FST_VD_INOUT (3),
|
||||
FST_VD_BUFFER (4),
|
||||
FST_VD_LINKAGE (5);
|
||||
public final int varDir;
|
||||
private VarDir(int varDir) {
|
||||
this.varDir = varDir;
|
||||
}
|
||||
};
|
||||
|
||||
public static enum AttrType {
|
||||
FST_AT_MISC ( 0), /* self-contained: does not need matching FST_HT_ATTREND */
|
||||
FST_AT_ARRAY ( 1),
|
||||
FST_AT_ENUM ( 2),
|
||||
FST_AT_PACK ( 3);
|
||||
public final int attrType;
|
||||
private AttrType(int attrType) {
|
||||
this.attrType = attrType;
|
||||
}
|
||||
};
|
||||
|
||||
@FieldOrder({"type","name","component", "name_length", "component_length"})
|
||||
public static class HierScope extends Structure {
|
||||
public byte type; /* FST_ST_MIN ... FST_ST_MAX */
|
||||
public String name;
|
||||
public String component;
|
||||
public int name_length; /* strlen(u.scope.name) */
|
||||
public int component_length; /* strlen(u.scope.component) */
|
||||
};
|
||||
|
||||
@FieldOrder({"type","direction","svt_workspace", "sdt_workspace", "sxt_workspace", "name","length","handle","name_length", "is_alias"})
|
||||
public static class HierVar extends Structure {
|
||||
public byte type; /* FST_VT_MIN ... FST_VT_MAX */
|
||||
public byte direction; /* FST_VD_MIN ... FST_VD_MAX */
|
||||
public byte svt_workspace; /* zeroed out by FST reader, for client code use */
|
||||
public byte sdt_workspace; /* zeroed out by FST reader, for client code use */
|
||||
public int sxt_workspace; /* zeroed out by FST reader, for client code use */
|
||||
public String name;
|
||||
public int length;
|
||||
public int handle; /*fstHandle*/
|
||||
public int name_length; /* strlen(u.var.name) */
|
||||
public int is_alias;
|
||||
};
|
||||
|
||||
@FieldOrder({"type","subtype","name", "arg", "arg_from_name", "name_length"})
|
||||
public static class HierAttr extends Structure {
|
||||
public byte type; /* FST_AT_MIN ... FST_AT_MAX */
|
||||
public byte subtype; /* from fstMiscType, fstArrayType, fstEnumValueType, fstPackType */
|
||||
public String name;
|
||||
public long arg; /* number of array elements, struct members, or some other payload (possibly ignored) */
|
||||
public long arg_from_name; /* for when name is overloaded as a variable-length integer (FST_AT_MISC + FST_MT_SOURCESTEM) */
|
||||
public long name_length; /* strlen(u.attr.name) */
|
||||
};
|
||||
|
||||
|
||||
public static native Pointer fstReaderOpen(String name);
|
||||
public static native Pointer fstReaderOpenForUtilitiesOnly();
|
||||
public static native void fstReaderClose(Pointer ctx);
|
||||
public static native String fstReaderGetVersionString(Pointer ctx);
|
||||
public static native String fstReaderGetDateString(Pointer ctx);
|
||||
public static native int fstReaderGetFileType(Pointer ctx);
|
||||
public static native long fstReaderGetVarCount(Pointer ctx);
|
||||
public static native long fstReaderGetScopeCount(Pointer ctx);
|
||||
public static native long fstReaderGetAliasCount(Pointer ctx);
|
||||
public static native long fstReaderGetValueChangeSectionCount(Pointer ctx);
|
||||
public static native long fstReaderGetStartTime(Pointer ctx);
|
||||
public static native long fstReaderGetEndTime(Pointer ctx);
|
||||
public static native byte fstReaderGetTimescale(Pointer ctx);
|
||||
public static native long fstReaderGetTimezero(Pointer ctx);
|
||||
public static native int fstReaderGetMaxHandle(Pointer ctx);
|
||||
|
||||
public static native void fstReaderResetScope(Pointer ctx);
|
||||
public static native String fstReaderPushScope(Pointer ctx, String nam, Pointer user_info);
|
||||
public static native String fstReaderPopScope(Pointer ctx);
|
||||
public static native int fstReaderGetCurrentScopeLen(Pointer ctx);
|
||||
public static native String fstReaderGetCurrentFlatScope(Pointer ctx);
|
||||
|
||||
public static native int fstReaderGetNumberDumpActivityChanges(Pointer ctx);
|
||||
public static native long fstReaderGetDumpActivityChangeTime(Pointer ctx, int idx);
|
||||
public static native byte fstReaderGetDumpActivityChangeValue(Pointer ctx, int idx);
|
||||
|
||||
public static native int fstReaderIterateHierRewind(Pointer ctx);
|
||||
public static native Pointer fstReaderIterateHier(Pointer ctx);
|
||||
public static native int getHierType(Pointer hier);
|
||||
public static native void getHierScope(Pointer hier, HierScope scope);
|
||||
public static native void getHierVar(Pointer hier, HierVar scope);
|
||||
public static native void getHierAttr(Pointer hier, HierAttr scope);
|
||||
public static native int fstReaderGetFacProcessMask(Pointer ctx, int facidx);
|
||||
public static native void fstReaderSetFacProcessMask(Pointer ctx, int facidx);
|
||||
public static native void fstReaderClrFacProcessMask(Pointer ctx, int facidx);
|
||||
public static native void fstReaderSetFacProcessMaskAll(Pointer ctx);
|
||||
public static native void fstReaderClrFacProcessMaskAll(Pointer ctx);
|
||||
|
||||
public interface ValueChangeCallback extends Callback {
|
||||
void callback(long time, int facidx, String value);
|
||||
}
|
||||
|
||||
public static native void iterateValueChanges(Pointer ctx, ValueChangeCallback vcc);
|
||||
|
||||
/* untranslated functions:
|
||||
int fstReaderIterBlocks(Pointer ctx, ValueChangeCallback vcc, Pointer user_callback_data_pointer, Pointer vcdhandle);
|
||||
Pointer fstReaderGetCurrentScopeUserInfo(Pointer ctx);
|
||||
int fstReaderGetDoubleEndianMatchState(Pointer ctx);
|
||||
int fstReaderGetFseekFailed(Pointer ctx);
|
||||
long fstReaderGetMemoryUsedByWriter(Pointer ctx);
|
||||
String fstReaderGetValueFromHandleAtTime(Pointer ctx, long tim, fstHandle facidx, Stringbuf);
|
||||
int fstReaderIterBlocks2(Pointer ctx,
|
||||
void (*value_change_callback)(Pointer user_callback_data_pointer, long time, fstHandle facidx, const unsigned Stringvalue),
|
||||
void (*value_change_callback_varlen)(Pointer user_callback_data_pointer, long time, fstHandle facidx, const unsigned Stringvalue, int len),
|
||||
Pointer user_callback_data_pointer, FILE *vcdhandle);
|
||||
void fstReaderIterBlocksSetNativeDoublesOnCallback(Pointer ctx, int enable);
|
||||
int fstReaderProcessHier(Pointer ctx, FILE *vcdhandle);
|
||||
void fstReaderSetLimitTimeRange(Pointer ctx, long start_time, long end_time);
|
||||
void fstReaderSetUnlimitedTimeRange(Pointer ctx);
|
||||
void fstReaderSetVcdExtensions(Pointer ctx, int enable);
|
||||
*/
|
||||
|
||||
static {
|
||||
// System.setProperty("jna.debug_load", "true");
|
||||
Native.register("fstapi");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.fst;
|
||||
|
||||
import com.minres.scviewer.database.DirectionType;
|
||||
import com.minres.scviewer.database.EventEntry;
|
||||
import com.minres.scviewer.database.EventList;
|
||||
import com.minres.scviewer.database.HierNode;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
import com.minres.scviewer.database.IEventList;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.WaveformType;
|
||||
|
||||
public class FstSignal<T extends IEvent> extends HierNode implements IWaveform {
|
||||
|
||||
private final FstDbLoader loader;
|
||||
|
||||
private final int direction;
|
||||
|
||||
private final int id;
|
||||
|
||||
private final String fullName;
|
||||
|
||||
private final int width;
|
||||
|
||||
private final IEventList values;
|
||||
|
||||
public FstSignal(FstDbLoader loader, String name) {
|
||||
this(loader, 0, name, 0, 1);
|
||||
}
|
||||
|
||||
public FstSignal(FstDbLoader loader, int id, String name) {
|
||||
this(loader, id,name, 0,1);
|
||||
}
|
||||
|
||||
public FstSignal(FstDbLoader loader, int id, String name, int direction, int width) {
|
||||
super(name);
|
||||
fullName=name;
|
||||
this.loader=loader;
|
||||
this.id=id;
|
||||
this.direction = direction;
|
||||
this.width=width;
|
||||
this.values=new EventList();
|
||||
}
|
||||
|
||||
public FstSignal(FstSignal<T> o, int id, String name) {
|
||||
super(name);
|
||||
fullName=name;
|
||||
this.loader=o.loader;
|
||||
this.id=id;
|
||||
this.direction = 0;
|
||||
this.width=o.width;
|
||||
this.values=o.values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEventList getEvents() {
|
||||
if(values.size()==0)
|
||||
loader.getEvents(id, width, values);
|
||||
return values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent[] getEventsAtTime(long time) {
|
||||
return getEvents().get(time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent[] getEventsBeforeTime(long time) {
|
||||
EventEntry e = getEvents().floorEntry(time);
|
||||
if(e==null)
|
||||
return new IEvent[] {};
|
||||
else
|
||||
return getEvents().floorEntry(time).events;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSame(IWaveform other) {
|
||||
return( other instanceof FstSignal<?> && this.getId() == other.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public WaveformType getType() {
|
||||
return WaveformType.SIGNAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKind() {
|
||||
return "signal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionType getDirection() {
|
||||
switch(direction) {
|
||||
case 1: return DirectionType.INPUT;
|
||||
case 2: return DirectionType.OUTPUT;
|
||||
case 3: return DirectionType.INOUT;
|
||||
case 4: return DirectionType.BUFFER;
|
||||
case 5: return DirectionType.LINKAGE;
|
||||
}
|
||||
return DirectionType.IMPLICIT;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.fst;
|
||||
|
||||
/**
|
||||
* The Interface IVCDDatabaseBuilder. It allows to add VCD events into the database
|
||||
*/
|
||||
public interface IFstDatabaseBuilder {
|
||||
|
||||
/**
|
||||
* Enter module.
|
||||
*
|
||||
* @param tokenString the token string
|
||||
*/
|
||||
public void enterModule(String tokenString);
|
||||
|
||||
/**
|
||||
* Exit module.
|
||||
*/
|
||||
public void exitModule();
|
||||
|
||||
/**
|
||||
* New net.
|
||||
*
|
||||
* @param netName the net name
|
||||
* @param i the index of the net, -1 if a new one, otherwise the id if the referenced
|
||||
* @param width the width, -1 equals real, 0... is a bit vector
|
||||
* @return the net id
|
||||
*/
|
||||
public void newNet(String netName, int handle, int width, int direction, boolean alias) ;
|
||||
|
||||
/**
|
||||
* Gets the net width.
|
||||
*
|
||||
* @param intValue the net id
|
||||
* @return the net width, -1 means a real-valued net
|
||||
*/
|
||||
public int getNetWidth(int netId);
|
||||
|
||||
public void setMaxTime(long time, int timeScale);
|
||||
}
|
Binary file not shown.
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.17.3</version>
|
||||
<version>2.18.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
|
|
@ -37,7 +37,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
|||
protected FtrDbLoader loader;
|
||||
|
||||
/** The events. */
|
||||
IEventList events = new EventList();
|
||||
protected IEventList events = new EventList();
|
||||
|
||||
/** The max concurrency. */
|
||||
private int rowCount = -1;
|
||||
|
@ -74,16 +74,6 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
|||
events.put(evt.getTime(), evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the events.
|
||||
*
|
||||
* @return the events
|
||||
*/
|
||||
@Override
|
||||
public IEventList getEvents() {
|
||||
return events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the events at time.
|
||||
*
|
||||
|
@ -142,6 +132,11 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
|||
return rowCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate concurrency.
|
||||
*/
|
||||
|
@ -150,7 +145,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
|||
return;
|
||||
ArrayList<Long> rowEndTime = new ArrayList<>();
|
||||
HashMap<Long, Integer> rowByTxId = new HashMap<>();
|
||||
for(EventEntry entry: events) {
|
||||
for(EventEntry entry: getEvents()) {
|
||||
for(IEvent evt:entry.events) {
|
||||
TxEvent txEvt = (TxEvent) evt;
|
||||
ITx tx = txEvt.getTransaction();
|
||||
|
@ -184,5 +179,4 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
|||
rowCount=rowEndTime.size()>0?rowEndTime.size():1;
|
||||
getChildNodes().parallelStream().forEach(c -> ((TxGenerator)c).calculateConcurrency());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.FileLock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
@ -48,13 +49,16 @@ import jacob.CborType;
|
|||
*/
|
||||
public class FtrDbLoader implements IWaveformDbLoader {
|
||||
|
||||
enum FileType { NONE, PLAIN, GZIP, LZ4};
|
||||
static final private CborType break_type = CborType.valueOf(0xff);
|
||||
|
||||
/** The max time. */
|
||||
private Long maxTime = 0L;
|
||||
private long maxTime = 0L;
|
||||
|
||||
ArrayList<String> strDict = new ArrayList<>();
|
||||
|
||||
FileInputStream fis = null;
|
||||
|
||||
FileLock lock = null;
|
||||
|
||||
/** The attr values. */
|
||||
final List<String> attrValues = new ArrayList<>();
|
||||
|
@ -94,7 +98,6 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||
|
||||
long time_scale_factor = 1000l;
|
||||
|
||||
/**
|
||||
* Adds the property change listener.
|
||||
*
|
||||
|
@ -104,7 +107,6 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
pcs.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the property change listener.
|
||||
*
|
||||
|
@ -114,7 +116,6 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
pcs.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the max time.
|
||||
*
|
||||
|
@ -124,12 +125,11 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
public long getMaxTime() {
|
||||
return maxTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the transaction.
|
||||
*
|
||||
* @param txId the tx id
|
||||
* @return the transaction
|
||||
* @return the transaction or null if the transaction is not available
|
||||
*/
|
||||
public synchronized ITx getTransaction(long txId) {
|
||||
if (txCache.containsKey(txId))
|
||||
|
@ -139,7 +139,7 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
txCache.put(txId, tx);
|
||||
return tx;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,6 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
else
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the all waves.
|
||||
*
|
||||
|
@ -161,7 +160,6 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
ret.addAll(txGenerators.values());
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the all relation types.
|
||||
*
|
||||
|
@ -170,7 +168,6 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
public Collection<RelationType> getAllRelationTypes() {
|
||||
return relationTypes.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load.
|
||||
*
|
||||
|
@ -180,11 +177,14 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
* @throws InputFormatException the input format exception
|
||||
*/
|
||||
@Override
|
||||
public void load(IWaveformDb db, File file) throws InputFormatException {
|
||||
public void load(File file) throws InputFormatException {
|
||||
dispose();
|
||||
this.file=file;
|
||||
try(FileInputStream fis = new FileInputStream(file)) {
|
||||
new CborDbParser(this, fis);
|
||||
try {
|
||||
fis = new FileInputStream(file);
|
||||
FileChannel channel = fis.getChannel();
|
||||
lock=channel.lock(0, Long.MAX_VALUE, true);
|
||||
parseInput(new CborDecoder(fis), channel);
|
||||
} catch (IOException e) {
|
||||
LOG.warn("Problem parsing file "+file.getName()+": " , e);
|
||||
} catch (Exception e) {
|
||||
|
@ -192,12 +192,11 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
transactions.clear();
|
||||
throw new InputFormatException(e.toString());
|
||||
}
|
||||
txStreams.values().parallelStream().forEach(TxStream::calculateConcurrency);
|
||||
}
|
||||
|
||||
public List<? extends byte[]> getChunksAtOffsets(ArrayList<Long> fileOffsets) throws InputFormatException {
|
||||
public synchronized List<? extends byte[]> getChunksAtOffsets(ArrayList<Long> fileOffsets) throws InputFormatException {
|
||||
List<byte[]> ret = new ArrayList<>();
|
||||
try(FileInputStream fis = new FileInputStream(file)) {
|
||||
try {
|
||||
FileChannel fc = fis.getChannel();
|
||||
for (Long offset : fileOffsets) {
|
||||
if(offset>=0) {
|
||||
|
@ -220,6 +219,72 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
return ret;
|
||||
}
|
||||
|
||||
void parseTx(TxStream txStream, long blockId, byte[] chunk) throws IOException {
|
||||
CborDecoder cborDecoder = new CborDecoder(new ByteArrayInputStream(chunk));
|
||||
long size = cborDecoder.readArrayLength();
|
||||
assert(size==-1);
|
||||
CborType next = cborDecoder.peekType();
|
||||
while(next != null && !break_type.isEqualType(next)) {
|
||||
long blockOffset = cborDecoder.getPos();
|
||||
long tx_size = cborDecoder.readArrayLength();
|
||||
long txId = 0;
|
||||
long genId = 0;
|
||||
for(long i = 0; i<tx_size; ++i) {
|
||||
long tag = cborDecoder.readTag();
|
||||
switch((int)tag) {
|
||||
case 6: // id/generator/start/end
|
||||
long len = cborDecoder.readArrayLength();
|
||||
assert(len==4);
|
||||
txId = cborDecoder.readInt();
|
||||
genId = cborDecoder.readInt();
|
||||
long startTime = cborDecoder.readInt()*time_scale_factor;
|
||||
long endTime = cborDecoder.readInt()*time_scale_factor;
|
||||
TxGenerator gen = txGenerators.get(genId);
|
||||
FtrTx scvTx = new FtrTx(txId, gen.stream.getId(), genId, startTime, endTime, blockId, blockOffset);
|
||||
updateTransactions(txId, scvTx);
|
||||
TxStream stream = txStreams.get(gen.stream.getId());
|
||||
if (scvTx.beginTime == scvTx.endTime) {
|
||||
stream.addEvent(new TxEvent(this, EventKind.SINGLE, txId, scvTx.beginTime));
|
||||
gen.addEvent(new TxEvent(this, EventKind.SINGLE, txId, scvTx.beginTime));
|
||||
} else {
|
||||
stream.addEvent(new TxEvent(this, EventKind.BEGIN, txId, scvTx.beginTime));
|
||||
gen.addEvent(new TxEvent(this, EventKind.BEGIN, txId, scvTx.beginTime));
|
||||
stream.addEvent(new TxEvent(this, EventKind.END, txId, scvTx.endTime));
|
||||
gen.addEvent(new TxEvent(this, EventKind.END, txId, scvTx.endTime));
|
||||
}
|
||||
break;
|
||||
default: { // skip over 7:begin attr, 8:record attr, 9:end attr
|
||||
long sz = cborDecoder.readArrayLength();
|
||||
assert(sz==3);
|
||||
cborDecoder.readInt();
|
||||
long type_id = cborDecoder.readInt();
|
||||
switch(DataType.values()[(int)type_id]) {
|
||||
case BOOLEAN:
|
||||
cborDecoder.readBoolean();
|
||||
break;
|
||||
case FLOATING_POINT_NUMBER: // FLOATING_POINT_NUMBER
|
||||
case FIXED_POINT_INTEGER: // FIXED_POINT_INTEGER
|
||||
case UNSIGNED_FIXED_POINT_INTEGER: // UNSIGNED_FIXED_POINT_INTEGER
|
||||
cborDecoder.readFloat();
|
||||
break;
|
||||
case NONE: // UNSIGNED_FIXED_POINT_INTEGER
|
||||
LOG.warn("Unsupported data type: "+type_id);
|
||||
break;
|
||||
default:
|
||||
cborDecoder.readInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
next = cborDecoder.peekType();
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void updateTransactions(long txId, FtrTx scvTx) {
|
||||
maxTime = maxTime > scvTx.endTime ? maxTime : scvTx.endTime;
|
||||
transactions.put(txId, scvTx);
|
||||
}
|
||||
|
||||
public List<? extends ITxAttribute> parseAtrributes(byte[] chunk, long blockOffset) {
|
||||
List<ITxAttribute> ret = new ArrayList<>();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(chunk);
|
||||
|
@ -290,12 +355,17 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
TxAttributeType attrType = attributeTypes.get(attrName);
|
||||
return attrType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose.
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
try {
|
||||
if(lock!=null) lock.close();
|
||||
lock=null;
|
||||
if(fis!=null) fis.close();
|
||||
fis=null;
|
||||
} catch (IOException e) { }
|
||||
attrValues.clear();
|
||||
relationTypes.clear();
|
||||
txStreams.clear();
|
||||
|
@ -306,252 +376,179 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
relationsOut.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class TextDbParser.
|
||||
*/
|
||||
static class CborDbParser extends CborDecoder {
|
||||
|
||||
static final private CborType break_type = CborType.valueOf(0xff);
|
||||
|
||||
/** The loader. */
|
||||
final FtrDbLoader loader;
|
||||
|
||||
/**
|
||||
* Instantiates a new text db parser.
|
||||
*
|
||||
* @param loader the loader
|
||||
*/
|
||||
public CborDbParser(FtrDbLoader loader, FileInputStream inputStream) {
|
||||
super(inputStream);
|
||||
this.loader = loader;
|
||||
try {
|
||||
long cbor_tag = readTag();
|
||||
assert(cbor_tag == 55799);
|
||||
long array_len = readArrayLength();
|
||||
assert(array_len==-1);
|
||||
CborType next = peekType();
|
||||
while(next != null && !break_type.isEqualType(next)) {
|
||||
long tag = readTag();
|
||||
switch((int)tag) {
|
||||
<<<<<<< HEAD
|
||||
case 6: // info
|
||||
=======
|
||||
case 6: { // info
|
||||
>>>>>>> refs/heads/release/2.17.1
|
||||
CborDecoder cbd = new CborDecoder(new ByteArrayInputStream(readByteString()));
|
||||
long sz = cbd.readArrayLength();
|
||||
assert(sz==3);
|
||||
long time_numerator=cbd.readInt();
|
||||
long time_denominator=cbd.readInt();
|
||||
loader.time_scale_factor = 1000000000000000l*time_numerator/time_denominator;
|
||||
long epoch_tag = cbd.readTag();
|
||||
assert(epoch_tag==1);
|
||||
cbd.readInt(); // epoch
|
||||
break;
|
||||
}
|
||||
case 8: { // dictionary uncompressed
|
||||
parseDict(new CborDecoder(new ByteArrayInputStream(readByteString())));
|
||||
break;
|
||||
}
|
||||
case 9: { // dictionary compressed
|
||||
long sz = readArrayLength();
|
||||
assert(sz==2);
|
||||
readInt(); // uncompressed size
|
||||
parseDict(new CborDecoder(new BlockLZ4CompressorInputStream(new ByteArrayInputStream(readByteString()))));
|
||||
break;
|
||||
}
|
||||
case 10: { // directory uncompressed
|
||||
parseDir(new CborDecoder(new ByteArrayInputStream(readByteString())));
|
||||
break;
|
||||
}
|
||||
case 11: { // directory compressed
|
||||
long sz = readArrayLength();
|
||||
assert(sz==2);
|
||||
readInt(); // uncompressed size
|
||||
parseDir(new CborDecoder(new BlockLZ4CompressorInputStream(new ByteArrayInputStream(readByteString()))));
|
||||
break;
|
||||
}
|
||||
case 12: { //tx chunk uncompressed
|
||||
long len = readArrayLength();
|
||||
assert(len==2);
|
||||
long stream_id = readInt();
|
||||
TxStream txStream = loader.txStreams.get(stream_id);
|
||||
txStream.fileOffsets.add(inputStream.getChannel().position());
|
||||
parseTx(txStream, txStream.fileOffsets.size()-1, readByteString());
|
||||
break;
|
||||
}
|
||||
case 13: { //tx chunk compressed
|
||||
long len = readArrayLength();
|
||||
assert(len==3);
|
||||
long stream_id = readInt();
|
||||
readInt(); // uncompressed size
|
||||
TxStream txStream = loader.txStreams.get(stream_id);
|
||||
txStream.fileOffsets.add(0-inputStream.getChannel().position());
|
||||
BlockLZ4CompressorInputStream decomp = new BlockLZ4CompressorInputStream(new ByteArrayInputStream(readByteString()));
|
||||
parseTx(txStream, txStream.fileOffsets.size()-1, decomp.readAllBytes());
|
||||
decomp.close();
|
||||
break;
|
||||
}
|
||||
case 14: { // relations uncompressed
|
||||
parseRel(new CborDecoder(new ByteArrayInputStream(readByteString())));
|
||||
break;
|
||||
}
|
||||
case 15: { // relations uncompressed
|
||||
long sz = readArrayLength();
|
||||
assert(sz==2);
|
||||
readInt(); // uncompressed size
|
||||
parseRel(new CborDecoder(new BlockLZ4CompressorInputStream(new ByteArrayInputStream(readByteString()))));
|
||||
break;
|
||||
}
|
||||
}
|
||||
next = peekType();
|
||||
}
|
||||
} catch(IOException e) {
|
||||
long pos = 0;
|
||||
try {pos=inputStream.getChannel().position(); } catch (Exception ee) {}
|
||||
LOG.error("Error parsing file input stream at position" + pos, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void parseDict(CborDecoder cborDecoder) throws IOException {
|
||||
long size = cborDecoder.readMapLength();
|
||||
ArrayList<String> lst = new ArrayList<>((int)size);
|
||||
for(long i = 0; i<size; ++i) {
|
||||
long idx = cborDecoder.readInt();
|
||||
assert(idx==loader.strDict.size()+1);
|
||||
lst.add(cborDecoder.readTextString());
|
||||
}
|
||||
loader.strDict.addAll(lst);
|
||||
}
|
||||
|
||||
private void parseDir(CborDecoder cborDecoder) throws IOException {
|
||||
long size = cborDecoder.readArrayLength();
|
||||
if(size<0) {
|
||||
CborType next = cborDecoder.peekType();
|
||||
while(next != null && !break_type.isEqualType(next)) {
|
||||
parseDictEntry(cborDecoder);
|
||||
next = cborDecoder.peekType();
|
||||
}
|
||||
} else
|
||||
for(long i = 0; i<size; ++i) {
|
||||
parseDictEntry(cborDecoder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void parseDictEntry(CborDecoder cborDecoder) throws IOException {
|
||||
long id = cborDecoder.readTag();
|
||||
if(id==16) { // a stream
|
||||
long len = cborDecoder.readArrayLength();
|
||||
assert(len==3);
|
||||
long stream_id = cborDecoder.readInt();
|
||||
long name_id = cborDecoder.readInt();
|
||||
long kind_id = cborDecoder.readInt();
|
||||
add(stream_id, new TxStream(loader, stream_id, loader.strDict.get((int)name_id), loader.strDict.get((int)kind_id)));
|
||||
} else if(id==17) { // a generator
|
||||
long len = cborDecoder.readArrayLength();
|
||||
assert(len==3);
|
||||
long gen_id = cborDecoder.readInt();
|
||||
long name_id = cborDecoder.readInt();
|
||||
long stream_id = cborDecoder.readInt();
|
||||
if(loader.txStreams.containsKey(stream_id))
|
||||
add(gen_id, new TxGenerator(loader, gen_id, loader.strDict.get((int)name_id), loader.txStreams.get(stream_id)));
|
||||
} else {
|
||||
throw new IOException("Illegal tage ncountered: "+id);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseTx(TxStream txStream, long blockId, byte[] chunk) throws IOException {
|
||||
CborDecoder cborDecoder = new CborDecoder(new ByteArrayInputStream(chunk));
|
||||
long size = cborDecoder.readArrayLength();
|
||||
assert(size==-1);
|
||||
CborType next = cborDecoder.peekType();
|
||||
while(next != null && !break_type.isEqualType(next)) {
|
||||
long blockOffset = cborDecoder.getPos();
|
||||
long tx_size = cborDecoder.readArrayLength();
|
||||
long txId = 0;
|
||||
long genId = 0;
|
||||
for(long i = 0; i<tx_size; ++i) {
|
||||
long tag = cborDecoder.readTag();
|
||||
switch((int)tag) {
|
||||
case 6: // id/generator/start/end
|
||||
long len = cborDecoder.readArrayLength();
|
||||
assert(len==4);
|
||||
txId = cborDecoder.readInt();
|
||||
genId = cborDecoder.readInt();
|
||||
long startTime = cborDecoder.readInt()*loader.time_scale_factor;
|
||||
long endTime = cborDecoder.readInt()*loader.time_scale_factor;
|
||||
TxGenerator gen = loader.txGenerators.get(genId);
|
||||
FtrTx scvTx = new FtrTx(txId, gen.stream.getId(), genId, startTime, endTime, blockId, blockOffset);
|
||||
loader.maxTime = loader.maxTime > scvTx.endTime ? loader.maxTime : scvTx.endTime;
|
||||
loader.transactions.put(txId, scvTx);
|
||||
TxStream stream = loader.txStreams.get(gen.stream.getId());
|
||||
if (scvTx.beginTime == scvTx.endTime) {
|
||||
stream.addEvent(new TxEvent(loader, EventKind.SINGLE, txId, scvTx.beginTime));
|
||||
gen.addEvent(new TxEvent(loader, EventKind.SINGLE, txId, scvTx.beginTime));
|
||||
} else {
|
||||
stream.addEvent(new TxEvent(loader, EventKind.BEGIN, txId, scvTx.beginTime));
|
||||
gen.addEvent(new TxEvent(loader, EventKind.BEGIN, txId, scvTx.beginTime));
|
||||
stream.addEvent(new TxEvent(loader, EventKind.END, txId, scvTx.endTime));
|
||||
gen.addEvent(new TxEvent(loader, EventKind.END, txId, scvTx.endTime));
|
||||
}
|
||||
break;
|
||||
default: { // skip over 7:begin attr, 8:record attr, 9:end attr
|
||||
long sz = cborDecoder.readArrayLength();
|
||||
assert(sz==3);
|
||||
cborDecoder.readInt();
|
||||
long type_id = cborDecoder.readInt();
|
||||
switch(DataType.values()[(int)type_id]) {
|
||||
case BOOLEAN:
|
||||
cborDecoder.readBoolean();
|
||||
break;
|
||||
case FLOATING_POINT_NUMBER: // FLOATING_POINT_NUMBER
|
||||
case FIXED_POINT_INTEGER: // FIXED_POINT_INTEGER
|
||||
case UNSIGNED_FIXED_POINT_INTEGER: // UNSIGNED_FIXED_POINT_INTEGER
|
||||
cborDecoder.readFloat();
|
||||
break;
|
||||
case NONE: // UNSIGNED_FIXED_POINT_INTEGER
|
||||
LOG.warn("Unsupported data type: "+type_id);
|
||||
break;
|
||||
default:
|
||||
cborDecoder.readInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
next = cborDecoder.peekType();
|
||||
}
|
||||
}
|
||||
|
||||
private void parseRel(CborDecoder cborDecoder) throws IOException {
|
||||
long size = cborDecoder.readArrayLength();
|
||||
assert(size==-1);
|
||||
CborType next = cborDecoder.peekType();
|
||||
while(next != null && !break_type.isEqualType(next)) {
|
||||
long sz = cborDecoder.readArrayLength();
|
||||
assert(sz==3);
|
||||
long type_id = cborDecoder.readInt();
|
||||
long from_id = cborDecoder.readInt();
|
||||
long to_id = cborDecoder.readInt();
|
||||
String rel_name = loader.strDict.get((int)type_id);
|
||||
FtrRelation ftrRel = new FtrRelation(loader.relationTypes.getOrDefault(rel_name, RelationTypeFactory.create(rel_name)), from_id, to_id);
|
||||
loader.relationsOut.put(from_id, ftrRel);
|
||||
loader.relationsIn.put(to_id, ftrRel);
|
||||
next = cborDecoder.peekType();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void add(Long id, TxStream stream) {
|
||||
loader.txStreams.put(id, stream);
|
||||
loader.pcs.firePropertyChange(IWaveformDbLoader.STREAM_ADDED, null, stream);
|
||||
}
|
||||
|
||||
private void add(Long id, TxGenerator generator) {
|
||||
loader.txGenerators.put(id, generator);
|
||||
loader.pcs.firePropertyChange(IWaveformDbLoader.GENERATOR_ADDED, null, generator);
|
||||
static long calculateTimescaleMultipierPower(long power){
|
||||
long answer = 1;
|
||||
if(power<=0){
|
||||
return answer;
|
||||
} else{
|
||||
for(int i = 1; i<= power; i++)
|
||||
answer *= 10;
|
||||
return answer;
|
||||
}
|
||||
}
|
||||
|
||||
public void parseInput(CborDecoder cborDecoder, FileChannel channel) {
|
||||
try {
|
||||
long cbor_tag = cborDecoder.readTag();
|
||||
assert(cbor_tag == 55799);
|
||||
long array_len = cborDecoder.readArrayLength();
|
||||
assert(array_len==-1);
|
||||
CborType next = cborDecoder.peekType();
|
||||
while(next != null && !break_type.isEqualType(next)) {
|
||||
long tag = cborDecoder.readTag();
|
||||
switch((int)tag) {
|
||||
case 6: { // info
|
||||
CborDecoder cbd = new CborDecoder(new ByteArrayInputStream(cborDecoder.readByteString()));
|
||||
long sz = cbd.readArrayLength();
|
||||
assert(sz==2);
|
||||
long time_scale=cbd.readInt();
|
||||
long eff_time_scale=time_scale-IWaveformDb.databaseTimeScale;
|
||||
time_scale_factor = calculateTimescaleMultipierPower(eff_time_scale);
|
||||
long epoch_tag = cbd.readTag();
|
||||
assert(epoch_tag==1);
|
||||
cbd.readInt(); // epoch
|
||||
break;
|
||||
}
|
||||
case 8: { // dictionary uncompressed
|
||||
parseDict(new CborDecoder(new ByteArrayInputStream(cborDecoder.readByteString())));
|
||||
break;
|
||||
}
|
||||
case 9: { // dictionary compressed
|
||||
long sz = cborDecoder.readArrayLength();
|
||||
assert(sz==2);
|
||||
cborDecoder.readInt(); // uncompressed size
|
||||
parseDict(new CborDecoder(new BlockLZ4CompressorInputStream(new ByteArrayInputStream(cborDecoder.readByteString()))));
|
||||
break;
|
||||
}
|
||||
case 10: { // directory uncompressed
|
||||
parseDir(new CborDecoder(new ByteArrayInputStream(cborDecoder.readByteString())));
|
||||
break;
|
||||
}
|
||||
case 11: { // directory compressed
|
||||
long sz = cborDecoder.readArrayLength();
|
||||
assert(sz==2);
|
||||
cborDecoder.readInt(); // uncompressed size
|
||||
parseDir(new CborDecoder(new BlockLZ4CompressorInputStream(new ByteArrayInputStream(cborDecoder.readByteString()))));
|
||||
break;
|
||||
}
|
||||
case 12: { //tx chunk uncompressed
|
||||
long len = cborDecoder.readArrayLength();
|
||||
assert(len==4);
|
||||
long stream_id = cborDecoder.readInt();
|
||||
cborDecoder.readInt(); // start time of block
|
||||
long end_time = cborDecoder.readInt()*time_scale_factor;
|
||||
maxTime = end_time>maxTime?end_time:maxTime;
|
||||
txStreams.get(stream_id).fileOffsets.add(channel.position());
|
||||
cborDecoder.readByteString();
|
||||
break;
|
||||
}
|
||||
case 13: { //tx chunk compressed
|
||||
long len = cborDecoder.readArrayLength();
|
||||
assert(len==5);
|
||||
long stream_id = cborDecoder.readInt();
|
||||
cborDecoder.readInt(); // start time of block
|
||||
long end_time = cborDecoder.readInt()*time_scale_factor;
|
||||
cborDecoder.readInt(); // uncompressed size
|
||||
maxTime = end_time>maxTime?end_time:maxTime;
|
||||
txStreams.get(stream_id).fileOffsets.add(0-channel.position());
|
||||
cborDecoder.readByteString();
|
||||
break;
|
||||
}
|
||||
case 14: { // relations uncompressed
|
||||
parseRel(new CborDecoder(new ByteArrayInputStream(cborDecoder.readByteString())));
|
||||
break;
|
||||
}
|
||||
case 15: { // relations uncompressed
|
||||
long sz = cborDecoder.readArrayLength();
|
||||
assert(sz==2);
|
||||
cborDecoder.readInt(); // uncompressed size
|
||||
parseRel(new CborDecoder(new BlockLZ4CompressorInputStream(new ByteArrayInputStream(cborDecoder.readByteString()))));
|
||||
break;
|
||||
}
|
||||
}
|
||||
next = cborDecoder.peekType();
|
||||
}
|
||||
} catch(IOException e) {
|
||||
long pos = 0;
|
||||
try {pos=channel.position(); } catch (Exception ee) {}
|
||||
LOG.error("Error parsing file input stream at position" + pos, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseDict(CborDecoder cborDecoder) throws IOException {
|
||||
long size = cborDecoder.readMapLength();
|
||||
ArrayList<String> lst = new ArrayList<>((int)size);
|
||||
for(long i = 0; i<size; ++i) {
|
||||
long idx = cborDecoder.readInt();
|
||||
assert(idx==strDict.size()+lst.size());
|
||||
lst.add(cborDecoder.readTextString());
|
||||
}
|
||||
strDict.addAll(lst);
|
||||
}
|
||||
|
||||
private void parseDir(CborDecoder cborDecoder) throws IOException {
|
||||
long size = cborDecoder.readArrayLength();
|
||||
if(size<0) {
|
||||
CborType next = cborDecoder.peekType();
|
||||
while(next != null && !break_type.isEqualType(next)) {
|
||||
parseDictEntry(cborDecoder);
|
||||
next = cborDecoder.peekType();
|
||||
}
|
||||
} else
|
||||
for(long i = 0; i<size; ++i) {
|
||||
parseDictEntry(cborDecoder);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseDictEntry(CborDecoder cborDecoder) throws IOException {
|
||||
long id = cborDecoder.readTag();
|
||||
if(id==16) { // a stream
|
||||
long len = cborDecoder.readArrayLength();
|
||||
assert(len==3);
|
||||
long stream_id = cborDecoder.readInt();
|
||||
long name_id = cborDecoder.readInt();
|
||||
long kind_id = cborDecoder.readInt();
|
||||
add(stream_id, new TxStream(this, stream_id, strDict.get((int)name_id), strDict.get((int)kind_id)));
|
||||
} else if(id==17) { // a generator
|
||||
long len = cborDecoder.readArrayLength();
|
||||
assert(len==3);
|
||||
long gen_id = cborDecoder.readInt();
|
||||
long name_id = cborDecoder.readInt();
|
||||
long stream_id = cborDecoder.readInt();
|
||||
if(txStreams.containsKey(stream_id))
|
||||
add(gen_id, new TxGenerator(this, gen_id, strDict.get((int)name_id), txStreams.get(stream_id)));
|
||||
} else {
|
||||
throw new IOException("Illegal tage ncountered: "+id);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseRel(CborDecoder cborDecoder) throws IOException {
|
||||
long size = cborDecoder.readArrayLength();
|
||||
assert(size==-1);
|
||||
CborType next = cborDecoder.peekType();
|
||||
while(next != null && !break_type.isEqualType(next)) {
|
||||
long sz = cborDecoder.readArrayLength();
|
||||
assert(sz==5 || sz==3);
|
||||
long type_id = cborDecoder.readInt();
|
||||
long from_id = cborDecoder.readInt();
|
||||
long to_id = cborDecoder.readInt();
|
||||
long from_fiber = sz>3?cborDecoder.readInt():-1;
|
||||
long to_fiber = sz>3?cborDecoder.readInt():-1;
|
||||
String rel_name = strDict.get((int)type_id);
|
||||
FtrRelation ftrRel = new FtrRelation(relationTypes.getOrDefault(rel_name, RelationTypeFactory.create(rel_name)), from_id, to_id, from_fiber, to_fiber);
|
||||
relationsOut.put(from_id, ftrRel);
|
||||
relationsIn.put(to_id, ftrRel);
|
||||
next = cborDecoder.peekType();
|
||||
}
|
||||
}
|
||||
|
||||
private void add(Long id, TxStream stream) {
|
||||
txStreams.put(id, stream);
|
||||
pcs.firePropertyChange(IWaveformDbLoader.STREAM_ADDED, null, stream);
|
||||
}
|
||||
|
||||
private void add(Long id, TxGenerator generator) {
|
||||
txGenerators.put(id, generator);
|
||||
pcs.firePropertyChange(IWaveformDbLoader.GENERATOR_ADDED, null, generator);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,12 @@ class FtrRelation implements Serializable {
|
|||
/** The target. */
|
||||
final long target;
|
||||
|
||||
/** The source. */
|
||||
final long source_fiber;
|
||||
|
||||
/** The target. */
|
||||
final long target_fiber;
|
||||
|
||||
/** The relation type. */
|
||||
final RelationType relationType;
|
||||
|
||||
|
@ -38,9 +44,11 @@ class FtrRelation implements Serializable {
|
|||
* @param source the source
|
||||
* @param target the target
|
||||
*/
|
||||
public FtrRelation(RelationType relationType, long source, long target) {
|
||||
public FtrRelation(RelationType relationType, long source, long target, long source_fiber, long target_fiber) {
|
||||
this.source = source;
|
||||
this.target = target;
|
||||
this.source_fiber = source_fiber;
|
||||
this.target_fiber = target_fiber;
|
||||
this.relationType = relationType;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,4 +81,8 @@ public class TxAttribute implements ITxAttribute, Serializable {
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FtxAttr: " + attributeType.toString() + "=" + value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,14 @@
|
|||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.ftr;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.DirectionType;
|
||||
import com.minres.scviewer.database.IEventList;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.InputFormatException;
|
||||
|
||||
/**
|
||||
* The Class TxGenerator.
|
||||
|
@ -54,6 +58,30 @@ class TxGenerator extends AbstractTxStream {
|
|||
return (other instanceof TxGenerator && this.getId()==other.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the events.
|
||||
*
|
||||
* @return the events
|
||||
*/
|
||||
@Override
|
||||
public IEventList getEvents() {
|
||||
if(events.size()==0) {
|
||||
try {
|
||||
List<byte[]> chunks = stream.getChunks();
|
||||
int blockid = 0;
|
||||
for (byte[] bs : chunks) {
|
||||
loader.parseTx(stream, blockid, bs);
|
||||
}
|
||||
} catch (InputFormatException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return events;
|
||||
}
|
||||
/**
|
||||
* Gets the begin attrs.
|
||||
*
|
||||
|
@ -92,4 +120,8 @@ class TxGenerator extends AbstractTxStream {
|
|||
return ((AbstractTxStream)parent).getFullName()+"."+name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionType getDirection() {
|
||||
return DirectionType.IMPLICIT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,14 @@
|
|||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.ftr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
import com.minres.scviewer.database.tx.ITx;
|
||||
import com.minres.scviewer.database.tx.ITxAttribute;
|
||||
import com.minres.scviewer.database.tx.ITxRelation;
|
||||
|
||||
/**
|
||||
|
@ -53,7 +59,9 @@ class TxRelation implements ITxRelation {
|
|||
*/
|
||||
@Override
|
||||
public ITx getSource() {
|
||||
return loader.getTransaction(scvRelation.source);
|
||||
ITx tx = loader.getTransaction(scvRelation.source);
|
||||
if(tx!=null) return tx;
|
||||
return new TxFacade(scvRelation.source_fiber, scvRelation.source);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +71,82 @@ class TxRelation implements ITxRelation {
|
|||
*/
|
||||
@Override
|
||||
public ITx getTarget() {
|
||||
return loader.getTransaction(scvRelation.target);
|
||||
ITx tx = loader.getTransaction(scvRelation.target);
|
||||
if(tx!=null) return tx;
|
||||
return new TxFacade(scvRelation.target_fiber, scvRelation.target);
|
||||
}
|
||||
|
||||
private class TxFacade implements ITx {
|
||||
|
||||
final long fiberId;
|
||||
|
||||
final long txId;
|
||||
|
||||
ITx tx = null;
|
||||
|
||||
public TxFacade(long fiberId, long txId) {
|
||||
this.fiberId = fiberId;
|
||||
this.txId=txId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ITx o) {
|
||||
return tx==null?-1:tx.compareTo(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return txId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWaveform getStream() {
|
||||
if(tx==null) {
|
||||
TxStream fiber = loader.txStreams.get(fiberId);
|
||||
fiber.loadStream();
|
||||
tx = loader.getTransaction(txId);
|
||||
return loader.txStreams.get(fiberId);
|
||||
} else
|
||||
return tx.getStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWaveform getGenerator() {
|
||||
if(tx==null) {
|
||||
loader.txStreams.get(fiberId).loadStream();
|
||||
tx = loader.getTransaction(txId);
|
||||
}
|
||||
return tx.getGenerator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBeginTime() {
|
||||
return tx==null?-1:tx.getBeginTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEndTime() {
|
||||
return tx==null?-1:tx.getBeginTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ITxAttribute> getAttributes() {
|
||||
return tx==null?new ArrayList<>():tx.getAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ITxRelation> getIncomingRelations() {
|
||||
return tx==null?new ArrayList<>():tx.getIncomingRelations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ITxRelation> getOutgoingRelations() {
|
||||
return tx==null?new ArrayList<>():tx.getOutgoingRelations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return tx==null?("tx#" + getId() + "[not available]"):tx.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,12 @@
|
|||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.ftr;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.DirectionType;
|
||||
import com.minres.scviewer.database.IEventList;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.InputFormatException;
|
||||
|
||||
|
@ -69,4 +72,33 @@ class TxStream extends AbstractTxStream {
|
|||
return chunks;
|
||||
}
|
||||
|
||||
public void loadStream() {
|
||||
try {
|
||||
List<byte[]> chunks = getChunks();
|
||||
int blockid = 0;
|
||||
for (byte[] bs : chunks) {
|
||||
loader.parseTx(this, blockid, bs);
|
||||
blockid++;
|
||||
}
|
||||
} catch (InputFormatException e) {
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the events.
|
||||
*
|
||||
* @return the events
|
||||
*/
|
||||
@Override
|
||||
public IEventList getEvents() {
|
||||
if(events.size()==0) {
|
||||
loadStream();
|
||||
}
|
||||
return events;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionType getDirection() {
|
||||
return DirectionType.IMPLICIT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -4,7 +4,7 @@
|
|||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.17.3</version>
|
||||
<version>2.18.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
|
|
@ -71,6 +71,11 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
|||
return maxConcurrency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEventList getEvents(){
|
||||
if(events==null){
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbLoader;
|
||||
import com.minres.scviewer.database.InputFormatException;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
|
@ -94,8 +93,8 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
|
|||
// }
|
||||
|
||||
@Override
|
||||
public void load(IWaveformDb db, File file) throws InputFormatException {
|
||||
database=new SQLiteDatabase(file.getAbsolutePath(), db);
|
||||
public void load(File file) throws InputFormatException {
|
||||
database=new SQLiteDatabase(file.getAbsolutePath());
|
||||
database.setData("TIMERESOLUTION", 1L);
|
||||
SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<>(ScvSimProps.class, database);
|
||||
try {
|
||||
|
|
|
@ -16,6 +16,7 @@ import java.sql.SQLException;
|
|||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.minres.scviewer.database.DirectionType;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.sqlite.db.IDatabase;
|
||||
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
|
||||
|
@ -76,4 +77,8 @@ public class TxGenerator extends AbstractTxStream {
|
|||
return transactions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionType getDirection() {
|
||||
return DirectionType.IMPLICIT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.minres.scviewer.database.DirectionType;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.sqlite.db.IDatabase;
|
||||
|
@ -102,4 +103,9 @@ public class TxStream extends AbstractTxStream {
|
|||
public String getKind() {
|
||||
return scvStream.getKind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionType getDirection() {
|
||||
return DirectionType.IMPLICIT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ public class SQLiteDatabase implements IDatabase {
|
|||
|
||||
protected String dbFileName;
|
||||
|
||||
protected IWaveformDb waveformDb;
|
||||
|
||||
protected HashMap<String, Object> props;
|
||||
|
||||
static {
|
||||
|
@ -43,10 +41,9 @@ public class SQLiteDatabase implements IDatabase {
|
|||
}
|
||||
}
|
||||
|
||||
public SQLiteDatabase(String dbFileName, IWaveformDb waveformDb) {
|
||||
public SQLiteDatabase(String dbFileName) {
|
||||
super();
|
||||
this.dbFileName = dbFileName;
|
||||
this.waveformDb = waveformDb;
|
||||
props = new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
|
@ -96,7 +93,7 @@ public class SQLiteDatabase implements IDatabase {
|
|||
|
||||
@Override
|
||||
public IWaveformDb getWaveformDb() {
|
||||
return waveformDb;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.17.3</version>
|
||||
<version>2.18.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
|
|
@ -143,6 +143,10 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
|
|||
return rowCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Calculate concurrency.
|
||||
*/
|
||||
|
|
|
@ -46,7 +46,6 @@ import com.minres.scviewer.database.AssociationType;
|
|||
import com.minres.scviewer.database.DataType;
|
||||
import com.minres.scviewer.database.EventKind;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbLoader;
|
||||
import com.minres.scviewer.database.InputFormatException;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
|
@ -222,7 +221,7 @@ public class TextDbLoader implements IWaveformDbLoader {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void load(IWaveformDb db, File file) throws InputFormatException {
|
||||
public void load(File file) throws InputFormatException {
|
||||
dispose();
|
||||
FileType fType = getFileType(file);
|
||||
if (file.length() < MEMMAP_LIMIT * (fType!=FileType.PLAIN ? 1 : 10)
|
||||
|
@ -520,6 +519,7 @@ public class TextDbLoader implements IWaveformDbLoader {
|
|||
* @return the long
|
||||
*/
|
||||
private long stringToScale(String scale) {
|
||||
// TODO: scale to IWaveformDb.databaseTimeScale
|
||||
String cmp = scale.trim();
|
||||
if ("fs".equals(cmp))
|
||||
return 1L;
|
||||
|
|
|
@ -14,6 +14,7 @@ package com.minres.scviewer.database.text;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.DirectionType;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
|
||||
/**
|
||||
|
@ -93,4 +94,8 @@ class TxGenerator extends AbstractTxStream {
|
|||
return ((AbstractTxStream)parent).getFullName()+"."+name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionType getDirection() {
|
||||
return DirectionType.IMPLICIT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.text;
|
||||
|
||||
import com.minres.scviewer.database.DirectionType;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
|
||||
/**
|
||||
|
@ -55,4 +56,8 @@ class TxStream extends AbstractTxStream {
|
|||
return kind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionType getDirection() {
|
||||
return DirectionType.IMPLICIT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.17.3</version>
|
||||
<version>2.18.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
|
||||
* Copyright (c) 2015-2023 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -12,8 +12,8 @@ package com.minres.scviewer.database.ui;
|
|||
|
||||
public interface ICursor {
|
||||
|
||||
public long getTime();
|
||||
long getTime();
|
||||
|
||||
public void setTime(long time);
|
||||
void setTime(long time);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
|
||||
* Copyright (c) 2015-2023 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -35,82 +35,86 @@ public interface IWaveformView extends PropertyChangeListener, ISelectionProvide
|
|||
|
||||
static final int MARKER_POS = 1;
|
||||
|
||||
public static final RelationType NEXT_PREV_IN_STREAM = RelationTypeFactory.create("Prev/Next in stream");
|
||||
static final RelationType NEXT_PREV_IN_STREAM = RelationTypeFactory.create("Prev/Next in stream");
|
||||
|
||||
public void addSelectionChangedListener(ISelectionChangedListener listener);
|
||||
void addSelectionChangedListener(ISelectionChangedListener listener);
|
||||
|
||||
public void removeSelectionChangedListener(ISelectionChangedListener listener);
|
||||
void removeSelectionChangedListener(ISelectionChangedListener listener);
|
||||
|
||||
public void setStyleProvider(IWaveformStyleProvider styleProvider);
|
||||
void setStyleProvider(IWaveformStyleProvider styleProvider);
|
||||
|
||||
public void update();
|
||||
void update();
|
||||
|
||||
public Control getControl();
|
||||
Control getControl();
|
||||
|
||||
public Control getNameControl();
|
||||
Control getNameControl();
|
||||
|
||||
public Control getValueControl();
|
||||
Control getValueControl();
|
||||
|
||||
public Control getWaveformControl();
|
||||
Control getWaveformControl();
|
||||
|
||||
public ISelection getSelection();
|
||||
ISelection getSelection();
|
||||
|
||||
public void setSelection(ISelection selection);
|
||||
void setSelection(ISelection selection);
|
||||
|
||||
public void setSelection(ISelection selection, boolean showIfNeeded);
|
||||
void setSelection(ISelection selection, boolean showIfNeeded);
|
||||
|
||||
public void addToSelection(ISelection selection, boolean showIfNeeded);
|
||||
void addToSelection(ISelection selection, boolean showIfNeeded);
|
||||
|
||||
public void moveSelection(GotoDirection direction);
|
||||
void moveSelection(GotoDirection direction);
|
||||
|
||||
public void moveSelection(GotoDirection direction, RelationType relationType);
|
||||
void moveSelection(GotoDirection direction, RelationType relationType);
|
||||
|
||||
public void moveCursor(GotoDirection direction);
|
||||
void moveCursor(GotoDirection direction);
|
||||
|
||||
public List<TrackEntry> getStreamList();
|
||||
List<TrackEntry> getStreamList();
|
||||
|
||||
public TrackEntry getEntryFor(ITx source);
|
||||
TrackEntry getEntryFor(ITx source);
|
||||
|
||||
public TrackEntry getEntryFor(IWaveform source);
|
||||
TrackEntry getEntryFor(IWaveform source);
|
||||
|
||||
public List<Object> getElementsAt(Point pt);
|
||||
List<Object> getElementsAt(Point pt);
|
||||
|
||||
public void moveSelectedTrack(int i);
|
||||
void moveSelectedTrack(int i);
|
||||
|
||||
public void setHighliteRelation(RelationType relationType);
|
||||
void setHighliteRelation(RelationType relationType);
|
||||
|
||||
public void setMaxTime(long maxTime);
|
||||
void setMaxTime(long maxTime);
|
||||
|
||||
public void setCursorTime(long time);
|
||||
void setCursorTime(long time);
|
||||
|
||||
public void setMarkerTime(int marker, long time);
|
||||
void setMarkerTime(int marker, long time);
|
||||
|
||||
public long getCursorTime();
|
||||
long getCursorTime();
|
||||
|
||||
public int getSelectedMarker();
|
||||
int getSelectedMarker();
|
||||
|
||||
public long getMarkerTime(int marker);
|
||||
long getMarkerTime(int marker);
|
||||
|
||||
public void addPropertyChangeListener(PropertyChangeListener listener);
|
||||
void addPropertyChangeListener(PropertyChangeListener listener);
|
||||
|
||||
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener);
|
||||
void addPropertyChangeListener(String propertyName, PropertyChangeListener listener);
|
||||
|
||||
public void removePropertyChangeListener(PropertyChangeListener listener);
|
||||
void removePropertyChangeListener(PropertyChangeListener listener);
|
||||
|
||||
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener);
|
||||
void removePropertyChangeListener(String propertyName, PropertyChangeListener listener);
|
||||
|
||||
public List<ICursor> getCursorList();
|
||||
List<ICursor> getCursorList();
|
||||
|
||||
public void scrollHorizontal(int percent);
|
||||
void scrollHorizontal(int percent);
|
||||
|
||||
public void scrollTo(int pos);
|
||||
void scrollTo(int pos);
|
||||
|
||||
public void addDisposeListener( DisposeListener listener );
|
||||
void addDisposeListener( DisposeListener listener );
|
||||
|
||||
public void deleteSelectedTracks();
|
||||
void addEventListner(IWaveformviewEventListener listener);
|
||||
|
||||
public TrackEntry addWaveform(IWaveform waveform, int pos);
|
||||
void removeEventListner(IWaveformviewEventListener listener);
|
||||
|
||||
public IWaveformZoom getWaveformZoom();
|
||||
void deleteSelectedTracks();
|
||||
|
||||
TrackEntry addWaveform(IWaveform waveform, int pos);
|
||||
|
||||
IWaveformZoom getWaveformZoom();
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
|
||||
* Copyright (c) 2015-2023 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -13,7 +13,7 @@ package com.minres.scviewer.database.ui;
|
|||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
public interface IWaveformViewFactory {
|
||||
public IWaveformView createPanel(Composite parent);
|
||||
IWaveformView createPanel(Composite parent);
|
||||
|
||||
public IWaveformView createPanel(Composite parent, IWaveformStyleProvider styleProvider);
|
||||
IWaveformView createPanel(Composite parent, IWaveformStyleProvider styleProvider);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2023 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package com.minres.scviewer.database.ui;
|
||||
|
||||
public interface IWaveformviewEventListener {
|
||||
void onTrackEntryDoubleClickEvent (TrackEntry trackEntry);
|
||||
}
|
|
@ -11,14 +11,19 @@
|
|||
package com.minres.scviewer.database.ui;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.minres.scviewer.database.EmptyWaveform;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
|
||||
public class TrackEntry {
|
||||
|
||||
IWaveformStyleProvider styleProvider;
|
||||
public enum HierState {
|
||||
NONE, CLOSED, OPENED
|
||||
}
|
||||
|
||||
public enum ValueDisplay {
|
||||
DEFAULT, SIGNED, UNSIGNED
|
||||
DEFAULT, BINARY, SIGNED, UNSIGNED
|
||||
|
||||
}
|
||||
|
||||
|
@ -26,13 +31,19 @@ public class TrackEntry {
|
|||
DEFAULT, STEP_WISE, CONTINOUS
|
||||
}
|
||||
|
||||
IWaveformStyleProvider styleProvider = null;
|
||||
|
||||
final public IWaveform waveform;
|
||||
|
||||
public int vOffset;
|
||||
public int vOffset=0;
|
||||
|
||||
public int height;
|
||||
public int height=0;
|
||||
|
||||
public boolean selected;
|
||||
public boolean selected=false;
|
||||
|
||||
public HierState hierState=HierState.NONE;
|
||||
|
||||
public List<TrackEntry> waveforms = new ArrayList<>();
|
||||
|
||||
public String currentValue="";
|
||||
|
||||
|
@ -40,12 +51,23 @@ public class TrackEntry {
|
|||
|
||||
public WaveDisplay waveDisplay = WaveDisplay.DEFAULT;
|
||||
|
||||
public TrackEntry() {
|
||||
this.waveform = null;
|
||||
this.styleProvider=null;
|
||||
}
|
||||
|
||||
public TrackEntry(IWaveform waveform, IWaveformStyleProvider styleProvider) {
|
||||
this.waveform = waveform;
|
||||
this.styleProvider=styleProvider;
|
||||
vOffset=0;
|
||||
height=0;
|
||||
selected=false;
|
||||
this.hierState = (waveform!=null && waveform.getChildNodes().size()>0)?HierState.CLOSED:HierState.NONE;
|
||||
}
|
||||
|
||||
public TrackEntry(TrackEntry[] waveform, IWaveformStyleProvider styleProvider) {
|
||||
this(new EmptyWaveform(), styleProvider);
|
||||
this.hierState = HierState.CLOSED;
|
||||
for (TrackEntry iWaveform : waveform) {
|
||||
waveforms.add(iWaveform);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,4 +78,5 @@ public class TrackEntry {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@ public enum WaveformColors {
|
|||
LINE, LINE_HIGHLITE,
|
||||
TRACK_BG_EVEN, TRACK_BG_ODD, TRACK_BG_HIGHLITE,
|
||||
TX_BG, TX_BG_HIGHLITE, TX_BORDER,
|
||||
SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNALU, SIGNAL_TEXT, SIGNAL_REAL, SIGNAL_NAN,
|
||||
SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNAL_CHANGE, SIGNALU, SIGNAL_TEXT, SIGNAL_REAL, SIGNAL_NAN,
|
||||
CURSOR, CURSOR_DRAG, CURSOR_TEXT,
|
||||
MARKER, MARKER_TEXT, REL_ARROW, REL_ARROW_HIGHLITE
|
||||
MARKER, MARKER_TEXT, REL_ARROW, REL_ARROW_HIGHLITE, SEPARATOR
|
||||
}
|
|
@ -13,10 +13,10 @@ public class Constants {
|
|||
public static final String CONTENT_PROVIDER_TAG = "TOOLTIP_CONTENT_PROVIDER";
|
||||
public static final String HELP_PROVIDER_TAG = "TOOLTIP_HELP_PROVIDER";
|
||||
|
||||
public static final DecimalFormat TIME_FORMAT_FS = new DecimalFormat("#");
|
||||
public static final DecimalFormat TIME_FORMAT_PS = new DecimalFormat("#");
|
||||
public static final DecimalFormat TIME_FORMAT_NS = new DecimalFormat("#.0##");
|
||||
public static final DecimalFormat TIME_FORMAT_UMS = new DecimalFormat("#.0#####");
|
||||
public static final DecimalFormat TIME_FORMAT_FS = new DecimalFormat("#0");
|
||||
public static final DecimalFormat TIME_FORMAT_PS = new DecimalFormat("#0");
|
||||
public static final DecimalFormat TIME_FORMAT_NS = new DecimalFormat("#0.0##");
|
||||
public static final DecimalFormat TIME_FORMAT_UMS = new DecimalFormat("#0.0#####");
|
||||
public static final long[] POWERS_OF_TEN = {
|
||||
1L,
|
||||
10L,
|
||||
|
|
|
@ -39,6 +39,7 @@ public class DefaultWaveformStyleProvider implements IWaveformStyleProvider {
|
|||
colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW);
|
||||
colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51);
|
||||
colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
|
||||
colors[WaveformColors.SIGNAL_CHANGE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
|
||||
colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
|
@ -49,6 +50,7 @@ public class DefaultWaveformStyleProvider implements IWaveformStyleProvider {
|
|||
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
|
||||
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
|
||||
colors[WaveformColors.SEPARATOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_RED);
|
||||
}
|
||||
/**
|
||||
* needs redraw() afterwards
|
||||
|
|
|
@ -109,20 +109,21 @@ public class ArrowPainter implements IPainter {
|
|||
protected void deriveGeom(Collection<ITxRelation> relations, List<LinkEntry> res, boolean useTarget) {
|
||||
for (ITxRelation iTxRelation : relations) {
|
||||
ITx otherTx = useTarget ? iTxRelation.getTarget() : iTxRelation.getSource();
|
||||
for(IWaveform iWaveform: new IWaveform[]{otherTx.getStream(), otherTx.getGenerator()}) {
|
||||
if (waveCanvas.wave2painterMap.containsKey(iWaveform)) {
|
||||
IWaveformPainter painter = waveCanvas.wave2painterMap.get(iWaveform);
|
||||
if(painter!=null) {
|
||||
int height = waveCanvas.styleProvider.getTrackHeight();
|
||||
Rectangle bb = new Rectangle(
|
||||
(int) (otherTx.getBeginTime() / scaleFactor),
|
||||
waveCanvas.rulerHeight + painter.getVerticalOffset() + height * getConcurrencyIndex(otherTx),
|
||||
(int) ((otherTx.getEndTime() - otherTx.getBeginTime()) / scaleFactor),
|
||||
height);
|
||||
res.add(new LinkEntry(bb, iTxRelation.getRelationType()));
|
||||
if(otherTx!=null && otherTx.getBeginTime()>=0)
|
||||
for(IWaveform iWaveform: new IWaveform[]{otherTx.getStream(), otherTx.getGenerator()}) {
|
||||
if (waveCanvas.wave2painterMap.containsKey(iWaveform)) {
|
||||
IWaveformPainter painter = waveCanvas.wave2painterMap.get(iWaveform);
|
||||
if(painter!=null) {
|
||||
int height = waveCanvas.styleProvider.getTrackHeight();
|
||||
Rectangle bb = new Rectangle(
|
||||
(int) (otherTx.getBeginTime() / scaleFactor),
|
||||
waveCanvas.rulerHeight + painter.getVerticalOffset() + height * getConcurrencyIndex(otherTx),
|
||||
(int) ((otherTx.getEndTime() - otherTx.getBeginTime()) / scaleFactor),
|
||||
height);
|
||||
res.add(new LinkEntry(bb, iTxRelation.getRelationType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.ui.swt.internal;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.FontData;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
public class EmptyPainter extends TrackPainter {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final WaveformCanvas waveCanvas;
|
||||
|
||||
private static final JPanel DUMMY_PANEL = new JPanel();
|
||||
|
||||
public EmptyPainter(WaveformCanvas txDisplay, boolean even, TrackEntry trackEntry) {
|
||||
super(trackEntry, even);
|
||||
this.waveCanvas = txDisplay;
|
||||
}
|
||||
|
||||
public void paintArea(Projection proj, Rectangle area) {
|
||||
Color bgColor = trackEntry.selected?this.waveCanvas.styleProvider.getColor(WaveformColors.TRACK_BG_HIGHLITE):this.waveCanvas.styleProvider.getColor(even ? WaveformColors.TRACK_BG_EVEN : WaveformColors.TRACK_BG_ODD);
|
||||
GC gc = proj.getGC();
|
||||
proj.setBackground(bgColor);
|
||||
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
||||
proj.fillRectangle(area);
|
||||
Color drawColor = this.waveCanvas.styleProvider.getColor(WaveformColors.SEPARATOR);
|
||||
int trackHeight=trackEntry.height;
|
||||
int txBase=trackHeight*2/5;
|
||||
int txHeight=trackHeight/5;
|
||||
proj.setBackground(drawColor);
|
||||
proj.fillRectangle(new Rectangle(area.x, area.y+txBase, area.width, txHeight));
|
||||
|
||||
String label = trackEntry.waveform.getName();
|
||||
if(label.length()>0) {
|
||||
Color textColor=waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_TEXT);
|
||||
FontData fd = gc.getFont().getFontData()[0];
|
||||
int height = gc.getDevice().getDPI().y * fd.getHeight() / 72;
|
||||
java.awt.Font tmpAwtFont = new java.awt.Font(fd.getName(), fd.getStyle(), height);
|
||||
int width = DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(label);
|
||||
|
||||
int xBegin = (area.width-width)/2-5;
|
||||
xBegin = xBegin<0?0:xBegin;
|
||||
int xEnd = (area.width+width)/2+5;
|
||||
xEnd = xEnd>area.width?area.width:xEnd;
|
||||
int yOffsetT = this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
|
||||
int yOffsetM = this.waveCanvas.styleProvider.getTrackHeight() / 2 + area.y;
|
||||
int yOffsetB = 4 * this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
|
||||
int[] points = {
|
||||
xBegin, yOffsetM,
|
||||
xBegin + 1, yOffsetT,
|
||||
xEnd - 1, yOffsetT,
|
||||
xEnd, yOffsetM,
|
||||
xEnd - 1, yOffsetB,
|
||||
xBegin + 1, yOffsetB
|
||||
};
|
||||
gc.setBackground(bgColor);
|
||||
gc.fillPolygon(points);
|
||||
gc.setForeground(drawColor);
|
||||
gc.drawPolygon(points);
|
||||
Rectangle old = gc.getClipping();
|
||||
gc.setForeground(textColor);
|
||||
gc.setClipping(xBegin + 3, yOffsetT, xEnd - xBegin - 5, yOffsetB - yOffsetT);
|
||||
gc.drawText(label, xBegin + 3, yOffsetM - height / 2 - 1);
|
||||
gc.setClipping(old);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -115,7 +115,7 @@ public class ObservableList<E> implements List<E> {
|
|||
|
||||
public boolean addAll(int index, Collection<? extends E> c) {
|
||||
int oldSize = size();
|
||||
boolean success = this.delegate.addAll(index, c);
|
||||
boolean success = this.delegate.addAll(index<0?0:index, c);
|
||||
|
||||
if ((success) && (c != null)) {
|
||||
List<E> values = new ArrayList<>();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.ui.swt.internal;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
|
@ -191,7 +192,7 @@ public class SignalPainter extends TrackPainter {
|
|||
}
|
||||
|
||||
public void draw(Projection proj, Rectangle area, IEvent left, IEvent right, int xBegin, int xEnd, boolean multiple) {
|
||||
Color colorBorder = waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL0);
|
||||
Color colorBorder = waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_CHANGE);
|
||||
BitVector last = (BitVector) left;
|
||||
if (Arrays.toString(last.getValue()).contains("X")) {
|
||||
colorBorder = waveCanvas.styleProvider.getColor(WaveformColors.SIGNALX);
|
||||
|
@ -199,7 +200,8 @@ public class SignalPainter extends TrackPainter {
|
|||
colorBorder = waveCanvas.styleProvider.getColor(WaveformColors.SIGNALZ);
|
||||
}
|
||||
int width = xEnd - xBegin;
|
||||
if (width > 1) {
|
||||
switch(width) {
|
||||
default: {
|
||||
int[] points = {
|
||||
xBegin, yOffsetM,
|
||||
xBegin + 1, yOffsetT,
|
||||
|
@ -214,28 +216,45 @@ public class SignalPainter extends TrackPainter {
|
|||
String label = null;
|
||||
switch(trackEntry.valueDisplay) {
|
||||
case SIGNED:
|
||||
label=Long.toString(last.toSignedValue());
|
||||
label=last.toSignedValue().toString();
|
||||
break;
|
||||
case UNSIGNED:
|
||||
label=Long.toString(last.toUnsignedValue());
|
||||
label=last.toUnsignedValue().toString();
|
||||
break;
|
||||
case BINARY:
|
||||
label=last.toString();
|
||||
break;
|
||||
default:
|
||||
label="h'"+last.toHexString();
|
||||
label=/*"h'"+*/last.toHexString();
|
||||
}
|
||||
Point bb = new Point(DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(label), height);
|
||||
if (xBegin < area.x) {
|
||||
xBegin = area.x;
|
||||
width = xEnd - xBegin;
|
||||
}
|
||||
Point bb = new Point(DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(label), height);
|
||||
String ext = "";
|
||||
while(width<bb.x && label.length()>1) {
|
||||
label = label.substring(0, label.length()-1);
|
||||
ext="+";
|
||||
bb = new Point(DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(label +ext), height);
|
||||
}
|
||||
if (width > (bb.x+1)) {
|
||||
Rectangle old = proj.getClipping();
|
||||
proj.setClipping(xBegin + 3, yOffsetT, xEnd - xBegin - 5, yOffsetB - yOffsetT);
|
||||
proj.drawText(label, xBegin + 3, yOffsetM - bb.y / 2 - 1);
|
||||
proj.drawText(label+ext, xBegin + 3, yOffsetM - bb.y / 2 - 1);
|
||||
proj.setClipping(old);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
case 1:
|
||||
proj.setForeground(colorBorder);
|
||||
proj.drawLine(xEnd, yOffsetT, xEnd, yOffsetB);
|
||||
proj.drawPolygon(new int[]{/*tl*/xBegin, yOffsetT,/*tr*/xEnd, yOffsetT,/*br*/xEnd, yOffsetB,/*bl*/xBegin, yOffsetB});
|
||||
break;
|
||||
case 0:
|
||||
proj.setForeground(colorBorder);
|
||||
proj.drawLine(xBegin, yOffsetT, xBegin, yOffsetB);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,9 +264,9 @@ public class SignalPainter extends TrackPainter {
|
|||
|
||||
final boolean continous;
|
||||
final boolean signed;
|
||||
private long maxVal;
|
||||
private long minVal;
|
||||
double yRange = (yOffsetB-yOffsetT);
|
||||
private BigInteger maxVal;
|
||||
private BigInteger minVal;
|
||||
int yRange = (yOffsetB-yOffsetT);
|
||||
public MultiBitStencilAnalog(IEventList entries, Object left, boolean continous, boolean signed) {
|
||||
this.continous=continous;
|
||||
this.signed=signed;
|
||||
|
@ -257,28 +276,30 @@ public class SignalPainter extends TrackPainter {
|
|||
maxVal=minVal;
|
||||
for (EventEntry tp : ievents)
|
||||
for(IEvent e: tp.events) {
|
||||
long v = signed?((BitVector)e).toSignedValue():((BitVector)e).toUnsignedValue();
|
||||
maxVal=Math.max(maxVal, v);
|
||||
minVal=Math.min(minVal, v);
|
||||
BigInteger v = signed?((BitVector)e).toSignedValue():((BitVector)e).toUnsignedValue();
|
||||
maxVal=maxVal.max(v);
|
||||
minVal=minVal.min(v);
|
||||
}
|
||||
if(maxVal==minVal) {
|
||||
maxVal--;
|
||||
minVal++;
|
||||
maxVal=maxVal.subtract(BigInteger.ONE);
|
||||
minVal=minVal.add(BigInteger.ONE);
|
||||
}
|
||||
} else {
|
||||
minVal--;
|
||||
maxVal=minVal+2;
|
||||
minVal=minVal.subtract(BigInteger.ONE);
|
||||
maxVal=minVal.multiply(BigInteger.valueOf(2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void draw(Projection proj, Rectangle area, IEvent left, IEvent right, int xBegin, int xEnd, boolean multiple) {
|
||||
long leftVal = signed?((BitVector)left).toSignedValue():((BitVector)left).toUnsignedValue();
|
||||
long rightVal= signed?((BitVector)right).toSignedValue():((BitVector)right).toUnsignedValue();
|
||||
BigInteger leftVal = signed?((BitVector)left).toSignedValue():((BitVector)left).toUnsignedValue();
|
||||
BigInteger rightVal= signed?((BitVector)right).toSignedValue():((BitVector)right).toUnsignedValue();
|
||||
proj.setForeground(waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_REAL));
|
||||
long range = maxVal-minVal;
|
||||
int yOffsetLeft = (int) ((leftVal-minVal) * yRange / range);
|
||||
int yOffsetRight = (int) ((rightVal-minVal) * yRange / range);
|
||||
BigInteger range = maxVal.subtract(minVal);
|
||||
// ((leftVal-minVal) * yRange / range);
|
||||
int yOffsetLeft = leftVal.subtract(minVal).multiply(BigInteger.valueOf(yRange)).divide(range).intValue();
|
||||
// ((rightVal-minVal) * yRange / range);
|
||||
int yOffsetRight = rightVal.subtract(minVal).multiply(BigInteger.valueOf(yRange)).divide(range).intValue();
|
||||
if(continous) {
|
||||
if (xEnd > maxPosX) {
|
||||
proj.drawLine(xBegin, yOffsetB-yOffsetLeft, maxPosX, yOffsetB-yOffsetRight);
|
||||
|
@ -337,8 +358,11 @@ public class SignalPainter extends TrackPainter {
|
|||
break;
|
||||
default:
|
||||
}
|
||||
if (yOffset != yNext)
|
||||
if (yOffset != yNext) {
|
||||
Color transition_color = waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_CHANGE);
|
||||
proj.setForeground(transition_color);
|
||||
proj.drawLine(xEnd, yOffset, xEnd, yNext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -363,6 +363,9 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
|
|||
} else { /* image is less higher than client area */
|
||||
vertical.setMaximum(clientHeight);
|
||||
vertical.setEnabled(false);
|
||||
if ( -origin.y > vertical.getMaximum() - height) {
|
||||
origin.y = -vertical.getMaximum() + height;
|
||||
}
|
||||
}
|
||||
vertical.setThumb(clientHeight);
|
||||
vertical.setSelection(-origin.y);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
|
||||
* Copyright (c) 2015-2023 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -47,7 +47,6 @@ import org.eclipse.swt.dnd.Transfer;
|
|||
import org.eclipse.swt.events.ControlAdapter;
|
||||
import org.eclipse.swt.events.ControlEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.MouseListener;
|
||||
import org.eclipse.swt.events.PaintEvent;
|
||||
|
@ -90,7 +89,9 @@ import com.minres.scviewer.database.ui.ICursor;
|
|||
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
||||
import com.minres.scviewer.database.ui.IWaveformView;
|
||||
import com.minres.scviewer.database.ui.IWaveformZoom;
|
||||
import com.minres.scviewer.database.ui.IWaveformviewEventListener;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.TrackEntry.HierState;
|
||||
import com.minres.scviewer.database.ui.swt.internal.slider.ZoomBar;
|
||||
|
||||
public class WaveformView implements IWaveformView {
|
||||
|
@ -99,6 +100,8 @@ public class WaveformView implements IWaveformView {
|
|||
|
||||
private PropertyChangeSupport pcs;
|
||||
|
||||
private List<IWaveformviewEventListener> eventListener = new ArrayList<>();
|
||||
|
||||
private ITx currentTxSelection;
|
||||
|
||||
private ArrayList<TrackEntry> currentWaveformSelection = new ArrayList<>();
|
||||
|
@ -137,7 +140,7 @@ public class WaveformView implements IWaveformView {
|
|||
|
||||
protected TrackEntry lastClickedEntry;
|
||||
|
||||
protected MouseListener nameValueMouseListener = new MouseAdapter() {
|
||||
protected MouseListener nameValueMouseListener = new MouseListener() {
|
||||
|
||||
@Override
|
||||
public void mouseDown(MouseEvent e) {
|
||||
|
@ -146,6 +149,26 @@ public class WaveformView implements IWaveformView {
|
|||
if (entry != null)
|
||||
entry.getValue().selected = true;
|
||||
} else if (e.button == 3) {
|
||||
ISelection sel = getSelection();
|
||||
if(sel instanceof StructuredSelection) {
|
||||
if(((StructuredSelection)sel).isEmpty()) {
|
||||
Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
|
||||
setSelection(new StructuredSelection(entry.getValue()), false, false);
|
||||
lastClickedEntry = entry.getValue();
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
long c = ((IStructuredSelection)sel).toList().stream().filter(x -> x instanceof TrackEntry).count();
|
||||
if(c==1) {
|
||||
Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
|
||||
@SuppressWarnings("unchecked")
|
||||
Optional<TrackEntry> o = ((IStructuredSelection)sel).toList().stream().filter(x -> x instanceof TrackEntry).findFirst();
|
||||
if(!entry.getValue().equals(o.get())) {
|
||||
setSelection(new StructuredSelection(entry.getValue()), false, false);
|
||||
lastClickedEntry = entry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Menu topMenu = top.getMenu();
|
||||
if (topMenu != null)
|
||||
topMenu.setVisible(true);
|
||||
|
@ -173,6 +196,17 @@ public class WaveformView implements IWaveformView {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDoubleClick(MouseEvent e) {
|
||||
Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
|
||||
if(entry != null)
|
||||
setSelection(new StructuredSelection(entry.getValue()), false, false);
|
||||
lastClickedEntry = entry.getValue();
|
||||
for (IWaveformviewEventListener listner : eventListener) {
|
||||
listner.onTrackEntryDoubleClickEvent(entry.getValue());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class WaveformMouseListener implements PaintListener, Listener {
|
||||
|
@ -316,9 +350,7 @@ public class WaveformView implements IWaveformView {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected WaveformMouseListener waveformMouseListener = new WaveformMouseListener();
|
||||
|
@ -551,29 +583,29 @@ public class WaveformView implements IWaveformView {
|
|||
public void update() {
|
||||
tracksVerticalHeight = 0;
|
||||
int nameMaxWidth = 0;
|
||||
IWaveformPainter painter = null;
|
||||
trackVerticalOffset.clear();
|
||||
waveformCanvas.clearAllWaveformPainter(false);
|
||||
boolean even = true;
|
||||
TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
|
||||
tl.setFont(styleProvider.getNameFont());
|
||||
for (TrackEntry streamEntry : streams) {
|
||||
streamEntry.height = styleProvider.getTrackHeight();
|
||||
streamEntry.vOffset = tracksVerticalHeight;
|
||||
if (streamEntry.waveform.getType() == WaveformType.TRANSACTION) {
|
||||
streamEntry.currentValue = "";
|
||||
streamEntry.height *= streamEntry.waveform.getRowCount();
|
||||
painter = new StreamPainter(waveformCanvas, even, streamEntry);
|
||||
} else if (streamEntry.waveform.getType() == WaveformType.SIGNAL) {
|
||||
streamEntry.currentValue = "---";
|
||||
painter = new SignalPainter(waveformCanvas, even, streamEntry);
|
||||
if(streamEntry.hierState == HierState.OPENED) {
|
||||
for (TrackEntry trackEntry : streamEntry.waveforms) {
|
||||
addPainter(even, trackEntry);
|
||||
trackVerticalOffset.put(tracksVerticalHeight, trackEntry);
|
||||
tl.setText(trackEntry.waveform.getFullName());
|
||||
nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width);
|
||||
tracksVerticalHeight += trackEntry.height;
|
||||
even = !even;
|
||||
}
|
||||
} else {
|
||||
addPainter(even, streamEntry);
|
||||
trackVerticalOffset.put(tracksVerticalHeight, streamEntry);
|
||||
tl.setText(streamEntry.waveform.getFullName());
|
||||
nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width);
|
||||
tracksVerticalHeight += streamEntry.height;
|
||||
even = !even;
|
||||
}
|
||||
waveformCanvas.addWaveformPainter(painter, false);
|
||||
trackVerticalOffset.put(tracksVerticalHeight, streamEntry);
|
||||
tl.setText(streamEntry.waveform.getFullName());
|
||||
nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width);
|
||||
tracksVerticalHeight += streamEntry.height;
|
||||
even = !even;
|
||||
}
|
||||
waveformCanvas.syncSb();
|
||||
nameList.setSize(nameMaxWidth + 15, tracksVerticalHeight);
|
||||
|
@ -588,6 +620,23 @@ public class WaveformView implements IWaveformView {
|
|||
tl.dispose();
|
||||
}
|
||||
|
||||
private void addPainter(boolean even, TrackEntry streamEntry) {
|
||||
streamEntry.height = styleProvider.getTrackHeight();
|
||||
streamEntry.vOffset = tracksVerticalHeight;
|
||||
if (streamEntry.waveform.getType() == WaveformType.TRANSACTION) {
|
||||
streamEntry.currentValue = "";
|
||||
streamEntry.height *= streamEntry.waveform.getRowCount();
|
||||
IWaveformPainter painter = new StreamPainter(waveformCanvas, even, streamEntry);
|
||||
waveformCanvas.addWaveformPainter(painter, false);
|
||||
} else if (streamEntry.waveform.getType() == WaveformType.SIGNAL) {
|
||||
streamEntry.currentValue = "---";
|
||||
waveformCanvas.addWaveformPainter(new SignalPainter(waveformCanvas, even, streamEntry), false);
|
||||
} else if (streamEntry.waveform.getType() == WaveformType.EMPTY) {
|
||||
streamEntry.currentValue = "";
|
||||
waveformCanvas.addWaveformPainter(new EmptyPainter(waveformCanvas, even, streamEntry), false);
|
||||
}
|
||||
}
|
||||
|
||||
private int calculateValueWidth() {
|
||||
TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
|
||||
tl.setFont(styleProvider.getNameFontHighlite());
|
||||
|
@ -602,7 +651,7 @@ public class WaveformView implements IWaveformView {
|
|||
|
||||
private void updateValueList() {
|
||||
final Long time = getCursorTime();
|
||||
for (TrackEntry entry : streams) {
|
||||
streams.stream()/*.parallel()*/.forEach(entry -> {
|
||||
if (entry.waveform.getType() == WaveformType.SIGNAL) {
|
||||
IEvent[] value = entry.waveform.getEventsBeforeTime(time);
|
||||
if (value[0] instanceof BitVector) {
|
||||
|
@ -612,10 +661,13 @@ public class WaveformView implements IWaveformView {
|
|||
else {
|
||||
switch (entry.valueDisplay) {
|
||||
case SIGNED:
|
||||
entry.currentValue = Long.toString(bv.toSignedValue());
|
||||
entry.currentValue = bv.toSignedValue().toString();
|
||||
break;
|
||||
case UNSIGNED:
|
||||
entry.currentValue = Long.toString(bv.toUnsignedValue());
|
||||
entry.currentValue = bv.toUnsignedValue().toString();
|
||||
break;
|
||||
case BINARY:
|
||||
entry.currentValue=bv.toString();
|
||||
break;
|
||||
default:
|
||||
entry.currentValue = "h'" + bv.toHexString();
|
||||
|
@ -658,7 +710,7 @@ public class WaveformView implements IWaveformView {
|
|||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
int width = calculateValueWidth();
|
||||
valueList.setSize(width, tracksVerticalHeight);
|
||||
valueListScrolled.setMinSize(width, tracksVerticalHeight);
|
||||
|
@ -1087,19 +1139,11 @@ public class WaveformView implements IWaveformView {
|
|||
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, styleProvider.getTrackHeight());
|
||||
if (lastKey.equals(firstKey)) {
|
||||
TrackEntry trackEntry = trackVerticalOffset.get(firstKey);
|
||||
IWaveform w = trackEntry.waveform;
|
||||
if (w.getType() == WaveformType.TRANSACTION)
|
||||
subArea.height *= w.getRowCount();
|
||||
drawTextFormat(gc, subArea, firstKey, w.getFullName(), trackEntry.selected);
|
||||
drawName(gc, subArea, firstKey, trackVerticalOffset.get(firstKey));
|
||||
} else {
|
||||
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
|
||||
.entrySet()) {
|
||||
IWaveform w = entry.getValue().waveform;
|
||||
subArea.height = styleProvider.getTrackHeight();
|
||||
if (w.getType() == WaveformType.TRANSACTION)
|
||||
subArea.height *= w.getRowCount();
|
||||
drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), entry.getValue().selected);
|
||||
drawName(gc, subArea, entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
} catch (NoSuchElementException e) {
|
||||
|
@ -1118,16 +1162,13 @@ public class WaveformView implements IWaveformView {
|
|||
if (lastKey.equals(firstKey)) {
|
||||
TrackEntry trackEntry = trackVerticalOffset.get(firstKey);
|
||||
IWaveform w = trackEntry.waveform;
|
||||
if (w.getType() == WaveformType.TRANSACTION)
|
||||
subArea.height *= w.getRowCount();
|
||||
subArea.height = w.getRowCount() * styleProvider.getTrackHeight();
|
||||
drawValue(gc, subArea, firstKey, trackEntry.currentValue, trackEntry.selected);
|
||||
} else {
|
||||
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
|
||||
.entrySet()) {
|
||||
IWaveform w = entry.getValue().waveform;
|
||||
subArea.height = styleProvider.getTrackHeight();
|
||||
if (w.getType() == WaveformType.TRANSACTION)
|
||||
subArea.height *= w.getRowCount();
|
||||
subArea.height = w.getRowCount() * styleProvider.getTrackHeight();
|
||||
drawValue(gc, subArea, entry.getKey(), entry.getValue().currentValue,
|
||||
entry.getValue().selected);
|
||||
}
|
||||
|
@ -1137,6 +1178,12 @@ public class WaveformView implements IWaveformView {
|
|||
}
|
||||
}
|
||||
|
||||
protected void drawName(GC gc, Rectangle subArea, Integer firstKey, TrackEntry entry) {
|
||||
IWaveform w = entry.waveform;
|
||||
subArea.height = w.getRowCount() * styleProvider.getTrackHeight();
|
||||
drawTextFormat(gc, subArea, firstKey, w.getFullName(), entry.selected, entry.hierState);
|
||||
}
|
||||
|
||||
protected void drawValue(GC gc, Rectangle subArea, Integer yOffset, String value, boolean highlite) {
|
||||
int beginIndex = 0;
|
||||
for (int offset = 0; offset < subArea.height; offset += styleProvider.getTrackHeight()) {
|
||||
|
@ -1149,7 +1196,12 @@ public class WaveformView implements IWaveformView {
|
|||
}
|
||||
|
||||
protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String value, boolean highlite) {
|
||||
drawTextFormat(gc, subArea, yOffset, value, highlite, HierState.NONE);
|
||||
}
|
||||
|
||||
protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String value, boolean highlite, HierState state) {
|
||||
Point size = gc.textExtent(value);
|
||||
int height = styleProvider.getTrackHeight();
|
||||
if (highlite) {
|
||||
gc.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION));
|
||||
gc.setForeground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION_TEXT));
|
||||
|
@ -1160,7 +1212,28 @@ public class WaveformView implements IWaveformView {
|
|||
gc.setForeground(namePaneHeader.getForeground());
|
||||
gc.setFont(styleProvider.getNameFont());
|
||||
}
|
||||
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (styleProvider.getTrackHeight() - size.y) / 2, true);
|
||||
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (height - size.y) / 2, true);
|
||||
/* if(state==HierState.NONE) {
|
||||
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (height - size.y) / 2, true);
|
||||
} else {
|
||||
gc.setBackground(highlite?SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION_TEXT):namePaneHeader.getForeground());
|
||||
int o = yOffset + (height-12)/2;
|
||||
if(state==HierState.OPENED) {
|
||||
Point tl = new Point(1,o+2);
|
||||
Point tr = new Point(10,o+2);
|
||||
Point br = new Point(6,o+9);
|
||||
Point bl = new Point(5,o+9);
|
||||
gc.fillPolygon(new int[] {tl.x, tl.y, tr.x, tr.y, br.x, br.y, bl.x, bl.y});
|
||||
} else {
|
||||
Point tl = new Point(2,o+1);
|
||||
Point tr = new Point(9,o+5);
|
||||
Point br = new Point(9,o+6);
|
||||
Point bl = new Point(2,o+10);
|
||||
gc.fillPolygon(new int[] {tl.x, tl.y, tr.x, tr.y, br.x, br.y, bl.x, bl.y});
|
||||
}
|
||||
Rectangle textArea = new Rectangle(subArea.x+12, subArea.y, subArea.width-12, subArea.height);
|
||||
gc.drawText(value, textArea.x + 5, subArea.y + yOffset + (height - size.y) / 2, true);
|
||||
}*/
|
||||
}
|
||||
|
||||
public void setHighliteRelation(RelationType relationType) {
|
||||
|
@ -1512,6 +1585,20 @@ public class WaveformView implements IWaveformView {
|
|||
waveformCanvas.addDisposeListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEventListner(IWaveformviewEventListener listener) {
|
||||
if(!eventListener.contains(listener)) {
|
||||
eventListener.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEventListner(IWaveformviewEventListener listener) {
|
||||
if(eventListener.contains(listener)) {
|
||||
eventListener.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStyleProvider(IWaveformStyleProvider styleProvider) {
|
||||
this.styleProvider = styleProvider;
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.17.3</version>
|
||||
<version>2.18.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
|
|
@ -28,7 +28,6 @@ import com.minres.scviewer.database.BitVector;
|
|||
import com.minres.scviewer.database.DoubleVal;
|
||||
import com.minres.scviewer.database.IEventList;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbLoader;
|
||||
import com.minres.scviewer.database.InputFormatException;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
|
@ -71,7 +70,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void load(IWaveformDb db, File file) throws InputFormatException {
|
||||
public void load(File file) throws InputFormatException {
|
||||
dispose();
|
||||
this.maxTime=0;
|
||||
boolean res = false;
|
||||
|
@ -176,7 +175,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
|||
@Override
|
||||
public int getNetWidth(int intValue) {
|
||||
VCDSignal<?> signal = (VCDSignal<?>) signals.get(intValue);
|
||||
return signal.getRowCount();
|
||||
return signal.getWidth();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -16,12 +16,13 @@ import java.util.*;
|
|||
|
||||
import com.minres.scviewer.database.BitValue;
|
||||
import com.minres.scviewer.database.BitVector;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
|
||||
class VCDFileParser {
|
||||
private StreamTokenizer tokenizer;
|
||||
private IVCDDatabaseBuilder traceBuilder;
|
||||
private HashMap<String, Integer> nameToNetMap = new HashMap<>();
|
||||
private long picoSecondsPerIncrement;
|
||||
private long timeScaleFactor;
|
||||
private boolean stripNetWidth;
|
||||
private boolean replaceColon;
|
||||
long currentTime;
|
||||
|
@ -121,29 +122,37 @@ class VCDFileParser {
|
|||
nextToken();
|
||||
}
|
||||
String s = sb.toString();
|
||||
int fac =1;
|
||||
switch (s.charAt(s.length() - 2)){
|
||||
case 'f': // Nano-seconds
|
||||
fac = -15;
|
||||
s = s.substring(0, s.length() - 2).trim();
|
||||
break;
|
||||
case 'p': // Nano-seconds
|
||||
picoSecondsPerIncrement = 1;
|
||||
fac = -12;
|
||||
s = s.substring(0, s.length() - 2).trim();
|
||||
break;
|
||||
case 'n': // Nano-seconds
|
||||
picoSecondsPerIncrement = 1000;
|
||||
fac = -9;
|
||||
s = s.substring(0, s.length() - 2).trim();
|
||||
break;
|
||||
case 'u': // Microseconds
|
||||
picoSecondsPerIncrement = 1000000;
|
||||
fac = -6;
|
||||
s = s.substring(0, s.length() - 2).trim();
|
||||
break;
|
||||
case 'm': // Microseconds
|
||||
picoSecondsPerIncrement = 1000000000;
|
||||
fac = -3;
|
||||
s = s.substring(0, s.length() - 2).trim();
|
||||
break;
|
||||
default: // Seconds
|
||||
picoSecondsPerIncrement = 1000000000000L;
|
||||
fac = 1;
|
||||
s = s.substring(0, s.length() - 1);
|
||||
break;
|
||||
}
|
||||
picoSecondsPerIncrement *= Long.parseLong(s);
|
||||
timeScaleFactor = 1;
|
||||
for(int i = 1; i<= fac-IWaveformDb.databaseTimeScale; i++)
|
||||
timeScaleFactor *= 10;
|
||||
timeScaleFactor = Long.parseLong(s);
|
||||
}
|
||||
|
||||
private boolean parseDefinition() throws IOException, ParseException {
|
||||
|
@ -171,7 +180,7 @@ class VCDFileParser {
|
|||
private boolean parseTransition() throws IOException {
|
||||
if (!nextToken()) return false;
|
||||
if (tokenizer.sval.charAt(0) == '#') { // If the line begins with a #, this is a timestamp.
|
||||
currentTime = Long.parseLong(tokenizer.sval.substring(1)) * picoSecondsPerIncrement;
|
||||
currentTime = Long.parseLong(tokenizer.sval.substring(1)) * timeScaleFactor;
|
||||
} else {
|
||||
if(tokenizer.sval.equals("$comment")){
|
||||
do {
|
||||
|
@ -205,41 +214,17 @@ class VCDFileParser {
|
|||
else
|
||||
traceBuilder.appendTransition(net, currentTime, Double.parseDouble(value));
|
||||
} else {
|
||||
BitVector decodedValues = new BitVector(netWidth);
|
||||
BitVector decodedValues;
|
||||
if (value.equals("z") && netWidth > 1) {
|
||||
decodedValues = new BitVector(netWidth);
|
||||
for (int i = 0; i < netWidth; i++)
|
||||
decodedValues.setValue(i, BitValue.Z);
|
||||
} else if (value.equals("x") && netWidth > 1) {
|
||||
decodedValues = new BitVector(netWidth);
|
||||
for (int i = 0; i < netWidth; i++)
|
||||
decodedValues.setValue(i, BitValue.X);
|
||||
} else {
|
||||
int stringIndex = 0;
|
||||
for (int convertedIndex = netWidth -1; convertedIndex >=0; convertedIndex--) {
|
||||
if(convertedIndex<value.length()) {
|
||||
switch (value.charAt(stringIndex++)) {
|
||||
case 'z':
|
||||
decodedValues.setValue(convertedIndex, BitValue.Z);
|
||||
break;
|
||||
|
||||
case '1':
|
||||
decodedValues.setValue(convertedIndex, BitValue.ONE);
|
||||
break;
|
||||
|
||||
case '0':
|
||||
decodedValues.setValue(convertedIndex, BitValue.ZERO);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
decodedValues.setValue(convertedIndex, BitValue.X);
|
||||
break;
|
||||
|
||||
default:
|
||||
decodedValues.setValue(convertedIndex, BitValue.X);
|
||||
}
|
||||
} else {
|
||||
decodedValues.setValue(convertedIndex, BitValue.ZERO);
|
||||
}
|
||||
}
|
||||
decodedValues = BitVector.fromString(netWidth, value);
|
||||
}
|
||||
traceBuilder.appendTransition(net, currentTime, decodedValues);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.vcd;
|
||||
|
||||
import com.minres.scviewer.database.DirectionType;
|
||||
import com.minres.scviewer.database.EventEntry;
|
||||
import com.minres.scviewer.database.EventList;
|
||||
import com.minres.scviewer.database.HierNode;
|
||||
|
@ -100,13 +101,21 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKind() {
|
||||
return "signal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionType getDirection() {
|
||||
return DirectionType.IMPLICIT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -4,7 +4,7 @@
|
|||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
<version>2.17.3</version>
|
||||
<version>2.18.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* The Class BitVector.
|
||||
*/
|
||||
|
@ -33,6 +36,37 @@ public class BitVector implements IEvent {
|
|||
packedValues[i] = 0;
|
||||
}
|
||||
|
||||
public static BitVector fromString(int netWidth, String value){
|
||||
BitVector bv = new BitVector(netWidth);
|
||||
int stringIndex = 0;
|
||||
for (int convertedIndex = netWidth -1; convertedIndex >=0; convertedIndex--) {
|
||||
if(convertedIndex<value.length()) {
|
||||
switch (value.charAt(stringIndex++)) {
|
||||
case 'z':
|
||||
bv.setValue(convertedIndex, BitValue.Z);
|
||||
break;
|
||||
|
||||
case '1':
|
||||
bv.setValue(convertedIndex, BitValue.ONE);
|
||||
break;
|
||||
|
||||
case '0':
|
||||
bv.setValue(convertedIndex, BitValue.ZERO);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
bv.setValue(convertedIndex, BitValue.X);
|
||||
break;
|
||||
|
||||
default:
|
||||
bv.setValue(convertedIndex, BitValue.X);
|
||||
}
|
||||
} else {
|
||||
bv.setValue(convertedIndex, BitValue.ZERO);
|
||||
}
|
||||
}
|
||||
return bv;
|
||||
}
|
||||
/**
|
||||
* Sets the value.
|
||||
*
|
||||
|
@ -135,7 +169,9 @@ public class BitVector implements IEvent {
|
|||
}
|
||||
res[i] = Character.forDigit(digit, 16); // ((digit < 10) ? '0' + digit : 'a' + digit -10)
|
||||
}
|
||||
return new String(res);
|
||||
int idx=0;
|
||||
while(res[idx]=='0' && idx<(res.length-1)) idx++;
|
||||
return new String( Arrays.copyOfRange(res, idx, res.length));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,8 +179,8 @@ public class BitVector implements IEvent {
|
|||
*
|
||||
* @return the long
|
||||
*/
|
||||
public long toUnsignedValue() {
|
||||
long res = 0;
|
||||
public BigInteger toUnsignedValue() {
|
||||
BigInteger res = BigInteger.ZERO;
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
int currentWord = 0;
|
||||
|
@ -154,11 +190,11 @@ public class BitVector implements IEvent {
|
|||
currentWord = packedValues[wordOffset];
|
||||
switch (currentWord & 3) {
|
||||
case 1:
|
||||
res |= 1 << i;
|
||||
res=res.add(BigInteger.ONE.shiftLeft(i));
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
return 0;
|
||||
return BigInteger.ZERO;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -178,38 +214,14 @@ public class BitVector implements IEvent {
|
|||
*
|
||||
* @return the long
|
||||
*/
|
||||
public long toSignedValue() {
|
||||
long res = 0;
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
int currentWord = 0;
|
||||
int lastVal = 0;
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
if (bitOffset == 0)
|
||||
currentWord = packedValues[wordOffset];
|
||||
lastVal = 0;
|
||||
switch (currentWord & 3) {
|
||||
case 1:
|
||||
res |= 1 << i;
|
||||
lastVal = 1;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
return 0;
|
||||
default:
|
||||
}
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
bitOffset = 0;
|
||||
} else {
|
||||
currentWord >>= 2;
|
||||
}
|
||||
public BigInteger toSignedValue() {
|
||||
BigInteger res = toUnsignedValue();
|
||||
BigInteger pos_max = BigInteger.ONE.shiftLeft(width-1);
|
||||
if(res.compareTo(pos_max)<0)
|
||||
return res;
|
||||
else {
|
||||
return res.subtract(BigInteger.ONE.shiftLeft(width));
|
||||
}
|
||||
if (lastVal != 0)
|
||||
res |= -1l << width;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2020 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
/**
|
||||
* The Enum DirectionType.
|
||||
*/
|
||||
public enum DirectionType {
|
||||
IMPLICIT,
|
||||
INPUT,
|
||||
OUTPUT,
|
||||
INOUT,
|
||||
BUFFER,
|
||||
LINKAGE;
|
||||
|
||||
public String toString() {
|
||||
switch(this) {
|
||||
case INPUT: return "I";
|
||||
case OUTPUT: return "O";
|
||||
case INOUT: return "IO";
|
||||
case BUFFER: return "B";
|
||||
case LINKAGE: return "L";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2023 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class EmptyWaveform implements IWaveform {
|
||||
|
||||
private String label = "";
|
||||
|
||||
|
||||
public EmptyWaveform() {
|
||||
}
|
||||
|
||||
public EmptyWaveform(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFullName() {
|
||||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
label=name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParent(IHierNode parent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IHierNode getParent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IHierNode> getChildNodes() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChild(IHierNode child) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDerivedWaveform deriveWaveform() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(IHierNode o) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSame(IWaveform other) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEventList getEvents() {
|
||||
return new EventList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent[] getEventsAtTime(long time) {
|
||||
return new IEvent[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent[] getEventsBeforeTime(long time) {
|
||||
return new IEvent[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public WaveformType getType() {
|
||||
return WaveformType.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKind() {
|
||||
return "separator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectionType getDirection() {
|
||||
return DirectionType.IMPLICIT;
|
||||
}
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
package com.minres.scviewer.database;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* The Interface IWaveform.
|
||||
*
|
||||
|
@ -19,6 +19,7 @@ package com.minres.scviewer.database;
|
|||
*/
|
||||
public interface IWaveform extends IHierNode {
|
||||
|
||||
public DirectionType getDirection();
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
|
@ -78,4 +79,11 @@ public interface IWaveform extends IHierNode {
|
|||
*/
|
||||
public int getRowCount();
|
||||
|
||||
/**
|
||||
* Gets the width.
|
||||
*
|
||||
* @return the width
|
||||
*/
|
||||
public int getWidth();
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,11 @@ import java.util.List;
|
|||
*/
|
||||
public interface IWaveformDb extends IHierNode {
|
||||
|
||||
/**
|
||||
* the time scale of the database. This is the exponent of the value i.e. -12 is ps
|
||||
*/
|
||||
public static final int databaseTimeScale = -15;
|
||||
|
||||
/**
|
||||
* Gets the max time.
|
||||
*
|
||||
|
@ -62,4 +67,13 @@ public interface IWaveformDb extends IHierNode {
|
|||
*/
|
||||
public boolean isLoaded();
|
||||
|
||||
/**
|
||||
* close an open database.
|
||||
*
|
||||
* @param inp the inp
|
||||
* @return true, if successful
|
||||
*/
|
||||
public void close();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public interface IWaveformDbLoader {
|
|||
* @param inputFile the input file
|
||||
* @throws InputFormatException the input format exception
|
||||
*/
|
||||
public void load(IWaveformDb db, File inputFile) throws InputFormatException;
|
||||
public void load(File inputFile) throws InputFormatException;
|
||||
|
||||
/**
|
||||
* Gets the max time.
|
||||
|
|
|
@ -20,5 +20,7 @@ public enum WaveformType {
|
|||
/** The transaction. */
|
||||
TRANSACTION,
|
||||
/** The filter. */
|
||||
FILTER
|
||||
FILTER,
|
||||
/** The blank line. */
|
||||
EMPTY
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue