Commit Graph

734 Commits

Author SHA1 Message Date
Lars-Peter Clausen 0e62ff153d Add support for void cast function call
SystemVerilog has explicit support for calling a function
as a statement. This is allowed when the function call is encapsulated in
`void'(...)`. E.g. `void'(f(1, 2, 3));`

We already support calling function calls as statements without the void
cast and emit a warning when doing so.

Adding support for void casts only requires to update the parser to handle
the void cast and then do not emit the warning if a function is called as
a statement as part of a void cast.

Void casting a task or void function call is not allowed and will generate
an elaboration error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-17 11:19:30 -08:00
Lars-Peter Clausen e0ec2ed386 Do not allow to create objects of virtual classes
It is not allowed to create objects of virtual classes. Currently the
virtual keyword is accepted by the parser, but otherwise ignored.

Keep track of whether a class is virtual and generate an error when the
class new operator is used for a virtual type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-13 21:27:53 -08:00
Lars-Peter Clausen 4e69fe1355 Remove ivl_variable_type_t from PWire
The ivl_variable_type_t in PWire is now only used for passing the base type
for vector types to the elaboration stage. But we can query the base the
from the vector_type_t itself. If the there is no data_type_t set for the
PWire the base type will default to IVL_VT_LOGIC.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 17:08:24 -08:00
Stephen Williams 2bb1489f92
Merge pull request #808 from steveicarus/steveicarus/for-loop-step-opt
Allow for for_step of for loops to be optional
2022-12-11 17:07:31 -08:00
Stephen Williams 4ead552203
Merge pull request #805 from larsclausen/sv-type-params
Support type parameters
2022-12-11 16:45:39 -08:00
Stephen Williams 5b9ceee062 Make the for_step of for loops optional
In IEEE Std 1800-2017 A.6.8: the for_step part of the for loop
is optional. If missing, it is assumed that the programmer known
what they are doing.
2022-12-11 16:39:53 -08:00
Stephen Williams bb779112c7
Merge pull request #807 from steveicarus/steveicarus/issue801-empty-for-init
Handle empty for-loop init statement
2022-12-11 16:07:24 -08:00
Stephen Williams 78f37f7156 Handle for loops with empty initialization statement
For loops may have empty initialization statements. In that case some things
can't be done, such as loop unrolling or synthesis, but otherwise it is a
valid thing to do. So generate the correct code in this case.
2022-12-11 15:46:16 -08:00
Lars-Peter Clausen e141aef828 Allow to omit dimensions in foreach loop
SystemVerilog allows to skip dimensions in a foreach loop by not specifying
an identifier name for the dimensions. E.g. the following will iterate over
the first and last dimensions, but skip the middle dimension.

```
int x[1][2][3];
foreach(x[a,,b]) ...
```

Add support for this to the parser as well as elaboration.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 13:56:48 -08:00
Lars-Peter Clausen 5ef847ea87 Support type parameters
SystemVerilog supports type parameters. These are similar to value
parameters, but they allow to pass a type to a module or similar when
instantiating it.

E.g.

```
module A #(parameter type T = int);
endmodule

module B;
  A #(.T(real)) i_a;
endmodule
```

Add support for handling type parameters.

For the vlog95 and vhdl backends type parameters, similar to typedefs, get
replaced with their actual value. For modules with non-local type
parameters for each module instance a unique module or architecture is
generated with the actual type.

Querying type parameters through VPI is not yet supported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 13:50:14 -08:00
Lars-Peter Clausen cdc9629ce7 Add support for forward type declarations
SystemVerilog supports forward type declarations. This allows to declare a
type identifier and use it, e.g. in a signal declaration, before declaring
what the actual type is. The type still needs to be fully defined
eventually in the same scope as its forward type declaration. E.g.

```
typedef T;
T x;
typedef int T;
```

The forward type definition can also contain the kind of the type it is
going to be. E.g struct, union, class, etc. The LRM calls this the basic
type. If the actual type is not of the basic type specified in the forward
type declaration this is an error. E.g.

```
typedef struct T;
typedef int T; // Error, int is not a struct
```

It is legal to have more than one forward type declaration for the same
type name, as long as the basic type is the compatible. It is even legal to
have a forward type declaration after the actual type has already been
declared. E.g.

```
typedef T;
typedef int T;
typedef T;
```

Implement support for forward type definitions as part of the new
typedef_t. The basic type will be attached to the typedef_t.

The compatibility of the basic type for multiple forward type declarations
will be checked in the parser. The compatibility of the basic type to the
actual type will be checked during elaboration, once the actual type is
known.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 10:19:59 -08:00
Lars-Peter Clausen 2e0d6d5af1 Allow to attach additional information to typedefs
Currently typedefs are just a pointer to a data_type_t.

Currently typedefs are implemented by setting the name field of a
data_type_t when a typedef of the type is declared. This works mostly, but
there are some corner cases that can't be supported.

E.g. a typedef of a typedef does not work as it overwrites the name field
of the same data_type_t multiple times.

Forward typedefs can also not be supported since forward typedefs allow to
reference a type before it has been declared.

There are also some problems with type identifier references from a
higher-level scope if there is a type identifier in the current scope with
the same name, but it is declared after the type identifier has been
referenced. E.g. in the following x should be a vector fo width 8, but it
will be a vector of width 4, because while the right type is used it is
elaborated in the wrong scope.

```
localparam A = 8;
typedef logic [A-1:0] T;
module M;
  localparam A = 4;
  T x;
  typedef int T;
endmodule
```

Furthermore typedefs used for the type of ports are elaborated in the wrong
scope.

To handle these corner case issues introduce a data_type_t for typedefs.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 10:18:22 -08:00
Lars-Peter Clausen 410c8207ef Support compressed assignment statements for genvar loops
SystemVerilog supports using compressed assignment operators for the genvar
for loop variable update.

Add support for this in a similar way as increment/decrement operators by
transforming the statement to its uncompressed equivalent. E.g. `x += y`
gets transformed to `x = x + y`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-04 14:37:21 -08:00
Stephen Williams c2dbf4e483
Merge pull request #785 from larsclausen/type-ref
Improve handling of type identifier references
2022-10-16 20:52:52 -07:00
Stephen Williams 5a98e50db7
Merge pull request #783 from lparkes/master
Add #include <cstdarg> to all source files that use va_list
2022-10-16 20:51:38 -07:00
Lars-Peter Clausen b7fce4a66e Improve handling of type identifier references
Currently when referencing a typedef this gets replaced with the
`data_type_t` that the typedef points to. This works for most cases, but
there are some corner cases where it breaks down.

E.g. it is possible to have a scoped type identifier which references a
type defined in a package. For such type identifiers, only the data_type_t
itself is remembered, but not the package scope. This will cause the type
identifier to be elaborated in the wrong scope.

Furthermore type identifiers of vector types used for module or task port
might not be elaborated in the correct scope.

Introduce a new `typeref_t` which has `data_type_t` as a base type and can
be used as the data type for a signal. A new instance of a `typeref_t` is
created when referencing a type identifier. The `typeref_t` remembers both
the data type and the scope of the type identifier.

When elaborating the `typeref_t` the elaboration is passed through to the
referenced `data_type_t`. But special care is taken to lookup the right
scope first.

With the new approach also typedefs of typedefs are supported. This
previously did not work because chained typedefs all reference the same
`data_type_t`, but each typedef sets the `name` field of the `data_type_t`.
So the second typedef overwrites the first typedef and a lookup of the
scope of the first typedef by name will fail as it will return the scope of
the second typedef.

This refactoring also allows to define clear ownership of a data_type_t
instance. This e.g. means that an array type owns its base type and the
base type can be freed when the array type itself is freed. The same is
true for signals and class properties, they now own their data type and the
data type can be freed when the signal or property is freed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-15 12:32:22 +02:00
Lars-Peter Clausen 20d82bbdcb Simplify class end label parser rule
The current class end label parser rule gets the data type from the
TYPE_IDENTIFIER, casts that to a class_type_t and gets the name from that.
This code was written when the TYPE_IDENTIFIER only provided the data type.

But these days it provides both the data type and the name. Simplify the
code to get the name directly from the TYPE_IDENTIIFER.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-15 12:32:02 +02:00
Lloyd Parkes 6c975eb89c Add #include <cstdarg> to all source files that use va_list. 2022-10-12 15:31:35 +13:00
Lars-Peter Clausen 8d7e7b6283 Improve parsing of package scoped identifiers
In order to avoid conflicts in the grammar the lexer distinguishes between
identifiers and type identifiers. To correctly classify an identifier the
lexer needs to know in which scope a token is parsed. E.g. when the parser
encounters a package scope operator it calls `lex_in_package_scope()` to tell
the lexer which scope the following identifier should be classified in.

Currently the `lex_in_package_scope()` is only used when a type identifiers
is parsed, but on for normal identifiers. As a result it is not possible to
reference variables or function from a package scope that have the same
name as a type identifier in the current scope. E.g.

```
package P;
  int T;
endpackage

module test;
  typedef int T;
  initial $display(P::T);
endmodule
```

Another problem is that in expressions both type identifiers and signal
identifiers can be referenced. As a result there are two rules in an
expression that can be reduced

  * <PACKAGE_TYPE> :: <TYPE_IDENTIFIER>
  * <PACKAGE_TYPE> :: <IDENTIFIER>

The way the rules are formulated at the moment the parser has to use token
lookahead to decide which rule to follow before it can reduce the package
scope operator. As a result the lexer detects the token before
lex_in_package_scope() is called and the identifier does not get evaluated
in the package scope, but in the current scope. Which can cause the
identifier to be misclassified. E.g.

```
package P;
  typedef int T;
  shortint X;
endpackage

module test;
   typedef byte X;
   initial $display($bits(P::T));
   initial $display($bits(P::X));
endmodule
```

Here `P::T` gets classified as a signal identifier and `P::X` gets
classified as a type identifier.

To solve this introduce a common rule for the package scope operator. Using
the same rule everywhere allows the parser to reduce it unconditionally
without using lookahead.

Note that there are additional problems with resolving the type of a scoped
type identifiers in expressions, but this is a prerequisite to solve that.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-04 10:42:56 +02:00
Stephen Williams 4f1dbee4ee
Merge pull request #775 from larsclausen/ps-function-call
Allow package scoped functions to be called without arguments
2022-10-03 19:43:26 -07:00
Lars-Peter Clausen fb8681a376 Allow package scoped functions to be called without arguments
The parser currently only allows package scoped functions to be called if
there is at least one argument. But package scoped functions are the same
as normal functions and it is allowed to call them with no arguments. It is
even possible to pass no value for a positional argument, if the positional
argument has a default value.

Update the parser to handle this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-20 20:41:23 +02:00
Lars-Peter Clausen f9aadc13b5 Fix memory leaks when parsing function calls
For function calls when calling the PECallFunction() constructor a copy is
made of the argument expression list. This means the original list should
be deleted within the rule.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-20 20:08:24 +02:00
Lars-Peter Clausen 2385b32cb3 Correctly handle unpacked array typedefs for ports
If the type of a port is an array type it currently always gets evaluated
in the scope where the port is declared.

But if the type is a typedef it might be declared in a different scope and
must be evaluated in that scope. E.g. the following will declare an array
port with 10 entries and an element type of a 5 bit vector, while it should
declare one with 4 entries and an element type of a 2 bit vector.

```
localparam A = 2;
localparam B = 4;
typedef [A-1:0] T[B];

module test (
  T x
);

localparam A = 5;
localparam B = 10;

endmodule
```

This is in part due to array types being given special handling. This was
necessary before because each base type required slightly different
handling and so the base type had to be extracted from the array type.

This has now been consolidated and all data types are treated the same.
The only exception is the vector type which still needs special handling to
support separate definition of port direction and type.

As a result it is possible to remove the special handling of the array
type. This solves the problem of evaluating the type in the wrong scope.

Some special handling needs to be retained though to be able to
differentiate between array dimensions that are part of a type and array
dimensions that are part of port declaration. This is again necessary to
correctly support separate definition of port direction and type. E.g. in
the example below port `x` and `y` get treated slightly differently, even
though the resulting signals will be identical.

```
typedef logic [7:0] T[1:0];
...
input T x;
input [7:0] y[1:0];
```

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-20 12:25:14 +02:00
Lars-Peter Clausen 8f78590bd2 Remove most references to ivl_variable_type_t from the parser
The parser used to have behavior that was dependent on the
`ivl_variable_type_t` of a signal. It also used the `ivl_variable_type_t`
of a signal to decide whether a signal can be re-declared as part of a
non-ANSI port declaration.

Neither of these is done anymore and most of the reference to
`ivl_variable_type_t` can be removed from the parser. The only thing it is
still needed for is to decide whether a vector type is 4-state or 2-state.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-15 09:36:19 +02:00
Lars-Peter Clausen b307da0831 pform_make_task_ports(): Reuse `pform_set_net_range()`
`pform_make_task_ports()` has code very similar to `pform_set_net_range()`.
Use that helper function instead of duplicating the code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-15 09:36:19 +02:00
Stephen Williams b1bafe5e02
Merge pull request #766 from larsclausen/remove-unused
Remove unused functions/methods
2022-09-14 09:27:00 -07:00
Stephen Williams fa0217af87
Merge pull request #764 from larsclausen/module-port-list-default
Support default port values in port declarations lists
2022-09-14 09:25:33 -07:00
Lars-Peter Clausen f1e50e927b Remove unused `make_range_from_width()`
The last user of the `make_range_from_width()` was removed in commit
f6042033d0 ("Correctly handle separate port type declaration for
`integer` and `time`").

Remove the function itself as well.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-14 13:50:31 +02:00
Lars-Peter Clausen a19a07254b Support default port values in port declarations lists
Both Verilog (2005) and SystemVerilog support default port values for
variable output ports. SystemVerilog also supports default port values for
input ports. For port declaration lists it is possible to specify the
default value for port identifier.

E.g.

```
module M (
  input integer x, y = 1,
  output integer z, w = 2
) ...
```

Currently the parser only supports specifying the default value for the
first identifier in the list. Extend the parser to also allow to specify
the default value for identifiers in the list.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-13 14:14:41 +02:00
Lars-Peter Clausen a9bd522fd3 parser: Add a helper rule for optional initializers
There are a few places where it is possible to provide an optional
initializer in the form of `[ = <expression> ]`.

There are currently multiple rules that implement this behavior as well as
few places with duplicated rules, one with and one without the initializer.

Introduce a common helper rule for optional initializers. This allows to
remove some duplicated code from the parser.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-13 14:14:41 +02:00
Lars-Peter Clausen dd4ae93942 Fix port direction for output port declaration lists with default value
For output port lists with a default value for the first port declaration
all subsequent port declarations are declared as inout ports. This is due
to a small typo when setting the `port_declaration_context` port direction.

Fix this to make sure all ports in the port declaration list are declared
as output ports.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-13 13:41:46 +02:00
Lars-Peter Clausen a73ee3e3e7 Add support for SystemVerilog sign cast
SystemVerilog supports sign cast where it is possible to change the
signedness of an expression. Syntactical it is similar to width or type
casting, except that the keywords 'signed' or 'unsigned' are used in front
of the cast operator. E.g.

```
  logic [3:0] a = 4'b1000;
  logic [7:0] b = signed'(a); // b is 8'b11111000;
  logic signed [3:0] c = 4'b1000;
  logic signed [7:0] d = unsigned'(c); // d is 8'b00001000;
```

As noted by the LRM section 6.24.1 ("Cast operator") applying a sign cast
to an expression is equivalent to calling the $signed() and $unsigned()
system functions on the expression.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-11 19:06:22 +02:00
Lars-Peter Clausen d753e6a5d0 Add SystemVerilog `var` keyword support
SystemVerilog adds the `var` keyword that can be used to declare a signal
as a variable.

In contexts where a signal is always a variable it is purely optional and
it makes no difference whether it is specified or not. This is in
  * for loop variable declarations
  * task and function port declarations

For variable declarations as block items when `var` is used it is possible
to omit the explicit data type and use a implicit data type instead. E.g.
all of the following are valid.

```
var x;
var signed y;
var [1:0] z;
```

For module input and output ports the `var` keyword can be used in place of
the net type. It can be combined with either an implicit or explicit data
type.

E.g.
```
input var x
output var [1:0] y
```

inout ports can not be variables and will be reported as an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-10 21:39:10 +02:00
Lars-Peter Clausen 134e7d6f08 Refactor variable lifetime parser rules
Refactor the variable lifetime parser rules so that instead of having too
rules, one with lifetime and one without, there is a single rule where the
lifetime is an optional element.

This helps to avoid a combinatorial explosion of parser rules once we
add `var` support.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-10 21:39:10 +02:00
Lars-Peter Clausen 8b0346d7b5 Recover from parser errors in all variable declarations
Currently the parser can recover from `integer` or `time` variable
declarations, but not for variables of other types. Refector the parser
rules so that it can recover for all variable types as well as events.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-10 21:39:10 +02: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
Lars-Peter Clausen dddc41891e lgate: Inherit from LineInfo
The lgate struct has its own fields for tracking file and line number,
while everything else that has this information attached inherits from the
LineInfo class.

Make lgate also inherit from LineInfo for consistency.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-24 17:00:46 +02:00
Lars-Peter Clausen 254e9dc094 pform_set_data_type(): Avoid signal look-up by name
The `pform_set_data_type()` function is used to set the data type as well
as attributes on a list of signals. Currently the signals are passed as a
list of signal names and then the function looks up the actual signals from
the names.

Refactor the code to directly pass a list of signals. This will allow to
skip the look-up by name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-18 12:07:16 +02:00
Lars-Peter Clausen 52da910313 Move pform_set_reg_idx() into pform_makewire()
`pform_set_reg_idx()` is always called right after `pform_makewire()`. Move
it into the function. This avoids the extra lookup that
`pform_set_reg_idx()` does to get the PWire from the name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:22:47 +02:00
Lars-Peter Clausen 7aee124cfe pform_makewire(): Remove unused parameters
There are a few parameters for `pform_makewire()` and related functions
that always get passed the same value.

 * port_type is always NetNet::NOT_A_PORT
 * attr is always 0

Remove these parameters.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:22:31 +02:00
Stephen Williams 7c5694e516
Merge pull request #673 from larsclausen/package-no-implicit-var
Require explicit data type for package variable declarations
2022-04-10 15:06:26 -07:00
Stephen Williams 3da5b4cf65
Merge pull request #664 from larsclausen/integer-port
Correctly handle separate port type declaration for integer types
2022-04-10 15:05:48 -07:00
Lars-Peter Clausen 8f6a9c5d3c Require explicit data type for package variable declarations
Variable declarations in packages need an explicit data type. Omitting the
data type or using just packed dimensions is not valid syntax. E.g. the
following should not work.

```
package P;
  x;
  [1:0] y;
endpackage
```

The current implementation does accept this tough. To fix this update the
parser to only allow explicit data types for package variable declarations.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-09 09:15:19 +02:00
Lars-Peter Clausen f6042033d0 Correctly handle separate port type declaration for `integer` and `time`
When using non-ANSI style port declarations it is possible to declare the
port direction and the data type for the port in separate statements. E.g.

```
input x;
reg x;
```

When using packed array dimensions they must match for both declarations.
E.g.

```
input [3:0] x;
reg [3:0] x;
```

But this only applies for vector types, i.e. the packed dimension is
explicitly declared. It does not apply to the `integer` and `time` types,
which have an implicit packed dimension.

The current implementation requires that even for `integer` and `time`
types the implicit dimension needs to be explicitly declared in the port
direction. E.g. the following will result in a elaboration error
complaining about a packed dimension mismatch.

```
module test;
  output x;
  integer x;
endmodule
```

Currently the parser creates a vector_type_t for `time` and `integer`. This
means that e.g. `time` and `reg [63:0]` are indistinguishable during
elaboration, even though they require different behavior.

To fix let the atom2_type_t handle `integer` and `time`. Since it no longer
exclusively handles 2-state types, rename it to atom_type_t.

This also fixes a problem with the vlog95 target unit tests. The vlog95
target translates

```
module test(output integer x);
endmodule
```

to

```
module test(x);
  output x;
  integer x;
endmodule
```

which then fails when being elaborated again. There were some regression
tests that were failing because of this that will now pass.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:40:06 +02:00
Lars-Peter Clausen 51eae02e78 Support class method calls without parenthesis
It is possible to call a class method without parenthesis if no arguments
are specified.

At the moment this works when calling a class method by name. But when
using the implicit class handle `this` or `super` it does not work.

Add support for this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:13:58 +02:00
Lars-Peter Clausen da5b9a4e5f Support class constructor without parenthesis
Class constructors can be declared without parenthesis after the `new` when
no arguments are required. Just like for normal function.

In a similar way the base class constructor can also be invoked without
parenthesis after the `new`.

```
class C extends D;
  function new;
    super.new;
  endfunction
endclass
```

Add support for this by making the parenthesis optional in the parser.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:13:58 +02:00
Lars-Peter Clausen e3bc99dbf3 Don't allow non-ANSI ports for class constructors
Class constructors don't allow for non-ANSI ports. E.g. the following is
not valid.

```
class C;
  function new();
    input int i;
  endfunction
endclass
```

The parser will currently accept this, but otherwise ignore the non-ANSI
port. Modify the parser rules so that this is a syntax error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:13:58 +02:00
Lars-Peter Clausen 967e3455fe Add parser helper rule for class identifiers
There are a few places in the grammar that follow the pattern of
`implicit_class_handle '.' hierarchy_identifier` and then splice the two
identifier paths into a single one. Factor this into a common helper rule
to avoid duplicated code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:13:58 +02:00
Lars-Peter Clausen 9810ce6e60 Add parser helper rules for optional argument list
There are a few places in the grammar where it is possible to specify a
argument list in parenthesis or nothing. E.g. a task invocation.

```
task t(int a = 10);
endtask

initial begin
  // All 3 are valid syntax
  t(1);
  t();
  t;
end
```

Factor this out into a common rule to be able to remove some duplicated
code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:12:24 +02:00
Lars-Peter Clausen ad9f5a3aa6 Add parser helper rule for optional task port list
There are a few places in the grammar where it is possible to specify a
task/function port list in parenthesis or nothing. E.g. task and function
prototypes. Factor this out into a common rule to be able to remove some
duplicated code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:11:37 +02:00