Commit Graph

352 Commits

Author SHA1 Message Date
Lars-Peter Clausen 79919e33a2 Handle continuous assignment of assignment patterns to array elements
Currently when creating the NetNet for a continuous assignment to an array
element the type of the element is flattened into a canonical 1 dimensional
form. This works for most cases because packed types are compatible if
their total packed with is the same.

But there are some contexts such as if the right-hand-side is an assignment
pattern where the actual type matters and flattening the type will result
in incorrect behavior.

Retain the original type of the array element when creating the NetNet for
the array element assignment.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-03-05 01:09:36 -08:00
Lars-Peter Clausen e24aa18a80 Add common implementation for scoped symbol search
In SystemVerilog identifiers can usually have an additional package scope
in which they should be resolved. At the moment there are many places in
the code base that handle the resolution of the package scope.

Add a common data type for package scoped paths as well as a
symbol_search() variant that works on package scoped identifiers. This
allows to handle package scope resolution in a central place.

Having the code in a central place makes it easier to ensure consistent and
correct behavior. E.g. there are currently some corner case bugs that are
common to all implementations. With the common implementation it only has
to be fixed in one place.

It will also make it easier to eventually implement class scoped
identifiers.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 12:26:24 -08:00
Stephen Williams 46a11f4b67
Merge pull request #845 from wmlye/wmlye/assertion-issue823
Clean up assertions in #823 and #840
2023-01-16 10:35:00 -08:00
Bill Lye 56eb91ea9e Fix for assertion failure in Issue #823 2022-12-30 11:12:29 -08:00
Bill Lye ee0c6bb5e4 Modifications to give error messages rather than assertions 2022-12-30 10:36:38 -08:00
Lars-Peter Clausen e88f9c52ea Handle continuous array assignments from package scoped indentifiers
Make sure the package scope is considered when elaborating identifiers for
continuous unpacked array assignments.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-30 10:35:28 -08:00
Cary R dc8b7d0184 Cleanup some cppcheck warnings 2022-12-28 00:00:31 -08: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 e15b125da8 Replace svector with std::vector
The custom `svector` class is essentially a subset of `std::vector`. There
is no inherent advantage to using `svector`. Both have the same memory
footprint.

`svector` was designed to be of static size, but there are a few places in
the parser where it has to grow at runtime. Handling this becomes a bit
easier by switching to `std::vector` since it is possible to use its
methods which take care of resizing the vector.

This also allows to remove the unused parameter of the `lgate` struct
constructor, which was only needed for compatibility with `svector`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-15 21:56:48 +02:00
Martin Whitaker ecbbb60fb6 Remove "using namespace std" from compiler header files and fix the fallout. 2021-11-04 16:55:03 +00:00
Martin Whitaker 7d7aa0604c Properly report errors for out-of-bounds constant indexed part selects.
(replacing assertions)

The IEEE standard either requires out-of-bounds bits to be ignored on
write, returned as 1'bx on read, or requires a compile-time error message.
The latter is easier to implement.
2021-04-20 22:58:40 +01:00
Martin Whitaker 4af830187e Support indexed part selects that index sub-arrays (issue #497) 2021-04-20 21:29:00 +01:00
Cary R da7484eea1 Update compiler with suggestions from cppcheck 2021-01-02 14:04:46 -08:00
Cary R c37f1c9309 An input port driven by a variable is not collapsible 2020-11-30 22:48:39 -08:00
Stephen Williams a79b55ae28 Support nested struct in continuous assign l-values
When doing continuous assignment of packed structs, support the case
where the value being assigned is a member of a member, etc. Procedural
assignments already support this.

See issue#307
2020-11-29 18:18:55 -08:00
Maciej Suminski b4baace4b1 ivl: Support for part selection in multidimensional packed ports assignment. 2016-03-07 09:54:28 +01:00
Larry Doolittle 3e2196651a Remove unused parameter to indices_to_expressions
need_addr has been hanging around, unused, since commit 078a3fd4 on Jan 17, 2014.
2015-07-31 09:48:33 -07:00
Stephen Williams a98f21aa65 Merge branch 'master' into vec4-stack
Conflicts:
	elab_lval.cc
	netmisc.cc
	tgt-vvp/eval_object.c
	tgt-vvp/vvp_process.c
	vvp/codes.h
	vvp/compile.cc
	vvp/opcodes.txt
	vvp/vpi_tasks.cc
	vvp/vpi_vthr_vector.cc
	vvp/vthread.cc
2014-10-21 09:12:02 -07:00
Cary R 0611135758 Some more cppcheck cleanup/updates 2014-06-29 20:39:40 -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
Stephen Williams e2bad56a5c Fix overflow calculating packed offset in certain cases. 2014-04-06 08:40:09 -07:00
Stephen Williams 0accab6ec4 Handle non-overlapping assignments to unpacked arrays. 2014-04-06 08:40:09 -07:00
Stephen Williams fc1f9ac6a5 Handle unpacked arrays as module input ports. 2014-04-06 08:40:09 -07:00
Stephen Williams 6caa41cc93 First pass at support for continuous assign of unpacked net arrays. 2014-04-06 08:40:09 -07:00
Stephen Williams 1d63875e5d Merge branch 'master' into vec4-stack
Conflicts:
	elab_lval.cc
2014-02-10 16:26:22 -08:00
Stephen Williams 0be577cc44 Allow some behavioral assignments to unresolved wires.
If the l-value is an unresolved wire, then elaboration can allow
the assignment as long as it is to bits that are not otherwise
driven. Handle this in some simple cases.
2014-02-02 11:08:43 -08:00
Stephen Williams 0eca210722 Merge branch 'master' into vec4-stack 2014-01-30 17:07:54 -08:00
Larry Doolittle 3e95966d70 More spelling fixes
Mostly comments
Changs "initilzers" in a string visible with debug_elaborate.
Includes a few British->American changes in the root directory only.
2014-01-30 16:43:17 -08:00
Stephen Williams 1fc4093191 Fix possible overflow in calculation of canonical indices. 2014-01-15 14:26:53 -08:00
Stephen Williams 0b4056817a Generalize struct member type 2013-12-07 12:20:28 -08:00
Martin Whitaker 6f8eede371 Handle out-of range and undefined LHS bit/part selects in assignments.
For constant bit/part selects, issue a warning if the select is out
of range or an undefined value. In any case, the RHS value should be
discarded, and the actual assignment should be skipped.
2013-05-21 21:44:31 +01:00
Martin Whitaker 26dc6d68cd Handle out-of range and undefined LHS word indices in assignments.
For constant word indices, issue a warning if the index is out of
range or an undefined value. In any case, the RHS value should be
discarded, and the actual assignment should be skipped.
2013-05-18 19:21:37 +01:00
Cary R b098e31cc7 Fix cppcheck warning and update suppression file 2012-12-18 11:54:26 -08:00
Stephen Williams 6cc1010281 Handle part select of packed struct members.
This fixes the case of part select of struct members
in continuous assignment l-values.
2012-12-18 10:43:07 -08: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 92313654ec Rework the way vectors are represented in NetNet objects. 2012-10-14 17:16:47 -07:00
Stephen Williams 9cca1378bb Handle continuous assign to packed member of packed array of struct.
This still requires that the index expression is constant.
2012-09-03 16:00:10 -07:00
Arun Persaud f5aafc32f9 updated FSF-address 2012-08-29 10:12:10 -07:00
Andrew Stevens 9b3d20239a Extend VPI and build to for SIMetrix cosimulation
Added: basic vpiPort VPI Objects for vpiModulkes
    vpiDirection, vpiPortIndex,   vpiName, vpiSize attributes

   Since ports do not exist as net-like entities (nets either side
   module instance boundaries are in effect connect directly in
   the language front-ends internal representation) the port information
   is effectively just meta-data passed through t-dll  interface and
   output as a additional annotation of module scopes in vvp.

Added: vpiLocalParam attribute for vpiParameter VPI objects

Added: support build for 32-bit target on 64-bit host (--with-m32
   option to configure.in and minor tweaks to Makefiles and systemc-vpi).
2012-06-07 08:00:02 -07:00
Stephen Williams 8154ce2a4a Reword how we enforce program block constraints
Making the scope type NESTED_MODULE was just plain wrong, because
it didn't really encapsulate the meaning of program blocks OR
nested modules. So instead create nested_module() and program_block()
flags and use those to test scope constraints.
2012-05-27 18:26:53 -07:00
Stephen Williams dfe7beec31 Allow modules (and program blocks in particular) to nest.
An important advantage of program blocks is its ability to nest
within a module. This winds up also allowing modules to nest, which
is legal but presumably less used feature.
2012-05-27 18:26:53 -07:00
Stephen Williams 342646264e Merge branch 'pei1' 2012-05-25 16:32:12 -07:00
Stephen Williams 6e8aef8262 Get unpacked arrays working. 2012-05-25 15:58:29 -07:00
Stephen Williams e7a974347e Handle packed array slices at module ports. 2012-05-22 17:31:26 -07:00
Stephen Williams 2013addd22 Fix check for SV continuous assign to variable.
SystemVerilog allows a variable to be used as a variable OR
as an unresolved wire. The detection of this case was checking
the references to the affected value, instead of the l-value
references.
(cherry picked from commit cceeaa30f27260cd444015cb39b04353cb858768)
2012-04-30 17:04:45 -07:00
Stephen Williams 8ea1e49768 Improve net bit select calculations. 2012-04-30 11:48:33 -07:00
Cary R 761a38d0a8 Spelling fix 2012-04-11 09:13:14 -07:00
Stephen Williams dd3a7411cd Parse SystemVerilog ref ports. 2012-02-25 10:19:48 -08:00
Stephen Williams 3e4f8b625f Get packed signals working through to simulation in some situations.
When dynamic indexing of early dimensions is not needed, we can get
pretty far with getting packed arrays to work.
2012-02-10 17:17:59 -08:00
Stephen Williams 5d35ad8a0d Support uwire resolved writes to non-overlapping parts
The individual bits of an unresolved wire may be assigned in
different continuous assignments without generating an error.
2012-02-02 16:18:50 -08:00