Commit Graph

6240 Commits

Author SHA1 Message Date
Cary R ca7e64afaf Fix some keywords, add -g2001-noconfig and fix up uwire/wone.
This patch adds -g2001-noconfig command line flag. The compiler
already supported this with `begin_keywords. Document this in
the manual page and fix a few other issues.

Fix endgenerate to be a 2001 keyword and add a few missing
keywords at the appropriate standard level e.g.(unsigned).

Add uwire and deprecate wone. wone used to just convert without
a warning to a wire. uwire will display a warning that it is
being converted to a wire without a check. wone is converted to
a uwire with a warning and then prints the uwire message. The
uwire message will be replaced with a real check fairly soon.
2009-06-07 16:31:34 -07:00
nog c842cdbdc4 Avoid stepping on free'd memory during recursive macro expansion
During macro expansion (with arguments), there is one global buffer
(exp_buf) that keeps getting reallocated to fit all the macro's text
that's currently being expanded.  The problem with this scheme is that if
a macro with arguments needs to be expanded from the macro text of another
macro with arguments, it may happen that the second expansion forces
the above exp_buf buffer to be reallocated.  Which is fine until the
previous macro processing resumes where (struct include_stack_t *)->str
now points to uninitialised memory.  Basically, the code that can trigger
such behaviour is as follows:

`define FOO(a)	(a+3)
`define BAR(b)	(`FOO(b)+2)

`BAR(x)

Ofcourse, you need to get lucky to get the exp_buf to be realloced at the
right point, but it's possible.

I don't see the advantage in keeping all the expanding macro's text
together, so my solution is to simply allocate a new buffer and pass it
as (struct include_stack_t *)->str to the flex parsing function and free
it at the end.
2009-06-07 16:24:49 -07:00
Cary R 80c21adb4a Allow devel to parse a .scope statements with out the `celldefine info.
This change allows us to test V0.9 files under V0.10.devel.
2009-06-07 16:19:10 -07:00
Cary R d06f6dfc51 Add support for unconnected_drive.
Icarus has recognized this directive, but it did not do anything
with the information. This patch adds the functionality for most
common cases. It adds this by changing the input net type from
wire/tri to tri1 or tri0 depending on the pull. The issue is that
if the input net is not a wire or tri this is not safe and should
really be done as an external pull gate connected to the input.
We will need to handle this is it ever comes up. For now a sorry
message is printed.
2009-06-07 16:14:52 -07:00
Cary R 364cf99a67 Add more default net types
Previously Icarus only supported a default net type of wire or none.
This patch adds the rest of the supported net types (all except
uwire and trireg) to the `default_nettype directive. It also fixes
make_implicit_net_() to use the default_nettype instead of always
using implicit (the same as wire).
2009-06-07 16:09:00 -07:00
Cary R 6297422427 Rework the `timescale directive and cleanup `line a bit.
This patch reworks the `timescale directive to do a better
job of parsing the line, it refactors some of the code and
should produce better error messages. It also tightens up
parsing the numeric constant, etc. to better match the
Verilog standard.

The parsing of `line has been enhanced to only allow 0, 1 or
2 for the level and a single line comment at the end of the
line is ignored.
2009-06-07 16:03:04 -07:00
Cary R 5fc236accc Use strchr() instead of index().
strchr() is more portable and index() is not available under
MinGW so replace index() with strchr().
2009-06-06 11:15:22 -07:00
Stephen Williams bc6f3cc905 Re-implement force/link to use a vvp_fun_force node.
The vvp_fun_force node converts its input to a call to the
force method of the target node. This eliminates the need for
linking a net to a force input of a signal.
2009-06-06 11:01:12 -07:00
Stephen Williams 29a47efa81 Remove the signal functor force-2 input port hack.
The vvp_net_t port 2 was used to implement force behavior, but that
is no longer how we plan to implement force, so remove it from the
implementation of signal nodes. This currently breaks much of the
force/release functionality, but we'll get it back by other means.
2009-05-27 20:37:46 -07:00
Stephen Williams 30ee9a104e Merge branch 'master' into vvp-net-out-rework 2009-05-23 14:57:42 -07:00
Cary R 4affc6e412 Make ivl warn that it does not support `ifndef or `elsif
We added support for these two directives some time ago,
but ivl was never updated to warn that it did not support
them and you needed to use ivlpp.
2009-05-23 14:32:31 -07:00
Cary R 1bce6ec726 Add better error checking to the two line directives.
Icarus supports both a #line and `line directive. This patch
reworks the parsing of these to provide better error detection
and full checking.
2009-05-23 14:27:58 -07:00
Cary R 4991711672 Add support for `resetall and other directive changes.
This patch adds support for the `resetall directive.

It also changes `celldefine, `endcelldefine and `resetall
to no longer grab text following them. These directives do
not take an argument so they should not be grabbing any
text and silently discarding it.

The `timescale processing was reworked to handle being
reset and hooks were added to easily change the default
time units and precision when we add that feature request.
2009-05-23 14:21:39 -07:00
Cary R 636758f66d Add support for `celldefine, vpiCellInstance
This patch adds real functionality for `celldefine and pushes this
property to the run time which can access this with vpiCellInstance.
This is technically only available for a module, but all scopes
have the property and only modules should return true when the
'endmodule' is between a `celldefine and `endcelldefine directive.
2009-05-23 14:13:47 -07:00
Cary R 22416b4d01 Print a better error message for a '~' token in front of ('&' | '|' | '^')
Some users may expect this to work so this patch catches these
specific cases and tells the user to use the singe unary operators
'~&', etc. instead.
2009-05-23 14:08:22 -07:00
Cary R 9c02c7d7a4 Cleanup if an invalid option is given.
Cleanup the temporary files and memory if iverilog is given
an invalid option.
2009-05-23 14:04:10 -07:00
Cary R 79578f20d1 Fix memory leak when parsing command files.
These are not leaks in the true sense of the word, but it is
memory that is not being freed before the program finishes
so valgrind will complain about this.
2009-05-23 14:04:01 -07:00
Larry Doolittle 9619eb3a0d Remove fresh const lint
It looks pretty stupid and non-c++-y, but it does remove two compiler warnings
vvp/stop.cc: In function 'void stop_handler(int)':
vvp/stop.cc:492: warning: deprecated conversion from string constant to 'char*'
vvp/stop.cc:493: warning: deprecated conversion from string constant to 'char*'
2009-05-23 14:00:47 -07:00
Stephen Williams 9a348e2174 Split type-specific filters into type-specific derived classes.
The wire base class cannot carry all the overhead for handling all
the different net types, so split it out into derived classes. This
will also move me closer to splitting wires away from variables.
2009-05-23 10:55:07 -07:00
Stephen Williams 6e1d7b6210 Merge branch 'master' into vvp-net-out-rework 2009-05-18 19:46:13 -07:00
Cary R 90d9debe81 Display and error for hierarchical references in a parameter r-value expr.
Display and error message when the user uses a hierarchical reference
in a parameter r-value expression.
2009-05-18 17:52:49 -07:00
Cary R 7f20f8c768 Add support for displaying a real parameter using %d.
This patch modifies the real parameter get_value routine to use
the standard vpip_real_get_value() routine. This routine has
support for an integer and a decimal string value.
2009-05-18 17:49:35 -07:00
Cary R fe3dd3a559 Add support for initializing outputs declared as output reg.
The standard allows an output declared as "output reg" to be
given an initialization assignment in the output declaration.
this patch adds that functionality. Specifically:

  output reg out = 1'b0;

works as expected.
2009-05-18 17:43:54 -07:00
Cary R 9a04f1c380 Add escaping to the stringification of macros.
Icarus support returning a string version of a macro ``<MACRO>.
The problem was that it did not escape '\' or '"' so if the
macro to be escaped had either of these it would create an
invalid string. This patch fixes this by translating these two
codes to their octal equivalent when the macro is converted.
2009-05-18 17:40:52 -07:00
Cary R fd2e27fe0f Document -gsystem-verilog and add -gno-system-verilog 2009-05-18 17:38:48 -07:00
Cary R 6c0e1480ff Fix the %assign/v0/x1 operators for width equal negative offset case.
This patch fixes the three %assign/v0/x1 operators to correctly
notice that the select has fallen off the start of the vector
for the case that the negative offset equaled the width.
2009-05-18 17:34:56 -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 d780af1eca Merge branch 'master' into vvp-net-out-rework 2009-05-05 20:09:51 -07:00
Cary R eba5d12deb Fix %t to work with real system functions.
Fix %t to get the real value when the argument comes from a real
valued system function.
2009-05-05 19:36:15 -07:00
Stephen Williams a5046bd8c6 Filters need to let through the forced value.
When the forced value is first set, the filter needs to let that
value through. Otherwise, the forced value will not propagate out
from the net.
2009-05-04 20:39:26 -07:00
Stephen Williams ba00c6caf7 Change implementation of force/release to use filters.
This is moving towards moving force/release out of the signal
class. The end-game is to remove all of the wire implementation
out of the functor and into the filter. Variables will remain in
the functor.
2009-05-04 20:26:41 -07:00
Stephen Williams 79a5dde7c4 Merge branch 'master' into vvp-net-out-rework 2009-04-28 19:34:31 -07:00
Cary R c768805d9f Add a warning message for some array words when dumping.
When dumping an array word the name is implicitly converted to
an escaped identifier. If this implicit name conflicts with an
explicitly created escaped identifier this patch will print a
warning message warning that the array word will conflict with
an escaped identifier.
2009-04-28 19:02:22 -07:00
Cary R bbb132aaa7 Vec8 delays should schedule like vec4 delays.
This patch adds code to calculate the vec8 delays using the
same method that is used to calculate the vec4 delays.
2009-04-28 18:57:23 -07:00
Cary R 31fae351d2 Calculate the width of an array word correctly.
When finding the width of an array word we need to skip any word
selects for the array dimensions.
2009-04-28 18:04:57 -07:00
Cary R 192522b3d8 Check for name space collisions.
This patch adds code to check for most of the name space
collisions. genvars are not checked correctly since they
are not completely implemented.
2009-04-27 17:24:36 -07:00
Stephen Williams 7e9e50d3b0 The vvp_vpi_callback belongs with the vvp_set_sig stuff.
Move the vvp_vpi_callback to the vvp_net_sig.h header file, and
collapse some useless hierarchy. (Specifically, all callbackable
items are also wordable.)

Move the run_vpi_callback invocation for wires/variables from the
output generator to the newly implemented filter object. This is
starting to get the filter class working.
2009-04-24 21:50:00 -07:00
Stephen Williams 53051be2d4 Merge branch 'master' into vvp-net-out-rework 2009-04-17 18:48:16 -07:00
Cary R c685911653 Update manual pages to be 0.10.devel.
This patch updates the manual pages to reference 0.10.devel
and fixes a few things in the main iverilog manual page.
2009-04-17 18:33:56 -07:00
Cary R e23d14269a Dump the streams when entering interactive mode.
This patch adds code to automatically dump the output stream
including any dump file when entering interactive mode. When
the user typed ^C or $stop was executed.
2009-04-17 18:30:25 -07:00
Cary R 278e2060a8 Add support for dumping non-constant array selects as a constant select.
Dumping array words is an enhancement that we have added to Icarus.
The problem was that if you wanted to dump the whole array you would
like to use a for loop as follows:

for (lp = 0; lp < max ; lp = lp + 1) $dumpvars(0, array[lp]);

This used to work, but some of the VPI rework broke it because it
counted on the word select to be constant. This patch restores the
functionality by converting the variable word select into a constant
word select in the calltf routine. This is done without warning and
only for the $dumpvars() routine.

Adding this functionality necessitated adding support for vpiIndex
to the &A<> routines.
2009-04-17 18:23:43 -07:00
Cary R b1dd0b1f6d It is an error to select part of a scalar value.
In 1364-2005 it is an explicit error to take the select of a scalar
or real value. We added the checks for real a while ago. This patch
adds the functionality for scalar values. In the future we may want
to push the scalar property to the run time.
2009-04-17 18:18:22 -07:00
Cary R 5d5c7e88f9 Warn the user if they use both a default and `timescale based delay.
This patch add code to print a warning message if it finds both a
default and `timescale based delays. The -Wall or more specifically
the -Wtimescale flag can be used to find the module with the missing
`timescale directive.
2009-04-17 18:12:27 -07:00
Cary R 1ef6c405c3 Handle $stop and $finish at the interactive prompt.
This patch adds interactive support for $stop and $finish.
$stop displays a message that the simulator is already stopped.
$finish acts exactly like (calls) the interactive "finish"
command. Having $stop do nothing and $finish not finish until
you exit interactive mode is not very intuitive.
2009-04-17 18:08:55 -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 d0457a1ac2 Generate better error messages for concat. with indefinite width.
This patch generates a more user friendly error message for a
concatenation with an indefinite width operand.
2009-04-17 17:59:28 -07:00
Cary R fc8549c9f8 Add $readmempath to set a search path for $readmem{b,h}.
This patch add a new system function $readmempath. It accepts
a ":" separated list of directories that $readmem{b,h} will
use when trying to open a given file. If the file given to
$readmem{b,h} starts with a '/' (an absolute path) the search
list will not be used. A new call to $readmempath will replace
the previous search list with the given list. The search list
elements are check to see if they exist and are directories.
If not a warning will be displayed and they will not be added
to the list.
2009-04-17 17:44:52 -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
Stephen Williams 8310babdfe Merge branch 'master' into vvp-net-out-rework 2009-04-08 21:05:30 -07:00
Cary R 047828ded0 Allow macro expansions to take arguments with multiple arguments.
This patch allows a macro expansion to have an argument which
itself has multiple arguments (handle nested ",").
2009-04-08 17:55:45 -07:00