Commit Graph

530 Commits

Author SHA1 Message Date
Martin Whitaker 351a4e5f5e Improve vvp handling of excessively large shift distances. 2019-11-16 12:11:49 +00:00
Martin Whitaker 0a4cae2644 Fix vvp %shift instructions to treat right operand as unsigned.
1364-2005 section 5.1.12 says "The right operand is always treated
as an unsigned number".

This fixes GitHub issue #283.
2019-11-15 21:24:47 +00:00
Martin Whitaker 1aa22735ce Add new %cast/vec2/dar and %cast/vec4/dar instructions to vvp. 2019-09-11 21:56:27 +01:00
Martin Whitaker 74ff44314e Add new %cast/vec4/str instruction to vvp. 2019-09-11 21:56:09 +01:00
Martin Whitaker 2ff6af254b Use LLONG_MIN instead of LONG_LONG_MIN.
GCC 8 no longer defines LONG_LONG_MIN. We already assume a C99 compliant
compiler in other places.
2019-01-26 16:47:28 +00:00
Martin Whitaker 7ad5b59a6f Fix for GitHub issue #199: handle signed division overflow.
When performing a signed division or modulus operation using native
arithmetic, trap the special case that the numerator is the minimum
integer value and the denominator is -1, as this gives an undefined
result in C++.
2018-06-12 21:59:58 +01:00
Cary R db1ea05452 Fix #0 to trigger in the inactive region and add a trigger for always_comb/latch 2017-12-03 20:17:42 -08:00
Cary R 3fc9ad2db0 Add support for the wild compare operators ==? and !=? 2017-11-17 19:32:50 -08:00
Martin Whitaker e315cafa01 Fix for GitHub issue #165 : assertion failure on thread join.
If a thread becomes detached due to a join_any statement, that
thread must not attempt to join its parent, even if the parent
is waiting on a subsequent join statement.
2017-10-07 16:41:26 +01:00
Martin Whitaker a1a7f5deff Fix error in last commit. 2017-09-17 19:58:13 +01:00
Martin Whitaker 0bed890bc6 Fix use after free bug in vvp when a task or function is disabled.
Use test_joinable() and do_join() to ensure everything gets cleaned
up before the thread is reaped. This should fix br1016, br1017, and
br1018.
2017-09-17 19:48:54 +01:00
Maciej Suminski f32b64f497 Fixed warnings about shifting a negative value 2016-09-19 12:54:15 -07:00
Martin Whitaker 61c82d2cb0 Handle mixed continuous and non-blocking assignments to same vector.
SystemVerilog allows a mixture of procedural and continuous assignments
to be applied to different parts of the same vector. The previous attempt
to make this work for non-blocking assignments was flawed (see preceding
fix for vvp_fun_part_pv::recv_vec4_pv). Instead, handle this case by
converting the non-blocking assignment into a delayed force statement,
which matches the way mixed continuous and blocking assignments are
handled.
2016-05-10 22:16:40 +01:00
Larry Doolittle 4521be4510 More spelling, comments only 2016-04-01 11:02:34 -07:00
Stephen Williams 9a7f31c728 Functions that return strings pass the return value on the stack. 2016-03-01 15:38:28 -08:00
Cary R 841593d013 Remove some compile warnings 2016-02-03 21:40:18 -08:00
Stephen Williams 76ced1cf7c Fix %ret/* and %retload/* opcodes to search up for function thread. 2016-02-01 14:51:18 -08:00
Stephen Williams f494b478cc Merge branch 'master' into return-stack
# Conflicts:
#	sv_vpi_user.h
2016-02-01 14:47:44 -08:00
Stephen Williams ce692f90ad Implement and use the %retload/real opcode. 2016-02-01 09:31:06 -08:00
Stephen Williams 604a62379c Make .scope aware of return type, and extend %ret/vec4 operands
The .scope needs to be aware of return types so that the %call/vec4
function knows how to intialize the return value. We also need to
extend the %ret/vec4 to support writing parts of the return value.
2016-01-31 15:29:52 -08:00
Stephen Williams e435a879fc Add ability to read back return value / Add vec4 stacked user functions.
Also:
- handle functions as arguments to system tasks.
- Cleanup detect of signal as return value.
2016-01-24 18:36:26 -08:00
Stephen Williams 0c91a6b041 Add .ufunc/real functor to handle functions with return value on stack. 2016-01-17 16:23:28 -08:00
Stephen Williams bfc9cd8715 Make real functions in processes use parent stack for return value. 2016-01-10 17:09:33 -08:00
Maciej Suminski df6b24fd3a ivl & vvp: Enabled 'string' as the return type in VPI functions. 2016-01-05 14:23:25 +01:00
Stephen Williams 63ad15ee2e Rework user function calls to use specialized opcodes.
Create The %callf/* opcodes to invoke user defined functions in a
more specialized way. This allows for some sanity checking on the
way, and also is a step towards keeping return values on stacks.
2015-12-27 20:29:10 -08:00
Stephen Williams fff69390ac C++-ify the __vpiScope classes. 2015-12-20 20:26:57 -08:00
Stephen Williams 466b6464bc Some minor vvp runtime performance tweaks. 2015-10-01 12:43:56 -07:00
Stephen Williams 4338d43cea Opcodes documentation fixes. 2015-09-30 16:25:35 -07:00
Stephen Williams fe7156289b Remove some useless vvp opcodes. 2015-09-30 15:41:22 -07:00
Frederick C. Kurz c35f2f8334 Changes to vvp/vthread.cc
"child->delay_delete = 1;" was added, for when building with "Microsoft Visual Studio Express 2015 RC Web" in DEBUG mode, so that pr2909555.v would pass with -strict, otherwise it would cause memory access error will trying to access the previously deleted "child" variable.
2015-07-22 18:02:45 -07:00
Martin Whitaker 97c6339241 Ensure VPI release on net connected to island returns correct value. 2015-07-01 09:00:43 +01:00
Martin Whitaker dad223316e Fix propagation of unforced bits when forcing a part select.
vvp_net_t::force_vec4 propagates all bits of the forced value passed
to it, regardless of the mask value. I can't see any way to fix this
directly, so instead make sure anything that calls force_vec4 sets
the unforced bits of the passed value to the correct value.
2015-06-25 00:13:57 +01:00
Larry Doolittle 2739f83702 Spelling fixes in C and C++ comments 2015-06-04 15:00:29 -07:00
Cary R feb710a186 Add support for any width 2-state darray objects 2015-02-27 11:43:25 -08:00
Cary R 62abb199d7 Add support for 4-state dynamic arrays 2015-02-26 17:56:49 -08:00
Cary R 47688d234b Assert if an unsupported dynamic array type is given. 2015-01-16 18:54:43 -08:00
Martin Whitaker 0282b8450c Fix potential memory leak when a thread is disabled.
A disable statement can terminate a thread whilst it still has
local variables on the stack (e.g. the loop counter for a repeat
statement). We need to clear the thread stacks when this happens.
2014-12-11 20:10:17 +00:00
Cary R 48b0fed29e Use uint64_t casting of constants since UL does not work on 32-bit machines
Using a UL constant in a unit64_t context does not work on a 32-bit
machine since UL is 32-bits. Instead create uint64_t constants using
static casts and the appropriate bit operators.
2014-12-10 14:41:18 -08:00
Martin Whitaker 0d7daf5862 Fix vvp memory leak for user function calls in a continuous assignment. 2014-12-07 13:47:50 +00:00
Stephen Williams 409f8c5823 Add the vec4 %subi instruction 2014-12-05 09:45:29 -08:00
Stephen Williams 03198356a5 vec4-stack stack manipulation improvements. 2014-12-04 17:15:27 -08:00
Stephen Williams b1d2393789 Optimize the %sub instruction by integrating it with vvp_vector4_t class 2014-12-04 17:01:16 -08:00
Stephen Williams 0f740289e9 Optimize %mul instructions by integrating with vvp_vector4_t class. 2014-12-04 16:00:57 -08:00
Stephen Williams 46ce236cfb Optimize the %add and %addi instructions
Tightly integrate with the vvp_vector4_t class to get much
better add performance.
2014-12-04 12:38:08 -08:00
Stephen Williams 86139c855d Optimize the vec4-stack %cmp/s and %cmpi/s instructions.
Magnitude compare is called a LOT, so it is worth putting some
special effort into it.
2014-12-04 10:42:48 -08:00
Stephen Williams eb070b061b Optimize the vec4_to_index, which implements %ix/vec4 instructions. 2014-12-03 17:53:45 -08:00
Stephen Williams 2b1393e7b9 Reduce some vector copies in %load/vec4 and %concat/vec4 instructions.
By clever stack manipulations, we can eliminate some vector copies,
which can improve performance.
2014-12-03 13:12:06 -08:00
Stephen Williams 85c7b07a9b Implement %cmp/ne and %cmpi/ne
These pull in the inversion of the output flags so that they more
efficiently implement != and !==, without %flag_inv instructions.
2014-12-03 11:06:11 -08:00
Stephen Williams 58fb80aec4 Implement and put to use the %muli instruction. 2014-12-02 12:46:17 -08:00
Stephen Williams 38f277d81b Merge branch 'master' into vec4-stack
Conflicts:
	vvp/array.cc
	vvp/vthread.cc
2014-12-02 11:21:58 -08:00
Maciej Suminski 7c77097f71 vvp: array_[set/get]_word changed to __vpiArray::[set/get]_word. 2014-11-28 14:14:42 +01:00
Maciej Suminski cc4c5f4998 vvp: Changed get_array_word_size(vvp_array_t) to __vpiArray::get_word_size(). 2014-11-28 14:14:42 +01:00
Stephen Williams 679021a1b5 Optimize special cases of immediate value extraction. 2014-11-22 10:38:16 -08:00
Stephen Williams f3392561ed Optimize the vvp pad implementation. 2014-11-22 09:59:02 -08:00
Stephen Williams c222b3b6a4 Minor improvements to the %split/vec4 instruction. 2014-11-21 16:51:59 -08:00
Stephen Williams 663c79d4af Add the %cmp/e instructions, and put them to use.
When testing for == and ===, there is no need to also calculate <,
so it makes sense to have a special instruction for these cases.
2014-11-21 16:45:27 -08:00
Stephen Williams bea03db25d Minor vec4 stack manipulation optimizations. 2014-11-21 14:41:31 -08:00
Stephen Williams b96f04ccce Implement the %parti/X instructions
This allows part select with constant base to be handled optimally.
Also update some more instructions to more optimally work with
the vec4 stack.
2014-11-20 18:43:24 -08:00
Stephen Williams a9db765f98 Generate better code for condition expressions. 2014-11-20 14:47:44 -08:00
Stephen Williams 04bdfbccee Add %cmpi/s and %cmpi/u instructions for performance
These bypass the vec4 stack in some common cases, saving instructions
and vec4 manipulations.

Also, minor improvement to the %flag/set/vec4 statement.

Kill a few warnings.
2014-11-19 16:38:43 -08:00
Stephen Williams 2acc9fbdee Remove dead instructsion %set/qb and %set/qf / Kill some warnings. 2014-11-19 09:15:01 -08:00
Stephen Williams 725ed869ba Remove dead %load/vp0 instructions and related infrastructure
Also remove some &A<> and &PV<> symbols that use this now dead
infrastructure.
2014-11-19 09:02:21 -08:00
Stephen Williams 301edf69d3 Add and use %concati/vec4 and %addi instructions.
Also, clean up some warnings, and optimize some existing opcodes.
2014-11-18 12:27:55 -08:00
Stephen Williams 1612c6d638 Instruction %concat/vec4, %pad/u and %shiftl manipulate stack in place 2014-11-17 16:32:18 -08:00
Stephen Williams aadd67cd3b Some instructions can do stack manipultations in place.
By doing some stack manipulations in place, certain instructions
can eliminate, or optimize, vector copies.
2014-11-14 18:38:15 -08:00
Stephen Williams 0601b4e43b Optimizations for %pushi/vec4 and %load/vec4
- Have %pushi/vec4 handle some special cases optimally.
- Eliminate some duplicated method calls in %load/vec4.
- Optimize the vvp_vector4_t::copy_from_ method by inlining
some parts.
2014-11-14 14:41:04 -08:00
Stephen Williams 8aca66b109 Performance tweaks
Better performance for %cmp/s and the vvp_fun_part_sa node.
2014-11-14 11:48:36 -08:00
Martin Whitaker c2e53f0d63 Fix for br963 - vvp qpop instructions need to call thr_check_addr. 2014-11-02 15:36:52 +00:00
Stephen Williams 48d3972299 Remove a bunch of dead vvp opcodes. 2014-10-24 15:13:28 -07:00
Stephen Williams 09d3a5de59 Port %pushv/str to vec4-stack style. 2014-10-24 10:16:35 -07:00
Stephen Williams 97bde47c31 Remove dead %set/dar and %set/dar/obj instructions. 2014-10-24 10:03:22 -07:00
Stephen Williams 4588f7c615 vec4 stack versions of queue pop methods. 2014-10-24 09:03:20 -07:00
Stephen Williams 35f5d51028 Support testing nul for property that is an object. 2014-10-22 12:58:50 -07:00
Stephen Williams 9964d67e5e Implicit crop of vectors assigned to vector properties.
The %store/prop/v takes a width so that it is guaranteed that
all assignments to a vector property will get the size right.
2014-10-21 11:46:59 -07:00
Stephen Williams a98f21aa65 Merge branch 'master' into vec4-stack
Conflicts:
	elab_lval.cc
	netmisc.cc
	tgt-vvp/eval_object.c
	tgt-vvp/vvp_process.c
	vvp/codes.h
	vvp/compile.cc
	vvp/opcodes.txt
	vvp/vpi_tasks.cc
	vvp/vpi_vthr_vector.cc
	vvp/vthread.cc
2014-10-21 09:12:02 -07:00
Cary R f36bebf0e1 Remove some compile warnings. 2014-10-13 16:31:53 -07:00
Stephen Williams 98799ff7fa Allow class properties to be arrayed.
This adds the runtime support for class properties that are classes
to be arrayed. Add a means to define the dimensions of a property
in the vvp format, and add functions for setting/extracting elements
of a property.
2014-09-15 17:37:30 -07:00
Stephen Williams facc982af4 Ability to compare arbitrary class-valued expression to nil. 2014-09-07 16:22:49 -07:00
Stephen Williams dec4cd5071 Handle arrays of class objects.
This goes all the way down to the vvp level, where we create support
for arrays of objects, generate the new code in the -tvvp code
generator, and elaborate the arrays in the first place.
2014-08-30 10:18:57 -07:00
Stephen Williams 335db49282 Add vvp implementations for pop_back and pop_front methods. 2014-08-21 16:44:46 -07:00
Stephen Williams c9ff48bd4e Add support for dynamic array/queue "last" index ($)
Internally, treat the "$" as a special expression type that takes
as an argument the signal that is being indexed. In the vvp target,
use the $last system function to implement this.
2014-08-21 16:44:45 -07:00
Stephen Williams da63ef02d4 Implement the size method for queues.
This works by translating it to a $size() system function call.
The $size function is already implemented for dynamic queues and
it is easy enough to expand it for queues.
2014-08-21 16:44:45 -07:00
Stephen Williams d891285326 vvp code generation for push_back/push_front for queue objects. 2014-08-21 16:44:45 -07:00
Stephen Williams 88e4938074 Merge branch 'master' into vec4-stack 2014-03-04 19:08:56 -08:00
Stephen Williams 4068570f43 Fix %pow and %pow/s to properly account for 'x operands. 2014-03-01 16:11:47 -08:00
Martin Whitaker 3e41a93f3e Fix for br948 : user-func call may return incorrect value in a CA context.
%exec_ufunc assumed that because a function can never block, a call to
vthread_run() on the function code would only return when the final %end
instruction had been executed. This is not true if the function contains
a named block, which will be executed via a %fork instruction, allowing
the main function thread to suspend after a %join instruction. The fix
is to break %exec_ufunc into two instructions, the first setting the
function inputs and executing the function code, the second collecting
the function result. This provides the opportunity for the parent thread
to suspend after the %exec_ufunc instruction until all its children have
completed.
2014-03-01 23:38:23 +00:00
Stephen Williams 7ceb18fb37 Merge branch 'master' into vec4-stack
Conflicts:
	netmisc.cc
	tgt-vvp/eval_expr.c
	vvp/vthread.cc
2014-03-01 09:02:14 -08:00
Martin Whitaker 1f81d4c081 Fix for br947.
When performing the initial assignment for a procedural continuous
assignment, any previous continuous assignment to the destination
signal must be unlinked first, otherwise the initial value for the
assignment will propagate to any other nets that are driven by the
original source signal.
2014-02-26 08:39:33 +00:00
Stephen Williams 91b7c6ab55 Merge branch 'master' into vec4-stack
Conflicts:
	vvp/vthread.cc
2014-02-21 18:04:16 -08:00
Stephen Williams ebed793dec Merge branch 'master' into vec4-stack
Conflicts:
	vvp/vthread.cc

Signed-off-by: Stephen Williams <steve@icarus.com>
2014-02-21 17:34:59 -08:00
Martin Whitaker 345c9cf21c Implement correct behaviour for signed vector power operations in vvp.
Signed vector power operations were being implemented using the double
pow() function. This gave inaccurate results when the operands or
result were not exactly representable by a 64-bit floating point number.
2014-02-19 20:11:57 +00:00
Martin Whitaker 5853f7d867 Fix for GitHub issue 9 part 1 : Efficiency of vvp_vector2_t::pow() function.
The vvp_vector2_t::pow() function is recursive, and performs a multiplication
operation on each step. The multiplication operator was expanding the result
vector to accomodate the maximum possible result value for the given operand
vectors, thus causing the execution time of the power operation to be
exponentially proportional to the exponent value. Both in this case and
in general, it is unnecessary for the multiplication result vector to be
expanded, as the compiler has already determined the required vector width
during elaboration, and sizes the operand vectors to match.
2014-02-15 21:40:55 +00:00
Martin Whitaker 68f8de28af Fix for GitHub issue 7 : Undef propagation in power operator.
The vvp_vector2_t constructor that takes a vvp_vector4_t value was
documented as creating a NaN value if the supplied vector contained
any X or Z bits, but instead used the standard Verilog 4-state to
2-state conversion semantics (X or Z translate to 0). I've added an
optional second parameter to the constructor to allow the user to
choose which semantics they want, as both are needed.
2014-02-15 13:14:45 +00:00
Stephen Williams 801e795112 Better job of matching adder operand sizes for vec4 code generator. 2014-02-10 18:06:56 -08:00
Stephen Williams 554fb7ebdd Various internal vec4 size mismatches fixed. 2014-02-07 17:50:13 -08:00
Stephen Williams c9e8392dc7 Fix dangling vec4 stack when force assignment is suppressed.
Also improve the %debug/thr instruction.
2014-02-07 16:10:28 -08:00
Stephen Williams 60d37e1f53 More vec4 support for various things. 2014-02-07 11:24:41 -08:00
Stephen Williams 401fccdf6e vec4 handling of DARRAY of vec4 vectors. 2014-02-06 15:05:26 -08:00
Stephen Williams 1805598eae Fix some vec4 handling of putc, len, and other string methods. 2014-01-31 19:01:28 -08:00
Stephen Williams 23ba0bc019 various vec4 fixes. 2014-01-25 19:25:21 -08:00