当前位置:网站首页>Use set_ Handler filters out specific SystemC wrapping & error messages
Use set_ Handler filters out specific SystemC wrapping & error messages
2022-07-01 11:45:00 【123axj】
SystemC Defined some warning and error Scene , These scenarios will not report errors when compiling , But in the process of implementation, it will report similar Error: (E554) sc_start called unexpectedly Error of , among E Express Error,W Express warning,554 Is the wrong number ,“sc_start called unexpectedly” Corresponding to the error message Output .
Search in the source code SC_DEFINE_MESSAGE You can find all the defined message Information , And the corresponding error number . The main documents are as follows , The file names are marked with _ids For the end .
#include “sysc/utils/sc_utils_ids.h”
#include “sysc/kernel/sc_kernel_ids.h”
#include “sysc/communication/sc_communication_ids.h”
#include “sysc/datatypes/bit/sc_bit_ids.h”
#include “sysc/datatypes/fx/sc_fx_ids.h”
#include “sysc/datatypes/int/sc_int_ids.h”
#include “sysc/tracing/sc_tracing_ids.h”
about E554, Let's sort out Its code calls the procedure :
stay sc_simcontext.cpp in ,sc_start When called , Meeting check Is it already in running state , If it is , Will execute to SC_REPORT_ERROR This business , That is, it will call sc_core::sc_report_handler::report. You can see here message tpe yes
if( !(status == SC_PAUSED || status == SC_ELABORATION) )
{
SC_REPORT_ERROR(SC_ID_SIMULATION_START_UNEXPECTED_, “”);
return;
}
sc_report.h :
#define SC_REPORT_WARNING( msg_type, msg )
::sc_core::sc_report_handler::report(
::sc_core::SC_WARNING, msg_type, msg, FILE, LINE )
#define SC_REPORT_ERROR( msg_type, msg )
::sc_core::sc_report_handler::report(
::sc_core::SC_ERROR, msg_type, msg, FILE, LINE )

sc_report_handler_proc sc_report_handler::handler =
&sc_report_handler::default_handler;
void sc_report_handler::default_handler(const sc_report& rep,
const sc_actions& actions)
{
if ( actions & SC_DISPLAY )
::std::cout << ::std::endl << sc_report_compose_message(rep) <<
::std::endl;
if ( (actions & SC_LOG) && get_log_file_name() )
{
log_stream.update_file_name(get_log_file_name());
*log_stream << rep.get_time() << ": "
<< sc_report_compose_message(rep) << ::std::endl;
}
if ( actions & SC_STOP )
{
sc_stop_here(rep.get_msg_type(), rep.get_severity());
sc_stop();
}
if ( actions & SC_INTERRUPT )
sc_interrupt_here(rep.get_msg_type(), rep.get_severity());
if ( actions & SC_ABORT )
sc_abort();
if ( actions & SC_THROW ) {
sc_process_b* proc_p = sc_get_current_process_b();
if( proc_p && proc_p->is_unwinding() )
proc_p->clear_unwinding();
throw rep;
}
}
such as , stay https://blog.csdn.net/zgcjaxj/article/details/116210266 Medium In the code void TestPlatform::PrintMessage() in Add a row sc_start(1,SC_NS), Will report Error: (E554) sc_start called unexpectedly In file: …/…/…/src/sysc/kernel/sc_simcontext.cpp:1708 Error of .
Sometimes , We may wish to ignore some SystemC Defined Error perhaps warning, For example E554, Then you can use sc_report_handler::set_handler(user_handler); To replace default_handler, among user_handler For custom handler function , It can be used for specific Warning or Error To filter .
because sc_stop_here / get_log_file_name Equal function is cpp Internal definition or protect type , Cannot be used in custom functions , So once you choose Customize handler function ,log Information cannot be printed to set_log_file_name() Corresponding It's in the document .
#include <iostream>
#include <fstream>
#include "systemc.h"
using namespace std;
using namespace sc_core;
void user_handler(const sc_report &rep,
const sc_actions &actions)
{
if (std::string(rep.get_msg_type()) == "sc_start called unexpectedly")
{
std::cout << " here just bypass the E554" << std::endl;
}
else
{
if (actions & SC_DISPLAY)
::std::cout << ::std::endl
<< sc_report_compose_message(rep) << ::std::endl;
// if ((actions & SC_LOG) && get_log_file_name())
// {
// log_stream.update_file_name(get_log_file_name());
// *log_stream << rep.get_time() << ": "
// << sc_report_compose_message(rep) << ::std::endl;
// }
// if (actions & SC_STOP)
// {
// sc_stop_here(rep.get_msg_type(), rep.get_severity());
// sc_stop();
// }
// if (actions & SC_INTERRUPT)
// sc_interrupt_here(rep.get_msg_type(), rep.get_severity());
if (actions & SC_ABORT)
sc_abort();
// if (actions & SC_THROW)
// {
// sc_process_b *proc_p = sc_get_current_process_b();
// if (proc_p && proc_p->is_unwinding())
// proc_p->clear_unwinding();
// throw rep;
// }
}
}
class TestPlatform
: public sc_module
{
public:
SC_HAS_PROCESS(TestPlatform);
TestPlatform(const sc_module_name &name)
: sc_module(name), m_period(sc_time(1000, SC_PS))
{
SC_THREAD(PrintMessage);
};
public:
void PrintMessage();
~TestPlatform()
{
;
}
public:
sc_time m_period;
};
void TestPlatform::PrintMessage()
{
while (1)
{
sc_start(1, SC_NS);
wait(m_period);
SC_REPORT_INFO_VERB(name(), "this is a SC_LOW info message ", SC_LOW);
SC_REPORT_INFO_VERB(name(), "this is a SC_MEDIUM info message ", SC_MEDIUM);
SC_REPORT_INFO_VERB(name(), "this is a SC_HIGH info message ", SC_HIGH);
SC_REPORT_INFO_VERB(name(), "this is a SC_FULL info message ", SC_FULL);
SC_REPORT_INFO_VERB(name(), "this is a SC_DEBUG info message ", SC_DEBUG);
SC_REPORT_WARNING(name(), "this is a SC_WARNING message "); // SC_WARNING
SC_REPORT_WARNING(name(), "this is a SC_ERROR message ");
SC_REPORT_WARNING(name(), "this is a SC_FATAL message ");
cout << "SC_INFO counter " << sc_report_handler::get_count(SC_INFO) << endl; // Get is SC_INFO Number of lines printed (SC_LOW + SC_MEDIUM + ....)
cout << "SC_WARNING counter " << sc_report_handler::get_count(SC_WARNING) << endl; // Get is SC_WARNINNG Number of lines printed (SC_WARNING * 3 )a
sc_report_handler::stop_after(SC_INFO, 500); // When SC_INFO The number of lines printed has reached 500 That's ok when Just call st_stop()
}
}
int sc_main(int argc, char **argv)
{
TestPlatform *m_platform;
m_platform = new TestPlatform("TestPlatform");
sc_report_handler::set_handler(user_handler);
const char *filename = "./log_file";
sc_report_handler::set_log_file_name(filename);
sc_report_handler::set_actions(SC_INFO, SC_DISPLAY | SC_LOG);
sc_report_handler::suppress(SC_LOG); // Inhibition SC_LOG, That is, do not print to log file
// sc_report_handler::suppress(); // Without any parameters , Used to clear previous suppress
sc_report_handler::force(SC_LOG); // Force open SC_LOG, That is, before this line of code about SC_LOG Of suppress All fail
// sc_report_handler::suppress(SC_DISPLAY);
sc_report_handler::set_verbosity_level(sc_core::SC_MEDIUM); // Set global verbosity level, Only aim at SC_INFO
sc_start(500, SC_NS);
return 0;
}
边栏推荐
- 我在中山,到哪里开户比较好?实际上网上开户安全么?
- redis中value/String
- Ultra detailed black apple installation graphic tutorial sent to EFI configuration collection and system
- 分享psd格式怎么预览的方法和psd文件缩略图插件[通俗易懂]
- Brief analysis of edgedb architecture
- Can solo be accessed through IPv6?
- Istio, ebpf and rsocket Broker: in depth study of service grid
- CPI tutorial - asynchronous interface creation and use
- Tempest HDMI leak receive 3
- Activity workflow engine
猜你喜欢

Tempest HDMI leak receive 5

Istio、eBPF 和 RSocket Broker:深入研究服务网格

S7-1500plc simulation

Dameng data rushes to the scientific innovation board: it plans to raise 2.4 billion yuan. Feng Yucai was once a professor of Huake

Tempest HDMI leak reception 4

Learning summary on June 28, 2022

使用set_handler过滤掉特定的SystemC Wraning &Error Message

CPI tutorial - asynchronous interface creation and use

TEMPEST HDMI泄漏接收 4

Compile and debug net6 source code
随机推荐
solo 可以通过 IPV6 访问吗?
微信小程序开发 – 用户授权登陆「建议收藏」
S7-1500plc simulation
Goldfish rhca memoirs: do447 uses ansible to communicate with API -- using ansible tower API to start jobs
Y48. Chapter III kubernetes from introduction to mastery -- pod status and probe (21)
ABBIRB120工业机器人机械零点位置
开发说,“ 这个不用测,回归正常流程就行 “,测试人员怎么办?
Impressive bug summary (continuously updated)
Getting started with Paxos
How to realize the four isolation levels of MySQL (brief)
Tempest HDMI leak receive 3
Nordic nrf52832 flash download M4 error
2022/6/30学习总结
Shangtang entered the lifting period: the core management voluntarily banned and strengthened the company's long-term value confidence
Redis启动与库进入
Exploration and practice of inress in kubernetes
Tempest HDMI leak reception 4
How does Nike dominate the list all the year round? Here comes the answer to the latest financial report
Flip the array gracefully
我在中山,到哪里开户比较好?实际上网上开户安全么?