Jump to content

How to build an ELN primitive that can provide additional information


Recommended Posts

Hi community,

I would like to build an advanced ELN primitive which acts as the primitive and automatically calculates for instance the power of the primitive. Furthermore, the power should be traceable when it is needed but it should also be possible to leave the power information dangling.

My first idea was to create an ELN module (sca_eln::sca_module) that consists of the ELN primitive, a voltage sink (sca_eln::sca_tdf_vsink), a current sink (sca_eln::sca_isink) and a variable (sca_tdf::sca_trace_variable). The sca_trace_variable should contain the current power p(t) and it would be traceable when needed and could also be dangling. Due the sca_trace_variable is a TDF MOC, in the AMS-LRM §5.1.14.3 is mentioned that the sca_trace_variable should only be read or written in the member function processing(). Now the problem arise, that in an ELN module (sca_eln::sca_module) no member function processing() can be called because ELN modules have no one.

Does anyone have an idea, of how to build an advanced ELN primitive that can provide additional (traceable) information without affecting the ELN equation system?

Kind regards
Thomas

Link to comment
Share on other sites

You don't have to create a new ELN primitive to achieve what you described. However, the sketched-out approach is good: Indeed, you have to connect a sca_eln::sca_vsink and sca_eln::sca_isink to your ELN circuit for which you want to trace the power to measure the voltage drop across and the current flowing through the circuit. Describing such an ELN netlist is done in an sc_core::sc_module instead of an sca_eln::sca_module as a netlist constitutes a structural description of the circuit and not a new ELN primitive (which would add new equations describing the circuit element behaviour to the equation system). Defining such user-defined ELN primitives is not standardised in IEEE Std 1666.1-2016 so you have to live with the pre-defined set of ELN primitives. The isink and vsink modules have a TDF output port, which you have to connect via two signals to a user-defined TDF module, which will define in its processing() member function the calculation of the power and the updating of the corresponding trace variable. Depending on your needs, you may also consider to add a second trace variable for tracing the energy (i.e., the integral over time of the power). You might consider to wrap the isink and vsink as well as the power-calculation TDF module into an sc_core::sc_module, which only exposes the electrical terminals needed for power measurement and the trace variables. This may simplify instantiation of several power measurements.

Another approach you may consider is to simply trace the relevant voltages and currents and calculate the power/energy offline in your waveform viewer or math tool, which can process the SystemC AMS trace file format (e.g., Octave). 

Link to comment
Share on other sites

Hi Torsten,

thanks for the fast and detailed reply. Yes, I also want to calculate the energy, but first I wanted to start with a simple example.

I attached an example that should correspond to your suggestion. The ELN primitive is in this case a simple resistor and the source code compiles without warnings. But, as soon as the simulation is started, the program stops and throws the error:

Error: (E109) complete binding failed: port not bound: port 'my_adv_primitive.isink.n' (sca_eln::sca_terminal) In file: ../../../../src/sysc/communication/sc_port.cpp:231

The port is connected in the example. So, I can only explain the error by the fact that the TDF cluster has no sample time. In this case, the sample time depends on the trace file itself or on other signals in the trace file. Is there a way to pass the sample time via the function sca_trace() to the calculation module?

Kind regards
Thomas

 

Edited by T. Zimmermann
The attached example was not well suited. I'll create a better one.
Link to comment
Share on other sites

Regarding your port binding error: It is not sufficient to bind the isink.n terminal to another terminal. Instead, you have to make sure that through these terminal-to-terminal bindings at some point a node of type sca_eln::sca_node or sca_eln::sca_node_ref is bound. (This is basically the same as SystemC allows port-to-port bindings, but requires any port to be bound at some point to a channel.)

Regarding setting the sample time of the ELN/TDF cluster: You can use the sca_core::sca_module::set_timestep() member function for this purpose, which can be used across all MoCs (TDF, ELN, LSF) as their specialised primitive module classes derive from the sca_core::sca_module base class.

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