adds test for tracing of sc_fixed datatypes

This commit is contained in:
Eyck Jentzsch 2024-10-10 12:53:33 +02:00
parent 9a41d1ac80
commit 12f3ecd6f3
5 changed files with 90 additions and 4 deletions

View File

@ -14,7 +14,7 @@
</extensions> </extensions>
</storageModule> </storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="cmake4eclipse.mbs.toolchain.cmake.134761605" name="Debug" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=" parent="org.eclipse.cdt.build.core.emptycfg"> <configuration artifactName="${ProjName}" buildProperties="" description="" id="cmake4eclipse.mbs.toolchain.cmake.134761605" name="Debug" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=" parent="org.eclipse.cdt.build.core.emptycfg">
<folderInfo id="cmake4eclipse.mbs.toolchain.cmake.134761605.1159094612" name="/" resourcePath=""> <folderInfo id="cmake4eclipse.mbs.toolchain.cmake.134761605.1159094612" name="/" resourcePath="">
<toolChain id="cmake4eclipse.mbs.toolchain.cmake.1883503430" name="CMake driven" superClass="cmake4eclipse.mbs.toolchain.cmake"> <toolChain id="cmake4eclipse.mbs.toolchain.cmake.1883503430" name="CMake driven" superClass="cmake4eclipse.mbs.toolchain.cmake">
<targetPlatform id="cmake4eclipse.mbs.targetPlatform.cmake.1279728098" name="Any Platform" superClass="cmake4eclipse.mbs.targetPlatform.cmake"/> <targetPlatform id="cmake4eclipse.mbs.targetPlatform.cmake.1279728098" name="Any Platform" superClass="cmake4eclipse.mbs.targetPlatform.cmake"/>
@ -28,8 +28,8 @@
</configuration> </configuration>
</storageModule> </storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
<storageModule buildDir="build/${ConfigName}" dirtyTs="1715065528068" moduleId="de.marw.cmake4eclipse.mbs.settings"> <storageModule buildDir="build/${ConfigName}" dirtyTs="1728554089717" moduleId="de.marw.cmake4eclipse.mbs.settings">
<options/> <options otherArguments="--preset Debug"/>
<defs> <defs>
<def name="CMAKE_BUILD_TYPE" type="STRING" val="Debug"/> <def name="CMAKE_BUILD_TYPE" type="STRING" val="Debug"/>
<def name="BUILD_SCC_DOCUMENTATION" type="BOOL" val="OFF"/> <def name="BUILD_SCC_DOCUMENTATION" type="BOOL" val="OFF"/>

2
scc

@ -1 +1 @@
Subproject commit 010aac102a7bfda042debf09c51981ee55c723ac Subproject commit 966e575aba7f2f4ffc8a422d522f7173c4c7d98c

View File

@ -7,6 +7,7 @@ add_subdirectory(axi4_pin_level)
add_subdirectory(ace_pin_level) add_subdirectory(ace_pin_level)
add_subdirectory(configuration) add_subdirectory(configuration)
add_subdirectory(configurer) add_subdirectory(configurer)
add_subdirectory(sc_fixed_tracing)
if(FULL_TEST_SUITE) if(FULL_TEST_SUITE)
add_subdirectory(sim_performance) add_subdirectory(sim_performance)
endif() endif()

View File

@ -0,0 +1,3 @@
add_executable (sc_fixed_tracing sc_main.cpp)
target_link_libraries (sc_fixed_tracing LINK_PUBLIC scc-sysc)
add_test(NAME sc_fixed_tracing_test COMMAND sc_fixed_tracing )

View File

@ -0,0 +1,82 @@
#define SC_INCLUDE_FX
#include <scc/cci_util.h>
#include <scc/configurer.h>
#include <scc/observer.h>
#include <scc/sc_variable.h>
#include <scc/tracer.h>
#include <string>
#include <systemc>
using namespace sc_dt;
using namespace std;
struct testbench : public sc_core::sc_module {
scc::sc_variable<sc_dt::sc_fixed<6, 4>> a{"a", sc_dt::sc_fixed<6, 4>()};
scc::sc_variable<sc_fixed<4, 2, SC_RND, SC_SAT>> b_sc_sat{"b_sc_sat", 0};
scc::sc_variable<sc_fixed<8, 3>> a_qant{"a_qant", 0};
scc::sc_variable<sc_fixed<5, 3, SC_RND>> b_sc_rnd{"b_sc_rnd", 0};
scc::sc_variable<sc_fixed<5, 3, SC_TRN>> b_sc_trn{"b_sc_trn", 0};
sc_fixed<5, 3> a_fixed;
sc_dt::sc_fix a_fix{5, 3};
sc_fxtype_params params{5, 4};
sc_fxtype_context context{params};
// becase we do not specify in b_fix constructor anything
// the parameters are taken form the latest created context
sc_fix b_fix;
sc_fix c_fix{5, 3};
testbench(sc_core::sc_module_name const& nm)
: sc_module(nm) {
SC_HAS_PROCESS(testbench);
SC_THREAD(run);
}
void trace(sc_core::sc_trace_file* trf) const override {
a.trace(trf);
scc::sc_trace(trf, a_fixed, std::string(name()) + ".a_fixed");
scc::sc_trace(trf, a_fix, std::string(name()) + ".a_fix");
scc::sc_trace(trf, b_fix, std::string(name()) + ".b_fix");
scc::sc_trace(trf, c_fix, std::string(name()) + ".c_fix");
}
void run() {
wait(1_ns);
init();
wait(1_ns);
test_overflow_modes();
wait(1_ns);
test_quantization_modes();
wait(1_ns);
this->a = 2;
wait(1_ps);
sc_core::sc_stop();
}
void init() {
a_fixed = 1.75;
a_fix = 1.75;
b_fix = 1.75;
c_fix = 1.75;
}
void test_overflow_modes() {
a = -7;
b_sc_sat = *a;
}
void test_quantization_modes() {
a_qant = -2.3125;
b_sc_rnd = *a_qant;
b_sc_trn = *a_qant;
}
};
int sc_main(int sc_argc, char* sc_argv[]) {
scc::init_logging(scc::log::INFO);
scc::configurer cfg("");
scc::tracer trc("sc_fixed_tracing");
testbench tb("tb");
sc_core::sc_start();
SCCINFO("sc_main") << "End Simulation.";
return sc_core::sc_report_handler::get_count(sc_core::SC_ERROR) + sc_core::sc_report_handler::get_count(sc_core::SC_WARNING);
} // End of 'sc_main'