Languages
Can you show an example of using a 'probe_value'
primitive to dump the signal values to a text file?
The attached package contains an example of using a 'probe_value'
primitive to sample the values of a signal at specified trigger events and record the results to a text file. The 'probe_value'
primitive can be triggered either internally, i.e., at a fixed period after an initial delay, or externally, i.e., whenever an xbit
-typed trigger input toggles to a different value.
The schematic cellview 'sandbox.tb_record_val:schematic'
shown below records the values of the signal 'sig'
in these two ways. The first 'probe_value'
primitive samples the signal at every 1.0ns and records the values to a file named "samples.dat"
. On the other hand, the second 'probe_value'
primitive samples the signal when the signal is at their maximum or minimum peak and records the values to a file named "peaks.dat"
. It is achieved by having a 'deriv'
primitive computing the time-derivative of the signal and a 'trig_cross'
primitive generating a trigger event whenever the derivative crosses zero, in other words, when the signal is at its maximum or minimum peak.
Consider a case when the signal is a sinusoid with an exponentially-decaying amplitude, like the one shown below.
The text file "samples.dat"
produced by the first 'probe_value'
primitive is expected to list the signal values sampled at 1ns interval.
On the other hand, the text file "peaks.dat"
produced by the second 'probe_value'
primitive is expected to list the maximum or minimum peak values of the signal.
The text files produced by the 'probe_value'
primitives can be easily read and processed in various programs. For example, in Python, the numpy.loadtxt()
function can directly read the values into an array. Below is a simple example computing the minimum and maximum among the values.
#!/usr/bin/env xmodelpy import numpy as np samples = np.loadtxt('samples.dat') peaks = np.loadtxt('peaks.dat') print "SAMPLES: %e ~ %e" % (samples.min(), samples.max()) print "PEAKS : %e ~ %e" % (peaks.min(), peaks.max())
Attachment: record_val_20221023.tar.gz
Please login or Register to submit your answer
'probe_value'
primitive를 활용해서 신호의 값을 텍스트 파일에 덤프하는 예제를 보여주실 수 있나요?
The attached package contains an example of using a 'probe_value'
primitive to sample the values of a signal at specified trigger events and record the results to a text file. The 'probe_value'
primitive can be triggered either internally, i.e., at a fixed period after an initial delay, or externally, i.e., whenever an xbit
-typed trigger input toggles to a different value.
The schematic cellview 'sandbox.tb_record_val:schematic'
shown below records the values of the signal 'sig'
in these two ways. The first 'probe_value'
primitive samples the signal at every 1.0ns and records the values to a file named "samples.dat"
. On the other hand, the second 'probe_value'
primitive samples the signal when the signal is at their maximum or minimum peak and records the values to a file named "peaks.dat"
. It is achieved by having a 'deriv'
primitive computing the time-derivative of the signal and a 'trig_cross'
primitive generating a trigger event whenever the derivative crosses zero, in other words, when the signal is at its maximum or minimum peak.
Consider a case when the signal is a sinusoid with an exponentially-decaying amplitude, like the one shown below.
The text file "samples.dat"
produced by the first 'probe_value'
primitive is expected to list the signal values sampled at 1ns interval.
On the other hand, the text file "peaks.dat"
produced by the second 'probe_value'
primitive is expected to list the maximum or minimum peak values of the signal.
The text files produced by the 'probe_value'
primitives can be easily read and processed in various programs. For example, in Python, the numpy.loadtxt()
function can directly read the values into an array. Below is a simple example computing the minimum and maximum among the values.
#!/usr/bin/env xmodelpy import numpy as np samples = np.loadtxt('samples.dat') peaks = np.loadtxt('peaks.dat') print "SAMPLES: %e ~ %e" % (samples.min(), samples.max()) print "PEAKS : %e ~ %e" % (peaks.min(), peaks.max())
Attachment: record_val_20221023.tar.gz
Please login or Register to submit your answer