Commit Graph

234 Commits

Author SHA1 Message Date
Cary R fc7e7640ed Remove some MinGW32-w64 compile warnings. 2012-01-05 17:26:08 -08:00
Cary R cc5efa45ba Fix two bugs and use the more efficient !empty() vs size() > 0
These two bugs were found with a recent cppcheck addition. It also
changes one occurrence of size() > 0 for the more efficient ! empty().
2011-11-22 19:44:55 -08:00
Prasad Joshi fa589badd8 Add support for increment and decrement operators
This patch adds support for increment/decrement operators as an
expression. The operations on real and vector slices have been
disabled for now.

These operators can be used as in independent statements. However, the
corresponding support is not added in parser.

Changes since V2:
- Additional error checking in elaboration to deny operation on vector
slices and real (suggested by Martin)

Changes since V1:
- Use 'i' and 'I' for increment (suggested by Cary)
- Evaluate sub-expression once (suggested by Cary and Stev)
- Add necessary checks during elaboration to ensure that the
	expression is valid (suggested Stev)
- Proper width handling with vectors (suggested by Martin)

Signed-off-by: Prasad Joshi <prasad@canopusconsultancy.com>
2011-08-11 14:25:19 -07:00
Prasad Joshi 6a40d9edaa Change the net expression cast from 'i' to 'v'
Icarus uses 'i' in the net expressions for a cast to integer. Replacing
it with 'v' would free the character 'i' that can be used for increment
operators. This changes cast operators to become 'v', '2', and 'r'.

Signed-off-by: Prasad Joshi <prasad@canopusconsultancy.com>
Suggested-by: Cary R. <cygcary@yahoo.com>
2011-08-07 11:40:34 -07:00
Cary R 836e61e878 Fix spacing issues in the code.
Remove space at the end of line and space before tab since they serve
no purpose.
2011-07-30 09:33:28 -07:00
Stephen Williams 4989555646 Fix unary convert of real to bool
Sometimes real values are converted to BOOL values, and the
NetECast needs to handle it properly.
2011-07-20 18:45:13 -07:00
Martin Whitaker 2176212e2b Miscellaneous improvements and fixes to shift elaboration.
This patch ensures that the result of a shift is an undefined value
if the right operand is an undefined value. It also improves the
code generated for right shifts where the right operand is constant
and optimises away shifts where the right operand is a constant 0.
It also fixes a few places where the expression type (signed/unsigned)
was not being set correctly.
2011-03-14 16:37:40 -07:00
Larry Doolittle e9fda22ad9 Spelling fixes
Mostly then/than confusion.  All comments or README files,
except for one user-visible change in a tgt-vlog95 error message.
2011-03-14 16:28:36 -07:00
Cary R 06447817d3 Add support for tracing procedural statements.
This patch adds support for tracing procedural statement execution in vvp.
This is accomplished by adding a new opcode that is inserted before the
code that represents a procedural statement. These opcodes also trigger
a message whenever time advances. By default these opcodes are not added.
To add them, pass the -pfileline=1 flag to the compiler. In the future we
may add support for turning the debug output on and off once the opcodes
have been added with a system task or from the interactive prompt.
2011-03-01 18:45:29 -08:00
Martin Whitaker b08120e223 Patch to improve sign extension efficiency in vvp.
Currently the vvp target emits multiple single bit %mov instructions
to perform sign extension. This patch adds a new %pad instruction
that allows sign extension to be performed with just one instruction.
2011-02-01 18:05:09 -08: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
Stephen Williams 3733c59e49 Merge branch 'work1' 2010-10-21 19:31:49 -07:00
Stephen Williams b081818a90 Cast expressions from logic to bool.
Handle assignments from logic to bool variables by inserting
the proper cast expression nodes.
2010-10-19 19:09:06 -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 ec49f10e2d Revert bad merge from vhdl branch 2010-10-02 11:02:27 -07:00
Stephen Williams c4c7a619ea Merge branch 'vhdl' 2010-10-01 15:13:29 -07:00
Larry Doolittle 6388430661 Down payment on const-correctness
Clears out the unambiguous and easy-to-fix const faults,
so we can focus better on the fundamental ones.
2010-09-29 17:15:40 -07:00
Larry Doolittle b909c74a20 Spelling fixes
All fixes are in comments, except for one error message (was "iternal error")
2010-09-22 10:43:32 -07:00
Cary R cac725ed3d Fix signed/unsigned compare warnings.
Fix all the Icarus files that can be so that we do not have any
signed/unsigned compare warnings. It also removes const as a
return qualifier for two routines in discipline.h.
2010-09-22 09:09:26 -07:00
Cary R dd4fb9b4ef Fix spacing issues.
This patch removes space before a tab and space or tab before end
of line.
2010-09-19 13:21:59 -07:00
Cary R 029a61d074 Fix the white space errors in tgt-vvp 2010-07-30 18:59:38 -07:00
Cary R a8198b38fb Add unlimited tail recursion for the real ternary operator.
This patch modifies the real ternary operator code to support
unlimited tail recursion without overflowing the thread
registers. Head recursion is still limited by the available
registers.

It fixes the thread word checks to use a new define that has
the correct number of thread words (16). It adds a message
instead of just an assert if the thread words are exhausted.

And it also changes some of the error messages to use vvp.tgt
in the message to be consistent with the other messages.
2010-07-11 17:24:37 -07:00
Cary R 21d15ceece Fix the compiler and modpath scaling of real delays.
A real delay must be scaled and rounded using the local precision
before it is finally scaled to the simulation time units. This
patch fixes the compiler to do this correctly or generate the
correct code for run time calculated delays. Delays in a CA
already worked correctly. The run time was also fixed to scale
modpath (SDF back annotation) delays correctly.
2010-06-18 16:11:54 -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 15a0cf4256 Fix shadow warnings found on OpenBSD.
gcc on OpenBSD reported shadow warnings for variables, arguments named
log, time and exp. This patch renanes those variables to logic, timerec
and expr.
2010-05-28 07:03:02 -07:00
Cary R 7969a58eeb Fix some large/negative immediate value compiler bugs.
Fix how immediate values are checked and allow a large negative
value to be returned from get_number_immediate().
2010-05-24 18:40:16 -07:00
Cary R b91657dbb9 Fix a few more cppcheck issues.
Here are some more cleanups recommended by cppcheck. Mostly fixing the
variable scope and removing some unneeded code.
2010-04-23 11:40:26 -07:00
Cary R 9a94d55738 Ignore zero replication constants.
This patch enhances elaboration to drop/ignore zero replication
count constants. Not doing this was causing problems later in
the compiler. We still pass non-constant expressions since
both user and system functions must be run for their possible
side effects. Constants can never have a side effect so just
dropping them is acceptable.
2010-03-22 18:02:28 -07:00
Cary R d5c10af4f4 NB-assign needs to convert reals at the l-value width.
This patch mimics what was done for normal assignments to get the
width correct for nonblocking assignments when converting a real
r-value to a l-value vector.
2010-03-16 15:39:57 -07:00
Stephen Williams 3927917133 Handle selects unsized literal values accounting for bit extension.
When selecting bits from unsized literals, we do not put a limit
on the size of the literal, so there is no top above which we
stop getting literal bits.
2010-03-06 16:21:10 -08:00
Stephen Williams 33e52c50c0 Handle special case bit selects if unsized 0/-1.
Unsized constant 0 and -1 are pretty special, and part selects
of these values can be handled very specially.
2010-03-05 19:36:54 -08:00
Cary R 458258d554 A signal select is signed if the select not the signal is signed.
The padding for a signal select was using the signal to determine
if the padding should be singed or not. In reality this should be
unsigned padding unless the select was enclosed in a $signed().
2010-01-06 13:47:24 -08:00
Martin Whitaker b416176c4d Fix for pr2913404.
In combination with the patch to make all operations on thread words
operate on 64-bit values, this patch ensures casts between real values
and large vector values work correctly.
2009-12-21 09:59:12 -08:00
Cary R dff6a1ebff Add file/line information to named events and better expr. error.
This patch adds file and line number information to named events.
It also modifies the draw_eval_expr_wid() routine to fail with
an appropriate message for named events. This checking needs to
be pushed into the elaboration stage, but this will give a better
message than we had before.
2009-09-08 15:58:24 -07:00
Cary R 2b17366ad5 Major rewrite of indexed part selects.
This patch is a major rewrite of the indexed part selects (+: and -:).

It made the following enhancements:

1. Make indexed part selects work correctly with both big and little
   endian vectors.

2. Add a warning flag that warns about constant out of bounds/or 'bx
   indexed selects.

3. Moved the -: parameter code to its own routine.

4. Added support for straddling before part selects in a CA.

5. Added more assert(! number_is_unknown) statements.

6. Add warning for &PV<> select with a signed index signal that is
  less than the width of an int. This will be fixed later.

7. Add support for loading a 'bx/'bz constant into a numeric register.

8. Add a number of signed value fixes to the compiler/code generator.

9. Major fix of draw_select_expr() in the code generator.
2009-08-31 11:22:58 -07:00
Cary R e362a86b16 Fix procedural concatenation/repetition problems
This patch evaluates the whole concatenation expression and
makes the concatenation padding sign aware. This is needed
when $signed({...}) is passed as an argument.

A repetition is just N copies of the base expression not N
evaluations of the base expression. This is only a problem
when functions have side effects. It's also faster to copy.
The evaluation must also be done when the replication count
is zero (see 1364-2005).
2009-07-28 19:45:26 -07:00
Cary R 236f56949f Use correct sign for signal and constant addition.
This was incorrectly using the expression sign not checking if
the two sub-expressions are both signed. This likely used to
work, but in the context of $signed which sets the expression
to signed so we can have a signed expression without both
sub-expressions being signed.
2009-07-03 19:33:35 -07:00
Larry Doolittle b0c4a87133 Spelling fixes
Mostly comments, but includes user-visible debug messages.
2009-03-09 14:39:36 -07:00
Stephen Williams fa02455f36 Delays expressions are 64bit integers.
Fix the PDelay processing to account for the fact that delay expressions
are 64bits. Use int64_t instead of unsigned long.
2009-02-25 21:30:05 -08:00
Stephen Williams 1c17412223 Allow constant delay literals to be handled as 64bits.
This is mostly a minor definition change in the parsing of literal
numbers by the vvp lexor. Allow for 64bit numbers in the .delay
records, and have the code generator also able to cope with the
situation.
2009-02-24 13:50:18 -08:00
Cary R 5ae86bd6b4 Add support for 64 bit delays in procedural non-blocking assignments.
This patch adds support for 64 bit non-blocking delays in procedural
code. We fixed the procedural delay operator (blocking delays) earlier.
This patch mostly mimics what was done there. The continuous assignment
delay operator still needs to be fixed.
2009-02-17 10:32:11 -08:00
Larry Doolittle 9ff319b39b Shadow reduction part 5
Continue cleaning up shadowed variables, flagged by turning on -Wshadow.
No intended change in functionality.  Patch looks right, and is tested
to compile and run on my machine.  No regressions in test suite.

This patch set covers C code, with the notable exception of
vpi/lxt_write{,2}.c.
2008-12-18 16:42:55 -08:00
Cary R 2ce9841354 A power needs to use the signed (real pow) if either argument is signed.
The power operator is different in that it uses the signed version
if either of it's arguments are signed. This patch fixes the code
generator to do this correctly.
2008-11-28 10:44:31 -08:00
Stephen Williams 4de891d096 Support drawing some select expressions in place.
Select of signals is natural for evaluating in place, if possible.
Doing so can save instructions for certain expressions.
2008-11-22 21:17:05 -08:00
Stephen Williams 83a7497912 Lor takes advantave of STUFF_OK_47
It is ot uncommon for the arguments to logical or to leave stuff
in bit registers 4-7. Allow the lor itself to take advantage of
that to save some %mov instructions.
2008-11-22 10:45:15 -08:00
Stephen Williams bc8b97dbcd Pad expression in place
When padding expressions, pre-allocate the target space and calculate
the sub-expression directly into the target. Then pad from there. This
saves a move into the result space.
2008-11-21 21:12:40 -08:00
Cary R e191fcdd28 A non-negated reduction needs to change a 1'bz into a 1'bx.
In a procedural single bit non-negated reduction (&, | or ^)
we need to translate a 1'bz to a 1'bx. The easiest way to do
that is with two %inv opcodes. This patch modifies the code
generator to do this for this very special case.
2008-11-17 19:55:25 -08:00
Cary R dc6a9e03c9 Shifting a signed constant should just return the L-value.
We already covered the case of shifting zero, but the case of
shifting a signed constant was missed.
2008-11-14 21:48:09 -08:00
Martin Whitaker 416bd35f2e Fix for leak in thread vector allocation.
In the vvp code generator, when zero/sign extending a sub-expression,
the sub-expression is first evaluated and stored in one location in
the thread vector store, then is copied and extended into a second
location. The storage used for the initial sub-expression evaluation
is never deallocated.
2008-11-12 22:12:00 -08:00
Stephen Williams 87654f8661 Fix bug generating code for shift of constant zero.
The code generator detects this case, but instead of returning the
constant zero, it breaks out and writes partial code for the shift.
2008-11-12 21:46:23 -08:00