Commit Graph

17 Commits

Author SHA1 Message Date
Lars-Peter Clausen 763907b0e5 Add a typedef for `std::vector<netrange_t>`
`std::vector<netrange_t>` is used for signal array dimensions. As such it is
used in quite a few places.

Add a typedef that can be used as a shorthand to refer to it. This helps to
keep lines where this is used from growing to overly long.

The new type is called `netranges_t`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-09-09 05:50:40 -07:00
Lars-Peter Clausen 7f3621d47d Add initial support for struct assignment pattern
Structs can be initialized by an assignment pattern. E.g.

```
struct packed {
  int x;
  shortint y;
} S = '{ 1, 2};
```

is the same as

```
struct packed {
  int x;
  shortint y;
} S;
s.x = 1;
s.y = 2;
```

Add initial support for unnamed struct assignment patterns. Named struct
assignment patterns like

```
struct packed {
  int x;
  shortint y;
} S = '{x: 1, y: 2};
```

are still unsupported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-02-04 14:32:51 -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 662e82c013 Handle signedness of struct members
struct members are currently always treated as unsigned. This leads to
incorrect behavior in contexts where the sign makes a difference. E.g.

```
struct packed {
  int x;
} s;

s.x = -1;
if (s.x > 0) $display("FAILED");
```

Query the signedness of the struct member form the type of the member.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-27 10:53:19 +01:00
Lars-Peter Clausen 09ac7c207e Add support for signed packed structs/unions
packed structs and packed unions as a whole can either be signed or
unsigned. This information is used when it is used as a primary in an
expression, i.e. without accessing any of the members.

Add support for parsing and elaborating signed structs.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-16 16:16:24 +01:00
Cary R d6b6b76015 Update header files to use a more standard name to prevent rereading
This is from github report #16. There are likely a few more issues
that need to be addressed though this takes care of the major ones.
2014-07-23 13:42:56 -07:00
Stephen Williams 0d6c15e45a Handle packed unions properly during elaboration.
This also gets r-value use of packed unions correct.
2013-12-07 12:20:28 -08:00
Stephen Williams 0b4056817a Generalize struct member type 2013-12-07 12:20:28 -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 4e76912331 ivl_target access to type information. 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
Arun Persaud f5aafc32f9 updated FSF-address 2012-08-29 10:12:10 -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
Cary R 42239a8498 Add code to test the width of individual structure elements.
This patch adds code to correctly set the type and width of individual
structure elements. Note the sign information is not currently available.
2012-04-02 19:53:47 -07:00
Stephen Williams 3a2866b57c Handle members of packed struct as implicit part selects.
Packed struct members are synonymous with part selects, but in a
much more convenient form, so get them to work that way.
2012-02-02 16:18:49 -08:00
Stephen Williams d362c8dba0 Parse support for struct variables. 2012-02-02 16:18:49 -08:00