Commit Graph

5049 Commits

Author SHA1 Message Date
Cary R f8caebd076 Convert real array index to integer.
This patch converts a constant real index to an integer value when
defining an array. This can happen when using 2**8 which returns a
real value since the operands are signed.
2008-02-27 18:00:21 -08:00
Cary R 70c5c9fe14 Propagate file and line information in more places.
There where a few places that were not propagating the file and
line information.
2008-02-27 17:31:20 -08:00
Stephen Williams 75df8fb6bb Remove index register restrictions on ix/arith instructions.
The %ix/<arith> instructions are currently not in use, but even so
it is just plain wrong to restrict their register argument to 0-3.
2008-02-27 17:01:53 -08:00
Cary R ec87c7f6de Fix %ix/load to work with all index registers.
draw_number_bool64() in tgt-vvp/eval_bool.c was using %ix/load to
load immediate values into registers greater than three. The problem
was that of_IX_LOAD() in vvp/vthread.cc was masking off the upper
bits. This was putting the results in the wrong register. This patch
removes the bit masking from of_IX_LOAD() and updates the %ix/load
documentation.
2008-02-27 16:54:38 -08:00
Cary R b5ef6d7a37 Fix some problems in driver-vpi/main.c
Fixed a few problems in driver-vpi/main.c that were preventing
the Verilog-A math library from compiling.
2008-02-25 16:01:59 -08:00
Cary R 285ff2859f Add power operator synthesize().
This patch adds synthesize() for the power operator.
2008-02-25 15:57:56 -08:00
Michael Witten a01bc5e245 ivlpp: Cleanup: Formatting/Detabification
The file lexor.lex was beginning to suffer a catastrophic
increase in entropy due mainly to the mingling of spaces
and tabs--an age-old problem that often finds itself as
the subject of many a religious war.

The key rule: Make it consistent in as many editors as
possible; this was achieved by converting all hard tabs
into soft tabs (composed of spaces) of width 4.

I couldn't help but make modifications to the code as I
tabifified, but most of the changes are strictly style.

While maintainers generally treat large scale whitespace and
formatting changes with much caution, I believe that the code
is now much more maintainable; moreover, the test suite
produces the same results as before.

Signed-off-by: Michael Witten <mfwitten@mit.edu>
2008-02-25 15:52:41 -08:00
Michael Witten c6ce3f6f38 ivlpp: Error checking for macro names
Macro names cannot be compiler directive names.
Such trespasses are now recognized and reported:

    (1) Offending `define lines are skipped.

    (2) Offending macros meant to be expanded
        are replaced with nothing.

Signed-off-by: Michael Witten <mfwitten@mit.edu>
2008-02-25 15:51:34 -08:00
Cary R fac1cc5a1c Add user function synth and clean up expression code.
This patch adds synthesize() for user functions. It also cleans up a
number of inconsistencies and missing checks in the expression code.
2008-02-24 20:00:18 -08:00
Stephen Williams 11a33a0907 Merge branch 'pscope' 2008-02-24 19:45:21 -08:00
Stephen Williams 8e704cbf93 Rework handling of lexical scope
Move the storage of wires (signals) out of the Module class into
the PScope base class, and instead of putting the PWires all into
the Module object, distribute them into the various lexical scopes
(derived from PScope) so that the wire names do not need to carry
scope information.

This required some rewiring of elaboration of signals, and rewriting
of lexical scope handling.
2008-02-24 19:40:54 -08:00
Cary R 3716e972ec Add support for unary +/- in real parameter evaluation.
This patch adds support for unary + and - of real value constants
to the eval_tree() functionality.
2008-02-20 17:24:44 -08:00
Cary R 538d3d1f4d Print an error message if $fscanf() is called with a NULL fd.
If $fscanf() is called with a NULL file descriptor an appropriate
error message is printed and the program exits.
2008-02-20 17:16:52 -08:00
Cary R 528af27769 Fix a realloc size error and initialize enable_ in the dff.
The buffer reallocation in scan_format_string() was one character
too small. The enable_ pin to the dff primitive was not given an
initial value.
2008-02-19 10:06:44 -08:00
Michael Witten 2bd13964cd ivlpp: Slight rearrangement of do_include()
The ordering of the logic was a little strange before.
Also, there were unnecessary operations, like the assert
and the include_dir[0]=0 business.

Signed-off-by: Michael Witten <mfwitten@mit.edu>
2008-02-19 09:56:18 -08:00
Michael Witten 105885402f ivlpp: Fixed include_path inconsistency
Discussions online and "standards" documents are never
conclusive, but the code that was present suggests that
iverilog adopts the sane practice of resolving relative
paths against the directory of the file that is currently
being processed.

Unfortunately, when a relative path is made absolute, the
code forgot to update the necessary include_stack_t object.

This has now been fixed.

Signed-off-by: Michael Witten <mfwitten@mit.edu>
2008-02-19 09:56:18 -08:00
Michael Witten b512671643 ivlpp: Removed yywrap() to handle EOF more sanely
When the lexical analyzer encounters and EOF, the
analyzer invokes yywrap() to determine what to do
next. The function determines one of two paths of
execution:

	(1)	If yywrap() returns 0, then the analyzer
		assumes that yywrap() has setup a new input
		source, and so scanning continues.

	(2)	If yywrap() returns non-zero, then the analyzer
		assumes that yywrap() has not setup a new input
		source, and so the analyzer proceeds to run the
		matching EOF action (the default of which invokes
		yyterminate()).

	NOTE:	The analyzer does not touch the start condition.

The old implementation was using yywrap() to destroy the current
input source and setup the next one. However, this causes problems
when the analyzer is in the middle of parsing some directive:

	(1)	Because yywrap() is called before any EOF action,
		the include_stack_t structure is destroyed before
		being used in the EOF action; the result is a segfault.

	(2)	Because yywrap() does not change the start condition,
		any EOF action would occur completely out of context;
		however, because of (1), this problem never cropped
		up.

The new implementation simply:

	(1)	Employs "%option noyywrap", which effectively causes
		the analyzer to act as though yywrap() produces a non-zero.

	(2)	Renames yywrap "load_next_input".

	(3)	Calls load_next_input() explicitly in exhaustive EOF actions,
		so that control is more fine grained.

The added benefit is that the code that finishes parsing EOF terminated
directives now works properly; `include and `define directives previously
segfaulted in such situations.

Signed-off-by: Michael Witten <mfwitten@mit.edu>
2008-02-19 09:56:18 -08:00
Michael Witten c064451e15 ivlpp: Formatting/Simplification
Code is now shared among rules.

Signed-off-by: Michael Witten <mfwitten@mit.edu>
2008-02-19 09:31:02 -08:00
Michael Witten 73f8c2e68c ivlpp: Fixed incorrect lineno
Signed-off-by: Michael Witten <mfwitten@mit.edu>
2008-02-19 09:31:02 -08:00
Michael Witten 6103a72927 ivlpp: Removed delayed_close
This variable was used in yywrap purportedly to obviate
hidden access to a file that should be closable.

After investigating the code flex produces, it would
seem that these fears are unfounded.

Signed-off-by: Michael Witten <mfwitten@mit.edu>
2008-02-19 09:31:02 -08:00
Michael Witten 3bdf0a13d6 ivlpp: Clarification
A simple comment to clarify the use of standby for the inclusion stack.

Signed-off-by: Michael Witten <mfwitten@mit.edu>
2008-02-19 09:31:02 -08:00
Michael Witten 623073c722 ivlpp: Removed the unnecessary parser
The verilog preprocessing language is sufficiently simple
that the parser may be implemented by hand on top of the
lexical analyzer.

In fact, ivlpp was already implemented in this way; relevant
[bison] parser files specified no grammar, and the parser
entry-point (yyparse) was simply an indirect use of the lexical
analyzer (yylex).

Therefore, parse.y has been removed, invocations of yyparse()
have been replaced by yylex(), references to bison generated
files have been removed, and Makefile.in has been updated
accordingly.

Signed-off-by: Michael Witten <mfwitten@mit.edu>
2008-02-19 09:31:02 -08:00
Cary R e989f63192 Fix thread address check and wide vector unaligned copy.
This patch fixes two problems. The first is that thr_check_addr()
was being used inconsistently. It should be passed a real address,
but the resize of the vector should be at least one more than this
address. The extra and unneeded CPU_WORD_BITS was also removed
from the routine.

The second problem involved an invalid memory access in
vvp_vector4_t::set_vec() when the vector being copied was an integer
multiple of the machine word width. Under this condition there would
be no remaining bits that needed to be copied but the routine was always
trying to copying some remaining bits. This code is now only executed
when there is a remainder.

Neither of these appear to be causing runtime problems. The second one
was found with valgrind. The first were found while tracking down the
second problem.
2008-02-19 09:21:20 -08:00
Larry Doolittle 39dd22ace4 Adjust unusual spacing
minimal changes, nearly eliminates oddball/inconsistent
source code use of whitespace
2008-02-19 09:15:03 -08:00
Stephen Williams ceef77e15f Merge branch 'master' of steve-icarus@icarus.com:git/verilog 2008-02-15 21:21:13 -08:00
Stephen Williams b0e4a6884a Objects of lexical scope use PScope base class.
All the pform objects that represent lexical scope now are derived
from the PScope class, and are kept in a lexical_scope table so that
the scope can be managed.
2008-02-15 21:20:24 -08:00
Cary R e7ea90c812 Explicitly initialize real values to 0.0.
This patch explicitly initializes real values to 0.0. Not doing
this was creating an intermittent time zero value problem.
2008-02-15 15:12:55 -08:00
Larry Doolittle f9bf502324 Correct format string
vvp_scope.c:1741: warning: format '%d' expects type 'int', but argument 5 has type 'long unsigned int'
introduced in commit
  331faa2217
2008-02-15 13:26:24 -08:00
Larry Doolittle d28fcb8941 Add missing consts
Fixes char usage introduced in commit
  331faa2217
2008-02-15 13:25:28 -08:00
Cary R 2b5560957a Force the L-value and R-value to match for real values.
Check that if either the L-value or the R-value are real then both
must be real. This prevents a runtime crash.
2008-02-13 20:44:16 -08:00
Cary R b6f26e62df Add support for delaying constants at T0.
This patch adds support for delaying constants at time zero. It also
cleans up the code in elab_net.cc to use this capability instead of
building it with an extra BUFZ to carry the delay information.
2008-02-13 20:10:55 -08:00
Stephen Williams 3f2fa29482 Factor compile-time scopes into PScope class
Modules, functions and tasks are named scopes so derive them all
from the PScope base class. These items all take scoped items, so
the eventual plan is to move these items into PScope.
2008-02-13 19:59:05 -08:00
Cary R 4d8db7b5bc Clean pulse events for real signals.
This patch cleans pulse events for real signals. Not doing this
can produce invalid results under some conditions.
2008-02-13 15:43:19 -08:00
Cary R 2bab415626 Add message for unsupported release of part/bit select.
This patch adds a real error message instead of an assert when
someone attempts to release a part or bit select. I plan to work
on the real functionality soon.
2008-02-13 15:37:53 -08:00
Stephen Williams 110bc2e6eb Merge branch 'master' of ssh://steve-icarus@icarus.com/home/u/icarus/steve/git/verilog 2008-02-13 15:27:39 -08:00
Cary R 331faa2217 Add signed bit based power to continuous assignments.
This patch adds the power operator for signed bit based values
in a continuous assignment. It also fixes a few other power
expression width problems. The expression width is still not
calculated correctly, since the correct method can produce huge
possible bit widths. The result is currently limited to the width
of the native long. This is because lround() is used to convert
from a double to an integer. A check in the code generator protects
the runtime from this limitation.
2008-02-11 20:06:41 -08:00
Stephen Williams f2ff25bfef Dump delays of constants. 2008-02-09 22:20:01 -08:00
Stephen Williams bc1d3eb7cd Add support for generate case
Generate case is a complex generate scheme where the items are
sub-schemes of the case generate itself. The parser handles them
something like nested generate statements, but storing the case
guards as the test expression. Then the elaborator notes the
case scheme and reaches into the case item schemes inside to make
up tests, select the generate item, and elaborate.
2008-02-09 22:19:42 -08:00
Larry Doolittle 63e2aa8d1a refine man page treatment of -d
also renames config file option from scope to scopes,
for consistency with the source code, and adds a
wiki reference to the man page.
2008-02-08 15:30:21 -08:00
Stephen Williams 0ac36dc5af Merge branch 'master' of steve-icarus@icarus.com:git/verilog 2008-02-06 18:38:55 -08:00
Stephen Williams 3a300725de Output delays for part select nets.
Implement net delays for part select devices.
2008-02-06 18:37:42 -08:00
Cary R 85229a6cdc Add unsigned bit based power to continuous assignments.
This patch adds the power operator for unsigned bit based values
in a continuous assignment. It also refactors the power code for
normal expressions and continuous assignments.
2008-02-06 14:38:16 -08:00
Cary R 47d1d981d5 Mangle the scope for user functions in a continuous assignment.
User functions called in a continuous assignment were not getting
their scope mangled. This is needed to handle arrayed instances and
possibly other things.
2008-02-06 14:28:08 -08:00
Stephen Williams fb63bf7dba Compile portability issues. 2008-02-05 20:36:57 -08:00
Martin Whitaker 3d2e791e52 Fix for pr1887168.
This patch fixes some bugs in the implementation of signed integer
division with wide operands in constant expressions and adds support
for signed integer modulus with wide operands in constant expressions.
It also removes a few redundant lines of code.
2008-02-05 15:48:07 -08:00
Larry Doolittle aaf8908676 Document new -d flag to driver
followup to commit 6256dd8040
2008-02-05 15:44:14 -08:00
Cary R 4cf8920e48 Fix trimming of unsigned verinum values.
Incorrect trimming of unsigned verinum values was causing the
compilers unsigned constant verinum pow function to give
incorrect results. This patch restores the pow compile time
optimization and fixes the trimming to always leave a single
zero in the MSB.
2008-02-05 15:40:21 -08:00
Cary R e82293c981 Add unsigned bit based power support to normal expressions.
This patch adds bit based power support to normal expressions.
It also pushes the constant unsigned bit based calculation to
the runtime until the bit based method can be copied to the
compiler. Continuous assignments also need to use this type
of calculation.
2008-02-05 15:33:51 -08:00
Stephen Williams 1b410f0c7d Factor code for processing parameters and localparams
Replace some redundant code with a single function that handles the
elaboration and type management of parameters identically.
2008-02-05 13:37:33 -08:00
Martin Whitaker 51b1804660 Fix for pr1885847.
Currently, if a localparam declaration does not include a type or
range, the RHS expression is cast to an unsigned value. This patch
changes this to make the localparam inherit the type of the RHS
expression, as is done for parameter declarations and is specified
by the Verilog-2001 standard.
2008-02-05 13:06:42 -08:00