Aaron0127 Posted March 20, 2018 Report Share Posted March 20, 2018 Hi, I'm trying to use a SC_METHOD in my simulation. Here is the code: gcrypt::gcrypt(sc_module_name name): gcrypt_base(name) { SC_METHOD(on_clock_update); sensitive << clock; dont_initialize(); }; void gcrypt::on_clock_update() { if (clock.read() == 0) { SC_REPORT_WARNING(name(), "Invalid clock port value of 0"); _ns_per_cycle = 0; return; } _ns_per_cycle = 1e9 / clock.read(); } The gcrypt_base constructor is: gcrypt_base::gcrypt_base(sc_module_name name) : sc_module(name), ... { ... } I get this exception thrown by SC_METHOD: Exception thrown at 0x6FB78281 (vcruntime140d.dll) in SystemCModuleTest.exe: 0xC0000005: Access violation reading location 0x115348EF. I saw the __vfptr value was "Unable to read memory". How to solve this problem? Thanks, Chao Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted March 20, 2018 Report Share Posted March 20, 2018 I don't see a problem in a given code sample. Can you provide a small complete reproducer for problem? Quote Link to comment Share on other sites More sharing options...
Aaron0127 Posted March 20, 2018 Author Report Share Posted March 20, 2018 26 minutes ago, Roman Popov said: I don't see a problem in a given code sample. Can you provide a small complete reproducer for problem? Hi @Roman Popov, I try to include as many detail as I can. In testbench.cpp, I initialise the gcrypt object. class testbench : public sc_core::sc_module { public: vworks::models::gcrypt g; testbench(sc_core::sc_module_name name): sc_core::sc_module(name), g("g"){ //code initialze connection and signal } The constructor of gcrypt is: gcrypt::gcrypt(sc_module_name name): gcrypt_base(name) { SC_METHOD(on_clock_update); sensitive << clock; dont_initialize(); }; void gcrypt::on_clock_update() { if (clock.read() == 0) { SC_REPORT_WARNING(name(), "Invalid clock port value of 0"); _ns_per_cycle = 0; return; } _ns_per_cycle = 1e9 / clock.read(); } The gcrypt_base constructor is: gcrypt_base::gcrypt_base(sc_module_name name) : sc_module(name), ... { ... } When I run the testbench.cpp in Visual Studio 2017, the exception was thrown in SC_METHOD(on_clock_update) in gcrypt.cpp. The exception error is: Exception thrown at 0x6FB78281 (vcruntime140d.dll) in SystemCModuleTest.exe: 0xC0000005: Access violation reading location 0x115348EF. Thanks, Chao Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted March 20, 2018 Report Share Posted March 20, 2018 No, I don't see problems in your code. It can be a problem with your visual studio settings, since expection you get comes from vs runtime. Can't help without reproducer. Quote Link to comment Share on other sites More sharing options...
Aaron0127 Posted March 20, 2018 Author Report Share Posted March 20, 2018 Could you tell me a little about reproducer? I'm not familiar with this terminology. Thank you Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted March 20, 2018 Report Share Posted March 20, 2018 I mean a small complete code sample I can run on my computer to reproduce the your error. Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted March 20, 2018 Report Share Posted March 20, 2018 Have you included "/vmg" in the additional compiler options in your MSVC project? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.