Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verible-verilog-obfuscate fails to obfuscate 'sample' keyword in struct #2032

Open
tictacmenthe opened this issue Oct 27, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@tictacmenthe
Copy link

This may be linked to this: #1103
When "sample" is used in a struct element name, it is not obfuscated by the tool in the struct definition, but obfuscated whenever it is used:

struct packed {
    logic  abcd123;
    logic  sample;
    logic  efgh456;
} t_struct;
t_struct test_struct_inst;
logic [1:0] test_sig;
assign test_sig[1] = test_struct_inst.abcd123;
assign test_sig[0] = test_struct_inst.sample;

The result:

struct packed {
    logic  mihKyiG;
    logic  sample;
    logic  I3UJXqM;
} pgyfzHV3;
pgyfzHV3 dSRXAn3s1x0zMCva;      
logic [1:0] LFmB12IJ;
assign LFmB12IJ[1] = dSRXAn3s1x0zMCva.mihKyiG;
assign LFmB12IJ[0] = dSRXAn3s1x0zMCva.Hsm8JW;

If --save_map is used, the resulting dictionary includes the sample keyword and its obfuscated version (here Hsm8JW).

If used as a simple signal (logic sample) outside of a struct, it is just not obfuscated at all.

@IEncinas10
Copy link
Collaborator

As far as I can see it is a parser issue. You can check it by doing
verible-verilog-syntax --printtree filename.sv

This outputs:

Node @0 (tag: kStructUnionMember) {
  Node @1 (tag: kDataTypeImplicitIdDimensions) {
    Node @0 (tag: kDataType) {
      Node @1 (tag: kDataTypePrimitive) {
        Leaf @0 (#"logic" @18-23: "logic")
      }
      Node @3 (tag: kPackedDimensions) {
      }
    }
    Leaf @2 (#SymbolIdentifier @24-31: "abcd123") <-- Your expected identifier
    Node @3 (tag: kUnpackedDimensions) {
    }
  }
  Leaf @3 (#';' @31-32: ";")
}
Node @1 (tag: kStructUnionMember) {
  Node @1 (tag: kDataTypeImplicitIdDimensions) {
    Node @0 (tag: kDataType) {
      Node @1 (tag: kDataTypePrimitive) {
        Leaf @0 (#"logic" @35-40: "logic")
      }
      Node @3 (tag: kPackedDimensions) {
      }
    }
    Leaf @2 (#"sample" @41-47: "sample")          <-- Keyword 
    Node @3 (tag: kUnpackedDimensions) {
    }
  }
  Leaf @3 (#';' @47-48: ";")
}

"..."

Node @2 (tag: kExpression) {
  Node @0 (tag: kFunctionCall) {
    Node @0 (tag: kReference) {
      Node @0 (tag: kLocalRoot) {
        Node @0 (tag: kUnqualifiedId) {
          Leaf @0 (#SymbolIdentifier @195-211: "test_struct_inst")
        }
      }
      Node @1 (tag: kHierarchyExtension) {
        Leaf @0 (#'.' @211-212: ".")
        Node @1 (tag: kUnqualifiedId) {
          Leaf @0 (#SymbolIdentifier @212-218: "sample")  <-- Identifier
        }
      }
    }
  }
}

with version

v0.0-3422-g520ca4b9
Commit  2023-10-16
Built   2023-10-20T20:03:43Z

The obfuscator doesn't obfuscate the first sample because it thinks it is a keyword.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants