Commit Graph

155 Commits

Author SHA1 Message Date
Stephen Williams e5f52320e6 Fix handling of bool(bit) vectors with odd widths. 2011-04-02 15:50:49 -07:00
Cary R a4a7b0a09d Make ivl_alloc.h the last include so it doesn't effect any system includes.
In ivl_alloc.h we redefine malloc(), realloc() and calloc() to have
standard error checking. We don't want to do this for anything that
comes from the standard headers. This specifically doesn't work if
a C++ header files does std::malloc, etc.

Also change to -W instead of -Wextra since that is more portable. I
plan to add a check from -Wextra and use it when available since it
is more descriptive.
2010-11-02 10:51:57 -07:00
Cary R 77feb50d7b Fix valgrind code to work with new SV types. 2010-11-02 10:42:11 -07:00
Cary R fc2ab8f7c2 Fix some recent -Wextra warnings in vvp. 2010-11-02 10:39:15 -07:00
Stephen Williams 3733c59e49 Merge branch 'work1' 2010-10-21 19:31:49 -07:00
Cary R b0269fa926 Add -Wextra for C++ compiling in the vpi and vvp directory.
This patch adds -Wextra to the compilation flags for C++ files in
the vvp and vpi subdirectories. It also fixes all the problems
found while adding -Wextra. This mostly entailed removing some of
the unused arguments, removing the name for others and using the
correct number of initializers.
2010-10-14 19:18:18 -07:00
Cary R cb86fb15bf Add error checking definitions for malloc(), realloc() and calloc()
This patch adds defines that translate all malloc(), realloc() and calloc()
calls into ones with error checking when ivl_alloc.h is included.
2010-10-14 17:39:23 -07:00
Stephen Williams 6a0cbc5fa8 VPI access to atom2 types.
Create the .var/2u and .var/2s variable records and give them
basic implementations. Make available to VPI the proper types
for the SystemVerilog types that these variables represent.
2010-10-10 10:06:27 -07:00
Stephen Williams 0950fbb9a3 Clean up some vvp signal casts. 2010-10-06 15:02:45 -07:00
Cary R 1993bf6f69 Remove malloc.h support and for C++ files use <c...> include files.
The functions (malloc, free, etc.) that used to be provided in
malloc.h are now provided in cstdlib for C++ files and stdlib.h for
C files. Since we require a C99 compliant compiler it makes sense
that malloc.h is no longer needed.

This patch also modifies all the C++ files to use the <c...>
version of the standard C header files (e.g. <cstdlib> vs
<stdlib.h>). Some of the files used the C++ version and others did
not. There are still a few other header changes that could be done,
but this takes care of much of it.
2010-06-01 08:56:30 -07:00
Cary R 1be00e0322 Not all compilers support dynamic array creation (array[<variable>]).
gcc supports creating an array with a run time defined size. The
SunPro compiler for OpenSolaris does not. This patch converts the
array creation to use conventional (malloc based) array creation.
2010-05-13 19:11:14 -07:00
Cary R 7866e92761 Fix an obscure memory leak and fix formatting.
This patch fixes an obscure memory leak and make the formatting
of these two routines match the rest of the code in the file.
2010-01-23 09:44:13 -08:00
Cary R d6246cf041 Add some casts in vvp to remove warnings.
The Cygwin compiler is a bit picky. This patch adds some casts
to remove compilation warnings. In the past I have had warnings
off because of problems with the STL, but for this directory we
may as well squash as many warings as we can. It also does not
recognize that an assert(0) or assert(false) ends a routine so
it complains about no return at end of function or variables
not being defined.
2009-12-11 21:43:42 -08:00
Stephen Williams 971179d617 Performance optimizations
For the %mov instruction, implement a vvp_vector4_t::mov method to
manipulate the thread vector directly.

For the %load/v instruction, rework the vec4_value() methods to
avoid creating vvp_vector4_t temporaries, and therefore reduce the
copy overhead.
2009-11-20 17:54:48 -08:00
Stephen Williams 5fb89262df Fix the vpiObjTypeVal for signals to be scalar or vector.
Scalar signals have a preferred type of vpiScalarVal, but vectors
have a preferred type of vpiVectorVal. Use the signal width to
distinguish.
2009-10-29 11:53:31 -07:00
Cary R c7d05eefb4 More valgrind cleanup (local nets).
This patch adds code to cleanup local nets and changes a few of
memory cleanup messages.
2009-10-20 09:38:55 -07:00
Cary R dec524a151 More valgrind cleanup.
This patch adds code to cleanup system functions driving a
continuous assignment. It also modifies the user function
cleanup to not interfere with this. It also adds a count
of the nets and signals that were not cleaned up that is
pnly printed when running valgrind. They are not flagged
y valgrind since they are pool managed objects. There are
a few signals that need to be cleaned up and local nets
are missed so there are a lot of nets.
2009-10-16 20:03:26 -07:00
Stephen Williams 8a3df7c4ff Fix build errors when configured --with-valgrind
The vpi_callback base class is parent of the filter object of nets,
and not the functor. The good news is the clear_all_callbacks method
can now be got at without casts.
2009-09-24 15:11:56 -07:00
Stephen Williams 6cc16711db Merge branch 'master' into vvp-net-out-rework 2009-09-22 17:48:33 -07:00
Cary R c82baa2793 Only process the first 32 bits of the part select base.
When reading from thread space only read the first 32 bits
(sizeof int) for the part select base. This matches the other
parts of the PV_get_base() code.
2009-09-22 17:18:04 -07:00
Cary R 617897f3bf Add support to &PV<> for signed base values from thread space.
When calculating a value from thread space we need to tell &PV<>
if the base value is signed or not. This patch adds support for
that functionality.
2009-09-22 17:11:55 -07:00
Stephen Williams 0a72df2025 Remove vvp_signal_value from the vvp_fun_signal hierarchy.
We no longer need to access values from the signal functor. Use
the filter (the wire part) everywhere to access signal values.
2009-09-13 18:30:13 -07:00
Stephen Williams 3d5d312786 Merge branch 'master' into vvp-net-out-rework
Conflicts:
	vvp/vpi_signal.cc
2009-09-13 12:31:17 -07:00
Cary R 43f41572cb Fix 64 bit problem in vvp/vpi_signal.c
This is based on a suggested fix from Martin. It fixes the crash
for two tests in the test suite. As a bonus it is more efficient.
2009-09-13 08:18:11 -07:00
Stephen Williams 1a21b5843f Value change on part select needs to track the filter, not the functor. 2009-09-11 19:49:23 -07:00
Cary R 1b0dd8c8e5 Add support for 'bx from a signal to &PV<>
&PV<> was just using vpi_get_value() when a signal was driving
the select. This incorrectly returned 0 for 'bx or 'bz. This
patch adds a check for an undefined value and returns INT_MIN
for this case.
2009-09-08 16:01:14 -07:00
Stephen Williams 0018cb38b0 Merge branch 'master' into vvp-net-out-rework
Conflicts:
	vvp/schedule.cc
	vvp/schedule.h
2009-09-05 10:19:20 -07:00
Stephen Williams 5be1b25726 Release filter accounts for net vs variable.
When releasing a net, the release needs to propagate the driven
value. When releasing a variable, the driven value must be set
to the previously forced value.
2009-09-04 21:37:31 -07:00
Stephen Williams 1ea0d40208 Remove "net" flag to release methods.
This flag is redundant. The behavior should be handled in other ways.
2009-09-03 21:15:35 -07:00
Stephen Williams aad5029ff3 Get rid of some lingering references to vvp_fun_signal_vec::vec4_value. 2009-08-28 22:08:40 -07:00
Cary R 83c7a24cff Add missing limits.h include in vpi_signal.cc 2009-08-27 17:48:27 -07:00
Cary R 1306a6db81 Add vvp support for out of bound variable part selects.
This patch adds support for variable part selects with out of bound
and 'bx index values.
2009-08-27 13:38:41 -07:00
Stephen Williams dc47c2b6e4 Split the filter out from under signals.
Signals in vvp should not derive from their filter, they should instead
share the vvp_net with a wire that acts as its filter.
2009-08-20 20:31:11 -07:00
Stephen Williams 8bbb7ff7db Create the vvp_wire_base class to handle wires.
Take wires out of the signals/variables and move them into a filter
instead. This is a big shift, and finally starts us on the path to
divide wires out of signals.
2009-07-27 21:42:04 -07:00
Stephen Williams 682ab886d8 Implement release and deassign more directly.
There is no use implementing the release and deassign methods as
port commands. It's confusing and a waste of vvp_net_t functionality.
It also obscures what needs to be done to more force/release into
the filter object.
2009-05-15 20:49:07 -07:00
Stephen Williams 5529182f1f Spread the vvp_net.h contents out a bit.
the vvp_net.h header file is getting pretty huge. This divides
the obviously separable signal functor code out into its own
header and source files.

Also, fill out the use of the filter member of the vvp_net_t
object. Test the output of the vvp_net_t against the filter.
2009-04-15 19:08:37 -07:00
Cary R 66ce204771 The default type of a signal is a vector.
In Icarus all signals are vectors so when asking for the vpiObjTypeVal
we need to return the vpiVectorVal.
2009-02-23 16:19:48 -08:00
Cary R ec1ca8509d The cleanup of &A and &PV can nest and cleanup some VCD memory.
When cleaning up the &A<> and &PV<> we need to check if the handle
argument is a nested call to another &A<> or &PV<> if it is then
we need to also delete that construct.

We also need to cleanup the vcd_info information list.
2009-02-02 19:48:34 -08:00
Cary R 7b1905b997 Add memory freeing and pool management for valgrind.
This patch adds code to free most of the memory when vvp
finishes. It also adds valgrind hooks to manage the various
memory pools. The functionality is enabled by passing
--with-valgrind to configure. It requires that the
valgrind/memcheck.h header from a recent version of
valgrind be available. It check for the existence of this
file, but not that it is new enough (version 3.1.3 is known
to not work and version 3.4.0 is known to work).

You can still use valgrind when this option is not given,
but you will have memory that is not released and the
memory pools show as a single block.

With this vvp is 100% clean for many of the tests in the
test suite. There are still a few things that need to be
cleaned up, but it should be much easier to find any real
leaks now.

Enabling this causes a negligible increase in run time and
memory. The memory could be a problem for very large
simulations. The increase in run time is only noticeable on
very short simulations where it should not matter.
2009-02-01 06:55:28 -08:00
Cary R c419e77710 More end of simulation memory cleanup.
This patch adds some more memory freeing routines to vvp and
the vpi library. Much more to do before this is finished.
2009-01-25 07:40:28 -08:00
Cary R 3e2c828778 Add missing vpiModule handle code.
Most named objects should have a vpiModule handle to get a handle
to the enclosing module. This patch adds code to get this for all
the elements that I could find that needed it.

It also adds a three more names to vpi_get_str(vpiType, ...) and
fixes a problem in the vpiLeftRange for PV signals.
2009-01-16 18:32:27 -08:00
Cary R d2e7ea0b68 Convert $monitor to use string based formatting.
This completes the transition to the new string based formatting.
All the tasks now use the string formatting routines. Better
compile time checking and better messages were also added.

Also a couple of types were added to vpi_get_str(vpiType, ...)
and the calculation for vpiConstantSelect was fixed for both
the &A<> and &PV<> constructs. If the value is a plain variable
or if it is calculated in thread space we assume it is not a
constant.  This may not be true because of limitations/bugs in
the compiler (constant user functions are one known problem).
2009-01-15 19:42:42 -08:00
Cary R 221b83b932 Rework $plusarg routines.
This patch addresses a number of issues:

Rewrote the $test$plusargs and $value$plusargs routines to have
better error/warning messages, to support runtime strings, to
correctly load bit based values (truncating, padding, negative
value), added support for the real formats using strtod() and
added "x/X" as an alias for "h/H" to match the other part of
Icarus.

Rewrite the vpip_{bin,oct,hex}_str_to_vec4 routines to ignore
embedded "_" characters. Add support for a negative value and
set the entire value to 'bx if an invalid digit is found. A
warning is printed for this case.

Rewrite vpip_dec_str_to_vec4 to ignore embedded "_" characters,
to support a single "x" or "z" constant and to return 'bx if an
invalid digit is found. A warning is printed for this case.

It simplifies the system task/functions error/warning messages.

It removes the signed flag for the bin and dec string conversions.
This was not being used (was always false) and the new negative
value support makes this obsolete.

Add support for a real variable to handle Bin, Oct, Dec and Hex
strings. They are converted into a vvp_vector4_t which is then
converted to a real value.

Add support for setting a bit based value using a real value.

Removed an unneeded rfp signal in vpip_make_reg()
2008-11-13 15:56:29 -08:00
Martin Whitaker 04377151bc Checks for illegal use of automatically allocated variables.
This patch adds a number of compile and run-time checks for illegal
uses of variables declared in automatic tasks and functions. It
also adds a check for event expressions in automatic tasks that use
features not yet supported in VVP.
2008-11-11 20:45:19 -08:00
Martin Whitaker 18edf2f15f Rework of automatic task/function support.
This patch splits any VVP net functor that needs to access both
statically and automatically allocated state into two sub-classes,
one for handling operations on statically allocated state, the
other for handling operations on automatically allocated state.
This undoes the increase in run-time memory use introduced when
automatic task/function support was first introduced.

This patch also fixes various issues with event handling in automatic
scopes. Event expressions in automatic scopes may now reference either
statically or automatically allocated variables or arrays, or part
selects or word selects thereof. More complex expressions (e.g.
containing arithmetic or logical operators, function calls, etc.) are
not currently supported.

This patch introduces some error checking for language constructs
that may not reference automatically allocated variables. Further
error checking will follow in a subsequent patch.
2008-10-29 20:43:00 -07:00
Larry Doolittle 66949122cf Non-controversial whitespace cleanup
Nothing to do with tab width!  Eliminates useless
trailing spaces and tabs, and nearly all <space><tab>
pairings.  No change to derived files (e.g., .vvp),
non-master files (e.g., lxt2_write.c) or the new tgt-vhdl
directory.

Low priority, simple entropy reduction.  Please apply
unless it deletes some steganographic content you want
to keep.
2008-09-04 21:31:30 -07:00
Cary R 370ff9719f Make &A and &PV nestable.
This patch makes it so that &A and &PV can nest for the symbol
argument. This allows nested array selects, etc.
2008-08-27 21:09:41 -07:00
Cary R 5e512e6570 Finish $clog2 function.
This patch fixes problems in the initial $clog2 implementation
and adds correct functionality to the runtime.
2008-08-20 09:01:21 -07:00
Cary R 12783674cb Clean up compiler warning. 2008-06-25 16:34:54 -07:00
Stephen Williams 8c54803094 vpi_get_value of integer values replaces x/z bits with 0.
In arithmetic expressions, vectors with x/z are replaced with 0,
but vpi_get_value replaces x/z bits with 0 bits without replacing
the whole vector.
2008-06-25 13:59:39 -07:00