Jump to content

last_value of a signal


jsmith125x

Recommended Posts

Hi. 

 

Accessing the last value is not possible in SystemC out of the box. 

I see two possibilities here. 

First is to implement your own signal class derived from sc_signal. Then, you can override the update method, store the last value and add your own methods to access this value. 

 

Second, you may use dynamic sensitivity. If the value of the signal is '1', you can wait for the 'negedge_event' directly. Otherwise, you can wait for a 'posedge_event' first and then wait for the following 'negedge_event'. 

 

Greetings

Ralph

Link to comment
Share on other sites

Hi,

 

Is there similar in SystemC like last_value attribute in VHDL?

 

I have a sc_logic signal and I'd like to determine a real negedge (1->0) but not from (X->0). How to do that?

 

Hello Sir,

One option would be to have a module thread that is sensitive to ALL

changes in e.g., an input signal. Then each time a new value is read

in, compare it with the previous value of the same signal variable,and

take appropriate action. The current value of the signal variable is stored,

after all processing is complete, as the last value, to be used for

comparison for the next value of the signal variable. A very intuitive,

straightforward approach. Please note that VHDL has been designed

with the very aim of simulating hardware, and so there would not be

any direct parallels with C++ features - but workarounds are always

possible. Hope that helps.

Link to comment
Share on other sites

Hi.

 

 

 

One option would be to have a module thread that is sensitive to ALL

changes in e.g., an input signal.

 

You have to be careful with this solution because it adds one delta cycle to the signal flow. This may not be a problem, but, e.g., with clock signals, this may lead to erroneous behavior. 

Using immediate notification possibly solves this problem, but immediate notification has its own pitfalls.

 

Greetings

Ralph

Link to comment
Share on other sites

I think deriving your own specialized signal class is the best solution. This is similar to Ralph's suggestion, but restricted to sc_logic. It will make the coding go faster.

 

struct my_signal : sc_signal<sc_logic>

{

  // Override appropriate methods

  void write(...) {

  }

  void update() {

    ...

  }

private:

  sc_logic prev;

}

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