- added SQLite back end
- reworked graphical representation to use widgets
This commit is contained in:
152
scv_tr_sqlite/.cproject
Normal file
152
scv_tr_sqlite/.cproject
Normal file
@ -0,0 +1,152 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.macosx.exe.debug.133691581">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.macosx.exe.debug.133691581" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.macosx.exe.debug.133691581" name="Debug" parent="cdt.managedbuild.config.gnu.macosx.exe.debug">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.macosx.exe.debug.133691581." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.macosx.exe.debug.500082514" name="MacOSX GCC" superClass="cdt.managedbuild.toolchain.gnu.macosx.exe.debug">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.macosx.exe.debug.493103663" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.macosx.exe.debug"/>
|
||||
<builder buildPath="${workspace_loc:/scv_tr_sqlite}/Debug" id="cdt.managedbuild.target.gnu.builder.base.214255941" keepEnvironmentInBuildfile="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/>
|
||||
<tool id="cdt.managedbuild.tool.macosx.c.linker.macosx.exe.debug.1022976995" name="MacOS X C Linker" superClass="cdt.managedbuild.tool.macosx.c.linker.macosx.exe.debug"/>
|
||||
<tool command="c++" id="cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.debug.1153644061" name="MacOS X C++ Linker" superClass="cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.debug">
|
||||
<option id="macosx.cpp.link.option.paths.33338975" name="Library search path (-L)" superClass="macosx.cpp.link.option.paths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value="/Users/eyck//Library/Frameworks/SystemC.framework/Versions/2.3.1/lib-macosx64"/>
|
||||
</option>
|
||||
<option id="macosx.cpp.link.option.libs.1238143593" name="Libraries (-l)" superClass="macosx.cpp.link.option.libs" valueType="libs">
|
||||
<listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="systemc"/>
|
||||
<listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="scv"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.macosx.cpp.linker.input.10448631" superClass="cdt.managedbuild.tool.macosx.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.assembler.macosx.exe.debug.1589927489" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.macosx.exe.debug">
|
||||
<option id="gnu.both.asm.option.include.paths.1741076851" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/usr/include"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1649108682" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.archiver.macosx.base.422966961" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.macosx.base"/>
|
||||
<tool command="c++" id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.debug.1149501692" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.debug">
|
||||
<option id="gnu.cpp.compilermacosx.exe.debug.option.optimization.level.1228519118" name="Optimization Level" superClass="gnu.cpp.compilermacosx.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.macosx.exe.debug.option.debugging.level.1854731682" name="Debug Level" superClass="gnu.cpp.compiler.macosx.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.2045160591" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1"/>
|
||||
<listOptionValue builtIn="false" value="/Users/eyck//Library/Frameworks/SystemC.framework/Versions/2.3.1/include"/>
|
||||
<listOptionValue builtIn="false" value="/usr/include"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.506955043" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool command="clang" id="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.1993665797" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.macosx.exe.debug.option.optimization.level.1133705337" name="Optimization Level" superClass="gnu.c.compiler.macosx.exe.debug.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.macosx.exe.debug.option.debugging.level.396108330" name="Debug Level" superClass="gnu.c.compiler.macosx.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.28061496" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/usr/include"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1884051627" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="cdt.managedbuild.config.macosx.exe.release.222902119">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.macosx.exe.release.222902119" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.macosx.exe.release.222902119" name="Release" parent="cdt.managedbuild.config.macosx.exe.release">
|
||||
<folderInfo id="cdt.managedbuild.config.macosx.exe.release.222902119." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.macosx.exe.release.370067321" name="MacOSX GCC" superClass="cdt.managedbuild.toolchain.gnu.macosx.exe.release">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.macosx.exe.release.1613432662" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.macosx.exe.release"/>
|
||||
<builder buildPath="${workspace_loc:/scv_tr_sqlite}/Release" id="cdt.managedbuild.target.gnu.builder.macosx.exe.release.1921784777" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.macosx.exe.release"/>
|
||||
<tool id="cdt.managedbuild.tool.macosx.c.linker.macosx.exe.release.835264205" name="MacOS X C Linker" superClass="cdt.managedbuild.tool.macosx.c.linker.macosx.exe.release"/>
|
||||
<tool id="cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.release.807087528" name="MacOS X C++ Linker" superClass="cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.release">
|
||||
<option id="macosx.cpp.link.option.paths.1094947030" name="Library search path (-L)" superClass="macosx.cpp.link.option.paths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value="/Users/eyck//Library/Frameworks/SystemC.framework/Versions/2.3.1/lib-macosx64"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.macosx.cpp.linker.input.1729026262" superClass="cdt.managedbuild.tool.macosx.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.assembler.macosx.exe.release.960768765" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.macosx.exe.release">
|
||||
<option id="gnu.both.asm.option.include.paths.1211035001" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/usr/include"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1845360319" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.archiver.macosx.base.2005529856" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.macosx.base"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.release.1207281858" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.release">
|
||||
<option id="gnu.cpp.compiler.macosx.exe.release.option.optimization.level.1947685650" name="Optimization Level" superClass="gnu.cpp.compiler.macosx.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.macosx.exe.release.option.debugging.level.1098045969" name="Debug Level" superClass="gnu.cpp.compiler.macosx.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.2920067" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/Users/eyck//Library/Frameworks/SystemC.framework/Versions/2.3.1/include"/>
|
||||
<listOptionValue builtIn="false" value="/usr/include"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.749408456" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.release.2136924185" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.release">
|
||||
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.macosx.exe.release.option.optimization.level.713312654" name="Optimization Level" superClass="gnu.c.compiler.macosx.exe.release.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.macosx.exe.release.option.debugging.level.1629703352" name="Debug Level" superClass="gnu.c.compiler.macosx.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.1878457622" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/usr/include"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.220005104" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="scv_tr_sqlite.cdt.managedbuild.target.macosx.exe.1724881597" name="Executable" projectType="cdt.managedbuild.target.macosx.exe"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.macosx.exe.debug.133691581;cdt.managedbuild.config.gnu.macosx.exe.debug.133691581.;cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.debug.1149501692;cdt.managedbuild.tool.gnu.cpp.compiler.input.506955043">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.macosx.exe.release.222902119;cdt.managedbuild.config.macosx.exe.release.222902119.;cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.release.2136924185;cdt.managedbuild.tool.gnu.c.compiler.input.220005104">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.macosx.exe.debug.133691581;cdt.managedbuild.config.gnu.macosx.exe.debug.133691581.;cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.1993665797;cdt.managedbuild.tool.gnu.c.compiler.input.1884051627">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.macosx.exe.release.222902119;cdt.managedbuild.config.macosx.exe.release.222902119.;cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.release.1207281858;cdt.managedbuild.tool.gnu.cpp.compiler.input.749408456">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
</cproject>
|
3
scv_tr_sqlite/.gitignore
vendored
Normal file
3
scv_tr_sqlite/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/Debug/
|
||||
/my_db.log
|
||||
/my_db.tx
|
27
scv_tr_sqlite/.project
Normal file
27
scv_tr_sqlite/.project
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>scv_tr_sqlite</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
370
scv_tr_sqlite/src/scv_tr_recording_example.cpp
Normal file
370
scv_tr_sqlite/src/scv_tr_recording_example.cpp
Normal file
@ -0,0 +1,370 @@
|
||||
// -*- C++ -*- <this line is for emacs to recognize it as C++ code>
|
||||
/*****************************************************************************
|
||||
|
||||
The following code is derived, directly or indirectly, from the SystemC
|
||||
source code Copyright (c) 1996-2014 by all Contributors.
|
||||
All Rights reserved.
|
||||
|
||||
The contents of this file are subject to the restrictions and limitations
|
||||
set forth in the SystemC Open Source License (the "License");
|
||||
You may not use this file except in compliance with such restrictions and
|
||||
limitations. You may obtain instructions on how to receive a copy of the
|
||||
License at http://www.accellera.org/. Software distributed by Contributors
|
||||
under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
|
||||
ANY KIND, either express or implied. See the License for the specific
|
||||
language governing rights and limitations under the License.
|
||||
|
||||
*****************************************************************************/
|
||||
#include "scv.h"
|
||||
|
||||
// hack to fake a true fifo_mutex
|
||||
#define fifo_mutex sc_mutex
|
||||
|
||||
const unsigned ram_size = 256;
|
||||
|
||||
class rw_task_if: virtual public sc_interface {
|
||||
public:
|
||||
typedef sc_uint<8> addr_t;
|
||||
typedef sc_uint<8> data_t;
|
||||
struct write_t {
|
||||
addr_t addr;
|
||||
data_t data;
|
||||
};
|
||||
|
||||
virtual data_t read(const addr_t*) = 0;
|
||||
virtual void write(const write_t*) = 0;
|
||||
};
|
||||
|
||||
SCV_EXTENSIONS(rw_task_if::write_t){
|
||||
public:
|
||||
scv_extensions<rw_task_if::addr_t> addr;
|
||||
scv_extensions<rw_task_if::data_t> data;
|
||||
SCV_EXTENSIONS_CTOR(rw_task_if::write_t) {
|
||||
SCV_FIELD(addr);
|
||||
SCV_FIELD(data);
|
||||
}
|
||||
};
|
||||
|
||||
class pipelined_bus_ports: public sc_module {
|
||||
public:
|
||||
sc_in<bool> clk;
|
||||
sc_inout<bool> rw;
|
||||
sc_inout<bool> addr_req;
|
||||
sc_inout<bool> addr_ack;
|
||||
sc_inout<sc_uint<8> > bus_addr;
|
||||
sc_inout<bool> data_rdy;
|
||||
sc_inout<sc_uint<8> > bus_data;
|
||||
|
||||
SC_CTOR(pipelined_bus_ports) :
|
||||
clk("clk"), rw("rw"), addr_req("addr_req"), addr_ack("addr_ack"), bus_addr("bus_addr"), data_rdy("data_rdy"), bus_data(
|
||||
"bus_data") {
|
||||
}
|
||||
};
|
||||
|
||||
class rw_pipelined_transactor: public rw_task_if, public pipelined_bus_ports {
|
||||
|
||||
fifo_mutex addr_phase;fifo_mutex data_phase;
|
||||
|
||||
scv_tr_stream pipelined_stream;
|
||||
scv_tr_stream addr_stream;
|
||||
scv_tr_stream data_stream;
|
||||
scv_tr_generator<sc_uint<8>, sc_uint<8> > read_gen;
|
||||
scv_tr_generator<sc_uint<8>, sc_uint<8> > write_gen;
|
||||
scv_tr_generator<sc_uint<8> > addr_gen;
|
||||
scv_tr_generator<_scv_tr_generator_default_data, sc_uint<8> > rdata_gen;
|
||||
scv_tr_generator<sc_uint<8> > wdata_gen;
|
||||
|
||||
public:
|
||||
rw_pipelined_transactor(sc_module_name nm)
|
||||
: pipelined_bus_ports(nm)
|
||||
, addr_phase("addr_phase")
|
||||
, data_phase("data_phase")
|
||||
, pipelined_stream("pipelined_stream", "transactor")
|
||||
, addr_stream( "addr_stream", "transactor")
|
||||
, data_stream("data_stream", "transactor")
|
||||
, read_gen("read", pipelined_stream, "addr", "data")
|
||||
, write_gen("write", pipelined_stream, "addr", "data")
|
||||
, addr_gen("addr", addr_stream, "addr")
|
||||
, rdata_gen("rdata", data_stream, NULL, "data")
|
||||
, wdata_gen("wdata", data_stream, "data")
|
||||
{
|
||||
}
|
||||
virtual data_t read(const addr_t* p_addr);
|
||||
virtual void write(const write_t * req);
|
||||
};
|
||||
|
||||
rw_task_if::data_t rw_pipelined_transactor::read(const addr_t* addr) {
|
||||
addr_phase.lock();
|
||||
scv_tr_handle h = read_gen.begin_transaction(*addr);
|
||||
h.record_attribute("data_size", sizeof(data_t));
|
||||
scv_tr_handle h1 = addr_gen.begin_transaction(*addr, "addr_phase", h);
|
||||
wait(clk->posedge_event());
|
||||
bus_addr = *addr;
|
||||
rw=false;
|
||||
addr_req = 1;
|
||||
wait(addr_ack->posedge_event());
|
||||
wait(clk->negedge_event());
|
||||
addr_req = 0;
|
||||
wait(addr_ack->negedge_event());
|
||||
addr_gen.end_transaction(h1);
|
||||
addr_phase.unlock();
|
||||
|
||||
data_phase.lock();
|
||||
scv_tr_handle h2 = rdata_gen.begin_transaction("data_phase", h);
|
||||
wait(data_rdy->posedge_event());
|
||||
data_t data = bus_data.read();
|
||||
wait(data_rdy->negedge_event());
|
||||
rdata_gen.end_transaction(h2, data);
|
||||
read_gen.end_transaction(h, data);
|
||||
data_phase.unlock();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void rw_pipelined_transactor::write(const write_t * req) {
|
||||
addr_phase.lock();
|
||||
scv_tr_handle h = write_gen.begin_transaction(req->addr);
|
||||
h.record_attribute("data_size", sizeof(data_t));
|
||||
scv_tr_handle h1 = addr_gen.begin_transaction(req->addr, "addr_phase", h);
|
||||
wait(clk->posedge_event());
|
||||
bus_addr = req->addr;
|
||||
rw=true;
|
||||
addr_req = 1;
|
||||
wait(addr_ack->posedge_event());
|
||||
wait(clk->negedge_event());
|
||||
addr_req = 0;
|
||||
wait(addr_ack->negedge_event());
|
||||
addr_gen.end_transaction(h1);
|
||||
addr_phase.unlock();
|
||||
|
||||
data_phase.lock();
|
||||
scv_tr_handle h2 = wdata_gen.begin_transaction(req->data, "data_phase", h);
|
||||
bus_data=req->data;
|
||||
wait(data_rdy->posedge_event());
|
||||
wait(data_rdy->negedge_event());
|
||||
wdata_gen.end_transaction(h2);
|
||||
write_gen.end_transaction(h, req->data);
|
||||
data_phase.unlock();
|
||||
}
|
||||
|
||||
class test: public sc_module {
|
||||
public:
|
||||
sc_port<rw_task_if> transactor;
|
||||
SC_HAS_PROCESS(test);
|
||||
test( ::sc_core::sc_module_name ){
|
||||
SC_THREAD(main1);
|
||||
SC_THREAD(main2);
|
||||
}
|
||||
void main1();
|
||||
void main2();
|
||||
};
|
||||
|
||||
class write_constraint: virtual public scv_constraint_base {
|
||||
public:
|
||||
scv_smart_ptr<rw_task_if::write_t> write;SCV_CONSTRAINT_CTOR(write_constraint) {
|
||||
SCV_CONSTRAINT(write->addr() <= ram_size);
|
||||
SCV_CONSTRAINT(write->addr() != write->data());
|
||||
}
|
||||
};
|
||||
|
||||
inline void process(scv_smart_ptr<int> data) {
|
||||
}
|
||||
|
||||
inline void test::main1() {
|
||||
// simple sequential tests
|
||||
for (int i = 0; i < 3; i++) {
|
||||
rw_task_if::addr_t addr = i;
|
||||
rw_task_if::data_t data = transactor->read(&addr);
|
||||
cout << "at time " << sc_time_stamp() << ": ";
|
||||
cout << "received data : " << data << endl;
|
||||
}
|
||||
|
||||
scv_smart_ptr<rw_task_if::addr_t> addr;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
addr->next();
|
||||
rw_task_if::data_t data = transactor->read(addr->get_instance());
|
||||
cout << "data for address " << *addr << " is " << data << endl;
|
||||
}
|
||||
|
||||
scv_smart_ptr<rw_task_if::write_t> write;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
write->next();
|
||||
transactor->write(write->get_instance());
|
||||
cout << "send data : " << write->data << endl;
|
||||
}
|
||||
|
||||
scv_smart_ptr<int> data;
|
||||
scv_bag<int> distribution;
|
||||
distribution.push(1, 40);
|
||||
distribution.push(2, 60);
|
||||
data->set_mode(distribution);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
data->next();
|
||||
process(data);
|
||||
}
|
||||
}
|
||||
|
||||
inline void test::main2() {
|
||||
// simple sequential tests
|
||||
for (int i = 0; i < 3; i++) {
|
||||
rw_task_if::addr_t addr = i;
|
||||
rw_task_if::data_t data = transactor->read(&addr);
|
||||
cout << "at time " << sc_time_stamp() << ": ";
|
||||
cout << "received data : " << data << endl;
|
||||
}
|
||||
|
||||
scv_smart_ptr<rw_task_if::addr_t> addr;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
addr->next();
|
||||
rw_task_if::data_t data = transactor->read(addr->get_instance());
|
||||
cout << "data for address " << *addr << " is " << data << endl;
|
||||
}
|
||||
|
||||
scv_smart_ptr<rw_task_if::write_t> write;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
write->next();
|
||||
transactor->write(write->get_instance());
|
||||
cout << "send data : " << write->data << endl;
|
||||
}
|
||||
|
||||
scv_smart_ptr<int> data;
|
||||
scv_bag<int> distribution;
|
||||
distribution.push(1, 140);
|
||||
distribution.push(2, 160);
|
||||
data->set_mode(distribution);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
data->next();
|
||||
process(data);
|
||||
}
|
||||
}
|
||||
class design: public pipelined_bus_ports {
|
||||
std::list<sc_uint<8> > outstandingAddresses;
|
||||
std::list<bool> outstandingType;
|
||||
sc_uint<8> memory[ram_size];
|
||||
|
||||
public:
|
||||
SC_HAS_PROCESS(design);
|
||||
design(sc_module_name nm) :
|
||||
pipelined_bus_ports(nm) {
|
||||
for (unsigned i = 0; i < ram_size; ++i) {
|
||||
memory[i] = i;
|
||||
}
|
||||
SC_THREAD(addr_phase);
|
||||
SC_THREAD(data_phase);
|
||||
}
|
||||
void addr_phase();
|
||||
void data_phase();
|
||||
};
|
||||
|
||||
inline void design::addr_phase() {
|
||||
while (1) {
|
||||
while (addr_req.read() != 1) {
|
||||
wait(addr_req->value_changed_event());
|
||||
}
|
||||
sc_uint<8> _addr = bus_addr.read();
|
||||
bool _rw = rw.read();
|
||||
|
||||
int cycle = rand() % 10 + 1;
|
||||
while (cycle-- > 0) {
|
||||
wait(clk->posedge_event());
|
||||
}
|
||||
|
||||
addr_ack = 1;
|
||||
wait(clk->posedge_event());
|
||||
addr_ack = 0;
|
||||
|
||||
outstandingAddresses.push_back(_addr);
|
||||
outstandingType.push_back(_rw);
|
||||
cout << "at time " << sc_time_stamp() << ": ";
|
||||
cout << "received request for memory address " << _addr << endl;
|
||||
}
|
||||
}
|
||||
|
||||
inline void design::data_phase() {
|
||||
while (1) {
|
||||
while (outstandingAddresses.empty()) {
|
||||
wait(clk->posedge_event());
|
||||
}
|
||||
int cycle = rand() % 10 + 1;
|
||||
while (cycle-- > 0) {
|
||||
wait(clk->posedge_event());
|
||||
}
|
||||
if (outstandingType.front() == false) {
|
||||
cout << "reading memory address " << outstandingAddresses.front() << " with value "
|
||||
<< memory[outstandingAddresses.front().to_ulong()] << endl;
|
||||
bus_data = memory[outstandingAddresses.front().to_ulong()];
|
||||
data_rdy = 1;
|
||||
wait(clk->posedge_event());
|
||||
data_rdy = 0;
|
||||
|
||||
} else {
|
||||
cout << "writing memory address " << outstandingAddresses.front() << " with value "
|
||||
<< bus_data << endl;
|
||||
memory[outstandingAddresses.front().to_ulong()]=bus_data;
|
||||
data_rdy = 1;
|
||||
wait(clk->posedge_event());
|
||||
data_rdy = 0;
|
||||
}
|
||||
outstandingAddresses.pop_front();
|
||||
outstandingType.pop_front();
|
||||
}
|
||||
}
|
||||
extern void scv_tr_sqlite_init();
|
||||
|
||||
int sc_main(int argc, char *argv[]) {
|
||||
scv_startup();
|
||||
|
||||
#if 0
|
||||
scv_tr_text_init();
|
||||
const char* fileName = "my_db.log";
|
||||
#else
|
||||
scv_tr_sqlite_init();
|
||||
const char* fileName = "my_db";
|
||||
#endif
|
||||
scv_tr_db db(fileName);
|
||||
scv_tr_db::set_default_db(&db);
|
||||
|
||||
// create signals
|
||||
sc_clock clk("clk", 20.0, SC_NS, 0.5, 0.0, SC_NS, true);
|
||||
sc_signal<bool> rw;
|
||||
sc_signal<bool> addr_req;
|
||||
sc_signal<bool> addr_ack;
|
||||
sc_signal<sc_uint<8> > bus_addr;
|
||||
sc_signal<bool> data_rdy;
|
||||
sc_signal<sc_uint<8> > bus_data;
|
||||
|
||||
// create modules/channels
|
||||
test t("t");
|
||||
rw_pipelined_transactor tr("tr");
|
||||
design duv("duv");
|
||||
|
||||
// connect them up
|
||||
t.transactor(tr);
|
||||
|
||||
tr.clk(clk);
|
||||
tr.rw(rw);
|
||||
tr.addr_req(addr_req);
|
||||
tr.addr_ack(addr_ack);
|
||||
tr.bus_addr(bus_addr);
|
||||
tr.data_rdy(data_rdy);
|
||||
tr.bus_data(bus_data);
|
||||
|
||||
duv.clk(clk);
|
||||
duv.rw(rw);
|
||||
duv.addr_req(addr_req);
|
||||
duv.addr_ack(addr_ack);
|
||||
duv.bus_addr(bus_addr);
|
||||
duv.data_rdy(data_rdy);
|
||||
duv.bus_data(bus_data);
|
||||
|
||||
// Accellera SystemC >=2.2 got picky about multiple drivers.
|
||||
// Disable check for bus simulation.
|
||||
sc_report_handler::set_actions(SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, SC_DO_NOTHING);
|
||||
// run the simulation
|
||||
sc_start(1.0, SC_MS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
336
scv_tr_sqlite/src/scv_tr_sqlite.cpp
Normal file
336
scv_tr_sqlite/src/scv_tr_sqlite.cpp
Normal file
@ -0,0 +1,336 @@
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include "scv/scv_util.h"
|
||||
#include "scv/scv_introspection.h"
|
||||
#include "scv/scv_tr.h"
|
||||
#include "sqlite3.h"
|
||||
// ----------------------------------------------------------------------------
|
||||
#define SQLITEWRAPPER_ERROR 1000
|
||||
// ----------------------------------------------------------------------------
|
||||
using namespace std;
|
||||
|
||||
struct SQLiteDB {
|
||||
struct SQLiteException : public runtime_error{
|
||||
SQLiteException(const int nErrCode, const char* msg, bool doFree=true)
|
||||
: runtime_error(msg), mnErrCode(0){
|
||||
if (doFree && msg) sqlite3_free(const_cast<char*>(msg));
|
||||
}
|
||||
virtual ~SQLiteException()_NOEXCEPT {}
|
||||
const int errorCode() { return mnErrCode; }
|
||||
const char* errorMessage() { return what(); }
|
||||
private:
|
||||
int mnErrCode;
|
||||
};
|
||||
|
||||
SQLiteDB():busyTimeoutMs(60000), db(NULL){}
|
||||
|
||||
void open(const string szFile){
|
||||
int nRet = sqlite3_open(szFile.c_str(), &db);
|
||||
if (nRet != SQLITE_OK) throw SQLiteException(nRet, sqlite3_errmsg(db), false);
|
||||
sqlite3_busy_timeout(db, busyTimeoutMs);
|
||||
}
|
||||
|
||||
inline
|
||||
bool isOpen(){return db!=NULL;}
|
||||
|
||||
void close(){
|
||||
if (db){
|
||||
if (sqlite3_close(db) == SQLITE_OK)
|
||||
db = 0;
|
||||
else
|
||||
throw SQLiteException(SQLITEWRAPPER_ERROR, "Unable to close database", false);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
int exec(const string szSQL){return exec(szSQL.c_str());};
|
||||
|
||||
int exec(const char* szSQL){
|
||||
checkDB();
|
||||
char* szError=0;
|
||||
int nRet = sqlite3_exec(db, szSQL, 0, 0, &szError);
|
||||
if (nRet == SQLITE_OK)
|
||||
return sqlite3_changes(db);
|
||||
else
|
||||
throw SQLiteException(nRet, szError);
|
||||
}
|
||||
protected:
|
||||
inline void checkDB(){
|
||||
if (!db) throw SQLiteException(SQLITEWRAPPER_ERROR, "Database not open", false);
|
||||
}
|
||||
|
||||
private:
|
||||
int busyTimeoutMs;
|
||||
sqlite3* db;
|
||||
};
|
||||
// ----------------------------------------------------------------------------
|
||||
static SQLiteDB db;
|
||||
static ostringstream stringBuilder, queryBuilder;
|
||||
// ----------------------------------------------------------------------------
|
||||
enum EventType {BEGIN, RECORD, END};
|
||||
typedef scv_extensions_if::data_type data_type;
|
||||
// ----------------------------------------------------------------------------
|
||||
#define SIM_PROPS "ScvSimProps"
|
||||
#define STREAM_TABLE "ScvStream"
|
||||
#define GENERATOR_TABLE "ScvGenerator"
|
||||
#define TX_TABLE "ScvTx"
|
||||
#define TX_EVENT_TABLE "ScvTxEvent"
|
||||
#define TX_ATTRIBUTE_TABLE "ScvTxAttribute"
|
||||
#define TX_RELATION_TABLE "ScvTxRelation"
|
||||
|
||||
static void dbCb(const scv_tr_db& _scv_tr_db, scv_tr_db::callback_reason reason, void* data) {
|
||||
// This is called from the scv_tr_db ctor.
|
||||
static string my_sqlite_file_name("DEFAULT_scv_tr_sqlite");
|
||||
switch (reason) {
|
||||
case scv_tr_db::CREATE:
|
||||
if ((_scv_tr_db.get_name() != NULL) && (strlen(_scv_tr_db.get_name()) != 0)) {
|
||||
my_sqlite_file_name = _scv_tr_db.get_name();
|
||||
}
|
||||
try {
|
||||
my_sqlite_file_name+=".tx";
|
||||
remove(my_sqlite_file_name.c_str());
|
||||
db.open(my_sqlite_file_name.c_str());
|
||||
// scv_out << "TB Transaction Recording has started, file = " << my_sqlite_file_name << endl;
|
||||
db.exec("CREATE TABLE IF NOT EXISTS " STREAM_TABLE "(id INTEGER NOT NULL PRIMARY KEY, name TEXT, kind TEXT);");
|
||||
db.exec("CREATE TABLE IF NOT EXISTS " GENERATOR_TABLE "(id INTEGER NOT NULL PRIMARY KEY, stream INTEGER REFERENCES " STREAM_TABLE "(id), name TEXT, begin_attr INTEGER, end_attr INTEGER);");
|
||||
db.exec("CREATE TABLE IF NOT EXISTS " TX_TABLE "(id INTEGER NOT NULL PRIMARY KEY, generator INTEGER REFERENCES " GENERATOR_TABLE "(id), stream INTEGER REFERENCES " STREAM_TABLE "(id));");
|
||||
db.exec("CREATE TABLE IF NOT EXISTS " TX_EVENT_TABLE "(tx INTEGER REFERENCES " TX_TABLE "(id), type INTEGER, time INTEGER);");
|
||||
db.exec("CREATE TABLE IF NOT EXISTS " TX_ATTRIBUTE_TABLE "(tx INTEGER REFERENCES " TX_TABLE "(id), type INTEGER, name TEXT, data_type INTEGER, data_value TEXT);");
|
||||
db.exec("CREATE TABLE IF NOT EXISTS " TX_RELATION_TABLE "(name TEXT, src INTEGER REFERENCES " TX_TABLE "(id), sink INTEGER REFERENCES " TX_TABLE "(id));");
|
||||
db.exec("CREATE TABLE IF NOT EXISTS " SIM_PROPS "(time_resolution INTEGER);");
|
||||
queryBuilder.str("");
|
||||
queryBuilder << "INSERT INTO " SIM_PROPS " (time_resolution) values ("
|
||||
<< (long)(sc_get_time_resolution().to_seconds()*1e15) << ");";
|
||||
db.exec(queryBuilder.str().c_str());
|
||||
} catch (SQLiteDB::SQLiteException& e) {
|
||||
_scv_message::message(_scv_message::TRANSACTION_RECORDING_INTERNAL, "Can't open recording file");
|
||||
}
|
||||
break;
|
||||
case scv_tr_db::DELETE:
|
||||
try {
|
||||
// scv_out << "Transaction Recording is closing file: " << my_sqlite_file_name << endl;
|
||||
db.close();
|
||||
} catch (SQLiteDB::SQLiteException& e) {
|
||||
_scv_message::message(_scv_message::TRANSACTION_RECORDING_INTERNAL, "Can't close recording file");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_scv_message::message(_scv_message::TRANSACTION_RECORDING_INTERNAL, "Unknown reason in scv_tr_db callback");
|
||||
}
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
static void streamCb(const scv_tr_stream& s, scv_tr_stream::callback_reason reason, void* data) {
|
||||
if (reason == scv_tr_stream::CREATE && db.isOpen()) {
|
||||
try {
|
||||
queryBuilder.str("");
|
||||
queryBuilder << "INSERT INTO " STREAM_TABLE " (id, name, kind) values (" << s.get_id() << ",'" << s.get_name() << "','"
|
||||
<< (s.get_stream_kind() ? s.get_stream_kind() : "<unnamed>") << "');";
|
||||
db.exec(queryBuilder.str().c_str());
|
||||
} catch (SQLiteDB::SQLiteException& e) {
|
||||
_scv_message::message(_scv_message::TRANSACTION_RECORDING_INTERNAL, "Can't create stream");
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
void recordAttribute(uint64_t id, EventType event, const string& name, data_type type, const string& value) {
|
||||
try {
|
||||
queryBuilder.str("");
|
||||
queryBuilder << "INSERT INTO " TX_ATTRIBUTE_TABLE " (tx,type,name,data_type,data_value)" << " values ("
|
||||
<< id << "," << event << ",'"<< name << "'," << type << ",'" << value << "');";
|
||||
db.exec(queryBuilder.str().c_str());
|
||||
} catch (SQLiteDB::SQLiteException& e) {
|
||||
_scv_message::message(_scv_message::TRANSACTION_RECORDING_INTERNAL, "Can't create attribute entry");
|
||||
}
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
inline
|
||||
void recordAttribute(uint64_t id, EventType event, const string& name, data_type type, long long value) {
|
||||
stringBuilder.str("");
|
||||
stringBuilder <<value;
|
||||
recordAttribute(id,event,name,type,stringBuilder.str());
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
inline
|
||||
void recordAttribute(uint64_t id, EventType event, const string& name, data_type type, double value) {
|
||||
stringBuilder.str("");
|
||||
stringBuilder <<value;
|
||||
recordAttribute(id,event,name,type,stringBuilder.str());
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
static void recordAttributes(uint64_t id, EventType eventType, string& prefix, const scv_extensions_if* my_exts_p){
|
||||
if (my_exts_p == 0) return;
|
||||
string name;
|
||||
if (prefix == "") {
|
||||
name = my_exts_p->get_name();
|
||||
} else {
|
||||
if ((my_exts_p->get_name() == 0) || (strlen(my_exts_p->get_name()) == 0)) {
|
||||
name = prefix;
|
||||
} else {
|
||||
name = prefix + "." + my_exts_p->get_name();
|
||||
}
|
||||
}
|
||||
if (name == "") name = "<unnamed>";
|
||||
switch (my_exts_p->get_type()) {
|
||||
case scv_extensions_if::RECORD:
|
||||
{
|
||||
int num_fields = my_exts_p->get_num_fields();
|
||||
if (num_fields > 0) {
|
||||
for (int field_counter = 0; field_counter < num_fields; field_counter++) {
|
||||
const scv_extensions_if* field_data_p = my_exts_p->get_field(field_counter);
|
||||
recordAttributes(id, eventType, prefix, field_data_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case scv_extensions_if::ENUMERATION:
|
||||
recordAttribute(id, eventType, name, scv_extensions_if::ENUMERATION, my_exts_p->get_enum_string((int) (my_exts_p->get_integer())));
|
||||
break;
|
||||
case scv_extensions_if::BOOLEAN:
|
||||
recordAttribute(id, eventType, name, scv_extensions_if::BOOLEAN, my_exts_p->get_bool()?"TRUE":"FALSE");
|
||||
break;
|
||||
case scv_extensions_if::INTEGER:
|
||||
case scv_extensions_if::FIXED_POINT_INTEGER:
|
||||
recordAttribute(id, eventType, name, scv_extensions_if::INTEGER, my_exts_p->get_integer());
|
||||
break;
|
||||
case scv_extensions_if::UNSIGNED:
|
||||
recordAttribute(id, eventType, name, scv_extensions_if::UNSIGNED, my_exts_p->get_integer());
|
||||
break;
|
||||
case scv_extensions_if::POINTER:
|
||||
recordAttribute(id, eventType, name, scv_extensions_if::POINTER, (long long)my_exts_p->get_pointer());
|
||||
break;
|
||||
case scv_extensions_if::STRING:
|
||||
recordAttribute(id, eventType, name, scv_extensions_if::STRING, my_exts_p->get_string());
|
||||
break;
|
||||
case scv_extensions_if::FLOATING_POINT_NUMBER:
|
||||
recordAttribute(id, eventType, name, scv_extensions_if::FLOATING_POINT_NUMBER, my_exts_p->get_double());
|
||||
break;
|
||||
case scv_extensions_if::BIT_VECTOR:
|
||||
{
|
||||
sc_bv_base tmp_bv(my_exts_p->get_bitwidth());
|
||||
my_exts_p->get_value(tmp_bv);
|
||||
recordAttribute(id, eventType, name, scv_extensions_if::BIT_VECTOR, tmp_bv.to_string());
|
||||
}
|
||||
break;
|
||||
case scv_extensions_if::LOGIC_VECTOR:
|
||||
{
|
||||
sc_lv_base tmp_lv(my_exts_p->get_bitwidth());
|
||||
my_exts_p->get_value(tmp_lv);
|
||||
recordAttribute(id, eventType, name, scv_extensions_if::LOGIC_VECTOR, tmp_lv.to_string());
|
||||
}
|
||||
break;
|
||||
case scv_extensions_if::ARRAY:
|
||||
for (int array_elt_index = 0; array_elt_index < my_exts_p->get_array_size(); array_elt_index++) {
|
||||
const scv_extensions_if* field_data_p = my_exts_p->get_array_elt(array_elt_index);
|
||||
recordAttributes(id, eventType, prefix, field_data_p);
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
char tmpString[100];
|
||||
sprintf(tmpString, "Unsupported attribute type = %d", my_exts_p->get_type());
|
||||
_scv_message::message(_scv_message::TRANSACTION_RECORDING_INTERNAL, tmpString);
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
static void generatorCb(const scv_tr_generator_base& g, scv_tr_generator_base::callback_reason reason, void* data) {
|
||||
if (reason == scv_tr_generator_base::CREATE && db.isOpen()) {
|
||||
try {
|
||||
queryBuilder.str("");
|
||||
queryBuilder << "INSERT INTO " GENERATOR_TABLE " (id,stream, name)"
|
||||
<<" values (" << g.get_id() << ","<<g.get_scv_tr_stream().get_id()<<",'" << g.get_name() << "');";
|
||||
db.exec(queryBuilder.str().c_str());
|
||||
} catch (SQLiteDB::SQLiteException& e) {
|
||||
_scv_message::message(_scv_message::TRANSACTION_RECORDING_INTERNAL, "Can't create generator entry");
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
static void transactionCb(const scv_tr_handle& t, scv_tr_handle::callback_reason reason, void* data) {
|
||||
if (!db.isOpen()) return;
|
||||
if (t.get_scv_tr_stream().get_scv_tr_db() == NULL) return;
|
||||
if (t.get_scv_tr_stream().get_scv_tr_db()->get_recording() == false) return;
|
||||
|
||||
const scv_extensions_if* my_exts_p;
|
||||
switch (reason) {
|
||||
case scv_tr_handle::BEGIN:{
|
||||
try {
|
||||
queryBuilder.str("");
|
||||
queryBuilder << "INSERT INTO " TX_TABLE " (id,generator,stream)" << " values (" << t.get_id() << "," << t.get_scv_tr_generator_base().get_id()
|
||||
<<","<<t.get_scv_tr_stream().get_id()<< ");";
|
||||
db.exec(queryBuilder.str().c_str());
|
||||
|
||||
queryBuilder.str("");
|
||||
queryBuilder << "INSERT INTO " TX_EVENT_TABLE " (tx,type,time)" << " values (" << t.get_id() << "," << BEGIN << ","
|
||||
<< t.get_begin_sc_time().value() << ");";
|
||||
db.exec(queryBuilder.str().c_str());
|
||||
|
||||
} catch (SQLiteDB::SQLiteException& e) {
|
||||
_scv_message::message(_scv_message::TRANSACTION_RECORDING_INTERNAL, e.errorMessage());
|
||||
}
|
||||
my_exts_p = t.get_begin_exts_p();
|
||||
if (my_exts_p == NULL) {
|
||||
my_exts_p = t.get_scv_tr_generator_base().get_begin_exts_p();
|
||||
}
|
||||
string tmp_str =
|
||||
t.get_scv_tr_generator_base().get_begin_attribute_name() ? t.get_scv_tr_generator_base().get_begin_attribute_name() : "";
|
||||
recordAttributes(t.get_id(), BEGIN, tmp_str, my_exts_p);
|
||||
} break;
|
||||
case scv_tr_handle::END:{
|
||||
try {
|
||||
queryBuilder.str("");
|
||||
queryBuilder << "INSERT INTO " TX_EVENT_TABLE " (tx,type,time)" << " values (" << t.get_id() << "," << END << ","
|
||||
<< t.get_end_sc_time().value() << ");";
|
||||
db.exec(queryBuilder.str().c_str());
|
||||
|
||||
} catch (SQLiteDB::SQLiteException& e) {
|
||||
_scv_message::message(_scv_message::TRANSACTION_RECORDING_INTERNAL, "Can't create transaction end");
|
||||
}
|
||||
my_exts_p = t.get_end_exts_p();
|
||||
if (my_exts_p == NULL) {
|
||||
my_exts_p = t.get_scv_tr_generator_base().get_end_exts_p();
|
||||
}
|
||||
string tmp_str =
|
||||
t.get_scv_tr_generator_base().get_end_attribute_name() ? t.get_scv_tr_generator_base().get_end_attribute_name() : "";
|
||||
recordAttributes(t.get_id(), END, tmp_str, my_exts_p);
|
||||
} break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
static void attributeCb(const scv_tr_handle& t, const char* name, const scv_extensions_if* ext, void* data) {
|
||||
if (!db.isOpen()) return;
|
||||
if (t.get_scv_tr_stream().get_scv_tr_db() == NULL) return;
|
||||
if (t.get_scv_tr_stream().get_scv_tr_db()->get_recording() == false) return;
|
||||
string tmp_str(name == 0?"":name);
|
||||
recordAttributes(t.get_id(), RECORD, tmp_str, ext);
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
static void relationCb(const scv_tr_handle& tr_1, const scv_tr_handle& tr_2, void* data,
|
||||
scv_tr_relation_handle_t relation_handle) {
|
||||
if (!db.isOpen()) return;
|
||||
if (tr_1.get_scv_tr_stream().get_scv_tr_db() == NULL) return;
|
||||
if (tr_1.get_scv_tr_stream().get_scv_tr_db()->get_recording() == false) return;
|
||||
try {
|
||||
queryBuilder.str("");
|
||||
queryBuilder << "INSERT INTO " TX_RELATION_TABLE " (name,src,sink)"
|
||||
<< "values ('" << tr_1.get_scv_tr_stream().get_scv_tr_db()->get_relation_name(relation_handle) << "',"
|
||||
<< tr_1.get_id() << ","<< tr_2.get_id() << ");";
|
||||
db.exec(queryBuilder.str().c_str());
|
||||
|
||||
} catch (SQLiteDB::SQLiteException& e) {
|
||||
_scv_message::message(_scv_message::TRANSACTION_RECORDING_INTERNAL, "Can't create transaction relation");
|
||||
}
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
void scv_tr_sqlite_init() {
|
||||
scv_tr_db::register_class_cb(dbCb);
|
||||
scv_tr_stream::register_class_cb(streamCb);
|
||||
scv_tr_generator_base::register_class_cb(generatorCb);
|
||||
scv_tr_handle::register_class_cb(transactionCb);
|
||||
scv_tr_handle::register_record_attribute_cb(attributeCb);
|
||||
scv_tr_handle::register_relation_cb(relationCb);
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
|
153091
scv_tr_sqlite/src/sqlite3.c
Normal file
153091
scv_tr_sqlite/src/sqlite3.c
Normal file
File diff suppressed because it is too large
Load Diff
7695
scv_tr_sqlite/src/sqlite3.h
Normal file
7695
scv_tr_sqlite/src/sqlite3.h
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user