Commit Graph

17 Commits

Author SHA1 Message Date
Cary R 956f6ccf4c Update VPI routines to on error signal VVP to return non-zero 2021-01-20 23:50:53 -08:00
Larry Doolittle 89edf62206 Capitalize Verilog in a few places 2016-04-01 11:02:24 -07:00
Martin Whitaker 6836068a16 Initial support for $countdrivers.
This patch implements the $countdrivers system function. It does not
yet support wires connected to islands (and outputs a suitable "sorry"
message when this is detected).
2012-07-27 18:09:32 -07:00
Cary R 073083f3d9 Make some messages consistent in sys_icarus.c.
This patch makes some of the VPI messages consistent with the rest.
2011-10-31 10:32:20 -07:00
Cary R 7a473166d9 Add the stochastic (queue) tasks/function
This patch adds full support for the stochastic tasks/functions except
the mean inter-arrival and average wait statistics are not currently
available. These will be added in a later patch. This implementation
goes a bit beyond the standard and supports the following:

 1. The job and inform arguments support 32 bit four state values.
 2. The id for all routines, the job and inform arguments for $q_add(),
    the statistic code for $q_exam() along with the queue type and
    maximum length arguments for $q_initialize() can be less than or
    equal to 32 bits. The argument will be sign extended if needed to
    fill the internal 32 bit value.
 3. The job and inform arguments to $q_remove() and the status argument
    for all the routines must be 32 bits, but do not have to be an
    integer variable (e.g. a 32 bit register or part select is OK).
 4. An undefined bit in the id argument for any of the routines will
    return a status of 2 (undefined queue id). Undefined bits are not
    automatically converted to zero.
 5. Undefined bits in the $q_initialize() queue type and maximum
    length arguments or the $q_exam() statistic code argument are also
    flagged as an error (are not converted to zero).
 6. The $q_full() function returns 2 on error, the other routines that
    return a value $q_remove() job/inform arguments and the $q_exam()
    statistic value argument will usually return x on error.
 7. An invalid statistic code will set the $q_exam() status to 8.
 8. The $q_exam() statistic value argument can be 32 bits or larger.
    This allows returning large statistical time values.
 9. All time values are internally saved in simulation time units.
    They will be converted to the calling module's time unit (with
    rounding) before they are returned.
10. If a $q_exam() statistical value is too large to fit into the
    variable the maximum positive value will be returned and the
    status code will be set to 9 (value is too large).
11. If a statistical value is currently undefined $q_exam() will
    return 10 (no statistical information) (e.g. using code 5 on an
    empty queue).
2011-04-13 18:48:57 -07:00
Larry Doolittle 5d977cac73 Brainless start to const-correct changes
Results of running
cd vpi
for f in *.c *.h; do sed -i \
  -e "s/_calltf(PLI_BYTE8/_calltf(ICARUS_VPI_CONST PLI_BYTE8/" \
  -e "s/_compiletf(PLI_BYTE8/_compiletf(ICARUS_VPI_CONST PLI_BYTE8/" $f; done
and a trivial patch to vpi_user.h to, among other things, make
ICARUS_VPI_CONST blank.

Thus, this patch does absolutely nothing.  Will be followed by a
(much shorter) patch that makes it do something.  :-)
2010-10-06 15:08:54 -07:00
Cary R ecacd7bae9 Make sure to call vpi_config.h first.
vpi_config.h defines _FILE_OFFSET_BITS. This must be defined before
any system includes files are processed, so vpi_config.h must be
called first. This patch puts vpi_config.h first. It also removes
direct calls for both vpi_config.h and vpi_user.h when sys_priv.h
is included since it already includes these two files.

It also updates the code to always include vpi_user.h using double
quotes.
2010-05-17 20:51:59 -07:00
Cary R f2d5acabd5 Add support for vpiUserSystf iteration, etc.
This patch adds support for iterating over the list of vpiUserSystf
tasks/functions that have vpiUserDefn set. The vpiUserDefn property
is true by default, but you can call vpip_make_systf_system_defined()
to set this property false (will hide the vpiUserSystf object). All
the normal system tasks/functions have been modified to call this
procedure to remove them from the list of vpiUserSystf objects. Only
user defined system tasks or functions should appear in the list.

vpi_compare_objects() is just a simple are the two pointers the
same. This works correctly for the vpiUserSystf objects, but the
other handle objects have not been checked.
2010-04-13 20:54:59 -07:00
Cary R ce89a68735 Add full $ferror() support, bug fixes, etc.
This patch adds $ferror() support. This is enhanced over what the standard
says needs to be supported. All file I/O routines set/clear the errno flag,
This allows $ferror() to check when an invalid fd/MCD is passed to a
system task. The $ferror() fd is only checked if errno is not set since
all the other routines will set EBADF when they are called. This allows us
to test the output from $fopen() which sets the fd to zero (an invalid fd)
when it has a problem.

The following bugs (changes) are also fixed:

Fix $fdisplay*, $fwrite*, $fstrobe*, $fflush, $fclose to not accept 0 as
a valid MCD.

For the $fdisplay*, $fwrite* and $fstrobe tasks an invalid fd/MCD is now
a warning instead of an error like the other file I/O routines.

Modify $fputc() to be a function and return a value like $ungetc().

Modify $ungetc() to return a value like the standard dictates (-1 on
error else 0) and pass the value as a full int to get EOF as an error.

Remove some extra checks that could not happen in $fseek() and to
be safe convert the numeric codes to the system symbolic values.

Skip $fstrobe callback when the fd/MCD is closed. The standard says
we need to cancel the callback, but we currently do not have the
ability to do that so just skipping this will work for now.

Free the argument handle when $fscanf() is called with an invalid fd
(memory leak).
2009-08-02 10:53:29 -07:00
Cary R ad604253f2 Print a better error message for the optional system tasks/funcs
This patch adds better error messages (compiletf) for the optional
system tasks and functions (Annex C 1364-2005). Doing this also
makes calling them fail more gracefully (it is no longer a RE).
2009-04-17 18:05:31 -07:00
Cary R a8716cf759 Add message the the $dumpports* task are not available
These are in the standard and we did not have error messages
for them. This patch make calling these tasks a compiletf
fatal error.
2009-03-27 16:10:53 -07:00
Cary R a6529c2c59 Add the $fread() system function.
This patch adds the $fread() system function. Icarus does not
currently allow missing arguments in functions so the following
standard specified functionality is not supported:

  res = $fread(mem, fd,,count);

It also fixes a memory leak in fopen related to the get_filename
refactoring I recently did.
(cherry picked from commit 036c176e8b)
2009-03-26 14:06:31 -07:00
Cary R 92dd13a225 Error message for missing system tasks/functions.
This patch adds an error message for the standard system
tasks and functions that are not currently implemented.
These are currently $fmonitor*, $ferror, $fread, the
queue and PLA tasks.
2008-08-23 09:20:30 -07:00
Cary R 7c152685dc Clean up more compiletf routines, etc.
This patch cleans up some of the code to use common compiletf
routines where appropriate. It also adds code to print the
number of extra arguments and cleans up the messages a bit.
2008-06-06 20:44:21 -07:00
Cary R 4010f6e710 Add $simparam and other fixes.
This patch adds $simparam and $simparam$str from Verilog-A.
The analog simulator parameters return 0.0 or N/A. The
vvp_cpu_wordsize system function has been moved into the
$simparam call and is now named CPUWordSize.

This patch also starts the factoring of common code in the
vpi directory. Some routines were renamed.

The priv.c file was renamed to sys_priv.c to match the
include file.

System functions can now have strings put to their output.
2008-06-03 20:56:37 -07:00
Cary R 608c2574bd Add $finish_and_return.
This new system task can be used to set the vvp return value
and finish the simulation.
2008-05-22 20:34:38 -07:00
Cary R 3a8a6976e1 Add $vvp_cpu_wordsize function
This patch adds a new system function $vvp_cpu_wordsize. It returns
the size of the underlying CPU word (long) in bits. This function
can be used to write fully portable tests for the test suite. Other
functions will be added as needed.
2008-05-07 09:42:02 -07:00