Commit Graph

22 Commits

Author SHA1 Message Date
Lars-Peter Clausen 4269388878 `netrange_width()`: Add a base_width parameter
There are sometimes cases where calculating the total width of a
`vector<netrange_t>` has to take into account an existing base width. E.g.
when chaining multiple `vector<netrange_t>`. Add support to the
`netrange_width()` function to be able to handle this case.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-09-09 05:49:46 -07:00
Lars-Peter Clausen 5ec72f4cc8 Add error checking for continuous unpacked array assignments
Currently there is no error checking for continuous assignments to unpacked
arrays. If the lvalue and rvalue net are not compatible undefined behavior
occurs. For some types of incompatibility it will crash during elaboration,
for others it will crash during simulation, and for some it will just work,
even though the assignment is not allowed by the standard.

Implement checking to ensure the two nets are compatible as required by the
standard and report an error otherwise.

Two arrays are considered to be compatible if their element types are
equivalent, they have the same number of ranges and each range has the same
number of elements.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-17 15:29:38 -08:00
Lars-Peter Clausen 5fa1aecd4f Improve type compatibility checking for dynamic arrays and queues
SystemVerilog defines different levels of type compatibility.
 * Matching
 * Equivalent
 * Assignment compatible
 * Cast compatible

At the moment the `nettype_t` has only one type compatibility test. It is
used to check assignment compatibility when assigning to a dynamic array,
queue or class.

The current implementation rejects a few cases that should allowed and
allows a few cases that should be rejected.

Dynamic arrays and queues are assignment compatible if their element types
are compatible. And two packed types are equivalent if they are both
2-state or 4-state, both signed or unsigned and have the same packed with.

In the current implementation the sign is not considered and instead of
checking if the packed width is the same it checks that the dimensions are
identical.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-08 14:01:41 +02:00
Lars-Peter Clausen 6f0d3ae332 ivl_type_s: Add get_scalar() method
Currently only the netvector_t type implements the get_scalar() method. To
check whether a type is scalar it is first cast to netvector_t and then the
method is called.

But there are other types, such as areal that can also be scalar. To
support indicating that a real type is scalar add a virtual get_scalar()
method to ivl_type_s, which is the base class for all types.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-12 18:48:59 +02:00
Stephen Williams 16646c547c Rework parsing of parameter types
Use the common data_type_or_implicit rules to support type
definitions for parameters. This eliminates a bunch of special
rules in parse.y, and opens the door for parameters having
more complex types.
2020-12-27 21:17:57 -08:00
Martin Whitaker 1448210f28 Fix for GitHub issue 112 - index calculation for >2D packed arrays. 2016-07-09 23:33:33 +01:00
Larry Doolittle 2739f83702 Spelling fixes in C and C++ comments 2015-06-04 15:00:29 -07:00
Stephen Williams 40b36337e2 Fix some bugs with packed array dimensions.
The netparray_t::slice_dimensions bug was the most insidious and
caused all manner of confusion. Also fix some other packed array
and unpacked array (and mixed) indexing calculations.
2014-04-06 08:40:10 -07:00
Larry Doolittle 77a01f65d0 Remove fixable unused-parameter warnings
I see other warnings within vhdlpp/lexor.cc caused by a flex bug
(see http://sourceforge.net/p/flex/bugs/115/), which I won't try to work around.
2014-01-30 15:34:08 -08:00
Stephen Williams 0b4056817a Generalize struct member type 2013-12-07 12:20:28 -08:00
Stephen Williams 18c338ad09 Handle array assignment patters through pform.
This gets us to elaboration. In the process also fix up ivl_type_t
type comparisons to do deep type comparison.
2013-10-19 15:34:14 -07:00
Cary R bb37b74f98 Fix for br884 (packed array access problems) 2013-07-28 13:24:57 -07:00
Stephen Williams 1aa21aa9e8 ivl_target interface to packed type details.
The darray in particular needs to know about the subtype info.
In the process, clean up some of the type information.
2012-10-14 17:16:47 -07:00
Stephen Williams 914ebeca4a Some rework to allow for nested packed types.
This also simplifies the NetNet set of contructors and generalizes
the types that are supported, especially packed types.
2012-10-14 17:16:47 -07:00
Stephen Williams 4e76912331 ivl_target access to type information. 2012-10-14 17:16:47 -07:00
Stephen Williams 494dc876a5 Move net vector properties to netvector_t object. 2012-10-14 17:16:47 -07:00
Stephen Williams 92313654ec Rework the way vectors are represented in NetNet objects. 2012-10-14 17:16:47 -07:00
Stephen Williams b4cc9d14a5 Handle packed arrays of packed struct in l-value expressions. 2012-09-03 16:00:09 -07:00
Arun Persaud f5aafc32f9 updated FSF-address 2012-08-29 10:12:10 -07:00
Cary R 7ce8a9b01c Fix some cppcheck warnings in the main directory 2012-08-08 11:28:20 -07:00
Stephen Williams 14f229de30 Parse support for dynamic arrays.
This includes limited support for dynamic arrays down to the code
generator, and some stubs in the vvp code generator and vvp run time.
2012-07-22 10:52:06 -07:00
Stephen Williams 78b0b49a4e Support struct members that are packed arrays. 2012-05-22 17:31:25 -07:00