Jump to content
Aaron0127

SC_METHOD Eception

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×