Jump to content

SC_METHOD Eception


Aaron0127

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

Link to comment
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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...