Sigasi has several checks on Verilog assignment patterns.
Default member must be last
Concrete assignments must precede more general assignments; otherwise, some assignments may be ignored (rule 28). In particular:
- for arrays,
defaultmust be at the end of the list - for structures,
defaultmust be at the end, but type-default must be after the particular member assignments
module badcode;
int a[3:0] = '{0: 5, default: 0, 3: 1};
typedef struct {
int x;
int y;
real radius;
} circle_t;
circle_t b = '{default: 0, x:1};
circle_t c = '{default: 0, real: 0.0};
endmodule
module goodcode;
int a[3:0] = '{0: 5, 3: 1, default: 0};
typedef struct {
int x;
int y;
real radius;
} circle_t;
circle_t b = '{x:1, default: 0};
circle_t c = '{real: 0.0, default: 0};
endmoduleOnly one default member expression is allowed
Sigasi flags an error when expressions have multiple default assignments (rule 29). In particular:
- arrays cannot have multiple default assignments
- structures cannot have multiple default assignments or multiple type-default assignments
module badcode;
int a[3:0] = '{default: 1, 0: 2, default: 3}; // multiple default assignments
typedef struct {
int x;
int y;
real radius;
} circle_t;
circle_t b = '{default: 0, radius: 1.0, default: 0}; // multiple default assignments
circle_t c = '{int: 0, radius: 1.0, int: 0}; // multiple *type*-default assignments
endmodule
module goodcode;
int a[3:0] = '{0: 2, default: 3};
typedef struct {
int x;
int y;
real radius;
} circle_t;
circle_t b = '{radius: 1.0, default: 0};
circle_t c = '{radius: 1.0, int: 0};
endmoduleOverwritten type key in assignment pattern
Sigasi warns about duplicate type member keys in assignment patterns (rule 30). This is not an error according to the language reference manual, but the last used type key overwrites previously matched members, making the code confusing and hard to maintain.
module uglycode;
struct { int x, y; } a = '{int: 0, int: 1};
int b[10] = '{int: 0, int: 1};
endmodule
module goodcode;
struct { int x, y; } a = '{int: 1};
int b[10] = '{int: 1};
endmoduleDuplicate member key in structure assignment pattern
Sigasi flags an error for duplicate members/index keys in assignment patterns (rule 31). Each member/index key can occur only once.
module badcode;
struct { int x, y; } a = '{x: 0, y: 0, x: 0};
int b[10] = '{5: 1, 5: 2, default: 0};
endmodule
module goodcode;
struct { int x, y; } a = '{x: 0, y: 0};
int b[10] = '{5: 1, default:0};
endmoduleMixed named and ordered notation in assignment pattern
Sigasi flags an error when an assignment contains a mix of ordered and named elements (rule 32).
module badcode;
// Mix of ordered and named associations: not correct
struct { int x, y; } a = '{0, y: 1};
int b[4] = '{0, 1, 2:5, 3:7};
endmodule
module ok_code;
// Place binding: correct but may be harder to read, particularly with many elements
struct { int x, y; } a = '{0, 1};
int b[4] = '{0, 1, 5, 7};
endmodule
module goodcode;
// Name binding: esay to understand and maintain
struct { int x, y; } a = '{x: 0, y: 1};
int b[4] = '{0: 0, 1: 1, 2: 5, 3: 7};
endmoduleRule configuration
These rules can be disabled for your project, or their severity and parameters can be modified in the project linting settings. Alternatively, they can be manually configured using one of the following templates, depending on the type of project you use.
For Modular Projects, add these entries to your project's
.sigasi/settings.jsonsettings file. To scope the settings to a specific folder or file instead of the whole project, place them inside an@overrideblock; to scope them to a specific target, place them inside a@targetsblock.JSONC{ "verilog.rules.28.severity": "{ERROR|WARNING|INFO|IGNORE}", // default member must be last "verilog.rules.30.severity": "{ERROR|WARNING|INFO|IGNORE}", // overwritten type key in assignment pattern "verilog.rules.31.severity": "{ERROR|WARNING|INFO|IGNORE}", // duplicate member key in structure assignment pattern "verilog.rules.32.severity": "{ERROR|WARNING|INFO|IGNORE}" // mixed named and ordered notation in assignment pattern }For Classic Projects, add the VHDL lines to
.settings/com.sigasi.hdt.vhdl.linting.prefsand the Verilog/SystemVerilog lines to.settings/com.sigasi.hdt.verilog.linting.prefs:PREFS28/severity/${path}={error|warning|info|ignore} # default member must be last 30/severity/${path}={error|warning|info|ignore} # overwritten type key in assignment pattern 31/severity/${path}={error|warning|info|ignore} # duplicate member key in structure assignment pattern 32/severity/${path}={error|warning|info|ignore} # mixed named and ordered notation in assignment pattern