Jump to content

What is the difference in default_event() and value_changed_event()


rahuljn

Recommended Posts

Hi Folks

 

What is the difference in default_event() and value_changed_event() for sc_signal channel.

I have an sc_in port in my module and a process run is sensitive on it

 

SC_THREAD(run)

sensitive<<irq;

 

When the run will be activated

- when there any any event on irq (read or write)

- when there is some value change event

 

When I use

 

SC_THREAD(run)

sensitive<<irq.value_changed_event();

or

 

SC_THREAD(run)

sensitive<<irq.default_event();

 

I get the following error

Error: (E112) get interface failed: port is not bound: port 'initiator.irq' (sc_in)
In file: ../../../../systemc-2.3.0/src/sysc/communication/sc_port.cpp:230
 

 

 

Regards

RahulJn

Link to comment
Share on other sites

Hi Alan

 

Yes it is clear from the LRM but I still didn't get why I am getting following error with

 

SC_THREAD(run)

sensitive<<irq.value_changed_event();

or

 

SC_THREAD(run)

sensitive<<irq.default_event();

 

 

I get the following error

Error: (E112) get interface failed: port is not bound: port 'initiator.irq' (sc_in)
In file: ../../../../systemc-2.3.0/src/sysc/communication/sc_port.cpp:230

 

 

Thanks

RahulJn

Link to comment
Share on other sites

Ah, that's a different question! :-)

 

When you want to be sensitive to something, you need to get a reference to the event.

 

In the constructor of a module, the ports are not yet bound, so it is not possible to get a reference to the event directly. Instead you must use an "event finder". The event finder is a bit of magic code that defers returning a reference until after binding is complete.

 

If you look at the LRM, you'll see that the sc_in port has an event finder called "value_changed()". Also the bool and sc_logic specialisations have pos() and neg() as event finders.

 

You can call default_event() or value_changed_event() inside an SC_THREAD if you like, because at that point the signal is bound, and so the event can be returned.

 

regards

Alan

 

P.S. It's educational to look at sc_in<bool> and sc_signal<bool> and see the difference between pos(), posedge(), and posedge_event().

Link to comment
Share on other sites

Hi Folks

 

What is the difference in default_event() and value_changed_event() for sc_signal channel.

I have an sc_in port in my module and a process run is sensitive on it

 

SC_THREAD(run)

sensitive<<irq;

 

When the run will be activated

- when there any any event on irq (read or write)

- when there is some value change event

 

When I use

 

SC_THREAD(run)

sensitive<<irq.value_changed_event();

or

 

SC_THREAD(run)

sensitive<<irq.default_event();

 

I get the following error

Error: (E112) get interface failed: port is not bound: port 'initiator.irq' (sc_in)

In file: ../../../../systemc-2.3.0/src/sysc/communication/sc_port.cpp:230

 

 

 

Regards

RahulJn

Hello Sir,

It might be worthwhile to not use explicit events, and use implicit events.

It relieves the programmer of the task of tracking events, and puts the

burden on the SystemC runtime environment and module sensitivity

lists to tackle events. Hope that helps.

Link to comment
Share on other sites

  • 2 months later...

Hi Guys

 

section 6.4.9 in the 1666-2011 LRM says the following.

 

6.4.9 Member functions for events

virtual const sc_event& default_event() const;

virtual const sc_event& value_changed_event() const;

Member functions default_event and value_changed_event shall both return a reference to the value-changed event

 

So both are same.

Am I right ?

 

So what should I use when

- I want to invoke the process when the value is changed (1->0 or 0-> 1). The process should not execute when the written value is same as the original value(i.e. 0->0 or 1->1)

- I want to invoke the process whenever there is some event on irq(i.e. 1->0, 0->0, 0->1, 1->1 in all cases whether or not the value is changed.

 

 

Thanks

RahulJn

Link to comment
Share on other sites

  • 3 months later...

Hi Folks

 

One thing is still not clear to me and that is why there are two functions default_event() and value_changed_event() doing the same things.

From the LRM these appears exactly the same. If they are same than why not have a single function i.e. either default_event() or value_changed_event(), instead of two.

Is there some difference between these two ?

 

 

Thanks

RahulJn

Link to comment
Share on other sites

There is one function defined in class sc_interface called default_event(). It's purpose is to allow you to implement static sensitivity by overriding it in your channel.

 

If you already have an event declared in your channel that you want to use for static sensitivity, then you would return a reference to it using default_event() - and then your channel could be used in a static sensitivity list.

 

That is the general use of the default_event() function, see section 5.14.5 of the LRM.

 

Note that this is not specific to sc_signal, it may be implemented by any channel derived from sc_interface.

 

In the case of sc_signal, there happens to be one event object declared inside the channel. Since it is the only one, it can be used as the default event for static sensitivity, so a reference to it is returned by default_event().

 

The designers of sc_signal also chose to create an access method to that same event. Since that event is triggered by a change in value, they called that method value_changed_event().

 

I hope that helps,

 

regards

Alan

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...