Commit Graph

7964 Commits

Author SHA1 Message Date
Cary R 8977248ee2 For valgrind testing remove the UDP functionality object.
When checking with valgrind we need to remove the UDP functionality
object to avoid a reported memory issue.
2011-10-19 14:56:30 -07:00
Cary R 7a75f94eda Move UDP name to the UDP base class.
The name is not currently used, but when it is it makes sense for it to
be in the base class. Also the name cannot be deleted after compiling
since it may be used later.
2011-10-19 14:46:15 -07:00
Martin Whitaker 1e814cfc1e Fix for pr3420994.
The VPI object data model diagrams show a one to many relationship
between the "mod path" and "path term" objects. This means that the
correct way to obtain handles to "path term" objects is to use the
vpi_iterate and vpi_scan functions.

Support for the old method of obtaining handles to "path term" objects
using the vpi_handle function is retained for backwards compatibility.
2011-10-19 14:37:20 -07:00
Stephen Williams eeeadea3ac Fix recently broken write of vhdl packages to work space. 2011-10-16 12:18:34 -07:00
Stephen Williams a109df04bb Proper expression type for vhdl relation expressions. 2011-10-16 11:02:07 -07:00
Stephen Williams 93e5a72d84 Get parameter output syntax right for vhdlpp. 2011-10-16 11:01:32 -07:00
Stephen Williams d9acfe57b1 Put off array bound evaluation / describe entity generics as parameters
Entity generics are easily implemented as module parameters, so make
it so. Give the parameters their default values from the generic declaration.

Array bounds may use values that cannot be evaluated right away, so
put off their evaluation.
2011-10-15 17:41:48 -07:00
Stephen Williams a6f63b8a54 Parse generic clause in entity headers
The generic clause can create named generics in entities. This patch
gets the parser support for them working, even though they cannot
yet evaluate.
2011-10-15 09:49:24 -07:00
Cary R 6184871242 Remove cppcheck warnings in ivl code.
This patch removes the new cppcheck warnings in the main (ivl) directory.
2011-10-14 18:40:49 -07:00
Cary R 209a78a439 Remove a more cppcheck warnings in vhdlpp.
This patch removes a few more cppcheck warnings in the vhdlpp directory.
2011-10-14 18:40:39 -07:00
Cary R 8f17e79b7e Remove a few cppcheck warnings.
This patch removes a few cppcheck warnings.
2011-10-14 18:40:24 -07:00
Cary R 8e3d80679d Add an implementation for the enumeration name() method.
Add an implementation for the enumeration name() method. This currently
only works if the context defines the return width (e.g. the result is
assigned to a variable). It does not work in a self-determined context
(e.g. as an argument to a system function or in a comparison). This is
a limitation in the compiler/code generator/run time not the method
implementation provided here. We may need full string support to make
this work 100%.
2011-10-14 18:37:06 -07:00
Cary R 52d05c0215 Use correct name to iterate on enumeration constants.
The standard defines how to calculate the name for an access function
or iterator if one is not given. It is supposed to be vpi followed by
the words in the name with each word capitalized. For the one to many
(iterator) interface from the enumeration typespec to the individual
constants this is vpiEnumConst not vpiMember.
2011-10-14 18:35:39 -07:00
Cary R b905c699d1 Rework enumeration next() and prev() methods to support count argument.
Rework the actual next() and prev() methods to correctly process the
numeric count argument. Also rework the compiletf routine to give better
error messages and combine the call routine for the two methods.

Add a compiletf routine that checks the arguments and then report that
the name() method is not currently implemented.
2011-10-14 18:31:18 -07:00
Cary R 4692756eb9 Add primitive vpiBaseTypespec support for enumerations.
We don't currently have the information needed to correctly provide the
base typespec, but in the next() and prev() methods I need to know if
the enumeration is two or four state. This patch sets the base typespec
for four state enumerations to vpiReg and to vpiBitVar for two state
enumerations. This provide enough information to get next() and prev()
working correctly.
2011-10-14 18:22:23 -07:00
Cary R 6a99520fa6 Add string display for vpiEnumTypespec and create hook for UdpDefn iteration.
This patch adds vpiEnumTypespec to the list so that vpi_get_str(vpiType, ...)
returns an appropriate string when an enum type is passed.

It also adds the initial hook to allow iteration (global) over the UDP
definitions. This along with table traversal will be needed to free the
memory allocated when the UDP definition is created. Ultimately this
will all the UDP test to be valgrind clean.
2011-10-14 18:20:23 -07:00
Martin Whitaker a3813c006d Corrected tf_getlongsimtime() to match behaviour of other simulators.
The PLI tf_getlongsimtime() function is a non-standard function provided
for compatibility with some commercial simulators. To match the behaviour
of those simulators, it should return the raw simulation time, not a
scaled time.
2011-10-14 18:13:34 -07:00
Cary R 19307ba9dc Add an enum type to the appropriate scope and add valgrind cleanup code.
Add the enum type to the scope when it is created. Also delete the type
when checking with valgrind.
2011-10-14 18:09:36 -07:00
Cary R 5a9e4aaec7 When printing a Dec numeric value use the string size and the minimum size.
The vpiDecStrVal case for the get_numeric() function needs to use the
existing string width as the minimum result size. -1 can be represented as
a signed value with a width of 1. This gives a display width of -1 which
is too small for the -1 string value. This was creating valgrind issues.
In general the string value should be the minimum so this is a safe change.
2011-10-14 18:07:45 -07:00
Cary R 7f65f3b157 Free memory at EOS and convert to C code (vhdl_table.cc).
This patch converts the vhdl_table.cc file to C code and adds
code to free the allocated memory at the end of simulation to
make valgrind happy.
2011-10-14 18:04:11 -07:00
Cary R 82e946b51a Free the iterator if there are extra arguments.
To avoid extra memory usage on error free the iterator if there are
extra arguments.
2011-10-14 18:02:37 -07:00
Cary R aa2a063bc0 Remove the use of a freed variable.
If a constant is padded the original constant will be freed and replaced
with a new one. This results in the ce pointer pointing to freed memory.
In reality the second check only needs to be done if the first one is
false so avoid the whole issue by only performing the second check if
the first on is false.
2011-10-14 17:59:54 -07:00
Cary R 50a2f55364 Define the mode when testing the width of a wait statement argument.
If a wait statement has a constant argument then the mode must be defined
before test_width() is called since the current mode is used in the
PENumber test_width routine.
2011-10-14 17:55:41 -07:00
Cary R e22c692656 Fix a memory leak in ivlpp.
The new VHDL strings need to be freed to make valgrind happy.
2011-10-14 17:53:49 -07:00
Cary R 0bad7bc337 An enumeration method can be called as a function.
Add code to allow an enumeration method to be called as a function.
This is only the compiler support. The runtime support is still missing
so only an empty argument call will succeed (e.g. next(), etc.). For now
the rest get a warning message.
2011-10-14 17:52:03 -07:00
Cary R dc2c67e25f Remove two unused argument warnings 2011-10-14 17:49:47 -07:00
Martin Whitaker 7e66947f2c Fix vpiUserDefn definition in vpi_user.h.
This patch changes the code value for vpiUserDefn to match the IEEE
standard.
2011-10-14 17:48:22 -07:00
Stephen Williams 6268db6e68 Handle simple type declarations. 2011-10-09 15:25:35 -07:00
Stephen Williams 30cfcbe2dc Rework elaborate/emit of types.
This rework is needed to reasonably handle new types, like enums.
2011-10-02 10:56:00 -07:00
Stephen Williams 271aaf6376 Parse enumeration type declarations. 2011-10-01 17:04:04 -07:00
Stephen Williams 8003382b3e Elaborate and emit case statements. 2011-10-01 11:45:28 -07:00
Cary R cff0deeacc Update lxt_write and lxt2_write files from GTKWave
Update the lxt_write.[ch] and lxt2_write.[ch] files to the latest from
GTKWave. This is just comment changes.
2011-10-01 09:48:41 -07:00
Cary R 3b6e26aa90 An enumeration cannot have duplicate values.
Add code to check that an enumeration does not have duplicate values.
2011-10-01 09:32:37 -07:00
Cary R be1be31deb Update some cppcheck suppressions and fix one problem in the code.
Update the line number for a couple cppcheck suppressions and add one for
the pool variable in the vvp directory.

Also move a check for null to the correct place.
2011-09-29 09:40:40 -07:00
Martin Whitaker c59d27e19f Remove more clang warnings.
clang warns that the yyinput function generated by flex is never used.
2011-09-25 10:14:16 -07:00
Cary R eab5bacf9f Remove clang/clang++ warnings.
This patch makes the code consistently use struct/class in the C++ files,
it removes a couple shadow warnings and where a class pointer is passed to
the C routines, it defines the pointer as a class for C++ and as struct for
C and it removes a namespace std duplication.
2011-09-25 10:14:04 -07:00
Cary R 609c038484 Add more support for signed enumerations in SV.
This patch add support for passing if the enumeration is signed or not
to the run time. This is really only needed for debug and VPI access.
2011-09-25 09:56:02 -07:00
Stephen Williams 52019b0e55 Merge branch 'master' into work8 2011-09-18 19:48:50 -07:00
Stephen Williams 88cce86c63 Emit code for the to_unsigned() bulit-in function. 2011-09-18 19:31:28 -07:00
Stephen Williams 557e331ce1 Support SystemVerilog size cast. 2011-09-18 19:21:46 -07:00
Stephen Williams 873a447b5c Evaluate VHDL <name>'length attribute at compile time. 2011-09-18 17:45:06 -07:00
Stephen Williams 677a22d353 Generate code for vhdl for loops. 2011-09-18 15:51:31 -07:00
Stephen Williams f0e61a1db7 Basic vhdl elaboration for unary not operator. 2011-09-18 15:13:30 -07:00
Stephen Williams f4217af506 ostream operator for perm_string objects. 2011-09-18 15:12:51 -07:00
Stephen Williams 4d445dc269 Fix parse of unnamed processes. 2011-09-18 09:37:11 -07:00
Alexander Klimov 766bf45dcf Fix long division.
On a 64-bit machine the following module shows incorrect division
results:

`define X {4'b 1000, `N'b 0}
`define Y {1'b  1, `N'b 0}
module b;
   reg [`N:0] y = `Y;
   reg [3:0] z1, z2;
   initial begin
      z1 = `X / `Y;
      z2 = `X /  y;
      $display("%3d %b %b", `N, z1, z2);
   end
endmodule // b

$ for N in {60..65}; do /usr/bin/iverilog -DN=$N -oa b.v && /usr/bin/vvp a; done
 60 1000 1000
 61 1000 1000
 62 1000 0111
 63 1000 0101
 64 1000 1000
 65 1000 1000

The first chunk of the patch (result -> tmp_result) fixes this:

$ for N in {60..65}; do iverilog -DN=$N -oa b.v && vvp a; done
 60 1000 1000
 61 1000 1000
 62 1000 1000
 63 1000 1000
 64 1000 1000
 65 1000 1000

The second chunk fixes

`define X 264'h 800000000000000000000000000000000000000000000000000000000000000000
`define Y 192'h c6df998d06b97b0db1f056638484d609c0895e8112153524
module c;
   reg [191:0] y = `Y;
   reg [72:0] z1, z2;
   initial begin
      z1 = `X / `Y;
      z2 = `X /  y;
      $display("%x %x %b", z1, z2, z1 == z2);
   end
endmodule // c

$ /usr/bin/iverilog -oa c.v && /usr/bin/vvp a
0a4c4a2c1dacd76220c 0809033397ca3427927 0

$ iverilog -oa c.v && vvp a
0a4c4a2c1dacd76220c 0a4c4a2c1dacd76220c 1
2011-09-17 18:35:25 -07:00
Stephen Williams f0bf64271b SystemVerilog has more lax rules for function declarations.
Allow empty parameter lists
Allow lists of statements instead of simple statements.
2011-09-17 12:10:05 -07:00
Stephen Williams 1d02f89a09 Handle vhdh array aggregate expressions.
Support the more general case of explicit element expressions
defined at various index positions, mixed with "others" records.
2011-09-11 17:08:22 -07:00
Stephen Williams 3497e2e663 Distinguish bit selects of entity ports from function calls.
Besides variables and signals, a name with a bit select may
be an entity port. Distinguish these from function calls.
2011-09-11 15:28:58 -07:00
Cary R 64e16d34f3 Add vhdl_sys.vpi to the make clean target 2011-09-11 12:08:06 -07:00