Skip to content

Commit f95f995

Browse files
committed
Handle assignment to static class properties in class methods
Assigning a value to a static class property in a class task or function will currently not write to the static signal, but instead to an otherwise invisible per instance property. E.g. the example below will print 0 when the task `t` is called. ``` class C; static int i; task t; i = 10; $display(i); end endclass ``` Since static class properties are implemented as normal signals just fallback to the default signal handling when an assignment to a static class property is detected. Signed-off-by: Lars-Peter Clausen <[email protected]>
1 parent f3c4967 commit f95f995

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

elab_lval.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,13 @@ NetAssign_* PEIdent::elaborate_lval_method_class_member_(Design*des,
393393
if (pidx < 0)
394394
return 0;
395395

396+
property_qualifier_t qual = class_type->get_prop_qual(pidx);
397+
398+
// Static properties are handled as normal signals. Regular symbol
399+
// search will find it.
400+
if (qual.test_static())
401+
return 0;
402+
396403
NetScope*scope_method = find_method_containing_scope(*this, scope);
397404
ivl_assert(*this, scope_method);
398405

@@ -428,7 +435,6 @@ NetAssign_* PEIdent::elaborate_lval_method_class_member_(Design*des,
428435
// Detect assignment to constant properties. Note that the
429436
// initializer constructor MAY assign to constant properties,
430437
// as this is how the property gets its value.
431-
property_qualifier_t qual = class_type->get_prop_qual(pidx);
432438
if (qual.test_const()) {
433439
if (class_type->get_prop_initialized(pidx)) {
434440
cerr << get_fileline() << ": error: "

0 commit comments

Comments
 (0)