Commit Graph

6240 Commits

Author SHA1 Message Date
Martin Whitaker b8e350188e Fix for vvp assertion error on forward reference to array.
If an &A() operator contains a label for an array that has not
yet been declared, vvp fails with an assertion error. This
patch delays the calls to array_find() in the functions that
compile &A() operators, using the usual resolve list mechanism.
2009-01-25 07:46:36 -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
Nick Gasson e5ce88304e Fix mapping of VHDL expressions to function arguments
Noticed this as part of the test case for pr2516774b. Under some
circumstances the input arguments would be cast to the wrong type.
This patch ensures that all the arguments have the correct type.
2009-01-22 17:39:50 -08:00
Nick Gasson 3cc2018346 Emit VHDL hex constants for some unsigned bits strings
This patch changes the output of VHDL unsigned bit strings
which are 4, 8, 16, 32, or 64 bits to use VHDL hex string
constants.

So the following:
  "00000001"
Becomes
  X"01"

Which is much easier to read
2009-01-22 17:39:41 -08:00
Nick Gasson c787e1acd8 Fix VHDL bug where input may be driven by input
This is a fix for pr2527366 where draw_nexus would sometimes
generate code to drive an input from in an input (where they
should have been left unconnected)
2009-01-22 17:38:38 -08:00
Cary R ad3fcf3455 Fix a few memory leaks in vvp.
This patch fixes two memory leaks in the compile stage and one easy
fix in vpi/sys_display.c.
2009-01-21 19:35:47 -08:00
Nick Gasson ba8688c0d1 Fix regression of always3.1.8A with VHDL target
The patch for pr2516774 exposed a bug which caused
always3.1.8A to fail. This patch corrects that.

The test to decide when to use a sensitivity list
rather than an explicit wait statement wasn't tight enough.
2009-01-19 19:54:56 -08:00
Nick Gasson 78bc4b5d47 Fix assignment to VHDL function arguments
This patch is a fix for pr2516774.

The idea is to generate a local variable inside
a function whenever an argument is assigned to. The
variable has an initial value of the argument value
and is used in its place for the remainder of the
function. This patch also handles the case where the
argument is assigned to inside a while loop.
2009-01-19 19:50:48 -08:00
Nick Gasson e6846ea3a7 Improve memory management in VHDL target
Previously the VHDL code generator managed memory for
the AST objects by requiring that each AST element be
responsible for deleting its children. The disadvantages
of this are that it's quite easy to accidentally leak
memory by forgetting to delete a child, and no AST pointers
may be shared by multiple parents (or we'd end up with
double-deletes) -- this results in unnecessary copies of
objects being made.

There's no real need for fine-grained memory management of
AST objects since once they're allocated they tend to
persist until the code generator is about to terminate, when
they should all be freed.

This patch provides a custom new/delete operator for
vhdl_element which logs the vhdl_element objects allocated
in a std::vector (after calling the default operator new).
Once the code generator is finished a single free_all_objects
call deletes all the AST objects in one go. The custom delete
operator is required so that we can still explicitly deallocate
vhdl_element objects before the code generator completes.

There are also some allocation statistics printed at the end
when -pdebug=1 is specified.
2009-01-18 16:42:10 -08:00
Nick Gasson f9448b9dd7 Clean up VHDL debug messages
This won't produce so many useless messages, and the messages
produced should be more relevant.
2009-01-17 09:19:58 -08:00
Nick Gasson f1f9274bb9 Move VHDL global state management to a single file
The new state.cc/hh file now manages all the global
state that we maintain while generating VHDL. This
should make the code a bit tidier.
2009-01-17 09:19:58 -08:00
Nick Gasson 8043629231 Fix some cases where VHDL `buffer' ports were generated incorrectly
This actually removes generation of `buffer' for now.
2009-01-17 09:19:58 -08:00
Nick Gasson ede6acca77 Store only a single VHDL entity for each Verilog module 2009-01-17 09:19:57 -08:00
Nick Gasson 3c2080e502 Start improving performace of VHDL hierarchy generation
This should prune a large amount of the visits to scopes
in the hierarchy. In particular, only one instance of each
scope type should be visited.
2009-01-17 09:19:57 -08:00
Cary R 4b114ff783 Fix for add valid FD/MCD check to $fflush and $fclose.
This patch fixes some issues in the previous patch. Specifically
I need to use vpi_mcd_printf and some trickery was needed to
prevent the compiler from complaining about the format string.
2009-01-16 19:26:47 -08:00
Cary R c2d7ac61c2 Add valid FD/MCD checks to $fflush and $fclose.
This patch adds a check to verify the the FD/MCD is valid in these
two tasks. It displays a warning for invalid descriptors.
2009-01-16 19:26:38 -08:00
Cary R e8f91780e4 Factor out some common compiletf code in vpi/sys_display.c
This patch just factors out the common code for two of the
compiletf routines.
2009-01-16 19:20:21 -08:00
Cary R 71fdf0c849 Add/modify compiletf routines for $timeformat and $printtimescale.
Update/add compiletf routines for these two tasks. The
$printtimescale task was updated to work with more types
of objects.
2009-01-16 19:14:33 -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 6f9ddea07f Keep parameters as a parameters reference for vpi calls.
For most cases just using the value of a parameter is fine, but
a vpi call can access more than the value so we want to use a
parameter reference instead of the value for vpi calls.

Strings were working correctly, integer values need some minor
code generator changes and real values needed to be pushed from
elaboration to the code generators. I also changed the default
real value comment from %g to %#g so that it is more obvious
that the value is a real value.
2009-01-16 18:21:50 -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 22cc681073 Handle old style scope declarations correctly.
I forgot to modify the old style scope declarations so the
code was trying to free a constant string. Found in the vvp
test examples/hello.vvp.
2009-01-15 19:39:10 -08:00
Stephen Williams 8c07d3b51c Fix memory leak in vpi_put_value.
Certain paths through vpi_put_value cause a vpip_put_value_event to
be created with no path for deleting in. Add the capability in the
schedule_generic method, so that it can be delete as soon as it is
executed.
2009-01-14 20:15:50 -08:00
Cary R 185860a4f1 Make $strobe and $fstrobe use the string based formatting.
This patch modifies $strobe and $fstrobe to use the string
formatting routines. It also combines the $display/$write
and $fdisplay/$fwrite routines into one and removes the
old routines that are no longer needed.
2009-01-14 18:55:03 -08:00
Cary R 4b66ffd08c Use a static buffer when returning the vector value of a const. string.
This patch fixes vvp to use the standard static result buffer
when returning the vector value of a constant string. The
previous calloc method was creating a memory leak.
2009-01-14 18:51:36 -08:00
Cary R eddfa12569 Cleanup the lexor state information when done parsing.
This patch frees the lexor buffers when we are done parsing
the input file.
2009-01-14 18:48:44 -08:00
Larry Doolittle c6336d621e Allow building with gcc-4.4
With this small patch, building succeeds with Debian's current gcc-snapshot,
gcc (Debian 20090107-1) 4.4.0 20090107 (experimental) [trunk revision 143170]

That build shows no regressions in the test suite.  The patch does not
break building, or show test suite regressions, with gcc-4.3.

That new gcc version still emits a pile of new and arguably bogus warnings
 "dereferencing pointer '<anonymous>' does break strict-aliasing rules" for
   elaborate.cc:3422
   StringHeap.h:31
   vvp/vvp_net.h:687  (really vvp/vvp_net.h:825)
2009-01-14 18:47:06 -08:00
Cary R fb6e1c202a Update some copyright dates.
Update tgt-stub to have a 2009 copyright and a few individual files.
2009-01-14 18:45:40 -08:00
Cary R 2707a68d1b Fix more memory leaks in vvp and one in ivlpp.
This patch fixes some more memory leaks in vvp. Mostly related
to UDP compilation and one in find_scope() that was found when
testing the VPI code. The leak in ivlpp was that the define
temporary buffer not being freed when the lexor was finished.
2009-01-14 18:40:54 -08:00
Stephen Williams ea954a7ccc Merge branch 'master' of ssh://steve-icarus@icarus.com/~steve-icarus/git/verilog 2009-01-13 17:46:49 -08:00
Stephen Williams b1aa4496ec Stub no longer references ivl_nexus_name.
The ivl_nexus_name function is deprecated.
2009-01-13 17:45:36 -08:00
Cary R c2605a5c9b Fix memory leaks in vvp and change vvp T_STRING token to be new based.
This patch fixes a bunch of memory leaks in vvp and converts the
T_STRING lexical token to be new based. There are still two
known leaks that I need to find a way to fix and likely some
unknown leaks that still need to be found and fixed.
2009-01-13 10:53:23 -08:00
Stephen Williams 8ca3ea2e83 Better handle right shift of unsized expressions.
When doing right shift of unsized expressions, pad the left operand
so that the right shift does not lose. This better accounts for the
lossless expectations of unsized arguments.
2009-01-12 19:19:00 -08:00
Larry Doolittle 5b9857fe76 Refactor two NetPins related methods
Seemingly does nothing, just refactors to create two new methods:
   bool NetPins::is_linked(void)
   void NetNet::initialize_value_and_dir(verinum::V init_value, Link::DIR dir)
and rearranges netlist.h.

This patch causes no regression in the testsuite.
It smooths the way for any attempt to address pr2023076.
2009-01-12 18:21:06 -08:00
Sreeraj.R bd5c48eccd Added gsystem-verilog gen flag and 4 additional keywords
For future system-verilog additions
2009-01-10 11:05:48 -08:00
Cary R 4f26c62207 Make the $fdisplay/$fwrite family use the string formatting.
This patch makes the $fdisplay() and $fwrite() family of task
use the string formatting code. It also adds a compiletf routine
for the tasks and a run time check that the FD or MCD is correct.
If not it fails instead of just dropping the output.

It also cleans up a couple of memory leaks and adds no argument
compiletf routines for the $monitoron/$monitoroff tasks.
2009-01-10 10:38:51 -08:00
Cary R edc4bc1923 Add the $abstime() system function from VASM-2.3.
This patch adds the $abstime() system function from VAM-2.3.
It returns the current time as a real value scaled to seconds.
2009-01-09 17:26:52 -08:00
Cary R 5cf7e26acf Finish real modulus in verireal.
Verireal had hooks for this, but had an assert(0). This patch
replaces the assert(0) with assert(gn_icarus_misc_flag) and
then used fmod() to calculate the modulus. It is the callers
responsibility to verify and report a message to the user
if the current state should not support real modulus.
2009-01-09 17:21:50 -08:00
Cary R cba8b42580 Make a plain $stime print in 10 digits (32 bits).
This patch makes $stime a unique call in display and returns
the lower 32 bits in a 10 digit field when it is called.
2009-01-09 16:58:13 -08:00
Cary R 5d7f8c9706 Update copyright in files changed in 2009
This patch updates the copyright notice in the files that
were modified in 2009. It also updates the normal programs
and the vvp target.
2009-01-08 20:03:34 -08:00
Cary R f993e78185 Make eval_tree mixed case div/mod work.
This patch makes constant mixed case division or modulus
optimize correctly. The modulus is only done if the
gn_icarus_misc_flag is set.
2009-01-08 19:56:28 -08:00
Cary R f2f7933708 Make lexical token STRING new based.
The STRING lexical token was malloc based, but then was passed
to routines that are expecting a new based result. This patch
standardizes on a new/delete based approach.
2009-01-08 19:40:50 -08:00
Cary R 7ccc9d4484 Fix some valgrind warnings and display a real parameter as a real.
This patch fixes some technically benign problems found by valgrind,
but we may as well give the values a default to make sure things
work correctly. I believe that the default I choose is the
appropriate value for the context.

The other problem is that real valued (local)parameters should be
printed as a real value like a real variable, etc. Trying to
do this as a decimal with the string formatting was causing a
memory problem. I could have fixed the routine to handle this,
but the better solution was to just display things the right way.
2009-01-08 19:34:10 -08:00
Stephen Williams a2aff77ca2 Avoid creating Nexus objects until they are really needed.
By not creating Nexus objects until necessary, we avoid creating a
lot of spurious objects. In fact, it is true that almost every
link that is created and connected to another link will create a
spurious Nexus object without this patch.
2009-01-07 22:07:08 -08:00
Cary R 2353f91693 Make the CREATE_VERSION script create the correct file.
The version tag is now stored in the version_tag.h file
and is then copied along with the VERSION into the master
version.h file by the Makefile.
2009-01-06 20:48:54 -08:00
Nick Gasson 50f11390b2 Fix VHDL value of undriven net
This ensures an undriven net has the correct value in
the generated VHDL (either '1', '0', or 'Z').

This is a fix for pr2489116.
2009-01-06 20:36:33 -08:00
Nick Gasson 02b58f6ae8 Remove some redundant code from draw_synthesisable_wait
The default draw_wait now produces code for FFs with sync
waits that should synthesise OK.
2009-01-06 20:33:34 -08:00
Nick Gasson 6047eab005 Try to generate VHDL sensitivity lists whereever possible
This patch generates VHDL sensitivity lists for sequential
as well as combinatorial processes which do not contain
a wait statement. Otherwise it falls back on the original
wait-on/until behaviour.

This should make the generated VHDL more acceptable to
synthesisers.
2009-01-06 20:33:21 -08:00
Nick Gasson 19720a0f9d Prefer sensitivity list for VHDL combinatorial processes
This patch generates a sensitivity list for combinatorial
VHDL processes if they don't contain a wait statement, and
a wait-on statement if they do contain another wait statement.

This should help synthesisers correctly identifier
level-sensitive latches.
2009-01-06 20:33:08 -08:00
Nick Gasson a0489e9208 Generate more idiomatic VHDL for some Verilog templates
In particular this improves the code generated for flip-flops
so the output can be synthesised with certain tools (e.g. Synopsis).

See the comments above draw_synthesisable_wait for more details.
2009-01-06 20:32:54 -08:00