Jump to content

How do I stop AMS from interpolating discrete signals?

Recommended Posts

The problem I'm running into can be explained by the following simple example:


I have a SystemC module sending a speed over a signal to a TDF module that integrates that speed to get a position (with sca_ss).


The SystemC module will send out a speed of v=1 at t=0,1,2,3, then it will start sending out a speed of v=0 after that (t=4,5,6,.....).


Now the TDF module will calculate the correct position for the first few seconds:

t=0 ---> x=0

t=1 ---> x=1

t=2 ---> x=2

t=3 ---> x=3


but after that, the TDF module will interpolate the value for the speed between t=3 and t=4, and thus result in x=3.5 for t=4 (where v=0).


I realize I can circumvent this by setting very small timesteps, and setting the speed v=1 at t=3.999, but I was wondering if there is a less 'hacky' way of doing this. (Also setting small time steps will drastically slow down my simulation.)


I'm trying to compare the SystemC-AMS output to the output from the same model in MATLAB, which does not have this problem, and the difference is way off due to this.

Link to comment
Share on other sites

if the input signal has been changed, you can do one small timestep using the tstep parameter of the sca_tdf::sca_ss class. Alternatively you can use the dynamic timesteps of SystemC AMS 2.0 (e.g. trigerring to an event) and perform also one small timestep after a change.


best regards


I think I need a small timestep before the change, not after. Also, the changes are not scheduled, so I can't do a small timestep before the change.

Link to comment
Share on other sites

Section 2.3.2 in the SystemC AMS user's guide explains the effect you see:


Although the TDF model of computation processes the samples at discrete time steps, the equations of these embedded functions will be solved by considering the input samples as continuous-time signals.


This means that your input signal is *not* considered as discrete (sample-and-hold) values, but it will interpolate. This means that between t=3 and t=4 the area is 0.5, which counts up to the integrated value of  3.5.


So if you really want to integrate discrete (digital) signals, I recommend to write this in plain SystemC using discrete-event semantics.


(Note: If you ask me, Matlab/Simulink are not a good reference for comparison, because the execution semantics and models of computations are non-standard.)

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.

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