Commit Graph

148 Commits

Author SHA1 Message Date
Lars-Peter Clausen 3c4d1bbe4e Fix $left/$right for C-style unpacked arrays
Unpacked array dimensions that are specified with only a single size value
(C-style unpacked arrays) have a $left of 0 and a $right of size - 1. E.g.
`x[10]` is equivalent to `x[0:9]`. This is defined in the LRM (1800-2017)
section 7.4.2 ("Unpacked arrays").

Currently it is implemented the other way around. There are a few contexts
where this distinction matters. For example array to array assignments,
which are supposed to be done left-to-right.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-17 09:23:21 -08:00
Lars-Peter Clausen c853025305 Allow implicit cast between dynamic array and queue for all expressions
Dynamic arrays and queues can be implicitly cast between each other. At the
moment this only works if the right hand side is a signal or assignment
pattern.

But this should be possible for other r-value expression that returns a
queue or dynamic array type. E.g. function calls or class properties.

Since the expr_type() method is defined for all NetExpr objects we can use
that and do not have to cast to NetESignal.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:14:38 +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 711623f682 Remove redundant elab_and_eval_lossless(). 2021-05-16 17:31:59 +01:00
Martin Whitaker a040ddc070 Do not force lossless calculation for index expressions (issue #515)
The standard Verilog expression bit length rules must be used.
2021-05-16 17:19:13 +01:00
Cary R 753bf516d6 Update the symbol search to find class properties 2021-02-16 23:46:02 -08:00
Stephen Williams c335c68973 Fix compilation of enum.name method.
The implementation was mostly there, but elaboration failed
due to some obsolete assumtions.
2020-12-30 13:41:08 -08:00
Cary R 34d7be092e Remove R-value class check until class variables are found correctly 2020-12-28 04:55:59 -08:00
Stephen Williams a286764c1d Add support for string parameters
Parameters can have string type and do the usual string stuff,
and also implement some of the string methods on string parameters
so that they evaluate down to constants.
2020-12-27 21:17:57 -08: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
Cary R 51025149a9 Report operators that cannot be used with null/class vars 2020-12-27 19:05:49 -08:00
Cary R 761dc35e0b A queue or darray can be assign from a queue or darray. 2020-08-05 23:19:32 -07:00
Cary R c003bcc59a Add support for <-> in constant and procedural contexts 2020-07-07 23:29:19 -07:00
Noah Moroze d0fe513c7e Replace assertion in evaluate_index_prefix with useful error message. 2020-02-15 16:32:32 -05:00
Martin Whitaker 68a6fa06a2 Improve old code for detecting missing explicit cast. 2019-10-06 18:03:37 +01:00
Martin Whitaker de54a58991 Fix issue #265 - emit a sensible error message when an explicit cast is needed. 2019-10-06 17:54:44 +01:00
Martin Whitaker 832adc5c74 Improve handling of invalid packed and unpacked dimensions.
As reported on iverilog-devel on 2018-10-12, a dimension size of zero
could case the compiler to go into an infinite loop. Further tests
showed that unsized or queue dimensions entered as packed dimensions
would cause the compiler to crash.
2019-09-14 09:10:52 +01:00
Martin Whitaker c066e2d15c Properly implement casts from strings and dynamic arrays to vectors.
As discussed on iverilog-devel (2018-03-09), the existing implementation
(using Icarus-specific vpi functions) only worked with assignments to
simple variables, and could not be easily modified to work more generally.
So use the new vvp instructions added in the previous two commits.
2019-09-11 22:08:46 +01:00
Martin Whitaker 34bb98676a Fix assertion failure on illegal SV cast.
Bug reported on iverilog-devel on 2018-02027.
2019-09-07 14:35:19 +01:00
Cary R 3fc9ad2db0 Add support for the wild compare operators ==? and !=? 2017-11-17 19:32:50 -08:00
Martin Whitaker 9382d22063 Factor out common code for warning about inconsistent timescales.
Also reword the warning for SystemVerilog, where `timescale is not
the only (or indeed preferred) way of specifying timescales.
2017-11-05 09:39:21 +00:00
Martin Whitaker 7f612270b3 Improved fix for GitHub issue #112.
This does a better job of setting the intermediate expression types
and widths when calculating the canonical index into a packed array.
It still doesn't properly handle out-of-bound indices (br953).
2016-07-10 13:30:58 +01: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 89edf62206 Capitalize Verilog in a few places 2016-04-01 11:02:24 -07:00
Maciej Suminski de775975e8 ivl: Fixed slice base calculation
when range is rising (e.g. logic [0:3] arr) or when it
starts with a non-zero integer (e.g. logic [4:1] arr).
2016-03-07 17:11:53 +01:00
Maciej Suminski b4baace4b1 ivl: Support for part selection in multidimensional packed ports assignment. 2016-03-07 09:54:28 +01:00
Martin Whitaker 0199ad129d Fix expression type for compressed assignment statements.
A compressed assignment statement should give exactly the same
result as the equivalent uncompressed statement. This means
that the type (signed/unsigned) of the LHS affects the type of
the RHS expression (unlike in normal assignments). We need to
take care that bit/part selects and concatenations are correctly
identified as unsigned values, even in the cases where they
reduce to a single whole signal.
2016-02-23 16:53:01 +00: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
Larry Doolittle 2739f83702 Spelling fixes in C and C++ comments 2015-06-04 15:00:29 -07:00
Stephen Williams 77d1671d8f Merge branch 'master' into vec4-stack 2014-12-05 10:44:49 -08:00
Stephen Williams 561564065d deal with mixed nested index directions. 2014-12-05 10:43:39 -08:00
Stephen Williams d5123011b3 Merge branch 'master' into vec4-stack
Conflicts:
	elab_scope.cc
2014-11-01 14:57:05 -07:00
Martin Whitaker 871d447ff7 Reinstate error recovery for range expressions.
If an error is found whilst elaborating a range expression in a signal
declaration, create a dummy range and continue elaboration. This stops
the compiler reporting an error every time that signal is referenced.
2014-10-31 21:42:23 +00: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
Stephen Williams ea4b000be6 Get arrayed property expressions down to the ivl_target API. 2014-09-15 17:37:30 -07:00
Stephen Williams 88e951418b Handle elaboration of class properties referenced within sub-scopes. 2014-09-06 16:26:08 -07:00
Stephen Williams 3b0dfaadba Some support for unpacked arrays in class properties. 2014-09-02 09:23:54 -07:00
Stephen Williams 0cd6fbaf41 foreach loops around static arrays
Arrays with static dimensions can be handled specially.
This also allows for arbitrary numbers of dimensions.
2014-08-30 10:18:57 -07:00
Martin Whitaker e5f49baaac Fix for GitHub issue #37 - bug in expression width pruning.
If an expression contains a division, remainder, or right shift operation,
set the expression min_width to UINT_MAX to flag that the expression width
cannot be pruned. Using UINT_MAX ensures that the min_width won't change
as we continue to elaborate the expression.
2014-08-25 20:27:22 +01:00
Martin Whitaker 89f1344288 Fix for GitHub issue #33 - Problem with multi-dimensional arrays.
normalize_variable_unpacked() was not correctly calculating the
minimum expression width required to calculate the canonical
index.
2014-08-11 20:23:29 +01:00
Stephen Williams ef79f538d5 When making NetCondit objects, handle output part select.
When a mux (NetCondit) is only writing to a part of the output
vector (and using only a part of the inputs) then blend the mux
output with the previous statement output.
2014-05-25 18:33:26 -07:00
Stephen Williams 76883fa18c NetCondit synthesis accounts for smaller l-values
If both conditions of a NetCondit device assign to the same subset
of l-value bits, then generate a smaller NetMux device that only
switches the affected bits.
2014-05-24 20:08:48 -07:00
Stephen Williams 2e2317b7c7 Generalize the hname_t to handle n-dimensional scope arrays.
... Not that they actually exist yet. But this fixes some symbol
search issues and makes room for this support in the future.
2014-04-06 08:40:09 -07:00
Stephen Williams e2bad56a5c Fix overflow calculating packed offset in certain cases. 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 7ceb18fb37 Merge branch 'master' into vec4-stack
Conflicts:
	netmisc.cc
	tgt-vvp/eval_expr.c
	vvp/vthread.cc
2014-03-01 09:02:14 -08:00
Stephen Williams d2ff77d56c More standard handling of unsized numbers as system task arguments. 2014-03-01 08:38:23 -08:00
Martin Whitaker 5dcd2e8957 Added width cap for unsized expressions.
Unsized expressions can expand to extremely large widths. Usually this
is actually a mistake in the source code, but it can lead to the compiler
temporarily using extremely large amounts of memory, or in the worst
case, crashing. This adds a cap on the width of unsized expressions (by
default 65536 bits, but overridable by the user), and causes a warning
message to be output when the cap is reached.
2014-02-27 19:20:20 +00:00
Stephen Williams fdc9e8590d Merge branch 'master' into vec4-stack 2014-01-30 15:59:51 -08:00
Larry Doolittle be17bfc0e9 Spelling fixes
Mostly comments.
One user-visible string ("Evalutated to ") changed in the debug_eval_tree case.
2014-01-30 15:34:20 -08:00