Skip to content

Bitwise "not" operator does not have intended effect on ispresent #304

@nachumg

Description

@nachumg

Given this code:

  regfile a #(longint unsigned NUM_REGS = 1, bit reg_present = 1){
    regfile b {
      reg some_reg { field {} nested_field;} some_reg[NUM_REGS];
      reg other_reg { field {} nested_field; ispresent = ~reg_present;} other_reg;
    } b;
  };

When the type is instantiated with default params the value of

ispresent = ~reg_present
is (2^64 - 1) which is not false as clearly intended by the author.

The fix is to instead use

ispresent = !reg_present

My question: is this a feature or a bug? The standard is not clear on whether bit-type param fields are supposed to be full-width (64-bits) or minimum-width required to hold the default value (1-bit).

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions