Jump to content
Earless

Set timestep in ELN module

Recommended Posts

Probably a very simple request, but I'd like to set the timestep of my ELN module. I found the following piece in the Language Reference Manual: "The timestep for every ELN cluster shall be derived from the timestep of a connected TDF cluster or set by the member functions set_timestep or set_max_timestep of an ELN primitive module derived from class sca_eln::sca_module of the corresponding ELN cluster." From this, I understand that it is possible to set the timestep within the ELN module.

Right now, I've declared my module with SC_module(<name>).

  • When I simply call set_timestep() I get this error: "'set_timestep' was not declared in this scope"
  •  When I call sca_eln::sca_module::set_timestep() I get this error: "cannot call member function 'virtual void sca_core::sca_module::set_timestep(const sca_time&)' without object"
  •  When I declare the module as SCA_ELN_MODULE(<name>) (like SCA_TDF_MODULE(<name>)) I get this error: "expected constructor, destructor or type conversion before '(' token"

I guess my question is the following: is it possible to set the timestep in an ELN module? If so, how do I do this?

Bonus question: I'm trying to find the User's Guide, but I seem to only be able to find the SystemC AMS LRM. If somebody could point me to the User's Guide, that would be very helpful!

Thanks a lot in advance! My apologies for the (probably) stupid question.

 

Share this post


Link to post
Share on other sites

You seem to use the right approach of using an SC_MODULE to describe the structure of your circuit of ELN primitives. The macros SCA_ELN_MODULE and SCA_TDF_MODULE are exclusively used to define primitive modules in the respective MoCs, which describe the behaviour of the primitive, but not their inner structure. The statement from the SystemC AMS LRM regarding setting the time step refers to the set_timestep() member function, which is offered by all SystemC AMS primitive modules.

To keep my models flexible, I tend to prefer to set the time step from the test bench or top level module by calling the set_timestep() member function of one of the accessible primitive AMS modules in that scope, i.e., usually a stimuli source. E.g., if you have instantiated a

sca_eln:sca_vsource src1("src1", 2.0);

you would call

src1.set_timestep(10.0, sc_core::SC_US);

to set the time step of the module src1 and the connected ELN cluster to 10 us. I hope that this answers your primary question.

I definitely recommend you to read the SystemC AMS User's Guide to get a better insight into the fundamental concepts of SystemC AMS. It is an unfortunate situation that it is currently so hard to find as it is only provided as a bundled download together with the outdated Accellera SystemC AMS 1.0 standard. You can download it from the Accellera's SystemC standards page, where it is listed as "AMS 1.0" in the "Previous releases" section. The statements from this User's Guide are still relevant. It only lacks discussion of the advanced Dynamic TDF modelling features, which were added in SystemC AMS 2.0 and are also part of IEEE Std 1666.1-2016. Unfortunately, efforts to update the user's guide to the current SystemC AMS standard version got stalled due to lack of time of the involved people in the working group.

 

Share this post


Link to post
Share on other sites

@maehne First of all, thank you for your reply.

1 hour ago, maehne said:

The macros SCA_ELN_MODULE and SCA_TDF_MODULE are exclusively used to define primitive modules in the respective MoCs, which describe the behaviour of the primitive, but not their inner structure.

Maybe it is me, but I got the following error message when I tried SCA_ELN_MODULE: "expected constructor, destructor or type conversion before '(' token" . This makes me believe the macro is not defined. SCA_TDF_MODULE does not give me this error. Am I correct?

1 hour ago, maehne said:

sca_eln:sca_vsource src1("src1", 2.0);

you would call


src1.set_timestep(10.0, sc_core::SC_US);

I tried this with my ELN module as follows:

LifELN lifNeuron("lifNeuron", Cm, Rm, sampleRate);
lifNeuron.set_timestep(sca_core::sca_time(1000.0 / sampleRate, sc_core::SC_MS));

Unfortunately, the compiler gives me the following error: "struct LifELN has no member named 'set_timestep'". I assumed that this is what you tried to show me in your code example. What am I doing wrong here?

Then I tried to do something similar inside the constructor of the ELN module, but instead of calling set_timestep() of the module, I called set_timestep() of an ELN component. See below

/* HEADER */
sca_eln::sca_vsource Vrest;

/* CPP */
Vrest.p(n2);
Vrest.n(node);
Vrest.set_timestep(dt, sc_core::SC_MS);

Surprisingly, this worked as well. Is this a valid way to set a timestep (considering it is called within a constructor and not inside set_attributes())?

1 hour ago, maehne said:

It is an unfortunate situation that it is currently so hard to find as it is only provided as a bundled download together with the outdated Accellera SystemC AMS 1.0 standard. You can download it from the Accellera's SystemC standards page, where it is listed as "AMS 1.0" in the "Previous releases" section.

Thanks for pointing this out. Now I remember how I found it last time 🙂 Maybe it would be a good idea to bundle the 1.0 User Guide with the SystemC AMS 2.0 standard for the time being, until it is updated?

Apologies for the tedious reply. Again, thanks for your reply!

Share this post


Link to post
Share on other sites

Please note that the electrical primitives are predefined elements using the ELN model of computation; there is no mechanism to create your own electrical primitives. As such there is no such thing as a SCA_ELN_MODULE. Primitive modules can only be created for the TDF MoC, hence the SCA_TDF_MODULE macro as alternative to the class sca_tdf::sca_module.

Wrt the the SystemC AMS 1.0 User's Guide, I will start an action to make it available independently of the LRM.

Although the authors of the User's Guide are quite busy with other things, they full recognize the need to update the guide including the Dynamic TDF features as introduced in AMS 2.0 and IEEE1666.1. We hope to announce an update of the document in the coming period.

Share this post


Link to post
Share on other sites

@Martin Barnasconi is of course right about that there is no SCA_ELN_MODULE macro defined in the SystemC AMS standard, as it is currently not possible to define own primitive ELN modules. Personally, I prefer to avoid the use of preprocessor macros in C++ as much as possible -- especially when a fully equivalent concise proper C++ syntax exist. In the context of SystemC (AMS) the macros SC_MODULE, SCA_TDF_MODULE, SC_CTOR, and SCA_CTOR obfuscate in my humple opinion more the code than they help to render SystemC models more readable.

3 hours ago, Earless said:

I tried this with my ELN module as follows:


LifELN lifNeuron("lifNeuron", Cm, Rm, sampleRate);
lifNeuron.set_timestep(sca_core::sca_time(1000.0 / sampleRate, sc_core::SC_MS));

Unfortunately, the compiler gives me the following error: "struct LifELN has no member named 'set_timestep'". I assumed that this is what you tried to show me in your code example. What am I doing wrong here?

Your class LifELN is very probably a class derived from sc_core::sc_module (SC_MODULE) and which contains the netlist of your ELN model (i.e., a circuit of ELN primitives). The time step needs to be set always on at least one instance of a primitive SystemC AMS module, which is part of a cluster of connected SystemC AMS primitive modules. Therefore, your second approach:

3 hours ago, Earless said:

Then I tried to do something similar inside the constructor of the ELN module, but instead of calling set_timestep() of the module, I called set_timestep() of an ELN component. See below


/* HEADER */
sca_eln::sca_vsource Vrest;

/* CPP */
Vrest.p(n2);
Vrest.n(node);
Vrest.set_timestep(dt, sc_core::SC_MS);

Surprisingly, this worked as well. Is this a valid way to set a timestep (considering it is called within a constructor and not inside set_attributes())?

is the correct one.

Share this post


Link to post
Share on other sites

@Martin Barnasconi thank you for your reply. Good to hear that the User Guide might be more easily available 🙂

@maehne thank you for your reply as well. Looking back at your earlier post and example, I realize that I read it completely wrong. My second approach is exactly the same as your example. My apologies for the confusion. Thank you for the time and effort!

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

×