Basically the methods defined in the type_info_interface
class
are used by the simulation kernel to perform basic operations on data
types which are unknown by the kernel at kernel compile
time. There are three main method types:
get_type_id()
to get the type id of a type and
element_count()
to determine the number of scalar
elements of a type.
copy(...)
which copies the value of one instance to another. For
faster execution there is a special group of methods named
fast_...
. To improve execution performance this methods do not
use the virtual function mechanism. However, they can be called for
data instances of scalar type only.
str(...)
and print(...)
).
Most parameters of the virtual methods are void pointer. In fact they are referring to the actual VHDL data instance. However, because the VHDL data types are unknown to the kernel at kernel compile time, they are mapped to ``void *''.
Method | Description |
---|---|
type_info_interface(const type_id i) | Creates a new type info instance of type ``i''. |
type_id get_type_id() | Returns the type id of the current instance. |
virtual void *create() | Creates a new instance. The instance is initialised to the corresponding default value defined by the type declaration. |
virtual void *clone(const void *src) | ``clone'' instantiates a new instance of the corresponding VHDL data type which is a copy of the instance referenced by ``src''. It returns a reference to the new instance. |
virtual void *copy(void *dest,
const void *src) |
``copy'' copies an instance of the corresponding VHDL data type pointed to by ``src'' to ``dest''. It returns ``dest''. |
void *fast_copy(void *dest,
const void *src) |
Same as ``copy'' but faster. Works for scalar instances only. |
virtual bool compare(const void *src1,
const void *src2) |
Returns true if the instances ``src1'' and ``src2'' are pointing to are equal. |
bool fast_compare(const void *src1,
const void *src2) |
Same as ``compare'' but faster. Works for scalar instances only. |
virtual bool assign(void *dest,
const void *src) |
Same as ``copy''. However it returns true if ``dest'' changed its value due to the assignment). This function is used to assign new values to a signal reader. |
bool fast_assign(void *dest,
const void *src) |
Same as ``assign'' but faster. Works for scalar instances only. |
virtual void remove(void *src) | Removes an instance. |
void *element(void *src, acl *a) | Returns the address of the subelement of instance ``src'' addressed by acl ``a''. |
void *element(void *src, int i) | Returns the address of the subelement of instance ``src'' addressed by index ``i''. Each scalar subelement of ``src'' is associated with a unique index value. The leftmost scalar element of ``src'' is associated with index 0, the next scalar element with index 1, etc. |
virtual int element_count() | Calculates the number of scalar elements of the current type. |
virtual void print(ostrstream &str,
void *src) |
Prints the ASCII representation of the value of the current instance to the string stream ``str''. |
char *str(const void *src) | Prints value of instance (src is pointing to) into a char buffer and returns a pointer to the buffer. Note, the buffer is static! Hence, each call to str uses the same buffer! |
The method ``element'' may be used to calculate the address of an
(sub)element of a data instance. The subelement can be either selected
by an acl
instance or an index number. For a scalar type only
an acl
pointer equal to NULL
(respectively pointing to
the end of an acl
list) or an index value 0 are valid. The
method then simply returns the address of the scalar instance.
For a composite instance each scalar element is associated with an unique index number by enumerating all scalar elements of the instance. The leftmost scalar element of an array and the first scalar element of a record are associated with index number 0. The next scalar element is assigned the index 1, etc. If the composite instance consist of composite elements then the index number is calculated by recursively enumerating all scalar elements as described above.